@reason-machines/cli-darwin-arm64 0.2.160 → 0.2.163
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.
- package/bin/{Ara.app → Background/Reason.app}/Contents/Info.plist +3 -3
- package/bin/{Ara.app/Contents/MacOS/AraBackgroundIdentity → Background/Reason.app/Contents/MacOS/ReasonBackgroundIdentity} +0 -0
- package/bin/Reason.app/Contents/CodeResources +0 -0
- package/bin/Reason.app/Contents/Info.plist +2 -2
- package/bin/Reason.app/Contents/MacOS/Reason +0 -0
- package/bin/ara +2 -2
- package/bin/libara_device_keychain.dylib +0 -0
- package/bin/runtime/srt/sandbox-runtime.mjs +39 -38
- package/package.json +1 -1
- /package/bin/{Ara.app → Background/Reason.app}/Contents/Resources/AppIcon.icns +0 -0
- /package/bin/{Ara.app → Background/Reason.app}/Contents/_CodeSignature/CodeResources +0 -0
|
@@ -1,68 +1,69 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`)}return Q};C9.decode=function($,J){if(typeof $!=="string")throw TypeError('"input" must be a string.');if(typeof J!=="string")throw TypeError('"alphabet" must be a string.');var X=a7[J];if(!X){X=a7[J]=[];for(var Q=0;Q<J.length;++Q)X[J.charCodeAt(Q)]=Q}$=$.replace(/\s/g,"");var Y=J.length,G=J.charAt(0),W=[0];for(var Q=0;Q<$.length;Q++){var M=X[$.charCodeAt(Q)];if(M===void 0)return;for(var U=0,O=M;U<W.length;++U)O+=W[U]*Y,W[U]=O&255,O>>=8;while(O>0)W.push(O&255),O>>=8}for(var V=0;$[V]===G&&V<$.length-1;++V)W.push(0);if(typeof Buffer<"u")return Buffer.from(W.reverse());return new Uint8Array(W.reverse())};function VM($,J){var X=0,Q=J.length,Y=J.charAt(0),G=[0];for(X=0;X<$.length();++X){for(var W=0,M=$.at(X);W<G.length;++W)M+=G[W]<<8,G[W]=M%Q,M=M/Q|0;while(M>0)G.push(M%Q),M=M/Q|0}var U="";for(X=0;$.at(X)===0&&X<$.length()-1;++X)U+=Y;for(X=G.length-1;X>=0;--X)U+=J[G[X]];return U}});var C$=M$((sz,JG)=>{var t7=K$(),e7=r7(),j=JG.exports=t7.util=t7.util||{};(function(){if(typeof process<"u"&&process.nextTick){if(j.nextTick=process.nextTick,typeof setImmediate==="function")j.setImmediate=setImmediate;else j.setImmediate=j.nextTick;return}if(typeof setImmediate==="function"){j.setImmediate=function(){return setImmediate.apply(void 0,arguments)},j.nextTick=function(M){return setImmediate(M)};return}if(j.setImmediate=function(M){setTimeout(M,0)},typeof window<"u"&&typeof window.postMessage==="function"){let M=function(U){if(U.source===window&&U.data===$){U.stopPropagation();var O=J.slice();J.length=0,O.forEach(function(V){V()})}};var W=M,$="forge.setImmediate",J=[];j.setImmediate=function(U){if(J.push(U),J.length===1)window.postMessage($,"*")},window.addEventListener("message",M,!0)}if(typeof MutationObserver<"u"){var X=Date.now(),Q=!0,Y=document.createElement("div"),J=[];new MutationObserver(function(){var U=J.slice();J.length=0,U.forEach(function(O){O()})}).observe(Y,{attributes:!0});var G=j.setImmediate;j.setImmediate=function(U){if(Date.now()-X>15)X=Date.now(),G(U);else if(J.push(U),J.length===1)Y.setAttribute("a",Q=!Q)}}j.nextTick=j.setImmediate})();j.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;j.globalScope=function(){if(j.isNodejs)return global;return typeof self>"u"?window:self}();j.isArray=Array.isArray||function($){return Object.prototype.toString.call($)==="[object Array]"};j.isArrayBuffer=function($){return typeof ArrayBuffer<"u"&&$ instanceof ArrayBuffer};j.isArrayBufferView=function($){return $&&j.isArrayBuffer($.buffer)&&$.byteLength!==void 0};function VX($){if(!($===8||$===16||$===24||$===32))throw Error("Only 8, 16, 24, or 32 bits supported: "+$)}j.ByteBuffer=w9;function w9($){if(this.data="",this.read=0,typeof $==="string")this.data=$;else if(j.isArrayBuffer($)||j.isArrayBufferView($))if(typeof Buffer<"u"&&$ instanceof Buffer)this.data=$.toString("binary");else{var J=new Uint8Array($);try{this.data=String.fromCharCode.apply(null,J)}catch(Q){for(var X=0;X<J.length;++X)this.putByte(J[X])}}else if($ instanceof w9||typeof $==="object"&&typeof $.data==="string"&&typeof $.read==="number")this.data=$.data,this.read=$.read;this._constructedStringLength=0}j.ByteStringBuffer=w9;var HM=4096;j.ByteStringBuffer.prototype._optimizeConstructedString=function($){if(this._constructedStringLength+=$,this._constructedStringLength>HM)this.data.substr(0,1),this._constructedStringLength=0};j.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};j.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};j.ByteStringBuffer.prototype.putByte=function($){return this.putBytes(String.fromCharCode($))};j.ByteStringBuffer.prototype.fillWithByte=function($,J){$=String.fromCharCode($);var X=this.data;while(J>0){if(J&1)X+=$;if(J>>>=1,J>0)$+=$}return this.data=X,this._optimizeConstructedString(J),this};j.ByteStringBuffer.prototype.putBytes=function($){return this.data+=$,this._optimizeConstructedString($.length),this};j.ByteStringBuffer.prototype.putString=function($){return this.putBytes(j.encodeUtf8($))};j.ByteStringBuffer.prototype.putInt16=function($){return this.putBytes(String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt24=function($){return this.putBytes(String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt32=function($){return this.putBytes(String.fromCharCode($>>24&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt16Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255))};j.ByteStringBuffer.prototype.putInt24Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255)+String.fromCharCode($>>16&255))};j.ByteStringBuffer.prototype.putInt32Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>24&255))};j.ByteStringBuffer.prototype.putInt=function($,J){VX(J);var X="";do J-=8,X+=String.fromCharCode($>>J&255);while(J>0);return this.putBytes(X)};j.ByteStringBuffer.prototype.putSignedInt=function($,J){if($<0)$+=2<<J-1;return this.putInt($,J)};j.ByteStringBuffer.prototype.putBuffer=function($){return this.putBytes($.getBytes())};j.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};j.ByteStringBuffer.prototype.getInt16=function(){var $=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,$};j.ByteStringBuffer.prototype.getInt24=function(){var $=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,$};j.ByteStringBuffer.prototype.getInt32=function(){var $=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,$};j.ByteStringBuffer.prototype.getInt16Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,$};j.ByteStringBuffer.prototype.getInt24Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,$};j.ByteStringBuffer.prototype.getInt32Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,$};j.ByteStringBuffer.prototype.getInt=function($){VX($);var J=0;do J=(J<<8)+this.data.charCodeAt(this.read++),$-=8;while($>0);return J};j.ByteStringBuffer.prototype.getSignedInt=function($){var J=this.getInt($),X=2<<$-2;if(J>=X)J-=X<<1;return J};j.ByteStringBuffer.prototype.getBytes=function($){var J;if($)$=Math.min(this.length(),$),J=this.data.slice(this.read,this.read+$),this.read+=$;else if($===0)J="";else J=this.read===0?this.data:this.data.slice(this.read),this.clear();return J};j.ByteStringBuffer.prototype.bytes=function($){return typeof $>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+$)};j.ByteStringBuffer.prototype.at=function($){return this.data.charCodeAt(this.read+$)};j.ByteStringBuffer.prototype.setAt=function($,J){return this.data=this.data.substr(0,this.read+$)+String.fromCharCode(J)+this.data.substr(this.read+$+1),this};j.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};j.ByteStringBuffer.prototype.copy=function(){var $=j.createBuffer(this.data);return $.read=this.read,$};j.ByteStringBuffer.prototype.compact=function(){if(this.read>0)this.data=this.data.slice(this.read),this.read=0;return this};j.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};j.ByteStringBuffer.prototype.truncate=function($){var J=Math.max(0,this.length()-$);return this.data=this.data.substr(this.read,J),this.read=0,this};j.ByteStringBuffer.prototype.toHex=function(){var $="";for(var J=this.read;J<this.data.length;++J){var X=this.data.charCodeAt(J);if(X<16)$+="0";$+=X.toString(16)}return $};j.ByteStringBuffer.prototype.toString=function(){return j.decodeUtf8(this.bytes())};function qM($,J){J=J||{},this.read=J.readOffset||0,this.growSize=J.growSize||1024;var X=j.isArrayBuffer($),Q=j.isArrayBufferView($);if(X||Q){if(X)this.data=new DataView($);else this.data=new DataView($.buffer,$.byteOffset,$.byteLength);this.write="writeOffset"in J?J.writeOffset:this.data.byteLength;return}if(this.data=new DataView(new ArrayBuffer(0)),this.write=0,$!==null&&$!==void 0)this.putBytes($);if("writeOffset"in J)this.write=J.writeOffset}j.DataBuffer=qM;j.DataBuffer.prototype.length=function(){return this.write-this.read};j.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};j.DataBuffer.prototype.accommodate=function($,J){if(this.length()>=$)return this;J=Math.max(J||this.growSize,$);var X=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),Q=new Uint8Array(this.length()+J);return Q.set(X),this.data=new DataView(Q.buffer),this};j.DataBuffer.prototype.putByte=function($){return this.accommodate(1),this.data.setUint8(this.write++,$),this};j.DataBuffer.prototype.fillWithByte=function($,J){this.accommodate(J);for(var X=0;X<J;++X)this.data.setUint8($);return this};j.DataBuffer.prototype.putBytes=function($,J){if(j.isArrayBufferView($)){var X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),Q=X.byteLength-X.byteOffset;this.accommodate(Q);var Y=new Uint8Array(this.data.buffer,this.write);return Y.set(X),this.write+=Q,this}if(j.isArrayBuffer($)){var X=new Uint8Array($);this.accommodate(X.byteLength);var Y=new Uint8Array(this.data.buffer);return Y.set(X,this.write),this.write+=X.byteLength,this}if($ instanceof j.DataBuffer||typeof $==="object"&&typeof $.read==="number"&&typeof $.write==="number"&&j.isArrayBufferView($.data)){var X=new Uint8Array($.data.byteLength,$.read,$.length());this.accommodate(X.byteLength);var Y=new Uint8Array($.data.byteLength,this.write);return Y.set(X),this.write+=X.byteLength,this}if($ instanceof j.ByteStringBuffer)$=$.data,J="binary";if(J=J||"binary",typeof $==="string"){var G;if(J==="hex")return this.accommodate(Math.ceil($.length/2)),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.hex.decode($,G,this.write),this;if(J==="base64")return this.accommodate(Math.ceil($.length/4)*3),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.base64.decode($,G,this.write),this;if(J==="utf8")$=j.encodeUtf8($),J="binary";if(J==="binary"||J==="raw")return this.accommodate($.length),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.raw.decode(G),this;if(J==="utf16")return this.accommodate($.length*2),G=new Uint16Array(this.data.buffer,this.write),this.write+=j.text.utf16.encode(G),this;throw Error("Invalid encoding: "+J)}throw Error("Invalid parameter: "+$)};j.DataBuffer.prototype.putBuffer=function($){return this.putBytes($),$.clear(),this};j.DataBuffer.prototype.putString=function($){return this.putBytes($,"utf16")};j.DataBuffer.prototype.putInt16=function($){return this.accommodate(2),this.data.setInt16(this.write,$),this.write+=2,this};j.DataBuffer.prototype.putInt24=function($){return this.accommodate(3),this.data.setInt16(this.write,$>>8&65535),this.data.setInt8(this.write,$>>16&255),this.write+=3,this};j.DataBuffer.prototype.putInt32=function($){return this.accommodate(4),this.data.setInt32(this.write,$),this.write+=4,this};j.DataBuffer.prototype.putInt16Le=function($){return this.accommodate(2),this.data.setInt16(this.write,$,!0),this.write+=2,this};j.DataBuffer.prototype.putInt24Le=function($){return this.accommodate(3),this.data.setInt8(this.write,$>>16&255),this.data.setInt16(this.write,$>>8&65535,!0),this.write+=3,this};j.DataBuffer.prototype.putInt32Le=function($){return this.accommodate(4),this.data.setInt32(this.write,$,!0),this.write+=4,this};j.DataBuffer.prototype.putInt=function($,J){VX(J),this.accommodate(J/8);do J-=8,this.data.setInt8(this.write++,$>>J&255);while(J>0);return this};j.DataBuffer.prototype.putSignedInt=function($,J){if(VX(J),this.accommodate(J/8),$<0)$+=2<<J-1;return this.putInt($,J)};j.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};j.DataBuffer.prototype.getInt16=function(){var $=this.data.getInt16(this.read);return this.read+=2,$};j.DataBuffer.prototype.getInt24=function(){var $=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,$};j.DataBuffer.prototype.getInt32=function(){var $=this.data.getInt32(this.read);return this.read+=4,$};j.DataBuffer.prototype.getInt16Le=function(){var $=this.data.getInt16(this.read,!0);return this.read+=2,$};j.DataBuffer.prototype.getInt24Le=function(){var $=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,$};j.DataBuffer.prototype.getInt32Le=function(){var $=this.data.getInt32(this.read,!0);return this.read+=4,$};j.DataBuffer.prototype.getInt=function($){VX($);var J=0;do J=(J<<8)+this.data.getInt8(this.read++),$-=8;while($>0);return J};j.DataBuffer.prototype.getSignedInt=function($){var J=this.getInt($),X=2<<$-2;if(J>=X)J-=X<<1;return J};j.DataBuffer.prototype.getBytes=function($){var J;if($)$=Math.min(this.length(),$),J=this.data.slice(this.read,this.read+$),this.read+=$;else if($===0)J="";else J=this.read===0?this.data:this.data.slice(this.read),this.clear();return J};j.DataBuffer.prototype.bytes=function($){return typeof $>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+$)};j.DataBuffer.prototype.at=function($){return this.data.getUint8(this.read+$)};j.DataBuffer.prototype.setAt=function($,J){return this.data.setUint8($,J),this};j.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};j.DataBuffer.prototype.copy=function(){return new j.DataBuffer(this)};j.DataBuffer.prototype.compact=function(){if(this.read>0){var $=new Uint8Array(this.data.buffer,this.read),J=new Uint8Array($.byteLength);J.set($),this.data=new DataView(J),this.write-=this.read,this.read=0}return this};j.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};j.DataBuffer.prototype.truncate=function($){return this.write=Math.max(0,this.length()-$),this.read=Math.min(this.read,this.write),this};j.DataBuffer.prototype.toHex=function(){var $="";for(var J=this.read;J<this.data.byteLength;++J){var X=this.data.getUint8(J);if(X<16)$+="0";$+=X.toString(16)}return $};j.DataBuffer.prototype.toString=function($){var J=new Uint8Array(this.data,this.read,this.length());if($=$||"utf8",$==="binary"||$==="raw")return j.binary.raw.encode(J);if($==="hex")return j.binary.hex.encode(J);if($==="base64")return j.binary.base64.encode(J);if($==="utf8")return j.text.utf8.decode(J);if($==="utf16")return j.text.utf16.decode(J);throw Error("Invalid encoding: "+$)};j.createBuffer=function($,J){if(J=J||"raw",$!==void 0&&J==="utf8")$=j.encodeUtf8($);return new j.ByteBuffer($)};j.fillString=function($,J){var X="";while(J>0){if(J&1)X+=$;if(J>>>=1,J>0)$+=$}return X};j.xorBytes=function($,J,X){var Q="",Y="",G="",W=0,M=0;for(;X>0;--X,++W){if(Y=$.charCodeAt(W)^J.charCodeAt(W),M>=10)Q+=G,G="",M=0;G+=String.fromCharCode(Y),++M}return Q+=G,Q};j.hexToBytes=function($){var J="",X=0;if($.length&!0)X=1,J+=String.fromCharCode(parseInt($[0],16));for(;X<$.length;X+=2)J+=String.fromCharCode(parseInt($.substr(X,2),16));return J};j.bytesToHex=function($){return j.createBuffer($).toHex()};j.int32ToBytes=function($){return String.fromCharCode($>>24&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255)};var B0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",j0=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],$G="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";j.encode64=function($,J){var X="",Q="",Y,G,W,M=0;while(M<$.length){if(Y=$.charCodeAt(M++),G=$.charCodeAt(M++),W=$.charCodeAt(M++),X+=B0.charAt(Y>>2),X+=B0.charAt((Y&3)<<4|G>>4),isNaN(G))X+="==";else X+=B0.charAt((G&15)<<2|W>>6),X+=isNaN(W)?"=":B0.charAt(W&63);if(J&&X.length>J)Q+=X.substr(0,J)+`\r
|
|
4
|
-
`,X=X.substr(J)}return Q+=X,Q};j.decode64=function($){$=$.replace(/[^A-Za-z0-9\+\/\=]/g,"");var J="",X,Q,Y,G,W=0;while(W<$.length)if(X=
|
|
5
|
-
`,X=X.substr(J)}return Q+=X,Q};j.binary.base64.decode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array(Math.ceil($.length/4)*3);$=$.replace(/[^A-Za-z0-9\+\/\=]/g,""),X=X||0;var Y,G,W,M,U=0,O=X;while(U<$.length)if(Y=j0[$.charCodeAt(U++)-43],G=j0[$.charCodeAt(U++)-43],W=j0[$.charCodeAt(U++)-43],M=j0[$.charCodeAt(U++)-43],Q[O++]=Y<<2|G>>4,W!==64){if(Q[O++]=(G&15)<<4|W>>2,M!==64)Q[O++]=(W&3)<<6|M}return J?O-X:Q.subarray(0,O)};j.binary.base58.encode=function($,J){return j.binary.baseN.encode($,$G,J)};j.binary.base58.decode=function($,J){return j.binary.baseN.decode($,$G,J)};j.text={utf8:{},utf16:{}};j.text.utf8.encode=function($,J,X){$=j.encodeUtf8($);var Q=J;if(!Q)Q=new Uint8Array($.length);X=X||0;var Y=X;for(var G=0;G<$.length;++G)Q[Y++]=$.charCodeAt(G);return J?Y-X:Q};j.text.utf8.decode=function($){return j.decodeUtf8(String.fromCharCode.apply(null,$))};j.text.utf16.encode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array($.length*2);var Y=new Uint16Array(Q.buffer);X=X||0;var G=X,W=X;for(var M=0;M<$.length;++M)Y[W++]=$.charCodeAt(M),G+=2;return J?G-X:Q};j.text.utf16.decode=function($){return String.fromCharCode.apply(null,new Uint16Array($.buffer))};j.deflate=function($,J,X){if(J=j.decode64($.deflate(j.encode64(J)).rval),X){var Q=2,Y=J.charCodeAt(1);if(Y&32)Q=6;J=J.substring(Q,J.length-4)}return J};j.inflate=function($,J,X){var Q=$.inflate(j.encode64(J)).rval;return Q===null?null:j.decode64(Q)};var P9=function($,J,X){if(!$)throw Error("WebStorage not available.");var Q;if(X===null)Q=$.removeItem(J);else X=j.encode64(JSON.stringify(X)),Q=$.setItem(J,X);if(typeof Q<"u"&&Q.rval!==!0){var Y=Error(Q.error.message);throw Y.id=Q.error.id,Y.name=Q.error.name,Y}},_9=function($,J){if(!$)throw Error("WebStorage not available.");var X=$.getItem(J);if($.init)if(X.rval===null){if(X.error){var Q=Error(X.error.message);throw Q.id=X.error.id,Q.name=X.error.name,Q}X=null}else X=X.rval;if(X!==null)X=JSON.parse(j.decode64(X));return X},KM=function($,J,X,Q){var Y=_9($,J);if(Y===null)Y={};Y[X]=Q,P9($,J,Y)},zM=function($,J,X){var Q=_9($,J);if(Q!==null)Q=X in Q?Q[X]:null;return Q},EM=function($,J,X){var Q=_9($,J);if(Q!==null&&X in Q){delete Q[X];var Y=!0;for(var G in Q){Y=!1;break}if(Y)Q=null;P9($,J,Q)}},FM=function($,J){P9($,J,null)},XY=function($,J,X){var Q=null;if(typeof X>"u")X=["web","flash"];var Y,G=!1,W=null;for(var M in X){Y=X[M];try{if(Y==="flash"||Y==="both"){if(J[0]===null)throw Error("Flash local storage not available.");Q=$.apply(this,J),G=Y==="flash"}if(Y==="web"||Y==="both")J[0]=localStorage,Q=$.apply(this,J),G=!0}catch(U){W=U}if(G)break}if(!G)throw W;return Q};j.setItem=function($,J,X,Q,Y){XY(KM,arguments,Y)};j.getItem=function($,J,X,Q){return XY(zM,arguments,Q)};j.removeItem=function($,J,X,Q){XY(EM,arguments,Q)};j.clearItems=function($,J,X){XY(FM,arguments,X)};j.isEmpty=function($){for(var J in $)if($.hasOwnProperty(J))return!1;return!0};j.format=function($){var J=/%./g,X,Q,Y=0,G=[],W=0;while(X=J.exec($)){if(Q=$.substring(W,J.lastIndex-2),Q.length>0)G.push(Q);W=J.lastIndex;var M=X[0][1];switch(M){case"s":case"o":if(Y<arguments.length)G.push(arguments[Y+++1]);else G.push("<?>");break;case"%":G.push("%");break;default:G.push("<%"+M+"?>")}}return G.push($.substring(W)),G.join("")};j.formatNumber=function($,J,X,Q){var Y=$,G=isNaN(J=Math.abs(J))?2:J,W=X===void 0?",":X,M=Q===void 0?".":Q,U=Y<0?"-":"",O=parseInt(Y=Math.abs(+Y||0).toFixed(G),10)+"",V=O.length>3?O.length%3:0;return U+(V?O.substr(0,V)+M:"")+O.substr(V).replace(/(\d{3})(?=\d)/g,"$1"+M)+(G?W+Math.abs(Y-O).toFixed(G).slice(2):"")};j.formatSize=function($){if($>=1073741824)$=j.formatNumber($/1073741824,2,".","")+" GiB";else if($>=1048576)$=j.formatNumber($/1048576,2,".","")+" MiB";else if($>=1024)$=j.formatNumber($/1024,0)+" KiB";else $=j.formatNumber($,0)+" bytes";return $};j.bytesFromIP=function($){if($.indexOf(".")!==-1)return j.bytesFromIPv4($);if($.indexOf(":")!==-1)return j.bytesFromIPv6($);return null};j.bytesFromIPv4=function($){if($=$.split("."),$.length!==4)return null;var J=j.createBuffer();for(var X=0;X<$.length;++X){var Q=parseInt($[X],10);if(isNaN(Q))return null;J.putByte(Q)}return J.getBytes()};j.bytesFromIPv6=function($){var J=0;$=$.split(":").filter(function(W){if(W.length===0)++J;return!0});var X=(8-$.length+J)*2,Q=j.createBuffer();for(var Y=0;Y<8;++Y){if(!$[Y]||$[Y].length===0){Q.fillWithByte(0,X),X=0;continue}var G=j.hexToBytes($[Y]);if(G.length<2)Q.putByte(0);Q.putBytes(G)}return Q.getBytes()};j.bytesToIP=function($){if($.length===4)return j.bytesToIPv4($);if($.length===16)return j.bytesToIPv6($);return null};j.bytesToIPv4=function($){if($.length!==4)return null;var J=[];for(var X=0;X<$.length;++X)J.push($.charCodeAt(X));return J.join(".")};j.bytesToIPv6=function($){if($.length!==16)return null;var J=[],X=[],Q=0;for(var Y=0;Y<$.length;Y+=2){var G=j.bytesToHex($[Y]+$[Y+1]);while(G[0]==="0"&&G!=="0")G=G.substr(1);if(G==="0"){var W=X[X.length-1],M=J.length;if(!W||M!==W.end+1)X.push({start:M,end:M});else if(W.end=M,W.end-W.start>X[Q].end-X[Q].start)Q=X.length-1}J.push(G)}if(X.length>0){var U=X[Q];if(U.end-U.start>0){if(J.splice(U.start,U.end-U.start+1,""),U.start===0)J.unshift("");if(U.end===7)J.push("")}}return J.join(":")};j.estimateCores=function($,J){if(typeof $==="function")J=$,$={};if($=$||{},"cores"in j&&!$.update)return J(null,j.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return j.cores=navigator.hardwareConcurrency,J(null,j.cores);if(typeof Worker>"u")return j.cores=1,J(null,j.cores);if(typeof Blob>"u")return j.cores=2,J(null,j.cores);var X=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(W){var M=Date.now(),U=M+4;while(Date.now()<U);self.postMessage({st:M,et:U})})}.toString(),")()"],{type:"application/javascript"}));Q([],5,16);function Q(W,M,U){if(M===0){var O=Math.floor(W.reduce(function(V,H){return V+H},0)/W.length);return j.cores=Math.max(1,O),URL.revokeObjectURL(X),J(null,j.cores)}Y(U,function(V,H){W.push(G(U,H)),Q(W,M-1,U)})}function Y(W,M){var U=[],O=[];for(var V=0;V<W;++V){var H=new Worker(X);H.addEventListener("message",function(q){if(O.push(q.data),O.length===W){for(var F=0;F<W;++F)U[F].terminate();M(null,O)}}),U.push(H)}for(var V=0;V<W;++V)U[V].postMessage(V)}function G(W,M){var U=[];for(var O=0;O<W;++O){var V=M[O],H=U[O]=[];for(var q=0;q<W;++q){if(O===q)continue;var F=M[q];if(V.st>F.st&&V.st<F.et||F.st>V.st&&F.st<V.et)H.push(q)}}return U.reduce(function(K,R){return Math.max(K,R.length)},0)}}});var YY=M$((rz,QG)=>{var MJ=K$();C$();QG.exports=MJ.cipher=MJ.cipher||{};MJ.cipher.algorithms=MJ.cipher.algorithms||{};MJ.cipher.createCipher=function($,J){var X=$;if(typeof X==="string"){if(X=MJ.cipher.getAlgorithm(X),X)X=X()}if(!X)throw Error("Unsupported algorithm: "+$);return new MJ.cipher.BlockCipher({algorithm:X,key:J,decrypt:!1})};MJ.cipher.createDecipher=function($,J){var X=$;if(typeof X==="string"){if(X=MJ.cipher.getAlgorithm(X),X)X=X()}if(!X)throw Error("Unsupported algorithm: "+$);return new MJ.cipher.BlockCipher({algorithm:X,key:J,decrypt:!0})};MJ.cipher.registerAlgorithm=function($,J){$=$.toUpperCase(),MJ.cipher.algorithms[$]=J};MJ.cipher.getAlgorithm=function($){if($=$.toUpperCase(),$ in MJ.cipher.algorithms)return MJ.cipher.algorithms[$];return null};var x9=MJ.cipher.BlockCipher=function($){this.algorithm=$.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=$.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=$.decrypt,this.algorithm.initialize($)};x9.prototype.start=function($){$=$||{};var J={};for(var X in $)J[X]=$[X];J.decrypt=this._decrypt,this._finish=!1,this._input=MJ.util.createBuffer(),this.output=$.output||MJ.util.createBuffer(),this.mode.start(J)};x9.prototype.update=function($){if($)this._input.putBuffer($);while(!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish);this._input.compact()};x9.prototype.finish=function($){if($&&(this.mode.name==="ECB"||this.mode.name==="CBC"))this.mode.pad=function(X){return $(this.blockSize,X,!1)},this.mode.unpad=function(X){return $(this.blockSize,X,!0)};var J={};if(J.decrypt=this._decrypt,J.overflow=this._input.length()%this.blockSize,!this._decrypt&&this.mode.pad){if(!this.mode.pad(this._input,J))return!1}if(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad){if(!this.mode.unpad(this.output,J))return!1}if(this.mode.afterFinish){if(!this.mode.afterFinish(this.output,J))return!1}return!0}});var k9=M$((tz,XG)=>{var UJ=K$();C$();UJ.cipher=UJ.cipher||{};var N$=XG.exports=UJ.cipher.modes=UJ.cipher.modes||{};N$.ecb=function($){$=$||{},this.name="ECB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)};N$.ecb.prototype.start=function($){};N$.ecb.prototype.encrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q])};N$.ecb.prototype.decrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q])};N$.ecb.prototype.pad=function($,J){var X=$.length()===this.blockSize?this.blockSize:this.blockSize-$.length();return $.fillWithByte(X,X),!0};N$.ecb.prototype.unpad=function($,J){if(J.overflow>0)return!1;var X=$.length(),Q=$.at(X-1);if(Q>this.blockSize<<2)return!1;return $.truncate(Q),!0};N$.cbc=function($){$=$||{},this.name="CBC",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)};N$.cbc.prototype.start=function($){if($.iv===null){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if(!("iv"in $))throw Error("Invalid IV parameter.");else this._iv=GY($.iv,this.blockSize),this._prev=this._iv.slice(0)};N$.cbc.prototype.encrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=this._prev[Q]^$.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q]);this._prev=this._outBlock};N$.cbc.prototype.decrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._prev[Q]^this._outBlock[Q]);this._prev=this._inBlock.slice(0)};N$.cbc.prototype.pad=function($,J){var X=$.length()===this.blockSize?this.blockSize:this.blockSize-$.length();return $.fillWithByte(X,X),!0};N$.cbc.prototype.unpad=function($,J){if(J.overflow>0)return!1;var X=$.length(),Q=$.at(X-1);if(Q>this.blockSize<<2)return!1;return $.truncate(Q),!0};N$.cfb=function($){$=$||{},this.name="CFB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=UJ.util.createBuffer(),this._partialBytes=0};N$.cfb.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=GY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};N$.cfb.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=$.getInt32()^this._outBlock[Y],J.putInt32(this._inBlock[Y]);return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialBlock[Y]=$.getInt32()^this._outBlock[Y],this._partialOutput.putInt32(this._partialBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._partialBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};N$.cfb.prototype.decrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=$.getInt32(),J.putInt32(this._inBlock[Y]^this._outBlock[Y]);return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialBlock[Y]=$.getInt32(),this._partialOutput.putInt32(this._partialBlock[Y]^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._partialBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};N$.ofb=function($){$=$||{},this.name="OFB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=UJ.util.createBuffer(),this._partialBytes=0};N$.ofb.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=GY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};N$.ofb.prototype.encrypt=function($,J,X){var Q=$.length();if($.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)J.putInt32($.getInt32()^this._outBlock[Y]),this._inBlock[Y]=this._outBlock[Y];return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._outBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};N$.ofb.prototype.decrypt=N$.ofb.prototype.encrypt;N$.ctr=function($){$=$||{},this.name="CTR",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=UJ.util.createBuffer(),this._partialBytes=0};N$.ctr.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=GY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};N$.ctr.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize)for(var Y=0;Y<this._ints;++Y)J.putInt32($.getInt32()^this._outBlock[Y]);else{var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0}WY(this._inBlock)};N$.ctr.prototype.decrypt=N$.ctr.prototype.encrypt;N$.gcm=function($){$=$||{},this.name="GCM",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=UJ.util.createBuffer(),this._partialBytes=0,this._R=3774873600};N$.gcm.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");var J=UJ.util.createBuffer($.iv);this._cipherLength=0;var X;if("additionalData"in $)X=UJ.util.createBuffer($.additionalData);else X=UJ.util.createBuffer();if("tagLength"in $)this._tagLength=$.tagLength;else this._tagLength=128;if(this._tag=null,$.decrypt){if(this._tag=UJ.util.createBuffer($.tag).getBytes(),this._tag.length!==this._tagLength/8)throw Error("Authentication tag does not match tag length.")}this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var Q=J.length();if(Q===12)this._j0=[J.getInt32(),J.getInt32(),J.getInt32(),1];else{this._j0=[0,0,0,0];while(J.length()>0)this._j0=this.ghash(this._hashSubkey,this._j0,[J.getInt32(),J.getInt32(),J.getInt32(),J.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(v9(Q*8)))}this._inBlock=this._j0.slice(0),WY(this._inBlock),this._partialBytes=0,X=UJ.util.createBuffer(X),this._aDataLength=v9(X.length()*8);var Y=X.length()%this.blockSize;if(Y)X.fillWithByte(0,this.blockSize-Y);this._s=[0,0,0,0];while(X.length()>0)this._s=this.ghash(this._hashSubkey,this._s,[X.getInt32(),X.getInt32(),X.getInt32(),X.getInt32()])};N$.gcm.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)J.putInt32(this._outBlock[Y]^=$.getInt32());this._cipherLength+=this.blockSize}else{var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G<=0||X){if(X){var W=Q%this.blockSize;this._cipherLength+=W,this._partialOutput.truncate(this.blockSize-W)}else this._cipherLength+=this.blockSize;for(var Y=0;Y<this._ints;++Y)this._outBlock[Y]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return $.read-=this.blockSize,J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),WY(this._inBlock)};N$.gcm.prototype.decrypt=function($,J,X){var Q=$.length();if(Q<this.blockSize&&!(X&&Q>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),WY(this._inBlock),this._hashBlock[0]=$.getInt32(),this._hashBlock[1]=$.getInt32(),this._hashBlock[2]=$.getInt32(),this._hashBlock[3]=$.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var Y=0;Y<this._ints;++Y)J.putInt32(this._outBlock[Y]^this._hashBlock[Y]);if(Q<this.blockSize)this._cipherLength+=Q%this.blockSize;else this._cipherLength+=this.blockSize};N$.gcm.prototype.afterFinish=function($,J){var X=!0;if(J.decrypt&&J.overflow)$.truncate(this.blockSize-J.overflow);this.tag=UJ.util.createBuffer();var Q=this._aDataLength.concat(v9(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,Q);var Y=[];this.cipher.encrypt(this._j0,Y);for(var G=0;G<this._ints;++G)this.tag.putInt32(this._s[G]^Y[G]);if(this.tag.truncate(this.tag.length()%(this._tagLength/8)),J.decrypt&&this.tag.bytes()!==this._tag)X=!1;return X};N$.gcm.prototype.multiply=function($,J){var X=[0,0,0,0],Q=J.slice(0);for(var Y=0;Y<128;++Y){var G=$[Y/32|0]&1<<31-Y%32;if(G)X[0]^=Q[0],X[1]^=Q[1],X[2]^=Q[2],X[3]^=Q[3];this.pow(Q,Q)}return X};N$.gcm.prototype.pow=function($,J){var X=$[3]&1;for(var Q=3;Q>0;--Q)J[Q]=$[Q]>>>1|($[Q-1]&1)<<31;if(J[0]=$[0]>>>1,X)J[0]^=this._R};N$.gcm.prototype.tableMultiply=function($){var J=[0,0,0,0];for(var X=0;X<32;++X){var Q=X/8|0,Y=$[Q]>>>(7-X%8)*4&15,G=this._m[X][Y];J[0]^=G[0],J[1]^=G[1],J[2]^=G[2],J[3]^=G[3]}return J};N$.gcm.prototype.ghash=function($,J,X){return J[0]^=X[0],J[1]^=X[1],J[2]^=X[2],J[3]^=X[3],this.tableMultiply(J)};N$.gcm.prototype.generateHashTable=function($,J){var X=8/J,Q=4*X,Y=16*X,G=Array(Y);for(var W=0;W<Y;++W){var M=[0,0,0,0],U=W/Q|0,O=(Q-1-W%Q)*J;M[U]=1<<J-1<<O,G[W]=this.generateSubHashTable(this.multiply(M,$),J)}return G};N$.gcm.prototype.generateSubHashTable=function($,J){var X=1<<J,Q=X>>>1,Y=Array(X);Y[Q]=$.slice(0);var G=Q>>>1;while(G>0)this.pow(Y[2*G],Y[G]=[]),G>>=1;G=2;while(G<Q){for(var W=1;W<G;++W){var M=Y[G],U=Y[W];Y[G+W]=[M[0]^U[0],M[1]^U[1],M[2]^U[2],M[3]^U[3]]}G*=2}Y[0]=[0,0,0,0];for(G=Q+1;G<X;++G){var O=Y[G^Q];Y[G]=[$[0]^O[0],$[1]^O[1],$[2]^O[2],$[3]^O[3]]}return Y};function GY($,J){if(typeof $==="string")$=UJ.util.createBuffer($);if(UJ.util.isArray($)&&$.length>4){var X=$;$=UJ.util.createBuffer();for(var Q=0;Q<X.length;++Q)$.putByte(X[Q])}if($.length()<J)throw Error("Invalid IV length; got "+$.length()+" bytes and expected "+J+" bytes.");if(!UJ.util.isArray($)){var Y=[],G=J/4;for(var Q=0;Q<G;++Q)Y.push($.getInt32());$=Y}return $}function WY($){$[$.length-1]=$[$.length-1]+1&4294967295}function v9($){return[$/4294967296|0,$&4294967295]}});var T0=M$((ez,MG)=>{var y$=K$();YY();k9();C$();MG.exports=y$.aes=y$.aes||{};y$.aes.startEncrypting=function($,J,X,Q){var Y=MY({key:$,output:X,decrypt:!1,mode:Q});return Y.start(J),Y};y$.aes.createEncryptionCipher=function($,J){return MY({key:$,output:null,decrypt:!1,mode:J})};y$.aes.startDecrypting=function($,J,X,Q){var Y=MY({key:$,output:X,decrypt:!0,mode:Q});return Y.start(J),Y};y$.aes.createDecryptionCipher=function($,J){return MY({key:$,output:null,decrypt:!0,mode:J})};y$.aes.Algorithm=function($,J){if(!b9)GG();var X=this;X.name=$,X.mode=new J({blockSize:16,cipher:{encrypt:function(Q,Y){return y9(X._w,Q,Y,!1)},decrypt:function(Q,Y){return y9(X._w,Q,Y,!0)}}}),X._init=!1};y$.aes.Algorithm.prototype.initialize=function($){if(this._init)return;var J=$.key,X;if(typeof J==="string"&&(J.length===16||J.length===24||J.length===32))J=y$.util.createBuffer(J);else if(y$.util.isArray(J)&&(J.length===16||J.length===24||J.length===32)){X=J,J=y$.util.createBuffer();for(var Q=0;Q<X.length;++Q)J.putByte(X[Q])}if(!y$.util.isArray(J)){X=J,J=[];var Y=X.length();if(Y===16||Y===24||Y===32){Y=Y>>>2;for(var Q=0;Q<Y;++Q)J.push(X.getInt32())}}if(!y$.util.isArray(J)||!(J.length===4||J.length===6||J.length===8))throw Error("Invalid key parameter.");var G=this.mode.name,W=["CFB","OFB","CTR","GCM"].indexOf(G)!==-1;this._w=WG(J,$.decrypt&&!W),this._init=!0};y$.aes._expandKey=function($,J){if(!b9)GG();return WG($,J)};y$.aes._updateBlock=y9;AQ("AES-ECB",y$.cipher.modes.ecb);AQ("AES-CBC",y$.cipher.modes.cbc);AQ("AES-CFB",y$.cipher.modes.cfb);AQ("AES-OFB",y$.cipher.modes.ofb);AQ("AES-CTR",y$.cipher.modes.ctr);AQ("AES-GCM",y$.cipher.modes.gcm);function AQ($,J){var X=function(){return new y$.aes.Algorithm($,J)};y$.cipher.registerAlgorithm($,X)}var b9=!1,RQ=4,NJ,f9,YG,r0,uJ;function GG(){b9=!0,YG=[0,1,2,4,8,16,32,64,128,27,54];var $=Array(256);for(var J=0;J<128;++J)$[J]=J<<1,$[J+128]=J+128<<1^283;NJ=Array(256),f9=Array(256),r0=[,,,,],uJ=[,,,,];for(var J=0;J<4;++J)r0[J]=Array(256),uJ[J]=Array(256);var X=0,Q=0,Y,G,W,M,U,O,V;for(var J=0;J<256;++J){M=Q^Q<<1^Q<<2^Q<<3^Q<<4,M=M>>8^M&255^99,NJ[X]=M,f9[M]=X,U=$[M],Y=$[X],G=$[Y],W=$[G],O=U<<24^M<<16^M<<8^(M^U),V=(Y^G^W)<<24^(X^W)<<16^(X^G^W)<<8^(X^Y^W);for(var H=0;H<4;++H)r0[H][X]=O,uJ[H][M]=V,O=O<<24|O>>>8,V=V<<24|V>>>8;if(X===0)X=Q=1;else X=Y^$[$[$[Y^W]]],Q^=$[$[Q]]}}function WG($,J){var X=$.slice(0),Q,Y=1,G=X.length,W=G+6+1,M=RQ*W;for(var U=G;U<M;++U){if(Q=X[U-1],U%G===0)Q=NJ[Q>>>16&255]<<24^NJ[Q>>>8&255]<<16^NJ[Q&255]<<8^NJ[Q>>>24]^YG[Y]<<24,Y++;else if(G>6&&U%G===4)Q=NJ[Q>>>24]<<24^NJ[Q>>>16&255]<<16^NJ[Q>>>8&255]<<8^NJ[Q&255];X[U]=X[U-G]^Q}if(J){var O,V=uJ[0],H=uJ[1],q=uJ[2],F=uJ[3],K=X.slice(0);M=X.length;for(var U=0,R=M-RQ;U<M;U+=RQ,R-=RQ)if(U===0||U===M-RQ)K[U]=X[R],K[U+1]=X[R+3],K[U+2]=X[R+2],K[U+3]=X[R+1];else for(var L=0;L<RQ;++L)O=X[R+L],K[U+(3&-L)]=V[NJ[O>>>24]]^H[NJ[O>>>16&255]]^q[NJ[O>>>8&255]]^F[NJ[O&255]];X=K}return X}function y9($,J,X,Q){var Y=$.length/4-1,G,W,M,U,O;if(Q)G=uJ[0],W=uJ[1],M=uJ[2],U=uJ[3],O=f9;else G=r0[0],W=r0[1],M=r0[2],U=r0[3],O=NJ;var V,H,q,F,K,R,L;V=J[0]^$[0],H=J[Q?3:1]^$[1],q=J[2]^$[2],F=J[Q?1:3]^$[3];var D=3;for(var w=1;w<Y;++w)K=G[V>>>24]^W[H>>>16&255]^M[q>>>8&255]^U[F&255]^$[++D],R=G[H>>>24]^W[q>>>16&255]^M[F>>>8&255]^U[V&255]^$[++D],L=G[q>>>24]^W[F>>>16&255]^M[V>>>8&255]^U[H&255]^$[++D],F=G[F>>>24]^W[V>>>16&255]^M[H>>>8&255]^U[q&255]^$[++D],V=K,H=R,q=L;X[0]=O[V>>>24]<<24^O[H>>>16&255]<<16^O[q>>>8&255]<<8^O[F&255]^$[++D],X[Q?3:1]=O[H>>>24]<<24^O[q>>>16&255]<<16^O[F>>>8&255]<<8^O[V&255]^$[++D],X[2]=O[q>>>24]<<24^O[F>>>16&255]<<16^O[V>>>8&255]<<8^O[H&255]^$[++D],X[Q?1:3]=O[F>>>24]<<24^O[V>>>16&255]<<16^O[H>>>8&255]<<8^O[q&255]^$[++D]}function MY($){$=$||{};var J=($.mode||"CBC").toUpperCase(),X="AES-"+J,Q;if($.decrypt)Q=y$.cipher.createDecipher(X,$.key);else Q=y$.cipher.createCipher(X,$.key);var Y=Q.start;return Q.start=function(G,W){var M=null;if(W instanceof y$.util.ByteBuffer)M=W,W={};W=W||{},W.output=M,W.iv=G,Y.call(Q,W)},Q}});var S0=M$(($E,UG)=>{var HX=K$();HX.pki=HX.pki||{};var h9=UG.exports=HX.pki.oids=HX.oids=HX.oids||{};function y($,J){h9[$]=J,h9[J]=$}function _$($,J){h9[$]=J}y("1.2.840.113549.1.1.1","rsaEncryption");y("1.2.840.113549.1.1.4","md5WithRSAEncryption");y("1.2.840.113549.1.1.5","sha1WithRSAEncryption");y("1.2.840.113549.1.1.7","RSAES-OAEP");y("1.2.840.113549.1.1.8","mgf1");y("1.2.840.113549.1.1.9","pSpecified");y("1.2.840.113549.1.1.10","RSASSA-PSS");y("1.2.840.113549.1.1.11","sha256WithRSAEncryption");y("1.2.840.113549.1.1.12","sha384WithRSAEncryption");y("1.2.840.113549.1.1.13","sha512WithRSAEncryption");y("1.3.101.112","EdDSA25519");y("1.2.840.10040.4.3","dsa-with-sha1");y("1.3.14.3.2.7","desCBC");y("1.3.14.3.2.26","sha1");y("1.3.14.3.2.29","sha1WithRSASignature");y("2.16.840.1.101.3.4.2.1","sha256");y("2.16.840.1.101.3.4.2.2","sha384");y("2.16.840.1.101.3.4.2.3","sha512");y("2.16.840.1.101.3.4.2.4","sha224");y("2.16.840.1.101.3.4.2.5","sha512-224");y("2.16.840.1.101.3.4.2.6","sha512-256");y("1.2.840.113549.2.2","md2");y("1.2.840.113549.2.5","md5");y("1.2.840.113549.1.7.1","data");y("1.2.840.113549.1.7.2","signedData");y("1.2.840.113549.1.7.3","envelopedData");y("1.2.840.113549.1.7.4","signedAndEnvelopedData");y("1.2.840.113549.1.7.5","digestedData");y("1.2.840.113549.1.7.6","encryptedData");y("1.2.840.113549.1.9.1","emailAddress");y("1.2.840.113549.1.9.2","unstructuredName");y("1.2.840.113549.1.9.3","contentType");y("1.2.840.113549.1.9.4","messageDigest");y("1.2.840.113549.1.9.5","signingTime");y("1.2.840.113549.1.9.6","counterSignature");y("1.2.840.113549.1.9.7","challengePassword");y("1.2.840.113549.1.9.8","unstructuredAddress");y("1.2.840.113549.1.9.14","extensionRequest");y("1.2.840.113549.1.9.20","friendlyName");y("1.2.840.113549.1.9.21","localKeyId");y("1.2.840.113549.1.9.22.1","x509Certificate");y("1.2.840.113549.1.12.10.1.1","keyBag");y("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");y("1.2.840.113549.1.12.10.1.3","certBag");y("1.2.840.113549.1.12.10.1.4","crlBag");y("1.2.840.113549.1.12.10.1.5","secretBag");y("1.2.840.113549.1.12.10.1.6","safeContentsBag");y("1.2.840.113549.1.5.13","pkcs5PBES2");y("1.2.840.113549.1.5.12","pkcs5PBKDF2");y("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");y("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");y("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");y("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");y("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");y("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");y("1.2.840.113549.2.7","hmacWithSHA1");y("1.2.840.113549.2.8","hmacWithSHA224");y("1.2.840.113549.2.9","hmacWithSHA256");y("1.2.840.113549.2.10","hmacWithSHA384");y("1.2.840.113549.2.11","hmacWithSHA512");y("1.2.840.113549.3.7","des-EDE3-CBC");y("2.16.840.1.101.3.4.1.2","aes128-CBC");y("2.16.840.1.101.3.4.1.22","aes192-CBC");y("2.16.840.1.101.3.4.1.42","aes256-CBC");y("2.5.4.3","commonName");y("2.5.4.4","surname");y("2.5.4.5","serialNumber");y("2.5.4.6","countryName");y("2.5.4.7","localityName");y("2.5.4.8","stateOrProvinceName");y("2.5.4.9","streetAddress");y("2.5.4.10","organizationName");y("2.5.4.11","organizationalUnitName");y("2.5.4.12","title");y("2.5.4.13","description");y("2.5.4.15","businessCategory");y("2.5.4.17","postalCode");y("2.5.4.42","givenName");y("2.5.4.65","pseudonym");y("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");y("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");y("2.16.840.1.113730.1.1","nsCertType");y("2.16.840.1.113730.1.13","nsComment");_$("2.5.29.1","authorityKeyIdentifier");_$("2.5.29.2","keyAttributes");_$("2.5.29.3","certificatePolicies");_$("2.5.29.4","keyUsageRestriction");_$("2.5.29.5","policyMapping");_$("2.5.29.6","subtreesConstraint");_$("2.5.29.7","subjectAltName");_$("2.5.29.8","issuerAltName");_$("2.5.29.9","subjectDirectoryAttributes");_$("2.5.29.10","basicConstraints");_$("2.5.29.11","nameConstraints");_$("2.5.29.12","policyConstraints");_$("2.5.29.13","basicConstraints");y("2.5.29.14","subjectKeyIdentifier");y("2.5.29.15","keyUsage");_$("2.5.29.16","privateKeyUsagePeriod");y("2.5.29.17","subjectAltName");y("2.5.29.18","issuerAltName");y("2.5.29.19","basicConstraints");_$("2.5.29.20","cRLNumber");_$("2.5.29.21","cRLReason");_$("2.5.29.22","expirationDate");_$("2.5.29.23","instructionCode");_$("2.5.29.24","invalidityDate");_$("2.5.29.25","cRLDistributionPoints");_$("2.5.29.26","issuingDistributionPoint");_$("2.5.29.27","deltaCRLIndicator");_$("2.5.29.28","issuingDistributionPoint");_$("2.5.29.29","certificateIssuer");_$("2.5.29.30","nameConstraints");y("2.5.29.31","cRLDistributionPoints");y("2.5.29.32","certificatePolicies");_$("2.5.29.33","policyMappings");_$("2.5.29.34","policyConstraints");y("2.5.29.35","authorityKeyIdentifier");_$("2.5.29.36","policyConstraints");y("2.5.29.37","extKeyUsage");_$("2.5.29.46","freshestCRL");_$("2.5.29.54","inhibitAnyPolicy");y("1.3.6.1.4.1.11129.2.4.2","timestampList");y("1.3.6.1.5.5.7.1.1","authorityInfoAccess");y("1.3.6.1.5.5.7.3.1","serverAuth");y("1.3.6.1.5.5.7.3.2","clientAuth");y("1.3.6.1.5.5.7.3.3","codeSigning");y("1.3.6.1.5.5.7.3.4","emailProtection");y("1.3.6.1.5.5.7.3.8","timeStamping")});var gJ=M$((JE,VG)=>{var u$=K$();C$();S0();var p=VG.exports=u$.asn1=u$.asn1||{};p.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};p.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};p.maxDepth=256;p.create=function($,J,X,Q,Y){if(u$.util.isArray(Q)){var G=[];for(var W=0;W<Q.length;++W)if(Q[W]!==void 0)G.push(Q[W]);Q=G}var M={tagClass:$,type:J,constructed:X,composed:X||u$.util.isArray(Q),value:Q};if(Y&&"bitStringContents"in Y)M.bitStringContents=Y.bitStringContents,M.original=p.copy(M);return M};p.copy=function($,J){var X;if(u$.util.isArray($)){X=[];for(var Q=0;Q<$.length;++Q)X.push(p.copy($[Q],J));return X}if(typeof $==="string")return $;if(X={tagClass:$.tagClass,type:$.type,constructed:$.constructed,composed:$.composed,value:p.copy($.value,J)},J&&!J.excludeBitStringContents)X.bitStringContents=$.bitStringContents;return X};p.equals=function($,J,X){if(u$.util.isArray($)){if(!u$.util.isArray(J))return!1;if($.length!==J.length)return!1;for(var Q=0;Q<$.length;++Q)if(!p.equals($[Q],J[Q]))return!1;return!0}if(typeof $!==typeof J)return!1;if(typeof $==="string")return $===J;var Y=$.tagClass===J.tagClass&&$.type===J.type&&$.constructed===J.constructed&&$.composed===J.composed&&p.equals($.value,J.value);if(X&&X.includeBitStringContents)Y=Y&&$.bitStringContents===J.bitStringContents;return Y};p.getBerValueLength=function($){var J=$.getByte();if(J===128)return;var X,Q=J&128;if(!Q)X=J;else X=$.getInt((J&127)<<3);return X};function qX($,J,X){if(X>J){var Q=Error("Too few bytes to parse DER.");throw Q.available=$.length(),Q.remaining=J,Q.requested=X,Q}}var NM=function($,J){var X=$.getByte();if(J--,X===128)return;var Q,Y=X&128;if(!Y)Q=X;else{var G=X&127;qX($,J,G),Q=$.getInt(G<<3)}if(Q<0)throw Error("Negative length: "+Q);return Q};p.fromDer=function($,J){if(J===void 0)J={strict:!0,parseAllBytes:!0,decodeBitStrings:!0};if(typeof J==="boolean")J={strict:J,parseAllBytes:!0,decodeBitStrings:!0};if(!("strict"in J))J.strict=!0;if(!("parseAllBytes"in J))J.parseAllBytes=!0;if(!("decodeBitStrings"in J))J.decodeBitStrings=!0;if(!("maxDepth"in J))J.maxDepth=p.maxDepth;if(typeof $==="string")$=u$.util.createBuffer($);var X=$.length(),Q=UY($,$.length(),0,J);if(J.parseAllBytes&&$.length()!==0){var Y=Error("Unparsed DER bytes remain after ASN.1 parsing.");throw Y.byteCount=X,Y.remaining=$.length(),Y}return Q};function UY($,J,X,Q){if(X>=Q.maxDepth)throw Error("ASN.1 parsing error: Max depth exceeded.");var Y;qX($,J,2);var G=$.getByte();J--;var W=G&192,M=G&31;Y=$.length();var U=NM($,J);if(J-=Y-$.length(),U!==void 0&&U>J){if(Q.strict){var O=Error("Too few bytes to read ASN.1 value.");throw O.available=$.length(),O.remaining=J,O.requested=U,O}U=J}var V,H,q=(G&32)===32;if(q)if(V=[],U===void 0)for(;;){if(qX($,J,2),$.bytes(2)===String.fromCharCode(0,0)){$.getBytes(2),J-=2;break}Y=$.length(),V.push(UY($,J,X+1,Q)),J-=Y-$.length()}else while(U>0)Y=$.length(),V.push(UY($,U,X+1,Q)),J-=Y-$.length(),U-=Y-$.length();if(V===void 0&&W===p.Class.UNIVERSAL&&M===p.Type.BITSTRING)H=$.bytes(U);if(V===void 0&&Q.decodeBitStrings&&W===p.Class.UNIVERSAL&&M===p.Type.BITSTRING&&U>1){var F=$.read,K=J,R=0;if(M===p.Type.BITSTRING)qX($,J,1),R=$.getByte(),J--;if(R===0)try{Y=$.length();var L={strict:!0,decodeBitStrings:!0},D=UY($,J,X+1,L),w=Y-$.length();if(J-=w,M==p.Type.BITSTRING)w++;var T=D.tagClass;if(w===U&&(T===p.Class.UNIVERSAL||T===p.Class.CONTEXT_SPECIFIC))V=[D]}catch(S){}if(V===void 0)$.read=F,J=K}if(V===void 0){if(U===void 0){if(Q.strict)throw Error("Non-constructed ASN.1 object of indefinite length.");U=J}if(M===p.Type.BMPSTRING){V="";for(;U>0;U-=2)qX($,J,2),V+=String.fromCharCode($.getInt16()),J-=2}else V=$.getBytes(U),J-=U}var P=H===void 0?null:{bitStringContents:H};return p.create(W,M,q,V,P)}p.toDer=function($){var J=u$.util.createBuffer(),X=$.tagClass|$.type,Q=u$.util.createBuffer(),Y=!1;if("bitStringContents"in $){if(Y=!0,$.original)Y=p.equals($,$.original)}if(Y)Q.putBytes($.bitStringContents);else if($.composed){if($.constructed)X|=32;else Q.putByte(0);for(var G=0;G<$.value.length;++G)if($.value[G]!==void 0)Q.putBuffer(p.toDer($.value[G]))}else if($.type===p.Type.BMPSTRING)for(var G=0;G<$.value.length;++G)Q.putInt16($.value.charCodeAt(G));else if($.type===p.Type.INTEGER&&$.value.length>1&&($.value.charCodeAt(0)===0&&($.value.charCodeAt(1)&128)===0||$.value.charCodeAt(0)===255&&($.value.charCodeAt(1)&128)===128))Q.putBytes($.value.substr(1));else Q.putBytes($.value);if(J.putByte(X),Q.length()<=127)J.putByte(Q.length()&127);else{var W=Q.length(),M="";do M+=String.fromCharCode(W&255),W=W>>>8;while(W>0);J.putByte(M.length|128);for(var G=M.length-1;G>=0;--G)J.putByte(M.charCodeAt(G))}return J.putBuffer(Q),J};p.oidToDer=function($){var J=$.split("."),X=u$.util.createBuffer();X.putByte(40*parseInt(J[0],10)+parseInt(J[1],10));var Q,Y,G,W;for(var M=2;M<J.length;++M){if(Q=!0,Y=[],G=parseInt(J[M],10),G>4294967295)throw Error("OID value too large; max is 32-bits.");do{if(W=G&127,G=G>>>7,!Q)W|=128;Y.push(W),Q=!1}while(G>0);for(var U=Y.length-1;U>=0;--U)X.putByte(Y[U])}return X};p.derToOid=function($){var J;if(typeof $==="string")$=u$.util.createBuffer($);var X=$.getByte();J=Math.floor(X/40)+"."+X%40;var Q=0;while($.length()>0){if(Q>70368744177663)throw Error("OID value too large; max is 53-bits.");if(X=$.getByte(),Q=Q*128,X&128)Q+=X&127;else J+="."+(Q+X),Q=0}return J};p.utcTimeToDate=function($){var J=new Date,X=parseInt($.substr(0,2),10);X=X>=50?1900+X:2000+X;var Q=parseInt($.substr(2,2),10)-1,Y=parseInt($.substr(4,2),10),G=parseInt($.substr(6,2),10),W=parseInt($.substr(8,2),10),M=0;if($.length>11){var U=$.charAt(10),O=10;if(U!=="+"&&U!=="-")M=parseInt($.substr(10,2),10),O+=2}if(J.setUTCFullYear(X,Q,Y),J.setUTCHours(G,W,M,0),O){if(U=$.charAt(O),U==="+"||U==="-"){var V=parseInt($.substr(O+1,2),10),H=parseInt($.substr(O+4,2),10),q=V*60+H;if(q*=60000,U==="+")J.setTime(+J-q);else J.setTime(+J+q)}}return J};p.generalizedTimeToDate=function($){var J=new Date,X=parseInt($.substr(0,4),10),Q=parseInt($.substr(4,2),10)-1,Y=parseInt($.substr(6,2),10),G=parseInt($.substr(8,2),10),W=parseInt($.substr(10,2),10),M=parseInt($.substr(12,2),10),U=0,O=0,V=!1;if($.charAt($.length-1)==="Z")V=!0;var H=$.length-5,q=$.charAt(H);if(q==="+"||q==="-"){var F=parseInt($.substr(H+1,2),10),K=parseInt($.substr(H+4,2),10);if(O=F*60+K,O*=60000,q==="+")O*=-1;V=!0}if($.charAt(14)===".")U=parseFloat($.substr(14),10)*1000;if(V)J.setUTCFullYear(X,Q,Y),J.setUTCHours(G,W,M,U),J.setTime(+J+O);else J.setFullYear(X,Q,Y),J.setHours(G,W,M,U);return J};p.dateToUtcTime=function($){if(typeof $==="string")return $;var J="",X=[];X.push((""+$.getUTCFullYear()).substr(2)),X.push(""+($.getUTCMonth()+1)),X.push(""+$.getUTCDate()),X.push(""+$.getUTCHours()),X.push(""+$.getUTCMinutes()),X.push(""+$.getUTCSeconds());for(var Q=0;Q<X.length;++Q){if(X[Q].length<2)J+="0";J+=X[Q]}return J+="Z",J};p.dateToGeneralizedTime=function($){if(typeof $==="string")return $;var J="",X=[];X.push(""+$.getUTCFullYear()),X.push(""+($.getUTCMonth()+1)),X.push(""+$.getUTCDate()),X.push(""+$.getUTCHours()),X.push(""+$.getUTCMinutes()),X.push(""+$.getUTCSeconds());for(var Q=0;Q<X.length;++Q){if(X[Q].length<2)J+="0";J+=X[Q]}return J+="Z",J};p.integerToDer=function($){var J=u$.util.createBuffer();if($>=-128&&$<128)return J.putSignedInt($,8);if($>=-32768&&$<32768)return J.putSignedInt($,16);if($>=-8388608&&$<8388608)return J.putSignedInt($,24);if($>=-2147483648&&$<2147483648)return J.putSignedInt($,32);var X=Error("Integer too large; max is 32-bits.");throw X.integer=$,X};p.derToInteger=function($){if(typeof $==="string")$=u$.util.createBuffer($);var J=$.length()*8;if(J>32)throw Error("Integer too large; max is 32-bits.");return $.getSignedInt(J)};p.validate=function($,J,X,Q){var Y=!1;if(($.tagClass===J.tagClass||typeof J.tagClass>"u")&&($.type===J.type||typeof J.type>"u")){if($.constructed===J.constructed||typeof J.constructed>"u"){if(Y=!0,J.value&&u$.util.isArray(J.value)){var G=0;for(var W=0;Y&&W<J.value.length;++W){var M=J.value[W];Y=!!M.optional;var U=$.value[G];if(!U){if(!M.optional){if(Y=!1,Q)Q.push("["+J.name+'] Missing required element. Expected tag class "'+M.tagClass+'", type "'+M.type+'"')}continue}var O=typeof M.tagClass<"u"&&typeof M.type<"u";if(O&&(U.tagClass!==M.tagClass||U.type!==M.type))if(M.optional){Y=!0;continue}else{if(Y=!1,Q)Q.push("["+J.name+"] Tag mismatch. Expected ("+M.tagClass+","+M.type+"), got ("+U.tagClass+","+U.type+")");break}var V=p.validate(U,M,X,Q);if(V)++G,Y=!0;else if(M.optional)Y=!0;else{Y=!1;break}}}if(Y&&X){if(J.capture)X[J.capture]=$.value;if(J.captureAsn1)X[J.captureAsn1]=$;if(J.captureBitStringContents&&"bitStringContents"in $)X[J.captureBitStringContents]=$.bitStringContents;if(J.captureBitStringValue&&"bitStringContents"in $){var H;if($.bitStringContents.length<2)X[J.captureBitStringValue]="";else{var q=$.bitStringContents.charCodeAt(0);if(q!==0)throw Error("captureBitStringValue only supported for zero unused bits");X[J.captureBitStringValue]=$.bitStringContents.slice(1)}}}}else if(Q)Q.push("["+J.name+'] Expected constructed "'+J.constructed+'", got "'+$.constructed+'"')}else if(Q){if($.tagClass!==J.tagClass)Q.push("["+J.name+'] Expected tag class "'+J.tagClass+'", got "'+$.tagClass+'"');if($.type!==J.type)Q.push("["+J.name+'] Expected type "'+J.type+'", got "'+$.type+'"')}return Y};var OG=/[^\\u0000-\\u00ff]/;p.prettyPrint=function($,J,X){var Q="";if(J=J||0,X=X||2,J>0)Q+=`
|
|
6
|
-
`;var Y="";for(var G=0;G<J*X;++G)Y+=" ";switch(Q+=Y+"Tag: ",$.tagClass){case
|
|
2
|
+
var PU=Object.create;var{getPrototypeOf:_U,defineProperty:u9,getOwnPropertyNames:xU}=Object;var vU=Object.prototype.hasOwnProperty;function kU($){return this[$]}var fU,yU,g9=($,J,X)=>{var Q=$!=null&&typeof $==="object";if(Q){var Y=J?fU??=new WeakMap:yU??=new WeakMap,G=Y.get($);if(G)return G}X=$!=null?PU(_U($)):{};let W=J||!$||!$.__esModule?u9(X,"default",{value:$,enumerable:!0}):X;for(let U of xU($))if(!vU.call(W,U))u9(W,U,{get:kU.bind($,U),enumerable:!0});if(Q)Y.set($,W);return W};var O$=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var bU=($)=>$;function hU($,J){this[$]=bU.bind(null,J)}var uU=($,J)=>{for(var X in J)u9($,X,{get:J[X],enumerable:!0,configurable:!0,set:hU.bind(J,X)})};var OX=import.meta.require;var z$=O$((aE,EG)=>{EG.exports={options:{usePureJavaScript:!1}}});var LG=O$((sE,NG)=>{var p9={};NG.exports=p9;var FG={};p9.encode=function($,J,X){if(typeof J!=="string")throw TypeError('"alphabet" must be a string.');if(X!==void 0&&typeof X!=="number")throw TypeError('"maxline" must be a number.');var Q="";if(!($ instanceof Uint8Array))Q=iU($,J);else{var Y=0,G=J.length,W=J.charAt(0),U=[0];for(Y=0;Y<$.length;++Y){for(var M=0,O=$[Y];M<U.length;++M)O+=U[M]<<8,U[M]=O%G,O=O/G|0;while(O>0)U.push(O%G),O=O/G|0}for(Y=0;$[Y]===0&&Y<$.length-1;++Y)Q+=W;for(Y=U.length-1;Y>=0;--Y)Q+=J[U[Y]]}if(X){var V=new RegExp(".{1,"+X+"}","g");Q=Q.match(V).join(`\r
|
|
3
|
+
`)}return Q};p9.decode=function($,J){if(typeof $!=="string")throw TypeError('"input" must be a string.');if(typeof J!=="string")throw TypeError('"alphabet" must be a string.');var X=FG[J];if(!X){X=FG[J]=[];for(var Q=0;Q<J.length;++Q)X[J.charCodeAt(Q)]=Q}$=$.replace(/\s/g,"");var Y=J.length,G=J.charAt(0),W=[0];for(var Q=0;Q<$.length;Q++){var U=X[$.charCodeAt(Q)];if(U===void 0)return;for(var M=0,O=U;M<W.length;++M)O+=W[M]*Y,W[M]=O&255,O>>=8;while(O>0)W.push(O&255),O>>=8}for(var V=0;$[V]===G&&V<$.length-1;++V)W.push(0);if(typeof Buffer<"u")return Buffer.from(W.reverse());return new Uint8Array(W.reverse())};function iU($,J){var X=0,Q=J.length,Y=J.charAt(0),G=[0];for(X=0;X<$.length();++X){for(var W=0,U=$.at(X);W<G.length;++W)U+=G[W]<<8,G[W]=U%Q,U=U/Q|0;while(U>0)G.push(U%Q),U=U/Q|0}var M="";for(X=0;$.at(X)===0&&X<$.length()-1;++X)M+=Y;for(X=G.length-1;X>=0;--X)M+=J[G[X]];return M}});var w$=O$((rE,ZG)=>{var AG=z$(),RG=LG(),j=ZG.exports=AG.util=AG.util||{};(function(){if(typeof process<"u"&&process.nextTick){if(j.nextTick=process.nextTick,typeof setImmediate==="function")j.setImmediate=setImmediate;else j.setImmediate=j.nextTick;return}if(typeof setImmediate==="function"){j.setImmediate=function(){return setImmediate.apply(void 0,arguments)},j.nextTick=function(U){return setImmediate(U)};return}if(j.setImmediate=function(U){setTimeout(U,0)},typeof window<"u"&&typeof window.postMessage==="function"){let U=function(M){if(M.source===window&&M.data===$){M.stopPropagation();var O=J.slice();J.length=0,O.forEach(function(V){V()})}};var W=U,$="forge.setImmediate",J=[];j.setImmediate=function(M){if(J.push(M),J.length===1)window.postMessage($,"*")},window.addEventListener("message",U,!0)}if(typeof MutationObserver<"u"){var X=Date.now(),Q=!0,Y=document.createElement("div"),J=[];new MutationObserver(function(){var M=J.slice();J.length=0,M.forEach(function(O){O()})}).observe(Y,{attributes:!0});var G=j.setImmediate;j.setImmediate=function(M){if(Date.now()-X>15)X=Date.now(),G(M);else if(J.push(M),J.length===1)Y.setAttribute("a",Q=!Q)}}j.nextTick=j.setImmediate})();j.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;j.globalScope=function(){if(j.isNodejs)return global;return typeof self>"u"?window:self}();j.isArray=Array.isArray||function($){return Object.prototype.toString.call($)==="[object Array]"};j.isArrayBuffer=function($){return typeof ArrayBuffer<"u"&&$ instanceof ArrayBuffer};j.isArrayBufferView=function($){return $&&j.isArrayBuffer($.buffer)&&$.byteLength!==void 0};function EX($){if(!($===8||$===16||$===24||$===32))throw Error("Only 8, 16, 24, or 32 bits supported: "+$)}j.ByteBuffer=d9;function d9($){if(this.data="",this.read=0,typeof $==="string")this.data=$;else if(j.isArrayBuffer($)||j.isArrayBufferView($))if(typeof Buffer<"u"&&$ instanceof Buffer)this.data=$.toString("binary");else{var J=new Uint8Array($);try{this.data=String.fromCharCode.apply(null,J)}catch(Q){for(var X=0;X<J.length;++X)this.putByte(J[X])}}else if($ instanceof d9||typeof $==="object"&&typeof $.data==="string"&&typeof $.read==="number")this.data=$.data,this.read=$.read;this._constructedStringLength=0}j.ByteStringBuffer=d9;var oU=4096;j.ByteStringBuffer.prototype._optimizeConstructedString=function($){if(this._constructedStringLength+=$,this._constructedStringLength>oU)this.data.substr(0,1),this._constructedStringLength=0};j.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};j.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};j.ByteStringBuffer.prototype.putByte=function($){return this.putBytes(String.fromCharCode($))};j.ByteStringBuffer.prototype.fillWithByte=function($,J){$=String.fromCharCode($);var X=this.data;while(J>0){if(J&1)X+=$;if(J>>>=1,J>0)$+=$}return this.data=X,this._optimizeConstructedString(J),this};j.ByteStringBuffer.prototype.putBytes=function($){return this.data+=$,this._optimizeConstructedString($.length),this};j.ByteStringBuffer.prototype.putString=function($){return this.putBytes(j.encodeUtf8($))};j.ByteStringBuffer.prototype.putInt16=function($){return this.putBytes(String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt24=function($){return this.putBytes(String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt32=function($){return this.putBytes(String.fromCharCode($>>24&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255))};j.ByteStringBuffer.prototype.putInt16Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255))};j.ByteStringBuffer.prototype.putInt24Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255)+String.fromCharCode($>>16&255))};j.ByteStringBuffer.prototype.putInt32Le=function($){return this.putBytes(String.fromCharCode($&255)+String.fromCharCode($>>8&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>24&255))};j.ByteStringBuffer.prototype.putInt=function($,J){EX(J);var X="";do J-=8,X+=String.fromCharCode($>>J&255);while(J>0);return this.putBytes(X)};j.ByteStringBuffer.prototype.putSignedInt=function($,J){if($<0)$+=2<<J-1;return this.putInt($,J)};j.ByteStringBuffer.prototype.putBuffer=function($){return this.putBytes($.getBytes())};j.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};j.ByteStringBuffer.prototype.getInt16=function(){var $=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,$};j.ByteStringBuffer.prototype.getInt24=function(){var $=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,$};j.ByteStringBuffer.prototype.getInt32=function(){var $=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,$};j.ByteStringBuffer.prototype.getInt16Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,$};j.ByteStringBuffer.prototype.getInt24Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,$};j.ByteStringBuffer.prototype.getInt32Le=function(){var $=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,$};j.ByteStringBuffer.prototype.getInt=function($){EX($);var J=0;do J=(J<<8)+this.data.charCodeAt(this.read++),$-=8;while($>0);return J};j.ByteStringBuffer.prototype.getSignedInt=function($){var J=this.getInt($),X=2<<$-2;if(J>=X)J-=X<<1;return J};j.ByteStringBuffer.prototype.getBytes=function($){var J;if($)$=Math.min(this.length(),$),J=this.data.slice(this.read,this.read+$),this.read+=$;else if($===0)J="";else J=this.read===0?this.data:this.data.slice(this.read),this.clear();return J};j.ByteStringBuffer.prototype.bytes=function($){return typeof $>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+$)};j.ByteStringBuffer.prototype.at=function($){return this.data.charCodeAt(this.read+$)};j.ByteStringBuffer.prototype.setAt=function($,J){return this.data=this.data.substr(0,this.read+$)+String.fromCharCode(J)+this.data.substr(this.read+$+1),this};j.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};j.ByteStringBuffer.prototype.copy=function(){var $=j.createBuffer(this.data);return $.read=this.read,$};j.ByteStringBuffer.prototype.compact=function(){if(this.read>0)this.data=this.data.slice(this.read),this.read=0;return this};j.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};j.ByteStringBuffer.prototype.truncate=function($){var J=Math.max(0,this.length()-$);return this.data=this.data.substr(this.read,J),this.read=0,this};j.ByteStringBuffer.prototype.toHex=function(){var $="";for(var J=this.read;J<this.data.length;++J){var X=this.data.charCodeAt(J);if(X<16)$+="0";$+=X.toString(16)}return $};j.ByteStringBuffer.prototype.toString=function(){return j.decodeUtf8(this.bytes())};function aU($,J){J=J||{},this.read=J.readOffset||0,this.growSize=J.growSize||1024;var X=j.isArrayBuffer($),Q=j.isArrayBufferView($);if(X||Q){if(X)this.data=new DataView($);else this.data=new DataView($.buffer,$.byteOffset,$.byteLength);this.write="writeOffset"in J?J.writeOffset:this.data.byteLength;return}if(this.data=new DataView(new ArrayBuffer(0)),this.write=0,$!==null&&$!==void 0)this.putBytes($);if("writeOffset"in J)this.write=J.writeOffset}j.DataBuffer=aU;j.DataBuffer.prototype.length=function(){return this.write-this.read};j.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};j.DataBuffer.prototype.accommodate=function($,J){if(this.length()>=$)return this;J=Math.max(J||this.growSize,$);var X=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),Q=new Uint8Array(this.length()+J);return Q.set(X),this.data=new DataView(Q.buffer),this};j.DataBuffer.prototype.putByte=function($){return this.accommodate(1),this.data.setUint8(this.write++,$),this};j.DataBuffer.prototype.fillWithByte=function($,J){this.accommodate(J);for(var X=0;X<J;++X)this.data.setUint8($);return this};j.DataBuffer.prototype.putBytes=function($,J){if(j.isArrayBufferView($)){var X=new Uint8Array($.buffer,$.byteOffset,$.byteLength),Q=X.byteLength-X.byteOffset;this.accommodate(Q);var Y=new Uint8Array(this.data.buffer,this.write);return Y.set(X),this.write+=Q,this}if(j.isArrayBuffer($)){var X=new Uint8Array($);this.accommodate(X.byteLength);var Y=new Uint8Array(this.data.buffer);return Y.set(X,this.write),this.write+=X.byteLength,this}if($ instanceof j.DataBuffer||typeof $==="object"&&typeof $.read==="number"&&typeof $.write==="number"&&j.isArrayBufferView($.data)){var X=new Uint8Array($.data.byteLength,$.read,$.length());this.accommodate(X.byteLength);var Y=new Uint8Array($.data.byteLength,this.write);return Y.set(X),this.write+=X.byteLength,this}if($ instanceof j.ByteStringBuffer)$=$.data,J="binary";if(J=J||"binary",typeof $==="string"){var G;if(J==="hex")return this.accommodate(Math.ceil($.length/2)),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.hex.decode($,G,this.write),this;if(J==="base64")return this.accommodate(Math.ceil($.length/4)*3),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.base64.decode($,G,this.write),this;if(J==="utf8")$=j.encodeUtf8($),J="binary";if(J==="binary"||J==="raw")return this.accommodate($.length),G=new Uint8Array(this.data.buffer,this.write),this.write+=j.binary.raw.decode(G),this;if(J==="utf16")return this.accommodate($.length*2),G=new Uint16Array(this.data.buffer,this.write),this.write+=j.text.utf16.encode(G),this;throw Error("Invalid encoding: "+J)}throw Error("Invalid parameter: "+$)};j.DataBuffer.prototype.putBuffer=function($){return this.putBytes($),$.clear(),this};j.DataBuffer.prototype.putString=function($){return this.putBytes($,"utf16")};j.DataBuffer.prototype.putInt16=function($){return this.accommodate(2),this.data.setInt16(this.write,$),this.write+=2,this};j.DataBuffer.prototype.putInt24=function($){return this.accommodate(3),this.data.setInt16(this.write,$>>8&65535),this.data.setInt8(this.write,$>>16&255),this.write+=3,this};j.DataBuffer.prototype.putInt32=function($){return this.accommodate(4),this.data.setInt32(this.write,$),this.write+=4,this};j.DataBuffer.prototype.putInt16Le=function($){return this.accommodate(2),this.data.setInt16(this.write,$,!0),this.write+=2,this};j.DataBuffer.prototype.putInt24Le=function($){return this.accommodate(3),this.data.setInt8(this.write,$>>16&255),this.data.setInt16(this.write,$>>8&65535,!0),this.write+=3,this};j.DataBuffer.prototype.putInt32Le=function($){return this.accommodate(4),this.data.setInt32(this.write,$,!0),this.write+=4,this};j.DataBuffer.prototype.putInt=function($,J){EX(J),this.accommodate(J/8);do J-=8,this.data.setInt8(this.write++,$>>J&255);while(J>0);return this};j.DataBuffer.prototype.putSignedInt=function($,J){if(EX(J),this.accommodate(J/8),$<0)$+=2<<J-1;return this.putInt($,J)};j.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};j.DataBuffer.prototype.getInt16=function(){var $=this.data.getInt16(this.read);return this.read+=2,$};j.DataBuffer.prototype.getInt24=function(){var $=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,$};j.DataBuffer.prototype.getInt32=function(){var $=this.data.getInt32(this.read);return this.read+=4,$};j.DataBuffer.prototype.getInt16Le=function(){var $=this.data.getInt16(this.read,!0);return this.read+=2,$};j.DataBuffer.prototype.getInt24Le=function(){var $=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,$};j.DataBuffer.prototype.getInt32Le=function(){var $=this.data.getInt32(this.read,!0);return this.read+=4,$};j.DataBuffer.prototype.getInt=function($){EX($);var J=0;do J=(J<<8)+this.data.getInt8(this.read++),$-=8;while($>0);return J};j.DataBuffer.prototype.getSignedInt=function($){var J=this.getInt($),X=2<<$-2;if(J>=X)J-=X<<1;return J};j.DataBuffer.prototype.getBytes=function($){var J;if($)$=Math.min(this.length(),$),J=this.data.slice(this.read,this.read+$),this.read+=$;else if($===0)J="";else J=this.read===0?this.data:this.data.slice(this.read),this.clear();return J};j.DataBuffer.prototype.bytes=function($){return typeof $>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+$)};j.DataBuffer.prototype.at=function($){return this.data.getUint8(this.read+$)};j.DataBuffer.prototype.setAt=function($,J){return this.data.setUint8($,J),this};j.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};j.DataBuffer.prototype.copy=function(){return new j.DataBuffer(this)};j.DataBuffer.prototype.compact=function(){if(this.read>0){var $=new Uint8Array(this.data.buffer,this.read),J=new Uint8Array($.byteLength);J.set($),this.data=new DataView(J),this.write-=this.read,this.read=0}return this};j.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};j.DataBuffer.prototype.truncate=function($){return this.write=Math.max(0,this.length()-$),this.read=Math.min(this.read,this.write),this};j.DataBuffer.prototype.toHex=function(){var $="";for(var J=this.read;J<this.data.byteLength;++J){var X=this.data.getUint8(J);if(X<16)$+="0";$+=X.toString(16)}return $};j.DataBuffer.prototype.toString=function($){var J=new Uint8Array(this.data,this.read,this.length());if($=$||"utf8",$==="binary"||$==="raw")return j.binary.raw.encode(J);if($==="hex")return j.binary.hex.encode(J);if($==="base64")return j.binary.base64.encode(J);if($==="utf8")return j.text.utf8.decode(J);if($==="utf16")return j.text.utf16.decode(J);throw Error("Invalid encoding: "+$)};j.createBuffer=function($,J){if(J=J||"raw",$!==void 0&&J==="utf8")$=j.encodeUtf8($);return new j.ByteBuffer($)};j.fillString=function($,J){var X="";while(J>0){if(J&1)X+=$;if(J>>>=1,J>0)$+=$}return X};j.xorBytes=function($,J,X){var Q="",Y="",G="",W=0,U=0;for(;X>0;--X,++W){if(Y=$.charCodeAt(W)^J.charCodeAt(W),U>=10)Q+=G,G="",U=0;G+=String.fromCharCode(Y),++U}return Q+=G,Q};j.hexToBytes=function($){var J="",X=0;if($.length&!0)X=1,J+=String.fromCharCode(parseInt($[0],16));for(;X<$.length;X+=2)J+=String.fromCharCode(parseInt($.substr(X,2),16));return J};j.bytesToHex=function($){return j.createBuffer($).toHex()};j.int32ToBytes=function($){return String.fromCharCode($>>24&255)+String.fromCharCode($>>16&255)+String.fromCharCode($>>8&255)+String.fromCharCode($&255)};var I0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",C0=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],DG="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";j.encode64=function($,J){var X="",Q="",Y,G,W,U=0;while(U<$.length){if(Y=$.charCodeAt(U++),G=$.charCodeAt(U++),W=$.charCodeAt(U++),X+=I0.charAt(Y>>2),X+=I0.charAt((Y&3)<<4|G>>4),isNaN(G))X+="==";else X+=I0.charAt((G&15)<<2|W>>6),X+=isNaN(W)?"=":I0.charAt(W&63);if(J&&X.length>J)Q+=X.substr(0,J)+`\r
|
|
4
|
+
`,X=X.substr(J)}return Q+=X,Q};j.decode64=function($){$=$.replace(/[^A-Za-z0-9\+\/\=]/g,"");var J="",X,Q,Y,G,W=0;while(W<$.length)if(X=C0[$.charCodeAt(W++)-43],Q=C0[$.charCodeAt(W++)-43],Y=C0[$.charCodeAt(W++)-43],G=C0[$.charCodeAt(W++)-43],J+=String.fromCharCode(X<<2|Q>>4),Y!==64){if(J+=String.fromCharCode((Q&15)<<4|Y>>2),G!==64)J+=String.fromCharCode((Y&3)<<6|G)}return J};j.encodeUtf8=function($){return unescape(encodeURIComponent($))};j.decodeUtf8=function($){return decodeURIComponent(escape($))};j.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:RG.encode,decode:RG.decode}};j.binary.raw.encode=function($){return String.fromCharCode.apply(null,$)};j.binary.raw.decode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array($.length);X=X||0;var Y=X;for(var G=0;G<$.length;++G)Q[Y++]=$.charCodeAt(G);return J?Y-X:Q};j.binary.hex.encode=j.bytesToHex;j.binary.hex.decode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array(Math.ceil($.length/2));X=X||0;var Y=0,G=X;if($.length&1)Y=1,Q[G++]=parseInt($[0],16);for(;Y<$.length;Y+=2)Q[G++]=parseInt($.substr(Y,2),16);return J?G-X:Q};j.binary.base64.encode=function($,J){var X="",Q="",Y,G,W,U=0;while(U<$.byteLength){if(Y=$[U++],G=$[U++],W=$[U++],X+=I0.charAt(Y>>2),X+=I0.charAt((Y&3)<<4|G>>4),isNaN(G))X+="==";else X+=I0.charAt((G&15)<<2|W>>6),X+=isNaN(W)?"=":I0.charAt(W&63);if(J&&X.length>J)Q+=X.substr(0,J)+`\r
|
|
5
|
+
`,X=X.substr(J)}return Q+=X,Q};j.binary.base64.decode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array(Math.ceil($.length/4)*3);$=$.replace(/[^A-Za-z0-9\+\/\=]/g,""),X=X||0;var Y,G,W,U,M=0,O=X;while(M<$.length)if(Y=C0[$.charCodeAt(M++)-43],G=C0[$.charCodeAt(M++)-43],W=C0[$.charCodeAt(M++)-43],U=C0[$.charCodeAt(M++)-43],Q[O++]=Y<<2|G>>4,W!==64){if(Q[O++]=(G&15)<<4|W>>2,U!==64)Q[O++]=(W&3)<<6|U}return J?O-X:Q.subarray(0,O)};j.binary.base58.encode=function($,J){return j.binary.baseN.encode($,DG,J)};j.binary.base58.decode=function($,J){return j.binary.baseN.decode($,DG,J)};j.text={utf8:{},utf16:{}};j.text.utf8.encode=function($,J,X){$=j.encodeUtf8($);var Q=J;if(!Q)Q=new Uint8Array($.length);X=X||0;var Y=X;for(var G=0;G<$.length;++G)Q[Y++]=$.charCodeAt(G);return J?Y-X:Q};j.text.utf8.decode=function($){return j.decodeUtf8(String.fromCharCode.apply(null,$))};j.text.utf16.encode=function($,J,X){var Q=J;if(!Q)Q=new Uint8Array($.length*2);var Y=new Uint16Array(Q.buffer);X=X||0;var G=X,W=X;for(var U=0;U<$.length;++U)Y[W++]=$.charCodeAt(U),G+=2;return J?G-X:Q};j.text.utf16.decode=function($){return String.fromCharCode.apply(null,new Uint16Array($.buffer))};j.deflate=function($,J,X){if(J=j.decode64($.deflate(j.encode64(J)).rval),X){var Q=2,Y=J.charCodeAt(1);if(Y&32)Q=6;J=J.substring(Q,J.length-4)}return J};j.inflate=function($,J,X){var Q=$.inflate(j.encode64(J)).rval;return Q===null?null:j.decode64(Q)};var c9=function($,J,X){if(!$)throw Error("WebStorage not available.");var Q;if(X===null)Q=$.removeItem(J);else X=j.encode64(JSON.stringify(X)),Q=$.setItem(J,X);if(typeof Q<"u"&&Q.rval!==!0){var Y=Error(Q.error.message);throw Y.id=Q.error.id,Y.name=Q.error.name,Y}},n9=function($,J){if(!$)throw Error("WebStorage not available.");var X=$.getItem(J);if($.init)if(X.rval===null){if(X.error){var Q=Error(X.error.message);throw Q.id=X.error.id,Q.name=X.error.name,Q}X=null}else X=X.rval;if(X!==null)X=JSON.parse(j.decode64(X));return X},sU=function($,J,X,Q){var Y=n9($,J);if(Y===null)Y={};Y[X]=Q,c9($,J,Y)},rU=function($,J,X){var Q=n9($,J);if(Q!==null)Q=X in Q?Q[X]:null;return Q},tU=function($,J,X){var Q=n9($,J);if(Q!==null&&X in Q){delete Q[X];var Y=!0;for(var G in Q){Y=!1;break}if(Y)Q=null;c9($,J,Q)}},eU=function($,J){c9($,J,null)},zY=function($,J,X){var Q=null;if(typeof X>"u")X=["web","flash"];var Y,G=!1,W=null;for(var U in X){Y=X[U];try{if(Y==="flash"||Y==="both"){if(J[0]===null)throw Error("Flash local storage not available.");Q=$.apply(this,J),G=Y==="flash"}if(Y==="web"||Y==="both")J[0]=localStorage,Q=$.apply(this,J),G=!0}catch(M){W=M}if(G)break}if(!G)throw W;return Q};j.setItem=function($,J,X,Q,Y){zY(sU,arguments,Y)};j.getItem=function($,J,X,Q){return zY(rU,arguments,Q)};j.removeItem=function($,J,X,Q){zY(tU,arguments,Q)};j.clearItems=function($,J,X){zY(eU,arguments,X)};j.isEmpty=function($){for(var J in $)if($.hasOwnProperty(J))return!1;return!0};j.format=function($){var J=/%./g,X,Q,Y=0,G=[],W=0;while(X=J.exec($)){if(Q=$.substring(W,J.lastIndex-2),Q.length>0)G.push(Q);W=J.lastIndex;var U=X[0][1];switch(U){case"s":case"o":if(Y<arguments.length)G.push(arguments[Y+++1]);else G.push("<?>");break;case"%":G.push("%");break;default:G.push("<%"+U+"?>")}}return G.push($.substring(W)),G.join("")};j.formatNumber=function($,J,X,Q){var Y=$,G=isNaN(J=Math.abs(J))?2:J,W=X===void 0?",":X,U=Q===void 0?".":Q,M=Y<0?"-":"",O=parseInt(Y=Math.abs(+Y||0).toFixed(G),10)+"",V=O.length>3?O.length%3:0;return M+(V?O.substr(0,V)+U:"")+O.substr(V).replace(/(\d{3})(?=\d)/g,"$1"+U)+(G?W+Math.abs(Y-O).toFixed(G).slice(2):"")};j.formatSize=function($){if($>=1073741824)$=j.formatNumber($/1073741824,2,".","")+" GiB";else if($>=1048576)$=j.formatNumber($/1048576,2,".","")+" MiB";else if($>=1024)$=j.formatNumber($/1024,0)+" KiB";else $=j.formatNumber($,0)+" bytes";return $};j.bytesFromIP=function($){if($.indexOf(".")!==-1)return j.bytesFromIPv4($);if($.indexOf(":")!==-1)return j.bytesFromIPv6($);return null};j.bytesFromIPv4=function($){if($=$.split("."),$.length!==4)return null;var J=j.createBuffer();for(var X=0;X<$.length;++X){var Q=parseInt($[X],10);if(isNaN(Q))return null;J.putByte(Q)}return J.getBytes()};j.bytesFromIPv6=function($){var J=0;$=$.split(":").filter(function(W){if(W.length===0)++J;return!0});var X=(8-$.length+J)*2,Q=j.createBuffer();for(var Y=0;Y<8;++Y){if(!$[Y]||$[Y].length===0){Q.fillWithByte(0,X),X=0;continue}var G=j.hexToBytes($[Y]);if(G.length<2)Q.putByte(0);Q.putBytes(G)}return Q.getBytes()};j.bytesToIP=function($){if($.length===4)return j.bytesToIPv4($);if($.length===16)return j.bytesToIPv6($);return null};j.bytesToIPv4=function($){if($.length!==4)return null;var J=[];for(var X=0;X<$.length;++X)J.push($.charCodeAt(X));return J.join(".")};j.bytesToIPv6=function($){if($.length!==16)return null;var J=[],X=[],Q=0;for(var Y=0;Y<$.length;Y+=2){var G=j.bytesToHex($[Y]+$[Y+1]);while(G[0]==="0"&&G!=="0")G=G.substr(1);if(G==="0"){var W=X[X.length-1],U=J.length;if(!W||U!==W.end+1)X.push({start:U,end:U});else if(W.end=U,W.end-W.start>X[Q].end-X[Q].start)Q=X.length-1}J.push(G)}if(X.length>0){var M=X[Q];if(M.end-M.start>0){if(J.splice(M.start,M.end-M.start+1,""),M.start===0)J.unshift("");if(M.end===7)J.push("")}}return J.join(":")};j.estimateCores=function($,J){if(typeof $==="function")J=$,$={};if($=$||{},"cores"in j&&!$.update)return J(null,j.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return j.cores=navigator.hardwareConcurrency,J(null,j.cores);if(typeof Worker>"u")return j.cores=1,J(null,j.cores);if(typeof Blob>"u")return j.cores=2,J(null,j.cores);var X=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(W){var U=Date.now(),M=U+4;while(Date.now()<M);self.postMessage({st:U,et:M})})}.toString(),")()"],{type:"application/javascript"}));Q([],5,16);function Q(W,U,M){if(U===0){var O=Math.floor(W.reduce(function(V,H){return V+H},0)/W.length);return j.cores=Math.max(1,O),URL.revokeObjectURL(X),J(null,j.cores)}Y(M,function(V,H){W.push(G(M,H)),Q(W,U-1,M)})}function Y(W,U){var M=[],O=[];for(var V=0;V<W;++V){var H=new Worker(X);H.addEventListener("message",function(q){if(O.push(q.data),O.length===W){for(var F=0;F<W;++F)M[F].terminate();U(null,O)}}),M.push(H)}for(var V=0;V<W;++V)M[V].postMessage(V)}function G(W,U){var M=[];for(var O=0;O<W;++O){var V=U[O],H=M[O]=[];for(var q=0;q<W;++q){if(O===q)continue;var F=U[q];if(V.st>F.st&&V.st<F.et||F.st>V.st&&F.st<V.et)H.push(q)}}return M.reduce(function(K,A){return Math.max(K,A.length)},0)}}});var EY=O$((tE,BG)=>{var MJ=z$();w$();BG.exports=MJ.cipher=MJ.cipher||{};MJ.cipher.algorithms=MJ.cipher.algorithms||{};MJ.cipher.createCipher=function($,J){var X=$;if(typeof X==="string"){if(X=MJ.cipher.getAlgorithm(X),X)X=X()}if(!X)throw Error("Unsupported algorithm: "+$);return new MJ.cipher.BlockCipher({algorithm:X,key:J,decrypt:!1})};MJ.cipher.createDecipher=function($,J){var X=$;if(typeof X==="string"){if(X=MJ.cipher.getAlgorithm(X),X)X=X()}if(!X)throw Error("Unsupported algorithm: "+$);return new MJ.cipher.BlockCipher({algorithm:X,key:J,decrypt:!0})};MJ.cipher.registerAlgorithm=function($,J){$=$.toUpperCase(),MJ.cipher.algorithms[$]=J};MJ.cipher.getAlgorithm=function($){if($=$.toUpperCase(),$ in MJ.cipher.algorithms)return MJ.cipher.algorithms[$];return null};var i9=MJ.cipher.BlockCipher=function($){this.algorithm=$.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=$.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=$.decrypt,this.algorithm.initialize($)};i9.prototype.start=function($){$=$||{};var J={};for(var X in $)J[X]=$[X];J.decrypt=this._decrypt,this._finish=!1,this._input=MJ.util.createBuffer(),this.output=$.output||MJ.util.createBuffer(),this.mode.start(J)};i9.prototype.update=function($){if($)this._input.putBuffer($);while(!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish);this._input.compact()};i9.prototype.finish=function($){if($&&(this.mode.name==="ECB"||this.mode.name==="CBC"))this.mode.pad=function(X){return $(this.blockSize,X,!1)},this.mode.unpad=function(X){return $(this.blockSize,X,!0)};var J={};if(J.decrypt=this._decrypt,J.overflow=this._input.length()%this.blockSize,!this._decrypt&&this.mode.pad){if(!this.mode.pad(this._input,J))return!1}if(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad){if(!this.mode.unpad(this.output,J))return!1}if(this.mode.afterFinish){if(!this.mode.afterFinish(this.output,J))return!1}return!0}});var a9=O$((eE,jG)=>{var OJ=z$();w$();OJ.cipher=OJ.cipher||{};var A$=jG.exports=OJ.cipher.modes=OJ.cipher.modes||{};A$.ecb=function($){$=$||{},this.name="ECB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)};A$.ecb.prototype.start=function($){};A$.ecb.prototype.encrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q])};A$.ecb.prototype.decrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q])};A$.ecb.prototype.pad=function($,J){var X=$.length()===this.blockSize?this.blockSize:this.blockSize-$.length();return $.fillWithByte(X,X),!0};A$.ecb.prototype.unpad=function($,J){if(J.overflow>0)return!1;var X=$.length(),Q=$.at(X-1);if(Q>this.blockSize<<2)return!1;return $.truncate(Q),!0};A$.cbc=function($){$=$||{},this.name="CBC",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)};A$.cbc.prototype.start=function($){if($.iv===null){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if(!("iv"in $))throw Error("Invalid IV parameter.");else this._iv=FY($.iv,this.blockSize),this._prev=this._iv.slice(0)};A$.cbc.prototype.encrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=this._prev[Q]^$.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._outBlock[Q]);this._prev=this._outBlock};A$.cbc.prototype.decrypt=function($,J,X){if($.length()<this.blockSize&&!(X&&$.length()>0))return!0;for(var Q=0;Q<this._ints;++Q)this._inBlock[Q]=$.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var Q=0;Q<this._ints;++Q)J.putInt32(this._prev[Q]^this._outBlock[Q]);this._prev=this._inBlock.slice(0)};A$.cbc.prototype.pad=function($,J){var X=$.length()===this.blockSize?this.blockSize:this.blockSize-$.length();return $.fillWithByte(X,X),!0};A$.cbc.prototype.unpad=function($,J){if(J.overflow>0)return!1;var X=$.length(),Q=$.at(X-1);if(Q>this.blockSize<<2)return!1;return $.truncate(Q),!0};A$.cfb=function($){$=$||{},this.name="CFB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=OJ.util.createBuffer(),this._partialBytes=0};A$.cfb.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=FY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};A$.cfb.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=$.getInt32()^this._outBlock[Y],J.putInt32(this._inBlock[Y]);return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialBlock[Y]=$.getInt32()^this._outBlock[Y],this._partialOutput.putInt32(this._partialBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._partialBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};A$.cfb.prototype.decrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=$.getInt32(),J.putInt32(this._inBlock[Y]^this._outBlock[Y]);return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialBlock[Y]=$.getInt32(),this._partialOutput.putInt32(this._partialBlock[Y]^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._partialBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};A$.ofb=function($){$=$||{},this.name="OFB",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=OJ.util.createBuffer(),this._partialBytes=0};A$.ofb.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=FY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};A$.ofb.prototype.encrypt=function($,J,X){var Q=$.length();if($.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)J.putInt32($.getInt32()^this._outBlock[Y]),this._inBlock[Y]=this._outBlock[Y];return}var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;else for(var Y=0;Y<this._ints;++Y)this._inBlock[Y]=this._outBlock[Y];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0};A$.ofb.prototype.decrypt=A$.ofb.prototype.encrypt;A$.ctr=function($){$=$||{},this.name="CTR",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=OJ.util.createBuffer(),this._partialBytes=0};A$.ctr.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");this._iv=FY($.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};A$.ctr.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize)for(var Y=0;Y<this._ints;++Y)J.putInt32($.getInt32()^this._outBlock[Y]);else{var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G>0)$.read-=this.blockSize;if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0}NY(this._inBlock)};A$.ctr.prototype.decrypt=A$.ctr.prototype.encrypt;A$.gcm=function($){$=$||{},this.name="GCM",this.cipher=$.cipher,this.blockSize=$.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=OJ.util.createBuffer(),this._partialBytes=0,this._R=3774873600};A$.gcm.prototype.start=function($){if(!("iv"in $))throw Error("Invalid IV parameter.");var J=OJ.util.createBuffer($.iv);this._cipherLength=0;var X;if("additionalData"in $)X=OJ.util.createBuffer($.additionalData);else X=OJ.util.createBuffer();if("tagLength"in $)this._tagLength=$.tagLength;else this._tagLength=128;if(this._tag=null,$.decrypt){if(this._tag=OJ.util.createBuffer($.tag).getBytes(),this._tag.length!==this._tagLength/8)throw Error("Authentication tag does not match tag length.")}this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var Q=J.length();if(Q===12)this._j0=[J.getInt32(),J.getInt32(),J.getInt32(),1];else{this._j0=[0,0,0,0];while(J.length()>0)this._j0=this.ghash(this._hashSubkey,this._j0,[J.getInt32(),J.getInt32(),J.getInt32(),J.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(o9(Q*8)))}this._inBlock=this._j0.slice(0),NY(this._inBlock),this._partialBytes=0,X=OJ.util.createBuffer(X),this._aDataLength=o9(X.length()*8);var Y=X.length()%this.blockSize;if(Y)X.fillWithByte(0,this.blockSize-Y);this._s=[0,0,0,0];while(X.length()>0)this._s=this.ghash(this._hashSubkey,this._s,[X.getInt32(),X.getInt32(),X.getInt32(),X.getInt32()])};A$.gcm.prototype.encrypt=function($,J,X){var Q=$.length();if(Q===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&Q>=this.blockSize){for(var Y=0;Y<this._ints;++Y)J.putInt32(this._outBlock[Y]^=$.getInt32());this._cipherLength+=this.blockSize}else{var G=(this.blockSize-Q)%this.blockSize;if(G>0)G=this.blockSize-G;this._partialOutput.clear();for(var Y=0;Y<this._ints;++Y)this._partialOutput.putInt32($.getInt32()^this._outBlock[Y]);if(G<=0||X){if(X){var W=Q%this.blockSize;this._cipherLength+=W,this._partialOutput.truncate(this.blockSize-W)}else this._cipherLength+=this.blockSize;for(var Y=0;Y<this._ints;++Y)this._outBlock[Y]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(G>0&&!X)return $.read-=this.blockSize,J.putBytes(this._partialOutput.getBytes(G-this._partialBytes)),this._partialBytes=G,!0;J.putBytes(this._partialOutput.getBytes(Q-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),NY(this._inBlock)};A$.gcm.prototype.decrypt=function($,J,X){var Q=$.length();if(Q<this.blockSize&&!(X&&Q>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),NY(this._inBlock),this._hashBlock[0]=$.getInt32(),this._hashBlock[1]=$.getInt32(),this._hashBlock[2]=$.getInt32(),this._hashBlock[3]=$.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var Y=0;Y<this._ints;++Y)J.putInt32(this._outBlock[Y]^this._hashBlock[Y]);if(Q<this.blockSize)this._cipherLength+=Q%this.blockSize;else this._cipherLength+=this.blockSize};A$.gcm.prototype.afterFinish=function($,J){var X=!0;if(J.decrypt&&J.overflow)$.truncate(this.blockSize-J.overflow);this.tag=OJ.util.createBuffer();var Q=this._aDataLength.concat(o9(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,Q);var Y=[];this.cipher.encrypt(this._j0,Y);for(var G=0;G<this._ints;++G)this.tag.putInt32(this._s[G]^Y[G]);if(this.tag.truncate(this.tag.length()%(this._tagLength/8)),J.decrypt&&this.tag.bytes()!==this._tag)X=!1;return X};A$.gcm.prototype.multiply=function($,J){var X=[0,0,0,0],Q=J.slice(0);for(var Y=0;Y<128;++Y){var G=$[Y/32|0]&1<<31-Y%32;if(G)X[0]^=Q[0],X[1]^=Q[1],X[2]^=Q[2],X[3]^=Q[3];this.pow(Q,Q)}return X};A$.gcm.prototype.pow=function($,J){var X=$[3]&1;for(var Q=3;Q>0;--Q)J[Q]=$[Q]>>>1|($[Q-1]&1)<<31;if(J[0]=$[0]>>>1,X)J[0]^=this._R};A$.gcm.prototype.tableMultiply=function($){var J=[0,0,0,0];for(var X=0;X<32;++X){var Q=X/8|0,Y=$[Q]>>>(7-X%8)*4&15,G=this._m[X][Y];J[0]^=G[0],J[1]^=G[1],J[2]^=G[2],J[3]^=G[3]}return J};A$.gcm.prototype.ghash=function($,J,X){return J[0]^=X[0],J[1]^=X[1],J[2]^=X[2],J[3]^=X[3],this.tableMultiply(J)};A$.gcm.prototype.generateHashTable=function($,J){var X=8/J,Q=4*X,Y=16*X,G=Array(Y);for(var W=0;W<Y;++W){var U=[0,0,0,0],M=W/Q|0,O=(Q-1-W%Q)*J;U[M]=1<<J-1<<O,G[W]=this.generateSubHashTable(this.multiply(U,$),J)}return G};A$.gcm.prototype.generateSubHashTable=function($,J){var X=1<<J,Q=X>>>1,Y=Array(X);Y[Q]=$.slice(0);var G=Q>>>1;while(G>0)this.pow(Y[2*G],Y[G]=[]),G>>=1;G=2;while(G<Q){for(var W=1;W<G;++W){var U=Y[G],M=Y[W];Y[G+W]=[U[0]^M[0],U[1]^M[1],U[2]^M[2],U[3]^M[3]]}G*=2}Y[0]=[0,0,0,0];for(G=Q+1;G<X;++G){var O=Y[G^Q];Y[G]=[$[0]^O[0],$[1]^O[1],$[2]^O[2],$[3]^O[3]]}return Y};function FY($,J){if(typeof $==="string")$=OJ.util.createBuffer($);if(OJ.util.isArray($)&&$.length>4){var X=$;$=OJ.util.createBuffer();for(var Q=0;Q<X.length;++Q)$.putByte(X[Q])}if($.length()<J)throw Error("Invalid IV length; got "+$.length()+" bytes and expected "+J+" bytes.");if(!OJ.util.isArray($)){var Y=[],G=J/4;for(var Q=0;Q<G;++Q)Y.push($.getInt32());$=Y}return $}function NY($){$[$.length-1]=$[$.length-1]+1&4294967295}function o9($){return[$/4294967296|0,$&4294967295]}});var w0=O$(($F,CG)=>{var m$=z$();EY();a9();w$();CG.exports=m$.aes=m$.aes||{};m$.aes.startEncrypting=function($,J,X,Q){var Y=LY({key:$,output:X,decrypt:!1,mode:Q});return Y.start(J),Y};m$.aes.createEncryptionCipher=function($,J){return LY({key:$,output:null,decrypt:!1,mode:J})};m$.aes.startDecrypting=function($,J,X,Q){var Y=LY({key:$,output:X,decrypt:!0,mode:Q});return Y.start(J),Y};m$.aes.createDecryptionCipher=function($,J){return LY({key:$,output:null,decrypt:!0,mode:J})};m$.aes.Algorithm=function($,J){if(!t9)SG();var X=this;X.name=$,X.mode=new J({blockSize:16,cipher:{encrypt:function(Q,Y){return r9(X._w,Q,Y,!1)},decrypt:function(Q,Y){return r9(X._w,Q,Y,!0)}}}),X._init=!1};m$.aes.Algorithm.prototype.initialize=function($){if(this._init)return;var J=$.key,X;if(typeof J==="string"&&(J.length===16||J.length===24||J.length===32))J=m$.util.createBuffer(J);else if(m$.util.isArray(J)&&(J.length===16||J.length===24||J.length===32)){X=J,J=m$.util.createBuffer();for(var Q=0;Q<X.length;++Q)J.putByte(X[Q])}if(!m$.util.isArray(J)){X=J,J=[];var Y=X.length();if(Y===16||Y===24||Y===32){Y=Y>>>2;for(var Q=0;Q<Y;++Q)J.push(X.getInt32())}}if(!m$.util.isArray(J)||!(J.length===4||J.length===6||J.length===8))throw Error("Invalid key parameter.");var G=this.mode.name,W=["CFB","OFB","CTR","GCM"].indexOf(G)!==-1;this._w=IG(J,$.decrypt&&!W),this._init=!0};m$.aes._expandKey=function($,J){if(!t9)SG();return IG($,J)};m$.aes._updateBlock=r9;jQ("AES-ECB",m$.cipher.modes.ecb);jQ("AES-CBC",m$.cipher.modes.cbc);jQ("AES-CFB",m$.cipher.modes.cfb);jQ("AES-OFB",m$.cipher.modes.ofb);jQ("AES-CTR",m$.cipher.modes.ctr);jQ("AES-GCM",m$.cipher.modes.gcm);function jQ($,J){var X=function(){return new m$.aes.Algorithm($,J)};m$.cipher.registerAlgorithm($,X)}var t9=!1,BQ=4,LJ,s9,TG,$Q,gJ;function SG(){t9=!0,TG=[0,1,2,4,8,16,32,64,128,27,54];var $=Array(256);for(var J=0;J<128;++J)$[J]=J<<1,$[J+128]=J+128<<1^283;LJ=Array(256),s9=Array(256),$Q=[,,,,],gJ=[,,,,];for(var J=0;J<4;++J)$Q[J]=Array(256),gJ[J]=Array(256);var X=0,Q=0,Y,G,W,U,M,O,V;for(var J=0;J<256;++J){U=Q^Q<<1^Q<<2^Q<<3^Q<<4,U=U>>8^U&255^99,LJ[X]=U,s9[U]=X,M=$[U],Y=$[X],G=$[Y],W=$[G],O=M<<24^U<<16^U<<8^(U^M),V=(Y^G^W)<<24^(X^W)<<16^(X^G^W)<<8^(X^Y^W);for(var H=0;H<4;++H)$Q[H][X]=O,gJ[H][U]=V,O=O<<24|O>>>8,V=V<<24|V>>>8;if(X===0)X=Q=1;else X=Y^$[$[$[Y^W]]],Q^=$[$[Q]]}}function IG($,J){var X=$.slice(0),Q,Y=1,G=X.length,W=G+6+1,U=BQ*W;for(var M=G;M<U;++M){if(Q=X[M-1],M%G===0)Q=LJ[Q>>>16&255]<<24^LJ[Q>>>8&255]<<16^LJ[Q&255]<<8^LJ[Q>>>24]^TG[Y]<<24,Y++;else if(G>6&&M%G===4)Q=LJ[Q>>>24]<<24^LJ[Q>>>16&255]<<16^LJ[Q>>>8&255]<<8^LJ[Q&255];X[M]=X[M-G]^Q}if(J){var O,V=gJ[0],H=gJ[1],q=gJ[2],F=gJ[3],K=X.slice(0);U=X.length;for(var M=0,A=U-BQ;M<U;M+=BQ,A-=BQ)if(M===0||M===U-BQ)K[M]=X[A],K[M+1]=X[A+3],K[M+2]=X[A+2],K[M+3]=X[A+1];else for(var L=0;L<BQ;++L)O=X[A+L],K[M+(3&-L)]=V[LJ[O>>>24]]^H[LJ[O>>>16&255]]^q[LJ[O>>>8&255]]^F[LJ[O&255]];X=K}return X}function r9($,J,X,Q){var Y=$.length/4-1,G,W,U,M,O;if(Q)G=gJ[0],W=gJ[1],U=gJ[2],M=gJ[3],O=s9;else G=$Q[0],W=$Q[1],U=$Q[2],M=$Q[3],O=LJ;var V,H,q,F,K,A,L;V=J[0]^$[0],H=J[Q?3:1]^$[1],q=J[2]^$[2],F=J[Q?1:3]^$[3];var R=3;for(var I=1;I<Y;++I)K=G[V>>>24]^W[H>>>16&255]^U[q>>>8&255]^M[F&255]^$[++R],A=G[H>>>24]^W[q>>>16&255]^U[F>>>8&255]^M[V&255]^$[++R],L=G[q>>>24]^W[F>>>16&255]^U[V>>>8&255]^M[H&255]^$[++R],F=G[F>>>24]^W[V>>>16&255]^U[H>>>8&255]^M[q&255]^$[++R],V=K,H=A,q=L;X[0]=O[V>>>24]<<24^O[H>>>16&255]<<16^O[q>>>8&255]<<8^O[F&255]^$[++R],X[Q?3:1]=O[H>>>24]<<24^O[q>>>16&255]<<16^O[F>>>8&255]<<8^O[V&255]^$[++R],X[2]=O[q>>>24]<<24^O[F>>>16&255]<<16^O[V>>>8&255]<<8^O[H&255]^$[++R],X[Q?1:3]=O[F>>>24]<<24^O[V>>>16&255]<<16^O[H>>>8&255]<<8^O[q&255]^$[++R]}function LY($){$=$||{};var J=($.mode||"CBC").toUpperCase(),X="AES-"+J,Q;if($.decrypt)Q=m$.cipher.createDecipher(X,$.key);else Q=m$.cipher.createCipher(X,$.key);var Y=Q.start;return Q.start=function(G,W){var U=null;if(W instanceof m$.util.ByteBuffer)U=W,W={};W=W||{},W.output=U,W.iv=G,Y.call(Q,W)},Q}});var P0=O$((JF,wG)=>{var FX=z$();FX.pki=FX.pki||{};var e9=wG.exports=FX.pki.oids=FX.oids=FX.oids||{};function h($,J){e9[$]=J,e9[J]=$}function k$($,J){e9[$]=J}h("1.2.840.113549.1.1.1","rsaEncryption");h("1.2.840.113549.1.1.4","md5WithRSAEncryption");h("1.2.840.113549.1.1.5","sha1WithRSAEncryption");h("1.2.840.113549.1.1.7","RSAES-OAEP");h("1.2.840.113549.1.1.8","mgf1");h("1.2.840.113549.1.1.9","pSpecified");h("1.2.840.113549.1.1.10","RSASSA-PSS");h("1.2.840.113549.1.1.11","sha256WithRSAEncryption");h("1.2.840.113549.1.1.12","sha384WithRSAEncryption");h("1.2.840.113549.1.1.13","sha512WithRSAEncryption");h("1.3.101.112","EdDSA25519");h("1.2.840.10040.4.3","dsa-with-sha1");h("1.3.14.3.2.7","desCBC");h("1.3.14.3.2.26","sha1");h("1.3.14.3.2.29","sha1WithRSASignature");h("2.16.840.1.101.3.4.2.1","sha256");h("2.16.840.1.101.3.4.2.2","sha384");h("2.16.840.1.101.3.4.2.3","sha512");h("2.16.840.1.101.3.4.2.4","sha224");h("2.16.840.1.101.3.4.2.5","sha512-224");h("2.16.840.1.101.3.4.2.6","sha512-256");h("1.2.840.113549.2.2","md2");h("1.2.840.113549.2.5","md5");h("1.2.840.113549.1.7.1","data");h("1.2.840.113549.1.7.2","signedData");h("1.2.840.113549.1.7.3","envelopedData");h("1.2.840.113549.1.7.4","signedAndEnvelopedData");h("1.2.840.113549.1.7.5","digestedData");h("1.2.840.113549.1.7.6","encryptedData");h("1.2.840.113549.1.9.1","emailAddress");h("1.2.840.113549.1.9.2","unstructuredName");h("1.2.840.113549.1.9.3","contentType");h("1.2.840.113549.1.9.4","messageDigest");h("1.2.840.113549.1.9.5","signingTime");h("1.2.840.113549.1.9.6","counterSignature");h("1.2.840.113549.1.9.7","challengePassword");h("1.2.840.113549.1.9.8","unstructuredAddress");h("1.2.840.113549.1.9.14","extensionRequest");h("1.2.840.113549.1.9.20","friendlyName");h("1.2.840.113549.1.9.21","localKeyId");h("1.2.840.113549.1.9.22.1","x509Certificate");h("1.2.840.113549.1.12.10.1.1","keyBag");h("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");h("1.2.840.113549.1.12.10.1.3","certBag");h("1.2.840.113549.1.12.10.1.4","crlBag");h("1.2.840.113549.1.12.10.1.5","secretBag");h("1.2.840.113549.1.12.10.1.6","safeContentsBag");h("1.2.840.113549.1.5.13","pkcs5PBES2");h("1.2.840.113549.1.5.12","pkcs5PBKDF2");h("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");h("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");h("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");h("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");h("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");h("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");h("1.2.840.113549.2.7","hmacWithSHA1");h("1.2.840.113549.2.8","hmacWithSHA224");h("1.2.840.113549.2.9","hmacWithSHA256");h("1.2.840.113549.2.10","hmacWithSHA384");h("1.2.840.113549.2.11","hmacWithSHA512");h("1.2.840.113549.3.7","des-EDE3-CBC");h("2.16.840.1.101.3.4.1.2","aes128-CBC");h("2.16.840.1.101.3.4.1.22","aes192-CBC");h("2.16.840.1.101.3.4.1.42","aes256-CBC");h("2.5.4.3","commonName");h("2.5.4.4","surname");h("2.5.4.5","serialNumber");h("2.5.4.6","countryName");h("2.5.4.7","localityName");h("2.5.4.8","stateOrProvinceName");h("2.5.4.9","streetAddress");h("2.5.4.10","organizationName");h("2.5.4.11","organizationalUnitName");h("2.5.4.12","title");h("2.5.4.13","description");h("2.5.4.15","businessCategory");h("2.5.4.17","postalCode");h("2.5.4.42","givenName");h("2.5.4.65","pseudonym");h("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");h("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");h("2.16.840.1.113730.1.1","nsCertType");h("2.16.840.1.113730.1.13","nsComment");k$("2.5.29.1","authorityKeyIdentifier");k$("2.5.29.2","keyAttributes");k$("2.5.29.3","certificatePolicies");k$("2.5.29.4","keyUsageRestriction");k$("2.5.29.5","policyMapping");k$("2.5.29.6","subtreesConstraint");k$("2.5.29.7","subjectAltName");k$("2.5.29.8","issuerAltName");k$("2.5.29.9","subjectDirectoryAttributes");k$("2.5.29.10","basicConstraints");k$("2.5.29.11","nameConstraints");k$("2.5.29.12","policyConstraints");k$("2.5.29.13","basicConstraints");h("2.5.29.14","subjectKeyIdentifier");h("2.5.29.15","keyUsage");k$("2.5.29.16","privateKeyUsagePeriod");h("2.5.29.17","subjectAltName");h("2.5.29.18","issuerAltName");h("2.5.29.19","basicConstraints");k$("2.5.29.20","cRLNumber");k$("2.5.29.21","cRLReason");k$("2.5.29.22","expirationDate");k$("2.5.29.23","instructionCode");k$("2.5.29.24","invalidityDate");k$("2.5.29.25","cRLDistributionPoints");k$("2.5.29.26","issuingDistributionPoint");k$("2.5.29.27","deltaCRLIndicator");k$("2.5.29.28","issuingDistributionPoint");k$("2.5.29.29","certificateIssuer");k$("2.5.29.30","nameConstraints");h("2.5.29.31","cRLDistributionPoints");h("2.5.29.32","certificatePolicies");k$("2.5.29.33","policyMappings");k$("2.5.29.34","policyConstraints");h("2.5.29.35","authorityKeyIdentifier");k$("2.5.29.36","policyConstraints");h("2.5.29.37","extKeyUsage");k$("2.5.29.46","freshestCRL");k$("2.5.29.54","inhibitAnyPolicy");h("1.3.6.1.4.1.11129.2.4.2","timestampList");h("1.3.6.1.5.5.7.1.1","authorityInfoAccess");h("1.3.6.1.5.5.7.3.1","serverAuth");h("1.3.6.1.5.5.7.3.2","clientAuth");h("1.3.6.1.5.5.7.3.3","codeSigning");h("1.3.6.1.5.5.7.3.4","emailProtection");h("1.3.6.1.5.5.7.3.8","timeStamping")});var mJ=O$((QF,_G)=>{var p$=z$();w$();P0();var c=_G.exports=p$.asn1=p$.asn1||{};c.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};c.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};c.maxDepth=256;c.create=function($,J,X,Q,Y){if(p$.util.isArray(Q)){var G=[];for(var W=0;W<Q.length;++W)if(Q[W]!==void 0)G.push(Q[W]);Q=G}var U={tagClass:$,type:J,constructed:X,composed:X||p$.util.isArray(Q),value:Q};if(Y&&"bitStringContents"in Y)U.bitStringContents=Y.bitStringContents,U.original=c.copy(U);return U};c.copy=function($,J){var X;if(p$.util.isArray($)){X=[];for(var Q=0;Q<$.length;++Q)X.push(c.copy($[Q],J));return X}if(typeof $==="string")return $;if(X={tagClass:$.tagClass,type:$.type,constructed:$.constructed,composed:$.composed,value:c.copy($.value,J)},J&&!J.excludeBitStringContents)X.bitStringContents=$.bitStringContents;return X};c.equals=function($,J,X){if(p$.util.isArray($)){if(!p$.util.isArray(J))return!1;if($.length!==J.length)return!1;for(var Q=0;Q<$.length;++Q)if(!c.equals($[Q],J[Q]))return!1;return!0}if(typeof $!==typeof J)return!1;if(typeof $==="string")return $===J;var Y=$.tagClass===J.tagClass&&$.type===J.type&&$.constructed===J.constructed&&$.composed===J.composed&&c.equals($.value,J.value);if(X&&X.includeBitStringContents)Y=Y&&$.bitStringContents===J.bitStringContents;return Y};c.getBerValueLength=function($){var J=$.getByte();if(J===128)return;var X,Q=J&128;if(!Q)X=J;else X=$.getInt((J&127)<<3);return X};function NX($,J,X){if(X>J){var Q=Error("Too few bytes to parse DER.");throw Q.available=$.length(),Q.remaining=J,Q.requested=X,Q}}var $M=function($,J){var X=$.getByte();if(J--,X===128)return;var Q,Y=X&128;if(!Y)Q=X;else{var G=X&127;NX($,J,G),Q=$.getInt(G<<3)}if(Q<0)throw Error("Negative length: "+Q);return Q};c.fromDer=function($,J){if(J===void 0)J={strict:!0,parseAllBytes:!0,decodeBitStrings:!0};if(typeof J==="boolean")J={strict:J,parseAllBytes:!0,decodeBitStrings:!0};if(!("strict"in J))J.strict=!0;if(!("parseAllBytes"in J))J.parseAllBytes=!0;if(!("decodeBitStrings"in J))J.decodeBitStrings=!0;if(!("maxDepth"in J))J.maxDepth=c.maxDepth;if(typeof $==="string")$=p$.util.createBuffer($);var X=$.length(),Q=AY($,$.length(),0,J);if(J.parseAllBytes&&$.length()!==0){var Y=Error("Unparsed DER bytes remain after ASN.1 parsing.");throw Y.byteCount=X,Y.remaining=$.length(),Y}return Q};function AY($,J,X,Q){if(X>=Q.maxDepth)throw Error("ASN.1 parsing error: Max depth exceeded.");var Y;NX($,J,2);var G=$.getByte();J--;var W=G&192,U=G&31;Y=$.length();var M=$M($,J);if(J-=Y-$.length(),M!==void 0&&M>J){if(Q.strict){var O=Error("Too few bytes to read ASN.1 value.");throw O.available=$.length(),O.remaining=J,O.requested=M,O}M=J}var V,H,q=(G&32)===32;if(q)if(V=[],M===void 0)for(;;){if(NX($,J,2),$.bytes(2)===String.fromCharCode(0,0)){$.getBytes(2),J-=2;break}Y=$.length(),V.push(AY($,J,X+1,Q)),J-=Y-$.length()}else while(M>0)Y=$.length(),V.push(AY($,M,X+1,Q)),J-=Y-$.length(),M-=Y-$.length();if(V===void 0&&W===c.Class.UNIVERSAL&&U===c.Type.BITSTRING)H=$.bytes(M);if(V===void 0&&Q.decodeBitStrings&&W===c.Class.UNIVERSAL&&U===c.Type.BITSTRING&&M>1){var F=$.read,K=J,A=0;if(U===c.Type.BITSTRING)NX($,J,1),A=$.getByte(),J--;if(A===0)try{Y=$.length();var L={strict:!0,decodeBitStrings:!0},R=AY($,J,X+1,L),I=Y-$.length();if(J-=I,U==c.Type.BITSTRING)I++;var T=R.tagClass;if(I===M&&(T===c.Class.UNIVERSAL||T===c.Class.CONTEXT_SPECIFIC))V=[R]}catch(w){}if(V===void 0)$.read=F,J=K}if(V===void 0){if(M===void 0){if(Q.strict)throw Error("Non-constructed ASN.1 object of indefinite length.");M=J}if(U===c.Type.BMPSTRING){V="";for(;M>0;M-=2)NX($,J,2),V+=String.fromCharCode($.getInt16()),J-=2}else V=$.getBytes(M),J-=M}var C=H===void 0?null:{bitStringContents:H};return c.create(W,U,q,V,C)}c.toDer=function($){var J=p$.util.createBuffer(),X=$.tagClass|$.type,Q=p$.util.createBuffer(),Y=!1;if("bitStringContents"in $){if(Y=!0,$.original)Y=c.equals($,$.original)}if(Y)Q.putBytes($.bitStringContents);else if($.composed){if($.constructed)X|=32;else Q.putByte(0);for(var G=0;G<$.value.length;++G)if($.value[G]!==void 0)Q.putBuffer(c.toDer($.value[G]))}else if($.type===c.Type.BMPSTRING)for(var G=0;G<$.value.length;++G)Q.putInt16($.value.charCodeAt(G));else if($.type===c.Type.INTEGER&&$.value.length>1&&($.value.charCodeAt(0)===0&&($.value.charCodeAt(1)&128)===0||$.value.charCodeAt(0)===255&&($.value.charCodeAt(1)&128)===128))Q.putBytes($.value.substr(1));else Q.putBytes($.value);if(J.putByte(X),Q.length()<=127)J.putByte(Q.length()&127);else{var W=Q.length(),U="";do U+=String.fromCharCode(W&255),W=W>>>8;while(W>0);J.putByte(U.length|128);for(var G=U.length-1;G>=0;--G)J.putByte(U.charCodeAt(G))}return J.putBuffer(Q),J};c.oidToDer=function($){var J=$.split("."),X=p$.util.createBuffer();X.putByte(40*parseInt(J[0],10)+parseInt(J[1],10));var Q,Y,G,W;for(var U=2;U<J.length;++U){if(Q=!0,Y=[],G=parseInt(J[U],10),G>4294967295)throw Error("OID value too large; max is 32-bits.");do{if(W=G&127,G=G>>>7,!Q)W|=128;Y.push(W),Q=!1}while(G>0);for(var M=Y.length-1;M>=0;--M)X.putByte(Y[M])}return X};c.derToOid=function($){var J;if(typeof $==="string")$=p$.util.createBuffer($);var X=$.getByte();J=Math.floor(X/40)+"."+X%40;var Q=0;while($.length()>0){if(Q>70368744177663)throw Error("OID value too large; max is 53-bits.");if(X=$.getByte(),Q=Q*128,X&128)Q+=X&127;else J+="."+(Q+X),Q=0}return J};c.utcTimeToDate=function($){var J=new Date,X=parseInt($.substr(0,2),10);X=X>=50?1900+X:2000+X;var Q=parseInt($.substr(2,2),10)-1,Y=parseInt($.substr(4,2),10),G=parseInt($.substr(6,2),10),W=parseInt($.substr(8,2),10),U=0;if($.length>11){var M=$.charAt(10),O=10;if(M!=="+"&&M!=="-")U=parseInt($.substr(10,2),10),O+=2}if(J.setUTCFullYear(X,Q,Y),J.setUTCHours(G,W,U,0),O){if(M=$.charAt(O),M==="+"||M==="-"){var V=parseInt($.substr(O+1,2),10),H=parseInt($.substr(O+4,2),10),q=V*60+H;if(q*=60000,M==="+")J.setTime(+J-q);else J.setTime(+J+q)}}return J};c.generalizedTimeToDate=function($){var J=new Date,X=parseInt($.substr(0,4),10),Q=parseInt($.substr(4,2),10)-1,Y=parseInt($.substr(6,2),10),G=parseInt($.substr(8,2),10),W=parseInt($.substr(10,2),10),U=parseInt($.substr(12,2),10),M=0,O=0,V=!1;if($.charAt($.length-1)==="Z")V=!0;var H=$.length-5,q=$.charAt(H);if(q==="+"||q==="-"){var F=parseInt($.substr(H+1,2),10),K=parseInt($.substr(H+4,2),10);if(O=F*60+K,O*=60000,q==="+")O*=-1;V=!0}if($.charAt(14)===".")M=parseFloat($.substr(14),10)*1000;if(V)J.setUTCFullYear(X,Q,Y),J.setUTCHours(G,W,U,M),J.setTime(+J+O);else J.setFullYear(X,Q,Y),J.setHours(G,W,U,M);return J};c.dateToUtcTime=function($){if(typeof $==="string")return $;var J="",X=[];X.push((""+$.getUTCFullYear()).substr(2)),X.push(""+($.getUTCMonth()+1)),X.push(""+$.getUTCDate()),X.push(""+$.getUTCHours()),X.push(""+$.getUTCMinutes()),X.push(""+$.getUTCSeconds());for(var Q=0;Q<X.length;++Q){if(X[Q].length<2)J+="0";J+=X[Q]}return J+="Z",J};c.dateToGeneralizedTime=function($){if(typeof $==="string")return $;var J="",X=[];X.push(""+$.getUTCFullYear()),X.push(""+($.getUTCMonth()+1)),X.push(""+$.getUTCDate()),X.push(""+$.getUTCHours()),X.push(""+$.getUTCMinutes()),X.push(""+$.getUTCSeconds());for(var Q=0;Q<X.length;++Q){if(X[Q].length<2)J+="0";J+=X[Q]}return J+="Z",J};c.integerToDer=function($){var J=p$.util.createBuffer();if($>=-128&&$<128)return J.putSignedInt($,8);if($>=-32768&&$<32768)return J.putSignedInt($,16);if($>=-8388608&&$<8388608)return J.putSignedInt($,24);if($>=-2147483648&&$<2147483648)return J.putSignedInt($,32);var X=Error("Integer too large; max is 32-bits.");throw X.integer=$,X};c.derToInteger=function($){if(typeof $==="string")$=p$.util.createBuffer($);var J=$.length()*8;if(J>32)throw Error("Integer too large; max is 32-bits.");return $.getSignedInt(J)};c.validate=function($,J,X,Q){var Y=!1;if(($.tagClass===J.tagClass||typeof J.tagClass>"u")&&($.type===J.type||typeof J.type>"u")){if($.constructed===J.constructed||typeof J.constructed>"u"){if(Y=!0,J.value&&p$.util.isArray(J.value)){var G=0;for(var W=0;Y&&W<J.value.length;++W){var U=J.value[W];Y=!!U.optional;var M=$.value[G];if(!M){if(!U.optional){if(Y=!1,Q)Q.push("["+J.name+'] Missing required element. Expected tag class "'+U.tagClass+'", type "'+U.type+'"')}continue}var O=typeof U.tagClass<"u"&&typeof U.type<"u";if(O&&(M.tagClass!==U.tagClass||M.type!==U.type))if(U.optional){Y=!0;continue}else{if(Y=!1,Q)Q.push("["+J.name+"] Tag mismatch. Expected ("+U.tagClass+","+U.type+"), got ("+M.tagClass+","+M.type+")");break}var V=c.validate(M,U,X,Q);if(V)++G,Y=!0;else if(U.optional)Y=!0;else{Y=!1;break}}}if(Y&&X){if(J.capture)X[J.capture]=$.value;if(J.captureAsn1)X[J.captureAsn1]=$;if(J.captureBitStringContents&&"bitStringContents"in $)X[J.captureBitStringContents]=$.bitStringContents;if(J.captureBitStringValue&&"bitStringContents"in $){var H;if($.bitStringContents.length<2)X[J.captureBitStringValue]="";else{var q=$.bitStringContents.charCodeAt(0);if(q!==0)throw Error("captureBitStringValue only supported for zero unused bits");X[J.captureBitStringValue]=$.bitStringContents.slice(1)}}}}else if(Q)Q.push("["+J.name+'] Expected constructed "'+J.constructed+'", got "'+$.constructed+'"')}else if(Q){if($.tagClass!==J.tagClass)Q.push("["+J.name+'] Expected tag class "'+J.tagClass+'", got "'+$.tagClass+'"');if($.type!==J.type)Q.push("["+J.name+'] Expected type "'+J.type+'", got "'+$.type+'"')}return Y};var PG=/[^\\u0000-\\u00ff]/;c.prettyPrint=function($,J,X){var Q="";if(J=J||0,X=X||2,J>0)Q+=`
|
|
6
|
+
`;var Y="";for(var G=0;G<J*X;++G)Y+=" ";switch(Q+=Y+"Tag: ",$.tagClass){case c.Class.UNIVERSAL:Q+="Universal:";break;case c.Class.APPLICATION:Q+="Application:";break;case c.Class.CONTEXT_SPECIFIC:Q+="Context-Specific:";break;case c.Class.PRIVATE:Q+="Private:";break}if($.tagClass===c.Class.UNIVERSAL)switch(Q+=$.type,$.type){case c.Type.NONE:Q+=" (None)";break;case c.Type.BOOLEAN:Q+=" (Boolean)";break;case c.Type.INTEGER:Q+=" (Integer)";break;case c.Type.BITSTRING:Q+=" (Bit string)";break;case c.Type.OCTETSTRING:Q+=" (Octet string)";break;case c.Type.NULL:Q+=" (Null)";break;case c.Type.OID:Q+=" (Object Identifier)";break;case c.Type.ODESC:Q+=" (Object Descriptor)";break;case c.Type.EXTERNAL:Q+=" (External or Instance of)";break;case c.Type.REAL:Q+=" (Real)";break;case c.Type.ENUMERATED:Q+=" (Enumerated)";break;case c.Type.EMBEDDED:Q+=" (Embedded PDV)";break;case c.Type.UTF8:Q+=" (UTF8)";break;case c.Type.ROID:Q+=" (Relative Object Identifier)";break;case c.Type.SEQUENCE:Q+=" (Sequence)";break;case c.Type.SET:Q+=" (Set)";break;case c.Type.PRINTABLESTRING:Q+=" (Printable String)";break;case c.Type.IA5String:Q+=" (IA5String (ASCII))";break;case c.Type.UTCTIME:Q+=" (UTC time)";break;case c.Type.GENERALIZEDTIME:Q+=" (Generalized time)";break;case c.Type.BMPSTRING:Q+=" (BMP String)";break}else Q+=$.type;if(Q+=`
|
|
7
7
|
`,Q+=Y+"Constructed: "+$.constructed+`
|
|
8
|
-
`,$.composed){var W=0,
|
|
9
|
-
`,Q;if($.procType)Q={name:"Proc-Type",values:[String($.procType.version),$.procType.type]},X+=
|
|
10
|
-
`;return X+=
|
|
8
|
+
`,$.composed){var W=0,U="";for(var G=0;G<$.value.length;++G)if($.value[G]!==void 0){if(W+=1,U+=c.prettyPrint($.value[G],J+1,X),G+1<$.value.length)U+=","}Q+=Y+"Sub values: "+W+U}else{if(Q+=Y+"Value: ",$.type===c.Type.OID){var M=c.derToOid($.value);if(Q+=M,p$.pki&&p$.pki.oids){if(M in p$.pki.oids)Q+=" ("+p$.pki.oids[M]+") "}}if($.type===c.Type.INTEGER)try{Q+=c.derToInteger($.value)}catch(V){Q+="0x"+p$.util.bytesToHex($.value)}else if($.type===c.Type.BITSTRING){if($.value.length>1)Q+="0x"+p$.util.bytesToHex($.value.slice(1));else Q+="(none)";if($.value.length>0){var O=$.value.charCodeAt(0);if(O==1)Q+=" (1 unused bit shown)";else if(O>1)Q+=" ("+O+" unused bits shown)"}}else if($.type===c.Type.OCTETSTRING){if(!PG.test($.value))Q+="("+$.value+") ";Q+="0x"+p$.util.bytesToHex($.value)}else if($.type===c.Type.UTF8)try{Q+=p$.util.decodeUtf8($.value)}catch(V){if(V.message==="URI malformed")Q+="0x"+p$.util.bytesToHex($.value)+" (malformed UTF8)";else throw V}else if($.type===c.Type.PRINTABLESTRING||$.type===c.Type.IA5String)Q+=$.value;else if(PG.test($.value))Q+="0x"+p$.util.bytesToHex($.value);else if($.value.length===0)Q+="[null]";else Q+=$.value}return Q}});var eJ=O$((XF,xG)=>{var RY=z$();xG.exports=RY.md=RY.md||{};RY.md.algorithms=RY.md.algorithms||{}});var TQ=O$((YF,vG)=>{var F0=z$();eJ();w$();var JM=vG.exports=F0.hmac=F0.hmac||{};JM.create=function(){var $=null,J=null,X=null,Q=null,Y={};return Y.start=function(G,W){if(G!==null)if(typeof G==="string")if(G=G.toLowerCase(),G in F0.md.algorithms)J=F0.md.algorithms[G].create();else throw Error('Unknown hash algorithm "'+G+'"');else J=G;if(W===null)W=$;else{if(typeof W==="string")W=F0.util.createBuffer(W);else if(F0.util.isArray(W)){var U=W;W=F0.util.createBuffer();for(var M=0;M<U.length;++M)W.putByte(U[M])}var O=W.length();if(O>J.blockLength)J.start(),J.update(W.bytes()),W=J.digest();X=F0.util.createBuffer(),Q=F0.util.createBuffer(),O=W.length();for(var M=0;M<O;++M){var U=W.at(M);X.putByte(54^U),Q.putByte(92^U)}if(O<J.blockLength){var U=J.blockLength-O;for(var M=0;M<U;++M)X.putByte(54),Q.putByte(92)}$=W,X=X.bytes(),Q=Q.bytes()}J.start(),J.update(X)},Y.update=function(G){J.update(G)},Y.getMac=function(){var G=J.digest().bytes();return J.start(),J.update(Q),J.update(G),J.digest()},Y.digest=Y.getMac,Y}});var ZY=O$((GF,bG)=>{var $0=z$();eJ();w$();var fG=bG.exports=$0.md5=$0.md5||{};$0.md.md5=$0.md.algorithms.md5=fG;fG.create=function(){if(!yG)QM();var $=null,J=$0.util.createBuffer(),X=Array(16),Q={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return Q.start=function(){Q.messageLength=0,Q.fullMessageLength=Q.messageLength64=[];var Y=Q.messageLengthSize/4;for(var G=0;G<Y;++G)Q.fullMessageLength.push(0);return J=$0.util.createBuffer(),$={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},Q},Q.start(),Q.update=function(Y,G){if(G==="utf8")Y=$0.util.encodeUtf8(Y);var W=Y.length;Q.messageLength+=W,W=[W/4294967296>>>0,W>>>0];for(var U=Q.fullMessageLength.length-1;U>=0;--U)Q.fullMessageLength[U]+=W[1],W[1]=W[0]+(Q.fullMessageLength[U]/4294967296>>>0),Q.fullMessageLength[U]=Q.fullMessageLength[U]>>>0,W[0]=W[1]/4294967296>>>0;if(J.putBytes(Y),kG($,X,J),J.read>2048||J.length()===0)J.compact();return Q},Q.digest=function(){var Y=$0.util.createBuffer();Y.putBytes(J.bytes());var G=Q.fullMessageLength[Q.fullMessageLength.length-1]+Q.messageLengthSize,W=G&Q.blockLength-1;Y.putBytes($8.substr(0,Q.blockLength-W));var U,M=0;for(var O=Q.fullMessageLength.length-1;O>=0;--O)U=Q.fullMessageLength[O]*8+M,M=U/4294967296>>>0,Y.putInt32Le(U>>>0);var V={h0:$.h0,h1:$.h1,h2:$.h2,h3:$.h3};kG(V,X,Y);var H=$0.util.createBuffer();return H.putInt32Le(V.h0),H.putInt32Le(V.h1),H.putInt32Le(V.h2),H.putInt32Le(V.h3),H},Q};var $8=null,DY=null,LX=null,SQ=null,yG=!1;function QM(){$8=String.fromCharCode(128),$8+=$0.util.fillString(String.fromCharCode(0),64),DY=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],LX=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],SQ=Array(64);for(var $=0;$<64;++$)SQ[$]=Math.floor(Math.abs(Math.sin($+1))*4294967296);yG=!0}function kG($,J,X){var Q,Y,G,W,U,M,O,V,H=X.length();while(H>=64){Y=$.h0,G=$.h1,W=$.h2,U=$.h3;for(V=0;V<16;++V)J[V]=X.getInt32Le(),M=U^G&(W^U),Q=Y+M+SQ[V]+J[V],O=LX[V],Y=U,U=W,W=G,G+=Q<<O|Q>>>32-O;for(;V<32;++V)M=W^U&(G^W),Q=Y+M+SQ[V]+J[DY[V]],O=LX[V],Y=U,U=W,W=G,G+=Q<<O|Q>>>32-O;for(;V<48;++V)M=G^W^U,Q=Y+M+SQ[V]+J[DY[V]],O=LX[V],Y=U,U=W,W=G,G+=Q<<O|Q>>>32-O;for(;V<64;++V)M=W^(G|~U),Q=Y+M+SQ[V]+J[DY[V]],O=LX[V],Y=U,U=W,W=G,G+=Q<<O|Q>>>32-O;$.h0=$.h0+Y|0,$.h1=$.h1+G|0,$.h2=$.h2+W|0,$.h3=$.h3+U|0,H-=64}}});var JQ=O$((WF,uG)=>{var jY=z$();w$();var hG=uG.exports=jY.pem=jY.pem||{};hG.encode=function($,J){J=J||{};var X="-----BEGIN "+$.type+`-----\r
|
|
9
|
+
`,Q;if($.procType)Q={name:"Proc-Type",values:[String($.procType.version),$.procType.type]},X+=BY(Q);if($.contentDomain)Q={name:"Content-Domain",values:[$.contentDomain]},X+=BY(Q);if($.dekInfo){if(Q={name:"DEK-Info",values:[$.dekInfo.algorithm]},$.dekInfo.parameters)Q.values.push($.dekInfo.parameters);X+=BY(Q)}if($.headers)for(var Y=0;Y<$.headers.length;++Y)X+=BY($.headers[Y]);if($.procType)X+=`\r
|
|
10
|
+
`;return X+=jY.util.encode64($.body,J.maxline||64)+`\r
|
|
11
11
|
`,X+="-----END "+$.type+`-----\r
|
|
12
|
-
`,X};
|
|
13
|
-
`;var G=0,W=-1;for(var Y=0;Y<J.length;++Y,++G)if(G>65&&W!==-1){var
|
|
12
|
+
`,X};hG.decode=function($){var J=[],X=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,Q=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,Y=/\r?\n/,G;while(!0){if(G=X.exec($),!G)break;var W=G[1];if(W==="NEW CERTIFICATE REQUEST")W="CERTIFICATE REQUEST";var U={type:W,procType:null,contentDomain:null,dekInfo:null,headers:[],body:jY.util.decode64(G[3])};if(J.push(U),!G[2])continue;var M=G[2].split(Y),O=0;while(G&&O<M.length){var V=M[O].replace(/\s+$/,"");for(var H=O+1;H<M.length;++H){var q=M[H];if(!/\s/.test(q[0]))break;V+=q,O=H}if(G=V.match(Q),G){var F={name:G[1],values:[]},K=G[2].split(",");for(var A=0;A<K.length;++A)F.values.push(XM(K[A]));if(!U.procType){if(F.name!=="Proc-Type")throw Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');else if(F.values.length!==2)throw Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');U.procType={version:K[0],type:K[1]}}else if(!U.contentDomain&&F.name==="Content-Domain")U.contentDomain=K[0]||"";else if(!U.dekInfo&&F.name==="DEK-Info"){if(F.values.length===0)throw Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');U.dekInfo={algorithm:K[0],parameters:K[1]||null}}else U.headers.push(F)}++O}if(U.procType==="ENCRYPTED"&&!U.dekInfo)throw Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}if(J.length===0)throw Error("Invalid PEM formatted message.");return J};function BY($){var J=$.name+": ",X=[],Q=function(M,O){return" "+O};for(var Y=0;Y<$.values.length;++Y)X.push($.values[Y].replace(/^(\S+\r\n)/,Q));J+=X.join(",")+`\r
|
|
13
|
+
`;var G=0,W=-1;for(var Y=0;Y<J.length;++Y,++G)if(G>65&&W!==-1){var U=J[W];if(U===",")++W,J=J.substr(0,W)+`\r
|
|
14
14
|
`+J.substr(W);else J=J.substr(0,W)+`\r
|
|
15
|
-
`+M+J.substr(W+1);G=Y-W-1,W=-1,++Y}else if(J[Y]===" "||J[Y]==="\t"||J[Y]===",")W=Y;return J}function AM($){return $.replace(/^\s+/,"")}});var zX=M$((WE,AG)=>{var l$=K$();YY();k9();C$();AG.exports=l$.des=l$.des||{};l$.des.startEncrypting=function($,J,X,Q){var Y=zY({key:$,output:X,decrypt:!1,mode:Q||(J===null?"ECB":"CBC")});return Y.start(J),Y};l$.des.createEncryptionCipher=function($,J){return zY({key:$,output:null,decrypt:!1,mode:J})};l$.des.startDecrypting=function($,J,X,Q){var Y=zY({key:$,output:X,decrypt:!0,mode:Q||(J===null?"ECB":"CBC")});return Y.start(J),Y};l$.des.createDecryptionCipher=function($,J){return zY({key:$,output:null,decrypt:!0,mode:J})};l$.des.Algorithm=function($,J){var X=this;X.name=$,X.mode=new J({blockSize:8,cipher:{encrypt:function(Q,Y){return RG(X._keys,Q,Y,!1)},decrypt:function(Q,Y){return RG(X._keys,Q,Y,!0)}}}),X._init=!1};l$.des.Algorithm.prototype.initialize=function($){if(this._init)return;var J=l$.util.createBuffer($.key);if(this.name.indexOf("3DES")===0){if(J.length()!==24)throw Error("Invalid Triple-DES key size: "+J.length()*8)}this._keys=wM(J),this._init=!0};eJ("DES-ECB",l$.cipher.modes.ecb);eJ("DES-CBC",l$.cipher.modes.cbc);eJ("DES-CFB",l$.cipher.modes.cfb);eJ("DES-OFB",l$.cipher.modes.ofb);eJ("DES-CTR",l$.cipher.modes.ctr);eJ("3DES-ECB",l$.cipher.modes.ecb);eJ("3DES-CBC",l$.cipher.modes.cbc);eJ("3DES-CFB",l$.cipher.modes.cfb);eJ("3DES-OFB",l$.cipher.modes.ofb);eJ("3DES-CTR",l$.cipher.modes.ctr);function eJ($,J){var X=function(){return new l$.des.Algorithm($,J)};l$.cipher.registerAlgorithm($,X)}var DM=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],ZM=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],BM=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],jM=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],TM=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],SM=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],IM=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],CM=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function wM($){var J=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],X=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],Q=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],Y=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],G=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],W=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],M=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],U=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],O=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],V=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],H=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],q=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],F=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],K=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],R=$.length()>8?3:1,L=[],D=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],w=0,T;for(var P=0;P<R;P++){var S=$.getInt32(),C=$.getInt32();T=(S>>>4^C)&252645135,C^=T,S^=T<<4,T=(C>>>-16^S)&65535,S^=T,C^=T<<-16,T=(S>>>2^C)&858993459,C^=T,S^=T<<2,T=(C>>>-16^S)&65535,S^=T,C^=T<<-16,T=(S>>>1^C)&1431655765,C^=T,S^=T<<1,T=(C>>>8^S)&16711935,S^=T,C^=T<<8,T=(S>>>1^C)&1431655765,C^=T,S^=T<<1,T=S<<8|C>>>20&240,S=C<<24|C<<8&16711680|C>>>8&65280|C>>>24&240,C=T;for(var h=0;h<D.length;++h){if(D[h])S=S<<2|S>>>26,C=C<<2|C>>>26;else S=S<<1|S>>>27,C=C<<1|C>>>27;S&=-15,C&=-15;var s=J[S>>>28]|X[S>>>24&15]|Q[S>>>20&15]|Y[S>>>16&15]|G[S>>>12&15]|W[S>>>8&15]|M[S>>>4&15],a=U[C>>>28]|O[C>>>24&15]|V[C>>>20&15]|H[C>>>16&15]|q[C>>>12&15]|F[C>>>8&15]|K[C>>>4&15];T=(a>>>16^s)&65535,L[w++]=s^T,L[w++]=a^T<<16}}return L}function RG($,J,X,Q){var Y=$.length===32?3:9,G;if(Y===3)G=Q?[30,-2,-2]:[0,32,2];else G=Q?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var W,M=J[0],U=J[1];W=(M>>>4^U)&252645135,U^=W,M^=W<<4,W=(M>>>16^U)&65535,U^=W,M^=W<<16,W=(U>>>2^M)&858993459,M^=W,U^=W<<2,W=(U>>>8^M)&16711935,M^=W,U^=W<<8,W=(M>>>1^U)&1431655765,U^=W,M^=W<<1,M=M<<1|M>>>31,U=U<<1|U>>>31;for(var O=0;O<Y;O+=3){var V=G[O+1],H=G[O+2];for(var q=G[O];q!=V;q+=H){var F=U^$[q],K=(U>>>4|U<<28)^$[q+1];W=M,M=U,U=W^(ZM[F>>>24&63]|jM[F>>>16&63]|SM[F>>>8&63]|CM[F&63]|DM[K>>>24&63]|BM[K>>>16&63]|TM[K>>>8&63]|IM[K&63])}W=M,M=U,U=W}M=M>>>1|M<<31,U=U>>>1|U<<31,W=(M>>>1^U)&1431655765,U^=W,M^=W<<1,W=(U>>>8^M)&16711935,M^=W,U^=W<<8,W=(U>>>2^M)&858993459,M^=W,U^=W<<2,W=(M>>>16^U)&65535,U^=W,M^=W<<16,W=(M>>>4^U)&252645135,U^=W,M^=W<<4,X[0]=M,X[1]=U}function zY($){$=$||{};var J=($.mode||"CBC").toUpperCase(),X="DES-"+J,Q;if($.decrypt)Q=l$.cipher.createDecipher(X,$.key);else Q=l$.cipher.createCipher(X,$.key);var Y=Q.start;return Q.start=function(G,W){var M=null;if(W instanceof l$.util.ByteBuffer)M=W,W={};W=W||{},W.output=M,W.iv=G,Y.call(Q,W)},Q}});var EY=M$((ME,DG)=>{var LJ=K$();DQ();rJ();C$();var PM=LJ.pkcs5=LJ.pkcs5||{},z0;if(LJ.util.isNodejs&&!LJ.options.usePureJavaScript)z0=YX("crypto");DG.exports=LJ.pbkdf2=PM.pbkdf2=function($,J,X,Q,Y,G){if(typeof Y==="function")G=Y,Y=null;if(LJ.util.isNodejs&&!LJ.options.usePureJavaScript&&z0.pbkdf2&&(Y===null||typeof Y!=="object")&&(z0.pbkdf2Sync.length>4||(!Y||Y==="sha1"))){if(typeof Y!=="string")Y="sha1";if($=Buffer.from($,"binary"),J=Buffer.from(J,"binary"),!G){if(z0.pbkdf2Sync.length===4)return z0.pbkdf2Sync($,J,X,Q).toString("binary");return z0.pbkdf2Sync($,J,X,Q,Y).toString("binary")}if(z0.pbkdf2Sync.length===4)return z0.pbkdf2($,J,X,Q,function(T,P){if(T)return G(T);G(null,P.toString("binary"))});return z0.pbkdf2($,J,X,Q,Y,function(T,P){if(T)return G(T);G(null,P.toString("binary"))})}if(typeof Y>"u"||Y===null)Y="sha1";if(typeof Y==="string"){if(!(Y in LJ.md.algorithms))throw Error("Unknown hash algorithm: "+Y);Y=LJ.md[Y].create()}var W=Y.digestLength;if(Q>4294967295*W){var M=Error("Derived key is too long.");if(G)return G(M);throw M}var U=Math.ceil(Q/W),O=Q-(U-1)*W,V=LJ.hmac.create();V.start(Y,$);var H="",q,F,K;if(!G){for(var R=1;R<=U;++R){V.start(null,null),V.update(J),V.update(LJ.util.int32ToBytes(R)),q=K=V.digest().getBytes();for(var L=2;L<=X;++L)V.start(null,null),V.update(K),F=V.digest().getBytes(),q=LJ.util.xorBytes(q,F,W),K=F;H+=R<U?q:q.substr(0,O)}return H}var R=1,L;function D(){if(R>U)return G(null,H);V.start(null,null),V.update(J),V.update(LJ.util.int32ToBytes(R)),q=K=V.digest().getBytes(),L=2,w()}function w(){if(L<=X)return V.start(null,null),V.update(K),F=V.digest().getBytes(),q=LJ.util.xorBytes(q,F,W),K=F,++L,LJ.util.setImmediate(w);H+=R<U?q:q.substr(0,O),++R,D()}D()}});var m9=M$((UE,SG)=>{var $0=K$();rJ();C$();var BG=SG.exports=$0.sha256=$0.sha256||{};$0.md.sha256=$0.md.algorithms.sha256=BG;BG.create=function(){if(!jG)_M();var $=null,J=$0.util.createBuffer(),X=Array(64),Q={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return Q.start=function(){Q.messageLength=0,Q.fullMessageLength=Q.messageLength64=[];var Y=Q.messageLengthSize/4;for(var G=0;G<Y;++G)Q.fullMessageLength.push(0);return J=$0.util.createBuffer(),$={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},Q},Q.start(),Q.update=function(Y,G){if(G==="utf8")Y=$0.util.encodeUtf8(Y);var W=Y.length;Q.messageLength+=W,W=[W/4294967296>>>0,W>>>0];for(var M=Q.fullMessageLength.length-1;M>=0;--M)Q.fullMessageLength[M]+=W[1],W[1]=W[0]+(Q.fullMessageLength[M]/4294967296>>>0),Q.fullMessageLength[M]=Q.fullMessageLength[M]>>>0,W[0]=W[1]/4294967296>>>0;if(J.putBytes(Y),ZG($,X,J),J.read>2048||J.length()===0)J.compact();return Q},Q.digest=function(){var Y=$0.util.createBuffer();Y.putBytes(J.bytes());var G=Q.fullMessageLength[Q.fullMessageLength.length-1]+Q.messageLengthSize,W=G&Q.blockLength-1;Y.putBytes(g9.substr(0,Q.blockLength-W));var M,U,O=Q.fullMessageLength[0]*8;for(var V=0;V<Q.fullMessageLength.length-1;++V)M=Q.fullMessageLength[V+1]*8,U=M/4294967296>>>0,O+=U,Y.putInt32(O>>>0),O=M>>>0;Y.putInt32(O);var H={h0:$.h0,h1:$.h1,h2:$.h2,h3:$.h3,h4:$.h4,h5:$.h5,h6:$.h6,h7:$.h7};ZG(H,X,Y);var q=$0.util.createBuffer();return q.putInt32(H.h0),q.putInt32(H.h1),q.putInt32(H.h2),q.putInt32(H.h3),q.putInt32(H.h4),q.putInt32(H.h5),q.putInt32(H.h6),q.putInt32(H.h7),q},Q};var g9=null,jG=!1,TG=null;function _M(){g9=String.fromCharCode(128),g9+=$0.util.fillString(String.fromCharCode(0),64),TG=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],jG=!0}function ZG($,J,X){var Q,Y,G,W,M,U,O,V,H,q,F,K,R,L,D,w=X.length();while(w>=64){for(O=0;O<16;++O)J[O]=X.getInt32();for(;O<64;++O)Q=J[O-2],Q=(Q>>>17|Q<<15)^(Q>>>19|Q<<13)^Q>>>10,Y=J[O-15],Y=(Y>>>7|Y<<25)^(Y>>>18|Y<<14)^Y>>>3,J[O]=Q+J[O-7]+Y+J[O-16]|0;V=$.h0,H=$.h1,q=$.h2,F=$.h3,K=$.h4,R=$.h5,L=$.h6,D=$.h7;for(O=0;O<64;++O)W=(K>>>6|K<<26)^(K>>>11|K<<21)^(K>>>25|K<<7),M=L^K&(R^L),G=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),U=V&H|q&(V^H),Q=D+W+M+TG[O]+J[O],Y=G+U,D=L,L=R,R=K,K=F+Q>>>0,F=q,q=H,H=V,V=Q+Y>>>0;$.h0=$.h0+V|0,$.h1=$.h1+H|0,$.h2=$.h2+q|0,$.h3=$.h3+F|0,$.h4=$.h4+K|0,$.h5=$.h5+R|0,$.h6=$.h6+L|0,$.h7=$.h7+D|0,w-=64}}});var l9=M$((OE,IG)=>{var J0=K$();C$();var FY=null;if(J0.util.isNodejs&&!J0.options.usePureJavaScript&&!process.versions["node-webkit"])FY=YX("crypto");var xM=IG.exports=J0.prng=J0.prng||{};xM.create=function($){var J={plugin:$,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},X=$.md,Q=Array(32);for(var Y=0;Y<32;++Y)Q[Y]=X.create();J.pools=Q,J.pool=0,J.generate=function(O,V){if(!V)return J.generateSync(O);var H=J.plugin.cipher,q=J.plugin.increment,F=J.plugin.formatKey,K=J.plugin.formatSeed,R=J0.util.createBuffer();J.key=null,L();function L(D){if(D)return V(D);if(R.length()>=O)return V(null,R.getBytes(O));if(J.generated>1048575)J.key=null;if(J.key===null)return J0.util.nextTick(function(){G(L)});var w=H(J.key,J.seed);J.generated+=w.length,R.putBytes(w),J.key=F(H(J.key,q(J.seed))),J.seed=K(H(J.key,J.seed)),J0.util.setImmediate(L)}},J.generateSync=function(O){var V=J.plugin.cipher,H=J.plugin.increment,q=J.plugin.formatKey,F=J.plugin.formatSeed;J.key=null;var K=J0.util.createBuffer();while(K.length()<O){if(J.generated>1048575)J.key=null;if(J.key===null)W();var R=V(J.key,J.seed);J.generated+=R.length,K.putBytes(R),J.key=q(V(J.key,H(J.seed))),J.seed=F(V(J.key,J.seed))}return K.getBytes(O)};function G(O){if(J.pools[0].messageLength>=32)return M(),O();var V=32-J.pools[0].messageLength<<5;J.seedFile(V,function(H,q){if(H)return O(H);J.collect(q),M(),O()})}function W(){if(J.pools[0].messageLength>=32)return M();var O=32-J.pools[0].messageLength<<5;J.collect(J.seedFileSync(O)),M()}function M(){J.reseeds=J.reseeds===4294967295?0:J.reseeds+1;var O=J.plugin.md.create();O.update(J.keyBytes);var V=1;for(var H=0;H<32;++H){if(J.reseeds%V===0)O.update(J.pools[H].digest().getBytes()),J.pools[H].start();V=V<<1}J.keyBytes=O.digest().getBytes(),O.start(),O.update(J.keyBytes);var q=O.digest().getBytes();J.key=J.plugin.formatKey(J.keyBytes),J.seed=J.plugin.formatSeed(q),J.generated=0}function U(O){var V=null,H=J0.util.globalScope,q=H.crypto||H.msCrypto;if(q&&q.getRandomValues)V=function(S){return q.getRandomValues(S)};var F=J0.util.createBuffer();if(V)while(F.length()<O){var K=Math.max(1,Math.min(O-F.length(),65536)/4),R=new Uint32Array(Math.floor(K));try{V(R);for(var L=0;L<R.length;++L)F.putInt32(R[L])}catch(S){if(!(typeof QuotaExceededError<"u"&&S instanceof QuotaExceededError))throw S}}if(F.length()<O){var D,w,T,P=Math.floor(Math.random()*65536);while(F.length()<O){w=16807*(P&65535),D=16807*(P>>16),w+=(D&32767)<<16,w+=D>>15,w=(w&2147483647)+(w>>31),P=w&4294967295;for(var L=0;L<3;++L)T=P>>>(L<<3),T^=Math.floor(Math.random()*256),F.putByte(T&255)}}return F.getBytes(O)}if(FY)J.seedFile=function(O,V){FY.randomBytes(O,function(H,q){if(H)return V(H);V(null,q.toString())})},J.seedFileSync=function(O){return FY.randomBytes(O).toString()};else J.seedFile=function(O,V){try{V(null,U(O))}catch(H){V(H)}},J.seedFileSync=U;return J.collect=function(O){var V=O.length;for(var H=0;H<V;++H)J.pools[J.pool].update(O.substr(H,1)),J.pool=J.pool===31?0:J.pool+1},J.collectInt=function(O,V){var H="";for(var q=0;q<V;q+=8)H+=String.fromCharCode(O>>q&255);J.collect(H)},J.registerWorker=function(O){if(O===self)J.seedFile=function(H,q){function F(K){var R=K.data;if(R.forge&&R.forge.prng)self.removeEventListener("message",F),q(R.forge.prng.err,R.forge.prng.bytes)}self.addEventListener("message",F),self.postMessage({forge:{prng:{needed:H}}})};else{var V=function(H){var q=H.data;if(q.forge&&q.forge.prng)J.seedFile(q.forge.prng.needed,function(F,K){O.postMessage({forge:{prng:{err:F,bytes:K}}})})};O.addEventListener("message",V)}},J}});var PJ=M$((VE,d9)=>{var OJ=K$();T0();m9();l9();C$();(function(){if(OJ.random&&OJ.random.getBytes){d9.exports=OJ.random;return}(function($){var J={},X=[,,,,],Q=OJ.util.createBuffer();J.formatKey=function(H){var q=OJ.util.createBuffer(H);return H=[,,,,],H[0]=q.getInt32(),H[1]=q.getInt32(),H[2]=q.getInt32(),H[3]=q.getInt32(),OJ.aes._expandKey(H,!1)},J.formatSeed=function(H){var q=OJ.util.createBuffer(H);return H=[,,,,],H[0]=q.getInt32(),H[1]=q.getInt32(),H[2]=q.getInt32(),H[3]=q.getInt32(),H},J.cipher=function(H,q){return OJ.aes._updateBlock(H,q,X,!1),Q.putInt32(X[0]),Q.putInt32(X[1]),Q.putInt32(X[2]),Q.putInt32(X[3]),Q.getBytes()},J.increment=function(H){return++H[3],H},J.md=OJ.md.sha256;function Y(){var H=OJ.prng.create(J);return H.getBytes=function(q,F){return H.generate(q,F)},H.getBytesSync=function(q){return H.generate(q)},H}var G=Y(),W=null,M=OJ.util.globalScope,U=M.crypto||M.msCrypto;if(U&&U.getRandomValues)W=function(H){return U.getRandomValues(H)};if(OJ.options.usePureJavaScript||!OJ.util.isNodejs&&!W){if(typeof window>"u"||window.document===void 0);if(G.collectInt(+new Date,32),typeof navigator<"u"){var O="";for(var V in navigator)try{if(typeof navigator[V]=="string")O+=navigator[V]}catch(H){}G.collect(O),O=null}if($)$().mousemove(function(H){G.collectInt(H.clientX,16),G.collectInt(H.clientY,16)}),$().keypress(function(H){G.collectInt(H.charCode,8)})}if(!OJ.random)OJ.random=G;else for(var V in G)OJ.random[V]=G[V];OJ.random.createInstance=Y,d9.exports=OJ.random})(typeof jQuery<"u"?jQuery:null)})()});var c9=M$((HE,PG)=>{var DJ=K$();C$();var p9=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],CG=[1,2,3,5],vM=function($,J){return $<<J&65535|($&65535)>>16-J},kM=function($,J){return($&65535)>>J|$<<16-J&65535};PG.exports=DJ.rc2=DJ.rc2||{};DJ.rc2.expandKey=function($,J){if(typeof $==="string")$=DJ.util.createBuffer($);J=J||128;var X=$,Q=$.length(),Y=J,G=Math.ceil(Y/8),W=255>>(Y&7),M;for(M=Q;M<128;M++)X.putByte(p9[X.at(M-1)+X.at(M-Q)&255]);X.setAt(128-G,p9[X.at(128-G)&W]);for(M=127-G;M>=0;M--)X.setAt(M,p9[X.at(M+1)^X.at(M+G)]);return X};var wG=function($,J,X){var Q=!1,Y=null,G=null,W=null,M,U,O,V,H=[];$=DJ.rc2.expandKey($,J);for(O=0;O<64;O++)H.push($.getInt16Le());if(X)M=function(K){for(O=0;O<4;O++)K[O]+=H[V]+(K[(O+3)%4]&K[(O+2)%4])+(~K[(O+3)%4]&K[(O+1)%4]),K[O]=vM(K[O],CG[O]),V++},U=function(K){for(O=0;O<4;O++)K[O]+=H[K[(O+3)%4]&63]};else M=function(K){for(O=3;O>=0;O--)K[O]=kM(K[O],CG[O]),K[O]-=H[V]+(K[(O+3)%4]&K[(O+2)%4])+(~K[(O+3)%4]&K[(O+1)%4]),V--},U=function(K){for(O=3;O>=0;O--)K[O]-=H[K[(O+3)%4]&63]};var q=function(K){var R=[];for(O=0;O<4;O++){var L=Y.getInt16Le();if(W!==null)if(X)L^=W.getInt16Le();else W.putInt16Le(L);R.push(L&65535)}V=X?0:63;for(var D=0;D<K.length;D++)for(var w=0;w<K[D][0];w++)K[D][1](R);for(O=0;O<4;O++){if(W!==null)if(X)W.putInt16Le(R[O]);else R[O]^=W.getInt16Le();G.putInt16Le(R[O])}},F=null;return F={start:function(K,R){if(K){if(typeof K==="string")K=DJ.util.createBuffer(K)}Q=!1,Y=DJ.util.createBuffer(),G=R||new DJ.util.createBuffer,W=K,F.output=G},update:function(K){if(!Q)Y.putBuffer(K);while(Y.length()>=8)q([[5,M],[1,U],[6,M],[1,U],[5,M]])},finish:function(K){var R=!0;if(X)if(K)R=K(8,Y,!X);else{var L=Y.length()===8?8:8-Y.length();Y.fillWithByte(L,L)}if(R)Q=!0,F.update();if(!X){if(R=Y.length()===0,R)if(K)R=K(8,G,!X);else{var D=G.length(),w=G.at(D-1);if(w>D)R=!1;else G.truncate(w)}}return R}},F};DJ.rc2.startEncrypting=function($,J,X){var Q=DJ.rc2.createEncryptionCipher($,128);return Q.start(J,X),Q};DJ.rc2.createEncryptionCipher=function($,J){return wG($,J,!0)};DJ.rc2.startDecrypting=function($,J,X){var Q=DJ.rc2.createDecryptionCipher($,128);return Q.start(J,X),Q};DJ.rc2.createDecryptionCipher=function($,J){return wG($,J,!1)}});var FX=M$((qE,hG)=>{var n9=K$();hG.exports=n9.jsbn=n9.jsbn||{};var E0,fM=244837814094590,_G=(fM&16777215)==15715070;function v($,J,X){if(this.data=[],$!=null)if(typeof $=="number")this.fromNumber($,J,X);else if(J==null&&typeof $!="string")this.fromString($,256);else this.fromString($,J)}n9.jsbn.BigInteger=v;function S$(){return new v(null)}function yM($,J,X,Q,Y,G){while(--G>=0){var W=J*this.data[$++]+X.data[Q]+Y;Y=Math.floor(W/67108864),X.data[Q++]=W&67108863}return Y}function bM($,J,X,Q,Y,G){var W=J&32767,M=J>>15;while(--G>=0){var U=this.data[$]&32767,O=this.data[$++]>>15,V=M*U+O*W;U=W*U+((V&32767)<<15)+X.data[Q]+(Y&1073741823),Y=(U>>>30)+(V>>>15)+M*O+(Y>>>30),X.data[Q++]=U&1073741823}return Y}function xG($,J,X,Q,Y,G){var W=J&16383,M=J>>14;while(--G>=0){var U=this.data[$]&16383,O=this.data[$++]>>14,V=M*U+O*W;U=W*U+((V&16383)<<14)+X.data[Q]+Y,Y=(U>>28)+(V>>14)+M*O,X.data[Q++]=U&268435455}return Y}if(typeof navigator>"u")v.prototype.am=xG,E0=28;else if(_G&&navigator.appName=="Microsoft Internet Explorer")v.prototype.am=bM,E0=30;else if(_G&&navigator.appName!="Netscape")v.prototype.am=yM,E0=26;else v.prototype.am=xG,E0=28;v.prototype.DB=E0;v.prototype.DM=(1<<E0)-1;v.prototype.DV=1<<E0;var i9=52;v.prototype.FV=Math.pow(2,i9);v.prototype.F1=i9-E0;v.prototype.F2=2*E0-i9;var hM="0123456789abcdefghijklmnopqrstuvwxyz",NY=[],BQ,_J;BQ=48;for(_J=0;_J<=9;++_J)NY[BQ++]=_J;BQ=97;for(_J=10;_J<36;++_J)NY[BQ++]=_J;BQ=65;for(_J=10;_J<36;++_J)NY[BQ++]=_J;function vG($){return hM.charAt($)}function kG($,J){var X=NY[$.charCodeAt(J)];return X==null?-1:X}function uM($){for(var J=this.t-1;J>=0;--J)$.data[J]=this.data[J];$.t=this.t,$.s=this.s}function gM($){if(this.t=1,this.s=$<0?-1:0,$>0)this.data[0]=$;else if($<-1)this.data[0]=$+this.DV;else this.t=0}function I0($){var J=S$();return J.fromInt($),J}function mM($,J){var X;if(J==16)X=4;else if(J==8)X=3;else if(J==256)X=8;else if(J==2)X=1;else if(J==32)X=5;else if(J==4)X=2;else{this.fromRadix($,J);return}this.t=0,this.s=0;var Q=$.length,Y=!1,G=0;while(--Q>=0){var W=X==8?$[Q]&255:kG($,Q);if(W<0){if($.charAt(Q)=="-")Y=!0;continue}if(Y=!1,G==0)this.data[this.t++]=W;else if(G+X>this.DB)this.data[this.t-1]|=(W&(1<<this.DB-G)-1)<<G,this.data[this.t++]=W>>this.DB-G;else this.data[this.t-1]|=W<<G;if(G+=X,G>=this.DB)G-=this.DB}if(X==8&&($[0]&128)!=0){if(this.s=-1,G>0)this.data[this.t-1]|=(1<<this.DB-G)-1<<G}if(this.clamp(),Y)v.ZERO.subTo(this,this)}function lM(){var $=this.s&this.DM;while(this.t>0&&this.data[this.t-1]==$)--this.t}function dM($){if(this.s<0)return"-"+this.negate().toString($);var J;if($==16)J=4;else if($==8)J=3;else if($==2)J=1;else if($==32)J=5;else if($==4)J=2;else return this.toRadix($);var X=(1<<J)-1,Q,Y=!1,G="",W=this.t,M=this.DB-W*this.DB%J;if(W-- >0){if(M<this.DB&&(Q=this.data[W]>>M)>0)Y=!0,G=vG(Q);while(W>=0){if(M<J)Q=(this.data[W]&(1<<M)-1)<<J-M,Q|=this.data[--W]>>(M+=this.DB-J);else if(Q=this.data[W]>>(M-=J)&X,M<=0)M+=this.DB,--W;if(Q>0)Y=!0;if(Y)G+=vG(Q)}}return Y?G:"0"}function pM(){var $=S$();return v.ZERO.subTo(this,$),$}function cM(){return this.s<0?this.negate():this}function nM($){var J=this.s-$.s;if(J!=0)return J;var X=this.t;if(J=X-$.t,J!=0)return this.s<0?-J:J;while(--X>=0)if((J=this.data[X]-$.data[X])!=0)return J;return 0}function LY($){var J=1,X;if((X=$>>>16)!=0)$=X,J+=16;if((X=$>>8)!=0)$=X,J+=8;if((X=$>>4)!=0)$=X,J+=4;if((X=$>>2)!=0)$=X,J+=2;if((X=$>>1)!=0)$=X,J+=1;return J}function iM(){if(this.t<=0)return 0;return this.DB*(this.t-1)+LY(this.data[this.t-1]^this.s&this.DM)}function oM($,J){var X;for(X=this.t-1;X>=0;--X)J.data[X+$]=this.data[X];for(X=$-1;X>=0;--X)J.data[X]=0;J.t=this.t+$,J.s=this.s}function aM($,J){for(var X=$;X<this.t;++X)J.data[X-$]=this.data[X];J.t=Math.max(this.t-$,0),J.s=this.s}function sM($,J){var X=$%this.DB,Q=this.DB-X,Y=(1<<Q)-1,G=Math.floor($/this.DB),W=this.s<<X&this.DM,M;for(M=this.t-1;M>=0;--M)J.data[M+G+1]=this.data[M]>>Q|W,W=(this.data[M]&Y)<<X;for(M=G-1;M>=0;--M)J.data[M]=0;J.data[G]=W,J.t=this.t+G+1,J.s=this.s,J.clamp()}function rM($,J){J.s=this.s;var X=Math.floor($/this.DB);if(X>=this.t){J.t=0;return}var Q=$%this.DB,Y=this.DB-Q,G=(1<<Q)-1;J.data[0]=this.data[X]>>Q;for(var W=X+1;W<this.t;++W)J.data[W-X-1]|=(this.data[W]&G)<<Y,J.data[W-X]=this.data[W]>>Q;if(Q>0)J.data[this.t-X-1]|=(this.s&G)<<Y;J.t=this.t-X,J.clamp()}function tM($,J){var X=0,Q=0,Y=Math.min($.t,this.t);while(X<Y)Q+=this.data[X]-$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;if($.t<this.t){Q-=$.s;while(X<this.t)Q+=this.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=this.s}else{Q+=this.s;while(X<$.t)Q-=$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q-=$.s}if(J.s=Q<0?-1:0,Q<-1)J.data[X++]=this.DV+Q;else if(Q>0)J.data[X++]=Q;J.t=X,J.clamp()}function eM($,J){var X=this.abs(),Q=$.abs(),Y=X.t;J.t=Y+Q.t;while(--Y>=0)J.data[Y]=0;for(Y=0;Y<Q.t;++Y)J.data[Y+X.t]=X.am(0,Q.data[Y],J,Y,0,X.t);if(J.s=0,J.clamp(),this.s!=$.s)v.ZERO.subTo(J,J)}function $U($){var J=this.abs(),X=$.t=2*J.t;while(--X>=0)$.data[X]=0;for(X=0;X<J.t-1;++X){var Q=J.am(X,J.data[X],$,2*X,0,1);if(($.data[X+J.t]+=J.am(X+1,2*J.data[X],$,2*X+1,Q,J.t-X-1))>=J.DV)$.data[X+J.t]-=J.DV,$.data[X+J.t+1]=1}if($.t>0)$.data[$.t-1]+=J.am(X,J.data[X],$,2*X,0,1);$.s=0,$.clamp()}function JU($,J,X){var Q=$.abs();if(Q.t<=0)return;var Y=this.abs();if(Y.t<Q.t){if(J!=null)J.fromInt(0);if(X!=null)this.copyTo(X);return}if(X==null)X=S$();var G=S$(),W=this.s,M=$.s,U=this.DB-LY(Q.data[Q.t-1]);if(U>0)Q.lShiftTo(U,G),Y.lShiftTo(U,X);else Q.copyTo(G),Y.copyTo(X);var O=G.t,V=G.data[O-1];if(V==0)return;var H=V*(1<<this.F1)+(O>1?G.data[O-2]>>this.F2:0),q=this.FV/H,F=(1<<this.F1)/H,K=1<<this.F2,R=X.t,L=R-O,D=J==null?S$():J;if(G.dlShiftTo(L,D),X.compareTo(D)>=0)X.data[X.t++]=1,X.subTo(D,X);v.ONE.dlShiftTo(O,D),D.subTo(G,G);while(G.t<O)G.data[G.t++]=0;while(--L>=0){var w=X.data[--R]==V?this.DM:Math.floor(X.data[R]*q+(X.data[R-1]+K)*F);if((X.data[R]+=G.am(0,w,X,L,0,O))<w){G.dlShiftTo(L,D),X.subTo(D,X);while(X.data[R]<--w)X.subTo(D,X)}}if(J!=null){if(X.drShiftTo(O,J),W!=M)v.ZERO.subTo(J,J)}if(X.t=O,X.clamp(),U>0)X.rShiftTo(U,X);if(W<0)v.ZERO.subTo(X,X)}function QU($){var J=S$();if(this.abs().divRemTo($,null,J),this.s<0&&J.compareTo(v.ZERO)>0)$.subTo(J,J);return J}function e0($){this.m=$}function XU($){if($.s<0||$.compareTo(this.m)>=0)return $.mod(this.m);else return $}function YU($){return $}function GU($){$.divRemTo(this.m,null,$)}function WU($,J,X){$.multiplyTo(J,X),this.reduce(X)}function MU($,J){$.squareTo(J),this.reduce(J)}e0.prototype.convert=XU;e0.prototype.revert=YU;e0.prototype.reduce=GU;e0.prototype.mulTo=WU;e0.prototype.sqrTo=MU;function UU(){if(this.t<1)return 0;var $=this.data[0];if(($&1)==0)return 0;var J=$&3;return J=J*(2-($&15)*J)&15,J=J*(2-($&255)*J)&255,J=J*(2-(($&65535)*J&65535))&65535,J=J*(2-$*J%this.DV)%this.DV,J>0?this.DV-J:-J}function $Q($){this.m=$,this.mp=$.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<$.DB-15)-1,this.mt2=2*$.t}function OU($){var J=S$();if($.abs().dlShiftTo(this.m.t,J),J.divRemTo(this.m,null,J),$.s<0&&J.compareTo(v.ZERO)>0)this.m.subTo(J,J);return J}function VU($){var J=S$();return $.copyTo(J),this.reduce(J),J}function HU($){while($.t<=this.mt2)$.data[$.t++]=0;for(var J=0;J<this.m.t;++J){var X=$.data[J]&32767,Q=X*this.mpl+((X*this.mph+($.data[J]>>15)*this.mpl&this.um)<<15)&$.DM;X=J+this.m.t,$.data[X]+=this.m.am(0,Q,$,J,0,this.m.t);while($.data[X]>=$.DV)$.data[X]-=$.DV,$.data[++X]++}if($.clamp(),$.drShiftTo(this.m.t,$),$.compareTo(this.m)>=0)$.subTo(this.m,$)}function qU($,J){$.squareTo(J),this.reduce(J)}function KU($,J,X){$.multiplyTo(J,X),this.reduce(X)}$Q.prototype.convert=OU;$Q.prototype.revert=VU;$Q.prototype.reduce=HU;$Q.prototype.mulTo=KU;$Q.prototype.sqrTo=qU;function zU(){return(this.t>0?this.data[0]&1:this.s)==0}function EU($,J){if($>4294967295||$<1)return v.ONE;var X=S$(),Q=S$(),Y=J.convert(this),G=LY($)-1;Y.copyTo(X);while(--G>=0)if(J.sqrTo(X,Q),($&1<<G)>0)J.mulTo(Q,Y,X);else{var W=X;X=Q,Q=W}return J.revert(X)}function FU($,J){var X;if($<256||J.isEven())X=new e0(J);else X=new $Q(J);return this.exp($,X)}v.prototype.copyTo=uM;v.prototype.fromInt=gM;v.prototype.fromString=mM;v.prototype.clamp=lM;v.prototype.dlShiftTo=oM;v.prototype.drShiftTo=aM;v.prototype.lShiftTo=sM;v.prototype.rShiftTo=rM;v.prototype.subTo=tM;v.prototype.multiplyTo=eM;v.prototype.squareTo=$U;v.prototype.divRemTo=JU;v.prototype.invDigit=UU;v.prototype.isEven=zU;v.prototype.exp=EU;v.prototype.toString=dM;v.prototype.negate=pM;v.prototype.abs=cM;v.prototype.compareTo=nM;v.prototype.bitLength=iM;v.prototype.mod=QU;v.prototype.modPowInt=FU;v.ZERO=I0(0);v.ONE=I0(1);function NU(){var $=S$();return this.copyTo($),$}function LU(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;else if(this.t==0)return-1}else if(this.t==1)return this.data[0];else if(this.t==0)return 0;return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function RU(){return this.t==0?this.s:this.data[0]<<24>>24}function AU(){return this.t==0?this.s:this.data[0]<<16>>16}function DU($){return Math.floor(Math.LN2*this.DB/Math.log($))}function ZU(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this.data[0]<=0)return 0;else return 1}function BU($){if($==null)$=10;if(this.signum()==0||$<2||$>36)return"0";var J=this.chunkSize($),X=Math.pow($,J),Q=I0(X),Y=S$(),G=S$(),W="";this.divRemTo(Q,Y,G);while(Y.signum()>0)W=(X+G.intValue()).toString($).substr(1)+W,Y.divRemTo(Q,Y,G);return G.intValue().toString($)+W}function jU($,J){if(this.fromInt(0),J==null)J=10;var X=this.chunkSize(J),Q=Math.pow(J,X),Y=!1,G=0,W=0;for(var M=0;M<$.length;++M){var U=kG($,M);if(U<0){if($.charAt(M)=="-"&&this.signum()==0)Y=!0;continue}if(W=J*W+U,++G>=X)this.dMultiply(Q),this.dAddOffset(W,0),G=0,W=0}if(G>0)this.dMultiply(Math.pow(J,G)),this.dAddOffset(W,0);if(Y)v.ZERO.subTo(this,this)}function TU($,J,X){if(typeof J=="number")if($<2)this.fromInt(1);else{if(this.fromNumber($,X),!this.testBit($-1))this.bitwiseTo(v.ONE.shiftLeft($-1),o9,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(J))if(this.dAddOffset(2,0),this.bitLength()>$)this.subTo(v.ONE.shiftLeft($-1),this)}else{var Q=[],Y=$&7;if(Q.length=($>>3)+1,J.nextBytes(Q),Y>0)Q[0]&=(1<<Y)-1;else Q[0]=0;this.fromString(Q,256)}}function SU(){var $=this.t,J=[];J[0]=this.s;var X=this.DB-$*this.DB%8,Q,Y=0;if($-- >0){if(X<this.DB&&(Q=this.data[$]>>X)!=(this.s&this.DM)>>X)J[Y++]=Q|this.s<<this.DB-X;while($>=0){if(X<8)Q=(this.data[$]&(1<<X)-1)<<8-X,Q|=this.data[--$]>>(X+=this.DB-8);else if(Q=this.data[$]>>(X-=8)&255,X<=0)X+=this.DB,--$;if((Q&128)!=0)Q|=-256;if(Y==0&&(this.s&128)!=(Q&128))++Y;if(Y>0||Q!=this.s)J[Y++]=Q}}return J}function IU($){return this.compareTo($)==0}function CU($){return this.compareTo($)<0?this:$}function wU($){return this.compareTo($)>0?this:$}function PU($,J,X){var Q,Y,G=Math.min($.t,this.t);for(Q=0;Q<G;++Q)X.data[Q]=J(this.data[Q],$.data[Q]);if($.t<this.t){Y=$.s&this.DM;for(Q=G;Q<this.t;++Q)X.data[Q]=J(this.data[Q],Y);X.t=this.t}else{Y=this.s&this.DM;for(Q=G;Q<$.t;++Q)X.data[Q]=J(Y,$.data[Q]);X.t=$.t}X.s=J(this.s,$.s),X.clamp()}function _U($,J){return $&J}function xU($){var J=S$();return this.bitwiseTo($,_U,J),J}function o9($,J){return $|J}function vU($){var J=S$();return this.bitwiseTo($,o9,J),J}function fG($,J){return $^J}function kU($){var J=S$();return this.bitwiseTo($,fG,J),J}function yG($,J){return $&~J}function fU($){var J=S$();return this.bitwiseTo($,yG,J),J}function yU(){var $=S$();for(var J=0;J<this.t;++J)$.data[J]=this.DM&~this.data[J];return $.t=this.t,$.s=~this.s,$}function bU($){var J=S$();if($<0)this.rShiftTo(-$,J);else this.lShiftTo($,J);return J}function hU($){var J=S$();if($<0)this.lShiftTo(-$,J);else this.rShiftTo($,J);return J}function uU($){if($==0)return-1;var J=0;if(($&65535)==0)$>>=16,J+=16;if(($&255)==0)$>>=8,J+=8;if(($&15)==0)$>>=4,J+=4;if(($&3)==0)$>>=2,J+=2;if(($&1)==0)++J;return J}function gU(){for(var $=0;$<this.t;++$)if(this.data[$]!=0)return $*this.DB+uU(this.data[$]);if(this.s<0)return this.t*this.DB;return-1}function mU($){var J=0;while($!=0)$&=$-1,++J;return J}function lU(){var $=0,J=this.s&this.DM;for(var X=0;X<this.t;++X)$+=mU(this.data[X]^J);return $}function dU($){var J=Math.floor($/this.DB);if(J>=this.t)return this.s!=0;return(this.data[J]&1<<$%this.DB)!=0}function pU($,J){var X=v.ONE.shiftLeft($);return this.bitwiseTo(X,J,X),X}function cU($){return this.changeBit($,o9)}function nU($){return this.changeBit($,yG)}function iU($){return this.changeBit($,fG)}function oU($,J){var X=0,Q=0,Y=Math.min($.t,this.t);while(X<Y)Q+=this.data[X]+$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;if($.t<this.t){Q+=$.s;while(X<this.t)Q+=this.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=this.s}else{Q+=this.s;while(X<$.t)Q+=$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=$.s}if(J.s=Q<0?-1:0,Q>0)J.data[X++]=Q;else if(Q<-1)J.data[X++]=this.DV+Q;J.t=X,J.clamp()}function aU($){var J=S$();return this.addTo($,J),J}function sU($){var J=S$();return this.subTo($,J),J}function rU($){var J=S$();return this.multiplyTo($,J),J}function tU(){var $=S$();return this.squareTo($),$}function eU($){var J=S$();return this.divRemTo($,J,null),J}function $O($){var J=S$();return this.divRemTo($,null,J),J}function JO($){var J=S$(),X=S$();return this.divRemTo($,J,X),[J,X]}function QO($){this.data[this.t]=this.am(0,$-1,this,0,0,this.t),++this.t,this.clamp()}function XO($,J){if($==0)return;while(this.t<=J)this.data[this.t++]=0;this.data[J]+=$;while(this.data[J]>=this.DV){if(this.data[J]-=this.DV,++J>=this.t)this.data[this.t++]=0;++this.data[J]}}function EX(){}function bG($){return $}function YO($,J,X){$.multiplyTo(J,X)}function GO($,J){$.squareTo(J)}EX.prototype.convert=bG;EX.prototype.revert=bG;EX.prototype.mulTo=YO;EX.prototype.sqrTo=GO;function WO($){return this.exp($,new EX)}function MO($,J,X){var Q=Math.min(this.t+$.t,J);X.s=0,X.t=Q;while(Q>0)X.data[--Q]=0;var Y;for(Y=X.t-this.t;Q<Y;++Q)X.data[Q+this.t]=this.am(0,$.data[Q],X,Q,0,this.t);for(Y=Math.min($.t,J);Q<Y;++Q)this.am(0,$.data[Q],X,Q,0,J-Q);X.clamp()}function UO($,J,X){--J;var Q=X.t=this.t+$.t-J;X.s=0;while(--Q>=0)X.data[Q]=0;for(Q=Math.max(J-this.t,0);Q<$.t;++Q)X.data[this.t+Q-J]=this.am(J-Q,$.data[Q],X,0,0,this.t+Q-J);X.clamp(),X.drShiftTo(1,X)}function jQ($){this.r2=S$(),this.q3=S$(),v.ONE.dlShiftTo(2*$.t,this.r2),this.mu=this.r2.divide($),this.m=$}function OO($){if($.s<0||$.t>2*this.m.t)return $.mod(this.m);else if($.compareTo(this.m)<0)return $;else{var J=S$();return $.copyTo(J),this.reduce(J),J}}function VO($){return $}function HO($){if($.drShiftTo(this.m.t-1,this.r2),$.t>this.m.t+1)$.t=this.m.t+1,$.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while($.compareTo(this.r2)<0)$.dAddOffset(1,this.m.t+1);$.subTo(this.r2,$);while($.compareTo(this.m)>=0)$.subTo(this.m,$)}function qO($,J){$.squareTo(J),this.reduce(J)}function KO($,J,X){$.multiplyTo(J,X),this.reduce(X)}jQ.prototype.convert=OO;jQ.prototype.revert=VO;jQ.prototype.reduce=HO;jQ.prototype.mulTo=KO;jQ.prototype.sqrTo=qO;function zO($,J){var X=$.bitLength(),Q,Y=I0(1),G;if(X<=0)return Y;else if(X<18)Q=1;else if(X<48)Q=3;else if(X<144)Q=4;else if(X<768)Q=5;else Q=6;if(X<8)G=new e0(J);else if(J.isEven())G=new jQ(J);else G=new $Q(J);var W=[],M=3,U=Q-1,O=(1<<Q)-1;if(W[1]=G.convert(this),Q>1){var V=S$();G.sqrTo(W[1],V);while(M<=O)W[M]=S$(),G.mulTo(V,W[M-2],W[M]),M+=2}var H=$.t-1,q,F=!0,K=S$(),R;X=LY($.data[H])-1;while(H>=0){if(X>=U)q=$.data[H]>>X-U&O;else if(q=($.data[H]&(1<<X+1)-1)<<U-X,H>0)q|=$.data[H-1]>>this.DB+X-U;M=Q;while((q&1)==0)q>>=1,--M;if((X-=M)<0)X+=this.DB,--H;if(F)W[q].copyTo(Y),F=!1;else{while(M>1)G.sqrTo(Y,K),G.sqrTo(K,Y),M-=2;if(M>0)G.sqrTo(Y,K);else R=Y,Y=K,K=R;G.mulTo(K,W[q],Y)}while(H>=0&&($.data[H]&1<<X)==0)if(G.sqrTo(Y,K),R=Y,Y=K,K=R,--X<0)X=this.DB-1,--H}return G.revert(Y)}function EO($){var J=this.s<0?this.negate():this.clone(),X=$.s<0?$.negate():$.clone();if(J.compareTo(X)<0){var Q=J;J=X,X=Q}var Y=J.getLowestSetBit(),G=X.getLowestSetBit();if(G<0)return J;if(Y<G)G=Y;if(G>0)J.rShiftTo(G,J),X.rShiftTo(G,X);while(J.signum()>0){if((Y=J.getLowestSetBit())>0)J.rShiftTo(Y,J);if((Y=X.getLowestSetBit())>0)X.rShiftTo(Y,X);if(J.compareTo(X)>=0)J.subTo(X,J),J.rShiftTo(1,J);else X.subTo(J,X),X.rShiftTo(1,X)}if(G>0)X.lShiftTo(G,X);return X}function FO($){if($<=0)return 0;var J=this.DV%$,X=this.s<0?$-1:0;if(this.t>0)if(J==0)X=this.data[0]%$;else for(var Q=this.t-1;Q>=0;--Q)X=(J*X+this.data[Q])%$;return X}function NO($){if(this.signum()==0)return v.ZERO;var J=$.isEven();if(this.isEven()&&J||$.signum()==0)return v.ZERO;var X=$.clone(),Q=this.clone(),Y=I0(1),G=I0(0),W=I0(0),M=I0(1);while(X.signum()!=0){while(X.isEven()){if(X.rShiftTo(1,X),J){if(!Y.isEven()||!G.isEven())Y.addTo(this,Y),G.subTo($,G);Y.rShiftTo(1,Y)}else if(!G.isEven())G.subTo($,G);G.rShiftTo(1,G)}while(Q.isEven()){if(Q.rShiftTo(1,Q),J){if(!W.isEven()||!M.isEven())W.addTo(this,W),M.subTo($,M);W.rShiftTo(1,W)}else if(!M.isEven())M.subTo($,M);M.rShiftTo(1,M)}if(X.compareTo(Q)>=0){if(X.subTo(Q,X),J)Y.subTo(W,Y);G.subTo(M,G)}else{if(Q.subTo(X,Q),J)W.subTo(Y,W);M.subTo(G,M)}}if(Q.compareTo(v.ONE)!=0)return v.ZERO;if(M.compareTo($)>=0)return M.subtract($);if(M.signum()<0)M.addTo($,M);else return M;if(M.signum()<0)return M.add($);else return M}var mJ=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],LO=67108864/mJ[mJ.length-1];function RO($){var J,X=this.abs();if(X.t==1&&X.data[0]<=mJ[mJ.length-1]){for(J=0;J<mJ.length;++J)if(X.data[0]==mJ[J])return!0;return!1}if(X.isEven())return!1;J=1;while(J<mJ.length){var Q=mJ[J],Y=J+1;while(Y<mJ.length&&Q<LO)Q*=mJ[Y++];Q=X.modInt(Q);while(J<Y)if(Q%mJ[J++]==0)return!1}return X.millerRabin($)}function AO($){var J=this.subtract(v.ONE),X=J.getLowestSetBit();if(X<=0)return!1;var Q=J.shiftRight(X),Y=DO(),G;for(var W=0;W<$;++W){do G=new v(this.bitLength(),Y);while(G.compareTo(v.ONE)<=0||G.compareTo(J)>=0);var M=G.modPow(Q,this);if(M.compareTo(v.ONE)!=0&&M.compareTo(J)!=0){var U=1;while(U++<X&&M.compareTo(J)!=0)if(M=M.modPowInt(2,this),M.compareTo(v.ONE)==0)return!1;if(M.compareTo(J)!=0)return!1}}return!0}function DO(){return{nextBytes:function($){for(var J=0;J<$.length;++J)$[J]=Math.floor(Math.random()*256)}}}v.prototype.chunkSize=DU;v.prototype.toRadix=BU;v.prototype.fromRadix=jU;v.prototype.fromNumber=TU;v.prototype.bitwiseTo=PU;v.prototype.changeBit=pU;v.prototype.addTo=oU;v.prototype.dMultiply=QO;v.prototype.dAddOffset=XO;v.prototype.multiplyLowerTo=MO;v.prototype.multiplyUpperTo=UO;v.prototype.modInt=FO;v.prototype.millerRabin=AO;v.prototype.clone=NU;v.prototype.intValue=LU;v.prototype.byteValue=RU;v.prototype.shortValue=AU;v.prototype.signum=ZU;v.prototype.toByteArray=SU;v.prototype.equals=IU;v.prototype.min=CU;v.prototype.max=wU;v.prototype.and=xU;v.prototype.or=vU;v.prototype.xor=kU;v.prototype.andNot=fU;v.prototype.not=yU;v.prototype.shiftLeft=bU;v.prototype.shiftRight=hU;v.prototype.getLowestSetBit=gU;v.prototype.bitCount=lU;v.prototype.testBit=dU;v.prototype.setBit=cU;v.prototype.clearBit=nU;v.prototype.flipBit=iU;v.prototype.add=aU;v.prototype.subtract=sU;v.prototype.multiply=rU;v.prototype.divide=eU;v.prototype.remainder=$O;v.prototype.divideAndRemainder=JO;v.prototype.modPow=zO;v.prototype.modInverse=NO;v.prototype.pow=WO;v.prototype.gcd=EO;v.prototype.isProbablePrime=RO;v.prototype.square=tU});var TQ=M$((KE,lG)=>{var Q0=K$();rJ();C$();var gG=lG.exports=Q0.sha1=Q0.sha1||{};Q0.md.sha1=Q0.md.algorithms.sha1=gG;gG.create=function(){if(!mG)ZO();var $=null,J=Q0.util.createBuffer(),X=Array(80),Q={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return Q.start=function(){Q.messageLength=0,Q.fullMessageLength=Q.messageLength64=[];var Y=Q.messageLengthSize/4;for(var G=0;G<Y;++G)Q.fullMessageLength.push(0);return J=Q0.util.createBuffer(),$={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},Q},Q.start(),Q.update=function(Y,G){if(G==="utf8")Y=Q0.util.encodeUtf8(Y);var W=Y.length;Q.messageLength+=W,W=[W/4294967296>>>0,W>>>0];for(var M=Q.fullMessageLength.length-1;M>=0;--M)Q.fullMessageLength[M]+=W[1],W[1]=W[0]+(Q.fullMessageLength[M]/4294967296>>>0),Q.fullMessageLength[M]=Q.fullMessageLength[M]>>>0,W[0]=W[1]/4294967296>>>0;if(J.putBytes(Y),uG($,X,J),J.read>2048||J.length()===0)J.compact();return Q},Q.digest=function(){var Y=Q0.util.createBuffer();Y.putBytes(J.bytes());var G=Q.fullMessageLength[Q.fullMessageLength.length-1]+Q.messageLengthSize,W=G&Q.blockLength-1;Y.putBytes(a9.substr(0,Q.blockLength-W));var M,U,O=Q.fullMessageLength[0]*8;for(var V=0;V<Q.fullMessageLength.length-1;++V)M=Q.fullMessageLength[V+1]*8,U=M/4294967296>>>0,O+=U,Y.putInt32(O>>>0),O=M>>>0;Y.putInt32(O);var H={h0:$.h0,h1:$.h1,h2:$.h2,h3:$.h3,h4:$.h4};uG(H,X,Y);var q=Q0.util.createBuffer();return q.putInt32(H.h0),q.putInt32(H.h1),q.putInt32(H.h2),q.putInt32(H.h3),q.putInt32(H.h4),q},Q};var a9=null,mG=!1;function ZO(){a9=String.fromCharCode(128),a9+=Q0.util.fillString(String.fromCharCode(0),64),mG=!0}function uG($,J,X){var Q,Y,G,W,M,U,O,V,H=X.length();while(H>=64){Y=$.h0,G=$.h1,W=$.h2,M=$.h3,U=$.h4;for(V=0;V<16;++V)Q=X.getInt32(),J[V]=Q,O=M^G&(W^M),Q=(Y<<5|Y>>>27)+O+U+1518500249+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<20;++V)Q=J[V-3]^J[V-8]^J[V-14]^J[V-16],Q=Q<<1|Q>>>31,J[V]=Q,O=M^G&(W^M),Q=(Y<<5|Y>>>27)+O+U+1518500249+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<32;++V)Q=J[V-3]^J[V-8]^J[V-14]^J[V-16],Q=Q<<1|Q>>>31,J[V]=Q,O=G^W^M,Q=(Y<<5|Y>>>27)+O+U+1859775393+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<40;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G^W^M,Q=(Y<<5|Y>>>27)+O+U+1859775393+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<60;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G&W|M&(G^W),Q=(Y<<5|Y>>>27)+O+U+2400959708+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<80;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G^W^M,Q=(Y<<5|Y>>>27)+O+U+3395469782+Q,U=M,M=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;$.h0=$.h0+Y|0,$.h1=$.h1+G|0,$.h2=$.h2+W|0,$.h3=$.h3+M|0,$.h4=$.h4+U|0,H-=64}}});var s9=M$((zE,pG)=>{var X0=K$();C$();PJ();TQ();var dG=pG.exports=X0.pkcs1=X0.pkcs1||{};dG.encode_rsa_oaep=function($,J,X){var Q,Y,G,W;if(typeof X==="string")Q=X,Y=arguments[3]||void 0,G=arguments[4]||void 0;else if(X){if(Q=X.label||void 0,Y=X.seed||void 0,G=X.md||void 0,X.mgf1&&X.mgf1.md)W=X.mgf1.md}if(!G)G=X0.md.sha1.create();else G.start();if(!W)W=G;var M=Math.ceil($.n.bitLength()/8),U=M-2*G.digestLength-2;if(J.length>U){var O=Error("RSAES-OAEP input message length is too long.");throw O.length=J.length,O.maxLength=U,O}if(!Q)Q="";G.update(Q,"raw");var V=G.digest(),H="",q=U-J.length;for(var F=0;F<q;F++)H+="\x00";var K=V.getBytes()+H+"\x01"+J;if(!Y)Y=X0.random.getBytes(G.digestLength);else if(Y.length!==G.digestLength){var O=Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw O.seedLength=Y.length,O.digestLength=G.digestLength,O}var R=RY(Y,M-G.digestLength-1,W),L=X0.util.xorBytes(K,R,K.length),D=RY(L,G.digestLength,W),w=X0.util.xorBytes(Y,D,Y.length);return"\x00"+w+L};dG.decode_rsa_oaep=function($,J,X){var Q,Y,G;if(typeof X==="string")Q=X,Y=arguments[3]||void 0;else if(X){if(Q=X.label||void 0,Y=X.md||void 0,X.mgf1&&X.mgf1.md)G=X.mgf1.md}var W=Math.ceil($.n.bitLength()/8);if(J.length!==W){var L=Error("RSAES-OAEP encoded message length is invalid.");throw L.length=J.length,L.expectedLength=W,L}if(Y===void 0)Y=X0.md.sha1.create();else Y.start();if(!G)G=Y;if(W<2*Y.digestLength+2)throw Error("RSAES-OAEP key is too short for the hash function.");if(!Q)Q="";Y.update(Q,"raw");var M=Y.digest().getBytes(),U=J.charAt(0),O=J.substring(1,Y.digestLength+1),V=J.substring(1+Y.digestLength),H=RY(V,Y.digestLength,G),q=X0.util.xorBytes(O,H,O.length),F=RY(q,W-Y.digestLength-1,G),K=X0.util.xorBytes(V,F,V.length),R=K.substring(0,Y.digestLength),L=U!=="\x00";for(var D=0;D<Y.digestLength;++D)L|=M.charAt(D)!==R.charAt(D);var w=1,T=Y.digestLength;for(var P=Y.digestLength;P<K.length;P++){var S=K.charCodeAt(P),C=S&1^1,h=w?65534:0;L|=S&h,w=w&C,T+=w}if(L||K.charCodeAt(T)!==1)throw Error("Invalid RSAES-OAEP padding.");return K.substring(T+1)};function RY($,J,X){if(!X)X=X0.md.sha1.create();var Q="",Y=Math.ceil(J/X.digestLength);for(var G=0;G<Y;++G){var W=String.fromCharCode(G>>24&255,G>>16&255,G>>8&255,G&255);X.start(),X.update($+W),Q+=X.digest().getBytes()}return Q.substring(0,J)}});var t9=M$((EE,r9)=>{var C0=K$();C$();FX();PJ();(function(){if(C0.prime){r9.exports=C0.prime;return}var $=r9.exports=C0.prime=C0.prime||{},J=C0.jsbn.BigInteger,X=[6,4,2,4,2,4,6,2],Q=new J(null);Q.fromInt(30);var Y=function(H,q){return H|q};$.generateProbablePrime=function(H,q,F){if(typeof q==="function")F=q,q={};q=q||{};var K=q.algorithm||"PRIMEINC";if(typeof K==="string")K={name:K};K.options=K.options||{};var R=q.prng||C0.random,L={nextBytes:function(D){var w=R.getBytesSync(D.length);for(var T=0;T<D.length;++T)D[T]=w.charCodeAt(T)}};if(K.name==="PRIMEINC")return G(H,L,K.options,F);throw Error("Invalid prime generation algorithm: "+K.name)};function G(H,q,F,K){if("workers"in F)return U(H,q,F,K);return W(H,q,F,K)}function W(H,q,F,K){var R=O(H,q),L=0,D=V(R.bitLength());if("millerRabinTests"in F)D=F.millerRabinTests;var w=10;if("maxBlockTime"in F)w=F.maxBlockTime;M(R,H,q,L,D,w,K)}function M(H,q,F,K,R,L,D){var w=+new Date;do{if(H.bitLength()>q)H=O(q,F);if(H.isProbablePrime(R))return D(null,H);H.dAddOffset(X[K++%8],0)}while(L<0||+new Date-w<L);C0.util.setImmediate(function(){M(H,q,F,K,R,L,D)})}function U(H,q,F,K){if(typeof Worker>"u")return W(H,q,F,K);var R=O(H,q),L=F.workers,D=F.workLoad||100,w=D*30/8,T=F.workerScript||"forge/prime.worker.js";if(L===-1)return C0.util.estimateCores(function(S,C){if(S)C=2;L=C-1,P()});P();function P(){L=Math.max(1,L);var S=[];for(var C=0;C<L;++C)S[C]=new Worker(T);var h=L;for(var C=0;C<L;++C)S[C].addEventListener("message",a);var s=!1;function a(O$){if(s)return;--h;var j$=O$.data;if(j$.found){for(var T$=0;T$<S.length;++T$)S[T$].terminate();return s=!0,K(null,new J(j$.prime,16))}if(R.bitLength()>H)R=O(H,q);var G$=R.toString(16);O$.target.postMessage({hex:G$,workLoad:D}),R.dAddOffset(w,0)}}}function O(H,q){var F=new J(H,q),K=H-1;if(!F.testBit(K))F.bitwiseTo(J.ONE.shiftLeft(K),Y,F);return F.dAddOffset(31-F.mod(Q).byteValue(),0),F}function V(H){if(H<=100)return 27;if(H<=150)return 18;if(H<=200)return 15;if(H<=250)return 12;if(H<=300)return 9;if(H<=350)return 8;if(H<=400)return 7;if(H<=500)return 6;if(H<=600)return 5;if(H<=800)return 4;if(H<=1250)return 3;return 2}})()});var NX=M$((FE,rG)=>{var t=K$();gJ();FX();S0();s9();t9();PJ();C$();if(typeof B$>"u")B$=t.jsbn.BigInteger;var B$,e9=t.util.isNodejs?YX("crypto"):null,I=t.asn1,xJ=t.util;t.pki=t.pki||{};rG.exports=t.pki.rsa=t.rsa=t.rsa||{};var U$=t.pki,BO=[6,4,2,4,2,4,6,2],jO={name:"PrivateKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},TO={name:"RSAPrivateKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},SO={name:"RSAPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:I.Class.UNIVERSAL,type:I.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},IO=t.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},CO={name:"DigestInfo",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:I.Class.UNIVERSAL,type:I.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:I.Class.UNIVERSAL,type:I.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:I.Class.UNIVERSAL,type:I.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:I.Class.UNIVERSAL,type:I.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},wO=function($){var J;if($.algorithm in U$.oids)J=U$.oids[$.algorithm];else{var X=Error("Unknown message digest algorithm.");throw X.algorithm=$.algorithm,X}var Q=I.oidToDer(J).getBytes(),Y=I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[]),G=I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[]);G.value.push(I.create(I.Class.UNIVERSAL,I.Type.OID,!1,Q)),G.value.push(I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,""));var W=I.create(I.Class.UNIVERSAL,I.Type.OCTETSTRING,!1,$.digest().getBytes());return Y.value.push(G),Y.value.push(W),I.toDer(Y).getBytes()},aG=function($,J,X){if(X)return $.modPow(J.e,J.n);if(!J.p||!J.q)return $.modPow(J.d,J.n);if(!J.dP)J.dP=J.d.mod(J.p.subtract(B$.ONE));if(!J.dQ)J.dQ=J.d.mod(J.q.subtract(B$.ONE));if(!J.qInv)J.qInv=J.q.modInverse(J.p);var Q;do Q=new B$(t.util.bytesToHex(t.random.getBytes(J.n.bitLength()/8)),16);while(Q.compareTo(J.n)>=0||!Q.gcd(J.n).equals(B$.ONE));$=$.multiply(Q.modPow(J.e,J.n)).mod(J.n);var Y=$.mod(J.p).modPow(J.dP,J.p),G=$.mod(J.q).modPow(J.dQ,J.q);while(Y.compareTo(G)<0)Y=Y.add(J.p);var W=Y.subtract(G).multiply(J.qInv).mod(J.p).multiply(J.q).add(G);return W=W.multiply(Q.modInverse(J.n)).mod(J.n),W};U$.rsa.encrypt=function($,J,X){var Q=X,Y,G=Math.ceil(J.n.bitLength()/8);if(X!==!1&&X!==!0)Q=X===2,Y=sG($,J,X);else Y=t.util.createBuffer(),Y.putBytes($);var W=new B$(Y.toHex(),16),M=aG(W,J,Q),U=M.toString(16),O=t.util.createBuffer(),V=G-Math.ceil(U.length/2);while(V>0)O.putByte(0),--V;return O.putBytes(t.util.hexToBytes(U)),O.getBytes()};U$.rsa.decrypt=function($,J,X,Q){var Y=Math.ceil(J.n.bitLength()/8);if($.length!==Y){var G=Error("Encrypted message length is invalid.");throw G.length=$.length,G.expected=Y,G}var W=new B$(t.util.createBuffer($).toHex(),16);if(W.compareTo(J.n)>=0)throw Error("Encrypted message is invalid.");var M=aG(W,J,X),U=M.toString(16),O=t.util.createBuffer(),V=Y-Math.ceil(U.length/2);while(V>0)O.putByte(0),--V;if(O.putBytes(t.util.hexToBytes(U)),Q!==!1)return AY(O.getBytes(),J,X);return O.getBytes()};U$.rsa.createKeyPairGenerationState=function($,J,X){if(typeof $==="string")$=parseInt($,10);$=$||2048,X=X||{};var Q=X.prng||t.random,Y={nextBytes:function(M){var U=Q.getBytesSync(M.length);for(var O=0;O<M.length;++O)M[O]=U.charCodeAt(O)}},G=X.algorithm||"PRIMEINC",W;if(G==="PRIMEINC")W={algorithm:G,state:0,bits:$,rng:Y,eInt:J||65537,e:new B$(null),p:null,q:null,qBits:$>>1,pBits:$-($>>1),pqState:0,num:null,keys:null},W.e.fromInt(W.eInt);else throw Error("Invalid key generation algorithm: "+G);return W};U$.rsa.stepKeyPairGenerationState=function($,J){if(!("algorithm"in $))$.algorithm="PRIMEINC";var X=new B$(null);X.fromInt(30);var Q=0,Y=function(H,q){return H|q},G=+new Date,W,M=0;while($.keys===null&&(J<=0||M<J)){if($.state===0){var U=$.p===null?$.pBits:$.qBits,O=U-1;if($.pqState===0){if($.num=new B$(U,$.rng),!$.num.testBit(O))$.num.bitwiseTo(B$.ONE.shiftLeft(O),Y,$.num);$.num.dAddOffset(31-$.num.mod(X).byteValue(),0),Q=0,++$.pqState}else if($.pqState===1)if($.num.bitLength()>U)$.pqState=0;else if($.num.isProbablePrime(_O($.num.bitLength())))++$.pqState;else $.num.dAddOffset(BO[Q++%8],0);else if($.pqState===2)$.pqState=$.num.subtract(B$.ONE).gcd($.e).compareTo(B$.ONE)===0?3:0;else if($.pqState===3){if($.pqState=0,$.p===null)$.p=$.num;else $.q=$.num;if($.p!==null&&$.q!==null)++$.state;$.num=null}}else if($.state===1){if($.p.compareTo($.q)<0)$.num=$.p,$.p=$.q,$.q=$.num;++$.state}else if($.state===2)$.p1=$.p.subtract(B$.ONE),$.q1=$.q.subtract(B$.ONE),$.phi=$.p1.multiply($.q1),++$.state;else if($.state===3)if($.phi.gcd($.e).compareTo(B$.ONE)===0)++$.state;else $.p=null,$.q=null,$.state=0;else if($.state===4)if($.n=$.p.multiply($.q),$.n.bitLength()===$.bits)++$.state;else $.q=null,$.state=0;else if($.state===5){var V=$.e.modInverse($.phi);$.keys={privateKey:U$.rsa.setPrivateKey($.n,$.e,V,$.p,$.q,V.mod($.p1),V.mod($.q1),$.q.modInverse($.p)),publicKey:U$.rsa.setPublicKey($.n,$.e)}}W=+new Date,M+=W-G,G=W}return $.keys!==null};U$.rsa.generateKeyPair=function($,J,X,Q){if(arguments.length===1){if(typeof $==="object")X=$,$=void 0;else if(typeof $==="function")Q=$,$=void 0}else if(arguments.length===2)if(typeof $==="number"){if(typeof J==="function")Q=J,J=void 0;else if(typeof J!=="number")X=J,J=void 0}else X=$,Q=J,$=void 0,J=void 0;else if(arguments.length===3)if(typeof J==="number"){if(typeof X==="function")Q=X,X=void 0}else Q=X,X=J,J=void 0;if(X=X||{},$===void 0)$=X.bits||2048;if(J===void 0)J=X.e||65537;if(!t.options.usePureJavaScript&&!X.prng&&$>=256&&$<=16384&&(J===65537||J===3)){if(Q){if(cG("generateKeyPair"))return e9.generateKeyPair("rsa",{modulusLength:$,publicExponent:J,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(M,U,O){if(M)return Q(M);Q(null,{privateKey:U$.privateKeyFromPem(O),publicKey:U$.publicKeyFromPem(U)})});if(nG("generateKey")&&nG("exportKey"))return xJ.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:$,publicExponent:oG(J),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(M){return xJ.globalScope.crypto.subtle.exportKey("pkcs8",M.privateKey)}).then(void 0,function(M){Q(M)}).then(function(M){if(M){var U=U$.privateKeyFromAsn1(I.fromDer(t.util.createBuffer(M)));Q(null,{privateKey:U,publicKey:U$.setRsaPublicKey(U.n,U.e)})}});if(iG("generateKey")&&iG("exportKey")){var Y=xJ.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:$,publicExponent:oG(J),hash:{name:"SHA-256"}},!0,["sign","verify"]);Y.oncomplete=function(M){var U=M.target.result,O=xJ.globalScope.msCrypto.subtle.exportKey("pkcs8",U.privateKey);O.oncomplete=function(V){var H=V.target.result,q=U$.privateKeyFromAsn1(I.fromDer(t.util.createBuffer(H)));Q(null,{privateKey:q,publicKey:U$.setRsaPublicKey(q.n,q.e)})},O.onerror=function(V){Q(V)}},Y.onerror=function(M){Q(M)};return}}else if(cG("generateKeyPairSync")){var G=e9.generateKeyPairSync("rsa",{modulusLength:$,publicExponent:J,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:U$.privateKeyFromPem(G.privateKey),publicKey:U$.publicKeyFromPem(G.publicKey)}}}var W=U$.rsa.createKeyPairGenerationState($,J,X);if(!Q)return U$.rsa.stepKeyPairGenerationState(W,0),W.keys;PO(W,X,Q)};U$.setRsaPublicKey=U$.rsa.setPublicKey=function($,J){var X={n:$,e:J};return X.encrypt=function(Q,Y,G){if(typeof Y==="string")Y=Y.toUpperCase();else if(Y===void 0)Y="RSAES-PKCS1-V1_5";if(Y==="RSAES-PKCS1-V1_5")Y={encode:function(M,U,O){return sG(M,U,2).getBytes()}};else if(Y==="RSA-OAEP"||Y==="RSAES-OAEP")Y={encode:function(M,U){return t.pkcs1.encode_rsa_oaep(U,M,G)}};else if(["RAW","NONE","NULL",null].indexOf(Y)!==-1)Y={encode:function(M){return M}};else if(typeof Y==="string")throw Error('Unsupported encryption scheme: "'+Y+'".');var W=Y.encode(Q,X,!0);return U$.rsa.encrypt(W,X,!0)},X.verify=function(Q,Y,G,W){if(typeof G==="string")G=G.toUpperCase();else if(G===void 0)G="RSASSA-PKCS1-V1_5";if(W===void 0)W={_parseAllDigestBytes:!0,_skipPaddingChecks:!1};if(!("_parseAllDigestBytes"in W))W._parseAllDigestBytes=!0;if(!("_skipPaddingChecks"in W))W._skipPaddingChecks=!1;if(G==="RSASSA-PKCS1-V1_5")G={verify:function(U,O){O=AY(O,X,!0,void 0,W);var V=I.fromDer(O,{parseAllBytes:W._parseAllDigestBytes}),H={},q=[];if(!I.validate(V,CO,H,q)||V.value.length!==2){var F=Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw F.errors=q,F}var K=I.derToOid(H.algorithmIdentifier);if(!(K===t.oids.md2||K===t.oids.md5||K===t.oids.sha1||K===t.oids.sha224||K===t.oids.sha256||K===t.oids.sha384||K===t.oids.sha512||K===t.oids["sha512-224"]||K===t.oids["sha512-256"])){var F=Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw F.oid=K,F}if(K===t.oids.md2||K===t.oids.md5){if(!("parameters"in H))throw Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.")}return U===H.digest}};else if(G==="NONE"||G==="NULL"||G===null)G={verify:function(U,O){return O=AY(O,X,!0,void 0,W),U===O}};var M=U$.rsa.decrypt(Y,X,!0,!1);return G.verify(Q,M,X.n.bitLength())},X};U$.setRsaPrivateKey=U$.rsa.setPrivateKey=function($,J,X,Q,Y,G,W,M){var U={n:$,e:J,d:X,p:Q,q:Y,dP:G,dQ:W,qInv:M};return U.decrypt=function(O,V,H){if(typeof V==="string")V=V.toUpperCase();else if(V===void 0)V="RSAES-PKCS1-V1_5";var q=U$.rsa.decrypt(O,U,!1,!1);if(V==="RSAES-PKCS1-V1_5")V={decode:AY};else if(V==="RSA-OAEP"||V==="RSAES-OAEP")V={decode:function(F,K){return t.pkcs1.decode_rsa_oaep(K,F,H)}};else if(["RAW","NONE","NULL",null].indexOf(V)!==-1)V={decode:function(F){return F}};else throw Error('Unsupported encryption scheme: "'+V+'".');return V.decode(q,U,!1)},U.sign=function(O,V){var H=!1;if(typeof V==="string")V=V.toUpperCase();if(V===void 0||V==="RSASSA-PKCS1-V1_5")V={encode:wO},H=1;else if(V==="NONE"||V==="NULL"||V===null)V={encode:function(){return O}},H=1;var q=V.encode(O,U.n.bitLength());return U$.rsa.encrypt(q,U,H)},U};U$.wrapRsaPrivateKey=function($){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,I.integerToDer(0).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.OID,!1,I.oidToDer(U$.oids.rsaEncryption).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,"")]),I.create(I.Class.UNIVERSAL,I.Type.OCTETSTRING,!1,I.toDer($).getBytes())])};U$.privateKeyFromAsn1=function($){var J={},X=[];if(I.validate($,jO,J,X))$=I.fromDer(t.util.createBuffer(J.privateKey));if(J={},X=[],!I.validate($,TO,J,X)){var Q=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw Q.errors=X,Q}var Y,G,W,M,U,O,V,H;return Y=t.util.createBuffer(J.privateKeyModulus).toHex(),G=t.util.createBuffer(J.privateKeyPublicExponent).toHex(),W=t.util.createBuffer(J.privateKeyPrivateExponent).toHex(),M=t.util.createBuffer(J.privateKeyPrime1).toHex(),U=t.util.createBuffer(J.privateKeyPrime2).toHex(),O=t.util.createBuffer(J.privateKeyExponent1).toHex(),V=t.util.createBuffer(J.privateKeyExponent2).toHex(),H=t.util.createBuffer(J.privateKeyCoefficient).toHex(),U$.setRsaPrivateKey(new B$(Y,16),new B$(G,16),new B$(W,16),new B$(M,16),new B$(U,16),new B$(O,16),new B$(V,16),new B$(H,16))};U$.privateKeyToAsn1=U$.privateKeyToRSAPrivateKey=function($){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,I.integerToDer(0).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.n)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.e)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.d)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.p)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.q)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.dP)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.dQ)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.qInv))])};U$.publicKeyFromAsn1=function($){var J={},X=[];if(I.validate($,IO,J,X)){var Q=I.derToOid(J.publicKeyOid);if(Q!==U$.oids.rsaEncryption){var Y=Error("Cannot read public key. Unknown OID.");throw Y.oid=Q,Y}$=J.rsaPublicKey}if(X=[],!I.validate($,SO,J,X)){var Y=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw Y.errors=X,Y}var G=t.util.createBuffer(J.publicKeyModulus).toHex(),W=t.util.createBuffer(J.publicKeyExponent).toHex();return U$.setRsaPublicKey(new B$(G,16),new B$(W,16))};U$.publicKeyToAsn1=U$.publicKeyToSubjectPublicKeyInfo=function($){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.OID,!1,I.oidToDer(U$.oids.rsaEncryption).getBytes()),I.create(I.Class.UNIVERSAL,I.Type.NULL,!1,"")]),I.create(I.Class.UNIVERSAL,I.Type.BITSTRING,!1,[U$.publicKeyToRSAPublicKey($)])])};U$.publicKeyToRSAPublicKey=function($){return I.create(I.Class.UNIVERSAL,I.Type.SEQUENCE,!0,[I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.n)),I.create(I.Class.UNIVERSAL,I.Type.INTEGER,!1,Y0($.e))])};function sG($,J,X){var Q=t.util.createBuffer(),Y=Math.ceil(J.n.bitLength()/8);if($.length>Y-11){var G=Error("Message is too long for PKCS#1 v1.5 padding.");throw G.length=$.length,G.max=Y-11,G}Q.putByte(0),Q.putByte(X);var W=Y-3-$.length,M;if(X===0||X===1){M=X===0?0:255;for(var U=0;U<W;++U)Q.putByte(M)}else while(W>0){var O=0,V=t.random.getBytes(W);for(var U=0;U<W;++U)if(M=V.charCodeAt(U),M===0)++O;else Q.putByte(M);W=O}return Q.putByte(0),Q.putBytes($),Q}function AY($,J,X,Q,Y){var G=Math.ceil(J.n.bitLength()/8),W=t.util.createBuffer($),M=W.getByte(),U=W.getByte();if(M!==0||X&&U!==0&&U!==1||!X&&U!==2||X&&U===0&&typeof Q>"u")throw Error("Encryption block is invalid.");var O=0;if(U===0){O=G-3-Q;for(var V=0;V<O;++V)if(W.getByte()!==0)throw Error("Encryption block is invalid.")}else if(U===1){O=0;while(W.length()>1){if(W.getByte()!==255){--W.read;break}++O}if(O<8&&!(Y?Y._skipPaddingChecks:!1))throw Error("Encryption block is invalid.")}else if(U===2){O=0;while(W.length()>1){if(W.getByte()===0){--W.read;break}++O}if(O<8&&!(Y?Y._skipPaddingChecks:!1))throw Error("Encryption block is invalid.")}var H=W.getByte();if(H!==0||O!==G-3-W.length())throw Error("Encryption block is invalid.");return W.getBytes()}function PO($,J,X){if(typeof J==="function")X=J,J={};J=J||{};var Q={algorithm:{name:J.algorithm||"PRIMEINC",options:{workers:J.workers||2,workLoad:J.workLoad||100,workerScript:J.workerScript}}};if("prng"in J)Q.prng=J.prng;Y();function Y(){G($.pBits,function(M,U){if(M)return X(M);if($.p=U,$.q!==null)return W(M,$.q);G($.qBits,W)})}function G(M,U){t.prime.generateProbablePrime(M,Q,U)}function W(M,U){if(M)return X(M);if($.q=U,$.p.compareTo($.q)<0){var O=$.p;$.p=$.q,$.q=O}if($.p.subtract(B$.ONE).gcd($.e).compareTo(B$.ONE)!==0){$.p=null,Y();return}if($.q.subtract(B$.ONE).gcd($.e).compareTo(B$.ONE)!==0){$.q=null,G($.qBits,W);return}if($.p1=$.p.subtract(B$.ONE),$.q1=$.q.subtract(B$.ONE),$.phi=$.p1.multiply($.q1),$.phi.gcd($.e).compareTo(B$.ONE)!==0){$.p=$.q=null,Y();return}if($.n=$.p.multiply($.q),$.n.bitLength()!==$.bits){$.q=null,G($.qBits,W);return}var V=$.e.modInverse($.phi);$.keys={privateKey:U$.rsa.setPrivateKey($.n,$.e,V,$.p,$.q,V.mod($.p1),V.mod($.q1),$.q.modInverse($.p)),publicKey:U$.rsa.setPublicKey($.n,$.e)},X(null,$.keys)}}function Y0($){var J=$.toString(16);if(J[0]>="8")J="00"+J;var X=t.util.hexToBytes(J);if(X.length>1&&(X.charCodeAt(0)===0&&(X.charCodeAt(1)&128)===0||X.charCodeAt(0)===255&&(X.charCodeAt(1)&128)===128))return X.substr(1);return X}function _O($){if($<=100)return 27;if($<=150)return 18;if($<=200)return 15;if($<=250)return 12;if($<=300)return 9;if($<=350)return 8;if($<=400)return 7;if($<=500)return 6;if($<=600)return 5;if($<=800)return 4;if($<=1250)return 3;return 2}function cG($){return t.util.isNodejs&&typeof e9[$]==="function"}function nG($){return typeof xJ.globalScope<"u"&&typeof xJ.globalScope.crypto==="object"&&typeof xJ.globalScope.crypto.subtle==="object"&&typeof xJ.globalScope.crypto.subtle[$]==="function"}function iG($){return typeof xJ.globalScope<"u"&&typeof xJ.globalScope.msCrypto==="object"&&typeof xJ.globalScope.msCrypto.subtle==="object"&&typeof xJ.globalScope.msCrypto.subtle[$]==="function"}function oG($){var J=t.util.hexToBytes($.toString(16)),X=new Uint8Array(J.length);for(var Q=0;Q<J.length;++Q)X[Q]=J.charCodeAt(Q);return X}});var J8=M$((NE,J1)=>{var i=K$();T0();gJ();zX();rJ();S0();EY();t0();PJ();c9();NX();C$();if(typeof $8>"u")$8=i.jsbn.BigInteger;var $8,_=i.asn1,q$=i.pki=i.pki||{};J1.exports=q$.pbe=i.pbe=i.pbe||{};var JQ=q$.oids,xO={name:"EncryptedPrivateKeyInfo",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},vO={name:"PBES2Algorithms",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},kO={name:"pkcs-12PbeParams",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,capture:"iterations"}]};q$.encryptPrivateKeyInfo=function($,J,X){X=X||{},X.saltSize=X.saltSize||8,X.count=X.count||2048,X.algorithm=X.algorithm||"aes128",X.prfAlgorithm=X.prfAlgorithm||"sha1";var Q=i.random.getBytesSync(X.saltSize),Y=X.count,G=_.integerToDer(Y),W,M,U;if(X.algorithm.indexOf("aes")===0||X.algorithm==="des"){var O,V,H;switch(X.algorithm){case"aes128":W=16,O=16,V=JQ["aes128-CBC"],H=i.aes.createEncryptionCipher;break;case"aes192":W=24,O=16,V=JQ["aes192-CBC"],H=i.aes.createEncryptionCipher;break;case"aes256":W=32,O=16,V=JQ["aes256-CBC"],H=i.aes.createEncryptionCipher;break;case"des":W=8,O=8,V=JQ.desCBC,H=i.des.createEncryptionCipher;break;default:var q=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw q.algorithm=X.algorithm,q}var F="hmacWith"+X.prfAlgorithm.toUpperCase(),K=$1(F),R=i.pkcs5.pbkdf2(J,Q,Y,W,K),L=i.random.getBytesSync(O),D=H(R);D.start(L),D.update(_.toDer($)),D.finish(),U=D.output.getBytes();var w=fO(Q,G,W,F);M=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(JQ.pkcs5PBES2).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(JQ.pkcs5PBKDF2).getBytes()),w]),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(V).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,L)])])])}else if(X.algorithm==="3des"){W=24;var T=new i.util.ByteBuffer(Q),R=q$.pbe.generatePkcs12Key(J,T,1,Y,W),L=q$.pbe.generatePkcs12Key(J,T,2,Y,W),D=i.des.createEncryptionCipher(R);D.start(L),D.update(_.toDer($)),D.finish(),U=D.output.getBytes(),M=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(JQ["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,Q),_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,G.getBytes())])])}else{var q=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw q.algorithm=X.algorithm,q}var P=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[M,_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,U)]);return P};q$.decryptPrivateKeyInfo=function($,J){var X=null,Q={},Y=[];if(!_.validate($,xO,Q,Y)){var G=Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}var W=_.derToOid(Q.encryptionOid),M=q$.pbe.getCipher(W,Q.encryptionParams,J),U=i.util.createBuffer(Q.encryptedData);if(M.update(U),M.finish())X=_.fromDer(M.output);return X};q$.encryptedPrivateKeyToPem=function($,J){var X={type:"ENCRYPTED PRIVATE KEY",body:_.toDer($).getBytes()};return i.pem.encode(X,{maxline:J})};q$.encryptedPrivateKeyFromPem=function($){var J=i.pem.decode($)[0];if(J.type!=="ENCRYPTED PRIVATE KEY"){var X=Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return _.fromDer(J.body)};q$.encryptRsaPrivateKey=function($,J,X){if(X=X||{},!X.legacy){var Q=q$.wrapRsaPrivateKey(q$.privateKeyToAsn1($));return Q=q$.encryptPrivateKeyInfo(Q,J,X),q$.encryptedPrivateKeyToPem(Q)}var Y,G,W,M;switch(X.algorithm){case"aes128":Y="AES-128-CBC",W=16,G=i.random.getBytesSync(16),M=i.aes.createEncryptionCipher;break;case"aes192":Y="AES-192-CBC",W=24,G=i.random.getBytesSync(16),M=i.aes.createEncryptionCipher;break;case"aes256":Y="AES-256-CBC",W=32,G=i.random.getBytesSync(16),M=i.aes.createEncryptionCipher;break;case"3des":Y="DES-EDE3-CBC",W=24,G=i.random.getBytesSync(8),M=i.des.createEncryptionCipher;break;case"des":Y="DES-CBC",W=8,G=i.random.getBytesSync(8),M=i.des.createEncryptionCipher;break;default:var U=Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+X.algorithm+'".');throw U.algorithm=X.algorithm,U}var O=i.pbe.opensslDeriveBytes(J,G.substr(0,8),W),V=M(O);V.start(G),V.update(_.toDer(q$.privateKeyToAsn1($))),V.finish();var H={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:Y,parameters:i.util.bytesToHex(G).toUpperCase()},body:V.output.getBytes()};return i.pem.encode(H)};q$.decryptRsaPrivateKey=function($,J){var X=null,Q=i.pem.decode($)[0];if(Q.type!=="ENCRYPTED PRIVATE KEY"&&Q.type!=="PRIVATE KEY"&&Q.type!=="RSA PRIVATE KEY"){var Y=Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw Y.headerType=Y,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED"){var G,W;switch(Q.dekInfo.algorithm){case"DES-CBC":G=8,W=i.des.createDecryptionCipher;break;case"DES-EDE3-CBC":G=24,W=i.des.createDecryptionCipher;break;case"AES-128-CBC":G=16,W=i.aes.createDecryptionCipher;break;case"AES-192-CBC":G=24,W=i.aes.createDecryptionCipher;break;case"AES-256-CBC":G=32,W=i.aes.createDecryptionCipher;break;case"RC2-40-CBC":G=5,W=function(H){return i.rc2.createDecryptionCipher(H,40)};break;case"RC2-64-CBC":G=8,W=function(H){return i.rc2.createDecryptionCipher(H,64)};break;case"RC2-128-CBC":G=16,W=function(H){return i.rc2.createDecryptionCipher(H,128)};break;default:var Y=Error('Could not decrypt private key; unsupported encryption algorithm "'+Q.dekInfo.algorithm+'".');throw Y.algorithm=Q.dekInfo.algorithm,Y}var M=i.util.hexToBytes(Q.dekInfo.parameters),U=i.pbe.opensslDeriveBytes(J,M.substr(0,8),G),O=W(U);if(O.start(M),O.update(i.util.createBuffer(Q.body)),O.finish())X=O.output.getBytes();else return X}else X=Q.body;if(Q.type==="ENCRYPTED PRIVATE KEY")X=q$.decryptPrivateKeyInfo(_.fromDer(X),J);else X=_.fromDer(X);if(X!==null)X=q$.privateKeyFromAsn1(X);return X};q$.pbe.generatePkcs12Key=function($,J,X,Q,Y,G){var W,M;if(typeof G>"u"||G===null){if(!("sha1"in i.md))throw Error('"sha1" hash algorithm unavailable.');G=i.md.sha1.create()}var{digestLength:U,blockLength:O}=G,V=new i.util.ByteBuffer,H=new i.util.ByteBuffer;if($!==null&&$!==void 0){for(M=0;M<$.length;M++)H.putInt16($.charCodeAt(M));H.putInt16(0)}var q=H.length(),F=J.length(),K=new i.util.ByteBuffer;K.fillWithByte(X,O);var R=O*Math.ceil(F/O),L=new i.util.ByteBuffer;for(M=0;M<R;M++)L.putByte(J.at(M%F));var D=O*Math.ceil(q/O),w=new i.util.ByteBuffer;for(M=0;M<D;M++)w.putByte(H.at(M%q));var T=L;T.putBuffer(w);var P=Math.ceil(Y/U);for(var S=1;S<=P;S++){var C=new i.util.ByteBuffer;C.putBytes(K.bytes()),C.putBytes(T.bytes());for(var h=0;h<Q;h++)G.start(),G.update(C.getBytes()),C=G.digest();var s=new i.util.ByteBuffer;for(M=0;M<O;M++)s.putByte(C.at(M%U));var a=Math.ceil(F/O)+Math.ceil(q/O),O$=new i.util.ByteBuffer;for(W=0;W<a;W++){var j$=new i.util.ByteBuffer(T.getBytes(O)),T$=511;for(M=s.length()-1;M>=0;M--)T$=T$>>8,T$+=s.at(M)+j$.at(M),j$.setAt(M,T$&255);O$.putBuffer(j$)}T=O$,V.putBuffer(C)}return V.truncate(V.length()-Y),V};q$.pbe.getCipher=function($,J,X){switch($){case q$.oids.pkcs5PBES2:return q$.pbe.getCipherForPBES2($,J,X);case q$.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case q$.oids["pbewithSHAAnd40BitRC2-CBC"]:return q$.pbe.getCipherForPKCS12PBE($,J,X);default:var Q=Error("Cannot read encrypted PBE data block. Unsupported OID.");throw Q.oid=$,Q.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],Q}};q$.pbe.getCipherForPBES2=function($,J,X){var Q={},Y=[];if(!_.validate(J,vO,Q,Y)){var G=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}if($=_.derToOid(Q.kdfOid),$!==q$.oids.pkcs5PBKDF2){var G=Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw G.oid=$,G.supportedOids=["pkcs5PBKDF2"],G}if($=_.derToOid(Q.encOid),$!==q$.oids["aes128-CBC"]&&$!==q$.oids["aes192-CBC"]&&$!==q$.oids["aes256-CBC"]&&$!==q$.oids["des-EDE3-CBC"]&&$!==q$.oids.desCBC){var G=Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw G.oid=$,G.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],G}var W=Q.kdfSalt,M=i.util.createBuffer(Q.kdfIterationCount);M=M.getInt(M.length()<<3);var U,O;switch(q$.oids[$]){case"aes128-CBC":U=16,O=i.aes.createDecryptionCipher;break;case"aes192-CBC":U=24,O=i.aes.createDecryptionCipher;break;case"aes256-CBC":U=32,O=i.aes.createDecryptionCipher;break;case"des-EDE3-CBC":U=24,O=i.des.createDecryptionCipher;break;case"desCBC":U=8,O=i.des.createDecryptionCipher;break}var V=eG(Q.prfOid),H=i.pkcs5.pbkdf2(X,W,M,U,V),q=Q.encIv,F=O(H);return F.start(q),F};q$.pbe.getCipherForPKCS12PBE=function($,J,X){var Q={},Y=[];if(!_.validate(J,kO,Q,Y)){var G=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}var W=i.util.createBuffer(Q.salt),M=i.util.createBuffer(Q.iterations);M=M.getInt(M.length()<<3);var U,O,V;switch($){case q$.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:U=24,O=8,V=i.des.startDecrypting;break;case q$.oids["pbewithSHAAnd40BitRC2-CBC"]:U=5,O=8,V=function(R,L){var D=i.rc2.createDecryptionCipher(R,40);return D.start(L,null),D};break;default:var G=Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw G.oid=$,G}var H=eG(Q.prfOid),q=q$.pbe.generatePkcs12Key(X,W,1,M,U,H);H.start();var F=q$.pbe.generatePkcs12Key(X,W,2,M,O,H);return V(q,F)};q$.pbe.opensslDeriveBytes=function($,J,X,Q){if(typeof Q>"u"||Q===null){if(!("md5"in i.md))throw Error('"md5" hash algorithm unavailable.');Q=i.md.md5.create()}if(J===null)J="";var Y=[tG(Q,$+J)];for(var G=16,W=1;G<X;++W,G+=16)Y.push(tG(Q,Y[W-1]+$+J));return Y.join("").substr(0,X)};function tG($,J){return $.start().update(J).digest().getBytes()}function eG($){var J;if(!$)J="hmacWithSHA1";else if(J=q$.oids[_.derToOid($)],!J){var X=Error("Unsupported PRF OID.");throw X.oid=$,X.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],X}return $1(J)}function $1($){var J=i.md;switch($){case"hmacWithSHA224":J=i.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":$=$.substr(8).toLowerCase();break;default:var X=Error("Unsupported PRF algorithm.");throw X.algorithm=$,X.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],X}if(!J||!($ in J))throw Error("Unknown hash algorithm: "+$);return J[$].create()}function fO($,J,X,Q){var Y=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,$),_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,J.getBytes())]);if(Q!=="hmacWithSHA1")Y.value.push(_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,i.util.hexToBytes(X.toString(16))),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(q$.oids[Q]).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.NULL,!1,"")]));return Y}});var Q8=M$((LE,Y1)=>{var SQ=K$();gJ();C$();var n=SQ.asn1,IQ=Y1.exports=SQ.pkcs7asn1=SQ.pkcs7asn1||{};SQ.pkcs7=SQ.pkcs7||{};SQ.pkcs7.asn1=IQ;var Q1={name:"ContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};IQ.contentInfoValidator=Q1;var X1={name:"EncryptedContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};IQ.envelopedDataValidator={name:"EnvelopedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(X1)};IQ.encryptedDataValidator={name:"EncryptedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"}].concat(X1)};var yO={name:"SignerInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};IQ.signedDataValidator={name:"SignedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},Q1,{name:"SignedData.Certificates",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,capture:"signerInfos",optional:!0,value:[yO]}]};IQ.recipientInfoValidator={name:"RecipientInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var X8=M$((RE,G1)=>{var QQ=K$();C$();QQ.mgf=QQ.mgf||{};var bO=G1.exports=QQ.mgf.mgf1=QQ.mgf1=QQ.mgf1||{};bO.create=function($){var J={generate:function(X,Q){var Y=new QQ.util.ByteBuffer,G=Math.ceil(Q/$.digestLength);for(var W=0;W<G;W++){var M=new QQ.util.ByteBuffer;M.putInt32(W),$.start(),$.update(X+M.getBytes()),Y.putBuffer($.digest())}return Y.truncate(Y.length()-Q),Y.getBytes()}};return J}});var M1=M$((AE,W1)=>{var DY=K$();X8();W1.exports=DY.mgf=DY.mgf||{};DY.mgf.mgf1=DY.mgf1});var ZY=M$((DE,U1)=>{var XQ=K$();PJ();C$();var hO=U1.exports=XQ.pss=XQ.pss||{};hO.create=function($){if(arguments.length===3)$={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]};var{md:J,mgf:X}=$,Q=J.digestLength,Y=$.salt||null;if(typeof Y==="string")Y=XQ.util.createBuffer(Y);var G;if("saltLength"in $)G=$.saltLength;else if(Y!==null)G=Y.length();else throw Error("Salt length not specified or specific salt not given.");if(Y!==null&&Y.length()!==G)throw Error("Given salt length does not match length of given salt.");var W=$.prng||XQ.random,M={};return M.encode=function(U,O){var V,H=O-1,q=Math.ceil(H/8),F=U.digest().getBytes();if(q<Q+G+2)throw Error("Message is too long to encrypt.");var K;if(Y===null)K=W.getBytesSync(G);else K=Y.bytes();var R=new XQ.util.ByteBuffer;R.fillWithByte(0,8),R.putBytes(F),R.putBytes(K),J.start(),J.update(R.getBytes());var L=J.digest().getBytes(),D=new XQ.util.ByteBuffer;D.fillWithByte(0,q-G-Q-2),D.putByte(1),D.putBytes(K);var w=D.getBytes(),T=q-Q-1,P=X.generate(L,T),S="";for(V=0;V<T;V++)S+=String.fromCharCode(w.charCodeAt(V)^P.charCodeAt(V));var C=65280>>8*q-H&255;return S=String.fromCharCode(S.charCodeAt(0)&~C)+S.substr(1),S+L+String.fromCharCode(188)},M.verify=function(U,O,V){var H,q=V-1,F=Math.ceil(q/8);if(O=O.substr(-F),F<Q+G+2)throw Error("Inconsistent parameters to PSS signature verification.");if(O.charCodeAt(F-1)!==188)throw Error("Encoded message does not end in 0xBC.");var K=F-Q-1,R=O.substr(0,K),L=O.substr(K,Q),D=65280>>8*F-q&255;if((R.charCodeAt(0)&D)!==0)throw Error("Bits beyond keysize not zero as expected.");var w=X.generate(L,K),T="";for(H=0;H<K;H++)T+=String.fromCharCode(R.charCodeAt(H)^w.charCodeAt(H));T=String.fromCharCode(T.charCodeAt(0)&~D)+T.substr(1);var P=F-Q-G-2;for(H=0;H<P;H++)if(T.charCodeAt(H)!==0)throw Error("Leftmost octets not zero as expected");if(T.charCodeAt(P)!==1)throw Error("Inconsistent PSS signature, 0x01 marker not found");var S=T.substr(-G),C=new XQ.util.ByteBuffer;C.fillWithByte(0,8),C.putBytes(U),C.putBytes(S),J.start(),J.update(C.getBytes());var h=J.digest().getBytes();return L===h},M}});var TY=M$((ZE,K1)=>{var e=K$();T0();gJ();zX();rJ();M1();S0();t0();ZY();NX();C$();var z=e.asn1,u=K1.exports=e.pki=e.pki||{},I$=u.oids,n$={};n$.CN=I$.commonName;n$.commonName="CN";n$.C=I$.countryName;n$.countryName="C";n$.L=I$.localityName;n$.localityName="L";n$.ST=I$.stateOrProvinceName;n$.stateOrProvinceName="ST";n$.O=I$.organizationName;n$.organizationName="O";n$.OU=I$.organizationalUnitName;n$.organizationalUnitName="OU";n$.E=I$.emailAddress;n$.emailAddress="E";var V1=e.pki.rsa.publicKeyValidator,uO={name:"Certificate",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:z.Class.UNIVERSAL,type:z.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:z.Class.UNIVERSAL,type:z.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:z.Class.UNIVERSAL,type:z.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:z.Class.UNIVERSAL,type:z.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},V1,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:z.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:z.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:z.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},gO={name:"rsapss",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:z.Class.UNIVERSAL,type:z.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:z.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:z.Class.UNIVERSAL,type:z.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:z.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:z.Class.UNIVERSAL,type:z.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:z.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:z.Class.UNIVERSAL,type:z.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},mO={name:"CertificationRequestInfo",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},V1,{name:"CertificationRequestInfo.attributes",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:z.Class.UNIVERSAL,type:z.Type.SET,constructed:!0}]}]}]},lO={name:"CertificationRequest",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[mO,{name:"CertificationRequest.signatureAlgorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};u.RDNAttributesAsArray=function($,J){var X=[],Q,Y,G;for(var W=0;W<$.value.length;++W){Q=$.value[W];for(var M=0;M<Q.value.length;++M){if(G={},Y=Q.value[M],G.type=z.derToOid(Y.value[0].value),G.value=Y.value[1].value,G.valueTagClass=Y.value[1].type,G.type in I$){if(G.name=I$[G.type],G.name in n$)G.shortName=n$[G.name]}if(J)J.update(G.type),J.update(G.value);X.push(G)}}return X};u.CRIAttributesAsArray=function($){var J=[];for(var X=0;X<$.length;++X){var Q=$[X],Y=z.derToOid(Q.value[0].value),G=Q.value[1].value;for(var W=0;W<G.length;++W){var M={};if(M.type=Y,M.value=G[W].value,M.valueTagClass=G[W].type,M.type in I$){if(M.name=I$[M.type],M.name in n$)M.shortName=n$[M.name]}if(M.type===I$.extensionRequest){M.extensions=[];for(var U=0;U<M.value.length;++U)M.extensions.push(u.certificateExtensionFromAsn1(M.value[U]))}J.push(M)}}return J};function w0($,J){if(typeof J==="string")J={shortName:J};var X=null,Q;for(var Y=0;X===null&&Y<$.attributes.length;++Y)if(Q=$.attributes[Y],J.type&&J.type===Q.type)X=Q;else if(J.name&&J.name===Q.name)X=Q;else if(J.shortName&&J.shortName===Q.shortName)X=Q;return X}var BY=function($,J,X){var Q={};if($!==I$["RSASSA-PSS"])return Q;if(X)Q={hash:{algorithmOid:I$.sha1},mgf:{algorithmOid:I$.mgf1,hash:{algorithmOid:I$.sha1}},saltLength:20};var Y={},G=[];if(!z.validate(J,gO,Y,G)){var W=Error("Cannot read RSASSA-PSS parameter block.");throw W.errors=G,W}if(Y.hashOid!==void 0)Q.hash=Q.hash||{},Q.hash.algorithmOid=z.derToOid(Y.hashOid);if(Y.maskGenOid!==void 0)Q.mgf=Q.mgf||{},Q.mgf.algorithmOid=z.derToOid(Y.maskGenOid),Q.mgf.hash=Q.mgf.hash||{},Q.mgf.hash.algorithmOid=z.derToOid(Y.maskGenHashOid);if(Y.saltLength!==void 0)Q.saltLength=Y.saltLength.charCodeAt(0);return Q},jY=function($){switch(I$[$.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return e.md.sha1.create();case"md5WithRSAEncryption":return e.md.md5.create();case"sha256WithRSAEncryption":return e.md.sha256.create();case"sha384WithRSAEncryption":return e.md.sha384.create();case"sha512WithRSAEncryption":return e.md.sha512.create();case"RSASSA-PSS":return e.md.sha256.create();default:var J=Error("Could not compute "+$.type+" digest. Unknown signature OID.");throw J.signatureOid=$.signatureOid,J}},H1=function($){var J=$.certificate,X;switch(J.signatureOid){case I$.sha1WithRSAEncryption:case I$.sha1WithRSASignature:break;case I$["RSASSA-PSS"]:var Q,Y;if(Q=I$[J.signatureParameters.mgf.hash.algorithmOid],Q===void 0||e.md[Q]===void 0){var G=Error("Unsupported MGF hash function.");throw G.oid=J.signatureParameters.mgf.hash.algorithmOid,G.name=Q,G}if(Y=I$[J.signatureParameters.mgf.algorithmOid],Y===void 0||e.mgf[Y]===void 0){var G=Error("Unsupported MGF function.");throw G.oid=J.signatureParameters.mgf.algorithmOid,G.name=Y,G}if(Y=e.mgf[Y].create(e.md[Q].create()),Q=I$[J.signatureParameters.hash.algorithmOid],Q===void 0||e.md[Q]===void 0){var G=Error("Unsupported RSASSA-PSS hash function.");throw G.oid=J.signatureParameters.hash.algorithmOid,G.name=Q,G}X=e.pss.create(e.md[Q].create(),Y,J.signatureParameters.saltLength);break}return J.publicKey.verify($.md.digest().getBytes(),$.signature,X)};u.certificateFromPem=function($,J,X){var Q=e.pem.decode($)[0];if(Q.type!=="CERTIFICATE"&&Q.type!=="X509 CERTIFICATE"&&Q.type!=="TRUSTED CERTIFICATE"){var Y=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw Y.headerType=Q.type,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED")throw Error("Could not convert certificate from PEM; PEM is encrypted.");var G=z.fromDer(Q.body,X);return u.certificateFromAsn1(G,J)};u.certificateToPem=function($,J){var X={type:"CERTIFICATE",body:z.toDer(u.certificateToAsn1($)).getBytes()};return e.pem.encode(X,{maxline:J})};u.publicKeyFromPem=function($){var J=e.pem.decode($)[0];if(J.type!=="PUBLIC KEY"&&J.type!=="RSA PUBLIC KEY"){var X=Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert public key from PEM; PEM is encrypted.");var Q=z.fromDer(J.body);return u.publicKeyFromAsn1(Q)};u.publicKeyToPem=function($,J){var X={type:"PUBLIC KEY",body:z.toDer(u.publicKeyToAsn1($)).getBytes()};return e.pem.encode(X,{maxline:J})};u.publicKeyToRSAPublicKeyPem=function($,J){var X={type:"RSA PUBLIC KEY",body:z.toDer(u.publicKeyToRSAPublicKey($)).getBytes()};return e.pem.encode(X,{maxline:J})};u.getPublicKeyFingerprint=function($,J){J=J||{};var X=J.md||e.md.sha1.create(),Q=J.type||"RSAPublicKey",Y;switch(Q){case"RSAPublicKey":Y=z.toDer(u.publicKeyToRSAPublicKey($)).getBytes();break;case"SubjectPublicKeyInfo":Y=z.toDer(u.publicKeyToAsn1($)).getBytes();break;default:throw Error('Unknown fingerprint type "'+J.type+'".')}X.start(),X.update(Y);var G=X.digest();if(J.encoding==="hex"){var W=G.toHex();if(J.delimiter)return W.match(/.{2}/g).join(J.delimiter);return W}else if(J.encoding==="binary")return G.getBytes();else if(J.encoding)throw Error('Unknown encoding "'+J.encoding+'".');return G};u.certificationRequestFromPem=function($,J,X){var Q=e.pem.decode($)[0];if(Q.type!=="CERTIFICATE REQUEST"){var Y=Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw Y.headerType=Q.type,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED")throw Error("Could not convert certification request from PEM; PEM is encrypted.");var G=z.fromDer(Q.body,X);return u.certificationRequestFromAsn1(G,J)};u.certificationRequestToPem=function($,J){var X={type:"CERTIFICATE REQUEST",body:z.toDer(u.certificationRequestToAsn1($)).getBytes()};return e.pem.encode(X,{maxline:J})};u.createCertificate=function(){var $={};return $.version=2,$.serialNumber="00",$.signatureOid=null,$.signature=null,$.siginfo={},$.siginfo.algorithmOid=null,$.validity={},$.validity.notBefore=new Date,$.validity.notAfter=new Date,$.issuer={},$.issuer.getField=function(J){return w0($.issuer,J)},$.issuer.addField=function(J){vJ([J]),$.issuer.attributes.push(J)},$.issuer.attributes=[],$.issuer.hash=null,$.subject={},$.subject.getField=function(J){return w0($.subject,J)},$.subject.addField=function(J){vJ([J]),$.subject.attributes.push(J)},$.subject.attributes=[],$.subject.hash=null,$.extensions=[],$.publicKey=null,$.md=null,$.setSubject=function(J,X){if(vJ(J),$.subject.attributes=J,delete $.subject.uniqueId,X)$.subject.uniqueId=X;$.subject.hash=null},$.setIssuer=function(J,X){if(vJ(J),$.issuer.attributes=J,delete $.issuer.uniqueId,X)$.issuer.uniqueId=X;$.issuer.hash=null},$.setExtensions=function(J){for(var X=0;X<J.length;++X)q1(J[X],{cert:$});$.extensions=J},$.getExtension=function(J){if(typeof J==="string")J={name:J};var X=null,Q;for(var Y=0;X===null&&Y<$.extensions.length;++Y)if(Q=$.extensions[Y],J.id&&Q.id===J.id)X=Q;else if(J.name&&Q.name===J.name)X=Q;return X},$.sign=function(J,X){$.md=X||e.md.sha1.create();var Q=I$[$.md.algorithm+"WithRSAEncryption"];if(!Q){var Y=Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw Y.algorithm=$.md.algorithm,Y}$.signatureOid=$.siginfo.algorithmOid=Q,$.tbsCertificate=u.getTBSCertificate($);var G=z.toDer($.tbsCertificate);$.md.update(G.getBytes()),$.signature=J.sign($.md)},$.verify=function(J){var X=!1;if(!$.issued(J)){var Q=J.issuer,Y=$.subject,G=Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw G.expectedIssuer=Y.attributes,G.actualIssuer=Q.attributes,G}var W=J.md;if(W===null){W=jY({signatureOid:J.signatureOid,type:"certificate"});var M=J.tbsCertificate||u.getTBSCertificate(J),U=z.toDer(M);W.update(U.getBytes())}if(W!==null)X=H1({certificate:$,md:W,signature:J.signature});return X},$.isIssuer=function(J){var X=!1,Q=$.issuer,Y=J.subject;if(Q.hash&&Y.hash)X=Q.hash===Y.hash;else if(Q.attributes.length===Y.attributes.length){X=!0;var G,W;for(var M=0;X&&M<Q.attributes.length;++M)if(G=Q.attributes[M],W=Y.attributes[M],G.type!==W.type||G.value!==W.value)X=!1}return X},$.issued=function(J){return J.isIssuer($)},$.generateSubjectKeyIdentifier=function(){return u.getPublicKeyFingerprint($.publicKey,{type:"RSAPublicKey"})},$.verifySubjectKeyIdentifier=function(){var J=I$.subjectKeyIdentifier;for(var X=0;X<$.extensions.length;++X){var Q=$.extensions[X];if(Q.id===J){var Y=$.generateSubjectKeyIdentifier().getBytes();return e.util.hexToBytes(Q.subjectKeyIdentifier)===Y}}return!1},$};u.certificateFromAsn1=function($,J){var X={},Q=[];if(!z.validate($,uO,X,Q)){var Y=Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw Y.errors=Q,Y}var G=z.derToOid(X.publicKeyOid);if(G!==u.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var W=u.createCertificate();W.version=X.certVersion?X.certVersion.charCodeAt(0):0;var M=e.util.createBuffer(X.certSerialNumber);W.serialNumber=M.toHex(),W.signatureOid=e.asn1.derToOid(X.certSignatureOid),W.signatureParameters=BY(W.signatureOid,X.certSignatureParams,!0),W.siginfo.algorithmOid=e.asn1.derToOid(X.certinfoSignatureOid),W.siginfo.parameters=BY(W.siginfo.algorithmOid,X.certinfoSignatureParams,!1),W.signature=X.certSignature;var U=[];if(X.certValidity1UTCTime!==void 0)U.push(z.utcTimeToDate(X.certValidity1UTCTime));if(X.certValidity2GeneralizedTime!==void 0)U.push(z.generalizedTimeToDate(X.certValidity2GeneralizedTime));if(X.certValidity3UTCTime!==void 0)U.push(z.utcTimeToDate(X.certValidity3UTCTime));if(X.certValidity4GeneralizedTime!==void 0)U.push(z.generalizedTimeToDate(X.certValidity4GeneralizedTime));if(U.length>2)throw Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(U.length<2)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(W.validity.notBefore=U[0],W.validity.notAfter=U[1],W.tbsCertificate=X.tbsCertificate,J){W.md=jY({signatureOid:W.signatureOid,type:"certificate"});var O=z.toDer(W.tbsCertificate);W.md.update(O.getBytes())}var V=e.md.sha1.create(),H=z.toDer(X.certIssuer);if(V.update(H.getBytes()),W.issuer.getField=function(K){return w0(W.issuer,K)},W.issuer.addField=function(K){vJ([K]),W.issuer.attributes.push(K)},W.issuer.attributes=u.RDNAttributesAsArray(X.certIssuer),X.certIssuerUniqueId)W.issuer.uniqueId=X.certIssuerUniqueId;W.issuer.hash=V.digest().toHex();var q=e.md.sha1.create(),F=z.toDer(X.certSubject);if(q.update(F.getBytes()),W.subject.getField=function(K){return w0(W.subject,K)},W.subject.addField=function(K){vJ([K]),W.subject.attributes.push(K)},W.subject.attributes=u.RDNAttributesAsArray(X.certSubject),X.certSubjectUniqueId)W.subject.uniqueId=X.certSubjectUniqueId;if(W.subject.hash=q.digest().toHex(),X.certExtensions)W.extensions=u.certificateExtensionsFromAsn1(X.certExtensions);else W.extensions=[];return W.publicKey=u.publicKeyFromAsn1(X.subjectPublicKeyInfo),W};u.certificateExtensionsFromAsn1=function($){var J=[];for(var X=0;X<$.value.length;++X){var Q=$.value[X];for(var Y=0;Y<Q.value.length;++Y)J.push(u.certificateExtensionFromAsn1(Q.value[Y]))}return J};u.certificateExtensionFromAsn1=function($){var J={};if(J.id=z.derToOid($.value[0].value),J.critical=!1,$.value[1].type===z.Type.BOOLEAN)J.critical=$.value[1].value.charCodeAt(0)!==0,J.value=$.value[2].value;else J.value=$.value[1].value;if(J.id in I$){if(J.name=I$[J.id],J.name==="keyUsage"){var X=z.fromDer(J.value),Q=0,Y=0;if(X.value.length>1)Q=X.value.charCodeAt(1),Y=X.value.length>2?X.value.charCodeAt(2):0;J.digitalSignature=(Q&128)===128,J.nonRepudiation=(Q&64)===64,J.keyEncipherment=(Q&32)===32,J.dataEncipherment=(Q&16)===16,J.keyAgreement=(Q&8)===8,J.keyCertSign=(Q&4)===4,J.cRLSign=(Q&2)===2,J.encipherOnly=(Q&1)===1,J.decipherOnly=(Y&128)===128}else if(J.name==="basicConstraints"){var X=z.fromDer(J.value);if(X.value.length>0&&X.value[0].type===z.Type.BOOLEAN)J.cA=X.value[0].value.charCodeAt(0)!==0;else J.cA=!1;var G=null;if(X.value.length>0&&X.value[0].type===z.Type.INTEGER)G=X.value[0].value;else if(X.value.length>1)G=X.value[1].value;if(G!==null)J.pathLenConstraint=z.derToInteger(G)}else if(J.name==="extKeyUsage"){var X=z.fromDer(J.value);for(var W=0;W<X.value.length;++W){var M=z.derToOid(X.value[W].value);if(M in I$)J[I$[M]]=!0;else J[M]=!0}}else if(J.name==="nsCertType"){var X=z.fromDer(J.value),Q=0;if(X.value.length>1)Q=X.value.charCodeAt(1);J.client=(Q&128)===128,J.server=(Q&64)===64,J.email=(Q&32)===32,J.objsign=(Q&16)===16,J.reserved=(Q&8)===8,J.sslCA=(Q&4)===4,J.emailCA=(Q&2)===2,J.objCA=(Q&1)===1}else if(J.name==="subjectAltName"||J.name==="issuerAltName"){J.altNames=[];var U,X=z.fromDer(J.value);for(var O=0;O<X.value.length;++O){U=X.value[O];var V={type:U.type,value:U.value};switch(J.altNames.push(V),U.type){case 1:case 2:case 6:break;case 7:V.ip=e.util.bytesToIP(U.value);break;case 8:V.oid=z.derToOid(U.value);break;default:}}}else if(J.name==="subjectKeyIdentifier"){var X=z.fromDer(J.value);J.subjectKeyIdentifier=e.util.bytesToHex(X.value)}}return J};u.certificationRequestFromAsn1=function($,J){var X={},Q=[];if(!z.validate($,lO,X,Q)){var Y=Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw Y.errors=Q,Y}var G=z.derToOid(X.publicKeyOid);if(G!==u.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var W=u.createCertificationRequest();if(W.version=X.csrVersion?X.csrVersion.charCodeAt(0):0,W.signatureOid=e.asn1.derToOid(X.csrSignatureOid),W.signatureParameters=BY(W.signatureOid,X.csrSignatureParams,!0),W.siginfo.algorithmOid=e.asn1.derToOid(X.csrSignatureOid),W.siginfo.parameters=BY(W.siginfo.algorithmOid,X.csrSignatureParams,!1),W.signature=X.csrSignature,W.certificationRequestInfo=X.certificationRequestInfo,J){W.md=jY({signatureOid:W.signatureOid,type:"certification request"});var M=z.toDer(W.certificationRequestInfo);W.md.update(M.getBytes())}var U=e.md.sha1.create();return W.subject.getField=function(O){return w0(W.subject,O)},W.subject.addField=function(O){vJ([O]),W.subject.attributes.push(O)},W.subject.attributes=u.RDNAttributesAsArray(X.certificationRequestInfoSubject,U),W.subject.hash=U.digest().toHex(),W.publicKey=u.publicKeyFromAsn1(X.subjectPublicKeyInfo),W.getAttribute=function(O){return w0(W,O)},W.addAttribute=function(O){vJ([O]),W.attributes.push(O)},W.attributes=u.CRIAttributesAsArray(X.certificationRequestInfoAttributes||[]),W};u.createCertificationRequest=function(){var $={};return $.version=0,$.signatureOid=null,$.signature=null,$.siginfo={},$.siginfo.algorithmOid=null,$.subject={},$.subject.getField=function(J){return w0($.subject,J)},$.subject.addField=function(J){vJ([J]),$.subject.attributes.push(J)},$.subject.attributes=[],$.subject.hash=null,$.publicKey=null,$.attributes=[],$.getAttribute=function(J){return w0($,J)},$.addAttribute=function(J){vJ([J]),$.attributes.push(J)},$.md=null,$.setSubject=function(J){vJ(J),$.subject.attributes=J,$.subject.hash=null},$.setAttributes=function(J){vJ(J),$.attributes=J},$.sign=function(J,X){$.md=X||e.md.sha1.create();var Q=I$[$.md.algorithm+"WithRSAEncryption"];if(!Q){var Y=Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw Y.algorithm=$.md.algorithm,Y}$.signatureOid=$.siginfo.algorithmOid=Q,$.certificationRequestInfo=u.getCertificationRequestInfo($);var G=z.toDer($.certificationRequestInfo);$.md.update(G.getBytes()),$.signature=J.sign($.md)},$.verify=function(){var J=!1,X=$.md;if(X===null){X=jY({signatureOid:$.signatureOid,type:"certification request"});var Q=$.certificationRequestInfo||u.getCertificationRequestInfo($),Y=z.toDer(Q);X.update(Y.getBytes())}if(X!==null)J=H1({certificate:$,md:X,signature:$.signature});return J},$};function CQ($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),X,Q,Y=$.attributes;for(var G=0;G<Y.length;++G){X=Y[G];var W=X.value,M=z.Type.PRINTABLESTRING;if("valueTagClass"in X){if(M=X.valueTagClass,M===z.Type.UTF8)W=e.util.encodeUtf8(W)}Q=z.create(z.Class.UNIVERSAL,z.Type.SET,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(X.type).getBytes()),z.create(z.Class.UNIVERSAL,M,!1,W)])]),J.value.push(Q)}return J}function vJ($){var J;for(var X=0;X<$.length;++X){if(J=$[X],typeof J.name>"u"){if(J.type&&J.type in u.oids)J.name=u.oids[J.type];else if(J.shortName&&J.shortName in n$)J.name=u.oids[n$[J.shortName]]}if(typeof J.type>"u")if(J.name&&J.name in u.oids)J.type=u.oids[J.name];else{var Q=Error("Attribute type not specified.");throw Q.attribute=J,Q}if(typeof J.shortName>"u"){if(J.name&&J.name in n$)J.shortName=n$[J.name]}if(J.type===I$.extensionRequest){if(J.valueConstructed=!0,J.valueTagClass=z.Type.SEQUENCE,!J.value&&J.extensions){J.value=[];for(var Y=0;Y<J.extensions.length;++Y)J.value.push(u.certificateExtensionToAsn1(q1(J.extensions[Y])))}}if(typeof J.value>"u"){var Q=Error("Attribute value not specified.");throw Q.attribute=J,Q}}}function q1($,J){if(J=J||{},typeof $.name>"u"){if($.id&&$.id in u.oids)$.name=u.oids[$.id]}if(typeof $.id>"u")if($.name&&$.name in u.oids)$.id=u.oids[$.name];else{var X=Error("Extension ID not specified.");throw X.extension=$,X}if(typeof $.value<"u")return $;if($.name==="keyUsage"){var Q=0,Y=0,G=0;if($.digitalSignature)Y|=128,Q=7;if($.nonRepudiation)Y|=64,Q=6;if($.keyEncipherment)Y|=32,Q=5;if($.dataEncipherment)Y|=16,Q=4;if($.keyAgreement)Y|=8,Q=3;if($.keyCertSign)Y|=4,Q=2;if($.cRLSign)Y|=2,Q=1;if($.encipherOnly)Y|=1,Q=0;if($.decipherOnly)G|=128,Q=7;var W=String.fromCharCode(Q);if(G!==0)W+=String.fromCharCode(Y)+String.fromCharCode(G);else if(Y!==0)W+=String.fromCharCode(Y);$.value=z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,W)}else if($.name==="basicConstraints"){if($.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),$.cA)$.value.value.push(z.create(z.Class.UNIVERSAL,z.Type.BOOLEAN,!1,String.fromCharCode(255)));if("pathLenConstraint"in $)$.value.value.push(z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.pathLenConstraint).getBytes()))}else if($.name==="extKeyUsage"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var M=$.value.value;for(var U in $){if($[U]!==!0)continue;if(U in I$)M.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(I$[U]).getBytes()));else if(U.indexOf(".")!==-1)M.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(U).getBytes()))}}else if($.name==="nsCertType"){var Q=0,Y=0;if($.client)Y|=128,Q=7;if($.server)Y|=64,Q=6;if($.email)Y|=32,Q=5;if($.objsign)Y|=16,Q=4;if($.reserved)Y|=8,Q=3;if($.sslCA)Y|=4,Q=2;if($.emailCA)Y|=2,Q=1;if($.objCA)Y|=1,Q=0;var W=String.fromCharCode(Q);if(Y!==0)W+=String.fromCharCode(Y);$.value=z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,W)}else if($.name==="subjectAltName"||$.name==="issuerAltName"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var O;for(var V=0;V<$.altNames.length;++V){O=$.altNames[V];var W=O.value;if(O.type===7&&O.ip){if(W=e.util.bytesFromIP(O.ip),W===null){var X=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw X.extension=$,X}}else if(O.type===8)if(O.oid)W=z.oidToDer(z.oidToDer(O.oid));else W=z.oidToDer(W);$.value.value.push(z.create(z.Class.CONTEXT_SPECIFIC,O.type,!1,W))}}else if($.name==="nsComment"&&J.cert){if(!/^[\x00-\x7F]*$/.test($.comment)||$.comment.length<1||$.comment.length>128)throw Error('Invalid "nsComment" content.');$.value=z.create(z.Class.UNIVERSAL,z.Type.IA5STRING,!1,$.comment)}else if($.name==="subjectKeyIdentifier"&&J.cert){var H=J.cert.generateSubjectKeyIdentifier();$.subjectKeyIdentifier=H.toHex(),$.value=z.create(z.Class.UNIVERSAL,z.Type.OCTETSTRING,!1,H.getBytes())}else if($.name==="authorityKeyIdentifier"&&J.cert){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var M=$.value.value;if($.keyIdentifier){var q=$.keyIdentifier===!0?J.cert.generateSubjectKeyIdentifier().getBytes():$.keyIdentifier;M.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!1,q))}if($.authorityCertIssuer){var F=[z.create(z.Class.CONTEXT_SPECIFIC,4,!0,[CQ($.authorityCertIssuer===!0?J.cert.issuer:$.authorityCertIssuer)])];M.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,F))}if($.serialNumber){var K=e.util.hexToBytes($.serialNumber===!0?J.cert.serialNumber:$.serialNumber);M.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!1,K))}}else if($.name==="cRLDistributionPoints"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var M=$.value.value,R=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),L=z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[]),O;for(var V=0;V<$.altNames.length;++V){O=$.altNames[V];var W=O.value;if(O.type===7&&O.ip){if(W=e.util.bytesFromIP(O.ip),W===null){var X=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw X.extension=$,X}}else if(O.type===8)if(O.oid)W=z.oidToDer(z.oidToDer(O.oid));else W=z.oidToDer(W);L.value.push(z.create(z.Class.CONTEXT_SPECIFIC,O.type,!1,W))}R.value.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[L])),M.push(R)}if(typeof $.value>"u"){var X=Error("Extension value not specified.");throw X.extension=$,X}return $}function Y8($,J){switch($){case I$["RSASSA-PSS"]:var X=[];if(J.hash.algorithmOid!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.hash.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")])]));if(J.mgf.algorithmOid!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.mgf.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.mgf.hash.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")])])]));if(J.saltLength!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer(J.saltLength).getBytes())]));return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,X);default:return z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")}}function dO($){var J=z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[]);if($.attributes.length===0)return J;var X=$.attributes;for(var Q=0;Q<X.length;++Q){var Y=X[Q],G=Y.value,W=z.Type.UTF8;if("valueTagClass"in Y)W=Y.valueTagClass;if(W===z.Type.UTF8)G=e.util.encodeUtf8(G);var M=!1;if("valueConstructed"in Y)M=Y.valueConstructed;var U=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(Y.type).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.SET,!0,[z.create(z.Class.UNIVERSAL,W,M,G)])]);J.value.push(U)}return J}var pO=new Date("1950-01-01T00:00:00Z"),cO=new Date("2050-01-01T00:00:00Z");function O1($){if($>=pO&&$<cO)return z.create(z.Class.UNIVERSAL,z.Type.UTCTIME,!1,z.dateToUtcTime($));else return z.create(z.Class.UNIVERSAL,z.Type.GENERALIZEDTIME,!1,z.dateToGeneralizedTime($))}u.getTBSCertificate=function($){var J=O1($.validity.notBefore),X=O1($.validity.notAfter),Q=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.version).getBytes())]),z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,e.util.hexToBytes($.serialNumber)),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.siginfo.algorithmOid).getBytes()),Y8($.siginfo.algorithmOid,$.siginfo.parameters)]),CQ($.issuer),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,X]),CQ($.subject),u.publicKeyToAsn1($.publicKey)]);if($.issuer.uniqueId)Q.value.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,[z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.issuer.uniqueId)]));if($.subject.uniqueId)Q.value.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!0,[z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.subject.uniqueId)]));if($.extensions.length>0)Q.value.push(u.certificateExtensionsToAsn1($.extensions));return Q};u.getCertificationRequestInfo=function($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.version).getBytes()),CQ($.subject),u.publicKeyToAsn1($.publicKey),dO($)]);return J};u.distinguishedNameToAsn1=function($){return CQ($)};u.certificateToAsn1=function($){var J=$.tbsCertificate||u.getTBSCertificate($);return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.signatureOid).getBytes()),Y8($.signatureOid,$.signatureParameters)]),z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.signature)])};u.certificateExtensionsToAsn1=function($){var J=z.create(z.Class.CONTEXT_SPECIFIC,3,!0,[]),X=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);J.value.push(X);for(var Q=0;Q<$.length;++Q)X.value.push(u.certificateExtensionToAsn1($[Q]));return J};u.certificateExtensionToAsn1=function($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);if(J.value.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.id).getBytes())),$.critical)J.value.push(z.create(z.Class.UNIVERSAL,z.Type.BOOLEAN,!1,String.fromCharCode(255)));var X=$.value;if(typeof $.value!=="string")X=z.toDer(X).getBytes();return J.value.push(z.create(z.Class.UNIVERSAL,z.Type.OCTETSTRING,!1,X)),J};u.certificationRequestToAsn1=function($){var J=$.certificationRequestInfo||u.getCertificationRequestInfo($);return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.signatureOid).getBytes()),Y8($.signatureOid,$.signatureParameters)]),z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.signature)])};u.createCaStore=function($){var J={certs:{}};J.getIssuer=function(W){var M=X(W.issuer);return M},J.addCertificate=function(W){if(typeof W==="string")W=e.pki.certificateFromPem(W);if(Q(W.subject),!J.hasCertificate(W))if(W.subject.hash in J.certs){var M=J.certs[W.subject.hash];if(!e.util.isArray(M))M=[M];M.push(W),J.certs[W.subject.hash]=M}else J.certs[W.subject.hash]=W},J.hasCertificate=function(W){if(typeof W==="string")W=e.pki.certificateFromPem(W);var M=X(W.subject);if(!M)return!1;if(!e.util.isArray(M))M=[M];var U=z.toDer(u.certificateToAsn1(W)).getBytes();for(var O=0;O<M.length;++O){var V=z.toDer(u.certificateToAsn1(M[O])).getBytes();if(U===V)return!0}return!1},J.listAllCertificates=function(){var W=[];for(var M in J.certs)if(J.certs.hasOwnProperty(M)){var U=J.certs[M];if(!e.util.isArray(U))W.push(U);else for(var O=0;O<U.length;++O)W.push(U[O])}return W},J.removeCertificate=function(W){var M;if(typeof W==="string")W=e.pki.certificateFromPem(W);if(Q(W.subject),!J.hasCertificate(W))return null;var U=X(W.subject);if(!e.util.isArray(U))return M=J.certs[W.subject.hash],delete J.certs[W.subject.hash],M;var O=z.toDer(u.certificateToAsn1(W)).getBytes();for(var V=0;V<U.length;++V){var H=z.toDer(u.certificateToAsn1(U[V])).getBytes();if(O===H)M=U[V],U.splice(V,1)}if(U.length===0)delete J.certs[W.subject.hash];return M};function X(W){return Q(W),J.certs[W.hash]||null}function Q(W){if(!W.hash){var M=e.md.sha1.create();W.attributes=u.RDNAttributesAsArray(CQ(W),M),W.hash=M.digest().toHex()}}if($)for(var Y=0;Y<$.length;++Y){var G=$[Y];J.addCertificate(G)}return J};u.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};u.verifyCertificateChain=function($,J,X){if(typeof X==="function")X={verify:X};X=X||{},J=J.slice(0);var Q=J.slice(0),Y=X.validityCheckDate;if(typeof Y>"u")Y=new Date;var G=!0,W=null,M=0;do{var U=J.shift(),O=null,V=!1;if(Y){if(Y<U.validity.notBefore||Y>U.validity.notAfter)W={message:"Certificate is not valid yet or has expired.",error:u.certificateError.certificate_expired,notBefore:U.validity.notBefore,notAfter:U.validity.notAfter,now:Y}}if(W===null){if(O=J[0]||$.getIssuer(U),O===null){if(U.isIssuer(U))V=!0,O=U}if(O){var H=O;if(!e.util.isArray(H))H=[H];var q=!1;while(!q&&H.length>0){O=H.shift();try{q=O.verify(U)}catch(S){}}if(!q)W={message:"Certificate signature is invalid.",error:u.certificateError.bad_certificate}}if(W===null&&(!O||V)&&!$.hasCertificate(U))W={message:"Certificate is not trusted.",error:u.certificateError.unknown_ca}}if(W===null&&O&&!U.isIssuer(O))W={message:"Certificate issuer is invalid.",error:u.certificateError.bad_certificate};if(W===null){var F={keyUsage:!0,basicConstraints:!0};for(var K=0;W===null&&K<U.extensions.length;++K){var R=U.extensions[K];if(R.critical&&!(R.name in F))W={message:"Certificate has an unsupported critical extension.",error:u.certificateError.unsupported_certificate}}}if(W===null&&(!G||J.length===0&&(!O||V))){var L=U.getExtension("basicConstraints"),D=U.getExtension("keyUsage");if(D!==null){if(!D.keyCertSign||L===null)W={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:u.certificateError.bad_certificate}}if(W===null&&L===null)W={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:u.certificateError.bad_certificate};if(W===null&&L!==null&&!L.cA)W={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:u.certificateError.bad_certificate};if(W===null&&D!==null&&"pathLenConstraint"in L){var w=M-1;if(w>L.pathLenConstraint)W={message:"Certificate basicConstraints pathLenConstraint violated.",error:u.certificateError.bad_certificate}}}var T=W===null?!0:W.error,P=X.verify?X.verify(T,M,Q):T;if(P===!0)W=null;else{if(T===!0)W={message:"The application rejected the certificate.",error:u.certificateError.bad_certificate};if(P||P===0){if(typeof P==="object"&&!e.util.isArray(P)){if(P.message)W.message=P.message;if(P.error)W.error=P.error}else if(typeof P==="string")W.error=P}throw W}G=!1,++M}while(J.length>0);return!0}});var W8=M$((BE,E1)=>{var b$=K$();gJ();DQ();S0();Q8();J8();PJ();NX();TQ();C$();TY();var{asn1:A,pki:L$}=b$,RX=E1.exports=b$.pkcs12=b$.pkcs12||{},z1={name:"ContentInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:A.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},nO={name:"PFX",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"version"},z1,{name:"PFX.macData",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:A.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},iO={name:"SafeBag",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:A.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:A.Class.UNIVERSAL,type:A.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},oO={name:"Attribute",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:A.Class.UNIVERSAL,type:A.Type.SET,constructed:!0,capture:"values"}]},aO={name:"CertBag",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:A.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:A.Class.UNIVERSAL,type:A.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function LX($,J,X,Q){var Y=[];for(var G=0;G<$.length;G++)for(var W=0;W<$[G].safeBags.length;W++){var M=$[G].safeBags[W];if(Q!==void 0&&M.type!==Q)continue;if(J===null){Y.push(M);continue}if(M.attributes[J]!==void 0&&M.attributes[J].indexOf(X)>=0)Y.push(M)}return Y}RX.pkcs12FromAsn1=function($,J,X){if(typeof J==="string")X=J,J=!0;else if(J===void 0)J=!0;var Q={},Y=[];if(!A.validate($,nO,Q,Y)){var G=Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw G.errors=G,G}var W={version:Q.version.charCodeAt(0),safeContents:[],getBags:function(L){var D={},w;if("localKeyId"in L)w=L.localKeyId;else if("localKeyIdHex"in L)w=b$.util.hexToBytes(L.localKeyIdHex);if(w===void 0&&!("friendlyName"in L)&&"bagType"in L)D[L.bagType]=LX(W.safeContents,null,null,L.bagType);if(w!==void 0)D.localKeyId=LX(W.safeContents,"localKeyId",w,L.bagType);if("friendlyName"in L)D.friendlyName=LX(W.safeContents,"friendlyName",L.friendlyName,L.bagType);return D},getBagsByFriendlyName:function(L,D){return LX(W.safeContents,"friendlyName",L,D)},getBagsByLocalKeyId:function(L,D){return LX(W.safeContents,"localKeyId",L,D)}};if(Q.version.charCodeAt(0)!==3){var G=Error("PKCS#12 PFX of version other than 3 not supported.");throw G.version=Q.version.charCodeAt(0),G}if(A.derToOid(Q.contentType)!==L$.oids.data){var G=Error("Only PKCS#12 PFX in password integrity mode supported.");throw G.oid=A.derToOid(Q.contentType),G}var M=Q.content.value[0];if(M.tagClass!==A.Class.UNIVERSAL||M.type!==A.Type.OCTETSTRING)throw Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(M=G8(M),Q.mac){var U=null,O=0,V=A.derToOid(Q.macAlgorithm);switch(V){case L$.oids.sha1:U=b$.md.sha1.create(),O=20;break;case L$.oids.sha256:U=b$.md.sha256.create(),O=32;break;case L$.oids.sha384:U=b$.md.sha384.create(),O=48;break;case L$.oids.sha512:U=b$.md.sha512.create(),O=64;break;case L$.oids.md5:U=b$.md.md5.create(),O=16;break}if(U===null)throw Error("PKCS#12 uses unsupported MAC algorithm: "+V);var H=new b$.util.ByteBuffer(Q.macSalt),q="macIterations"in Q?parseInt(b$.util.bytesToHex(Q.macIterations),16):1,F=RX.generateKey(X,H,3,q,O,U),K=b$.hmac.create();K.start(U,F),K.update(M.value);var R=K.getMac();if(R.getBytes()!==Q.macDigest)throw Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray($.value)&&$.value.length>2)throw Error("Invalid PKCS#12. macData field present but MAC was not validated.");return sO(W,M.value,J,X),W};function G8($){if($.composed||$.constructed){var J=b$.util.createBuffer();for(var X=0;X<$.value.length;++X)J.putBytes($.value[X].value);$.composed=$.constructed=!1,$.value=J.getBytes()}return $}function sO($,J,X,Q){if(J=A.fromDer(J,X),J.tagClass!==A.Class.UNIVERSAL||J.type!==A.Type.SEQUENCE||J.constructed!==!0)throw Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var Y=0;Y<J.value.length;Y++){var G=J.value[Y],W={},M=[];if(!A.validate(G,z1,W,M)){var U=Error("Cannot read ContentInfo.");throw U.errors=M,U}var O={encrypted:!1},V=null,H=W.content.value[0];switch(A.derToOid(W.contentType)){case L$.oids.data:if(H.tagClass!==A.Class.UNIVERSAL||H.type!==A.Type.OCTETSTRING)throw Error("PKCS#12 SafeContents Data is not an OCTET STRING.");V=G8(H).value;break;case L$.oids.encryptedData:V=rO(H,Q),O.encrypted=!0;break;default:var U=Error("Unsupported PKCS#12 contentType.");throw U.contentType=A.derToOid(W.contentType),U}O.safeBags=tO(V,X,Q),$.safeContents.push(O)}}function rO($,J){var X={},Q=[];if(!A.validate($,b$.pkcs7.asn1.encryptedDataValidator,X,Q)){var Y=Error("Cannot read EncryptedContentInfo.");throw Y.errors=Q,Y}var G=A.derToOid(X.contentType);if(G!==L$.oids.data){var Y=Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw Y.oid=G,Y}G=A.derToOid(X.encAlgorithm);var W=L$.pbe.getCipher(G,X.encParameter,J),M=G8(X.encryptedContentAsn1),U=b$.util.createBuffer(M.value);if(W.update(U),!W.finish())throw Error("Failed to decrypt PKCS#12 SafeContents.");return W.output.getBytes()}function tO($,J,X){if(!J&&$.length===0)return[];if($=A.fromDer($,J),$.tagClass!==A.Class.UNIVERSAL||$.type!==A.Type.SEQUENCE||$.constructed!==!0)throw Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");var Q=[];for(var Y=0;Y<$.value.length;Y++){var G=$.value[Y],W={},M=[];if(!A.validate(G,iO,W,M)){var U=Error("Cannot read SafeBag.");throw U.errors=M,U}var O={type:A.derToOid(W.bagId),attributes:eO(W.bagAttributes)};Q.push(O);var V,H,q=W.bagValue.value[0];switch(O.type){case L$.oids.pkcs8ShroudedKeyBag:if(q=L$.decryptPrivateKeyInfo(q,X),q===null)throw Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case L$.oids.keyBag:try{O.key=L$.privateKeyFromAsn1(q)}catch(K){O.key=null,O.asn1=q}continue;case L$.oids.certBag:V=aO,H=function(){if(A.derToOid(W.certId)!==L$.oids.x509Certificate){var K=Error("Unsupported certificate type, only X.509 supported.");throw K.oid=A.derToOid(W.certId),K}var R=A.fromDer(W.cert,J);try{O.cert=L$.certificateFromAsn1(R,!0)}catch(L){O.cert=null,O.asn1=R}};break;default:var U=Error("Unsupported PKCS#12 SafeBag type.");throw U.oid=O.type,U}if(V!==void 0&&!A.validate(q,V,W,M)){var U=Error("Cannot read PKCS#12 "+V.name);throw U.errors=M,U}H()}return Q}function eO($){var J={};if($!==void 0)for(var X=0;X<$.length;++X){var Q={},Y=[];if(!A.validate($[X],oO,Q,Y)){var G=Error("Cannot read PKCS#12 BagAttribute.");throw G.errors=Y,G}var W=A.derToOid(Q.oid);if(L$.oids[W]===void 0)continue;J[L$.oids[W]]=[];for(var M=0;M<Q.values.length;++M)J[L$.oids[W]].push(Q.values[M].value)}return J}RX.toPkcs12Asn1=function($,J,X,Q){if(Q=Q||{},Q.saltSize=Q.saltSize||8,Q.count=Q.count||2048,Q.algorithm=Q.algorithm||Q.encAlgorithm||"aes128",!("useMac"in Q))Q.useMac=!0;if(!("localKeyId"in Q))Q.localKeyId=null;if(!("generateLocalKeyId"in Q))Q.generateLocalKeyId=!0;var Y=Q.localKeyId,G;if(Y!==null)Y=b$.util.hexToBytes(Y);else if(Q.generateLocalKeyId)if(J){var W=b$.util.isArray(J)?J[0]:J;if(typeof W==="string")W=L$.certificateFromPem(W);var M=b$.md.sha1.create();M.update(A.toDer(L$.certificateToAsn1(W)).getBytes()),Y=M.digest().getBytes()}else Y=b$.random.getBytes(20);var U=[];if(Y!==null)U.push(A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.localKeyId).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SET,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,Y)])]));if("friendlyName"in Q)U.push(A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.friendlyName).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SET,!0,[A.create(A.Class.UNIVERSAL,A.Type.BMPSTRING,!1,Q.friendlyName)])]));if(U.length>0)G=A.create(A.Class.UNIVERSAL,A.Type.SET,!0,U);var O=[],V=[];if(J!==null)if(b$.util.isArray(J))V=J;else V=[J];var H=[];for(var q=0;q<V.length;++q){if(J=V[q],typeof J==="string")J=L$.certificateFromPem(J);var F=q===0?G:void 0,K=L$.certificateToAsn1(J),R=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.certBag).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.x509Certificate).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,A.toDer(K).getBytes())])])]),F]);H.push(R)}if(H.length>0){var L=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,H),D=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.data).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,A.toDer(L).getBytes())])]);O.push(D)}var w=null;if($!==null){var T=L$.wrapRsaPrivateKey(L$.privateKeyToAsn1($));if(X===null)w=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.keyBag).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[T]),G]);else w=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.pkcs8ShroudedKeyBag).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[L$.encryptPrivateKeyInfo(T,X,Q)]),G]);var P=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[w]),S=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.data).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,A.toDer(P).getBytes())])]);O.push(S)}var C=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,O),h;if(Q.useMac){var M=b$.md.sha1.create(),s=new b$.util.ByteBuffer(b$.random.getBytes(Q.saltSize)),a=Q.count,$=RX.generateKey(X,s,3,a,20),O$=b$.hmac.create();O$.start(M,$),O$.update(A.toDer(C).getBytes());var j$=O$.getMac();h=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.sha1).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")]),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,j$.getBytes())]),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,s.getBytes()),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,A.integerToDer(a).getBytes())])}return A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,A.integerToDer(3).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(L$.oids.data).getBytes()),A.create(A.Class.CONTEXT_SPECIFIC,0,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,A.toDer(C).getBytes())])]),h])};RX.generateKey=b$.pbe.generatePkcs12Key});var U8=M$((jE,F1)=>{var P0=K$();gJ();S0();J8();t0();EY();W8();ZY();NX();C$();TY();var M8=P0.asn1,wQ=F1.exports=P0.pki=P0.pki||{};wQ.pemToDer=function($){var J=P0.pem.decode($)[0];if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert PEM to DER; PEM is encrypted.");return P0.util.createBuffer(J.body)};wQ.privateKeyFromPem=function($){var J=P0.pem.decode($)[0];if(J.type!=="PRIVATE KEY"&&J.type!=="RSA PRIVATE KEY"){var X=Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert private key from PEM; PEM is encrypted.");var Q=M8.fromDer(J.body);return wQ.privateKeyFromAsn1(Q)};wQ.privateKeyToPem=function($,J){var X={type:"RSA PRIVATE KEY",body:M8.toDer(wQ.privateKeyToAsn1($)).getBytes()};return P0.pem.encode(X,{maxline:J})};wQ.privateKeyInfoToPem=function($,J){var X={type:"PRIVATE KEY",body:M8.toDer($).getBytes()};return P0.pem.encode(X,{maxline:J})}});var z8=M$((TE,j1)=>{var k=K$();gJ();DQ();HY();t0();U8();PJ();TQ();C$();var CY=function($,J,X,Q){var Y=k.util.createBuffer(),G=$.length>>1,W=G+($.length&1),M=$.substr(0,W),U=$.substr(G,W),O=k.util.createBuffer(),V=k.hmac.create();X=J+X;var H=Math.ceil(Q/16),q=Math.ceil(Q/20);V.start("MD5",M);var F=k.util.createBuffer();O.putBytes(X);for(var K=0;K<H;++K)V.start(null,null),V.update(O.getBytes()),O.putBuffer(V.digest()),V.start(null,null),V.update(O.bytes()+X),F.putBuffer(V.digest());V.start("SHA1",U);var R=k.util.createBuffer();O.clear(),O.putBytes(X);for(var K=0;K<q;++K)V.start(null,null),V.update(O.getBytes()),O.putBuffer(V.digest()),V.start(null,null),V.update(O.bytes()+X),R.putBuffer(V.digest());return Y.putBytes(k.util.xorBytes(F.getBytes(),R.getBytes(),Q)),Y},$V=function($,J,X){var Q=k.hmac.create();Q.start("SHA1",$);var Y=k.util.createBuffer();return Y.putInt32(J[0]),Y.putInt32(J[1]),Y.putByte(X.type),Y.putByte(X.version.major),Y.putByte(X.version.minor),Y.putInt16(X.length),Y.putBytes(X.fragment.bytes()),Q.update(Y.getBytes()),Q.digest().getBytes()},JV=function($,J,X){var Q=!1;try{var Y=$.deflate(J.fragment.getBytes());J.fragment=k.util.createBuffer(Y),J.length=Y.length,Q=!0}catch(G){}return Q},QV=function($,J,X){var Q=!1;try{var Y=$.inflate(J.fragment.getBytes());J.fragment=k.util.createBuffer(Y),J.length=Y.length,Q=!0}catch(G){}return Q},TJ=function($,J){var X=0;switch(J){case 1:X=$.getByte();break;case 2:X=$.getInt16();break;case 3:X=$.getInt24();break;case 4:X=$.getInt32();break}return k.util.createBuffer($.getBytes(X))},kJ=function($,J,X){$.putInt(X.length(),J<<3),$.putBuffer(X)},N={};N.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};N.SupportedVersions=[N.Versions.TLS_1_1,N.Versions.TLS_1_0];N.Version=N.SupportedVersions[0];N.MaxFragment=15360;N.ConnectionEnd={server:0,client:1};N.PRFAlgorithm={tls_prf_sha256:0};N.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};N.CipherType={stream:0,block:1,aead:2};N.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};N.CompressionMethod={none:0,deflate:1};N.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};N.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20};N.Alert={};N.Alert.Level={warning:1,fatal:2};N.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};N.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};N.CipherSuites={};N.getCipherSuite=function($){var J=null;for(var X in N.CipherSuites){var Q=N.CipherSuites[X];if(Q.id[0]===$.charCodeAt(0)&&Q.id[1]===$.charCodeAt(1)){J=Q;break}}return J};N.handleUnexpected=function($,J){var X=!$.open&&$.entity===N.ConnectionEnd.client;if(!X)$.error($,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unexpected_message}})};N.handleHelloRequest=function($,J,X){if(!$.handshaking&&$.handshakes>0)N.queue($,N.createAlert($,{level:N.Alert.Level.warning,description:N.Alert.Description.no_renegotiation})),N.flush($);$.process()};N.parseHelloMessage=function($,J,X){var Q=null,Y=$.entity===N.ConnectionEnd.client;if(X<38)$.error($,{message:Y?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});else{var G=J.fragment,W=G.length();if(Q={version:{major:G.getByte(),minor:G.getByte()},random:k.util.createBuffer(G.getBytes(32)),session_id:TJ(G,1),extensions:[]},Y)Q.cipher_suite=G.getBytes(2),Q.compression_method=G.getByte();else Q.cipher_suites=TJ(G,2),Q.compression_methods=TJ(G,1);if(W=X-(W-G.length()),W>0){var M=TJ(G,2);while(M.length()>0)Q.extensions.push({type:[M.getByte(),M.getByte()],data:TJ(M,2)});if(!Y)for(var U=0;U<Q.extensions.length;++U){var O=Q.extensions[U];if(O.type[0]===0&&O.type[1]===0){var V=TJ(O.data,2);while(V.length()>0){var H=V.getByte();if(H!==0)break;$.session.extensions.server_name.serverNameList.push(TJ(V,2).getBytes())}}}}if($.session.version){if(Q.version.major!==$.session.version.major||Q.version.minor!==$.session.version.minor)return $.error($,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}})}if(Y)$.session.cipherSuite=N.getCipherSuite(Q.cipher_suite);else{var q=k.util.createBuffer(Q.cipher_suites.bytes());while(q.length()>0)if($.session.cipherSuite=N.getCipherSuite(q.getBytes(2)),$.session.cipherSuite!==null)break}if($.session.cipherSuite===null)return $.error($,{message:"No cipher suites in common.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.handshake_failure},cipherSuite:k.util.bytesToHex(Q.cipher_suite)});if(Y)$.session.compressionMethod=Q.compression_method;else $.session.compressionMethod=N.CompressionMethod.none}return Q};N.createSecurityParameters=function($,J){var X=$.entity===N.ConnectionEnd.client,Q=J.random.bytes(),Y=X?$.session.sp.client_random:Q,G=X?Q:N.createRandom().getBytes();$.session.sp={entity:$.entity,prf_algorithm:N.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:$.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:Y,server_random:G}};N.handleServerHello=function($,J,X){var Q=N.parseHelloMessage($,J,X);if($.fail)return;if(Q.version.minor<=$.version.minor)$.version.minor=Q.version.minor;else return $.error($,{message:"Incompatible TLS version.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}});$.session.version=$.version;var Y=Q.session_id.bytes();if(Y.length>0&&Y===$.session.id)$.expect=R1,$.session.resuming=!0,$.session.sp.server_random=Q.random.bytes();else $.expect=YV,$.session.resuming=!1,N.createSecurityParameters($,Q);$.session.id=Y,$.process()};N.handleClientHello=function($,J,X){var Q=N.parseHelloMessage($,J,X);if($.fail)return;var Y=Q.session_id.bytes(),G=null;if($.sessionCache){if(G=$.sessionCache.getSession(Y),G===null)Y="";else if(G.version.major!==Q.version.major||G.version.minor>Q.version.minor)G=null,Y=""}if(Y.length===0)Y=k.random.getBytes(32);if($.session.id=Y,$.session.clientHelloVersion=Q.version,$.session.sp={},G)$.version=$.session.version=G.version,$.session.sp=G.sp;else{var W;for(var M=1;M<N.SupportedVersions.length;++M)if(W=N.SupportedVersions[M],W.minor<=Q.version.minor)break;$.version={major:W.major,minor:W.minor},$.session.version=$.version}if(G!==null)$.expect=q8,$.session.resuming=!0,$.session.sp.client_random=Q.random.bytes();else $.expect=$.verifyClient!==!1?HV:H8,$.session.resuming=!1,N.createSecurityParameters($,Q);if($.open=!0,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerHello($)})),$.session.resuming)N.queue($,N.createRecord($,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),$.state.pending=N.createConnectionState($),$.state.current.write=$.state.pending.write,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createFinished($)}));else if(N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificate($)})),!$.fail){if(N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerKeyExchange($)})),$.verifyClient!==!1)N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificateRequest($)}));N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerHelloDone($)}))}N.flush($),$.process()};N.handleCertificate=function($,J,X){if(X<3)return $.error($,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment,Y={certificate_list:TJ(Q,3)},G,W,M=[];try{while(Y.certificate_list.length()>0)G=TJ(Y.certificate_list,3),W=k.asn1.fromDer(G),G=k.pki.certificateFromAsn1(W,!0),M.push(G)}catch(O){return $.error($,{message:"Could not parse certificate list.",cause:O,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate}})}var U=$.entity===N.ConnectionEnd.client;if((U||$.verifyClient===!0)&&M.length===0)$.error($,{message:U?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});else if(M.length===0)$.expect=U?N1:H8;else{if(U)$.session.serverCertificate=M[0];else $.session.clientCertificate=M[0];if(N.verifyCertificateChain($,M))$.expect=U?N1:H8}$.process()};N.handleServerKeyExchange=function($,J,X){if(X>0)return $.error($,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unsupported_certificate}});$.expect=GV,$.process()};N.handleClientKeyExchange=function($,J,X){if(X<48)return $.error($,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unsupported_certificate}});var Q=J.fragment,Y={enc_pre_master_secret:TJ(Q,2).getBytes()},G=null;if($.getPrivateKey)try{G=$.getPrivateKey($,$.session.serverCertificate),G=k.pki.privateKeyFromPem(G)}catch(U){$.error($,{message:"Could not get private key.",cause:U,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}})}if(G===null)return $.error($,{message:"No private key set.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});try{var W=$.session.sp;W.pre_master_secret=G.decrypt(Y.enc_pre_master_secret);var M=$.session.clientHelloVersion;if(M.major!==W.pre_master_secret.charCodeAt(0)||M.minor!==W.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.")}catch(U){W.pre_master_secret=k.random.getBytes(48)}if($.expect=q8,$.session.clientCertificate!==null)$.expect=qV;$.process()};N.handleCertificateRequest=function($,J,X){if(X<3)return $.error($,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment,Y={certificate_types:TJ(Q,1),certificate_authorities:TJ(Q,2)};$.session.certificateRequest=Y,$.expect=WV,$.process()};N.handleCertificateVerify=function($,J,X){if(X<2)return $.error($,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment;Q.read-=4;var Y=Q.bytes();Q.read+=4;var G={signature:TJ(Q,2).getBytes()},W=k.util.createBuffer();W.putBuffer($.session.md5.digest()),W.putBuffer($.session.sha1.digest()),W=W.getBytes();try{var M=$.session.clientCertificate;if(!M.publicKey.verify(W,G.signature,"NONE"))throw Error("CertificateVerify signature does not match.");$.session.md5.update(Y),$.session.sha1.update(Y)}catch(U){return $.error($,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.handshake_failure}})}$.expect=q8,$.process()};N.handleServerHelloDone=function($,J,X){if(X>0)return $.error($,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.record_overflow}});if($.serverCertificate===null){var Q={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.insufficient_security}},Y=0,G=$.verify($,Q.alert.description,Y,[]);if(G!==!0){if(G||G===0){if(typeof G==="object"&&!k.util.isArray(G)){if(G.message)Q.message=G.message;if(G.alert)Q.alert.description=G.alert}else if(typeof G==="number")Q.alert.description=G}return $.error($,Q)}}if($.session.certificateRequest!==null)J=N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificate($)}),N.queue($,J);J=N.createRecord($,{type:N.ContentType.handshake,data:N.createClientKeyExchange($)}),N.queue($,J),$.expect=OV;var W=function(M,U){if(M.session.certificateRequest!==null&&M.session.clientCertificate!==null)N.queue(M,N.createRecord(M,{type:N.ContentType.handshake,data:N.createCertificateVerify(M,U)}));N.queue(M,N.createRecord(M,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),M.state.pending=N.createConnectionState(M),M.state.current.write=M.state.pending.write,N.queue(M,N.createRecord(M,{type:N.ContentType.handshake,data:N.createFinished(M)})),M.expect=R1,N.flush(M),M.process()};if($.session.certificateRequest===null||$.session.clientCertificate===null)return W($,null);N.getClientSignature($,W)};N.handleChangeCipherSpec=function($,J){if(J.fragment.getByte()!==1)return $.error($,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var X=$.entity===N.ConnectionEnd.client;if($.session.resuming&&X||!$.session.resuming&&!X)$.state.pending=N.createConnectionState($);if($.state.current.read=$.state.pending.read,!$.session.resuming&&X||$.session.resuming&&!X)$.state.pending=null;$.expect=X?MV:KV,$.process()};N.handleFinished=function($,J,X){var Q=J.fragment;Q.read-=4;var Y=Q.bytes();Q.read+=4;var G=J.fragment.getBytes();Q=k.util.createBuffer(),Q.putBuffer($.session.md5.digest()),Q.putBuffer($.session.sha1.digest());var W=$.entity===N.ConnectionEnd.client,M=W?"server finished":"client finished",U=$.session.sp,O=12,V=CY;if(Q=V(U.master_secret,M,Q.getBytes(),O),Q.getBytes()!==G)return $.error($,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.decrypt_error}});if($.session.md5.update(Y),$.session.sha1.update(Y),$.session.resuming&&W||!$.session.resuming&&!W)N.queue($,N.createRecord($,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),$.state.current.write=$.state.pending.write,$.state.pending=null,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createFinished($)}));$.expect=W?UV:zV,$.handshaking=!1,++$.handshakes,$.peerCertificate=W?$.session.serverCertificate:$.session.clientCertificate,N.flush($),$.isConnected=!0,$.connected($),$.process()};N.handleAlert=function($,J){var X=J.fragment,Q={level:X.getByte(),description:X.getByte()},Y;switch(Q.description){case N.Alert.Description.close_notify:Y="Connection closed.";break;case N.Alert.Description.unexpected_message:Y="Unexpected message.";break;case N.Alert.Description.bad_record_mac:Y="Bad record MAC.";break;case N.Alert.Description.decryption_failed:Y="Decryption failed.";break;case N.Alert.Description.record_overflow:Y="Record overflow.";break;case N.Alert.Description.decompression_failure:Y="Decompression failed.";break;case N.Alert.Description.handshake_failure:Y="Handshake failure.";break;case N.Alert.Description.bad_certificate:Y="Bad certificate.";break;case N.Alert.Description.unsupported_certificate:Y="Unsupported certificate.";break;case N.Alert.Description.certificate_revoked:Y="Certificate revoked.";break;case N.Alert.Description.certificate_expired:Y="Certificate expired.";break;case N.Alert.Description.certificate_unknown:Y="Certificate unknown.";break;case N.Alert.Description.illegal_parameter:Y="Illegal parameter.";break;case N.Alert.Description.unknown_ca:Y="Unknown certificate authority.";break;case N.Alert.Description.access_denied:Y="Access denied.";break;case N.Alert.Description.decode_error:Y="Decode error.";break;case N.Alert.Description.decrypt_error:Y="Decrypt error.";break;case N.Alert.Description.export_restriction:Y="Export restriction.";break;case N.Alert.Description.protocol_version:Y="Unsupported protocol version.";break;case N.Alert.Description.insufficient_security:Y="Insufficient security.";break;case N.Alert.Description.internal_error:Y="Internal error.";break;case N.Alert.Description.user_canceled:Y="User canceled.";break;case N.Alert.Description.no_renegotiation:Y="Renegotiation not supported.";break;default:Y="Unknown error.";break}if(Q.description===N.Alert.Description.close_notify)return $.close();$.error($,{message:Y,send:!1,origin:$.entity===N.ConnectionEnd.client?"server":"client",alert:Q}),$.process()};N.handleHandshake=function($,J){var X=J.fragment,Q=X.getByte(),Y=X.getInt24();if(Y>X.length())return $.fragmented=J,J.fragment=k.util.createBuffer(),X.read-=4,$.process();$.fragmented=null,X.read-=4;var G=X.bytes(Y+4);if(X.read+=4,Q in IY[$.entity][$.expect]){if($.entity===N.ConnectionEnd.server&&!$.open&&!$.fail)$.handshaking=!0,$.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:k.md.md5.create(),sha1:k.md.sha1.create()};if(Q!==N.HandshakeType.hello_request&&Q!==N.HandshakeType.certificate_verify&&Q!==N.HandshakeType.finished)$.session.md5.update(G),$.session.sha1.update(G);IY[$.entity][$.expect][Q]($,J,Y)}else N.handleUnexpected($,J)};N.handleApplicationData=function($,J){$.data.putBuffer(J.fragment),$.dataReady($),$.process()};N.handleHeartbeat=function($,J){var X=J.fragment,Q=X.getByte(),Y=X.getInt16(),G=X.getBytes(Y);if(Q===N.HeartbeatMessageType.heartbeat_request){if($.handshaking||Y>G.length)return $.process();N.queue($,N.createRecord($,{type:N.ContentType.heartbeat,data:N.createHeartbeat(N.HeartbeatMessageType.heartbeat_response,G)})),N.flush($)}else if(Q===N.HeartbeatMessageType.heartbeat_response){if(G!==$.expectedHeartbeatPayload)return $.process();if($.heartbeatReceived)$.heartbeatReceived($,k.util.createBuffer(G))}$.process()};var XV=0,YV=1,N1=2,GV=3,WV=4,R1=5,MV=6,UV=7,OV=8,VV=0,HV=1,H8=2,qV=3,q8=4,KV=5,zV=6,E=N.handleUnexpected,A1=N.handleChangeCipherSpec,HJ=N.handleAlert,RJ=N.handleHandshake,D1=N.handleApplicationData,qJ=N.handleHeartbeat,K8=[];K8[N.ConnectionEnd.client]=[[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[A1,HJ,E,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,D1,qJ],[E,HJ,RJ,E,qJ]];K8[N.ConnectionEnd.server]=[[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,E,qJ],[A1,HJ,E,E,qJ],[E,HJ,RJ,E,qJ],[E,HJ,RJ,D1,qJ],[E,HJ,RJ,E,qJ]];var{handleHelloRequest:_0,handleServerHello:EV,handleCertificate:Z1,handleServerKeyExchange:L1,handleCertificateRequest:O8,handleServerHelloDone:SY,handleFinished:B1}=N,IY=[];IY[N.ConnectionEnd.client]=[[E,E,EV,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,Z1,L1,O8,SY,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,L1,O8,SY,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,E,O8,SY,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,E,E,SY,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,B1],[_0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[_0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];var{handleClientHello:FV,handleClientKeyExchange:NV,handleCertificateVerify:LV}=N;IY[N.ConnectionEnd.server]=[[E,FV,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,Z1,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,NV,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,LV,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,B1],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];N.generateKeys=function($,J){var X=CY,Q=J.client_random+J.server_random;if(!$.session.resuming)J.master_secret=X(J.pre_master_secret,"master secret",Q,48).bytes(),J.pre_master_secret=null;Q=J.server_random+J.client_random;var Y=2*J.mac_key_length+2*J.enc_key_length,G=$.version.major===N.Versions.TLS_1_0.major&&$.version.minor===N.Versions.TLS_1_0.minor;if(G)Y+=2*J.fixed_iv_length;var W=X(J.master_secret,"key expansion",Q,Y),M={client_write_MAC_key:W.getBytes(J.mac_key_length),server_write_MAC_key:W.getBytes(J.mac_key_length),client_write_key:W.getBytes(J.enc_key_length),server_write_key:W.getBytes(J.enc_key_length)};if(G)M.client_write_IV=W.getBytes(J.fixed_iv_length),M.server_write_IV=W.getBytes(J.fixed_iv_length);return M};N.createConnectionState=function($){var J=$.entity===N.ConnectionEnd.client,X=function(){var G={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(W){return!0},compressionState:null,compressFunction:function(W){return!0},updateSequenceNumber:function(){if(G.sequenceNumber[1]===4294967295)G.sequenceNumber[1]=0,++G.sequenceNumber[0];else++G.sequenceNumber[1]}};return G},Q={read:X(),write:X()};if(Q.read.update=function(G,W){if(!Q.read.cipherFunction(W,Q.read))G.error(G,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_record_mac}});else if(!Q.read.compressFunction(G,W,Q.read))G.error(G,{message:"Could not decompress record.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.decompression_failure}});return!G.fail},Q.write.update=function(G,W){if(!Q.write.compressFunction(G,W,Q.write))G.error(G,{message:"Could not compress record.",send:!1,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});else if(!Q.write.cipherFunction(W,Q.write))G.error(G,{message:"Could not encrypt record.",send:!1,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});return!G.fail},$.session){var Y=$.session.sp;switch($.session.cipherSuite.initSecurityParameters(Y),Y.keys=N.generateKeys($,Y),Q.read.macKey=J?Y.keys.server_write_MAC_key:Y.keys.client_write_MAC_key,Q.write.macKey=J?Y.keys.client_write_MAC_key:Y.keys.server_write_MAC_key,$.session.cipherSuite.initConnectionState(Q,$,Y),Y.compression_algorithm){case N.CompressionMethod.none:break;case N.CompressionMethod.deflate:Q.read.compressFunction=QV,Q.write.compressFunction=JV;break;default:throw Error("Unsupported compression algorithm.")}}return Q};N.createRandom=function(){var $=new Date,J=+$+$.getTimezoneOffset()*60000,X=k.util.createBuffer();return X.putInt32(J),X.putBytes(k.random.getBytes(28)),X};N.createRecord=function($,J){if(!J.data)return null;var X={type:J.type,version:{major:$.version.major,minor:$.version.minor},length:J.data.length(),fragment:J.data};return X};N.createAlert=function($,J){var X=k.util.createBuffer();return X.putByte(J.level),X.putByte(J.description),N.createRecord($,{type:N.ContentType.alert,data:X})};N.createClientHello=function($){$.session.clientHelloVersion={major:$.version.major,minor:$.version.minor};var J=k.util.createBuffer();for(var X=0;X<$.cipherSuites.length;++X){var Q=$.cipherSuites[X];J.putByte(Q.id[0]),J.putByte(Q.id[1])}var Y=J.length(),G=k.util.createBuffer();G.putByte(N.CompressionMethod.none);var W=G.length(),M=k.util.createBuffer();if($.virtualHost){var U=k.util.createBuffer();U.putByte(0),U.putByte(0);var O=k.util.createBuffer();O.putByte(0),kJ(O,2,k.util.createBuffer($.virtualHost));var V=k.util.createBuffer();kJ(V,2,O),kJ(U,2,V),M.putBuffer(U)}var H=M.length();if(H>0)H+=2;var q=$.session.id,F=q.length+1+2+4+28+2+Y+1+W+H,K=k.util.createBuffer();if(K.putByte(N.HandshakeType.client_hello),K.putInt24(F),K.putByte($.version.major),K.putByte($.version.minor),K.putBytes($.session.sp.client_random),kJ(K,1,k.util.createBuffer(q)),kJ(K,2,J),kJ(K,1,G),H>0)kJ(K,2,M);return K};N.createServerHello=function($){var J=$.session.id,X=J.length+1+2+4+28+2+1,Q=k.util.createBuffer();return Q.putByte(N.HandshakeType.server_hello),Q.putInt24(X),Q.putByte($.version.major),Q.putByte($.version.minor),Q.putBytes($.session.sp.server_random),kJ(Q,1,k.util.createBuffer(J)),Q.putByte($.session.cipherSuite.id[0]),Q.putByte($.session.cipherSuite.id[1]),Q.putByte($.session.compressionMethod),Q};N.createCertificate=function($){var J=$.entity===N.ConnectionEnd.client,X=null;if($.getCertificate){var Q;if(J)Q=$.session.certificateRequest;else Q=$.session.extensions.server_name.serverNameList;X=$.getCertificate($,Q)}var Y=k.util.createBuffer();if(X!==null)try{if(!k.util.isArray(X))X=[X];var G=null;for(var W=0;W<X.length;++W){var M=k.pem.decode(X[W])[0];if(M.type!=="CERTIFICATE"&&M.type!=="X509 CERTIFICATE"&&M.type!=="TRUSTED CERTIFICATE"){var U=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw U.headerType=M.type,U}if(M.procType&&M.procType.type==="ENCRYPTED")throw Error("Could not convert certificate from PEM; PEM is encrypted.");var O=k.util.createBuffer(M.body);if(G===null)G=k.asn1.fromDer(O.bytes(),!1);var V=k.util.createBuffer();kJ(V,3,O),Y.putBuffer(V)}if(X=k.pki.certificateFromAsn1(G),J)$.session.clientCertificate=X;else $.session.serverCertificate=X}catch(F){return $.error($,{message:"Could not send certificate list.",cause:F,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate}})}var H=3+Y.length(),q=k.util.createBuffer();return q.putByte(N.HandshakeType.certificate),q.putInt24(H),kJ(q,3,Y),q};N.createClientKeyExchange=function($){var J=k.util.createBuffer();J.putByte($.session.clientHelloVersion.major),J.putByte($.session.clientHelloVersion.minor),J.putBytes(k.random.getBytes(46));var X=$.session.sp;X.pre_master_secret=J.getBytes();var Q=$.session.serverCertificate.publicKey;J=Q.encrypt(X.pre_master_secret);var Y=J.length+2,G=k.util.createBuffer();return G.putByte(N.HandshakeType.client_key_exchange),G.putInt24(Y),G.putInt16(J.length),G.putBytes(J),G};N.createServerKeyExchange=function($){var J=0,X=k.util.createBuffer();if(J>0)X.putByte(N.HandshakeType.server_key_exchange),X.putInt24(J);return X};N.getClientSignature=function($,J){var X=k.util.createBuffer();X.putBuffer($.session.md5.digest()),X.putBuffer($.session.sha1.digest()),X=X.getBytes(),$.getSignature=$.getSignature||function(Q,Y,G){var W=null;if(Q.getPrivateKey)try{W=Q.getPrivateKey(Q,Q.session.clientCertificate),W=k.pki.privateKeyFromPem(W)}catch(M){Q.error(Q,{message:"Could not get private key.",cause:M,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}})}if(W===null)Q.error(Q,{message:"No private key set.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});else Y=W.sign(Y,null);G(Q,Y)},$.getSignature($,X,J)};N.createCertificateVerify=function($,J){var X=J.length+2,Q=k.util.createBuffer();return Q.putByte(N.HandshakeType.certificate_verify),Q.putInt24(X),Q.putInt16(J.length),Q.putBytes(J),Q};N.createCertificateRequest=function($){var J=k.util.createBuffer();J.putByte(1);var X=k.util.createBuffer();for(var Q in $.caStore.certs){var Y=$.caStore.certs[Q],G=k.pki.distinguishedNameToAsn1(Y.subject),W=k.asn1.toDer(G);X.putInt16(W.length()),X.putBuffer(W)}var M=1+J.length()+2+X.length(),U=k.util.createBuffer();return U.putByte(N.HandshakeType.certificate_request),U.putInt24(M),kJ(U,1,J),kJ(U,2,X),U};N.createServerHelloDone=function($){var J=k.util.createBuffer();return J.putByte(N.HandshakeType.server_hello_done),J.putInt24(0),J};N.createChangeCipherSpec=function(){var $=k.util.createBuffer();return $.putByte(1),$};N.createFinished=function($){var J=k.util.createBuffer();J.putBuffer($.session.md5.digest()),J.putBuffer($.session.sha1.digest());var X=$.entity===N.ConnectionEnd.client,Q=$.session.sp,Y=12,G=CY,W=X?"client finished":"server finished";J=G(Q.master_secret,W,J.getBytes(),Y);var M=k.util.createBuffer();return M.putByte(N.HandshakeType.finished),M.putInt24(J.length()),M.putBuffer(J),M};N.createHeartbeat=function($,J,X){if(typeof X>"u")X=J.length;var Q=k.util.createBuffer();Q.putByte($),Q.putInt16(X),Q.putBytes(J);var Y=Q.length(),G=Math.max(16,Y-X-3);return Q.putBytes(k.random.getBytes(G)),Q};N.queue=function($,J){if(!J)return;if(J.fragment.length()===0){if(J.type===N.ContentType.handshake||J.type===N.ContentType.alert||J.type===N.ContentType.change_cipher_spec)return}if(J.type===N.ContentType.handshake){var X=J.fragment.bytes();$.session.md5.update(X),$.session.sha1.update(X),X=null}var Q;if(J.fragment.length()<=N.MaxFragment)Q=[J];else{Q=[];var Y=J.fragment.bytes();while(Y.length>N.MaxFragment)Q.push(N.createRecord($,{type:J.type,data:k.util.createBuffer(Y.slice(0,N.MaxFragment))})),Y=Y.slice(N.MaxFragment);if(Y.length>0)Q.push(N.createRecord($,{type:J.type,data:k.util.createBuffer(Y)}))}for(var G=0;G<Q.length&&!$.fail;++G){var W=Q[G],M=$.state.current.write;if(M.update($,W))$.records.push(W)}};N.flush=function($){for(var J=0;J<$.records.length;++J){var X=$.records[J];$.tlsData.putByte(X.type),$.tlsData.putByte(X.version.major),$.tlsData.putByte(X.version.minor),$.tlsData.putInt16(X.fragment.length()),$.tlsData.putBuffer($.records[J].fragment)}return $.records=[],$.tlsDataReady($)};var V8=function($){switch($){case!0:return!0;case k.pki.certificateError.bad_certificate:return N.Alert.Description.bad_certificate;case k.pki.certificateError.unsupported_certificate:return N.Alert.Description.unsupported_certificate;case k.pki.certificateError.certificate_revoked:return N.Alert.Description.certificate_revoked;case k.pki.certificateError.certificate_expired:return N.Alert.Description.certificate_expired;case k.pki.certificateError.certificate_unknown:return N.Alert.Description.certificate_unknown;case k.pki.certificateError.unknown_ca:return N.Alert.Description.unknown_ca;default:return N.Alert.Description.bad_certificate}},RV=function($){switch($){case!0:return!0;case N.Alert.Description.bad_certificate:return k.pki.certificateError.bad_certificate;case N.Alert.Description.unsupported_certificate:return k.pki.certificateError.unsupported_certificate;case N.Alert.Description.certificate_revoked:return k.pki.certificateError.certificate_revoked;case N.Alert.Description.certificate_expired:return k.pki.certificateError.certificate_expired;case N.Alert.Description.certificate_unknown:return k.pki.certificateError.certificate_unknown;case N.Alert.Description.unknown_ca:return k.pki.certificateError.unknown_ca;default:return k.pki.certificateError.bad_certificate}};N.verifyCertificateChain=function($,J){try{var X={};for(var Q in $.verifyOptions)X[Q]=$.verifyOptions[Q];X.verify=function(G,W,M){var U=V8(G),O=$.verify($,G,W,M);if(O!==!0){if(typeof O==="object"&&!k.util.isArray(O)){var V=Error("The application rejected the certificate.");if(V.send=!0,V.alert={level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate},O.message)V.message=O.message;if(O.alert)V.alert.description=O.alert;throw V}if(O!==G)O=RV(O)}return O},k.pki.verifyCertificateChain($.caStore,J,X)}catch(G){var Y=G;if(typeof Y!=="object"||k.util.isArray(Y))Y={send:!0,alert:{level:N.Alert.Level.fatal,description:V8(G)}};if(!("send"in Y))Y.send=!0;if(!("alert"in Y))Y.alert={level:N.Alert.Level.fatal,description:V8(Y.error)};$.error($,Y)}return!$.fail};N.createSessionCache=function($,J){var X=null;if($&&$.getSession&&$.setSession&&$.order)X=$;else{X={},X.cache=$||{},X.capacity=Math.max(J||100,1),X.order=[];for(var Q in $)if(X.order.length<=J)X.order.push(Q);else delete $[Q];X.getSession=function(Y){var G=null,W=null;if(Y)W=k.util.bytesToHex(Y);else if(X.order.length>0)W=X.order[0];if(W!==null&&W in X.cache){G=X.cache[W],delete X.cache[W];for(var M in X.order)if(X.order[M]===W){X.order.splice(M,1);break}}return G},X.setSession=function(Y,G){if(X.order.length===X.capacity){var W=X.order.shift();delete X.cache[W]}var W=k.util.bytesToHex(Y);X.order.push(W),X.cache[W]=G}}return X};N.createConnection=function($){var J=null;if($.caStore)if(k.util.isArray($.caStore))J=k.pki.createCaStore($.caStore);else J=$.caStore;else J=k.pki.createCaStore();var X=$.cipherSuites||null;if(X===null){X=[];for(var Q in N.CipherSuites)X.push(N.CipherSuites[Q])}var Y=$.server?N.ConnectionEnd.server:N.ConnectionEnd.client,G=$.sessionCache?N.createSessionCache($.sessionCache):null,W={version:{major:N.Version.major,minor:N.Version.minor},entity:Y,sessionId:$.sessionId,caStore:J,sessionCache:G,cipherSuites:X,connected:$.connected,virtualHost:$.virtualHost||null,verifyClient:$.verifyClient||!1,verify:$.verify||function(V,H,q,F){return H},verifyOptions:$.verifyOptions||{},getCertificate:$.getCertificate||null,getPrivateKey:$.getPrivateKey||null,getSignature:$.getSignature||null,input:k.util.createBuffer(),tlsData:k.util.createBuffer(),data:k.util.createBuffer(),tlsDataReady:$.tlsDataReady,dataReady:$.dataReady,heartbeatReceived:$.heartbeatReceived,closed:$.closed,error:function(V,H){if(H.origin=H.origin||(V.entity===N.ConnectionEnd.client?"client":"server"),H.send)N.queue(V,N.createAlert(V,H.alert)),N.flush(V);var q=H.fatal!==!1;if(q)V.fail=!0;if($.error(V,H),q)V.close(!1)},deflate:$.deflate||null,inflate:$.inflate||null};W.reset=function(V){W.version={major:N.Version.major,minor:N.Version.minor},W.record=null,W.session=null,W.peerCertificate=null,W.state={pending:null,current:null},W.expect=W.entity===N.ConnectionEnd.client?XV:VV,W.fragmented=null,W.records=[],W.open=!1,W.handshakes=0,W.handshaking=!1,W.isConnected=!1,W.fail=!(V||typeof V>"u"),W.input.clear(),W.tlsData.clear(),W.data.clear(),W.state.current=N.createConnectionState(W)},W.reset();var M=function(V,H){var q=H.type-N.ContentType.change_cipher_spec,F=K8[V.entity][V.expect];if(q in F)F[q](V,H);else N.handleUnexpected(V,H)},U=function(V){var H=0,q=V.input,F=q.length();if(F<5)H=5-F;else{V.record={type:q.getByte(),version:{major:q.getByte(),minor:q.getByte()},length:q.getInt16(),fragment:k.util.createBuffer(),ready:!1};var K=V.record.version.major===V.version.major;if(K&&V.session&&V.session.version)K=V.record.version.minor===V.version.minor;if(!K)V.error(V,{message:"Incompatible TLS version.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}})}return H},O=function(V){var H=0,q=V.input,F=q.length();if(F<V.record.length)H=V.record.length-F;else{V.record.fragment.putBytes(q.getBytes(V.record.length)),q.compact();var K=V.state.current.read;if(K.update(V,V.record)){if(V.fragmented!==null)if(V.fragmented.type===V.record.type)V.fragmented.fragment.putBuffer(V.record.fragment),V.record=V.fragmented;else V.error(V,{message:"Invalid fragmented record.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unexpected_message}});V.record.ready=!0}}return H};return W.handshake=function(V){if(W.entity!==N.ConnectionEnd.client)W.error(W,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(W.handshaking)W.error(W,{message:"Handshake already in progress.",fatal:!1});else{if(W.fail&&!W.open&&W.handshakes===0)W.fail=!1;W.handshaking=!0,V=V||"";var H=null;if(V.length>0){if(W.sessionCache)H=W.sessionCache.getSession(V);if(H===null)V=""}if(V.length===0&&W.sessionCache){if(H=W.sessionCache.getSession(),H!==null)V=H.id}if(W.session={id:V,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:k.md.md5.create(),sha1:k.md.sha1.create()},H)W.version=H.version,W.session.sp=H.sp;W.session.sp.client_random=N.createRandom().getBytes(),W.open=!0,N.queue(W,N.createRecord(W,{type:N.ContentType.handshake,data:N.createClientHello(W)})),N.flush(W)}},W.process=function(V){var H=0;if(V)W.input.putBytes(V);if(!W.fail){if(W.record!==null&&W.record.ready&&W.record.fragment.isEmpty())W.record=null;if(W.record===null)H=U(W);if(!W.fail&&W.record!==null&&!W.record.ready)H=O(W);if(!W.fail&&W.record!==null&&W.record.ready)M(W,W.record)}return H},W.prepare=function(V){return N.queue(W,N.createRecord(W,{type:N.ContentType.application_data,data:k.util.createBuffer(V)})),N.flush(W)},W.prepareHeartbeatRequest=function(V,H){if(V instanceof k.util.ByteBuffer)V=V.bytes();if(typeof H>"u")H=V.length;return W.expectedHeartbeatPayload=V,N.queue(W,N.createRecord(W,{type:N.ContentType.heartbeat,data:N.createHeartbeat(N.HeartbeatMessageType.heartbeat_request,V,H)})),N.flush(W)},W.close=function(V){if(!W.fail&&W.sessionCache&&W.session){var H={id:W.session.id,version:W.session.version,sp:W.session.sp};H.sp.keys=null,W.sessionCache.setSession(H.id,H)}if(W.open){if(W.open=!1,W.input.clear(),W.isConnected||W.handshaking)W.isConnected=W.handshaking=!1,N.queue(W,N.createAlert(W,{level:N.Alert.Level.warning,description:N.Alert.Description.close_notify})),N.flush(W);W.closed(W)}W.reset(V)},W};j1.exports=k.tls=k.tls||{};for(AX in N)if(typeof N[AX]!=="function")k.tls[AX]=N[AX];var AX;k.tls.prf_tls1=CY;k.tls.hmac_sha1=$V;k.tls.createSessionCache=N.createSessionCache;k.tls.createConnection=N.createConnection});var I1=M$((SE,S1)=>{var x0=K$();T0();z8();var fJ=S1.exports=x0.tls;fJ.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function($){$.bulk_cipher_algorithm=fJ.BulkCipherAlgorithm.aes,$.cipher_type=fJ.CipherType.block,$.enc_key_length=16,$.block_length=16,$.fixed_iv_length=16,$.record_iv_length=16,$.mac_algorithm=fJ.MACAlgorithm.hmac_sha1,$.mac_length=20,$.mac_key_length=20},initConnectionState:T1};fJ.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function($){$.bulk_cipher_algorithm=fJ.BulkCipherAlgorithm.aes,$.cipher_type=fJ.CipherType.block,$.enc_key_length=32,$.block_length=16,$.fixed_iv_length=16,$.record_iv_length=16,$.mac_algorithm=fJ.MACAlgorithm.hmac_sha1,$.mac_length=20,$.mac_key_length=20},initConnectionState:T1};function T1($,J,X){var Q=J.entity===x0.tls.ConnectionEnd.client;$.read.cipherState={init:!1,cipher:x0.cipher.createDecipher("AES-CBC",Q?X.keys.server_write_key:X.keys.client_write_key),iv:Q?X.keys.server_write_IV:X.keys.client_write_IV},$.write.cipherState={init:!1,cipher:x0.cipher.createCipher("AES-CBC",Q?X.keys.client_write_key:X.keys.server_write_key),iv:Q?X.keys.client_write_IV:X.keys.server_write_IV},$.read.cipherFunction=BV,$.write.cipherFunction=AV,$.read.macLength=$.write.macLength=X.mac_length,$.read.macFunction=$.write.macFunction=fJ.hmac_sha1}function AV($,J){var X=!1,Q=J.macFunction(J.macKey,J.sequenceNumber,$);$.fragment.putBytes(Q),J.updateSequenceNumber();var Y;if($.version.minor===fJ.Versions.TLS_1_0.minor)Y=J.cipherState.init?null:J.cipherState.iv;else Y=x0.random.getBytesSync(16);J.cipherState.init=!0;var G=J.cipherState.cipher;if(G.start({iv:Y}),$.version.minor>=fJ.Versions.TLS_1_1.minor)G.output.putBytes(Y);if(G.update($.fragment),G.finish(DV))$.fragment=G.output,$.length=$.fragment.length(),X=!0;return X}function DV($,J,X){if(!X){var Q=$-J.length()%$;J.fillWithByte(Q-1,Q)}return!0}function ZV($,J,X){var Q=!0;if(X){var Y=J.length(),G=J.last();for(var W=Y-1-G;W<Y-1;++W)Q=Q&&J.at(W)==G;if(Q)J.truncate(G+1)}return Q}function BV($,J){var X=!1,Q;if($.version.minor===fJ.Versions.TLS_1_0.minor)Q=J.cipherState.init?null:J.cipherState.iv;else Q=$.fragment.getBytes(16);J.cipherState.init=!0;var Y=J.cipherState.cipher;Y.start({iv:Q}),Y.update($.fragment),X=Y.finish(ZV);var G=J.macLength,W=x0.random.getBytesSync(G),M=Y.output.length();if(M>=G)$.fragment=Y.output.getBytes(M-G),W=Y.output.getBytes(G);else $.fragment=Y.output.getBytes();$.fragment=x0.util.createBuffer($.fragment),$.length=$.fragment.length();var U=J.macFunction(J.macKey,J.sequenceNumber,$);return J.updateSequenceNumber(),X=jV(J.macKey,W,U)&&X,X}function jV($,J,X){var Q=x0.hmac.create();return Q.start("SHA1",$),Q.update(J),J=Q.digest().getBytes(),Q.start(null,null),Q.update(X),X=Q.digest().getBytes(),J===X}});var N8=M$((IE,_1)=>{var g$=K$();rJ();C$();var DX=_1.exports=g$.sha512=g$.sha512||{};g$.md.sha512=g$.md.algorithms.sha512=DX;var w1=g$.sha384=g$.sha512.sha384=g$.sha512.sha384||{};w1.create=function(){return DX.create("SHA-384")};g$.md.sha384=g$.md.algorithms.sha384=w1;g$.sha512.sha256=g$.sha512.sha256||{create:function(){return DX.create("SHA-512/256")}};g$.md["sha512/256"]=g$.md.algorithms["sha512/256"]=g$.sha512.sha256;g$.sha512.sha224=g$.sha512.sha224||{create:function(){return DX.create("SHA-512/224")}};g$.md["sha512/224"]=g$.md.algorithms["sha512/224"]=g$.sha512.sha224;DX.create=function($){if(!P1)TV();if(typeof $>"u")$="SHA-512";if(!($ in YQ))throw Error("Invalid SHA-512 algorithm: "+$);var J=YQ[$],X=null,Q=g$.util.createBuffer(),Y=Array(80);for(var G=0;G<80;++G)Y[G]=[,,];var W=64;switch($){case"SHA-384":W=48;break;case"SHA-512/256":W=32;break;case"SHA-512/224":W=28;break}var M={algorithm:$.replace("-","").toLowerCase(),blockLength:128,digestLength:W,messageLength:0,fullMessageLength:null,messageLengthSize:16};return M.start=function(){M.messageLength=0,M.fullMessageLength=M.messageLength128=[];var U=M.messageLengthSize/4;for(var O=0;O<U;++O)M.fullMessageLength.push(0);Q=g$.util.createBuffer(),X=Array(J.length);for(var O=0;O<J.length;++O)X[O]=J[O].slice(0);return M},M.start(),M.update=function(U,O){if(O==="utf8")U=g$.util.encodeUtf8(U);var V=U.length;M.messageLength+=V,V=[V/4294967296>>>0,V>>>0];for(var H=M.fullMessageLength.length-1;H>=0;--H)M.fullMessageLength[H]+=V[1],V[1]=V[0]+(M.fullMessageLength[H]/4294967296>>>0),M.fullMessageLength[H]=M.fullMessageLength[H]>>>0,V[0]=V[1]/4294967296>>>0;if(Q.putBytes(U),C1(X,Y,Q),Q.read>2048||Q.length()===0)Q.compact();return M},M.digest=function(){var U=g$.util.createBuffer();U.putBytes(Q.bytes());var O=M.fullMessageLength[M.fullMessageLength.length-1]+M.messageLengthSize,V=O&M.blockLength-1;U.putBytes(E8.substr(0,M.blockLength-V));var H,q,F=M.fullMessageLength[0]*8;for(var K=0;K<M.fullMessageLength.length-1;++K)H=M.fullMessageLength[K+1]*8,q=H/4294967296>>>0,F+=q,U.putInt32(F>>>0),F=H>>>0;U.putInt32(F);var R=Array(X.length);for(var K=0;K<X.length;++K)R[K]=X[K].slice(0);C1(R,Y,U);var L=g$.util.createBuffer(),D;if($==="SHA-512")D=R.length;else if($==="SHA-384")D=R.length-2;else D=R.length-4;for(var K=0;K<D;++K)if(L.putInt32(R[K][0]),K!==D-1||$!=="SHA-512/224")L.putInt32(R[K][1]);return L},M};var E8=null,P1=!1,F8=null,YQ=null;function TV(){E8=String.fromCharCode(128),E8+=g$.util.fillString(String.fromCharCode(0),128),F8=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],YQ={},YQ["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],YQ["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],YQ["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],YQ["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],P1=!0}function C1($,J,X){var Q,Y,G,W,M,U,O,V,H,q,F,K,R,L,D,w,T,P,S,C,h,s,a,O$,j$,T$,G$,r,m,W$,l,H$,JJ,w$,D$,z$=X.length();while(z$>=128){for(m=0;m<16;++m)J[m][0]=X.getInt32()>>>0,J[m][1]=X.getInt32()>>>0;for(;m<80;++m)H$=J[m-2],W$=H$[0],l=H$[1],Q=((W$>>>19|l<<13)^(l>>>29|W$<<3)^W$>>>6)>>>0,Y=((W$<<13|l>>>19)^(l<<3|W$>>>29)^(W$<<26|l>>>6))>>>0,w$=J[m-15],W$=w$[0],l=w$[1],G=((W$>>>1|l<<31)^(W$>>>8|l<<24)^W$>>>7)>>>0,W=((W$<<31|l>>>1)^(W$<<24|l>>>8)^(W$<<25|l>>>7))>>>0,JJ=J[m-7],D$=J[m-16],l=Y+JJ[1]+W+D$[1],J[m][0]=Q+JJ[0]+G+D$[0]+(l/4294967296>>>0)>>>0,J[m][1]=l>>>0;R=$[0][0],L=$[0][1],D=$[1][0],w=$[1][1],T=$[2][0],P=$[2][1],S=$[3][0],C=$[3][1],h=$[4][0],s=$[4][1],a=$[5][0],O$=$[5][1],j$=$[6][0],T$=$[6][1],G$=$[7][0],r=$[7][1];for(m=0;m<80;++m)O=((h>>>14|s<<18)^(h>>>18|s<<14)^(s>>>9|h<<23))>>>0,V=((h<<18|s>>>14)^(h<<14|s>>>18)^(s<<23|h>>>9))>>>0,H=(j$^h&(a^j$))>>>0,q=(T$^s&(O$^T$))>>>0,M=((R>>>28|L<<4)^(L>>>2|R<<30)^(L>>>7|R<<25))>>>0,U=((R<<4|L>>>28)^(L<<30|R>>>2)^(L<<25|R>>>7))>>>0,F=(R&D|T&(R^D))>>>0,K=(L&w|P&(L^w))>>>0,l=r+V+q+F8[m][1]+J[m][1],Q=G$+O+H+F8[m][0]+J[m][0]+(l/4294967296>>>0)>>>0,Y=l>>>0,l=U+K,G=M+F+(l/4294967296>>>0)>>>0,W=l>>>0,G$=j$,r=T$,j$=a,T$=O$,a=h,O$=s,l=C+Y,h=S+Q+(l/4294967296>>>0)>>>0,s=l>>>0,S=T,C=P,T=D,P=w,D=R,w=L,l=Y+W,R=Q+G+(l/4294967296>>>0)>>>0,L=l>>>0;l=$[0][1]+L,$[0][0]=$[0][0]+R+(l/4294967296>>>0)>>>0,$[0][1]=l>>>0,l=$[1][1]+w,$[1][0]=$[1][0]+D+(l/4294967296>>>0)>>>0,$[1][1]=l>>>0,l=$[2][1]+P,$[2][0]=$[2][0]+T+(l/4294967296>>>0)>>>0,$[2][1]=l>>>0,l=$[3][1]+C,$[3][0]=$[3][0]+S+(l/4294967296>>>0)>>>0,$[3][1]=l>>>0,l=$[4][1]+s,$[4][0]=$[4][0]+h+(l/4294967296>>>0)>>>0,$[4][1]=l>>>0,l=$[5][1]+O$,$[5][0]=$[5][0]+a+(l/4294967296>>>0)>>>0,$[5][1]=l>>>0,l=$[6][1]+T$,$[6][0]=$[6][0]+j$+(l/4294967296>>>0)>>>0,$[6][1]=l>>>0,l=$[7][1]+r,$[7][0]=$[7][0]+G$+(l/4294967296>>>0)>>>0,$[7][1]=l>>>0,z$-=128}}});var x1=M$((IV)=>{var SV=K$();gJ();var VJ=SV.asn1;IV.privateKeyValidator={name:"PrivateKeyInfo",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]};IV.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:VJ.Class.UNIVERSAL,type:VJ.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}});var p1=M$((wE,d1)=>{var KJ=K$();FX();PJ();N8();C$();var b1=x1(),PV=b1.publicKeyValidator,_V=b1.privateKeyValidator;if(typeof R8>"u")R8=KJ.jsbn.BigInteger;var R8,A8=KJ.util.ByteBuffer,ZJ=typeof Buffer>"u"?Uint8Array:Buffer;KJ.pki=KJ.pki||{};d1.exports=KJ.pki.ed25519=KJ.ed25519=KJ.ed25519||{};var R$=KJ.ed25519;R$.constants={};R$.constants.PUBLIC_KEY_BYTE_LENGTH=32;R$.constants.PRIVATE_KEY_BYTE_LENGTH=64;R$.constants.SEED_BYTE_LENGTH=32;R$.constants.SIGN_BYTE_LENGTH=64;R$.constants.HASH_BYTE_LENGTH=64;R$.generateKeyPair=function($){$=$||{};var J=$.seed;if(J===void 0)J=KJ.random.getBytesSync(R$.constants.SEED_BYTE_LENGTH);else if(typeof J==="string"){if(J.length!==R$.constants.SEED_BYTE_LENGTH)throw TypeError('"seed" must be '+R$.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(J instanceof Uint8Array))throw TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');J=F0({message:J,encoding:"binary"});var X=new ZJ(R$.constants.PUBLIC_KEY_BYTE_LENGTH),Q=new ZJ(R$.constants.PRIVATE_KEY_BYTE_LENGTH);for(var Y=0;Y<32;++Y)Q[Y]=J[Y];return fV(X,Q),{publicKey:X,privateKey:Q}};R$.privateKeyFromAsn1=function($){var J={},X=[],Q=KJ.asn1.validate($,_V,J,X);if(!Q){var Y=Error("Invalid Key.");throw Y.errors=X,Y}var G=KJ.asn1.derToOid(J.privateKeyOid),W=KJ.oids.EdDSA25519;if(G!==W)throw Error('Invalid OID "'+G+'"; OID must be "'+W+'".');var M=J.privateKey,U=F0({message:KJ.asn1.fromDer(M).value,encoding:"binary"});return{privateKeyBytes:U}};R$.publicKeyFromAsn1=function($){var J={},X=[],Q=KJ.asn1.validate($,PV,J,X);if(!Q){var Y=Error("Invalid Key.");throw Y.errors=X,Y}var G=KJ.asn1.derToOid(J.publicKeyOid),W=KJ.oids.EdDSA25519;if(G!==W)throw Error('Invalid OID "'+G+'"; OID must be "'+W+'".');var M=J.ed25519PublicKey;if(M.length!==R$.constants.PUBLIC_KEY_BYTE_LENGTH)throw Error("Key length is invalid.");return F0({message:M,encoding:"binary"})};R$.publicKeyFromPrivateKey=function($){$=$||{};var J=F0({message:$.privateKey,encoding:"binary"});if(J.length!==R$.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError('"options.privateKey" must have a byte length of '+R$.constants.PRIVATE_KEY_BYTE_LENGTH);var X=new ZJ(R$.constants.PUBLIC_KEY_BYTE_LENGTH);for(var Q=0;Q<X.length;++Q)X[Q]=J[32+Q];return X};R$.sign=function($){$=$||{};var J=F0($),X=F0({message:$.privateKey,encoding:"binary"});if(X.length===R$.constants.SEED_BYTE_LENGTH){var Q=R$.generateKeyPair({seed:X});X=Q.privateKey}else if(X.length!==R$.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError('"options.privateKey" must have a byte length of '+R$.constants.SEED_BYTE_LENGTH+" or "+R$.constants.PRIVATE_KEY_BYTE_LENGTH);var Y=new ZJ(R$.constants.SIGN_BYTE_LENGTH+J.length);yV(Y,J,J.length,X);var G=new ZJ(R$.constants.SIGN_BYTE_LENGTH);for(var W=0;W<G.length;++W)G[W]=Y[W];return G};R$.verify=function($){$=$||{};var J=F0($);if($.signature===void 0)throw TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var X=F0({message:$.signature,encoding:"binary"});if(X.length!==R$.constants.SIGN_BYTE_LENGTH)throw TypeError('"options.signature" must have a byte length of '+R$.constants.SIGN_BYTE_LENGTH);var Q=F0({message:$.publicKey,encoding:"binary"});if(Q.length!==R$.constants.PUBLIC_KEY_BYTE_LENGTH)throw TypeError('"options.publicKey" must have a byte length of '+R$.constants.PUBLIC_KEY_BYTE_LENGTH);var Y=new ZJ(R$.constants.SIGN_BYTE_LENGTH+J.length),G=new ZJ(R$.constants.SIGN_BYTE_LENGTH+J.length),W;for(W=0;W<R$.constants.SIGN_BYTE_LENGTH;++W)Y[W]=X[W];for(W=0;W<J.length;++W)Y[W+R$.constants.SIGN_BYTE_LENGTH]=J[W];return bV(G,Y,Y.length,Q)>=0};function F0($){var J=$.message;if(J instanceof Uint8Array||J instanceof ZJ)return J;var X=$.encoding;if(J===void 0)if($.md)J=$.md.digest().getBytes(),X="binary";else throw TypeError('"options.message" or "options.md" not specified.');if(typeof J==="string"&&!X)throw TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof J==="string"){if(typeof Buffer<"u")return Buffer.from(J,X);J=new A8(J,X)}else if(!(J instanceof A8))throw TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');var Q=new ZJ(J.length());for(var Y=0;Y<Q.length;++Y)Q[Y]=J.at(Y);return Q}var D8=X$(),wY=X$([1]),xV=X$([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),vV=X$([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),v1=X$([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),k1=X$([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ZX=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),kV=X$([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function BX($,J){var X=KJ.md.sha512.create(),Q=new A8($);X.update(Q.getBytes(J),"binary");var Y=X.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(Y,"binary");var G=new ZJ(R$.constants.HASH_BYTE_LENGTH);for(var W=0;W<64;++W)G[W]=Y.charCodeAt(W);return G}function fV($,J){var X=[X$(),X$(),X$(),X$()],Q,Y=BX(J,32);Y[0]&=248,Y[31]&=127,Y[31]|=64,T8(X,Y),j8($,X);for(Q=0;Q<32;++Q)J[Q+32]=$[Q];return 0}function yV($,J,X,Q){var Y,G,W=new Float64Array(64),M=[X$(),X$(),X$(),X$()],U=BX(Q,32);U[0]&=248,U[31]&=127,U[31]|=64;var O=X+64;for(Y=0;Y<X;++Y)$[64+Y]=J[Y];for(Y=0;Y<32;++Y)$[32+Y]=U[32+Y];var V=BX($.subarray(32),X+32);Z8(V),T8(M,V),j8($,M);for(Y=32;Y<64;++Y)$[Y]=Q[Y];var H=BX($,X+64);Z8(H);for(Y=32;Y<64;++Y)W[Y]=0;for(Y=0;Y<32;++Y)W[Y]=V[Y];for(Y=0;Y<32;++Y)for(G=0;G<32;G++)W[Y+G]+=H[Y]*U[G];return h1($.subarray(32),W),O}function bV($,J,X,Q){var Y,G,W=new ZJ(32),M=[X$(),X$(),X$(),X$()],U=[X$(),X$(),X$(),X$()];if(G=-1,X<64)return-1;if(uV(U,Q))return-1;if(!hV(J,32))return-1;for(Y=0;Y<X;++Y)$[Y]=J[Y];for(Y=0;Y<32;++Y)$[Y+32]=Q[Y];var O=BX($,X);if(Z8(O),m1(M,U,O),T8(U,J.subarray(32)),B8(M,U),j8(W,M),X-=64,u1(J,0,W,0)){for(Y=0;Y<X;++Y)$[Y]=0;return-1}for(Y=0;Y<X;++Y)$[Y]=J[Y+64];return G=X,G}function hV($,J){var X;for(X=31;X>=0;--X){if($[J+X]<ZX[X])return!0;if($[J+X]>ZX[X])return!1}return!1}function h1($,J){var X,Q,Y,G;for(Q=63;Q>=32;--Q){X=0;for(Y=Q-32,G=Q-12;Y<G;++Y)J[Y]+=X-16*J[Q]*ZX[Y-(Q-32)],X=J[Y]+128>>8,J[Y]-=X*256;J[Y]+=X,J[Q]=0}X=0;for(Y=0;Y<32;++Y)J[Y]+=X-(J[31]>>4)*ZX[Y],X=J[Y]>>8,J[Y]&=255;for(Y=0;Y<32;++Y)J[Y]-=X*ZX[Y];for(Q=0;Q<32;++Q)J[Q+1]+=J[Q]>>8,$[Q]=J[Q]&255}function Z8($){var J=new Float64Array(64);for(var X=0;X<64;++X)J[X]=$[X],$[X]=0;h1($,J)}function B8($,J){var X=X$(),Q=X$(),Y=X$(),G=X$(),W=X$(),M=X$(),U=X$(),O=X$(),V=X$();_Q(X,$[1],$[0]),_Q(V,J[1],J[0]),v$(X,X,V),PQ(Q,$[0],$[1]),PQ(V,J[0],J[1]),v$(Q,Q,V),v$(Y,$[3],J[3]),v$(Y,Y,vV),v$(G,$[2],J[2]),PQ(G,G,G),_Q(W,Q,X),_Q(M,G,Y),PQ(U,G,Y),PQ(O,Q,X),v$($[0],W,M),v$($[1],O,U),v$($[2],U,M),v$($[3],W,O)}function f1($,J,X){for(var Q=0;Q<4;++Q)l1($[Q],J[Q],X)}function j8($,J){var X=X$(),Q=X$(),Y=X$();dV(Y,J[2]),v$(X,J[0],Y),v$(Q,J[1],Y),PY($,Q),$[31]^=g1(X)<<7}function PY($,J){var X,Q,Y,G=X$(),W=X$();for(X=0;X<16;++X)W[X]=J[X];L8(W),L8(W),L8(W);for(Q=0;Q<2;++Q){G[0]=W[0]-65517;for(X=1;X<15;++X)G[X]=W[X]-65535-(G[X-1]>>16&1),G[X-1]&=65535;G[15]=W[15]-32767-(G[14]>>16&1),Y=G[15]>>16&1,G[14]&=65535,l1(W,G,1-Y)}for(X=0;X<16;X++)$[2*X]=W[X]&255,$[2*X+1]=W[X]>>8}function uV($,J){var X=X$(),Q=X$(),Y=X$(),G=X$(),W=X$(),M=X$(),U=X$();if(v0($[2],wY),gV($[1],J),GQ(Y,$[1]),v$(G,Y,xV),_Q(Y,Y,$[2]),PQ(G,$[2],G),GQ(W,G),GQ(M,W),v$(U,M,W),v$(X,U,Y),v$(X,X,G),mV(X,X),v$(X,X,Y),v$(X,X,G),v$(X,X,G),v$($[0],X,G),GQ(Q,$[0]),v$(Q,Q,G),y1(Q,Y))v$($[0],$[0],kV);if(GQ(Q,$[0]),v$(Q,Q,G),y1(Q,Y))return-1;if(g1($[0])===J[31]>>7)_Q($[0],D8,$[0]);return v$($[3],$[0],$[1]),0}function gV($,J){var X;for(X=0;X<16;++X)$[X]=J[2*X]+(J[2*X+1]<<8);$[15]&=32767}function mV($,J){var X=X$(),Q;for(Q=0;Q<16;++Q)X[Q]=J[Q];for(Q=250;Q>=0;--Q)if(GQ(X,X),Q!==1)v$(X,X,J);for(Q=0;Q<16;++Q)$[Q]=X[Q]}function y1($,J){var X=new ZJ(32),Q=new ZJ(32);return PY(X,$),PY(Q,J),u1(X,0,Q,0)}function u1($,J,X,Q){return lV($,J,X,Q,32)}function lV($,J,X,Q,Y){var G,W=0;for(G=0;G<Y;++G)W|=$[J+G]^X[Q+G];return(1&W-1>>>8)-1}function g1($){var J=new ZJ(32);return PY(J,$),J[0]&1}function m1($,J,X){var Q,Y;v0($[0],D8),v0($[1],wY),v0($[2],wY),v0($[3],D8);for(Y=255;Y>=0;--Y)Q=X[Y/8|0]>>(Y&7)&1,f1($,J,Q),B8(J,$),B8($,$),f1($,J,Q)}function T8($,J){var X=[X$(),X$(),X$(),X$()];v0(X[0],v1),v0(X[1],k1),v0(X[2],wY),v$(X[3],v1,k1),m1($,X,J)}function v0($,J){var X;for(X=0;X<16;X++)$[X]=J[X]|0}function dV($,J){var X=X$(),Q;for(Q=0;Q<16;++Q)X[Q]=J[Q];for(Q=253;Q>=0;--Q)if(GQ(X,X),Q!==2&&Q!==4)v$(X,X,J);for(Q=0;Q<16;++Q)$[Q]=X[Q]}function L8($){var J,X,Q=1;for(J=0;J<16;++J)X=$[J]+Q+65535,Q=Math.floor(X/65536),$[J]=X-Q*65536;$[0]+=Q-1+37*(Q-1)}function l1($,J,X){var Q,Y=~(X-1);for(var G=0;G<16;++G)Q=Y&($[G]^J[G]),$[G]^=Q,J[G]^=Q}function X$($){var J,X=new Float64Array(16);if($)for(J=0;J<$.length;++J)X[J]=$[J];return X}function PQ($,J,X){for(var Q=0;Q<16;++Q)$[Q]=J[Q]+X[Q]}function _Q($,J,X){for(var Q=0;Q<16;++Q)$[Q]=J[Q]-X[Q]}function GQ($,J){v$($,J,J)}function v$($,J,X){var Q,Y,G=0,W=0,M=0,U=0,O=0,V=0,H=0,q=0,F=0,K=0,R=0,L=0,D=0,w=0,T=0,P=0,S=0,C=0,h=0,s=0,a=0,O$=0,j$=0,T$=0,G$=0,r=0,m=0,W$=0,l=0,H$=0,JJ=0,w$=X[0],D$=X[1],z$=X[2],$$=X[3],d$=X[4],h$=X[5],t$=X[6],QJ=X[7],o$=X[8],XJ=X[9],YJ=X[10],c$=X[11],x$=X[12],m$=X[13],a$=X[14],GJ=X[15];Q=J[0],G+=Q*w$,W+=Q*D$,M+=Q*z$,U+=Q*$$,O+=Q*d$,V+=Q*h$,H+=Q*t$,q+=Q*QJ,F+=Q*o$,K+=Q*XJ,R+=Q*YJ,L+=Q*c$,D+=Q*x$,w+=Q*m$,T+=Q*a$,P+=Q*GJ,Q=J[1],W+=Q*w$,M+=Q*D$,U+=Q*z$,O+=Q*$$,V+=Q*d$,H+=Q*h$,q+=Q*t$,F+=Q*QJ,K+=Q*o$,R+=Q*XJ,L+=Q*YJ,D+=Q*c$,w+=Q*x$,T+=Q*m$,P+=Q*a$,S+=Q*GJ,Q=J[2],M+=Q*w$,U+=Q*D$,O+=Q*z$,V+=Q*$$,H+=Q*d$,q+=Q*h$,F+=Q*t$,K+=Q*QJ,R+=Q*o$,L+=Q*XJ,D+=Q*YJ,w+=Q*c$,T+=Q*x$,P+=Q*m$,S+=Q*a$,C+=Q*GJ,Q=J[3],U+=Q*w$,O+=Q*D$,V+=Q*z$,H+=Q*$$,q+=Q*d$,F+=Q*h$,K+=Q*t$,R+=Q*QJ,L+=Q*o$,D+=Q*XJ,w+=Q*YJ,T+=Q*c$,P+=Q*x$,S+=Q*m$,C+=Q*a$,h+=Q*GJ,Q=J[4],O+=Q*w$,V+=Q*D$,H+=Q*z$,q+=Q*$$,F+=Q*d$,K+=Q*h$,R+=Q*t$,L+=Q*QJ,D+=Q*o$,w+=Q*XJ,T+=Q*YJ,P+=Q*c$,S+=Q*x$,C+=Q*m$,h+=Q*a$,s+=Q*GJ,Q=J[5],V+=Q*w$,H+=Q*D$,q+=Q*z$,F+=Q*$$,K+=Q*d$,R+=Q*h$,L+=Q*t$,D+=Q*QJ,w+=Q*o$,T+=Q*XJ,P+=Q*YJ,S+=Q*c$,C+=Q*x$,h+=Q*m$,s+=Q*a$,a+=Q*GJ,Q=J[6],H+=Q*w$,q+=Q*D$,F+=Q*z$,K+=Q*$$,R+=Q*d$,L+=Q*h$,D+=Q*t$,w+=Q*QJ,T+=Q*o$,P+=Q*XJ,S+=Q*YJ,C+=Q*c$,h+=Q*x$,s+=Q*m$,a+=Q*a$,O$+=Q*GJ,Q=J[7],q+=Q*w$,F+=Q*D$,K+=Q*z$,R+=Q*$$,L+=Q*d$,D+=Q*h$,w+=Q*t$,T+=Q*QJ,P+=Q*o$,S+=Q*XJ,C+=Q*YJ,h+=Q*c$,s+=Q*x$,a+=Q*m$,O$+=Q*a$,j$+=Q*GJ,Q=J[8],F+=Q*w$,K+=Q*D$,R+=Q*z$,L+=Q*$$,D+=Q*d$,w+=Q*h$,T+=Q*t$,P+=Q*QJ,S+=Q*o$,C+=Q*XJ,h+=Q*YJ,s+=Q*c$,a+=Q*x$,O$+=Q*m$,j$+=Q*a$,T$+=Q*GJ,Q=J[9],K+=Q*w$,R+=Q*D$,L+=Q*z$,D+=Q*$$,w+=Q*d$,T+=Q*h$,P+=Q*t$,S+=Q*QJ,C+=Q*o$,h+=Q*XJ,s+=Q*YJ,a+=Q*c$,O$+=Q*x$,j$+=Q*m$,T$+=Q*a$,G$+=Q*GJ,Q=J[10],R+=Q*w$,L+=Q*D$,D+=Q*z$,w+=Q*$$,T+=Q*d$,P+=Q*h$,S+=Q*t$,C+=Q*QJ,h+=Q*o$,s+=Q*XJ,a+=Q*YJ,O$+=Q*c$,j$+=Q*x$,T$+=Q*m$,G$+=Q*a$,r+=Q*GJ,Q=J[11],L+=Q*w$,D+=Q*D$,w+=Q*z$,T+=Q*$$,P+=Q*d$,S+=Q*h$,C+=Q*t$,h+=Q*QJ,s+=Q*o$,a+=Q*XJ,O$+=Q*YJ,j$+=Q*c$,T$+=Q*x$,G$+=Q*m$,r+=Q*a$,m+=Q*GJ,Q=J[12],D+=Q*w$,w+=Q*D$,T+=Q*z$,P+=Q*$$,S+=Q*d$,C+=Q*h$,h+=Q*t$,s+=Q*QJ,a+=Q*o$,O$+=Q*XJ,j$+=Q*YJ,T$+=Q*c$,G$+=Q*x$,r+=Q*m$,m+=Q*a$,W$+=Q*GJ,Q=J[13],w+=Q*w$,T+=Q*D$,P+=Q*z$,S+=Q*$$,C+=Q*d$,h+=Q*h$,s+=Q*t$,a+=Q*QJ,O$+=Q*o$,j$+=Q*XJ,T$+=Q*YJ,G$+=Q*c$,r+=Q*x$,m+=Q*m$,W$+=Q*a$,l+=Q*GJ,Q=J[14],T+=Q*w$,P+=Q*D$,S+=Q*z$,C+=Q*$$,h+=Q*d$,s+=Q*h$,a+=Q*t$,O$+=Q*QJ,j$+=Q*o$,T$+=Q*XJ,G$+=Q*YJ,r+=Q*c$,m+=Q*x$,W$+=Q*m$,l+=Q*a$,H$+=Q*GJ,Q=J[15],P+=Q*w$,S+=Q*D$,C+=Q*z$,h+=Q*$$,s+=Q*d$,a+=Q*h$,O$+=Q*t$,j$+=Q*QJ,T$+=Q*o$,G$+=Q*XJ,r+=Q*YJ,m+=Q*c$,W$+=Q*x$,l+=Q*m$,H$+=Q*a$,JJ+=Q*GJ,G+=38*S,W+=38*C,M+=38*h,U+=38*s,O+=38*a,V+=38*O$,H+=38*j$,q+=38*T$,F+=38*G$,K+=38*r,R+=38*m,L+=38*W$,D+=38*l,w+=38*H$,T+=38*JJ,Y=1,Q=G+Y+65535,Y=Math.floor(Q/65536),G=Q-Y*65536,Q=W+Y+65535,Y=Math.floor(Q/65536),W=Q-Y*65536,Q=M+Y+65535,Y=Math.floor(Q/65536),M=Q-Y*65536,Q=U+Y+65535,Y=Math.floor(Q/65536),U=Q-Y*65536,Q=O+Y+65535,Y=Math.floor(Q/65536),O=Q-Y*65536,Q=V+Y+65535,Y=Math.floor(Q/65536),V=Q-Y*65536,Q=H+Y+65535,Y=Math.floor(Q/65536),H=Q-Y*65536,Q=q+Y+65535,Y=Math.floor(Q/65536),q=Q-Y*65536,Q=F+Y+65535,Y=Math.floor(Q/65536),F=Q-Y*65536,Q=K+Y+65535,Y=Math.floor(Q/65536),K=Q-Y*65536,Q=R+Y+65535,Y=Math.floor(Q/65536),R=Q-Y*65536,Q=L+Y+65535,Y=Math.floor(Q/65536),L=Q-Y*65536,Q=D+Y+65535,Y=Math.floor(Q/65536),D=Q-Y*65536,Q=w+Y+65535,Y=Math.floor(Q/65536),w=Q-Y*65536,Q=T+Y+65535,Y=Math.floor(Q/65536),T=Q-Y*65536,Q=P+Y+65535,Y=Math.floor(Q/65536),P=Q-Y*65536,G+=Y-1+37*(Y-1),Y=1,Q=G+Y+65535,Y=Math.floor(Q/65536),G=Q-Y*65536,Q=W+Y+65535,Y=Math.floor(Q/65536),W=Q-Y*65536,Q=M+Y+65535,Y=Math.floor(Q/65536),M=Q-Y*65536,Q=U+Y+65535,Y=Math.floor(Q/65536),U=Q-Y*65536,Q=O+Y+65535,Y=Math.floor(Q/65536),O=Q-Y*65536,Q=V+Y+65535,Y=Math.floor(Q/65536),V=Q-Y*65536,Q=H+Y+65535,Y=Math.floor(Q/65536),H=Q-Y*65536,Q=q+Y+65535,Y=Math.floor(Q/65536),q=Q-Y*65536,Q=F+Y+65535,Y=Math.floor(Q/65536),F=Q-Y*65536,Q=K+Y+65535,Y=Math.floor(Q/65536),K=Q-Y*65536,Q=R+Y+65535,Y=Math.floor(Q/65536),R=Q-Y*65536,Q=L+Y+65535,Y=Math.floor(Q/65536),L=Q-Y*65536,Q=D+Y+65535,Y=Math.floor(Q/65536),D=Q-Y*65536,Q=w+Y+65535,Y=Math.floor(Q/65536),w=Q-Y*65536,Q=T+Y+65535,Y=Math.floor(Q/65536),T=Q-Y*65536,Q=P+Y+65535,Y=Math.floor(Q/65536),P=Q-Y*65536,G+=Y-1+37*(Y-1),$[0]=G,$[1]=W,$[2]=M,$[3]=U,$[4]=O,$[5]=V,$[6]=H,$[7]=q,$[8]=F,$[9]=K,$[10]=R,$[11]=L,$[12]=D,$[13]=w,$[14]=T,$[15]=P}});var o1=M$((PE,i1)=>{var SJ=K$();C$();PJ();FX();i1.exports=SJ.kem=SJ.kem||{};var c1=SJ.jsbn.BigInteger;SJ.kem.rsa={};SJ.kem.rsa.create=function($,J){J=J||{};var X=J.prng||SJ.random,Q={};return Q.encrypt=function(Y,G){var W=Math.ceil(Y.n.bitLength()/8),M;do M=new c1(SJ.util.bytesToHex(X.getBytesSync(W)),16).mod(Y.n);while(M.compareTo(c1.ONE)<=0);M=SJ.util.hexToBytes(M.toString(16));var U=W-M.length;if(U>0)M=SJ.util.fillString(String.fromCharCode(0),U)+M;var O=Y.encrypt(M,"NONE"),V=$.generate(M,G);return{encapsulation:O,key:V}},Q.decrypt=function(Y,G,W){var M=Y.decrypt(G,"NONE");return $.generate(M,W)},Q};SJ.kem.kdf1=function($,J){n1(this,$,0,J||$.digestLength)};SJ.kem.kdf2=function($,J){n1(this,$,1,J||$.digestLength)};function n1($,J,X,Q){$.generate=function(Y,G){var W=new SJ.util.ByteBuffer,M=Math.ceil(G/Q)+X,U=new SJ.util.ByteBuffer;for(var O=X;O<M;++O){U.putInt32(O),J.start(),J.update(Y+U.getBytes());var V=J.digest();W.putBytes(V.getBytes(Q))}return W.truncate(W.length()-G),W.getBytes()}}});var s1=M$((_E,a1)=>{var Z$=K$();C$();a1.exports=Z$.log=Z$.log||{};Z$.log.levels=["none","error","warning","info","debug","verbose","max"];var vY={},S8=[],jX=null;Z$.log.LEVEL_LOCKED=2;Z$.log.NO_LEVEL_CHECK=4;Z$.log.INTERPOLATE=8;for(yJ=0;yJ<Z$.log.levels.length;++yJ)_Y=Z$.log.levels[yJ],vY[_Y]={index:yJ,name:_Y.toUpperCase()};var _Y,yJ;Z$.log.logMessage=function($){var J=vY[$.level].index;for(var X=0;X<S8.length;++X){var Q=S8[X];if(Q.flags&Z$.log.NO_LEVEL_CHECK)Q.f($);else{var Y=vY[Q.level].index;if(J<=Y)Q.f(Q,$)}}};Z$.log.prepareStandard=function($){if(!("standard"in $))$.standard=vY[$.level].name+" ["+$.category+"] "+$.message};Z$.log.prepareFull=function($){if(!("full"in $)){var J=[$.message];J=J.concat([]),$.full=Z$.util.format.apply(this,J)}};Z$.log.prepareStandardFull=function($){if(!("standardFull"in $))Z$.log.prepareStandard($),$.standardFull=$.standard};xY=["error","warning","info","debug","verbose"];for(yJ=0;yJ<xY.length;++yJ)(function(J){Z$.log[J]=function(X,Q){var Y=Array.prototype.slice.call(arguments).slice(2),G={timestamp:new Date,level:J,category:X,message:Q,arguments:Y};Z$.log.logMessage(G)}})(xY[yJ]);var xY,yJ;Z$.log.makeLogger=function($){var J={flags:0,f:$};return Z$.log.setLevel(J,"none"),J};Z$.log.setLevel=function($,J){var X=!1;if($&&!($.flags&Z$.log.LEVEL_LOCKED))for(var Q=0;Q<Z$.log.levels.length;++Q){var Y=Z$.log.levels[Q];if(J==Y){$.level=J,X=!0;break}}return X};Z$.log.lock=function($,J){if(typeof J>"u"||J)$.flags|=Z$.log.LEVEL_LOCKED;else $.flags&=~Z$.log.LEVEL_LOCKED};Z$.log.addLogger=function($){S8.push($)};if(typeof console<"u"&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug)I8={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},vQ=function($,J){Z$.log.prepareStandard(J);var X=I8[J.level],Q=[J.standard];Q=Q.concat(J.arguments.slice()),X.apply(console,Q)},WQ=Z$.log.makeLogger(vQ);else vQ=function(J,X){Z$.log.prepareStandardFull(X),console.log(X.standardFull)},WQ=Z$.log.makeLogger(vQ);Z$.log.setLevel(WQ,"debug"),Z$.log.addLogger(WQ),jX=WQ}else console={log:function(){}};var WQ,I8,vQ;if(jX!==null&&typeof window<"u"&&window.location){if(xQ=new URL(window.location.href).searchParams,xQ.has("console.level"))Z$.log.setLevel(jX,xQ.get("console.level").slice(-1)[0]);if(xQ.has("console.lock")){if(C8=xQ.get("console.lock").slice(-1)[0],C8=="true")Z$.log.lock(jX)}}var xQ,C8;Z$.log.consoleLogger=jX});var t1=M$((xE,r1)=>{r1.exports=rJ();HY();TQ();m9();N8()});var JW=M$((vE,$W)=>{var d=K$();T0();gJ();zX();S0();t0();Q8();PJ();C$();TY();var B=d.asn1,AJ=$W.exports=d.pkcs7=d.pkcs7||{};AJ.messageFromPem=function($){var J=d.pem.decode($)[0];if(J.type!=="PKCS7"){var X=Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var Q=B.fromDer(J.body);return AJ.messageFromAsn1(Q)};AJ.messageToPem=function($,J){var X={type:"PKCS7",body:B.toDer($.toAsn1()).getBytes()};return d.pem.encode(X,{maxline:J})};AJ.messageFromAsn1=function($){var J={},X=[];if(!B.validate($,AJ.asn1.contentInfoValidator,J,X)){var Q=Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw Q.errors=X,Q}var Y=B.derToOid(J.contentType),G;switch(Y){case d.pki.oids.envelopedData:G=AJ.createEnvelopedData();break;case d.pki.oids.encryptedData:G=AJ.createEncryptedData();break;case d.pki.oids.signedData:G=AJ.createSignedData();break;default:throw Error("Cannot read PKCS#7 message. ContentType with OID "+Y+" is not (yet) supported.")}return G.fromAsn1(J.content.value[0]),G};AJ.createSignedData=function(){var $=null;return $={type:d.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(Q){if(P8($,Q,AJ.asn1.signedDataValidator),$.certificates=[],$.crls=[],$.digestAlgorithmIdentifiers=[],$.contentInfo=null,$.signerInfos=[],$.rawCapture.certificates){var Y=$.rawCapture.certificates.value;for(var G=0;G<Y.length;++G)$.certificates.push(d.pki.certificateFromAsn1(Y[G]))}},toAsn1:function(){if(!$.contentInfo)$.sign();var Q=[];for(var Y=0;Y<$.certificates.length;++Y)Q.push(d.pki.certificateToAsn1($.certificates[Y]));var G=[],W=B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,$.digestAlgorithmIdentifiers),$.contentInfo])]);if(Q.length>0)W.value[0].value.push(B.create(B.Class.CONTEXT_SPECIFIC,0,!0,Q));if(G.length>0)W.value[0].value.push(B.create(B.Class.CONTEXT_SPECIFIC,1,!0,G));return W.value[0].value.push(B.create(B.Class.UNIVERSAL,B.Type.SET,!0,$.signerInfos)),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),W])},addSigner:function(Q){var{issuer:Y,serialNumber:G}=Q;if(Q.certificate){var W=Q.certificate;if(typeof W==="string")W=d.pki.certificateFromPem(W);Y=W.issuer.attributes,G=W.serialNumber}var M=Q.key;if(!M)throw Error("Could not add PKCS#7 signer; no private key specified.");if(typeof M==="string")M=d.pki.privateKeyFromPem(M);var U=Q.digestAlgorithm||d.pki.oids.sha1;switch(U){case d.pki.oids.sha1:case d.pki.oids.sha256:case d.pki.oids.sha384:case d.pki.oids.sha512:case d.pki.oids.md5:break;default:throw Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+U)}var O=Q.authenticatedAttributes||[];if(O.length>0){var V=!1,H=!1;for(var q=0;q<O.length;++q){var F=O[q];if(!V&&F.type===d.pki.oids.contentType){if(V=!0,H)break;continue}if(!H&&F.type===d.pki.oids.messageDigest){if(H=!0,V)break;continue}}if(!V||!H)throw Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}$.signers.push({key:M,version:1,issuer:Y,serialNumber:G,digestAlgorithm:U,signatureAlgorithm:d.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:O,unauthenticatedAttributes:[]})},sign:function(Q){if(Q=Q||{},typeof $.content!=="object"||$.contentInfo===null){if($.contentInfo=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(d.pki.oids.data).getBytes())]),"content"in $){var Y;if($.content instanceof d.util.ByteBuffer)Y=$.content.bytes();else if(typeof $.content==="string")Y=d.util.encodeUtf8($.content);if(Q.detached)$.detachedContent=B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,Y);else $.contentInfo.value.push(B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,Y)]))}}if($.signers.length===0)return;var G=J();X(G)},verify:function(){throw Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(Q){if(typeof Q==="string")Q=d.pki.certificateFromPem(Q);$.certificates.push(Q)},addCertificateRevokationList:function(Q){throw Error("PKCS#7 CRL support not yet implemented.")}},$;function J(){var Q={};for(var Y=0;Y<$.signers.length;++Y){var G=$.signers[Y],W=G.digestAlgorithm;if(!(W in Q))Q[W]=d.md[d.pki.oids[W]].create();if(G.authenticatedAttributes.length===0)G.md=Q[W];else G.md=d.md[d.pki.oids[W]].create()}$.digestAlgorithmIdentifiers=[];for(var W in Q)$.digestAlgorithmIdentifiers.push(B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(W).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")]));return Q}function X(Q){var Y;if($.detachedContent)Y=$.detachedContent;else Y=$.contentInfo.value[1],Y=Y.value[0];if(!Y)throw Error("Could not sign PKCS#7 message; there is no content to sign.");var G=B.derToOid($.contentInfo.value[0].value),W=B.toDer(Y);W.getByte(),B.getBerValueLength(W),W=W.getBytes();for(var M in Q)Q[M].start().update(W);var U=new Date;for(var O=0;O<$.signers.length;++O){var V=$.signers[O];if(V.authenticatedAttributes.length===0){if(G!==d.pki.oids.data)throw Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{V.authenticatedAttributesAsn1=B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[]);var H=B.create(B.Class.UNIVERSAL,B.Type.SET,!0,[]);for(var q=0;q<V.authenticatedAttributes.length;++q){var F=V.authenticatedAttributes[q];if(F.type===d.pki.oids.messageDigest)F.value=Q[V.digestAlgorithm].digest();else if(F.type===d.pki.oids.signingTime){if(!F.value)F.value=U}H.value.push(w8(F)),V.authenticatedAttributesAsn1.value.push(w8(F))}W=B.toDer(H).getBytes(),V.md.start().update(W)}V.signature=V.key.sign(V.md,"RSASSA-PKCS1-V1_5")}$.signerInfos=aV($.signers)}};AJ.createEncryptedData=function(){var $=null;return $={type:d.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:d.pki.oids["aes256-CBC"]},fromAsn1:function(J){P8($,J,AJ.asn1.encryptedDataValidator)},decrypt:function(J){if(J!==void 0)$.encryptedContent.key=J;e1($)}},$};AJ.createEnvelopedData=function(){var $=null;return $={type:d.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:d.pki.oids["aes256-CBC"]},fromAsn1:function(J){var X=P8($,J,AJ.asn1.envelopedDataValidator);$.recipients=nV(X.recipientInfos.value)},toAsn1:function(){return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,iV($.recipients)),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,sV($.encryptedContent))])])])},findRecipient:function(J){var X=J.issuer.attributes;for(var Q=0;Q<$.recipients.length;++Q){var Y=$.recipients[Q],G=Y.issuer;if(Y.serialNumber!==J.serialNumber)continue;if(G.length!==X.length)continue;var W=!0;for(var M=0;M<X.length;++M)if(G[M].type!==X[M].type||G[M].value!==X[M].value){W=!1;break}if(W)return Y}return null},decrypt:function(J,X){if($.encryptedContent.key===void 0&&J!==void 0&&X!==void 0)switch(J.encryptedContent.algorithm){case d.pki.oids.rsaEncryption:case d.pki.oids.desCBC:var Q=X.decrypt(J.encryptedContent.content);$.encryptedContent.key=d.util.createBuffer(Q);break;default:throw Error("Unsupported asymmetric cipher, OID "+J.encryptedContent.algorithm)}e1($)},addRecipient:function(J){$.recipients.push({version:0,issuer:J.issuer.attributes,serialNumber:J.serialNumber,encryptedContent:{algorithm:d.pki.oids.rsaEncryption,key:J.publicKey}})},encrypt:function(J,X){if($.encryptedContent.content===void 0){X=X||$.encryptedContent.algorithm,J=J||$.encryptedContent.key;var Q,Y,G;switch(X){case d.pki.oids["aes128-CBC"]:Q=16,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["aes192-CBC"]:Q=24,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["aes256-CBC"]:Q=32,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["des-EDE3-CBC"]:Q=24,Y=8,G=d.des.createEncryptionCipher;break;default:throw Error("Unsupported symmetric cipher, OID "+X)}if(J===void 0)J=d.util.createBuffer(d.random.getBytes(Q));else if(J.length()!=Q)throw Error("Symmetric key has wrong length; got "+J.length()+" bytes, expected "+Q+".");$.encryptedContent.algorithm=X,$.encryptedContent.key=J,$.encryptedContent.parameter=d.util.createBuffer(d.random.getBytes(Y));var W=G(J);if(W.start($.encryptedContent.parameter.copy()),W.update($.content),!W.finish())throw Error("Symmetric encryption failed.");$.encryptedContent.content=W.output}for(var M=0;M<$.recipients.length;++M){var U=$.recipients[M];if(U.encryptedContent.content!==void 0)continue;switch(U.encryptedContent.algorithm){case d.pki.oids.rsaEncryption:U.encryptedContent.content=U.encryptedContent.key.encrypt($.encryptedContent.key.data);break;default:throw Error("Unsupported asymmetric cipher, OID "+U.encryptedContent.algorithm)}}}},$};function pV($){var J={},X=[];if(!B.validate($,AJ.asn1.recipientInfoValidator,J,X)){var Q=Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw Q.errors=X,Q}return{version:J.version.charCodeAt(0),issuer:d.pki.RDNAttributesAsArray(J.issuer),serialNumber:d.util.createBuffer(J.serial).toHex(),encryptedContent:{algorithm:B.derToOid(J.encAlgorithm),parameter:J.encParameter?J.encParameter.value:void 0,content:J.encKey}}}function cV($){return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[d.pki.distinguishedNameToAsn1({attributes:$.issuer}),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,d.util.hexToBytes($.serialNumber))]),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.encryptedContent.algorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")]),B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.encryptedContent.content)])}function nV($){var J=[];for(var X=0;X<$.length;++X)J.push(pV($[X]));return J}function iV($){var J=[];for(var X=0;X<$.length;++X)J.push(cV($[X]));return J}function oV($){var J=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[d.pki.distinguishedNameToAsn1({attributes:$.issuer}),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,d.util.hexToBytes($.serialNumber))]),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.digestAlgorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")])]);if($.authenticatedAttributesAsn1)J.value.push($.authenticatedAttributesAsn1);if(J.value.push(B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.signatureAlgorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")])),J.value.push(B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.signature)),$.unauthenticatedAttributes.length>0){var X=B.create(B.Class.CONTEXT_SPECIFIC,1,!0,[]);for(var Q=0;Q<$.unauthenticatedAttributes.length;++Q){var Y=$.unauthenticatedAttributes[Q];X.values.push(w8(Y))}J.value.push(X)}return J}function aV($){var J=[];for(var X=0;X<$.length;++X)J.push(oV($[X]));return J}function w8($){var J;if($.type===d.pki.oids.contentType)J=B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.value).getBytes());else if($.type===d.pki.oids.messageDigest)J=B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.value.bytes());else if($.type===d.pki.oids.signingTime){var X=new Date("1950-01-01T00:00:00Z"),Q=new Date("2050-01-01T00:00:00Z"),Y=$.value;if(typeof Y==="string"){var G=Date.parse(Y);if(!isNaN(G))Y=new Date(G);else if(Y.length===13)Y=B.utcTimeToDate(Y);else Y=B.generalizedTimeToDate(Y)}if(Y>=X&&Y<Q)J=B.create(B.Class.UNIVERSAL,B.Type.UTCTIME,!1,B.dateToUtcTime(Y));else J=B.create(B.Class.UNIVERSAL,B.Type.GENERALIZEDTIME,!1,B.dateToGeneralizedTime(Y))}return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,[J])])}function sV($){return[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(d.pki.oids.data).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.algorithm).getBytes()),!$.parameter?void 0:B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.parameter.getBytes())]),B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.content.getBytes())])]}function P8($,J,X){var Q={},Y=[];if(!B.validate(J,X,Q,Y)){var G=Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw G.errors=G,G}var W=B.derToOid(Q.contentType);if(W!==d.pki.oids.data)throw Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(Q.encryptedContent){var M="";if(d.util.isArray(Q.encryptedContent))for(var U=0;U<Q.encryptedContent.length;++U){if(Q.encryptedContent[U].type!==B.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");M+=Q.encryptedContent[U].value}else M=Q.encryptedContent;$.encryptedContent={algorithm:B.derToOid(Q.encAlgorithm),parameter:d.util.createBuffer(Q.encParameter.value),content:d.util.createBuffer(M)}}if(Q.content){var M="";if(d.util.isArray(Q.content))for(var U=0;U<Q.content.length;++U){if(Q.content[U].type!==B.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");M+=Q.content[U].value}else M=Q.content;$.content=d.util.createBuffer(M)}return $.version=Q.version.charCodeAt(0),$.rawCapture=Q,Q}function e1($){if($.encryptedContent.key===void 0)throw Error("Symmetric key not available.");if($.content===void 0){var J;switch($.encryptedContent.algorithm){case d.pki.oids["aes128-CBC"]:case d.pki.oids["aes192-CBC"]:case d.pki.oids["aes256-CBC"]:J=d.aes.createDecryptionCipher($.encryptedContent.key);break;case d.pki.oids.desCBC:case d.pki.oids["des-EDE3-CBC"]:J=d.des.createDecryptionCipher($.encryptedContent.key);break;default:throw Error("Unsupported symmetric cipher, OID "+$.encryptedContent.algorithm)}if(J.start($.encryptedContent.parameter),J.update($.encryptedContent.content),!J.finish())throw Error("Symmetric decryption failed.");$.content=J.output}}});var XW=M$((kE,QW)=>{var $J=K$();T0();DQ();HY();TQ();C$();var fY=QW.exports=$J.ssh=$J.ssh||{};fY.privateKeyToPutty=function($,J,X){X=X||"",J=J||"";var Q="ssh-rsa",Y=J===""?"none":"aes256-cbc",G="PuTTY-User-Key-File-2: "+Q+`\r
|
|
15
|
+
`+U+J.substr(W+1);G=Y-W-1,W=-1,++Y}else if(J[Y]===" "||J[Y]==="\t"||J[Y]===",")W=Y;return J}function XM($){return $.replace(/^\s+/,"")}});var AX=O$((UF,mG)=>{var i$=z$();EY();a9();w$();mG.exports=i$.des=i$.des||{};i$.des.startEncrypting=function($,J,X,Q){var Y=TY({key:$,output:X,decrypt:!1,mode:Q||(J===null?"ECB":"CBC")});return Y.start(J),Y};i$.des.createEncryptionCipher=function($,J){return TY({key:$,output:null,decrypt:!1,mode:J})};i$.des.startDecrypting=function($,J,X,Q){var Y=TY({key:$,output:X,decrypt:!0,mode:Q||(J===null?"ECB":"CBC")});return Y.start(J),Y};i$.des.createDecryptionCipher=function($,J){return TY({key:$,output:null,decrypt:!0,mode:J})};i$.des.Algorithm=function($,J){var X=this;X.name=$,X.mode=new J({blockSize:8,cipher:{encrypt:function(Q,Y){return gG(X._keys,Q,Y,!1)},decrypt:function(Q,Y){return gG(X._keys,Q,Y,!0)}}}),X._init=!1};i$.des.Algorithm.prototype.initialize=function($){if(this._init)return;var J=i$.util.createBuffer($.key);if(this.name.indexOf("3DES")===0){if(J.length()!==24)throw Error("Invalid Triple-DES key size: "+J.length()*8)}this._keys=qM(J),this._init=!0};J0("DES-ECB",i$.cipher.modes.ecb);J0("DES-CBC",i$.cipher.modes.cbc);J0("DES-CFB",i$.cipher.modes.cfb);J0("DES-OFB",i$.cipher.modes.ofb);J0("DES-CTR",i$.cipher.modes.ctr);J0("3DES-ECB",i$.cipher.modes.ecb);J0("3DES-CBC",i$.cipher.modes.cbc);J0("3DES-CFB",i$.cipher.modes.cfb);J0("3DES-OFB",i$.cipher.modes.ofb);J0("3DES-CTR",i$.cipher.modes.ctr);function J0($,J){var X=function(){return new i$.des.Algorithm($,J)};i$.cipher.registerAlgorithm($,X)}var YM=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],GM=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],WM=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],UM=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],MM=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],OM=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],VM=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],HM=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function qM($){var J=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],X=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],Q=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],Y=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],G=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],W=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],U=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],M=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],O=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],V=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],H=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],q=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],F=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],K=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],A=$.length()>8?3:1,L=[],R=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],I=0,T;for(var C=0;C<A;C++){var w=$.getInt32(),P=$.getInt32();T=(w>>>4^P)&252645135,P^=T,w^=T<<4,T=(P>>>-16^w)&65535,w^=T,P^=T<<-16,T=(w>>>2^P)&858993459,P^=T,w^=T<<2,T=(P>>>-16^w)&65535,w^=T,P^=T<<-16,T=(w>>>1^P)&1431655765,P^=T,w^=T<<1,T=(P>>>8^w)&16711935,w^=T,P^=T<<8,T=(w>>>1^P)&1431655765,P^=T,w^=T<<1,T=w<<8|P>>>20&240,w=P<<24|P<<8&16711680|P>>>8&65280|P>>>24&240,P=T;for(var l=0;l<R.length;++l){if(R[l])w=w<<2|w>>>26,P=P<<2|P>>>26;else w=w<<1|w>>>27,P=P<<1|P>>>27;w&=-15,P&=-15;var k=J[w>>>28]|X[w>>>24&15]|Q[w>>>20&15]|Y[w>>>16&15]|G[w>>>12&15]|W[w>>>8&15]|U[w>>>4&15],p=M[P>>>28]|O[P>>>24&15]|V[P>>>20&15]|H[P>>>16&15]|q[P>>>12&15]|F[P>>>8&15]|K[P>>>4&15];T=(p>>>16^k)&65535,L[I++]=k^T,L[I++]=p^T<<16}}return L}function gG($,J,X,Q){var Y=$.length===32?3:9,G;if(Y===3)G=Q?[30,-2,-2]:[0,32,2];else G=Q?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var W,U=J[0],M=J[1];W=(U>>>4^M)&252645135,M^=W,U^=W<<4,W=(U>>>16^M)&65535,M^=W,U^=W<<16,W=(M>>>2^U)&858993459,U^=W,M^=W<<2,W=(M>>>8^U)&16711935,U^=W,M^=W<<8,W=(U>>>1^M)&1431655765,M^=W,U^=W<<1,U=U<<1|U>>>31,M=M<<1|M>>>31;for(var O=0;O<Y;O+=3){var V=G[O+1],H=G[O+2];for(var q=G[O];q!=V;q+=H){var F=M^$[q],K=(M>>>4|M<<28)^$[q+1];W=U,U=M,M=W^(GM[F>>>24&63]|UM[F>>>16&63]|OM[F>>>8&63]|HM[F&63]|YM[K>>>24&63]|WM[K>>>16&63]|MM[K>>>8&63]|VM[K&63])}W=U,U=M,M=W}U=U>>>1|U<<31,M=M>>>1|M<<31,W=(U>>>1^M)&1431655765,M^=W,U^=W<<1,W=(M>>>8^U)&16711935,U^=W,M^=W<<8,W=(M>>>2^U)&858993459,U^=W,M^=W<<2,W=(U>>>16^M)&65535,M^=W,U^=W<<16,W=(U>>>4^M)&252645135,M^=W,U^=W<<4,X[0]=U,X[1]=M}function TY($){$=$||{};var J=($.mode||"CBC").toUpperCase(),X="DES-"+J,Q;if($.decrypt)Q=i$.cipher.createDecipher(X,$.key);else Q=i$.cipher.createCipher(X,$.key);var Y=Q.start;return Q.start=function(G,W){var U=null;if(W instanceof i$.util.ByteBuffer)U=W,W={};W=W||{},W.output=U,W.iv=G,Y.call(Q,W)},Q}});var SY=O$((MF,lG)=>{var AJ=z$();TQ();eJ();w$();var KM=AJ.pkcs5=AJ.pkcs5||{},N0;if(AJ.util.isNodejs&&!AJ.options.usePureJavaScript)N0=OX("crypto");lG.exports=AJ.pbkdf2=KM.pbkdf2=function($,J,X,Q,Y,G){if(typeof Y==="function")G=Y,Y=null;if(AJ.util.isNodejs&&!AJ.options.usePureJavaScript&&N0.pbkdf2&&(Y===null||typeof Y!=="object")&&(N0.pbkdf2Sync.length>4||(!Y||Y==="sha1"))){if(typeof Y!=="string")Y="sha1";if($=Buffer.from($,"binary"),J=Buffer.from(J,"binary"),!G){if(N0.pbkdf2Sync.length===4)return N0.pbkdf2Sync($,J,X,Q).toString("binary");return N0.pbkdf2Sync($,J,X,Q,Y).toString("binary")}if(N0.pbkdf2Sync.length===4)return N0.pbkdf2($,J,X,Q,function(T,C){if(T)return G(T);G(null,C.toString("binary"))});return N0.pbkdf2($,J,X,Q,Y,function(T,C){if(T)return G(T);G(null,C.toString("binary"))})}if(typeof Y>"u"||Y===null)Y="sha1";if(typeof Y==="string"){if(!(Y in AJ.md.algorithms))throw Error("Unknown hash algorithm: "+Y);Y=AJ.md[Y].create()}var W=Y.digestLength;if(Q>4294967295*W){var U=Error("Derived key is too long.");if(G)return G(U);throw U}var M=Math.ceil(Q/W),O=Q-(M-1)*W,V=AJ.hmac.create();V.start(Y,$);var H="",q,F,K;if(!G){for(var A=1;A<=M;++A){V.start(null,null),V.update(J),V.update(AJ.util.int32ToBytes(A)),q=K=V.digest().getBytes();for(var L=2;L<=X;++L)V.start(null,null),V.update(K),F=V.digest().getBytes(),q=AJ.util.xorBytes(q,F,W),K=F;H+=A<M?q:q.substr(0,O)}return H}var A=1,L;function R(){if(A>M)return G(null,H);V.start(null,null),V.update(J),V.update(AJ.util.int32ToBytes(A)),q=K=V.digest().getBytes(),L=2,I()}function I(){if(L<=X)return V.start(null,null),V.update(K),F=V.digest().getBytes(),q=AJ.util.xorBytes(q,F,W),K=F,++L,AJ.util.setImmediate(I);H+=A<M?q:q.substr(0,O),++A,R()}R()}});var Q8=O$((OF,iG)=>{var Q0=z$();eJ();w$();var dG=iG.exports=Q0.sha256=Q0.sha256||{};Q0.md.sha256=Q0.md.algorithms.sha256=dG;dG.create=function(){if(!cG)zM();var $=null,J=Q0.util.createBuffer(),X=Array(64),Q={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return Q.start=function(){Q.messageLength=0,Q.fullMessageLength=Q.messageLength64=[];var Y=Q.messageLengthSize/4;for(var G=0;G<Y;++G)Q.fullMessageLength.push(0);return J=Q0.util.createBuffer(),$={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},Q},Q.start(),Q.update=function(Y,G){if(G==="utf8")Y=Q0.util.encodeUtf8(Y);var W=Y.length;Q.messageLength+=W,W=[W/4294967296>>>0,W>>>0];for(var U=Q.fullMessageLength.length-1;U>=0;--U)Q.fullMessageLength[U]+=W[1],W[1]=W[0]+(Q.fullMessageLength[U]/4294967296>>>0),Q.fullMessageLength[U]=Q.fullMessageLength[U]>>>0,W[0]=W[1]/4294967296>>>0;if(J.putBytes(Y),pG($,X,J),J.read>2048||J.length()===0)J.compact();return Q},Q.digest=function(){var Y=Q0.util.createBuffer();Y.putBytes(J.bytes());var G=Q.fullMessageLength[Q.fullMessageLength.length-1]+Q.messageLengthSize,W=G&Q.blockLength-1;Y.putBytes(J8.substr(0,Q.blockLength-W));var U,M,O=Q.fullMessageLength[0]*8;for(var V=0;V<Q.fullMessageLength.length-1;++V)U=Q.fullMessageLength[V+1]*8,M=U/4294967296>>>0,O+=M,Y.putInt32(O>>>0),O=U>>>0;Y.putInt32(O);var H={h0:$.h0,h1:$.h1,h2:$.h2,h3:$.h3,h4:$.h4,h5:$.h5,h6:$.h6,h7:$.h7};pG(H,X,Y);var q=Q0.util.createBuffer();return q.putInt32(H.h0),q.putInt32(H.h1),q.putInt32(H.h2),q.putInt32(H.h3),q.putInt32(H.h4),q.putInt32(H.h5),q.putInt32(H.h6),q.putInt32(H.h7),q},Q};var J8=null,cG=!1,nG=null;function zM(){J8=String.fromCharCode(128),J8+=Q0.util.fillString(String.fromCharCode(0),64),nG=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],cG=!0}function pG($,J,X){var Q,Y,G,W,U,M,O,V,H,q,F,K,A,L,R,I=X.length();while(I>=64){for(O=0;O<16;++O)J[O]=X.getInt32();for(;O<64;++O)Q=J[O-2],Q=(Q>>>17|Q<<15)^(Q>>>19|Q<<13)^Q>>>10,Y=J[O-15],Y=(Y>>>7|Y<<25)^(Y>>>18|Y<<14)^Y>>>3,J[O]=Q+J[O-7]+Y+J[O-16]|0;V=$.h0,H=$.h1,q=$.h2,F=$.h3,K=$.h4,A=$.h5,L=$.h6,R=$.h7;for(O=0;O<64;++O)W=(K>>>6|K<<26)^(K>>>11|K<<21)^(K>>>25|K<<7),U=L^K&(A^L),G=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),M=V&H|q&(V^H),Q=R+W+U+nG[O]+J[O],Y=G+M,R=L,L=A,A=K,K=F+Q>>>0,F=q,q=H,H=V,V=Q+Y>>>0;$.h0=$.h0+V|0,$.h1=$.h1+H|0,$.h2=$.h2+q|0,$.h3=$.h3+F|0,$.h4=$.h4+K|0,$.h5=$.h5+A|0,$.h6=$.h6+L|0,$.h7=$.h7+R|0,I-=64}}});var X8=O$((VF,oG)=>{var X0=z$();w$();var IY=null;if(X0.util.isNodejs&&!X0.options.usePureJavaScript&&!process.versions["node-webkit"])IY=OX("crypto");var EM=oG.exports=X0.prng=X0.prng||{};EM.create=function($){var J={plugin:$,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},X=$.md,Q=Array(32);for(var Y=0;Y<32;++Y)Q[Y]=X.create();J.pools=Q,J.pool=0,J.generate=function(O,V){if(!V)return J.generateSync(O);var H=J.plugin.cipher,q=J.plugin.increment,F=J.plugin.formatKey,K=J.plugin.formatSeed,A=X0.util.createBuffer();J.key=null,L();function L(R){if(R)return V(R);if(A.length()>=O)return V(null,A.getBytes(O));if(J.generated>1048575)J.key=null;if(J.key===null)return X0.util.nextTick(function(){G(L)});var I=H(J.key,J.seed);J.generated+=I.length,A.putBytes(I),J.key=F(H(J.key,q(J.seed))),J.seed=K(H(J.key,J.seed)),X0.util.setImmediate(L)}},J.generateSync=function(O){var V=J.plugin.cipher,H=J.plugin.increment,q=J.plugin.formatKey,F=J.plugin.formatSeed;J.key=null;var K=X0.util.createBuffer();while(K.length()<O){if(J.generated>1048575)J.key=null;if(J.key===null)W();var A=V(J.key,J.seed);J.generated+=A.length,K.putBytes(A),J.key=q(V(J.key,H(J.seed))),J.seed=F(V(J.key,J.seed))}return K.getBytes(O)};function G(O){if(J.pools[0].messageLength>=32)return U(),O();var V=32-J.pools[0].messageLength<<5;J.seedFile(V,function(H,q){if(H)return O(H);J.collect(q),U(),O()})}function W(){if(J.pools[0].messageLength>=32)return U();var O=32-J.pools[0].messageLength<<5;J.collect(J.seedFileSync(O)),U()}function U(){J.reseeds=J.reseeds===4294967295?0:J.reseeds+1;var O=J.plugin.md.create();O.update(J.keyBytes);var V=1;for(var H=0;H<32;++H){if(J.reseeds%V===0)O.update(J.pools[H].digest().getBytes()),J.pools[H].start();V=V<<1}J.keyBytes=O.digest().getBytes(),O.start(),O.update(J.keyBytes);var q=O.digest().getBytes();J.key=J.plugin.formatKey(J.keyBytes),J.seed=J.plugin.formatSeed(q),J.generated=0}function M(O){var V=null,H=X0.util.globalScope,q=H.crypto||H.msCrypto;if(q&&q.getRandomValues)V=function(w){return q.getRandomValues(w)};var F=X0.util.createBuffer();if(V)while(F.length()<O){var K=Math.max(1,Math.min(O-F.length(),65536)/4),A=new Uint32Array(Math.floor(K));try{V(A);for(var L=0;L<A.length;++L)F.putInt32(A[L])}catch(w){if(!(typeof QuotaExceededError<"u"&&w instanceof QuotaExceededError))throw w}}if(F.length()<O){var R,I,T,C=Math.floor(Math.random()*65536);while(F.length()<O){I=16807*(C&65535),R=16807*(C>>16),I+=(R&32767)<<16,I+=R>>15,I=(I&2147483647)+(I>>31),C=I&4294967295;for(var L=0;L<3;++L)T=C>>>(L<<3),T^=Math.floor(Math.random()*256),F.putByte(T&255)}}return F.getBytes(O)}if(IY)J.seedFile=function(O,V){IY.randomBytes(O,function(H,q){if(H)return V(H);V(null,q.toString())})},J.seedFileSync=function(O){return IY.randomBytes(O).toString()};else J.seedFile=function(O,V){try{V(null,M(O))}catch(H){V(H)}},J.seedFileSync=M;return J.collect=function(O){var V=O.length;for(var H=0;H<V;++H)J.pools[J.pool].update(O.substr(H,1)),J.pool=J.pool===31?0:J.pool+1},J.collectInt=function(O,V){var H="";for(var q=0;q<V;q+=8)H+=String.fromCharCode(O>>q&255);J.collect(H)},J.registerWorker=function(O){if(O===self)J.seedFile=function(H,q){function F(K){var A=K.data;if(A.forge&&A.forge.prng)self.removeEventListener("message",F),q(A.forge.prng.err,A.forge.prng.bytes)}self.addEventListener("message",F),self.postMessage({forge:{prng:{needed:H}}})};else{var V=function(H){var q=H.data;if(q.forge&&q.forge.prng)J.seedFile(q.forge.prng.needed,function(F,K){O.postMessage({forge:{prng:{err:F,bytes:K}}})})};O.addEventListener("message",V)}},J}});var _J=O$((HF,Y8)=>{var VJ=z$();w0();Q8();X8();w$();(function(){if(VJ.random&&VJ.random.getBytes){Y8.exports=VJ.random;return}(function($){var J={},X=[,,,,],Q=VJ.util.createBuffer();J.formatKey=function(H){var q=VJ.util.createBuffer(H);return H=[,,,,],H[0]=q.getInt32(),H[1]=q.getInt32(),H[2]=q.getInt32(),H[3]=q.getInt32(),VJ.aes._expandKey(H,!1)},J.formatSeed=function(H){var q=VJ.util.createBuffer(H);return H=[,,,,],H[0]=q.getInt32(),H[1]=q.getInt32(),H[2]=q.getInt32(),H[3]=q.getInt32(),H},J.cipher=function(H,q){return VJ.aes._updateBlock(H,q,X,!1),Q.putInt32(X[0]),Q.putInt32(X[1]),Q.putInt32(X[2]),Q.putInt32(X[3]),Q.getBytes()},J.increment=function(H){return++H[3],H},J.md=VJ.md.sha256;function Y(){var H=VJ.prng.create(J);return H.getBytes=function(q,F){return H.generate(q,F)},H.getBytesSync=function(q){return H.generate(q)},H}var G=Y(),W=null,U=VJ.util.globalScope,M=U.crypto||U.msCrypto;if(M&&M.getRandomValues)W=function(H){return M.getRandomValues(H)};if(VJ.options.usePureJavaScript||!VJ.util.isNodejs&&!W){if(typeof window>"u"||window.document===void 0);if(G.collectInt(+new Date,32),typeof navigator<"u"){var O="";for(var V in navigator)try{if(typeof navigator[V]=="string")O+=navigator[V]}catch(H){}G.collect(O),O=null}if($)$().mousemove(function(H){G.collectInt(H.clientX,16),G.collectInt(H.clientY,16)}),$().keypress(function(H){G.collectInt(H.charCode,8)})}if(!VJ.random)VJ.random=G;else for(var V in G)VJ.random[V]=G[V];VJ.random.createInstance=Y,Y8.exports=VJ.random})(typeof jQuery<"u"?jQuery:null)})()});var W8=O$((qF,rG)=>{var ZJ=z$();w$();var G8=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],aG=[1,2,3,5],FM=function($,J){return $<<J&65535|($&65535)>>16-J},NM=function($,J){return($&65535)>>J|$<<16-J&65535};rG.exports=ZJ.rc2=ZJ.rc2||{};ZJ.rc2.expandKey=function($,J){if(typeof $==="string")$=ZJ.util.createBuffer($);J=J||128;var X=$,Q=$.length(),Y=J,G=Math.ceil(Y/8),W=255>>(Y&7),U;for(U=Q;U<128;U++)X.putByte(G8[X.at(U-1)+X.at(U-Q)&255]);X.setAt(128-G,G8[X.at(128-G)&W]);for(U=127-G;U>=0;U--)X.setAt(U,G8[X.at(U+1)^X.at(U+G)]);return X};var sG=function($,J,X){var Q=!1,Y=null,G=null,W=null,U,M,O,V,H=[];$=ZJ.rc2.expandKey($,J);for(O=0;O<64;O++)H.push($.getInt16Le());if(X)U=function(K){for(O=0;O<4;O++)K[O]+=H[V]+(K[(O+3)%4]&K[(O+2)%4])+(~K[(O+3)%4]&K[(O+1)%4]),K[O]=FM(K[O],aG[O]),V++},M=function(K){for(O=0;O<4;O++)K[O]+=H[K[(O+3)%4]&63]};else U=function(K){for(O=3;O>=0;O--)K[O]=NM(K[O],aG[O]),K[O]-=H[V]+(K[(O+3)%4]&K[(O+2)%4])+(~K[(O+3)%4]&K[(O+1)%4]),V--},M=function(K){for(O=3;O>=0;O--)K[O]-=H[K[(O+3)%4]&63]};var q=function(K){var A=[];for(O=0;O<4;O++){var L=Y.getInt16Le();if(W!==null)if(X)L^=W.getInt16Le();else W.putInt16Le(L);A.push(L&65535)}V=X?0:63;for(var R=0;R<K.length;R++)for(var I=0;I<K[R][0];I++)K[R][1](A);for(O=0;O<4;O++){if(W!==null)if(X)W.putInt16Le(A[O]);else A[O]^=W.getInt16Le();G.putInt16Le(A[O])}},F=null;return F={start:function(K,A){if(K){if(typeof K==="string")K=ZJ.util.createBuffer(K)}Q=!1,Y=ZJ.util.createBuffer(),G=A||new ZJ.util.createBuffer,W=K,F.output=G},update:function(K){if(!Q)Y.putBuffer(K);while(Y.length()>=8)q([[5,U],[1,M],[6,U],[1,M],[5,U]])},finish:function(K){var A=!0;if(X)if(K)A=K(8,Y,!X);else{var L=Y.length()===8?8:8-Y.length();Y.fillWithByte(L,L)}if(A)Q=!0,F.update();if(!X){if(A=Y.length()===0,A)if(K)A=K(8,G,!X);else{var R=G.length(),I=G.at(R-1);if(I>R)A=!1;else G.truncate(I)}}return A}},F};ZJ.rc2.startEncrypting=function($,J,X){var Q=ZJ.rc2.createEncryptionCipher($,128);return Q.start(J,X),Q};ZJ.rc2.createEncryptionCipher=function($,J){return sG($,J,!0)};ZJ.rc2.startDecrypting=function($,J,X){var Q=ZJ.rc2.createDecryptionCipher($,128);return Q.start(J,X),Q};ZJ.rc2.createDecryptionCipher=function($,J){return sG($,J,!1)}});var DX=O$((KF,G1)=>{var U8=z$();G1.exports=U8.jsbn=U8.jsbn||{};var L0,LM=244837814094590,tG=(LM&16777215)==15715070;function f($,J,X){if(this.data=[],$!=null)if(typeof $=="number")this.fromNumber($,J,X);else if(J==null&&typeof $!="string")this.fromString($,256);else this.fromString($,J)}U8.jsbn.BigInteger=f;function I$(){return new f(null)}function AM($,J,X,Q,Y,G){while(--G>=0){var W=J*this.data[$++]+X.data[Q]+Y;Y=Math.floor(W/67108864),X.data[Q++]=W&67108863}return Y}function RM($,J,X,Q,Y,G){var W=J&32767,U=J>>15;while(--G>=0){var M=this.data[$]&32767,O=this.data[$++]>>15,V=U*M+O*W;M=W*M+((V&32767)<<15)+X.data[Q]+(Y&1073741823),Y=(M>>>30)+(V>>>15)+U*O+(Y>>>30),X.data[Q++]=M&1073741823}return Y}function eG($,J,X,Q,Y,G){var W=J&16383,U=J>>14;while(--G>=0){var M=this.data[$]&16383,O=this.data[$++]>>14,V=U*M+O*W;M=W*M+((V&16383)<<14)+X.data[Q]+Y,Y=(M>>28)+(V>>14)+U*O,X.data[Q++]=M&268435455}return Y}if(typeof navigator>"u")f.prototype.am=eG,L0=28;else if(tG&&navigator.appName=="Microsoft Internet Explorer")f.prototype.am=RM,L0=30;else if(tG&&navigator.appName!="Netscape")f.prototype.am=AM,L0=26;else f.prototype.am=eG,L0=28;f.prototype.DB=L0;f.prototype.DM=(1<<L0)-1;f.prototype.DV=1<<L0;var M8=52;f.prototype.FV=Math.pow(2,M8);f.prototype.F1=M8-L0;f.prototype.F2=2*L0-M8;var DM="0123456789abcdefghijklmnopqrstuvwxyz",CY=[],IQ,xJ;IQ=48;for(xJ=0;xJ<=9;++xJ)CY[IQ++]=xJ;IQ=97;for(xJ=10;xJ<36;++xJ)CY[IQ++]=xJ;IQ=65;for(xJ=10;xJ<36;++xJ)CY[IQ++]=xJ;function $1($){return DM.charAt($)}function J1($,J){var X=CY[$.charCodeAt(J)];return X==null?-1:X}function ZM($){for(var J=this.t-1;J>=0;--J)$.data[J]=this.data[J];$.t=this.t,$.s=this.s}function BM($){if(this.t=1,this.s=$<0?-1:0,$>0)this.data[0]=$;else if($<-1)this.data[0]=$+this.DV;else this.t=0}function _0($){var J=I$();return J.fromInt($),J}function jM($,J){var X;if(J==16)X=4;else if(J==8)X=3;else if(J==256)X=8;else if(J==2)X=1;else if(J==32)X=5;else if(J==4)X=2;else{this.fromRadix($,J);return}this.t=0,this.s=0;var Q=$.length,Y=!1,G=0;while(--Q>=0){var W=X==8?$[Q]&255:J1($,Q);if(W<0){if($.charAt(Q)=="-")Y=!0;continue}if(Y=!1,G==0)this.data[this.t++]=W;else if(G+X>this.DB)this.data[this.t-1]|=(W&(1<<this.DB-G)-1)<<G,this.data[this.t++]=W>>this.DB-G;else this.data[this.t-1]|=W<<G;if(G+=X,G>=this.DB)G-=this.DB}if(X==8&&($[0]&128)!=0){if(this.s=-1,G>0)this.data[this.t-1]|=(1<<this.DB-G)-1<<G}if(this.clamp(),Y)f.ZERO.subTo(this,this)}function TM(){var $=this.s&this.DM;while(this.t>0&&this.data[this.t-1]==$)--this.t}function SM($){if(this.s<0)return"-"+this.negate().toString($);var J;if($==16)J=4;else if($==8)J=3;else if($==2)J=1;else if($==32)J=5;else if($==4)J=2;else return this.toRadix($);var X=(1<<J)-1,Q,Y=!1,G="",W=this.t,U=this.DB-W*this.DB%J;if(W-- >0){if(U<this.DB&&(Q=this.data[W]>>U)>0)Y=!0,G=$1(Q);while(W>=0){if(U<J)Q=(this.data[W]&(1<<U)-1)<<J-U,Q|=this.data[--W]>>(U+=this.DB-J);else if(Q=this.data[W]>>(U-=J)&X,U<=0)U+=this.DB,--W;if(Q>0)Y=!0;if(Y)G+=$1(Q)}}return Y?G:"0"}function IM(){var $=I$();return f.ZERO.subTo(this,$),$}function CM(){return this.s<0?this.negate():this}function wM($){var J=this.s-$.s;if(J!=0)return J;var X=this.t;if(J=X-$.t,J!=0)return this.s<0?-J:J;while(--X>=0)if((J=this.data[X]-$.data[X])!=0)return J;return 0}function wY($){var J=1,X;if((X=$>>>16)!=0)$=X,J+=16;if((X=$>>8)!=0)$=X,J+=8;if((X=$>>4)!=0)$=X,J+=4;if((X=$>>2)!=0)$=X,J+=2;if((X=$>>1)!=0)$=X,J+=1;return J}function PM(){if(this.t<=0)return 0;return this.DB*(this.t-1)+wY(this.data[this.t-1]^this.s&this.DM)}function _M($,J){var X;for(X=this.t-1;X>=0;--X)J.data[X+$]=this.data[X];for(X=$-1;X>=0;--X)J.data[X]=0;J.t=this.t+$,J.s=this.s}function xM($,J){for(var X=$;X<this.t;++X)J.data[X-$]=this.data[X];J.t=Math.max(this.t-$,0),J.s=this.s}function vM($,J){var X=$%this.DB,Q=this.DB-X,Y=(1<<Q)-1,G=Math.floor($/this.DB),W=this.s<<X&this.DM,U;for(U=this.t-1;U>=0;--U)J.data[U+G+1]=this.data[U]>>Q|W,W=(this.data[U]&Y)<<X;for(U=G-1;U>=0;--U)J.data[U]=0;J.data[G]=W,J.t=this.t+G+1,J.s=this.s,J.clamp()}function kM($,J){J.s=this.s;var X=Math.floor($/this.DB);if(X>=this.t){J.t=0;return}var Q=$%this.DB,Y=this.DB-Q,G=(1<<Q)-1;J.data[0]=this.data[X]>>Q;for(var W=X+1;W<this.t;++W)J.data[W-X-1]|=(this.data[W]&G)<<Y,J.data[W-X]=this.data[W]>>Q;if(Q>0)J.data[this.t-X-1]|=(this.s&G)<<Y;J.t=this.t-X,J.clamp()}function fM($,J){var X=0,Q=0,Y=Math.min($.t,this.t);while(X<Y)Q+=this.data[X]-$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;if($.t<this.t){Q-=$.s;while(X<this.t)Q+=this.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=this.s}else{Q+=this.s;while(X<$.t)Q-=$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q-=$.s}if(J.s=Q<0?-1:0,Q<-1)J.data[X++]=this.DV+Q;else if(Q>0)J.data[X++]=Q;J.t=X,J.clamp()}function yM($,J){var X=this.abs(),Q=$.abs(),Y=X.t;J.t=Y+Q.t;while(--Y>=0)J.data[Y]=0;for(Y=0;Y<Q.t;++Y)J.data[Y+X.t]=X.am(0,Q.data[Y],J,Y,0,X.t);if(J.s=0,J.clamp(),this.s!=$.s)f.ZERO.subTo(J,J)}function bM($){var J=this.abs(),X=$.t=2*J.t;while(--X>=0)$.data[X]=0;for(X=0;X<J.t-1;++X){var Q=J.am(X,J.data[X],$,2*X,0,1);if(($.data[X+J.t]+=J.am(X+1,2*J.data[X],$,2*X+1,Q,J.t-X-1))>=J.DV)$.data[X+J.t]-=J.DV,$.data[X+J.t+1]=1}if($.t>0)$.data[$.t-1]+=J.am(X,J.data[X],$,2*X,0,1);$.s=0,$.clamp()}function hM($,J,X){var Q=$.abs();if(Q.t<=0)return;var Y=this.abs();if(Y.t<Q.t){if(J!=null)J.fromInt(0);if(X!=null)this.copyTo(X);return}if(X==null)X=I$();var G=I$(),W=this.s,U=$.s,M=this.DB-wY(Q.data[Q.t-1]);if(M>0)Q.lShiftTo(M,G),Y.lShiftTo(M,X);else Q.copyTo(G),Y.copyTo(X);var O=G.t,V=G.data[O-1];if(V==0)return;var H=V*(1<<this.F1)+(O>1?G.data[O-2]>>this.F2:0),q=this.FV/H,F=(1<<this.F1)/H,K=1<<this.F2,A=X.t,L=A-O,R=J==null?I$():J;if(G.dlShiftTo(L,R),X.compareTo(R)>=0)X.data[X.t++]=1,X.subTo(R,X);f.ONE.dlShiftTo(O,R),R.subTo(G,G);while(G.t<O)G.data[G.t++]=0;while(--L>=0){var I=X.data[--A]==V?this.DM:Math.floor(X.data[A]*q+(X.data[A-1]+K)*F);if((X.data[A]+=G.am(0,I,X,L,0,O))<I){G.dlShiftTo(L,R),X.subTo(R,X);while(X.data[A]<--I)X.subTo(R,X)}}if(J!=null){if(X.drShiftTo(O,J),W!=U)f.ZERO.subTo(J,J)}if(X.t=O,X.clamp(),M>0)X.rShiftTo(M,X);if(W<0)f.ZERO.subTo(X,X)}function uM($){var J=I$();if(this.abs().divRemTo($,null,J),this.s<0&&J.compareTo(f.ZERO)>0)$.subTo(J,J);return J}function QQ($){this.m=$}function gM($){if($.s<0||$.compareTo(this.m)>=0)return $.mod(this.m);else return $}function mM($){return $}function lM($){$.divRemTo(this.m,null,$)}function pM($,J,X){$.multiplyTo(J,X),this.reduce(X)}function dM($,J){$.squareTo(J),this.reduce(J)}QQ.prototype.convert=gM;QQ.prototype.revert=mM;QQ.prototype.reduce=lM;QQ.prototype.mulTo=pM;QQ.prototype.sqrTo=dM;function cM(){if(this.t<1)return 0;var $=this.data[0];if(($&1)==0)return 0;var J=$&3;return J=J*(2-($&15)*J)&15,J=J*(2-($&255)*J)&255,J=J*(2-(($&65535)*J&65535))&65535,J=J*(2-$*J%this.DV)%this.DV,J>0?this.DV-J:-J}function XQ($){this.m=$,this.mp=$.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<$.DB-15)-1,this.mt2=2*$.t}function nM($){var J=I$();if($.abs().dlShiftTo(this.m.t,J),J.divRemTo(this.m,null,J),$.s<0&&J.compareTo(f.ZERO)>0)this.m.subTo(J,J);return J}function iM($){var J=I$();return $.copyTo(J),this.reduce(J),J}function oM($){while($.t<=this.mt2)$.data[$.t++]=0;for(var J=0;J<this.m.t;++J){var X=$.data[J]&32767,Q=X*this.mpl+((X*this.mph+($.data[J]>>15)*this.mpl&this.um)<<15)&$.DM;X=J+this.m.t,$.data[X]+=this.m.am(0,Q,$,J,0,this.m.t);while($.data[X]>=$.DV)$.data[X]-=$.DV,$.data[++X]++}if($.clamp(),$.drShiftTo(this.m.t,$),$.compareTo(this.m)>=0)$.subTo(this.m,$)}function aM($,J){$.squareTo(J),this.reduce(J)}function sM($,J,X){$.multiplyTo(J,X),this.reduce(X)}XQ.prototype.convert=nM;XQ.prototype.revert=iM;XQ.prototype.reduce=oM;XQ.prototype.mulTo=sM;XQ.prototype.sqrTo=aM;function rM(){return(this.t>0?this.data[0]&1:this.s)==0}function tM($,J){if($>4294967295||$<1)return f.ONE;var X=I$(),Q=I$(),Y=J.convert(this),G=wY($)-1;Y.copyTo(X);while(--G>=0)if(J.sqrTo(X,Q),($&1<<G)>0)J.mulTo(Q,Y,X);else{var W=X;X=Q,Q=W}return J.revert(X)}function eM($,J){var X;if($<256||J.isEven())X=new QQ(J);else X=new XQ(J);return this.exp($,X)}f.prototype.copyTo=ZM;f.prototype.fromInt=BM;f.prototype.fromString=jM;f.prototype.clamp=TM;f.prototype.dlShiftTo=_M;f.prototype.drShiftTo=xM;f.prototype.lShiftTo=vM;f.prototype.rShiftTo=kM;f.prototype.subTo=fM;f.prototype.multiplyTo=yM;f.prototype.squareTo=bM;f.prototype.divRemTo=hM;f.prototype.invDigit=cM;f.prototype.isEven=rM;f.prototype.exp=tM;f.prototype.toString=SM;f.prototype.negate=IM;f.prototype.abs=CM;f.prototype.compareTo=wM;f.prototype.bitLength=PM;f.prototype.mod=uM;f.prototype.modPowInt=eM;f.ZERO=_0(0);f.ONE=_0(1);function $O(){var $=I$();return this.copyTo($),$}function JO(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;else if(this.t==0)return-1}else if(this.t==1)return this.data[0];else if(this.t==0)return 0;return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function QO(){return this.t==0?this.s:this.data[0]<<24>>24}function XO(){return this.t==0?this.s:this.data[0]<<16>>16}function YO($){return Math.floor(Math.LN2*this.DB/Math.log($))}function GO(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this.data[0]<=0)return 0;else return 1}function WO($){if($==null)$=10;if(this.signum()==0||$<2||$>36)return"0";var J=this.chunkSize($),X=Math.pow($,J),Q=_0(X),Y=I$(),G=I$(),W="";this.divRemTo(Q,Y,G);while(Y.signum()>0)W=(X+G.intValue()).toString($).substr(1)+W,Y.divRemTo(Q,Y,G);return G.intValue().toString($)+W}function UO($,J){if(this.fromInt(0),J==null)J=10;var X=this.chunkSize(J),Q=Math.pow(J,X),Y=!1,G=0,W=0;for(var U=0;U<$.length;++U){var M=J1($,U);if(M<0){if($.charAt(U)=="-"&&this.signum()==0)Y=!0;continue}if(W=J*W+M,++G>=X)this.dMultiply(Q),this.dAddOffset(W,0),G=0,W=0}if(G>0)this.dMultiply(Math.pow(J,G)),this.dAddOffset(W,0);if(Y)f.ZERO.subTo(this,this)}function MO($,J,X){if(typeof J=="number")if($<2)this.fromInt(1);else{if(this.fromNumber($,X),!this.testBit($-1))this.bitwiseTo(f.ONE.shiftLeft($-1),O8,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(J))if(this.dAddOffset(2,0),this.bitLength()>$)this.subTo(f.ONE.shiftLeft($-1),this)}else{var Q=[],Y=$&7;if(Q.length=($>>3)+1,J.nextBytes(Q),Y>0)Q[0]&=(1<<Y)-1;else Q[0]=0;this.fromString(Q,256)}}function OO(){var $=this.t,J=[];J[0]=this.s;var X=this.DB-$*this.DB%8,Q,Y=0;if($-- >0){if(X<this.DB&&(Q=this.data[$]>>X)!=(this.s&this.DM)>>X)J[Y++]=Q|this.s<<this.DB-X;while($>=0){if(X<8)Q=(this.data[$]&(1<<X)-1)<<8-X,Q|=this.data[--$]>>(X+=this.DB-8);else if(Q=this.data[$]>>(X-=8)&255,X<=0)X+=this.DB,--$;if((Q&128)!=0)Q|=-256;if(Y==0&&(this.s&128)!=(Q&128))++Y;if(Y>0||Q!=this.s)J[Y++]=Q}}return J}function VO($){return this.compareTo($)==0}function HO($){return this.compareTo($)<0?this:$}function qO($){return this.compareTo($)>0?this:$}function KO($,J,X){var Q,Y,G=Math.min($.t,this.t);for(Q=0;Q<G;++Q)X.data[Q]=J(this.data[Q],$.data[Q]);if($.t<this.t){Y=$.s&this.DM;for(Q=G;Q<this.t;++Q)X.data[Q]=J(this.data[Q],Y);X.t=this.t}else{Y=this.s&this.DM;for(Q=G;Q<$.t;++Q)X.data[Q]=J(Y,$.data[Q]);X.t=$.t}X.s=J(this.s,$.s),X.clamp()}function zO($,J){return $&J}function EO($){var J=I$();return this.bitwiseTo($,zO,J),J}function O8($,J){return $|J}function FO($){var J=I$();return this.bitwiseTo($,O8,J),J}function Q1($,J){return $^J}function NO($){var J=I$();return this.bitwiseTo($,Q1,J),J}function X1($,J){return $&~J}function LO($){var J=I$();return this.bitwiseTo($,X1,J),J}function AO(){var $=I$();for(var J=0;J<this.t;++J)$.data[J]=this.DM&~this.data[J];return $.t=this.t,$.s=~this.s,$}function RO($){var J=I$();if($<0)this.rShiftTo(-$,J);else this.lShiftTo($,J);return J}function DO($){var J=I$();if($<0)this.lShiftTo(-$,J);else this.rShiftTo($,J);return J}function ZO($){if($==0)return-1;var J=0;if(($&65535)==0)$>>=16,J+=16;if(($&255)==0)$>>=8,J+=8;if(($&15)==0)$>>=4,J+=4;if(($&3)==0)$>>=2,J+=2;if(($&1)==0)++J;return J}function BO(){for(var $=0;$<this.t;++$)if(this.data[$]!=0)return $*this.DB+ZO(this.data[$]);if(this.s<0)return this.t*this.DB;return-1}function jO($){var J=0;while($!=0)$&=$-1,++J;return J}function TO(){var $=0,J=this.s&this.DM;for(var X=0;X<this.t;++X)$+=jO(this.data[X]^J);return $}function SO($){var J=Math.floor($/this.DB);if(J>=this.t)return this.s!=0;return(this.data[J]&1<<$%this.DB)!=0}function IO($,J){var X=f.ONE.shiftLeft($);return this.bitwiseTo(X,J,X),X}function CO($){return this.changeBit($,O8)}function wO($){return this.changeBit($,X1)}function PO($){return this.changeBit($,Q1)}function _O($,J){var X=0,Q=0,Y=Math.min($.t,this.t);while(X<Y)Q+=this.data[X]+$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;if($.t<this.t){Q+=$.s;while(X<this.t)Q+=this.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=this.s}else{Q+=this.s;while(X<$.t)Q+=$.data[X],J.data[X++]=Q&this.DM,Q>>=this.DB;Q+=$.s}if(J.s=Q<0?-1:0,Q>0)J.data[X++]=Q;else if(Q<-1)J.data[X++]=this.DV+Q;J.t=X,J.clamp()}function xO($){var J=I$();return this.addTo($,J),J}function vO($){var J=I$();return this.subTo($,J),J}function kO($){var J=I$();return this.multiplyTo($,J),J}function fO(){var $=I$();return this.squareTo($),$}function yO($){var J=I$();return this.divRemTo($,J,null),J}function bO($){var J=I$();return this.divRemTo($,null,J),J}function hO($){var J=I$(),X=I$();return this.divRemTo($,J,X),[J,X]}function uO($){this.data[this.t]=this.am(0,$-1,this,0,0,this.t),++this.t,this.clamp()}function gO($,J){if($==0)return;while(this.t<=J)this.data[this.t++]=0;this.data[J]+=$;while(this.data[J]>=this.DV){if(this.data[J]-=this.DV,++J>=this.t)this.data[this.t++]=0;++this.data[J]}}function RX(){}function Y1($){return $}function mO($,J,X){$.multiplyTo(J,X)}function lO($,J){$.squareTo(J)}RX.prototype.convert=Y1;RX.prototype.revert=Y1;RX.prototype.mulTo=mO;RX.prototype.sqrTo=lO;function pO($){return this.exp($,new RX)}function dO($,J,X){var Q=Math.min(this.t+$.t,J);X.s=0,X.t=Q;while(Q>0)X.data[--Q]=0;var Y;for(Y=X.t-this.t;Q<Y;++Q)X.data[Q+this.t]=this.am(0,$.data[Q],X,Q,0,this.t);for(Y=Math.min($.t,J);Q<Y;++Q)this.am(0,$.data[Q],X,Q,0,J-Q);X.clamp()}function cO($,J,X){--J;var Q=X.t=this.t+$.t-J;X.s=0;while(--Q>=0)X.data[Q]=0;for(Q=Math.max(J-this.t,0);Q<$.t;++Q)X.data[this.t+Q-J]=this.am(J-Q,$.data[Q],X,0,0,this.t+Q-J);X.clamp(),X.drShiftTo(1,X)}function CQ($){this.r2=I$(),this.q3=I$(),f.ONE.dlShiftTo(2*$.t,this.r2),this.mu=this.r2.divide($),this.m=$}function nO($){if($.s<0||$.t>2*this.m.t)return $.mod(this.m);else if($.compareTo(this.m)<0)return $;else{var J=I$();return $.copyTo(J),this.reduce(J),J}}function iO($){return $}function oO($){if($.drShiftTo(this.m.t-1,this.r2),$.t>this.m.t+1)$.t=this.m.t+1,$.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while($.compareTo(this.r2)<0)$.dAddOffset(1,this.m.t+1);$.subTo(this.r2,$);while($.compareTo(this.m)>=0)$.subTo(this.m,$)}function aO($,J){$.squareTo(J),this.reduce(J)}function sO($,J,X){$.multiplyTo(J,X),this.reduce(X)}CQ.prototype.convert=nO;CQ.prototype.revert=iO;CQ.prototype.reduce=oO;CQ.prototype.mulTo=sO;CQ.prototype.sqrTo=aO;function rO($,J){var X=$.bitLength(),Q,Y=_0(1),G;if(X<=0)return Y;else if(X<18)Q=1;else if(X<48)Q=3;else if(X<144)Q=4;else if(X<768)Q=5;else Q=6;if(X<8)G=new QQ(J);else if(J.isEven())G=new CQ(J);else G=new XQ(J);var W=[],U=3,M=Q-1,O=(1<<Q)-1;if(W[1]=G.convert(this),Q>1){var V=I$();G.sqrTo(W[1],V);while(U<=O)W[U]=I$(),G.mulTo(V,W[U-2],W[U]),U+=2}var H=$.t-1,q,F=!0,K=I$(),A;X=wY($.data[H])-1;while(H>=0){if(X>=M)q=$.data[H]>>X-M&O;else if(q=($.data[H]&(1<<X+1)-1)<<M-X,H>0)q|=$.data[H-1]>>this.DB+X-M;U=Q;while((q&1)==0)q>>=1,--U;if((X-=U)<0)X+=this.DB,--H;if(F)W[q].copyTo(Y),F=!1;else{while(U>1)G.sqrTo(Y,K),G.sqrTo(K,Y),U-=2;if(U>0)G.sqrTo(Y,K);else A=Y,Y=K,K=A;G.mulTo(K,W[q],Y)}while(H>=0&&($.data[H]&1<<X)==0)if(G.sqrTo(Y,K),A=Y,Y=K,K=A,--X<0)X=this.DB-1,--H}return G.revert(Y)}function tO($){var J=this.s<0?this.negate():this.clone(),X=$.s<0?$.negate():$.clone();if(J.compareTo(X)<0){var Q=J;J=X,X=Q}var Y=J.getLowestSetBit(),G=X.getLowestSetBit();if(G<0)return J;if(Y<G)G=Y;if(G>0)J.rShiftTo(G,J),X.rShiftTo(G,X);while(J.signum()>0){if((Y=J.getLowestSetBit())>0)J.rShiftTo(Y,J);if((Y=X.getLowestSetBit())>0)X.rShiftTo(Y,X);if(J.compareTo(X)>=0)J.subTo(X,J),J.rShiftTo(1,J);else X.subTo(J,X),X.rShiftTo(1,X)}if(G>0)X.lShiftTo(G,X);return X}function eO($){if($<=0)return 0;var J=this.DV%$,X=this.s<0?$-1:0;if(this.t>0)if(J==0)X=this.data[0]%$;else for(var Q=this.t-1;Q>=0;--Q)X=(J*X+this.data[Q])%$;return X}function $V($){if(this.signum()==0)return f.ZERO;var J=$.isEven();if(this.isEven()&&J||$.signum()==0)return f.ZERO;var X=$.clone(),Q=this.clone(),Y=_0(1),G=_0(0),W=_0(0),U=_0(1);while(X.signum()!=0){while(X.isEven()){if(X.rShiftTo(1,X),J){if(!Y.isEven()||!G.isEven())Y.addTo(this,Y),G.subTo($,G);Y.rShiftTo(1,Y)}else if(!G.isEven())G.subTo($,G);G.rShiftTo(1,G)}while(Q.isEven()){if(Q.rShiftTo(1,Q),J){if(!W.isEven()||!U.isEven())W.addTo(this,W),U.subTo($,U);W.rShiftTo(1,W)}else if(!U.isEven())U.subTo($,U);U.rShiftTo(1,U)}if(X.compareTo(Q)>=0){if(X.subTo(Q,X),J)Y.subTo(W,Y);G.subTo(U,G)}else{if(Q.subTo(X,Q),J)W.subTo(Y,W);U.subTo(G,U)}}if(Q.compareTo(f.ONE)!=0)return f.ZERO;if(U.compareTo($)>=0)return U.subtract($);if(U.signum()<0)U.addTo($,U);else return U;if(U.signum()<0)return U.add($);else return U}var lJ=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],JV=67108864/lJ[lJ.length-1];function QV($){var J,X=this.abs();if(X.t==1&&X.data[0]<=lJ[lJ.length-1]){for(J=0;J<lJ.length;++J)if(X.data[0]==lJ[J])return!0;return!1}if(X.isEven())return!1;J=1;while(J<lJ.length){var Q=lJ[J],Y=J+1;while(Y<lJ.length&&Q<JV)Q*=lJ[Y++];Q=X.modInt(Q);while(J<Y)if(Q%lJ[J++]==0)return!1}return X.millerRabin($)}function XV($){var J=this.subtract(f.ONE),X=J.getLowestSetBit();if(X<=0)return!1;var Q=J.shiftRight(X),Y=YV(),G;for(var W=0;W<$;++W){do G=new f(this.bitLength(),Y);while(G.compareTo(f.ONE)<=0||G.compareTo(J)>=0);var U=G.modPow(Q,this);if(U.compareTo(f.ONE)!=0&&U.compareTo(J)!=0){var M=1;while(M++<X&&U.compareTo(J)!=0)if(U=U.modPowInt(2,this),U.compareTo(f.ONE)==0)return!1;if(U.compareTo(J)!=0)return!1}}return!0}function YV(){return{nextBytes:function($){for(var J=0;J<$.length;++J)$[J]=Math.floor(Math.random()*256)}}}f.prototype.chunkSize=YO;f.prototype.toRadix=WO;f.prototype.fromRadix=UO;f.prototype.fromNumber=MO;f.prototype.bitwiseTo=KO;f.prototype.changeBit=IO;f.prototype.addTo=_O;f.prototype.dMultiply=uO;f.prototype.dAddOffset=gO;f.prototype.multiplyLowerTo=dO;f.prototype.multiplyUpperTo=cO;f.prototype.modInt=eO;f.prototype.millerRabin=XV;f.prototype.clone=$O;f.prototype.intValue=JO;f.prototype.byteValue=QO;f.prototype.shortValue=XO;f.prototype.signum=GO;f.prototype.toByteArray=OO;f.prototype.equals=VO;f.prototype.min=HO;f.prototype.max=qO;f.prototype.and=EO;f.prototype.or=FO;f.prototype.xor=NO;f.prototype.andNot=LO;f.prototype.not=AO;f.prototype.shiftLeft=RO;f.prototype.shiftRight=DO;f.prototype.getLowestSetBit=BO;f.prototype.bitCount=TO;f.prototype.testBit=SO;f.prototype.setBit=CO;f.prototype.clearBit=wO;f.prototype.flipBit=PO;f.prototype.add=xO;f.prototype.subtract=vO;f.prototype.multiply=kO;f.prototype.divide=yO;f.prototype.remainder=bO;f.prototype.divideAndRemainder=hO;f.prototype.modPow=rO;f.prototype.modInverse=$V;f.prototype.pow=pO;f.prototype.gcd=tO;f.prototype.isProbablePrime=QV;f.prototype.square=fO});var wQ=O$((zF,O1)=>{var Y0=z$();eJ();w$();var U1=O1.exports=Y0.sha1=Y0.sha1||{};Y0.md.sha1=Y0.md.algorithms.sha1=U1;U1.create=function(){if(!M1)GV();var $=null,J=Y0.util.createBuffer(),X=Array(80),Q={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return Q.start=function(){Q.messageLength=0,Q.fullMessageLength=Q.messageLength64=[];var Y=Q.messageLengthSize/4;for(var G=0;G<Y;++G)Q.fullMessageLength.push(0);return J=Y0.util.createBuffer(),$={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},Q},Q.start(),Q.update=function(Y,G){if(G==="utf8")Y=Y0.util.encodeUtf8(Y);var W=Y.length;Q.messageLength+=W,W=[W/4294967296>>>0,W>>>0];for(var U=Q.fullMessageLength.length-1;U>=0;--U)Q.fullMessageLength[U]+=W[1],W[1]=W[0]+(Q.fullMessageLength[U]/4294967296>>>0),Q.fullMessageLength[U]=Q.fullMessageLength[U]>>>0,W[0]=W[1]/4294967296>>>0;if(J.putBytes(Y),W1($,X,J),J.read>2048||J.length()===0)J.compact();return Q},Q.digest=function(){var Y=Y0.util.createBuffer();Y.putBytes(J.bytes());var G=Q.fullMessageLength[Q.fullMessageLength.length-1]+Q.messageLengthSize,W=G&Q.blockLength-1;Y.putBytes(V8.substr(0,Q.blockLength-W));var U,M,O=Q.fullMessageLength[0]*8;for(var V=0;V<Q.fullMessageLength.length-1;++V)U=Q.fullMessageLength[V+1]*8,M=U/4294967296>>>0,O+=M,Y.putInt32(O>>>0),O=U>>>0;Y.putInt32(O);var H={h0:$.h0,h1:$.h1,h2:$.h2,h3:$.h3,h4:$.h4};W1(H,X,Y);var q=Y0.util.createBuffer();return q.putInt32(H.h0),q.putInt32(H.h1),q.putInt32(H.h2),q.putInt32(H.h3),q.putInt32(H.h4),q},Q};var V8=null,M1=!1;function GV(){V8=String.fromCharCode(128),V8+=Y0.util.fillString(String.fromCharCode(0),64),M1=!0}function W1($,J,X){var Q,Y,G,W,U,M,O,V,H=X.length();while(H>=64){Y=$.h0,G=$.h1,W=$.h2,U=$.h3,M=$.h4;for(V=0;V<16;++V)Q=X.getInt32(),J[V]=Q,O=U^G&(W^U),Q=(Y<<5|Y>>>27)+O+M+1518500249+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<20;++V)Q=J[V-3]^J[V-8]^J[V-14]^J[V-16],Q=Q<<1|Q>>>31,J[V]=Q,O=U^G&(W^U),Q=(Y<<5|Y>>>27)+O+M+1518500249+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<32;++V)Q=J[V-3]^J[V-8]^J[V-14]^J[V-16],Q=Q<<1|Q>>>31,J[V]=Q,O=G^W^U,Q=(Y<<5|Y>>>27)+O+M+1859775393+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<40;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G^W^U,Q=(Y<<5|Y>>>27)+O+M+1859775393+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<60;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G&W|U&(G^W),Q=(Y<<5|Y>>>27)+O+M+2400959708+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;for(;V<80;++V)Q=J[V-6]^J[V-16]^J[V-28]^J[V-32],Q=Q<<2|Q>>>30,J[V]=Q,O=G^W^U,Q=(Y<<5|Y>>>27)+O+M+3395469782+Q,M=U,U=W,W=(G<<30|G>>>2)>>>0,G=Y,Y=Q;$.h0=$.h0+Y|0,$.h1=$.h1+G|0,$.h2=$.h2+W|0,$.h3=$.h3+U|0,$.h4=$.h4+M|0,H-=64}}});var H8=O$((EF,H1)=>{var G0=z$();w$();_J();wQ();var V1=H1.exports=G0.pkcs1=G0.pkcs1||{};V1.encode_rsa_oaep=function($,J,X){var Q,Y,G,W;if(typeof X==="string")Q=X,Y=arguments[3]||void 0,G=arguments[4]||void 0;else if(X){if(Q=X.label||void 0,Y=X.seed||void 0,G=X.md||void 0,X.mgf1&&X.mgf1.md)W=X.mgf1.md}if(!G)G=G0.md.sha1.create();else G.start();if(!W)W=G;var U=Math.ceil($.n.bitLength()/8),M=U-2*G.digestLength-2;if(J.length>M){var O=Error("RSAES-OAEP input message length is too long.");throw O.length=J.length,O.maxLength=M,O}if(!Q)Q="";G.update(Q,"raw");var V=G.digest(),H="",q=M-J.length;for(var F=0;F<q;F++)H+="\x00";var K=V.getBytes()+H+"\x01"+J;if(!Y)Y=G0.random.getBytes(G.digestLength);else if(Y.length!==G.digestLength){var O=Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw O.seedLength=Y.length,O.digestLength=G.digestLength,O}var A=PY(Y,U-G.digestLength-1,W),L=G0.util.xorBytes(K,A,K.length),R=PY(L,G.digestLength,W),I=G0.util.xorBytes(Y,R,Y.length);return"\x00"+I+L};V1.decode_rsa_oaep=function($,J,X){var Q,Y,G;if(typeof X==="string")Q=X,Y=arguments[3]||void 0;else if(X){if(Q=X.label||void 0,Y=X.md||void 0,X.mgf1&&X.mgf1.md)G=X.mgf1.md}var W=Math.ceil($.n.bitLength()/8);if(J.length!==W){var L=Error("RSAES-OAEP encoded message length is invalid.");throw L.length=J.length,L.expectedLength=W,L}if(Y===void 0)Y=G0.md.sha1.create();else Y.start();if(!G)G=Y;if(W<2*Y.digestLength+2)throw Error("RSAES-OAEP key is too short for the hash function.");if(!Q)Q="";Y.update(Q,"raw");var U=Y.digest().getBytes(),M=J.charAt(0),O=J.substring(1,Y.digestLength+1),V=J.substring(1+Y.digestLength),H=PY(V,Y.digestLength,G),q=G0.util.xorBytes(O,H,O.length),F=PY(q,W-Y.digestLength-1,G),K=G0.util.xorBytes(V,F,V.length),A=K.substring(0,Y.digestLength),L=M!=="\x00";for(var R=0;R<Y.digestLength;++R)L|=U.charAt(R)!==A.charAt(R);var I=1,T=Y.digestLength;for(var C=Y.digestLength;C<K.length;C++){var w=K.charCodeAt(C),P=w&1^1,l=I?65534:0;L|=w&l,I=I&P,T+=I}if(L||K.charCodeAt(T)!==1)throw Error("Invalid RSAES-OAEP padding.");return K.substring(T+1)};function PY($,J,X){if(!X)X=G0.md.sha1.create();var Q="",Y=Math.ceil(J/X.digestLength);for(var G=0;G<Y;++G){var W=String.fromCharCode(G>>24&255,G>>16&255,G>>8&255,G&255);X.start(),X.update($+W),Q+=X.digest().getBytes()}return Q.substring(0,J)}});var K8=O$((FF,q8)=>{var x0=z$();w$();DX();_J();(function(){if(x0.prime){q8.exports=x0.prime;return}var $=q8.exports=x0.prime=x0.prime||{},J=x0.jsbn.BigInteger,X=[6,4,2,4,2,4,6,2],Q=new J(null);Q.fromInt(30);var Y=function(H,q){return H|q};$.generateProbablePrime=function(H,q,F){if(typeof q==="function")F=q,q={};q=q||{};var K=q.algorithm||"PRIMEINC";if(typeof K==="string")K={name:K};K.options=K.options||{};var A=q.prng||x0.random,L={nextBytes:function(R){var I=A.getBytesSync(R.length);for(var T=0;T<R.length;++T)R[T]=I.charCodeAt(T)}};if(K.name==="PRIMEINC")return G(H,L,K.options,F);throw Error("Invalid prime generation algorithm: "+K.name)};function G(H,q,F,K){if("workers"in F)return M(H,q,F,K);return W(H,q,F,K)}function W(H,q,F,K){var A=O(H,q),L=0,R=V(A.bitLength());if("millerRabinTests"in F)R=F.millerRabinTests;var I=10;if("maxBlockTime"in F)I=F.maxBlockTime;U(A,H,q,L,R,I,K)}function U(H,q,F,K,A,L,R){var I=+new Date;do{if(H.bitLength()>q)H=O(q,F);if(H.isProbablePrime(A))return R(null,H);H.dAddOffset(X[K++%8],0)}while(L<0||+new Date-I<L);x0.util.setImmediate(function(){U(H,q,F,K,A,L,R)})}function M(H,q,F,K){if(typeof Worker>"u")return W(H,q,F,K);var A=O(H,q),L=F.workers,R=F.workLoad||100,I=R*30/8,T=F.workerScript||"forge/prime.worker.js";if(L===-1)return x0.util.estimateCores(function(w,P){if(w)P=2;L=P-1,C()});C();function C(){L=Math.max(1,L);var w=[];for(var P=0;P<L;++P)w[P]=new Worker(T);var l=L;for(var P=0;P<L;++P)w[P].addEventListener("message",p);var k=!1;function p($$){if(k)return;--l;var N$=$$.data;if(N$.found){for(var M$=0;M$<w.length;++M$)w[M$].terminate();return k=!0,K(null,new J(N$.prime,16))}if(A.bitLength()>H)A=O(H,q);var b$=A.toString(16);$$.target.postMessage({hex:b$,workLoad:R}),A.dAddOffset(I,0)}}}function O(H,q){var F=new J(H,q),K=H-1;if(!F.testBit(K))F.bitwiseTo(J.ONE.shiftLeft(K),Y,F);return F.dAddOffset(31-F.mod(Q).byteValue(),0),F}function V(H){if(H<=100)return 27;if(H<=150)return 18;if(H<=200)return 15;if(H<=250)return 12;if(H<=300)return 9;if(H<=350)return 8;if(H<=400)return 7;if(H<=500)return 6;if(H<=600)return 5;if(H<=800)return 4;if(H<=1250)return 3;return 2}})()});var ZX=O$((NF,L1)=>{var Q$=z$();mJ();DX();P0();H8();K8();_J();w$();if(typeof T$>"u")T$=Q$.jsbn.BigInteger;var T$,z8=Q$.util.isNodejs?OX("crypto"):null,S=Q$.asn1,vJ=Q$.util;Q$.pki=Q$.pki||{};L1.exports=Q$.pki.rsa=Q$.rsa=Q$.rsa||{};var V$=Q$.pki,WV=[6,4,2,4,2,4,6,2],UV={name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},MV={name:"RSAPrivateKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},OV={name:"RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},VV=Q$.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},HV={name:"DigestInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:S.Class.UNIVERSAL,type:S.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},qV=function($){var J;if($.algorithm in V$.oids)J=V$.oids[$.algorithm];else{var X=Error("Unknown message digest algorithm.");throw X.algorithm=$.algorithm,X}var Q=S.oidToDer(J).getBytes(),Y=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]),G=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]);G.value.push(S.create(S.Class.UNIVERSAL,S.Type.OID,!1,Q)),G.value.push(S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,""));var W=S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,$.digest().getBytes());return Y.value.push(G),Y.value.push(W),S.toDer(Y).getBytes()},F1=function($,J,X){if(X)return $.modPow(J.e,J.n);if(!J.p||!J.q)return $.modPow(J.d,J.n);if(!J.dP)J.dP=J.d.mod(J.p.subtract(T$.ONE));if(!J.dQ)J.dQ=J.d.mod(J.q.subtract(T$.ONE));if(!J.qInv)J.qInv=J.q.modInverse(J.p);var Q;do Q=new T$(Q$.util.bytesToHex(Q$.random.getBytes(J.n.bitLength()/8)),16);while(Q.compareTo(J.n)>=0||!Q.gcd(J.n).equals(T$.ONE));$=$.multiply(Q.modPow(J.e,J.n)).mod(J.n);var Y=$.mod(J.p).modPow(J.dP,J.p),G=$.mod(J.q).modPow(J.dQ,J.q);while(Y.compareTo(G)<0)Y=Y.add(J.p);var W=Y.subtract(G).multiply(J.qInv).mod(J.p).multiply(J.q).add(G);return W=W.multiply(Q.modInverse(J.n)).mod(J.n),W};V$.rsa.encrypt=function($,J,X){var Q=X,Y,G=Math.ceil(J.n.bitLength()/8);if(X!==!1&&X!==!0)Q=X===2,Y=N1($,J,X);else Y=Q$.util.createBuffer(),Y.putBytes($);var W=new T$(Y.toHex(),16),U=F1(W,J,Q),M=U.toString(16),O=Q$.util.createBuffer(),V=G-Math.ceil(M.length/2);while(V>0)O.putByte(0),--V;return O.putBytes(Q$.util.hexToBytes(M)),O.getBytes()};V$.rsa.decrypt=function($,J,X,Q){var Y=Math.ceil(J.n.bitLength()/8);if($.length!==Y){var G=Error("Encrypted message length is invalid.");throw G.length=$.length,G.expected=Y,G}var W=new T$(Q$.util.createBuffer($).toHex(),16);if(W.compareTo(J.n)>=0)throw Error("Encrypted message is invalid.");var U=F1(W,J,X),M=U.toString(16),O=Q$.util.createBuffer(),V=Y-Math.ceil(M.length/2);while(V>0)O.putByte(0),--V;if(O.putBytes(Q$.util.hexToBytes(M)),Q!==!1)return _Y(O.getBytes(),J,X);return O.getBytes()};V$.rsa.createKeyPairGenerationState=function($,J,X){if(typeof $==="string")$=parseInt($,10);$=$||2048,X=X||{};var Q=X.prng||Q$.random,Y={nextBytes:function(U){var M=Q.getBytesSync(U.length);for(var O=0;O<U.length;++O)U[O]=M.charCodeAt(O)}},G=X.algorithm||"PRIMEINC",W;if(G==="PRIMEINC")W={algorithm:G,state:0,bits:$,rng:Y,eInt:J||65537,e:new T$(null),p:null,q:null,qBits:$>>1,pBits:$-($>>1),pqState:0,num:null,keys:null},W.e.fromInt(W.eInt);else throw Error("Invalid key generation algorithm: "+G);return W};V$.rsa.stepKeyPairGenerationState=function($,J){if(!("algorithm"in $))$.algorithm="PRIMEINC";var X=new T$(null);X.fromInt(30);var Q=0,Y=function(H,q){return H|q},G=+new Date,W,U=0;while($.keys===null&&(J<=0||U<J)){if($.state===0){var M=$.p===null?$.pBits:$.qBits,O=M-1;if($.pqState===0){if($.num=new T$(M,$.rng),!$.num.testBit(O))$.num.bitwiseTo(T$.ONE.shiftLeft(O),Y,$.num);$.num.dAddOffset(31-$.num.mod(X).byteValue(),0),Q=0,++$.pqState}else if($.pqState===1)if($.num.bitLength()>M)$.pqState=0;else if($.num.isProbablePrime(zV($.num.bitLength())))++$.pqState;else $.num.dAddOffset(WV[Q++%8],0);else if($.pqState===2)$.pqState=$.num.subtract(T$.ONE).gcd($.e).compareTo(T$.ONE)===0?3:0;else if($.pqState===3){if($.pqState=0,$.p===null)$.p=$.num;else $.q=$.num;if($.p!==null&&$.q!==null)++$.state;$.num=null}}else if($.state===1){if($.p.compareTo($.q)<0)$.num=$.p,$.p=$.q,$.q=$.num;++$.state}else if($.state===2)$.p1=$.p.subtract(T$.ONE),$.q1=$.q.subtract(T$.ONE),$.phi=$.p1.multiply($.q1),++$.state;else if($.state===3)if($.phi.gcd($.e).compareTo(T$.ONE)===0)++$.state;else $.p=null,$.q=null,$.state=0;else if($.state===4)if($.n=$.p.multiply($.q),$.n.bitLength()===$.bits)++$.state;else $.q=null,$.state=0;else if($.state===5){var V=$.e.modInverse($.phi);$.keys={privateKey:V$.rsa.setPrivateKey($.n,$.e,V,$.p,$.q,V.mod($.p1),V.mod($.q1),$.q.modInverse($.p)),publicKey:V$.rsa.setPublicKey($.n,$.e)}}W=+new Date,U+=W-G,G=W}return $.keys!==null};V$.rsa.generateKeyPair=function($,J,X,Q){if(arguments.length===1){if(typeof $==="object")X=$,$=void 0;else if(typeof $==="function")Q=$,$=void 0}else if(arguments.length===2)if(typeof $==="number"){if(typeof J==="function")Q=J,J=void 0;else if(typeof J!=="number")X=J,J=void 0}else X=$,Q=J,$=void 0,J=void 0;else if(arguments.length===3)if(typeof J==="number"){if(typeof X==="function")Q=X,X=void 0}else Q=X,X=J,J=void 0;if(X=X||{},$===void 0)$=X.bits||2048;if(J===void 0)J=X.e||65537;if(!Q$.options.usePureJavaScript&&!X.prng&&$>=256&&$<=16384&&(J===65537||J===3)){if(Q){if(q1("generateKeyPair"))return z8.generateKeyPair("rsa",{modulusLength:$,publicExponent:J,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(U,M,O){if(U)return Q(U);Q(null,{privateKey:V$.privateKeyFromPem(O),publicKey:V$.publicKeyFromPem(M)})});if(K1("generateKey")&&K1("exportKey"))return vJ.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:$,publicExponent:E1(J),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(U){return vJ.globalScope.crypto.subtle.exportKey("pkcs8",U.privateKey)}).then(void 0,function(U){Q(U)}).then(function(U){if(U){var M=V$.privateKeyFromAsn1(S.fromDer(Q$.util.createBuffer(U)));Q(null,{privateKey:M,publicKey:V$.setRsaPublicKey(M.n,M.e)})}});if(z1("generateKey")&&z1("exportKey")){var Y=vJ.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:$,publicExponent:E1(J),hash:{name:"SHA-256"}},!0,["sign","verify"]);Y.oncomplete=function(U){var M=U.target.result,O=vJ.globalScope.msCrypto.subtle.exportKey("pkcs8",M.privateKey);O.oncomplete=function(V){var H=V.target.result,q=V$.privateKeyFromAsn1(S.fromDer(Q$.util.createBuffer(H)));Q(null,{privateKey:q,publicKey:V$.setRsaPublicKey(q.n,q.e)})},O.onerror=function(V){Q(V)}},Y.onerror=function(U){Q(U)};return}}else if(q1("generateKeyPairSync")){var G=z8.generateKeyPairSync("rsa",{modulusLength:$,publicExponent:J,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:V$.privateKeyFromPem(G.privateKey),publicKey:V$.publicKeyFromPem(G.publicKey)}}}var W=V$.rsa.createKeyPairGenerationState($,J,X);if(!Q)return V$.rsa.stepKeyPairGenerationState(W,0),W.keys;KV(W,X,Q)};V$.setRsaPublicKey=V$.rsa.setPublicKey=function($,J){var X={n:$,e:J};return X.encrypt=function(Q,Y,G){if(typeof Y==="string")Y=Y.toUpperCase();else if(Y===void 0)Y="RSAES-PKCS1-V1_5";if(Y==="RSAES-PKCS1-V1_5")Y={encode:function(U,M,O){return N1(U,M,2).getBytes()}};else if(Y==="RSA-OAEP"||Y==="RSAES-OAEP")Y={encode:function(U,M){return Q$.pkcs1.encode_rsa_oaep(M,U,G)}};else if(["RAW","NONE","NULL",null].indexOf(Y)!==-1)Y={encode:function(U){return U}};else if(typeof Y==="string")throw Error('Unsupported encryption scheme: "'+Y+'".');var W=Y.encode(Q,X,!0);return V$.rsa.encrypt(W,X,!0)},X.verify=function(Q,Y,G,W){if(typeof G==="string")G=G.toUpperCase();else if(G===void 0)G="RSASSA-PKCS1-V1_5";if(W===void 0)W={_parseAllDigestBytes:!0,_skipPaddingChecks:!1};if(!("_parseAllDigestBytes"in W))W._parseAllDigestBytes=!0;if(!("_skipPaddingChecks"in W))W._skipPaddingChecks=!1;if(G==="RSASSA-PKCS1-V1_5")G={verify:function(M,O){O=_Y(O,X,!0,void 0,W);var V=S.fromDer(O,{parseAllBytes:W._parseAllDigestBytes}),H={},q=[];if(!S.validate(V,HV,H,q)||V.value.length!==2){var F=Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw F.errors=q,F}var K=S.derToOid(H.algorithmIdentifier);if(!(K===Q$.oids.md2||K===Q$.oids.md5||K===Q$.oids.sha1||K===Q$.oids.sha224||K===Q$.oids.sha256||K===Q$.oids.sha384||K===Q$.oids.sha512||K===Q$.oids["sha512-224"]||K===Q$.oids["sha512-256"])){var F=Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw F.oid=K,F}if(K===Q$.oids.md2||K===Q$.oids.md5){if(!("parameters"in H))throw Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.")}return M===H.digest}};else if(G==="NONE"||G==="NULL"||G===null)G={verify:function(M,O){return O=_Y(O,X,!0,void 0,W),M===O}};var U=V$.rsa.decrypt(Y,X,!0,!1);return G.verify(Q,U,X.n.bitLength())},X};V$.setRsaPrivateKey=V$.rsa.setPrivateKey=function($,J,X,Q,Y,G,W,U){var M={n:$,e:J,d:X,p:Q,q:Y,dP:G,dQ:W,qInv:U};return M.decrypt=function(O,V,H){if(typeof V==="string")V=V.toUpperCase();else if(V===void 0)V="RSAES-PKCS1-V1_5";var q=V$.rsa.decrypt(O,M,!1,!1);if(V==="RSAES-PKCS1-V1_5")V={decode:_Y};else if(V==="RSA-OAEP"||V==="RSAES-OAEP")V={decode:function(F,K){return Q$.pkcs1.decode_rsa_oaep(K,F,H)}};else if(["RAW","NONE","NULL",null].indexOf(V)!==-1)V={decode:function(F){return F}};else throw Error('Unsupported encryption scheme: "'+V+'".');return V.decode(q,M,!1)},M.sign=function(O,V){var H=!1;if(typeof V==="string")V=V.toUpperCase();if(V===void 0||V==="RSASSA-PKCS1-V1_5")V={encode:qV},H=1;else if(V==="NONE"||V==="NULL"||V===null)V={encode:function(){return O}},H=1;var q=V.encode(O,M.n.bitLength());return V$.rsa.encrypt(q,M,H)},M};V$.wrapRsaPrivateKey=function($){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(V$.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,S.toDer($).getBytes())])};V$.privateKeyFromAsn1=function($){var J={},X=[];if(S.validate($,UV,J,X))$=S.fromDer(Q$.util.createBuffer(J.privateKey));if(J={},X=[],!S.validate($,MV,J,X)){var Q=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw Q.errors=X,Q}var Y,G,W,U,M,O,V,H;return Y=Q$.util.createBuffer(J.privateKeyModulus).toHex(),G=Q$.util.createBuffer(J.privateKeyPublicExponent).toHex(),W=Q$.util.createBuffer(J.privateKeyPrivateExponent).toHex(),U=Q$.util.createBuffer(J.privateKeyPrime1).toHex(),M=Q$.util.createBuffer(J.privateKeyPrime2).toHex(),O=Q$.util.createBuffer(J.privateKeyExponent1).toHex(),V=Q$.util.createBuffer(J.privateKeyExponent2).toHex(),H=Q$.util.createBuffer(J.privateKeyCoefficient).toHex(),V$.setRsaPrivateKey(new T$(Y,16),new T$(G,16),new T$(W,16),new T$(U,16),new T$(M,16),new T$(O,16),new T$(V,16),new T$(H,16))};V$.privateKeyToAsn1=V$.privateKeyToRSAPrivateKey=function($){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.e)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.d)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.p)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.q)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.dP)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.dQ)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.qInv))])};V$.publicKeyFromAsn1=function($){var J={},X=[];if(S.validate($,VV,J,X)){var Q=S.derToOid(J.publicKeyOid);if(Q!==V$.oids.rsaEncryption){var Y=Error("Cannot read public key. Unknown OID.");throw Y.oid=Q,Y}$=J.rsaPublicKey}if(X=[],!S.validate($,OV,J,X)){var Y=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw Y.errors=X,Y}var G=Q$.util.createBuffer(J.publicKeyModulus).toHex(),W=Q$.util.createBuffer(J.publicKeyExponent).toHex();return V$.setRsaPublicKey(new T$(G,16),new T$(W,16))};V$.publicKeyToAsn1=V$.publicKeyToSubjectPublicKeyInfo=function($){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(V$.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.BITSTRING,!1,[V$.publicKeyToRSAPublicKey($)])])};V$.publicKeyToRSAPublicKey=function($){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,W0($.e))])};function N1($,J,X){var Q=Q$.util.createBuffer(),Y=Math.ceil(J.n.bitLength()/8);if($.length>Y-11){var G=Error("Message is too long for PKCS#1 v1.5 padding.");throw G.length=$.length,G.max=Y-11,G}Q.putByte(0),Q.putByte(X);var W=Y-3-$.length,U;if(X===0||X===1){U=X===0?0:255;for(var M=0;M<W;++M)Q.putByte(U)}else while(W>0){var O=0,V=Q$.random.getBytes(W);for(var M=0;M<W;++M)if(U=V.charCodeAt(M),U===0)++O;else Q.putByte(U);W=O}return Q.putByte(0),Q.putBytes($),Q}function _Y($,J,X,Q,Y){var G=Math.ceil(J.n.bitLength()/8),W=Q$.util.createBuffer($),U=W.getByte(),M=W.getByte();if(U!==0||X&&M!==0&&M!==1||!X&&M!==2||X&&M===0&&typeof Q>"u")throw Error("Encryption block is invalid.");var O=0;if(M===0){O=G-3-Q;for(var V=0;V<O;++V)if(W.getByte()!==0)throw Error("Encryption block is invalid.")}else if(M===1){O=0;while(W.length()>1){if(W.getByte()!==255){--W.read;break}++O}if(O<8&&!(Y?Y._skipPaddingChecks:!1))throw Error("Encryption block is invalid.")}else if(M===2){O=0;while(W.length()>1){if(W.getByte()===0){--W.read;break}++O}if(O<8&&!(Y?Y._skipPaddingChecks:!1))throw Error("Encryption block is invalid.")}var H=W.getByte();if(H!==0||O!==G-3-W.length())throw Error("Encryption block is invalid.");return W.getBytes()}function KV($,J,X){if(typeof J==="function")X=J,J={};J=J||{};var Q={algorithm:{name:J.algorithm||"PRIMEINC",options:{workers:J.workers||2,workLoad:J.workLoad||100,workerScript:J.workerScript}}};if("prng"in J)Q.prng=J.prng;Y();function Y(){G($.pBits,function(U,M){if(U)return X(U);if($.p=M,$.q!==null)return W(U,$.q);G($.qBits,W)})}function G(U,M){Q$.prime.generateProbablePrime(U,Q,M)}function W(U,M){if(U)return X(U);if($.q=M,$.p.compareTo($.q)<0){var O=$.p;$.p=$.q,$.q=O}if($.p.subtract(T$.ONE).gcd($.e).compareTo(T$.ONE)!==0){$.p=null,Y();return}if($.q.subtract(T$.ONE).gcd($.e).compareTo(T$.ONE)!==0){$.q=null,G($.qBits,W);return}if($.p1=$.p.subtract(T$.ONE),$.q1=$.q.subtract(T$.ONE),$.phi=$.p1.multiply($.q1),$.phi.gcd($.e).compareTo(T$.ONE)!==0){$.p=$.q=null,Y();return}if($.n=$.p.multiply($.q),$.n.bitLength()!==$.bits){$.q=null,G($.qBits,W);return}var V=$.e.modInverse($.phi);$.keys={privateKey:V$.rsa.setPrivateKey($.n,$.e,V,$.p,$.q,V.mod($.p1),V.mod($.q1),$.q.modInverse($.p)),publicKey:V$.rsa.setPublicKey($.n,$.e)},X(null,$.keys)}}function W0($){var J=$.toString(16);if(J[0]>="8")J="00"+J;var X=Q$.util.hexToBytes(J);if(X.length>1&&(X.charCodeAt(0)===0&&(X.charCodeAt(1)&128)===0||X.charCodeAt(0)===255&&(X.charCodeAt(1)&128)===128))return X.substr(1);return X}function zV($){if($<=100)return 27;if($<=150)return 18;if($<=200)return 15;if($<=250)return 12;if($<=300)return 9;if($<=350)return 8;if($<=400)return 7;if($<=500)return 6;if($<=600)return 5;if($<=800)return 4;if($<=1250)return 3;return 2}function q1($){return Q$.util.isNodejs&&typeof z8[$]==="function"}function K1($){return typeof vJ.globalScope<"u"&&typeof vJ.globalScope.crypto==="object"&&typeof vJ.globalScope.crypto.subtle==="object"&&typeof vJ.globalScope.crypto.subtle[$]==="function"}function z1($){return typeof vJ.globalScope<"u"&&typeof vJ.globalScope.msCrypto==="object"&&typeof vJ.globalScope.msCrypto.subtle==="object"&&typeof vJ.globalScope.msCrypto.subtle[$]==="function"}function E1($){var J=Q$.util.hexToBytes($.toString(16)),X=new Uint8Array(J.length);for(var Q=0;Q<J.length;++Q)X[Q]=J.charCodeAt(Q);return X}});var F8=O$((LF,Z1)=>{var o=z$();w0();mJ();AX();eJ();P0();SY();JQ();_J();W8();ZX();w$();if(typeof E8>"u")E8=o.jsbn.BigInteger;var E8,_=o.asn1,q$=o.pki=o.pki||{};Z1.exports=q$.pbe=o.pbe=o.pbe||{};var YQ=q$.oids,EV={name:"EncryptedPrivateKeyInfo",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},FV={name:"PBES2Algorithms",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:_.Class.UNIVERSAL,type:_.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},NV={name:"pkcs-12PbeParams",tagClass:_.Class.UNIVERSAL,type:_.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:_.Class.UNIVERSAL,type:_.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:_.Class.UNIVERSAL,type:_.Type.INTEGER,constructed:!1,capture:"iterations"}]};q$.encryptPrivateKeyInfo=function($,J,X){X=X||{},X.saltSize=X.saltSize||8,X.count=X.count||2048,X.algorithm=X.algorithm||"aes128",X.prfAlgorithm=X.prfAlgorithm||"sha1";var Q=o.random.getBytesSync(X.saltSize),Y=X.count,G=_.integerToDer(Y),W,U,M;if(X.algorithm.indexOf("aes")===0||X.algorithm==="des"){var O,V,H;switch(X.algorithm){case"aes128":W=16,O=16,V=YQ["aes128-CBC"],H=o.aes.createEncryptionCipher;break;case"aes192":W=24,O=16,V=YQ["aes192-CBC"],H=o.aes.createEncryptionCipher;break;case"aes256":W=32,O=16,V=YQ["aes256-CBC"],H=o.aes.createEncryptionCipher;break;case"des":W=8,O=8,V=YQ.desCBC,H=o.des.createEncryptionCipher;break;default:var q=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw q.algorithm=X.algorithm,q}var F="hmacWith"+X.prfAlgorithm.toUpperCase(),K=D1(F),A=o.pkcs5.pbkdf2(J,Q,Y,W,K),L=o.random.getBytesSync(O),R=H(A);R.start(L),R.update(_.toDer($)),R.finish(),M=R.output.getBytes();var I=LV(Q,G,W,F);U=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(YQ.pkcs5PBES2).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(YQ.pkcs5PBKDF2).getBytes()),I]),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(V).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,L)])])])}else if(X.algorithm==="3des"){W=24;var T=new o.util.ByteBuffer(Q),A=q$.pbe.generatePkcs12Key(J,T,1,Y,W),L=q$.pbe.generatePkcs12Key(J,T,2,Y,W),R=o.des.createEncryptionCipher(A);R.start(L),R.update(_.toDer($)),R.finish(),M=R.output.getBytes(),U=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(YQ["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,Q),_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,G.getBytes())])])}else{var q=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw q.algorithm=X.algorithm,q}var C=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[U,_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,M)]);return C};q$.decryptPrivateKeyInfo=function($,J){var X=null,Q={},Y=[];if(!_.validate($,EV,Q,Y)){var G=Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}var W=_.derToOid(Q.encryptionOid),U=q$.pbe.getCipher(W,Q.encryptionParams,J),M=o.util.createBuffer(Q.encryptedData);if(U.update(M),U.finish())X=_.fromDer(U.output);return X};q$.encryptedPrivateKeyToPem=function($,J){var X={type:"ENCRYPTED PRIVATE KEY",body:_.toDer($).getBytes()};return o.pem.encode(X,{maxline:J})};q$.encryptedPrivateKeyFromPem=function($){var J=o.pem.decode($)[0];if(J.type!=="ENCRYPTED PRIVATE KEY"){var X=Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return _.fromDer(J.body)};q$.encryptRsaPrivateKey=function($,J,X){if(X=X||{},!X.legacy){var Q=q$.wrapRsaPrivateKey(q$.privateKeyToAsn1($));return Q=q$.encryptPrivateKeyInfo(Q,J,X),q$.encryptedPrivateKeyToPem(Q)}var Y,G,W,U;switch(X.algorithm){case"aes128":Y="AES-128-CBC",W=16,G=o.random.getBytesSync(16),U=o.aes.createEncryptionCipher;break;case"aes192":Y="AES-192-CBC",W=24,G=o.random.getBytesSync(16),U=o.aes.createEncryptionCipher;break;case"aes256":Y="AES-256-CBC",W=32,G=o.random.getBytesSync(16),U=o.aes.createEncryptionCipher;break;case"3des":Y="DES-EDE3-CBC",W=24,G=o.random.getBytesSync(8),U=o.des.createEncryptionCipher;break;case"des":Y="DES-CBC",W=8,G=o.random.getBytesSync(8),U=o.des.createEncryptionCipher;break;default:var M=Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+X.algorithm+'".');throw M.algorithm=X.algorithm,M}var O=o.pbe.opensslDeriveBytes(J,G.substr(0,8),W),V=U(O);V.start(G),V.update(_.toDer(q$.privateKeyToAsn1($))),V.finish();var H={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:Y,parameters:o.util.bytesToHex(G).toUpperCase()},body:V.output.getBytes()};return o.pem.encode(H)};q$.decryptRsaPrivateKey=function($,J){var X=null,Q=o.pem.decode($)[0];if(Q.type!=="ENCRYPTED PRIVATE KEY"&&Q.type!=="PRIVATE KEY"&&Q.type!=="RSA PRIVATE KEY"){var Y=Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw Y.headerType=Y,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED"){var G,W;switch(Q.dekInfo.algorithm){case"DES-CBC":G=8,W=o.des.createDecryptionCipher;break;case"DES-EDE3-CBC":G=24,W=o.des.createDecryptionCipher;break;case"AES-128-CBC":G=16,W=o.aes.createDecryptionCipher;break;case"AES-192-CBC":G=24,W=o.aes.createDecryptionCipher;break;case"AES-256-CBC":G=32,W=o.aes.createDecryptionCipher;break;case"RC2-40-CBC":G=5,W=function(H){return o.rc2.createDecryptionCipher(H,40)};break;case"RC2-64-CBC":G=8,W=function(H){return o.rc2.createDecryptionCipher(H,64)};break;case"RC2-128-CBC":G=16,W=function(H){return o.rc2.createDecryptionCipher(H,128)};break;default:var Y=Error('Could not decrypt private key; unsupported encryption algorithm "'+Q.dekInfo.algorithm+'".');throw Y.algorithm=Q.dekInfo.algorithm,Y}var U=o.util.hexToBytes(Q.dekInfo.parameters),M=o.pbe.opensslDeriveBytes(J,U.substr(0,8),G),O=W(M);if(O.start(U),O.update(o.util.createBuffer(Q.body)),O.finish())X=O.output.getBytes();else return X}else X=Q.body;if(Q.type==="ENCRYPTED PRIVATE KEY")X=q$.decryptPrivateKeyInfo(_.fromDer(X),J);else X=_.fromDer(X);if(X!==null)X=q$.privateKeyFromAsn1(X);return X};q$.pbe.generatePkcs12Key=function($,J,X,Q,Y,G){var W,U;if(typeof G>"u"||G===null){if(!("sha1"in o.md))throw Error('"sha1" hash algorithm unavailable.');G=o.md.sha1.create()}var{digestLength:M,blockLength:O}=G,V=new o.util.ByteBuffer,H=new o.util.ByteBuffer;if($!==null&&$!==void 0){for(U=0;U<$.length;U++)H.putInt16($.charCodeAt(U));H.putInt16(0)}var q=H.length(),F=J.length(),K=new o.util.ByteBuffer;K.fillWithByte(X,O);var A=O*Math.ceil(F/O),L=new o.util.ByteBuffer;for(U=0;U<A;U++)L.putByte(J.at(U%F));var R=O*Math.ceil(q/O),I=new o.util.ByteBuffer;for(U=0;U<R;U++)I.putByte(H.at(U%q));var T=L;T.putBuffer(I);var C=Math.ceil(Y/M);for(var w=1;w<=C;w++){var P=new o.util.ByteBuffer;P.putBytes(K.bytes()),P.putBytes(T.bytes());for(var l=0;l<Q;l++)G.start(),G.update(P.getBytes()),P=G.digest();var k=new o.util.ByteBuffer;for(U=0;U<O;U++)k.putByte(P.at(U%M));var p=Math.ceil(F/O)+Math.ceil(q/O),$$=new o.util.ByteBuffer;for(W=0;W<p;W++){var N$=new o.util.ByteBuffer(T.getBytes(O)),M$=511;for(U=k.length()-1;U>=0;U--)M$=M$>>8,M$+=k.at(U)+N$.at(U),N$.setAt(U,M$&255);$$.putBuffer(N$)}T=$$,V.putBuffer(P)}return V.truncate(V.length()-Y),V};q$.pbe.getCipher=function($,J,X){switch($){case q$.oids.pkcs5PBES2:return q$.pbe.getCipherForPBES2($,J,X);case q$.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case q$.oids["pbewithSHAAnd40BitRC2-CBC"]:return q$.pbe.getCipherForPKCS12PBE($,J,X);default:var Q=Error("Cannot read encrypted PBE data block. Unsupported OID.");throw Q.oid=$,Q.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],Q}};q$.pbe.getCipherForPBES2=function($,J,X){var Q={},Y=[];if(!_.validate(J,FV,Q,Y)){var G=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}if($=_.derToOid(Q.kdfOid),$!==q$.oids.pkcs5PBKDF2){var G=Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw G.oid=$,G.supportedOids=["pkcs5PBKDF2"],G}if($=_.derToOid(Q.encOid),$!==q$.oids["aes128-CBC"]&&$!==q$.oids["aes192-CBC"]&&$!==q$.oids["aes256-CBC"]&&$!==q$.oids["des-EDE3-CBC"]&&$!==q$.oids.desCBC){var G=Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw G.oid=$,G.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],G}var W=Q.kdfSalt,U=o.util.createBuffer(Q.kdfIterationCount);U=U.getInt(U.length()<<3);var M,O;switch(q$.oids[$]){case"aes128-CBC":M=16,O=o.aes.createDecryptionCipher;break;case"aes192-CBC":M=24,O=o.aes.createDecryptionCipher;break;case"aes256-CBC":M=32,O=o.aes.createDecryptionCipher;break;case"des-EDE3-CBC":M=24,O=o.des.createDecryptionCipher;break;case"desCBC":M=8,O=o.des.createDecryptionCipher;break}var V=R1(Q.prfOid),H=o.pkcs5.pbkdf2(X,W,U,M,V),q=Q.encIv,F=O(H);return F.start(q),F};q$.pbe.getCipherForPKCS12PBE=function($,J,X){var Q={},Y=[];if(!_.validate(J,NV,Q,Y)){var G=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw G.errors=Y,G}var W=o.util.createBuffer(Q.salt),U=o.util.createBuffer(Q.iterations);U=U.getInt(U.length()<<3);var M,O,V;switch($){case q$.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:M=24,O=8,V=o.des.startDecrypting;break;case q$.oids["pbewithSHAAnd40BitRC2-CBC"]:M=5,O=8,V=function(A,L){var R=o.rc2.createDecryptionCipher(A,40);return R.start(L,null),R};break;default:var G=Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw G.oid=$,G}var H=R1(Q.prfOid),q=q$.pbe.generatePkcs12Key(X,W,1,U,M,H);H.start();var F=q$.pbe.generatePkcs12Key(X,W,2,U,O,H);return V(q,F)};q$.pbe.opensslDeriveBytes=function($,J,X,Q){if(typeof Q>"u"||Q===null){if(!("md5"in o.md))throw Error('"md5" hash algorithm unavailable.');Q=o.md.md5.create()}if(J===null)J="";var Y=[A1(Q,$+J)];for(var G=16,W=1;G<X;++W,G+=16)Y.push(A1(Q,Y[W-1]+$+J));return Y.join("").substr(0,X)};function A1($,J){return $.start().update(J).digest().getBytes()}function R1($){var J;if(!$)J="hmacWithSHA1";else if(J=q$.oids[_.derToOid($)],!J){var X=Error("Unsupported PRF OID.");throw X.oid=$,X.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],X}return D1(J)}function D1($){var J=o.md;switch($){case"hmacWithSHA224":J=o.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":$=$.substr(8).toLowerCase();break;default:var X=Error("Unsupported PRF algorithm.");throw X.algorithm=$,X.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],X}if(!J||!($ in J))throw Error("Unknown hash algorithm: "+$);return J[$].create()}function LV($,J,X,Q){var Y=_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OCTETSTRING,!1,$),_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,J.getBytes())]);if(Q!=="hmacWithSHA1")Y.value.push(_.create(_.Class.UNIVERSAL,_.Type.INTEGER,!1,o.util.hexToBytes(X.toString(16))),_.create(_.Class.UNIVERSAL,_.Type.SEQUENCE,!0,[_.create(_.Class.UNIVERSAL,_.Type.OID,!1,_.oidToDer(q$.oids[Q]).getBytes()),_.create(_.Class.UNIVERSAL,_.Type.NULL,!1,"")]));return Y}});var N8=O$((AF,T1)=>{var PQ=z$();mJ();w$();var i=PQ.asn1,_Q=T1.exports=PQ.pkcs7asn1=PQ.pkcs7asn1||{};PQ.pkcs7=PQ.pkcs7||{};PQ.pkcs7.asn1=_Q;var B1={name:"ContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};_Q.contentInfoValidator=B1;var j1={name:"EncryptedContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};_Q.envelopedDataValidator={name:"EnvelopedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(j1)};_Q.encryptedDataValidator={name:"EncryptedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"}].concat(j1)};var AV={name:"SignerInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};_Q.signedDataValidator={name:"SignedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},B1,{name:"SignedData.Certificates",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:"signerInfos",optional:!0,value:[AV]}]};_Q.recipientInfoValidator={name:"RecipientInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var L8=O$((RF,S1)=>{var GQ=z$();w$();GQ.mgf=GQ.mgf||{};var RV=S1.exports=GQ.mgf.mgf1=GQ.mgf1=GQ.mgf1||{};RV.create=function($){var J={generate:function(X,Q){var Y=new GQ.util.ByteBuffer,G=Math.ceil(Q/$.digestLength);for(var W=0;W<G;W++){var U=new GQ.util.ByteBuffer;U.putInt32(W),$.start(),$.update(X+U.getBytes()),Y.putBuffer($.digest())}return Y.truncate(Y.length()-Q),Y.getBytes()}};return J}});var C1=O$((DF,I1)=>{var xY=z$();L8();I1.exports=xY.mgf=xY.mgf||{};xY.mgf.mgf1=xY.mgf1});var vY=O$((ZF,w1)=>{var WQ=z$();_J();w$();var DV=w1.exports=WQ.pss=WQ.pss||{};DV.create=function($){if(arguments.length===3)$={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]};var{md:J,mgf:X}=$,Q=J.digestLength,Y=$.salt||null;if(typeof Y==="string")Y=WQ.util.createBuffer(Y);var G;if("saltLength"in $)G=$.saltLength;else if(Y!==null)G=Y.length();else throw Error("Salt length not specified or specific salt not given.");if(Y!==null&&Y.length()!==G)throw Error("Given salt length does not match length of given salt.");var W=$.prng||WQ.random,U={};return U.encode=function(M,O){var V,H=O-1,q=Math.ceil(H/8),F=M.digest().getBytes();if(q<Q+G+2)throw Error("Message is too long to encrypt.");var K;if(Y===null)K=W.getBytesSync(G);else K=Y.bytes();var A=new WQ.util.ByteBuffer;A.fillWithByte(0,8),A.putBytes(F),A.putBytes(K),J.start(),J.update(A.getBytes());var L=J.digest().getBytes(),R=new WQ.util.ByteBuffer;R.fillWithByte(0,q-G-Q-2),R.putByte(1),R.putBytes(K);var I=R.getBytes(),T=q-Q-1,C=X.generate(L,T),w="";for(V=0;V<T;V++)w+=String.fromCharCode(I.charCodeAt(V)^C.charCodeAt(V));var P=65280>>8*q-H&255;return w=String.fromCharCode(w.charCodeAt(0)&~P)+w.substr(1),w+L+String.fromCharCode(188)},U.verify=function(M,O,V){var H,q=V-1,F=Math.ceil(q/8);if(O=O.substr(-F),F<Q+G+2)throw Error("Inconsistent parameters to PSS signature verification.");if(O.charCodeAt(F-1)!==188)throw Error("Encoded message does not end in 0xBC.");var K=F-Q-1,A=O.substr(0,K),L=O.substr(K,Q),R=65280>>8*F-q&255;if((A.charCodeAt(0)&R)!==0)throw Error("Bits beyond keysize not zero as expected.");var I=X.generate(L,K),T="";for(H=0;H<K;H++)T+=String.fromCharCode(A.charCodeAt(H)^I.charCodeAt(H));T=String.fromCharCode(T.charCodeAt(0)&~R)+T.substr(1);var C=F-Q-G-2;for(H=0;H<C;H++)if(T.charCodeAt(H)!==0)throw Error("Leftmost octets not zero as expected");if(T.charCodeAt(C)!==1)throw Error("Inconsistent PSS signature, 0x01 marker not found");var w=T.substr(-G),P=new WQ.util.ByteBuffer;P.fillWithByte(0,8),P.putBytes(M),P.putBytes(w),J.start(),J.update(P.getBytes());var l=J.digest().getBytes();return L===l},U}});var yY=O$((BF,k1)=>{var X$=z$();w0();mJ();AX();eJ();C1();P0();JQ();vY();ZX();w$();var z=X$.asn1,g=k1.exports=X$.pki=X$.pki||{},C$=g.oids,s$={};s$.CN=C$.commonName;s$.commonName="CN";s$.C=C$.countryName;s$.countryName="C";s$.L=C$.localityName;s$.localityName="L";s$.ST=C$.stateOrProvinceName;s$.stateOrProvinceName="ST";s$.O=C$.organizationName;s$.organizationName="O";s$.OU=C$.organizationalUnitName;s$.organizationalUnitName="OU";s$.E=C$.emailAddress;s$.emailAddress="E";var _1=X$.pki.rsa.publicKeyValidator,ZV={name:"Certificate",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:z.Class.UNIVERSAL,type:z.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:z.Class.UNIVERSAL,type:z.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:z.Class.UNIVERSAL,type:z.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:z.Class.UNIVERSAL,type:z.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},_1,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:z.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:z.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:z.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},BV={name:"rsapss",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:z.Class.UNIVERSAL,type:z.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:z.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:z.Class.UNIVERSAL,type:z.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:z.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:z.Class.UNIVERSAL,type:z.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:z.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:z.Class.UNIVERSAL,type:z.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},jV={name:"CertificationRequestInfo",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:z.Class.UNIVERSAL,type:z.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},_1,{name:"CertificationRequestInfo.attributes",tagClass:z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:z.Class.UNIVERSAL,type:z.Type.SET,constructed:!0}]}]}]},TV={name:"CertificationRequest",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[jV,{name:"CertificationRequest.signatureAlgorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:z.Class.UNIVERSAL,type:z.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:z.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:z.Class.UNIVERSAL,type:z.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};g.RDNAttributesAsArray=function($,J){var X=[],Q,Y,G;for(var W=0;W<$.value.length;++W){Q=$.value[W];for(var U=0;U<Q.value.length;++U){if(G={},Y=Q.value[U],G.type=z.derToOid(Y.value[0].value),G.value=Y.value[1].value,G.valueTagClass=Y.value[1].type,G.type in C$){if(G.name=C$[G.type],G.name in s$)G.shortName=s$[G.name]}if(J)J.update(G.type),J.update(G.value);X.push(G)}}return X};g.CRIAttributesAsArray=function($){var J=[];for(var X=0;X<$.length;++X){var Q=$[X],Y=z.derToOid(Q.value[0].value),G=Q.value[1].value;for(var W=0;W<G.length;++W){var U={};if(U.type=Y,U.value=G[W].value,U.valueTagClass=G[W].type,U.type in C$){if(U.name=C$[U.type],U.name in s$)U.shortName=s$[U.name]}if(U.type===C$.extensionRequest){U.extensions=[];for(var M=0;M<U.value.length;++M)U.extensions.push(g.certificateExtensionFromAsn1(U.value[M]))}J.push(U)}}return J};function v0($,J){if(typeof J==="string")J={shortName:J};var X=null,Q;for(var Y=0;X===null&&Y<$.attributes.length;++Y)if(Q=$.attributes[Y],J.type&&J.type===Q.type)X=Q;else if(J.name&&J.name===Q.name)X=Q;else if(J.shortName&&J.shortName===Q.shortName)X=Q;return X}var kY=function($,J,X){var Q={};if($!==C$["RSASSA-PSS"])return Q;if(X)Q={hash:{algorithmOid:C$.sha1},mgf:{algorithmOid:C$.mgf1,hash:{algorithmOid:C$.sha1}},saltLength:20};var Y={},G=[];if(!z.validate(J,BV,Y,G)){var W=Error("Cannot read RSASSA-PSS parameter block.");throw W.errors=G,W}if(Y.hashOid!==void 0)Q.hash=Q.hash||{},Q.hash.algorithmOid=z.derToOid(Y.hashOid);if(Y.maskGenOid!==void 0)Q.mgf=Q.mgf||{},Q.mgf.algorithmOid=z.derToOid(Y.maskGenOid),Q.mgf.hash=Q.mgf.hash||{},Q.mgf.hash.algorithmOid=z.derToOid(Y.maskGenHashOid);if(Y.saltLength!==void 0)Q.saltLength=Y.saltLength.charCodeAt(0);return Q},fY=function($){switch(C$[$.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return X$.md.sha1.create();case"md5WithRSAEncryption":return X$.md.md5.create();case"sha256WithRSAEncryption":return X$.md.sha256.create();case"sha384WithRSAEncryption":return X$.md.sha384.create();case"sha512WithRSAEncryption":return X$.md.sha512.create();case"RSASSA-PSS":return X$.md.sha256.create();default:var J=Error("Could not compute "+$.type+" digest. Unknown signature OID.");throw J.signatureOid=$.signatureOid,J}},x1=function($){var J=$.certificate,X;switch(J.signatureOid){case C$.sha1WithRSAEncryption:case C$.sha1WithRSASignature:break;case C$["RSASSA-PSS"]:var Q,Y;if(Q=C$[J.signatureParameters.mgf.hash.algorithmOid],Q===void 0||X$.md[Q]===void 0){var G=Error("Unsupported MGF hash function.");throw G.oid=J.signatureParameters.mgf.hash.algorithmOid,G.name=Q,G}if(Y=C$[J.signatureParameters.mgf.algorithmOid],Y===void 0||X$.mgf[Y]===void 0){var G=Error("Unsupported MGF function.");throw G.oid=J.signatureParameters.mgf.algorithmOid,G.name=Y,G}if(Y=X$.mgf[Y].create(X$.md[Q].create()),Q=C$[J.signatureParameters.hash.algorithmOid],Q===void 0||X$.md[Q]===void 0){var G=Error("Unsupported RSASSA-PSS hash function.");throw G.oid=J.signatureParameters.hash.algorithmOid,G.name=Q,G}X=X$.pss.create(X$.md[Q].create(),Y,J.signatureParameters.saltLength);break}return J.publicKey.verify($.md.digest().getBytes(),$.signature,X)};g.certificateFromPem=function($,J,X){var Q=X$.pem.decode($)[0];if(Q.type!=="CERTIFICATE"&&Q.type!=="X509 CERTIFICATE"&&Q.type!=="TRUSTED CERTIFICATE"){var Y=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw Y.headerType=Q.type,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED")throw Error("Could not convert certificate from PEM; PEM is encrypted.");var G=z.fromDer(Q.body,X);return g.certificateFromAsn1(G,J)};g.certificateToPem=function($,J){var X={type:"CERTIFICATE",body:z.toDer(g.certificateToAsn1($)).getBytes()};return X$.pem.encode(X,{maxline:J})};g.publicKeyFromPem=function($){var J=X$.pem.decode($)[0];if(J.type!=="PUBLIC KEY"&&J.type!=="RSA PUBLIC KEY"){var X=Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert public key from PEM; PEM is encrypted.");var Q=z.fromDer(J.body);return g.publicKeyFromAsn1(Q)};g.publicKeyToPem=function($,J){var X={type:"PUBLIC KEY",body:z.toDer(g.publicKeyToAsn1($)).getBytes()};return X$.pem.encode(X,{maxline:J})};g.publicKeyToRSAPublicKeyPem=function($,J){var X={type:"RSA PUBLIC KEY",body:z.toDer(g.publicKeyToRSAPublicKey($)).getBytes()};return X$.pem.encode(X,{maxline:J})};g.getPublicKeyFingerprint=function($,J){J=J||{};var X=J.md||X$.md.sha1.create(),Q=J.type||"RSAPublicKey",Y;switch(Q){case"RSAPublicKey":Y=z.toDer(g.publicKeyToRSAPublicKey($)).getBytes();break;case"SubjectPublicKeyInfo":Y=z.toDer(g.publicKeyToAsn1($)).getBytes();break;default:throw Error('Unknown fingerprint type "'+J.type+'".')}X.start(),X.update(Y);var G=X.digest();if(J.encoding==="hex"){var W=G.toHex();if(J.delimiter)return W.match(/.{2}/g).join(J.delimiter);return W}else if(J.encoding==="binary")return G.getBytes();else if(J.encoding)throw Error('Unknown encoding "'+J.encoding+'".');return G};g.certificationRequestFromPem=function($,J,X){var Q=X$.pem.decode($)[0];if(Q.type!=="CERTIFICATE REQUEST"){var Y=Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw Y.headerType=Q.type,Y}if(Q.procType&&Q.procType.type==="ENCRYPTED")throw Error("Could not convert certification request from PEM; PEM is encrypted.");var G=z.fromDer(Q.body,X);return g.certificationRequestFromAsn1(G,J)};g.certificationRequestToPem=function($,J){var X={type:"CERTIFICATE REQUEST",body:z.toDer(g.certificationRequestToAsn1($)).getBytes()};return X$.pem.encode(X,{maxline:J})};g.createCertificate=function(){var $={};return $.version=2,$.serialNumber="00",$.signatureOid=null,$.signature=null,$.siginfo={},$.siginfo.algorithmOid=null,$.validity={},$.validity.notBefore=new Date,$.validity.notAfter=new Date,$.issuer={},$.issuer.getField=function(J){return v0($.issuer,J)},$.issuer.addField=function(J){kJ([J]),$.issuer.attributes.push(J)},$.issuer.attributes=[],$.issuer.hash=null,$.subject={},$.subject.getField=function(J){return v0($.subject,J)},$.subject.addField=function(J){kJ([J]),$.subject.attributes.push(J)},$.subject.attributes=[],$.subject.hash=null,$.extensions=[],$.publicKey=null,$.md=null,$.setSubject=function(J,X){if(kJ(J),$.subject.attributes=J,delete $.subject.uniqueId,X)$.subject.uniqueId=X;$.subject.hash=null},$.setIssuer=function(J,X){if(kJ(J),$.issuer.attributes=J,delete $.issuer.uniqueId,X)$.issuer.uniqueId=X;$.issuer.hash=null},$.setExtensions=function(J){for(var X=0;X<J.length;++X)v1(J[X],{cert:$});$.extensions=J},$.getExtension=function(J){if(typeof J==="string")J={name:J};var X=null,Q;for(var Y=0;X===null&&Y<$.extensions.length;++Y)if(Q=$.extensions[Y],J.id&&Q.id===J.id)X=Q;else if(J.name&&Q.name===J.name)X=Q;return X},$.sign=function(J,X){$.md=X||X$.md.sha1.create();var Q=C$[$.md.algorithm+"WithRSAEncryption"];if(!Q){var Y=Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw Y.algorithm=$.md.algorithm,Y}$.signatureOid=$.siginfo.algorithmOid=Q,$.tbsCertificate=g.getTBSCertificate($);var G=z.toDer($.tbsCertificate);$.md.update(G.getBytes()),$.signature=J.sign($.md)},$.verify=function(J){var X=!1;if(!$.issued(J)){var Q=J.issuer,Y=$.subject,G=Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw G.expectedIssuer=Y.attributes,G.actualIssuer=Q.attributes,G}var W=J.md;if(W===null){W=fY({signatureOid:J.signatureOid,type:"certificate"});var U=J.tbsCertificate||g.getTBSCertificate(J),M=z.toDer(U);W.update(M.getBytes())}if(W!==null)X=x1({certificate:$,md:W,signature:J.signature});return X},$.isIssuer=function(J){var X=!1,Q=$.issuer,Y=J.subject;if(Q.hash&&Y.hash)X=Q.hash===Y.hash;else if(Q.attributes.length===Y.attributes.length){X=!0;var G,W;for(var U=0;X&&U<Q.attributes.length;++U)if(G=Q.attributes[U],W=Y.attributes[U],G.type!==W.type||G.value!==W.value)X=!1}return X},$.issued=function(J){return J.isIssuer($)},$.generateSubjectKeyIdentifier=function(){return g.getPublicKeyFingerprint($.publicKey,{type:"RSAPublicKey"})},$.verifySubjectKeyIdentifier=function(){var J=C$.subjectKeyIdentifier;for(var X=0;X<$.extensions.length;++X){var Q=$.extensions[X];if(Q.id===J){var Y=$.generateSubjectKeyIdentifier().getBytes();return X$.util.hexToBytes(Q.subjectKeyIdentifier)===Y}}return!1},$};g.certificateFromAsn1=function($,J){var X={},Q=[];if(!z.validate($,ZV,X,Q)){var Y=Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw Y.errors=Q,Y}var G=z.derToOid(X.publicKeyOid);if(G!==g.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var W=g.createCertificate();W.version=X.certVersion?X.certVersion.charCodeAt(0):0;var U=X$.util.createBuffer(X.certSerialNumber);W.serialNumber=U.toHex(),W.signatureOid=X$.asn1.derToOid(X.certSignatureOid),W.signatureParameters=kY(W.signatureOid,X.certSignatureParams,!0),W.siginfo.algorithmOid=X$.asn1.derToOid(X.certinfoSignatureOid),W.siginfo.parameters=kY(W.siginfo.algorithmOid,X.certinfoSignatureParams,!1),W.signature=X.certSignature;var M=[];if(X.certValidity1UTCTime!==void 0)M.push(z.utcTimeToDate(X.certValidity1UTCTime));if(X.certValidity2GeneralizedTime!==void 0)M.push(z.generalizedTimeToDate(X.certValidity2GeneralizedTime));if(X.certValidity3UTCTime!==void 0)M.push(z.utcTimeToDate(X.certValidity3UTCTime));if(X.certValidity4GeneralizedTime!==void 0)M.push(z.generalizedTimeToDate(X.certValidity4GeneralizedTime));if(M.length>2)throw Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(M.length<2)throw Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(W.validity.notBefore=M[0],W.validity.notAfter=M[1],W.tbsCertificate=X.tbsCertificate,J){W.md=fY({signatureOid:W.signatureOid,type:"certificate"});var O=z.toDer(W.tbsCertificate);W.md.update(O.getBytes())}var V=X$.md.sha1.create(),H=z.toDer(X.certIssuer);if(V.update(H.getBytes()),W.issuer.getField=function(K){return v0(W.issuer,K)},W.issuer.addField=function(K){kJ([K]),W.issuer.attributes.push(K)},W.issuer.attributes=g.RDNAttributesAsArray(X.certIssuer),X.certIssuerUniqueId)W.issuer.uniqueId=X.certIssuerUniqueId;W.issuer.hash=V.digest().toHex();var q=X$.md.sha1.create(),F=z.toDer(X.certSubject);if(q.update(F.getBytes()),W.subject.getField=function(K){return v0(W.subject,K)},W.subject.addField=function(K){kJ([K]),W.subject.attributes.push(K)},W.subject.attributes=g.RDNAttributesAsArray(X.certSubject),X.certSubjectUniqueId)W.subject.uniqueId=X.certSubjectUniqueId;if(W.subject.hash=q.digest().toHex(),X.certExtensions)W.extensions=g.certificateExtensionsFromAsn1(X.certExtensions);else W.extensions=[];return W.publicKey=g.publicKeyFromAsn1(X.subjectPublicKeyInfo),W};g.certificateExtensionsFromAsn1=function($){var J=[];for(var X=0;X<$.value.length;++X){var Q=$.value[X];for(var Y=0;Y<Q.value.length;++Y)J.push(g.certificateExtensionFromAsn1(Q.value[Y]))}return J};g.certificateExtensionFromAsn1=function($){var J={};if(J.id=z.derToOid($.value[0].value),J.critical=!1,$.value[1].type===z.Type.BOOLEAN)J.critical=$.value[1].value.charCodeAt(0)!==0,J.value=$.value[2].value;else J.value=$.value[1].value;if(J.id in C$){if(J.name=C$[J.id],J.name==="keyUsage"){var X=z.fromDer(J.value),Q=0,Y=0;if(X.value.length>1)Q=X.value.charCodeAt(1),Y=X.value.length>2?X.value.charCodeAt(2):0;J.digitalSignature=(Q&128)===128,J.nonRepudiation=(Q&64)===64,J.keyEncipherment=(Q&32)===32,J.dataEncipherment=(Q&16)===16,J.keyAgreement=(Q&8)===8,J.keyCertSign=(Q&4)===4,J.cRLSign=(Q&2)===2,J.encipherOnly=(Q&1)===1,J.decipherOnly=(Y&128)===128}else if(J.name==="basicConstraints"){var X=z.fromDer(J.value);if(X.value.length>0&&X.value[0].type===z.Type.BOOLEAN)J.cA=X.value[0].value.charCodeAt(0)!==0;else J.cA=!1;var G=null;if(X.value.length>0&&X.value[0].type===z.Type.INTEGER)G=X.value[0].value;else if(X.value.length>1)G=X.value[1].value;if(G!==null)J.pathLenConstraint=z.derToInteger(G)}else if(J.name==="extKeyUsage"){var X=z.fromDer(J.value);for(var W=0;W<X.value.length;++W){var U=z.derToOid(X.value[W].value);if(U in C$)J[C$[U]]=!0;else J[U]=!0}}else if(J.name==="nsCertType"){var X=z.fromDer(J.value),Q=0;if(X.value.length>1)Q=X.value.charCodeAt(1);J.client=(Q&128)===128,J.server=(Q&64)===64,J.email=(Q&32)===32,J.objsign=(Q&16)===16,J.reserved=(Q&8)===8,J.sslCA=(Q&4)===4,J.emailCA=(Q&2)===2,J.objCA=(Q&1)===1}else if(J.name==="subjectAltName"||J.name==="issuerAltName"){J.altNames=[];var M,X=z.fromDer(J.value);for(var O=0;O<X.value.length;++O){M=X.value[O];var V={type:M.type,value:M.value};switch(J.altNames.push(V),M.type){case 1:case 2:case 6:break;case 7:V.ip=X$.util.bytesToIP(M.value);break;case 8:V.oid=z.derToOid(M.value);break;default:}}}else if(J.name==="subjectKeyIdentifier"){var X=z.fromDer(J.value);J.subjectKeyIdentifier=X$.util.bytesToHex(X.value)}}return J};g.certificationRequestFromAsn1=function($,J){var X={},Q=[];if(!z.validate($,TV,X,Q)){var Y=Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw Y.errors=Q,Y}var G=z.derToOid(X.publicKeyOid);if(G!==g.oids.rsaEncryption)throw Error("Cannot read public key. OID is not RSA.");var W=g.createCertificationRequest();if(W.version=X.csrVersion?X.csrVersion.charCodeAt(0):0,W.signatureOid=X$.asn1.derToOid(X.csrSignatureOid),W.signatureParameters=kY(W.signatureOid,X.csrSignatureParams,!0),W.siginfo.algorithmOid=X$.asn1.derToOid(X.csrSignatureOid),W.siginfo.parameters=kY(W.siginfo.algorithmOid,X.csrSignatureParams,!1),W.signature=X.csrSignature,W.certificationRequestInfo=X.certificationRequestInfo,J){W.md=fY({signatureOid:W.signatureOid,type:"certification request"});var U=z.toDer(W.certificationRequestInfo);W.md.update(U.getBytes())}var M=X$.md.sha1.create();return W.subject.getField=function(O){return v0(W.subject,O)},W.subject.addField=function(O){kJ([O]),W.subject.attributes.push(O)},W.subject.attributes=g.RDNAttributesAsArray(X.certificationRequestInfoSubject,M),W.subject.hash=M.digest().toHex(),W.publicKey=g.publicKeyFromAsn1(X.subjectPublicKeyInfo),W.getAttribute=function(O){return v0(W,O)},W.addAttribute=function(O){kJ([O]),W.attributes.push(O)},W.attributes=g.CRIAttributesAsArray(X.certificationRequestInfoAttributes||[]),W};g.createCertificationRequest=function(){var $={};return $.version=0,$.signatureOid=null,$.signature=null,$.siginfo={},$.siginfo.algorithmOid=null,$.subject={},$.subject.getField=function(J){return v0($.subject,J)},$.subject.addField=function(J){kJ([J]),$.subject.attributes.push(J)},$.subject.attributes=[],$.subject.hash=null,$.publicKey=null,$.attributes=[],$.getAttribute=function(J){return v0($,J)},$.addAttribute=function(J){kJ([J]),$.attributes.push(J)},$.md=null,$.setSubject=function(J){kJ(J),$.subject.attributes=J,$.subject.hash=null},$.setAttributes=function(J){kJ(J),$.attributes=J},$.sign=function(J,X){$.md=X||X$.md.sha1.create();var Q=C$[$.md.algorithm+"WithRSAEncryption"];if(!Q){var Y=Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw Y.algorithm=$.md.algorithm,Y}$.signatureOid=$.siginfo.algorithmOid=Q,$.certificationRequestInfo=g.getCertificationRequestInfo($);var G=z.toDer($.certificationRequestInfo);$.md.update(G.getBytes()),$.signature=J.sign($.md)},$.verify=function(){var J=!1,X=$.md;if(X===null){X=fY({signatureOid:$.signatureOid,type:"certification request"});var Q=$.certificationRequestInfo||g.getCertificationRequestInfo($),Y=z.toDer(Q);X.update(Y.getBytes())}if(X!==null)J=x1({certificate:$,md:X,signature:$.signature});return J},$};function xQ($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),X,Q,Y=$.attributes;for(var G=0;G<Y.length;++G){X=Y[G];var W=X.value,U=z.Type.PRINTABLESTRING;if("valueTagClass"in X){if(U=X.valueTagClass,U===z.Type.UTF8)W=X$.util.encodeUtf8(W)}Q=z.create(z.Class.UNIVERSAL,z.Type.SET,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(X.type).getBytes()),z.create(z.Class.UNIVERSAL,U,!1,W)])]),J.value.push(Q)}return J}function kJ($){var J;for(var X=0;X<$.length;++X){if(J=$[X],typeof J.name>"u"){if(J.type&&J.type in g.oids)J.name=g.oids[J.type];else if(J.shortName&&J.shortName in s$)J.name=g.oids[s$[J.shortName]]}if(typeof J.type>"u")if(J.name&&J.name in g.oids)J.type=g.oids[J.name];else{var Q=Error("Attribute type not specified.");throw Q.attribute=J,Q}if(typeof J.shortName>"u"){if(J.name&&J.name in s$)J.shortName=s$[J.name]}if(J.type===C$.extensionRequest){if(J.valueConstructed=!0,J.valueTagClass=z.Type.SEQUENCE,!J.value&&J.extensions){J.value=[];for(var Y=0;Y<J.extensions.length;++Y)J.value.push(g.certificateExtensionToAsn1(v1(J.extensions[Y])))}}if(typeof J.value>"u"){var Q=Error("Attribute value not specified.");throw Q.attribute=J,Q}}}function v1($,J){if(J=J||{},typeof $.name>"u"){if($.id&&$.id in g.oids)$.name=g.oids[$.id]}if(typeof $.id>"u")if($.name&&$.name in g.oids)$.id=g.oids[$.name];else{var X=Error("Extension ID not specified.");throw X.extension=$,X}if(typeof $.value<"u")return $;if($.name==="keyUsage"){var Q=0,Y=0,G=0;if($.digitalSignature)Y|=128,Q=7;if($.nonRepudiation)Y|=64,Q=6;if($.keyEncipherment)Y|=32,Q=5;if($.dataEncipherment)Y|=16,Q=4;if($.keyAgreement)Y|=8,Q=3;if($.keyCertSign)Y|=4,Q=2;if($.cRLSign)Y|=2,Q=1;if($.encipherOnly)Y|=1,Q=0;if($.decipherOnly)G|=128,Q=7;var W=String.fromCharCode(Q);if(G!==0)W+=String.fromCharCode(Y)+String.fromCharCode(G);else if(Y!==0)W+=String.fromCharCode(Y);$.value=z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,W)}else if($.name==="basicConstraints"){if($.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),$.cA)$.value.value.push(z.create(z.Class.UNIVERSAL,z.Type.BOOLEAN,!1,String.fromCharCode(255)));if("pathLenConstraint"in $)$.value.value.push(z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.pathLenConstraint).getBytes()))}else if($.name==="extKeyUsage"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var U=$.value.value;for(var M in $){if($[M]!==!0)continue;if(M in C$)U.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(C$[M]).getBytes()));else if(M.indexOf(".")!==-1)U.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(M).getBytes()))}}else if($.name==="nsCertType"){var Q=0,Y=0;if($.client)Y|=128,Q=7;if($.server)Y|=64,Q=6;if($.email)Y|=32,Q=5;if($.objsign)Y|=16,Q=4;if($.reserved)Y|=8,Q=3;if($.sslCA)Y|=4,Q=2;if($.emailCA)Y|=2,Q=1;if($.objCA)Y|=1,Q=0;var W=String.fromCharCode(Q);if(Y!==0)W+=String.fromCharCode(Y);$.value=z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,W)}else if($.name==="subjectAltName"||$.name==="issuerAltName"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var O;for(var V=0;V<$.altNames.length;++V){O=$.altNames[V];var W=O.value;if(O.type===7&&O.ip){if(W=X$.util.bytesFromIP(O.ip),W===null){var X=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw X.extension=$,X}}else if(O.type===8)if(O.oid)W=z.oidToDer(z.oidToDer(O.oid));else W=z.oidToDer(W);$.value.value.push(z.create(z.Class.CONTEXT_SPECIFIC,O.type,!1,W))}}else if($.name==="nsComment"&&J.cert){if(!/^[\x00-\x7F]*$/.test($.comment)||$.comment.length<1||$.comment.length>128)throw Error('Invalid "nsComment" content.');$.value=z.create(z.Class.UNIVERSAL,z.Type.IA5STRING,!1,$.comment)}else if($.name==="subjectKeyIdentifier"&&J.cert){var H=J.cert.generateSubjectKeyIdentifier();$.subjectKeyIdentifier=H.toHex(),$.value=z.create(z.Class.UNIVERSAL,z.Type.OCTETSTRING,!1,H.getBytes())}else if($.name==="authorityKeyIdentifier"&&J.cert){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var U=$.value.value;if($.keyIdentifier){var q=$.keyIdentifier===!0?J.cert.generateSubjectKeyIdentifier().getBytes():$.keyIdentifier;U.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!1,q))}if($.authorityCertIssuer){var F=[z.create(z.Class.CONTEXT_SPECIFIC,4,!0,[xQ($.authorityCertIssuer===!0?J.cert.issuer:$.authorityCertIssuer)])];U.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,F))}if($.serialNumber){var K=X$.util.hexToBytes($.serialNumber===!0?J.cert.serialNumber:$.serialNumber);U.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!1,K))}}else if($.name==="cRLDistributionPoints"){$.value=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);var U=$.value.value,A=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]),L=z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[]),O;for(var V=0;V<$.altNames.length;++V){O=$.altNames[V];var W=O.value;if(O.type===7&&O.ip){if(W=X$.util.bytesFromIP(O.ip),W===null){var X=Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw X.extension=$,X}}else if(O.type===8)if(O.oid)W=z.oidToDer(z.oidToDer(O.oid));else W=z.oidToDer(W);L.value.push(z.create(z.Class.CONTEXT_SPECIFIC,O.type,!1,W))}A.value.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[L])),U.push(A)}if(typeof $.value>"u"){var X=Error("Extension value not specified.");throw X.extension=$,X}return $}function A8($,J){switch($){case C$["RSASSA-PSS"]:var X=[];if(J.hash.algorithmOid!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.hash.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")])]));if(J.mgf.algorithmOid!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,[z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.mgf.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(J.mgf.hash.algorithmOid).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")])])]));if(J.saltLength!==void 0)X.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer(J.saltLength).getBytes())]));return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,X);default:return z.create(z.Class.UNIVERSAL,z.Type.NULL,!1,"")}}function SV($){var J=z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[]);if($.attributes.length===0)return J;var X=$.attributes;for(var Q=0;Q<X.length;++Q){var Y=X[Q],G=Y.value,W=z.Type.UTF8;if("valueTagClass"in Y)W=Y.valueTagClass;if(W===z.Type.UTF8)G=X$.util.encodeUtf8(G);var U=!1;if("valueConstructed"in Y)U=Y.valueConstructed;var M=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer(Y.type).getBytes()),z.create(z.Class.UNIVERSAL,z.Type.SET,!0,[z.create(z.Class.UNIVERSAL,W,U,G)])]);J.value.push(M)}return J}var IV=new Date("1950-01-01T00:00:00Z"),CV=new Date("2050-01-01T00:00:00Z");function P1($){if($>=IV&&$<CV)return z.create(z.Class.UNIVERSAL,z.Type.UTCTIME,!1,z.dateToUtcTime($));else return z.create(z.Class.UNIVERSAL,z.Type.GENERALIZEDTIME,!1,z.dateToGeneralizedTime($))}g.getTBSCertificate=function($){var J=P1($.validity.notBefore),X=P1($.validity.notAfter),Q=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.CONTEXT_SPECIFIC,0,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.version).getBytes())]),z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,X$.util.hexToBytes($.serialNumber)),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.siginfo.algorithmOid).getBytes()),A8($.siginfo.algorithmOid,$.siginfo.parameters)]),xQ($.issuer),z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,X]),xQ($.subject),g.publicKeyToAsn1($.publicKey)]);if($.issuer.uniqueId)Q.value.push(z.create(z.Class.CONTEXT_SPECIFIC,1,!0,[z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.issuer.uniqueId)]));if($.subject.uniqueId)Q.value.push(z.create(z.Class.CONTEXT_SPECIFIC,2,!0,[z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.subject.uniqueId)]));if($.extensions.length>0)Q.value.push(g.certificateExtensionsToAsn1($.extensions));return Q};g.getCertificationRequestInfo=function($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.INTEGER,!1,z.integerToDer($.version).getBytes()),xQ($.subject),g.publicKeyToAsn1($.publicKey),SV($)]);return J};g.distinguishedNameToAsn1=function($){return xQ($)};g.certificateToAsn1=function($){var J=$.tbsCertificate||g.getTBSCertificate($);return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.signatureOid).getBytes()),A8($.signatureOid,$.signatureParameters)]),z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.signature)])};g.certificateExtensionsToAsn1=function($){var J=z.create(z.Class.CONTEXT_SPECIFIC,3,!0,[]),X=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);J.value.push(X);for(var Q=0;Q<$.length;++Q)X.value.push(g.certificateExtensionToAsn1($[Q]));return J};g.certificateExtensionToAsn1=function($){var J=z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[]);if(J.value.push(z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.id).getBytes())),$.critical)J.value.push(z.create(z.Class.UNIVERSAL,z.Type.BOOLEAN,!1,String.fromCharCode(255)));var X=$.value;if(typeof $.value!=="string")X=z.toDer(X).getBytes();return J.value.push(z.create(z.Class.UNIVERSAL,z.Type.OCTETSTRING,!1,X)),J};g.certificationRequestToAsn1=function($){var J=$.certificationRequestInfo||g.getCertificationRequestInfo($);return z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[J,z.create(z.Class.UNIVERSAL,z.Type.SEQUENCE,!0,[z.create(z.Class.UNIVERSAL,z.Type.OID,!1,z.oidToDer($.signatureOid).getBytes()),A8($.signatureOid,$.signatureParameters)]),z.create(z.Class.UNIVERSAL,z.Type.BITSTRING,!1,String.fromCharCode(0)+$.signature)])};g.createCaStore=function($){var J={certs:{}};J.getIssuer=function(W){var U=X(W.issuer);return U},J.addCertificate=function(W){if(typeof W==="string")W=X$.pki.certificateFromPem(W);if(Q(W.subject),!J.hasCertificate(W))if(W.subject.hash in J.certs){var U=J.certs[W.subject.hash];if(!X$.util.isArray(U))U=[U];U.push(W),J.certs[W.subject.hash]=U}else J.certs[W.subject.hash]=W},J.hasCertificate=function(W){if(typeof W==="string")W=X$.pki.certificateFromPem(W);var U=X(W.subject);if(!U)return!1;if(!X$.util.isArray(U))U=[U];var M=z.toDer(g.certificateToAsn1(W)).getBytes();for(var O=0;O<U.length;++O){var V=z.toDer(g.certificateToAsn1(U[O])).getBytes();if(M===V)return!0}return!1},J.listAllCertificates=function(){var W=[];for(var U in J.certs)if(J.certs.hasOwnProperty(U)){var M=J.certs[U];if(!X$.util.isArray(M))W.push(M);else for(var O=0;O<M.length;++O)W.push(M[O])}return W},J.removeCertificate=function(W){var U;if(typeof W==="string")W=X$.pki.certificateFromPem(W);if(Q(W.subject),!J.hasCertificate(W))return null;var M=X(W.subject);if(!X$.util.isArray(M))return U=J.certs[W.subject.hash],delete J.certs[W.subject.hash],U;var O=z.toDer(g.certificateToAsn1(W)).getBytes();for(var V=0;V<M.length;++V){var H=z.toDer(g.certificateToAsn1(M[V])).getBytes();if(O===H)U=M[V],M.splice(V,1)}if(M.length===0)delete J.certs[W.subject.hash];return U};function X(W){return Q(W),J.certs[W.hash]||null}function Q(W){if(!W.hash){var U=X$.md.sha1.create();W.attributes=g.RDNAttributesAsArray(xQ(W),U),W.hash=U.digest().toHex()}}if($)for(var Y=0;Y<$.length;++Y){var G=$[Y];J.addCertificate(G)}return J};g.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};g.verifyCertificateChain=function($,J,X){if(typeof X==="function")X={verify:X};X=X||{},J=J.slice(0);var Q=J.slice(0),Y=X.validityCheckDate;if(typeof Y>"u")Y=new Date;var G=!0,W=null,U=0;do{var M=J.shift(),O=null,V=!1;if(Y){if(Y<M.validity.notBefore||Y>M.validity.notAfter)W={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:M.validity.notBefore,notAfter:M.validity.notAfter,now:Y}}if(W===null){if(O=J[0]||$.getIssuer(M),O===null){if(M.isIssuer(M))V=!0,O=M}if(O){var H=O;if(!X$.util.isArray(H))H=[H];var q=!1;while(!q&&H.length>0){O=H.shift();try{q=O.verify(M)}catch(w){}}if(!q)W={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate}}if(W===null&&(!O||V)&&!$.hasCertificate(M))W={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca}}if(W===null&&O&&!M.isIssuer(O))W={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate};if(W===null){var F={keyUsage:!0,basicConstraints:!0};for(var K=0;W===null&&K<M.extensions.length;++K){var A=M.extensions[K];if(A.critical&&!(A.name in F))W={message:"Certificate has an unsupported critical extension.",error:g.certificateError.unsupported_certificate}}}if(W===null&&(!G||J.length===0&&(!O||V))){var L=M.getExtension("basicConstraints"),R=M.getExtension("keyUsage");if(R!==null){if(!R.keyCertSign||L===null)W={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:g.certificateError.bad_certificate}}if(W===null&&L===null)W={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:g.certificateError.bad_certificate};if(W===null&&L!==null&&!L.cA)W={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:g.certificateError.bad_certificate};if(W===null&&R!==null&&"pathLenConstraint"in L){var I=U-1;if(I>L.pathLenConstraint)W={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate}}}var T=W===null?!0:W.error,C=X.verify?X.verify(T,U,Q):T;if(C===!0)W=null;else{if(T===!0)W={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate};if(C||C===0){if(typeof C==="object"&&!X$.util.isArray(C)){if(C.message)W.message=C.message;if(C.error)W.error=C.error}else if(typeof C==="string")W.error=C}throw W}G=!1,++U}while(J.length>0);return!0}});var D8=O$((jF,y1)=>{var l$=z$();mJ();TQ();P0();N8();F8();_J();ZX();wQ();w$();yY();var{asn1:D,pki:R$}=l$,jX=y1.exports=l$.pkcs12=l$.pkcs12||{},f1={name:"ContentInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:D.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},wV={name:"PFX",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"version"},f1,{name:"PFX.macData",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:D.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:D.Class.UNIVERSAL,type:D.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:D.Class.UNIVERSAL,type:D.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},PV={name:"SafeBag",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:D.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:D.Class.UNIVERSAL,type:D.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},_V={name:"Attribute",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:D.Class.UNIVERSAL,type:D.Type.SET,constructed:!0,capture:"values"}]},xV={name:"CertBag",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:D.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:D.Class.UNIVERSAL,type:D.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function BX($,J,X,Q){var Y=[];for(var G=0;G<$.length;G++)for(var W=0;W<$[G].safeBags.length;W++){var U=$[G].safeBags[W];if(Q!==void 0&&U.type!==Q)continue;if(J===null){Y.push(U);continue}if(U.attributes[J]!==void 0&&U.attributes[J].indexOf(X)>=0)Y.push(U)}return Y}jX.pkcs12FromAsn1=function($,J,X){if(typeof J==="string")X=J,J=!0;else if(J===void 0)J=!0;var Q={},Y=[];if(!D.validate($,wV,Q,Y)){var G=Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw G.errors=G,G}var W={version:Q.version.charCodeAt(0),safeContents:[],getBags:function(L){var R={},I;if("localKeyId"in L)I=L.localKeyId;else if("localKeyIdHex"in L)I=l$.util.hexToBytes(L.localKeyIdHex);if(I===void 0&&!("friendlyName"in L)&&"bagType"in L)R[L.bagType]=BX(W.safeContents,null,null,L.bagType);if(I!==void 0)R.localKeyId=BX(W.safeContents,"localKeyId",I,L.bagType);if("friendlyName"in L)R.friendlyName=BX(W.safeContents,"friendlyName",L.friendlyName,L.bagType);return R},getBagsByFriendlyName:function(L,R){return BX(W.safeContents,"friendlyName",L,R)},getBagsByLocalKeyId:function(L,R){return BX(W.safeContents,"localKeyId",L,R)}};if(Q.version.charCodeAt(0)!==3){var G=Error("PKCS#12 PFX of version other than 3 not supported.");throw G.version=Q.version.charCodeAt(0),G}if(D.derToOid(Q.contentType)!==R$.oids.data){var G=Error("Only PKCS#12 PFX in password integrity mode supported.");throw G.oid=D.derToOid(Q.contentType),G}var U=Q.content.value[0];if(U.tagClass!==D.Class.UNIVERSAL||U.type!==D.Type.OCTETSTRING)throw Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(U=R8(U),Q.mac){var M=null,O=0,V=D.derToOid(Q.macAlgorithm);switch(V){case R$.oids.sha1:M=l$.md.sha1.create(),O=20;break;case R$.oids.sha256:M=l$.md.sha256.create(),O=32;break;case R$.oids.sha384:M=l$.md.sha384.create(),O=48;break;case R$.oids.sha512:M=l$.md.sha512.create(),O=64;break;case R$.oids.md5:M=l$.md.md5.create(),O=16;break}if(M===null)throw Error("PKCS#12 uses unsupported MAC algorithm: "+V);var H=new l$.util.ByteBuffer(Q.macSalt),q="macIterations"in Q?parseInt(l$.util.bytesToHex(Q.macIterations),16):1,F=jX.generateKey(X,H,3,q,O,M),K=l$.hmac.create();K.start(M,F),K.update(U.value);var A=K.getMac();if(A.getBytes()!==Q.macDigest)throw Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray($.value)&&$.value.length>2)throw Error("Invalid PKCS#12. macData field present but MAC was not validated.");return vV(W,U.value,J,X),W};function R8($){if($.composed||$.constructed){var J=l$.util.createBuffer();for(var X=0;X<$.value.length;++X)J.putBytes($.value[X].value);$.composed=$.constructed=!1,$.value=J.getBytes()}return $}function vV($,J,X,Q){if(J=D.fromDer(J,X),J.tagClass!==D.Class.UNIVERSAL||J.type!==D.Type.SEQUENCE||J.constructed!==!0)throw Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var Y=0;Y<J.value.length;Y++){var G=J.value[Y],W={},U=[];if(!D.validate(G,f1,W,U)){var M=Error("Cannot read ContentInfo.");throw M.errors=U,M}var O={encrypted:!1},V=null,H=W.content.value[0];switch(D.derToOid(W.contentType)){case R$.oids.data:if(H.tagClass!==D.Class.UNIVERSAL||H.type!==D.Type.OCTETSTRING)throw Error("PKCS#12 SafeContents Data is not an OCTET STRING.");V=R8(H).value;break;case R$.oids.encryptedData:V=kV(H,Q),O.encrypted=!0;break;default:var M=Error("Unsupported PKCS#12 contentType.");throw M.contentType=D.derToOid(W.contentType),M}O.safeBags=fV(V,X,Q),$.safeContents.push(O)}}function kV($,J){var X={},Q=[];if(!D.validate($,l$.pkcs7.asn1.encryptedDataValidator,X,Q)){var Y=Error("Cannot read EncryptedContentInfo.");throw Y.errors=Q,Y}var G=D.derToOid(X.contentType);if(G!==R$.oids.data){var Y=Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw Y.oid=G,Y}G=D.derToOid(X.encAlgorithm);var W=R$.pbe.getCipher(G,X.encParameter,J),U=R8(X.encryptedContentAsn1),M=l$.util.createBuffer(U.value);if(W.update(M),!W.finish())throw Error("Failed to decrypt PKCS#12 SafeContents.");return W.output.getBytes()}function fV($,J,X){if(!J&&$.length===0)return[];if($=D.fromDer($,J),$.tagClass!==D.Class.UNIVERSAL||$.type!==D.Type.SEQUENCE||$.constructed!==!0)throw Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");var Q=[];for(var Y=0;Y<$.value.length;Y++){var G=$.value[Y],W={},U=[];if(!D.validate(G,PV,W,U)){var M=Error("Cannot read SafeBag.");throw M.errors=U,M}var O={type:D.derToOid(W.bagId),attributes:yV(W.bagAttributes)};Q.push(O);var V,H,q=W.bagValue.value[0];switch(O.type){case R$.oids.pkcs8ShroudedKeyBag:if(q=R$.decryptPrivateKeyInfo(q,X),q===null)throw Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case R$.oids.keyBag:try{O.key=R$.privateKeyFromAsn1(q)}catch(K){O.key=null,O.asn1=q}continue;case R$.oids.certBag:V=xV,H=function(){if(D.derToOid(W.certId)!==R$.oids.x509Certificate){var K=Error("Unsupported certificate type, only X.509 supported.");throw K.oid=D.derToOid(W.certId),K}var A=D.fromDer(W.cert,J);try{O.cert=R$.certificateFromAsn1(A,!0)}catch(L){O.cert=null,O.asn1=A}};break;default:var M=Error("Unsupported PKCS#12 SafeBag type.");throw M.oid=O.type,M}if(V!==void 0&&!D.validate(q,V,W,U)){var M=Error("Cannot read PKCS#12 "+V.name);throw M.errors=U,M}H()}return Q}function yV($){var J={};if($!==void 0)for(var X=0;X<$.length;++X){var Q={},Y=[];if(!D.validate($[X],_V,Q,Y)){var G=Error("Cannot read PKCS#12 BagAttribute.");throw G.errors=Y,G}var W=D.derToOid(Q.oid);if(R$.oids[W]===void 0)continue;J[R$.oids[W]]=[];for(var U=0;U<Q.values.length;++U)J[R$.oids[W]].push(Q.values[U].value)}return J}jX.toPkcs12Asn1=function($,J,X,Q){if(Q=Q||{},Q.saltSize=Q.saltSize||8,Q.count=Q.count||2048,Q.algorithm=Q.algorithm||Q.encAlgorithm||"aes128",!("useMac"in Q))Q.useMac=!0;if(!("localKeyId"in Q))Q.localKeyId=null;if(!("generateLocalKeyId"in Q))Q.generateLocalKeyId=!0;var Y=Q.localKeyId,G;if(Y!==null)Y=l$.util.hexToBytes(Y);else if(Q.generateLocalKeyId)if(J){var W=l$.util.isArray(J)?J[0]:J;if(typeof W==="string")W=R$.certificateFromPem(W);var U=l$.md.sha1.create();U.update(D.toDer(R$.certificateToAsn1(W)).getBytes()),Y=U.digest().getBytes()}else Y=l$.random.getBytes(20);var M=[];if(Y!==null)M.push(D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.localKeyId).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.SET,!0,[D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,Y)])]));if("friendlyName"in Q)M.push(D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.friendlyName).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.SET,!0,[D.create(D.Class.UNIVERSAL,D.Type.BMPSTRING,!1,Q.friendlyName)])]));if(M.length>0)G=D.create(D.Class.UNIVERSAL,D.Type.SET,!0,M);var O=[],V=[];if(J!==null)if(l$.util.isArray(J))V=J;else V=[J];var H=[];for(var q=0;q<V.length;++q){if(J=V[q],typeof J==="string")J=R$.certificateFromPem(J);var F=q===0?G:void 0,K=R$.certificateToAsn1(J),A=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.certBag).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.x509Certificate).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(K).getBytes())])])]),F]);H.push(A)}if(H.length>0){var L=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,H),R=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.data).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(L).getBytes())])]);O.push(R)}var I=null;if($!==null){var T=R$.wrapRsaPrivateKey(R$.privateKeyToAsn1($));if(X===null)I=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.keyBag).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[T]),G]);else I=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.pkcs8ShroudedKeyBag).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[R$.encryptPrivateKeyInfo(T,X,Q)]),G]);var C=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[I]),w=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.data).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(C).getBytes())])]);O.push(w)}var P=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,O),l;if(Q.useMac){var U=l$.md.sha1.create(),k=new l$.util.ByteBuffer(l$.random.getBytes(Q.saltSize)),p=Q.count,$=jX.generateKey(X,k,3,p,20),$$=l$.hmac.create();$$.start(U,$),$$.update(D.toDer(P).getBytes());var N$=$$.getMac();l=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.sha1).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,"")]),D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,N$.getBytes())]),D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,k.getBytes()),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(p).getBytes())])}return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(3).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(R$.oids.data).getBytes()),D.create(D.Class.CONTEXT_SPECIFIC,0,!0,[D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(P).getBytes())])]),l])};jX.generateKey=l$.pbe.generatePkcs12Key});var B8=O$((TF,b1)=>{var k0=z$();mJ();P0();F8();JQ();SY();D8();vY();ZX();w$();yY();var Z8=k0.asn1,vQ=b1.exports=k0.pki=k0.pki||{};vQ.pemToDer=function($){var J=k0.pem.decode($)[0];if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert PEM to DER; PEM is encrypted.");return k0.util.createBuffer(J.body)};vQ.privateKeyFromPem=function($){var J=k0.pem.decode($)[0];if(J.type!=="PRIVATE KEY"&&J.type!=="RSA PRIVATE KEY"){var X=Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert private key from PEM; PEM is encrypted.");var Q=Z8.fromDer(J.body);return vQ.privateKeyFromAsn1(Q)};vQ.privateKeyToPem=function($,J){var X={type:"RSA PRIVATE KEY",body:Z8.toDer(vQ.privateKeyToAsn1($)).getBytes()};return k0.pem.encode(X,{maxline:J})};vQ.privateKeyInfoToPem=function($,J){var X={type:"PRIVATE KEY",body:Z8.toDer($).getBytes()};return k0.pem.encode(X,{maxline:J})}});var w8=O$((SF,c1)=>{var y=z$();mJ();TQ();ZY();JQ();B8();_J();wQ();w$();var uY=function($,J,X,Q){var Y=y.util.createBuffer(),G=$.length>>1,W=G+($.length&1),U=$.substr(0,W),M=$.substr(G,W),O=y.util.createBuffer(),V=y.hmac.create();X=J+X;var H=Math.ceil(Q/16),q=Math.ceil(Q/20);V.start("MD5",U);var F=y.util.createBuffer();O.putBytes(X);for(var K=0;K<H;++K)V.start(null,null),V.update(O.getBytes()),O.putBuffer(V.digest()),V.start(null,null),V.update(O.bytes()+X),F.putBuffer(V.digest());V.start("SHA1",M);var A=y.util.createBuffer();O.clear(),O.putBytes(X);for(var K=0;K<q;++K)V.start(null,null),V.update(O.getBytes()),O.putBuffer(V.digest()),V.start(null,null),V.update(O.bytes()+X),A.putBuffer(V.digest());return Y.putBytes(y.util.xorBytes(F.getBytes(),A.getBytes(),Q)),Y},bV=function($,J,X){var Q=y.hmac.create();Q.start("SHA1",$);var Y=y.util.createBuffer();return Y.putInt32(J[0]),Y.putInt32(J[1]),Y.putByte(X.type),Y.putByte(X.version.major),Y.putByte(X.version.minor),Y.putInt16(X.length),Y.putBytes(X.fragment.bytes()),Q.update(Y.getBytes()),Q.digest().getBytes()},hV=function($,J,X){var Q=!1;try{var Y=$.deflate(J.fragment.getBytes());J.fragment=y.util.createBuffer(Y),J.length=Y.length,Q=!0}catch(G){}return Q},uV=function($,J,X){var Q=!1;try{var Y=$.inflate(J.fragment.getBytes());J.fragment=y.util.createBuffer(Y),J.length=Y.length,Q=!0}catch(G){}return Q},SJ=function($,J){var X=0;switch(J){case 1:X=$.getByte();break;case 2:X=$.getInt16();break;case 3:X=$.getInt24();break;case 4:X=$.getInt32();break}return y.util.createBuffer($.getBytes(X))},fJ=function($,J,X){$.putInt(X.length(),J<<3),$.putBuffer(X)},N={};N.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};N.SupportedVersions=[N.Versions.TLS_1_1,N.Versions.TLS_1_0];N.Version=N.SupportedVersions[0];N.MaxFragment=15360;N.ConnectionEnd={server:0,client:1};N.PRFAlgorithm={tls_prf_sha256:0};N.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};N.CipherType={stream:0,block:1,aead:2};N.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};N.CompressionMethod={none:0,deflate:1};N.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};N.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20};N.Alert={};N.Alert.Level={warning:1,fatal:2};N.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};N.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};N.CipherSuites={};N.getCipherSuite=function($){var J=null;for(var X in N.CipherSuites){var Q=N.CipherSuites[X];if(Q.id[0]===$.charCodeAt(0)&&Q.id[1]===$.charCodeAt(1)){J=Q;break}}return J};N.handleUnexpected=function($,J){var X=!$.open&&$.entity===N.ConnectionEnd.client;if(!X)$.error($,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unexpected_message}})};N.handleHelloRequest=function($,J,X){if(!$.handshaking&&$.handshakes>0)N.queue($,N.createAlert($,{level:N.Alert.Level.warning,description:N.Alert.Description.no_renegotiation})),N.flush($);$.process()};N.parseHelloMessage=function($,J,X){var Q=null,Y=$.entity===N.ConnectionEnd.client;if(X<38)$.error($,{message:Y?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});else{var G=J.fragment,W=G.length();if(Q={version:{major:G.getByte(),minor:G.getByte()},random:y.util.createBuffer(G.getBytes(32)),session_id:SJ(G,1),extensions:[]},Y)Q.cipher_suite=G.getBytes(2),Q.compression_method=G.getByte();else Q.cipher_suites=SJ(G,2),Q.compression_methods=SJ(G,1);if(W=X-(W-G.length()),W>0){var U=SJ(G,2);while(U.length()>0)Q.extensions.push({type:[U.getByte(),U.getByte()],data:SJ(U,2)});if(!Y)for(var M=0;M<Q.extensions.length;++M){var O=Q.extensions[M];if(O.type[0]===0&&O.type[1]===0){var V=SJ(O.data,2);while(V.length()>0){var H=V.getByte();if(H!==0)break;$.session.extensions.server_name.serverNameList.push(SJ(V,2).getBytes())}}}}if($.session.version){if(Q.version.major!==$.session.version.major||Q.version.minor!==$.session.version.minor)return $.error($,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}})}if(Y)$.session.cipherSuite=N.getCipherSuite(Q.cipher_suite);else{var q=y.util.createBuffer(Q.cipher_suites.bytes());while(q.length()>0)if($.session.cipherSuite=N.getCipherSuite(q.getBytes(2)),$.session.cipherSuite!==null)break}if($.session.cipherSuite===null)return $.error($,{message:"No cipher suites in common.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.handshake_failure},cipherSuite:y.util.bytesToHex(Q.cipher_suite)});if(Y)$.session.compressionMethod=Q.compression_method;else $.session.compressionMethod=N.CompressionMethod.none}return Q};N.createSecurityParameters=function($,J){var X=$.entity===N.ConnectionEnd.client,Q=J.random.bytes(),Y=X?$.session.sp.client_random:Q,G=X?Q:N.createRandom().getBytes();$.session.sp={entity:$.entity,prf_algorithm:N.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:$.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:Y,server_random:G}};N.handleServerHello=function($,J,X){var Q=N.parseHelloMessage($,J,X);if($.fail)return;if(Q.version.minor<=$.version.minor)$.version.minor=Q.version.minor;else return $.error($,{message:"Incompatible TLS version.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}});$.session.version=$.version;var Y=Q.session_id.bytes();if(Y.length>0&&Y===$.session.id)$.expect=g1,$.session.resuming=!0,$.session.sp.server_random=Q.random.bytes();else $.expect=mV,$.session.resuming=!1,N.createSecurityParameters($,Q);$.session.id=Y,$.process()};N.handleClientHello=function($,J,X){var Q=N.parseHelloMessage($,J,X);if($.fail)return;var Y=Q.session_id.bytes(),G=null;if($.sessionCache){if(G=$.sessionCache.getSession(Y),G===null)Y="";else if(G.version.major!==Q.version.major||G.version.minor>Q.version.minor)G=null,Y=""}if(Y.length===0)Y=y.random.getBytes(32);if($.session.id=Y,$.session.clientHelloVersion=Q.version,$.session.sp={},G)$.version=$.session.version=G.version,$.session.sp=G.sp;else{var W;for(var U=1;U<N.SupportedVersions.length;++U)if(W=N.SupportedVersions[U],W.minor<=Q.version.minor)break;$.version={major:W.major,minor:W.minor},$.session.version=$.version}if(G!==null)$.expect=I8,$.session.resuming=!0,$.session.sp.client_random=Q.random.bytes();else $.expect=$.verifyClient!==!1?oV:S8,$.session.resuming=!1,N.createSecurityParameters($,Q);if($.open=!0,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerHello($)})),$.session.resuming)N.queue($,N.createRecord($,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),$.state.pending=N.createConnectionState($),$.state.current.write=$.state.pending.write,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createFinished($)}));else if(N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificate($)})),!$.fail){if(N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerKeyExchange($)})),$.verifyClient!==!1)N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificateRequest($)}));N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createServerHelloDone($)}))}N.flush($),$.process()};N.handleCertificate=function($,J,X){if(X<3)return $.error($,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment,Y={certificate_list:SJ(Q,3)},G,W,U=[];try{while(Y.certificate_list.length()>0)G=SJ(Y.certificate_list,3),W=y.asn1.fromDer(G),G=y.pki.certificateFromAsn1(W,!0),U.push(G)}catch(O){return $.error($,{message:"Could not parse certificate list.",cause:O,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate}})}var M=$.entity===N.ConnectionEnd.client;if((M||$.verifyClient===!0)&&U.length===0)$.error($,{message:M?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});else if(U.length===0)$.expect=M?h1:S8;else{if(M)$.session.serverCertificate=U[0];else $.session.clientCertificate=U[0];if(N.verifyCertificateChain($,U))$.expect=M?h1:S8}$.process()};N.handleServerKeyExchange=function($,J,X){if(X>0)return $.error($,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unsupported_certificate}});$.expect=lV,$.process()};N.handleClientKeyExchange=function($,J,X){if(X<48)return $.error($,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unsupported_certificate}});var Q=J.fragment,Y={enc_pre_master_secret:SJ(Q,2).getBytes()},G=null;if($.getPrivateKey)try{G=$.getPrivateKey($,$.session.serverCertificate),G=y.pki.privateKeyFromPem(G)}catch(M){$.error($,{message:"Could not get private key.",cause:M,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}})}if(G===null)return $.error($,{message:"No private key set.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});try{var W=$.session.sp;W.pre_master_secret=G.decrypt(Y.enc_pre_master_secret);var U=$.session.clientHelloVersion;if(U.major!==W.pre_master_secret.charCodeAt(0)||U.minor!==W.pre_master_secret.charCodeAt(1))throw Error("TLS version rollback attack detected.")}catch(M){W.pre_master_secret=y.random.getBytes(48)}if($.expect=I8,$.session.clientCertificate!==null)$.expect=aV;$.process()};N.handleCertificateRequest=function($,J,X){if(X<3)return $.error($,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment,Y={certificate_types:SJ(Q,1),certificate_authorities:SJ(Q,2)};$.session.certificateRequest=Y,$.expect=pV,$.process()};N.handleCertificateVerify=function($,J,X){if(X<2)return $.error($,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var Q=J.fragment;Q.read-=4;var Y=Q.bytes();Q.read+=4;var G={signature:SJ(Q,2).getBytes()},W=y.util.createBuffer();W.putBuffer($.session.md5.digest()),W.putBuffer($.session.sha1.digest()),W=W.getBytes();try{var U=$.session.clientCertificate;if(!U.publicKey.verify(W,G.signature,"NONE"))throw Error("CertificateVerify signature does not match.");$.session.md5.update(Y),$.session.sha1.update(Y)}catch(M){return $.error($,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.handshake_failure}})}$.expect=I8,$.process()};N.handleServerHelloDone=function($,J,X){if(X>0)return $.error($,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.record_overflow}});if($.serverCertificate===null){var Q={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.insufficient_security}},Y=0,G=$.verify($,Q.alert.description,Y,[]);if(G!==!0){if(G||G===0){if(typeof G==="object"&&!y.util.isArray(G)){if(G.message)Q.message=G.message;if(G.alert)Q.alert.description=G.alert}else if(typeof G==="number")Q.alert.description=G}return $.error($,Q)}}if($.session.certificateRequest!==null)J=N.createRecord($,{type:N.ContentType.handshake,data:N.createCertificate($)}),N.queue($,J);J=N.createRecord($,{type:N.ContentType.handshake,data:N.createClientKeyExchange($)}),N.queue($,J),$.expect=nV;var W=function(U,M){if(U.session.certificateRequest!==null&&U.session.clientCertificate!==null)N.queue(U,N.createRecord(U,{type:N.ContentType.handshake,data:N.createCertificateVerify(U,M)}));N.queue(U,N.createRecord(U,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),U.state.pending=N.createConnectionState(U),U.state.current.write=U.state.pending.write,N.queue(U,N.createRecord(U,{type:N.ContentType.handshake,data:N.createFinished(U)})),U.expect=g1,N.flush(U),U.process()};if($.session.certificateRequest===null||$.session.clientCertificate===null)return W($,null);N.getClientSignature($,W)};N.handleChangeCipherSpec=function($,J){if(J.fragment.getByte()!==1)return $.error($,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.illegal_parameter}});var X=$.entity===N.ConnectionEnd.client;if($.session.resuming&&X||!$.session.resuming&&!X)$.state.pending=N.createConnectionState($);if($.state.current.read=$.state.pending.read,!$.session.resuming&&X||$.session.resuming&&!X)$.state.pending=null;$.expect=X?dV:sV,$.process()};N.handleFinished=function($,J,X){var Q=J.fragment;Q.read-=4;var Y=Q.bytes();Q.read+=4;var G=J.fragment.getBytes();Q=y.util.createBuffer(),Q.putBuffer($.session.md5.digest()),Q.putBuffer($.session.sha1.digest());var W=$.entity===N.ConnectionEnd.client,U=W?"server finished":"client finished",M=$.session.sp,O=12,V=uY;if(Q=V(M.master_secret,U,Q.getBytes(),O),Q.getBytes()!==G)return $.error($,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.decrypt_error}});if($.session.md5.update(Y),$.session.sha1.update(Y),$.session.resuming&&W||!$.session.resuming&&!W)N.queue($,N.createRecord($,{type:N.ContentType.change_cipher_spec,data:N.createChangeCipherSpec()})),$.state.current.write=$.state.pending.write,$.state.pending=null,N.queue($,N.createRecord($,{type:N.ContentType.handshake,data:N.createFinished($)}));$.expect=W?cV:rV,$.handshaking=!1,++$.handshakes,$.peerCertificate=W?$.session.serverCertificate:$.session.clientCertificate,N.flush($),$.isConnected=!0,$.connected($),$.process()};N.handleAlert=function($,J){var X=J.fragment,Q={level:X.getByte(),description:X.getByte()},Y;switch(Q.description){case N.Alert.Description.close_notify:Y="Connection closed.";break;case N.Alert.Description.unexpected_message:Y="Unexpected message.";break;case N.Alert.Description.bad_record_mac:Y="Bad record MAC.";break;case N.Alert.Description.decryption_failed:Y="Decryption failed.";break;case N.Alert.Description.record_overflow:Y="Record overflow.";break;case N.Alert.Description.decompression_failure:Y="Decompression failed.";break;case N.Alert.Description.handshake_failure:Y="Handshake failure.";break;case N.Alert.Description.bad_certificate:Y="Bad certificate.";break;case N.Alert.Description.unsupported_certificate:Y="Unsupported certificate.";break;case N.Alert.Description.certificate_revoked:Y="Certificate revoked.";break;case N.Alert.Description.certificate_expired:Y="Certificate expired.";break;case N.Alert.Description.certificate_unknown:Y="Certificate unknown.";break;case N.Alert.Description.illegal_parameter:Y="Illegal parameter.";break;case N.Alert.Description.unknown_ca:Y="Unknown certificate authority.";break;case N.Alert.Description.access_denied:Y="Access denied.";break;case N.Alert.Description.decode_error:Y="Decode error.";break;case N.Alert.Description.decrypt_error:Y="Decrypt error.";break;case N.Alert.Description.export_restriction:Y="Export restriction.";break;case N.Alert.Description.protocol_version:Y="Unsupported protocol version.";break;case N.Alert.Description.insufficient_security:Y="Insufficient security.";break;case N.Alert.Description.internal_error:Y="Internal error.";break;case N.Alert.Description.user_canceled:Y="User canceled.";break;case N.Alert.Description.no_renegotiation:Y="Renegotiation not supported.";break;default:Y="Unknown error.";break}if(Q.description===N.Alert.Description.close_notify)return $.close();$.error($,{message:Y,send:!1,origin:$.entity===N.ConnectionEnd.client?"server":"client",alert:Q}),$.process()};N.handleHandshake=function($,J){var X=J.fragment,Q=X.getByte(),Y=X.getInt24();if(Y>X.length())return $.fragmented=J,J.fragment=y.util.createBuffer(),X.read-=4,$.process();$.fragmented=null,X.read-=4;var G=X.bytes(Y+4);if(X.read+=4,Q in hY[$.entity][$.expect]){if($.entity===N.ConnectionEnd.server&&!$.open&&!$.fail)$.handshaking=!0,$.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:y.md.md5.create(),sha1:y.md.sha1.create()};if(Q!==N.HandshakeType.hello_request&&Q!==N.HandshakeType.certificate_verify&&Q!==N.HandshakeType.finished)$.session.md5.update(G),$.session.sha1.update(G);hY[$.entity][$.expect][Q]($,J,Y)}else N.handleUnexpected($,J)};N.handleApplicationData=function($,J){$.data.putBuffer(J.fragment),$.dataReady($),$.process()};N.handleHeartbeat=function($,J){var X=J.fragment,Q=X.getByte(),Y=X.getInt16(),G=X.getBytes(Y);if(Q===N.HeartbeatMessageType.heartbeat_request){if($.handshaking||Y>G.length)return $.process();N.queue($,N.createRecord($,{type:N.ContentType.heartbeat,data:N.createHeartbeat(N.HeartbeatMessageType.heartbeat_response,G)})),N.flush($)}else if(Q===N.HeartbeatMessageType.heartbeat_response){if(G!==$.expectedHeartbeatPayload)return $.process();if($.heartbeatReceived)$.heartbeatReceived($,y.util.createBuffer(G))}$.process()};var gV=0,mV=1,h1=2,lV=3,pV=4,g1=5,dV=6,cV=7,nV=8,iV=0,oV=1,S8=2,aV=3,I8=4,sV=5,rV=6,E=N.handleUnexpected,m1=N.handleChangeCipherSpec,qJ=N.handleAlert,RJ=N.handleHandshake,l1=N.handleApplicationData,KJ=N.handleHeartbeat,C8=[];C8[N.ConnectionEnd.client]=[[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[m1,qJ,E,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,l1,KJ],[E,qJ,RJ,E,KJ]];C8[N.ConnectionEnd.server]=[[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,E,KJ],[m1,qJ,E,E,KJ],[E,qJ,RJ,E,KJ],[E,qJ,RJ,l1,KJ],[E,qJ,RJ,E,KJ]];var{handleHelloRequest:f0,handleServerHello:tV,handleCertificate:p1,handleServerKeyExchange:u1,handleCertificateRequest:j8,handleServerHelloDone:bY,handleFinished:d1}=N,hY=[];hY[N.ConnectionEnd.client]=[[E,E,tV,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,p1,u1,j8,bY,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,u1,j8,bY,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,E,j8,bY,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,E,E,bY,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,d1],[f0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[f0,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];var{handleClientHello:eV,handleClientKeyExchange:$H,handleCertificateVerify:JH}=N;hY[N.ConnectionEnd.server]=[[E,eV,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,p1,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,$H,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,JH,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,d1],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];N.generateKeys=function($,J){var X=uY,Q=J.client_random+J.server_random;if(!$.session.resuming)J.master_secret=X(J.pre_master_secret,"master secret",Q,48).bytes(),J.pre_master_secret=null;Q=J.server_random+J.client_random;var Y=2*J.mac_key_length+2*J.enc_key_length,G=$.version.major===N.Versions.TLS_1_0.major&&$.version.minor===N.Versions.TLS_1_0.minor;if(G)Y+=2*J.fixed_iv_length;var W=X(J.master_secret,"key expansion",Q,Y),U={client_write_MAC_key:W.getBytes(J.mac_key_length),server_write_MAC_key:W.getBytes(J.mac_key_length),client_write_key:W.getBytes(J.enc_key_length),server_write_key:W.getBytes(J.enc_key_length)};if(G)U.client_write_IV=W.getBytes(J.fixed_iv_length),U.server_write_IV=W.getBytes(J.fixed_iv_length);return U};N.createConnectionState=function($){var J=$.entity===N.ConnectionEnd.client,X=function(){var G={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(W){return!0},compressionState:null,compressFunction:function(W){return!0},updateSequenceNumber:function(){if(G.sequenceNumber[1]===4294967295)G.sequenceNumber[1]=0,++G.sequenceNumber[0];else++G.sequenceNumber[1]}};return G},Q={read:X(),write:X()};if(Q.read.update=function(G,W){if(!Q.read.cipherFunction(W,Q.read))G.error(G,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_record_mac}});else if(!Q.read.compressFunction(G,W,Q.read))G.error(G,{message:"Could not decompress record.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.decompression_failure}});return!G.fail},Q.write.update=function(G,W){if(!Q.write.compressFunction(G,W,Q.write))G.error(G,{message:"Could not compress record.",send:!1,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});else if(!Q.write.cipherFunction(W,Q.write))G.error(G,{message:"Could not encrypt record.",send:!1,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});return!G.fail},$.session){var Y=$.session.sp;switch($.session.cipherSuite.initSecurityParameters(Y),Y.keys=N.generateKeys($,Y),Q.read.macKey=J?Y.keys.server_write_MAC_key:Y.keys.client_write_MAC_key,Q.write.macKey=J?Y.keys.client_write_MAC_key:Y.keys.server_write_MAC_key,$.session.cipherSuite.initConnectionState(Q,$,Y),Y.compression_algorithm){case N.CompressionMethod.none:break;case N.CompressionMethod.deflate:Q.read.compressFunction=uV,Q.write.compressFunction=hV;break;default:throw Error("Unsupported compression algorithm.")}}return Q};N.createRandom=function(){var $=new Date,J=+$+$.getTimezoneOffset()*60000,X=y.util.createBuffer();return X.putInt32(J),X.putBytes(y.random.getBytes(28)),X};N.createRecord=function($,J){if(!J.data)return null;var X={type:J.type,version:{major:$.version.major,minor:$.version.minor},length:J.data.length(),fragment:J.data};return X};N.createAlert=function($,J){var X=y.util.createBuffer();return X.putByte(J.level),X.putByte(J.description),N.createRecord($,{type:N.ContentType.alert,data:X})};N.createClientHello=function($){$.session.clientHelloVersion={major:$.version.major,minor:$.version.minor};var J=y.util.createBuffer();for(var X=0;X<$.cipherSuites.length;++X){var Q=$.cipherSuites[X];J.putByte(Q.id[0]),J.putByte(Q.id[1])}var Y=J.length(),G=y.util.createBuffer();G.putByte(N.CompressionMethod.none);var W=G.length(),U=y.util.createBuffer();if($.virtualHost){var M=y.util.createBuffer();M.putByte(0),M.putByte(0);var O=y.util.createBuffer();O.putByte(0),fJ(O,2,y.util.createBuffer($.virtualHost));var V=y.util.createBuffer();fJ(V,2,O),fJ(M,2,V),U.putBuffer(M)}var H=U.length();if(H>0)H+=2;var q=$.session.id,F=q.length+1+2+4+28+2+Y+1+W+H,K=y.util.createBuffer();if(K.putByte(N.HandshakeType.client_hello),K.putInt24(F),K.putByte($.version.major),K.putByte($.version.minor),K.putBytes($.session.sp.client_random),fJ(K,1,y.util.createBuffer(q)),fJ(K,2,J),fJ(K,1,G),H>0)fJ(K,2,U);return K};N.createServerHello=function($){var J=$.session.id,X=J.length+1+2+4+28+2+1,Q=y.util.createBuffer();return Q.putByte(N.HandshakeType.server_hello),Q.putInt24(X),Q.putByte($.version.major),Q.putByte($.version.minor),Q.putBytes($.session.sp.server_random),fJ(Q,1,y.util.createBuffer(J)),Q.putByte($.session.cipherSuite.id[0]),Q.putByte($.session.cipherSuite.id[1]),Q.putByte($.session.compressionMethod),Q};N.createCertificate=function($){var J=$.entity===N.ConnectionEnd.client,X=null;if($.getCertificate){var Q;if(J)Q=$.session.certificateRequest;else Q=$.session.extensions.server_name.serverNameList;X=$.getCertificate($,Q)}var Y=y.util.createBuffer();if(X!==null)try{if(!y.util.isArray(X))X=[X];var G=null;for(var W=0;W<X.length;++W){var U=y.pem.decode(X[W])[0];if(U.type!=="CERTIFICATE"&&U.type!=="X509 CERTIFICATE"&&U.type!=="TRUSTED CERTIFICATE"){var M=Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw M.headerType=U.type,M}if(U.procType&&U.procType.type==="ENCRYPTED")throw Error("Could not convert certificate from PEM; PEM is encrypted.");var O=y.util.createBuffer(U.body);if(G===null)G=y.asn1.fromDer(O.bytes(),!1);var V=y.util.createBuffer();fJ(V,3,O),Y.putBuffer(V)}if(X=y.pki.certificateFromAsn1(G),J)$.session.clientCertificate=X;else $.session.serverCertificate=X}catch(F){return $.error($,{message:"Could not send certificate list.",cause:F,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate}})}var H=3+Y.length(),q=y.util.createBuffer();return q.putByte(N.HandshakeType.certificate),q.putInt24(H),fJ(q,3,Y),q};N.createClientKeyExchange=function($){var J=y.util.createBuffer();J.putByte($.session.clientHelloVersion.major),J.putByte($.session.clientHelloVersion.minor),J.putBytes(y.random.getBytes(46));var X=$.session.sp;X.pre_master_secret=J.getBytes();var Q=$.session.serverCertificate.publicKey;J=Q.encrypt(X.pre_master_secret);var Y=J.length+2,G=y.util.createBuffer();return G.putByte(N.HandshakeType.client_key_exchange),G.putInt24(Y),G.putInt16(J.length),G.putBytes(J),G};N.createServerKeyExchange=function($){var J=0,X=y.util.createBuffer();if(J>0)X.putByte(N.HandshakeType.server_key_exchange),X.putInt24(J);return X};N.getClientSignature=function($,J){var X=y.util.createBuffer();X.putBuffer($.session.md5.digest()),X.putBuffer($.session.sha1.digest()),X=X.getBytes(),$.getSignature=$.getSignature||function(Q,Y,G){var W=null;if(Q.getPrivateKey)try{W=Q.getPrivateKey(Q,Q.session.clientCertificate),W=y.pki.privateKeyFromPem(W)}catch(U){Q.error(Q,{message:"Could not get private key.",cause:U,send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}})}if(W===null)Q.error(Q,{message:"No private key set.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.internal_error}});else Y=W.sign(Y,null);G(Q,Y)},$.getSignature($,X,J)};N.createCertificateVerify=function($,J){var X=J.length+2,Q=y.util.createBuffer();return Q.putByte(N.HandshakeType.certificate_verify),Q.putInt24(X),Q.putInt16(J.length),Q.putBytes(J),Q};N.createCertificateRequest=function($){var J=y.util.createBuffer();J.putByte(1);var X=y.util.createBuffer();for(var Q in $.caStore.certs){var Y=$.caStore.certs[Q],G=y.pki.distinguishedNameToAsn1(Y.subject),W=y.asn1.toDer(G);X.putInt16(W.length()),X.putBuffer(W)}var U=1+J.length()+2+X.length(),M=y.util.createBuffer();return M.putByte(N.HandshakeType.certificate_request),M.putInt24(U),fJ(M,1,J),fJ(M,2,X),M};N.createServerHelloDone=function($){var J=y.util.createBuffer();return J.putByte(N.HandshakeType.server_hello_done),J.putInt24(0),J};N.createChangeCipherSpec=function(){var $=y.util.createBuffer();return $.putByte(1),$};N.createFinished=function($){var J=y.util.createBuffer();J.putBuffer($.session.md5.digest()),J.putBuffer($.session.sha1.digest());var X=$.entity===N.ConnectionEnd.client,Q=$.session.sp,Y=12,G=uY,W=X?"client finished":"server finished";J=G(Q.master_secret,W,J.getBytes(),Y);var U=y.util.createBuffer();return U.putByte(N.HandshakeType.finished),U.putInt24(J.length()),U.putBuffer(J),U};N.createHeartbeat=function($,J,X){if(typeof X>"u")X=J.length;var Q=y.util.createBuffer();Q.putByte($),Q.putInt16(X),Q.putBytes(J);var Y=Q.length(),G=Math.max(16,Y-X-3);return Q.putBytes(y.random.getBytes(G)),Q};N.queue=function($,J){if(!J)return;if(J.fragment.length()===0){if(J.type===N.ContentType.handshake||J.type===N.ContentType.alert||J.type===N.ContentType.change_cipher_spec)return}if(J.type===N.ContentType.handshake){var X=J.fragment.bytes();$.session.md5.update(X),$.session.sha1.update(X),X=null}var Q;if(J.fragment.length()<=N.MaxFragment)Q=[J];else{Q=[];var Y=J.fragment.bytes();while(Y.length>N.MaxFragment)Q.push(N.createRecord($,{type:J.type,data:y.util.createBuffer(Y.slice(0,N.MaxFragment))})),Y=Y.slice(N.MaxFragment);if(Y.length>0)Q.push(N.createRecord($,{type:J.type,data:y.util.createBuffer(Y)}))}for(var G=0;G<Q.length&&!$.fail;++G){var W=Q[G],U=$.state.current.write;if(U.update($,W))$.records.push(W)}};N.flush=function($){for(var J=0;J<$.records.length;++J){var X=$.records[J];$.tlsData.putByte(X.type),$.tlsData.putByte(X.version.major),$.tlsData.putByte(X.version.minor),$.tlsData.putInt16(X.fragment.length()),$.tlsData.putBuffer($.records[J].fragment)}return $.records=[],$.tlsDataReady($)};var T8=function($){switch($){case!0:return!0;case y.pki.certificateError.bad_certificate:return N.Alert.Description.bad_certificate;case y.pki.certificateError.unsupported_certificate:return N.Alert.Description.unsupported_certificate;case y.pki.certificateError.certificate_revoked:return N.Alert.Description.certificate_revoked;case y.pki.certificateError.certificate_expired:return N.Alert.Description.certificate_expired;case y.pki.certificateError.certificate_unknown:return N.Alert.Description.certificate_unknown;case y.pki.certificateError.unknown_ca:return N.Alert.Description.unknown_ca;default:return N.Alert.Description.bad_certificate}},QH=function($){switch($){case!0:return!0;case N.Alert.Description.bad_certificate:return y.pki.certificateError.bad_certificate;case N.Alert.Description.unsupported_certificate:return y.pki.certificateError.unsupported_certificate;case N.Alert.Description.certificate_revoked:return y.pki.certificateError.certificate_revoked;case N.Alert.Description.certificate_expired:return y.pki.certificateError.certificate_expired;case N.Alert.Description.certificate_unknown:return y.pki.certificateError.certificate_unknown;case N.Alert.Description.unknown_ca:return y.pki.certificateError.unknown_ca;default:return y.pki.certificateError.bad_certificate}};N.verifyCertificateChain=function($,J){try{var X={};for(var Q in $.verifyOptions)X[Q]=$.verifyOptions[Q];X.verify=function(G,W,U){var M=T8(G),O=$.verify($,G,W,U);if(O!==!0){if(typeof O==="object"&&!y.util.isArray(O)){var V=Error("The application rejected the certificate.");if(V.send=!0,V.alert={level:N.Alert.Level.fatal,description:N.Alert.Description.bad_certificate},O.message)V.message=O.message;if(O.alert)V.alert.description=O.alert;throw V}if(O!==G)O=QH(O)}return O},y.pki.verifyCertificateChain($.caStore,J,X)}catch(G){var Y=G;if(typeof Y!=="object"||y.util.isArray(Y))Y={send:!0,alert:{level:N.Alert.Level.fatal,description:T8(G)}};if(!("send"in Y))Y.send=!0;if(!("alert"in Y))Y.alert={level:N.Alert.Level.fatal,description:T8(Y.error)};$.error($,Y)}return!$.fail};N.createSessionCache=function($,J){var X=null;if($&&$.getSession&&$.setSession&&$.order)X=$;else{X={},X.cache=$||{},X.capacity=Math.max(J||100,1),X.order=[];for(var Q in $)if(X.order.length<=J)X.order.push(Q);else delete $[Q];X.getSession=function(Y){var G=null,W=null;if(Y)W=y.util.bytesToHex(Y);else if(X.order.length>0)W=X.order[0];if(W!==null&&W in X.cache){G=X.cache[W],delete X.cache[W];for(var U in X.order)if(X.order[U]===W){X.order.splice(U,1);break}}return G},X.setSession=function(Y,G){if(X.order.length===X.capacity){var W=X.order.shift();delete X.cache[W]}var W=y.util.bytesToHex(Y);X.order.push(W),X.cache[W]=G}}return X};N.createConnection=function($){var J=null;if($.caStore)if(y.util.isArray($.caStore))J=y.pki.createCaStore($.caStore);else J=$.caStore;else J=y.pki.createCaStore();var X=$.cipherSuites||null;if(X===null){X=[];for(var Q in N.CipherSuites)X.push(N.CipherSuites[Q])}var Y=$.server?N.ConnectionEnd.server:N.ConnectionEnd.client,G=$.sessionCache?N.createSessionCache($.sessionCache):null,W={version:{major:N.Version.major,minor:N.Version.minor},entity:Y,sessionId:$.sessionId,caStore:J,sessionCache:G,cipherSuites:X,connected:$.connected,virtualHost:$.virtualHost||null,verifyClient:$.verifyClient||!1,verify:$.verify||function(V,H,q,F){return H},verifyOptions:$.verifyOptions||{},getCertificate:$.getCertificate||null,getPrivateKey:$.getPrivateKey||null,getSignature:$.getSignature||null,input:y.util.createBuffer(),tlsData:y.util.createBuffer(),data:y.util.createBuffer(),tlsDataReady:$.tlsDataReady,dataReady:$.dataReady,heartbeatReceived:$.heartbeatReceived,closed:$.closed,error:function(V,H){if(H.origin=H.origin||(V.entity===N.ConnectionEnd.client?"client":"server"),H.send)N.queue(V,N.createAlert(V,H.alert)),N.flush(V);var q=H.fatal!==!1;if(q)V.fail=!0;if($.error(V,H),q)V.close(!1)},deflate:$.deflate||null,inflate:$.inflate||null};W.reset=function(V){W.version={major:N.Version.major,minor:N.Version.minor},W.record=null,W.session=null,W.peerCertificate=null,W.state={pending:null,current:null},W.expect=W.entity===N.ConnectionEnd.client?gV:iV,W.fragmented=null,W.records=[],W.open=!1,W.handshakes=0,W.handshaking=!1,W.isConnected=!1,W.fail=!(V||typeof V>"u"),W.input.clear(),W.tlsData.clear(),W.data.clear(),W.state.current=N.createConnectionState(W)},W.reset();var U=function(V,H){var q=H.type-N.ContentType.change_cipher_spec,F=C8[V.entity][V.expect];if(q in F)F[q](V,H);else N.handleUnexpected(V,H)},M=function(V){var H=0,q=V.input,F=q.length();if(F<5)H=5-F;else{V.record={type:q.getByte(),version:{major:q.getByte(),minor:q.getByte()},length:q.getInt16(),fragment:y.util.createBuffer(),ready:!1};var K=V.record.version.major===V.version.major;if(K&&V.session&&V.session.version)K=V.record.version.minor===V.version.minor;if(!K)V.error(V,{message:"Incompatible TLS version.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.protocol_version}})}return H},O=function(V){var H=0,q=V.input,F=q.length();if(F<V.record.length)H=V.record.length-F;else{V.record.fragment.putBytes(q.getBytes(V.record.length)),q.compact();var K=V.state.current.read;if(K.update(V,V.record)){if(V.fragmented!==null)if(V.fragmented.type===V.record.type)V.fragmented.fragment.putBuffer(V.record.fragment),V.record=V.fragmented;else V.error(V,{message:"Invalid fragmented record.",send:!0,alert:{level:N.Alert.Level.fatal,description:N.Alert.Description.unexpected_message}});V.record.ready=!0}}return H};return W.handshake=function(V){if(W.entity!==N.ConnectionEnd.client)W.error(W,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(W.handshaking)W.error(W,{message:"Handshake already in progress.",fatal:!1});else{if(W.fail&&!W.open&&W.handshakes===0)W.fail=!1;W.handshaking=!0,V=V||"";var H=null;if(V.length>0){if(W.sessionCache)H=W.sessionCache.getSession(V);if(H===null)V=""}if(V.length===0&&W.sessionCache){if(H=W.sessionCache.getSession(),H!==null)V=H.id}if(W.session={id:V,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:y.md.md5.create(),sha1:y.md.sha1.create()},H)W.version=H.version,W.session.sp=H.sp;W.session.sp.client_random=N.createRandom().getBytes(),W.open=!0,N.queue(W,N.createRecord(W,{type:N.ContentType.handshake,data:N.createClientHello(W)})),N.flush(W)}},W.process=function(V){var H=0;if(V)W.input.putBytes(V);if(!W.fail){if(W.record!==null&&W.record.ready&&W.record.fragment.isEmpty())W.record=null;if(W.record===null)H=M(W);if(!W.fail&&W.record!==null&&!W.record.ready)H=O(W);if(!W.fail&&W.record!==null&&W.record.ready)U(W,W.record)}return H},W.prepare=function(V){return N.queue(W,N.createRecord(W,{type:N.ContentType.application_data,data:y.util.createBuffer(V)})),N.flush(W)},W.prepareHeartbeatRequest=function(V,H){if(V instanceof y.util.ByteBuffer)V=V.bytes();if(typeof H>"u")H=V.length;return W.expectedHeartbeatPayload=V,N.queue(W,N.createRecord(W,{type:N.ContentType.heartbeat,data:N.createHeartbeat(N.HeartbeatMessageType.heartbeat_request,V,H)})),N.flush(W)},W.close=function(V){if(!W.fail&&W.sessionCache&&W.session){var H={id:W.session.id,version:W.session.version,sp:W.session.sp};H.sp.keys=null,W.sessionCache.setSession(H.id,H)}if(W.open){if(W.open=!1,W.input.clear(),W.isConnected||W.handshaking)W.isConnected=W.handshaking=!1,N.queue(W,N.createAlert(W,{level:N.Alert.Level.warning,description:N.Alert.Description.close_notify})),N.flush(W);W.closed(W)}W.reset(V)},W};c1.exports=y.tls=y.tls||{};for(TX in N)if(typeof N[TX]!=="function")y.tls[TX]=N[TX];var TX;y.tls.prf_tls1=uY;y.tls.hmac_sha1=bV;y.tls.createSessionCache=N.createSessionCache;y.tls.createConnection=N.createConnection});var o1=O$((IF,i1)=>{var y0=z$();w0();w8();var yJ=i1.exports=y0.tls;yJ.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function($){$.bulk_cipher_algorithm=yJ.BulkCipherAlgorithm.aes,$.cipher_type=yJ.CipherType.block,$.enc_key_length=16,$.block_length=16,$.fixed_iv_length=16,$.record_iv_length=16,$.mac_algorithm=yJ.MACAlgorithm.hmac_sha1,$.mac_length=20,$.mac_key_length=20},initConnectionState:n1};yJ.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function($){$.bulk_cipher_algorithm=yJ.BulkCipherAlgorithm.aes,$.cipher_type=yJ.CipherType.block,$.enc_key_length=32,$.block_length=16,$.fixed_iv_length=16,$.record_iv_length=16,$.mac_algorithm=yJ.MACAlgorithm.hmac_sha1,$.mac_length=20,$.mac_key_length=20},initConnectionState:n1};function n1($,J,X){var Q=J.entity===y0.tls.ConnectionEnd.client;$.read.cipherState={init:!1,cipher:y0.cipher.createDecipher("AES-CBC",Q?X.keys.server_write_key:X.keys.client_write_key),iv:Q?X.keys.server_write_IV:X.keys.client_write_IV},$.write.cipherState={init:!1,cipher:y0.cipher.createCipher("AES-CBC",Q?X.keys.client_write_key:X.keys.server_write_key),iv:Q?X.keys.client_write_IV:X.keys.server_write_IV},$.read.cipherFunction=WH,$.write.cipherFunction=XH,$.read.macLength=$.write.macLength=X.mac_length,$.read.macFunction=$.write.macFunction=yJ.hmac_sha1}function XH($,J){var X=!1,Q=J.macFunction(J.macKey,J.sequenceNumber,$);$.fragment.putBytes(Q),J.updateSequenceNumber();var Y;if($.version.minor===yJ.Versions.TLS_1_0.minor)Y=J.cipherState.init?null:J.cipherState.iv;else Y=y0.random.getBytesSync(16);J.cipherState.init=!0;var G=J.cipherState.cipher;if(G.start({iv:Y}),$.version.minor>=yJ.Versions.TLS_1_1.minor)G.output.putBytes(Y);if(G.update($.fragment),G.finish(YH))$.fragment=G.output,$.length=$.fragment.length(),X=!0;return X}function YH($,J,X){if(!X){var Q=$-J.length()%$;J.fillWithByte(Q-1,Q)}return!0}function GH($,J,X){var Q=!0;if(X){var Y=J.length(),G=J.last();for(var W=Y-1-G;W<Y-1;++W)Q=Q&&J.at(W)==G;if(Q)J.truncate(G+1)}return Q}function WH($,J){var X=!1,Q;if($.version.minor===yJ.Versions.TLS_1_0.minor)Q=J.cipherState.init?null:J.cipherState.iv;else Q=$.fragment.getBytes(16);J.cipherState.init=!0;var Y=J.cipherState.cipher;Y.start({iv:Q}),Y.update($.fragment),X=Y.finish(GH);var G=J.macLength,W=y0.random.getBytesSync(G),U=Y.output.length();if(U>=G)$.fragment=Y.output.getBytes(U-G),W=Y.output.getBytes(G);else $.fragment=Y.output.getBytes();$.fragment=y0.util.createBuffer($.fragment),$.length=$.fragment.length();var M=J.macFunction(J.macKey,J.sequenceNumber,$);return J.updateSequenceNumber(),X=UH(J.macKey,W,M)&&X,X}function UH($,J,X){var Q=y0.hmac.create();return Q.start("SHA1",$),Q.update(J),J=Q.digest().getBytes(),Q.start(null,null),Q.update(X),X=Q.digest().getBytes(),J===X}});var x8=O$((CF,t1)=>{var d$=z$();eJ();w$();var SX=t1.exports=d$.sha512=d$.sha512||{};d$.md.sha512=d$.md.algorithms.sha512=SX;var s1=d$.sha384=d$.sha512.sha384=d$.sha512.sha384||{};s1.create=function(){return SX.create("SHA-384")};d$.md.sha384=d$.md.algorithms.sha384=s1;d$.sha512.sha256=d$.sha512.sha256||{create:function(){return SX.create("SHA-512/256")}};d$.md["sha512/256"]=d$.md.algorithms["sha512/256"]=d$.sha512.sha256;d$.sha512.sha224=d$.sha512.sha224||{create:function(){return SX.create("SHA-512/224")}};d$.md["sha512/224"]=d$.md.algorithms["sha512/224"]=d$.sha512.sha224;SX.create=function($){if(!r1)MH();if(typeof $>"u")$="SHA-512";if(!($ in UQ))throw Error("Invalid SHA-512 algorithm: "+$);var J=UQ[$],X=null,Q=d$.util.createBuffer(),Y=Array(80);for(var G=0;G<80;++G)Y[G]=[,,];var W=64;switch($){case"SHA-384":W=48;break;case"SHA-512/256":W=32;break;case"SHA-512/224":W=28;break}var U={algorithm:$.replace("-","").toLowerCase(),blockLength:128,digestLength:W,messageLength:0,fullMessageLength:null,messageLengthSize:16};return U.start=function(){U.messageLength=0,U.fullMessageLength=U.messageLength128=[];var M=U.messageLengthSize/4;for(var O=0;O<M;++O)U.fullMessageLength.push(0);Q=d$.util.createBuffer(),X=Array(J.length);for(var O=0;O<J.length;++O)X[O]=J[O].slice(0);return U},U.start(),U.update=function(M,O){if(O==="utf8")M=d$.util.encodeUtf8(M);var V=M.length;U.messageLength+=V,V=[V/4294967296>>>0,V>>>0];for(var H=U.fullMessageLength.length-1;H>=0;--H)U.fullMessageLength[H]+=V[1],V[1]=V[0]+(U.fullMessageLength[H]/4294967296>>>0),U.fullMessageLength[H]=U.fullMessageLength[H]>>>0,V[0]=V[1]/4294967296>>>0;if(Q.putBytes(M),a1(X,Y,Q),Q.read>2048||Q.length()===0)Q.compact();return U},U.digest=function(){var M=d$.util.createBuffer();M.putBytes(Q.bytes());var O=U.fullMessageLength[U.fullMessageLength.length-1]+U.messageLengthSize,V=O&U.blockLength-1;M.putBytes(P8.substr(0,U.blockLength-V));var H,q,F=U.fullMessageLength[0]*8;for(var K=0;K<U.fullMessageLength.length-1;++K)H=U.fullMessageLength[K+1]*8,q=H/4294967296>>>0,F+=q,M.putInt32(F>>>0),F=H>>>0;M.putInt32(F);var A=Array(X.length);for(var K=0;K<X.length;++K)A[K]=X[K].slice(0);a1(A,Y,M);var L=d$.util.createBuffer(),R;if($==="SHA-512")R=A.length;else if($==="SHA-384")R=A.length-2;else R=A.length-4;for(var K=0;K<R;++K)if(L.putInt32(A[K][0]),K!==R-1||$!=="SHA-512/224")L.putInt32(A[K][1]);return L},U};var P8=null,r1=!1,_8=null,UQ=null;function MH(){P8=String.fromCharCode(128),P8+=d$.util.fillString(String.fromCharCode(0),128),_8=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],UQ={},UQ["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],UQ["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],UQ["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],UQ["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],r1=!0}function a1($,J,X){var Q,Y,G,W,U,M,O,V,H,q,F,K,A,L,R,I,T,C,w,P,l,k,p,$$,N$,M$,b$,XJ,j$,U$,v,a,P$,E$,s,S$=X.length();while(S$>=128){for(j$=0;j$<16;++j$)J[j$][0]=X.getInt32()>>>0,J[j$][1]=X.getInt32()>>>0;for(;j$<80;++j$)a=J[j$-2],U$=a[0],v=a[1],Q=((U$>>>19|v<<13)^(v>>>29|U$<<3)^U$>>>6)>>>0,Y=((U$<<13|v>>>19)^(v<<3|U$>>>29)^(U$<<26|v>>>6))>>>0,E$=J[j$-15],U$=E$[0],v=E$[1],G=((U$>>>1|v<<31)^(U$>>>8|v<<24)^U$>>>7)>>>0,W=((U$<<31|v>>>1)^(U$<<24|v>>>8)^(U$<<25|v>>>7))>>>0,P$=J[j$-7],s=J[j$-16],v=Y+P$[1]+W+s[1],J[j$][0]=Q+P$[0]+G+s[0]+(v/4294967296>>>0)>>>0,J[j$][1]=v>>>0;A=$[0][0],L=$[0][1],R=$[1][0],I=$[1][1],T=$[2][0],C=$[2][1],w=$[3][0],P=$[3][1],l=$[4][0],k=$[4][1],p=$[5][0],$$=$[5][1],N$=$[6][0],M$=$[6][1],b$=$[7][0],XJ=$[7][1];for(j$=0;j$<80;++j$)O=((l>>>14|k<<18)^(l>>>18|k<<14)^(k>>>9|l<<23))>>>0,V=((l<<18|k>>>14)^(l<<14|k>>>18)^(k<<23|l>>>9))>>>0,H=(N$^l&(p^N$))>>>0,q=(M$^k&($$^M$))>>>0,U=((A>>>28|L<<4)^(L>>>2|A<<30)^(L>>>7|A<<25))>>>0,M=((A<<4|L>>>28)^(L<<30|A>>>2)^(L<<25|A>>>7))>>>0,F=(A&R|T&(A^R))>>>0,K=(L&I|C&(L^I))>>>0,v=XJ+V+q+_8[j$][1]+J[j$][1],Q=b$+O+H+_8[j$][0]+J[j$][0]+(v/4294967296>>>0)>>>0,Y=v>>>0,v=M+K,G=U+F+(v/4294967296>>>0)>>>0,W=v>>>0,b$=N$,XJ=M$,N$=p,M$=$$,p=l,$$=k,v=P+Y,l=w+Q+(v/4294967296>>>0)>>>0,k=v>>>0,w=T,P=C,T=R,C=I,R=A,I=L,v=Y+W,A=Q+G+(v/4294967296>>>0)>>>0,L=v>>>0;v=$[0][1]+L,$[0][0]=$[0][0]+A+(v/4294967296>>>0)>>>0,$[0][1]=v>>>0,v=$[1][1]+I,$[1][0]=$[1][0]+R+(v/4294967296>>>0)>>>0,$[1][1]=v>>>0,v=$[2][1]+C,$[2][0]=$[2][0]+T+(v/4294967296>>>0)>>>0,$[2][1]=v>>>0,v=$[3][1]+P,$[3][0]=$[3][0]+w+(v/4294967296>>>0)>>>0,$[3][1]=v>>>0,v=$[4][1]+k,$[4][0]=$[4][0]+l+(v/4294967296>>>0)>>>0,$[4][1]=v>>>0,v=$[5][1]+$$,$[5][0]=$[5][0]+p+(v/4294967296>>>0)>>>0,$[5][1]=v>>>0,v=$[6][1]+M$,$[6][0]=$[6][0]+N$+(v/4294967296>>>0)>>>0,$[6][1]=v>>>0,v=$[7][1]+XJ,$[7][0]=$[7][0]+b$+(v/4294967296>>>0)>>>0,$[7][1]=v>>>0,S$-=128}}});var e1=O$((VH)=>{var OH=z$();mJ();var HJ=OH.asn1;VH.privateKeyValidator={name:"PrivateKeyInfo",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]};VH.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:HJ.Class.UNIVERSAL,type:HJ.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}});var HW=O$((PF,VW)=>{var zJ=z$();DX();_J();x8();w$();var YW=e1(),KH=YW.publicKeyValidator,zH=YW.privateKeyValidator;if(typeof k8>"u")k8=zJ.jsbn.BigInteger;var k8,f8=zJ.util.ByteBuffer,BJ=typeof Buffer>"u"?Uint8Array:Buffer;zJ.pki=zJ.pki||{};VW.exports=zJ.pki.ed25519=zJ.ed25519=zJ.ed25519||{};var D$=zJ.ed25519;D$.constants={};D$.constants.PUBLIC_KEY_BYTE_LENGTH=32;D$.constants.PRIVATE_KEY_BYTE_LENGTH=64;D$.constants.SEED_BYTE_LENGTH=32;D$.constants.SIGN_BYTE_LENGTH=64;D$.constants.HASH_BYTE_LENGTH=64;D$.generateKeyPair=function($){$=$||{};var J=$.seed;if(J===void 0)J=zJ.random.getBytesSync(D$.constants.SEED_BYTE_LENGTH);else if(typeof J==="string"){if(J.length!==D$.constants.SEED_BYTE_LENGTH)throw TypeError('"seed" must be '+D$.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(J instanceof Uint8Array))throw TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');J=A0({message:J,encoding:"binary"});var X=new BJ(D$.constants.PUBLIC_KEY_BYTE_LENGTH),Q=new BJ(D$.constants.PRIVATE_KEY_BYTE_LENGTH);for(var Y=0;Y<32;++Y)Q[Y]=J[Y];return LH(X,Q),{publicKey:X,privateKey:Q}};D$.privateKeyFromAsn1=function($){var J={},X=[],Q=zJ.asn1.validate($,zH,J,X);if(!Q){var Y=Error("Invalid Key.");throw Y.errors=X,Y}var G=zJ.asn1.derToOid(J.privateKeyOid),W=zJ.oids.EdDSA25519;if(G!==W)throw Error('Invalid OID "'+G+'"; OID must be "'+W+'".');var U=J.privateKey,M=A0({message:zJ.asn1.fromDer(U).value,encoding:"binary"});return{privateKeyBytes:M}};D$.publicKeyFromAsn1=function($){var J={},X=[],Q=zJ.asn1.validate($,KH,J,X);if(!Q){var Y=Error("Invalid Key.");throw Y.errors=X,Y}var G=zJ.asn1.derToOid(J.publicKeyOid),W=zJ.oids.EdDSA25519;if(G!==W)throw Error('Invalid OID "'+G+'"; OID must be "'+W+'".');var U=J.ed25519PublicKey;if(U.length!==D$.constants.PUBLIC_KEY_BYTE_LENGTH)throw Error("Key length is invalid.");return A0({message:U,encoding:"binary"})};D$.publicKeyFromPrivateKey=function($){$=$||{};var J=A0({message:$.privateKey,encoding:"binary"});if(J.length!==D$.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError('"options.privateKey" must have a byte length of '+D$.constants.PRIVATE_KEY_BYTE_LENGTH);var X=new BJ(D$.constants.PUBLIC_KEY_BYTE_LENGTH);for(var Q=0;Q<X.length;++Q)X[Q]=J[32+Q];return X};D$.sign=function($){$=$||{};var J=A0($),X=A0({message:$.privateKey,encoding:"binary"});if(X.length===D$.constants.SEED_BYTE_LENGTH){var Q=D$.generateKeyPair({seed:X});X=Q.privateKey}else if(X.length!==D$.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError('"options.privateKey" must have a byte length of '+D$.constants.SEED_BYTE_LENGTH+" or "+D$.constants.PRIVATE_KEY_BYTE_LENGTH);var Y=new BJ(D$.constants.SIGN_BYTE_LENGTH+J.length);AH(Y,J,J.length,X);var G=new BJ(D$.constants.SIGN_BYTE_LENGTH);for(var W=0;W<G.length;++W)G[W]=Y[W];return G};D$.verify=function($){$=$||{};var J=A0($);if($.signature===void 0)throw TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var X=A0({message:$.signature,encoding:"binary"});if(X.length!==D$.constants.SIGN_BYTE_LENGTH)throw TypeError('"options.signature" must have a byte length of '+D$.constants.SIGN_BYTE_LENGTH);var Q=A0({message:$.publicKey,encoding:"binary"});if(Q.length!==D$.constants.PUBLIC_KEY_BYTE_LENGTH)throw TypeError('"options.publicKey" must have a byte length of '+D$.constants.PUBLIC_KEY_BYTE_LENGTH);var Y=new BJ(D$.constants.SIGN_BYTE_LENGTH+J.length),G=new BJ(D$.constants.SIGN_BYTE_LENGTH+J.length),W;for(W=0;W<D$.constants.SIGN_BYTE_LENGTH;++W)Y[W]=X[W];for(W=0;W<J.length;++W)Y[W+D$.constants.SIGN_BYTE_LENGTH]=J[W];return RH(G,Y,Y.length,Q)>=0};function A0($){var J=$.message;if(J instanceof Uint8Array||J instanceof BJ)return J;var X=$.encoding;if(J===void 0)if($.md)J=$.md.digest().getBytes(),X="binary";else throw TypeError('"options.message" or "options.md" not specified.');if(typeof J==="string"&&!X)throw TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof J==="string"){if(typeof Buffer<"u")return Buffer.from(J,X);J=new f8(J,X)}else if(!(J instanceof f8))throw TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');var Q=new BJ(J.length());for(var Y=0;Y<Q.length;++Y)Q[Y]=J.at(Y);return Q}var y8=G$(),gY=G$([1]),EH=G$([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),FH=G$([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),$W=G$([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),JW=G$([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),IX=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),NH=G$([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function CX($,J){var X=zJ.md.sha512.create(),Q=new f8($);X.update(Q.getBytes(J),"binary");var Y=X.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(Y,"binary");var G=new BJ(D$.constants.HASH_BYTE_LENGTH);for(var W=0;W<64;++W)G[W]=Y.charCodeAt(W);return G}function LH($,J){var X=[G$(),G$(),G$(),G$()],Q,Y=CX(J,32);Y[0]&=248,Y[31]&=127,Y[31]|=64,g8(X,Y),u8($,X);for(Q=0;Q<32;++Q)J[Q+32]=$[Q];return 0}function AH($,J,X,Q){var Y,G,W=new Float64Array(64),U=[G$(),G$(),G$(),G$()],M=CX(Q,32);M[0]&=248,M[31]&=127,M[31]|=64;var O=X+64;for(Y=0;Y<X;++Y)$[64+Y]=J[Y];for(Y=0;Y<32;++Y)$[32+Y]=M[32+Y];var V=CX($.subarray(32),X+32);b8(V),g8(U,V),u8($,U);for(Y=32;Y<64;++Y)$[Y]=Q[Y];var H=CX($,X+64);b8(H);for(Y=32;Y<64;++Y)W[Y]=0;for(Y=0;Y<32;++Y)W[Y]=V[Y];for(Y=0;Y<32;++Y)for(G=0;G<32;G++)W[Y+G]+=H[Y]*M[G];return GW($.subarray(32),W),O}function RH($,J,X,Q){var Y,G,W=new BJ(32),U=[G$(),G$(),G$(),G$()],M=[G$(),G$(),G$(),G$()];if(G=-1,X<64)return-1;if(ZH(M,Q))return-1;if(!DH(J,32))return-1;for(Y=0;Y<X;++Y)$[Y]=J[Y];for(Y=0;Y<32;++Y)$[Y+32]=Q[Y];var O=CX($,X);if(b8(O),MW(U,M,O),g8(M,J.subarray(32)),h8(U,M),u8(W,U),X-=64,WW(J,0,W,0)){for(Y=0;Y<X;++Y)$[Y]=0;return-1}for(Y=0;Y<X;++Y)$[Y]=J[Y+64];return G=X,G}function DH($,J){var X;for(X=31;X>=0;--X){if($[J+X]<IX[X])return!0;if($[J+X]>IX[X])return!1}return!1}function GW($,J){var X,Q,Y,G;for(Q=63;Q>=32;--Q){X=0;for(Y=Q-32,G=Q-12;Y<G;++Y)J[Y]+=X-16*J[Q]*IX[Y-(Q-32)],X=J[Y]+128>>8,J[Y]-=X*256;J[Y]+=X,J[Q]=0}X=0;for(Y=0;Y<32;++Y)J[Y]+=X-(J[31]>>4)*IX[Y],X=J[Y]>>8,J[Y]&=255;for(Y=0;Y<32;++Y)J[Y]-=X*IX[Y];for(Q=0;Q<32;++Q)J[Q+1]+=J[Q]>>8,$[Q]=J[Q]&255}function b8($){var J=new Float64Array(64);for(var X=0;X<64;++X)J[X]=$[X],$[X]=0;GW($,J)}function h8($,J){var X=G$(),Q=G$(),Y=G$(),G=G$(),W=G$(),U=G$(),M=G$(),O=G$(),V=G$();fQ(X,$[1],$[0]),fQ(V,J[1],J[0]),h$(X,X,V),kQ(Q,$[0],$[1]),kQ(V,J[0],J[1]),h$(Q,Q,V),h$(Y,$[3],J[3]),h$(Y,Y,FH),h$(G,$[2],J[2]),kQ(G,G,G),fQ(W,Q,X),fQ(U,G,Y),kQ(M,G,Y),kQ(O,Q,X),h$($[0],W,U),h$($[1],O,M),h$($[2],M,U),h$($[3],W,O)}function QW($,J,X){for(var Q=0;Q<4;++Q)OW($[Q],J[Q],X)}function u8($,J){var X=G$(),Q=G$(),Y=G$();SH(Y,J[2]),h$(X,J[0],Y),h$(Q,J[1],Y),mY($,Q),$[31]^=UW(X)<<7}function mY($,J){var X,Q,Y,G=G$(),W=G$();for(X=0;X<16;++X)W[X]=J[X];v8(W),v8(W),v8(W);for(Q=0;Q<2;++Q){G[0]=W[0]-65517;for(X=1;X<15;++X)G[X]=W[X]-65535-(G[X-1]>>16&1),G[X-1]&=65535;G[15]=W[15]-32767-(G[14]>>16&1),Y=G[15]>>16&1,G[14]&=65535,OW(W,G,1-Y)}for(X=0;X<16;X++)$[2*X]=W[X]&255,$[2*X+1]=W[X]>>8}function ZH($,J){var X=G$(),Q=G$(),Y=G$(),G=G$(),W=G$(),U=G$(),M=G$();if(b0($[2],gY),BH($[1],J),MQ(Y,$[1]),h$(G,Y,EH),fQ(Y,Y,$[2]),kQ(G,$[2],G),MQ(W,G),MQ(U,W),h$(M,U,W),h$(X,M,Y),h$(X,X,G),jH(X,X),h$(X,X,Y),h$(X,X,G),h$(X,X,G),h$($[0],X,G),MQ(Q,$[0]),h$(Q,Q,G),XW(Q,Y))h$($[0],$[0],NH);if(MQ(Q,$[0]),h$(Q,Q,G),XW(Q,Y))return-1;if(UW($[0])===J[31]>>7)fQ($[0],y8,$[0]);return h$($[3],$[0],$[1]),0}function BH($,J){var X;for(X=0;X<16;++X)$[X]=J[2*X]+(J[2*X+1]<<8);$[15]&=32767}function jH($,J){var X=G$(),Q;for(Q=0;Q<16;++Q)X[Q]=J[Q];for(Q=250;Q>=0;--Q)if(MQ(X,X),Q!==1)h$(X,X,J);for(Q=0;Q<16;++Q)$[Q]=X[Q]}function XW($,J){var X=new BJ(32),Q=new BJ(32);return mY(X,$),mY(Q,J),WW(X,0,Q,0)}function WW($,J,X,Q){return TH($,J,X,Q,32)}function TH($,J,X,Q,Y){var G,W=0;for(G=0;G<Y;++G)W|=$[J+G]^X[Q+G];return(1&W-1>>>8)-1}function UW($){var J=new BJ(32);return mY(J,$),J[0]&1}function MW($,J,X){var Q,Y;b0($[0],y8),b0($[1],gY),b0($[2],gY),b0($[3],y8);for(Y=255;Y>=0;--Y)Q=X[Y/8|0]>>(Y&7)&1,QW($,J,Q),h8(J,$),h8($,$),QW($,J,Q)}function g8($,J){var X=[G$(),G$(),G$(),G$()];b0(X[0],$W),b0(X[1],JW),b0(X[2],gY),h$(X[3],$W,JW),MW($,X,J)}function b0($,J){var X;for(X=0;X<16;X++)$[X]=J[X]|0}function SH($,J){var X=G$(),Q;for(Q=0;Q<16;++Q)X[Q]=J[Q];for(Q=253;Q>=0;--Q)if(MQ(X,X),Q!==2&&Q!==4)h$(X,X,J);for(Q=0;Q<16;++Q)$[Q]=X[Q]}function v8($){var J,X,Q=1;for(J=0;J<16;++J)X=$[J]+Q+65535,Q=Math.floor(X/65536),$[J]=X-Q*65536;$[0]+=Q-1+37*(Q-1)}function OW($,J,X){var Q,Y=~(X-1);for(var G=0;G<16;++G)Q=Y&($[G]^J[G]),$[G]^=Q,J[G]^=Q}function G$($){var J,X=new Float64Array(16);if($)for(J=0;J<$.length;++J)X[J]=$[J];return X}function kQ($,J,X){for(var Q=0;Q<16;++Q)$[Q]=J[Q]+X[Q]}function fQ($,J,X){for(var Q=0;Q<16;++Q)$[Q]=J[Q]-X[Q]}function MQ($,J){h$($,J,J)}function h$($,J,X){var Q,Y,G=0,W=0,U=0,M=0,O=0,V=0,H=0,q=0,F=0,K=0,A=0,L=0,R=0,I=0,T=0,C=0,w=0,P=0,l=0,k=0,p=0,$$=0,N$=0,M$=0,b$=0,XJ=0,j$=0,U$=0,v=0,a=0,P$=0,E$=X[0],s=X[1],S$=X[2],J$=X[3],g$=X[4],_$=X[5],K$=X[6],c$=X[7],v$=X[8],YJ=X[9],GJ=X[10],a$=X[11],y$=X[12],n$=X[13],t$=X[14],WJ=X[15];Q=J[0],G+=Q*E$,W+=Q*s,U+=Q*S$,M+=Q*J$,O+=Q*g$,V+=Q*_$,H+=Q*K$,q+=Q*c$,F+=Q*v$,K+=Q*YJ,A+=Q*GJ,L+=Q*a$,R+=Q*y$,I+=Q*n$,T+=Q*t$,C+=Q*WJ,Q=J[1],W+=Q*E$,U+=Q*s,M+=Q*S$,O+=Q*J$,V+=Q*g$,H+=Q*_$,q+=Q*K$,F+=Q*c$,K+=Q*v$,A+=Q*YJ,L+=Q*GJ,R+=Q*a$,I+=Q*y$,T+=Q*n$,C+=Q*t$,w+=Q*WJ,Q=J[2],U+=Q*E$,M+=Q*s,O+=Q*S$,V+=Q*J$,H+=Q*g$,q+=Q*_$,F+=Q*K$,K+=Q*c$,A+=Q*v$,L+=Q*YJ,R+=Q*GJ,I+=Q*a$,T+=Q*y$,C+=Q*n$,w+=Q*t$,P+=Q*WJ,Q=J[3],M+=Q*E$,O+=Q*s,V+=Q*S$,H+=Q*J$,q+=Q*g$,F+=Q*_$,K+=Q*K$,A+=Q*c$,L+=Q*v$,R+=Q*YJ,I+=Q*GJ,T+=Q*a$,C+=Q*y$,w+=Q*n$,P+=Q*t$,l+=Q*WJ,Q=J[4],O+=Q*E$,V+=Q*s,H+=Q*S$,q+=Q*J$,F+=Q*g$,K+=Q*_$,A+=Q*K$,L+=Q*c$,R+=Q*v$,I+=Q*YJ,T+=Q*GJ,C+=Q*a$,w+=Q*y$,P+=Q*n$,l+=Q*t$,k+=Q*WJ,Q=J[5],V+=Q*E$,H+=Q*s,q+=Q*S$,F+=Q*J$,K+=Q*g$,A+=Q*_$,L+=Q*K$,R+=Q*c$,I+=Q*v$,T+=Q*YJ,C+=Q*GJ,w+=Q*a$,P+=Q*y$,l+=Q*n$,k+=Q*t$,p+=Q*WJ,Q=J[6],H+=Q*E$,q+=Q*s,F+=Q*S$,K+=Q*J$,A+=Q*g$,L+=Q*_$,R+=Q*K$,I+=Q*c$,T+=Q*v$,C+=Q*YJ,w+=Q*GJ,P+=Q*a$,l+=Q*y$,k+=Q*n$,p+=Q*t$,$$+=Q*WJ,Q=J[7],q+=Q*E$,F+=Q*s,K+=Q*S$,A+=Q*J$,L+=Q*g$,R+=Q*_$,I+=Q*K$,T+=Q*c$,C+=Q*v$,w+=Q*YJ,P+=Q*GJ,l+=Q*a$,k+=Q*y$,p+=Q*n$,$$+=Q*t$,N$+=Q*WJ,Q=J[8],F+=Q*E$,K+=Q*s,A+=Q*S$,L+=Q*J$,R+=Q*g$,I+=Q*_$,T+=Q*K$,C+=Q*c$,w+=Q*v$,P+=Q*YJ,l+=Q*GJ,k+=Q*a$,p+=Q*y$,$$+=Q*n$,N$+=Q*t$,M$+=Q*WJ,Q=J[9],K+=Q*E$,A+=Q*s,L+=Q*S$,R+=Q*J$,I+=Q*g$,T+=Q*_$,C+=Q*K$,w+=Q*c$,P+=Q*v$,l+=Q*YJ,k+=Q*GJ,p+=Q*a$,$$+=Q*y$,N$+=Q*n$,M$+=Q*t$,b$+=Q*WJ,Q=J[10],A+=Q*E$,L+=Q*s,R+=Q*S$,I+=Q*J$,T+=Q*g$,C+=Q*_$,w+=Q*K$,P+=Q*c$,l+=Q*v$,k+=Q*YJ,p+=Q*GJ,$$+=Q*a$,N$+=Q*y$,M$+=Q*n$,b$+=Q*t$,XJ+=Q*WJ,Q=J[11],L+=Q*E$,R+=Q*s,I+=Q*S$,T+=Q*J$,C+=Q*g$,w+=Q*_$,P+=Q*K$,l+=Q*c$,k+=Q*v$,p+=Q*YJ,$$+=Q*GJ,N$+=Q*a$,M$+=Q*y$,b$+=Q*n$,XJ+=Q*t$,j$+=Q*WJ,Q=J[12],R+=Q*E$,I+=Q*s,T+=Q*S$,C+=Q*J$,w+=Q*g$,P+=Q*_$,l+=Q*K$,k+=Q*c$,p+=Q*v$,$$+=Q*YJ,N$+=Q*GJ,M$+=Q*a$,b$+=Q*y$,XJ+=Q*n$,j$+=Q*t$,U$+=Q*WJ,Q=J[13],I+=Q*E$,T+=Q*s,C+=Q*S$,w+=Q*J$,P+=Q*g$,l+=Q*_$,k+=Q*K$,p+=Q*c$,$$+=Q*v$,N$+=Q*YJ,M$+=Q*GJ,b$+=Q*a$,XJ+=Q*y$,j$+=Q*n$,U$+=Q*t$,v+=Q*WJ,Q=J[14],T+=Q*E$,C+=Q*s,w+=Q*S$,P+=Q*J$,l+=Q*g$,k+=Q*_$,p+=Q*K$,$$+=Q*c$,N$+=Q*v$,M$+=Q*YJ,b$+=Q*GJ,XJ+=Q*a$,j$+=Q*y$,U$+=Q*n$,v+=Q*t$,a+=Q*WJ,Q=J[15],C+=Q*E$,w+=Q*s,P+=Q*S$,l+=Q*J$,k+=Q*g$,p+=Q*_$,$$+=Q*K$,N$+=Q*c$,M$+=Q*v$,b$+=Q*YJ,XJ+=Q*GJ,j$+=Q*a$,U$+=Q*y$,v+=Q*n$,a+=Q*t$,P$+=Q*WJ,G+=38*w,W+=38*P,U+=38*l,M+=38*k,O+=38*p,V+=38*$$,H+=38*N$,q+=38*M$,F+=38*b$,K+=38*XJ,A+=38*j$,L+=38*U$,R+=38*v,I+=38*a,T+=38*P$,Y=1,Q=G+Y+65535,Y=Math.floor(Q/65536),G=Q-Y*65536,Q=W+Y+65535,Y=Math.floor(Q/65536),W=Q-Y*65536,Q=U+Y+65535,Y=Math.floor(Q/65536),U=Q-Y*65536,Q=M+Y+65535,Y=Math.floor(Q/65536),M=Q-Y*65536,Q=O+Y+65535,Y=Math.floor(Q/65536),O=Q-Y*65536,Q=V+Y+65535,Y=Math.floor(Q/65536),V=Q-Y*65536,Q=H+Y+65535,Y=Math.floor(Q/65536),H=Q-Y*65536,Q=q+Y+65535,Y=Math.floor(Q/65536),q=Q-Y*65536,Q=F+Y+65535,Y=Math.floor(Q/65536),F=Q-Y*65536,Q=K+Y+65535,Y=Math.floor(Q/65536),K=Q-Y*65536,Q=A+Y+65535,Y=Math.floor(Q/65536),A=Q-Y*65536,Q=L+Y+65535,Y=Math.floor(Q/65536),L=Q-Y*65536,Q=R+Y+65535,Y=Math.floor(Q/65536),R=Q-Y*65536,Q=I+Y+65535,Y=Math.floor(Q/65536),I=Q-Y*65536,Q=T+Y+65535,Y=Math.floor(Q/65536),T=Q-Y*65536,Q=C+Y+65535,Y=Math.floor(Q/65536),C=Q-Y*65536,G+=Y-1+37*(Y-1),Y=1,Q=G+Y+65535,Y=Math.floor(Q/65536),G=Q-Y*65536,Q=W+Y+65535,Y=Math.floor(Q/65536),W=Q-Y*65536,Q=U+Y+65535,Y=Math.floor(Q/65536),U=Q-Y*65536,Q=M+Y+65535,Y=Math.floor(Q/65536),M=Q-Y*65536,Q=O+Y+65535,Y=Math.floor(Q/65536),O=Q-Y*65536,Q=V+Y+65535,Y=Math.floor(Q/65536),V=Q-Y*65536,Q=H+Y+65535,Y=Math.floor(Q/65536),H=Q-Y*65536,Q=q+Y+65535,Y=Math.floor(Q/65536),q=Q-Y*65536,Q=F+Y+65535,Y=Math.floor(Q/65536),F=Q-Y*65536,Q=K+Y+65535,Y=Math.floor(Q/65536),K=Q-Y*65536,Q=A+Y+65535,Y=Math.floor(Q/65536),A=Q-Y*65536,Q=L+Y+65535,Y=Math.floor(Q/65536),L=Q-Y*65536,Q=R+Y+65535,Y=Math.floor(Q/65536),R=Q-Y*65536,Q=I+Y+65535,Y=Math.floor(Q/65536),I=Q-Y*65536,Q=T+Y+65535,Y=Math.floor(Q/65536),T=Q-Y*65536,Q=C+Y+65535,Y=Math.floor(Q/65536),C=Q-Y*65536,G+=Y-1+37*(Y-1),$[0]=G,$[1]=W,$[2]=U,$[3]=M,$[4]=O,$[5]=V,$[6]=H,$[7]=q,$[8]=F,$[9]=K,$[10]=A,$[11]=L,$[12]=R,$[13]=I,$[14]=T,$[15]=C}});var EW=O$((_F,zW)=>{var IJ=z$();w$();_J();DX();zW.exports=IJ.kem=IJ.kem||{};var qW=IJ.jsbn.BigInteger;IJ.kem.rsa={};IJ.kem.rsa.create=function($,J){J=J||{};var X=J.prng||IJ.random,Q={};return Q.encrypt=function(Y,G){var W=Math.ceil(Y.n.bitLength()/8),U;do U=new qW(IJ.util.bytesToHex(X.getBytesSync(W)),16).mod(Y.n);while(U.compareTo(qW.ONE)<=0);U=IJ.util.hexToBytes(U.toString(16));var M=W-U.length;if(M>0)U=IJ.util.fillString(String.fromCharCode(0),M)+U;var O=Y.encrypt(U,"NONE"),V=$.generate(U,G);return{encapsulation:O,key:V}},Q.decrypt=function(Y,G,W){var U=Y.decrypt(G,"NONE");return $.generate(U,W)},Q};IJ.kem.kdf1=function($,J){KW(this,$,0,J||$.digestLength)};IJ.kem.kdf2=function($,J){KW(this,$,1,J||$.digestLength)};function KW($,J,X,Q){$.generate=function(Y,G){var W=new IJ.util.ByteBuffer,U=Math.ceil(G/Q)+X,M=new IJ.util.ByteBuffer;for(var O=X;O<U;++O){M.putInt32(O),J.start(),J.update(Y+M.getBytes());var V=J.digest();W.putBytes(V.getBytes(Q))}return W.truncate(W.length()-G),W.getBytes()}}});var NW=O$((xF,FW)=>{var B$=z$();w$();FW.exports=B$.log=B$.log||{};B$.log.levels=["none","error","warning","info","debug","verbose","max"];var dY={},m8=[],wX=null;B$.log.LEVEL_LOCKED=2;B$.log.NO_LEVEL_CHECK=4;B$.log.INTERPOLATE=8;for(bJ=0;bJ<B$.log.levels.length;++bJ)lY=B$.log.levels[bJ],dY[lY]={index:bJ,name:lY.toUpperCase()};var lY,bJ;B$.log.logMessage=function($){var J=dY[$.level].index;for(var X=0;X<m8.length;++X){var Q=m8[X];if(Q.flags&B$.log.NO_LEVEL_CHECK)Q.f($);else{var Y=dY[Q.level].index;if(J<=Y)Q.f(Q,$)}}};B$.log.prepareStandard=function($){if(!("standard"in $))$.standard=dY[$.level].name+" ["+$.category+"] "+$.message};B$.log.prepareFull=function($){if(!("full"in $)){var J=[$.message];J=J.concat([]),$.full=B$.util.format.apply(this,J)}};B$.log.prepareStandardFull=function($){if(!("standardFull"in $))B$.log.prepareStandard($),$.standardFull=$.standard};pY=["error","warning","info","debug","verbose"];for(bJ=0;bJ<pY.length;++bJ)(function(J){B$.log[J]=function(X,Q){var Y=Array.prototype.slice.call(arguments).slice(2),G={timestamp:new Date,level:J,category:X,message:Q,arguments:Y};B$.log.logMessage(G)}})(pY[bJ]);var pY,bJ;B$.log.makeLogger=function($){var J={flags:0,f:$};return B$.log.setLevel(J,"none"),J};B$.log.setLevel=function($,J){var X=!1;if($&&!($.flags&B$.log.LEVEL_LOCKED))for(var Q=0;Q<B$.log.levels.length;++Q){var Y=B$.log.levels[Q];if(J==Y){$.level=J,X=!0;break}}return X};B$.log.lock=function($,J){if(typeof J>"u"||J)$.flags|=B$.log.LEVEL_LOCKED;else $.flags&=~B$.log.LEVEL_LOCKED};B$.log.addLogger=function($){m8.push($)};if(typeof console<"u"&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug)l8={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},bQ=function($,J){B$.log.prepareStandard(J);var X=l8[J.level],Q=[J.standard];Q=Q.concat(J.arguments.slice()),X.apply(console,Q)},OQ=B$.log.makeLogger(bQ);else bQ=function(J,X){B$.log.prepareStandardFull(X),console.log(X.standardFull)},OQ=B$.log.makeLogger(bQ);B$.log.setLevel(OQ,"debug"),B$.log.addLogger(OQ),wX=OQ}else console={log:function(){}};var OQ,l8,bQ;if(wX!==null&&typeof window<"u"&&window.location){if(yQ=new URL(window.location.href).searchParams,yQ.has("console.level"))B$.log.setLevel(wX,yQ.get("console.level").slice(-1)[0]);if(yQ.has("console.lock")){if(p8=yQ.get("console.lock").slice(-1)[0],p8=="true")B$.log.lock(wX)}}var yQ,p8;B$.log.consoleLogger=wX});var AW=O$((vF,LW)=>{LW.exports=eJ();ZY();wQ();Q8();x8()});var ZW=O$((kF,DW)=>{var d=z$();w0();mJ();AX();P0();JQ();N8();_J();w$();yY();var B=d.asn1,DJ=DW.exports=d.pkcs7=d.pkcs7||{};DJ.messageFromPem=function($){var J=d.pem.decode($)[0];if(J.type!=="PKCS7"){var X=Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw X.headerType=J.type,X}if(J.procType&&J.procType.type==="ENCRYPTED")throw Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var Q=B.fromDer(J.body);return DJ.messageFromAsn1(Q)};DJ.messageToPem=function($,J){var X={type:"PKCS7",body:B.toDer($.toAsn1()).getBytes()};return d.pem.encode(X,{maxline:J})};DJ.messageFromAsn1=function($){var J={},X=[];if(!B.validate($,DJ.asn1.contentInfoValidator,J,X)){var Q=Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw Q.errors=X,Q}var Y=B.derToOid(J.contentType),G;switch(Y){case d.pki.oids.envelopedData:G=DJ.createEnvelopedData();break;case d.pki.oids.encryptedData:G=DJ.createEncryptedData();break;case d.pki.oids.signedData:G=DJ.createSignedData();break;default:throw Error("Cannot read PKCS#7 message. ContentType with OID "+Y+" is not (yet) supported.")}return G.fromAsn1(J.content.value[0]),G};DJ.createSignedData=function(){var $=null;return $={type:d.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(Q){if(c8($,Q,DJ.asn1.signedDataValidator),$.certificates=[],$.crls=[],$.digestAlgorithmIdentifiers=[],$.contentInfo=null,$.signerInfos=[],$.rawCapture.certificates){var Y=$.rawCapture.certificates.value;for(var G=0;G<Y.length;++G)$.certificates.push(d.pki.certificateFromAsn1(Y[G]))}},toAsn1:function(){if(!$.contentInfo)$.sign();var Q=[];for(var Y=0;Y<$.certificates.length;++Y)Q.push(d.pki.certificateToAsn1($.certificates[Y]));var G=[],W=B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,$.digestAlgorithmIdentifiers),$.contentInfo])]);if(Q.length>0)W.value[0].value.push(B.create(B.Class.CONTEXT_SPECIFIC,0,!0,Q));if(G.length>0)W.value[0].value.push(B.create(B.Class.CONTEXT_SPECIFIC,1,!0,G));return W.value[0].value.push(B.create(B.Class.UNIVERSAL,B.Type.SET,!0,$.signerInfos)),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),W])},addSigner:function(Q){var{issuer:Y,serialNumber:G}=Q;if(Q.certificate){var W=Q.certificate;if(typeof W==="string")W=d.pki.certificateFromPem(W);Y=W.issuer.attributes,G=W.serialNumber}var U=Q.key;if(!U)throw Error("Could not add PKCS#7 signer; no private key specified.");if(typeof U==="string")U=d.pki.privateKeyFromPem(U);var M=Q.digestAlgorithm||d.pki.oids.sha1;switch(M){case d.pki.oids.sha1:case d.pki.oids.sha256:case d.pki.oids.sha384:case d.pki.oids.sha512:case d.pki.oids.md5:break;default:throw Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+M)}var O=Q.authenticatedAttributes||[];if(O.length>0){var V=!1,H=!1;for(var q=0;q<O.length;++q){var F=O[q];if(!V&&F.type===d.pki.oids.contentType){if(V=!0,H)break;continue}if(!H&&F.type===d.pki.oids.messageDigest){if(H=!0,V)break;continue}}if(!V||!H)throw Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}$.signers.push({key:U,version:1,issuer:Y,serialNumber:G,digestAlgorithm:M,signatureAlgorithm:d.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:O,unauthenticatedAttributes:[]})},sign:function(Q){if(Q=Q||{},typeof $.content!=="object"||$.contentInfo===null){if($.contentInfo=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(d.pki.oids.data).getBytes())]),"content"in $){var Y;if($.content instanceof d.util.ByteBuffer)Y=$.content.bytes();else if(typeof $.content==="string")Y=d.util.encodeUtf8($.content);if(Q.detached)$.detachedContent=B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,Y);else $.contentInfo.value.push(B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,Y)]))}}if($.signers.length===0)return;var G=J();X(G)},verify:function(){throw Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(Q){if(typeof Q==="string")Q=d.pki.certificateFromPem(Q);$.certificates.push(Q)},addCertificateRevokationList:function(Q){throw Error("PKCS#7 CRL support not yet implemented.")}},$;function J(){var Q={};for(var Y=0;Y<$.signers.length;++Y){var G=$.signers[Y],W=G.digestAlgorithm;if(!(W in Q))Q[W]=d.md[d.pki.oids[W]].create();if(G.authenticatedAttributes.length===0)G.md=Q[W];else G.md=d.md[d.pki.oids[W]].create()}$.digestAlgorithmIdentifiers=[];for(var W in Q)$.digestAlgorithmIdentifiers.push(B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(W).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")]));return Q}function X(Q){var Y;if($.detachedContent)Y=$.detachedContent;else Y=$.contentInfo.value[1],Y=Y.value[0];if(!Y)throw Error("Could not sign PKCS#7 message; there is no content to sign.");var G=B.derToOid($.contentInfo.value[0].value),W=B.toDer(Y);W.getByte(),B.getBerValueLength(W),W=W.getBytes();for(var U in Q)Q[U].start().update(W);var M=new Date;for(var O=0;O<$.signers.length;++O){var V=$.signers[O];if(V.authenticatedAttributes.length===0){if(G!==d.pki.oids.data)throw Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{V.authenticatedAttributesAsn1=B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[]);var H=B.create(B.Class.UNIVERSAL,B.Type.SET,!0,[]);for(var q=0;q<V.authenticatedAttributes.length;++q){var F=V.authenticatedAttributes[q];if(F.type===d.pki.oids.messageDigest)F.value=Q[V.digestAlgorithm].digest();else if(F.type===d.pki.oids.signingTime){if(!F.value)F.value=M}H.value.push(d8(F)),V.authenticatedAttributesAsn1.value.push(d8(F))}W=B.toDer(H).getBytes(),V.md.start().update(W)}V.signature=V.key.sign(V.md,"RSASSA-PKCS1-V1_5")}$.signerInfos=xH($.signers)}};DJ.createEncryptedData=function(){var $=null;return $={type:d.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:d.pki.oids["aes256-CBC"]},fromAsn1:function(J){c8($,J,DJ.asn1.encryptedDataValidator)},decrypt:function(J){if(J!==void 0)$.encryptedContent.key=J;RW($)}},$};DJ.createEnvelopedData=function(){var $=null;return $={type:d.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:d.pki.oids["aes256-CBC"]},fromAsn1:function(J){var X=c8($,J,DJ.asn1.envelopedDataValidator);$.recipients=wH(X.recipientInfos.value)},toAsn1:function(){return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,PH($.recipients)),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,vH($.encryptedContent))])])])},findRecipient:function(J){var X=J.issuer.attributes;for(var Q=0;Q<$.recipients.length;++Q){var Y=$.recipients[Q],G=Y.issuer;if(Y.serialNumber!==J.serialNumber)continue;if(G.length!==X.length)continue;var W=!0;for(var U=0;U<X.length;++U)if(G[U].type!==X[U].type||G[U].value!==X[U].value){W=!1;break}if(W)return Y}return null},decrypt:function(J,X){if($.encryptedContent.key===void 0&&J!==void 0&&X!==void 0)switch(J.encryptedContent.algorithm){case d.pki.oids.rsaEncryption:case d.pki.oids.desCBC:var Q=X.decrypt(J.encryptedContent.content);$.encryptedContent.key=d.util.createBuffer(Q);break;default:throw Error("Unsupported asymmetric cipher, OID "+J.encryptedContent.algorithm)}RW($)},addRecipient:function(J){$.recipients.push({version:0,issuer:J.issuer.attributes,serialNumber:J.serialNumber,encryptedContent:{algorithm:d.pki.oids.rsaEncryption,key:J.publicKey}})},encrypt:function(J,X){if($.encryptedContent.content===void 0){X=X||$.encryptedContent.algorithm,J=J||$.encryptedContent.key;var Q,Y,G;switch(X){case d.pki.oids["aes128-CBC"]:Q=16,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["aes192-CBC"]:Q=24,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["aes256-CBC"]:Q=32,Y=16,G=d.aes.createEncryptionCipher;break;case d.pki.oids["des-EDE3-CBC"]:Q=24,Y=8,G=d.des.createEncryptionCipher;break;default:throw Error("Unsupported symmetric cipher, OID "+X)}if(J===void 0)J=d.util.createBuffer(d.random.getBytes(Q));else if(J.length()!=Q)throw Error("Symmetric key has wrong length; got "+J.length()+" bytes, expected "+Q+".");$.encryptedContent.algorithm=X,$.encryptedContent.key=J,$.encryptedContent.parameter=d.util.createBuffer(d.random.getBytes(Y));var W=G(J);if(W.start($.encryptedContent.parameter.copy()),W.update($.content),!W.finish())throw Error("Symmetric encryption failed.");$.encryptedContent.content=W.output}for(var U=0;U<$.recipients.length;++U){var M=$.recipients[U];if(M.encryptedContent.content!==void 0)continue;switch(M.encryptedContent.algorithm){case d.pki.oids.rsaEncryption:M.encryptedContent.content=M.encryptedContent.key.encrypt($.encryptedContent.key.data);break;default:throw Error("Unsupported asymmetric cipher, OID "+M.encryptedContent.algorithm)}}}},$};function IH($){var J={},X=[];if(!B.validate($,DJ.asn1.recipientInfoValidator,J,X)){var Q=Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw Q.errors=X,Q}return{version:J.version.charCodeAt(0),issuer:d.pki.RDNAttributesAsArray(J.issuer),serialNumber:d.util.createBuffer(J.serial).toHex(),encryptedContent:{algorithm:B.derToOid(J.encAlgorithm),parameter:J.encParameter?J.encParameter.value:void 0,content:J.encKey}}}function CH($){return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[d.pki.distinguishedNameToAsn1({attributes:$.issuer}),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,d.util.hexToBytes($.serialNumber))]),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.encryptedContent.algorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")]),B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.encryptedContent.content)])}function wH($){var J=[];for(var X=0;X<$.length;++X)J.push(IH($[X]));return J}function PH($){var J=[];for(var X=0;X<$.length;++X)J.push(CH($[X]));return J}function _H($){var J=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,B.integerToDer($.version).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[d.pki.distinguishedNameToAsn1({attributes:$.issuer}),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,d.util.hexToBytes($.serialNumber))]),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.digestAlgorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")])]);if($.authenticatedAttributesAsn1)J.value.push($.authenticatedAttributesAsn1);if(J.value.push(B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.signatureAlgorithm).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")])),J.value.push(B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.signature)),$.unauthenticatedAttributes.length>0){var X=B.create(B.Class.CONTEXT_SPECIFIC,1,!0,[]);for(var Q=0;Q<$.unauthenticatedAttributes.length;++Q){var Y=$.unauthenticatedAttributes[Q];X.values.push(d8(Y))}J.value.push(X)}return J}function xH($){var J=[];for(var X=0;X<$.length;++X)J.push(_H($[X]));return J}function d8($){var J;if($.type===d.pki.oids.contentType)J=B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.value).getBytes());else if($.type===d.pki.oids.messageDigest)J=B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.value.bytes());else if($.type===d.pki.oids.signingTime){var X=new Date("1950-01-01T00:00:00Z"),Q=new Date("2050-01-01T00:00:00Z"),Y=$.value;if(typeof Y==="string"){var G=Date.parse(Y);if(!isNaN(G))Y=new Date(G);else if(Y.length===13)Y=B.utcTimeToDate(Y);else Y=B.generalizedTimeToDate(Y)}if(Y>=X&&Y<Q)J=B.create(B.Class.UNIVERSAL,B.Type.UTCTIME,!1,B.dateToUtcTime(Y));else J=B.create(B.Class.UNIVERSAL,B.Type.GENERALIZEDTIME,!1,B.dateToGeneralizedTime(Y))}return B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.type).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SET,!0,[J])])}function vH($){return[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(d.pki.oids.data).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer($.algorithm).getBytes()),!$.parameter?void 0:B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.parameter.getBytes())]),B.create(B.Class.CONTEXT_SPECIFIC,0,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,$.content.getBytes())])]}function c8($,J,X){var Q={},Y=[];if(!B.validate(J,X,Q,Y)){var G=Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw G.errors=G,G}var W=B.derToOid(Q.contentType);if(W!==d.pki.oids.data)throw Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(Q.encryptedContent){var U="";if(d.util.isArray(Q.encryptedContent))for(var M=0;M<Q.encryptedContent.length;++M){if(Q.encryptedContent[M].type!==B.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");U+=Q.encryptedContent[M].value}else U=Q.encryptedContent;$.encryptedContent={algorithm:B.derToOid(Q.encAlgorithm),parameter:d.util.createBuffer(Q.encParameter.value),content:d.util.createBuffer(U)}}if(Q.content){var U="";if(d.util.isArray(Q.content))for(var M=0;M<Q.content.length;++M){if(Q.content[M].type!==B.Type.OCTETSTRING)throw Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");U+=Q.content[M].value}else U=Q.content;$.content=d.util.createBuffer(U)}return $.version=Q.version.charCodeAt(0),$.rawCapture=Q,Q}function RW($){if($.encryptedContent.key===void 0)throw Error("Symmetric key not available.");if($.content===void 0){var J;switch($.encryptedContent.algorithm){case d.pki.oids["aes128-CBC"]:case d.pki.oids["aes192-CBC"]:case d.pki.oids["aes256-CBC"]:J=d.aes.createDecryptionCipher($.encryptedContent.key);break;case d.pki.oids.desCBC:case d.pki.oids["des-EDE3-CBC"]:J=d.des.createDecryptionCipher($.encryptedContent.key);break;default:throw Error("Unsupported symmetric cipher, OID "+$.encryptedContent.algorithm)}if(J.start($.encryptedContent.parameter),J.update($.encryptedContent.content),!J.finish())throw Error("Symmetric decryption failed.");$.content=J.output}}});var jW=O$((fF,BW)=>{var QJ=z$();w0();TQ();ZY();wQ();w$();var nY=BW.exports=QJ.ssh=QJ.ssh||{};nY.privateKeyToPutty=function($,J,X){X=X||"",J=J||"";var Q="ssh-rsa",Y=J===""?"none":"aes256-cbc",G="PuTTY-User-Key-File-2: "+Q+`\r
|
|
16
16
|
`;G+="Encryption: "+Y+`\r
|
|
17
17
|
`,G+="Comment: "+X+`\r
|
|
18
|
-
`;var W
|
|
19
|
-
`,G+=
|
|
20
|
-
Private-Lines: `+
|
|
21
|
-
`,G+=V;var L=
|
|
22
|
-
Private-MAC: `+
|
|
23
|
-
`,G};fY.publicKeyToOpenSSH=function($,J){var X="ssh-rsa";J=J||"";var Q=$J.util.createBuffer();return kQ(Q,X),G0(Q,$.e),G0(Q,$.n),X+" "+$J.util.encode64(Q.bytes())+" "+J};fY.privateKeyToOpenSSH=function($,J){if(!J)return $J.pki.privateKeyToPem($);return $J.pki.encryptRsaPrivateKey($,J,{legacy:!0,algorithm:"aes128"})};fY.getPublicKeyFingerprint=function($,J){J=J||{};var X=J.md||$J.md.md5.create(),Q="ssh-rsa",Y=$J.util.createBuffer();kQ(Y,Q),G0(Y,$.e),G0(Y,$.n),X.start(),X.update(Y.getBytes());var G=X.digest();if(J.encoding==="hex"){var W=G.toHex();if(J.delimiter)return W.match(/.{2}/g).join(J.delimiter);return W}else if(J.encoding==="binary")return G.getBytes();else if(J.encoding)throw Error('Unknown encoding "'+J.encoding+'".');return G};function G0($,J){var X=J.toString(16);if(X[0]>="8")X="00"+X;var Q=$J.util.hexToBytes(X);$.putInt32(Q.length),$.putBytes(Q)}function kQ($,J){$.putInt32(J.length),$.putString(J)}function kY(){var $=$J.md.sha1.create(),J=arguments.length;for(var X=0;X<J;++X)$.update(arguments[X]);return $.digest()}});var _8=M$((fE,YW)=>{YW.exports=K$();T0();I1();gJ();YY();zX();p1();DQ();o1();s1();t1();X8();EY();t0();s9();W8();JW();U8();t9();l9();ZY();PJ();c9();XW();z8();C$()});var cW=M$((fF,pW)=>{var{create:sH,defineProperty:cY,getOwnPropertyDescriptor:rH,getOwnPropertyNames:tH,getPrototypeOf:eH}=Object,$q=Object.prototype.hasOwnProperty,Jq=($,J)=>{for(var X in J)cY($,X,{get:J[X],enumerable:!0})},uW=($,J,X,Q)=>{if(J&&typeof J==="object"||typeof J==="function"){for(let Y of tH(J))if(!$q.call($,Y)&&Y!==X)cY($,Y,{get:()=>J[Y],enumerable:!(Q=rH(J,Y))||Q.enumerable})}return $},gW=($,J,X)=>(X=$!=null?sH(eH($)):{},uW(J||!$||!$.__esModule?cY(X,"default",{value:$,enumerable:!0}):X,$)),Qq=($)=>uW(cY({},"__esModule",{value:!0}),$),mW={};Jq(mW,{Socks5Server:()=>dW,createServer:()=>Wq,defaultConnectionHandler:()=>r8});pW.exports=Qq(mW);var Xq=gW(YX("net")),lW=(($)=>{return $[$.connect=1]="connect",$[$.bind=2]="bind",$[$.udp=3]="udp",$})(lW||{}),s8=(($)=>{return $[$.REQUEST_GRANTED=0]="REQUEST_GRANTED",$[$.GENERAL_FAILURE=1]="GENERAL_FAILURE",$[$.CONNECTION_NOT_ALLOWED=2]="CONNECTION_NOT_ALLOWED",$[$.NETWORK_UNREACHABLE=3]="NETWORK_UNREACHABLE",$[$.HOST_UNREACHABLE=4]="HOST_UNREACHABLE",$[$.CONNECTION_REFUSED=5]="CONNECTION_REFUSED",$[$.TTL_EXPIRED=6]="TTL_EXPIRED",$[$.COMMAND_NOT_SUPPORTED=7]="COMMAND_NOT_SUPPORTED",$[$.ADDRESS_TYPE_NOT_SUPPORTED=8]="ADDRESS_TYPE_NOT_SUPPORTED",$})(s8||{}),Yq=class{constructor($,J){this.errorHandler=()=>{},this.metadata={},this.socket=J,this.server=$,J.on("error",this.errorHandler),J.pause(),this.handleGreeting()}readBytes($){return new Promise((J)=>{let X=Buffer.allocUnsafe($),Q=0,Y=(G)=>{let W=Math.min(G.length,$-Q);if(G.copy(X,Q,0,W),Q+=W,Q<$)return;this.socket.removeListener("data",Y),this.socket.push(G.subarray(W)),J(X),this.socket.pause()};this.socket.on("data",Y),this.socket.resume()})}async handleGreeting(){if((await this.readBytes(1)).readUInt8()!==5)return this.socket.destroy();let J=(await this.readBytes(1)).readUInt8();if(J>128||J===0)return this.socket.destroy();let X=await this.readBytes(J),Q=this.server.authHandler?2:0;if(!X.includes(Q))return this.socket.write(Buffer.from([5,255])),this.socket.destroy();if(this.socket.write(Buffer.from([5,Q])),this.server.authHandler)this.handleUserPassword();else this.handleConnectionRequest()}async handleUserPassword(){await this.readBytes(1);let $=(await this.readBytes(1)).readUint8(),J=(await this.readBytes($)).toString(),X=(await this.readBytes(1)).readUint8(),Q=(await this.readBytes(X)).toString();this.username=J,this.password=Q;let Y=!1,G=()=>{if(Y)return;Y=!0,this.socket.write(Buffer.from([1,0])),this.handleConnectionRequest()},W=()=>{if(Y)return;Y=!0,this.socket.write(Buffer.from([1,1])),this.socket.destroy()},M=await this.server.authHandler(this,G,W);if(M===!0)G();else if(M===!1)W()}async handleConnectionRequest(){await this.readBytes(1);let $=(await this.readBytes(1))[0],J=lW[$];if(!J)return this.socket.destroy();this.command=J,await this.readBytes(1);let X=(await this.readBytes(1)).readUInt8(),Q="";switch(X){case 1:Q=(await this.readBytes(4)).join(".");break;case 3:let O=(await this.readBytes(1)).readUInt8();Q=(await this.readBytes(O)).toString();break;case 4:let V=await this.readBytes(16);for(let H=0;H<16;H++){if(H%2===0&&H>0)Q+=":";Q+=`${V[H]<16?"0":""}${V[H].toString(16)}`}break;default:this.socket.destroy();return}let Y=(await this.readBytes(2)).readUInt16BE();if(!this.server.supportedCommands.has(J))return this.socket.write(Buffer.from([5,7])),this.socket.destroy();this.destAddress=Q,this.destPort=Y;let G=!1,W=()=>{if(G)return;G=!0,this.connect()};if(!this.server.rulesetValidator)return W();let M=()=>{if(G)return;G=!0,this.socket.write(Buffer.from([5,2,0,1,0,0,0,0,0,0])),this.socket.destroy()},U=await this.server.rulesetValidator(this,W,M);if(U===!0)W();else if(U===!1)M()}connect(){this.socket.removeListener("error",this.errorHandler),this.server.connectionHandler(this,($)=>{if(s8[$]===void 0)throw Error(`"${$}" is not a valid status.`);if(this.socket.write(Buffer.from([5,s8[$],0,1,0,0,0,0,0,0])),$!=="REQUEST_GRANTED")this.socket.destroy()}),this.socket.resume()}},Gq=gW(YX("net"));function r8($,J){if($.command!=="connect")return J("COMMAND_NOT_SUPPORTED");$.socket.on("error",()=>{});let X=Gq.default.createConnection({host:$.destAddress,port:$.destPort});X.setNoDelay();let Q=!1;return X.on("error",(Y)=>{if(!Q)switch(Y.code){case"EINVAL":case"ENOENT":case"ENOTFOUND":case"ETIMEDOUT":case"EADDRNOTAVAIL":case"EHOSTUNREACH":J("HOST_UNREACHABLE");break;case"ENETUNREACH":J("NETWORK_UNREACHABLE");break;case"ECONNREFUSED":J("CONNECTION_REFUSED");break;default:J("GENERAL_FAILURE")}}),X.on("ready",()=>{Q=!0,J("REQUEST_GRANTED"),$.socket.pipe(X).pipe($.socket)}),$.socket.on("close",()=>X.destroy()),X}var dW=class{constructor(){this.supportedCommands=new Set(["connect"]),this.connectionHandler=r8,this.server=Xq.default.createServer(($)=>{$.setNoDelay(),this._handleConnection($)})}listen(...$){return this.server.listen(...$),this}close($){return this.server.close($),this}setAuthHandler($){return this.authHandler=$,this}disableAuthHandler(){return this.authHandler=void 0,this}setRulesetValidator($){return this.rulesetValidator=$,this}disableRulesetValidator(){return this.rulesetValidator=void 0,this}setConnectionHandler($){return this.connectionHandler=$,this}useDefaultConnectionHandler(){return this.connectionHandler=r8,this}_handleConnection($){return new Yq(this,$),this}};function Wq($){let J=new dW;if($?.auth)J.setAuthHandler((X)=>{return X.username===$.auth.username&&X.password===$.auth.password});if($?.port)J.listen($.port,$.hostname);return J}});import{Agent as pH,createServer as cH}from"http";import{request as a8}from"http";import{request as yW}from"https";import{connect as nH,isIP as iH}from"net";import{URL as bW}from"url";function Z($,J){if(!process.env.SRT_DEBUG)return;let X=J?.level||"info",Q="[SandboxDebug]";switch(X){case"error":console.error(`${Q} ${$}`);break;case"warn":console.warn(`${Q} ${$}`);break;default:console.error(`${Q} ${$}`)}}import{timingSafeEqual as XM}from"crypto";function rX($,J){let X=Buffer.from($),Q=Buffer.from(J);if(X.length!==Q.length)return!1;return XM(X,Q)}import{homedir as tX}from"os";import*as WJ from"path";import*as o0 from"fs";import*as c7 from"fs";function S9(){if(process.platform!=="linux")return;try{let $=c7.readFileSync("/proc/version",{encoding:"utf8"}),J=$.match(/WSL(\d+)/i);if(J&&J[1])return J[1];if($.toLowerCase().includes("microsoft"))return"1";return}catch{return}}function P$(){switch(process.platform){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:return"unknown"}}var GX=[".gitconfig",".gitmodules",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".ripgreprc",".mcp.json"],YM=[".git",".vscode",".idea"];function $Y(){return[...YM.filter(($)=>$!==".git"),".claude/commands",".claude/agents"]}function I9($){return $.toLowerCase()}function FJ($){return $.includes("*")||$.includes("?")||$.includes("[")||$.includes("]")}function WX($){return $.includes("*")||$.includes("?")}function n7($){return P$()==="windows"?WX($):FJ($)}function i7($){if(/^\\\\\?\\unc\\/i.test($))return"\\\\"+$.slice(8);if($.startsWith("\\\\?\\"))return $.slice(4);return $}function MX($){let J=WJ.win32.toNamespacedPath($);return/^[\\/]{2}[?.][\\/]unc[\\/]/i.test(J)}function q0($){return $.replace(/\/\*\*$/,"")||"/"}function eX($,J){let X=WJ.normalize($),Q=WJ.normalize(J);if(Q===X)return!1;if(X.startsWith("/tmp/")&&Q==="/private"+X)return!1;if(X.startsWith("/var/")&&Q==="/private"+X)return!1;if(X.startsWith("/private/tmp/")&&Q===X)return!1;if(X.startsWith("/private/var/")&&Q===X)return!1;if(Q==="/")return!0;if(Q.split("/").filter(Boolean).length<=1)return!0;if(X.startsWith(Q+"/"))return!0;let G=X;if(X.startsWith("/tmp/"))G="/private"+X;else if(X.startsWith("/var/"))G="/private"+X;if(G!==X&&G.startsWith(Q+"/"))return!0;let W=Q.startsWith(X+"/"),M=G!==X&&Q.startsWith(G+"/");if(Q!==X&&!(G!==X&&Q===G)&&!W&&!M)return!0;return!1}function GM($){if($==="~")return tX();if($.startsWith("~/")||process.platform==="win32"&&$.startsWith("~\\"))return tX()+$.slice(1);return $}function WM($){let J=tX(),X=/^[A-Za-z]:/.test(J)?J.slice(0,2):"",Q=X?J.slice(2):J;return $.replace(/%USERPROFILE%/gi,J).replace(/%HOMEDRIVE%/gi,X).replace(/%HOMEPATH%/gi,Q)}function e$($){let J=process.cwd();if(P$()==="windows"){if($=i7(WM($)),/^[a-z]:/.test($))$=$[0].toUpperCase()+$.slice(1);if(MX($)&&!WX($))return WJ.win32.normalize($)}if(P$()!=="windows"&&$.endsWith("/")&&$!=="/"&&!n7($))$=$.replace(/\/+$/,"")||"/";let X=GM($);if(X!==$);else if($.startsWith("./")||$.startsWith("../"))X=WJ.resolve(J,$);else if(!WJ.isAbsolute($))X=WJ.resolve(J,$);if(n7(X)){let Q=P$()==="windows"?/[*?]/:/[*?[\]]/,Y=X.split(Q)[0];if(Y&&Y!=="/"){let G=Y.endsWith("/")?Y.slice(0,-1):WJ.dirname(Y);try{let W=o0.realpathSync(G);if(!eX(G,W)){let M=X.slice(G.length);return W+M}}catch{}}return X}try{let Q=o0.realpathSync(X);if(eX(X,Q));else X=Q}catch{}return X}function NQ($){let J=$??tX();return["/dev/stdout","/dev/stderr","/dev/null","/dev/tty","/dev/dtracehelper","/dev/autofs_nowait","/tmp/claude","/private/tmp/claude",WJ.join(J,".npm/_logs"),WJ.join(J,".claude/debug")]}var MM=["NODE_EXTRA_CA_CERTS","SSL_CERT_FILE","CURL_CA_BUNDLE","REQUESTS_CA_BUNDLE","PIP_CERT","GIT_SSL_CAINFO","AWS_CA_BUNDLE","CARGO_HTTP_CAINFO","DENO_CERT","CLOUDSDK_CORE_CUSTOM_CA_CERTS_FILE","NIX_SSL_CERT_FILE"];function LQ($,J,X,Q,Y,G){let W=OM(G),M=W===H0?W:encodeURIComponent(W),U=Q?`${M}:${Q}@`:"",O=P$()==="linux"?"127.0.0.1":"localhost",V=["SANDBOX_RUNTIME=1"];if(!Y){let F=process.env.CLAUDE_CODE_TMPDIR||process.env.CLAUDE_TMPDIR||"/tmp/claude";V.push(`TMPDIR=${F}`)}if(X)for(let F of MM)V.push(`${F}=${X}`);if(!$&&!J)return V;let H=["localhost","127.0.0.1","::1","169.254.0.0/16","10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"].join(",");if(V.push(`NO_PROXY=${H}`),V.push(`no_proxy=${H}`),$){if(V.push(`HTTP_PROXY=http://${U}${O}:${$}`),V.push(`HTTPS_PROXY=http://${U}${O}:${$}`),V.push(`http_proxy=http://${U}${O}:${$}`),V.push(`https_proxy=http://${U}${O}:${$}`),Q)V.push("GIT_CONFIG_PARAMETERS='http.proxyAuthMethod=basic'")}let q=$?`http://${U}${O}:${$}`:`socks5h://${U}${O}:${J}`;if(V.push(`ALL_PROXY=${q}`),V.push(`all_proxy=${q}`),V.push(`GRPC_PROXY=${q}`),V.push(`grpc_proxy=${q}`),J){let K=P$();if(K==="macos")V.push(`GIT_SSH_COMMAND=ssh -o ControlMaster=no -o ControlPath=none -o ProxyCommand='nc -X 5 -x localhost:${J} %h %p'`);else if(K==="linux"&&$){let R=Q?`,proxyauth=${W}:${Q}`:"";V.push(`GIT_SSH_COMMAND=ssh -o ControlMaster=no -o ControlPath=none -o ProxyCommand='socat - PROXY:${O}:%h:%p,proxyport=${$}${R}'`)}if(V.push(`FTP_PROXY=socks5h://${U}${O}:${J}`),V.push(`ftp_proxy=socks5h://${U}${O}:${J}`),V.push(`RSYNC_PROXY=${O}:${J}`),V.push(`DOCKER_HTTP_PROXY=http://${U}${O}:${$||J}`),V.push(`DOCKER_HTTPS_PROXY=http://${U}${O}:${$||J}`),$){if(V.push("CLOUDSDK_PROXY_TYPE=http"),V.push(`CLOUDSDK_PROXY_ADDRESS=${O}`),V.push(`CLOUDSDK_PROXY_PORT=${$}`),Q)V.push(`CLOUDSDK_PROXY_USERNAME=${W}`),V.push(`CLOUDSDK_PROXY_PASSWORD=${Q}`)}}return V}var UM=8;function UX($){if($.baseEnv?.GIT_CONFIG_COUNT==="0")return{};let J=Number.parseInt($.baseEnv?.GIT_CONFIG_COUNT??"",10),X=Number.isFinite(J)&&J>=0?J:0,Q=X,Y={},G=(M,U)=>{Y[`GIT_CONFIG_KEY_${Q}`]=M,Y[`GIT_CONFIG_VALUE_${Q}`]=U,Q++},W=[...new Set($.safeDirs.filter((M)=>!!M).map((M)=>{let O=M.replace(/\\/g,"/").replace(/\/+$/,"");if(O===""||/^[A-Za-z]:$/.test(O))return`${O}/`;return O}))];if(W.length>UM)G("safe.directory","*");else for(let M of W)G("safe.directory",M),G("safe.directory",M.endsWith("/")?`${M}*`:`${M}/*`);if($.schannelCa)G("http.schannelUseSSLCAInfo","true"),G("http.schannelCheckRevoke","false");if(Q===X)return{};return Y.GIT_CONFIG_COUNT=String(Q),Y}function JY($){let J={GIT_CONFIG_COUNT:process.env.GIT_CONFIG_COUNT};for(let X of $.unsetEnvVars??[])delete J[X];return Object.assign(J,$.setEnvVars??{}),UX({safeDirs:$.safeDirs,baseEnv:J})}function wJ($){let J=$.slice(0,100);return Buffer.from(J).toString("base64")}function a0($){return Buffer.from($,"base64").toString("utf8")}var H0="srt";function OM($){if(!$)return H0;let J=`${H0}.${$}`;return Buffer.byteLength(J)<=255?J:H0}function QY($){if(!$||!$.startsWith(`${H0}.`))return;return $.slice(H0.length+1)||void 0}function OX($){return"^"+$.replace(/[.^$+{}()|\\]/g,"\\$&").replace(/\[([^\]]*?)$/g,"\\[$1").replace(/\*\*\//g,"__GLOBSTAR_SLASH__").replace(/\*\*/g,"__GLOBSTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__GLOBSTAR_SLASH__/g,"(.*/)?").replace(/__GLOBSTAR__/g,".*")+"$"}function s0($,J={}){let X=(U)=>process.platform==="win32"?U.replace(/\\/g,"/"):U,Q=X(e$($)),Y=Q.split(/[*?[\]]/)[0];if(!Y||Y==="/")return Z(`[Sandbox] Glob pattern too broad, skipping: ${$}`),[];let G=Y.endsWith("/")?Y.slice(0,-1):WJ.dirname(Y);if(!o0.existsSync(G))return Z(`[Sandbox] Base directory for glob does not exist: ${G}`),[];let W=new RegExp(OX(Q),J.caseInsensitive?"i":""),M=[];try{let U=o0.readdirSync(G,{recursive:!0,withFileTypes:!0});for(let O of U){let V=O.parentPath??O.path??G,H=WJ.join(V,O.name);if(W.test(X(H)))M.push(H)}}catch(U){Z(`[Sandbox] Error expanding glob pattern ${$}: ${U}`)}return M}var UW=T9(_8(),1);import{sign as rV,X509Certificate as tV}from"crypto";import{mkdtempSync as OW,readFileSync as x8,writeFileSync as v8}from"fs";import{rm as eV}from"fs/promises";import{tmpdir as VW}from"os";import{join as TX,dirname as GW}from"path";import{rootCertificates as $H}from"tls";var{asn1:i$,pki:lJ,md:JH,random:QH,util:HW}=UW.default,XH=lJ.getTBSCertificate,YH=/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g,yY="/srt.crl";function k8($){let J=$.getExtension("subjectKeyIdentifier");return J?.subjectKeyIdentifier?HW.hexToBytes(J.subjectKeyIdentifier):$.generateSubjectKeyIdentifier().getBytes()}function f8($,J){let X=lJ.oids.sha256WithRSAEncryption;$.siginfo.algorithmOid=X,$.signatureOid=X,$.tbsCertificate=XH($);let Q=i$.toDer($.tbsCertificate).getBytes();$.signature=qW(Q,J),$.md=JH.sha256.create(),$.md.update(Q)}function qW($,J){return rV("sha256",Buffer.from($,"binary"),J).toString("binary")}function y8($){if($.caCertPem&&$.caKeyPem){let J=IX($.caCertPem,$.caKeyPem);if(!J.ok)throw Error(`tlsTerminate: CA PEM pair: ${J.reason}`);return b8($.caCertPem,$.caKeyPem,J.cert,J.key,{certPath:$.caCertPath??"",keyPath:$.caKeyPath??"",extraCaCertPaths:$.extraCaCertPaths})}if($.caCertPath&&$.caKeyPath)return MH($.caCertPath,$.caKeyPath,$.extraCaCertPaths);if($.caCertPath||$.caKeyPath)throw Error("tlsTerminate: caCertPath and caKeyPath must be provided together");return UH($.extraCaCertPaths)}async function KW($){let J=new Set([GW($.trustBundlePath)]);if($.ephemeral)J.add(GW($.certPath));for(let X of J)try{await eV(X,{recursive:!0,force:!0})}catch(Q){Z(`[mitm-ca] cleanup failed: ${Q.message}`,{level:"warn"})}}function GH($,J,X){let Q=[J.trim(),...$H],Y=process.env.NODE_EXTRA_CA_CERTS;if(Y)try{Q.push(x8(Y,"utf8").trim())}catch{}for(let W of X??[]){let M;try{M=x8(W,"utf8")}catch(O){let V=O.code??String(O);Z(`[mitm-ca] extraCaCertPaths: cannot read ${W} (${V}); skipping`,{level:"warn"});continue}let U=M.match(YH);if(!U){Z(`[mitm-ca] extraCaCertPaths: ${W} has no PEM CERTIFICATE block; skipping`,{level:"warn"});continue}Q.push(...U)}let G=TX($,"trust-bundle.crt");return v8(G,Q.join(`
|
|
18
|
+
`;var W=QJ.util.createBuffer();hQ(W,Q),U0(W,$.e),U0(W,$.n);var U=QJ.util.encode64(W.bytes(),64),M=Math.floor(U.length/66)+1;G+="Public-Lines: "+M+`\r
|
|
19
|
+
`,G+=U;var O=QJ.util.createBuffer();U0(O,$.d),U0(O,$.p),U0(O,$.q),U0(O,$.qInv);var V;if(!J)V=QJ.util.encode64(O.bytes(),64);else{var H=O.length()+16-1;H-=H%16;var q=cY(O.bytes());q.truncate(q.length()-H+O.length()),O.putBuffer(q);var F=QJ.util.createBuffer();F.putBuffer(cY("\x00\x00\x00\x00",J)),F.putBuffer(cY("\x00\x00\x00\x01",J));var K=QJ.aes.createEncryptionCipher(F.truncate(8),"CBC");K.start(QJ.util.createBuffer().fillWithByte(0,16)),K.update(O.copy()),K.finish();var A=K.output;A.truncate(16),V=QJ.util.encode64(A.bytes(),64)}M=Math.floor(V.length/66)+1,G+=`\r
|
|
20
|
+
Private-Lines: `+M+`\r
|
|
21
|
+
`,G+=V;var L=cY("putty-private-key-file-mac-key",J),R=QJ.util.createBuffer();hQ(R,Q),hQ(R,Y),hQ(R,X),R.putInt32(W.length()),R.putBuffer(W),R.putInt32(O.length()),R.putBuffer(O);var I=QJ.hmac.create();return I.start("sha1",L),I.update(R.bytes()),G+=`\r
|
|
22
|
+
Private-MAC: `+I.digest().toHex()+`\r
|
|
23
|
+
`,G};nY.publicKeyToOpenSSH=function($,J){var X="ssh-rsa";J=J||"";var Q=QJ.util.createBuffer();return hQ(Q,X),U0(Q,$.e),U0(Q,$.n),X+" "+QJ.util.encode64(Q.bytes())+" "+J};nY.privateKeyToOpenSSH=function($,J){if(!J)return QJ.pki.privateKeyToPem($);return QJ.pki.encryptRsaPrivateKey($,J,{legacy:!0,algorithm:"aes128"})};nY.getPublicKeyFingerprint=function($,J){J=J||{};var X=J.md||QJ.md.md5.create(),Q="ssh-rsa",Y=QJ.util.createBuffer();hQ(Y,Q),U0(Y,$.e),U0(Y,$.n),X.start(),X.update(Y.getBytes());var G=X.digest();if(J.encoding==="hex"){var W=G.toHex();if(J.delimiter)return W.match(/.{2}/g).join(J.delimiter);return W}else if(J.encoding==="binary")return G.getBytes();else if(J.encoding)throw Error('Unknown encoding "'+J.encoding+'".');return G};function U0($,J){var X=J.toString(16);if(X[0]>="8")X="00"+X;var Q=QJ.util.hexToBytes(X);$.putInt32(Q.length),$.putBytes(Q)}function hQ($,J){$.putInt32(J.length),$.putString(J)}function cY(){var $=QJ.md.sha1.create(),J=arguments.length;for(var X=0;X<J;++X)$.update(arguments[X]);return $.digest()}});var n8=O$((yF,TW)=>{TW.exports=z$();w0();o1();mJ();EY();AX();HW();TQ();EW();NW();AW();L8();SY();JQ();H8();D8();ZW();B8();K8();X8();vY();_J();W8();jW();w8();w$()});var q4=O$((yN,H4)=>{var{create:vq,defineProperty:Q9,getOwnPropertyDescriptor:kq,getOwnPropertyNames:fq,getPrototypeOf:yq}=Object,bq=Object.prototype.hasOwnProperty,hq=($,J)=>{for(var X in J)Q9($,X,{get:J[X],enumerable:!0})},W4=($,J,X,Q)=>{if(J&&typeof J==="object"||typeof J==="function"){for(let Y of fq(J))if(!bq.call($,Y)&&Y!==X)Q9($,Y,{get:()=>J[Y],enumerable:!(Q=kq(J,Y))||Q.enumerable})}return $},U4=($,J,X)=>(X=$!=null?vq(yq($)):{},W4(J||!$||!$.__esModule?Q9(X,"default",{value:$,enumerable:!0}):X,$)),uq=($)=>W4(Q9({},"__esModule",{value:!0}),$),M4={};hq(M4,{Socks5Server:()=>V4,createServer:()=>pq,defaultConnectionHandler:()=>q7});H4.exports=uq(M4);var gq=U4(OX("net")),O4=(($)=>{return $[$.connect=1]="connect",$[$.bind=2]="bind",$[$.udp=3]="udp",$})(O4||{}),H7=(($)=>{return $[$.REQUEST_GRANTED=0]="REQUEST_GRANTED",$[$.GENERAL_FAILURE=1]="GENERAL_FAILURE",$[$.CONNECTION_NOT_ALLOWED=2]="CONNECTION_NOT_ALLOWED",$[$.NETWORK_UNREACHABLE=3]="NETWORK_UNREACHABLE",$[$.HOST_UNREACHABLE=4]="HOST_UNREACHABLE",$[$.CONNECTION_REFUSED=5]="CONNECTION_REFUSED",$[$.TTL_EXPIRED=6]="TTL_EXPIRED",$[$.COMMAND_NOT_SUPPORTED=7]="COMMAND_NOT_SUPPORTED",$[$.ADDRESS_TYPE_NOT_SUPPORTED=8]="ADDRESS_TYPE_NOT_SUPPORTED",$})(H7||{}),mq=class{constructor($,J){this.errorHandler=()=>{},this.metadata={},this.socket=J,this.server=$,J.on("error",this.errorHandler),J.pause(),this.handleGreeting()}readBytes($){return new Promise((J)=>{let X=Buffer.allocUnsafe($),Q=0,Y=(G)=>{let W=Math.min(G.length,$-Q);if(G.copy(X,Q,0,W),Q+=W,Q<$)return;this.socket.removeListener("data",Y),this.socket.push(G.subarray(W)),J(X),this.socket.pause()};this.socket.on("data",Y),this.socket.resume()})}async handleGreeting(){if((await this.readBytes(1)).readUInt8()!==5)return this.socket.destroy();let J=(await this.readBytes(1)).readUInt8();if(J>128||J===0)return this.socket.destroy();let X=await this.readBytes(J),Q=this.server.authHandler?2:0;if(!X.includes(Q))return this.socket.write(Buffer.from([5,255])),this.socket.destroy();if(this.socket.write(Buffer.from([5,Q])),this.server.authHandler)this.handleUserPassword();else this.handleConnectionRequest()}async handleUserPassword(){await this.readBytes(1);let $=(await this.readBytes(1)).readUint8(),J=(await this.readBytes($)).toString(),X=(await this.readBytes(1)).readUint8(),Q=(await this.readBytes(X)).toString();this.username=J,this.password=Q;let Y=!1,G=()=>{if(Y)return;Y=!0,this.socket.write(Buffer.from([1,0])),this.handleConnectionRequest()},W=()=>{if(Y)return;Y=!0,this.socket.write(Buffer.from([1,1])),this.socket.destroy()},U=await this.server.authHandler(this,G,W);if(U===!0)G();else if(U===!1)W()}async handleConnectionRequest(){await this.readBytes(1);let $=(await this.readBytes(1))[0],J=O4[$];if(!J)return this.socket.destroy();this.command=J,await this.readBytes(1);let X=(await this.readBytes(1)).readUInt8(),Q="";switch(X){case 1:Q=(await this.readBytes(4)).join(".");break;case 3:let O=(await this.readBytes(1)).readUInt8();Q=(await this.readBytes(O)).toString();break;case 4:let V=await this.readBytes(16);for(let H=0;H<16;H++){if(H%2===0&&H>0)Q+=":";Q+=`${V[H]<16?"0":""}${V[H].toString(16)}`}break;default:this.socket.destroy();return}let Y=(await this.readBytes(2)).readUInt16BE();if(!this.server.supportedCommands.has(J))return this.socket.write(Buffer.from([5,7])),this.socket.destroy();this.destAddress=Q,this.destPort=Y;let G=!1,W=()=>{if(G)return;G=!0,this.connect()};if(!this.server.rulesetValidator)return W();let U=()=>{if(G)return;G=!0,this.socket.write(Buffer.from([5,2,0,1,0,0,0,0,0,0])),this.socket.destroy()},M=await this.server.rulesetValidator(this,W,U);if(M===!0)W();else if(M===!1)U()}connect(){this.socket.removeListener("error",this.errorHandler),this.server.connectionHandler(this,($)=>{if(H7[$]===void 0)throw Error(`"${$}" is not a valid status.`);if(this.socket.write(Buffer.from([5,H7[$],0,1,0,0,0,0,0,0])),$!=="REQUEST_GRANTED")this.socket.destroy()}),this.socket.resume()}},lq=U4(OX("net"));function q7($,J){if($.command!=="connect")return J("COMMAND_NOT_SUPPORTED");$.socket.on("error",()=>{});let X=lq.default.createConnection({host:$.destAddress,port:$.destPort});X.setNoDelay();let Q=!1;return X.on("error",(Y)=>{if(!Q)switch(Y.code){case"EINVAL":case"ENOENT":case"ENOTFOUND":case"ETIMEDOUT":case"EADDRNOTAVAIL":case"EHOSTUNREACH":J("HOST_UNREACHABLE");break;case"ENETUNREACH":J("NETWORK_UNREACHABLE");break;case"ECONNREFUSED":J("CONNECTION_REFUSED");break;default:J("GENERAL_FAILURE")}}),X.on("ready",()=>{Q=!0,J("REQUEST_GRANTED"),$.socket.pipe(X).pipe($.socket)}),$.socket.on("close",()=>X.destroy()),X}var V4=class{constructor(){this.supportedCommands=new Set(["connect"]),this.connectionHandler=q7,this.server=gq.default.createServer(($)=>{$.setNoDelay(),this._handleConnection($)})}listen(...$){return this.server.listen(...$),this}close($){return this.server.close($),this}setAuthHandler($){return this.authHandler=$,this}disableAuthHandler(){return this.authHandler=void 0,this}setRulesetValidator($){return this.rulesetValidator=$,this}disableRulesetValidator(){return this.rulesetValidator=void 0,this}setConnectionHandler($){return this.connectionHandler=$,this}useDefaultConnectionHandler(){return this.connectionHandler=q7,this}_handleConnection($){return new mq(this,$),this}};function pq($){let J=new V4;if($?.auth)J.setAuthHandler((X)=>{return X.username===$.auth.username&&X.password===$.auth.password});if($?.port)J.listen($.port,$.hostname);return J}});import{Agent as Iq,createServer as Cq}from"http";import{request as V7}from"http";import{request as X4}from"https";import{connect as wq,isIP as Pq}from"net";import{URL as Y4}from"url";function Z($,J){if(!process.env.SRT_DEBUG)return;let X=J?.level||"info",Q="[SandboxDebug]";switch(X){case"error":console.error(`${Q} ${$}`);break;case"warn":console.warn(`${Q} ${$}`);break;default:console.error(`${Q} ${$}`)}}import{timingSafeEqual as gU}from"crypto";function MY($,J){let X=Buffer.from($),Q=Buffer.from(J);if(X.length!==Q.length)return!1;return gU(X,Q)}import{homedir as OY}from"os";import*as UJ from"path";import*as r0 from"fs";import*as qG from"fs";function m9(){if(process.platform!=="linux")return;try{let $=qG.readFileSync("/proc/version",{encoding:"utf8"}),J=$.match(/WSL(\d+)/i);if(J&&J[1])return J[1];if($.toLowerCase().includes("microsoft"))return"1";return}catch{return}}function x$(){switch(process.platform){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:return"unknown"}}var VX=[".gitconfig",".gitmodules",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".ripgreprc",".mcp.json"],mU=[".git",".vscode",".idea"];function HY(){return[...mU.filter(($)=>$!==".git"),".claude/commands",".claude/agents"]}function l9($){return $.toLowerCase()}function NJ($){return $.includes("*")||$.includes("?")||$.includes("[")||$.includes("]")}function HX($){return $.includes("*")||$.includes("?")}function KG($){return x$()==="windows"?HX($):NJ($)}function zG($){if(/^\\\\\?\\unc\\/i.test($))return"\\\\"+$.slice(8);if($.startsWith("\\\\?\\"))return $.slice(4);return $}function qX($){let J=UJ.win32.toNamespacedPath($);return/^[\\/]{2}[?.][\\/]unc[\\/]/i.test(J)}function E0($){return $.replace(/\/\*\*$/,"")||"/"}function VY($,J){let X=UJ.normalize($),Q=UJ.normalize(J);if(Q===X)return!1;if(X.startsWith("/tmp/")&&Q==="/private"+X)return!1;if(X.startsWith("/var/")&&Q==="/private"+X)return!1;if(X.startsWith("/private/tmp/")&&Q===X)return!1;if(X.startsWith("/private/var/")&&Q===X)return!1;if(Q==="/")return!0;if(Q.split("/").filter(Boolean).length<=1)return!0;if(X.startsWith(Q+"/"))return!0;let G=X;if(X.startsWith("/tmp/"))G="/private"+X;else if(X.startsWith("/var/"))G="/private"+X;if(G!==X&&G.startsWith(Q+"/"))return!0;let W=Q.startsWith(X+"/"),U=G!==X&&Q.startsWith(G+"/");if(Q!==X&&!(G!==X&&Q===G)&&!W&&!U)return!0;return!1}function lU($){if($==="~")return OY();if($.startsWith("~/")||process.platform==="win32"&&$.startsWith("~\\"))return OY()+$.slice(1);return $}function pU($){let J=OY(),X=/^[A-Za-z]:/.test(J)?J.slice(0,2):"",Q=X?J.slice(2):J;return $.replace(/%USERPROFILE%/gi,J).replace(/%HOMEDRIVE%/gi,X).replace(/%HOMEPATH%/gi,Q)}function JJ($){let J=process.cwd();if(x$()==="windows"){if($=zG(pU($)),/^[a-z]:/.test($))$=$[0].toUpperCase()+$.slice(1);if(qX($)&&!HX($))return UJ.win32.normalize($)}if(x$()!=="windows"&&$.endsWith("/")&&$!=="/"&&!KG($))$=$.replace(/\/+$/,"")||"/";let X=lU($);if(X!==$);else if($.startsWith("./")||$.startsWith("../"))X=UJ.resolve(J,$);else if(!UJ.isAbsolute($))X=UJ.resolve(J,$);if(KG(X)){let Q=x$()==="windows"?/[*?]/:/[*?[\]]/,Y=X.split(Q)[0];if(Y&&Y!=="/"){let G=Y.endsWith("/")?Y.slice(0,-1):UJ.dirname(Y);try{let W=r0.realpathSync(G);if(!VY(G,W)){let U=X.slice(G.length);return W+U}}catch{}}return X}try{let Q=r0.realpathSync(X);if(VY(X,Q));else X=Q}catch{}return X}function DQ($){let J=$??OY();return["/dev/stdout","/dev/stderr","/dev/null","/dev/tty","/dev/dtracehelper","/dev/autofs_nowait","/tmp/claude","/private/tmp/claude",UJ.join(J,".npm/_logs"),UJ.join(J,".claude/debug")]}var dU=["NODE_EXTRA_CA_CERTS","SSL_CERT_FILE","CURL_CA_BUNDLE","REQUESTS_CA_BUNDLE","PIP_CERT","GIT_SSL_CAINFO","AWS_CA_BUNDLE","CARGO_HTTP_CAINFO","DENO_CERT","CLOUDSDK_CORE_CUSTOM_CA_CERTS_FILE","NIX_SSL_CERT_FILE"];function ZQ($,J,X,Q,Y,G){let W=nU(G),U=W===z0?W:encodeURIComponent(W),M=Q?`${U}:${Q}@`:"",O=x$()==="linux"?"127.0.0.1":"localhost",V=["SANDBOX_RUNTIME=1"];if(!Y){let F=process.env.CLAUDE_CODE_TMPDIR||process.env.CLAUDE_TMPDIR||"/tmp/claude";V.push(`TMPDIR=${F}`)}if(X)for(let F of dU)V.push(`${F}=${X}`);if(!$&&!J)return V;let H=["localhost","127.0.0.1","::1","169.254.0.0/16","10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"].join(",");if(V.push(`NO_PROXY=${H}`),V.push(`no_proxy=${H}`),$){if(V.push(`HTTP_PROXY=http://${M}${O}:${$}`),V.push(`HTTPS_PROXY=http://${M}${O}:${$}`),V.push(`http_proxy=http://${M}${O}:${$}`),V.push(`https_proxy=http://${M}${O}:${$}`),Q)V.push("GIT_CONFIG_PARAMETERS='http.proxyAuthMethod=basic'")}let q=$?`http://${M}${O}:${$}`:`socks5h://${M}${O}:${J}`;if(V.push(`ALL_PROXY=${q}`),V.push(`all_proxy=${q}`),V.push(`GRPC_PROXY=${q}`),V.push(`grpc_proxy=${q}`),J){let K=x$();if(K==="macos")V.push(`GIT_SSH_COMMAND=ssh -o ControlMaster=no -o ControlPath=none -o ProxyCommand='nc -X 5 -x localhost:${J} %h %p'`);else if(K==="linux"&&$){let A=Q?`,proxyauth=${W}:${Q}`:"";V.push(`GIT_SSH_COMMAND=ssh -o ControlMaster=no -o ControlPath=none -o ProxyCommand='socat - PROXY:${O}:%h:%p,proxyport=${$}${A}'`)}if(V.push(`FTP_PROXY=socks5h://${M}${O}:${J}`),V.push(`ftp_proxy=socks5h://${M}${O}:${J}`),V.push(`RSYNC_PROXY=${O}:${J}`),V.push(`DOCKER_HTTP_PROXY=http://${M}${O}:${$||J}`),V.push(`DOCKER_HTTPS_PROXY=http://${M}${O}:${$||J}`),$){if(V.push("CLOUDSDK_PROXY_TYPE=http"),V.push(`CLOUDSDK_PROXY_ADDRESS=${O}`),V.push(`CLOUDSDK_PROXY_PORT=${$}`),Q)V.push(`CLOUDSDK_PROXY_USERNAME=${W}`),V.push(`CLOUDSDK_PROXY_PASSWORD=${Q}`)}}return V}var cU=8;function KX($){if($.baseEnv?.GIT_CONFIG_COUNT==="0")return{};let J=Number.parseInt($.baseEnv?.GIT_CONFIG_COUNT??"",10),X=Number.isFinite(J)&&J>=0?J:0,Q=X,Y={},G=(U,M)=>{Y[`GIT_CONFIG_KEY_${Q}`]=U,Y[`GIT_CONFIG_VALUE_${Q}`]=M,Q++},W=[...new Set($.safeDirs.filter((U)=>!!U).map((U)=>{let O=U.replace(/\\/g,"/").replace(/\/+$/,"");if(O===""||/^[A-Za-z]:$/.test(O))return`${O}/`;return O}))];if(W.length>cU)G("safe.directory","*");else for(let U of W)G("safe.directory",U),G("safe.directory",U.endsWith("/")?`${U}*`:`${U}/*`);if($.schannelCa)G("http.schannelUseSSLCAInfo","true"),G("http.schannelCheckRevoke","false");if(Q===X)return{};return Y.GIT_CONFIG_COUNT=String(Q),Y}function qY($){let J={GIT_CONFIG_COUNT:process.env.GIT_CONFIG_COUNT};for(let X of $.unsetEnvVars??[])delete J[X];return Object.assign(J,$.setEnvVars??{}),KX({safeDirs:$.safeDirs,baseEnv:J})}function PJ($){let J=$.slice(0,100);return Buffer.from(J).toString("base64")}function t0($){return Buffer.from($,"base64").toString("utf8")}var z0="srt";function nU($){if(!$)return z0;let J=`${z0}.${$}`;return Buffer.byteLength(J)<=255?J:z0}function KY($){if(!$||!$.startsWith(`${z0}.`))return;return $.slice(z0.length+1)||void 0}function zX($){return"^"+$.replace(/[.^$+{}()|\\]/g,"\\$&").replace(/\[([^\]]*?)$/g,"\\[$1").replace(/\*\*\//g,"__GLOBSTAR_SLASH__").replace(/\*\*/g,"__GLOBSTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__GLOBSTAR_SLASH__/g,"(.*/)?").replace(/__GLOBSTAR__/g,".*")+"$"}function e0($,J={}){let X=(M)=>process.platform==="win32"?M.replace(/\\/g,"/"):M,Q=X(JJ($)),Y=Q.split(/[*?[\]]/)[0];if(!Y||Y==="/")return Z(`[Sandbox] Glob pattern too broad, skipping: ${$}`),[];let G=Y.endsWith("/")?Y.slice(0,-1):UJ.dirname(Y);if(!r0.existsSync(G))return Z(`[Sandbox] Base directory for glob does not exist: ${G}`),[];let W=new RegExp(zX(Q),J.caseInsensitive?"i":""),U=[];try{let M=r0.readdirSync(G,{recursive:!0,withFileTypes:!0});for(let O of M){let V=O.parentPath??O.path??G,H=UJ.join(V,O.name);if(W.test(X(H)))U.push(H)}}catch(M){Z(`[Sandbox] Error expanding glob pattern ${$}: ${M}`)}return U}var wW=g9(n8(),1);import{sign as kH,X509Certificate as fH}from"crypto";import{mkdtempSync as PW,readFileSync as i8,writeFileSync as o8}from"fs";import{rm as yH}from"fs/promises";import{tmpdir as _W}from"os";import{join as PX,dirname as SW}from"path";import{rootCertificates as bH}from"tls";var{asn1:r$,pki:pJ,md:hH,random:uH,util:xW}=wW.default,gH=pJ.getTBSCertificate,mH=/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g,iY="/srt.crl";function a8($){let J=$.getExtension("subjectKeyIdentifier");return J?.subjectKeyIdentifier?xW.hexToBytes(J.subjectKeyIdentifier):$.generateSubjectKeyIdentifier().getBytes()}function s8($,J){let X=pJ.oids.sha256WithRSAEncryption;$.siginfo.algorithmOid=X,$.signatureOid=X,$.tbsCertificate=gH($);let Q=r$.toDer($.tbsCertificate).getBytes();$.signature=vW(Q,J),$.md=hH.sha256.create(),$.md.update(Q)}function vW($,J){return kH("sha256",Buffer.from($,"binary"),J).toString("binary")}function r8($){if($.caCertPem&&$.caKeyPem){let J=xX($.caCertPem,$.caKeyPem);if(!J.ok)throw Error(`tlsTerminate: CA PEM pair: ${J.reason}`);return t8($.caCertPem,$.caKeyPem,J.cert,J.key,{certPath:$.caCertPath??"",keyPath:$.caKeyPath??"",extraCaCertPaths:$.extraCaCertPaths})}if($.caCertPath&&$.caKeyPath)return dH($.caCertPath,$.caKeyPath,$.extraCaCertPaths);if($.caCertPath||$.caKeyPath)throw Error("tlsTerminate: caCertPath and caKeyPath must be provided together");return cH($.extraCaCertPaths)}async function kW($){let J=new Set([SW($.trustBundlePath)]);if($.ephemeral)J.add(SW($.certPath));for(let X of J)try{await yH(X,{recursive:!0,force:!0})}catch(Q){Z(`[mitm-ca] cleanup failed: ${Q.message}`,{level:"warn"})}}function lH($,J,X){let Q=[J.trim(),...bH],Y=process.env.NODE_EXTRA_CA_CERTS;if(Y)try{Q.push(i8(Y,"utf8").trim())}catch{}for(let W of X??[]){let U;try{U=i8(W,"utf8")}catch(O){let V=O.code??String(O);Z(`[mitm-ca] extraCaCertPaths: cannot read ${W} (${V}); skipping`,{level:"warn"});continue}let M=U.match(mH);if(!M){Z(`[mitm-ca] extraCaCertPaths: ${W} has no PEM CERTIFICATE block; skipping`,{level:"warn"});continue}Q.push(...M)}let G=PX($,"trust-bundle.crt");return o8(G,Q.join(`
|
|
24
24
|
`)+`
|
|
25
|
-
`,{mode:420}),G}function
|
|
26
|
-
`)}function
|
|
25
|
+
`,{mode:420}),G}function pH($,J){let X=pJ.oids.sha256WithRSAEncryption,Q=()=>uQ([r$.create(hJ.UNIVERSAL,M0.OID,!1,r$.oidToDer(X).getBytes()),r$.create(hJ.UNIVERSAL,M0.NULL,!1,"")]),Y=(q,F)=>uQ([r$.create(hJ.UNIVERSAL,M0.OID,!1,r$.oidToDer(q).getBytes()),r$.create(hJ.UNIVERSAL,M0.OCTETSTRING,!1,r$.toDer(F).getBytes())]),G=r$.create(hJ.CONTEXT_SPECIFIC,0,!0,[uQ([Y(pJ.oids.authorityKeyIdentifier,uQ([r$.create(hJ.CONTEXT_SPECIFIC,0,!1,a8($))])),Y("2.5.29.20",r$.create(hJ.UNIVERSAL,M0.INTEGER,!1,"\x01"))])]),W=new Date,U=$.validity.notAfter,M=U>W?U:_X(1),O=uQ([r$.create(hJ.UNIVERSAL,M0.INTEGER,!1,"\x01"),Q(),pJ.distinguishedNameToAsn1($.subject),IW(W),IW(M),G]),V=vW(r$.toDer(O).getBytes(),J),H=uQ([O,Q(),r$.create(hJ.UNIVERSAL,M0.BITSTRING,!1,"\x00"+V)]);return Buffer.from(r$.toDer(H).getBytes(),"binary")}var{Class:hJ,Type:M0}=r$;function uQ($){return r$.create(hJ.UNIVERSAL,M0.SEQUENCE,!0,$)}function IW($){return $.getUTCFullYear()<2050?r$.create(hJ.UNIVERSAL,M0.UTCTIME,!1,r$.dateToUtcTime($)):r$.create(hJ.UNIVERSAL,M0.GENERALIZEDTIME,!1,r$.dateToGeneralizedTime($))}function dH($,J,X){let Q=CW($,"CERTIFICATE","tlsTerminate.caCertPath"),Y=CW(J,"PRIVATE KEY","tlsTerminate.caKeyPath"),G=xX(Q,Y);if(!G.ok)throw Error(`tlsTerminate: CA at ${$}: ${G.reason}`);return Z(`[mitm-ca] loaded CA from ${$}`),t8(Q,Y,G.cert,G.key,{certPath:$,keyPath:J,extraCaCertPaths:X})}function t8($,J,X,Q,Y){let G=PW(PX(_W(),"srt-ca-"));return{certPath:Y.certPath,keyPath:Y.keyPath,trustBundlePath:lH(G,$,Y.extraCaCertPaths),certPem:$,keyPem:J,cert:X,key:Q,leafCerts:new Map,secureContexts:new Map,crlDer:pH(X,J),ephemeral:Y.ephemeral??!1}}function oY($={}){let J=pJ.rsa.generateKeyPair(2048),X=pJ.createCertificate();X.publicKey=J.publicKey,X.serialNumber=e8(),X.validity.notBefore=_X(-1),X.validity.notAfter=_X($.validityDays??825);let Q=[{name:"commonName",value:$.cn??"sandbox-runtime ephemeral CA"},{name:"organizationName",value:"sandbox-runtime"}];X.setSubject(Q),X.setIssuer(Q),X.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",critical:!0,keyCertSign:!0,cRLSign:!0,digitalSignature:!0},{name:"subjectKeyIdentifier"}]);let Y=pJ.privateKeyToPem(J.privateKey);return s8(X,Y),{certPem:pJ.certificateToPem(X),keyPem:Y,cert:X,key:J.privateKey}}function gQ($){return new fH($).fingerprint.replace(/:/g,"").toUpperCase()}function xX($,J){let X,Q;try{X=pJ.certificateFromPem($),Q=pJ.privateKeyFromPem(J)}catch(W){return{ok:!1,reason:`parse: ${W.message}`}}if(!("n"in Q)||!("d"in Q))return{ok:!1,reason:"key is not RSA"};if(X.validity.notBefore.getTime()>Date.now())return{ok:!1,reason:`notBefore ${X.validity.notBefore.toISOString()} is in the future (clock skew?)`};let Y=X.publicKey;if(!("n"in Y)||Y.n.compareTo(Q.n))return{ok:!1,reason:"key does not match certificate public key"};let G;try{G=gQ($)}catch(W){return{ok:!1,reason:`thumbprint: ${W.message}`}}return{ok:!0,thumbprint:G,notAfter:X.validity.notAfter,cert:X,key:Q}}function cH($){let{certPem:J,keyPem:X,cert:Q,key:Y}=oY(),G=PW(PX(_W(),"srt-ca-")),W=PX(G,"ca.crt"),U=PX(G,"ca.key");return o8(W,J,{mode:420}),o8(U,X,{mode:384}),Z(`[mitm-ca] generated ephemeral CA at ${W}`),t8(J,X,Q,Y,{certPath:W,keyPath:U,extraCaCertPaths:$,ephemeral:!0})}function CW($,J,X){let Q;try{Q=i8($,"utf8")}catch(Y){let G=Y.code??String(Y);throw Error(`${X}: cannot read ${$} (${G})`)}if(!new RegExp(`-----BEGIN [A-Z ]*${J}-----`).test(Q))throw Error(`${X}: ${$} is not a PEM ${J}`);return Q}function e8(){let $=uH.getBytesSync(16),J=xW.bytesToHex($);return(parseInt(J[0],16)&7).toString(16)+J.slice(1)}function _X($){let J=new Date;return J.setDate(J.getDate()+$),J}import{PassThrough as nH,Readable as fW}from"stream";var $7=new Set(["GET","HEAD","OPTIONS"]),hW="denied by sandbox policy";function yW($,J){if(J.writableFinished||J.destroyed){$.destroy();return}J.once("finish",()=>$.destroy()),J.once("close",()=>$.destroy())}async function aY($,J,X,Q,Y,G){let W=J.method??"GET",U,M=J,O=Boolean(J.headers["content-length"]||J.headers["transfer-encoding"]),V=$7.has(W);if(!V||O){let F=new nH;F.on("error",()=>{}),J.pipe(F);let K=fW.toWeb(F),[A,L]=K.tee();U=A,M=fW.fromWeb(L);let R=M;R.on("error",()=>{}),J.on("error",(I)=>{F.end(),R.destroy(I)})}let H;try{if(U&&!(U instanceof ReadableStream))throw TypeError("Unexpected request body stream");let F=U&&!V?{body:U,duplex:"half"}:{};H=new Request(Q,{method:W,headers:iH(J),signal:Y,...F})}catch(F){let K=`malformed request: ${F.message}`;if(G?.(W,Q,K),bW(X,{action:"deny",reason:K}),U?.cancel().catch(()=>{}),M.destroy(),M!==J)yW(J,X);return null}let q;try{q=await $(H)}catch(F){q={action:"deny",reason:`sandbox policy check failed: ${F.message}`}}if(U&&!H.bodyUsed)U.cancel().catch(()=>{});if(q.action==="allow")return Z(`[request-filter] allow ${W} ${Q}`),M;if(G?.(W,Q,q.reason??hW),bW(X,q),M.destroy(),M!==J)yW(J,X);return null}function bW($,J){vX($,J.reason??hW)}function vX($,J){if(Z(`[request-filter] deny: ${J}`),$.headersSent){$.destroy();return}$.writeHead(403,{"Content-Type":"text/plain","X-Proxy-Error":"blocked-by-sandbox-runtime"}),$.end(J+`
|
|
26
|
+
`)}function iH($){let J=new Headers;for(let[X,Q]of Object.entries($.headers)){if(Q===void 0)continue;if(Array.isArray(Q))for(let Y of Q)J.append(X,Y);else J.append(X,Q)}return J}import{createServer as zq,request as Eq}from"https";import{connect as Fq,isIP as rW}from"net";import{unlink as Nq}from"fs";import{tmpdir as Lq}from"os";import{join as Aq}from"path";import{Transform as oH}from"stream";function aH($){return $.every((J)=>J.sentinel.length===J.realValue.length)}function sY($,J,X,Q){if($===void 0)return;let Y=J.headers["content-length"]!==void 0||J.headers["transfer-encoding"]!==void 0;if($7.has(J.method??"GET")&&!Y)return;let G=$(Q);if(!G?.length)return;if(J.headers["content-encoding"]!==void 0){Z(`[body-substitution] ${Q}: request body has Content-Encoding "${String(J.headers["content-encoding"])}"; masked-credential `+"substitution skipped \u2014 a sentinel in this body reaches the "+"upstream as the fake value",{level:"warn"});return}if(!aH(G))delete X["content-length"];return sH(G)}function sH($){let J=Math.max(...$.map((Q)=>Q.sentinel.length)),X;return new oH({transform(Q,Y,G){let W=Buffer.isBuffer(Q)?Q:Buffer.from(Q,Y),U=X?.length?Buffer.concat([X,W]):W,{out:M,tail:O}=rH(U,$,J);X=O,G(null,M)},flush(Q){Q(null,X?.length?X:void 0)}})}function rH($,J,X){let Q=[],Y=0;for(;;){let W=-1,U;for(let M of J){let O=$.indexOf(M.sentinel,Y);if(O!==-1&&(W===-1||O<W))W=O,U=M}if(U===void 0)break;Q.push($.subarray(Y,W),U.realValue),Y=W+U.sentinel.length}let G=Math.max(Y,$.length-(X-1));return Q.push($.subarray(Y,G)),{out:Buffer.concat(Q),tail:Buffer.from($.subarray(G))}}var uW=g9(n8(),1);import{isIP as tH}from"net";import{createSecureContext as eH}from"tls";var{pki:rY}=uW.default;function J7($,J){let X=$.leafCerts.get(J);if(X)return X;let Q=rY.rsa.generateKeyPair(2048),Y=rY.createCertificate();Y.publicKey=Q.publicKey,Y.serialNumber=e8();let G=_X(-1);Y.validity.notBefore=G,Y.validity.notAfter=Jq($.cert,G),Y.setSubject([{name:"commonName",value:J}]),Y.setIssuer($.cert.subject.attributes),Y.setExtensions([{name:"basicConstraints",cA:!1,critical:!0},{name:"keyUsage",critical:!0,digitalSignature:!0,keyEncipherment:!0},{name:"extKeyUsage",serverAuth:!0},{name:"subjectAltName",altNames:[$q(J)]},{name:"subjectKeyIdentifier"},{name:"authorityKeyIdentifier",keyIdentifier:a8($.cert)},...$.crlUrl?[{name:"cRLDistributionPoints",altNames:[{type:6,value:$.crlUrl}]}]:[]]),s8(Y,$.keyPem);let W={certPem:rY.certificateToPem(Y)+$.certPem,keyPem:rY.privateKeyToPem(Q.privateKey)};return $.leafCerts.set(J,W),Z(`[mitm-leaf] minted RSA leaf for ${J}`),W}function gW($,J){let X=$.secureContexts.get(J);if(X)return X;let{certPem:Q,keyPem:Y}=J7($,J),G=eH({cert:Q,key:Y});return $.secureContexts.set(J,G),G}function $q($){return tH($)!==0?{type:7,ip:$}:{type:2,value:$}}function Jq($,J){let X=$.validity.notAfter,Q=new Date(J);return Q.setDate(Q.getDate()+99),X<Q?new Date(X):Q}import{BlockList as mW,connect as lW,isIP as VQ}from"net";import{connect as Qq}from"tls";import{URL as Q7}from"url";var pW=30000,Xq=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade"]);function X7($){let J=$?.http??process.env.HTTP_PROXY??process.env.http_proxy??void 0,X=$?.https??process.env.HTTPS_PROXY??process.env.https_proxy??J,Q=$?.noProxy??process.env.NO_PROXY??process.env.no_proxy??"";if(!J&&!X)return;let Y=(U)=>{if(!U)return;let O=/^[a-z][a-z0-9+.-]*:\/\//i.test(U)?U:`http://${U}`;try{let V=new Q7(O);if(V.protocol!=="http:"&&V.protocol!=="https:"||!V.hostname)throw Error("unsupported scheme or empty host");return V}catch{Z(`Invalid parent proxy URL, ignoring: ${Wq(U)}`,{level:"error"});return}},G=Y(J),W=Y(X);if(!G&&!W)return;return{httpUrl:G,httpsUrl:W,noProxy:Yq(Q)}}function Yq($){let J={all:!1,suffixes:[],cidr:new mW};for(let X of $.split(",")){if(X=X.trim(),!X)continue;if(X==="*"){J.all=!0;continue}let Q=X.indexOf("/");if(Q!==-1){let U=X.slice(0,Q),M=X.slice(Q+1),O=VQ(U);if(O&&M!==""&&/^\d+$/.test(M)){let V=Number(M),H=O===6?128:32;if(V>=0&&V<=H){try{J.cidr.addSubnet(U,V,O===6?"ipv6":"ipv4")}catch{}continue}}continue}let Y=X.toLowerCase(),G=/^\[([^\]]+)\](?::\d+)?$/.exec(Y);if(G)Y=G[1];if(Y.startsWith("*."))Y=Y.slice(1);let W=VQ(Y);if(!W){let U=Y.lastIndexOf(":");if(U!==-1&&/^\d+$/.test(Y.slice(U+1)))Y=Y.slice(0,U)}else try{J.cidr.addAddress(Y,W===6?"ipv6":"ipv4");continue}catch{}J.suffixes.push(Y)}return J}function kX($,J){let X=dJ(J.toLowerCase().replace(/\.$/,""));if(X==="localhost")return!0;let Q=VQ(X);if(Q){if(Gq.check(X,Q===6?"ipv6":"ipv4"))return!0}if($.noProxy.all)return!0;if(Q){if($.noProxy.cidr.check(X,Q===6?"ipv6":"ipv4"))return!0}for(let Y of $.noProxy.suffixes)if(Y.startsWith(".")){if(X===Y.slice(1)||X.endsWith(Y))return!0}else if(X===Y||X.endsWith("."+Y))return!0;return!1}var Gq=(()=>{let $=new mW;return $.addSubnet("127.0.0.0",8,"ipv4"),$.addAddress("::1","ipv6"),$.addSubnet("::ffff:127.0.0.0",104,"ipv6"),$})();function fX($,J){if(J.isHttps)return $.httpsUrl??$.httpUrl;return $.httpUrl}function Y7($){let{destHost:J,destPort:X}=$,Q=dJ(J);if(!mQ(Q))return Promise.reject(Error(`Invalid destination host for CONNECT: ${JSON.stringify(J)}`));if(!Number.isInteger(X)||X<1||X>65535)return Promise.reject(Error(`Invalid destination port: ${X}`));let Y=VQ(Q)===6?`[${Q}]:${X}`:`${Q}:${X}`;return new Promise((G,W)=>{let U=$.dial(),M=!1,O=(H)=>{if(M)return;M=!0,U.destroy(),W(H)},V=()=>O(Error("Proxy closed during CONNECT handshake"));U.setTimeout($.timeoutMs??pW,()=>O(Error("CONNECT handshake timed out"))),U.once("error",O),U.once("close",V),U.once($.readyEvent,()=>{U.write(`CONNECT ${Y} HTTP/1.1\r
|
|
27
27
|
Host: ${Y}\r
|
|
28
28
|
`+($.authHeader?`Proxy-Authorization: ${$.authHeader}\r
|
|
29
29
|
`:"")+`\r
|
|
30
30
|
`);let H="",q=(F)=>{H+=F.toString("latin1");let K=H.indexOf(`\r
|
|
31
31
|
\r
|
|
32
|
-
`);if(K===-1){if(H.length>16384)O(Error("CONNECT response header too large"));return}
|
|
33
|
-
`));if(!/^HTTP\/1\.[01] 2\d\d(?:\s|$)/.test(
|
|
32
|
+
`);if(K===-1){if(H.length>16384)O(Error("CONNECT response header too large"));return}U.pause(),U.removeListener("data",q);let A=H.slice(0,H.indexOf(`\r
|
|
33
|
+
`));if(!/^HTTP\/1\.[01] 2\d\d(?:\s|$)/.test(A))return O(Error(`Proxy refused CONNECT: ${A.trim()}`));let L=H.slice(K+4);if(L.length)U.unshift(Buffer.from(L,"latin1"));M=!0,U.setTimeout(0),U.removeListener("error",O),U.removeListener("close",V),G(U)};U.on("data",q)})})}function tY($,J,X){let Q=dJ($.hostname),Y=Number($.port)||($.protocol==="https:"?443:80),G=$.protocol==="https:";return Y7({destHost:J,destPort:X,authHeader:G7($),readyEvent:G?"secureConnect":"connect",dial:()=>G?Qq({host:Q,port:Y,...VQ(Q)?{}:{servername:Q}}):lW(Y,Q)})}function G7($){if(!$.username&&!$.password)return;try{let J=`${decodeURIComponent($.username)}:${decodeURIComponent($.password)}`;return`Basic ${Buffer.from(J).toString("base64")}`}catch{let J=`${$.username}:${$.password}`;return`Basic ${Buffer.from(J).toString("base64")}`}}function h0($){let J=new Set,X=$.connection;if(X)for(let Y of String(X).split(","))J.add(Y.trim().toLowerCase());let Q={};for(let[Y,G]of Object.entries($)){let W=Y.toLowerCase();if(!Xq.has(W)&&!J.has(W))Q[Y]=G}return Q}function dJ($){return $.startsWith("[")&&$.endsWith("]")?$.slice(1,-1):$}function W7($){if(!$)return"-";if(!$.username&&!$.password)return $.href;let J=new Q7($.href);return J.username="***",J.password="***",J.href}function Wq($){return $.replace(/\/\/[^@/]*@/,"//***:***@")}function mQ($){if(!$||$.length>255)return!1;let J=dJ($);if(J.includes("%"))return!1;if(VQ(J))return!0;return/^[A-Za-z0-9._-]+$/.test(J)}function jJ($){try{let J=dJ($),X=VQ(J)===6?`[${J}]`:J,Q=new Q7(`http://${X}/`).hostname;return dJ(Q).replace(/\.$/,"")}catch{return}}function eY($,J,X=pW){return new Promise((Q,Y)=>{let G=lW(J,$),W=!1,U=(M)=>{if(W)return;if(W=!0,G.setTimeout(0),M)G.destroy(),Y(M);else Q(G)};G.setTimeout(X,()=>U(Error("connect timed out"))),G.once("connect",()=>U()),G.once("error",U),G.once("close",()=>U(Error("socket closed before connect")))})}import{createHash as Uq,createHmac as iW}from"crypto";var yX="AWS4-HMAC-SHA256",Mq="AWS4-ECDSA-P256-SHA256",J9="UNSIGNED-PAYLOAD";function oW($,J){let X=lQ($.authorization);if(X!==void 0&&X.startsWith(Mq)){let U=dW(X);if(U!==void 0)return{kind:"sigv4a",accessKeyId:U}}else if(X!==void 0&&X.startsWith(yX)){let U=dW(X);if(U!==void 0)return{kind:lQ($["x-amz-content-sha256"])?.startsWith("STREAMING-")?"streaming":"header-sigv4",accessKeyId:U}}let Q=J.indexOf("?");if(Q===-1)return null;let Y=new URLSearchParams(J.slice(Q+1));if(Y.get("X-Amz-Algorithm")!==yX)return null;if(!Y.has("X-Amz-Signature"))return null;let G=Y.get("X-Amz-Credential");if(!G)return null;let W=G.split("/")[0];return W?{kind:"presigned",accessKeyId:W}:null}function dW($){return/Credential=([^/,\s]+)\//.exec($)?.[1]}function aW($){if(!$.startsWith(yX))return null;let J=/Credential=([^,\s]+)/.exec($)?.[1],X=/SignedHeaders=([^,\s]+)/.exec($)?.[1],Q=/Signature=([0-9a-fA-F]+)/.exec($)?.[1];if(!J||!X||!Q)return null;let Y=J.split("/");if(Y.length!==5||Y[4]!=="aws4_request")return null;let[G,W,U,M]=Y;if(!G||!W||!U||!M)return null;return{accessKeyId:G,date:W,region:U,service:M,signedHeaders:X.split(";").map((O)=>O.toLowerCase()),signature:Q}}function U7($){return encodeURIComponent($).replace(/[!'()*]/g,(J)=>"%"+J.charCodeAt(0).toString(16).toUpperCase())}function Oq($,J){if($==="")return"/";if(J==="s3")return $;let X=[];for(let G of $.split("/")){if(G===""||G===".")continue;if(G==="..")X.pop();else X.push(G)}let Q=X.length>0&&$.endsWith("/")?"/":"",Y=`/${X.join("/")}${Q}`;return U7(Y).replace(/%2F/gi,"/")}function Vq($){if($==="")return"";let J=[];for(let X of $.split("&")){if(X==="")continue;let Q=X.indexOf("="),Y=Q===-1?X:X.slice(0,Q),G=Q===-1?"":X.slice(Q+1);J.push([U7(cW(Y)),U7(cW(G))])}return J.sort(([X,Q],[Y,G])=>X<Y?-1:X>Y?1:Q<G?-1:Q>G?1:0),J.map(([X,Q])=>`${X}=${Q}`).join("&")}function cW($){try{return decodeURIComponent($)}catch{return $}}function nW($){return $.trim().replace(/[ \t]+/g," ")}function Hq($){let J=$.requestTarget.indexOf("?"),X=J===-1?$.requestTarget:$.requestTarget.slice(0,J),Q=J===-1?"":$.requestTarget.slice(J+1),Y=[...$.signedHeaders].map((W)=>W.toLowerCase()).sort(),G=[];for(let W of Y){let U=W==="host"?$.hostHeader:$.headers[W];if(U===void 0)throw Error(`signed header "${W}" is missing from the request`);let M=Array.isArray(U)?U.map(nW).join(","):nW(String(U));G.push(`${W}:${M}`)}return[$.method.toUpperCase(),Oq(X,$.scope.service),Vq(Q),G.join(`
|
|
34
34
|
`)+`
|
|
35
35
|
`,Y.join(";"),$.payloadHash].join(`
|
|
36
|
-
`)}function
|
|
37
|
-
`)}function
|
|
36
|
+
`)}function qq($,J,X){return[yX,J,`${X.date}/${X.region}/${X.service}/aws4_request`,M7($)].join(`
|
|
37
|
+
`)}function Kq($,J){let X=$9(`AWS4${$}`,J.date),Q=$9(X,J.region),Y=$9(Q,J.service);return $9(Y,"aws4_request")}function sW($){let J=Hq($),X=qq(J,$.amzDate,$.scope),Q=iW("sha256",Kq($.secretAccessKey,$.scope)).update(X,"utf8").digest("hex"),Y=[...$.signedHeaders].map((W)=>W.toLowerCase()).sort(),G=`${$.scope.date}/${$.scope.region}/${$.scope.service}/aws4_request`;return{authorization:`${yX} Credential=${$.accessKeyId}/${G}, SignedHeaders=${Y.join(";")}, Signature=${Q}`,signature:Q,canonicalRequest:J,stringToSign:X}}function M7($){return Uq("sha256").update($).digest("hex")}function $9($,J){return iW("sha256",$).update(J,"utf8").digest()}function lQ($){return Array.isArray($)?$[0]:$}var $4=67108864;class O7 extends Error{}function tW($){return $.length>=3&&$[0]===22&&$[1]===3&&$[2]<=3}function J4($,J){if(J.length>=3)return Promise.resolve({isTLS:tW(J),head:J});return new Promise((X)=>{let Q=J,Y=()=>{$.removeListener("data",G),$.removeListener("close",Y),X({isTLS:tW(Q),head:Q})},G=(W)=>{if($.pause(),Q=Q.length?Buffer.concat([Q,W]):W,Q.length>=3)return Y();$.resume()};$.on("data",G),$.once("close",Y)})}function Rq($,J){let X=()=>{let Q;while((Q=$.read())!==null)if(!J.write(Q)){J.once("drain",X);return}$.once("readable",X)};X(),$.once("end",()=>J.end())}function Q4($,J,X,Q,Y,G,W,U,M=$4){let O=J7($,W.hostname),V=zq({ALPNProtocols:["http/1.1"],cert:O.certPem,key:O.keyPem,SNICallback:(F,K)=>{try{K(null,gW($,F||W.hostname))}catch(A){K(A)}}});V.on("request",(F,K)=>{F.on("error",(A)=>{Z(`[tls-terminate] client request error: ${A.message}`,{level:"error"})}),K.on("error",(A)=>{Z(`[tls-terminate] client response error: ${A.message}`,{level:"error"})}),Dq(J,X,Q,F,K,W,U,M)}),V.on("clientError",(F,K)=>{Z(`[tls-terminate] client connection error for ${W.hostname}: ${F.message}`,{level:"error"}),K.destroy()}),V.on("tlsClientError",(F,K)=>{Z(`[tls-terminate] client TLS error for ${W.hostname}: ${F.message}`,{level:"error"}),K.destroy()}),V.on("upgrade",(F,K)=>{Z("[tls-terminate] upgrade request refused",{level:"warn"}),K.destroy()});let H=Sq(),q=()=>{V.close(),Nq(H,()=>{})};V.on("error",(F)=>{Z(`[tls-terminate] inner server listen failed: ${F.message}`,{level:"error"}),Y.destroy(),q()}),V.listen(H,()=>{let F=Fq({path:H});F.on("error",(K)=>{Z(`[tls-terminate] inner loopback failed: ${K.message}`,{level:"error"}),Y.destroy(),q()}),F.once("connect",()=>{if(G.length)F.write(G);Rq(Y,F),F.pipe(Y)}),Y.on("error",()=>F.destroy()),Y.once("close",()=>{F.destroy(),q()}),F.once("close",()=>Y.destroy())}),V.unref()}function eW($,J){if(J.writableFinished||J.destroyed){$.destroy();return}J.once("finish",()=>$.destroy()),J.once("close",()=>$.destroy())}function Dq(...$){Zq(...$).catch((J)=>{Z(`[tls-terminate] forwardUpstream failed: ${J.message}`,{level:"error"})})}async function Zq($,J,X,Q,Y,G,W,U=$4){let M=jq(Q.url),O=Q;if($){let L=new AbortController;Y.once("close",()=>L.abort());let R=G.port===443?G.hostname:`${G.hostname}:${G.port}`,I=await aY($,Q,Y,`https://${R}${M}`,L.signal,G.onFilterRequestDeny);if(I===null)return;if(O=I,Q.destroyed&&!Q.readableEnded||Y.destroyed||Q.socket.destroyed||O.destroyed){O.destroy();return}}let V=h0(Q.headers);delete V.host;let H=W?.(Q.method??"GET",M,V,G.hostname);J?.(V,G.hostname);let q=sY(X,Q,V,G.hostname),F;if(H?.action==="deny"){if(vX(Y,H.reason),O.destroy(),O!==Q)eW(Q,Y);return}if(H?.action==="resign"){let L=H.payloadHash;if(L===void 0){let T=q?O.pipe(q):O;if(q)O.on("error",(C)=>q.destroy(C));try{F=await Bq(T,U)}catch(C){if(C instanceof O7){vX(Y,`AWS SigV4 request uses a masked credential and signs a literal body hash, so the proxy must buffer the body to re-sign it, but the body exceeds the ${U}-byte buffering limit; denied. Sign the payload as UNSIGNED-PAYLOAD to stream it without buffering, or use an unmasked credential to have the request forwarded untouched.`),T.resume();return}Z(`[tls-terminate] failed to buffer body for SigV4 re-sign: ${C.message}`,{level:"error"}),Y.destroy();return}L=M7(F),V["content-length"]=String(F.length)}let R=rW(G.hostname)===6?`[${G.hostname}]`:G.hostname,I=G.port===443?R:`${R}:${G.port}`;try{H.apply(V,I,L)}catch(T){if(vX(Y,`AWS SigV4 re-signing failed: ${T.message}`),O.destroy(),O!==Q)eW(Q,Y);return}}if(Boolean(Q.headers["content-length"]||Q.headers["transfer-encoding"])&&F===void 0&&V["content-length"]===void 0&&V["transfer-encoding"]===void 0)V["transfer-encoding"]="chunked";let A=Eq({host:G.hostname,port:G.port,path:M,method:Q.method,headers:V,...rW(G.hostname)?{}:{servername:G.hostname},...G.upstreamCA?{ca:G.upstreamCA}:{},agent:!1},(L)=>{L.on("error",(R)=>{Z(`[tls-terminate] upstream response error: ${R.message}`,{level:"error"}),Y.destroy()}),Y.writeHead(L.statusCode??502,h0(L.headers)),L.pipe(Y)});if(A.on("error",(L)=>{if(Z(`[tls-terminate] upstream ${G.hostname}:${G.port} failed: ${L.message}`,{level:"error"}),!Y.headersSent)Y.writeHead(502,{"Content-Type":"text/plain"}),Y.end("Bad Gateway");else Y.destroy()}),Y.on("close",()=>A.destroy()),F!==void 0)A.end(F);else if(q)q.on("error",(L)=>A.destroy(L)),O.on("error",(L)=>q.destroy(L)),Y.on("close",()=>q.destroy()),O.pipe(q).pipe(A);else O.on("error",(L)=>A.destroy(L)),O.pipe(A)}function Bq($,J){return new Promise((X,Q)=>{let Y=[],G=0,W=(U)=>{if(G+=U.length,G>J){Y.length=0,$.removeListener("data",W),Q(new O7(`request body exceeds ${J} bytes`));return}Y.push(U)};$.on("data",W),$.once("end",()=>X(Buffer.concat(Y))),$.once("error",Q)})}function jq($){let J=$??"/";if(J.startsWith("/"))return J;try{let X=new URL(J);return`${X.pathname}${X.search}`||"/"}catch{return J}}var Tq=0;function Sq(){return Aq(Lq(),`srt-tt-${process.pid}-${(Tq++).toString(36)}.sock`)}function _q($,J){if(!J)return{ok:!0};let X=/^basic\s+([a-z0-9+/=]+)\s*$/i.exec($??"");if(!X)return{ok:!1};let Q=Buffer.from(X[1],"base64").toString("utf8"),Y=Q.indexOf(":");if(Y<=0||!MY(Q.slice(Y+1),J))return{ok:!1};return{ok:!0,encodedCommand:KY(Q.slice(0,Y))}}function G4($){let J=Cq();J.on("clientError",(Q,Y)=>{if(Z(`Client connection error: ${Q.message}`,{level:"error"}),Y.on("error",()=>{}),Q.code!=="ECONNRESET"&&Y.writable){let G=Q.code==="HPE_HEADER_OVERFLOW"?"431 Request Header Fields Too Large":"400 Bad Request";Y.end(`HTTP/1.1 ${G}\r
|
|
38
38
|
\r
|
|
39
|
-
`,()=>Y.destroy()),setTimeout(()=>Y.destroy(),1000).unref?.();return}Y.destroy()});let X=(Q)=>
|
|
39
|
+
`,()=>Y.destroy()),setTimeout(()=>Y.destroy(),1000).unref?.();return}Y.destroy()});let X=(Q)=>_q(Q,$.proxyAuthToken);return J.on("connect",async(Q,Y,G)=>{Y.on("error",(R)=>{Z(`Client socket error: ${R.message}`,{level:"error"}),Y.destroy()});let W=!1;Y.once("close",()=>{W=!0});let U=()=>{W=!0,Y.destroy()},M=65536,O=0,V=!1,H=[],q=(R)=>{if(!V)return;if(O+=R.length,O>M){Z("CONNECT client exceeded pre-establishment capture cap; destroying",{level:"error"}),U();return}H.push(R)};if(!$.mitmCA)V=!0,Y.on("data",q);if(Y.readableEnded)U();else Y.once("end",U);let F=()=>{if(V=!1,H.length)G=Buffer.concat([G,...H]),H.length=0},K=()=>{Y.removeListener("end",U),F()},A=(R)=>{if(W||Y.destroyed||Y.readableEnded||!Y.writable){Z("CONNECT client gone before status write; dropping verdict and destroying socket"),Y.destroy();return}K(),Y.end(R)};if(W||Y.destroyed)return;let L=!1;try{let R=X(Q.headers["proxy-authorization"]);if(!R.ok){A(`HTTP/1.1 407 Proxy Authentication Required\r
|
|
40
40
|
Proxy-Authenticate: Basic realm="srt"\r
|
|
41
41
|
\r
|
|
42
|
-
`);return}let
|
|
42
|
+
`);return}let I=xq(Q.url);if(!I){Z(`Invalid CONNECT request: ${Q.url}`,{level:"error"}),A(`HTTP/1.1 400 Bad Request\r
|
|
43
43
|
\r
|
|
44
|
-
`);return}let{hostname:T,port:
|
|
44
|
+
`);return}let{hostname:T,port:C}=I;if(!await $.filter(C,T,Y,R.encodedCommand)){Z(`Connection blocked to ${T}:${C}`,{level:"error"}),A(`HTTP/1.1 403 Forbidden\r
|
|
45
45
|
Content-Type: text/plain\r
|
|
46
46
|
X-Proxy-Error: blocked-by-allowlist\r
|
|
47
47
|
\r
|
|
48
|
-
Connection blocked by network allowlist`);return}if(W||Y.destroyed){Y.destroy();return}let
|
|
48
|
+
Connection blocked by network allowlist`);return}if(W||Y.destroyed){Y.destroy();return}let P=jJ(T)??T;if($.mitmCA&&($.shouldTerminateTLS?.(P,C)??!0)){Y.write(`HTTP/1.1 200 Connection Established\r
|
|
49
49
|
\r
|
|
50
|
-
`),L=!0;let
|
|
50
|
+
`),L=!0;let $$=await J4(Y,G);if(W||Y.destroyed){Y.destroy();return}if($$.isTLS){K(),Q4($.mitmCA,$.filterRequest,$.mutateHeaders,$.getBodySubstitutions,Y,$$.head,{hostname:P,port:C,upstreamCA:$.tlsTerminateUpstreamCA,onFilterRequestDeny:$.onFilterRequestDenied?(N$,M$,b$)=>$.onFilterRequestDenied({method:N$,url:M$,reason:b$,encodedCommand:R.encodedCommand}):void 0},$.planSigv4,$.maxSigv4ResignBodyBytes);return}Z(`[tls-terminate] non-TLS bytes on CONNECT ${P}:${C}; opaque-tunnelling`),G=$$.head}else if($.mitmCA)Z(`[tls-terminate] policy exempts ${P}:${C}; opaque-tunnelling`);let l=$.getMitmSocketPath?.(P),k=!l&&$.parentProxy&&!kX($.parentProxy,P)?fX($.parentProxy,{isHttps:!0}):void 0,p;try{if(l)Z(`Routing CONNECT ${P}:${C} through MITM proxy at ${l}`),p=await Y7({dial:()=>wq({path:l}),readyEvent:"connect",destHost:P,destPort:C});else if(k)p=await tY(k,P,C);else p=await eY(P,C)}catch($$){if(Z(`CONNECT tunnel failed: ${$$.message}`,{level:"error"}),L)Y.destroy();else A(`HTTP/1.1 502 Bad Gateway\r
|
|
51
51
|
\r
|
|
52
|
-
`);return}if(W||Y.destroyed){
|
|
52
|
+
`);return}if(W||Y.destroyed){p.on("error",()=>{}),p.destroy(),Y.destroy();return}if(!L)Y.write(`HTTP/1.1 200 Connection Established\r
|
|
53
53
|
\r
|
|
54
|
-
`);if(K(),Y.allowHalfOpen=!0,G.length)
|
|
54
|
+
`);if(K(),Y.allowHalfOpen=!0,G.length)p.write(G);p.pipe(Y),Y.pipe(p),p.on("error",($$)=>{Z(`CONNECT tunnel failed: ${$$.message}`,{level:"error"}),Y.destroy()}),Y.on("close",()=>p.destroy()),p.on("close",()=>Y.destroy())}catch(R){if(Z(`Error handling CONNECT: ${R}`,{level:"error"}),L)Y.destroy();else A(`HTTP/1.1 500 Internal Server Error\r
|
|
55
55
|
\r
|
|
56
|
-
`)}}),J.on("request",async(Q,Y)=>{Q.on("error",(G)=>{Z(`Client request error: ${G.message}`,{level:"error"})}),Y.on("error",(G)=>{Z(`Client response error: ${G.message}`,{level:"error"}),Y.socket?.destroy()});try{if($.mitmCA&&Q.method==="GET"&&new
|
|
57
|
-
`)),$.end(
|
|
56
|
+
`)}}),J.on("request",async(Q,Y)=>{Q.on("error",(G)=>{Z(`Client request error: ${G.message}`,{level:"error"})}),Y.on("error",(G)=>{Z(`Client response error: ${G.message}`,{level:"error"}),Y.socket?.destroy()});try{if($.mitmCA&&Q.method==="GET"&&new Y4(Q.url??"","http://x").pathname===iY){Y.writeHead(200,{"Content-Type":"application/pkix-crl","Content-Length":$.mitmCA.crlDer.length}),Y.end($.mitmCA.crlDer);return}let G=X(Q.headers["proxy-authorization"]);if(!G.ok){Y.writeHead(407,{"Proxy-Authenticate":'Basic realm="srt"'}),Y.end();return}let W=new Y4(Q.url),U=dJ(W.hostname),M=W.port?parseInt(W.port,10):W.protocol==="https:"?443:80;if(!await $.filter(M,U,Q.socket,G.encodedCommand)){if(Z(`HTTP request blocked to ${U}:${M}`,{level:"error"}),Q.socket.destroyed||Y.destroyed){Y.destroy();return}Y.writeHead(403,{"Content-Type":"text/plain","X-Proxy-Error":"blocked-by-allowlist"}),Y.end("Connection blocked by network allowlist");return}if(Q.socket.destroyed)return;let V=jJ(U)??U,H=(Pq(V)===6?`[${V}]`:V)+(W.port?`:${W.port}`:""),q={...h0(Q.headers),host:H};$.mutateHeadersPlaintext?.(q,V);let F=sY($.getBodySubstitutionsPlaintext,Q,q,V),K=$.getMitmSocketPath?.(V),A=!K&&$.parentProxy&&!kX($.parentProxy,V)?fX($.parentProxy,{isHttps:W.protocol==="https:"}):void 0,L=`${W.protocol}//${H}${W.pathname}${W.search}`,R=Q;if($.filterRequest){let C=new AbortController;Y.once("close",()=>C.abort());let w=await aY($.filterRequest,Q,Y,L,C.signal,$.onFilterRequestDenied?(P,l,k)=>$.onFilterRequestDenied({method:P,url:l,reason:k,encodedCommand:G.encodedCommand}):void 0);if(w===null)return;if(R=w,Q.destroyed&&!Q.readableEnded||Y.destroyed||Q.socket.destroyed||R.destroyed){R.destroy();return}}if(Boolean(Q.headers["content-length"]||Q.headers["transfer-encoding"])&&q["content-length"]===void 0&&q["transfer-encoding"]===void 0)q["transfer-encoding"]="chunked";let T;if(K){Z(`Routing HTTP ${Q.method} ${V}:${M} through MITM proxy at ${K}`);let C=new Iq({socketPath:K});T=V7({agent:C,path:L,method:Q.method,headers:q},(w)=>{w.on("error",(P)=>{Z(`Upstream response error: ${P.message}`,{level:"error"}),Y.destroy()}),Y.writeHead(w.statusCode,h0(w.headers)),w.pipe(Y)})}else if(A){let C=dJ(A.hostname),w=Number(A.port)||(A.protocol==="https:"?443:80),P=G7(A);T=(A.protocol==="https:"?X4:V7)({hostname:C,port:w,path:L,method:Q.method,headers:P?{...q,"proxy-authorization":P}:q},(k)=>{k.on("error",(p)=>{Z(`Upstream response error: ${p.message}`,{level:"error"}),Y.destroy()}),Y.writeHead(k.statusCode,h0(k.headers)),k.pipe(Y)})}else T=(W.protocol==="https:"?X4:V7)({hostname:V,port:M,path:W.pathname+W.search,method:Q.method,headers:q},(w)=>{w.on("error",(P)=>{Z(`Upstream response error: ${P.message}`,{level:"error"}),Y.destroy()}),Y.writeHead(w.statusCode,h0(w.headers)),w.pipe(Y)});if(T.on("error",(C)=>{if(Z(`Proxy request failed: ${C.message}`,{level:"error"}),!Y.headersSent)Y.writeHead(502,{"Content-Type":"text/plain"}),Y.end("Bad Gateway");else Y.destroy()}),Y.on("close",()=>T.destroy()),F)F.on("error",(C)=>T.destroy(C)),R.on("error",(C)=>F.destroy(C)),Y.on("close",()=>F.destroy()),R.pipe(F).pipe(T);else R.on("error",(C)=>T.destroy(C)),R.pipe(T)}catch(G){if(Z(`Error handling HTTP request: ${G}`,{level:"error"}),!Y.headersSent)Y.writeHead(500,{"Content-Type":"text/plain"}),Y.end("Internal Server Error");else Y.destroy()}}),J}function xq($){let J=/^\[([^\]]+)\]:(\d+)$/.exec($)??/^([^:]+):(\d+)$/.exec($);if(!J)return;let X=Number(J[2]);if(!Number.isInteger(X)||X<1||X>65535)return;return{hostname:J[1],port:X}}var K4=g9(q4(),1);function dq($,J,X){if(!X||J===void 0)return!1;return $!==void 0&&($===z0||$.startsWith(`${z0}.`))&&MY(J,X)}function z4($){let J=K4.createServer();if($.proxyAuthToken)J.setAuthHandler((Q,Y,G)=>{if(dq(Q.username,Q.password,$.proxyAuthToken))Y();else Z("SOCKS auth rejected",{level:"error"}),G()});J.setRulesetValidator(async(Q)=>{try{let{destAddress:Y,destPort:G}=Q;if(!mQ(Y))return Z(`Rejecting malformed SOCKS host: ${JSON.stringify(Y)}`,{level:"error"}),!1;if(Z(`Connection request to ${Y}:${G}`),!await $.filter(G,Y,KY(Q.username)))return Z(`Connection blocked to ${Y}:${G}`,{level:"error"}),!1;return Z(`Connection allowed to ${Y}:${G}`),!0}catch(Y){return Z(`Error validating connection: ${Y}`,{level:"error"}),!1}}),J.setConnectionHandler((Q,Y)=>{let G=jJ(Q.destAddress)??Q.destAddress,W=Q.destPort,U=!1,M;Q.socket.once("close",()=>{U=!0,M?.destroy()}),Q.socket.on("error",()=>M?.destroy());let O=$.parentProxy&&!kX($.parentProxy,G)?fX($.parentProxy,{isHttps:!0}):void 0;(O?tY(O,G,W):eY(G,W)).then((H)=>{if(M=H,H.on("error",()=>Q.socket.destroy()),U){H.destroy();return}Y("REQUEST_GRANTED"),H.pipe(Q.socket),Q.socket.pipe(H),H.on("close",()=>Q.socket.destroy())}).catch((H)=>{if(Z(`SOCKS connect to ${G}:${W} failed: ${H.message}`,{level:"error"}),!U)try{Y("HOST_UNREACHABLE")}catch{}})});let X=new Set;return{handleConnection(Q){if(Q.setNoDelay(),X.add(Q),Q.once("close",()=>X.delete(Q)),!$.proxyAuthToken){J._handleConnection(Q);return}iq(Q,(Y)=>{if(Y){J._handleConnection(Q);return}oq(Q,$).catch(()=>Q.destroy())})},async close(){for(let Q of X)Q.destroy();X.clear()}}}var cq=0,nq=2;function iq($,J){let X=Buffer.alloc(0),Q=(Y)=>{if(X=Buffer.concat([X,Y]),X.length<2)return;if(X[0]!==5){$.off("data",Q),$.destroy();return}let G=X[1];if(X.length<2+G)return;$.off("data",Q),$.pause();let U=X.subarray(2,2+G).includes(nq),M=U?X:X.subarray(2+G);if(M.length>0)$.unshift(M);J(U)};$.on("data",Q),$.once("error",()=>$.off("data",Q))}async function oq($,J){$.write(Buffer.from([5,cq]));let X=await aq($);if(X===void 0){$.destroy();return}let{host:Q,port:Y}=X;if(!mQ(Q)){$.end(K7(2));return}let G=J.probeUnauthenticated?await J.probeUnauthenticated(Y,Q):{};if(Z(`SOCKS unauthenticated client refused for ${Q}:${Y}`+(G.deniedReason!==void 0?" (denied by policy)":"")),Y!==22){$.end(K7(2));return}let W=G.deniedReason??"This proxy requires authentication, and this client did not offer an authentication method, so the connection was refused.";$.write(K7(0)),$.write(Buffer.from(`SSH-2.0-policy_refusal\r
|
|
57
|
+
`)),$.end(sq(W))}function K7($){return Buffer.from([5,$,0,1,0,0,0,0,0,0])}function aq($){return new Promise((J)=>{let X=Buffer.alloc(0),Q=(W)=>{$.off("data",G),clearTimeout(Y),J(W)},Y=setTimeout(()=>Q(void 0),5000),G=(W)=>{if(X=Buffer.concat([X,W]),X.length<4)return;if(X[0]!==5||X[1]!==1){Q(void 0);return}let U=X[3];if(U===1){if(X.length<10)return;let M=Array.from(X.subarray(4,8)).join(".");Q({host:M,port:X.readUInt16BE(8)})}else if(U===3){if(X.length<5)return;let M=X[4];if(X.length<5+M+2)return;Q({host:X.subarray(5,5+M).toString("utf8"),port:X.readUInt16BE(5+M)})}else if(U===4){if(X.length<22)return;let M=[];for(let O=0;O<16;O+=2)M.push(X.readUInt16BE(4+O).toString(16));Q({host:M.join(":"),port:X.readUInt16BE(20)})}else Q(void 0)};$.on("data",G),$.resume(),$.once("error",()=>Q(void 0)),$.once("close",()=>Q(void 0))})}function sq($){let J=$.replace(/[\x00-\x1f\x7f-\x9f]+/g," ").slice(0,1000),X=Buffer.from(J,"utf8"),Q=Buffer.alloc(0),Y=Buffer.concat([Buffer.from([1]),X9(1),X9(X.length),X,X9(Q.length),Q]),G=8-(5+Y.length)%8;if(G<4)G+=8;return Buffer.concat([X9(1+Y.length+G),Buffer.from([G]),Y,Buffer.alloc(G)])}function X9($){let J=Buffer.alloc(4);return J.writeUInt32BE($,0),J}import{createServer as rq,connect as E4}from"net";import{join as tq}from"path";import{tmpdir as eq}from"os";import{unlink as F4}from"fs/promises";function Y9($,J,X,Q){return new Promise((Y,G)=>{let[W,U]=X??[0,0],M=W,O=()=>{while(Q.has(M)&&M<=U)M++;if(M>U){G(Error(`No free port in range ${W}-${U} (excluding ${[...Q].join(",")})`));return}let V=()=>{$.removeListener("error",H),Y()},H=(q)=>{if($.removeListener("listening",V),X&&q?.code==="EADDRINUSE"&&M<U){M++,O();return}G(q??Error("listen error"))};$.once("error",H),$.once("listening",V),J(X?M:0)};O()})}var $6=new Set([4,5]),J6=1e4,Q6=0;function X6(){return tq(eq(),`srt-mux-${process.pid}-${(Q6++).toString(36)}.sock`)}function N4($){let J=$.firstByteTimeoutMs??J6,X=x$()==="windows",Q,Y,G=new Set;function W(M){if(Q===void 0&&Y===void 0){Z("mux: HTTP dispatch before backend bound; dropping",{level:"error"}),M.destroy();return}let O=Q?E4(Q):E4(Y,"127.0.0.1");O.on("error",(V)=>{let H=V.code??"ERR";if(Z(`mux: HTTP backend dial failed: ${V.message}`,{level:"error"}),!M.destroyed)M.end(`HTTP/1.1 502 Bad Gateway\r
|
|
58
58
|
Connection: close\r
|
|
59
59
|
\r
|
|
60
60
|
mux backend dial failed (${H})
|
|
61
|
-
`)}),U.on("error",()=>O.destroy()),U.once("close",()=>O.destroy()),O.once("close",()=>U.destroy()),U.pipe(O),O.pipe(U)}let M=zq((U)=>{G.add(U),U.once("close",()=>G.delete(U)),U.on("error",(V)=>Z(`mux: client socket error: ${V.message}`));let O=setTimeout(()=>{Z("mux: first-byte timeout; destroying connection"),U.destroy()},J);if(typeof O.unref==="function")O.unref();U.once("readable",()=>{clearTimeout(O);let V=U.read(1);if(!V||V.length===0){U.destroy();return}if(U.unshift(V),Nq.has(V[0]))$.handleSocksConnection(U);else W(U)})});return{server:M,getPort(){let U=M.address();return U&&typeof U==="object"?U.port:void 0},async listenHttpBackend(){if(!X){let O=Aq();await aW(O).catch(()=>{}),await new Promise((V,H)=>{$.httpServer.once("error",H),$.httpServer.listen(O,()=>{$.httpServer.removeListener("error",H),V()})}),Q=O,Z(`mux: HTTP backend listening on ${O}`);return}await iY($.httpServer,(O)=>$.httpServer.listen(O,"127.0.0.1"),$.httpBackendPortRange,new Set);let U=$.httpServer.address();return Y=U&&typeof U==="object"?U.port:void 0,Z(`mux: HTTP backend listening on 127.0.0.1:${Y}`),Y},async close(){for(let U of G)U.destroy();if(G.clear(),await new Promise((U)=>M.close(()=>U())),await new Promise((U)=>$.httpServer.close(()=>U())),Q)await aW(Q).catch(()=>{}),Q=void 0;Y=void 0},unref(){M.unref(),$.httpServer.unref()}}}import{randomBytes as Dq,randomUUID as Zq}from"crypto";var xX="fake_value_",rW="abcdefghijklmnopqrstuvwxyz0123456789_-";function Bq($){let J=xX+Zq(),X=Buffer.byteLength($)-J.length;if(X<=0)return J;let Q=J;for(let Y of Dq(X))Q+=rW[Y%rW.length];return Q}class e8{byName=new Map;bySentinel=new Map;allSentinelsPrefixed=!0;register($,J,X){return this.registerWithSentinel($,Bq(J),J,X)}registerWithSentinel($,J,X,Q){let Y=this.byName.get($);if(Y!==void 0)return Y.realValue=X,Y.injectHosts=Q,Y.sentinel;if(!J.startsWith(xX))this.allSentinelsPrefixed=!1;let G={name:$,sentinel:J,realValue:X,injectHosts:Q};return this.byName.set($,G),this.bySentinel.set(J,G),J}lookupReal($){return this.bySentinel.get($)?.realValue}namesInjectableAt($,J){let X=[];for(let Q of this.byName.values())if(Q.injectHosts.some((Y)=>J($,Y)))X.push(Q.name);return X}sentinelsForHost($,J){let X=[];for(let Q of this.bySentinel.values()){if(!Q.injectHosts.some((Y)=>J($,Y)))continue;X.push({sentinel:Buffer.from(Q.sentinel),realValue:Buffer.from(Q.realValue)})}return X}*entries(){for(let $ of this.bySentinel.values())yield[$.sentinel,$.realValue]}get size(){return this.bySentinel.size}clear(){this.byName.clear(),this.bySentinel.clear(),this.allSentinelsPrefixed=!0}substituteInHeaders($,J,X){if(this.bySentinel.size===0)return;for(let[Q,Y]of Object.entries($)){if(Y===void 0)continue;if(Array.isArray(Y))for(let G=0;G<Y.length;G++)Y[G]=this.substituteInHeaderValue(Q,Y[G],J,X);else $[Q]=this.substituteInHeaderValue(Q,Y,J,X)}}substituteInHeaderValue($,J,X,Q){let Y=this.substituteInString(J,X,Q);if($.toLowerCase()!=="authorization")return Y;let G=/^(\s*basic\s+)([a-z0-9+/]+={0,2})(\s*)$/i.exec(Y);if(G===null)return Y;let W=G[2],M=Buffer.from(W,"base64");if(W.length%4!==0||M.toString("base64")!==W)return Y;let U=M.toString("utf8");if(!Buffer.from(U,"utf8").equals(M))return Y;let O=this.substituteInString(U,X,Q);if(O===U)return Y;return`${G[1]}${Buffer.from(O,"utf8").toString("base64")}${G[3]}`}substituteInString($,J,X){if(this.allSentinelsPrefixed&&!$.includes(xX))return $;let Q=$;for(let Y of this.bySentinel.values()){if(!Q.includes(Y.sentinel))continue;if(!Y.injectHosts.some((G)=>X(J,G)))continue;Q=Q.split(Y.sentinel).join(Y.realValue)}return Q}}import{randomUUID as _q}from"crypto";import*as pJ from"fs";import{tmpdir as xq}from"os";import{join as J4}from"path";function jq($,J){let X=!1;for(let Q=J+1;Q<$.length;Q++){let Y=$[Q];if(X){X=!1;continue}if(Y==="\\")X=!0;else if(Y==="]")return Q+1}return $.length}function Tq($){switch($){case"s":return{kind:"whitespace"};case"S":return{kind:"non-whitespace"};case"d":return{kind:"digit"};case"D":return{kind:"non-digit"};case"w":return{kind:"word"};case"W":return{kind:"non-word"};default:return{kind:"unknown"}}}function tW($,J){if($===null||J===null)return!0;if($.kind==="literal"&&J.kind==="literal")return $.value===J.value;if($.kind==="whitespace"&&J.kind==="non-whitespace"||$.kind==="non-whitespace"&&J.kind==="whitespace"||$.kind==="digit"&&J.kind==="non-digit"||$.kind==="non-digit"&&J.kind==="digit"||$.kind==="word"&&J.kind==="non-word"||$.kind==="non-word"&&J.kind==="word")return!1;return!0}function Sq($,J){if($[J+1]!=="?")return{next:J+1,capturing:!0};if($[J+2]==="<"){let Q=$[J+3];if(Q==="="||Q==="!")return{next:J+4,capturing:!1};let Y=$.indexOf(">",J+3);return{next:Y===-1?J+3:Y+1,capturing:!0}}return{next:J+3,capturing:!1}}function Iq($,J){let X=$[J];if(X==="*"||X==="+")return{next:$[J+1]==="?"?J+2:J+1,unbounded:!0};if(X==="?")return{next:$[J+1]==="?"?J+2:J+1,unbounded:!1};if(X!=="{")return null;let Q=J+1,Y=Q;while(/[0-9]/.test($[Q]??""))Q++;if(Q===Y)return null;let G=Number($.slice(Y,Q)),W=G,M=!1;if($[Q]===","){Q++;let U=Q;while(/[0-9]/.test($[Q]??""))Q++;if(Q===U)M=!0,W=void 0;else W=Number($.slice(U,Q))}if($[Q]!=="}")return null;if(!Number.isFinite(G)||G>4096||W!==void 0&&(!Number.isFinite(W)||W>4096))return{next:Q+1,unbounded:M,error:"finite repetitions must be at most 4096"};if(Q++,$[Q]==="?")Q++;return{next:Q,unbounded:M}}function Cq($){let J=[{previousAtom:null,lastAtom:null,atomCount:0,simpleClass:null,containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1}],X=0,Q=()=>J[J.length-1],Y=(G)=>{let W=Q();if(W.lastAtom?.hasUnboundedQuantifier&&G.hasUnboundedQuantifier&&W.lastAtom.repeatClass!==null&&G.repeatClass!==null&&tW(W.lastAtom.repeatClass,G.repeatClass))W.error="adjacent unbounded repetition with overlapping input is not supported";if(W.previousAtom=W.lastAtom,W.lastAtom=G,W.atomCount===0)W.simpleClass=G.repeatClass;else W.simpleClass=null;if(W.atomCount++,G.kind==="group")W.containsQuantifier||=G.containsQuantifier,W.containsAlternation||=G.containsAlternation;W.hasUnboundedQuantifier||=G.hasUnboundedQuantifier};for(let G=0;G<$.length;){if(Q().error!==void 0)return{groupCount:X,error:Q().error};let W=$[G];if(W==="\\"){let U=$[G+1];if(U!==void 0&&/[1-9]/.test(U)||U==="k"&&$[G+2]==="<")return{groupCount:X,error:"backreferences are not supported by the safe extractor"};let O=U==="b"||U==="B";if(Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:Tq(U)}),G+=U===void 0?1:2,O)Q().previousAtom=null,Q().lastAtom=null;continue}if(W==="["){Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:{kind:"unknown"}}),G=jq($,G);continue}if(W==="("){let U=Sq($,G);if(U.capturing)X++;J.push({previousAtom:null,lastAtom:null,atomCount:0,simpleClass:null,containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1}),G=U.next;continue}if(W===")"){if(J.length>1){let U=J.pop();if(U.error!==void 0)return{groupCount:X,error:U.error};Y({kind:"group",containsQuantifier:U.containsQuantifier,containsAlternation:U.containsAlternation,hasUnboundedQuantifier:U.hasUnboundedQuantifier,repeatClass:U.atomCount===1&&!U.containsAlternation?U.simpleClass:null})}G++;continue}if(W==="|"){Q().containsAlternation=!0,Q().previousAtom=null,Q().lastAtom=null,G++;continue}let M=Iq($,G);if(M!==null){if(M.error)return{groupCount:X,error:M.error};let U=Q(),O=U.lastAtom;if(M.unbounded&&O?.kind==="group"&&(O.containsQuantifier||O.containsAlternation))return{groupCount:X,error:"nested unbounded repetition or unbounded alternation is not supported"};if(M.unbounded&&U.previousAtom?.hasUnboundedQuantifier&&O!==null&&U.previousAtom.repeatClass!==null&&O.repeatClass!==null&&tW(U.previousAtom.repeatClass,O.repeatClass))return{groupCount:X,error:"adjacent unbounded repetition with overlapping input is not supported"};if(U.containsQuantifier=!0,O!==null)U.lastAtom={...O,containsQuantifier:!0,hasUnboundedQuantifier:O.hasUnboundedQuantifier||M.unbounded};U.hasUnboundedQuantifier||=M.unbounded,G=M.next;continue}if(W!=="^"&&W!=="$")Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:W==="."?{kind:"any"}:{kind:"literal",value:W}});else Q().previousAtom=null,Q().lastAtom=null;G++}return{groupCount:X,error:Q().error}}function $7($){if($.length>2048)throw Error("Credential extract pattern exceeds the 2048-character limit");let J;try{J=new RegExp($)}catch{throw Error("Credential extract pattern is not a valid regular expression")}let X=Cq($);if(X.error!==void 0)throw Error(`Credential extract pattern rejected: ${X.error}`);return{regex:J,groupCount:X.groupCount}}function wq($,J=""){$7($);try{return new RegExp($,J)}catch{throw Error("Credential extract pattern is not supported by this runtime")}}function oY($,J,X,Q={}){if($.length>1048576)throw Error("Credential extraction input exceeds the 1048576-character limit");let Y=wq(J,"gd"),G=new Map,W=new Map,M=[],U=0;for(let H of $.matchAll(Y)){if(U++,U>4096)throw Error("Credential extraction exceeds the 4096-match limit");let q=H[1];if(q===void 0)throw Error(`Credential extraction matched at offset ${H.index} without a group-1 capture; group 1 must capture the credential value on every match.`);if(q.length===0)continue;let F=G.get(q);if(F===void 0)G.set(q,F=G.size);let[K,R]=H.indices[1],L=X(q,F);if(!W.has(q))W.set(q,L);M.push({start:K,end:R,sentinel:L})}if(G.size===0)return null;if(Q.maskDuplicates){let H=[...G.keys()].sort((q,F)=>F.length-q.length);for(let q of H){let F=W.get(q);if(F===q)continue;for(let K=$.indexOf(q);K!==-1;K=$.indexOf(q,K+1)){let R=K+q.length;if(M.some((L)=>K<L.end&&L.start<R))continue;M.push({start:K,end:R,sentinel:F})}}M.sort((q,F)=>q.start-F.start)}let O="",V=0;for(let H of M)O+=$.slice(V,H.start)+H.sentinel,V=H.end;return{fakeContent:O+$.slice(V),captures:[...G.keys()]}}var eW="(eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+)";function J7($){try{return JSON.parse(Buffer.from($,"base64url").toString("utf8"))}catch{return}}function aY($){let J=$.split(".");if(J.length!==3)return!1;let X=J7(J[0]);if(typeof X!=="object"||X===null||!("alg"in X))return!1;return J7(J[1])!==void 0}var Pq=9999999999,$4="c3J0LWZha2U";function Q7($){return Buffer.from($,"utf8").toString("base64url")}function sY($){let J=Q7(JSON.stringify({alg:"HS256",typ:"JWT"})),X=Q7(JSON.stringify({sub:xX+$,exp:Pq}));return`${J}.${X}.${$4}`}function rY($,J,X){let[Q,Y]=$.split("."),G=J7(Y??"");if(typeof G!=="object"||G===null||Array.isArray(G))return null;let W=G,M=[];for(let O of J){let V=W[O];if(typeof V==="string")M.push([O,V])}if(M.length===0)return null;let U=new Map;for(let[O,V]of M){let H=X(O,V);W[O]=H,U.set(O,H)}return{fakeToken:`${Q}.${Q7(JSON.stringify(W))}.${$4}`,claimSentinels:U}}var vq="file:";class X7{dir;byKey=new Map;write($,J){if(this.dir===void 0)this.dir=pJ.mkdtempSync(J4(xq(),"srt-credmask-"));let X=this.byKey.get($);if(X===void 0)X=J4(this.dir,`${this.byKey.size}.fake`),this.byKey.set($,X);return pJ.rmSync(X,{force:!0}),pJ.writeFileSync(X,J,{mode:384}),X}dispose(){if(this.dir!==void 0)try{pJ.rmSync(this.dir,{recursive:!0,force:!0})}catch($){Z(`MaskedFileStore cleanup failed: ${$}`,{level:"error"})}this.dir=void 0,this.byKey.clear()}get dirPath(){return this.dir}}function Q4($,J,X,Q){let Y=[],G=[];for(let W of $){if(W.mode!=="mask")continue;let M=e$(W.path),U;try{if(pJ.statSync(M).isDirectory()){Z(`[credential-mask] Skipping masked file entry that resolves to a directory: ${W.path} \u2014 use mode "deny" for directories.`,{level:"warn"});continue}let K=pJ.readFileSync(M);if(U=K.toString("utf8"),Buffer.byteLength(U,"utf8")!==K.length){Z(`[credential-mask] Skipping masked file with non-UTF-8 content (binary credential files are not supported in mask mode): ${W.path}`,{level:"warn"});continue}}catch(F){Z(`[credential-mask] Skipping masked file (unreadable on host): ${W.path} \u2014 ${F.message}`);continue}let O=W.injectHosts??J,V=vq+M,H;if(W.extract===void 0&&W.decode===void 0)H=X.register(V,U,O);else{let F=W.extract??eW,K=0,R=oY(U,F,(L,D)=>{if(W.decode==="jwt"&&!aY(L))return L;let w=`${V}#${D}`;if(W.decode==="jwt"&&W.maskClaims?.length){let T=rY(L,W.maskClaims,(S,C)=>X.register(`${V}#jwt${D}.${S}`,C,O));if(T===null)return Z(`[credential-mask] ${W.path}: verified JWT candidate has none of maskClaims ${JSON.stringify(W.maskClaims)} as `+"string claims \u2014 left unmasked."),L;let P=W.maskClaims.filter((S)=>!T.claimSentinels.has(S));if(P.length>0)Z(`[credential-mask] ${W.path}: maskClaims ${JSON.stringify(P)} absent or non-string in a `+"verified JWT \u2014 skipped.");return K++,X.registerWithSentinel(w,T.fakeToken,L,O)}return K++,W.decode==="jwt"?X.registerWithSentinel(w,sY(_q()),L,O):X.register(w,L,O)},{maskDuplicates:W.maskDuplicates??!1});if(R===null||K===0){let L=W.decode==="jwt"?W.maskClaims?.length?`decode "jwt" with pattern "${F}" that matched no verified JWT with maskable claims (maskClaims: ${JSON.stringify(W.maskClaims)})`:`decode "jwt" with pattern "${F}" that matched no verified JWT`:`extract pattern "${F}" that matched nothing`,D=W.onExtractNoMatch??"warn";if(D==="error")throw Error(`credentials.files entry "${W.path}": ${L} (onExtractNoMatch: "error"). Fix the config, change to "warn"/"deny", or remove the entry.`);if(D==="deny"){Z(`[credential-mask] ${W.path} has ${L} \u2014 degrading to `+'mode "deny".',{level:"warn"}),G.push(M);continue}let w=`[sandbox-runtime] WARNING: credentials.files entry "${W.path}" has ${L} in the file. The file is left UNPROTECTED (readable as-is inside the sandbox). Fix the config, set onExtractNoMatch to "deny" or "error", or remove the entry.`;console.warn(w),Z(w,{level:"warn"});continue}H=R.fakeContent}let q=Q.write(V,H);Y.push({realPath:M,fakePath:q})}return{binds:Y,degradeToDenyPaths:G}}import{randomUUID as kq}from"crypto";var tY="env:";function X4($,J,X,Q=process.env){let Y={},G=[];for(let W of $){if(W.mode!=="mask")continue;let M=Q[W.name];if(M===void 0)continue;let U=W.injectHosts??J;if(W.decode==="jwt"){if(!aY(M)){let V=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has decode "jwt" but its value did not verify as a JWT. The variable is left UNPROTECTED (real value visible as-is inside the sandbox). Fix the config or remove the entry.`;console.warn(V),Z(V,{level:"warn"});continue}if(W.maskClaims?.length){let V=rY(M,W.maskClaims,(q,F)=>X.register(`${tY}${W.name}#${q}`,F,U));if(V===null){let q=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has maskClaims ${JSON.stringify(W.maskClaims)} but none is present as a string claim in its JWT value. The variable is left UNPROTECTED (real value visible as-is inside the sandbox). Fix the config or remove the entry.`;console.warn(q),Z(q,{level:"warn"});continue}let H=W.maskClaims.filter((q)=>!V.claimSentinels.has(q));if(H.length>0)Z(`[credential-mask] env var "${W.name}": maskClaims ${JSON.stringify(H)} absent or non-string in the `+"JWT \u2014 skipped.");Y[W.name]=X.registerWithSentinel(`${tY}${W.name}`,V.fakeToken,M,U);continue}Y[W.name]=X.registerWithSentinel(`${tY}${W.name}`,sY(kq()),M,U);continue}if(W.extract===void 0){Y[W.name]=X.register(W.name,M,U);continue}let O=oY(M,W.extract,(V,H)=>X.register(`${tY}${W.name}#${H}`,V,U));if(O===null){let V=W.onExtractNoMatch??"warn";if(V==="error")throw Error(`credentials.envVars entry "${W.name}": extract pattern "${W.extract}" matched nothing (onExtractNoMatch: "error"). Fix the regex, change to "warn"/"deny", or remove the entry.`);if(V==="deny"){Z(`[credential-mask] extract pattern /${W.extract}/ matched nothing in the value of ${W.name} \u2014 unsetting the variable.`,{level:"warn"}),G.push(W.name);continue}let H=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has extract pattern "${W.extract}" that matched nothing in the variable's value. The variable is left UNPROTECTED (visible as-is inside the sandbox). Fix the regex, set onExtractNoMatch to "deny" or "error", or remove the entry.`;console.warn(H),Z(H,{level:"warn"});continue}Y[W.name]=O.fakeContent}return{setEnvVars:Y,degradeToUnsetNames:G}}var Y4="AWS_ACCESS_KEY_ID",G4="AWS_SECRET_ACCESS_KEY",W4="AWS_SESSION_TOKEN";class Y7{bySentinel=new Map;register($){this.bySentinel.set($.accessKeyIdSentinel,$)}lookup($){return this.bySentinel.get($)}get size(){return this.bySentinel.size}clear(){this.bySentinel.clear()}}function M4($,J,X,Q,Y,G=process.env){let W=[...J??[]],M=new Set(W.flatMap((H)=>[H.accessKeyIdVar,H.secretAccessKeyVar,...H.sessionTokenVar?[H.sessionTokenVar]:[]]));if(![Y4,G4,W4].some((H)=>M.has(H)))W.push({accessKeyIdVar:Y4,secretAccessKeyVar:G4,sessionTokenVar:W4});let O=(H)=>$.find((q)=>q.name===H&&q.mode==="mask"&&q.extract===void 0&&q.decode===void 0),V=(H)=>O(H)!==void 0?Q[H]:void 0;for(let H of W){let q=V(H.accessKeyIdVar),F=V(H.secretAccessKeyVar)!==void 0,K=G[H.accessKeyIdVar],R=G[H.secretAccessKeyVar];if(q===void 0||!F||K===void 0||R===void 0){if(F&&q===void 0){let T=`[sandbox-runtime] WARNING: "${H.secretAccessKeyVar}" is masked but "${H.accessKeyIdVar}" is not, so no AWS credential pair was registered. SigV4 requests will be signed with the masked placeholder secret and the proxy cannot `+"detect or re-sign them \u2014 they will fail upstream. Mask both "+"variables (whole-value) to enable re-signing.";console.warn(T),Z(T,{level:"warn"})}continue}let L=O(H.accessKeyIdVar),w=(H.sessionTokenVar!==void 0?V(H.sessionTokenVar):void 0)!==void 0&&H.sessionTokenVar!==void 0?G[H.sessionTokenVar]:void 0;Y.register({accessKeyIdSentinel:q,realAccessKeyId:K,realSecretAccessKey:R,...w!==void 0?{realSessionToken:w}:{},injectHosts:L.injectHosts??X}),Z(`[credential-aws] registered SigV4 pair for ${H.accessKeyIdVar}/${H.secretAccessKeyVar}`+(w!==void 0?" (+session token)":""))}}function fq($){return{streaming:$?.streaming??"deny",presigned:$?.presigned??"deny",sigv4a:$?.sigv4a??"deny"}}function U4($,J,X){let Q=fq(J);return(Y,G,W,M)=>{if($.size===0)return;let U=IW(W,G);if(U===null)return;let O=$.lookup(U.accessKeyId);if(O===void 0)return;if(!O.injectHosts.some((K)=>X(M,K)))return;if(U.kind!=="header-sigv4"){if(Q[U.kind]==="passthrough"){Z(`[credential-aws] ${U.kind} request with masked credential passed through un-resigned per credentials.sigv4.${U.kind} (its signature covers the placeholder secret and will fail upstream)`);return}return{action:"deny",reason:`AWS SigV4 ${U.kind} request uses a masked credential but cannot be re-signed by the sandbox proxy; denied by policy. Set credentials.sigv4.${U.kind} to "passthrough" to forward it unmodified (it will fail upstream: the signature covers the masked placeholder).`}}let V=CW(hQ(W.authorization));if(V===null)return{action:"deny",reason:"AWS SigV4 request uses a masked credential but its Authorization header is malformed; the proxy cannot re-sign it."};let H=hQ(W["x-amz-date"]);if(H===void 0)return{action:"deny",reason:"AWS SigV4 request uses a masked credential but carries no x-amz-date header; the proxy cannot re-sign it."};let q=[...V.signedHeaders];for(let K of q){if(K==="host")continue;if(K==="x-amz-security-token"&&O.realSessionToken!==void 0)continue;if(W[K]===void 0)return{action:"deny",reason:`AWS SigV4 request uses a masked credential but signed header "${K}" is missing; the proxy cannot re-sign it.`}}if(O.realSessionToken!==void 0&&!q.includes("x-amz-security-token"))q.push("x-amz-security-token");let F=hQ(W["x-amz-content-sha256"]);return{action:"resign",payloadHash:F===pY?pY:void 0,apply(K,R,L){if(O.realSessionToken!==void 0)K["x-amz-security-token"]=O.realSessionToken;if(K["x-amz-content-sha256"]!==void 0&&F!==pY)K["x-amz-content-sha256"]=L;let{authorization:D}=wW({method:Y,requestTarget:G,headers:K,hostHeader:R,signedHeaders:q,payloadHash:L,amzDate:H,scope:{date:V.date,region:V.region,service:V.service},accessKeyId:O.realAccessKeyId,secretAccessKey:O.realSecretAccessKey});K.authorization=D}}}}import{spawnSync as yq}from"child_process";function N0($){if(typeof globalThis.Bun<"u")return globalThis.Bun.which($);let J=yq("which",[$],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1000});if(J.status===0&&J.stdout)return J.stdout.trim();return null}import*as g0 from"fs";import{randomBytes as PK}from"crypto";function IJ($){return $.map((J)=>{if(J==="")return"''";if(/^[A-Za-z0-9_./:@+,-][A-Za-z0-9_./:=@+,-]*$/.test(J))return J;return"'"+J.replace(/'/g,`'"'"'`)+"'"}).join(" ")}import{randomBytes as cq}from"crypto";import*as J$ from"fs";import{spawn as H4}from"child_process";import{tmpdir as H7}from"os";import k$,{join as q4}from"path";import{spawn as bq}from"child_process";import{text as O4}from"stream/consumers";var hq={ms:1e4};class eY extends Error{constructor($){super(`ripgrep timed out after ${$} ms`);this.name="RipgrepTimeoutError"}}async function G7($,J,X,Q={command:"rg"}){let{command:Y,args:G=[],argv0:W}=Q,M=bq(Y,[...G,...$,J],{argv0:W,env:{PATH:process.env.PATH??"/usr/bin:/bin"},signal:X,windowsHide:!0}),U=hq.ms,O=!1,V=setTimeout(()=>{O=!0,M.kill("SIGKILL")},U),H,q,F;try{[H,q,F]=await Promise.all([O4(M.stdout),O4(M.stderr),new Promise((K,R)=>{M.on("close",K),M.on("error",R)})])}finally{clearTimeout(V)}if(O)throw new eY(U);if(F===0)return H.trim().split(`
|
|
62
|
-
`).filter(Boolean);if(F===1)return[];throw Error(`ripgrep failed with exit code ${F}: ${q}`)}import{join as
|
|
63
|
-
`);return`${W} -c ${IJ([V])}`}function V7($){try{if(J$.lstatSync($).isSymbolicLink())return J$.realpathSync($)}catch{}return $}function N4($,J,X,Q){let Y=J==="/"?"/":J+"/";$.push("--tmpfs",J);for(let G of X)if(G.startsWith(Y)||G===J)$.push("--bind",G,G),Z(`[Sandbox Linux] Re-bound write path wiped by denyRead tmpfs: ${G}`);for(let G of Q)if(G.startsWith(Y)||G===J){if(!J$.existsSync(G)){Z(`[Sandbox Linux] Skipping non-existent read allow path: ${G}`);continue}if(X.some((W)=>(W.startsWith(Y)||W===J)&&(G===W||G.startsWith(W+"/"))))continue;$.push("--ro-bind",G,G),Z(`[Sandbox Linux] Re-allowed read access within denied region: ${G}`)}}async function eq($,J,X,Q,Y={command:"rg"},G=q7,W=!1,M){let U=[],O=[],V=[],H=new Map,q=new Map;if(J){U.push("--ro-bind","/","/");for(let G$ of J.allowOnly||[]){let r=e$(G$).replace(/\/+$/,"")||"/";if(Z(`[Sandbox Linux] Processing write path: ${G$} -> ${r}`),r.startsWith("/dev/")){Z(`[Sandbox Linux] Skipping /dev path: ${r}`);continue}if(!J$.existsSync(r)){Z(`[Sandbox Linux] Skipping non-existent write path: ${r}`);continue}try{let m=J$.realpathSync(r),W$=r.replace(/\/+$/,"");if(m!==W$&&eX(r,m)){Z(`[Sandbox Linux] Skipping symlink write path pointing outside expected location: ${G$} -> ${m}`);continue}}catch{Z(`[Sandbox Linux] Skipping write path that could not be resolved: ${r}`);continue}U.push("--bind",r,r),O.push(r)}let S,C=()=>{if(S!==void 0)return S;let G$=[];for(let m of O){G$.push(m);try{let W$=J$.realpathSync(m);if(W$!==m)G$.push(W$)}catch{}}let r=[];if($){let m=[],W$=new Set(["proc","dev","sys"]);for(let l of $.denyOnly||[])if(e$(l)==="/")try{for(let H$ of J$.readdirSync("/"))if(!W$.has(H$))m.push("/"+H$)}catch{}else m.push(l);if(J$.existsSync("/etc/ssh/ssh_config.d"))m.push("/etc/ssh/ssh_config.d");for(let l of m){let H$=e$(l),JJ=!1;try{JJ=J$.statSync(H$).isDirectory()}catch{continue}if(!JJ)continue;r.push(H$);try{let w$=J$.realpathSync(H$);if(w$!==H$)r.push(w$)}catch{}}}return S={allowedWritePathsBothForms:G$,prospectiveReadDenyTmpfsDirsBothForms:r},S},h=(G$)=>O.some((r)=>G$.startsWith(r+"/")||G$===r),s=[...J.denyWithinAllow||[],...await sq(Y,G,W,M)],a=new Set;for(let G$ of s){let r=e$(G$);if(r.startsWith("/dev/"))continue;let m=K4(r);if(m===null||m.startsWith("/dev/"))continue;if(O7(m,O))continue;let W$=!1;try{W$=J$.statSync(m).isDirectory()}catch{continue}if(!W$)continue;if(h(m)){let l=H.get(m);if(l===void 0)l=new Set,H.set(m,l);l.add(r)}}let O$=new Map,j$=(G$)=>{let r=O$.get(G$);if(r!==void 0)return r;let{allowedWritePathsBothForms:m,prospectiveReadDenyTmpfsDirsBothForms:W$}=C(),l=m.some((H$)=>H$.startsWith(G$+"/"))||W$.some((H$)=>H$===G$||H$.startsWith(G$+"/"))||W$.some((H$)=>[G$,...H.get(G$)??[]].some((JJ)=>JJ===H$||JJ.startsWith(H$+"/")));return O$.set(G$,l),l},T$=[...H.keys()];for(let G$ of s){let r=e$(G$);if(r.startsWith("/dev/"))continue;let m=K4(r);if(m===null){let H$=O7(r,O);if(H$&&!a.has(H$))a.add(H$),V.push("--ro-bind","/dev/null",H$),q.set(H$,r);Z(`[Sandbox Linux] Deny path could not be resolved through symlinks, failing closed: ${r}`);continue}if(m!==r)Z(`[Sandbox Linux] Resolved symlinked deny path: ${r} -> ${m}`);if(m.startsWith("/dev/"))continue;if(a.has(m))continue;a.add(m);let W$=O7(m,O);if(W$){if(!a.has(W$))a.add(W$),V.push("--ro-bind","/dev/null",W$),q.set(W$,r);Z(`[Sandbox Linux] Mounted /dev/null at symlink ${W$} to prevent symlink replacement attack`);continue}if(!J$.existsSync(m)){if(oq(m)){Z(`[Sandbox Linux] Skipping deny path with file ancestor (cannot create paths under a file): ${m}`);continue}let H$=k$.dirname(m);while(H$!=="/"&&!J$.existsSync(H$))H$=k$.dirname(H$);let JJ=h(H$)||h(m),w$=T$.filter((z$)=>H$===z$||H$.startsWith(z$+"/")),D$=w$.length>0&&!w$.some(j$);if(JJ&&!D$){let z$=aq(m);if(z$!==m){let $$=J$.mkdtempSync(k$.join(H7(),"claude-empty-"));V.push("--ro-bind",$$,z$),q.set(z$,r),J9.add(z$),E4(),Z(`[Sandbox Linux] Mounted empty dir at ${z$} to block creation of ${m}`)}else V.push("--ro-bind","/dev/null",z$),q.set(z$,r),J9.add(z$),E4(),Z(`[Sandbox Linux] Mounted /dev/null at ${z$} to block creation of ${m}`)}else if(D$)Z(`[Sandbox Linux] Skipping non-existent deny path inside a read-only denied directory (already uncreatable): ${m}`);else Z(`[Sandbox Linux] Skipping non-existent deny path not within allowed paths: ${m}`);continue}if(h(m))V.push("--ro-bind",m,m),q.set(m,r);else Z(`[Sandbox Linux] Skipping deny path not within allowed paths: ${m}`)}}else U.push("--bind","/","/");let F=[],K=($?.allowWithinDeny||[]).map((S)=>e$(S)),R=new Map,L=[],D=new Set(["proc","dev","sys"]);for(let S of $?.denyOnly||[])if(e$(S)==="/"){for(let C of J$.readdirSync("/"))if(!D.has(C))F.push("/"+C)}else F.push(S);if($&&J$.existsSync("/etc/ssh/ssh_config.d"))F.push("/etc/ssh/ssh_config.d");let w=F.map((S)=>e$(S)).sort((S,C)=>S.split("/").length-C.split("/").length);for(let S of w){if(!J$.existsSync(S)){Z(`[Sandbox Linux] Skipping non-existent read deny path: ${S}`);continue}if(J$.statSync(S).isDirectory())L.push(S),N4(U,S,O,K);else{if(K.includes(S)){Z(`[Sandbox Linux] Skipping read deny for re-allowed path: ${S}`);continue}let h=V7(S);U.push("--ro-bind","/dev/null",h),R.set(h,"/dev/null"),R.set(S,"/dev/null")}}for(let{realPath:S,fakePath:C}of X??[]){let h=V7(S);U.push("--ro-bind",C,h),R.set(h,C),R.set(S,C)}let T=(S)=>L.some((C)=>{if(!(S===C||S.startsWith(C+"/")))return!1;return!O.some((a)=>(a===C||a.startsWith(C+"/"))&&(S===a||S.startsWith(a+"/")))}),P=[];for(let S=0;S<V.length;S+=3){let C=V[S+2],h=q.get(C)??C;if(R.has(C))continue;if(T(C)||T(h)){Z(`[Sandbox Linux] Skipping denyWrite bind already hidden by denyRead tmpfs: ${C}`);continue}if(U.push(V[S],V[S+1],C),P.push(C),h!==C)P.push(h)}for(let S of L)if(P.some((C)=>S.startsWith(C+"/")))Z(`[Sandbox Linux] Re-applying denyRead tmpfs re-exposed by denyWrite bind: ${S}`),N4(U,S,O,K);for(let[S,C]of R)if(P.some((h)=>S.startsWith(h+"/"))){if(V7(S)!==S)continue;Z(`[Sandbox Linux] Re-applying file mask re-exposed by denyWrite bind: ${S}`),U.push("--ro-bind",C,S)}if(Q!==void 0)U.push("--ro-bind",Q,Q);return U}async function A4($){let{command:J,commandId:X,needsNetworkRestriction:Q,httpSocketPath:Y,socksSocketPath:G,httpProxyPort:W,socksProxyPort:M,proxyAuthToken:U,caCertPath:O,readConfig:V,writeConfig:H,unsetEnvVars:q,setEnvVars:F,maskedFileBinds:K,maskedFileStoreDir:R,enableWeakerNestedSandbox:L,runAsUid:D,runAsGid:w,runAsHostUid:T,runAsHostGid:P,runAsHostHome:S,runAsHostUser:C,setprivPath:h,allowAllUnixSockets:s,binShell:a,ripgrepConfig:O$={command:"rg"},mandatoryDenySearchDepth:j$=q7,allowGitConfig:T$=!1,gitSafeDirectories:G$,seccompConfig:r,bwrapPath:m,socatPath:W$,observeSocketPath:l,abortSignal:H$}=$,JJ=V&&V.denyOnly.length>0||K!==void 0&&K.length>0,w$=H!==void 0,D$=q!==void 0&&q.length>0||F!==void 0&&Object.keys(F).length>0,z$=(G$?.length??0)>0;if(!Q&&!JJ&&!w$&&!D$&&!z$)return J;f0++;let $$=["--new-session","--die-with-parent"],d$=[],h$;try{if(!s)if(h$=rq(r?.applyPath,r?.argv0),!h$)Z("[Sandbox Linux] apply-seccomp binary not available - unix socket blocking disabled. Install @anthropic-ai/sandbox-runtime globally for full protection.",{level:"warn"});else Z("[Sandbox Linux] Applying seccomp filter for Unix socket blocking");else Z("[Sandbox Linux] Skipping seccomp filter - allowAllUnixSockets is enabled");if(l&&h$)if(J$.existsSync(l))d$.push("--bind",l,l),$$.push("--setenv","SRT_OBSERVE_SOCK",l),$$.push("--setenv","SRT_ENCODED_CMD",wJ(X??J));else Z("[Sandbox Linux] observe socket missing \u2014 supervisor not running; "+"continuing without violation monitoring");if(D$){for(let x$ of q??[])$$.push("--unsetenv",x$);for(let[x$,m$]of Object.entries(F??{}))$$.push("--setenv",x$,m$)}if(G$&&G$.length>0){let x$=JY({safeDirs:G$,unsetEnvVars:q,setEnvVars:F});for(let[m$,a$]of Object.entries(x$))$$.push("--setenv",m$,a$)}if(Q){if($$.push("--unshare-net"),Y&&G){if(!J$.existsSync(Y))throw Error(`Linux HTTP bridge socket does not exist: ${Y}. The bridge process may have died. Try reinitializing the sandbox.`);if(!J$.existsSync(G))throw Error(`Linux SOCKS bridge socket does not exist: ${G}. The bridge process may have died. Try reinitializing the sandbox.`);if(d$.push("--bind",Y,Y),G!==Y)d$.push("--bind",G,G);let x$=LQ(3128,1080,O,U,H===void 0,wJ(X??J));if($$.push(...x$.flatMap((m$)=>{let a$=m$.indexOf("="),GJ=m$.slice(0,a$),n5=m$.slice(a$+1);return["--setenv",GJ,n5]})),W!==void 0)$$.push("--setenv","CLAUDE_CODE_HOST_HTTP_PROXY_PORT",String(W));if(M!==void 0)$$.push("--setenv","CLAUDE_CODE_HOST_SOCKS_PROXY_PORT",String(M))}}let t$=await eq(V,H,K,R,O$,j$,T$,H$);if($$.push(...t$),$$.push(...d$),$$.push("--dev","/dev"),$$.push("--unshare-pid"),!L){if($$.push("--unshare-user","--cap-drop","ALL","--proc","/proc"),!h$)$$.push("--ro-bind","/dev/null","/proc/sysrq-trigger")}else $$.push("--unshare-user","--bind","/proc","/proc");if(D!==void 0)$$.push("--uid",String(D)),$$.push("--gid",String(w??D));if(T!==void 0){if(S)$$.push("--setenv","HOME",S);if(C)$$.push("--setenv","USER",C),$$.push("--setenv","LOGNAME",C)}let QJ=a||"bash",o$=N0(QJ);if(!o$)throw Error(`Shell '${QJ}' not found in PATH`);if($$.push("--",o$,"-c"),Q&&Y&&G){let x$=tq(Y,G,J,h$,o$,W$);$$.push(x$)}else if(h$){let x$=h$+IJ([o$,"-c",J]);$$.push(x$)}else $$.push(J);let XJ=[m??"bwrap",...$$],YJ=IJ(nq({bwrapCommand:XJ,uid:T,gid:P,setprivPath:h,unsetEnvVars:q,setEnvVars:F})),c$=[];if(Q)c$.push("network");if(JJ||w$)c$.push("filesystem");if(D$)c$.push("env");if(h$)c$.push("seccomp(unix-block)");return Z(`[Sandbox Linux] Wrapped command with bwrap (${c$.join(", ")} restrictions)`),YJ}catch(t$){if(f0>0)f0--;throw t$}}import{spawn as $K}from"child_process";import*as L0 from"path";class X9{violations=[];totalCount=0;maxSize=100;listeners=new Set;addViolation($){if(this.violations.push({...$,line:K7($.line).replace(/[<>]/g,"")}),this.totalCount++,this.violations.length>this.maxSize)this.violations=this.violations.slice(-this.maxSize);this.notifyListeners()}getViolations($){if($===void 0)return[...this.violations];return this.violations.slice(-$)}getCount(){return this.violations.length}getTotalCount(){return this.totalCount}getViolationsForCommand($){let J=wJ($);return this.violations.filter((X)=>X.encodedCommand===J)}clear(){this.violations=[],this.notifyListeners()}subscribe($){return this.listeners.add($),$(this.getViolations()),()=>{this.listeners.delete($)}}notifyListeners(){let $=this.getViolations();this.listeners.forEach((J)=>J($))}}function uQ($,J,X){if(!X)return!1;if((X["*"]??[]).some((Y)=>$.includes(Y)))return!0;if(J===void 0)return!1;for(let[Y,G]of Object.entries(X))if(Y!=="*"&&J.includes(Y)&&G.some((W)=>$.includes(W)))return!0;return!1}function K7($){return $.replace(/[\x00-\x1f\x7f-\x9f]+/g," ").trim()}function JK($=!1){let J=process.cwd(),X=[];for(let Q of GX)X.push(L0.resolve(J,Q)),X.push(`**/${Q}`);for(let Q of $Y())X.push(L0.resolve(J,Q)),X.push(`**/${Q}/**`);if(X.push(L0.resolve(J,".git/hooks")),X.push("**/.git/hooks/**"),!$)X.push(L0.resolve(J,".git/config")),X.push("**/.git/config");return[...new Set(X)]}var D4=`_${Math.random().toString(36).slice(2,11)}_SBX`;function QK($){return`CMD64_${wJ($)}_END_${D4}`}function gQ($){return FJ($)?`(regex ${cJ(OX($))})`:`(subpath ${cJ($)})`}function N7($){return OX($).slice(0,-1)+"(/.*)?$"}function UQ($){return FJ($)?`(regex ${cJ(N7($))})`:`(subpath ${cJ($)})`}function Z4($){return $.replace(/\[[^\]]*\]|[*?]+/g,"x")}function E7($,J){let X=[...new Set(J)];if(X.length===0)return $;let Q=X.map((Y)=>`(require-not ${Y})`).join(" ");return`(require-all ${$} ${Q})`}function z7($){let J=e$($);return{path:J,glob:FJ(J)}}function B4($,J){return $.test(J.glob?Z4(J.path):J.path)}function Y9($,J){let X=$.glob?Z4($.path):$.path;return X.startsWith(J==="/"?"/":J+"/")&&X!==J}function XK($,J){return{denies:($.denyOnly||[]).map(z7),allows:($.allowWithinDeny||[]).map(z7),writeRoots:(J||[]).map(z7)}}function YK($){let J=[],X=!1,Q=$.allows.filter((Y)=>!Y.glob).map((Y)=>Y.path);for(let Y of $.denies){if(!Y.glob){if(Q.some((M)=>Y.path.startsWith(M+"/")))J.push(UQ(Y.path));continue}let G=new RegExp(N7(Y.path));if(G.test("/"))X=!0;let W=$.allows.filter((M)=>B4(G,M)).map((M)=>gQ(M.path));J.push(E7(UQ(Y.path),W))}return{filters:J,coversRoot:X}}function j4($){let J=$.split(/[*?[\]]/)[0];if(!J||J==="/")return"/";return J.endsWith("/")?J.slice(0,-1):L0.dirname(J)}function GK($,J){let{denies:X,allows:Q,writeRoots:Y}=$;if(Y.length===0)return[];let G=Y.filter((H)=>H.glob).map((H)=>new RegExp(OX(H.path))),W=Y.filter((H)=>!H.glob).map((H)=>H.path),M=(H)=>W.some((q)=>Y9({path:H,glob:!1},q))||G.some((q)=>q.test(H)),U=(H)=>[...Q,...Y].filter((q)=>Y9(q,H)).map((q)=>gQ(q.path)),O=new Set,V=(H)=>{for(let q of H)if(M(q))O.add(`(literal ${cJ(q)})`)};for(let H of X)if(H.glob){let q=j4(H.path);if(!(G.length>0||W.some((L)=>q===L||Y9({path:q,glob:!1},L)||Y9({path:L,glob:!1},q))))continue;let K=new RegExp(N7(H.path)),R=[...Q,...Y].filter((L)=>B4(K,L)).map((L)=>gQ(L.path));if(O.add(E7(UQ(H.path),R)),q!=="/")V([q,...F7(q)])}else{if(!M(H.path))continue;O.add(E7(UQ(H.path),U(H.path))),V(F7(H.path))}return y0("deny",["file-write-unlink"],O,J)}function y0($,J,X,Q){if(X.size===0)return[];return[`(${$} ${J.join(" ")}`,...[...X].map((Y)=>` ${Y}`),` (with message "${Q}"))`]}function F7($){let J=[],X=L0.dirname($);while(X!=="/"&&X!=="."){J.push(X);let Q=L0.dirname(X);if(Q===X)break;X=Q}return J}function T4($,J){let X=new Set;for(let Q of $){let Y=e$(Q);X.add(UQ(Y));let G;if(FJ(Y)){if(G=j4(Y),G==="/")continue;X.add(`(literal ${cJ(G)})`)}else G=Y;for(let W of F7(G))X.add(`(literal ${cJ(W)})`)}return y0("deny",["file-write-unlink","file-write-create"],X,J)}function WK($,J){if(!$)return["(allow file-read*)"];let X=[];X.push("(allow file-read*)");let Q=$.denies.some((U)=>U.path==="/"),Y=new Set($.denies.map((U)=>UQ(U.path)));X.push(...y0("deny",["file-read*"],Y,J));let G=new Set($.allows.map((U)=>gQ(U.path)));X.push(...y0("allow",["file-read*"],G,J));let W=YK($);if(X.push(...y0("deny",["file-read*"],new Set(W.filters),J)),Q||W.coversRoot)X.push('(allow file-read* (literal "/"))');if($.denies.length>0)X.push("(allow file-read-metadata"," (vnode-type DIRECTORY))");X.push(...T4($.denies.map((U)=>U.path),J));let M=new Set($.writeRoots.map((U)=>gQ(U.path)));return X.push(...y0("allow",["file-write-unlink","file-write-create"],M,J)),X}function MK($,J,X=!1){if(!$)return["(allow file-write*)"];let Q=[],Y=new Set;for(let M of $.allowOnly||[])Y.add(gQ(e$(M)));Q.push(...y0("allow",["file-write*"],Y,J));let G=[...$.denyWithinAllow||[],...JK(X)],W=new Set;for(let M of G)W.add(UQ(e$(M)));return Q.push(...y0("deny",["file-write*"],W,J)),Q.push(...T4(G,J)),Q}function UK({readConfig:$,writeConfig:J,httpProxyPort:X,socksProxyPort:Q,needsNetworkRestriction:Y,allowUnixSockets:G,allowAllUnixSockets:W,allowLocalBinding:M,allowMachLookup:U,allowPty:O,allowGitConfig:V=!1,enableWeakerNetworkIsolation:H=!1,allowAppleEvents:q=!1,logTag:F}){let K=["(version 1)",`(deny default (with message "${F}"))`,"",`; LogTag: ${F}`,"","; 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.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")',")","",...H?["; trustd.agent - needed for Go TLS certificate verification (weaker network isolation)",'(allow mach-lookup (global-name "com.apple.trustd.agent"))']:[],...q?["; Apple Events - opt-in; needed for open/osascript to talk to other apps (appleeventsd)","(allow appleevent-send)",'(allow mach-lookup (global-name "com.apple.coreservices.appleevents"))',"; Launch Services open requests need the lsopen operation plus, on","; macOS 14/15, coreservicesd and the quarantine resolver - without","; these open fails with -10822 kLSServerCommunicationErr or -54","(allow lsopen)",'(allow mach-lookup (global-name "com.apple.CoreServices.coreservicesd"))','(allow mach-lookup (global-name "com.apple.coreservices.quarantine-resolver"))']:[],...U&&U.length>0?["; User-specified XPC/Mach services",...U.map((L)=>L.endsWith("*")?`(allow mach-lookup (global-name-prefix ${cJ(L.slice(0,-1))}))`:`(allow mach-lookup (global-name ${cJ(L)}))`)]:[],"","; 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(K.push("; Network"),!Y)K.push("(allow network*)");else{if(M)K.push('(allow network-bind (local ip "*:*"))'),K.push('(allow network-inbound (local ip "*:*"))'),K.push('(allow network-outbound (remote ip "localhost:*"))');if(W)K.push("(allow system-socket (socket-domain AF_UNIX))"),K.push('(allow network-bind (local unix-socket (path-regex #"^/")))'),K.push('(allow network-outbound (remote unix-socket (path-regex #"^/")))');else if(G&&G.length>0){K.push("(allow system-socket (socket-domain AF_UNIX))");for(let L of G){let D=e$(L);K.push(`(allow network-bind (local unix-socket (subpath ${cJ(D)})))`),K.push(`(allow network-outbound (remote unix-socket (subpath ${cJ(D)})))`)}}if(X!==void 0)K.push(`(allow network-bind (local ip "localhost:${X}"))`),K.push(`(allow network-inbound (local ip "localhost:${X}"))`),K.push(`(allow network-outbound (remote ip "localhost:${X}"))`);if(Q!==void 0&&Q!==X)K.push(`(allow network-bind (local ip "localhost:${Q}"))`),K.push(`(allow network-inbound (local ip "localhost:${Q}"))`),K.push(`(allow network-outbound (remote ip "localhost:${Q}"))`)}K.push("");let R=$?XK($,J?.allowOnly):void 0;if(K.push("; File read"),K.push(...WK(R,F)),K.push(""),K.push("; File write"),K.push(...MK(J,F,V)),R){let L=GK(R,F);if(L.length>0)K.push(""),K.push("; File read: keep read-denied paths inside write roots in place"),K.push(...L)}if(O)K.push(""),K.push("; Pseudo-terminal (pty) support"),K.push("(allow pseudo-tty)"),K.push("(allow file-ioctl"),K.push(' (literal "/dev/ptmx")'),K.push(' (regex #"^/dev/ttys")'),K.push(")"),K.push("(allow file-read* file-write*"),K.push(' (literal "/dev/ptmx")'),K.push(' (regex #"^/dev/ttys")'),K.push(")");return K.join(`
|
|
64
|
-
`)}function cJ($){return JSON.stringify($)}function S4($){let{command:J,commandId:X,needsNetworkRestriction:Q,httpProxyPort:Y,socksProxyPort:G,proxyAuthToken:W,caCertPath:M,allowUnixSockets:U,allowAllUnixSockets:O,allowLocalBinding:V,allowMachLookup:H,readConfig:q,writeConfig:F,unsetEnvVars:K,setEnvVars:R,maskedFileBinds:L,allowPty:D,allowGitConfig:w=!1,gitSafeDirectories:T,enableWeakerNetworkIsolation:P=!1,allowAppleEvents:S=!1,binShell:C}=$,h=q;if(L&&L.length>0)Z("[Sandbox macOS] file mask degrades to deny on macOS until the interposer lands"),h={denyOnly:[...q?.denyOnly??[],...L.map((D$)=>D$.realPath)],allowWithinDeny:q?.allowWithinDeny};let s=h&&h.denyOnly.length>0,a=F!==void 0,O$=K!==void 0&&K.length>0||R!==void 0&&Object.keys(R).length>0,j$=(T?.length??0)>0;if(!Q&&!s&&!a&&!O$&&!j$)return J;let T$=X??J,G$=QK(T$),r=UK({readConfig:h,writeConfig:F,httpProxyPort:Y,socksProxyPort:G,needsNetworkRestriction:Q,allowUnixSockets:U,allowAllUnixSockets:O,allowLocalBinding:V,allowMachLookup:H,allowPty:D,allowGitConfig:w,enableWeakerNetworkIsolation:P,allowAppleEvents:S,logTag:G$}),m=LQ(Y,G,M,W,F===void 0,wJ(T$));if(V&&Q){let $$=(K??[]).includes("JAVA_TOOL_OPTIONS")?"":process.env.JAVA_TOOL_OPTIONS??"",d$=$$.includes("-Djava.net.preferIPv4Stack=true")?$$:[$$,"-Djava.net.preferIPv4Stack=true"].filter(Boolean).join(" ");m.push(`JAVA_TOOL_OPTIONS=${d$}`)}if(T&&T.length>0){let D$=JY({safeDirs:T,unsetEnvVars:K,setEnvVars:R});for(let[z$,$$]of Object.entries(D$))m.push(`${z$}=${$$}`)}let W$=C||"bash",l=N0(W$);if(!l)throw Error(`Shell '${W$}' not found in PATH`);let H$=(K??[]).flatMap((D$)=>["-u",D$]),JJ=Object.entries(R??{}).map(([D$,z$])=>`${D$}=${z$}`),w$=IJ(["env",...H$,...JJ,...m,"/usr/bin/sandbox-exec","-p",r,l,"-c",J]);return Z(`[Sandbox macOS] Applied restrictions - network: ${!!(Y||G)}, read: ${h?"allowAllExcept"in h?"allowAllExcept":"denyAllExcept":"none"}, write: ${F?"allowAllExcept"in F?"allowAllExcept":"denyAllExcept":"none"}`),w$}function I4($,J,X=(Q)=>Q){let Q=/CMD64_(.+?)_END/,Y=/Sandbox:\s+(.+)$/,G=$K("log",["stream","--predicate",`(eventMessage ENDSWITH "${D4}")`,"--style","compact"]);return G.stdout?.on("data",(W)=>{let M=W.toString().split(`
|
|
65
|
-
`),U=M.find((K)=>K.includes("Sandbox:")&&K.includes("deny")),O=M.find((K)=>K.startsWith("CMD64_"));if(!U)return;let V=U.match(Y);if(!V?.[1])return;let H=V[1],q,F;if(O){if(F=O.match(Q)?.[1],F)try{q=X(a0(F))}catch{}}if(H.includes("mDNSResponder")||H.includes("mach-lookup com.apple.diagnosticd")||H.includes("mach-lookup com.apple.analyticsd"))return;if(uQ(H,q,J))return;$({line:H,command:q,encodedCommand:F,timestamp:new Date})}),G.stderr?.on("data",(W)=>{Z(`[Sandbox Monitor] Log stream stderr: ${W.toString()}`)}),G.on("error",(W)=>{Z(`[Sandbox Monitor] Failed to start log stream: ${W.message}`)}),G.on("exit",(W)=>{Z(`[Sandbox Monitor] Log stream exited with code: ${W}`)}),()=>{Z("[Sandbox Monitor] Stopping log monitor"),G.kill("SIGTERM")}}import{randomBytes as OK}from"crypto";import{chmodSync as C4,chownSync as VK,mkdtempSync as HK,rmSync as qK}from"fs";import{createServer as KK}from"net";import{tmpdir as zK}from"os";import{join as w4,posix as EK}from"path";import{createInterface as FK}from"readline";function P4($,J){let{allowWritePaths:X,denyWritePaths:Q,ignoreViolations:Y,resolveCommandText:G=(T)=>T,consumerUid:W,consumerGid:M}=J,U=HK(w4(zK(),"srt-obs-")),O=w4(U,`s${OK(4).toString("hex")}.sock`),V=(T,P)=>T===P||T.startsWith(P.endsWith("/")?P:P+"/"),H=(T)=>{let P=EK.normalize(T);if(Q.some((S)=>V(P,S)))return!0;return!X.some((S)=>V(P,S))},q=(T,P)=>{if(T.observe_init_error){Z(`[Sandbox Linux Monitor] observe filter not installed: ${T.observe_init_error}`);return}if(typeof T.path!=="string")return;if(!T.path.startsWith("/"))return;if(!H(T.path))return;let S;if(P)try{S=G(a0(P))}catch{}if(uQ(T.path,S,Y))return;let C={line:`deny ${T.syscall??"syscall"} ${T.path}`,command:S,encodedCommand:P,timestamp:new Date};$(C)},F,K=new Promise((T)=>{F=T}),R=O,L=KK((T)=>{let P,S=FK({input:T});S.on("line",(C)=>{if(!C)return;let h;try{h=JSON.parse(C)}catch{return}if(h.encodedCommand&&P===void 0)P=h.encodedCommand;q(h,P??h.encodedCommand)}),T.on("error",()=>S.close()),T.on("close",()=>S.close())});L.on("error",(T)=>{Z(`[Sandbox Linux Monitor] listen failed: ${T.message} - violation monitoring disabled`,{level:"warn"}),R=void 0,F()}),L.listen(O,()=>{if(W!==void 0)C4(U,457),VK(O,W,M??W),C4(O,384);F()});let D=new Set;return L.on("connection",(T)=>{D.add(T),T.on("close",()=>D.delete(T))}),{get observeSocketPath(){return R},ready:K,stop:()=>{Z("[Sandbox Linux Monitor] stopping");for(let T of D)T.destroy();L.close();try{qK(U,{recursive:!0,force:!0})}catch{}}}}import*as r$ from"fs";import*as v4 from"net";import*as s$ from"path";import{spawn as NK,spawnSync as LK}from"child_process";import{once as RK}from"events";import{fileURLToPath as AK}from"url";class F$ extends Error{code;subcommand;constructor($,J,X){super(J);this.name="WindowsSandboxError",this.code=$,this.subcommand=X}}var G9=[60080,60089],_4=["-NoProfile","-Command"];function W9($){let J=process.env.SystemRoot??"C:\\Windows",X={exe:s$.win32.join(J,"System32","cmd.exe"),args:["/d","/s","/c"]};if($===void 0||$===null)return X;if(typeof $==="object"){if(!s$.win32.isAbsolute($.exe))throw new F$("bin_shell_invalid",`binShell.exe must be an absolute path (got ${JSON.stringify($.exe)})`);if(!Array.isArray($.args))throw new F$("bin_shell_invalid",`binShell.args must be an array (got ${JSON.stringify($.args)})`);return $}let Q=s$.win32.basename($),Y=Q.toLowerCase(),G=s$.win32.isAbsolute($);if(!G&&$!==Q)throw new F$("bin_shell_invalid",`binShell string must be a bare token or an absolute path (got ${JSON.stringify($)})`);switch(Y){case"bash":case"bash.exe":case"sh":case"sh.exe":if(!G)throw new F$("bin_shell_invalid",`binShell bash path must be absolute (got ${JSON.stringify($)}); pass the resolved Git Bash install path`);return{exe:$,args:["-c"]};case"pwsh":case"pwsh.exe":return{exe:G?$:"pwsh.exe",args:_4};case"powershell":case"powershell.exe":return{exe:G?$:s$.win32.join(J,"System32","WindowsPowerShell","v1.0","powershell.exe"),args:_4};case"cmd":case"cmd.exe":return G?{exe:$,args:X.args}:X;default:throw new F$("bin_shell_invalid",`unrecognised binShell ${JSON.stringify($)}: expected 'cmd' | 'powershell' | 'pwsh' or an absolute path to bash.exe/sh.exe/pwsh.exe/powershell.exe`)}}function k4(){let $=s$.dirname(AK(import.meta.url));return s$.resolve($,"..","..")}var f4={x64:"x64",arm64:"arm64"},DK=s$.join(k4(),"vendor","srt-win",f4[process.arch]??process.arch,"srt-win.exe");function ZK(){let $=k4(),J=f4[process.arch],X=[];if(J)X.push(s$.join($,"vendor","srt-win",J,"srt-win.exe"));X.push(s$.join($,"vendor","srt-win-src","target","release","srt-win.exe"));for(let Q of X)if(r$.existsSync(Q))return Q;throw new F$("srt_win_not_found",`srt-win.exe not found. Set windows.srtWin.path or build with \`cargo build --release --manifest-path vendor/srt-win-src/Cargo.toml\`. Looked in: ${X.join(", ")}`)}var y4="--srt-win";function CJ($){if($?.path===void 0)throw new F$("srt_win_not_found","no srt-win path configured; set windows.srtWin.path (e.g. to the exported VENDORED_SRT_WIN_EXE constant for the packaged binary)");if(!r$.existsSync($.path))throw new F$("srt_win_not_found",`windows.srtWin.path is set to '${$.path}' but the file does not exist`);return{exe:$.path,prependArgs:[y4]}}function b0($,J={}){let{exe:X,prependArgs:Q}=J.srtWin??CJ(),Y=LK(X,[...Q,...$],{encoding:"utf8",windowsHide:!0,timeout:J.timeoutMs??15000,...J.stdin!==void 0?{input:J.stdin}:{}});if(Y.error){if(Y.error.code==="ETIMEDOUT")throw new F$("srt_win_timeout",`srt-win ${$.join(" ")} timed out after ${J.timeoutMs??15000}ms`+(Y.signal?` (killed by ${Y.signal})`:""),$[0]);throw new F$("spawn_failed",`srt-win ${$[0]}: spawn failed: ${Y.error.message}`,$[0])}return{status:Y.status,signal:Y.signal,stdout:(Y.stdout??"").trim(),stderr:(Y.stderr??"").trim()}}function R7($,J={}){let{exe:X,prependArgs:Q}=J.srtWin??CJ(),Y=J.timeoutMs??15000;return new Promise((G,W)=>{let M=NK(X,[...Q,...$],{windowsHide:!0}),U=!1,O=Y>0?setTimeout(()=>{U=!0,M.kill()},Y):void 0,V="",H="";M.stdout?.setEncoding("utf8").on("data",(q)=>V+=q),M.stderr?.setEncoding("utf8").on("data",(q)=>H+=q),M.stdin?.on("error",()=>{}).end(J.stdin),M.once("error",(q)=>{clearTimeout(O),W(new F$("spawn_failed",`srt-win ${$[0]}: spawn failed: ${q.message}`,$[0]))}),M.once("close",(q,F)=>{if(clearTimeout(O),U){W(new F$("srt_win_timeout",`srt-win ${$.join(" ")} timed out after ${Y}ms`+(F?` (killed by ${F})`:""),$[0]));return}G({status:q,signal:F,stdout:V.trim(),stderr:H.trim()})})})}function b4($,J){if(J.status!==0)throw new F$("srt_win_nonzero",`srt-win ${$.join(" ")} exited ${J.status}: ${J.stderr||J.stdout}`,$[0]);try{return JSON.parse(J.stdout)}catch(X){throw new F$("srt_win_bad_json",`srt-win ${$.join(" ")}: unparseable JSON output ${JSON.stringify(J.stdout)}: ${X.message}`,$[0])}}function A7($,J){return b4($,b0($,J))}async function D7($,J){return b4($,await R7($,J))}function h4($,J){let X=b0($,J),Q;try{Q=JSON.parse(X.stdout)}catch(Y){throw new F$("srt_win_bad_json",`srt-win ${$.join(" ")}: unparseable JSON output ${JSON.stringify(X.stdout)}: ${Y.message}`,$[0])}return{ok:X.status===0,json:Q,stderr:X.stderr}}function u4($){let J=["wfp","status"];if($)J.push("--sublayer-guid",$);return J}function M9($){return{state:$.state,filters:$.filters,...$.port_range&&{portRange:$.port_range},...$.user_sid&&{userSid:$.user_sid},...$.hint&&{hint:$.hint}}}function U9($){return{provisioned:$.user.exists,...$.user.sid&&{sid:$.user.sid},groupExists:$.user.group_exists,...$.user.group_sid&&{groupSid:$.user.group_sid},inBuiltinUsers:$.user.in_builtin_users,inSandboxGroup:$.user.in_sandbox_group,hiddenFromLogon:$.user.hidden_from_logon,credPresent:$.cred_present,...typeof $.marker_version==="number"&&{markerVersion:$.marker_version},realUserSid:$.real_user_sid,...$.ca_cert_thumb&&{caCertThumb:$.ca_cert_thumb},...$.ca_cert_pem&&{caCertPem:$.ca_cert_pem}}}function g4($={}){let J=["status"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);let X=A7(J,{srtWin:$.srtWin});return{user:U9(X.user),wfp:M9(X.wfp)}}async function m4($={}){let J=["status"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);let X=await D7(J,{srtWin:$.srtWin});return{user:U9(X.user),wfp:M9(X.wfp)}}function l4($={}){return M9(A7(u4($.sublayerGuid),{srtWin:$.srtWin}))}async function d4($={}){return M9(await D7(u4($.sublayerGuid),{srtWin:$.srtWin}))}async function Z7($={}){let J=$.target,X;if(!J){let[Q,Y]=$.proxyPortRange??G9;for(let G=0;G<5;G++){let W=v4.createServer();W.listen(0,"127.0.0.1"),await RK(W,"listening");let M=W.address().port;if(M<Q||M>Y){X=W,J=`127.0.0.1:${M}`;break}W.close()}if(!J)throw new F$("wfp_verify_bind_failed",`verifyWindowsWfpEgress: could not bind a loopback listener outside the WFP permit range [${Q},${Y}] in 5 attempts`)}try{let Q=b0(["wfp","verify","--target",J],{timeoutMs:30000,srtWin:$.srtWin});Z(`[Sandbox Windows] wfp verify exit=${Q.status}: ${Q.stderr||Q.stdout}`);let Y;try{Y=JSON.parse(Q.stdout)}catch{throw new F$("wfp_verify_unparseable","WFP egress fence could not be verified \u2014 `srt-win wfp "+`verify\` exited ${Q.status}`+(Q.signal?` (signal ${Q.signal})`:"")+` with unparseable output ${JSON.stringify(Q.stdout)} (stderr: ${JSON.stringify(Q.stderr)})`)}if(Q.status===3)throw new F$("wfp_fence_inactive","WFP egress fence is not active \u2014 direct outbound from the "+`sandbox user to ${Y.target} succeeded. Re-run \`srt-win install\` (one UAC prompt). (${Q.stderr})`);if(Q.status!==0)throw new F$("wfp_verify_inconclusive","WFP egress fence could not be verified \u2014 probe to "+`${Y.target} was '${Y.egress_probe}' (exit ${Q.status}). The fence may be absent. Re-run \`srt-win install\`. (${Q.stderr})`);return{target:Y.target,stderr:Q.stderr}}finally{X?.close()}}function B7($={}){return U9(A7(["user","status"],{srtWin:$.srtWin}))}async function vX($={}){return U9(await D7(["user","status"],{srtWin:$.srtWin}))}function j7($,J={}){let X=$??B7(J);if(!X.caCertThumb||!X.caCertPem)return null;return{pem:X.caCertPem,thumb:X.caCertThumb}}function BK($,J={}){let X=b0(["user","trust-ca",$],{timeoutMs:60000,srtWin:J.srtWin});c4($,X)}async function p4($,J={}){let X=await R7(["user","trust-ca",$],{timeoutMs:60000,srtWin:J.srtWin});c4($,X)}function c4($,J){if(Z(`[Sandbox Windows] user trust-ca exit=${J.status}: ${J.stderr||J.stdout}`),J.status!==0)throw new F$("trust_ca_failed",`srt-win user trust-ca '${$}' failed (exit ${J.status}): ${J.stderr||J.stdout}`)}function n4(){let $=process.env.ProgramData;if(!$)throw Error("ProgramData is not set");return s$.win32.join($,"sandbox-runtime")}async function T7($={}){let J=$.status??await vX({srtWin:$.srtWin});if(!J.provisioned||!J.credPresent)throw Error(`ensurePersistentWindowsCa: sandbox user is not provisioned (user=${J.provisioned}, cred=${J.credPresent}). Run \`npx sandbox-runtime windows-install\` first.`);let X=$.dir?void 0:n4();if(X&&!r$.existsSync(X))throw Error(`ensurePersistentWindowsCa: state directory ${X} does not exist. Run \`npx sandbox-runtime windows-install\` first.`);let Q=$.dir??s$.win32.join(X,"ca"),Y=s$.join(Q,"ca.json"),G=s$.join(Q,"cert.pem"),W=s$.join(Q,"key.pem"),M=($.regenerateWithinDays??30)*24*60*60*1000,U=(L,D)=>{let w=`${L}.tmp.${process.pid}`;r$.writeFileSync(w,D),r$.renameSync(w,L)},O=async(L,D,w,T)=>{U(G,L),U(W,D);let P=T||J.caCertThumb!==w;if(P){let S=s$.join(Q,`.trust.${process.pid}.${Date.now()}.pem`);r$.writeFileSync(S,L);try{await p4(S,{srtWin:$.srtWin})}finally{r$.rmSync(S,{force:!0})}}return Z(`[Sandbox Windows] persistent CA ${T?"generated":"reused"} (thumb=${w}${P&&!T?", trust reconciled":""})`),{certPem:L,keyPem:D,certPath:G,keyPath:W,thumbprint:w,generated:T,trusted:P}},V=()=>{let L;try{L=JSON.parse(r$.readFileSync(Y,"utf8"))}catch(w){Z(`[Sandbox Windows] persistent CA ca.json unreadable (${w.message})`,{level:"warn"});return}if(typeof L.certPem!=="string"||typeof L.keyPem!=="string")return;let D=IX(L.certPem,L.keyPem);if(!D.ok){Z(`[Sandbox Windows] persistent CA invalid (${D.reason})`,{level:"warn"});return}return{certPem:L.certPem,keyPem:L.keyPem,thumbprint:D.thumbprint,notAfter:D.notAfter}};if(!$.force){let L=V();if(L&&L.notAfter.getTime()-Date.now()>M)return await O(L.certPem,L.keyPem,L.thumbprint,!1);if(L)Z(`[Sandbox Windows] persistent CA expiring ${L.notAfter.toISOString()}; regenerating`,{level:"warn"})}r$.mkdirSync(Q,{recursive:!0});try{let L=Date.now()-300000;for(let D of r$.readdirSync(Q)){if(!D.includes(".tmp.")&&!D.startsWith(".trust."))continue;let w=s$.join(Q,D);if(r$.statSync(w).mtimeMs<L)r$.rmSync(w,{force:!0})}}catch{}let H=bY({cn:"sandbox-runtime persistent CA"});U(Y,JSON.stringify({certPem:H.certPem,keyPem:H.keyPem}));let q=V(),{certPem:F,keyPem:K,thumbprint:R}=q??{certPem:H.certPem,keyPem:H.keyPem,thumbprint:yQ(H.certPem)};return await O(F,K,R,!0)}function S7($){return $.timeoutMs??120000}function i4($){let J=["install"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);if($.proxyPortRange)J.push("--proxy-port-range",`${$.proxyPortRange[0]}-${$.proxyPortRange[1]}`);if($.sandboxUser)J.push("--sandbox-user",$.sandboxUser);if($.force)J.push("--force");return J}function o4($){if($ instanceof F$&&$.code==="srt_win_timeout")throw new F$("install_timeout","srt-win install timed out \u2014 the UAC prompt may still be open. "+`Re-run when ready to grant elevation. (${$.message})`);throw $}function a4($){if(Z(`[Sandbox Windows] install exit=${$.status}: ${$.stderr||$.stdout}`),$.status===0||$.status===10)return;let J=$.stderr||$.stdout;switch($.status){case 12:throw new F$("install_wfp_failed",`srt-win install: WFP filter install failed: ${J}`);case 14:throw new F$("install_user_failed",`srt-win install: sandbox user provisioning failed: ${J}`);case 13:throw new F$("install_config_conflict",`srt-win install: filters already exist under this sublayer with a different port range or sandbox-user name. Pass {force: true} to replace, or pick a different sublayerGuid. Output: ${J}`);case 17:throw new F$("install_ambient_failed",`srt-win install: ambient write-deny stamping failed (stock world-writable system dirs could not be deny-stamped for the sandbox user): ${J}`);default:throw new F$("install_failed",`srt-win install failed (exit ${$.status}): ${J}`)}}function jK($={}){let J=$.srtWin??CJ(),X;try{X=b0(i4($),{timeoutMs:S7($),srtWin:J})}catch(Y){o4(Y)}a4(X);let Q=g4({sublayerGuid:$.sublayerGuid,srtWin:J});return X.status===10?{...Q,cancelled:!0}:Q}async function TK($={}){let J=$.srtWin??CJ(),X;try{X=await R7(i4($),{timeoutMs:S7($),srtWin:J})}catch(Y){o4(Y)}a4(X);let Q=await m4({sublayerGuid:$.sublayerGuid,srtWin:J});return X.status===10?{...Q,cancelled:!0}:Q}function SK($={}){let J=["uninstall"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);if($.keepUser)J.push("--keep-user");let X=b0(J,{timeoutMs:S7($),srtWin:$.srtWin});if(Z(`[Sandbox Windows] uninstall exit=${X.status}: ${X.stderr||X.stdout}`),X.status===10)return{cancelled:!0};if(X.status!==0)throw new F$("uninstall_failed",`srt-win uninstall failed (exit ${X.status}): ${X.stderr||X.stdout}`);return{}}function O9($,J){let X=new Set;for(let Q of $){let Y=e$(Q),G=WX(Y);if(MX(Y)&&!G){X.add(Y);continue}let W=G?s0(Y,{caseInsensitive:!0}):[Y];for(let M of W){if(!r$.statSync(M,{throwIfNoEntry:!1})){if(J?.mode==="deny"&&!G)X.add(/[\\/]$/.test(Q)&&!/[\\/]$/.test(M)?M+"\\":M);continue}X.add(M)}}return[...X]}function IK($){for(let J of $.split(/\r?\n/)){let X=J.trim();if(!X.startsWith("{")||!X.includes('"code"'))continue;try{let Q=JSON.parse(X);if(Q.code==="mapped_drive_cwd")return Object.assign(new F$("mapped_drive_cwd",Q.message??"mapped/network-drive working directory","exec"),{drive:Q.drive})}catch{}}return}function I7($){let J=$.holderPid??process.pid,X=JSON.stringify({denyRead:$.denyRead,denyWrite:$.denyWrite}),Q=b0(["acl","stamp","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid],{timeoutMs:60000,stdin:X,srtWin:$.srtWin});if(Z(`[Sandbox Windows] acl stamp exit=${Q.status}: ${Q.stderr||Q.stdout}`),Q.status!==0)throw new F$("acl_stamp_failed",`srt-win acl stamp exited ${Q.status} `+(Q.status===2?"(partial \u2014 some inputs skipped)":"(failed)")+`: ${Q.stderr||Q.stdout}`)}function V9($){let J=$.holderPid??process.pid;try{let X=h4(["acl","restore","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid,"--json"],{timeoutMs:60000,srtWin:$.srtWin});if(!X.ok)Z(`[Sandbox Windows] acl restore exited non-zero (per-path outcomes preserved): ${X.stderr}`,{level:"error"});return Array.isArray(X.json)?X.json:[...X.json.paths??[],...X.json.parents??[]]}catch(X){Z(`[Sandbox Windows] acl restore: ${X.message}`,{level:"error"});return}}function C7($){let J=$.holderPid??process.pid,X=JSON.stringify({read:$.read,write:$.write}),Q=b0(["acl","grant","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid],{timeoutMs:60000,stdin:X,srtWin:$.srtWin});if(Z(`[Sandbox Windows] acl grant exit=${Q.status}: ${Q.stderr||Q.stdout}`),Q.status!==0)throw new F$("acl_grant_failed",`srt-win acl grant exited ${Q.status}: ${Q.stderr||Q.stdout}`)}function H9($){let J=$.holderPid??process.pid;try{let X=h4(["acl","revoke","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid,"--json"],{timeoutMs:60000,srtWin:$.srtWin});if(!X.ok)Z(`[Sandbox Windows] acl revoke exited non-zero: ${X.stderr}`,{level:"error"});return X.json}catch(X){Z(`[Sandbox Windows] acl revoke: ${X.message}`,{level:"error"});return}}function s4($){let{exe:J,prependArgs:X}=$.srtWin??CJ(),Q=CK(LQ($.httpProxyPort,$.socksProxyPort,$.caCertPath?.replace(/\\/g,"/"),$.proxyAuthToken,void 0,wJ($.commandId??$.command)));delete Q.TMPDIR,delete Q.NO_PROXY,delete Q.no_proxy;let Y=UX({safeDirs:[$.cwd??process.cwd(),...$.allowWrite??[],...$.gitSafeDirectories??[]],schannelCa:$.caCertPath!==void 0,baseEnv:$.setEnvVars}),G=[J,...X,"exec"];if($.quiet!==!1)G.push("--quiet");for(let V of $.denyRead??[])G.push("--deny-read",V);for(let V of $.denyWrite??[])G.push("--deny-write",V);let W={PATH:process.env.PATH,PATHEXT:process.env.PATHEXT,...$.setEnvVars??{},...Q,...Y};for(let[V,H]of Object.entries(W))if(H!==void 0)G.push("--env",`${V}=${H}`);G.push("--");let M=$.binShell??W9(void 0);G.push(M.exe,...M.args,$.command);let U=G.reduce((V,H)=>V+H.length+3,0);if(U>30000)throw new F$("argv_too_long",`Windows sandbox argv is ~${U} chars (CreateProcessW limit is 32 767).`);let O={...process.env,...Q};return{argv:G,env:O}}function CK($){let J={};for(let X of $){let Q=X.indexOf("=");if(Q===-1)continue;J[X.slice(0,Q)]=X.slice(Q+1)}return J}function L7($){let J=$?` --sublayer-guid ${$}`:"";return`Windows sandbox needs a one-time install (one UAC prompt):
|
|
61
|
+
`)}),M.on("error",()=>O.destroy()),M.once("close",()=>O.destroy()),O.once("close",()=>M.destroy()),M.pipe(O),O.pipe(M)}let U=rq((M)=>{G.add(M),M.once("close",()=>G.delete(M)),M.on("error",(V)=>Z(`mux: client socket error: ${V.message}`));let O=setTimeout(()=>{Z("mux: first-byte timeout; destroying connection"),M.destroy()},J);if(typeof O.unref==="function")O.unref();M.once("readable",()=>{clearTimeout(O);let V=M.read(1);if(!V||V.length===0){M.destroy();return}if(M.unshift(V),$6.has(V[0]))$.handleSocksConnection(M);else W(M)})});return{server:U,getPort(){let M=U.address();return M&&typeof M==="object"?M.port:void 0},async listenHttpBackend(){if(!X){let O=X6();await F4(O).catch(()=>{}),await new Promise((V,H)=>{$.httpServer.once("error",H),$.httpServer.listen(O,()=>{$.httpServer.removeListener("error",H),V()})}),Q=O,Z(`mux: HTTP backend listening on ${O}`);return}await Y9($.httpServer,(O)=>$.httpServer.listen(O,"127.0.0.1"),$.httpBackendPortRange,new Set);let M=$.httpServer.address();return Y=M&&typeof M==="object"?M.port:void 0,Z(`mux: HTTP backend listening on 127.0.0.1:${Y}`),Y},async close(){for(let M of G)M.destroy();if(G.clear(),await new Promise((M)=>U.close(()=>M())),await new Promise((M)=>$.httpServer.close(()=>M())),Q)await F4(Q).catch(()=>{}),Q=void 0;Y=void 0},unref(){U.unref(),$.httpServer.unref()}}}import{randomBytes as Y6,randomUUID as G6}from"crypto";var bX="fake_value_",L4="abcdefghijklmnopqrstuvwxyz0123456789_-";function W6($){let J=bX+G6(),X=Buffer.byteLength($)-J.length;if(X<=0)return J;let Q=J;for(let Y of Y6(X))Q+=L4[Y%L4.length];return Q}class z7{byName=new Map;bySentinel=new Map;allSentinelsPrefixed=!0;register($,J,X){return this.registerWithSentinel($,W6(J),J,X)}registerWithSentinel($,J,X,Q){let Y=this.byName.get($);if(Y!==void 0)return Y.realValue=X,Y.injectHosts=Q,Y.sentinel;if(!J.startsWith(bX))this.allSentinelsPrefixed=!1;let G={name:$,sentinel:J,realValue:X,injectHosts:Q};return this.byName.set($,G),this.bySentinel.set(J,G),J}lookupReal($){return this.bySentinel.get($)?.realValue}namesInjectableAt($,J){let X=[];for(let Q of this.byName.values())if(Q.injectHosts.some((Y)=>J($,Y)))X.push(Q.name);return X}sentinelsForHost($,J){let X=[];for(let Q of this.bySentinel.values()){if(!Q.injectHosts.some((Y)=>J($,Y)))continue;X.push({sentinel:Buffer.from(Q.sentinel),realValue:Buffer.from(Q.realValue)})}return X}*entries(){for(let $ of this.bySentinel.values())yield[$.sentinel,$.realValue]}get size(){return this.bySentinel.size}clear(){this.byName.clear(),this.bySentinel.clear(),this.allSentinelsPrefixed=!0}substituteInHeaders($,J,X){if(this.bySentinel.size===0)return;for(let[Q,Y]of Object.entries($)){if(Y===void 0)continue;if(Array.isArray(Y))for(let G=0;G<Y.length;G++)Y[G]=this.substituteInHeaderValue(Q,Y[G],J,X);else $[Q]=this.substituteInHeaderValue(Q,Y,J,X)}}substituteInHeaderValue($,J,X,Q){let Y=this.substituteInString(J,X,Q);if($.toLowerCase()!=="authorization")return Y;let G=/^(\s*basic\s+)([a-z0-9+/]+={0,2})(\s*)$/i.exec(Y);if(G===null)return Y;let W=G[2],U=Buffer.from(W,"base64");if(W.length%4!==0||U.toString("base64")!==W)return Y;let M=U.toString("utf8");if(!Buffer.from(M,"utf8").equals(U))return Y;let O=this.substituteInString(M,X,Q);if(O===M)return Y;return`${G[1]}${Buffer.from(O,"utf8").toString("base64")}${G[3]}`}substituteInString($,J,X){if(this.allSentinelsPrefixed&&!$.includes(bX))return $;let Q=$;for(let Y of this.bySentinel.values()){if(!Q.includes(Y.sentinel))continue;if(!Y.injectHosts.some((G)=>X(J,G)))continue;Q=Q.split(Y.sentinel).join(Y.realValue)}return Q}}import{randomUUID as z6}from"crypto";import*as cJ from"fs";import{tmpdir as E6}from"os";import{join as Z4}from"path";function U6($,J){let X=!1;for(let Q=J+1;Q<$.length;Q++){let Y=$[Q];if(X){X=!1;continue}if(Y==="\\")X=!0;else if(Y==="]")return Q+1}return $.length}function M6($){switch($){case"s":return{kind:"whitespace"};case"S":return{kind:"non-whitespace"};case"d":return{kind:"digit"};case"D":return{kind:"non-digit"};case"w":return{kind:"word"};case"W":return{kind:"non-word"};default:return{kind:"unknown"}}}function A4($,J){if($===null||J===null)return!0;if($.kind==="literal"&&J.kind==="literal")return $.value===J.value;if($.kind==="whitespace"&&J.kind==="non-whitespace"||$.kind==="non-whitespace"&&J.kind==="whitespace"||$.kind==="digit"&&J.kind==="non-digit"||$.kind==="non-digit"&&J.kind==="digit"||$.kind==="word"&&J.kind==="non-word"||$.kind==="non-word"&&J.kind==="word")return!1;return!0}function O6($,J){if($[J+1]!=="?")return{next:J+1,capturing:!0};if($[J+2]==="<"){let Q=$[J+3];if(Q==="="||Q==="!")return{next:J+4,capturing:!1};let Y=$.indexOf(">",J+3);return{next:Y===-1?J+3:Y+1,capturing:!0}}return{next:J+3,capturing:!1}}function V6($,J){let X=$[J];if(X==="*"||X==="+")return{next:$[J+1]==="?"?J+2:J+1,unbounded:!0};if(X==="?")return{next:$[J+1]==="?"?J+2:J+1,unbounded:!1};if(X!=="{")return null;let Q=J+1,Y=Q;while(/[0-9]/.test($[Q]??""))Q++;if(Q===Y)return null;let G=Number($.slice(Y,Q)),W=G,U=!1;if($[Q]===","){Q++;let M=Q;while(/[0-9]/.test($[Q]??""))Q++;if(Q===M)U=!0,W=void 0;else W=Number($.slice(M,Q))}if($[Q]!=="}")return null;if(!Number.isFinite(G)||G>4096||W!==void 0&&(!Number.isFinite(W)||W>4096))return{next:Q+1,unbounded:U,error:"finite repetitions must be at most 4096"};if(Q++,$[Q]==="?")Q++;return{next:Q,unbounded:U}}function H6($){let J=[{previousAtom:null,lastAtom:null,atomCount:0,simpleClass:null,containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1}],X=0,Q=()=>J[J.length-1],Y=(G)=>{let W=Q();if(W.lastAtom?.hasUnboundedQuantifier&&G.hasUnboundedQuantifier&&W.lastAtom.repeatClass!==null&&G.repeatClass!==null&&A4(W.lastAtom.repeatClass,G.repeatClass))W.error="adjacent unbounded repetition with overlapping input is not supported";if(W.previousAtom=W.lastAtom,W.lastAtom=G,W.atomCount===0)W.simpleClass=G.repeatClass;else W.simpleClass=null;if(W.atomCount++,G.kind==="group")W.containsQuantifier||=G.containsQuantifier,W.containsAlternation||=G.containsAlternation;W.hasUnboundedQuantifier||=G.hasUnboundedQuantifier};for(let G=0;G<$.length;){if(Q().error!==void 0)return{groupCount:X,error:Q().error};let W=$[G];if(W==="\\"){let M=$[G+1];if(M!==void 0&&/[1-9]/.test(M)||M==="k"&&$[G+2]==="<")return{groupCount:X,error:"backreferences are not supported by the safe extractor"};let O=M==="b"||M==="B";if(Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:M6(M)}),G+=M===void 0?1:2,O)Q().previousAtom=null,Q().lastAtom=null;continue}if(W==="["){Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:{kind:"unknown"}}),G=U6($,G);continue}if(W==="("){let M=O6($,G);if(M.capturing)X++;J.push({previousAtom:null,lastAtom:null,atomCount:0,simpleClass:null,containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1}),G=M.next;continue}if(W===")"){if(J.length>1){let M=J.pop();if(M.error!==void 0)return{groupCount:X,error:M.error};Y({kind:"group",containsQuantifier:M.containsQuantifier,containsAlternation:M.containsAlternation,hasUnboundedQuantifier:M.hasUnboundedQuantifier,repeatClass:M.atomCount===1&&!M.containsAlternation?M.simpleClass:null})}G++;continue}if(W==="|"){Q().containsAlternation=!0,Q().previousAtom=null,Q().lastAtom=null,G++;continue}let U=V6($,G);if(U!==null){if(U.error)return{groupCount:X,error:U.error};let M=Q(),O=M.lastAtom;if(U.unbounded&&O?.kind==="group"&&(O.containsQuantifier||O.containsAlternation))return{groupCount:X,error:"nested unbounded repetition or unbounded alternation is not supported"};if(U.unbounded&&M.previousAtom?.hasUnboundedQuantifier&&O!==null&&M.previousAtom.repeatClass!==null&&O.repeatClass!==null&&A4(M.previousAtom.repeatClass,O.repeatClass))return{groupCount:X,error:"adjacent unbounded repetition with overlapping input is not supported"};if(M.containsQuantifier=!0,O!==null)M.lastAtom={...O,containsQuantifier:!0,hasUnboundedQuantifier:O.hasUnboundedQuantifier||U.unbounded};M.hasUnboundedQuantifier||=U.unbounded,G=U.next;continue}if(W!=="^"&&W!=="$")Y({kind:"token",containsQuantifier:!1,containsAlternation:!1,hasUnboundedQuantifier:!1,repeatClass:W==="."?{kind:"any"}:{kind:"literal",value:W}});else Q().previousAtom=null,Q().lastAtom=null;G++}return{groupCount:X,error:Q().error}}function E7($){if($.length>2048)throw Error("Credential extract pattern exceeds the 2048-character limit");let J;try{J=new RegExp($)}catch{throw Error("Credential extract pattern is not a valid regular expression")}let X=H6($);if(X.error!==void 0)throw Error(`Credential extract pattern rejected: ${X.error}`);return{regex:J,groupCount:X.groupCount}}function q6($,J=""){E7($);try{return new RegExp($,J)}catch{throw Error("Credential extract pattern is not supported by this runtime")}}function G9($,J,X,Q={}){if($.length>1048576)throw Error("Credential extraction input exceeds the 1048576-character limit");let Y=q6(J,"gd"),G=new Map,W=new Map,U=[],M=0;for(let H of $.matchAll(Y)){if(M++,M>4096)throw Error("Credential extraction exceeds the 4096-match limit");let q=H[1];if(q===void 0)throw Error(`Credential extraction matched at offset ${H.index} without a group-1 capture; group 1 must capture the credential value on every match.`);if(q.length===0)continue;let F=G.get(q);if(F===void 0)G.set(q,F=G.size);let[K,A]=H.indices[1],L=X(q,F);if(!W.has(q))W.set(q,L);U.push({start:K,end:A,sentinel:L})}if(G.size===0)return null;if(Q.maskDuplicates){let H=[...G.keys()].sort((q,F)=>F.length-q.length);for(let q of H){let F=W.get(q);if(F===q)continue;for(let K=$.indexOf(q);K!==-1;K=$.indexOf(q,K+1)){let A=K+q.length;if(U.some((L)=>K<L.end&&L.start<A))continue;U.push({start:K,end:A,sentinel:F})}}U.sort((q,F)=>q.start-F.start)}let O="",V=0;for(let H of U)O+=$.slice(V,H.start)+H.sentinel,V=H.end;return{fakeContent:O+$.slice(V),captures:[...G.keys()]}}var R4="(eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+)";function F7($){try{return JSON.parse(Buffer.from($,"base64url").toString("utf8"))}catch{return}}function W9($){let J=$.split(".");if(J.length!==3)return!1;let X=F7(J[0]);if(typeof X!=="object"||X===null||!("alg"in X))return!1;return F7(J[1])!==void 0}var K6=9999999999,D4="c3J0LWZha2U";function N7($){return Buffer.from($,"utf8").toString("base64url")}function U9($){let J=N7(JSON.stringify({alg:"HS256",typ:"JWT"})),X=N7(JSON.stringify({sub:bX+$,exp:K6}));return`${J}.${X}.${D4}`}function M9($,J,X){let[Q,Y]=$.split("."),G=F7(Y??"");if(typeof G!=="object"||G===null||Array.isArray(G))return null;let W=G,U=[];for(let O of J){let V=W[O];if(typeof V==="string")U.push([O,V])}if(U.length===0)return null;let M=new Map;for(let[O,V]of U){let H=X(O,V);W[O]=H,M.set(O,H)}return{fakeToken:`${Q}.${N7(JSON.stringify(W))}.${D4}`,claimSentinels:M}}var F6="file:";class L7{dir;byKey=new Map;write($,J){if(this.dir===void 0)this.dir=cJ.mkdtempSync(Z4(E6(),"srt-credmask-"));let X=this.byKey.get($);if(X===void 0)X=Z4(this.dir,`${this.byKey.size}.fake`),this.byKey.set($,X);return cJ.rmSync(X,{force:!0}),cJ.writeFileSync(X,J,{mode:384}),X}dispose(){if(this.dir!==void 0)try{cJ.rmSync(this.dir,{recursive:!0,force:!0})}catch($){Z(`MaskedFileStore cleanup failed: ${$}`,{level:"error"})}this.dir=void 0,this.byKey.clear()}get dirPath(){return this.dir}}function B4($,J,X,Q){let Y=[],G=[];for(let W of $){if(W.mode!=="mask")continue;let U=JJ(W.path),M;try{if(cJ.statSync(U).isDirectory()){Z(`[credential-mask] Skipping masked file entry that resolves to a directory: ${W.path} \u2014 use mode "deny" for directories.`,{level:"warn"});continue}let K=cJ.readFileSync(U);if(M=K.toString("utf8"),Buffer.byteLength(M,"utf8")!==K.length){Z(`[credential-mask] Skipping masked file with non-UTF-8 content (binary credential files are not supported in mask mode): ${W.path}`,{level:"warn"});continue}}catch(F){Z(`[credential-mask] Skipping masked file (unreadable on host): ${W.path} \u2014 ${F.message}`);continue}let O=W.injectHosts??J,V=F6+U,H;if(W.extract===void 0&&W.decode===void 0)H=X.register(V,M,O);else{let F=W.extract??R4,K=0,A=G9(M,F,(L,R)=>{if(W.decode==="jwt"&&!W9(L))return L;let I=`${V}#${R}`;if(W.decode==="jwt"&&W.maskClaims?.length){let T=M9(L,W.maskClaims,(w,P)=>X.register(`${V}#jwt${R}.${w}`,P,O));if(T===null)return Z(`[credential-mask] ${W.path}: verified JWT candidate has none of maskClaims ${JSON.stringify(W.maskClaims)} as `+"string claims \u2014 left unmasked."),L;let C=W.maskClaims.filter((w)=>!T.claimSentinels.has(w));if(C.length>0)Z(`[credential-mask] ${W.path}: maskClaims ${JSON.stringify(C)} absent or non-string in a `+"verified JWT \u2014 skipped.");return K++,X.registerWithSentinel(I,T.fakeToken,L,O)}return K++,W.decode==="jwt"?X.registerWithSentinel(I,U9(z6()),L,O):X.register(I,L,O)},{maskDuplicates:W.maskDuplicates??!1});if(A===null||K===0){let L=W.decode==="jwt"?W.maskClaims?.length?`decode "jwt" with pattern "${F}" that matched no verified JWT with maskable claims (maskClaims: ${JSON.stringify(W.maskClaims)})`:`decode "jwt" with pattern "${F}" that matched no verified JWT`:`extract pattern "${F}" that matched nothing`,R=W.onExtractNoMatch??"warn";if(R==="error")throw Error(`credentials.files entry "${W.path}": ${L} (onExtractNoMatch: "error"). Fix the config, change to "warn"/"deny", or remove the entry.`);if(R==="deny"){Z(`[credential-mask] ${W.path} has ${L} \u2014 degrading to `+'mode "deny".',{level:"warn"}),G.push(U);continue}let I=`[sandbox-runtime] WARNING: credentials.files entry "${W.path}" has ${L} in the file. The file is left UNPROTECTED (readable as-is inside the sandbox). Fix the config, set onExtractNoMatch to "deny" or "error", or remove the entry.`;console.warn(I),Z(I,{level:"warn"});continue}H=A.fakeContent}let q=Q.write(V,H);Y.push({realPath:U,fakePath:q})}return{binds:Y,degradeToDenyPaths:G}}import{randomUUID as N6}from"crypto";var O9="env:";function j4($,J,X,Q=process.env){let Y={},G=[];for(let W of $){if(W.mode!=="mask")continue;let U=Q[W.name];if(U===void 0)continue;let M=W.injectHosts??J;if(W.decode==="jwt"){if(!W9(U)){let V=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has decode "jwt" but its value did not verify as a JWT. The variable is left UNPROTECTED (real value visible as-is inside the sandbox). Fix the config or remove the entry.`;console.warn(V),Z(V,{level:"warn"});continue}if(W.maskClaims?.length){let V=M9(U,W.maskClaims,(q,F)=>X.register(`${O9}${W.name}#${q}`,F,M));if(V===null){let q=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has maskClaims ${JSON.stringify(W.maskClaims)} but none is present as a string claim in its JWT value. The variable is left UNPROTECTED (real value visible as-is inside the sandbox). Fix the config or remove the entry.`;console.warn(q),Z(q,{level:"warn"});continue}let H=W.maskClaims.filter((q)=>!V.claimSentinels.has(q));if(H.length>0)Z(`[credential-mask] env var "${W.name}": maskClaims ${JSON.stringify(H)} absent or non-string in the `+"JWT \u2014 skipped.");Y[W.name]=X.registerWithSentinel(`${O9}${W.name}`,V.fakeToken,U,M);continue}Y[W.name]=X.registerWithSentinel(`${O9}${W.name}`,U9(N6()),U,M);continue}if(W.extract===void 0){Y[W.name]=X.register(W.name,U,M);continue}let O=G9(U,W.extract,(V,H)=>X.register(`${O9}${W.name}#${H}`,V,M));if(O===null){let V=W.onExtractNoMatch??"warn";if(V==="error")throw Error(`credentials.envVars entry "${W.name}": extract pattern "${W.extract}" matched nothing (onExtractNoMatch: "error"). Fix the regex, change to "warn"/"deny", or remove the entry.`);if(V==="deny"){Z(`[credential-mask] extract pattern /${W.extract}/ matched nothing in the value of ${W.name} \u2014 unsetting the variable.`,{level:"warn"}),G.push(W.name);continue}let H=`[sandbox-runtime] WARNING: credentials.envVars entry "${W.name}" has extract pattern "${W.extract}" that matched nothing in the variable's value. The variable is left UNPROTECTED (visible as-is inside the sandbox). Fix the regex, set onExtractNoMatch to "deny" or "error", or remove the entry.`;console.warn(H),Z(H,{level:"warn"});continue}Y[W.name]=O.fakeContent}return{setEnvVars:Y,degradeToUnsetNames:G}}var T4="AWS_ACCESS_KEY_ID",S4="AWS_SECRET_ACCESS_KEY",I4="AWS_SESSION_TOKEN";class A7{bySentinel=new Map;register($){this.bySentinel.set($.accessKeyIdSentinel,$)}lookup($){return this.bySentinel.get($)}get size(){return this.bySentinel.size}clear(){this.bySentinel.clear()}}function C4($,J,X,Q,Y,G=process.env){let W=[...J??[]],U=new Set(W.flatMap((H)=>[H.accessKeyIdVar,H.secretAccessKeyVar,...H.sessionTokenVar?[H.sessionTokenVar]:[]]));if(![T4,S4,I4].some((H)=>U.has(H)))W.push({accessKeyIdVar:T4,secretAccessKeyVar:S4,sessionTokenVar:I4});let O=(H)=>$.find((q)=>q.name===H&&q.mode==="mask"&&q.extract===void 0&&q.decode===void 0),V=(H)=>O(H)!==void 0?Q[H]:void 0;for(let H of W){let q=V(H.accessKeyIdVar),F=V(H.secretAccessKeyVar)!==void 0,K=G[H.accessKeyIdVar],A=G[H.secretAccessKeyVar];if(q===void 0||!F||K===void 0||A===void 0){if(F&&q===void 0){let T=`[sandbox-runtime] WARNING: "${H.secretAccessKeyVar}" is masked but "${H.accessKeyIdVar}" is not, so no AWS credential pair was registered. SigV4 requests will be signed with the masked placeholder secret and the proxy cannot `+"detect or re-sign them \u2014 they will fail upstream. Mask both "+"variables (whole-value) to enable re-signing.";console.warn(T),Z(T,{level:"warn"})}continue}let L=O(H.accessKeyIdVar),I=(H.sessionTokenVar!==void 0?V(H.sessionTokenVar):void 0)!==void 0&&H.sessionTokenVar!==void 0?G[H.sessionTokenVar]:void 0;Y.register({accessKeyIdSentinel:q,realAccessKeyId:K,realSecretAccessKey:A,...I!==void 0?{realSessionToken:I}:{},injectHosts:L.injectHosts??X}),Z(`[credential-aws] registered SigV4 pair for ${H.accessKeyIdVar}/${H.secretAccessKeyVar}`+(I!==void 0?" (+session token)":""))}}function L6($){return{streaming:$?.streaming??"deny",presigned:$?.presigned??"deny",sigv4a:$?.sigv4a??"deny"}}function w4($,J,X){let Q=L6(J);return(Y,G,W,U)=>{if($.size===0)return;let M=oW(W,G);if(M===null)return;let O=$.lookup(M.accessKeyId);if(O===void 0)return;if(!O.injectHosts.some((K)=>X(U,K)))return;if(M.kind!=="header-sigv4"){if(Q[M.kind]==="passthrough"){Z(`[credential-aws] ${M.kind} request with masked credential passed through un-resigned per credentials.sigv4.${M.kind} (its signature covers the placeholder secret and will fail upstream)`);return}return{action:"deny",reason:`AWS SigV4 ${M.kind} request uses a masked credential but cannot be re-signed by the sandbox proxy; denied by policy. Set credentials.sigv4.${M.kind} to "passthrough" to forward it unmodified (it will fail upstream: the signature covers the masked placeholder).`}}let V=aW(lQ(W.authorization));if(V===null)return{action:"deny",reason:"AWS SigV4 request uses a masked credential but its Authorization header is malformed; the proxy cannot re-sign it."};let H=lQ(W["x-amz-date"]);if(H===void 0)return{action:"deny",reason:"AWS SigV4 request uses a masked credential but carries no x-amz-date header; the proxy cannot re-sign it."};let q=[...V.signedHeaders];for(let K of q){if(K==="host")continue;if(K==="x-amz-security-token"&&O.realSessionToken!==void 0)continue;if(W[K]===void 0)return{action:"deny",reason:`AWS SigV4 request uses a masked credential but signed header "${K}" is missing; the proxy cannot re-sign it.`}}if(O.realSessionToken!==void 0&&!q.includes("x-amz-security-token"))q.push("x-amz-security-token");let F=lQ(W["x-amz-content-sha256"]);return{action:"resign",payloadHash:F===J9?J9:void 0,apply(K,A,L){if(O.realSessionToken!==void 0)K["x-amz-security-token"]=O.realSessionToken;if(K["x-amz-content-sha256"]!==void 0&&F!==J9)K["x-amz-content-sha256"]=L;let{authorization:R}=sW({method:Y,requestTarget:G,headers:K,hostHeader:A,signedHeaders:q,payloadHash:L,amzDate:H,scope:{date:V.date,region:V.region,service:V.service},accessKeyId:O.realAccessKeyId,secretAccessKey:O.realSecretAccessKey});K.authorization=R}}}}import{spawnSync as A6}from"child_process";function R0($){if(typeof globalThis.Bun<"u")return globalThis.Bun.which($);let J=A6("which",[$],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1000});if(J.status===0&&J.stdout)return J.stdout.trim();return null}import*as p0 from"fs";import{randomBytes as _K}from"crypto";function CJ($){return $.map((J)=>{if(J==="")return"''";if(/^[A-Za-z0-9_./:@+,-][A-Za-z0-9_./:=@+,-]*$/.test(J))return J;return"'"+J.replace(/'/g,`'"'"'`)+"'"}).join(" ")}import{randomBytes as d6}from"crypto";import*as t from"fs";import{spawn as o4}from"child_process";import{tmpdir as E9}from"os";import f$,{join as a4}from"path";import{spawn as R6}from"child_process";import{text as P4}from"stream/consumers";var D6={ms:1e4};class V9 extends Error{constructor($){super(`ripgrep timed out after ${$} ms`);this.name="RipgrepTimeoutError"}}async function R7($,J,X,Q={command:"rg"}){let{command:Y,args:G=[],argv0:W}=Q,U=R6(Y,[...G,...$,J],{argv0:W,env:{PATH:process.env.PATH??"/usr/bin:/bin"},signal:X,windowsHide:!0}),M=D6.ms,O=!1,V=setTimeout(()=>{O=!0,U.kill("SIGKILL")},M),H,q,F;try{[H,q,F]=await Promise.all([P4(U.stdout),P4(U.stderr),new Promise((K,A)=>{U.on("close",K),U.on("error",A)})])}finally{clearTimeout(V)}if(O)throw new V9(M);if(F===0)return H.trim().split(`
|
|
62
|
+
`).filter(Boolean);if(F===1)return[];throw Error(`ripgrep failed with exit code ${F}: ${q}`)}import{join as O0,dirname as Z6}from"path";import{fileURLToPath as B6}from"url";import*as H9 from"fs";import{homedir as j6}from"os";var D7=new Map,Z7=null;function T6(){if(Z7)return Z7;let $=[],J=j6();return $.push(O0("/usr","lib","node_modules","@anthropic-ai","sandbox-runtime"),O0("/usr","local","lib","node_modules","@anthropic-ai","sandbox-runtime"),O0("/opt","homebrew","lib","node_modules","@anthropic-ai","sandbox-runtime"),O0(J,".npm","lib","node_modules","@anthropic-ai","sandbox-runtime"),O0(J,".npm-global","lib","node_modules","@anthropic-ai","sandbox-runtime")),Z7=$,$}function _4(){let $=process.arch;switch($){case"x64":case"x86_64":return"x64";case"arm64":case"aarch64":return"arm64";case"ia32":case"x86":return Z("[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 Z(`[SeccompFilter] Unsupported architecture: ${$}. Only x64 and arm64 are supported.`),null}}function S6($){let J=_4();if(!J)return[];let X=Z6(B6(import.meta.url)),Q=O0("vendor","seccomp",J,$);return[O0(X,Q),O0(X,"..","..",Q),O0(X,"..",Q)]}function B7($){let J=$??"";if(D7.has(J))return D7.get(J);let X=I6($);return D7.set(J,X),X}function I6($){if($){if(H9.existsSync($))return Z(`[SeccompFilter] Using apply-seccomp binary from explicit path: ${$}`),$;Z(`[SeccompFilter] Explicit path provided but file not found: ${$}`)}let J=_4();if(!J)return Z(`[SeccompFilter] Cannot find apply-seccomp binary: unsupported architecture ${process.arch}`),null;Z(`[SeccompFilter] Looking for apply-seccomp binary for architecture: ${J}`);for(let X of S6("apply-seccomp"))if(H9.existsSync(X))return Z(`[SeccompFilter] Found apply-seccomp binary: ${X} (${J})`),X;for(let X of T6()){let Q=O0(X,"vendor","seccomp",J,"apply-seccomp");if(H9.existsSync(Q))return Z(`[SeccompFilter] Found apply-seccomp binary in global install: ${Q} (${J})`),Q}return Z(`[SeccompFilter] apply-seccomp binary not found in any expected location (${J})`),null}import{spawnSync as C6}from"child_process";import{createHash as w6}from"crypto";import*as r from"fs";import nJ from"path";class uX extends Error{}var P6={dir:"/run/srt-stubs",uid:0,lockWaitMs:2000,flockPath:"/usr/bin/flock"},pQ=P6,_6,k4;var q9=r.constants.O_CLOEXEC??524288,j7={kind:"masked"},x4={kind:"real"},hX={kind:"unregistered"},x6=new Set(["ENOENT","EACCES"]),v6=new Set(["ENOENT","ENOTDIR","EROFS"]),V0=null,HQ=null,k6=0;function gX($){return $?.code}function S7($){return w6("sha256").update($).digest("hex")}function I7(){if(process.platform!=="linux")return"off";let{dir:$,uid:J,flockPath:X}=pQ;if(process.geteuid?.()!==J)return"off";try{r.accessSync(X,r.constants.X_OK)}catch(Y){return x6.has(gX(Y)??"")?"off":"error"}try{r.mkdirSync($,{mode:448}),r.chmodSync($,448)}catch(Y){let G=gX(Y)??"";if(G!=="EEXIST")return v6.has(G)?"off":"error"}let Q;try{Q=r.lstatSync($)}catch{return"error"}if(!Q.isDirectory()||Q.uid!==J||(Q.mode&511)!==448)return Z(`[Sandbox Linux] ${$} is not a 0700 directory owned by uid ${J}; mask stubs are not shared`,{level:"warn"}),"off";return $}function f4($,J){try{return r.openSync(nJ.join($,J),r.constants.O_RDONLY|r.constants.O_CREAT|r.constants.O_NOFOLLOW|q9,384)}catch{return null}}function y4($,J){try{return C6(pQ.flockPath,[...J,"3"],{stdio:["ignore","ignore","ignore",$],timeout:pQ.lockWaitMs+5000}).status===0}catch{return!1}}function v4($,J,X){let Q=f4($,J);if(Q===null)return null;let Y=(pQ.lockWaitMs/1000).toFixed(3);if(y4(Q,[X,"-w",Y]))return Q;return r.closeSync(Q),null}function b4($){try{r.closeSync($)}catch{}}function h4(){let $=I7();if($==="off")return!1;if($==="error")throw new uX(`srt: cannot read the mask stub registry ${pQ.dir}; refusing to start the sandbox`);if(V0===null)V0=v4($,"lock","-s");if(V0!==null&&HQ===null)HQ=v4($,"claims","-x");if(V0===null||HQ===null)throw new uX(`srt: mask stub registry ${$} is busy (no ${V0===null?"shared":"claims"} lock within ${pQ.lockWaitMs} ms); refusing to start the sandbox rather than risk a mask another call removes`);return!0}function K9(){if(HQ===null)return;b4(HQ),HQ=null}function f6(){if(V0===null)return;b4(V0),V0=null}function u4(){let $=I7();if($==="off")return null;if($==="error"||V0===null||HQ===null)throw new uX("srt: mask stub claimed without holding the registry; refusing to start the sandbox");return $}function mX($){try{return r.lstatSync($,{bigint:!0})}catch(J){return gX(J)==="ENOENT"?"absent":"unknown"}}function g4($){try{let J=JSON.parse(r.readFileSync($,"utf8")),{v:X,type:Q,uid:Y,dev:G,ino:W,ctimeNs:U,path:M}=J,O=(V)=>typeof V==="string"&&/^\d+$/.test(V);if(X!==1||Q!=="f"&&Q!=="d"||typeof Y!=="number"||!O(G)||!O(W)||!O(U)||typeof M!=="string"||!M.startsWith("/"))return null;return{type:Q,uid:Y,dev:BigInt(G),ino:BigInt(W),ctimeNs:BigInt(U),dest:M}}catch{return null}}function m4($,J){return nJ.join($,`${S7(J)}.stub`)}function y6($,J){let X=S7(J.dest),Q=nJ.join($,`${X}.stub.${process.pid}-${++k6}`),Y=JSON.stringify({v:1,type:J.type,uid:J.uid,dev:String(J.dev),ino:String(J.ino),ctimeNs:String(J.ctimeNs),path:J.dest});r.writeFileSync(Q,Y+`
|
|
63
|
+
`,{flag:"wx",mode:384}),r.renameSync(Q,nJ.join($,`${X}.stub`))}function l4($,J){return(J.type==="f"?$.isFile()&&$.size===BigInt(0):$.isDirectory())&&$.uid===BigInt(J.uid)&&$.dev===J.dev&&$.ino===J.ino&&$.ctimeNs===J.ctimeNs}function C7($){let J=nJ.dirname($),X;try{X=r.openSync(J,r.constants.O_RDONLY|r.constants.O_DIRECTORY|r.constants.O_NOFOLLOW|q9)}catch{return null}try{if(r.readlinkSync(`/proc/self/fd/${X}`)===J)return X}catch{}return r.closeSync(X),null}function p4($,J,X){return{type:$,uid:Number(J.uid),dev:J.dev,ino:J.ino,ctimeNs:J.ctimeNs,dest:X}}function b6($){let J=C7($);if(J===null)return null;try{let X;try{X=r.openSync(`/proc/self/fd/${J}/${nJ.basename($)}`,r.constants.O_RDONLY|r.constants.O_CREAT|r.constants.O_EXCL|r.constants.O_NOFOLLOW|q9,292)}catch(Q){return gX(Q)==="EEXIST"?"exists":null}try{return k4?.($),p4("f",r.fstatSync(X,{bigint:!0}),$)}finally{r.closeSync(X)}}finally{r.closeSync(J)}}function h6($,J){let X=C7($);if(X===null)return null;try{let Q=`/proc/self/fd/${X}/${nJ.basename($)}`;try{r.mkdirSync(Q,{mode:493})}catch(G){return gX(G)==="EEXIST"?"exists":null}k4?.($);let Y;try{Y=r.openSync(Q,r.constants.O_RDONLY|r.constants.O_DIRECTORY|r.constants.O_NOFOLLOW|q9)}catch{return null}try{let G=r.fstatSync(Y,{bigint:!0});if(!G.isDirectory()||G.uid!==BigInt(process.geteuid?.()??-1)||G.nlink>BigInt(2)||r.readdirSync(`/proc/self/fd/${Y}`).length!==0)return null;if(J)r.fchownSync(Y,J.uid,J.gid);return p4("d",r.fstatSync(Y,{bigint:!0}),$)}catch{return null}finally{r.closeSync(Y)}}finally{r.closeSync(X)}}function u6($){let J=C7($.dest);if(J===null)return;try{let X=`/proc/self/fd/${J}/${nJ.basename($.dest)}`,Q=mX(X);if(typeof Q==="object"&&l4(Q,$)){if($.type==="d")r.rmdirSync(X);else r.unlinkSync(X);Z(`[Sandbox Linux] Removed shared mask stub: ${$.dest}`)}}catch{}finally{r.closeSync(J)}}function g6($){try{r.unlinkSync($)}catch{}}function T7($,J,X,Q){let Y=g4(m4($,J));return Y!==null&&Y.type===Q&&Y.dest===J&&l4(X,Y)}function d4($,J,X){let Q=u4();if(Q===null)return hX;if(_6?.($)==="unregistered")return hX;let Y=mX($);if(Y==="unknown")return hX;if(Y!=="absent")return T7(Q,$,Y,J)?j7:x4;let G=X();if(G==="exists"){let W=mX($);return typeof W==="object"&&T7(Q,$,W,J)?j7:x4}if(G===null)return hX;try{y6(Q,G)}catch(W){Z(`[Sandbox Linux] mask stub marker not written for ${$}: ${W}`,{level:"warn"})}return j7}function m6($){return d4($,"f",()=>b6($))}function l6($,J){return d4($,"d",()=>h6($,J))}function c4($,J){let X=u4();if(X===null)return null;let Q=(G)=>J.some((W)=>G.startsWith(W+"/")),Y=[];for(let G=nJ.dirname($);Q(G);G=nJ.dirname(G))Y.unshift(G);for(let G of Y){let W=mX(G);if(typeof W==="object"&&T7(X,G,W,"d"))return G}return null}function n4($,J){try{return $()}catch(X){if(X instanceof uX)throw X;return Z(`[Sandbox Linux] mask stub not recorded for ${J}: ${X}`,{level:"warn"}),hX}}function w7($){return n4(()=>m6($),$)}function i4($,J){return n4(()=>l6($,J),$)}function p6($){let J;try{J=r.readdirSync($)}catch{return}let X=[],Q=[];for(let G of J){let W=/^([0-9a-f]{64})\.stub(\..*)?$/.exec(G);if(W===null)continue;let U=nJ.join($,G);if(Q.push(U),W[2]===void 0){let M=g4(U);if(M!==null&&S7(M.dest)===W[1])X.push(M)}}let Y=(G)=>G.dest.split("/").length;X.sort((G,W)=>G.type===W.type?Y(W)-Y(G):G.type==="f"?-1:1);for(let G of X)u6(G);for(let G of Q)g6(G)}function P7($,J){let X=I7(),Q=V0!==null;if(K9(),f6(),X==="off"){for(let G of $)J(G);return[]}if(X==="error")return[...$];if(!Q&&$.length===0)return[];let Y=f4(X,"lock");if(Y===null)return[...$];try{if(!y4(Y,["-x","-n"]))return[...$];for(let G of $)if(mX(m4(X,G))==="absent")J(G);return p6(X),[]}catch(G){return Z(`[Sandbox Linux] mask stub sweep failed: ${G}`,{level:"warn"}),[...$]}finally{r.closeSync(Y)}}var v7=3;function c6($){let J=$.uid===void 0?$.bwrapCommand:[$.setprivPath??"/usr/bin/setpriv",`--reuid=${$.uid}`,`--regid=${$.gid??$.uid}`,"--clear-groups","--inh-caps=-all","--ambient-caps=-all","--bounding-set=-all",...$.bwrapCommand],X=$.unsetEnvVars??[],Q=Object.entries($.setEnvVars??{});if(X.length===0&&Q.length===0)return J;return["/usr/bin/env",...X.flatMap((Y)=>["-u",Y]),...Q.map(([Y,G])=>`${Y}=${G}`),...J]}function _7($,J){let X=$.split(f$.sep),Q="";for(let Y of X){if(!Y)continue;let G=Q+f$.sep+Y;try{if(t.lstatSync(G).isSymbolicLink()){if(J.some((M)=>G.startsWith(M+"/")||G===M))return G}}catch{break}Q=G}return null}var n6=40;function s4($){let J=$;for(let X=0;X<n6;X++){try{return t.realpathSync(J)}catch{}let Q=J,Y=[],G=null;while(G===null){let M=f$.dirname(Q);if(M===Q)return null;Y.unshift(f$.basename(Q)),Q=M;try{G=t.realpathSync(Q)}catch{}}let W=f$.join(G,Y[0]),U=null;try{U=t.readlinkSync(W)}catch{}if(U===null)return f$.join(G,...Y);J=f$.join(f$.resolve(f$.dirname(W),U),...Y.slice(1))}return null}function i6($){let J=$.split(f$.sep),X="";for(let Q of J){if(!Q)continue;let Y=X+f$.sep+Q;try{let G=t.statSync(Y);if(G.isFile()||G.isSymbolicLink())return!0}catch{break}X=Y}return!1}function o6($){let J=$.split(f$.sep),X="";for(let Q of J){if(!Q)continue;let Y=X+f$.sep+Q;if(!t.existsSync(Y))return Y;X=Y}return $}async function a6($={command:"rg"},J=v7,X=!1,Q){let Y=process.cwd(),G=new AbortController,W=Q??G.signal,U=HY(),M=[...VX.map((K)=>f$.resolve(Y,K)),...U.map((K)=>f$.resolve(Y,K))],O=f$.resolve(Y,".git"),V=!1;try{V=t.statSync(O).isDirectory()}catch{}if(V){if(M.push(f$.resolve(Y,".git/hooks")),!X)M.push(f$.resolve(Y,".git/config"))}let H=[];for(let K of VX)H.push("--iglob",K);for(let K of U)H.push("--iglob",`**/${K}/**`);if(H.push("--iglob","**/.git/hooks/**"),!X)H.push("--iglob","**/.git/config");let q=["--files","--hidden","--no-ignore","--max-depth",String(J),...H,"-g","!**/node_modules/**"],F;try{F=await R7(q,Y,W,$)}catch(K){if(K instanceof V9)throw Error(`mandatory deny scan failed: ${K}`);Z(`[Sandbox] ripgrep scan failed, retrying once: ${K}`);try{F=await R7(q,Y,W,$)}catch(A){throw Error(`mandatory deny scan failed: ${A}`)}}for(let K of F){let A=f$.resolve(Y,K),L=!1;for(let R of[...U,".git"]){let I=l9(R),T=A.split(f$.sep),C=T.findIndex((w)=>l9(w)===I);if(C!==-1){if(R===".git"){let w=T.slice(0,C+1).join(f$.sep);if(K.includes(".git/hooks"))M.push(f$.join(w,"hooks"));else if(K.includes(".git/config"))M.push(f$.join(w,"config"))}else M.push(T.slice(0,C+1).join(f$.sep));L=!0;break}}if(!L)M.push(A)}return[...new Set(M)]}var lX;function s6(){if(process.getuid?.()!==0||process.env.ARA_SRT_FILE_MASK!=="empty")return"/dev/null";if(lX)try{let X=t.lstatSync(lX);if(X.isFile()&&X.size===0&&X.uid===0&&(X.mode&146)===0)return lX}catch{}let $=t.mkdtempSync(f$.join(E9(),"claude-empty-file-"));F9.add($),t.chmodSync($,493);let J=f$.join($,"empty");return t.writeFileSync(J,"",{flag:"wx",mode:292}),t.chmodSync(J,292),lX=J,J}var pX=new Set,F9=new Set;function r4($,J){return $===J?s6():"/dev/null"}function r6($){try{let J=t.lstatSync($);return J.isFile()&&J.size===0}catch{return!1}}var D0=0,t4=!1;function z9(){if(t4)return;process.on("exit",()=>{N9({force:!0})}),t4=!0}function N9($){if(!$?.force){if(D0>0)D0--;if(D0>0){Z(`[Sandbox Linux] Deferring mount point cleanup \u2014 ${D0} sandbox(es) still active`);return}}else D0=0;let J=[],X=[];for(let G of pX)try{let W=t.statSync(G);if(W.isFile()&&W.size===0)J.push(G);else if(W.isDirectory())X.push(G)}catch{}let Q=(G)=>G.split("/").length;X.sort((G,W)=>Q(W)-Q(G));let Y=P7([...J,...X],(G)=>{try{let W=t.statSync(G);if(W.isFile()&&W.size===0)t.unlinkSync(G),Z(`[Sandbox Linux] Cleaned up bwrap mount point (file): ${G}`);else if(W.isDirectory()){if(t.readdirSync(G).length!==0)return;t.rmdirSync(G),Z(`[Sandbox Linux] Cleaned up bwrap mount point (dir): ${G}`)}}catch{}});pX.clear();for(let G of Y)pX.add(G);for(let G of F9)try{t.rmSync(G,{recursive:!0,force:!0})}catch{}F9.clear(),lX=void 0}function e4($){try{return t.accessSync($,t.constants.X_OK),!0}catch{return!1}}function J5($){let{seccompConfig:J,bwrapPath:X,socatPath:Q}=$??{},Y=[],G=[];if(X){if(!e4(X))Y.push(`bubblewrap (bwrap) not executable at ${X}`)}else if(R0("bwrap")===null)Y.push("bubblewrap (bwrap) not installed");if(Q){if(!e4(Q))Y.push(`socat not executable at ${Q}`)}else if(R0("socat")===null)Y.push("socat not installed");if(!J?.argv0&&B7(J?.applyPath)===null)G.push("seccomp not available - unix socket access not restricted");return{warnings:G,errors:Y}}async function Q5($,J,X,Q,Y){let G=X??"socat",W=d6(8).toString("hex"),U=a4(E9(),`claude-http-${W}.sock`),M=a4(E9(),`claude-socks-${W}.sock`),O=[`UNIX-LISTEN:${U},fork,reuseaddr`,`TCP:localhost:${$},keepalive,keepidle=10,keepintvl=5,keepcnt=3`];Z(`Starting HTTP bridge: ${G} ${O.join(" ")}`);let V=o4(G,O,{stdio:"ignore"});if(V.on("error",(K)=>{Z(`HTTP bridge process error: ${K}`,{level:"error"})}),V.on("exit",(K,A)=>{Z(`HTTP bridge process exited with code ${K}, signal ${A}`,{level:K===0?"info":"error"})}),!V.pid)throw Error("Failed to start HTTP bridge process");let H,q;if(J===$)H=V,q=U;else{q=M;let K=[`UNIX-LISTEN:${M},fork,reuseaddr`,`TCP:localhost:${J},keepalive,keepidle=10,keepintvl=5,keepcnt=3`];if(Z(`Starting SOCKS bridge: ${G} ${K.join(" ")}`),H=o4(G,K,{stdio:"ignore"}),H.on("error",(A)=>{Z(`SOCKS bridge process error: ${A}`,{level:"error"})}),H.on("exit",(A,L)=>{Z(`SOCKS bridge process exited with code ${A}, signal ${L}`,{level:A===0?"info":"error"})}),!H.pid){if(V.pid)try{process.kill(V.pid,"SIGTERM")}catch{}throw Error("Failed to start SOCKS bridge process")}}let F=200;for(let K=0;K<F;K++){if(!V.pid||V.killed||!H.pid||H.killed)throw Error("Linux bridge process died unexpectedly");try{if(t.existsSync(U)&&t.existsSync(q)){if(Q!==void 0){let A=Y??Q;for(let L of new Set([U,q]))t.chownSync(L,Q,A),t.chmodSync(L,384)}Z(`Linux bridges ready after ${K+1} attempts`);break}}catch(A){Z(`Error checking sockets (attempt ${K+1}): ${A}`,{level:"error"})}if(K===F-1){if(V.pid)try{process.kill(V.pid,"SIGTERM")}catch{}if(H.pid)try{process.kill(H.pid,"SIGTERM")}catch{}throw Error(`Failed to create bridge sockets after ${F} attempts`)}await new Promise((A)=>setTimeout(A,5))}return{httpSocketPath:U,socksSocketPath:q,httpBridgeProcess:V,socksBridgeProcess:H,httpProxyPort:$,socksProxyPort:J}}function t6($,J){if(J){if(!$)throw Error("seccompConfig.argv0 requires seccompConfig.applyPath");return`ARGV0=${CJ([J])} ${CJ([$])} `}let X=B7($);return X?`${CJ([X])} `:void 0}function e6($,J,X,Q,Y,G){let W=Y||"bash",U=CJ([G??"socat"]),M=["srt_payload_pid=",`${U} TCP4-LISTEN:3128,bind=127.0.0.1,fork,reuseaddr ${CJ([`UNIX-CONNECT:${$}`])} >/dev/null 2>&1 &`,"srt_http_proxy_pid=$!",`${U} TCP4-LISTEN:1080,bind=127.0.0.1,fork,reuseaddr ${CJ([`UNIX-CONNECT:${J}`])} >/dev/null 2>&1 &`,"srt_socks_proxy_pid=$!","srt_cleanup_command() {"," srt_status=$?"," trap - EXIT INT TERM",' if [ -n "$srt_payload_pid" ]; then',' kill -KILL "$srt_payload_pid" 2>/dev/null',' wait "$srt_payload_pid" 2>/dev/null'," fi",' kill -KILL "$srt_http_proxy_pid" "$srt_socks_proxy_pid" 2>/dev/null',' wait "$srt_http_proxy_pid" "$srt_socks_proxy_pid" 2>/dev/null',' exit "$srt_status"',"}","trap srt_cleanup_command EXIT","trap 'exit 143' TERM","trap 'exit 130' INT",...[3128,1080].map((H)=>`${U} -u OPEN:/dev/null TCP4:127.0.0.1:${H},connect-timeout=0.1,retry=480,interval=0.005 >/dev/null 2>&1 || { printf '%s\\n' 'Sandbox proxy listener readiness failed' >&2; exit 1; }`),`kill -0 "$srt_http_proxy_pid" "$srt_socks_proxy_pid" 2>/dev/null || { printf '%s\\n' 'Sandbox proxy listener exited before command' >&2; exit 1; }`],O=(Q??"")+CJ([W,"-c",X]),V=[...M,`${O} <&0 &`,"srt_payload_pid=$!",'wait "$srt_payload_pid"',"srt_payload_status=$?","srt_payload_pid=",'exit "$srt_payload_status"'].join(`
|
|
64
|
+
`);return`${W} -c ${CJ([V])}`}function x7($){try{if(t.lstatSync($).isSymbolicLink())return t.realpathSync($)}catch{}return $}function $5($,J,X,Q){let Y=J==="/"?"/":J+"/";$.push("--tmpfs",J);for(let G of X)if(G.startsWith(Y)||G===J)$.push("--bind",G,G),Z(`[Sandbox Linux] Re-bound write path wiped by denyRead tmpfs: ${G}`);for(let G of Q)if(G.startsWith(Y)||G===J){if(!t.existsSync(G)){Z(`[Sandbox Linux] Skipping non-existent read allow path: ${G}`);continue}if(X.some((W)=>(W.startsWith(Y)||W===J)&&(G===W||G.startsWith(W+"/"))))continue;$.push("--ro-bind",G,G),Z(`[Sandbox Linux] Re-allowed read access within denied region: ${G}`)}}async function $K($,J,X,Q,Y={command:"rg"},G=v7,W=!1,U,M){let O=[],V=[],H=[],q=new Set,F=new Map,K=new Map;if(J){O.push("--ro-bind","/","/");for(let U$ of J.allowOnly||[]){let v=JJ(U$).replace(/\/+$/,"")||"/";if(Z(`[Sandbox Linux] Processing write path: ${U$} -> ${v}`),v.startsWith("/dev/")){Z(`[Sandbox Linux] Skipping /dev path: ${v}`);continue}if(!t.existsSync(v)){Z(`[Sandbox Linux] Skipping non-existent write path: ${v}`);continue}try{let a=t.realpathSync(v),P$=v.replace(/\/+$/,"");if(a!==P$&&VY(v,a)){Z(`[Sandbox Linux] Skipping symlink write path pointing outside expected location: ${U$} -> ${a}`);continue}}catch{Z(`[Sandbox Linux] Skipping write path that could not be resolved: ${v}`);continue}O.push("--bind",v,v),V.push(v)}let k,p=()=>{if(k!==void 0)return k;let U$=[];for(let a of V){U$.push(a);try{let P$=t.realpathSync(a);if(P$!==a)U$.push(P$)}catch{}}let v=[];if($){let a=[],P$=new Set(["proc","dev","sys"]);for(let E$ of $.denyOnly||[])if(JJ(E$)==="/")try{for(let s of t.readdirSync("/"))if(!P$.has(s))a.push("/"+s)}catch{}else a.push(E$);if(t.existsSync("/etc/ssh/ssh_config.d"))a.push("/etc/ssh/ssh_config.d");for(let E$ of a){let s=JJ(E$),S$=!1;try{S$=t.statSync(s).isDirectory()}catch{continue}if(!S$)continue;v.push(s);try{let J$=t.realpathSync(s);if(J$!==s)v.push(J$)}catch{}}}return k={allowedWritePathsBothForms:U$,prospectiveReadDenyTmpfsDirsBothForms:v},k},$$=(U$)=>V.some((v)=>U$.startsWith(v+"/")||U$===v),N$=[...J.denyWithinAllow||[],...await a6(Y,G,W,U)];h4();let M$=new Set;for(let U$ of N$){let v=JJ(U$);if(v.startsWith("/dev/"))continue;let a=s4(v);if(a===null||a.startsWith("/dev/"))continue;if(_7(a,V))continue;let P$=!1;try{P$=t.statSync(a).isDirectory()}catch{continue}if(!P$)continue;if($$(a)){let E$=F.get(a);if(E$===void 0)E$=new Set,F.set(a,E$);E$.add(v)}}let b$=new Map,XJ=(U$)=>{let v=b$.get(U$);if(v!==void 0)return v;let{allowedWritePathsBothForms:a,prospectiveReadDenyTmpfsDirsBothForms:P$}=p(),E$=a.some((s)=>s.startsWith(U$+"/"))||P$.some((s)=>s===U$||s.startsWith(U$+"/"))||P$.some((s)=>[U$,...F.get(U$)??[]].some((S$)=>S$===s||S$.startsWith(s+"/")));return b$.set(U$,E$),E$},j$=[...F.keys()];for(let U$ of N$){let v=JJ(U$);if(v.startsWith("/dev/"))continue;let a=s4(v);if(a===null){let s=_7(v,V);if(s&&!M$.has(s))M$.add(s),H.push("--ro-bind","/dev/null",s),K.set(s,v);Z(`[Sandbox Linux] Deny path could not be resolved through symlinks, failing closed: ${v}`);continue}if(a!==v)Z(`[Sandbox Linux] Resolved symlinked deny path: ${v} -> ${a}`);if(a.startsWith("/dev/"))continue;if(M$.has(a))continue;M$.add(a);let P$=_7(a,V);if(P$){if(!M$.has(P$))M$.add(P$),H.push("--ro-bind","/dev/null",P$),K.set(P$,v);Z(`[Sandbox Linux] Mounted /dev/null at symlink ${P$} to prevent symlink replacement attack`);continue}if(!t.existsSync(a)){if(i6(a)){Z(`[Sandbox Linux] Skipping deny path with file ancestor (cannot create paths under a file): ${a}`);continue}let s=f$.dirname(a);while(s!=="/"&&!t.existsSync(s))s=f$.dirname(s);let S$=$$(s)||$$(a),J$=j$.filter((_$)=>s===_$||s.startsWith(_$+"/")),g$=J$.length>0&&!J$.some(XJ);if(S$&&!g$){let _$=o6(a),K$=c4(_$,V)??_$;if(K$!==a){if(!q.has(K$)){let c$=i4(K$,M),v$=t.mkdtempSync(f$.join(E9(),"claude-empty-"));if(t.chmodSync(v$,365),F9.add(v$),H.push("--ro-bind",v$,K$),K.set(K$,v),q.add(K$),c$.kind==="unregistered")pX.add(K$);z9(),Z(`[Sandbox Linux] Mounted empty dir at ${K$} to block creation of ${a}`)}}else{let c$=w7(K$),v$=r4(a,v);if(c$.kind==="masked")H.push("--ro-bind",v$,K$),K.set(K$,v),z9(),Z(`[Sandbox Linux] Masked shared stub at ${K$} with ${v$} to block creation of ${a}`);else if(c$.kind==="real")H.push("--ro-bind",K$,K$),K.set(K$,v);else H.push("--ro-bind",v$,K$),K.set(K$,v),pX.add(K$),z9(),Z(`[Sandbox Linux] Mounted ${v$} at ${K$} to block creation of ${a}`)}}else if(g$)Z(`[Sandbox Linux] Skipping non-existent deny path inside a read-only denied directory (already uncreatable): ${a}`);else Z(`[Sandbox Linux] Skipping non-existent deny path not within allowed paths: ${a}`);continue}if($$(a)){if((r6(a)?w7(a):void 0)?.kind==="masked")H.push("--ro-bind",r4(a,v),a),z9();else H.push("--ro-bind",a,a);K.set(a,v)}else Z(`[Sandbox Linux] Skipping deny path not within allowed paths: ${a}`)}}else O.push("--bind","/","/");let A=[],L=($?.allowWithinDeny||[]).map((k)=>JJ(k)),R=new Map,I=[],T=new Set(["proc","dev","sys"]);for(let k of $?.denyOnly||[])if(JJ(k)==="/"){for(let p of t.readdirSync("/"))if(!T.has(p))A.push("/"+p)}else A.push(k);if($&&t.existsSync("/etc/ssh/ssh_config.d"))A.push("/etc/ssh/ssh_config.d");let C=A.map((k)=>JJ(k)).sort((k,p)=>k.split("/").length-p.split("/").length);for(let k of C){if(!t.existsSync(k)){Z(`[Sandbox Linux] Skipping non-existent read deny path: ${k}`);continue}if(t.statSync(k).isDirectory())I.push(k),$5(O,k,V,L);else{if(L.includes(k)){Z(`[Sandbox Linux] Skipping read deny for re-allowed path: ${k}`);continue}let $$=x7(k);O.push("--ro-bind","/dev/null",$$),R.set($$,"/dev/null"),R.set(k,"/dev/null")}}for(let{realPath:k,fakePath:p}of X??[]){let $$=x7(k);O.push("--ro-bind",p,$$),R.set($$,p),R.set(k,p)}let w=(k)=>I.some((p)=>{if(!(k===p||k.startsWith(p+"/")))return!1;return!V.some((M$)=>(M$===p||M$.startsWith(p+"/"))&&(k===M$||k.startsWith(M$+"/")))}),P=[...q].filter((k)=>{let p=K.get(k)??k;return!R.has(k)&&!w(k)&&!w(p)&&!V.some(($$)=>$$===k||$$.startsWith(k+"/"))}),l=[];for(let k=0;k<H.length;k+=3){let p=H[k+2],$$=K.get(p)??p;if(R.has(p))continue;if(w(p)||w($$)){Z(`[Sandbox Linux] Skipping denyWrite bind already hidden by denyRead tmpfs: ${p}`);continue}if(P.some((N$)=>p.startsWith(N$+"/"))){Z(`[Sandbox Linux] Skipping denyWrite bind under an empty-directory mask: ${p}`);continue}if(O.push(H[k],H[k+1],p),l.push(p),$$!==p)l.push($$)}for(let k of I)if(l.some((p)=>k.startsWith(p+"/")))Z(`[Sandbox Linux] Re-applying denyRead tmpfs re-exposed by denyWrite bind: ${k}`),$5(O,k,V,L);for(let[k,p]of R)if(l.some(($$)=>k.startsWith($$+"/"))){if(x7(k)!==k)continue;Z(`[Sandbox Linux] Re-applying file mask re-exposed by denyWrite bind: ${k}`),O.push("--ro-bind",p,k)}if(Q!==void 0)O.push("--ro-bind",Q,Q);return O}async function X5($){let{command:J,commandId:X,needsNetworkRestriction:Q,httpSocketPath:Y,socksSocketPath:G,httpProxyPort:W,socksProxyPort:U,proxyAuthToken:M,caCertPath:O,readConfig:V,writeConfig:H,unsetEnvVars:q,setEnvVars:F,maskedFileBinds:K,maskedFileStoreDir:A,enableWeakerNestedSandbox:L,runAsUid:R,runAsGid:I,runAsHostUid:T,runAsHostGid:C,runAsHostHome:w,runAsHostUser:P,setprivPath:l,allowAllUnixSockets:k,binShell:p,ripgrepConfig:$$={command:"rg"},mandatoryDenySearchDepth:N$=v7,allowGitConfig:M$=!1,gitSafeDirectories:b$,seccompConfig:XJ,bwrapPath:j$,socatPath:U$,observeSocketPath:v,abortSignal:a}=$,P$=V&&V.denyOnly.length>0||K!==void 0&&K.length>0,E$=H!==void 0,s=q!==void 0&&q.length>0||F!==void 0&&Object.keys(F).length>0,S$=(b$?.length??0)>0;if(!Q&&!P$&&!E$&&!s&&!S$)return J;D0++;let J$=["--new-session","--die-with-parent"],g$=[],_$;try{if(!k)if(_$=t6(XJ?.applyPath,XJ?.argv0),!_$)Z("[Sandbox Linux] apply-seccomp binary not available - unix socket blocking disabled. Install @anthropic-ai/sandbox-runtime globally for full protection.",{level:"warn"});else Z("[Sandbox Linux] Applying seccomp filter for Unix socket blocking");else Z("[Sandbox Linux] Skipping seccomp filter - allowAllUnixSockets is enabled");if(v&&_$)if(t.existsSync(v))g$.push("--bind",v,v),J$.push("--setenv","SRT_OBSERVE_SOCK",v),J$.push("--setenv","SRT_ENCODED_CMD",PJ(X??J));else Z("[Sandbox Linux] observe socket missing \u2014 supervisor not running; "+"continuing without violation monitoring");if(s){for(let y$ of q??[])J$.push("--unsetenv",y$);for(let[y$,n$]of Object.entries(F??{}))J$.push("--setenv",y$,n$)}if(b$&&b$.length>0){let y$=qY({safeDirs:b$,unsetEnvVars:q,setEnvVars:F});for(let[n$,t$]of Object.entries(y$))J$.push("--setenv",n$,t$)}if(Q){if(J$.push("--unshare-net"),Y&&G){if(!t.existsSync(Y))throw Error(`Linux HTTP bridge socket does not exist: ${Y}. The bridge process may have died. Try reinitializing the sandbox.`);if(!t.existsSync(G))throw Error(`Linux SOCKS bridge socket does not exist: ${G}. The bridge process may have died. Try reinitializing the sandbox.`);if(g$.push("--bind",Y,Y),G!==Y)g$.push("--bind",G,G);let y$=ZQ(3128,1080,O,M,H===void 0,PJ(X??J));if(J$.push(...y$.flatMap((n$)=>{let t$=n$.indexOf("="),WJ=n$.slice(0,t$),wU=n$.slice(t$+1);return["--setenv",WJ,wU]})),W!==void 0)J$.push("--setenv","CLAUDE_CODE_HOST_HTTP_PROXY_PORT",String(W));if(U!==void 0)J$.push("--setenv","CLAUDE_CODE_HOST_SOCKS_PROXY_PORT",String(U))}}let K$=await $K(V,H,K,A,$$,N$,M$,a,T===void 0?void 0:{uid:T,gid:C??T});if(K9(),J$.push(...K$),J$.push(...g$),J$.push("--dev","/dev"),J$.push("--unshare-pid"),!L){if(J$.push("--unshare-user","--cap-drop","ALL","--proc","/proc"),!_$)J$.push("--ro-bind","/dev/null","/proc/sysrq-trigger")}else J$.push("--unshare-user","--bind","/proc","/proc");if(R!==void 0)J$.push("--uid",String(R)),J$.push("--gid",String(I??R));if(T!==void 0){if(w)J$.push("--setenv","HOME",w);if(P)J$.push("--setenv","USER",P),J$.push("--setenv","LOGNAME",P)}let c$=p||"bash",v$=R0(c$);if(!v$)throw Error(`Shell '${c$}' not found in PATH`);if(J$.push("--",v$,"-c"),Q&&Y&&G){let y$=e6(Y,G,J,_$,v$,U$);J$.push(y$)}else if(_$){let y$=_$+CJ([v$,"-c",J]);J$.push(y$)}else J$.push(J);let YJ=[j$??"bwrap",...J$],GJ=CJ(c6({bwrapCommand:YJ,uid:T,gid:C,setprivPath:l,unsetEnvVars:q,setEnvVars:F})),a$=[];if(Q)a$.push("network");if(P$||E$)a$.push("filesystem");if(s)a$.push("env");if(_$)a$.push("seccomp(unix-block)");return Z(`[Sandbox Linux] Wrapped command with bwrap (${a$.join(", ")} restrictions)`),GJ}catch(K$){if(D0>0)D0--;if(K9(),D0===0)P7([],()=>{});throw K$}}import{spawn as JK}from"child_process";import*as Z0 from"path";class L9{violations=[];totalCount=0;maxSize=100;listeners=new Set;addViolation($){if(this.violations.push({...$,line:k7($.line).replace(/[<>]/g,"")}),this.totalCount++,this.violations.length>this.maxSize)this.violations=this.violations.slice(-this.maxSize);this.notifyListeners()}getViolations($){if($===void 0)return[...this.violations];return this.violations.slice(-$)}getCount(){return this.violations.length}getTotalCount(){return this.totalCount}getViolationsForCommand($){let J=PJ($);return this.violations.filter((X)=>X.encodedCommand===J)}clear(){this.violations=[],this.notifyListeners()}subscribe($){return this.listeners.add($),$(this.getViolations()),()=>{this.listeners.delete($)}}notifyListeners(){let $=this.getViolations();this.listeners.forEach((J)=>J($))}}function dQ($,J,X){if(!X)return!1;if((X["*"]??[]).some((Y)=>$.includes(Y)))return!0;if(J===void 0)return!1;for(let[Y,G]of Object.entries(X))if(Y!=="*"&&J.includes(Y)&&G.some((W)=>$.includes(W)))return!0;return!1}function k7($){return $.replace(/[\x00-\x1f\x7f-\x9f]+/g," ").trim()}function QK($=!1){let J=process.cwd(),X=[];for(let Q of VX)X.push(Z0.resolve(J,Q)),X.push(`**/${Q}`);for(let Q of HY())X.push(Z0.resolve(J,Q)),X.push(`**/${Q}/**`);if(X.push(Z0.resolve(J,".git/hooks")),X.push("**/.git/hooks/**"),!$)X.push(Z0.resolve(J,".git/config")),X.push("**/.git/config");return[...new Set(X)]}var Y5=`_${Math.random().toString(36).slice(2,11)}_SBX`;function XK($){return`CMD64_${PJ($)}_END_${Y5}`}function cQ($){return NJ($)?`(regex ${iJ(zX($))})`:`(subpath ${iJ($)})`}function h7($){return zX($).slice(0,-1)+"(/.*)?$"}function qQ($){return NJ($)?`(regex ${iJ(h7($))})`:`(subpath ${iJ($)})`}function G5($){return $.replace(/\[[^\]]*\]|[*?]+/g,"x")}function y7($,J){let X=[...new Set(J)];if(X.length===0)return $;let Q=X.map((Y)=>`(require-not ${Y})`).join(" ");return`(require-all ${$} ${Q})`}function f7($){let J=JJ($);return{path:J,glob:NJ(J)}}function W5($,J){return $.test(J.glob?G5(J.path):J.path)}function A9($,J){let X=$.glob?G5($.path):$.path;return X.startsWith(J==="/"?"/":J+"/")&&X!==J}function YK($,J){return{denies:($.denyOnly||[]).map(f7),allows:($.allowWithinDeny||[]).map(f7),writeRoots:(J||[]).map(f7)}}function GK($){let J=[],X=!1,Q=$.allows.filter((Y)=>!Y.glob).map((Y)=>Y.path);for(let Y of $.denies){if(!Y.glob){if(Q.some((U)=>Y.path.startsWith(U+"/")))J.push(qQ(Y.path));continue}let G=new RegExp(h7(Y.path));if(G.test("/"))X=!0;let W=$.allows.filter((U)=>W5(G,U)).map((U)=>cQ(U.path));J.push(y7(qQ(Y.path),W))}return{filters:J,coversRoot:X}}function U5($){let J=$.split(/[*?[\]]/)[0];if(!J||J==="/")return"/";return J.endsWith("/")?J.slice(0,-1):Z0.dirname(J)}function WK($,J){let{denies:X,allows:Q,writeRoots:Y}=$;if(Y.length===0)return[];let G=Y.filter((H)=>H.glob).map((H)=>new RegExp(zX(H.path))),W=Y.filter((H)=>!H.glob).map((H)=>H.path),U=(H)=>W.some((q)=>A9({path:H,glob:!1},q))||G.some((q)=>q.test(H)),M=(H)=>[...Q,...Y].filter((q)=>A9(q,H)).map((q)=>cQ(q.path)),O=new Set,V=(H)=>{for(let q of H)if(U(q))O.add(`(literal ${iJ(q)})`)};for(let H of X)if(H.glob){let q=U5(H.path);if(!(G.length>0||W.some((L)=>q===L||A9({path:q,glob:!1},L)||A9({path:L,glob:!1},q))))continue;let K=new RegExp(h7(H.path)),A=[...Q,...Y].filter((L)=>W5(K,L)).map((L)=>cQ(L.path));if(O.add(y7(qQ(H.path),A)),q!=="/")V([q,...b7(q)])}else{if(!U(H.path))continue;O.add(y7(qQ(H.path),M(H.path))),V(b7(H.path))}return u0("deny",["file-write-unlink"],O,J)}function u0($,J,X,Q){if(X.size===0)return[];return[`(${$} ${J.join(" ")}`,...[...X].map((Y)=>` ${Y}`),` (with message "${Q}"))`]}function b7($){let J=[],X=Z0.dirname($);while(X!=="/"&&X!=="."){J.push(X);let Q=Z0.dirname(X);if(Q===X)break;X=Q}return J}function M5($,J){let X=new Set;for(let Q of $){let Y=JJ(Q);X.add(qQ(Y));let G;if(NJ(Y)){if(G=U5(Y),G==="/")continue;X.add(`(literal ${iJ(G)})`)}else G=Y;for(let W of b7(G))X.add(`(literal ${iJ(W)})`)}return u0("deny",["file-write-unlink","file-write-create"],X,J)}function UK($,J){if(!$)return["(allow file-read*)"];let X=[];X.push("(allow file-read*)");let Q=$.denies.some((M)=>M.path==="/"),Y=new Set($.denies.map((M)=>qQ(M.path)));X.push(...u0("deny",["file-read*"],Y,J));let G=new Set($.allows.map((M)=>cQ(M.path)));X.push(...u0("allow",["file-read*"],G,J));let W=GK($);if(X.push(...u0("deny",["file-read*"],new Set(W.filters),J)),Q||W.coversRoot)X.push('(allow file-read* (literal "/"))');if($.denies.length>0)X.push("(allow file-read-metadata"," (vnode-type DIRECTORY))");X.push(...M5($.denies.map((M)=>M.path),J));let U=new Set($.writeRoots.map((M)=>cQ(M.path)));return X.push(...u0("allow",["file-write-unlink","file-write-create"],U,J)),X}function MK($,J,X=!1){if(!$)return["(allow file-write*)"];let Q=[],Y=new Set;for(let U of $.allowOnly||[])Y.add(cQ(JJ(U)));Q.push(...u0("allow",["file-write*"],Y,J));let G=[...$.denyWithinAllow||[],...QK(X)],W=new Set;for(let U of G)W.add(qQ(JJ(U)));return Q.push(...u0("deny",["file-write*"],W,J)),Q.push(...M5(G,J)),Q}function OK({readConfig:$,writeConfig:J,httpProxyPort:X,socksProxyPort:Q,needsNetworkRestriction:Y,allowUnixSockets:G,allowAllUnixSockets:W,allowLocalBinding:U,allowMachLookup:M,allowPty:O,allowGitConfig:V=!1,enableWeakerNetworkIsolation:H=!1,allowAppleEvents:q=!1,logTag:F}){let K=["(version 1)",`(deny default (with message "${F}"))`,"",`; LogTag: ${F}`,"","; 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.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")',")","",...H?["; trustd.agent - needed for Go TLS certificate verification (weaker network isolation)",'(allow mach-lookup (global-name "com.apple.trustd.agent"))']:[],...q?["; Apple Events - opt-in; needed for open/osascript to talk to other apps (appleeventsd)","(allow appleevent-send)",'(allow mach-lookup (global-name "com.apple.coreservices.appleevents"))',"; Launch Services open requests need the lsopen operation plus, on","; macOS 14/15, coreservicesd and the quarantine resolver - without","; these open fails with -10822 kLSServerCommunicationErr or -54","(allow lsopen)",'(allow mach-lookup (global-name "com.apple.CoreServices.coreservicesd"))','(allow mach-lookup (global-name "com.apple.coreservices.quarantine-resolver"))']:[],...M&&M.length>0?["; User-specified XPC/Mach services",...M.map((L)=>L.endsWith("*")?`(allow mach-lookup (global-name-prefix ${iJ(L.slice(0,-1))}))`:`(allow mach-lookup (global-name ${iJ(L)}))`)]:[],"","; 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(K.push("; Network"),!Y)K.push("(allow network*)");else{if(U)K.push('(allow network-bind (local ip "*:*"))'),K.push('(allow network-inbound (local ip "*:*"))'),K.push('(allow network-outbound (remote ip "localhost:*"))');if(W)K.push("(allow system-socket (socket-domain AF_UNIX))"),K.push('(allow network-bind (local unix-socket (path-regex #"^/")))'),K.push('(allow network-outbound (remote unix-socket (path-regex #"^/")))');else if(G&&G.length>0){K.push("(allow system-socket (socket-domain AF_UNIX))");for(let L of G){let R=JJ(L);K.push(`(allow network-bind (local unix-socket (subpath ${iJ(R)})))`),K.push(`(allow network-outbound (remote unix-socket (subpath ${iJ(R)})))`)}}if(X!==void 0)K.push(`(allow network-bind (local ip "localhost:${X}"))`),K.push(`(allow network-inbound (local ip "localhost:${X}"))`),K.push(`(allow network-outbound (remote ip "localhost:${X}"))`);if(Q!==void 0&&Q!==X)K.push(`(allow network-bind (local ip "localhost:${Q}"))`),K.push(`(allow network-inbound (local ip "localhost:${Q}"))`),K.push(`(allow network-outbound (remote ip "localhost:${Q}"))`)}K.push("");let A=$?YK($,J?.allowOnly):void 0;if(K.push("; File read"),K.push(...UK(A,F)),K.push(""),K.push("; File write"),K.push(...MK(J,F,V)),A){let L=WK(A,F);if(L.length>0)K.push(""),K.push("; File read: keep read-denied paths inside write roots in place"),K.push(...L)}if(O)K.push(""),K.push("; Pseudo-terminal (pty) support"),K.push("(allow pseudo-tty)"),K.push("(allow file-ioctl"),K.push(' (literal "/dev/ptmx")'),K.push(' (regex #"^/dev/ttys")'),K.push(")"),K.push("(allow file-read* file-write*"),K.push(' (literal "/dev/ptmx")'),K.push(' (regex #"^/dev/ttys")'),K.push(")");return K.join(`
|
|
65
|
+
`)}function iJ($){return JSON.stringify($)}function O5($){let{command:J,commandId:X,needsNetworkRestriction:Q,httpProxyPort:Y,socksProxyPort:G,proxyAuthToken:W,caCertPath:U,allowUnixSockets:M,allowAllUnixSockets:O,allowLocalBinding:V,allowMachLookup:H,readConfig:q,writeConfig:F,unsetEnvVars:K,setEnvVars:A,maskedFileBinds:L,allowPty:R,allowGitConfig:I=!1,gitSafeDirectories:T,enableWeakerNetworkIsolation:C=!1,allowAppleEvents:w=!1,binShell:P}=$,l=q;if(L&&L.length>0)Z("[Sandbox macOS] file mask degrades to deny on macOS until the interposer lands"),l={denyOnly:[...q?.denyOnly??[],...L.map((s)=>s.realPath)],allowWithinDeny:q?.allowWithinDeny};let k=l&&l.denyOnly.length>0,p=F!==void 0,$$=K!==void 0&&K.length>0||A!==void 0&&Object.keys(A).length>0,N$=(T?.length??0)>0;if(!Q&&!k&&!p&&!$$&&!N$)return J;let M$=X??J,b$=XK(M$),XJ=OK({readConfig:l,writeConfig:F,httpProxyPort:Y,socksProxyPort:G,needsNetworkRestriction:Q,allowUnixSockets:M,allowAllUnixSockets:O,allowLocalBinding:V,allowMachLookup:H,allowPty:R,allowGitConfig:I,enableWeakerNetworkIsolation:C,allowAppleEvents:w,logTag:b$}),j$=ZQ(Y,G,U,W,F===void 0,PJ(M$));if(V&&Q){let J$=(K??[]).includes("JAVA_TOOL_OPTIONS")?"":process.env.JAVA_TOOL_OPTIONS??"",g$=J$.includes("-Djava.net.preferIPv4Stack=true")?J$:[J$,"-Djava.net.preferIPv4Stack=true"].filter(Boolean).join(" ");j$.push(`JAVA_TOOL_OPTIONS=${g$}`)}if(T&&T.length>0){let s=qY({safeDirs:T,unsetEnvVars:K,setEnvVars:A});for(let[S$,J$]of Object.entries(s))j$.push(`${S$}=${J$}`)}let U$=P||"bash",v=R0(U$);if(!v)throw Error(`Shell '${U$}' not found in PATH`);let a=(K??[]).flatMap((s)=>["-u",s]),P$=Object.entries(A??{}).map(([s,S$])=>`${s}=${S$}`),E$=CJ(["env",...a,...P$,...j$,"/usr/bin/sandbox-exec","-p",XJ,v,"-c",J]);return Z(`[Sandbox macOS] Applied restrictions - network: ${!!(Y||G)}, read: ${l?"allowAllExcept"in l?"allowAllExcept":"denyAllExcept":"none"}, write: ${F?"allowAllExcept"in F?"allowAllExcept":"denyAllExcept":"none"}`),E$}function V5($,J,X=(Q)=>Q){let Q=/CMD64_(.+?)_END/,Y=/Sandbox:\s+(.+)$/,G=JK("log",["stream","--predicate",`(eventMessage ENDSWITH "${Y5}")`,"--style","compact"]);return G.stdout?.on("data",(W)=>{let U=W.toString().split(`
|
|
66
|
+
`),M=U.find((K)=>K.includes("Sandbox:")&&K.includes("deny")),O=U.find((K)=>K.startsWith("CMD64_"));if(!M)return;let V=M.match(Y);if(!V?.[1])return;let H=V[1],q,F;if(O){if(F=O.match(Q)?.[1],F)try{q=X(t0(F))}catch{}}if(H.includes("mDNSResponder")||H.includes("mach-lookup com.apple.diagnosticd")||H.includes("mach-lookup com.apple.analyticsd"))return;if(dQ(H,q,J))return;$({line:H,command:q,encodedCommand:F,timestamp:new Date})}),G.stderr?.on("data",(W)=>{Z(`[Sandbox Monitor] Log stream stderr: ${W.toString()}`)}),G.on("error",(W)=>{Z(`[Sandbox Monitor] Failed to start log stream: ${W.message}`)}),G.on("exit",(W)=>{Z(`[Sandbox Monitor] Log stream exited with code: ${W}`)}),()=>{Z("[Sandbox Monitor] Stopping log monitor"),G.kill("SIGTERM")}}import{randomBytes as VK}from"crypto";import{chmodSync as H5,chownSync as HK,mkdtempSync as qK,rmSync as KK}from"fs";import{createServer as zK}from"net";import{tmpdir as EK}from"os";import{join as q5,posix as FK}from"path";import{createInterface as NK}from"readline";function K5($,J){let{allowWritePaths:X,denyWritePaths:Q,ignoreViolations:Y,resolveCommandText:G=(T)=>T,consumerUid:W,consumerGid:U}=J,M=qK(q5(EK(),"srt-obs-")),O=q5(M,`s${VK(4).toString("hex")}.sock`),V=(T,C)=>T===C||T.startsWith(C.endsWith("/")?C:C+"/"),H=(T)=>{let C=FK.normalize(T);if(Q.some((w)=>V(C,w)))return!0;return!X.some((w)=>V(C,w))},q=(T,C)=>{if(T.observe_init_error){Z(`[Sandbox Linux Monitor] observe filter not installed: ${T.observe_init_error}`);return}if(typeof T.path!=="string")return;if(!T.path.startsWith("/"))return;if(!H(T.path))return;let w;if(C)try{w=G(t0(C))}catch{}if(dQ(T.path,w,Y))return;let P={line:`deny ${T.syscall??"syscall"} ${T.path}`,command:w,encodedCommand:C,timestamp:new Date};$(P)},F,K=new Promise((T)=>{F=T}),A=O,L=zK((T)=>{let C,w=NK({input:T});w.on("line",(P)=>{if(!P)return;let l;try{l=JSON.parse(P)}catch{return}if(l.encodedCommand&&C===void 0)C=l.encodedCommand;q(l,C??l.encodedCommand)}),T.on("error",()=>w.close()),T.on("close",()=>w.close())});L.on("error",(T)=>{Z(`[Sandbox Linux Monitor] listen failed: ${T.message} - violation monitoring disabled`,{level:"warn"}),A=void 0,F()}),L.listen(O,()=>{if(W!==void 0)H5(M,457),HK(O,W,U??W),H5(O,384);F()});let R=new Set;return L.on("connection",(T)=>{R.add(T),T.on("close",()=>R.delete(T))}),{get observeSocketPath(){return A},ready:K,stop:()=>{Z("[Sandbox Linux Monitor] stopping");for(let T of R)T.destroy();L.close();try{KK(M,{recursive:!0,force:!0})}catch{}}}}import*as $J from"fs";import*as F5 from"net";import*as e$ from"path";import{spawn as LK,spawnSync as AK}from"child_process";import{once as RK}from"events";import{fileURLToPath as DK}from"url";class L$ extends Error{code;subcommand;constructor($,J,X){super(J);this.name="WindowsSandboxError",this.code=$,this.subcommand=X}}var R9=[60080,60089],z5=["-NoProfile","-Command"];function D9($){let J=process.env.SystemRoot??"C:\\Windows",X={exe:e$.win32.join(J,"System32","cmd.exe"),args:["/d","/s","/c"]};if($===void 0||$===null)return X;if(typeof $==="object"){if(!e$.win32.isAbsolute($.exe))throw new L$("bin_shell_invalid",`binShell.exe must be an absolute path (got ${JSON.stringify($.exe)})`);if(!Array.isArray($.args))throw new L$("bin_shell_invalid",`binShell.args must be an array (got ${JSON.stringify($.args)})`);return $}let Q=e$.win32.basename($),Y=Q.toLowerCase(),G=e$.win32.isAbsolute($);if(!G&&$!==Q)throw new L$("bin_shell_invalid",`binShell string must be a bare token or an absolute path (got ${JSON.stringify($)})`);switch(Y){case"bash":case"bash.exe":case"sh":case"sh.exe":if(!G)throw new L$("bin_shell_invalid",`binShell bash path must be absolute (got ${JSON.stringify($)}); pass the resolved Git Bash install path`);return{exe:$,args:["-c"]};case"pwsh":case"pwsh.exe":return{exe:G?$:"pwsh.exe",args:z5};case"powershell":case"powershell.exe":return{exe:G?$:e$.win32.join(J,"System32","WindowsPowerShell","v1.0","powershell.exe"),args:z5};case"cmd":case"cmd.exe":return G?{exe:$,args:X.args}:X;default:throw new L$("bin_shell_invalid",`unrecognised binShell ${JSON.stringify($)}: expected 'cmd' | 'powershell' | 'pwsh' or an absolute path to bash.exe/sh.exe/pwsh.exe/powershell.exe`)}}function N5(){let $=e$.dirname(DK(import.meta.url));return e$.resolve($,"..","..")}var L5={x64:"x64",arm64:"arm64"},ZK=e$.join(N5(),"vendor","srt-win",L5[process.arch]??process.arch,"srt-win.exe");function BK(){let $=N5(),J=L5[process.arch],X=[];if(J)X.push(e$.join($,"vendor","srt-win",J,"srt-win.exe"));X.push(e$.join($,"vendor","srt-win-src","target","release","srt-win.exe"));for(let Q of X)if($J.existsSync(Q))return Q;throw new L$("srt_win_not_found",`srt-win.exe not found. Set windows.srtWin.path or build with \`cargo build --release --manifest-path vendor/srt-win-src/Cargo.toml\`. Looked in: ${X.join(", ")}`)}var A5="--srt-win";function wJ($){if($?.path===void 0)throw new L$("srt_win_not_found","no srt-win path configured; set windows.srtWin.path (e.g. to the exported VENDORED_SRT_WIN_EXE constant for the packaged binary)");if(!$J.existsSync($.path))throw new L$("srt_win_not_found",`windows.srtWin.path is set to '${$.path}' but the file does not exist`);return{exe:$.path,prependArgs:[A5]}}function g0($,J={}){let{exe:X,prependArgs:Q}=J.srtWin??wJ(),Y=AK(X,[...Q,...$],{encoding:"utf8",windowsHide:!0,timeout:J.timeoutMs??15000,...J.stdin!==void 0?{input:J.stdin}:{}});if(Y.error){if(Y.error.code==="ETIMEDOUT")throw new L$("srt_win_timeout",`srt-win ${$.join(" ")} timed out after ${J.timeoutMs??15000}ms`+(Y.signal?` (killed by ${Y.signal})`:""),$[0]);throw new L$("spawn_failed",`srt-win ${$[0]}: spawn failed: ${Y.error.message}`,$[0])}return{status:Y.status,signal:Y.signal,stdout:(Y.stdout??"").trim(),stderr:(Y.stderr??"").trim()}}function g7($,J={}){let{exe:X,prependArgs:Q}=J.srtWin??wJ(),Y=J.timeoutMs??15000;return new Promise((G,W)=>{let U=LK(X,[...Q,...$],{windowsHide:!0}),M=!1,O=Y>0?setTimeout(()=>{M=!0,U.kill()},Y):void 0,V="",H="";U.stdout?.setEncoding("utf8").on("data",(q)=>V+=q),U.stderr?.setEncoding("utf8").on("data",(q)=>H+=q),U.stdin?.on("error",()=>{}).end(J.stdin),U.once("error",(q)=>{clearTimeout(O),W(new L$("spawn_failed",`srt-win ${$[0]}: spawn failed: ${q.message}`,$[0]))}),U.once("close",(q,F)=>{if(clearTimeout(O),M){W(new L$("srt_win_timeout",`srt-win ${$.join(" ")} timed out after ${Y}ms`+(F?` (killed by ${F})`:""),$[0]));return}G({status:q,signal:F,stdout:V.trim(),stderr:H.trim()})})})}function R5($,J){if(J.status!==0)throw new L$("srt_win_nonzero",`srt-win ${$.join(" ")} exited ${J.status}: ${J.stderr||J.stdout}`,$[0]);try{return JSON.parse(J.stdout)}catch(X){throw new L$("srt_win_bad_json",`srt-win ${$.join(" ")}: unparseable JSON output ${JSON.stringify(J.stdout)}: ${X.message}`,$[0])}}function m7($,J){return R5($,g0($,J))}async function l7($,J){return R5($,await g7($,J))}function D5($,J){let X=g0($,J),Q;try{Q=JSON.parse(X.stdout)}catch(Y){throw new L$("srt_win_bad_json",`srt-win ${$.join(" ")}: unparseable JSON output ${JSON.stringify(X.stdout)}: ${Y.message}`,$[0])}return{ok:X.status===0,json:Q,stderr:X.stderr}}function Z5($){let J=["wfp","status"];if($)J.push("--sublayer-guid",$);return J}function Z9($){return{state:$.state,filters:$.filters,...$.port_range&&{portRange:$.port_range},...$.user_sid&&{userSid:$.user_sid},...$.hint&&{hint:$.hint}}}function B9($){return{provisioned:$.user.exists,...$.user.sid&&{sid:$.user.sid},groupExists:$.user.group_exists,...$.user.group_sid&&{groupSid:$.user.group_sid},inBuiltinUsers:$.user.in_builtin_users,inSandboxGroup:$.user.in_sandbox_group,hiddenFromLogon:$.user.hidden_from_logon,credPresent:$.cred_present,...typeof $.marker_version==="number"&&{markerVersion:$.marker_version},realUserSid:$.real_user_sid,...$.ca_cert_thumb&&{caCertThumb:$.ca_cert_thumb},...$.ca_cert_pem&&{caCertPem:$.ca_cert_pem}}}function B5($={}){let J=["status"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);let X=m7(J,{srtWin:$.srtWin});return{user:B9(X.user),wfp:Z9(X.wfp)}}async function j5($={}){let J=["status"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);let X=await l7(J,{srtWin:$.srtWin});return{user:B9(X.user),wfp:Z9(X.wfp)}}function T5($={}){return Z9(m7(Z5($.sublayerGuid),{srtWin:$.srtWin}))}async function S5($={}){return Z9(await l7(Z5($.sublayerGuid),{srtWin:$.srtWin}))}async function p7($={}){let J=$.target,X;if(!J){let[Q,Y]=$.proxyPortRange??R9;for(let G=0;G<5;G++){let W=F5.createServer();W.listen(0,"127.0.0.1"),await RK(W,"listening");let U=W.address().port;if(U<Q||U>Y){X=W,J=`127.0.0.1:${U}`;break}W.close()}if(!J)throw new L$("wfp_verify_bind_failed",`verifyWindowsWfpEgress: could not bind a loopback listener outside the WFP permit range [${Q},${Y}] in 5 attempts`)}try{let Q=g0(["wfp","verify","--target",J],{timeoutMs:30000,srtWin:$.srtWin});Z(`[Sandbox Windows] wfp verify exit=${Q.status}: ${Q.stderr||Q.stdout}`);let Y;try{Y=JSON.parse(Q.stdout)}catch{throw new L$("wfp_verify_unparseable","WFP egress fence could not be verified \u2014 `srt-win wfp "+`verify\` exited ${Q.status}`+(Q.signal?` (signal ${Q.signal})`:"")+` with unparseable output ${JSON.stringify(Q.stdout)} (stderr: ${JSON.stringify(Q.stderr)})`)}if(Q.status===3)throw new L$("wfp_fence_inactive","WFP egress fence is not active \u2014 direct outbound from the "+`sandbox user to ${Y.target} succeeded. Re-run \`srt-win install\` (one UAC prompt). (${Q.stderr})`);if(Q.status!==0)throw new L$("wfp_verify_inconclusive","WFP egress fence could not be verified \u2014 probe to "+`${Y.target} was '${Y.egress_probe}' (exit ${Q.status}). The fence may be absent. Re-run \`srt-win install\`. (${Q.stderr})`);return{target:Y.target,stderr:Q.stderr}}finally{X?.close()}}function d7($={}){return B9(m7(["user","status"],{srtWin:$.srtWin}))}async function dX($={}){return B9(await l7(["user","status"],{srtWin:$.srtWin}))}function c7($,J={}){let X=$??d7(J);if(!X.caCertThumb||!X.caCertPem)return null;return{pem:X.caCertPem,thumb:X.caCertThumb}}function jK($,J={}){let X=g0(["user","trust-ca",$],{timeoutMs:60000,srtWin:J.srtWin});C5($,X)}async function I5($,J={}){let X=await g7(["user","trust-ca",$],{timeoutMs:60000,srtWin:J.srtWin});C5($,X)}function C5($,J){if(Z(`[Sandbox Windows] user trust-ca exit=${J.status}: ${J.stderr||J.stdout}`),J.status!==0)throw new L$("trust_ca_failed",`srt-win user trust-ca '${$}' failed (exit ${J.status}): ${J.stderr||J.stdout}`)}function w5(){let $=process.env.ProgramData;if(!$)throw Error("ProgramData is not set");return e$.win32.join($,"sandbox-runtime")}async function n7($={}){let J=$.status??await dX({srtWin:$.srtWin});if(!J.provisioned||!J.credPresent)throw Error(`ensurePersistentWindowsCa: sandbox user is not provisioned (user=${J.provisioned}, cred=${J.credPresent}). Run \`npx sandbox-runtime windows-install\` first.`);let X=$.dir?void 0:w5();if(X&&!$J.existsSync(X))throw Error(`ensurePersistentWindowsCa: state directory ${X} does not exist. Run \`npx sandbox-runtime windows-install\` first.`);let Q=$.dir??e$.win32.join(X,"ca"),Y=e$.join(Q,"ca.json"),G=e$.join(Q,"cert.pem"),W=e$.join(Q,"key.pem"),U=($.regenerateWithinDays??30)*24*60*60*1000,M=(L,R)=>{let I=`${L}.tmp.${process.pid}`;$J.writeFileSync(I,R),$J.renameSync(I,L)},O=async(L,R,I,T)=>{M(G,L),M(W,R);let C=T||J.caCertThumb!==I;if(C){let w=e$.join(Q,`.trust.${process.pid}.${Date.now()}.pem`);$J.writeFileSync(w,L);try{await I5(w,{srtWin:$.srtWin})}finally{$J.rmSync(w,{force:!0})}}return Z(`[Sandbox Windows] persistent CA ${T?"generated":"reused"} (thumb=${I}${C&&!T?", trust reconciled":""})`),{certPem:L,keyPem:R,certPath:G,keyPath:W,thumbprint:I,generated:T,trusted:C}},V=()=>{let L;try{L=JSON.parse($J.readFileSync(Y,"utf8"))}catch(I){Z(`[Sandbox Windows] persistent CA ca.json unreadable (${I.message})`,{level:"warn"});return}if(typeof L.certPem!=="string"||typeof L.keyPem!=="string")return;let R=xX(L.certPem,L.keyPem);if(!R.ok){Z(`[Sandbox Windows] persistent CA invalid (${R.reason})`,{level:"warn"});return}return{certPem:L.certPem,keyPem:L.keyPem,thumbprint:R.thumbprint,notAfter:R.notAfter}};if(!$.force){let L=V();if(L&&L.notAfter.getTime()-Date.now()>U)return await O(L.certPem,L.keyPem,L.thumbprint,!1);if(L)Z(`[Sandbox Windows] persistent CA expiring ${L.notAfter.toISOString()}; regenerating`,{level:"warn"})}$J.mkdirSync(Q,{recursive:!0});try{let L=Date.now()-300000;for(let R of $J.readdirSync(Q)){if(!R.includes(".tmp.")&&!R.startsWith(".trust."))continue;let I=e$.join(Q,R);if($J.statSync(I).mtimeMs<L)$J.rmSync(I,{force:!0})}}catch{}let H=oY({cn:"sandbox-runtime persistent CA"});M(Y,JSON.stringify({certPem:H.certPem,keyPem:H.keyPem}));let q=V(),{certPem:F,keyPem:K,thumbprint:A}=q??{certPem:H.certPem,keyPem:H.keyPem,thumbprint:gQ(H.certPem)};return await O(F,K,A,!0)}function i7($){return $.timeoutMs??120000}function P5($){let J=["install"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);if($.proxyPortRange)J.push("--proxy-port-range",`${$.proxyPortRange[0]}-${$.proxyPortRange[1]}`);if($.sandboxUser)J.push("--sandbox-user",$.sandboxUser);if($.force)J.push("--force");return J}function _5($){if($ instanceof L$&&$.code==="srt_win_timeout")throw new L$("install_timeout","srt-win install timed out \u2014 the UAC prompt may still be open. "+`Re-run when ready to grant elevation. (${$.message})`);throw $}function x5($){if(Z(`[Sandbox Windows] install exit=${$.status}: ${$.stderr||$.stdout}`),$.status===0||$.status===10)return;let J=$.stderr||$.stdout;switch($.status){case 12:throw new L$("install_wfp_failed",`srt-win install: WFP filter install failed: ${J}`);case 14:throw new L$("install_user_failed",`srt-win install: sandbox user provisioning failed: ${J}`);case 13:throw new L$("install_config_conflict",`srt-win install: filters already exist under this sublayer with a different port range or sandbox-user name. Pass {force: true} to replace, or pick a different sublayerGuid. Output: ${J}`);case 17:throw new L$("install_ambient_failed",`srt-win install: ambient write-deny stamping failed (stock world-writable system dirs could not be deny-stamped for the sandbox user): ${J}`);default:throw new L$("install_failed",`srt-win install failed (exit ${$.status}): ${J}`)}}function TK($={}){let J=$.srtWin??wJ(),X;try{X=g0(P5($),{timeoutMs:i7($),srtWin:J})}catch(Y){_5(Y)}x5(X);let Q=B5({sublayerGuid:$.sublayerGuid,srtWin:J});return X.status===10?{...Q,cancelled:!0}:Q}async function SK($={}){let J=$.srtWin??wJ(),X;try{X=await g7(P5($),{timeoutMs:i7($),srtWin:J})}catch(Y){_5(Y)}x5(X);let Q=await j5({sublayerGuid:$.sublayerGuid,srtWin:J});return X.status===10?{...Q,cancelled:!0}:Q}function IK($={}){let J=["uninstall"];if($.sublayerGuid)J.push("--sublayer-guid",$.sublayerGuid);if($.keepUser)J.push("--keep-user");let X=g0(J,{timeoutMs:i7($),srtWin:$.srtWin});if(Z(`[Sandbox Windows] uninstall exit=${X.status}: ${X.stderr||X.stdout}`),X.status===10)return{cancelled:!0};if(X.status!==0)throw new L$("uninstall_failed",`srt-win uninstall failed (exit ${X.status}): ${X.stderr||X.stdout}`);return{}}function j9($,J){let X=new Set;for(let Q of $){let Y=JJ(Q),G=HX(Y);if(qX(Y)&&!G){X.add(Y);continue}let W=G?e0(Y,{caseInsensitive:!0}):[Y];for(let U of W){if(!$J.statSync(U,{throwIfNoEntry:!1})){if(J?.mode==="deny"&&!G)X.add(/[\\/]$/.test(Q)&&!/[\\/]$/.test(U)?U+"\\":U);continue}X.add(U)}}return[...X]}function CK($){for(let J of $.split(/\r?\n/)){let X=J.trim();if(!X.startsWith("{")||!X.includes('"code"'))continue;try{let Q=JSON.parse(X);if(Q.code==="mapped_drive_cwd")return Object.assign(new L$("mapped_drive_cwd",Q.message??"mapped/network-drive working directory","exec"),{drive:Q.drive})}catch{}}return}function o7($){let J=$.holderPid??process.pid,X=JSON.stringify({denyRead:$.denyRead,denyWrite:$.denyWrite}),Q=g0(["acl","stamp","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid],{timeoutMs:60000,stdin:X,srtWin:$.srtWin});if(Z(`[Sandbox Windows] acl stamp exit=${Q.status}: ${Q.stderr||Q.stdout}`),Q.status!==0)throw new L$("acl_stamp_failed",`srt-win acl stamp exited ${Q.status} `+(Q.status===2?"(partial \u2014 some inputs skipped)":"(failed)")+`: ${Q.stderr||Q.stdout}`)}function T9($){let J=$.holderPid??process.pid;try{let X=D5(["acl","restore","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid,"--json"],{timeoutMs:60000,srtWin:$.srtWin});if(!X.ok)Z(`[Sandbox Windows] acl restore exited non-zero (per-path outcomes preserved): ${X.stderr}`,{level:"error"});return Array.isArray(X.json)?X.json:[...X.json.paths??[],...X.json.parents??[]]}catch(X){Z(`[Sandbox Windows] acl restore: ${X.message}`,{level:"error"});return}}function a7($){let J=$.holderPid??process.pid,X=JSON.stringify({read:$.read,write:$.write}),Q=g0(["acl","grant","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid],{timeoutMs:60000,stdin:X,srtWin:$.srtWin});if(Z(`[Sandbox Windows] acl grant exit=${Q.status}: ${Q.stderr||Q.stdout}`),Q.status!==0)throw new L$("acl_grant_failed",`srt-win acl grant exited ${Q.status}: ${Q.stderr||Q.stdout}`)}function S9($){let J=$.holderPid??process.pid;try{let X=D5(["acl","revoke","--holder-pid",`${J}`,"--sandbox-user-sid",$.sandboxUserSid,"--json"],{timeoutMs:60000,srtWin:$.srtWin});if(!X.ok)Z(`[Sandbox Windows] acl revoke exited non-zero: ${X.stderr}`,{level:"error"});return X.json}catch(X){Z(`[Sandbox Windows] acl revoke: ${X.message}`,{level:"error"});return}}function v5($){let{exe:J,prependArgs:X}=$.srtWin??wJ(),Q=wK(ZQ($.httpProxyPort,$.socksProxyPort,$.caCertPath?.replace(/\\/g,"/"),$.proxyAuthToken,void 0,PJ($.commandId??$.command)));delete Q.TMPDIR,delete Q.NO_PROXY,delete Q.no_proxy;let Y=KX({safeDirs:[$.cwd??process.cwd(),...$.allowWrite??[],...$.gitSafeDirectories??[]],schannelCa:$.caCertPath!==void 0,baseEnv:$.setEnvVars}),G=[J,...X,"exec"];if($.quiet!==!1)G.push("--quiet");for(let V of $.denyRead??[])G.push("--deny-read",V);for(let V of $.denyWrite??[])G.push("--deny-write",V);let W={PATH:process.env.PATH,PATHEXT:process.env.PATHEXT,...$.setEnvVars??{},...Q,...Y};for(let[V,H]of Object.entries(W))if(H!==void 0)G.push("--env",`${V}=${H}`);G.push("--");let U=$.binShell??D9(void 0);G.push(U.exe,...U.args,$.command);let M=G.reduce((V,H)=>V+H.length+3,0);if(M>30000)throw new L$("argv_too_long",`Windows sandbox argv is ~${M} chars (CreateProcessW limit is 32 767).`);let O={...process.env,...Q};return{argv:G,env:O}}function wK($){let J={};for(let X of $){let Q=X.indexOf("=");if(Q===-1)continue;J[X.slice(0,Q)]=X.slice(Q+1)}return J}function u7($){let J=$?` --sublayer-guid ${$}`:"";return`Windows sandbox needs a one-time install (one UAC prompt):
|
|
66
67
|
npx sandbox-runtime windows-install
|
|
67
68
|
`+" \u2014 or call installWindowsSandbox(), or run "+`\`srt-win.exe install${J}\` directly.
|
|
68
|
-
No logout is needed: the WFP filter keys on the dedicated \`srt-sandbox\` user's SID, so your network is unaffected.`}function x4($){try{return{status:"fulfilled",value:$()}}catch(J){return{status:"rejected",reason:J}}}function r4($,J,X){let Q=[],Y=[];if(J.status==="rejected")return Q.push(`srt-win user status failed: ${J.reason.message}`),{errors:Q,warnings:Y};let G=J.value;if(!G.provisioned||!G.credPresent)Q.push(`Sandbox user is not provisioned (user=${G.provisioned}, cred=${G.credPresent}). `+L7($));let W=X();if(W.status==="rejected")return Q.push(`srt-win wfp status failed: ${W.reason.message}`),{errors:Q,warnings:Y};let M=W.value;if(M.state==="cannot-read")Z(`[Sandbox Windows] wfp status cannot-read (non-elevated): ${M.hint}`);else if(M.state!=="installed"){if(G.provisioned&&G.credPresent)Q.push(`WFP filters not installed under sublayer ${$??"(default)"}. `+L7($))}else if(M.portRange)Z(`[Sandbox Windows] WFP installed: ${M.filters} filters, proxy port range ${M.portRange[0]}-${M.portRange[1]}`);return{errors:Q,warnings:Y}}function t4($={}){let J;try{J=$.srtWin??CJ()}catch(X){return{errors:[X.message],warnings:[]}}return Z(`[Sandbox Windows] using srt-win at ${J.exe}`),r4($.sublayerGuid,x4(()=>B7({srtWin:J})),()=>x4(()=>l4({sublayerGuid:$.sublayerGuid,srtWin:J})))}async function w7($={}){let J;try{J=$.srtWin??CJ()}catch(Y){return{errors:[Y.message],warnings:[]}}Z(`[Sandbox Windows] using srt-win at ${J.exe}`);let[X,Q]=await Promise.allSettled([vX({srtWin:J}),d4({sublayerGuid:$.sublayerGuid,srtWin:J})]);return r4($.sublayerGuid,X,()=>Q)}import{isIP as wK}from"net";function kX($){if($.startsWith("[")){let Q=$.indexOf("]");if(Q===-1)return{hostPattern:$,port:void 0};let Y=$.slice(1,Q),G=BJ(Y)??Y,W=$.slice(Q+1);if(W==="")return{hostPattern:G,port:void 0};let M=e4(W.startsWith(":")?W.slice(1):"");return M===void 0?{hostPattern:$,port:void 0}:{hostPattern:G,port:M}}let J=$.lastIndexOf(":");if(J===-1)return{hostPattern:$,port:void 0};if($.indexOf(":")!==J)return{hostPattern:BJ($)??$,port:void 0};let X=e4($.slice(J+1));if(X===void 0)return{hostPattern:$,port:void 0};return{hostPattern:$.slice(0,J),port:X}}function e4($){if(!/^[1-9][0-9]{0,4}$/.test($))return;let J=Number($);return J>65535?void 0:J}function fX($){return kX($).hostPattern}function R0($,J){let X=$.toLowerCase();if(J==="*")return!0;if(J.startsWith("*.")){if(wK(dJ(X)))return!1;let Q=J.substring(2).toLowerCase();return X.endsWith("."+Q)}return X===J.toLowerCase()}function yX($,J,X){let{hostPattern:Q,port:Y}=kX(X);if(Y!==void 0&&Y!==J)return!1;return R0($,Q)}function q9($,J){let X=J.map(fX);if(!$.startsWith("*."))return X.some((Y)=>R0($,Y));let Q=$.slice(2).toLowerCase();return X.some((Y)=>{if(!Y.startsWith("*."))return!1;let G=Y.slice(2).toLowerCase();return Q===G||Q.endsWith("."+G)})}function $5($,J,X,Q){if(!bQ(J))return{verdict:"deny",reason:"malformed host"};let Y=BJ(J)??J;for(let G of $.deniedDomains)if(yX(Y,X,G))return{verdict:"deny",reason:$.deniedDomainReasons?.[G]??"host is on the deny list",rule:G};for(let G of $.allowedDomains)if(yX(Y,X,G))return{verdict:"allow",rule:G};if(!Q||$.strictAllowlist)return{verdict:"deny",reason:"host is not on the allow list"};return{verdict:"ask"}}import{EOL as P7}from"os";import{dirname as _7}from"path";var f,uX,gX,mX,hJ,h0,bX,J5=!1,K9,mQ,m0,f$,l0,lQ,u0,z9,Q5=!1,lX,VQ=new X9,HQ=new e8,F9=new Y7,E9=new X7;function _K(){if(J5)return;let $=()=>h7().catch((J)=>{Z(`Cleanup failed in registerCleanup ${J}`,{level:"error"})});process.once("exit",$),process.once("SIGINT",$),process.once("SIGTERM",$),J5=!0}var xK=1024,OQ=new Map;function U5($,J){let X=J?.commandId,Q=J?.commandText??$;if(X===void 0||X===Q)return;let Y=a0(wJ(X));OQ.delete(Y),OQ.set(Y,Q);while(OQ.size>xK){let G=OQ.keys().next().value;if(G===void 0)break;OQ.delete(G)}}function X5($){return OQ.get($)??$}function x7($,J){let X=J?(()=>{let Q=a0(J);return OQ.get(Q)??K7(Q)})():void 0;if(uQ($,X,f?.ignoreViolations))return;VQ.addViolation({line:$,encodedCommand:J,command:X,timestamp:new Date})}function vK($){try{let J=new URL($);return`${J.origin}${J.pathname}${J.search?"?\u2026":""}`}catch{let J=$.indexOf("?");return J===-1?$:`${$.slice(0,J)}?\u2026`}}async function Y5($,J,X,Q){let Y=(W)=>{return x7(`deny network-outbound ${J}:${$} (${W})`,Q),!1};if(!f)return Z("No config available, denying network request"),Y("sandbox policy unavailable");let G=$5(f.network,J,$,X!==void 0);if(G.verdict==="allow")return Z(`Allowed by config rule: ${J}:${$}`),!0;if(G.verdict==="deny"){if(G.reason==="malformed host")Z(`Denying malformed host: ${JSON.stringify(J)}:${$}`,{level:"error"});else if(G.rule!==void 0)Z(`Denied by config rule: ${J}:${$}`);else Z(`No matching config rule, denying: ${J}:${$}`);return Y(G.reason)}Z(`No matching config rule, asking user: ${J}:${$}`);try{if(await X({host:J,port:$}))return Z(`User allowed: ${J}:${$}`),!0;return Z(`User denied: ${J}:${$}`),Y("user denied")}catch(W){return Z(`Error in permission callback: ${W}`,{level:"error"}),Y("permission prompt failed")}}function kK(){if(!f?.credentials)return;return($,J)=>{HQ.substituteInHeaders($,J,R0)}}function fK(){if(!f?.credentials)return;return($)=>HQ.sentinelsForHost($,R0)}function yK(){if(!f?.credentials)return;return($,J,X,Q)=>U4(F9,f?.credentials?.sigv4,R0)($,J,X,Q)}function bK($){if(!f?.network.mitmProxy)return;let{socketPath:J,domains:X}=f.network.mitmProxy,Q=BJ($)??$;for(let Y of X)if(R0(Q,Y))return Z(`Host ${$} matches MITM pattern ${Y}`),J;return}function hK($){let J=f?.network.tlsTerminate?.excludeDomains;if(!J?.length)return!0;let X=BJ($)??$;for(let Q of J){if(!R0(X,Q))continue;Z(`Host ${$} matches tlsTerminate.excludeDomains pattern ${Q}; skipping TLS termination`);let Y=HQ.namesInjectableAt(X,R0);if(Y.length>0)Z(`tlsTerminate.excludeDomains: masked credential(s) ${Y.join(", ")} are configured for injection at ${$}, but its connections are not terminated, so the upstream will receive the placeholder`,{level:"error"});return!1}return!0}async function uK($,J){let X=kK(),Q=fK();uX=hW({filter:(M,U,O,V)=>Y5(M,U,$,V),getMitmSocketPath:bK,mitmCA:f$,shouldTerminateTLS:hK,filterRequest:f?.network.filterRequest,onFilterRequestDenied:({method:M,url:U,reason:O,encodedCommand:V})=>{x7(`deny http-request ${M} ${vK(U)} (${O})`,V)},mutateHeaders:X,mutateHeadersPlaintext:f?.credentials?.allowPlaintextInject?X:void 0,getBodySubstitutions:Q,getBodySubstitutionsPlaintext:f?.credentials?.allowPlaintextInject?Q:void 0,planSigv4:yK(),parentProxy:m0,proxyAuthToken:l0}),gX=iW({filter:(M,U,O)=>Y5(M,U,$,O),parentProxy:m0,proxyAuthToken:l0,probeUnauthenticated:async(M,U)=>{if(!f)return{};let O=BJ(U)??U;for(let V of f.network.deniedDomains)if(yX(O,M,V)){let H=f.network.deniedDomainReasons?.[V]??"host is on the deny list";return x7(`deny network-outbound ${U}:${M} (${H})`,void 0),{deniedReason:H}}return{}}}),mX=sW({httpServer:uX,handleSocksConnection:(M)=>gX.handleConnection(M),httpBackendPortRange:J});let Y=mX,G=await Y.listenHttpBackend();await iY(Y.server,(M)=>Y.server.listen(M,"127.0.0.1"),J,G!==void 0?new Set([G]):new Set);let W=Y.getPort();if(W===void 0)throw Error("Failed to get mux proxy server port");return Y.unref(),Z(`Mux proxy (HTTP+SOCKS) listening on localhost:${W}`),W}async function gK($,J,X=!1){if(h0){await h0;return}if(f=$,m0=l8($.network.parentProxy),m0)Z(`Parent proxy configured: http=${c8(m0.httpUrl)} https=${c8(m0.httpsUrl)}`);if($.network.tlsTerminate&&$.network.mitmProxy)throw Error("network.tlsTerminate and network.mitmProxy are mutually exclusive");let Q=$.network.tlsTerminate,Y=P$()==="windows"&&Q!==void 0&&!Q.caCertPath&&!Q.caKeyPath;if(f$=Q&&!Y?y8(Q):void 0,f$&&$.runAsHostUid!==void 0&&P$()==="linux"){if(g0.chmodSync(_7(f$.trustBundlePath),457),g0.chmodSync(f$.trustBundlePath,420),f$.ephemeral)g0.chmodSync(_7(f$.certPath),457),g0.chmodSync(f$.certPath,420)}let G=await H5();if(G.errors.length>0)throw Error(`Sandbox dependencies not available: ${G.errors.join(", ")}`);if(X&&P$()==="macos")K9=I4(VQ.addViolation.bind(VQ),f.ignoreViolations,X5),Z("Started macOS sandbox log monitor");if(X&&P$()==="linux")mQ=P4(VQ.addViolation.bind(VQ),{allowWritePaths:[...NQ($.runAsHostHome),...f.filesystem.allowWrite],denyWritePaths:f.filesystem.denyWrite,ignoreViolations:f.ignoreViolations,resolveCommandText:X5,consumerUid:$.runAsHostUid,consumerGid:$.runAsHostGid}),mQ.ready,Z("Started Linux seccomp violation monitor");if(_K(),P$()==="windows"){lX=CJ($.windows?.srtWin);let W=lX,M=await vX({srtWin:W});if(!M.provisioned||!M.credPresent)throw f=void 0,new F$("not_provisioned",`Windows sandbox user is not provisioned (user=${M.provisioned}, cred=${M.credPresent}). Run \`npx sandbox-runtime windows-install\` (one UAC prompt) to provision it.`);if(!Q5){try{await Z7({proxyPortRange:$.windows?.proxyPortRange,srtWin:W})}catch(U){throw f=void 0,U}Q5=!0}if(Y&&Q)try{let U=await T7({status:M,srtWin:W});f$=y8({caCertPem:U.certPem,caKeyPem:U.keyPem,caCertPath:U.certPath,caKeyPath:U.keyPath,extraCaCertPaths:Q.extraCaCertPaths})}catch(U){throw f=void 0,U}if(Q&&f$&&!Y){let U=j7(M),O=yQ(f$.certPem);if(!U)throw f=void 0,new F$("trust_ca_not_installed",`tlsTerminate on Windows requires the sandbox to be installed with this CA (thumb=${O}): run \`srt-win user trust-ca ${f$.certPath}\`. Per-exec installs into the sandbox user's Root store are not supported.`);if(U.thumb!==O)throw f=void 0,new F$("trust_ca_thumbprint_mismatch",`tlsTerminate on Windows: the sandbox's installed CA (thumb=${U.thumb}) doesn't match this session's CA (thumb=${O}). Run \`srt-win user trust-ca ${f$.certPath}\` to update it.`)}try{let U=cK($);if(f$)U.grantRead.push(_7(f$.trustBundlePath));if(!M.sid)throw Error("sandbox user SID missing from `srt-win user status` (provisioned but in an inconsistent state)");let O=M.sid;if(u0=O,U.grantRead.length>0||U.grantWrite.length>0)C7({sandboxUserSid:O,read:U.grantRead,write:U.grantWrite,srtWin:W});if(U.denyRead.length>0||U.denyWrite.length>0)I7({sandboxUserSid:O,denyRead:U.denyRead,denyWrite:U.denyWrite,srtWin:W});if(U.grantRead.length>0||U.grantWrite.length>0||U.denyRead.length>0||U.denyWrite.length>0)lQ=U,Z(`[Sandbox Windows] fs applied: ${U.grantWrite.length} grantWrite, ${U.grantRead.length} grantRead, ${U.denyRead.length} denyRead, ${U.denyWrite.length} denyWrite`);z9=K5($)}catch(U){if(u0)H9({sandboxUserSid:u0,srtWin:W}),V9({sandboxUserSid:u0,srtWin:W});throw u0=void 0,f=void 0,U}}h0=(async()=>{try{let W=P$()==="windows"?f.windows?.proxyPortRange??G9:void 0;l0=f.network.httpProxyPort!==void 0?void 0:PK(16).toString("hex");let U=f.network.httpProxyPort===void 0||f.network.socksProxyPort===void 0?await uK(J,W):void 0,O=f.network.httpProxyPort??U,V=f.network.socksProxyPort??U;if(f$&&U!==void 0&&P$()==="windows")f$.crlUrl=`http://127.0.0.1:${U}${yY}`;if(f.network.httpProxyPort!==void 0)Z(`Using external HTTP proxy on port ${O}`);if(f.network.socksProxyPort!==void 0)Z(`Using external SOCKS proxy on port ${V}`);let H;if(P$()==="linux")H=await R4(O,V,f.socatPath,f.runAsHostUid,f.runAsHostGid);let q={httpProxyPort:O,socksProxyPort:V,linuxBridge:H};return hJ=q,Z("Network infrastructure initialized"),q}catch(W){throw h0=void 0,hJ=void 0,h7().catch((M)=>{Z(`Cleanup failed in initializationPromise ${M}`,{level:"error"})}),W}})(),await h0}function O5(){let $=P$();if($==="linux")return S9()!=="1";return $==="macos"||$==="windows"}function mK(){return f!==void 0}function V5($){if(!O5())return{done:{errors:["Unsupported platform"],warnings:[]}};let J=[],X=[],Q=P$();if(Q==="linux"){let Y=$??f?.ripgrep??{command:"rg"};if(N0(Y.command)===null)J.push(`ripgrep (${Y.command}) not found`);let G=L4({seccompConfig:f?.seccomp,bwrapPath:f?.bwrapPath,socatPath:f?.socatPath});J.push(...G.errors),X.push(...G.warnings)}else if(Q==="windows"){let Y;try{Y=CJ(f?.windows?.srtWin)}catch(G){return J.push(G.message),{done:{errors:J,warnings:X}}}return{windows:{sublayerGuid:f?.windows?.sublayerGuid??f?.windows?.wfpSublayerGuid,srtWin:Y}}}return{done:{errors:J,warnings:X}}}function lK($){let J=V5($);if("done"in J)return J.done;return t4(J.windows)}async function H5($){let J=V5($);if("done"in J)return J.done;return w7(J.windows)}function k7($,J){if(!$)return{denyReadPaths:[],unsetEnvVars:[],setEnvVars:{},maskedFileBinds:[],maskedFileStoreDir:void 0};let X=N9($),Q=[...new Set((J??[]).map(fX))],Y=[];for(let V of $.envVars??[])if(V.mode==="deny")Y.push(V.name);let{setEnvVars:G,degradeToUnsetNames:W}=X4($.envVars??[],Q,HQ);Y.push(...W),M4($.envVars??[],$.awsPairs,Q,G,F9);let M=$.files??[],{binds:U,degradeToDenyPaths:O}=Q4(M,Q,HQ,E9);return{denyReadPaths:[...new Set([...X,...O])],unsetEnvVars:[...new Set(Y)],setEnvVars:G,maskedFileBinds:U,maskedFileStoreDir:E9.dirPath}}function N9($){let J=$?.files??[];return[...new Set(J.filter((X)=>X.mode==="deny").map((X)=>X.path))]}function q5($,J){return[...new Set([...$,...J.denyReadPaths])]}function dK(){if(!f||f.filesystem.disabled)return{denyOnly:[],allowWithinDeny:[]};let $=q5(f.filesystem.denyRead,k7(f.credentials,f.network.allowedDomains)),J=[];for(let Q of $){let Y=q0(Q);if(P$()==="linux"&&FJ(Y)){let G=s0(Q);Z(`[Sandbox] Expanded glob pattern "${Q}" to ${G.length} paths on Linux`),J.push(...G)}else J.push(Y)}let X=[];for(let Q of f.filesystem.allowRead??[]){let Y=q0(Q);if(P$()==="linux"&&FJ(Y)){let G=s0(Q);Z(`[Sandbox] Expanded allowRead glob pattern "${Q}" to ${G.length} paths on Linux`),X.push(...G)}else X.push(Y)}return{denyOnly:J,allowWithinDeny:X}}function pK(){if(!f)return{allowOnly:NQ(),denyWithinAllow:[]};if(f.filesystem.disabled)return{allowOnly:["/"],denyWithinAllow:[]};let $=f.filesystem.allowWrite.map((Q)=>q0(Q)).filter((Q)=>{if(P$()==="linux"&&FJ(Q))return Z(`Skipping glob pattern on Linux/WSL: ${Q}`),!1;return!0}),J=f.filesystem.denyWrite.map((Q)=>q0(Q)).filter((Q)=>{if(P$()==="linux"&&FJ(Q))return Z(`Skipping glob pattern on Linux/WSL: ${Q}`),!1;return!0});return{allowOnly:[...NQ(v7()),...$],denyWithinAllow:J}}function cK($){let J=$.filesystem;if(J?.disabled)return{grantRead:[],grantWrite:[],denyRead:[],denyWrite:[]};let X=O9,Q=X([...new Set([...J?.denyRead??[],...N9($.credentials)])],{mode:"deny"}),Y=X(J?.denyWrite??[],{mode:"deny"});return{grantRead:X(J?.allowRead??[],{mode:"grant"}),grantWrite:X(J?.allowWrite??[],{mode:"grant"}),denyRead:Q,denyWrite:Y}}function K5($){return{disabled:$.filesystem.disabled??!1,denyRead:[...$.filesystem.denyRead],denyWrite:[...$.filesystem.denyWrite],allowRead:[...$.filesystem.allowRead??[]],allowWrite:[...$.filesystem.allowWrite],credFiles:N9($.credentials)}}function hX($,J){if($.length!==J.length)return!1;let X=new Set($);return J.every((Q)=>X.has(Q))}function nK($,J){return $.disabled===J.disabled&&hX($.denyRead,J.denyRead)&&hX($.denyWrite,J.denyWrite)&&hX($.allowRead,J.allowRead)&&hX($.allowWrite,J.allowWrite)&&hX($.credFiles,J.credFiles)}function iK($){return z9!==void 0&&nK(z9,K5($))}function oK(){if(!f)return{};let $=f.network.allowedDomains,J=f.network.deniedDomains;return{allowedHosts:$,...J.length>0&&{deniedHosts:J}}}function z5(){return f?.network?.allowUnixSockets}function G5(){return f?.network?.allowAllUnixSockets}function E5(){return f?.network?.allowLocalBinding}function F5(){return f?.network?.allowMachLookup}function N5(){return f?.ignoreViolations}function L5(){return f?.enableWeakerNestedSandbox}function aK(){return f?.runAsUid}function sK(){return f?.runAsGid}function rK(){return f?.runAsHostUid}function tK(){return f?.runAsHostGid}function v7(){return f?.runAsHostHome}function eK(){return f?.runAsHostUser}function $6(){return f?.enableWeakerNetworkIsolation}function J6(){return f?.allowAppleEvents}function Q6(){return f?.ripgrep??{command:"rg"}}function X6(){return f?.mandatoryDenySearchDepth??3}function W5(){return f?.filesystem?.allowGitConfig??!1}function R5($){return[...f?.git?.safeDirectories??[],...$?.git?.safeDirectories??[]]}function Y6(){return f?.seccomp}function G6(){return l0}function f7(){return hJ?.httpProxyPort}function y7(){return hJ?.socksProxyPort}function A5(){return hJ?.linuxBridge?.httpSocketPath}function D5(){return hJ?.linuxBridge?.socksSocketPath}async function b7(){if(!f)return!1;if(h0)try{return await h0,!0}catch{return!1}return hJ!==void 0}async function Z5($,J,X,Q,Y){let G=P$(),W=Y?.commandId;U5($,Y);let M=X?.filesystem!==void 0?X.filesystem.disabled??!1:f?.filesystem.disabled??!1,U=k7(X?.credentials??f?.credentials,X?.network?.allowedDomains??f?.network?.allowedDomains),O,V;if(!M){let L=(C)=>C.map((h)=>q0(h)).filter((h)=>{if(P$()==="linux"&&FJ(h))return Z(`[Sandbox] Skipping glob write pattern on Linux: ${h}`),!1;return!0}),D=L(X?.filesystem?.allowWrite??f?.filesystem.allowWrite??[]);O={allowOnly:[...NQ(X?.runAsHostHome??v7()),...D],denyWithinAllow:L(X?.filesystem?.denyWrite??f?.filesystem.denyWrite??[])};let w=q5(X?.filesystem?.denyRead??f?.filesystem.denyRead??[],U),T=[];for(let C of w){let h=q0(C);if(P$()==="linux"&&FJ(h))T.push(...s0(C));else T.push(h)}let P=X?.filesystem?.allowRead??f?.filesystem.allowRead??[],S=[];for(let C of P){let h=q0(C);if(P$()==="linux"&&FJ(h))S.push(...s0(C));else S.push(h)}if(f$)S.push(f$.certPath,f$.trustBundlePath);V={denyOnly:T,allowWithinDeny:S}}let H=X?.network?.allowedDomains!==void 0||f?.network?.allowedDomains!==void 0,q=H,F=H;if(F)await b7();let K=X?.allowPty??f?.allowPty,R=R5(X);switch(G){case"macos":return S4({command:$,commandId:W,needsNetworkRestriction:q,httpProxyPort:F?f7():void 0,socksProxyPort:F?y7():void 0,proxyAuthToken:F?l0:void 0,caCertPath:f$?.trustBundlePath,readConfig:V,writeConfig:O,unsetEnvVars:U.unsetEnvVars,setEnvVars:U.setEnvVars,maskedFileBinds:U.maskedFileBinds,allowUnixSockets:z5(),allowAllUnixSockets:G5(),allowLocalBinding:E5(),allowMachLookup:F5(),ignoreViolations:N5(),allowPty:K,allowGitConfig:W5(),gitSafeDirectories:R,enableWeakerNetworkIsolation:$6(),allowAppleEvents:J6(),binShell:J});case"linux":return A4({command:$,commandId:W,needsNetworkRestriction:q,httpSocketPath:F?A5():void 0,socksSocketPath:F?D5():void 0,httpProxyPort:F?hJ?.httpProxyPort:void 0,socksProxyPort:F?hJ?.socksProxyPort:void 0,proxyAuthToken:F?l0:void 0,caCertPath:f$?.trustBundlePath,readConfig:V,writeConfig:O,unsetEnvVars:U.unsetEnvVars,setEnvVars:U.setEnvVars,maskedFileBinds:U.maskedFileBinds,maskedFileStoreDir:U.maskedFileStoreDir,enableWeakerNestedSandbox:L5(),runAsUid:aK(),runAsGid:sK(),runAsHostUid:rK(),runAsHostGid:tK(),runAsHostHome:v7(),runAsHostUser:eK(),setprivPath:"/usr/bin/setpriv",allowAllUnixSockets:G5(),binShell:J,ripgrepConfig:Q6(),mandatoryDenySearchDepth:X6(),allowGitConfig:W5(),gitSafeDirectories:R,seccompConfig:Y6(),bwrapPath:f?.bwrapPath,socatPath:f?.socatPath,observeSocketPath:mQ?.observeSocketPath,abortSignal:Q});case"windows":throw Error("wrapWithSandbox() returns a shell string and is not supported on Windows. Use SandboxManager.wrapWithSandboxArgv() and spawn the result with {shell: false}.");default:throw Error(`Sandbox configuration is not supported on platform: ${G}`)}}async function W6($,J,X,Q,Y,G){if(P$()==="windows"){let O=X?.network?.allowedDomains!==void 0||f?.network?.allowedDomains!==void 0;if(O)await b7();let V=k7(X?.credentials??f?.credentials,X?.network?.allowedDomains??f?.network?.allowedDomains),H=X?.filesystem,q=[],F=[];if(!H?.disabled){if(H?.allowRead?.length||H?.allowWrite?.length)throw Error("Per-exec filesystem.allowRead/allowWrite is not supported "+"on Windows \u2014 `srt-win exec` only exposes per-exec "+"denies. Set them at the session level (initialize()).");let K=[...H?.denyRead??[],...N9(X?.credentials)],R=H?.denyWrite??[];if(K.length>0||R.length>0){let L=new Set(lQ?.denyRead??[]),D=new Set(lQ?.denyWrite??[]),w=O9;q=w(K,{mode:"deny"}).filter((T)=>!L.has(T)),F=w(R,{mode:"deny"}).filter((T)=>!L.has(T)&&!D.has(T))}}return U5($,G),s4({command:$,commandId:G?.commandId,httpProxyPort:O?f7():void 0,socksProxyPort:O?y7():void 0,proxyAuthToken:O?l0:void 0,setEnvVars:V.setEnvVars,denyRead:q,denyWrite:F,cwd:Y,allowWrite:lQ?.grantWrite,gitSafeDirectories:R5(X),caCertPath:f$?.trustBundlePath,binShell:W9(J),srtWin:X?.windows?.srtWin?CJ(X.windows.srtWin):lX??CJ(f?.windows?.srtWin)})}if(typeof J==="object")throw Error("binShell object form is Windows-only; pass a shell path string on macOS/Linux");let M=await Z5($,J,X,Q,G);return{argv:[J??"/bin/bash","-c",M],env:process.env}}function M6(){return f}function U6($){if(P$()==="windows"&&f&&!iK($))Z("[Sandbox Windows] updateConfig: the resolved file-access set "+"(filesystem.* \u222A credentials.files) changed but the ACL "+"stamp/grant is session-wide \u2014 call reset() then initialize() "+"to apply. The previously-applied set stays in effect.",{level:"warn"});let{filterRequest:J,...X}=$.network;f=structuredClone({...$,network:X}),f.network.filterRequest=J,m0=l8($.network.parentProxy),Z("Sandbox configuration updated")}function O6(){Q9()}var V6=1500;function M5($,J){if(!$.pid||$.exitCode!==null||$.signalCode!==null)return Promise.resolve();try{process.kill($.pid,"SIGTERM"),Z(`Sent SIGTERM to ${J} bridge process`)}catch(X){if(X.code!=="ESRCH")Z(`Error killing ${J} bridge: ${X}`,{level:"error"});return Promise.resolve()}return new Promise((X)=>{let Q=!1,Y=()=>{if(Q)return;Q=!0,clearTimeout(G),X()};$.once("exit",()=>{Z(`${J} bridge process exited`),Y()});let G=setTimeout(()=>{if($.exitCode===null&&$.signalCode===null){Z(`${J} bridge did not exit, forcing SIGKILL`,{level:"warn"});try{if($.pid)process.kill($.pid,"SIGKILL")}catch{}}Y()},V6);G.unref?.()})}function H6($){return new Promise((J)=>{if(typeof $.closeAllConnections==="function")$.closeAllConnections();$.close((X)=>{if(X&&X.message!=="Server is not running.")Z(`Error closing HTTP proxy server: ${X.message}`,{level:"error"});J()})})}async function q6(){if(lQ&&u0){let J=u0,X=lX,Q=new Set(["revoked","stillHeld","restored","alreadyOriginal"]),Y=(G,W)=>{if(!Q.has(W.status))Z(`[Sandbox Windows] ${G}: '${W.path}' ${W.status} \u2014 `+"ACE may be left in place; resolve and run `srt-win acl recover` to clear",{level:"warn"})};for(let G of H9({sandboxUserSid:J,srtWin:X})??[])Y("grant revoke",G);for(let G of V9({sandboxUserSid:J,srtWin:X})??[])Y("deny restore",G)}if(lQ=void 0,u0=void 0,z9=void 0,lX=void 0,Q9({force:!0}),K9)K9(),K9=void 0;if(mQ)mQ.stop(),mQ=void 0;if(hJ?.linuxBridge){let{httpSocketPath:J,socksSocketPath:X,httpBridgeProcess:Q,socksBridgeProcess:Y}=hJ.linuxBridge;if(await Promise.all([M5(Q,"HTTP"),M5(Y,"SOCKS")]),J)try{g0.rmSync(J,{force:!0}),Z("Cleaned up HTTP socket")}catch(G){Z(`HTTP socket cleanup error: ${G}`,{level:"error"})}if(X)try{g0.rmSync(X,{force:!0}),Z("Cleaned up SOCKS socket")}catch(G){Z(`SOCKS socket cleanup error: ${G}`,{level:"error"})}}let $=[];if(f$)$.push(KW(f$));if(mX)$.push(mX.close().catch((J)=>{Z(`Error closing mux proxy server: ${J.message}`,{level:"error"})}));if(uX)$.push(H6(uX));if(gX){let J=gX.close().catch((X)=>{Z(`Error closing SOCKS proxy server: ${X.message}`,{level:"error"})});$.push(J)}await Promise.all($),mX=void 0,uX=void 0,l0=void 0,gX=void 0,hJ=void 0,h0=void 0,m0=void 0,f$=void 0,HQ.clear(),F9.clear(),E9.dispose()}async function h7(){if(bX)return bX;bX=q6();try{await bX}finally{bX=void 0}}function K6(){return VQ}function z6($,J){if(!f)return J;let X=VQ.getViolationsForCommand($);if(X.length===0)return J;let Q=J;Q+=P7+"<sandbox_violations>"+P7;for(let Y of X)Q+=Y.line+P7;return Q+="</sandbox_violations>",Q}function E6(){if(P$()!=="linux"||!f||f.filesystem.disabled)return[];let $=[],J=[...f.filesystem.allowWrite,...f.filesystem.denyWrite];for(let X of J){let Q=q0(X);if(FJ(Q))$.push(X)}return $}var F6={initialize:gK,isSupportedPlatform:O5,isSandboxingEnabled:mK,checkDependencies:lK,checkDependenciesAsync:H5,getFsReadConfig:dK,getFsWriteConfig:pK,getNetworkRestrictionConfig:oK,getAllowUnixSockets:z5,getAllowLocalBinding:E5,getAllowMachLookup:F5,getIgnoreViolations:N5,getEnableWeakerNestedSandbox:L5,getProxyPort:f7,getProxyAuthToken:G6,getSocksProxyPort:y7,getLinuxHttpSocketPath:A5,getLinuxSocksSocketPath:D5,waitForNetworkInitialization:b7,wrapWithSandbox:Z5,wrapWithSandboxArgv:W6,cleanupAfterCommand:O6,reset:h7,getMitmCA:()=>f$,getSentinelRegistry:()=>HQ,getAwsPairRegistry:()=>F9,getMaskedFileStore:()=>E9,getSandboxViolationStore:K6,annotateStderrWithSandboxFailures:z6,getLinuxGlobPatternWarnings:E6,getConfig:M6,updateConfig:U6};import{isIP as Iz}from"net";import{isAbsolute as Cz}from"path";var x={};QM(x,{void:()=>$z,util:()=>A$,unknown:()=>t6,union:()=>Yz,undefined:()=>a6,tuple:()=>Mz,transformer:()=>Nz,symbol:()=>o6,string:()=>_5,strictObject:()=>Xz,setErrorMap:()=>R6,set:()=>Vz,record:()=>Uz,quotelessJson:()=>N6,promise:()=>Fz,preprocess:()=>Az,pipeline:()=>Dz,ostring:()=>Zz,optional:()=>Lz,onumber:()=>Bz,oboolean:()=>jz,objectUtil:()=>u7,object:()=>Qz,number:()=>x5,nullable:()=>Rz,null:()=>s6,never:()=>e6,nativeEnum:()=>Ez,nan:()=>c6,map:()=>Oz,makeIssue:()=>dX,literal:()=>Kz,lazy:()=>qz,late:()=>d6,isValid:()=>d0,isDirty:()=>R9,isAsync:()=>pQ,isAborted:()=>L9,intersection:()=>Wz,instanceof:()=>p6,getParsedType:()=>U0,getErrorMap:()=>dQ,function:()=>Hz,enum:()=>zz,effect:()=>Nz,discriminatedUnion:()=>Gz,defaultErrorMap:()=>A0,datetimeRegex:()=>C5,date:()=>i6,custom:()=>P5,coerce:()=>Tz,boolean:()=>v5,bigint:()=>n6,array:()=>Jz,any:()=>r6,addIssueToContext:()=>c,ZodVoid:()=>cX,ZodUnknown:()=>p0,ZodUnion:()=>sQ,ZodUndefined:()=>oQ,ZodType:()=>E$,ZodTuple:()=>V0,ZodTransformer:()=>sJ,ZodSymbol:()=>pX,ZodString:()=>nJ,ZodSet:()=>EQ,ZodSchema:()=>E$,ZodRecord:()=>nX,ZodReadonly:()=>XX,ZodPromise:()=>FQ,ZodPipeline:()=>aX,ZodParsedType:()=>g,ZodOptional:()=>oJ,ZodObject:()=>p$,ZodNumber:()=>c0,ZodNullable:()=>Z0,ZodNull:()=>aQ,ZodNever:()=>O0,ZodNativeEnum:()=>$X,ZodNaN:()=>oX,ZodMap:()=>iX,ZodLiteral:()=>eQ,ZodLazy:()=>tQ,ZodIssueCode:()=>b,ZodIntersection:()=>rQ,ZodFunction:()=>nQ,ZodFirstPartyTypeKind:()=>Y$,ZodError:()=>jJ,ZodEnum:()=>i0,ZodEffects:()=>sJ,ZodDiscriminatedUnion:()=>A9,ZodDefault:()=>JX,ZodDate:()=>KQ,ZodCatch:()=>QX,ZodBranded:()=>D9,ZodBoolean:()=>iQ,ZodBigInt:()=>n0,ZodArray:()=>iJ,ZodAny:()=>zQ,Schema:()=>E$,ParseStatus:()=>zJ,OK:()=>EJ,NEVER:()=>Sz,INVALID:()=>Q$,EMPTY_PATH:()=>A6,DIRTY:()=>qQ,BRAND:()=>l6});var A$;(function($){$.assertEqual=(Y)=>{};function J(Y){}$.assertIs=J;function X(Y){throw Error()}$.assertNever=X,$.arrayToEnum=(Y)=>{let G={};for(let W of Y)G[W]=W;return G},$.getValidEnumValues=(Y)=>{let G=$.objectKeys(Y).filter((M)=>typeof Y[Y[M]]!=="number"),W={};for(let M of G)W[M]=Y[M];return $.objectValues(W)},$.objectValues=(Y)=>{return $.objectKeys(Y).map(function(G){return Y[G]})},$.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let G=[];for(let W in Y)if(Object.prototype.hasOwnProperty.call(Y,W))G.push(W);return G},$.find=(Y,G)=>{for(let W of Y)if(G(W))return W;return},$.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&Number.isFinite(Y)&&Math.floor(Y)===Y;function Q(Y,G=" | "){return Y.map((W)=>typeof W==="string"?`'${W}'`:W).join(G)}$.joinValues=Q,$.jsonStringifyReplacer=(Y,G)=>{if(typeof G==="bigint")return G.toString();return G}})(A$||(A$={}));var u7;(function($){$.mergeShapes=(J,X)=>{return{...J,...X}}})(u7||(u7={}));var g=A$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),U0=($)=>{switch(typeof $){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN($)?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":if(Array.isArray($))return g.array;if($===null)return g.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return g.promise;if(typeof Map<"u"&&$ instanceof Map)return g.map;if(typeof Set<"u"&&$ instanceof Set)return g.set;if(typeof Date<"u"&&$ instanceof Date)return g.date;return g.object;default:return g.unknown}};var b=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"]),N6=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class jJ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(Y){return Y.message},X={_errors:[]},Q=(Y)=>{for(let G of Y.issues)if(G.code==="invalid_union")G.unionErrors.map(Q);else if(G.code==="invalid_return_type")Q(G.returnTypeError);else if(G.code==="invalid_arguments")Q(G.argumentsError);else if(G.path.length===0)X._errors.push(J(G));else{let W=X,M=0;while(M<G.path.length){let U=G.path[M];if(M!==G.path.length-1)W[U]=W[U]||{_errors:[]};else W[U]=W[U]||{_errors:[]},W[U]._errors.push(J(G));W=W[U],M++}}};return Q(this),X}static assert($){if(!($ instanceof jJ))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},X=[];for(let Q of this.issues)if(Q.path.length>0){let Y=Q.path[0];J[Y]=J[Y]||[],J[Y].push($(Q))}else X.push($(Q));return{formErrors:X,fieldErrors:J}}get formErrors(){return this.flatten()}}jJ.create=($)=>{return new jJ($)};var L6=($,J)=>{let X;switch($.code){case b.invalid_type:if($.received===g.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case b.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,A$.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:X=`Unrecognized key(s) in object: ${A$.joinValues($.keys,", ")}`;break;case b.invalid_union:X="Invalid input";break;case b.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${A$.joinValues($.options)}`;break;case b.invalid_enum_value:X=`Invalid enum value. Expected ${A$.joinValues($.options)}, received '${$.received}'`;break;case b.invalid_arguments:X="Invalid function arguments";break;case b.invalid_return_type:X="Invalid function return type";break;case b.invalid_date:X="Invalid date";break;case b.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else A$.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case b.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case b.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case b.custom:X="Invalid input";break;case b.invalid_intersection_types:X="Intersection results could not be merged";break;case b.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case b.not_finite:X="Number must be finite";break;default:X=J.defaultError,A$.assertNever($)}return{message:X}},A0=L6;var B5=A0;function R6($){B5=$}function dQ(){return B5}var dX=($)=>{let{data:J,path:X,errorMaps:Q,issueData:Y}=$,G=[...X,...Y.path||[]],W={...Y,path:G};if(Y.message!==void 0)return{...Y,path:G,message:Y.message};let M="",U=Q.filter((O)=>!!O).slice().reverse();for(let O of U)M=O(W,{data:J,defaultError:M}).message;return{...Y,path:G,message:M}},A6=[];function c($,J){let X=dQ(),Q=dX({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===A0?void 0:A0].filter((Y)=>!!Y)});$.common.issues.push(Q)}class zJ{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let X=[];for(let Q of J){if(Q.status==="aborted")return Q$;if(Q.status==="dirty")$.dirty();X.push(Q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,J){let X=[];for(let Q of J){let Y=await Q.key,G=await Q.value;X.push({key:Y,value:G})}return zJ.mergeObjectSync($,X)}static mergeObjectSync($,J){let X={};for(let Q of J){let{key:Y,value:G}=Q;if(Y.status==="aborted")return Q$;if(G.status==="aborted")return Q$;if(Y.status==="dirty")$.dirty();if(G.status==="dirty")$.dirty();if(Y.value!=="__proto__"&&(typeof G.value<"u"||Q.alwaysSet))X[Y.value]=G.value}return{status:$.value,value:X}}}var Q$=Object.freeze({status:"aborted"}),qQ=($)=>({status:"dirty",value:$}),EJ=($)=>({status:"valid",value:$}),L9=($)=>$.status==="aborted",R9=($)=>$.status==="dirty",d0=($)=>$.status==="valid",pQ=($)=>typeof Promise<"u"&&$ instanceof Promise;var o;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(o||(o={}));class aJ{constructor($,J,X,Q){this._cachedPath=[],this.parent=$,this.data=J,this._path=X,this._key=Q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var j5=($,J)=>{if(d0(J))return{success:!0,data:J.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new jJ($.common.issues);return this._error=X,this._error}}}};function V$($){if(!$)return{};let{errorMap:J,invalid_type_error:X,required_error:Q,description:Y}=$;if(J&&(X||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:Y};return{errorMap:(W,M)=>{let{message:U}=$;if(W.code==="invalid_enum_value")return{message:U??M.defaultError};if(typeof M.data>"u")return{message:U??Q??M.defaultError};if(W.code!=="invalid_type")return{message:M.defaultError};return{message:U??X??M.defaultError}},description:Y}}class E${get description(){return this._def.description}_getType($){return U0($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:U0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new zJ,ctx:{common:$.parent.common,data:$.data,parsedType:U0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(pQ(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let X=this.safeParse($,J);if(X.success)return X.data;throw X.error}safeParse($,J){let X={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:U0($)},Q=this._parseSync({data:$,path:X.path,parent:X});return j5(X,Q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:U0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:J});return d0(X)?{value:X.value}:{issues:J.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((X)=>d0(X)?{value:X.value}:{issues:J.common.issues})}async parseAsync($,J){let X=await this.safeParseAsync($,J);if(X.success)return X.data;throw X.error}async safeParseAsync($,J){let X={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:U0($)},Q=this._parse({data:$,path:X.path,parent:X}),Y=await(pQ(Q)?Q:Promise.resolve(Q));return j5(X,Y)}refine($,J){let X=(Q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(Q);else return J};return this._refinement((Q,Y)=>{let G=$(Q),W=()=>Y.addIssue({code:b.custom,...X(Q)});if(typeof Promise<"u"&&G instanceof Promise)return G.then((M)=>{if(!M)return W(),!1;else return!0});if(!G)return W(),!1;else return!0})}refinement($,J){return this._refinement((X,Q)=>{if(!$(X))return Q.addIssue(typeof J==="function"?J(X,Q):J),!1;else return!0})}_refinement($){return new sJ({schema:this,typeName:Y$.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(J)=>this["~validate"](J)}}optional(){return oJ.create(this,this._def)}nullable(){return Z0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return iJ.create(this)}promise(){return FQ.create(this,this._def)}or($){return sQ.create([this,$],this._def)}and($){return rQ.create(this,$,this._def)}transform($){return new sJ({...V$(this._def),schema:this,typeName:Y$.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new JX({...V$(this._def),innerType:this,defaultValue:J,typeName:Y$.ZodDefault})}brand(){return new D9({typeName:Y$.ZodBranded,type:this,...V$(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new QX({...V$(this._def),innerType:this,catchValue:J,typeName:Y$.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return aX.create(this,$)}readonly(){return XX.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var D6=/^c[^\s-]{8,}$/i,Z6=/^[0-9a-z]+$/,B6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,j6=/^[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,T6=/^[a-z0-9_-]{21}$/i,S6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,I6=/^[-+]?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)?)??$/,C6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",g7,P6=/^(?:(?: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])$/,_6=/^(?:(?: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])$/,x6=/^(([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]))$/,v6=/^(([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])$/,k6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,f6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,S5="((\\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])))",y6=new RegExp(`^${S5}$`);function I5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${X}`}function b6($){return new RegExp(`^${I5($)}$`)}function C5($){let J=`${S5}T${I5($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${X.join("|")})`,new RegExp(`^${J}$`)}function h6($,J){if((J==="v4"||!J)&&P6.test($))return!0;if((J==="v6"||!J)&&x6.test($))return!0;return!1}function u6($,J){if(!S6.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Y=JSON.parse(atob(Q));if(typeof Y!=="object"||Y===null)return!1;if("typ"in Y&&Y?.typ!=="JWT")return!1;if(!Y.alg)return!1;if(J&&Y.alg!==J)return!1;return!0}catch{return!1}}function g6($,J){if((J==="v4"||!J)&&_6.test($))return!0;if((J==="v6"||!J)&&v6.test($))return!0;return!1}class nJ extends E${_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==g.string){let Y=this._getOrReturnCtx($);return c(Y,{code:b.invalid_type,expected:g.string,received:Y.parsedType}),Q$}let X=new zJ,Q=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.length<Y.value)Q=this._getOrReturnCtx($,Q),c(Q,{code:b.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="max"){if($.data.length>Y.value)Q=this._getOrReturnCtx($,Q),c(Q,{code:b.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="length"){let G=$.data.length>Y.value,W=$.data.length<Y.value;if(G||W){if(Q=this._getOrReturnCtx($,Q),G)c(Q,{code:b.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});else if(W)c(Q,{code:b.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});X.dirty()}}else if(Y.kind==="email"){if(!C6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"email",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="emoji"){if(!g7)g7=new RegExp(w6,"u");if(!g7.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"emoji",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="uuid"){if(!j6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"uuid",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="nanoid"){if(!T6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"nanoid",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid"){if(!D6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"cuid",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid2"){if(!Z6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"cuid2",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ulid"){if(!B6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"ulid",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),c(Q,{validation:"url",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="regex"){if(Y.regex.lastIndex=0,!Y.regex.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"regex",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="trim")$.data=$.data.trim();else if(Y.kind==="includes"){if(!$.data.includes(Y.value,Y.position))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:{includes:Y.value,position:Y.position},message:Y.message}),X.dirty()}else if(Y.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Y.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Y.kind==="startsWith"){if(!$.data.startsWith(Y.value))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:{startsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="endsWith"){if(!$.data.endsWith(Y.value))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:{endsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="datetime"){if(!C5(Y).test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:"datetime",message:Y.message}),X.dirty()}else if(Y.kind==="date"){if(!y6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:"date",message:Y.message}),X.dirty()}else if(Y.kind==="time"){if(!b6(Y).test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{code:b.invalid_string,validation:"time",message:Y.message}),X.dirty()}else if(Y.kind==="duration"){if(!I6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"duration",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ip"){if(!h6($.data,Y.version))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"ip",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="jwt"){if(!u6($.data,Y.alg))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"jwt",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cidr"){if(!g6($.data,Y.version))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"cidr",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64"){if(!k6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"base64",code:b.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64url"){if(!f6.test($.data))Q=this._getOrReturnCtx($,Q),c(Q,{validation:"base64url",code:b.invalid_string,message:Y.message}),X.dirty()}else A$.assertNever(Y);return{status:X.value,value:$.data}}_regex($,J,X){return this.refinement((Q)=>$.test(Q),{validation:J,code:b.invalid_string,...o.errToObj(X)})}_addCheck($){return new nJ({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...o.errToObj($)})}url($){return this._addCheck({kind:"url",...o.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...o.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...o.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...o.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...o.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...o.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...o.errToObj($)})}base64($){return this._addCheck({kind:"base64",...o.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...o.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...o.errToObj($)})}ip($){return this._addCheck({kind:"ip",...o.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...o.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...o.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...o.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...o.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...o.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...o.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...o.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...o.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...o.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...o.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...o.errToObj(J)})}nonempty($){return this.min(1,o.errToObj($))}trim(){return new nJ({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new nJ({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new nJ({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}nJ.create=($)=>{return new nJ({checks:[],typeName:Y$.ZodString,coerce:$?.coerce??!1,...V$($)})};function m6($,J){let X=($.toString().split(".")[1]||"").length,Q=(J.toString().split(".")[1]||"").length,Y=X>Q?X:Q,G=Number.parseInt($.toFixed(Y).replace(".","")),W=Number.parseInt(J.toFixed(Y).replace(".",""));return G%W/10**Y}class c0 extends E${constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==g.number){let Y=this._getOrReturnCtx($);return c(Y,{code:b.invalid_type,expected:g.number,received:Y.parsedType}),Q$}let X=void 0,Q=new zJ;for(let Y of this._def.checks)if(Y.kind==="int"){if(!A$.isInteger($.data))X=this._getOrReturnCtx($,X),c(X,{code:b.invalid_type,expected:"integer",received:"float",message:Y.message}),Q.dirty()}else if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),c(X,{code:b.too_small,minimum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),Q.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),c(X,{code:b.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),Q.dirty()}else if(Y.kind==="multipleOf"){if(m6($.data,Y.value)!==0)X=this._getOrReturnCtx($,X),c(X,{code:b.not_multiple_of,multipleOf:Y.value,message:Y.message}),Q.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),c(X,{code:b.not_finite,message:Y.message}),Q.dirty()}else A$.assertNever(Y);return{status:Q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,o.toString(J))}gt($,J){return this.setLimit("min",$,!1,o.toString(J))}lte($,J){return this.setLimit("max",$,!0,o.toString(J))}lt($,J){return this.setLimit("max",$,!1,o.toString(J))}setLimit($,J,X,Q){return new c0({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:o.toString(Q)}]})}_addCheck($){return new c0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:o.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:o.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:o.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:o.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:o.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:o.toString(J)})}finite($){return this._addCheck({kind:"finite",message:o.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:o.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:o.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&A$.isInteger($.value))}get isFinite(){let $=null,J=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(J===null||X.value>J)J=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(J)&&Number.isFinite($)}}c0.create=($)=>{return new c0({checks:[],typeName:Y$.ZodNumber,coerce:$?.coerce||!1,...V$($)})};class n0 extends E${constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==g.bigint)return this._getInvalidInput($);let X=void 0,Q=new zJ;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),c(X,{code:b.too_small,type:"bigint",minimum:Y.value,inclusive:Y.inclusive,message:Y.message}),Q.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),c(X,{code:b.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),Q.dirty()}else if(Y.kind==="multipleOf"){if($.data%Y.value!==BigInt(0))X=this._getOrReturnCtx($,X),c(X,{code:b.not_multiple_of,multipleOf:Y.value,message:Y.message}),Q.dirty()}else A$.assertNever(Y);return{status:Q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return c(J,{code:b.invalid_type,expected:g.bigint,received:J.parsedType}),Q$}gte($,J){return this.setLimit("min",$,!0,o.toString(J))}gt($,J){return this.setLimit("min",$,!1,o.toString(J))}lte($,J){return this.setLimit("max",$,!0,o.toString(J))}lt($,J){return this.setLimit("max",$,!1,o.toString(J))}setLimit($,J,X,Q){return new n0({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:o.toString(Q)}]})}_addCheck($){return new n0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:o.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:o.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:o.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:o.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:o.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}n0.create=($)=>{return new n0({checks:[],typeName:Y$.ZodBigInt,coerce:$?.coerce??!1,...V$($)})};class iQ extends E${_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==g.boolean){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.boolean,received:X.parsedType}),Q$}return EJ($.data)}}iQ.create=($)=>{return new iQ({typeName:Y$.ZodBoolean,coerce:$?.coerce||!1,...V$($)})};class KQ extends E${_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==g.date){let Y=this._getOrReturnCtx($);return c(Y,{code:b.invalid_type,expected:g.date,received:Y.parsedType}),Q$}if(Number.isNaN($.data.getTime())){let Y=this._getOrReturnCtx($);return c(Y,{code:b.invalid_date}),Q$}let X=new zJ,Q=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.getTime()<Y.value)Q=this._getOrReturnCtx($,Q),c(Q,{code:b.too_small,message:Y.message,inclusive:!0,exact:!1,minimum:Y.value,type:"date"}),X.dirty()}else if(Y.kind==="max"){if($.data.getTime()>Y.value)Q=this._getOrReturnCtx($,Q),c(Q,{code:b.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),X.dirty()}else A$.assertNever(Y);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new KQ({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:o.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:o.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}KQ.create=($)=>{return new KQ({checks:[],coerce:$?.coerce||!1,typeName:Y$.ZodDate,...V$($)})};class pX extends E${_parse($){if(this._getType($)!==g.symbol){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.symbol,received:X.parsedType}),Q$}return EJ($.data)}}pX.create=($)=>{return new pX({typeName:Y$.ZodSymbol,...V$($)})};class oQ extends E${_parse($){if(this._getType($)!==g.undefined){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.undefined,received:X.parsedType}),Q$}return EJ($.data)}}oQ.create=($)=>{return new oQ({typeName:Y$.ZodUndefined,...V$($)})};class aQ extends E${_parse($){if(this._getType($)!==g.null){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.null,received:X.parsedType}),Q$}return EJ($.data)}}aQ.create=($)=>{return new aQ({typeName:Y$.ZodNull,...V$($)})};class zQ extends E${constructor(){super(...arguments);this._any=!0}_parse($){return EJ($.data)}}zQ.create=($)=>{return new zQ({typeName:Y$.ZodAny,...V$($)})};class p0 extends E${constructor(){super(...arguments);this._unknown=!0}_parse($){return EJ($.data)}}p0.create=($)=>{return new p0({typeName:Y$.ZodUnknown,...V$($)})};class O0 extends E${_parse($){let J=this._getOrReturnCtx($);return c(J,{code:b.invalid_type,expected:g.never,received:J.parsedType}),Q$}}O0.create=($)=>{return new O0({typeName:Y$.ZodNever,...V$($)})};class cX extends E${_parse($){if(this._getType($)!==g.undefined){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.void,received:X.parsedType}),Q$}return EJ($.data)}}cX.create=($)=>{return new cX({typeName:Y$.ZodVoid,...V$($)})};class iJ extends E${_parse($){let{ctx:J,status:X}=this._processInputParams($),Q=this._def;if(J.parsedType!==g.array)return c(J,{code:b.invalid_type,expected:g.array,received:J.parsedType}),Q$;if(Q.exactLength!==null){let G=J.data.length>Q.exactLength.value,W=J.data.length<Q.exactLength.value;if(G||W)c(J,{code:G?b.too_big:b.too_small,minimum:W?Q.exactLength.value:void 0,maximum:G?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),X.dirty()}if(Q.minLength!==null){if(J.data.length<Q.minLength.value)c(J,{code:b.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),X.dirty()}if(Q.maxLength!==null){if(J.data.length>Q.maxLength.value)c(J,{code:b.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),X.dirty()}if(J.common.async)return Promise.all([...J.data].map((G,W)=>{return Q.type._parseAsync(new aJ(J,G,J.path,W))})).then((G)=>{return zJ.mergeArray(X,G)});let Y=[...J.data].map((G,W)=>{return Q.type._parseSync(new aJ(J,G,J.path,W))});return zJ.mergeArray(X,Y)}get element(){return this._def.type}min($,J){return new iJ({...this._def,minLength:{value:$,message:o.toString(J)}})}max($,J){return new iJ({...this._def,maxLength:{value:$,message:o.toString(J)}})}length($,J){return new iJ({...this._def,exactLength:{value:$,message:o.toString(J)}})}nonempty($){return this.min(1,$)}}iJ.create=($,J)=>{return new iJ({type:$,minLength:null,maxLength:null,exactLength:null,typeName:Y$.ZodArray,...V$(J)})};function cQ($){if($ instanceof p$){let J={};for(let X in $.shape){let Q=$.shape[X];J[X]=oJ.create(cQ(Q))}return new p$({...$._def,shape:()=>J})}else if($ instanceof iJ)return new iJ({...$._def,type:cQ($.element)});else if($ instanceof oJ)return oJ.create(cQ($.unwrap()));else if($ instanceof Z0)return Z0.create(cQ($.unwrap()));else if($ instanceof V0)return V0.create($.items.map((J)=>cQ(J)));else return $}class p$ extends E${constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),J=A$.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==g.object){let U=this._getOrReturnCtx($);return c(U,{code:b.invalid_type,expected:g.object,received:U.parsedType}),Q$}let{status:X,ctx:Q}=this._processInputParams($),{shape:Y,keys:G}=this._getCached(),W=[];if(!(this._def.catchall instanceof O0&&this._def.unknownKeys==="strip")){for(let U in Q.data)if(!G.includes(U))W.push(U)}let M=[];for(let U of G){let O=Y[U],V=Q.data[U];M.push({key:{status:"valid",value:U},value:O._parse(new aJ(Q,V,Q.path,U)),alwaysSet:U in Q.data})}if(this._def.catchall instanceof O0){let U=this._def.unknownKeys;if(U==="passthrough")for(let O of W)M.push({key:{status:"valid",value:O},value:{status:"valid",value:Q.data[O]}});else if(U==="strict"){if(W.length>0)c(Q,{code:b.unrecognized_keys,keys:W}),X.dirty()}else if(U==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let U=this._def.catchall;for(let O of W){let V=Q.data[O];M.push({key:{status:"valid",value:O},value:U._parse(new aJ(Q,V,Q.path,O)),alwaysSet:O in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let U=[];for(let O of M){let V=await O.key,H=await O.value;U.push({key:V,value:H,alwaysSet:O.alwaysSet})}return U}).then((U)=>{return zJ.mergeObjectSync(X,U)});else return zJ.mergeObjectSync(X,M)}get shape(){return this._def.shape()}strict($){return o.errToObj,new p$({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,X)=>{let Q=this._def.errorMap?.(J,X).message??X.defaultError;if(J.code==="unrecognized_keys")return{message:o.errToObj($).message??Q};return{message:Q}}}:{}})}strip(){return new p$({...this._def,unknownKeys:"strip"})}passthrough(){return new p$({...this._def,unknownKeys:"passthrough"})}extend($){return new p$({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new p$({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:Y$.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new p$({...this._def,catchall:$})}pick($){let J={};for(let X of A$.objectKeys($))if($[X]&&this.shape[X])J[X]=this.shape[X];return new p$({...this._def,shape:()=>J})}omit($){let J={};for(let X of A$.objectKeys(this.shape))if(!$[X])J[X]=this.shape[X];return new p$({...this._def,shape:()=>J})}deepPartial(){return cQ(this)}partial($){let J={};for(let X of A$.objectKeys(this.shape)){let Q=this.shape[X];if($&&!$[X])J[X]=Q;else J[X]=Q.optional()}return new p$({...this._def,shape:()=>J})}required($){let J={};for(let X of A$.objectKeys(this.shape))if($&&!$[X])J[X]=this.shape[X];else{let Y=this.shape[X];while(Y instanceof oJ)Y=Y._def.innerType;J[X]=Y}return new p$({...this._def,shape:()=>J})}keyof(){return w5(A$.objectKeys(this.shape))}}p$.create=($,J)=>{return new p$({shape:()=>$,unknownKeys:"strip",catchall:O0.create(),typeName:Y$.ZodObject,...V$(J)})};p$.strictCreate=($,J)=>{return new p$({shape:()=>$,unknownKeys:"strict",catchall:O0.create(),typeName:Y$.ZodObject,...V$(J)})};p$.lazycreate=($,J)=>{return new p$({shape:$,unknownKeys:"strip",catchall:O0.create(),typeName:Y$.ZodObject,...V$(J)})};class sQ extends E${_parse($){let{ctx:J}=this._processInputParams($),X=this._def.options;function Q(Y){for(let W of Y)if(W.result.status==="valid")return W.result;for(let W of Y)if(W.result.status==="dirty")return J.common.issues.push(...W.ctx.common.issues),W.result;let G=Y.map((W)=>new jJ(W.ctx.common.issues));return c(J,{code:b.invalid_union,unionErrors:G}),Q$}if(J.common.async)return Promise.all(X.map(async(Y)=>{let G={...J,common:{...J.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:J.data,path:J.path,parent:G}),ctx:G}})).then(Q);else{let Y=void 0,G=[];for(let M of X){let U={...J,common:{...J.common,issues:[]},parent:null},O=M._parseSync({data:J.data,path:J.path,parent:U});if(O.status==="valid")return O;else if(O.status==="dirty"&&!Y)Y={result:O,ctx:U};if(U.common.issues.length)G.push(U.common.issues)}if(Y)return J.common.issues.push(...Y.ctx.common.issues),Y.result;let W=G.map((M)=>new jJ(M));return c(J,{code:b.invalid_union,unionErrors:W}),Q$}}get options(){return this._def.options}}sQ.create=($,J)=>{return new sQ({options:$,typeName:Y$.ZodUnion,...V$(J)})};var D0=($)=>{if($ instanceof tQ)return D0($.schema);else if($ instanceof sJ)return D0($.innerType());else if($ instanceof eQ)return[$.value];else if($ instanceof i0)return $.options;else if($ instanceof $X)return A$.objectValues($.enum);else if($ instanceof JX)return D0($._def.innerType);else if($ instanceof oQ)return[void 0];else if($ instanceof aQ)return[null];else if($ instanceof oJ)return[void 0,...D0($.unwrap())];else if($ instanceof Z0)return[null,...D0($.unwrap())];else if($ instanceof D9)return D0($.unwrap());else if($ instanceof XX)return D0($.unwrap());else if($ instanceof QX)return D0($._def.innerType);else return[]};class A9 extends E${_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==g.object)return c(J,{code:b.invalid_type,expected:g.object,received:J.parsedType}),Q$;let X=this.discriminator,Q=J.data[X],Y=this.optionsMap.get(Q);if(!Y)return c(J,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),Q$;if(J.common.async)return Y._parseAsync({data:J.data,path:J.path,parent:J});else return Y._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,X){let Q=new Map;for(let Y of J){let G=D0(Y.shape[$]);if(!G.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let W of G){if(Q.has(W))throw Error(`Discriminator property ${String($)} has duplicate value ${String(W)}`);Q.set(W,Y)}}return new A9({typeName:Y$.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:Q,...V$(X)})}}function m7($,J){let X=U0($),Q=U0(J);if($===J)return{valid:!0,data:$};else if(X===g.object&&Q===g.object){let Y=A$.objectKeys(J),G=A$.objectKeys($).filter((M)=>Y.indexOf(M)!==-1),W={...$,...J};for(let M of G){let U=m7($[M],J[M]);if(!U.valid)return{valid:!1};W[M]=U.data}return{valid:!0,data:W}}else if(X===g.array&&Q===g.array){if($.length!==J.length)return{valid:!1};let Y=[];for(let G=0;G<$.length;G++){let W=$[G],M=J[G],U=m7(W,M);if(!U.valid)return{valid:!1};Y.push(U.data)}return{valid:!0,data:Y}}else if(X===g.date&&Q===g.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class rQ extends E${_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=(Y,G)=>{if(L9(Y)||L9(G))return Q$;let W=m7(Y.value,G.value);if(!W.valid)return c(X,{code:b.invalid_intersection_types}),Q$;if(R9(Y)||R9(G))J.dirty();return{status:J.value,value:W.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Y,G])=>Q(Y,G));else return Q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}rQ.create=($,J,X)=>{return new rQ({left:$,right:J,typeName:Y$.ZodIntersection,...V$(X)})};class V0 extends E${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==g.array)return c(X,{code:b.invalid_type,expected:g.array,received:X.parsedType}),Q$;if(X.data.length<this._def.items.length)return c(X,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q$;if(!this._def.rest&&X.data.length>this._def.items.length)c(X,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let Y=[...X.data].map((G,W)=>{let M=this._def.items[W]||this._def.rest;if(!M)return null;return M._parse(new aJ(X,G,X.path,W))}).filter((G)=>!!G);if(X.common.async)return Promise.all(Y).then((G)=>{return zJ.mergeArray(J,G)});else return zJ.mergeArray(J,Y)}get items(){return this._def.items}rest($){return new V0({...this._def,rest:$})}}V0.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new V0({items:$,typeName:Y$.ZodTuple,rest:null,...V$(J)})};class nX extends E${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==g.object)return c(X,{code:b.invalid_type,expected:g.object,received:X.parsedType}),Q$;let Q=[],Y=this._def.keyType,G=this._def.valueType;for(let W in X.data)Q.push({key:Y._parse(new aJ(X,W,X.path,W)),value:G._parse(new aJ(X,X.data[W],X.path,W)),alwaysSet:W in X.data});if(X.common.async)return zJ.mergeObjectAsync(J,Q);else return zJ.mergeObjectSync(J,Q)}get element(){return this._def.valueType}static create($,J,X){if(J instanceof E$)return new nX({keyType:$,valueType:J,typeName:Y$.ZodRecord,...V$(X)});return new nX({keyType:nJ.create(),valueType:$,typeName:Y$.ZodRecord,...V$(J)})}}class iX extends E${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==g.map)return c(X,{code:b.invalid_type,expected:g.map,received:X.parsedType}),Q$;let Q=this._def.keyType,Y=this._def.valueType,G=[...X.data.entries()].map(([W,M],U)=>{return{key:Q._parse(new aJ(X,W,X.path,[U,"key"])),value:Y._parse(new aJ(X,M,X.path,[U,"value"]))}});if(X.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let M of G){let U=await M.key,O=await M.value;if(U.status==="aborted"||O.status==="aborted")return Q$;if(U.status==="dirty"||O.status==="dirty")J.dirty();W.set(U.value,O.value)}return{status:J.value,value:W}})}else{let W=new Map;for(let M of G){let{key:U,value:O}=M;if(U.status==="aborted"||O.status==="aborted")return Q$;if(U.status==="dirty"||O.status==="dirty")J.dirty();W.set(U.value,O.value)}return{status:J.value,value:W}}}}iX.create=($,J,X)=>{return new iX({valueType:J,keyType:$,typeName:Y$.ZodMap,...V$(X)})};class EQ extends E${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==g.set)return c(X,{code:b.invalid_type,expected:g.set,received:X.parsedType}),Q$;let Q=this._def;if(Q.minSize!==null){if(X.data.size<Q.minSize.value)c(X,{code:b.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),J.dirty()}if(Q.maxSize!==null){if(X.data.size>Q.maxSize.value)c(X,{code:b.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),J.dirty()}let Y=this._def.valueType;function G(M){let U=new Set;for(let O of M){if(O.status==="aborted")return Q$;if(O.status==="dirty")J.dirty();U.add(O.value)}return{status:J.value,value:U}}let W=[...X.data.values()].map((M,U)=>Y._parse(new aJ(X,M,X.path,U)));if(X.common.async)return Promise.all(W).then((M)=>G(M));else return G(W)}min($,J){return new EQ({...this._def,minSize:{value:$,message:o.toString(J)}})}max($,J){return new EQ({...this._def,maxSize:{value:$,message:o.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}EQ.create=($,J)=>{return new EQ({valueType:$,minSize:null,maxSize:null,typeName:Y$.ZodSet,...V$(J)})};class nQ extends E${constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==g.function)return c(J,{code:b.invalid_type,expected:g.function,received:J.parsedType}),Q$;function X(W,M){return dX({data:W,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,dQ(),A0].filter((U)=>!!U),issueData:{code:b.invalid_arguments,argumentsError:M}})}function Q(W,M){return dX({data:W,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,dQ(),A0].filter((U)=>!!U),issueData:{code:b.invalid_return_type,returnTypeError:M}})}let Y={errorMap:J.common.contextualErrorMap},G=J.data;if(this._def.returns instanceof FQ){let W=this;return EJ(async function(...M){let U=new jJ([]),O=await W._def.args.parseAsync(M,Y).catch((q)=>{throw U.addIssue(X(M,q)),U}),V=await Reflect.apply(G,this,O);return await W._def.returns._def.type.parseAsync(V,Y).catch((q)=>{throw U.addIssue(Q(V,q)),U})})}else{let W=this;return EJ(function(...M){let U=W._def.args.safeParse(M,Y);if(!U.success)throw new jJ([X(M,U.error)]);let O=Reflect.apply(G,this,U.data),V=W._def.returns.safeParse(O,Y);if(!V.success)throw new jJ([Q(O,V.error)]);return V.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new nQ({...this._def,args:V0.create($).rest(p0.create())})}returns($){return new nQ({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,X){return new nQ({args:$?$:V0.create([]).rest(p0.create()),returns:J||p0.create(),typeName:Y$.ZodFunction,...V$(X)})}}class tQ extends E${get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}tQ.create=($,J)=>{return new tQ({getter:$,typeName:Y$.ZodLazy,...V$(J)})};class eQ extends E${_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return c(J,{received:J.data,code:b.invalid_literal,expected:this._def.value}),Q$}return{status:"valid",value:$.data}}get value(){return this._def.value}}eQ.create=($,J)=>{return new eQ({value:$,typeName:Y$.ZodLiteral,...V$(J)})};function w5($,J){return new i0({values:$,typeName:Y$.ZodEnum,...V$(J)})}class i0 extends E${_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),X=this._def.values;return c(J,{expected:A$.joinValues(X),received:J.parsedType,code:b.invalid_type}),Q$}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),X=this._def.values;return c(J,{received:J.data,code:b.invalid_enum_value,options:X}),Q$}return EJ($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return i0.create($,{...this._def,...J})}exclude($,J=this._def){return i0.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...J})}}i0.create=w5;class $X extends E${_parse($){let J=A$.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==g.string&&X.parsedType!==g.number){let Q=A$.objectValues(J);return c(X,{expected:A$.joinValues(Q),received:X.parsedType,code:b.invalid_type}),Q$}if(!this._cache)this._cache=new Set(A$.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=A$.objectValues(J);return c(X,{received:X.data,code:b.invalid_enum_value,options:Q}),Q$}return EJ($.data)}get enum(){return this._def.values}}$X.create=($,J)=>{return new $X({values:$,typeName:Y$.ZodNativeEnum,...V$(J)})};class FQ extends E${unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==g.promise&&J.common.async===!1)return c(J,{code:b.invalid_type,expected:g.promise,received:J.parsedType}),Q$;let X=J.parsedType===g.promise?J.data:Promise.resolve(J.data);return EJ(X.then((Q)=>{return this._def.type.parseAsync(Q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}FQ.create=($,J)=>{return new FQ({type:$,typeName:Y$.ZodPromise,...V$(J)})};class sJ extends E${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=this._def.effect||null,Y={addIssue:(G)=>{if(c(X,G),G.fatal)J.abort();else J.dirty()},get path(){return X.path}};if(Y.addIssue=Y.addIssue.bind(Y),Q.type==="preprocess"){let G=Q.transform(X.data,Y);if(X.common.async)return Promise.resolve(G).then(async(W)=>{if(J.value==="aborted")return Q$;let M=await this._def.schema._parseAsync({data:W,path:X.path,parent:X});if(M.status==="aborted")return Q$;if(M.status==="dirty")return qQ(M.value);if(J.value==="dirty")return qQ(M.value);return M});else{if(J.value==="aborted")return Q$;let W=this._def.schema._parseSync({data:G,path:X.path,parent:X});if(W.status==="aborted")return Q$;if(W.status==="dirty")return qQ(W.value);if(J.value==="dirty")return qQ(W.value);return W}}if(Q.type==="refinement"){let G=(W)=>{let M=Q.refinement(W,Y);if(X.common.async)return Promise.resolve(M);if(M instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(X.common.async===!1){let W=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return Q$;if(W.status==="dirty")J.dirty();return G(W.value),{status:J.value,value:W.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((W)=>{if(W.status==="aborted")return Q$;if(W.status==="dirty")J.dirty();return G(W.value).then(()=>{return{status:J.value,value:W.value}})})}if(Q.type==="transform")if(X.common.async===!1){let G=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!d0(G))return Q$;let W=Q.transform(G.value,Y);if(W instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:W}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((G)=>{if(!d0(G))return Q$;return Promise.resolve(Q.transform(G.value,Y)).then((W)=>({status:J.value,value:W}))});A$.assertNever(Q)}}sJ.create=($,J,X)=>{return new sJ({schema:$,typeName:Y$.ZodEffects,effect:J,...V$(X)})};sJ.createWithPreprocess=($,J,X)=>{return new sJ({schema:J,effect:{type:"preprocess",transform:$},typeName:Y$.ZodEffects,...V$(X)})};class oJ extends E${_parse($){if(this._getType($)===g.undefined)return EJ(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}oJ.create=($,J)=>{return new oJ({innerType:$,typeName:Y$.ZodOptional,...V$(J)})};class Z0 extends E${_parse($){if(this._getType($)===g.null)return EJ(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}Z0.create=($,J)=>{return new Z0({innerType:$,typeName:Y$.ZodNullable,...V$(J)})};class JX extends E${_parse($){let{ctx:J}=this._processInputParams($),X=J.data;if(J.parsedType===g.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}JX.create=($,J)=>{return new JX({innerType:$,typeName:Y$.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...V$(J)})};class QX extends E${_parse($){let{ctx:J}=this._processInputParams($),X={...J,common:{...J.common,issues:[]}},Q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(pQ(Q))return Q.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new jJ(X.common.issues)},input:X.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new jJ(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}QX.create=($,J)=>{return new QX({innerType:$,typeName:Y$.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...V$(J)})};class oX extends E${_parse($){if(this._getType($)!==g.nan){let X=this._getOrReturnCtx($);return c(X,{code:b.invalid_type,expected:g.nan,received:X.parsedType}),Q$}return{status:"valid",value:$.data}}}oX.create=($)=>{return new oX({typeName:Y$.ZodNaN,...V$($)})};var l6=Symbol("zod_brand");class D9 extends E${_parse($){let{ctx:J}=this._processInputParams($),X=J.data;return this._def.type._parse({data:X,path:J.path,parent:J})}unwrap(){return this._def.type}}class aX extends E${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return Q$;if(Y.status==="dirty")return J.dirty(),qQ(Y.value);else return this._def.out._parseAsync({data:Y.value,path:X.path,parent:X})})();else{let Q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return Q$;if(Q.status==="dirty")return J.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:X.path,parent:X})}}static create($,J){return new aX({in:$,out:J,typeName:Y$.ZodPipeline})}}class XX extends E${_parse($){let J=this._def.innerType._parse($),X=(Q)=>{if(d0(Q))Q.value=Object.freeze(Q.value);return Q};return pQ(J)?J.then((Q)=>X(Q)):X(J)}unwrap(){return this._def.innerType}}XX.create=($,J)=>{return new XX({innerType:$,typeName:Y$.ZodReadonly,...V$(J)})};function T5($,J){let X=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function P5($,J={},X){if($)return zQ.create().superRefine((Q,Y)=>{let G=$(Q);if(G instanceof Promise)return G.then((W)=>{if(!W){let M=T5(J,Q),U=M.fatal??X??!0;Y.addIssue({code:"custom",...M,fatal:U})}});if(!G){let W=T5(J,Q),M=W.fatal??X??!0;Y.addIssue({code:"custom",...W,fatal:M})}return});return zQ.create()}var d6={object:p$.lazycreate},Y$;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(Y$||(Y$={}));var p6=($,J={message:`Input not instance of ${$.name}`})=>P5((X)=>X instanceof $,J),_5=nJ.create,x5=c0.create,c6=oX.create,n6=n0.create,v5=iQ.create,i6=KQ.create,o6=pX.create,a6=oQ.create,s6=aQ.create,r6=zQ.create,t6=p0.create,e6=O0.create,$z=cX.create,Jz=iJ.create,Qz=p$.create,Xz=p$.strictCreate,Yz=sQ.create,Gz=A9.create,Wz=rQ.create,Mz=V0.create,Uz=nX.create,Oz=iX.create,Vz=EQ.create,Hz=nQ.create,qz=tQ.create,Kz=eQ.create,zz=i0.create,Ez=$X.create,Fz=FQ.create,Nz=sJ.create,Lz=oJ.create,Rz=Z0.create,Az=sJ.createWithPreprocess,Dz=aX.create,Zz=()=>_5().optional(),Bz=()=>x5().optional(),jz=()=>v5().optional(),Tz={string:($)=>nJ.create({...$,coerce:!0}),number:($)=>c0.create({...$,coerce:!0}),boolean:($)=>iQ.create({...$,coerce:!0}),bigint:($)=>n0.create({...$,coerce:!0}),date:($)=>KQ.create({...$,coerce:!0})};var Sz=Q$;function d7($){if(Iz($)===6)return!0;if($.includes("://")||$.includes("/")||$.includes(":"))return!1;if($==="localhost")return!0;if($.startsWith("*.")){let J=$.slice(2);if(!J.includes(".")||J.startsWith(".")||J.endsWith("."))return!1;let X=J.split(".");return X.length>=2&&X.every((Q)=>Q.length>0)}if($.includes("*"))return!1;return $.includes(".")&&!$.startsWith(".")&&!$.endsWith(".")}var p7='Invalid domain pattern. Must be a valid domain (e.g., "example.com"), a wildcard (e.g., "*.example.com"), or a bracketed IPv6 literal (e.g., "[::1]", "[2001:db8::1]:443"). Overly broad patterns like "*.com" or "*" are not allowed for security reasons.',B9=x.string().refine(d7,{message:p7});function f5($){let J=$.indexOf(":");return!(J!==-1&&$.indexOf(":",J+1)!==-1)||$.startsWith("[")}var wz=x.string().refine(($)=>f5($)&&d7(kX($).hostPattern),{message:p7+' An optional ":port" suffix (1-65535) restricts the entry to that port.'}),Pz=x.string().refine(($)=>{if(!f5($))return!1;let{hostPattern:J}=kX($);return J==="*"||d7(J)},{message:p7+' In deniedDomains a bare "*" (deny-all) is also accepted, and an optional ":port" suffix (1-65535) restricts the entry to that port.'}),sX=x.string().min(1,"Path cannot be empty"),k5=x.string().min(1,"Path cannot be empty").refine(($)=>Cz($),{message:"Binary path must be absolute"}),_z=x.object({socketPath:x.string().min(1).describe("Unix socket path to the MITM proxy"),domains:x.array(B9).min(1).describe('Domains to route through the MITM proxy (e.g., ["api.example.com", "*.internal.org"])')}),xz=x.object({http:x.string().url().optional().describe("Upstream proxy URL for plain HTTP traffic"),https:x.string().url().optional().describe("Upstream proxy URL for HTTPS/CONNECT traffic (falls back to http if unset)"),noProxy:x.string().optional().describe("Comma-separated NO_PROXY list (hostname suffixes and CIDR ranges). Matching destinations connect directly instead of via the parent proxy.")}),y5=x.enum(["deny","mask"]),Z9=x.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"Environment variable name must start with a letter or underscore and contain only letters, digits, and underscores"),b5=x.string().superRefine(($,J)=>{try{let{groupCount:X}=$7($);if(X<1)J.addIssue({code:x.ZodIssueCode.custom,message:"extract must contain at least one capturing group \u2014 group 1 is "+'the credential value to mask (e.g. "token:\\s*(\\S+)").'})}catch(X){J.addIssue({code:x.ZodIssueCode.custom,message:X instanceof Error?X.message:"Credential extract pattern is invalid"})}}),vz=x.object({path:sX.describe("Path to a credential file or directory. Supports the same path forms as filesystem.denyRead (absolute paths and ~ expansion)."),mode:y5.describe("Access mode for this path"),extract:b5.optional().describe('Optional regex for structured masking. Applied globally; capture group 1 of each match is masked, the rest of the file is preserved. If the pattern matches nothing, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),onExtractNoMatch:x.enum(["warn","deny","error"]).optional().describe("What to do when extract matches nothing (or, with decode, no "+'candidate verifies): "warn" (default \u2014 stderr warning, file left '+'readable), "deny" (degrade to mode "deny" \u2014 file unreadable), or '+'"error" (throw at wrap time). Only meaningful with mode "mask" and extract or decode set.'),decode:x.enum(["jwt"]).optional().describe('Optional encoded-credential format. "jwt": decodes recognized JWTs so masking can target fields inside them (see maskClaims). Candidates are located with a built-in JWT regex (or the explicit extract pattern, if set) and verified to actually be JWTs before masking. Without maskClaims, the whole decoded value is treated as the credential and replaced with a structurally valid fake JWT, so client-side token parsing keeps working. If no candidate verifies, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),maskClaims:x.array(x.string().min(1)).optional().describe('Names of top-level payload claims to mask inside each decoded value, instead of replacing the whole token. Each named claim present with a string value gets its own sentinel; all other claims are preserved so claim-reading clients keep working. Requires decode. If no named claim matches in any verified token, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),maskDuplicates:x.boolean().optional().describe("If true, verbatim occurrences of each captured credential value outside the regex-matched spans are also replaced with the "+"corresponding sentinel \u2014 for a secret repeated where the regex "+`does not reach (e.g. in a comment). Matches raw substrings: short or common credential values may corrupt unrelated content, so this is intended for long, high-entropy secrets. With decode, only values that passed verification are scanned; duplicates reuse the verified value's fake without re-verification. Defaults to false. Only meaningful with mode "mask" and extract or decode set; accepted but ignored otherwise.`),injectHosts:x.array(B9).optional().describe("Optional narrowing of where the proxy substitutes this credential. "+"If unset, defaults to network.allowedDomains \u2014 the credential is "+'injected at every reachable host. Only meaningful when mode is "mask"; accepted but ignored for "deny".')}),kz=x.object({name:Z9.describe("Environment variable name"),mode:y5.describe("Access mode for this environment variable"),extract:b5.optional().describe('Optional regex for structured masking. Applied globally; capture group 1 of each match is masked, the rest of the value is preserved. If the pattern matches nothing, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),onExtractNoMatch:x.enum(["warn","deny","error"]).optional().describe('What to do when extract matches nothing: "warn" (default \u2014 stderr '+'warning, variable passes through unmasked), "deny" (variable unset inside the sandbox), or "error" (throw at wrap time). Only meaningful with mode "mask" and extract set.'),decode:x.enum(["jwt"]).optional().describe(`Optional encoded-credential format. "jwt": the variable's whole value is verified to actually be a JWT and replaced with a structurally valid fake JWT so client-side token parsing keeps working; the proxy swaps the whole fake token on egress. If the value does not verify, the variable is left unmasked with a stderr warning (fail-open). Only meaningful when mode is "mask"; accepted but ignored for "deny".`),maskClaims:x.array(x.string().min(1)).optional().describe('Names of top-level payload claims to mask inside the decoded value, instead of replacing the whole token. Each named claim present with a string value gets its own sentinel; all other claims are preserved so claim-reading clients keep working. Requires decode. If no named claim matches, the variable is left unmasked with a stderr warning (fail-open). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),injectHosts:x.array(B9).optional().describe("Optional narrowing of where the proxy substitutes this credential. "+"If unset, defaults to network.allowedDomains \u2014 the credential is "+'injected at every reachable host. Only meaningful when mode is "mask"; accepted but ignored for "deny".')}),fz=x.object({accessKeyIdVar:Z9.describe("Name of the masked env var holding the AWS access key id."),secretAccessKeyVar:Z9.describe("Name of the masked env var holding the AWS secret access key."),sessionTokenVar:Z9.optional().describe("Optional name of the masked env var holding the AWS session token (temporary credentials). When set, the proxy sends the real token as x-amz-security-token on re-signed requests and adds it to the signed header set if the client did not.")}).strict(),l7=x.enum(["deny","passthrough"]),yz=x.object({streaming:l7.optional().describe('Policy for aws-chunked streaming uploads (x-amz-content-sha256: STREAMING-*): per-chunk signatures chain off the seed signature, so re-signing would require rewriting the body. Default "deny".'),presigned:l7.optional().describe('Policy for presigned URLs (X-Amz-Algorithm/X-Amz-Signature in the query, no Authorization header): the signature lives in the URL itself. Default "deny".'),sigv4a:l7.optional().describe('Policy for SigV4A (AWS4-ECDSA-P256-SHA256) asymmetric signatures: there is no shared-key HMAC to recompute. Default "deny".')}).strict(),h5=x.object({files:x.array(vz).optional().describe("Credential files or directories to protect"),envVars:x.array(kz).optional().describe("Environment variables to protect"),allowPlaintextInject:x.boolean().optional().describe("Allow sentinel\u2192real substitution on the plain-HTTP proxy path. "+"Defaults to false: without TLS termination the upstream identity is unverified and the credential travels in cleartext. Set only for trusted-network test fixtures."),awsPairs:x.array(fz).optional().describe("Explicit groupings of masked env vars into AWS credential pairs for SigV4 re-signing, for non-standard variable names. The conventional AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN trio is paired automatically when masked."),sigv4:yz.optional().describe('Policies for AWS SigV4 request shapes the proxy cannot re-sign (streaming, presigned, sigv4a) when they reference a masked credential pair: "deny" (default) or "passthrough".')}).strict(),u5=x.object({allowedDomains:x.array(wz).describe('List of allowed domains (e.g., ["github.com", "*.npmjs.org", "api.example.com:443"]). An optional ":port" suffix restricts the entry to that destination port.'),deniedDomains:x.array(Pz).describe('List of denied domains. Unlike allowedDomains, a bare "*" is accepted here (deny-all). An optional ":port" suffix (e.g., "*:22") restricts the entry to that destination port.'),deniedDomainReasons:x.record(x.string(),x.string().min(1)).optional().describe('Optional model-facing reason keyed by the exact deniedDomains entry it explains (e.g., {"github.com:22": "SSH pushes to GitHub are blocked; use an https remote"}). Reported in the <sandbox_violations> line when that entry denies a connection; entries without one use a generic reason. Keys are matched by exact entry string, so a key with no matching deniedDomains entry never fires.'),strictAllowlist:x.boolean().optional().describe("If true, hosts not in allowedDomains are denied without consulting the ask callback. Set this when allowedDomains is policy enforcement, not a prompt-suppression hint."),allowUnixSockets:x.array(x.string()).optional().describe("macOS only: Unix socket paths to allow. Ignored on Linux (seccomp cannot filter by path)."),allowAllUnixSockets:x.boolean().optional().describe("If true, allow all Unix sockets (disables blocking on both platforms)."),allowLocalBinding:x.boolean().optional().describe("Whether to allow binding to local ports (default: false)"),allowMachLookup:x.array(x.string().refine(($)=>{return!($.endsWith("*")?$.slice(0,-1):$).includes("*")},{message:'Wildcards are only allowed as a single trailing "*" (e.g., "com.example.*" or "*" for all services).'})).optional().describe('macOS only: Additional XPC/Mach service names to allow looking up. Supports trailing-wildcard prefix matching (e.g., "2BUA8C4S2C.com.1password.*"). Needed for tools like 1Password CLI, Playwright, or the iOS Simulator that communicate via XPC.'),httpProxyPort:x.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:x.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."),mitmProxy:_z.optional().describe("Optional MITM proxy configuration. Routes matching domains through an upstream proxy via Unix socket while SRT still handles allow/deny filtering."),filterRequest:x.custom(($)=>typeof $==="function",{message:"filterRequest must be a function"}).optional().describe("Per-request filter callback. Receives the parsed HTTP request (web-standard Request) and returns {action, reason?}. Denied requests get a 403 with the reason. If the callback throws, the request is denied. Applies to plain HTTP through the proxy and, when tlsTerminate is configured, to terminated HTTPS. SRT does not provide a policy language; library consumers own matching."),tlsTerminate:x.object({caCertPath:x.string().min(1).optional().describe("Path to a PEM-encoded CA certificate. The sandboxed child is configured to trust this CA, and the TLS-terminating proxy uses it to sign per-host certificates. If omitted, on Windows SRT generates-if-absent a persistent CA under %ProgramData%\\sandbox-runtime\\ca\\ and trusts it in the sandbox user's Root store; on other platforms SRT generates an ephemeral CA into a temp directory for the lifetime of the session."),caKeyPath:x.string().min(1).optional().describe("Path to the PEM-encoded private key for caCertPath."),excludeDomains:x.array(B9).optional().describe("Domain patterns (same syntax as allowedDomains) whose HTTPS connections are NOT terminated. Matching CONNECTs are opaque byte tunnels: still subject to the allow/deny domain lists, but the sandboxed client completes its own TLS handshake with the upstream, so filterRequest and credential injection do not apply to their HTTPS traffic (plain-HTTP requests to the same hosts keep the normal request pipeline). Use for hosts the proxy must not re-originate: mTLS upstreams (only the client holds the client certificate) and clients that pin the upstream certificate and would reject the MITM CA. Hosts still need to be reachable via allowedDomains; this list only changes how they are tunnelled."),extraCaCertPaths:x.array(x.string().min(1)).optional().describe("Paths to PEM CA certificate files appended to the trust bundle the sandboxed child is pointed at, after the MITM CA and the host's regular roots. Use for site-local roots (e.g. an internal mTLS CA) presented by excluded/passthrough hosts, so the child can verify them itself. Only the CERTIFICATE blocks of each file are copied; files that are missing, unreadable, or contain no PEM CERTIFICATE block are skipped (with a debug log), so paths that exist on only some hosts are safe to list.")}).refine(($)=>!$.caCertPath===!$.caKeyPath,{message:"caCertPath and caKeyPath must be provided together"}).optional().describe("[EXPERIMENTAL] Enable in-process TLS termination so HTTPS request/response bodies are visible to SRT. Provide a CA cert+key, or omit both to have SRT generate an ephemeral one."),parentProxy:xz.optional().describe("Upstream HTTP proxy for outbound connections. When set, SRT's proxy tunnels non-mitmProxy traffic through this parent instead of connecting directly. Falls back to HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars if unset.")}),g5=x.object({disabled:x.boolean().optional().describe("Disable all filesystem policy enforcement. When true, no read or write rules are emitted: denyRead/allowRead/allowWrite/denyWrite are ignored, and the built-in mandatory write protections (.git/hooks, .git/config, shell rc files, .mcp.json, .vscode/.idea, .claude/commands, .claude/agents) are NOT applied. Use only when the sandboxed process is trusted with full host filesystem access. Network and credential-env restrictions still apply. On Linux, /dev is still replaced by the bwrap minimal devtmpfs."),denyRead:x.array(sX).describe("Paths denied for reading"),allowRead:x.array(sX).optional().describe("Paths to re-allow reading within denied regions (takes precedence over denyRead). Use with denyRead to deny a broad region then allow back specific subdirectories."),allowWrite:x.array(sX).describe("Paths allowed for writing"),denyWrite:x.array(sX).describe("Paths denied for writing (takes precedence over allowWrite)"),allowGitConfig:x.boolean().optional().describe("Allow writes to .git/config files (default: false). Enables git remote URL updates while keeping .git/hooks protected.")}),m5=x.record(x.string(),x.array(x.string())).describe('Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands'),l5=x.object({command:x.string().describe("The ripgrep command to execute"),args:x.array(x.string()).optional().describe("Additional arguments to pass before ripgrep args"),argv0:x.string().optional().describe("Override argv[0] when spawning (for multicall binaries that dispatch on argv[0])")}),d5=x.object({safeDirectories:x.array(x.string()).default([]).describe("Directories git should treat as safe (`safe.directory`) even though they're owned by a different user inside the sandbox. Use for the repo top-level when launching from a subdirectory. Does NOT grant write.")}),p5=x.object({path:x.string().min(1).describe("Path to the srt-win binary. Pass the exported VENDORED_SRT_WIN_EXE constant to use the packaged vendor/srt-win/<arch>/srt-win.exe (see its WARNING: in a dev checkout that file may sit inside your sandbox write grant). The binary is spawned with the `--srt-win` argv[1] sentinel so a multicall dispatcher can route to srt-win's CLI.")}),c5=x.object({sandboxUser:x.string().min(1).max(20,"Windows local usernames are limited to 20 characters").optional().describe("Name for the dedicated sandbox user account that `srt-win install` creates and the sandboxed child runs as. Default: `srt-sandbox`. Install refuses if an account by this name already exists and srt-win did not create it (it will not rotate the password of an account it does not own). Must match what `srt-win install --sandbox-user` was run with."),sublayerGuid:x.string().uuid().optional().describe("WFP sublayer GUID under which the filters were installed. Omit to use the srt-win compile-time default. Set this when filters were installed by enterprise tooling under a custom sublayer."),wfpSublayerGuid:x.string().uuid().optional().describe("Deprecated alias for sublayerGuid."),proxyPortRange:x.tuple([x.number().int().min(1),x.number().int().max(65535)]).refine(([$,J])=>$<=J&&J-$<=64,{message:"low must be \u2264 high and range width \u2264 64"}).optional().describe("Inclusive [low, high] port range the JS mux proxy listeners bind inside. MUST match the range passed to `srt-win install "+"--proxy-port-range` (default 60080\u201360089) \u2014 the WFP loopback "+"permit only covers ports in that range."),srtWin:p5.optional().describe("How to locate/invoke the srt-win helper binary. `srtWin.path` is "+"required to use the Windows sandbox \u2014 your own (multicall) binary, "+"or the exported VENDORED_SRT_WIN_EXE constant for the packaged exe.")}),bz=x.object({applyPath:x.string().optional().describe("Path to the apply-seccomp binary"),argv0:x.string().optional().describe("Invoke apply-seccomp as a multicall binary that dispatches on the ARGV0 environment variable. When set, applyPath is used verbatim (no existence check) and the invocation inside bwrap is prefixed with ARGV0=<this value>. The caller is responsible for ensuring applyPath resolves inside the bwrap namespace and that the target binary implements the apply-seccomp interface when ARGV0 matches.")}),hz=x.object({network:u5.describe("Network restrictions configuration"),filesystem:g5.describe("Filesystem restrictions configuration"),credentials:h5.optional().describe("Credential handling configuration. Only the explicitly declared files and environment variables are restricted."),ignoreViolations:m5.optional().describe("Optional configuration for ignoring specific violations"),enableWeakerNestedSandbox:x.boolean().optional().describe("Enable weaker nested sandbox mode (for Docker environments)"),runAsUid:x.number().int().nonnegative().optional().describe("ARA: uid to drop the sandboxed command to (bwrap --uid)"),runAsGid:x.number().int().nonnegative().optional().describe("ARA: gid to drop the sandboxed command to (bwrap --gid)"),runAsHostUid:x.number().int().positive().optional().describe("ARA: real host uid used to launch the sandboxed bwrap child"),runAsHostGid:x.number().int().positive().optional().describe("ARA: real host gid used to launch the sandboxed bwrap child"),runAsHostHome:x.string().min(1).optional().describe("ARA: HOME set inside a real-host-uid sandbox child"),runAsHostUser:x.string().min(1).optional().describe("ARA: USER and LOGNAME set inside a real-host-uid sandbox child"),enableWeakerNetworkIsolation:x.boolean().optional().describe("Enable weaker network isolation to allow access to com.apple.trustd.agent (macOS only). This is needed for Go programs (gh, gcloud, terraform, kubectl, etc.) to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Enabling this opens a potential data exfiltration vector through the trustd service. Only enable if you need Go TLS verification."),allowAppleEvents:x.boolean().optional().describe("Allow sending Apple Events and Launch Services open requests from the sandbox (macOS only). Needed for open, osascript, and anything that opens URLs or scripts other apps via AppleScript. This removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt (launched apps are not subject to the sandbox filesystem or network restrictions), and can script running apps subject to TCC automation consent. Default: false."),ripgrep:l5.optional().describe('Custom ripgrep configuration (default: { command: "rg" })'),mandatoryDenySearchDepth:x.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:x.boolean().optional().describe("Allow pseudo-terminal (pty) operations (macOS only)"),seccomp:bz.optional().describe("Custom seccomp binary paths (Linux only)."),bwrapPath:k5.optional().describe('Linux only: absolute path to the bwrap (bubblewrap) binary. When set, this path is used directly instead of resolving "bwrap" via PATH.'),socatPath:k5.optional().describe('Linux only: absolute path to the socat binary. When set, this path is used directly instead of resolving "socat" via PATH.'),windows:c5.optional().describe("Windows-specific settings (WFP sublayer, proxy port range)."),git:d5.optional().describe("Git configuration to inject via GIT_CONFIG_* env vars (cross-platform). `safeDirectories` marks paths as `safe.directory` without adding them to `filesystem.allowWrite`.")}).superRefine(($,J)=>{let X=$.credentials;if(!X)return;let Q=$.network.allowedDomains.map(fX),Y=(U,O)=>{for(let[V,H]of U.entries())if(!q9(H,Q))J.addIssue({code:x.ZodIssueCode.custom,path:[...O,V],message:`injectHosts entry "${H}" is not reachable via `+`network.allowedDomains \u2014 add "${H}" (or a covering wildcard) to allowedDomains, or remove it from injectHosts.`})},G=!1,W=(U,O)=>{if(U.injectHosts)Y(U.injectHosts,[...O,"injectHosts"]);if(U.mode!=="mask")return;G=!0;let V=$.network.tlsTerminate?.excludeDomains;if(V?.length){if(U.injectHosts){for(let[H,q]of U.injectHosts.entries())if(q9(q,V))J.addIssue({code:x.ZodIssueCode.custom,path:[...O,"injectHosts",H],message:`injectHosts entry "${q}" is entirely covered by network.tlsTerminate.excludeDomains. Credential injection only runs on TLS-terminated connections, so this host would receive the placeholder instead of the credential. Remove it from one of the two lists.`})}else if(Q.length>0&&Q.every((H)=>q9(H,V)))J.addIssue({code:x.ZodIssueCode.custom,path:O,message:"This masked credential has no injectHosts, so it defaults "+"to network.allowedDomains \u2014 but "+"network.tlsTerminate.excludeDomains covers every allowed domain, so it could never be injected anywhere. Credential injection only runs on TLS-terminated connections."})}if(U.injectHosts!==void 0&&U.injectHosts.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:O,message:"injectHosts is explicitly empty \u2014 the credential would be "+"masked but never injected. Omit injectHosts to default to network.allowedDomains, or list the intended hosts."})};for(let[U,O]of(X.envVars??[]).entries()){if(W(O,["credentials","envVars",U]),O.maskClaims!==void 0&&O.decode===void 0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","envVars",U,"maskClaims"],message:"maskClaims requires decode \u2014 it names claims inside the "+'decoded payload. Set decode (e.g. "jwt"), or remove maskClaims to mask the whole value.'});if(O.maskClaims!==void 0&&O.maskClaims.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","envVars",U,"maskClaims"],message:"maskClaims is explicitly empty \u2014 no claim would ever be "+"masked. Omit maskClaims to mask the whole token, or list the claims to protect."})}for(let[U,O]of(X.files??[]).entries()){if(W(O,["credentials","files",U]),O.maskClaims!==void 0&&O.decode===void 0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",U,"maskClaims"],message:"maskClaims requires decode \u2014 it names claims inside the "+'decoded payload. Set decode (e.g. "jwt"), or remove maskClaims to mask the extracted value whole.'});if(O.maskClaims!==void 0&&O.maskClaims.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",U,"maskClaims"],message:"maskClaims is explicitly empty \u2014 no claim would ever be "+"masked. Omit maskClaims to mask the whole token, or list the claims to protect."});if(O.mode==="mask"&&O.path.endsWith("/"))J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",U,"path"],message:`Credential mode "mask" applies to a single file, not a directory. Use mode "deny" for "${O.path}", or point at the credential file inside it.`})}let M=new Set;for(let[U,O]of(X.awsPairs??[]).entries()){let V=[["accessKeyIdVar",O.accessKeyIdVar],["secretAccessKeyVar",O.secretAccessKeyVar]];if(O.sessionTokenVar!==void 0)V.push(["sessionTokenVar",O.sessionTokenVar]);for(let[H,q]of V){let F=["credentials","awsPairs",U,H];if(M.has(q)){J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" appears in more than one awsPairs slot (within `+"or across pairs) \u2014 each variable can fill exactly one slot."});continue}M.add(q);let K=(X.envVars??[]).find((R)=>R.name===q);if(K===void 0||K.mode!=="mask")J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" does not reference a credentials.envVars entry `+'with mode "mask" \u2014 an AWS pair links already-masked '+"variables; add the entry (masking is the opt-in for SigV4 re-signing)."});else if(K.extract!==void 0||K.decode!==void 0)J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" uses extract/decode, but an AWS pair member must be masked whole-value: the SigV4 trigger is an exact match of the fake access key id, and the signer needs the entire real value.`})}}if(G&&$.network.tlsTerminate===void 0&&!X.allowPlaintextInject)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials"],message:"Credential masking requires network.tlsTerminate so substitution runs only over a verified TLS connection. Enable tlsTerminate, or set credentials.allowPlaintextInject to opt out (not recommended)."})});export{p4 as windowsTrustCaAsync,BK as windowsTrustCa,n4 as windowsStateDir,L7 as windowsInstallInstructions,Z7 as verifyWindowsWfpEgress,IX as validateCaPair,SK as uninstallWindowsSandbox,I7 as stampWindowsAcl,H9 as revokeWindowsAcl,V9 as restoreWindowsAcl,CJ as resolveSrtWin,IK as parseWindowsSandboxError,W9 as parseWindowsBinShell,MX as isUncPath,TK as installWindowsSandboxAsync,jK as installWindowsSandbox,C7 as grantWindowsAcl,S9 as getWslVersion,d4 as getWindowsWfpStatusAsync,l4 as getWindowsWfpStatus,vX as getWindowsSandboxUserStatusAsync,B7 as getWindowsSandboxUserStatus,j7 as getWindowsSandboxCaCert,ZK as getSrtWinPath,NQ as getDefaultWritePaths,bY as generateCa,O9 as expandWindowsFsPaths,T7 as ensurePersistentWindowsCa,m4 as checkWindowsSandboxStatusAsync,g4 as checkWindowsSandboxStatus,w7 as checkWindowsDependenciesAsync,yQ as certThumbprint,UX as buildGitConfigEnv,F$ as WindowsSandboxError,c5 as WindowsConfigSchema,DK as VENDORED_SRT_WIN_EXE,p5 as SrtWinConfigSchema,X9 as SandboxViolationStore,hz as SandboxRuntimeConfigSchema,F6 as SandboxManager,y4 as SRT_WIN_DISPATCH_ARG1,l5 as RipgrepConfigSchema,u5 as NetworkConfigSchema,m5 as IgnoreViolationsConfigSchema,d5 as GitConfigSchema,g5 as FilesystemConfigSchema,G9 as DEFAULT_WINDOWS_PROXY_PORT_RANGE,h5 as CredentialsConfigSchema};
|
|
69
|
+
No logout is needed: the WFP filter keys on the dedicated \`srt-sandbox\` user's SID, so your network is unaffected.`}function E5($){try{return{status:"fulfilled",value:$()}}catch(J){return{status:"rejected",reason:J}}}function k5($,J,X){let Q=[],Y=[];if(J.status==="rejected")return Q.push(`srt-win user status failed: ${J.reason.message}`),{errors:Q,warnings:Y};let G=J.value;if(!G.provisioned||!G.credPresent)Q.push(`Sandbox user is not provisioned (user=${G.provisioned}, cred=${G.credPresent}). `+u7($));let W=X();if(W.status==="rejected")return Q.push(`srt-win wfp status failed: ${W.reason.message}`),{errors:Q,warnings:Y};let U=W.value;if(U.state==="cannot-read")Z(`[Sandbox Windows] wfp status cannot-read (non-elevated): ${U.hint}`);else if(U.state!=="installed"){if(G.provisioned&&G.credPresent)Q.push(`WFP filters not installed under sublayer ${$??"(default)"}. `+u7($))}else if(U.portRange)Z(`[Sandbox Windows] WFP installed: ${U.filters} filters, proxy port range ${U.portRange[0]}-${U.portRange[1]}`);return{errors:Q,warnings:Y}}function f5($={}){let J;try{J=$.srtWin??wJ()}catch(X){return{errors:[X.message],warnings:[]}}return Z(`[Sandbox Windows] using srt-win at ${J.exe}`),k5($.sublayerGuid,E5(()=>d7({srtWin:J})),()=>E5(()=>T5({sublayerGuid:$.sublayerGuid,srtWin:J})))}async function s7($={}){let J;try{J=$.srtWin??wJ()}catch(Y){return{errors:[Y.message],warnings:[]}}Z(`[Sandbox Windows] using srt-win at ${J.exe}`);let[X,Q]=await Promise.allSettled([dX({srtWin:J}),S5({sublayerGuid:$.sublayerGuid,srtWin:J})]);return k5($.sublayerGuid,X,()=>Q)}import{isIP as PK}from"net";function cX($){if($.startsWith("[")){let Q=$.indexOf("]");if(Q===-1)return{hostPattern:$,port:void 0};let Y=$.slice(1,Q),G=jJ(Y)??Y,W=$.slice(Q+1);if(W==="")return{hostPattern:G,port:void 0};let U=y5(W.startsWith(":")?W.slice(1):"");return U===void 0?{hostPattern:$,port:void 0}:{hostPattern:G,port:U}}let J=$.lastIndexOf(":");if(J===-1)return{hostPattern:$,port:void 0};if($.indexOf(":")!==J)return{hostPattern:jJ($)??$,port:void 0};let X=y5($.slice(J+1));if(X===void 0)return{hostPattern:$,port:void 0};return{hostPattern:$.slice(0,J),port:X}}function y5($){if(!/^[1-9][0-9]{0,4}$/.test($))return;let J=Number($);return J>65535?void 0:J}function nX($){return cX($).hostPattern}function B0($,J){let X=$.toLowerCase();if(J==="*")return!0;if(J.startsWith("*.")){if(PK(dJ(X)))return!1;let Q=J.substring(2).toLowerCase();return X.endsWith("."+Q)}return X===J.toLowerCase()}function iX($,J,X){let{hostPattern:Q,port:Y}=cX(X);if(Y!==void 0&&Y!==J)return!1;return B0($,Q)}function I9($,J){let X=J.map(nX);if(!$.startsWith("*."))return X.some((Y)=>B0($,Y));let Q=$.slice(2).toLowerCase();return X.some((Y)=>{if(!Y.startsWith("*."))return!1;let G=Y.slice(2).toLowerCase();return Q===G||Q.endsWith("."+G)})}function b5($,J,X,Q){if(!mQ(J))return{verdict:"deny",reason:"malformed host"};let Y=jJ(J)??J;for(let G of $.deniedDomains)if(iX(Y,X,G))return{verdict:"deny",reason:$.deniedDomainReasons?.[G]??"host is on the deny list",rule:G};for(let G of $.allowedDomains)if(iX(Y,X,G))return{verdict:"allow",rule:G};if(!Q||$.strictAllowlist)return{verdict:"deny",reason:"host is not on the allow list"};return{verdict:"ask"}}import{EOL as r7}from"os";import{dirname as t7}from"path";var b,sX,rX,tX,uJ,m0,oX,h5=!1,C9,nQ,d0,u$,c0,iQ,l0,w9,u5=!1,eX,zQ=new L9,EQ=new z7,_9=new A7,P9=new L7;function xK(){if(h5)return;let $=()=>GG().catch((J)=>{Z(`Cleanup failed in registerCleanup ${J}`,{level:"error"})});process.once("exit",$),process.once("SIGINT",$),process.once("SIGTERM",$),h5=!0}var vK=1024,KQ=new Map;function c5($,J){let X=J?.commandId,Q=J?.commandText??$;if(X===void 0||X===Q)return;let Y=t0(PJ(X));KQ.delete(Y),KQ.set(Y,Q);while(KQ.size>vK){let G=KQ.keys().next().value;if(G===void 0)break;KQ.delete(G)}}function g5($){return KQ.get($)??$}function e7($,J){let X=J?(()=>{let Q=t0(J);return KQ.get(Q)??k7(Q)})():void 0;if(dQ($,X,b?.ignoreViolations))return;zQ.addViolation({line:$,encodedCommand:J,command:X,timestamp:new Date})}function kK($){try{let J=new URL($);return`${J.origin}${J.pathname}${J.search?"?\u2026":""}`}catch{let J=$.indexOf("?");return J===-1?$:`${$.slice(0,J)}?\u2026`}}async function m5($,J,X,Q){let Y=(W)=>{return e7(`deny network-outbound ${J}:${$} (${W})`,Q),!1};if(!b)return Z("No config available, denying network request"),Y("sandbox policy unavailable");let G=b5(b.network,J,$,X!==void 0);if(G.verdict==="allow")return Z(`Allowed by config rule: ${J}:${$}`),!0;if(G.verdict==="deny"){if(G.reason==="malformed host")Z(`Denying malformed host: ${JSON.stringify(J)}:${$}`,{level:"error"});else if(G.rule!==void 0)Z(`Denied by config rule: ${J}:${$}`);else Z(`No matching config rule, denying: ${J}:${$}`);return Y(G.reason)}Z(`No matching config rule, asking user: ${J}:${$}`);try{if(await X({host:J,port:$}))return Z(`User allowed: ${J}:${$}`),!0;return Z(`User denied: ${J}:${$}`),Y("user denied")}catch(W){return Z(`Error in permission callback: ${W}`,{level:"error"}),Y("permission prompt failed")}}function fK(){if(!b?.credentials)return;return($,J)=>{EQ.substituteInHeaders($,J,B0)}}function yK(){if(!b?.credentials)return;return($)=>EQ.sentinelsForHost($,B0)}function bK(){if(!b?.credentials)return;return($,J,X,Q)=>w4(_9,b?.credentials?.sigv4,B0)($,J,X,Q)}function hK($){if(!b?.network.mitmProxy)return;let{socketPath:J,domains:X}=b.network.mitmProxy,Q=jJ($)??$;for(let Y of X)if(B0(Q,Y))return Z(`Host ${$} matches MITM pattern ${Y}`),J;return}function uK($){let J=b?.network.tlsTerminate?.excludeDomains;if(!J?.length)return!0;let X=jJ($)??$;for(let Q of J){if(!B0(X,Q))continue;Z(`Host ${$} matches tlsTerminate.excludeDomains pattern ${Q}; skipping TLS termination`);let Y=EQ.namesInjectableAt(X,B0);if(Y.length>0)Z(`tlsTerminate.excludeDomains: masked credential(s) ${Y.join(", ")} are configured for injection at ${$}, but its connections are not terminated, so the upstream will receive the placeholder`,{level:"error"});return!1}return!0}async function gK($,J){let X=fK(),Q=yK();sX=G4({filter:(U,M,O,V)=>m5(U,M,$,V),getMitmSocketPath:hK,mitmCA:u$,shouldTerminateTLS:uK,filterRequest:b?.network.filterRequest,onFilterRequestDenied:({method:U,url:M,reason:O,encodedCommand:V})=>{e7(`deny http-request ${U} ${kK(M)} (${O})`,V)},mutateHeaders:X,mutateHeadersPlaintext:b?.credentials?.allowPlaintextInject?X:void 0,getBodySubstitutions:Q,getBodySubstitutionsPlaintext:b?.credentials?.allowPlaintextInject?Q:void 0,planSigv4:bK(),parentProxy:d0,proxyAuthToken:c0}),rX=z4({filter:(U,M,O)=>m5(U,M,$,O),parentProxy:d0,proxyAuthToken:c0,probeUnauthenticated:async(U,M)=>{if(!b)return{};let O=jJ(M)??M;for(let V of b.network.deniedDomains)if(iX(O,U,V)){let H=b.network.deniedDomainReasons?.[V]??"host is on the deny list";return e7(`deny network-outbound ${M}:${U} (${H})`,void 0),{deniedReason:H}}return{}}}),tX=N4({httpServer:sX,handleSocksConnection:(U)=>rX.handleConnection(U),httpBackendPortRange:J});let Y=tX,G=await Y.listenHttpBackend();await Y9(Y.server,(U)=>Y.server.listen(U,"127.0.0.1"),J,G!==void 0?new Set([G]):new Set);let W=Y.getPort();if(W===void 0)throw Error("Failed to get mux proxy server port");return Y.unref(),Z(`Mux proxy (HTTP+SOCKS) listening on localhost:${W}`),W}async function mK($,J,X=!1){if(m0){await m0;return}if(b=$,d0=X7($.network.parentProxy),d0)Z(`Parent proxy configured: http=${W7(d0.httpUrl)} https=${W7(d0.httpsUrl)}`);if($.network.tlsTerminate&&$.network.mitmProxy)throw Error("network.tlsTerminate and network.mitmProxy are mutually exclusive");let Q=$.network.tlsTerminate,Y=x$()==="windows"&&Q!==void 0&&!Q.caCertPath&&!Q.caKeyPath;if(u$=Q&&!Y?r8(Q):void 0,u$&&$.runAsHostUid!==void 0&&x$()==="linux"){if(p0.chmodSync(t7(u$.trustBundlePath),457),p0.chmodSync(u$.trustBundlePath,420),u$.ephemeral)p0.chmodSync(t7(u$.certPath),457),p0.chmodSync(u$.certPath,420)}let G=await o5();if(G.errors.length>0)throw Error(`Sandbox dependencies not available: ${G.errors.join(", ")}`);if(X&&x$()==="macos")C9=V5(zQ.addViolation.bind(zQ),b.ignoreViolations,g5),Z("Started macOS sandbox log monitor");if(X&&x$()==="linux")nQ=K5(zQ.addViolation.bind(zQ),{allowWritePaths:[...DQ($.runAsHostHome),...b.filesystem.allowWrite],denyWritePaths:b.filesystem.denyWrite,ignoreViolations:b.ignoreViolations,resolveCommandText:g5,consumerUid:$.runAsHostUid,consumerGid:$.runAsHostGid}),nQ.ready,Z("Started Linux seccomp violation monitor");if(xK(),x$()==="windows"){eX=wJ($.windows?.srtWin);let W=eX,U=await dX({srtWin:W});if(!U.provisioned||!U.credPresent)throw b=void 0,new L$("not_provisioned",`Windows sandbox user is not provisioned (user=${U.provisioned}, cred=${U.credPresent}). Run \`npx sandbox-runtime windows-install\` (one UAC prompt) to provision it.`);if(!u5){try{await p7({proxyPortRange:$.windows?.proxyPortRange,srtWin:W})}catch(M){throw b=void 0,M}u5=!0}if(Y&&Q)try{let M=await n7({status:U,srtWin:W});u$=r8({caCertPem:M.certPem,caKeyPem:M.keyPem,caCertPath:M.certPath,caKeyPath:M.keyPath,extraCaCertPaths:Q.extraCaCertPaths})}catch(M){throw b=void 0,M}if(Q&&u$&&!Y){let M=c7(U),O=gQ(u$.certPem);if(!M)throw b=void 0,new L$("trust_ca_not_installed",`tlsTerminate on Windows requires the sandbox to be installed with this CA (thumb=${O}): run \`srt-win user trust-ca ${u$.certPath}\`. Per-exec installs into the sandbox user's Root store are not supported.`);if(M.thumb!==O)throw b=void 0,new L$("trust_ca_thumbprint_mismatch",`tlsTerminate on Windows: the sandbox's installed CA (thumb=${M.thumb}) doesn't match this session's CA (thumb=${O}). Run \`srt-win user trust-ca ${u$.certPath}\` to update it.`)}try{let M=nK($);if(u$)M.grantRead.push(t7(u$.trustBundlePath));if(!U.sid)throw Error("sandbox user SID missing from `srt-win user status` (provisioned but in an inconsistent state)");let O=U.sid;if(l0=O,M.grantRead.length>0||M.grantWrite.length>0)a7({sandboxUserSid:O,read:M.grantRead,write:M.grantWrite,srtWin:W});if(M.denyRead.length>0||M.denyWrite.length>0)o7({sandboxUserSid:O,denyRead:M.denyRead,denyWrite:M.denyWrite,srtWin:W});if(M.grantRead.length>0||M.grantWrite.length>0||M.denyRead.length>0||M.denyWrite.length>0)iQ=M,Z(`[Sandbox Windows] fs applied: ${M.grantWrite.length} grantWrite, ${M.grantRead.length} grantRead, ${M.denyRead.length} denyRead, ${M.denyWrite.length} denyWrite`);w9=s5($)}catch(M){if(l0)S9({sandboxUserSid:l0,srtWin:W}),T9({sandboxUserSid:l0,srtWin:W});throw l0=void 0,b=void 0,M}}m0=(async()=>{try{let W=x$()==="windows"?b.windows?.proxyPortRange??R9:void 0;c0=b.network.httpProxyPort!==void 0?void 0:_K(16).toString("hex");let M=b.network.httpProxyPort===void 0||b.network.socksProxyPort===void 0?await gK(J,W):void 0,O=b.network.httpProxyPort??M,V=b.network.socksProxyPort??M;if(u$&&M!==void 0&&x$()==="windows")u$.crlUrl=`http://127.0.0.1:${M}${iY}`;if(b.network.httpProxyPort!==void 0)Z(`Using external HTTP proxy on port ${O}`);if(b.network.socksProxyPort!==void 0)Z(`Using external SOCKS proxy on port ${V}`);let H;if(x$()==="linux")H=await Q5(O,V,b.socatPath,b.runAsHostUid,b.runAsHostGid);let q={httpProxyPort:O,socksProxyPort:V,linuxBridge:H};return uJ=q,Z("Network infrastructure initialized"),q}catch(W){throw m0=void 0,uJ=void 0,GG().catch((U)=>{Z(`Cleanup failed in initializationPromise ${U}`,{level:"error"})}),W}})(),await m0}function n5(){let $=x$();if($==="linux")return m9()!=="1";return $==="macos"||$==="windows"}function lK(){return b!==void 0}function i5($){if(!n5())return{done:{errors:["Unsupported platform"],warnings:[]}};let J=[],X=[],Q=x$();if(Q==="linux"){let Y=$??b?.ripgrep??{command:"rg"};if(R0(Y.command)===null)J.push(`ripgrep (${Y.command}) not found`);let G=J5({seccompConfig:b?.seccomp,bwrapPath:b?.bwrapPath,socatPath:b?.socatPath});J.push(...G.errors),X.push(...G.warnings)}else if(Q==="windows"){let Y;try{Y=wJ(b?.windows?.srtWin)}catch(G){return J.push(G.message),{done:{errors:J,warnings:X}}}return{windows:{sublayerGuid:b?.windows?.sublayerGuid??b?.windows?.wfpSublayerGuid,srtWin:Y}}}return{done:{errors:J,warnings:X}}}function pK($){let J=i5($);if("done"in J)return J.done;return f5(J.windows)}async function o5($){let J=i5($);if("done"in J)return J.done;return s7(J.windows)}function JG($,J){if(!$)return{denyReadPaths:[],unsetEnvVars:[],setEnvVars:{},maskedFileBinds:[],maskedFileStoreDir:void 0};let X=x9($),Q=[...new Set((J??[]).map(nX))],Y=[];for(let V of $.envVars??[])if(V.mode==="deny")Y.push(V.name);let{setEnvVars:G,degradeToUnsetNames:W}=j4($.envVars??[],Q,EQ);Y.push(...W),C4($.envVars??[],$.awsPairs,Q,G,_9);let U=$.files??[],{binds:M,degradeToDenyPaths:O}=B4(U,Q,EQ,P9);return{denyReadPaths:[...new Set([...X,...O])],unsetEnvVars:[...new Set(Y)],setEnvVars:G,maskedFileBinds:M,maskedFileStoreDir:P9.dirPath}}function x9($){let J=$?.files??[];return[...new Set(J.filter((X)=>X.mode==="deny").map((X)=>X.path))]}function a5($,J){return[...new Set([...$,...J.denyReadPaths])]}function dK(){if(!b||b.filesystem.disabled)return{denyOnly:[],allowWithinDeny:[]};let $=a5(b.filesystem.denyRead,JG(b.credentials,b.network.allowedDomains)),J=[];for(let Q of $){let Y=E0(Q);if(x$()==="linux"&&NJ(Y)){let G=e0(Q);Z(`[Sandbox] Expanded glob pattern "${Q}" to ${G.length} paths on Linux`),J.push(...G)}else J.push(Y)}let X=[];for(let Q of b.filesystem.allowRead??[]){let Y=E0(Q);if(x$()==="linux"&&NJ(Y)){let G=e0(Q);Z(`[Sandbox] Expanded allowRead glob pattern "${Q}" to ${G.length} paths on Linux`),X.push(...G)}else X.push(Y)}return{denyOnly:J,allowWithinDeny:X}}function cK(){if(!b)return{allowOnly:DQ(),denyWithinAllow:[]};if(b.filesystem.disabled)return{allowOnly:["/"],denyWithinAllow:[]};let $=b.filesystem.allowWrite.map((Q)=>E0(Q)).filter((Q)=>{if(x$()==="linux"&&NJ(Q))return Z(`Skipping glob pattern on Linux/WSL: ${Q}`),!1;return!0}),J=b.filesystem.denyWrite.map((Q)=>E0(Q)).filter((Q)=>{if(x$()==="linux"&&NJ(Q))return Z(`Skipping glob pattern on Linux/WSL: ${Q}`),!1;return!0});return{allowOnly:[...DQ($G()),...$],denyWithinAllow:J}}function nK($){let J=$.filesystem;if(J?.disabled)return{grantRead:[],grantWrite:[],denyRead:[],denyWrite:[]};let X=j9,Q=X([...new Set([...J?.denyRead??[],...x9($.credentials)])],{mode:"deny"}),Y=X(J?.denyWrite??[],{mode:"deny"});return{grantRead:X(J?.allowRead??[],{mode:"grant"}),grantWrite:X(J?.allowWrite??[],{mode:"grant"}),denyRead:Q,denyWrite:Y}}function s5($){return{disabled:$.filesystem.disabled??!1,denyRead:[...$.filesystem.denyRead],denyWrite:[...$.filesystem.denyWrite],allowRead:[...$.filesystem.allowRead??[]],allowWrite:[...$.filesystem.allowWrite],credFiles:x9($.credentials)}}function aX($,J){if($.length!==J.length)return!1;let X=new Set($);return J.every((Q)=>X.has(Q))}function iK($,J){return $.disabled===J.disabled&&aX($.denyRead,J.denyRead)&&aX($.denyWrite,J.denyWrite)&&aX($.allowRead,J.allowRead)&&aX($.allowWrite,J.allowWrite)&&aX($.credFiles,J.credFiles)}function oK($){return w9!==void 0&&iK(w9,s5($))}function aK(){if(!b)return{};let $=b.network.allowedDomains,J=b.network.deniedDomains;return{allowedHosts:$,...J.length>0&&{deniedHosts:J}}}function r5(){return b?.network?.allowUnixSockets}function l5(){return b?.network?.allowAllUnixSockets}function t5(){return b?.network?.allowLocalBinding}function e5(){return b?.network?.allowMachLookup}function $U(){return b?.ignoreViolations}function JU(){return b?.enableWeakerNestedSandbox}function sK(){return b?.runAsUid}function rK(){return b?.runAsGid}function tK(){return b?.runAsHostUid}function eK(){return b?.runAsHostGid}function $G(){return b?.runAsHostHome}function $z(){return b?.runAsHostUser}function Jz(){return b?.enableWeakerNetworkIsolation}function Qz(){return b?.allowAppleEvents}function Xz(){return b?.ripgrep??{command:"rg"}}function Yz(){return b?.mandatoryDenySearchDepth??3}function p5(){return b?.filesystem?.allowGitConfig??!1}function QU($){return[...b?.git?.safeDirectories??[],...$?.git?.safeDirectories??[]]}function Gz(){return b?.seccomp}function Wz(){return c0}function QG(){return uJ?.httpProxyPort}function XG(){return uJ?.socksProxyPort}function XU(){return uJ?.linuxBridge?.httpSocketPath}function YU(){return uJ?.linuxBridge?.socksSocketPath}async function YG(){if(!b)return!1;if(m0)try{return await m0,!0}catch{return!1}return uJ!==void 0}async function GU($,J,X,Q,Y){let G=x$(),W=Y?.commandId;c5($,Y);let U=X?.filesystem!==void 0?X.filesystem.disabled??!1:b?.filesystem.disabled??!1,M=JG(X?.credentials??b?.credentials,X?.network?.allowedDomains??b?.network?.allowedDomains),O,V;if(!U){let L=(P)=>P.map((l)=>E0(l)).filter((l)=>{if(x$()==="linux"&&NJ(l))return Z(`[Sandbox] Skipping glob write pattern on Linux: ${l}`),!1;return!0}),R=L(X?.filesystem?.allowWrite??b?.filesystem.allowWrite??[]);O={allowOnly:[...DQ(X?.runAsHostHome??$G()),...R],denyWithinAllow:L(X?.filesystem?.denyWrite??b?.filesystem.denyWrite??[])};let I=a5(X?.filesystem?.denyRead??b?.filesystem.denyRead??[],M),T=[];for(let P of I){let l=E0(P);if(x$()==="linux"&&NJ(l))T.push(...e0(P));else T.push(l)}let C=X?.filesystem?.allowRead??b?.filesystem.allowRead??[],w=[];for(let P of C){let l=E0(P);if(x$()==="linux"&&NJ(l))w.push(...e0(P));else w.push(l)}if(u$)w.push(u$.certPath,u$.trustBundlePath);V={denyOnly:T,allowWithinDeny:w}}let H=X?.network?.allowedDomains!==void 0||b?.network?.allowedDomains!==void 0,q=H,F=H;if(F)await YG();let K=X?.allowPty??b?.allowPty,A=QU(X);switch(G){case"macos":return O5({command:$,commandId:W,needsNetworkRestriction:q,httpProxyPort:F?QG():void 0,socksProxyPort:F?XG():void 0,proxyAuthToken:F?c0:void 0,caCertPath:u$?.trustBundlePath,readConfig:V,writeConfig:O,unsetEnvVars:M.unsetEnvVars,setEnvVars:M.setEnvVars,maskedFileBinds:M.maskedFileBinds,allowUnixSockets:r5(),allowAllUnixSockets:l5(),allowLocalBinding:t5(),allowMachLookup:e5(),ignoreViolations:$U(),allowPty:K,allowGitConfig:p5(),gitSafeDirectories:A,enableWeakerNetworkIsolation:Jz(),allowAppleEvents:Qz(),binShell:J});case"linux":return X5({command:$,commandId:W,needsNetworkRestriction:q,httpSocketPath:F?XU():void 0,socksSocketPath:F?YU():void 0,httpProxyPort:F?uJ?.httpProxyPort:void 0,socksProxyPort:F?uJ?.socksProxyPort:void 0,proxyAuthToken:F?c0:void 0,caCertPath:u$?.trustBundlePath,readConfig:V,writeConfig:O,unsetEnvVars:M.unsetEnvVars,setEnvVars:M.setEnvVars,maskedFileBinds:M.maskedFileBinds,maskedFileStoreDir:M.maskedFileStoreDir,enableWeakerNestedSandbox:JU(),runAsUid:sK(),runAsGid:rK(),runAsHostUid:tK(),runAsHostGid:eK(),runAsHostHome:$G(),runAsHostUser:$z(),setprivPath:"/usr/bin/setpriv",allowAllUnixSockets:l5(),binShell:J,ripgrepConfig:Xz(),mandatoryDenySearchDepth:Yz(),allowGitConfig:p5(),gitSafeDirectories:A,seccompConfig:Gz(),bwrapPath:b?.bwrapPath,socatPath:b?.socatPath,observeSocketPath:nQ?.observeSocketPath,abortSignal:Q});case"windows":throw Error("wrapWithSandbox() returns a shell string and is not supported on Windows. Use SandboxManager.wrapWithSandboxArgv() and spawn the result with {shell: false}.");default:throw Error(`Sandbox configuration is not supported on platform: ${G}`)}}async function Uz($,J,X,Q,Y,G){if(x$()==="windows"){let O=X?.network?.allowedDomains!==void 0||b?.network?.allowedDomains!==void 0;if(O)await YG();let V=JG(X?.credentials??b?.credentials,X?.network?.allowedDomains??b?.network?.allowedDomains),H=X?.filesystem,q=[],F=[];if(!H?.disabled){if(H?.allowRead?.length||H?.allowWrite?.length)throw Error("Per-exec filesystem.allowRead/allowWrite is not supported "+"on Windows \u2014 `srt-win exec` only exposes per-exec "+"denies. Set them at the session level (initialize()).");let K=[...H?.denyRead??[],...x9(X?.credentials)],A=H?.denyWrite??[];if(K.length>0||A.length>0){let L=new Set(iQ?.denyRead??[]),R=new Set(iQ?.denyWrite??[]),I=j9;q=I(K,{mode:"deny"}).filter((T)=>!L.has(T)),F=I(A,{mode:"deny"}).filter((T)=>!L.has(T)&&!R.has(T))}}return c5($,G),v5({command:$,commandId:G?.commandId,httpProxyPort:O?QG():void 0,socksProxyPort:O?XG():void 0,proxyAuthToken:O?c0:void 0,setEnvVars:V.setEnvVars,denyRead:q,denyWrite:F,cwd:Y,allowWrite:iQ?.grantWrite,gitSafeDirectories:QU(X),caCertPath:u$?.trustBundlePath,binShell:D9(J),srtWin:X?.windows?.srtWin?wJ(X.windows.srtWin):eX??wJ(b?.windows?.srtWin)})}if(typeof J==="object")throw Error("binShell object form is Windows-only; pass a shell path string on macOS/Linux");let U=await GU($,J,X,Q,G);return{argv:[J??"/bin/bash","-c",U],env:process.env}}function Mz(){return b}function Oz($){if(x$()==="windows"&&b&&!oK($))Z("[Sandbox Windows] updateConfig: the resolved file-access set "+"(filesystem.* \u222A credentials.files) changed but the ACL "+"stamp/grant is session-wide \u2014 call reset() then initialize() "+"to apply. The previously-applied set stays in effect.",{level:"warn"});let{filterRequest:J,...X}=$.network;b=structuredClone({...$,network:X}),b.network.filterRequest=J,d0=X7($.network.parentProxy),Z("Sandbox configuration updated")}function Vz(){N9()}var Hz=1500;function d5($,J){if(!$.pid||$.exitCode!==null||$.signalCode!==null)return Promise.resolve();try{process.kill($.pid,"SIGTERM"),Z(`Sent SIGTERM to ${J} bridge process`)}catch(X){if(X.code!=="ESRCH")Z(`Error killing ${J} bridge: ${X}`,{level:"error"});return Promise.resolve()}return new Promise((X)=>{let Q=!1,Y=()=>{if(Q)return;Q=!0,clearTimeout(G),X()};$.once("exit",()=>{Z(`${J} bridge process exited`),Y()});let G=setTimeout(()=>{if($.exitCode===null&&$.signalCode===null){Z(`${J} bridge did not exit, forcing SIGKILL`,{level:"warn"});try{if($.pid)process.kill($.pid,"SIGKILL")}catch{}}Y()},Hz);G.unref?.()})}function qz($){return new Promise((J)=>{if(typeof $.closeAllConnections==="function")$.closeAllConnections();$.close((X)=>{if(X&&X.message!=="Server is not running.")Z(`Error closing HTTP proxy server: ${X.message}`,{level:"error"});J()})})}async function Kz(){if(iQ&&l0){let J=l0,X=eX,Q=new Set(["revoked","stillHeld","restored","alreadyOriginal"]),Y=(G,W)=>{if(!Q.has(W.status))Z(`[Sandbox Windows] ${G}: '${W.path}' ${W.status} \u2014 `+"ACE may be left in place; resolve and run `srt-win acl recover` to clear",{level:"warn"})};for(let G of S9({sandboxUserSid:J,srtWin:X})??[])Y("grant revoke",G);for(let G of T9({sandboxUserSid:J,srtWin:X})??[])Y("deny restore",G)}if(iQ=void 0,l0=void 0,w9=void 0,eX=void 0,N9({force:!0}),C9)C9(),C9=void 0;if(nQ)nQ.stop(),nQ=void 0;if(uJ?.linuxBridge){let{httpSocketPath:J,socksSocketPath:X,httpBridgeProcess:Q,socksBridgeProcess:Y}=uJ.linuxBridge;if(await Promise.all([d5(Q,"HTTP"),d5(Y,"SOCKS")]),J)try{p0.rmSync(J,{force:!0}),Z("Cleaned up HTTP socket")}catch(G){Z(`HTTP socket cleanup error: ${G}`,{level:"error"})}if(X)try{p0.rmSync(X,{force:!0}),Z("Cleaned up SOCKS socket")}catch(G){Z(`SOCKS socket cleanup error: ${G}`,{level:"error"})}}let $=[];if(u$)$.push(kW(u$));if(tX)$.push(tX.close().catch((J)=>{Z(`Error closing mux proxy server: ${J.message}`,{level:"error"})}));if(sX)$.push(qz(sX));if(rX){let J=rX.close().catch((X)=>{Z(`Error closing SOCKS proxy server: ${X.message}`,{level:"error"})});$.push(J)}await Promise.all($),tX=void 0,sX=void 0,c0=void 0,rX=void 0,uJ=void 0,m0=void 0,d0=void 0,u$=void 0,EQ.clear(),_9.clear(),P9.dispose()}async function GG(){if(oX)return oX;oX=Kz();try{await oX}finally{oX=void 0}}function zz(){return zQ}function Ez($,J){if(!b)return J;let X=zQ.getViolationsForCommand($);if(X.length===0)return J;let Q=J;Q+=r7+"<sandbox_violations>"+r7;for(let Y of X)Q+=Y.line+r7;return Q+="</sandbox_violations>",Q}function Fz(){if(x$()!=="linux"||!b||b.filesystem.disabled)return[];let $=[],J=[...b.filesystem.allowWrite,...b.filesystem.denyWrite];for(let X of J){let Q=E0(X);if(NJ(Q))$.push(X)}return $}var Nz={initialize:mK,isSupportedPlatform:n5,isSandboxingEnabled:lK,checkDependencies:pK,checkDependenciesAsync:o5,getFsReadConfig:dK,getFsWriteConfig:cK,getNetworkRestrictionConfig:aK,getAllowUnixSockets:r5,getAllowLocalBinding:t5,getAllowMachLookup:e5,getIgnoreViolations:$U,getEnableWeakerNestedSandbox:JU,getProxyPort:QG,getProxyAuthToken:Wz,getSocksProxyPort:XG,getLinuxHttpSocketPath:XU,getLinuxSocksSocketPath:YU,waitForNetworkInitialization:YG,wrapWithSandbox:GU,wrapWithSandboxArgv:Uz,cleanupAfterCommand:Vz,reset:GG,getMitmCA:()=>u$,getSentinelRegistry:()=>EQ,getAwsPairRegistry:()=>_9,getMaskedFileStore:()=>P9,getSandboxViolationStore:zz,annotateStderrWithSandboxFailures:Ez,getLinuxGlobPatternWarnings:Fz,getConfig:Mz,updateConfig:Oz};import{isIP as CE}from"net";import{isAbsolute as wE}from"path";var x={};uU(x,{void:()=>JE,util:()=>Z$,unknown:()=>ez,union:()=>GE,undefined:()=>sz,tuple:()=>ME,transformer:()=>LE,symbol:()=>az,string:()=>zU,strictObject:()=>YE,setErrorMap:()=>Rz,set:()=>HE,record:()=>OE,quotelessJson:()=>Lz,promise:()=>NE,preprocess:()=>DE,pipeline:()=>ZE,ostring:()=>BE,optional:()=>AE,onumber:()=>jE,oboolean:()=>TE,objectUtil:()=>WG,object:()=>XE,number:()=>EU,nullable:()=>RE,null:()=>rz,never:()=>$E,nativeEnum:()=>FE,nan:()=>nz,map:()=>VE,makeIssue:()=>$Y,literal:()=>zE,lazy:()=>KE,late:()=>dz,isValid:()=>n0,isDirty:()=>k9,isAsync:()=>aQ,isAborted:()=>v9,intersection:()=>UE,instanceof:()=>cz,getParsedType:()=>H0,getErrorMap:()=>oQ,function:()=>qE,enum:()=>EE,effect:()=>LE,discriminatedUnion:()=>WE,defaultErrorMap:()=>j0,datetimeRegex:()=>HU,date:()=>oz,custom:()=>KU,coerce:()=>SE,boolean:()=>FU,bigint:()=>iz,array:()=>QE,any:()=>tz,addIssueToContext:()=>n,ZodVoid:()=>QY,ZodUnknown:()=>i0,ZodUnion:()=>JX,ZodUndefined:()=>eQ,ZodType:()=>F$,ZodTuple:()=>K0,ZodTransformer:()=>tJ,ZodSymbol:()=>JY,ZodString:()=>oJ,ZodSet:()=>AQ,ZodSchema:()=>F$,ZodRecord:()=>XY,ZodReadonly:()=>MX,ZodPromise:()=>RQ,ZodPipeline:()=>WY,ZodParsedType:()=>m,ZodOptional:()=>sJ,ZodObject:()=>o$,ZodNumber:()=>o0,ZodNullable:()=>S0,ZodNull:()=>$X,ZodNever:()=>q0,ZodNativeEnum:()=>GX,ZodNaN:()=>GY,ZodMap:()=>YY,ZodLiteral:()=>YX,ZodLazy:()=>XX,ZodIssueCode:()=>u,ZodIntersection:()=>QX,ZodFunction:()=>rQ,ZodFirstPartyTypeKind:()=>W$,ZodError:()=>TJ,ZodEnum:()=>s0,ZodEffects:()=>tJ,ZodDiscriminatedUnion:()=>f9,ZodDefault:()=>WX,ZodDate:()=>NQ,ZodCatch:()=>UX,ZodBranded:()=>y9,ZodBoolean:()=>tQ,ZodBigInt:()=>a0,ZodArray:()=>aJ,ZodAny:()=>LQ,Schema:()=>F$,ParseStatus:()=>EJ,OK:()=>FJ,NEVER:()=>IE,INVALID:()=>Y$,EMPTY_PATH:()=>Dz,DIRTY:()=>FQ,BRAND:()=>pz});var Z$;(function($){$.assertEqual=(Y)=>{};function J(Y){}$.assertIs=J;function X(Y){throw Error()}$.assertNever=X,$.arrayToEnum=(Y)=>{let G={};for(let W of Y)G[W]=W;return G},$.getValidEnumValues=(Y)=>{let G=$.objectKeys(Y).filter((U)=>typeof Y[Y[U]]!=="number"),W={};for(let U of G)W[U]=Y[U];return $.objectValues(W)},$.objectValues=(Y)=>{return $.objectKeys(Y).map(function(G){return Y[G]})},$.objectKeys=typeof Object.keys==="function"?(Y)=>Object.keys(Y):(Y)=>{let G=[];for(let W in Y)if(Object.prototype.hasOwnProperty.call(Y,W))G.push(W);return G},$.find=(Y,G)=>{for(let W of Y)if(G(W))return W;return},$.isInteger=typeof Number.isInteger==="function"?(Y)=>Number.isInteger(Y):(Y)=>typeof Y==="number"&&Number.isFinite(Y)&&Math.floor(Y)===Y;function Q(Y,G=" | "){return Y.map((W)=>typeof W==="string"?`'${W}'`:W).join(G)}$.joinValues=Q,$.jsonStringifyReplacer=(Y,G)=>{if(typeof G==="bigint")return G.toString();return G}})(Z$||(Z$={}));var WG;(function($){$.mergeShapes=(J,X)=>{return{...J,...X}}})(WG||(WG={}));var m=Z$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),H0=($)=>{switch(typeof $){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN($)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":if(Array.isArray($))return m.array;if($===null)return m.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return m.promise;if(typeof Map<"u"&&$ instanceof Map)return m.map;if(typeof Set<"u"&&$ instanceof Set)return m.set;if(typeof Date<"u"&&$ instanceof Date)return m.date;return m.object;default:return m.unknown}};var u=Z$.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"]),Lz=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class TJ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(Y){return Y.message},X={_errors:[]},Q=(Y)=>{for(let G of Y.issues)if(G.code==="invalid_union")G.unionErrors.map(Q);else if(G.code==="invalid_return_type")Q(G.returnTypeError);else if(G.code==="invalid_arguments")Q(G.argumentsError);else if(G.path.length===0)X._errors.push(J(G));else{let W=X,U=0;while(U<G.path.length){let M=G.path[U];if(U!==G.path.length-1)W[M]=W[M]||{_errors:[]};else W[M]=W[M]||{_errors:[]},W[M]._errors.push(J(G));W=W[M],U++}}};return Q(this),X}static assert($){if(!($ instanceof TJ))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},X=[];for(let Q of this.issues)if(Q.path.length>0){let Y=Q.path[0];J[Y]=J[Y]||[],J[Y].push($(Q))}else X.push($(Q));return{formErrors:X,fieldErrors:J}}get formErrors(){return this.flatten()}}TJ.create=($)=>{return new TJ($)};var Az=($,J)=>{let X;switch($.code){case u.invalid_type:if($.received===m.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case u.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,Z$.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:X=`Unrecognized key(s) in object: ${Z$.joinValues($.keys,", ")}`;break;case u.invalid_union:X="Invalid input";break;case u.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${Z$.joinValues($.options)}`;break;case u.invalid_enum_value:X=`Invalid enum value. Expected ${Z$.joinValues($.options)}, received '${$.received}'`;break;case u.invalid_arguments:X="Invalid function arguments";break;case u.invalid_return_type:X="Invalid function return type";break;case u.invalid_date:X="Invalid date";break;case u.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else Z$.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case u.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case u.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case u.custom:X="Invalid input";break;case u.invalid_intersection_types:X="Intersection results could not be merged";break;case u.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case u.not_finite:X="Number must be finite";break;default:X=J.defaultError,Z$.assertNever($)}return{message:X}},j0=Az;var WU=j0;function Rz($){WU=$}function oQ(){return WU}var $Y=($)=>{let{data:J,path:X,errorMaps:Q,issueData:Y}=$,G=[...X,...Y.path||[]],W={...Y,path:G};if(Y.message!==void 0)return{...Y,path:G,message:Y.message};let U="",M=Q.filter((O)=>!!O).slice().reverse();for(let O of M)U=O(W,{data:J,defaultError:U}).message;return{...Y,path:G,message:U}},Dz=[];function n($,J){let X=oQ(),Q=$Y({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===j0?void 0:j0].filter((Y)=>!!Y)});$.common.issues.push(Q)}class EJ{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let X=[];for(let Q of J){if(Q.status==="aborted")return Y$;if(Q.status==="dirty")$.dirty();X.push(Q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,J){let X=[];for(let Q of J){let Y=await Q.key,G=await Q.value;X.push({key:Y,value:G})}return EJ.mergeObjectSync($,X)}static mergeObjectSync($,J){let X={};for(let Q of J){let{key:Y,value:G}=Q;if(Y.status==="aborted")return Y$;if(G.status==="aborted")return Y$;if(Y.status==="dirty")$.dirty();if(G.status==="dirty")$.dirty();if(Y.value!=="__proto__"&&(typeof G.value<"u"||Q.alwaysSet))X[Y.value]=G.value}return{status:$.value,value:X}}}var Y$=Object.freeze({status:"aborted"}),FQ=($)=>({status:"dirty",value:$}),FJ=($)=>({status:"valid",value:$}),v9=($)=>$.status==="aborted",k9=($)=>$.status==="dirty",n0=($)=>$.status==="valid",aQ=($)=>typeof Promise<"u"&&$ instanceof Promise;var e;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(e||(e={}));class rJ{constructor($,J,X,Q){this._cachedPath=[],this.parent=$,this.data=J,this._path=X,this._key=Q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var UU=($,J)=>{if(n0(J))return{success:!0,data:J.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new TJ($.common.issues);return this._error=X,this._error}}}};function H$($){if(!$)return{};let{errorMap:J,invalid_type_error:X,required_error:Q,description:Y}=$;if(J&&(X||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:Y};return{errorMap:(W,U)=>{let{message:M}=$;if(W.code==="invalid_enum_value")return{message:M??U.defaultError};if(typeof U.data>"u")return{message:M??Q??U.defaultError};if(W.code!=="invalid_type")return{message:U.defaultError};return{message:M??X??U.defaultError}},description:Y}}class F${get description(){return this._def.description}_getType($){return H0($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:H0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new EJ,ctx:{common:$.parent.common,data:$.data,parsedType:H0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(aQ(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let X=this.safeParse($,J);if(X.success)return X.data;throw X.error}safeParse($,J){let X={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:H0($)},Q=this._parseSync({data:$,path:X.path,parent:X});return UU(X,Q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:H0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:J});return n0(X)?{value:X.value}:{issues:J.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((X)=>n0(X)?{value:X.value}:{issues:J.common.issues})}async parseAsync($,J){let X=await this.safeParseAsync($,J);if(X.success)return X.data;throw X.error}async safeParseAsync($,J){let X={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:H0($)},Q=this._parse({data:$,path:X.path,parent:X}),Y=await(aQ(Q)?Q:Promise.resolve(Q));return UU(X,Y)}refine($,J){let X=(Q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(Q);else return J};return this._refinement((Q,Y)=>{let G=$(Q),W=()=>Y.addIssue({code:u.custom,...X(Q)});if(typeof Promise<"u"&&G instanceof Promise)return G.then((U)=>{if(!U)return W(),!1;else return!0});if(!G)return W(),!1;else return!0})}refinement($,J){return this._refinement((X,Q)=>{if(!$(X))return Q.addIssue(typeof J==="function"?J(X,Q):J),!1;else return!0})}_refinement($){return new tJ({schema:this,typeName:W$.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(J)=>this["~validate"](J)}}optional(){return sJ.create(this,this._def)}nullable(){return S0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return aJ.create(this)}promise(){return RQ.create(this,this._def)}or($){return JX.create([this,$],this._def)}and($){return QX.create(this,$,this._def)}transform($){return new tJ({...H$(this._def),schema:this,typeName:W$.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new WX({...H$(this._def),innerType:this,defaultValue:J,typeName:W$.ZodDefault})}brand(){return new y9({typeName:W$.ZodBranded,type:this,...H$(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new UX({...H$(this._def),innerType:this,catchValue:J,typeName:W$.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return WY.create(this,$)}readonly(){return MX.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Zz=/^c[^\s-]{8,}$/i,Bz=/^[0-9a-z]+$/,jz=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tz=/^[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,Sz=/^[a-z0-9_-]{21}$/i,Iz=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Cz=/^[-+]?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)?)??$/,wz=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",UG,_z=/^(?:(?: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])$/,xz=/^(?:(?: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])$/,vz=/^(([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]))$/,kz=/^(([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])$/,fz=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yz=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,OU="((\\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])))",bz=new RegExp(`^${OU}$`);function VU($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${X}`}function hz($){return new RegExp(`^${VU($)}$`)}function HU($){let J=`${OU}T${VU($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${X.join("|")})`,new RegExp(`^${J}$`)}function uz($,J){if((J==="v4"||!J)&&_z.test($))return!0;if((J==="v6"||!J)&&vz.test($))return!0;return!1}function gz($,J){if(!Iz.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Y=JSON.parse(atob(Q));if(typeof Y!=="object"||Y===null)return!1;if("typ"in Y&&Y?.typ!=="JWT")return!1;if(!Y.alg)return!1;if(J&&Y.alg!==J)return!1;return!0}catch{return!1}}function mz($,J){if((J==="v4"||!J)&&xz.test($))return!0;if((J==="v6"||!J)&&kz.test($))return!0;return!1}class oJ extends F${_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==m.string){let Y=this._getOrReturnCtx($);return n(Y,{code:u.invalid_type,expected:m.string,received:Y.parsedType}),Y$}let X=new EJ,Q=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.length<Y.value)Q=this._getOrReturnCtx($,Q),n(Q,{code:u.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="max"){if($.data.length>Y.value)Q=this._getOrReturnCtx($,Q),n(Q,{code:u.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!1,message:Y.message}),X.dirty()}else if(Y.kind==="length"){let G=$.data.length>Y.value,W=$.data.length<Y.value;if(G||W){if(Q=this._getOrReturnCtx($,Q),G)n(Q,{code:u.too_big,maximum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});else if(W)n(Q,{code:u.too_small,minimum:Y.value,type:"string",inclusive:!0,exact:!0,message:Y.message});X.dirty()}}else if(Y.kind==="email"){if(!wz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"email",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="emoji"){if(!UG)UG=new RegExp(Pz,"u");if(!UG.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"emoji",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="uuid"){if(!Tz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"uuid",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="nanoid"){if(!Sz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"nanoid",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid"){if(!Zz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"cuid",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cuid2"){if(!Bz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"cuid2",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ulid"){if(!jz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"ulid",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),n(Q,{validation:"url",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="regex"){if(Y.regex.lastIndex=0,!Y.regex.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"regex",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="trim")$.data=$.data.trim();else if(Y.kind==="includes"){if(!$.data.includes(Y.value,Y.position))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:{includes:Y.value,position:Y.position},message:Y.message}),X.dirty()}else if(Y.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Y.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Y.kind==="startsWith"){if(!$.data.startsWith(Y.value))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:{startsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="endsWith"){if(!$.data.endsWith(Y.value))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:{endsWith:Y.value},message:Y.message}),X.dirty()}else if(Y.kind==="datetime"){if(!HU(Y).test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:"datetime",message:Y.message}),X.dirty()}else if(Y.kind==="date"){if(!bz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:"date",message:Y.message}),X.dirty()}else if(Y.kind==="time"){if(!hz(Y).test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{code:u.invalid_string,validation:"time",message:Y.message}),X.dirty()}else if(Y.kind==="duration"){if(!Cz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"duration",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="ip"){if(!uz($.data,Y.version))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"ip",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="jwt"){if(!gz($.data,Y.alg))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"jwt",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="cidr"){if(!mz($.data,Y.version))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"cidr",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64"){if(!fz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"base64",code:u.invalid_string,message:Y.message}),X.dirty()}else if(Y.kind==="base64url"){if(!yz.test($.data))Q=this._getOrReturnCtx($,Q),n(Q,{validation:"base64url",code:u.invalid_string,message:Y.message}),X.dirty()}else Z$.assertNever(Y);return{status:X.value,value:$.data}}_regex($,J,X){return this.refinement((Q)=>$.test(Q),{validation:J,code:u.invalid_string,...e.errToObj(X)})}_addCheck($){return new oJ({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...e.errToObj($)})}url($){return this._addCheck({kind:"url",...e.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...e.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...e.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...e.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...e.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...e.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...e.errToObj($)})}base64($){return this._addCheck({kind:"base64",...e.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...e.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...e.errToObj($)})}ip($){return this._addCheck({kind:"ip",...e.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...e.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...e.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...e.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...e.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...e.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...e.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...e.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...e.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...e.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...e.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...e.errToObj(J)})}nonempty($){return this.min(1,e.errToObj($))}trim(){return new oJ({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new oJ({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new oJ({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}oJ.create=($)=>{return new oJ({checks:[],typeName:W$.ZodString,coerce:$?.coerce??!1,...H$($)})};function lz($,J){let X=($.toString().split(".")[1]||"").length,Q=(J.toString().split(".")[1]||"").length,Y=X>Q?X:Q,G=Number.parseInt($.toFixed(Y).replace(".","")),W=Number.parseInt(J.toFixed(Y).replace(".",""));return G%W/10**Y}class o0 extends F${constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==m.number){let Y=this._getOrReturnCtx($);return n(Y,{code:u.invalid_type,expected:m.number,received:Y.parsedType}),Y$}let X=void 0,Q=new EJ;for(let Y of this._def.checks)if(Y.kind==="int"){if(!Z$.isInteger($.data))X=this._getOrReturnCtx($,X),n(X,{code:u.invalid_type,expected:"integer",received:"float",message:Y.message}),Q.dirty()}else if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),n(X,{code:u.too_small,minimum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),Q.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),n(X,{code:u.too_big,maximum:Y.value,type:"number",inclusive:Y.inclusive,exact:!1,message:Y.message}),Q.dirty()}else if(Y.kind==="multipleOf"){if(lz($.data,Y.value)!==0)X=this._getOrReturnCtx($,X),n(X,{code:u.not_multiple_of,multipleOf:Y.value,message:Y.message}),Q.dirty()}else if(Y.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),n(X,{code:u.not_finite,message:Y.message}),Q.dirty()}else Z$.assertNever(Y);return{status:Q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,e.toString(J))}gt($,J){return this.setLimit("min",$,!1,e.toString(J))}lte($,J){return this.setLimit("max",$,!0,e.toString(J))}lt($,J){return this.setLimit("max",$,!1,e.toString(J))}setLimit($,J,X,Q){return new o0({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:e.toString(Q)}]})}_addCheck($){return new o0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:e.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:e.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:e.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:e.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:e.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:e.toString(J)})}finite($){return this._addCheck({kind:"finite",message:e.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:e.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:e.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&Z$.isInteger($.value))}get isFinite(){let $=null,J=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(J===null||X.value>J)J=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(J)&&Number.isFinite($)}}o0.create=($)=>{return new o0({checks:[],typeName:W$.ZodNumber,coerce:$?.coerce||!1,...H$($)})};class a0 extends F${constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==m.bigint)return this._getInvalidInput($);let X=void 0,Q=new EJ;for(let Y of this._def.checks)if(Y.kind==="min"){if(Y.inclusive?$.data<Y.value:$.data<=Y.value)X=this._getOrReturnCtx($,X),n(X,{code:u.too_small,type:"bigint",minimum:Y.value,inclusive:Y.inclusive,message:Y.message}),Q.dirty()}else if(Y.kind==="max"){if(Y.inclusive?$.data>Y.value:$.data>=Y.value)X=this._getOrReturnCtx($,X),n(X,{code:u.too_big,type:"bigint",maximum:Y.value,inclusive:Y.inclusive,message:Y.message}),Q.dirty()}else if(Y.kind==="multipleOf"){if($.data%Y.value!==BigInt(0))X=this._getOrReturnCtx($,X),n(X,{code:u.not_multiple_of,multipleOf:Y.value,message:Y.message}),Q.dirty()}else Z$.assertNever(Y);return{status:Q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return n(J,{code:u.invalid_type,expected:m.bigint,received:J.parsedType}),Y$}gte($,J){return this.setLimit("min",$,!0,e.toString(J))}gt($,J){return this.setLimit("min",$,!1,e.toString(J))}lte($,J){return this.setLimit("max",$,!0,e.toString(J))}lt($,J){return this.setLimit("max",$,!1,e.toString(J))}setLimit($,J,X,Q){return new a0({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:e.toString(Q)}]})}_addCheck($){return new a0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:e.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:e.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:e.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:e.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:e.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}a0.create=($)=>{return new a0({checks:[],typeName:W$.ZodBigInt,coerce:$?.coerce??!1,...H$($)})};class tQ extends F${_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==m.boolean){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.boolean,received:X.parsedType}),Y$}return FJ($.data)}}tQ.create=($)=>{return new tQ({typeName:W$.ZodBoolean,coerce:$?.coerce||!1,...H$($)})};class NQ extends F${_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==m.date){let Y=this._getOrReturnCtx($);return n(Y,{code:u.invalid_type,expected:m.date,received:Y.parsedType}),Y$}if(Number.isNaN($.data.getTime())){let Y=this._getOrReturnCtx($);return n(Y,{code:u.invalid_date}),Y$}let X=new EJ,Q=void 0;for(let Y of this._def.checks)if(Y.kind==="min"){if($.data.getTime()<Y.value)Q=this._getOrReturnCtx($,Q),n(Q,{code:u.too_small,message:Y.message,inclusive:!0,exact:!1,minimum:Y.value,type:"date"}),X.dirty()}else if(Y.kind==="max"){if($.data.getTime()>Y.value)Q=this._getOrReturnCtx($,Q),n(Q,{code:u.too_big,message:Y.message,inclusive:!0,exact:!1,maximum:Y.value,type:"date"}),X.dirty()}else Z$.assertNever(Y);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new NQ({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:e.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:e.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}NQ.create=($)=>{return new NQ({checks:[],coerce:$?.coerce||!1,typeName:W$.ZodDate,...H$($)})};class JY extends F${_parse($){if(this._getType($)!==m.symbol){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.symbol,received:X.parsedType}),Y$}return FJ($.data)}}JY.create=($)=>{return new JY({typeName:W$.ZodSymbol,...H$($)})};class eQ extends F${_parse($){if(this._getType($)!==m.undefined){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.undefined,received:X.parsedType}),Y$}return FJ($.data)}}eQ.create=($)=>{return new eQ({typeName:W$.ZodUndefined,...H$($)})};class $X extends F${_parse($){if(this._getType($)!==m.null){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.null,received:X.parsedType}),Y$}return FJ($.data)}}$X.create=($)=>{return new $X({typeName:W$.ZodNull,...H$($)})};class LQ extends F${constructor(){super(...arguments);this._any=!0}_parse($){return FJ($.data)}}LQ.create=($)=>{return new LQ({typeName:W$.ZodAny,...H$($)})};class i0 extends F${constructor(){super(...arguments);this._unknown=!0}_parse($){return FJ($.data)}}i0.create=($)=>{return new i0({typeName:W$.ZodUnknown,...H$($)})};class q0 extends F${_parse($){let J=this._getOrReturnCtx($);return n(J,{code:u.invalid_type,expected:m.never,received:J.parsedType}),Y$}}q0.create=($)=>{return new q0({typeName:W$.ZodNever,...H$($)})};class QY extends F${_parse($){if(this._getType($)!==m.undefined){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.void,received:X.parsedType}),Y$}return FJ($.data)}}QY.create=($)=>{return new QY({typeName:W$.ZodVoid,...H$($)})};class aJ extends F${_parse($){let{ctx:J,status:X}=this._processInputParams($),Q=this._def;if(J.parsedType!==m.array)return n(J,{code:u.invalid_type,expected:m.array,received:J.parsedType}),Y$;if(Q.exactLength!==null){let G=J.data.length>Q.exactLength.value,W=J.data.length<Q.exactLength.value;if(G||W)n(J,{code:G?u.too_big:u.too_small,minimum:W?Q.exactLength.value:void 0,maximum:G?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),X.dirty()}if(Q.minLength!==null){if(J.data.length<Q.minLength.value)n(J,{code:u.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),X.dirty()}if(Q.maxLength!==null){if(J.data.length>Q.maxLength.value)n(J,{code:u.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),X.dirty()}if(J.common.async)return Promise.all([...J.data].map((G,W)=>{return Q.type._parseAsync(new rJ(J,G,J.path,W))})).then((G)=>{return EJ.mergeArray(X,G)});let Y=[...J.data].map((G,W)=>{return Q.type._parseSync(new rJ(J,G,J.path,W))});return EJ.mergeArray(X,Y)}get element(){return this._def.type}min($,J){return new aJ({...this._def,minLength:{value:$,message:e.toString(J)}})}max($,J){return new aJ({...this._def,maxLength:{value:$,message:e.toString(J)}})}length($,J){return new aJ({...this._def,exactLength:{value:$,message:e.toString(J)}})}nonempty($){return this.min(1,$)}}aJ.create=($,J)=>{return new aJ({type:$,minLength:null,maxLength:null,exactLength:null,typeName:W$.ZodArray,...H$(J)})};function sQ($){if($ instanceof o$){let J={};for(let X in $.shape){let Q=$.shape[X];J[X]=sJ.create(sQ(Q))}return new o$({...$._def,shape:()=>J})}else if($ instanceof aJ)return new aJ({...$._def,type:sQ($.element)});else if($ instanceof sJ)return sJ.create(sQ($.unwrap()));else if($ instanceof S0)return S0.create(sQ($.unwrap()));else if($ instanceof K0)return K0.create($.items.map((J)=>sQ(J)));else return $}class o$ extends F${constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),J=Z$.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==m.object){let M=this._getOrReturnCtx($);return n(M,{code:u.invalid_type,expected:m.object,received:M.parsedType}),Y$}let{status:X,ctx:Q}=this._processInputParams($),{shape:Y,keys:G}=this._getCached(),W=[];if(!(this._def.catchall instanceof q0&&this._def.unknownKeys==="strip")){for(let M in Q.data)if(!G.includes(M))W.push(M)}let U=[];for(let M of G){let O=Y[M],V=Q.data[M];U.push({key:{status:"valid",value:M},value:O._parse(new rJ(Q,V,Q.path,M)),alwaysSet:M in Q.data})}if(this._def.catchall instanceof q0){let M=this._def.unknownKeys;if(M==="passthrough")for(let O of W)U.push({key:{status:"valid",value:O},value:{status:"valid",value:Q.data[O]}});else if(M==="strict"){if(W.length>0)n(Q,{code:u.unrecognized_keys,keys:W}),X.dirty()}else if(M==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let M=this._def.catchall;for(let O of W){let V=Q.data[O];U.push({key:{status:"valid",value:O},value:M._parse(new rJ(Q,V,Q.path,O)),alwaysSet:O in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let M=[];for(let O of U){let V=await O.key,H=await O.value;M.push({key:V,value:H,alwaysSet:O.alwaysSet})}return M}).then((M)=>{return EJ.mergeObjectSync(X,M)});else return EJ.mergeObjectSync(X,U)}get shape(){return this._def.shape()}strict($){return e.errToObj,new o$({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,X)=>{let Q=this._def.errorMap?.(J,X).message??X.defaultError;if(J.code==="unrecognized_keys")return{message:e.errToObj($).message??Q};return{message:Q}}}:{}})}strip(){return new o$({...this._def,unknownKeys:"strip"})}passthrough(){return new o$({...this._def,unknownKeys:"passthrough"})}extend($){return new o$({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new o$({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:W$.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new o$({...this._def,catchall:$})}pick($){let J={};for(let X of Z$.objectKeys($))if($[X]&&this.shape[X])J[X]=this.shape[X];return new o$({...this._def,shape:()=>J})}omit($){let J={};for(let X of Z$.objectKeys(this.shape))if(!$[X])J[X]=this.shape[X];return new o$({...this._def,shape:()=>J})}deepPartial(){return sQ(this)}partial($){let J={};for(let X of Z$.objectKeys(this.shape)){let Q=this.shape[X];if($&&!$[X])J[X]=Q;else J[X]=Q.optional()}return new o$({...this._def,shape:()=>J})}required($){let J={};for(let X of Z$.objectKeys(this.shape))if($&&!$[X])J[X]=this.shape[X];else{let Y=this.shape[X];while(Y instanceof sJ)Y=Y._def.innerType;J[X]=Y}return new o$({...this._def,shape:()=>J})}keyof(){return qU(Z$.objectKeys(this.shape))}}o$.create=($,J)=>{return new o$({shape:()=>$,unknownKeys:"strip",catchall:q0.create(),typeName:W$.ZodObject,...H$(J)})};o$.strictCreate=($,J)=>{return new o$({shape:()=>$,unknownKeys:"strict",catchall:q0.create(),typeName:W$.ZodObject,...H$(J)})};o$.lazycreate=($,J)=>{return new o$({shape:$,unknownKeys:"strip",catchall:q0.create(),typeName:W$.ZodObject,...H$(J)})};class JX extends F${_parse($){let{ctx:J}=this._processInputParams($),X=this._def.options;function Q(Y){for(let W of Y)if(W.result.status==="valid")return W.result;for(let W of Y)if(W.result.status==="dirty")return J.common.issues.push(...W.ctx.common.issues),W.result;let G=Y.map((W)=>new TJ(W.ctx.common.issues));return n(J,{code:u.invalid_union,unionErrors:G}),Y$}if(J.common.async)return Promise.all(X.map(async(Y)=>{let G={...J,common:{...J.common,issues:[]},parent:null};return{result:await Y._parseAsync({data:J.data,path:J.path,parent:G}),ctx:G}})).then(Q);else{let Y=void 0,G=[];for(let U of X){let M={...J,common:{...J.common,issues:[]},parent:null},O=U._parseSync({data:J.data,path:J.path,parent:M});if(O.status==="valid")return O;else if(O.status==="dirty"&&!Y)Y={result:O,ctx:M};if(M.common.issues.length)G.push(M.common.issues)}if(Y)return J.common.issues.push(...Y.ctx.common.issues),Y.result;let W=G.map((U)=>new TJ(U));return n(J,{code:u.invalid_union,unionErrors:W}),Y$}}get options(){return this._def.options}}JX.create=($,J)=>{return new JX({options:$,typeName:W$.ZodUnion,...H$(J)})};var T0=($)=>{if($ instanceof XX)return T0($.schema);else if($ instanceof tJ)return T0($.innerType());else if($ instanceof YX)return[$.value];else if($ instanceof s0)return $.options;else if($ instanceof GX)return Z$.objectValues($.enum);else if($ instanceof WX)return T0($._def.innerType);else if($ instanceof eQ)return[void 0];else if($ instanceof $X)return[null];else if($ instanceof sJ)return[void 0,...T0($.unwrap())];else if($ instanceof S0)return[null,...T0($.unwrap())];else if($ instanceof y9)return T0($.unwrap());else if($ instanceof MX)return T0($.unwrap());else if($ instanceof UX)return T0($._def.innerType);else return[]};class f9 extends F${_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==m.object)return n(J,{code:u.invalid_type,expected:m.object,received:J.parsedType}),Y$;let X=this.discriminator,Q=J.data[X],Y=this.optionsMap.get(Q);if(!Y)return n(J,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),Y$;if(J.common.async)return Y._parseAsync({data:J.data,path:J.path,parent:J});else return Y._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,X){let Q=new Map;for(let Y of J){let G=T0(Y.shape[$]);if(!G.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let W of G){if(Q.has(W))throw Error(`Discriminator property ${String($)} has duplicate value ${String(W)}`);Q.set(W,Y)}}return new f9({typeName:W$.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:Q,...H$(X)})}}function MG($,J){let X=H0($),Q=H0(J);if($===J)return{valid:!0,data:$};else if(X===m.object&&Q===m.object){let Y=Z$.objectKeys(J),G=Z$.objectKeys($).filter((U)=>Y.indexOf(U)!==-1),W={...$,...J};for(let U of G){let M=MG($[U],J[U]);if(!M.valid)return{valid:!1};W[U]=M.data}return{valid:!0,data:W}}else if(X===m.array&&Q===m.array){if($.length!==J.length)return{valid:!1};let Y=[];for(let G=0;G<$.length;G++){let W=$[G],U=J[G],M=MG(W,U);if(!M.valid)return{valid:!1};Y.push(M.data)}return{valid:!0,data:Y}}else if(X===m.date&&Q===m.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class QX extends F${_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=(Y,G)=>{if(v9(Y)||v9(G))return Y$;let W=MG(Y.value,G.value);if(!W.valid)return n(X,{code:u.invalid_intersection_types}),Y$;if(k9(Y)||k9(G))J.dirty();return{status:J.value,value:W.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Y,G])=>Q(Y,G));else return Q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}QX.create=($,J,X)=>{return new QX({left:$,right:J,typeName:W$.ZodIntersection,...H$(X)})};class K0 extends F${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==m.array)return n(X,{code:u.invalid_type,expected:m.array,received:X.parsedType}),Y$;if(X.data.length<this._def.items.length)return n(X,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y$;if(!this._def.rest&&X.data.length>this._def.items.length)n(X,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let Y=[...X.data].map((G,W)=>{let U=this._def.items[W]||this._def.rest;if(!U)return null;return U._parse(new rJ(X,G,X.path,W))}).filter((G)=>!!G);if(X.common.async)return Promise.all(Y).then((G)=>{return EJ.mergeArray(J,G)});else return EJ.mergeArray(J,Y)}get items(){return this._def.items}rest($){return new K0({...this._def,rest:$})}}K0.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new K0({items:$,typeName:W$.ZodTuple,rest:null,...H$(J)})};class XY extends F${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==m.object)return n(X,{code:u.invalid_type,expected:m.object,received:X.parsedType}),Y$;let Q=[],Y=this._def.keyType,G=this._def.valueType;for(let W in X.data)Q.push({key:Y._parse(new rJ(X,W,X.path,W)),value:G._parse(new rJ(X,X.data[W],X.path,W)),alwaysSet:W in X.data});if(X.common.async)return EJ.mergeObjectAsync(J,Q);else return EJ.mergeObjectSync(J,Q)}get element(){return this._def.valueType}static create($,J,X){if(J instanceof F$)return new XY({keyType:$,valueType:J,typeName:W$.ZodRecord,...H$(X)});return new XY({keyType:oJ.create(),valueType:$,typeName:W$.ZodRecord,...H$(J)})}}class YY extends F${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==m.map)return n(X,{code:u.invalid_type,expected:m.map,received:X.parsedType}),Y$;let Q=this._def.keyType,Y=this._def.valueType,G=[...X.data.entries()].map(([W,U],M)=>{return{key:Q._parse(new rJ(X,W,X.path,[M,"key"])),value:Y._parse(new rJ(X,U,X.path,[M,"value"]))}});if(X.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let U of G){let M=await U.key,O=await U.value;if(M.status==="aborted"||O.status==="aborted")return Y$;if(M.status==="dirty"||O.status==="dirty")J.dirty();W.set(M.value,O.value)}return{status:J.value,value:W}})}else{let W=new Map;for(let U of G){let{key:M,value:O}=U;if(M.status==="aborted"||O.status==="aborted")return Y$;if(M.status==="dirty"||O.status==="dirty")J.dirty();W.set(M.value,O.value)}return{status:J.value,value:W}}}}YY.create=($,J,X)=>{return new YY({valueType:J,keyType:$,typeName:W$.ZodMap,...H$(X)})};class AQ extends F${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==m.set)return n(X,{code:u.invalid_type,expected:m.set,received:X.parsedType}),Y$;let Q=this._def;if(Q.minSize!==null){if(X.data.size<Q.minSize.value)n(X,{code:u.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),J.dirty()}if(Q.maxSize!==null){if(X.data.size>Q.maxSize.value)n(X,{code:u.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),J.dirty()}let Y=this._def.valueType;function G(U){let M=new Set;for(let O of U){if(O.status==="aborted")return Y$;if(O.status==="dirty")J.dirty();M.add(O.value)}return{status:J.value,value:M}}let W=[...X.data.values()].map((U,M)=>Y._parse(new rJ(X,U,X.path,M)));if(X.common.async)return Promise.all(W).then((U)=>G(U));else return G(W)}min($,J){return new AQ({...this._def,minSize:{value:$,message:e.toString(J)}})}max($,J){return new AQ({...this._def,maxSize:{value:$,message:e.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}AQ.create=($,J)=>{return new AQ({valueType:$,minSize:null,maxSize:null,typeName:W$.ZodSet,...H$(J)})};class rQ extends F${constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==m.function)return n(J,{code:u.invalid_type,expected:m.function,received:J.parsedType}),Y$;function X(W,U){return $Y({data:W,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,oQ(),j0].filter((M)=>!!M),issueData:{code:u.invalid_arguments,argumentsError:U}})}function Q(W,U){return $Y({data:W,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,oQ(),j0].filter((M)=>!!M),issueData:{code:u.invalid_return_type,returnTypeError:U}})}let Y={errorMap:J.common.contextualErrorMap},G=J.data;if(this._def.returns instanceof RQ){let W=this;return FJ(async function(...U){let M=new TJ([]),O=await W._def.args.parseAsync(U,Y).catch((q)=>{throw M.addIssue(X(U,q)),M}),V=await Reflect.apply(G,this,O);return await W._def.returns._def.type.parseAsync(V,Y).catch((q)=>{throw M.addIssue(Q(V,q)),M})})}else{let W=this;return FJ(function(...U){let M=W._def.args.safeParse(U,Y);if(!M.success)throw new TJ([X(U,M.error)]);let O=Reflect.apply(G,this,M.data),V=W._def.returns.safeParse(O,Y);if(!V.success)throw new TJ([Q(O,V.error)]);return V.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new rQ({...this._def,args:K0.create($).rest(i0.create())})}returns($){return new rQ({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,X){return new rQ({args:$?$:K0.create([]).rest(i0.create()),returns:J||i0.create(),typeName:W$.ZodFunction,...H$(X)})}}class XX extends F${get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}XX.create=($,J)=>{return new XX({getter:$,typeName:W$.ZodLazy,...H$(J)})};class YX extends F${_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return n(J,{received:J.data,code:u.invalid_literal,expected:this._def.value}),Y$}return{status:"valid",value:$.data}}get value(){return this._def.value}}YX.create=($,J)=>{return new YX({value:$,typeName:W$.ZodLiteral,...H$(J)})};function qU($,J){return new s0({values:$,typeName:W$.ZodEnum,...H$(J)})}class s0 extends F${_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),X=this._def.values;return n(J,{expected:Z$.joinValues(X),received:J.parsedType,code:u.invalid_type}),Y$}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),X=this._def.values;return n(J,{received:J.data,code:u.invalid_enum_value,options:X}),Y$}return FJ($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return s0.create($,{...this._def,...J})}exclude($,J=this._def){return s0.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...J})}}s0.create=qU;class GX extends F${_parse($){let J=Z$.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==m.string&&X.parsedType!==m.number){let Q=Z$.objectValues(J);return n(X,{expected:Z$.joinValues(Q),received:X.parsedType,code:u.invalid_type}),Y$}if(!this._cache)this._cache=new Set(Z$.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=Z$.objectValues(J);return n(X,{received:X.data,code:u.invalid_enum_value,options:Q}),Y$}return FJ($.data)}get enum(){return this._def.values}}GX.create=($,J)=>{return new GX({values:$,typeName:W$.ZodNativeEnum,...H$(J)})};class RQ extends F${unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==m.promise&&J.common.async===!1)return n(J,{code:u.invalid_type,expected:m.promise,received:J.parsedType}),Y$;let X=J.parsedType===m.promise?J.data:Promise.resolve(J.data);return FJ(X.then((Q)=>{return this._def.type.parseAsync(Q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}RQ.create=($,J)=>{return new RQ({type:$,typeName:W$.ZodPromise,...H$(J)})};class tJ extends F${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===W$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=this._def.effect||null,Y={addIssue:(G)=>{if(n(X,G),G.fatal)J.abort();else J.dirty()},get path(){return X.path}};if(Y.addIssue=Y.addIssue.bind(Y),Q.type==="preprocess"){let G=Q.transform(X.data,Y);if(X.common.async)return Promise.resolve(G).then(async(W)=>{if(J.value==="aborted")return Y$;let U=await this._def.schema._parseAsync({data:W,path:X.path,parent:X});if(U.status==="aborted")return Y$;if(U.status==="dirty")return FQ(U.value);if(J.value==="dirty")return FQ(U.value);return U});else{if(J.value==="aborted")return Y$;let W=this._def.schema._parseSync({data:G,path:X.path,parent:X});if(W.status==="aborted")return Y$;if(W.status==="dirty")return FQ(W.value);if(J.value==="dirty")return FQ(W.value);return W}}if(Q.type==="refinement"){let G=(W)=>{let U=Q.refinement(W,Y);if(X.common.async)return Promise.resolve(U);if(U instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(X.common.async===!1){let W=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return Y$;if(W.status==="dirty")J.dirty();return G(W.value),{status:J.value,value:W.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((W)=>{if(W.status==="aborted")return Y$;if(W.status==="dirty")J.dirty();return G(W.value).then(()=>{return{status:J.value,value:W.value}})})}if(Q.type==="transform")if(X.common.async===!1){let G=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!n0(G))return Y$;let W=Q.transform(G.value,Y);if(W instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:W}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((G)=>{if(!n0(G))return Y$;return Promise.resolve(Q.transform(G.value,Y)).then((W)=>({status:J.value,value:W}))});Z$.assertNever(Q)}}tJ.create=($,J,X)=>{return new tJ({schema:$,typeName:W$.ZodEffects,effect:J,...H$(X)})};tJ.createWithPreprocess=($,J,X)=>{return new tJ({schema:J,effect:{type:"preprocess",transform:$},typeName:W$.ZodEffects,...H$(X)})};class sJ extends F${_parse($){if(this._getType($)===m.undefined)return FJ(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}sJ.create=($,J)=>{return new sJ({innerType:$,typeName:W$.ZodOptional,...H$(J)})};class S0 extends F${_parse($){if(this._getType($)===m.null)return FJ(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}S0.create=($,J)=>{return new S0({innerType:$,typeName:W$.ZodNullable,...H$(J)})};class WX extends F${_parse($){let{ctx:J}=this._processInputParams($),X=J.data;if(J.parsedType===m.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}WX.create=($,J)=>{return new WX({innerType:$,typeName:W$.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...H$(J)})};class UX extends F${_parse($){let{ctx:J}=this._processInputParams($),X={...J,common:{...J.common,issues:[]}},Q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(aQ(Q))return Q.then((Y)=>{return{status:"valid",value:Y.status==="valid"?Y.value:this._def.catchValue({get error(){return new TJ(X.common.issues)},input:X.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new TJ(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}UX.create=($,J)=>{return new UX({innerType:$,typeName:W$.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...H$(J)})};class GY extends F${_parse($){if(this._getType($)!==m.nan){let X=this._getOrReturnCtx($);return n(X,{code:u.invalid_type,expected:m.nan,received:X.parsedType}),Y$}return{status:"valid",value:$.data}}}GY.create=($)=>{return new GY({typeName:W$.ZodNaN,...H$($)})};var pz=Symbol("zod_brand");class y9 extends F${_parse($){let{ctx:J}=this._processInputParams($),X=J.data;return this._def.type._parse({data:X,path:J.path,parent:J})}unwrap(){return this._def.type}}class WY extends F${_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Y=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return Y$;if(Y.status==="dirty")return J.dirty(),FQ(Y.value);else return this._def.out._parseAsync({data:Y.value,path:X.path,parent:X})})();else{let Q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return Y$;if(Q.status==="dirty")return J.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:X.path,parent:X})}}static create($,J){return new WY({in:$,out:J,typeName:W$.ZodPipeline})}}class MX extends F${_parse($){let J=this._def.innerType._parse($),X=(Q)=>{if(n0(Q))Q.value=Object.freeze(Q.value);return Q};return aQ(J)?J.then((Q)=>X(Q)):X(J)}unwrap(){return this._def.innerType}}MX.create=($,J)=>{return new MX({innerType:$,typeName:W$.ZodReadonly,...H$(J)})};function MU($,J){let X=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function KU($,J={},X){if($)return LQ.create().superRefine((Q,Y)=>{let G=$(Q);if(G instanceof Promise)return G.then((W)=>{if(!W){let U=MU(J,Q),M=U.fatal??X??!0;Y.addIssue({code:"custom",...U,fatal:M})}});if(!G){let W=MU(J,Q),U=W.fatal??X??!0;Y.addIssue({code:"custom",...W,fatal:U})}return});return LQ.create()}var dz={object:o$.lazycreate},W$;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(W$||(W$={}));var cz=($,J={message:`Input not instance of ${$.name}`})=>KU((X)=>X instanceof $,J),zU=oJ.create,EU=o0.create,nz=GY.create,iz=a0.create,FU=tQ.create,oz=NQ.create,az=JY.create,sz=eQ.create,rz=$X.create,tz=LQ.create,ez=i0.create,$E=q0.create,JE=QY.create,QE=aJ.create,XE=o$.create,YE=o$.strictCreate,GE=JX.create,WE=f9.create,UE=QX.create,ME=K0.create,OE=XY.create,VE=YY.create,HE=AQ.create,qE=rQ.create,KE=XX.create,zE=YX.create,EE=s0.create,FE=GX.create,NE=RQ.create,LE=tJ.create,AE=sJ.create,RE=S0.create,DE=tJ.createWithPreprocess,ZE=WY.create,BE=()=>zU().optional(),jE=()=>EU().optional(),TE=()=>FU().optional(),SE={string:($)=>oJ.create({...$,coerce:!0}),number:($)=>o0.create({...$,coerce:!0}),boolean:($)=>tQ.create({...$,coerce:!0}),bigint:($)=>a0.create({...$,coerce:!0}),date:($)=>NQ.create({...$,coerce:!0})};var IE=Y$;function VG($){if(CE($)===6)return!0;if($.includes("://")||$.includes("/")||$.includes(":"))return!1;if($==="localhost")return!0;if($.startsWith("*.")){let J=$.slice(2);if(!J.includes(".")||J.startsWith(".")||J.endsWith("."))return!1;let X=J.split(".");return X.length>=2&&X.every((Q)=>Q.length>0)}if($.includes("*"))return!1;return $.includes(".")&&!$.startsWith(".")&&!$.endsWith(".")}var HG='Invalid domain pattern. Must be a valid domain (e.g., "example.com"), a wildcard (e.g., "*.example.com"), or a bracketed IPv6 literal (e.g., "[::1]", "[2001:db8::1]:443"). Overly broad patterns like "*.com" or "*" are not allowed for security reasons.',h9=x.string().refine(VG,{message:HG});function LU($){let J=$.indexOf(":");return!(J!==-1&&$.indexOf(":",J+1)!==-1)||$.startsWith("[")}var PE=x.string().refine(($)=>LU($)&&VG(cX($).hostPattern),{message:HG+' An optional ":port" suffix (1-65535) restricts the entry to that port.'}),_E=x.string().refine(($)=>{if(!LU($))return!1;let{hostPattern:J}=cX($);return J==="*"||VG(J)},{message:HG+' In deniedDomains a bare "*" (deny-all) is also accepted, and an optional ":port" suffix (1-65535) restricts the entry to that port.'}),UY=x.string().min(1,"Path cannot be empty"),NU=x.string().min(1,"Path cannot be empty").refine(($)=>wE($),{message:"Binary path must be absolute"}),xE=x.object({socketPath:x.string().min(1).describe("Unix socket path to the MITM proxy"),domains:x.array(h9).min(1).describe('Domains to route through the MITM proxy (e.g., ["api.example.com", "*.internal.org"])')}),vE=x.object({http:x.string().url().optional().describe("Upstream proxy URL for plain HTTP traffic"),https:x.string().url().optional().describe("Upstream proxy URL for HTTPS/CONNECT traffic (falls back to http if unset)"),noProxy:x.string().optional().describe("Comma-separated NO_PROXY list (hostname suffixes and CIDR ranges). Matching destinations connect directly instead of via the parent proxy.")}),AU=x.enum(["deny","mask"]),b9=x.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"Environment variable name must start with a letter or underscore and contain only letters, digits, and underscores"),RU=x.string().superRefine(($,J)=>{try{let{groupCount:X}=E7($);if(X<1)J.addIssue({code:x.ZodIssueCode.custom,message:"extract must contain at least one capturing group \u2014 group 1 is "+'the credential value to mask (e.g. "token:\\s*(\\S+)").'})}catch(X){J.addIssue({code:x.ZodIssueCode.custom,message:X instanceof Error?X.message:"Credential extract pattern is invalid"})}}),kE=x.object({path:UY.describe("Path to a credential file or directory. Supports the same path forms as filesystem.denyRead (absolute paths and ~ expansion)."),mode:AU.describe("Access mode for this path"),extract:RU.optional().describe('Optional regex for structured masking. Applied globally; capture group 1 of each match is masked, the rest of the file is preserved. If the pattern matches nothing, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),onExtractNoMatch:x.enum(["warn","deny","error"]).optional().describe("What to do when extract matches nothing (or, with decode, no "+'candidate verifies): "warn" (default \u2014 stderr warning, file left '+'readable), "deny" (degrade to mode "deny" \u2014 file unreadable), or '+'"error" (throw at wrap time). Only meaningful with mode "mask" and extract or decode set.'),decode:x.enum(["jwt"]).optional().describe('Optional encoded-credential format. "jwt": decodes recognized JWTs so masking can target fields inside them (see maskClaims). Candidates are located with a built-in JWT regex (or the explicit extract pattern, if set) and verified to actually be JWTs before masking. Without maskClaims, the whole decoded value is treated as the credential and replaced with a structurally valid fake JWT, so client-side token parsing keeps working. If no candidate verifies, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),maskClaims:x.array(x.string().min(1)).optional().describe('Names of top-level payload claims to mask inside each decoded value, instead of replacing the whole token. Each named claim present with a string value gets its own sentinel; all other claims are preserved so claim-reading clients keep working. Requires decode. If no named claim matches in any verified token, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),maskDuplicates:x.boolean().optional().describe("If true, verbatim occurrences of each captured credential value outside the regex-matched spans are also replaced with the "+"corresponding sentinel \u2014 for a secret repeated where the regex "+`does not reach (e.g. in a comment). Matches raw substrings: short or common credential values may corrupt unrelated content, so this is intended for long, high-entropy secrets. With decode, only values that passed verification are scanned; duplicates reuse the verified value's fake without re-verification. Defaults to false. Only meaningful with mode "mask" and extract or decode set; accepted but ignored otherwise.`),injectHosts:x.array(h9).optional().describe("Optional narrowing of where the proxy substitutes this credential. "+"If unset, defaults to network.allowedDomains \u2014 the credential is "+'injected at every reachable host. Only meaningful when mode is "mask"; accepted but ignored for "deny".')}),fE=x.object({name:b9.describe("Environment variable name"),mode:AU.describe("Access mode for this environment variable"),extract:RU.optional().describe('Optional regex for structured masking. Applied globally; capture group 1 of each match is masked, the rest of the value is preserved. If the pattern matches nothing, behaviour is governed by onExtractNoMatch (default "warn"). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),onExtractNoMatch:x.enum(["warn","deny","error"]).optional().describe('What to do when extract matches nothing: "warn" (default \u2014 stderr '+'warning, variable passes through unmasked), "deny" (variable unset inside the sandbox), or "error" (throw at wrap time). Only meaningful with mode "mask" and extract set.'),decode:x.enum(["jwt"]).optional().describe(`Optional encoded-credential format. "jwt": the variable's whole value is verified to actually be a JWT and replaced with a structurally valid fake JWT so client-side token parsing keeps working; the proxy swaps the whole fake token on egress. If the value does not verify, the variable is left unmasked with a stderr warning (fail-open). Only meaningful when mode is "mask"; accepted but ignored for "deny".`),maskClaims:x.array(x.string().min(1)).optional().describe('Names of top-level payload claims to mask inside the decoded value, instead of replacing the whole token. Each named claim present with a string value gets its own sentinel; all other claims are preserved so claim-reading clients keep working. Requires decode. If no named claim matches, the variable is left unmasked with a stderr warning (fail-open). Only meaningful when mode is "mask"; accepted but ignored for "deny".'),injectHosts:x.array(h9).optional().describe("Optional narrowing of where the proxy substitutes this credential. "+"If unset, defaults to network.allowedDomains \u2014 the credential is "+'injected at every reachable host. Only meaningful when mode is "mask"; accepted but ignored for "deny".')}),yE=x.object({accessKeyIdVar:b9.describe("Name of the masked env var holding the AWS access key id."),secretAccessKeyVar:b9.describe("Name of the masked env var holding the AWS secret access key."),sessionTokenVar:b9.optional().describe("Optional name of the masked env var holding the AWS session token (temporary credentials). When set, the proxy sends the real token as x-amz-security-token on re-signed requests and adds it to the signed header set if the client did not.")}).strict(),OG=x.enum(["deny","passthrough"]),bE=x.object({streaming:OG.optional().describe('Policy for aws-chunked streaming uploads (x-amz-content-sha256: STREAMING-*): per-chunk signatures chain off the seed signature, so re-signing would require rewriting the body. Default "deny".'),presigned:OG.optional().describe('Policy for presigned URLs (X-Amz-Algorithm/X-Amz-Signature in the query, no Authorization header): the signature lives in the URL itself. Default "deny".'),sigv4a:OG.optional().describe('Policy for SigV4A (AWS4-ECDSA-P256-SHA256) asymmetric signatures: there is no shared-key HMAC to recompute. Default "deny".')}).strict(),DU=x.object({files:x.array(kE).optional().describe("Credential files or directories to protect"),envVars:x.array(fE).optional().describe("Environment variables to protect"),allowPlaintextInject:x.boolean().optional().describe("Allow sentinel\u2192real substitution on the plain-HTTP proxy path. "+"Defaults to false: without TLS termination the upstream identity is unverified and the credential travels in cleartext. Set only for trusted-network test fixtures."),awsPairs:x.array(yE).optional().describe("Explicit groupings of masked env vars into AWS credential pairs for SigV4 re-signing, for non-standard variable names. The conventional AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN trio is paired automatically when masked."),sigv4:bE.optional().describe('Policies for AWS SigV4 request shapes the proxy cannot re-sign (streaming, presigned, sigv4a) when they reference a masked credential pair: "deny" (default) or "passthrough".')}).strict(),ZU=x.object({allowedDomains:x.array(PE).describe('List of allowed domains (e.g., ["github.com", "*.npmjs.org", "api.example.com:443"]). An optional ":port" suffix restricts the entry to that destination port.'),deniedDomains:x.array(_E).describe('List of denied domains. Unlike allowedDomains, a bare "*" is accepted here (deny-all). An optional ":port" suffix (e.g., "*:22") restricts the entry to that destination port.'),deniedDomainReasons:x.record(x.string(),x.string().min(1)).optional().describe('Optional model-facing reason keyed by the exact deniedDomains entry it explains (e.g., {"github.com:22": "SSH pushes to GitHub are blocked; use an https remote"}). Reported in the <sandbox_violations> line when that entry denies a connection; entries without one use a generic reason. Keys are matched by exact entry string, so a key with no matching deniedDomains entry never fires.'),strictAllowlist:x.boolean().optional().describe("If true, hosts not in allowedDomains are denied without consulting the ask callback. Set this when allowedDomains is policy enforcement, not a prompt-suppression hint."),allowUnixSockets:x.array(x.string()).optional().describe("macOS only: Unix socket paths to allow. Ignored on Linux (seccomp cannot filter by path)."),allowAllUnixSockets:x.boolean().optional().describe("If true, allow all Unix sockets (disables blocking on both platforms)."),allowLocalBinding:x.boolean().optional().describe("Whether to allow binding to local ports (default: false)"),allowMachLookup:x.array(x.string().refine(($)=>{return!($.endsWith("*")?$.slice(0,-1):$).includes("*")},{message:'Wildcards are only allowed as a single trailing "*" (e.g., "com.example.*" or "*" for all services).'})).optional().describe('macOS only: Additional XPC/Mach service names to allow looking up. Supports trailing-wildcard prefix matching (e.g., "2BUA8C4S2C.com.1password.*"). Needed for tools like 1Password CLI, Playwright, or the iOS Simulator that communicate via XPC.'),httpProxyPort:x.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:x.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."),mitmProxy:xE.optional().describe("Optional MITM proxy configuration. Routes matching domains through an upstream proxy via Unix socket while SRT still handles allow/deny filtering."),filterRequest:x.custom(($)=>typeof $==="function",{message:"filterRequest must be a function"}).optional().describe("Per-request filter callback. Receives the parsed HTTP request (web-standard Request) and returns {action, reason?}. Denied requests get a 403 with the reason. If the callback throws, the request is denied. Applies to plain HTTP through the proxy and, when tlsTerminate is configured, to terminated HTTPS. SRT does not provide a policy language; library consumers own matching."),tlsTerminate:x.object({caCertPath:x.string().min(1).optional().describe("Path to a PEM-encoded CA certificate. The sandboxed child is configured to trust this CA, and the TLS-terminating proxy uses it to sign per-host certificates. If omitted, on Windows SRT generates-if-absent a persistent CA under %ProgramData%\\sandbox-runtime\\ca\\ and trusts it in the sandbox user's Root store; on other platforms SRT generates an ephemeral CA into a temp directory for the lifetime of the session."),caKeyPath:x.string().min(1).optional().describe("Path to the PEM-encoded private key for caCertPath."),excludeDomains:x.array(h9).optional().describe("Domain patterns (same syntax as allowedDomains) whose HTTPS connections are NOT terminated. Matching CONNECTs are opaque byte tunnels: still subject to the allow/deny domain lists, but the sandboxed client completes its own TLS handshake with the upstream, so filterRequest and credential injection do not apply to their HTTPS traffic (plain-HTTP requests to the same hosts keep the normal request pipeline). Use for hosts the proxy must not re-originate: mTLS upstreams (only the client holds the client certificate) and clients that pin the upstream certificate and would reject the MITM CA. Hosts still need to be reachable via allowedDomains; this list only changes how they are tunnelled."),extraCaCertPaths:x.array(x.string().min(1)).optional().describe("Paths to PEM CA certificate files appended to the trust bundle the sandboxed child is pointed at, after the MITM CA and the host's regular roots. Use for site-local roots (e.g. an internal mTLS CA) presented by excluded/passthrough hosts, so the child can verify them itself. Only the CERTIFICATE blocks of each file are copied; files that are missing, unreadable, or contain no PEM CERTIFICATE block are skipped (with a debug log), so paths that exist on only some hosts are safe to list.")}).refine(($)=>!$.caCertPath===!$.caKeyPath,{message:"caCertPath and caKeyPath must be provided together"}).optional().describe("[EXPERIMENTAL] Enable in-process TLS termination so HTTPS request/response bodies are visible to SRT. Provide a CA cert+key, or omit both to have SRT generate an ephemeral one."),parentProxy:vE.optional().describe("Upstream HTTP proxy for outbound connections. When set, SRT's proxy tunnels non-mitmProxy traffic through this parent instead of connecting directly. Falls back to HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars if unset.")}),BU=x.object({disabled:x.boolean().optional().describe("Disable all filesystem policy enforcement. When true, no read or write rules are emitted: denyRead/allowRead/allowWrite/denyWrite are ignored, and the built-in mandatory write protections (.git/hooks, .git/config, shell rc files, .mcp.json, .vscode/.idea, .claude/commands, .claude/agents) are NOT applied. Use only when the sandboxed process is trusted with full host filesystem access. Network and credential-env restrictions still apply. On Linux, /dev is still replaced by the bwrap minimal devtmpfs."),denyRead:x.array(UY).describe("Paths denied for reading"),allowRead:x.array(UY).optional().describe("Paths to re-allow reading within denied regions (takes precedence over denyRead). Use with denyRead to deny a broad region then allow back specific subdirectories."),allowWrite:x.array(UY).describe("Paths allowed for writing"),denyWrite:x.array(UY).describe("Paths denied for writing (takes precedence over allowWrite)"),allowGitConfig:x.boolean().optional().describe("Allow writes to .git/config files (default: false). Enables git remote URL updates while keeping .git/hooks protected.")}),jU=x.record(x.string(),x.array(x.string())).describe('Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands'),TU=x.object({command:x.string().describe("The ripgrep command to execute"),args:x.array(x.string()).optional().describe("Additional arguments to pass before ripgrep args"),argv0:x.string().optional().describe("Override argv[0] when spawning (for multicall binaries that dispatch on argv[0])")}),SU=x.object({safeDirectories:x.array(x.string()).default([]).describe("Directories git should treat as safe (`safe.directory`) even though they're owned by a different user inside the sandbox. Use for the repo top-level when launching from a subdirectory. Does NOT grant write.")}),IU=x.object({path:x.string().min(1).describe("Path to the srt-win binary. Pass the exported VENDORED_SRT_WIN_EXE constant to use the packaged vendor/srt-win/<arch>/srt-win.exe (see its WARNING: in a dev checkout that file may sit inside your sandbox write grant). The binary is spawned with the `--srt-win` argv[1] sentinel so a multicall dispatcher can route to srt-win's CLI.")}),CU=x.object({sandboxUser:x.string().min(1).max(20,"Windows local usernames are limited to 20 characters").optional().describe("Name for the dedicated sandbox user account that `srt-win install` creates and the sandboxed child runs as. Default: `srt-sandbox`. Install refuses if an account by this name already exists and srt-win did not create it (it will not rotate the password of an account it does not own). Must match what `srt-win install --sandbox-user` was run with."),sublayerGuid:x.string().uuid().optional().describe("WFP sublayer GUID under which the filters were installed. Omit to use the srt-win compile-time default. Set this when filters were installed by enterprise tooling under a custom sublayer."),wfpSublayerGuid:x.string().uuid().optional().describe("Deprecated alias for sublayerGuid."),proxyPortRange:x.tuple([x.number().int().min(1),x.number().int().max(65535)]).refine(([$,J])=>$<=J&&J-$<=64,{message:"low must be \u2264 high and range width \u2264 64"}).optional().describe("Inclusive [low, high] port range the JS mux proxy listeners bind inside. MUST match the range passed to `srt-win install "+"--proxy-port-range` (default 60080\u201360089) \u2014 the WFP loopback "+"permit only covers ports in that range."),srtWin:IU.optional().describe("How to locate/invoke the srt-win helper binary. `srtWin.path` is "+"required to use the Windows sandbox \u2014 your own (multicall) binary, "+"or the exported VENDORED_SRT_WIN_EXE constant for the packaged exe.")}),hE=x.object({applyPath:x.string().optional().describe("Path to the apply-seccomp binary"),argv0:x.string().optional().describe("Invoke apply-seccomp as a multicall binary that dispatches on the ARGV0 environment variable. When set, applyPath is used verbatim (no existence check) and the invocation inside bwrap is prefixed with ARGV0=<this value>. The caller is responsible for ensuring applyPath resolves inside the bwrap namespace and that the target binary implements the apply-seccomp interface when ARGV0 matches.")}),uE=x.object({network:ZU.describe("Network restrictions configuration"),filesystem:BU.describe("Filesystem restrictions configuration"),credentials:DU.optional().describe("Credential handling configuration. Only the explicitly declared files and environment variables are restricted."),ignoreViolations:jU.optional().describe("Optional configuration for ignoring specific violations"),enableWeakerNestedSandbox:x.boolean().optional().describe("Enable weaker nested sandbox mode (for Docker environments)"),runAsUid:x.number().int().nonnegative().optional().describe("ARA: uid to drop the sandboxed command to (bwrap --uid)"),runAsGid:x.number().int().nonnegative().optional().describe("ARA: gid to drop the sandboxed command to (bwrap --gid)"),runAsHostUid:x.number().int().positive().optional().describe("ARA: real host uid used to launch the sandboxed bwrap child"),runAsHostGid:x.number().int().positive().optional().describe("ARA: real host gid used to launch the sandboxed bwrap child"),runAsHostHome:x.string().min(1).optional().describe("ARA: HOME set inside a real-host-uid sandbox child"),runAsHostUser:x.string().min(1).optional().describe("ARA: USER and LOGNAME set inside a real-host-uid sandbox child"),enableWeakerNetworkIsolation:x.boolean().optional().describe("Enable weaker network isolation to allow access to com.apple.trustd.agent (macOS only). This is needed for Go programs (gh, gcloud, terraform, kubectl, etc.) to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Enabling this opens a potential data exfiltration vector through the trustd service. Only enable if you need Go TLS verification."),allowAppleEvents:x.boolean().optional().describe("Allow sending Apple Events and Launch Services open requests from the sandbox (macOS only). Needed for open, osascript, and anything that opens URLs or scripts other apps via AppleScript. This removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt (launched apps are not subject to the sandbox filesystem or network restrictions), and can script running apps subject to TCC automation consent. Default: false."),ripgrep:TU.optional().describe('Custom ripgrep configuration (default: { command: "rg" })'),mandatoryDenySearchDepth:x.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:x.boolean().optional().describe("Allow pseudo-terminal (pty) operations (macOS only)"),seccomp:hE.optional().describe("Custom seccomp binary paths (Linux only)."),bwrapPath:NU.optional().describe('Linux only: absolute path to the bwrap (bubblewrap) binary. When set, this path is used directly instead of resolving "bwrap" via PATH.'),socatPath:NU.optional().describe('Linux only: absolute path to the socat binary. When set, this path is used directly instead of resolving "socat" via PATH.'),windows:CU.optional().describe("Windows-specific settings (WFP sublayer, proxy port range)."),git:SU.optional().describe("Git configuration to inject via GIT_CONFIG_* env vars (cross-platform). `safeDirectories` marks paths as `safe.directory` without adding them to `filesystem.allowWrite`.")}).superRefine(($,J)=>{let X=$.credentials;if(!X)return;let Q=$.network.allowedDomains.map(nX),Y=(M,O)=>{for(let[V,H]of M.entries())if(!I9(H,Q))J.addIssue({code:x.ZodIssueCode.custom,path:[...O,V],message:`injectHosts entry "${H}" is not reachable via `+`network.allowedDomains \u2014 add "${H}" (or a covering wildcard) to allowedDomains, or remove it from injectHosts.`})},G=!1,W=(M,O)=>{if(M.injectHosts)Y(M.injectHosts,[...O,"injectHosts"]);if(M.mode!=="mask")return;G=!0;let V=$.network.tlsTerminate?.excludeDomains;if(V?.length){if(M.injectHosts){for(let[H,q]of M.injectHosts.entries())if(I9(q,V))J.addIssue({code:x.ZodIssueCode.custom,path:[...O,"injectHosts",H],message:`injectHosts entry "${q}" is entirely covered by network.tlsTerminate.excludeDomains. Credential injection only runs on TLS-terminated connections, so this host would receive the placeholder instead of the credential. Remove it from one of the two lists.`})}else if(Q.length>0&&Q.every((H)=>I9(H,V)))J.addIssue({code:x.ZodIssueCode.custom,path:O,message:"This masked credential has no injectHosts, so it defaults "+"to network.allowedDomains \u2014 but "+"network.tlsTerminate.excludeDomains covers every allowed domain, so it could never be injected anywhere. Credential injection only runs on TLS-terminated connections."})}if(M.injectHosts!==void 0&&M.injectHosts.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:O,message:"injectHosts is explicitly empty \u2014 the credential would be "+"masked but never injected. Omit injectHosts to default to network.allowedDomains, or list the intended hosts."})};for(let[M,O]of(X.envVars??[]).entries()){if(W(O,["credentials","envVars",M]),O.maskClaims!==void 0&&O.decode===void 0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","envVars",M,"maskClaims"],message:"maskClaims requires decode \u2014 it names claims inside the "+'decoded payload. Set decode (e.g. "jwt"), or remove maskClaims to mask the whole value.'});if(O.maskClaims!==void 0&&O.maskClaims.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","envVars",M,"maskClaims"],message:"maskClaims is explicitly empty \u2014 no claim would ever be "+"masked. Omit maskClaims to mask the whole token, or list the claims to protect."})}for(let[M,O]of(X.files??[]).entries()){if(W(O,["credentials","files",M]),O.maskClaims!==void 0&&O.decode===void 0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",M,"maskClaims"],message:"maskClaims requires decode \u2014 it names claims inside the "+'decoded payload. Set decode (e.g. "jwt"), or remove maskClaims to mask the extracted value whole.'});if(O.maskClaims!==void 0&&O.maskClaims.length===0)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",M,"maskClaims"],message:"maskClaims is explicitly empty \u2014 no claim would ever be "+"masked. Omit maskClaims to mask the whole token, or list the claims to protect."});if(O.mode==="mask"&&O.path.endsWith("/"))J.addIssue({code:x.ZodIssueCode.custom,path:["credentials","files",M,"path"],message:`Credential mode "mask" applies to a single file, not a directory. Use mode "deny" for "${O.path}", or point at the credential file inside it.`})}let U=new Set;for(let[M,O]of(X.awsPairs??[]).entries()){let V=[["accessKeyIdVar",O.accessKeyIdVar],["secretAccessKeyVar",O.secretAccessKeyVar]];if(O.sessionTokenVar!==void 0)V.push(["sessionTokenVar",O.sessionTokenVar]);for(let[H,q]of V){let F=["credentials","awsPairs",M,H];if(U.has(q)){J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" appears in more than one awsPairs slot (within `+"or across pairs) \u2014 each variable can fill exactly one slot."});continue}U.add(q);let K=(X.envVars??[]).find((A)=>A.name===q);if(K===void 0||K.mode!=="mask")J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" does not reference a credentials.envVars entry `+'with mode "mask" \u2014 an AWS pair links already-masked '+"variables; add the entry (masking is the opt-in for SigV4 re-signing)."});else if(K.extract!==void 0||K.decode!==void 0)J.addIssue({code:x.ZodIssueCode.custom,path:F,message:`"${q}" uses extract/decode, but an AWS pair member must be masked whole-value: the SigV4 trigger is an exact match of the fake access key id, and the signer needs the entire real value.`})}}if(G&&$.network.tlsTerminate===void 0&&!X.allowPlaintextInject)J.addIssue({code:x.ZodIssueCode.custom,path:["credentials"],message:"Credential masking requires network.tlsTerminate so substitution runs only over a verified TLS connection. Enable tlsTerminate, or set credentials.allowPlaintextInject to opt out (not recommended)."})});export{I5 as windowsTrustCaAsync,jK as windowsTrustCa,w5 as windowsStateDir,u7 as windowsInstallInstructions,p7 as verifyWindowsWfpEgress,xX as validateCaPair,IK as uninstallWindowsSandbox,o7 as stampWindowsAcl,S9 as revokeWindowsAcl,T9 as restoreWindowsAcl,wJ as resolveSrtWin,CK as parseWindowsSandboxError,D9 as parseWindowsBinShell,qX as isUncPath,SK as installWindowsSandboxAsync,TK as installWindowsSandbox,a7 as grantWindowsAcl,m9 as getWslVersion,S5 as getWindowsWfpStatusAsync,T5 as getWindowsWfpStatus,dX as getWindowsSandboxUserStatusAsync,d7 as getWindowsSandboxUserStatus,c7 as getWindowsSandboxCaCert,BK as getSrtWinPath,DQ as getDefaultWritePaths,oY as generateCa,j9 as expandWindowsFsPaths,n7 as ensurePersistentWindowsCa,j5 as checkWindowsSandboxStatusAsync,B5 as checkWindowsSandboxStatus,s7 as checkWindowsDependenciesAsync,gQ as certThumbprint,KX as buildGitConfigEnv,L$ as WindowsSandboxError,CU as WindowsConfigSchema,ZK as VENDORED_SRT_WIN_EXE,IU as SrtWinConfigSchema,L9 as SandboxViolationStore,uE as SandboxRuntimeConfigSchema,Nz as SandboxManager,A5 as SRT_WIN_DISPATCH_ARG1,TU as RipgrepConfigSchema,ZU as NetworkConfigSchema,jU as IgnoreViolationsConfigSchema,SU as GitConfigSchema,BU as FilesystemConfigSchema,R9 as DEFAULT_WINDOWS_PROXY_PORT_RANGE,DU as CredentialsConfigSchema};
|