@limrun/ui 0.9.0-rc.14 → 0.9.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/components/remote-control.d.ts +125 -1
  2. package/dist/core/device-install/apple/provisioning.d.ts +55 -4
  3. package/dist/core/device-install/operations/limbuild-client.d.ts +15 -1
  4. package/dist/core/device-install/storage/browser-storage.d.ts +9 -5
  5. package/dist/core/device-install/types.d.ts +4 -1
  6. package/dist/device-install/index.cjs +1 -1
  7. package/dist/device-install/index.js +70 -64
  8. package/dist/device-install/react.cjs +1 -1
  9. package/dist/device-install/react.js +1 -1
  10. package/dist/device-install-dialog-DY35un0b.js +9 -0
  11. package/dist/device-install-dialog-chNLeiiL.mjs +2000 -0
  12. package/dist/device-install-dialog.css +1 -1
  13. package/dist/hooks/use-device-install.d.ts +5 -1
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.js +1286 -1116
  16. package/dist/use-device-install-BIrl0v-k.js +31 -0
  17. package/dist/{use-device-install-sDVvby1V.mjs → use-device-install-LGfEdqyM.mjs} +4388 -4271
  18. package/package.json +4 -2
  19. package/src/components/device-install/device-install-dialog.css +29 -0
  20. package/src/components/device-install/device-install-dialog.tsx +91 -30
  21. package/src/components/remote-control.tsx +535 -5
  22. package/src/core/device-install/apple/provisioning.test.ts +84 -0
  23. package/src/core/device-install/apple/provisioning.ts +91 -7
  24. package/src/core/device-install/operations/limbuild-client.ts +32 -2
  25. package/src/core/device-install/storage/browser-storage.ts +29 -14
  26. package/src/core/device-install/types.ts +5 -1
  27. package/src/hooks/use-device-install.ts +135 -59
  28. package/dist/device-install-dialog-CjH25hnN.js +0 -2
  29. package/dist/device-install-dialog-W5Xv9kWL.mjs +0 -443
  30. package/dist/use-device-install-Y1u6vIBB.js +0 -31
@@ -0,0 +1,31 @@
1
+ "use strict";const le=require("react");var Ds=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ls(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function i(){var d=!1;try{d=this instanceof i}catch{}return d?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var d=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,d.get?d:{enumerable:!0,get:function(){return t[i]}})}),r}var Ps=Object.defineProperty,Us=(t,e)=>{for(var r in e)Ps(t,r,{get:e[r],enumerable:!0})},Mt=self.crypto,ir={};Us(ir,{Hash:()=>ga,bigintFromBytes:()=>sr,bitLength:()=>Un,byteLength:()=>kn,bytesFromBigint:()=>Ze,concatBytes:()=>nt,constantTimeCompare:()=>Vn,fromHex:()=>oa,hash:()=>Ye,hashInterleave:()=>Fn,modPow:()=>kt,randomBytes:()=>ia,toHex:()=>bt,xorBytes:()=>On});function Un(t){return t.toString(2).length}function kn(t){return(Un(t)+7)/8|0}function sr(t){let e=0n;for(let r of t.values())e=(e<<8n)+BigInt(r);return e}function Ze(t){let e=new Uint8Array(kn(t));for(let r=e.length-1;t>0;r--,t>>=8n)e[r]=Number(t&0xffn);return e}function ia(t){if(t<1)throw new RangeError("numBytes must be >= 1");let e=new Uint8Array(t);return Mt.getRandomValues(e),e}function sa(t,e){if(e<1n)throw new RangeError("n must be > 0");let r=t%e;return r<0n?r+e:r}function ks(t,e){if(t<1n||e<1n)throw new RangeError("a and b must be > 0");let r=0n,i=1n,d=1n,v=0n;for(;t!==0n;){let c=e/t,a=e%t,g=r-d*c,f=i-v*c;e=t,t=a,r=d,i=v,d=g,v=f}return{g:e,x:r,y:i}}function Os(t,e){let r=ks(sa(t,e),e);if(r.g!==1n)throw new RangeError;return sa(r.x,e)}function kt(t,e,r){if(r<1n)throw new RangeError("n must be > 0");if(r===1n)return 0n;if(t=sa(t,r),e<0n)return Os(kt(t,e>=0?e:-e,r),r);let i=1n;for(;e>0;)e%2n===1n&&(i=i*t%r),e=e/2n,t=t**2n%r;return i}function nt(...t){let e=0;for(let d of t)e+=d.byteLength;let r=new Uint8Array(e),i=0;for(let d of t)r.set(d,i),i+=d.byteLength;return r}function On(t,e){if(t.length!==e.length)throw new Error("xorBytes: buffers must be same length");let r=t.length,i=new Uint8Array(r);for(let d=0;d<r;d++)i[d]=t[d]^e[d];return i}function bt(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function oa(t){return Uint8Array.from(t.match(/.{2}/g)?.map(e=>parseInt(e,16))??[])}function Vn(t,e){if(t.length!==e.length)return!1;let r=t.length,i=0;for(let d=0;d<r;d++)i|=t[d]^e[d];return i===0}var ga=(t=>(t[t.SHA1=3]="SHA1",t[t.SHA256=5]="SHA256",t[t.SHA384=6]="SHA384",t[t.SHA512=7]="SHA512",t))(ga||{});function Ye(t,e){switch(t){case 3:return Mt.subtle.digest("SHA-1",e);case 5:return Mt.subtle.digest("SHA-256",e);case 6:return Mt.subtle.digest("SHA-384",e);case 7:return Mt.subtle.digest("SHA-512",e)}}async function Fn(t,e){let r=new Uint8Array(e,0,e.byteLength);for(var i=0;i<r.length;i++)if(r[i]!==0){(e.byteLength-i)%2===1&&i++,r=new Uint8Array(e,i,e.byteLength-i);break}let d=r.length/2,v=new Uint8Array(d),c=new Uint8Array(d);for(let S=0;S<r.length;S++)v[S]=r[S*2],c[S]=r[S*2+1];let a=new Uint8Array(await Ye(t,v)),g=new Uint8Array(await Ye(t,c)),f=new Uint8Array(a.byteLength*2);for(let S=0;S<a.byteLength;S++)f[S*2]=a[S],f[S*2+1]=g[S];return f}var Kn=(t=>(t[t.RFC2945=0]="RFC2945",t[t.SRPTools=1]="SRPTools",t[t.GoSRP=2]="GoSRP",t[t.GSA=3]="GSA",t))(Kn||{}),Vs=new Map([[1024,{g:2n,N:0xeeaf0ab9adb38dd69c33f80afa8fc5e86072618775ff3c0b9ea2314c9c256576d674df7496ea81d3383b4813d692c6e0e0d5d8e250b98be48e495c1d6089dad15dc7d7b46154d6b6ce8ef4ad69b15d4982559b297bcf1885c529f566660e57ec68edbc3c05726cc02fd4cbf4976eaa9afd5138fe8376435b9fc61d2fc0eb06e3n,n:128}],[1536,{g:2n,N:0x9def3cafb939277ab1f12a8617a47bbbdba51df499ac4c80beeea9614b19cc4d5f4f5f556e27cbde51c6a94be4607a291558903ba0d0f84380b655bb9a22e8dcdf028a7cec67f0d08134b1c8b97989149b609e0be3bab63d47548381dbc5b1fc764e3f4b53dd9da1158bfd3e2b9c8cf56edf019539349627db2fd53d24b7c48665772e437d6c7f8ce442734af7ccb7ae837c264ae3a9beb87f8a2fe9b8b5292e5a021fff5e91479e8ce7a28c2442c6f315180f93499a234dcf76e3fed135f9bbn,n:192}],[2048,{g:2n,N:0xac6bdb41324a9a9bf166de5e1389582faf72b6651987ee07fc3192943db56050a37329cbb4a099ed8193e0757767a13dd52312ab4b03310dcd7f48a9da04fd50e8083969edb767b0cf6095179a163ab3661a05fbd5faaae82918a9962f0b93b855f97993ec975eeaa80d740adbf4ff747359d041d5c33ea71d281e446b14773bca97b43a23fb801676bd207a436c6481f1d2b9078717461a5b9d32e688f87748544523b524b0d57d5ea77a2775d2ecfa032cfbdbf52fb3786160279004e57ae6af874e7303ce53299ccc041c7bc308d82a5698f3a8d0c38271ae35f8e9dbfbb694b5c803d89f7ae435de236d525f54759b65e372fcd68ef20fa7111f9e4aff73n,n:256}],[3072,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffffn,n:384}],[4096,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffffn,n:512}],[6144,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffffn,n:768}],[8192,{g:19n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffffn,n:1024}]]);function Fs(t=0){t===0&&(t=2048);let e=Vs.get(t);if(!e)throw new Error(`Invalid prime field size ${t}`);return e}function tr(t,e){let r=Ze(t);if(r.length>=e)return r;let i=e-r.length,d=new Uint8Array(e);for(let v=0;v<i;v++)d[v]=0;return d.set(r,i),d}var Ks=class{constructor(t,e,r=0){this.m=t,this.h=e,this.pf=Fs(r)}pf;async hashInt(t){return sr(new Uint8Array(await Ye(this.h,t)))}async verifier(t,e,r){let i=this.m===2?new Uint8Array(await Ye(this.h,t)):t,d=this.m===2?new Uint8Array(await Ye(this.h,e)):e,v=this.pf;r||(r=ia(v.n));let c=this.m===2?await this.hashInt(nt(i,d,r)):await this.hashInt(nt(r,new Uint8Array(await Ye(this.h,nt(i,new Uint8Array([58]),d))))),a=kt(v.g,c,v.N);return new Ms({i,s:r,v:Ze(a),h:this.h,pf:v})}async newClient(t,e,r){let i=this.pf;return r||(r=sr(ia(i.n))),new qs({s:this,i:this.m===2?new Uint8Array(await Ye(this.h,t)):t,p:this.m===2?new Uint8Array(await Ye(this.h,e)):e,a:r,A:kt(i.g,r,i.N),k:await this.hashInt(nt(Ze(i.N),tr(i.g,Number(i.n))))})}},Ms=class{i;s;v;h;pf;constructor(t){this.i=t.i,this.s=t.s,this.v=t.v,this.h=t.h,this.pf=t.pf}encode(){let t=bt(this.i),e=[this.pf.n.toString(10),this.pf.N.toString(16),this.pf.g.toString(16),this.h.toString(10),t,bt(this.s),bt(this.v)].join(":");return[t,e]}},qs=class{s;i;p;a;A;k;_K;_M;get K(){return this._K}get M(){return this._M}constructor(t){this.s=t.s,this.i=t.i,this.p=t.p,this.a=t.a,this.A=t.A,this.k=t.k,this._K=new Uint8Array,this._M=new Uint8Array}credentials(){return[bt(this.i),bt(Ze(this.A))].join(":")}parseServerCredentials(t){let e=t.split(":");if(!e[0]||!e[1])throw new Error("Invalid server public key");let r=oa(e[0]),i=oa(e[1]);return[r,i]}async generate(t,e){let r=sr(e),i=this.s.pf;if(r%i.N===0n)throw new Error("Invalid server public key");let d=await this.s.hashInt(nt(tr(this.A,i.n),tr(r,i.n)));if(d===0n)throw new Error("Invalid server public key");let v=this.s.m===2?await this.s.hashInt(nt(this.i,this.p,t)):await this.s.hashInt(nt(t,new Uint8Array(await Ye(this.s.h,nt(this.s.m==3?new Uint8Array([]):this.i,new Uint8Array([58]),this.p))))),c=kt(i.g,v,i.N)*this.k,a=r-c,g=this.a+d*v,f=kt(a,g,i.N);return this._K=this.s.m===0?new Uint8Array(await Fn(this.s.h,Ze(f))):new Uint8Array(await Ye(this.s.h,Ze(f))),this.s.m===2?this._M=new Uint8Array(await Ye(this.s.h,nt(this._K,Ze(this.A),Ze(r),this.i,t,Ze(i.N),Ze(i.g)))):this._M=new Uint8Array(await Ye(this.s.h,nt(On(new Uint8Array(await Ye(this.s.h,Ze(i.N))),new Uint8Array(await Ye(this.s.h,this.s.m==3?tr(i.g,i.n):Ze(i.g)))),new Uint8Array(await Ye(this.s.h,this.i)),t,Ze(this.A),Ze(r),this._K))),bt(this._M)}async generateM2(){if(!this.M)throw new Error("M not generated");return new Uint8Array(await Ye(this.s.h,nt(Ze(this.A),this._M,this._K)))}async serverOk(t){let e=new TextEncoder,r=e.encode(bt(new Uint8Array(await Ye(this.s.h,nt(this._K,this.M))))),i=e.encode(t);return Vn(r,i)}};const Mn=new Ks(Kn.GSA,ga.SHA256,2048);class qn{constructor(e){this.accountName=e}srpClient;async init(){if(this.srpClient)throw new Error("SRP client is already initialized.");return this.srpClient=await Mn.newClient(ca(this.accountName),new Uint8Array),{accountName:this.accountName,protocols:["s2k","s2k_fo"],a:vr(ir.bytesFromBigint(this.srpClient.A))}}async complete(e,r){if(!this.srpClient)throw new Error("SRP client is not initialized.");if(r.protocol!=="s2k"&&r.protocol!=="s2k_fo")throw new Error(`Unsupported Apple SRP protocol ${r.protocol}.`);const i=Ua(r.salt),d=Ua(r.b),v=await Hs(r.protocol,e,i,r.iteration);this.srpClient.p=v,await this.srpClient.generate(i,d);const c=await this.srpClient.generateM2();return{accountName:this.accountName,c:r.c,m1:vr(this.srpClient._M),m2:vr(c)}}}async function Hs(t,e,r,i){let d=new Uint8Array(await ir.hash(Mn.h,gr(ca(e))));t==="s2k_fo"&&(d=ca(ir.toHex(d)));const v=await crypto.subtle.importKey("raw",gr(d),{name:"PBKDF2"},!1,["deriveBits"]),c=await crypto.subtle.deriveBits({name:"PBKDF2",hash:{name:"SHA-256"},iterations:i,salt:gr(r)},v,256);return new Uint8Array(c)}function ca(t){return new TextEncoder().encode(t)}function vr(t){let e="";for(const r of t)e+=String.fromCharCode(r);return btoa(e)}function Ua(t){const e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i+=1)r[i]=e.charCodeAt(i);return r}function gr(t){const e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}async function Hn(t,e){const r=await fetch(Et(t,"/apple/auth/session",e),{method:"POST",headers:Jn(e)});if(!r.ok)throw new Error(`Apple relay session failed: HTTP ${r.status} ${await r.text()}`);return await r.json()}async function ua(t,e,r){const i=await fetch(Et(t,"/apple/auth/session/delete",r),{method:"POST",headers:It(r),body:JSON.stringify({appleSessionId:e})});if(!i.ok)throw new Error(`Apple relay session delete failed: HTTP ${i.status} ${await i.text()}`)}async function Gn(t,e,r,i){return Xn(t,"/apple/auth/srp/init",e,r,i)}async function zn(t,e,r,i){return Xn(t,"/apple/auth/srp/complete",e,r,i)}async function Qn(t,e,r){const i=await fetch(Et(t,"/apple/auth/2fa/trigger",r),{method:"POST",headers:It(r),body:JSON.stringify({appleSessionId:e})});if(!i.ok)throw new Error(`Apple 2FA trigger failed: HTTP ${i.status} ${await i.text()}`);return await i.json()}async function $n(t,e,r,i="sms",d){const v=await fetch(Et(t,"/apple/auth/2fa/phone/trigger",d),{method:"POST",headers:It(d),body:JSON.stringify({appleSessionId:e,phoneNumberId:r,mode:i})});if(!v.ok)throw new Error(`Apple phone 2FA trigger failed: HTTP ${v.status} ${await v.text()}`);return await v.json()}async function Wn(t,e,r,i){const d=await fetch(Et(t,"/apple/auth/2fa",i),{method:"POST",headers:It(i),body:JSON.stringify({appleSessionId:e,code:r})});if(!d.ok)throw new Error(`Apple 2FA proxy failed: HTTP ${d.status} ${await d.text()}`);return await d.json()}async function Yn(t,e,r,i,d="sms",v){const c=await fetch(Et(t,"/apple/auth/2fa/phone",v),{method:"POST",headers:It(v),body:JSON.stringify({appleSessionId:e,phoneNumberId:r,mode:d,code:i})});if(!c.ok)throw new Error(`Apple phone 2FA proxy failed: HTTP ${c.status} ${await c.text()}`);return await c.json()}async function jn(t,e,r){const i=await fetch(Et(t,"/apple/auth/finalize",r),{method:"POST",headers:It(r),body:JSON.stringify({appleSessionId:e})});if(!i.ok)throw new Error(`Apple session finalization failed: HTTP ${i.status} ${await i.text()}`);return await i.json()}async function it(t,e,r,i){const d=await fetch(Et(t,"/apple/provisioning",i),{method:"POST",headers:It(i),body:JSON.stringify({appleSessionId:e,...r})});if(!d.ok)throw new Error(`Apple provisioning proxy failed: HTTP ${d.status} ${await d.text()}`);return Zn(await d.json())}async function Xn(t,e,r,i,d){const v=await fetch(Et(t,e,d),{method:"POST",headers:It(d),body:JSON.stringify({appleSessionId:r,payload:i})});if(!v.ok)throw new Error(`Apple proxy ${e} failed: HTTP ${v.status} ${await v.text()}`);return Zn(await v.json())}function Zn(t){if(t.body!==void 0||!t.rawBody)return t;try{return{...t,body:JSON.parse(t.rawBody)}}catch{return t}}function Et(t,e,r){const i=t.replace(/\/$/,""),d=e.startsWith("/")?e:`/${e}`,v=new URL(`${i}${d}`);return r&&v.searchParams.set("token",r),v}function It(t){return{"Content-Type":"application/json",...Jn(t)}}function Jn(t){return t?{Authorization:`Bearer ${t}`}:{}}async function ei({limbuildApiUrl:t,accountName:e,password:r,token:i}){const{appleSessionId:d}=await Hn(t,i);try{const v=new qn(e),c=await Gn(t,d,await v.init(),i);if(c.status<200||c.status>=300)throw new Error(`Apple SRP init failed: HTTP ${c.status} ${c.rawBody??""}`.trim());if(!c.body)throw new Error("Apple SRP init response did not include a body.");const a=await v.complete(r,c.body),g=await zn(t,d,{...a,rememberMe:!1,trustTokens:[]},i),f=g.status===409;let S,P={type:"trustedDevice"};if(f){S=await Qn(t,d,i);const b=Gs(S.body);if(b&&(P={type:"phone",phoneNumberId:b.id,mode:b.pushMode??"sms"}),S.status===412){if(!b)throw new Error("Apple requested phone verification but did not include a trusted phone number.");S=await $n(t,d,b.id,b.pushMode??"sms",i)}if(S.status<200||S.status>=300)throw new Error(`Apple two-factor challenge failed: HTTP ${S.status} ${S.rawBody??""}`.trim())}else if(g.status<200||g.status>=300)throw new Error(`Apple SRP complete failed: HTTP ${g.status} ${g.rawBody??""}`.trim());return{appleSessionId:d,completeResponse:g,twoFactorChallengeResponse:S,requiresTwoFactor:f,finishTwoFactor:async b=>{const l=P.type==="phone"?await Yn(t,d,P.phoneNumberId,b,P.mode,i):await Wn(t,d,b,i);if(l.status<200||l.status>=300)throw new Error(`Apple two-factor code failed: HTTP ${l.status} ${l.rawBody??""}`.trim());return l},finalize:async()=>jn(t,d,i),close:()=>ua(t,d,i)}}catch(v){throw await ua(t,d,i).catch(()=>{}),v}}function Gs(t){if(!fa(t))return;const e=fa(t.phoneNumberVerification)?t.phoneNumberVerification:void 0,r=yr(e?.trustedPhoneNumber)??yr(t.trustedPhoneNumber)??yr(t.phoneNumber);if(!r)return;const i=r.id;if(typeof i!="number")return;const d=typeof r.pushMode=="string"?r.pushMode:typeof t.mode=="string"?t.mode:void 0;return{id:i,pushMode:d}}function yr(t){return fa(t)?t:void 0}function fa(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var mr,ka;function ve(){return ka||(ka=1,mr={options:{usePureJavaScript:!1}}),mr}var Cr={exports:{}},Er,Oa;function zs(){if(Oa)return Er;Oa=1;var t={};Er=t;var e={};t.encode=function(i,d,v){if(typeof d!="string")throw new TypeError('"alphabet" must be a string.');if(v!==void 0&&typeof v!="number")throw new TypeError('"maxline" must be a number.');var c="";if(!(i instanceof Uint8Array))c=r(i,d);else{var a=0,g=d.length,f=d.charAt(0),S=[0];for(a=0;a<i.length;++a){for(var P=0,b=i[a];P<S.length;++P)b+=S[P]<<8,S[P]=b%g,b=b/g|0;for(;b>0;)S.push(b%g),b=b/g|0}for(a=0;i[a]===0&&a<i.length-1;++a)c+=f;for(a=S.length-1;a>=0;--a)c+=d[S[a]]}if(v){var l=new RegExp(".{1,"+v+"}","g");c=c.match(l).join(`\r
2
+ `)}return c},t.decode=function(i,d){if(typeof i!="string")throw new TypeError('"input" must be a string.');if(typeof d!="string")throw new TypeError('"alphabet" must be a string.');var v=e[d];if(!v){v=e[d]=[];for(var c=0;c<d.length;++c)v[d.charCodeAt(c)]=c}i=i.replace(/\s/g,"");for(var a=d.length,g=d.charAt(0),f=[0],c=0;c<i.length;c++){var S=v[i.charCodeAt(c)];if(S===void 0)return;for(var P=0,b=S;P<f.length;++P)b+=f[P]*a,f[P]=b&255,b>>=8;for(;b>0;)f.push(b&255),b>>=8}for(var l=0;i[l]===g&&l<i.length-1;++l)f.push(0);return typeof Buffer<"u"?Buffer.from(f.reverse()):new Uint8Array(f.reverse())};function r(i,d){var v=0,c=d.length,a=d.charAt(0),g=[0];for(v=0;v<i.length();++v){for(var f=0,S=i.at(v);f<g.length;++f)S+=g[f]<<8,g[f]=S%c,S=S/c|0;for(;S>0;)g.push(S%c),S=S/c|0}var P="";for(v=0;i.at(v)===0&&v<i.length()-1;++v)P+=a;for(v=g.length-1;v>=0;--v)P+=d[g[v]];return P}return Er}var Va;function Ee(){if(Va)return Cr.exports;Va=1;var t=ve(),e=zs(),r=Cr.exports=t.util=t.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){r.nextTick=process.nextTick,typeof setImmediate=="function"?r.setImmediate=setImmediate:r.setImmediate=r.nextTick;return}if(typeof setImmediate=="function"){r.setImmediate=function(){return setImmediate.apply(void 0,arguments)},r.nextTick=function(s){return setImmediate(s)};return}if(r.setImmediate=function(s){setTimeout(s,0)},typeof window<"u"&&typeof window.postMessage=="function"){let s=function(n){if(n.source===window&&n.data===o){n.stopPropagation();var B=h.slice();h.length=0,B.forEach(function(D){D()})}};var o="forge.setImmediate",h=[];r.setImmediate=function(n){h.push(n),h.length===1&&window.postMessage(o,"*")},window.addEventListener("message",s,!0)}if(typeof MutationObserver<"u"){var y=Date.now(),A=!0,_=document.createElement("div"),h=[];new MutationObserver(function(){var n=h.slice();h.length=0,n.forEach(function(B){B()})}).observe(_,{attributes:!0});var p=r.setImmediate;r.setImmediate=function(n){Date.now()-y>15?(y=Date.now(),p(n)):(h.push(n),h.length===1&&_.setAttribute("a",A=!A))}}r.nextTick=r.setImmediate})(),r.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,r.globalScope=(function(){return r.isNodejs?Ds:typeof self>"u"?window:self})(),r.isArray=Array.isArray||function(o){return Object.prototype.toString.call(o)==="[object Array]"},r.isArrayBuffer=function(o){return typeof ArrayBuffer<"u"&&o instanceof ArrayBuffer},r.isArrayBufferView=function(o){return o&&r.isArrayBuffer(o.buffer)&&o.byteLength!==void 0};function i(o){if(!(o===8||o===16||o===24||o===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+o)}r.ByteBuffer=d;function d(o){if(this.data="",this.read=0,typeof o=="string")this.data=o;else if(r.isArrayBuffer(o)||r.isArrayBufferView(o))if(typeof Buffer<"u"&&o instanceof Buffer)this.data=o.toString("binary");else{var h=new Uint8Array(o);try{this.data=String.fromCharCode.apply(null,h)}catch{for(var y=0;y<h.length;++y)this.putByte(h[y])}}else(o instanceof d||typeof o=="object"&&typeof o.data=="string"&&typeof o.read=="number")&&(this.data=o.data,this.read=o.read);this._constructedStringLength=0}r.ByteStringBuffer=d;var v=4096;r.ByteStringBuffer.prototype._optimizeConstructedString=function(o){this._constructedStringLength+=o,this._constructedStringLength>v&&(this.data.substr(0,1),this._constructedStringLength=0)},r.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},r.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},r.ByteStringBuffer.prototype.putByte=function(o){return this.putBytes(String.fromCharCode(o))},r.ByteStringBuffer.prototype.fillWithByte=function(o,h){o=String.fromCharCode(o);for(var y=this.data;h>0;)h&1&&(y+=o),h>>>=1,h>0&&(o+=o);return this.data=y,this._optimizeConstructedString(h),this},r.ByteStringBuffer.prototype.putBytes=function(o){return this.data+=o,this._optimizeConstructedString(o.length),this},r.ByteStringBuffer.prototype.putString=function(o){return this.putBytes(r.encodeUtf8(o))},r.ByteStringBuffer.prototype.putInt16=function(o){return this.putBytes(String.fromCharCode(o>>8&255)+String.fromCharCode(o&255))},r.ByteStringBuffer.prototype.putInt24=function(o){return this.putBytes(String.fromCharCode(o>>16&255)+String.fromCharCode(o>>8&255)+String.fromCharCode(o&255))},r.ByteStringBuffer.prototype.putInt32=function(o){return this.putBytes(String.fromCharCode(o>>24&255)+String.fromCharCode(o>>16&255)+String.fromCharCode(o>>8&255)+String.fromCharCode(o&255))},r.ByteStringBuffer.prototype.putInt16Le=function(o){return this.putBytes(String.fromCharCode(o&255)+String.fromCharCode(o>>8&255))},r.ByteStringBuffer.prototype.putInt24Le=function(o){return this.putBytes(String.fromCharCode(o&255)+String.fromCharCode(o>>8&255)+String.fromCharCode(o>>16&255))},r.ByteStringBuffer.prototype.putInt32Le=function(o){return this.putBytes(String.fromCharCode(o&255)+String.fromCharCode(o>>8&255)+String.fromCharCode(o>>16&255)+String.fromCharCode(o>>24&255))},r.ByteStringBuffer.prototype.putInt=function(o,h){i(h);var y="";do h-=8,y+=String.fromCharCode(o>>h&255);while(h>0);return this.putBytes(y)},r.ByteStringBuffer.prototype.putSignedInt=function(o,h){return o<0&&(o+=2<<h-1),this.putInt(o,h)},r.ByteStringBuffer.prototype.putBuffer=function(o){return this.putBytes(o.getBytes())},r.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},r.ByteStringBuffer.prototype.getInt16=function(){var o=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,o},r.ByteStringBuffer.prototype.getInt24=function(){var o=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,o},r.ByteStringBuffer.prototype.getInt32=function(){var o=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,o},r.ByteStringBuffer.prototype.getInt16Le=function(){var o=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,o},r.ByteStringBuffer.prototype.getInt24Le=function(){var o=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,o},r.ByteStringBuffer.prototype.getInt32Le=function(){var o=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,o},r.ByteStringBuffer.prototype.getInt=function(o){i(o);var h=0;do h=(h<<8)+this.data.charCodeAt(this.read++),o-=8;while(o>0);return h},r.ByteStringBuffer.prototype.getSignedInt=function(o){var h=this.getInt(o),y=2<<o-2;return h>=y&&(h-=y<<1),h},r.ByteStringBuffer.prototype.getBytes=function(o){var h;return o?(o=Math.min(this.length(),o),h=this.data.slice(this.read,this.read+o),this.read+=o):o===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.ByteStringBuffer.prototype.bytes=function(o){return typeof o>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+o)},r.ByteStringBuffer.prototype.at=function(o){return this.data.charCodeAt(this.read+o)},r.ByteStringBuffer.prototype.setAt=function(o,h){return this.data=this.data.substr(0,this.read+o)+String.fromCharCode(h)+this.data.substr(this.read+o+1),this},r.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},r.ByteStringBuffer.prototype.copy=function(){var o=r.createBuffer(this.data);return o.read=this.read,o},r.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},r.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},r.ByteStringBuffer.prototype.truncate=function(o){var h=Math.max(0,this.length()-o);return this.data=this.data.substr(this.read,h),this.read=0,this},r.ByteStringBuffer.prototype.toHex=function(){for(var o="",h=this.read;h<this.data.length;++h){var y=this.data.charCodeAt(h);y<16&&(o+="0"),o+=y.toString(16)}return o},r.ByteStringBuffer.prototype.toString=function(){return r.decodeUtf8(this.bytes())};function c(o,h){h=h||{},this.read=h.readOffset||0,this.growSize=h.growSize||1024;var y=r.isArrayBuffer(o),A=r.isArrayBufferView(o);if(y||A){y?this.data=new DataView(o):this.data=new DataView(o.buffer,o.byteOffset,o.byteLength),this.write="writeOffset"in h?h.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,o!=null&&this.putBytes(o),"writeOffset"in h&&(this.write=h.writeOffset)}r.DataBuffer=c,r.DataBuffer.prototype.length=function(){return this.write-this.read},r.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},r.DataBuffer.prototype.accommodate=function(o,h){if(this.length()>=o)return this;h=Math.max(h||this.growSize,o);var y=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),A=new Uint8Array(this.length()+h);return A.set(y),this.data=new DataView(A.buffer),this},r.DataBuffer.prototype.putByte=function(o){return this.accommodate(1),this.data.setUint8(this.write++,o),this},r.DataBuffer.prototype.fillWithByte=function(o,h){this.accommodate(h);for(var y=0;y<h;++y)this.data.setUint8(o);return this},r.DataBuffer.prototype.putBytes=function(o,h){if(r.isArrayBufferView(o)){var y=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),A=y.byteLength-y.byteOffset;this.accommodate(A);var _=new Uint8Array(this.data.buffer,this.write);return _.set(y),this.write+=A,this}if(r.isArrayBuffer(o)){var y=new Uint8Array(o);this.accommodate(y.byteLength);var _=new Uint8Array(this.data.buffer);return _.set(y,this.write),this.write+=y.byteLength,this}if(o instanceof r.DataBuffer||typeof o=="object"&&typeof o.read=="number"&&typeof o.write=="number"&&r.isArrayBufferView(o.data)){var y=new Uint8Array(o.data.byteLength,o.read,o.length());this.accommodate(y.byteLength);var _=new Uint8Array(o.data.byteLength,this.write);return _.set(y),this.write+=y.byteLength,this}if(o instanceof r.ByteStringBuffer&&(o=o.data,h="binary"),h=h||"binary",typeof o=="string"){var p;if(h==="hex")return this.accommodate(Math.ceil(o.length/2)),p=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.hex.decode(o,p,this.write),this;if(h==="base64")return this.accommodate(Math.ceil(o.length/4)*3),p=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.base64.decode(o,p,this.write),this;if(h==="utf8"&&(o=r.encodeUtf8(o),h="binary"),h==="binary"||h==="raw")return this.accommodate(o.length),p=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.raw.decode(p),this;if(h==="utf16")return this.accommodate(o.length*2),p=new Uint16Array(this.data.buffer,this.write),this.write+=r.text.utf16.encode(p),this;throw new Error("Invalid encoding: "+h)}throw Error("Invalid parameter: "+o)},r.DataBuffer.prototype.putBuffer=function(o){return this.putBytes(o),o.clear(),this},r.DataBuffer.prototype.putString=function(o){return this.putBytes(o,"utf16")},r.DataBuffer.prototype.putInt16=function(o){return this.accommodate(2),this.data.setInt16(this.write,o),this.write+=2,this},r.DataBuffer.prototype.putInt24=function(o){return this.accommodate(3),this.data.setInt16(this.write,o>>8&65535),this.data.setInt8(this.write,o>>16&255),this.write+=3,this},r.DataBuffer.prototype.putInt32=function(o){return this.accommodate(4),this.data.setInt32(this.write,o),this.write+=4,this},r.DataBuffer.prototype.putInt16Le=function(o){return this.accommodate(2),this.data.setInt16(this.write,o,!0),this.write+=2,this},r.DataBuffer.prototype.putInt24Le=function(o){return this.accommodate(3),this.data.setInt8(this.write,o>>16&255),this.data.setInt16(this.write,o>>8&65535,!0),this.write+=3,this},r.DataBuffer.prototype.putInt32Le=function(o){return this.accommodate(4),this.data.setInt32(this.write,o,!0),this.write+=4,this},r.DataBuffer.prototype.putInt=function(o,h){i(h),this.accommodate(h/8);do h-=8,this.data.setInt8(this.write++,o>>h&255);while(h>0);return this},r.DataBuffer.prototype.putSignedInt=function(o,h){return i(h),this.accommodate(h/8),o<0&&(o+=2<<h-1),this.putInt(o,h)},r.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},r.DataBuffer.prototype.getInt16=function(){var o=this.data.getInt16(this.read);return this.read+=2,o},r.DataBuffer.prototype.getInt24=function(){var o=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,o},r.DataBuffer.prototype.getInt32=function(){var o=this.data.getInt32(this.read);return this.read+=4,o},r.DataBuffer.prototype.getInt16Le=function(){var o=this.data.getInt16(this.read,!0);return this.read+=2,o},r.DataBuffer.prototype.getInt24Le=function(){var o=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,o},r.DataBuffer.prototype.getInt32Le=function(){var o=this.data.getInt32(this.read,!0);return this.read+=4,o},r.DataBuffer.prototype.getInt=function(o){i(o);var h=0;do h=(h<<8)+this.data.getInt8(this.read++),o-=8;while(o>0);return h},r.DataBuffer.prototype.getSignedInt=function(o){var h=this.getInt(o),y=2<<o-2;return h>=y&&(h-=y<<1),h},r.DataBuffer.prototype.getBytes=function(o){var h;return o?(o=Math.min(this.length(),o),h=this.data.slice(this.read,this.read+o),this.read+=o):o===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.DataBuffer.prototype.bytes=function(o){return typeof o>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+o)},r.DataBuffer.prototype.at=function(o){return this.data.getUint8(this.read+o)},r.DataBuffer.prototype.setAt=function(o,h){return this.data.setUint8(o,h),this},r.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},r.DataBuffer.prototype.copy=function(){return new r.DataBuffer(this)},r.DataBuffer.prototype.compact=function(){if(this.read>0){var o=new Uint8Array(this.data.buffer,this.read),h=new Uint8Array(o.byteLength);h.set(o),this.data=new DataView(h),this.write-=this.read,this.read=0}return this},r.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},r.DataBuffer.prototype.truncate=function(o){return this.write=Math.max(0,this.length()-o),this.read=Math.min(this.read,this.write),this},r.DataBuffer.prototype.toHex=function(){for(var o="",h=this.read;h<this.data.byteLength;++h){var y=this.data.getUint8(h);y<16&&(o+="0"),o+=y.toString(16)}return o},r.DataBuffer.prototype.toString=function(o){var h=new Uint8Array(this.data,this.read,this.length());if(o=o||"utf8",o==="binary"||o==="raw")return r.binary.raw.encode(h);if(o==="hex")return r.binary.hex.encode(h);if(o==="base64")return r.binary.base64.encode(h);if(o==="utf8")return r.text.utf8.decode(h);if(o==="utf16")return r.text.utf16.decode(h);throw new Error("Invalid encoding: "+o)},r.createBuffer=function(o,h){return h=h||"raw",o!==void 0&&h==="utf8"&&(o=r.encodeUtf8(o)),new r.ByteBuffer(o)},r.fillString=function(o,h){for(var y="";h>0;)h&1&&(y+=o),h>>>=1,h>0&&(o+=o);return y},r.xorBytes=function(o,h,y){for(var A="",_="",p="",s=0,n=0;y>0;--y,++s)_=o.charCodeAt(s)^h.charCodeAt(s),n>=10&&(A+=p,p="",n=0),p+=String.fromCharCode(_),++n;return A+=p,A},r.hexToBytes=function(o){var h="",y=0;for(o.length&!0&&(y=1,h+=String.fromCharCode(parseInt(o[0],16)));y<o.length;y+=2)h+=String.fromCharCode(parseInt(o.substr(y,2),16));return h},r.bytesToHex=function(o){return r.createBuffer(o).toHex()},r.int32ToBytes=function(o){return String.fromCharCode(o>>24&255)+String.fromCharCode(o>>16&255)+String.fromCharCode(o>>8&255)+String.fromCharCode(o&255)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=[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],f="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";r.encode64=function(o,h){for(var y="",A="",_,p,s,n=0;n<o.length;)_=o.charCodeAt(n++),p=o.charCodeAt(n++),s=o.charCodeAt(n++),y+=a.charAt(_>>2),y+=a.charAt((_&3)<<4|p>>4),isNaN(p)?y+="==":(y+=a.charAt((p&15)<<2|s>>6),y+=isNaN(s)?"=":a.charAt(s&63)),h&&y.length>h&&(A+=y.substr(0,h)+`\r
3
+ `,y=y.substr(h));return A+=y,A},r.decode64=function(o){o=o.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var h="",y,A,_,p,s=0;s<o.length;)y=g[o.charCodeAt(s++)-43],A=g[o.charCodeAt(s++)-43],_=g[o.charCodeAt(s++)-43],p=g[o.charCodeAt(s++)-43],h+=String.fromCharCode(y<<2|A>>4),_!==64&&(h+=String.fromCharCode((A&15)<<4|_>>2),p!==64&&(h+=String.fromCharCode((_&3)<<6|p)));return h},r.encodeUtf8=function(o){return unescape(encodeURIComponent(o))},r.decodeUtf8=function(o){return decodeURIComponent(escape(o))},r.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},r.binary.raw.encode=function(o){return String.fromCharCode.apply(null,o)},r.binary.raw.decode=function(o,h,y){var A=h;A||(A=new Uint8Array(o.length)),y=y||0;for(var _=y,p=0;p<o.length;++p)A[_++]=o.charCodeAt(p);return h?_-y:A},r.binary.hex.encode=r.bytesToHex,r.binary.hex.decode=function(o,h,y){var A=h;A||(A=new Uint8Array(Math.ceil(o.length/2))),y=y||0;var _=0,p=y;for(o.length&1&&(_=1,A[p++]=parseInt(o[0],16));_<o.length;_+=2)A[p++]=parseInt(o.substr(_,2),16);return h?p-y:A},r.binary.base64.encode=function(o,h){for(var y="",A="",_,p,s,n=0;n<o.byteLength;)_=o[n++],p=o[n++],s=o[n++],y+=a.charAt(_>>2),y+=a.charAt((_&3)<<4|p>>4),isNaN(p)?y+="==":(y+=a.charAt((p&15)<<2|s>>6),y+=isNaN(s)?"=":a.charAt(s&63)),h&&y.length>h&&(A+=y.substr(0,h)+`\r
4
+ `,y=y.substr(h));return A+=y,A},r.binary.base64.decode=function(o,h,y){var A=h;A||(A=new Uint8Array(Math.ceil(o.length/4)*3)),o=o.replace(/[^A-Za-z0-9\+\/\=]/g,""),y=y||0;for(var _,p,s,n,B=0,D=y;B<o.length;)_=g[o.charCodeAt(B++)-43],p=g[o.charCodeAt(B++)-43],s=g[o.charCodeAt(B++)-43],n=g[o.charCodeAt(B++)-43],A[D++]=_<<2|p>>4,s!==64&&(A[D++]=(p&15)<<4|s>>2,n!==64&&(A[D++]=(s&3)<<6|n));return h?D-y:A.subarray(0,D)},r.binary.base58.encode=function(o,h){return r.binary.baseN.encode(o,f,h)},r.binary.base58.decode=function(o,h){return r.binary.baseN.decode(o,f,h)},r.text={utf8:{},utf16:{}},r.text.utf8.encode=function(o,h,y){o=r.encodeUtf8(o);var A=h;A||(A=new Uint8Array(o.length)),y=y||0;for(var _=y,p=0;p<o.length;++p)A[_++]=o.charCodeAt(p);return h?_-y:A},r.text.utf8.decode=function(o){return r.decodeUtf8(String.fromCharCode.apply(null,o))},r.text.utf16.encode=function(o,h,y){var A=h;A||(A=new Uint8Array(o.length*2));var _=new Uint16Array(A.buffer);y=y||0;for(var p=y,s=y,n=0;n<o.length;++n)_[s++]=o.charCodeAt(n),p+=2;return h?p-y:A},r.text.utf16.decode=function(o){return String.fromCharCode.apply(null,new Uint16Array(o.buffer))},r.deflate=function(o,h,y){if(h=r.decode64(o.deflate(r.encode64(h)).rval),y){var A=2,_=h.charCodeAt(1);_&32&&(A=6),h=h.substring(A,h.length-4)}return h},r.inflate=function(o,h,y){var A=o.inflate(r.encode64(h)).rval;return A===null?null:r.decode64(A)};var S=function(o,h,y){if(!o)throw new Error("WebStorage not available.");var A;if(y===null?A=o.removeItem(h):(y=r.encode64(JSON.stringify(y)),A=o.setItem(h,y)),typeof A<"u"&&A.rval!==!0){var _=new Error(A.error.message);throw _.id=A.error.id,_.name=A.error.name,_}},P=function(o,h){if(!o)throw new Error("WebStorage not available.");var y=o.getItem(h);if(o.init)if(y.rval===null){if(y.error){var A=new Error(y.error.message);throw A.id=y.error.id,A.name=y.error.name,A}y=null}else y=y.rval;return y!==null&&(y=JSON.parse(r.decode64(y))),y},b=function(o,h,y,A){var _=P(o,h);_===null&&(_={}),_[y]=A,S(o,h,_)},l=function(o,h,y){var A=P(o,h);return A!==null&&(A=y in A?A[y]:null),A},m=function(o,h,y){var A=P(o,h);if(A!==null&&y in A){delete A[y];var _=!0;for(var p in A){_=!1;break}_&&(A=null),S(o,h,A)}},x=function(o,h){S(o,h,null)},C=function(o,h,y){var A=null;typeof y>"u"&&(y=["web","flash"]);var _,p=!1,s=null;for(var n in y){_=y[n];try{if(_==="flash"||_==="both"){if(h[0]===null)throw new Error("Flash local storage not available.");A=o.apply(this,h),p=_==="flash"}(_==="web"||_==="both")&&(h[0]=localStorage,A=o.apply(this,h),p=!0)}catch(B){s=B}if(p)break}if(!p)throw s;return A};return r.setItem=function(o,h,y,A,_){C(b,arguments,_)},r.getItem=function(o,h,y,A){return C(l,arguments,A)},r.removeItem=function(o,h,y,A){C(m,arguments,A)},r.clearItems=function(o,h,y){C(x,arguments,y)},r.isEmpty=function(o){for(var h in o)if(o.hasOwnProperty(h))return!1;return!0},r.format=function(o){for(var h=/%./g,y,A,_=0,p=[],s=0;y=h.exec(o);){A=o.substring(s,h.lastIndex-2),A.length>0&&p.push(A),s=h.lastIndex;var n=y[0][1];switch(n){case"s":case"o":_<arguments.length?p.push(arguments[_+++1]):p.push("<?>");break;case"%":p.push("%");break;default:p.push("<%"+n+"?>")}}return p.push(o.substring(s)),p.join("")},r.formatNumber=function(o,h,y,A){var _=o,p=isNaN(h=Math.abs(h))?2:h,s=y===void 0?",":y,n=A===void 0?".":A,B=_<0?"-":"",D=parseInt(_=Math.abs(+_||0).toFixed(p),10)+"",V=D.length>3?D.length%3:0;return B+(V?D.substr(0,V)+n:"")+D.substr(V).replace(/(\d{3})(?=\d)/g,"$1"+n)+(p?s+Math.abs(_-D).toFixed(p).slice(2):"")},r.formatSize=function(o){return o>=1073741824?o=r.formatNumber(o/1073741824,2,".","")+" GiB":o>=1048576?o=r.formatNumber(o/1048576,2,".","")+" MiB":o>=1024?o=r.formatNumber(o/1024,0)+" KiB":o=r.formatNumber(o,0)+" bytes",o},r.bytesFromIP=function(o){return o.indexOf(".")!==-1?r.bytesFromIPv4(o):o.indexOf(":")!==-1?r.bytesFromIPv6(o):null},r.bytesFromIPv4=function(o){if(o=o.split("."),o.length!==4)return null;for(var h=r.createBuffer(),y=0;y<o.length;++y){var A=parseInt(o[y],10);if(isNaN(A))return null;h.putByte(A)}return h.getBytes()},r.bytesFromIPv6=function(o){var h=0;o=o.split(":").filter(function(s){return s.length===0&&++h,!0});for(var y=(8-o.length+h)*2,A=r.createBuffer(),_=0;_<8;++_){if(!o[_]||o[_].length===0){A.fillWithByte(0,y),y=0;continue}var p=r.hexToBytes(o[_]);p.length<2&&A.putByte(0),A.putBytes(p)}return A.getBytes()},r.bytesToIP=function(o){return o.length===4?r.bytesToIPv4(o):o.length===16?r.bytesToIPv6(o):null},r.bytesToIPv4=function(o){if(o.length!==4)return null;for(var h=[],y=0;y<o.length;++y)h.push(o.charCodeAt(y));return h.join(".")},r.bytesToIPv6=function(o){if(o.length!==16)return null;for(var h=[],y=[],A=0,_=0;_<o.length;_+=2){for(var p=r.bytesToHex(o[_]+o[_+1]);p[0]==="0"&&p!=="0";)p=p.substr(1);if(p==="0"){var s=y[y.length-1],n=h.length;!s||n!==s.end+1?y.push({start:n,end:n}):(s.end=n,s.end-s.start>y[A].end-y[A].start&&(A=y.length-1))}h.push(p)}if(y.length>0){var B=y[A];B.end-B.start>0&&(h.splice(B.start,B.end-B.start+1,""),B.start===0&&h.unshift(""),B.end===7&&h.push(""))}return h.join(":")},r.estimateCores=function(o,h){if(typeof o=="function"&&(h=o,o={}),o=o||{},"cores"in r&&!o.update)return h(null,r.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return r.cores=navigator.hardwareConcurrency,h(null,r.cores);if(typeof Worker>"u")return r.cores=1,h(null,r.cores);if(typeof Blob>"u")return r.cores=2,h(null,r.cores);var y=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(s){var n=Date.now(),B=n+4;self.postMessage({st:n,et:B})})}).toString(),")()"],{type:"application/javascript"}));A([],5,16);function A(s,n,B){if(n===0){var D=Math.floor(s.reduce(function(V,U){return V+U},0)/s.length);return r.cores=Math.max(1,D),URL.revokeObjectURL(y),h(null,r.cores)}_(B,function(V,U){s.push(p(B,U)),A(s,n-1,B)})}function _(s,n){for(var B=[],D=[],V=0;V<s;++V){var U=new Worker(y);U.addEventListener("message",function(F){if(D.push(F.data),D.length===s){for(var q=0;q<s;++q)B[q].terminate();n(null,D)}}),B.push(U)}for(var V=0;V<s;++V)B[V].postMessage(V)}function p(s,n){for(var B=[],D=0;D<s;++D)for(var V=n[D],U=B[D]=[],F=0;F<s;++F)if(D!==F){var q=n[F];(V.st>q.st&&V.st<q.et||q.st>V.st&&q.st<V.et)&&U.push(F)}return B.reduce(function(M,H){return Math.max(M,H.length)},0)}},Cr.exports}var xr,Fa;function ya(){if(Fa)return xr;Fa=1;var t=ve();Ee(),xr=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(r,i){var d=r;if(typeof d=="string"&&(d=t.cipher.getAlgorithm(d),d&&(d=d())),!d)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:d,key:i,decrypt:!1})},t.cipher.createDecipher=function(r,i){var d=r;if(typeof d=="string"&&(d=t.cipher.getAlgorithm(d),d&&(d=d())),!d)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:d,key:i,decrypt:!0})},t.cipher.registerAlgorithm=function(r,i){r=r.toUpperCase(),t.cipher.algorithms[r]=i},t.cipher.getAlgorithm=function(r){return r=r.toUpperCase(),r in t.cipher.algorithms?t.cipher.algorithms[r]:null};var e=t.cipher.BlockCipher=function(r){this.algorithm=r.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=r.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=r.decrypt,this.algorithm.initialize(r)};return e.prototype.start=function(r){r=r||{};var i={};for(var d in r)i[d]=r[d];i.decrypt=this._decrypt,this._finish=!1,this._input=t.util.createBuffer(),this.output=r.output||t.util.createBuffer(),this.mode.start(i)},e.prototype.update=function(r){for(r&&this._input.putBuffer(r);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},e.prototype.finish=function(r){r&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(d){return r(this.blockSize,d,!1)},this.mode.unpad=function(d){return r(this.blockSize,d,!0)});var i={};return i.decrypt=this._decrypt,i.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,i)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,i))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,i))},xr}var Sr={exports:{}},Ka;function ti(){if(Ka)return Sr.exports;Ka=1;var t=ve();Ee(),t.cipher=t.cipher||{};var e=Sr.exports=t.cipher.modes=t.cipher.modes||{};e.ecb=function(v){v=v||{},this.name="ECB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.ecb.prototype.start=function(v){},e.ecb.prototype.encrypt=function(v,c,a){if(v.length()<this.blockSize&&!(a&&v.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=v.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)c.putInt32(this._outBlock[g])},e.ecb.prototype.decrypt=function(v,c,a){if(v.length()<this.blockSize&&!(a&&v.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=v.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)c.putInt32(this._outBlock[g])},e.ecb.prototype.pad=function(v,c){var a=v.length()===this.blockSize?this.blockSize:this.blockSize-v.length();return v.fillWithByte(a,a),!0},e.ecb.prototype.unpad=function(v,c){if(c.overflow>0)return!1;var a=v.length(),g=v.at(a-1);return g>this.blockSize<<2?!1:(v.truncate(g),!0)},e.cbc=function(v){v=v||{},this.name="CBC",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.cbc.prototype.start=function(v){if(v.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in v)this._iv=r(v.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(v,c,a){if(v.length()<this.blockSize&&!(a&&v.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=this._prev[g]^v.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)c.putInt32(this._outBlock[g]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(v,c,a){if(v.length()<this.blockSize&&!(a&&v.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=v.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)c.putInt32(this._prev[g]^this._outBlock[g]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(v,c){var a=v.length()===this.blockSize?this.blockSize:this.blockSize-v.length();return v.fillWithByte(a,a),!0},e.cbc.prototype.unpad=function(v,c){if(c.overflow>0)return!1;var a=v.length(),g=v.at(a-1);return g>this.blockSize<<2?!1:(v.truncate(g),!0)},e.cfb=function(v){v=v||{},this.name="CFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=r(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(v,c,a){var g=v.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=v.getInt32()^this._outBlock[f],c.putInt32(this._inBlock[f]);return}var S=(this.blockSize-g)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=v.getInt32()^this._outBlock[f],this._partialOutput.putInt32(this._partialBlock[f]);if(S>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(v,c,a){var g=v.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=v.getInt32(),c.putInt32(this._inBlock[f]^this._outBlock[f]);return}var S=(this.blockSize-g)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=v.getInt32(),this._partialOutput.putInt32(this._partialBlock[f]^this._outBlock[f]);if(S>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.ofb=function(v){v=v||{},this.name="OFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=r(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(v,c,a){var g=v.length();if(v.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var f=0;f<this._ints;++f)c.putInt32(v.getInt32()^this._outBlock[f]),this._inBlock[f]=this._outBlock[f];return}var S=(this.blockSize-g)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(S>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._outBlock[f];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(v){v=v||{},this.name="CTR",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=r(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(v,c,a){var g=v.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize)for(var f=0;f<this._ints;++f)c.putInt32(v.getInt32()^this._outBlock[f]);else{var S=(this.blockSize-g)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(S>0&&(v.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0}i(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(v){v=v||{},this.name="GCM",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0,this._R=3774873600},e.gcm.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");var c=t.util.createBuffer(v.iv);this._cipherLength=0;var a;if("additionalData"in v?a=t.util.createBuffer(v.additionalData):a=t.util.createBuffer(),"tagLength"in v?this._tagLength=v.tagLength:this._tagLength=128,this._tag=null,v.decrypt&&(this._tag=t.util.createBuffer(v.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var g=c.length();if(g===12)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(d(g*8)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,a=t.util.createBuffer(a),this._aDataLength=d(a.length()*8);var f=a.length()%this.blockSize;for(f&&a.fillWithByte(0,this.blockSize-f),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])},e.gcm.prototype.encrypt=function(v,c,a){var g=v.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var f=0;f<this._ints;++f)c.putInt32(this._outBlock[f]^=v.getInt32());this._cipherLength+=this.blockSize}else{var S=(this.blockSize-g)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(S<=0||a){if(a){var P=g%this.blockSize;this._cipherLength+=P,this._partialOutput.truncate(this.blockSize-P)}else this._cipherLength+=this.blockSize;for(var f=0;f<this._ints;++f)this._outBlock[f]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return v.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),i(this._inBlock)},e.gcm.prototype.decrypt=function(v,c,a){var g=v.length();if(g<this.blockSize&&!(a&&g>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),i(this._inBlock),this._hashBlock[0]=v.getInt32(),this._hashBlock[1]=v.getInt32(),this._hashBlock[2]=v.getInt32(),this._hashBlock[3]=v.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var f=0;f<this._ints;++f)c.putInt32(this._outBlock[f]^this._hashBlock[f]);g<this.blockSize?this._cipherLength+=g%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(v,c){var a=!0;c.decrypt&&c.overflow&&v.truncate(this.blockSize-c.overflow),this.tag=t.util.createBuffer();var g=this._aDataLength.concat(d(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,g);var f=[];this.cipher.encrypt(this._j0,f);for(var S=0;S<this._ints;++S)this.tag.putInt32(this._s[S]^f[S]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),c.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a},e.gcm.prototype.multiply=function(v,c){for(var a=[0,0,0,0],g=c.slice(0),f=0;f<128;++f){var S=v[f/32|0]&1<<31-f%32;S&&(a[0]^=g[0],a[1]^=g[1],a[2]^=g[2],a[3]^=g[3]),this.pow(g,g)}return a},e.gcm.prototype.pow=function(v,c){for(var a=v[3]&1,g=3;g>0;--g)c[g]=v[g]>>>1|(v[g-1]&1)<<31;c[0]=v[0]>>>1,a&&(c[0]^=this._R)},e.gcm.prototype.tableMultiply=function(v){for(var c=[0,0,0,0],a=0;a<32;++a){var g=a/8|0,f=v[g]>>>(7-a%8)*4&15,S=this._m[a][f];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},e.gcm.prototype.ghash=function(v,c,a){return c[0]^=a[0],c[1]^=a[1],c[2]^=a[2],c[3]^=a[3],this.tableMultiply(c)},e.gcm.prototype.generateHashTable=function(v,c){for(var a=8/c,g=4*a,f=16*a,S=new Array(f),P=0;P<f;++P){var b=[0,0,0,0],l=P/g|0,m=(g-1-P%g)*c;b[l]=1<<c-1<<m,S[P]=this.generateSubHashTable(this.multiply(b,v),c)}return S},e.gcm.prototype.generateSubHashTable=function(v,c){var a=1<<c,g=a>>>1,f=new Array(a);f[g]=v.slice(0);for(var S=g>>>1;S>0;)this.pow(f[2*S],f[S]=[]),S>>=1;for(S=2;S<g;){for(var P=1;P<S;++P){var b=f[S],l=f[P];f[S+P]=[b[0]^l[0],b[1]^l[1],b[2]^l[2],b[3]^l[3]]}S*=2}for(f[0]=[0,0,0,0],S=g+1;S<a;++S){var m=f[S^g];f[S]=[v[0]^m[0],v[1]^m[1],v[2]^m[2],v[3]^m[3]]}return f};function r(v,c){if(typeof v=="string"&&(v=t.util.createBuffer(v)),t.util.isArray(v)&&v.length>4){var a=v;v=t.util.createBuffer();for(var g=0;g<a.length;++g)v.putByte(a[g])}if(v.length()<c)throw new Error("Invalid IV length; got "+v.length()+" bytes and expected "+c+" bytes.");if(!t.util.isArray(v)){for(var f=[],S=c/4,g=0;g<S;++g)f.push(v.getInt32());v=f}return v}function i(v){v[v.length-1]=v[v.length-1]+1&4294967295}function d(v){return[v/4294967296|0,v&4294967295]}return Sr.exports}var br,Ma;function Dt(){if(Ma)return br;Ma=1;var t=ve();ya(),ti(),Ee(),br=t.aes=t.aes||{},t.aes.startEncrypting=function(l,m,x,C){var o=b({key:l,output:x,decrypt:!1,mode:C});return o.start(m),o},t.aes.createEncryptionCipher=function(l,m){return b({key:l,output:null,decrypt:!1,mode:m})},t.aes.startDecrypting=function(l,m,x,C){var o=b({key:l,output:x,decrypt:!0,mode:C});return o.start(m),o},t.aes.createDecryptionCipher=function(l,m){return b({key:l,output:null,decrypt:!0,mode:m})},t.aes.Algorithm=function(l,m){r||f();var x=this;x.name=l,x.mode=new m({blockSize:16,cipher:{encrypt:function(C,o){return P(x._w,C,o,!1)},decrypt:function(C,o){return P(x._w,C,o,!0)}}}),x._init=!1},t.aes.Algorithm.prototype.initialize=function(l){if(!this._init){var m=l.key,x;if(typeof m=="string"&&(m.length===16||m.length===24||m.length===32))m=t.util.createBuffer(m);else if(t.util.isArray(m)&&(m.length===16||m.length===24||m.length===32)){x=m,m=t.util.createBuffer();for(var C=0;C<x.length;++C)m.putByte(x[C])}if(!t.util.isArray(m)){x=m,m=[];var o=x.length();if(o===16||o===24||o===32){o=o>>>2;for(var C=0;C<o;++C)m.push(x.getInt32())}}if(!t.util.isArray(m)||!(m.length===4||m.length===6||m.length===8))throw new Error("Invalid key parameter.");var h=this.mode.name,y=["CFB","OFB","CTR","GCM"].indexOf(h)!==-1;this._w=S(m,l.decrypt&&!y),this._init=!0}},t.aes._expandKey=function(l,m){return r||f(),S(l,m)},t.aes._updateBlock=P,e("AES-ECB",t.cipher.modes.ecb),e("AES-CBC",t.cipher.modes.cbc),e("AES-CFB",t.cipher.modes.cfb),e("AES-OFB",t.cipher.modes.ofb),e("AES-CTR",t.cipher.modes.ctr),e("AES-GCM",t.cipher.modes.gcm);function e(l,m){var x=function(){return new t.aes.Algorithm(l,m)};t.cipher.registerAlgorithm(l,x)}var r=!1,i=4,d,v,c,a,g;function f(){r=!0,c=[0,1,2,4,8,16,32,64,128,27,54];for(var l=new Array(256),m=0;m<128;++m)l[m]=m<<1,l[m+128]=m+128<<1^283;d=new Array(256),v=new Array(256),a=new Array(4),g=new Array(4);for(var m=0;m<4;++m)a[m]=new Array(256),g[m]=new Array(256);for(var x=0,C=0,o,h,y,A,_,p,s,m=0;m<256;++m){A=C^C<<1^C<<2^C<<3^C<<4,A=A>>8^A&255^99,d[x]=A,v[A]=x,_=l[A],o=l[x],h=l[o],y=l[h],p=_<<24^A<<16^A<<8^(A^_),s=(o^h^y)<<24^(x^y)<<16^(x^h^y)<<8^(x^o^y);for(var n=0;n<4;++n)a[n][x]=p,g[n][A]=s,p=p<<24|p>>>8,s=s<<24|s>>>8;x===0?x=C=1:(x=o^l[l[l[o^y]]],C^=l[l[C]])}}function S(l,m){for(var x=l.slice(0),C,o=1,h=x.length,y=h+6+1,A=i*y,_=h;_<A;++_)C=x[_-1],_%h===0?(C=d[C>>>16&255]<<24^d[C>>>8&255]<<16^d[C&255]<<8^d[C>>>24]^c[o]<<24,o++):h>6&&_%h===4&&(C=d[C>>>24]<<24^d[C>>>16&255]<<16^d[C>>>8&255]<<8^d[C&255]),x[_]=x[_-h]^C;if(m){var p,s=g[0],n=g[1],B=g[2],D=g[3],V=x.slice(0);A=x.length;for(var _=0,U=A-i;_<A;_+=i,U-=i)if(_===0||_===A-i)V[_]=x[U],V[_+1]=x[U+3],V[_+2]=x[U+2],V[_+3]=x[U+1];else for(var F=0;F<i;++F)p=x[U+F],V[_+(3&-F)]=s[d[p>>>24]]^n[d[p>>>16&255]]^B[d[p>>>8&255]]^D[d[p&255]];x=V}return x}function P(l,m,x,C){var o=l.length/4-1,h,y,A,_,p;C?(h=g[0],y=g[1],A=g[2],_=g[3],p=v):(h=a[0],y=a[1],A=a[2],_=a[3],p=d);var s,n,B,D,V,U,F;s=m[0]^l[0],n=m[C?3:1]^l[1],B=m[2]^l[2],D=m[C?1:3]^l[3];for(var q=3,M=1;M<o;++M)V=h[s>>>24]^y[n>>>16&255]^A[B>>>8&255]^_[D&255]^l[++q],U=h[n>>>24]^y[B>>>16&255]^A[D>>>8&255]^_[s&255]^l[++q],F=h[B>>>24]^y[D>>>16&255]^A[s>>>8&255]^_[n&255]^l[++q],D=h[D>>>24]^y[s>>>16&255]^A[n>>>8&255]^_[B&255]^l[++q],s=V,n=U,B=F;x[0]=p[s>>>24]<<24^p[n>>>16&255]<<16^p[B>>>8&255]<<8^p[D&255]^l[++q],x[C?3:1]=p[n>>>24]<<24^p[B>>>16&255]<<16^p[D>>>8&255]<<8^p[s&255]^l[++q],x[2]=p[B>>>24]<<24^p[D>>>16&255]<<16^p[s>>>8&255]<<8^p[n&255]^l[++q],x[C?1:3]=p[D>>>24]<<24^p[s>>>16&255]<<16^p[n>>>8&255]<<8^p[B&255]^l[++q]}function b(l){l=l||{};var m=(l.mode||"CBC").toUpperCase(),x="AES-"+m,C;l.decrypt?C=t.cipher.createDecipher(x,l.key):C=t.cipher.createCipher(x,l.key);var o=C.start;return C.start=function(h,y){var A=null;y instanceof t.util.ByteBuffer&&(A=y,y={}),y=y||{},y.output=A,y.iv=h,o.call(C,y)},C}return br}var Tr={exports:{}},Ar={exports:{}},Ir={exports:{}},qa;function Lt(){if(qa)return Ir.exports;qa=1;var t=ve();t.pki=t.pki||{};var e=Ir.exports=t.pki.oids=t.oids=t.oids||{};function r(d,v){e[d]=v,e[v]=d}function i(d,v){e[d]=v}return r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("1.3.14.3.2.29","sha1WithRSASignature"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("2.16.840.1.101.3.4.2.4","sha224"),r("2.16.840.1.101.3.4.2.5","sha512-224"),r("2.16.840.1.101.3.4.2.6","sha512-256"),r("1.2.840.113549.2.2","md2"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.4","surname"),r("2.5.4.5","serialNumber"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.12","title"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("2.5.4.42","givenName"),r("2.5.4.65","pseudonym"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),i("2.5.29.1","authorityKeyIdentifier"),i("2.5.29.2","keyAttributes"),i("2.5.29.3","certificatePolicies"),i("2.5.29.4","keyUsageRestriction"),i("2.5.29.5","policyMapping"),i("2.5.29.6","subtreesConstraint"),i("2.5.29.7","subjectAltName"),i("2.5.29.8","issuerAltName"),i("2.5.29.9","subjectDirectoryAttributes"),i("2.5.29.10","basicConstraints"),i("2.5.29.11","nameConstraints"),i("2.5.29.12","policyConstraints"),i("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),i("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),i("2.5.29.20","cRLNumber"),i("2.5.29.21","cRLReason"),i("2.5.29.22","expirationDate"),i("2.5.29.23","instructionCode"),i("2.5.29.24","invalidityDate"),i("2.5.29.25","cRLDistributionPoints"),i("2.5.29.26","issuingDistributionPoint"),i("2.5.29.27","deltaCRLIndicator"),i("2.5.29.28","issuingDistributionPoint"),i("2.5.29.29","certificateIssuer"),i("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),i("2.5.29.33","policyMappings"),i("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),i("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),i("2.5.29.46","freshestCRL"),i("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping"),Ir.exports}var Ha;function gt(){if(Ha)return Ar.exports;Ha=1;var t=ve();Ee(),Lt();var e=Ar.exports=t.asn1=t.asn1||{};e.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},e.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},e.maxDepth=256,e.create=function(c,a,g,f,S){if(t.util.isArray(f)){for(var P=[],b=0;b<f.length;++b)f[b]!==void 0&&P.push(f[b]);f=P}var l={tagClass:c,type:a,constructed:g,composed:g||t.util.isArray(f),value:f};return S&&"bitStringContents"in S&&(l.bitStringContents=S.bitStringContents,l.original=e.copy(l)),l},e.copy=function(c,a){var g;if(t.util.isArray(c)){g=[];for(var f=0;f<c.length;++f)g.push(e.copy(c[f],a));return g}return typeof c=="string"?c:(g={tagClass:c.tagClass,type:c.type,constructed:c.constructed,composed:c.composed,value:e.copy(c.value,a)},a&&!a.excludeBitStringContents&&(g.bitStringContents=c.bitStringContents),g)},e.equals=function(c,a,g){if(t.util.isArray(c)){if(!t.util.isArray(a)||c.length!==a.length)return!1;for(var f=0;f<c.length;++f)if(!e.equals(c[f],a[f]))return!1;return!0}if(typeof c!=typeof a)return!1;if(typeof c=="string")return c===a;var S=c.tagClass===a.tagClass&&c.type===a.type&&c.constructed===a.constructed&&c.composed===a.composed&&e.equals(c.value,a.value);return g&&g.includeBitStringContents&&(S=S&&c.bitStringContents===a.bitStringContents),S},e.getBerValueLength=function(c){var a=c.getByte();if(a!==128){var g,f=a&128;return f?g=c.getInt((a&127)<<3):g=a,g}};function r(c,a,g){if(g>a){var f=new Error("Too few bytes to parse DER.");throw f.available=c.length(),f.remaining=a,f.requested=g,f}}var i=function(c,a){var g=c.getByte();if(a--,g!==128){var f,S=g&128;if(!S)f=g;else{var P=g&127;r(c,a,P),f=c.getInt(P<<3)}if(f<0)throw new Error("Negative length: "+f);return f}};e.fromDer=function(c,a){a===void 0&&(a={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof a=="boolean"&&(a={strict:a,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in a||(a.strict=!0),"parseAllBytes"in a||(a.parseAllBytes=!0),"decodeBitStrings"in a||(a.decodeBitStrings=!0),"maxDepth"in a||(a.maxDepth=e.maxDepth),typeof c=="string"&&(c=t.util.createBuffer(c));var g=c.length(),f=d(c,c.length(),0,a);if(a.parseAllBytes&&c.length()!==0){var S=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw S.byteCount=g,S.remaining=c.length(),S}return f};function d(c,a,g,f){if(g>=f.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var S;r(c,a,2);var P=c.getByte();a--;var b=P&192,l=P&31;S=c.length();var m=i(c,a);if(a-=S-c.length(),m!==void 0&&m>a){if(f.strict){var x=new Error("Too few bytes to read ASN.1 value.");throw x.available=c.length(),x.remaining=a,x.requested=m,x}m=a}var C,o,h=(P&32)===32;if(h)if(C=[],m===void 0)for(;;){if(r(c,a,2),c.bytes(2)==="\0\0"){c.getBytes(2),a-=2;break}S=c.length(),C.push(d(c,a,g+1,f)),a-=S-c.length()}else for(;m>0;)S=c.length(),C.push(d(c,m,g+1,f)),a-=S-c.length(),m-=S-c.length();if(C===void 0&&b===e.Class.UNIVERSAL&&l===e.Type.BITSTRING&&(o=c.bytes(m)),C===void 0&&f.decodeBitStrings&&b===e.Class.UNIVERSAL&&l===e.Type.BITSTRING&&m>1){var y=c.read,A=a,_=0;if(l===e.Type.BITSTRING&&(r(c,a,1),_=c.getByte(),a--),_===0)try{S=c.length();var p={strict:!0,decodeBitStrings:!0},s=d(c,a,g+1,p),n=S-c.length();a-=n,l==e.Type.BITSTRING&&n++;var B=s.tagClass;n===m&&(B===e.Class.UNIVERSAL||B===e.Class.CONTEXT_SPECIFIC)&&(C=[s])}catch{}C===void 0&&(c.read=y,a=A)}if(C===void 0){if(m===void 0){if(f.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=a}if(l===e.Type.BMPSTRING)for(C="";m>0;m-=2)r(c,a,2),C+=String.fromCharCode(c.getInt16()),a-=2;else C=c.getBytes(m),a-=m}var D=o===void 0?null:{bitStringContents:o};return e.create(b,l,h,C,D)}e.toDer=function(c){var a=t.util.createBuffer(),g=c.tagClass|c.type,f=t.util.createBuffer(),S=!1;if("bitStringContents"in c&&(S=!0,c.original&&(S=e.equals(c,c.original))),S)f.putBytes(c.bitStringContents);else if(c.composed){c.constructed?g|=32:f.putByte(0);for(var P=0;P<c.value.length;++P)c.value[P]!==void 0&&f.putBuffer(e.toDer(c.value[P]))}else if(c.type===e.Type.BMPSTRING)for(var P=0;P<c.value.length;++P)f.putInt16(c.value.charCodeAt(P));else c.type===e.Type.INTEGER&&c.value.length>1&&(c.value.charCodeAt(0)===0&&(c.value.charCodeAt(1)&128)===0||c.value.charCodeAt(0)===255&&(c.value.charCodeAt(1)&128)===128)?f.putBytes(c.value.substr(1)):f.putBytes(c.value);if(a.putByte(g),f.length()<=127)a.putByte(f.length()&127);else{var b=f.length(),l="";do l+=String.fromCharCode(b&255),b=b>>>8;while(b>0);a.putByte(l.length|128);for(var P=l.length-1;P>=0;--P)a.putByte(l.charCodeAt(P))}return a.putBuffer(f),a},e.oidToDer=function(c){var a=c.split("."),g=t.util.createBuffer();g.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var f,S,P,b,l=2;l<a.length;++l){if(f=!0,S=[],P=parseInt(a[l],10),P>4294967295)throw new Error("OID value too large; max is 32-bits.");do b=P&127,P=P>>>7,f||(b|=128),S.push(b),f=!1;while(P>0);for(var m=S.length-1;m>=0;--m)g.putByte(S[m])}return g},e.derToOid=function(c){var a;typeof c=="string"&&(c=t.util.createBuffer(c));var g=c.getByte();a=Math.floor(g/40)+"."+g%40;for(var f=0;c.length()>0;){if(f>70368744177663)throw new Error("OID value too large; max is 53-bits.");g=c.getByte(),f=f*128,g&128?f+=g&127:(a+="."+(f+g),f=0)}return a},e.utcTimeToDate=function(c){var a=new Date,g=parseInt(c.substr(0,2),10);g=g>=50?1900+g:2e3+g;var f=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),P=parseInt(c.substr(6,2),10),b=parseInt(c.substr(8,2),10),l=0;if(c.length>11){var m=c.charAt(10),x=10;m!=="+"&&m!=="-"&&(l=parseInt(c.substr(10,2),10),x+=2)}if(a.setUTCFullYear(g,f,S),a.setUTCHours(P,b,l,0),x&&(m=c.charAt(x),m==="+"||m==="-")){var C=parseInt(c.substr(x+1,2),10),o=parseInt(c.substr(x+4,2),10),h=C*60+o;h*=6e4,m==="+"?a.setTime(+a-h):a.setTime(+a+h)}return a},e.generalizedTimeToDate=function(c){var a=new Date,g=parseInt(c.substr(0,4),10),f=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),P=parseInt(c.substr(8,2),10),b=parseInt(c.substr(10,2),10),l=parseInt(c.substr(12,2),10),m=0,x=0,C=!1;c.charAt(c.length-1)==="Z"&&(C=!0);var o=c.length-5,h=c.charAt(o);if(h==="+"||h==="-"){var y=parseInt(c.substr(o+1,2),10),A=parseInt(c.substr(o+4,2),10);x=y*60+A,x*=6e4,h==="+"&&(x*=-1),C=!0}return c.charAt(14)==="."&&(m=parseFloat(c.substr(14),10)*1e3),C?(a.setUTCFullYear(g,f,S),a.setUTCHours(P,b,l,m),a.setTime(+a+x)):(a.setFullYear(g,f,S),a.setHours(P,b,l,m)),a},e.dateToUtcTime=function(c){if(typeof c=="string")return c;var a="",g=[];g.push((""+c.getUTCFullYear()).substr(2)),g.push(""+(c.getUTCMonth()+1)),g.push(""+c.getUTCDate()),g.push(""+c.getUTCHours()),g.push(""+c.getUTCMinutes()),g.push(""+c.getUTCSeconds());for(var f=0;f<g.length;++f)g[f].length<2&&(a+="0"),a+=g[f];return a+="Z",a},e.dateToGeneralizedTime=function(c){if(typeof c=="string")return c;var a="",g=[];g.push(""+c.getUTCFullYear()),g.push(""+(c.getUTCMonth()+1)),g.push(""+c.getUTCDate()),g.push(""+c.getUTCHours()),g.push(""+c.getUTCMinutes()),g.push(""+c.getUTCSeconds());for(var f=0;f<g.length;++f)g[f].length<2&&(a+="0"),a+=g[f];return a+="Z",a},e.integerToDer=function(c){var a=t.util.createBuffer();if(c>=-128&&c<128)return a.putSignedInt(c,8);if(c>=-32768&&c<32768)return a.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return a.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return a.putSignedInt(c,32);var g=new Error("Integer too large; max is 32-bits.");throw g.integer=c,g},e.derToInteger=function(c){typeof c=="string"&&(c=t.util.createBuffer(c));var a=c.length()*8;if(a>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(a)},e.validate=function(c,a,g,f){var S=!1;if((c.tagClass===a.tagClass||typeof a.tagClass>"u")&&(c.type===a.type||typeof a.type>"u"))if(c.constructed===a.constructed||typeof a.constructed>"u"){if(S=!0,a.value&&t.util.isArray(a.value))for(var P=0,b=0;S&&b<a.value.length;++b){var l=a.value[b];S=!!l.optional;var m=c.value[P];if(!m){l.optional||(S=!1,f&&f.push("["+a.name+'] Missing required element. Expected tag class "'+l.tagClass+'", type "'+l.type+'"'));continue}var x=typeof l.tagClass<"u"&&typeof l.type<"u";if(x&&(m.tagClass!==l.tagClass||m.type!==l.type))if(l.optional){S=!0;continue}else{S=!1,f&&f.push("["+a.name+"] Tag mismatch. Expected ("+l.tagClass+","+l.type+"), got ("+m.tagClass+","+m.type+")");break}var C=e.validate(m,l,g,f);if(C)++P,S=!0;else if(l.optional)S=!0;else{S=!1;break}}if(S&&g&&(a.capture&&(g[a.capture]=c.value),a.captureAsn1&&(g[a.captureAsn1]=c),a.captureBitStringContents&&"bitStringContents"in c&&(g[a.captureBitStringContents]=c.bitStringContents),a.captureBitStringValue&&"bitStringContents"in c))if(c.bitStringContents.length<2)g[a.captureBitStringValue]="";else{var o=c.bitStringContents.charCodeAt(0);if(o!==0)throw new Error("captureBitStringValue only supported for zero unused bits");g[a.captureBitStringValue]=c.bitStringContents.slice(1)}}else f&&f.push("["+a.name+'] Expected constructed "'+a.constructed+'", got "'+c.constructed+'"');else f&&(c.tagClass!==a.tagClass&&f.push("["+a.name+'] Expected tag class "'+a.tagClass+'", got "'+c.tagClass+'"'),c.type!==a.type&&f.push("["+a.name+'] Expected type "'+a.type+'", got "'+c.type+'"'));return S};var v=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(c,a,g){var f="";a=a||0,g=g||2,a>0&&(f+=`
5
+ `);for(var S="",P=0;P<a*g;++P)S+=" ";switch(f+=S+"Tag: ",c.tagClass){case e.Class.UNIVERSAL:f+="Universal:";break;case e.Class.APPLICATION:f+="Application:";break;case e.Class.CONTEXT_SPECIFIC:f+="Context-Specific:";break;case e.Class.PRIVATE:f+="Private:";break}if(c.tagClass===e.Class.UNIVERSAL)switch(f+=c.type,c.type){case e.Type.NONE:f+=" (None)";break;case e.Type.BOOLEAN:f+=" (Boolean)";break;case e.Type.INTEGER:f+=" (Integer)";break;case e.Type.BITSTRING:f+=" (Bit string)";break;case e.Type.OCTETSTRING:f+=" (Octet string)";break;case e.Type.NULL:f+=" (Null)";break;case e.Type.OID:f+=" (Object Identifier)";break;case e.Type.ODESC:f+=" (Object Descriptor)";break;case e.Type.EXTERNAL:f+=" (External or Instance of)";break;case e.Type.REAL:f+=" (Real)";break;case e.Type.ENUMERATED:f+=" (Enumerated)";break;case e.Type.EMBEDDED:f+=" (Embedded PDV)";break;case e.Type.UTF8:f+=" (UTF8)";break;case e.Type.ROID:f+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:f+=" (Sequence)";break;case e.Type.SET:f+=" (Set)";break;case e.Type.PRINTABLESTRING:f+=" (Printable String)";break;case e.Type.IA5String:f+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:f+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:f+=" (Generalized time)";break;case e.Type.BMPSTRING:f+=" (BMP String)";break}else f+=c.type;if(f+=`
6
+ `,f+=S+"Constructed: "+c.constructed+`
7
+ `,c.composed){for(var b=0,l="",P=0;P<c.value.length;++P)c.value[P]!==void 0&&(b+=1,l+=e.prettyPrint(c.value[P],a+1,g),P+1<c.value.length&&(l+=","));f+=S+"Sub values: "+b+l}else{if(f+=S+"Value: ",c.type===e.Type.OID){var m=e.derToOid(c.value);f+=m,t.pki&&t.pki.oids&&m in t.pki.oids&&(f+=" ("+t.pki.oids[m]+") ")}if(c.type===e.Type.INTEGER)try{f+=e.derToInteger(c.value)}catch{f+="0x"+t.util.bytesToHex(c.value)}else if(c.type===e.Type.BITSTRING){if(c.value.length>1?f+="0x"+t.util.bytesToHex(c.value.slice(1)):f+="(none)",c.value.length>0){var x=c.value.charCodeAt(0);x==1?f+=" (1 unused bit shown)":x>1&&(f+=" ("+x+" unused bits shown)")}}else if(c.type===e.Type.OCTETSTRING)v.test(c.value)||(f+="("+c.value+") "),f+="0x"+t.util.bytesToHex(c.value);else if(c.type===e.Type.UTF8)try{f+=t.util.decodeUtf8(c.value)}catch(C){if(C.message==="URI malformed")f+="0x"+t.util.bytesToHex(c.value)+" (malformed UTF8)";else throw C}else c.type===e.Type.PRINTABLESTRING||c.type===e.Type.IA5String?f+=c.value:v.test(c.value)?f+="0x"+t.util.bytesToHex(c.value):c.value.length===0?f+="[null]":f+=c.value}return f},Ar.exports}var Br={exports:{}},wr,Ga;function xt(){if(Ga)return wr;Ga=1;var t=ve();return wr=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},wr}var za;function Qt(){if(za)return Br.exports;za=1;var t=ve();xt(),Ee();var e=Br.exports=t.hmac=t.hmac||{};return e.create=function(){var r=null,i=null,d=null,v=null,c={};return c.start=function(a,g){if(a!==null)if(typeof a=="string")if(a=a.toLowerCase(),a in t.md.algorithms)i=t.md.algorithms[a].create();else throw new Error('Unknown hash algorithm "'+a+'"');else i=a;if(g===null)g=r;else{if(typeof g=="string")g=t.util.createBuffer(g);else if(t.util.isArray(g)){var f=g;g=t.util.createBuffer();for(var S=0;S<f.length;++S)g.putByte(f[S])}var P=g.length();P>i.blockLength&&(i.start(),i.update(g.bytes()),g=i.digest()),d=t.util.createBuffer(),v=t.util.createBuffer(),P=g.length();for(var S=0;S<P;++S){var f=g.at(S);d.putByte(54^f),v.putByte(92^f)}if(P<i.blockLength)for(var f=i.blockLength-P,S=0;S<f;++S)d.putByte(54),v.putByte(92);r=g,d=d.bytes(),v=v.bytes()}i.start(),i.update(d)},c.update=function(a){i.update(a)},c.getMac=function(){var a=i.digest().bytes();return i.start(),i.update(v),i.update(a),i.digest()},c.digest=c.getMac,c},Br.exports}var Nr={exports:{}},Qa;function ma(){if(Qa)return Nr.exports;Qa=1;var t=ve();xt(),Ee();var e=Nr.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){c||a();var f=null,S=t.util.createBuffer(),P=new Array(16),b={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return b.start=function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var l=b.messageLengthSize/4,m=0;m<l;++m)b.fullMessageLength.push(0);return S=t.util.createBuffer(),f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},b},b.start(),b.update=function(l,m){m==="utf8"&&(l=t.util.encodeUtf8(l));var x=l.length;b.messageLength+=x,x=[x/4294967296>>>0,x>>>0];for(var C=b.fullMessageLength.length-1;C>=0;--C)b.fullMessageLength[C]+=x[1],x[1]=x[0]+(b.fullMessageLength[C]/4294967296>>>0),b.fullMessageLength[C]=b.fullMessageLength[C]>>>0,x[0]=x[1]/4294967296>>>0;return S.putBytes(l),g(f,P,S),(S.read>2048||S.length()===0)&&S.compact(),b},b.digest=function(){var l=t.util.createBuffer();l.putBytes(S.bytes());var m=b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize,x=m&b.blockLength-1;l.putBytes(r.substr(0,b.blockLength-x));for(var C,o=0,h=b.fullMessageLength.length-1;h>=0;--h)C=b.fullMessageLength[h]*8+o,o=C/4294967296>>>0,l.putInt32Le(C>>>0);var y={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3};g(y,P,l);var A=t.util.createBuffer();return A.putInt32Le(y.h0),A.putInt32Le(y.h1),A.putInt32Le(y.h2),A.putInt32Le(y.h3),A},b};var r=null,i=null,d=null,v=null,c=!1;function a(){r="€",r+=t.util.fillString("\0",64),i=[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],d=[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],v=new Array(64);for(var f=0;f<64;++f)v[f]=Math.floor(Math.abs(Math.sin(f+1))*4294967296);c=!0}function g(f,S,P){for(var b,l,m,x,C,o,h,y,A=P.length();A>=64;){for(l=f.h0,m=f.h1,x=f.h2,C=f.h3,y=0;y<16;++y)S[y]=P.getInt32Le(),o=C^m&(x^C),b=l+o+v[y]+S[y],h=d[y],l=C,C=x,x=m,m+=b<<h|b>>>32-h;for(;y<32;++y)o=x^C&(m^x),b=l+o+v[y]+S[i[y]],h=d[y],l=C,C=x,x=m,m+=b<<h|b>>>32-h;for(;y<48;++y)o=m^x^C,b=l+o+v[y]+S[i[y]],h=d[y],l=C,C=x,x=m,m+=b<<h|b>>>32-h;for(;y<64;++y)o=x^(m|~C),b=l+o+v[y]+S[i[y]],h=d[y],l=C,C=x,x=m,m+=b<<h|b>>>32-h;f.h0=f.h0+l|0,f.h1=f.h1+m|0,f.h2=f.h2+x|0,f.h3=f.h3+C|0,A-=64}}return Nr.exports}var Rr={exports:{}},$a;function Ot(){if($a)return Rr.exports;$a=1;var t=ve();Ee();var e=Rr.exports=t.pem=t.pem||{};e.encode=function(d,v){v=v||{};var c="-----BEGIN "+d.type+`-----\r
8
+ `,a;if(d.procType&&(a={name:"Proc-Type",values:[String(d.procType.version),d.procType.type]},c+=r(a)),d.contentDomain&&(a={name:"Content-Domain",values:[d.contentDomain]},c+=r(a)),d.dekInfo&&(a={name:"DEK-Info",values:[d.dekInfo.algorithm]},d.dekInfo.parameters&&a.values.push(d.dekInfo.parameters),c+=r(a)),d.headers)for(var g=0;g<d.headers.length;++g)c+=r(d.headers[g]);return d.procType&&(c+=`\r
9
+ `),c+=t.util.encode64(d.body,v.maxline||64)+`\r
10
+ `,c+="-----END "+d.type+`-----\r
11
+ `,c},e.decode=function(d){for(var v=[],c=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,a=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,g=/\r?\n/,f;f=c.exec(d),!!f;){var S=f[1];S==="NEW CERTIFICATE REQUEST"&&(S="CERTIFICATE REQUEST");var P={type:S,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(f[3])};if(v.push(P),!!f[2]){for(var b=f[2].split(g),l=0;f&&l<b.length;){for(var m=b[l].replace(/\s+$/,""),x=l+1;x<b.length;++x){var C=b[x];if(!/\s/.test(C[0]))break;m+=C,l=x}if(f=m.match(a),f){for(var o={name:f[1],values:[]},h=f[2].split(","),y=0;y<h.length;++y)o.values.push(i(h[y]));if(P.procType)if(!P.contentDomain&&o.name==="Content-Domain")P.contentDomain=h[0]||"";else if(!P.dekInfo&&o.name==="DEK-Info"){if(o.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');P.dekInfo={algorithm:h[0],parameters:h[1]||null}}else P.headers.push(o);else{if(o.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(o.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');P.procType={version:h[0],type:h[1]}}}++l}if(P.procType==="ENCRYPTED"&&!P.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(v.length===0)throw new Error("Invalid PEM formatted message.");return v};function r(d){for(var v=d.name+": ",c=[],a=function(b,l){return" "+l},g=0;g<d.values.length;++g)c.push(d.values[g].replace(/^(\S+\r\n)/,a));v+=c.join(",")+`\r
12
+ `;for(var f=0,S=-1,g=0;g<v.length;++g,++f)if(f>65&&S!==-1){var P=v[S];P===","?(++S,v=v.substr(0,S)+`\r
13
+ `+v.substr(S)):v=v.substr(0,S)+`\r
14
+ `+P+v.substr(S+1),f=g-S-1,S=-1,++g}else(v[g]===" "||v[g]===" "||v[g]===",")&&(S=g);return v}function i(d){return d.replace(/^\s+/,"")}return Rr.exports}var _r={exports:{}},Dr,Wa;function fr(){if(Wa)return Dr;Wa=1;var t=ve();ya(),ti(),Ee(),Dr=t.des=t.des||{},t.des.startEncrypting=function(l,m,x,C){var o=b({key:l,output:x,decrypt:!1,mode:C||(m===null?"ECB":"CBC")});return o.start(m),o},t.des.createEncryptionCipher=function(l,m){return b({key:l,output:null,decrypt:!1,mode:m})},t.des.startDecrypting=function(l,m,x,C){var o=b({key:l,output:x,decrypt:!0,mode:C||(m===null?"ECB":"CBC")});return o.start(m),o},t.des.createDecryptionCipher=function(l,m){return b({key:l,output:null,decrypt:!0,mode:m})},t.des.Algorithm=function(l,m){var x=this;x.name=l,x.mode=new m({blockSize:8,cipher:{encrypt:function(C,o){return P(x._keys,C,o,!1)},decrypt:function(C,o){return P(x._keys,C,o,!0)}}}),x._init=!1},t.des.Algorithm.prototype.initialize=function(l){if(!this._init){var m=t.util.createBuffer(l.key);if(this.name.indexOf("3DES")===0&&m.length()!==24)throw new Error("Invalid Triple-DES key size: "+m.length()*8);this._keys=S(m),this._init=!0}},e("DES-ECB",t.cipher.modes.ecb),e("DES-CBC",t.cipher.modes.cbc),e("DES-CFB",t.cipher.modes.cfb),e("DES-OFB",t.cipher.modes.ofb),e("DES-CTR",t.cipher.modes.ctr),e("3DES-ECB",t.cipher.modes.ecb),e("3DES-CBC",t.cipher.modes.cbc),e("3DES-CFB",t.cipher.modes.cfb),e("3DES-OFB",t.cipher.modes.ofb),e("3DES-CTR",t.cipher.modes.ctr);function e(l,m){var x=function(){return new t.des.Algorithm(l,m)};t.cipher.registerAlgorithm(l,x)}var r=[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],i=[-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],d=[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],v=[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],c=[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],a=[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],g=[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],f=[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 S(l){for(var m=[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],C=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],h=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],y=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],A=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],_=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],p=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],s=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],n=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],B=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],D=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],V=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],U=l.length()>8?3:1,F=[],q=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],M=0,H,W=0;W<U;W++){var j=l.getInt32(),J=l.getInt32();H=(j>>>4^J)&252645135,J^=H,j^=H<<4,H=(J>>>-16^j)&65535,j^=H,J^=H<<-16,H=(j>>>2^J)&858993459,J^=H,j^=H<<2,H=(J>>>-16^j)&65535,j^=H,J^=H<<-16,H=(j>>>1^J)&1431655765,J^=H,j^=H<<1,H=(J>>>8^j)&16711935,j^=H,J^=H<<8,H=(j>>>1^J)&1431655765,J^=H,j^=H<<1,H=j<<8|J>>>20&240,j=J<<24|J<<8&16711680|J>>>8&65280|J>>>24&240,J=H;for(var ce=0;ce<q.length;++ce){q[ce]?(j=j<<2|j>>>26,J=J<<2|J>>>26):(j=j<<1|j>>>27,J=J<<1|J>>>27),j&=-15,J&=-15;var fe=m[j>>>28]|x[j>>>24&15]|C[j>>>20&15]|o[j>>>16&15]|h[j>>>12&15]|y[j>>>8&15]|A[j>>>4&15],me=_[J>>>28]|p[J>>>24&15]|s[J>>>20&15]|n[J>>>16&15]|B[J>>>12&15]|D[J>>>8&15]|V[J>>>4&15];H=(me>>>16^fe)&65535,F[M++]=fe^H,F[M++]=me^H<<16}}return F}function P(l,m,x,C){var o=l.length===32?3:9,h;o===3?h=C?[30,-2,-2]:[0,32,2]:h=C?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y,A=m[0],_=m[1];y=(A>>>4^_)&252645135,_^=y,A^=y<<4,y=(A>>>16^_)&65535,_^=y,A^=y<<16,y=(_>>>2^A)&858993459,A^=y,_^=y<<2,y=(_>>>8^A)&16711935,A^=y,_^=y<<8,y=(A>>>1^_)&1431655765,_^=y,A^=y<<1,A=A<<1|A>>>31,_=_<<1|_>>>31;for(var p=0;p<o;p+=3){for(var s=h[p+1],n=h[p+2],B=h[p];B!=s;B+=n){var D=_^l[B],V=(_>>>4|_<<28)^l[B+1];y=A,A=_,_=y^(i[D>>>24&63]|v[D>>>16&63]|a[D>>>8&63]|f[D&63]|r[V>>>24&63]|d[V>>>16&63]|c[V>>>8&63]|g[V&63])}y=A,A=_,_=y}A=A>>>1|A<<31,_=_>>>1|_<<31,y=(A>>>1^_)&1431655765,_^=y,A^=y<<1,y=(_>>>8^A)&16711935,A^=y,_^=y<<8,y=(_>>>2^A)&858993459,A^=y,_^=y<<2,y=(A>>>16^_)&65535,_^=y,A^=y<<16,y=(A>>>4^_)&252645135,_^=y,A^=y<<4,x[0]=A,x[1]=_}function b(l){l=l||{};var m=(l.mode||"CBC").toUpperCase(),x="DES-"+m,C;l.decrypt?C=t.cipher.createDecipher(x,l.key):C=t.cipher.createCipher(x,l.key);var o=C.start;return C.start=function(h,y){var A=null;y instanceof t.util.ByteBuffer&&(A=y,y={}),y=y||{},y.output=A,y.iv=h,o.call(C,y)},C}return Dr}const Qs={},$s=Object.freeze(Object.defineProperty({__proto__:null,default:Qs},Symbol.toStringTag,{value:"Module"})),Ca=Ls($s);var Lr,Ya;function Ea(){if(Ya)return Lr;Ya=1;var t=ve();Qt(),xt(),Ee();var e=t.pkcs5=t.pkcs5||{},r;return t.util.isNodejs&&!t.options.usePureJavaScript&&(r=Ca),Lr=t.pbkdf2=e.pbkdf2=function(i,d,v,c,a,g){if(typeof a=="function"&&(g=a,a=null),t.util.isNodejs&&!t.options.usePureJavaScript&&r.pbkdf2&&(a===null||typeof a!="object")&&(r.pbkdf2Sync.length>4||!a||a==="sha1"))return typeof a!="string"&&(a="sha1"),i=Buffer.from(i,"binary"),d=Buffer.from(d,"binary"),g?r.pbkdf2Sync.length===4?r.pbkdf2(i,d,v,c,function(p,s){if(p)return g(p);g(null,s.toString("binary"))}):r.pbkdf2(i,d,v,c,a,function(p,s){if(p)return g(p);g(null,s.toString("binary"))}):r.pbkdf2Sync.length===4?r.pbkdf2Sync(i,d,v,c).toString("binary"):r.pbkdf2Sync(i,d,v,c,a).toString("binary");if((typeof a>"u"||a===null)&&(a="sha1"),typeof a=="string"){if(!(a in t.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=t.md[a].create()}var f=a.digestLength;if(c>4294967295*f){var S=new Error("Derived key is too long.");if(g)return g(S);throw S}var P=Math.ceil(c/f),b=c-(P-1)*f,l=t.hmac.create();l.start(a,i);var m="",x,C,o;if(!g){for(var h=1;h<=P;++h){l.start(null,null),l.update(d),l.update(t.util.int32ToBytes(h)),x=o=l.digest().getBytes();for(var y=2;y<=v;++y)l.start(null,null),l.update(o),C=l.digest().getBytes(),x=t.util.xorBytes(x,C,f),o=C;m+=h<P?x:x.substr(0,b)}return m}var h=1,y;function A(){if(h>P)return g(null,m);l.start(null,null),l.update(d),l.update(t.util.int32ToBytes(h)),x=o=l.digest().getBytes(),y=2,_()}function _(){if(y<=v)return l.start(null,null),l.update(o),C=l.digest().getBytes(),x=t.util.xorBytes(x,C,f),o=C,++y,t.util.setImmediate(_);m+=h<P?x:x.substr(0,b),++h,A()}A()},Lr}var Zt={exports:{}},Pr={exports:{}},ja;function ri(){if(ja)return Pr.exports;ja=1;var t=ve();xt(),Ee();var e=Pr.exports=t.sha256=t.sha256||{};t.md.sha256=t.md.algorithms.sha256=e,e.create=function(){i||v();var a=null,g=t.util.createBuffer(),f=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return S.start=function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var P=S.messageLengthSize/4,b=0;b<P;++b)S.fullMessageLength.push(0);return g=t.util.createBuffer(),a={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},S},S.start(),S.update=function(P,b){b==="utf8"&&(P=t.util.encodeUtf8(P));var l=P.length;S.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var m=S.fullMessageLength.length-1;m>=0;--m)S.fullMessageLength[m]+=l[1],l[1]=l[0]+(S.fullMessageLength[m]/4294967296>>>0),S.fullMessageLength[m]=S.fullMessageLength[m]>>>0,l[0]=l[1]/4294967296>>>0;return g.putBytes(P),c(a,f,g),(g.read>2048||g.length()===0)&&g.compact(),S},S.digest=function(){var P=t.util.createBuffer();P.putBytes(g.bytes());var b=S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize,l=b&S.blockLength-1;P.putBytes(r.substr(0,S.blockLength-l));for(var m,x,C=S.fullMessageLength[0]*8,o=0;o<S.fullMessageLength.length-1;++o)m=S.fullMessageLength[o+1]*8,x=m/4294967296>>>0,C+=x,P.putInt32(C>>>0),C=m>>>0;P.putInt32(C);var h={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4,h5:a.h5,h6:a.h6,h7:a.h7};c(h,f,P);var y=t.util.createBuffer();return y.putInt32(h.h0),y.putInt32(h.h1),y.putInt32(h.h2),y.putInt32(h.h3),y.putInt32(h.h4),y.putInt32(h.h5),y.putInt32(h.h6),y.putInt32(h.h7),y},S};var r=null,i=!1,d=null;function v(){r="€",r+=t.util.fillString("\0",64),d=[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],i=!0}function c(a,g,f){for(var S,P,b,l,m,x,C,o,h,y,A,_,p,s,n,B=f.length();B>=64;){for(C=0;C<16;++C)g[C]=f.getInt32();for(;C<64;++C)S=g[C-2],S=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10,P=g[C-15],P=(P>>>7|P<<25)^(P>>>18|P<<14)^P>>>3,g[C]=S+g[C-7]+P+g[C-16]|0;for(o=a.h0,h=a.h1,y=a.h2,A=a.h3,_=a.h4,p=a.h5,s=a.h6,n=a.h7,C=0;C<64;++C)l=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),m=s^_&(p^s),b=(o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10),x=o&h|y&(o^h),S=n+l+m+d[C]+g[C],P=b+x,n=s,s=p,p=_,_=A+S>>>0,A=y,y=h,h=o,o=S+P>>>0;a.h0=a.h0+o|0,a.h1=a.h1+h|0,a.h2=a.h2+y|0,a.h3=a.h3+A|0,a.h4=a.h4+_|0,a.h5=a.h5+p|0,a.h6=a.h6+s|0,a.h7=a.h7+n|0,B-=64}}return Pr.exports}var Ur={exports:{}},Xa;function ai(){if(Xa)return Ur.exports;Xa=1;var t=ve();Ee();var e=null;t.util.isNodejs&&!t.options.usePureJavaScript&&!process.versions["node-webkit"]&&(e=Ca);var r=Ur.exports=t.prng=t.prng||{};return r.create=function(i){for(var d={plugin:i,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},v=i.md,c=new Array(32),a=0;a<32;++a)c[a]=v.create();d.pools=c,d.pool=0,d.generate=function(b,l){if(!l)return d.generateSync(b);var m=d.plugin.cipher,x=d.plugin.increment,C=d.plugin.formatKey,o=d.plugin.formatSeed,h=t.util.createBuffer();d.key=null,y();function y(A){if(A)return l(A);if(h.length()>=b)return l(null,h.getBytes(b));if(d.generated>1048575&&(d.key=null),d.key===null)return t.util.nextTick(function(){g(y)});var _=m(d.key,d.seed);d.generated+=_.length,h.putBytes(_),d.key=C(m(d.key,x(d.seed))),d.seed=o(m(d.key,d.seed)),t.util.setImmediate(y)}},d.generateSync=function(b){var l=d.plugin.cipher,m=d.plugin.increment,x=d.plugin.formatKey,C=d.plugin.formatSeed;d.key=null;for(var o=t.util.createBuffer();o.length()<b;){d.generated>1048575&&(d.key=null),d.key===null&&f();var h=l(d.key,d.seed);d.generated+=h.length,o.putBytes(h),d.key=x(l(d.key,m(d.seed))),d.seed=C(l(d.key,d.seed))}return o.getBytes(b)};function g(b){if(d.pools[0].messageLength>=32)return S(),b();var l=32-d.pools[0].messageLength<<5;d.seedFile(l,function(m,x){if(m)return b(m);d.collect(x),S(),b()})}function f(){if(d.pools[0].messageLength>=32)return S();var b=32-d.pools[0].messageLength<<5;d.collect(d.seedFileSync(b)),S()}function S(){d.reseeds=d.reseeds===4294967295?0:d.reseeds+1;var b=d.plugin.md.create();b.update(d.keyBytes);for(var l=1,m=0;m<32;++m)d.reseeds%l===0&&(b.update(d.pools[m].digest().getBytes()),d.pools[m].start()),l=l<<1;d.keyBytes=b.digest().getBytes(),b.start(),b.update(d.keyBytes);var x=b.digest().getBytes();d.key=d.plugin.formatKey(d.keyBytes),d.seed=d.plugin.formatSeed(x),d.generated=0}function P(b){var l=null,m=t.util.globalScope,x=m.crypto||m.msCrypto;x&&x.getRandomValues&&(l=function(n){return x.getRandomValues(n)});var C=t.util.createBuffer();if(l)for(;C.length()<b;){var o=Math.max(1,Math.min(b-C.length(),65536)/4),h=new Uint32Array(Math.floor(o));try{l(h);for(var y=0;y<h.length;++y)C.putInt32(h[y])}catch(n){if(!(typeof QuotaExceededError<"u"&&n instanceof QuotaExceededError))throw n}}if(C.length()<b)for(var A,_,p,s=Math.floor(Math.random()*65536);C.length()<b;){_=16807*(s&65535),A=16807*(s>>16),_+=(A&32767)<<16,_+=A>>15,_=(_&2147483647)+(_>>31),s=_&4294967295;for(var y=0;y<3;++y)p=s>>>(y<<3),p^=Math.floor(Math.random()*256),C.putByte(p&255)}return C.getBytes(b)}return e?(d.seedFile=function(b,l){e.randomBytes(b,function(m,x){if(m)return l(m);l(null,x.toString())})},d.seedFileSync=function(b){return e.randomBytes(b).toString()}):(d.seedFile=function(b,l){try{l(null,P(b))}catch(m){l(m)}},d.seedFileSync=P),d.collect=function(b){for(var l=b.length,m=0;m<l;++m)d.pools[d.pool].update(b.substr(m,1)),d.pool=d.pool===31?0:d.pool+1},d.collectInt=function(b,l){for(var m="",x=0;x<l;x+=8)m+=String.fromCharCode(b>>x&255);d.collect(m)},d.registerWorker=function(b){if(b===self)d.seedFile=function(m,x){function C(o){var h=o.data;h.forge&&h.forge.prng&&(self.removeEventListener("message",C),x(h.forge.prng.err,h.forge.prng.bytes))}self.addEventListener("message",C),self.postMessage({forge:{prng:{needed:m}}})};else{var l=function(m){var x=m.data;x.forge&&x.forge.prng&&d.seedFile(x.forge.prng.needed,function(C,o){b.postMessage({forge:{prng:{err:C,bytes:o}}})})};b.addEventListener("message",l)}},d},Ur.exports}var Za;function pt(){if(Za)return Zt.exports;Za=1;var t=ve();return Dt(),ri(),ai(),Ee(),(function(){if(t.random&&t.random.getBytes){Zt.exports=t.random;return}(function(e){var r={},i=new Array(4),d=t.util.createBuffer();r.formatKey=function(b){var l=t.util.createBuffer(b);return b=new Array(4),b[0]=l.getInt32(),b[1]=l.getInt32(),b[2]=l.getInt32(),b[3]=l.getInt32(),t.aes._expandKey(b,!1)},r.formatSeed=function(b){var l=t.util.createBuffer(b);return b=new Array(4),b[0]=l.getInt32(),b[1]=l.getInt32(),b[2]=l.getInt32(),b[3]=l.getInt32(),b},r.cipher=function(b,l){return t.aes._updateBlock(b,l,i,!1),d.putInt32(i[0]),d.putInt32(i[1]),d.putInt32(i[2]),d.putInt32(i[3]),d.getBytes()},r.increment=function(b){return++b[3],b},r.md=t.md.sha256;function v(){var b=t.prng.create(r);return b.getBytes=function(l,m){return b.generate(l,m)},b.getBytesSync=function(l){return b.generate(l)},b}var c=v(),a=null,g=t.util.globalScope,f=g.crypto||g.msCrypto;if(f&&f.getRandomValues&&(a=function(b){return f.getRandomValues(b)}),t.options.usePureJavaScript||!t.util.isNodejs&&!a){if(c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var P in navigator)try{typeof navigator[P]=="string"&&(S+=navigator[P])}catch{}c.collect(S),S=null}e&&(e().mousemove(function(b){c.collectInt(b.clientX,16),c.collectInt(b.clientY,16)}),e().keypress(function(b){c.collectInt(b.charCode,8)}))}if(!t.random)t.random=c;else for(var P in c)t.random[P]=c[P];t.random.createInstance=v,Zt.exports=t.random})(typeof jQuery<"u"?jQuery:null)})(),Zt.exports}var kr,Ja;function ni(){if(Ja)return kr;Ja=1;var t=ve();Ee();var e=[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],r=[1,2,3,5],i=function(c,a){return c<<a&65535|(c&65535)>>16-a},d=function(c,a){return(c&65535)>>a|c<<16-a&65535};kr=t.rc2=t.rc2||{},t.rc2.expandKey=function(c,a){typeof c=="string"&&(c=t.util.createBuffer(c)),a=a||128;var g=c,f=c.length(),S=a,P=Math.ceil(S/8),b=255>>(S&7),l;for(l=f;l<128;l++)g.putByte(e[g.at(l-1)+g.at(l-f)&255]);for(g.setAt(128-P,e[g.at(128-P)&b]),l=127-P;l>=0;l--)g.setAt(l,e[g.at(l+1)^g.at(l+P)]);return g};var v=function(c,a,g){var f=!1,S=null,P=null,b=null,l,m,x,C,o=[];for(c=t.rc2.expandKey(c,a),x=0;x<64;x++)o.push(c.getInt16Le());g?(l=function(A){for(x=0;x<4;x++)A[x]+=o[C]+(A[(x+3)%4]&A[(x+2)%4])+(~A[(x+3)%4]&A[(x+1)%4]),A[x]=i(A[x],r[x]),C++},m=function(A){for(x=0;x<4;x++)A[x]+=o[A[(x+3)%4]&63]}):(l=function(A){for(x=3;x>=0;x--)A[x]=d(A[x],r[x]),A[x]-=o[C]+(A[(x+3)%4]&A[(x+2)%4])+(~A[(x+3)%4]&A[(x+1)%4]),C--},m=function(A){for(x=3;x>=0;x--)A[x]-=o[A[(x+3)%4]&63]});var h=function(A){var _=[];for(x=0;x<4;x++){var p=S.getInt16Le();b!==null&&(g?p^=b.getInt16Le():b.putInt16Le(p)),_.push(p&65535)}C=g?0:63;for(var s=0;s<A.length;s++)for(var n=0;n<A[s][0];n++)A[s][1](_);for(x=0;x<4;x++)b!==null&&(g?b.putInt16Le(_[x]):_[x]^=b.getInt16Le()),P.putInt16Le(_[x])},y=null;return y={start:function(A,_){A&&typeof A=="string"&&(A=t.util.createBuffer(A)),f=!1,S=t.util.createBuffer(),P=_||new t.util.createBuffer,b=A,y.output=P},update:function(A){for(f||S.putBuffer(A);S.length()>=8;)h([[5,l],[1,m],[6,l],[1,m],[5,l]])},finish:function(A){var _=!0;if(g)if(A)_=A(8,S,!g);else{var p=S.length()===8?8:8-S.length();S.fillWithByte(p,p)}if(_&&(f=!0,y.update()),!g&&(_=S.length()===0,_))if(A)_=A(8,P,!g);else{var s=P.length(),n=P.at(s-1);n>s?_=!1:P.truncate(n)}return _}},y};return t.rc2.startEncrypting=function(c,a,g){var f=t.rc2.createEncryptionCipher(c,128);return f.start(a,g),f},t.rc2.createEncryptionCipher=function(c,a){return v(c,a,!0)},t.rc2.startDecrypting=function(c,a,g){var f=t.rc2.createDecryptionCipher(c,128);return f.start(a,g),f},t.rc2.createDecryptionCipher=function(c,a){return v(c,a,!1)},kr}var Or,en;function lr(){if(en)return Or;en=1;var t=ve();Or=t.jsbn=t.jsbn||{};var e;function r(T,w,k){this.data=[],T!=null&&(typeof T=="number"?this.fromNumber(T,w,k):w==null&&typeof T!="string"?this.fromString(T,256):this.fromString(T,w))}t.jsbn.BigInteger=r;function i(){return new r(null)}function d(T,w,k,K,$,Y){for(;--Y>=0;){var ie=w*this.data[T++]+k.data[K]+$;$=Math.floor(ie/67108864),k.data[K++]=ie&67108863}return $}function v(T,w,k,K,$,Y){for(var ie=w&32767,re=w>>15;--Y>=0;){var Se=this.data[T]&32767,We=this.data[T++]>>15,ot=re*Se+We*ie;Se=ie*Se+((ot&32767)<<15)+k.data[K]+($&1073741823),$=(Se>>>30)+(ot>>>15)+re*We+($>>>30),k.data[K++]=Se&1073741823}return $}function c(T,w,k,K,$,Y){for(var ie=w&16383,re=w>>14;--Y>=0;){var Se=this.data[T]&16383,We=this.data[T++]>>14,ot=re*Se+We*ie;Se=ie*Se+((ot&16383)<<14)+k.data[K]+$,$=(Se>>28)+(ot>>14)+re*We,k.data[K++]=Se&268435455}return $}typeof navigator>"u"?(r.prototype.am=c,e=28):navigator.appName=="Microsoft Internet Explorer"?(r.prototype.am=v,e=30):navigator.appName!="Netscape"?(r.prototype.am=d,e=26):(r.prototype.am=c,e=28),r.prototype.DB=e,r.prototype.DM=(1<<e)-1,r.prototype.DV=1<<e;var a=52;r.prototype.FV=Math.pow(2,a),r.prototype.F1=a-e,r.prototype.F2=2*e-a;var g="0123456789abcdefghijklmnopqrstuvwxyz",f=new Array,S,P;for(S=48,P=0;P<=9;++P)f[S++]=P;for(S=97,P=10;P<36;++P)f[S++]=P;for(S=65,P=10;P<36;++P)f[S++]=P;function b(T){return g.charAt(T)}function l(T,w){var k=f[T.charCodeAt(w)];return k??-1}function m(T){for(var w=this.t-1;w>=0;--w)T.data[w]=this.data[w];T.t=this.t,T.s=this.s}function x(T){this.t=1,this.s=T<0?-1:0,T>0?this.data[0]=T:T<-1?this.data[0]=T+this.DV:this.t=0}function C(T){var w=i();return w.fromInt(T),w}function o(T,w){var k;if(w==16)k=4;else if(w==8)k=3;else if(w==256)k=8;else if(w==2)k=1;else if(w==32)k=5;else if(w==4)k=2;else{this.fromRadix(T,w);return}this.t=0,this.s=0;for(var K=T.length,$=!1,Y=0;--K>=0;){var ie=k==8?T[K]&255:l(T,K);if(ie<0){T.charAt(K)=="-"&&($=!0);continue}$=!1,Y==0?this.data[this.t++]=ie:Y+k>this.DB?(this.data[this.t-1]|=(ie&(1<<this.DB-Y)-1)<<Y,this.data[this.t++]=ie>>this.DB-Y):this.data[this.t-1]|=ie<<Y,Y+=k,Y>=this.DB&&(Y-=this.DB)}k==8&&(T[0]&128)!=0&&(this.s=-1,Y>0&&(this.data[this.t-1]|=(1<<this.DB-Y)-1<<Y)),this.clamp(),$&&r.ZERO.subTo(this,this)}function h(){for(var T=this.s&this.DM;this.t>0&&this.data[this.t-1]==T;)--this.t}function y(T){if(this.s<0)return"-"+this.negate().toString(T);var w;if(T==16)w=4;else if(T==8)w=3;else if(T==2)w=1;else if(T==32)w=5;else if(T==4)w=2;else return this.toRadix(T);var k=(1<<w)-1,K,$=!1,Y="",ie=this.t,re=this.DB-ie*this.DB%w;if(ie-- >0)for(re<this.DB&&(K=this.data[ie]>>re)>0&&($=!0,Y=b(K));ie>=0;)re<w?(K=(this.data[ie]&(1<<re)-1)<<w-re,K|=this.data[--ie]>>(re+=this.DB-w)):(K=this.data[ie]>>(re-=w)&k,re<=0&&(re+=this.DB,--ie)),K>0&&($=!0),$&&(Y+=b(K));return $?Y:"0"}function A(){var T=i();return r.ZERO.subTo(this,T),T}function _(){return this.s<0?this.negate():this}function p(T){var w=this.s-T.s;if(w!=0)return w;var k=this.t;if(w=k-T.t,w!=0)return this.s<0?-w:w;for(;--k>=0;)if((w=this.data[k]-T.data[k])!=0)return w;return 0}function s(T){var w=1,k;return(k=T>>>16)!=0&&(T=k,w+=16),(k=T>>8)!=0&&(T=k,w+=8),(k=T>>4)!=0&&(T=k,w+=4),(k=T>>2)!=0&&(T=k,w+=2),(k=T>>1)!=0&&(T=k,w+=1),w}function n(){return this.t<=0?0:this.DB*(this.t-1)+s(this.data[this.t-1]^this.s&this.DM)}function B(T,w){var k;for(k=this.t-1;k>=0;--k)w.data[k+T]=this.data[k];for(k=T-1;k>=0;--k)w.data[k]=0;w.t=this.t+T,w.s=this.s}function D(T,w){for(var k=T;k<this.t;++k)w.data[k-T]=this.data[k];w.t=Math.max(this.t-T,0),w.s=this.s}function V(T,w){var k=T%this.DB,K=this.DB-k,$=(1<<K)-1,Y=Math.floor(T/this.DB),ie=this.s<<k&this.DM,re;for(re=this.t-1;re>=0;--re)w.data[re+Y+1]=this.data[re]>>K|ie,ie=(this.data[re]&$)<<k;for(re=Y-1;re>=0;--re)w.data[re]=0;w.data[Y]=ie,w.t=this.t+Y+1,w.s=this.s,w.clamp()}function U(T,w){w.s=this.s;var k=Math.floor(T/this.DB);if(k>=this.t){w.t=0;return}var K=T%this.DB,$=this.DB-K,Y=(1<<K)-1;w.data[0]=this.data[k]>>K;for(var ie=k+1;ie<this.t;++ie)w.data[ie-k-1]|=(this.data[ie]&Y)<<$,w.data[ie-k]=this.data[ie]>>K;K>0&&(w.data[this.t-k-1]|=(this.s&Y)<<$),w.t=this.t-k,w.clamp()}function F(T,w){for(var k=0,K=0,$=Math.min(T.t,this.t);k<$;)K+=this.data[k]-T.data[k],w.data[k++]=K&this.DM,K>>=this.DB;if(T.t<this.t){for(K-=T.s;k<this.t;)K+=this.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K+=this.s}else{for(K+=this.s;k<T.t;)K-=T.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K-=T.s}w.s=K<0?-1:0,K<-1?w.data[k++]=this.DV+K:K>0&&(w.data[k++]=K),w.t=k,w.clamp()}function q(T,w){var k=this.abs(),K=T.abs(),$=k.t;for(w.t=$+K.t;--$>=0;)w.data[$]=0;for($=0;$<K.t;++$)w.data[$+k.t]=k.am(0,K.data[$],w,$,0,k.t);w.s=0,w.clamp(),this.s!=T.s&&r.ZERO.subTo(w,w)}function M(T){for(var w=this.abs(),k=T.t=2*w.t;--k>=0;)T.data[k]=0;for(k=0;k<w.t-1;++k){var K=w.am(k,w.data[k],T,2*k,0,1);(T.data[k+w.t]+=w.am(k+1,2*w.data[k],T,2*k+1,K,w.t-k-1))>=w.DV&&(T.data[k+w.t]-=w.DV,T.data[k+w.t+1]=1)}T.t>0&&(T.data[T.t-1]+=w.am(k,w.data[k],T,2*k,0,1)),T.s=0,T.clamp()}function H(T,w,k){var K=T.abs();if(!(K.t<=0)){var $=this.abs();if($.t<K.t){w?.fromInt(0),k!=null&&this.copyTo(k);return}k==null&&(k=i());var Y=i(),ie=this.s,re=T.s,Se=this.DB-s(K.data[K.t-1]);Se>0?(K.lShiftTo(Se,Y),$.lShiftTo(Se,k)):(K.copyTo(Y),$.copyTo(k));var We=Y.t,ot=Y.data[We-1];if(ot!=0){var at=ot*(1<<this.F1)+(We>1?Y.data[We-2]>>this.F2:0),mt=this.FV/at,jt=(1<<this.F1)/at,ft=1<<this.F2,lt=k.t,Xt=lt-We,St=w??i();for(Y.dlShiftTo(Xt,St),k.compareTo(St)>=0&&(k.data[k.t++]=1,k.subTo(St,k)),r.ONE.dlShiftTo(We,St),St.subTo(Y,Y);Y.t<We;)Y.data[Y.t++]=0;for(;--Xt>=0;){var hr=k.data[--lt]==ot?this.DM:Math.floor(k.data[lt]*mt+(k.data[lt-1]+ft)*jt);if((k.data[lt]+=Y.am(0,hr,k,Xt,0,We))<hr)for(Y.dlShiftTo(Xt,St),k.subTo(St,k);k.data[lt]<--hr;)k.subTo(St,k)}w!=null&&(k.drShiftTo(We,w),ie!=re&&r.ZERO.subTo(w,w)),k.t=We,k.clamp(),Se>0&&k.rShiftTo(Se,k),ie<0&&r.ZERO.subTo(k,k)}}}function W(T){var w=i();return this.abs().divRemTo(T,null,w),this.s<0&&w.compareTo(r.ZERO)>0&&T.subTo(w,w),w}function j(T){this.m=T}function J(T){return T.s<0||T.compareTo(this.m)>=0?T.mod(this.m):T}function ce(T){return T}function fe(T){T.divRemTo(this.m,null,T)}function me(T,w,k){T.multiplyTo(w,k),this.reduce(k)}function be(T,w){T.squareTo(w),this.reduce(w)}j.prototype.convert=J,j.prototype.revert=ce,j.prototype.reduce=fe,j.prototype.mulTo=me,j.prototype.sqrTo=be;function he(){if(this.t<1)return 0;var T=this.data[0];if((T&1)==0)return 0;var w=T&3;return w=w*(2-(T&15)*w)&15,w=w*(2-(T&255)*w)&255,w=w*(2-((T&65535)*w&65535))&65535,w=w*(2-T*w%this.DV)%this.DV,w>0?this.DV-w:-w}function X(T){this.m=T,this.mp=T.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<T.DB-15)-1,this.mt2=2*T.t}function ee(T){var w=i();return T.abs().dlShiftTo(this.m.t,w),w.divRemTo(this.m,null,w),T.s<0&&w.compareTo(r.ZERO)>0&&this.m.subTo(w,w),w}function Ve(T){var w=i();return T.copyTo(w),this.reduce(w),w}function Be(T){for(;T.t<=this.mt2;)T.data[T.t++]=0;for(var w=0;w<this.m.t;++w){var k=T.data[w]&32767,K=k*this.mpl+((k*this.mph+(T.data[w]>>15)*this.mpl&this.um)<<15)&T.DM;for(k=w+this.m.t,T.data[k]+=this.m.am(0,K,T,w,0,this.m.t);T.data[k]>=T.DV;)T.data[k]-=T.DV,T.data[++k]++}T.clamp(),T.drShiftTo(this.m.t,T),T.compareTo(this.m)>=0&&T.subTo(this.m,T)}function E(T,w){T.squareTo(w),this.reduce(w)}function L(T,w,k){T.multiplyTo(w,k),this.reduce(k)}X.prototype.convert=ee,X.prototype.revert=Ve,X.prototype.reduce=Be,X.prototype.mulTo=L,X.prototype.sqrTo=E;function R(){return(this.t>0?this.data[0]&1:this.s)==0}function N(T,w){if(T>4294967295||T<1)return r.ONE;var k=i(),K=i(),$=w.convert(this),Y=s(T)-1;for($.copyTo(k);--Y>=0;)if(w.sqrTo(k,K),(T&1<<Y)>0)w.mulTo(K,$,k);else{var ie=k;k=K,K=ie}return w.revert(k)}function u(T,w){var k;return T<256||w.isEven()?k=new j(w):k=new X(w),this.exp(T,k)}r.prototype.copyTo=m,r.prototype.fromInt=x,r.prototype.fromString=o,r.prototype.clamp=h,r.prototype.dlShiftTo=B,r.prototype.drShiftTo=D,r.prototype.lShiftTo=V,r.prototype.rShiftTo=U,r.prototype.subTo=F,r.prototype.multiplyTo=q,r.prototype.squareTo=M,r.prototype.divRemTo=H,r.prototype.invDigit=he,r.prototype.isEven=R,r.prototype.exp=N,r.prototype.toString=y,r.prototype.negate=A,r.prototype.abs=_,r.prototype.compareTo=p,r.prototype.bitLength=n,r.prototype.mod=W,r.prototype.modPowInt=u,r.ZERO=C(0),r.ONE=C(1);function I(){var T=i();return this.copyTo(T),T}function O(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function G(){return this.t==0?this.s:this.data[0]<<24>>24}function ne(){return this.t==0?this.s:this.data[0]<<16>>16}function te(T){return Math.floor(Math.LN2*this.DB/Math.log(T))}function z(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function Q(T){if(T==null&&(T=10),this.signum()==0||T<2||T>36)return"0";var w=this.chunkSize(T),k=Math.pow(T,w),K=C(k),$=i(),Y=i(),ie="";for(this.divRemTo(K,$,Y);$.signum()>0;)ie=(k+Y.intValue()).toString(T).substr(1)+ie,$.divRemTo(K,$,Y);return Y.intValue().toString(T)+ie}function Z(T,w){this.fromInt(0),w==null&&(w=10);for(var k=this.chunkSize(w),K=Math.pow(w,k),$=!1,Y=0,ie=0,re=0;re<T.length;++re){var Se=l(T,re);if(Se<0){T.charAt(re)=="-"&&this.signum()==0&&($=!0);continue}ie=w*ie+Se,++Y>=k&&(this.dMultiply(K),this.dAddOffset(ie,0),Y=0,ie=0)}Y>0&&(this.dMultiply(Math.pow(w,Y)),this.dAddOffset(ie,0)),$&&r.ZERO.subTo(this,this)}function ye(T,w,k){if(typeof w=="number")if(T<2)this.fromInt(1);else for(this.fromNumber(T,k),this.testBit(T-1)||this.bitwiseTo(r.ONE.shiftLeft(T-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(w);)this.dAddOffset(2,0),this.bitLength()>T&&this.subTo(r.ONE.shiftLeft(T-1),this);else{var K=new Array,$=T&7;K.length=(T>>3)+1,w.nextBytes(K),$>0?K[0]&=(1<<$)-1:K[0]=0,this.fromString(K,256)}}function pe(){var T=this.t,w=new Array;w[0]=this.s;var k=this.DB-T*this.DB%8,K,$=0;if(T-- >0)for(k<this.DB&&(K=this.data[T]>>k)!=(this.s&this.DM)>>k&&(w[$++]=K|this.s<<this.DB-k);T>=0;)k<8?(K=(this.data[T]&(1<<k)-1)<<8-k,K|=this.data[--T]>>(k+=this.DB-8)):(K=this.data[T]>>(k-=8)&255,k<=0&&(k+=this.DB,--T)),(K&128)!=0&&(K|=-256),$==0&&(this.s&128)!=(K&128)&&++$,($>0||K!=this.s)&&(w[$++]=K);return w}function Ce(T){return this.compareTo(T)==0}function Ue(T){return this.compareTo(T)<0?this:T}function Re(T){return this.compareTo(T)>0?this:T}function Te(T,w,k){var K,$,Y=Math.min(T.t,this.t);for(K=0;K<Y;++K)k.data[K]=w(this.data[K],T.data[K]);if(T.t<this.t){for($=T.s&this.DM,K=Y;K<this.t;++K)k.data[K]=w(this.data[K],$);k.t=this.t}else{for($=this.s&this.DM,K=Y;K<T.t;++K)k.data[K]=w($,T.data[K]);k.t=T.t}k.s=w(this.s,T.s),k.clamp()}function Ae(T,w){return T&w}function Ie(T){var w=i();return this.bitwiseTo(T,Ae,w),w}function ge(T,w){return T|w}function De(T){var w=i();return this.bitwiseTo(T,ge,w),w}function ke(T,w){return T^w}function Fe(T){var w=i();return this.bitwiseTo(T,ke,w),w}function Ke(T,w){return T&~w}function je(T){var w=i();return this.bitwiseTo(T,Ke,w),w}function Je(){for(var T=i(),w=0;w<this.t;++w)T.data[w]=this.DM&~this.data[w];return T.t=this.t,T.s=~this.s,T}function et(T){var w=i();return T<0?this.rShiftTo(-T,w):this.lShiftTo(T,w),w}function rt(T){var w=i();return T<0?this.lShiftTo(-T,w):this.rShiftTo(T,w),w}function st(T){if(T==0)return-1;var w=0;return(T&65535)==0&&(T>>=16,w+=16),(T&255)==0&&(T>>=8,w+=8),(T&15)==0&&(T>>=4,w+=4),(T&3)==0&&(T>>=2,w+=2),(T&1)==0&&++w,w}function ct(){for(var T=0;T<this.t;++T)if(this.data[T]!=0)return T*this.DB+st(this.data[T]);return this.s<0?this.t*this.DB:-1}function ht(T){for(var w=0;T!=0;)T&=T-1,++w;return w}function yt(){for(var T=0,w=this.s&this.DM,k=0;k<this.t;++k)T+=ht(this.data[k]^w);return T}function ae(T){var w=Math.floor(T/this.DB);return w>=this.t?this.s!=0:(this.data[w]&1<<T%this.DB)!=0}function se(T,w){var k=r.ONE.shiftLeft(T);return this.bitwiseTo(k,w,k),k}function ue(T){return this.changeBit(T,ge)}function oe(T){return this.changeBit(T,Ke)}function de(T){return this.changeBit(T,ke)}function xe(T,w){for(var k=0,K=0,$=Math.min(T.t,this.t);k<$;)K+=this.data[k]+T.data[k],w.data[k++]=K&this.DM,K>>=this.DB;if(T.t<this.t){for(K+=T.s;k<this.t;)K+=this.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K+=this.s}else{for(K+=this.s;k<T.t;)K+=T.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K+=T.s}w.s=K<0?-1:0,K>0?w.data[k++]=K:K<-1&&(w.data[k++]=this.DV+K),w.t=k,w.clamp()}function we(T){var w=i();return this.addTo(T,w),w}function Le(T){var w=i();return this.subTo(T,w),w}function Pe(T){var w=i();return this.multiplyTo(T,w),w}function Ne(){var T=i();return this.squareTo(T),T}function Me(T){var w=i();return this.divRemTo(T,w,null),w}function qe(T){var w=i();return this.divRemTo(T,null,w),w}function He(T){var w=i(),k=i();return this.divRemTo(T,w,k),new Array(w,k)}function Ge(T){this.data[this.t]=this.am(0,T-1,this,0,0,this.t),++this.t,this.clamp()}function ze(T,w){if(T!=0){for(;this.t<=w;)this.data[this.t++]=0;for(this.data[w]+=T;this.data[w]>=this.DV;)this.data[w]-=this.DV,++w>=this.t&&(this.data[this.t++]=0),++this.data[w]}}function _e(){}function Oe(T){return T}function Qe(T,w,k){T.multiplyTo(w,k)}function $e(T,w){T.squareTo(w)}_e.prototype.convert=Oe,_e.prototype.revert=Oe,_e.prototype.mulTo=Qe,_e.prototype.sqrTo=$e;function gs(T){return this.exp(T,new _e)}function ys(T,w,k){var K=Math.min(this.t+T.t,w);for(k.s=0,k.t=K;K>0;)k.data[--K]=0;var $;for($=k.t-this.t;K<$;++K)k.data[K+this.t]=this.am(0,T.data[K],k,K,0,this.t);for($=Math.min(T.t,w);K<$;++K)this.am(0,T.data[K],k,K,0,w-K);k.clamp()}function ms(T,w,k){--w;var K=k.t=this.t+T.t-w;for(k.s=0;--K>=0;)k.data[K]=0;for(K=Math.max(w-this.t,0);K<T.t;++K)k.data[this.t+K-w]=this.am(w-K,T.data[K],k,0,0,this.t+K-w);k.clamp(),k.drShiftTo(1,k)}function Pt(T){this.r2=i(),this.q3=i(),r.ONE.dlShiftTo(2*T.t,this.r2),this.mu=this.r2.divide(T),this.m=T}function Cs(T){if(T.s<0||T.t>2*this.m.t)return T.mod(this.m);if(T.compareTo(this.m)<0)return T;var w=i();return T.copyTo(w),this.reduce(w),w}function Es(T){return T}function xs(T){for(T.drShiftTo(this.m.t-1,this.r2),T.t>this.m.t+1&&(T.t=this.m.t+1,T.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);T.compareTo(this.r2)<0;)T.dAddOffset(1,this.m.t+1);for(T.subTo(this.r2,T);T.compareTo(this.m)>=0;)T.subTo(this.m,T)}function Ss(T,w){T.squareTo(w),this.reduce(w)}function bs(T,w,k){T.multiplyTo(w,k),this.reduce(k)}Pt.prototype.convert=Cs,Pt.prototype.revert=Es,Pt.prototype.reduce=xs,Pt.prototype.mulTo=bs,Pt.prototype.sqrTo=Ss;function Ts(T,w){var k=T.bitLength(),K,$=C(1),Y;if(k<=0)return $;k<18?K=1:k<48?K=3:k<144?K=4:k<768?K=5:K=6,k<8?Y=new j(w):w.isEven()?Y=new Pt(w):Y=new X(w);var ie=new Array,re=3,Se=K-1,We=(1<<K)-1;if(ie[1]=Y.convert(this),K>1){var ot=i();for(Y.sqrTo(ie[1],ot);re<=We;)ie[re]=i(),Y.mulTo(ot,ie[re-2],ie[re]),re+=2}var at=T.t-1,mt,jt=!0,ft=i(),lt;for(k=s(T.data[at])-1;at>=0;){for(k>=Se?mt=T.data[at]>>k-Se&We:(mt=(T.data[at]&(1<<k+1)-1)<<Se-k,at>0&&(mt|=T.data[at-1]>>this.DB+k-Se)),re=K;(mt&1)==0;)mt>>=1,--re;if((k-=re)<0&&(k+=this.DB,--at),jt)ie[mt].copyTo($),jt=!1;else{for(;re>1;)Y.sqrTo($,ft),Y.sqrTo(ft,$),re-=2;re>0?Y.sqrTo($,ft):(lt=$,$=ft,ft=lt),Y.mulTo(ft,ie[mt],$)}for(;at>=0&&(T.data[at]&1<<k)==0;)Y.sqrTo($,ft),lt=$,$=ft,ft=lt,--k<0&&(k=this.DB-1,--at)}return Y.revert($)}function As(T){var w=this.s<0?this.negate():this.clone(),k=T.s<0?T.negate():T.clone();if(w.compareTo(k)<0){var K=w;w=k,k=K}var $=w.getLowestSetBit(),Y=k.getLowestSetBit();if(Y<0)return w;for($<Y&&(Y=$),Y>0&&(w.rShiftTo(Y,w),k.rShiftTo(Y,k));w.signum()>0;)($=w.getLowestSetBit())>0&&w.rShiftTo($,w),($=k.getLowestSetBit())>0&&k.rShiftTo($,k),w.compareTo(k)>=0?(w.subTo(k,w),w.rShiftTo(1,w)):(k.subTo(w,k),k.rShiftTo(1,k));return Y>0&&k.lShiftTo(Y,k),k}function Is(T){if(T<=0)return 0;var w=this.DV%T,k=this.s<0?T-1:0;if(this.t>0)if(w==0)k=this.data[0]%T;else for(var K=this.t-1;K>=0;--K)k=(w*k+this.data[K])%T;return k}function Bs(T){if(this.signum()==0)return r.ZERO;var w=T.isEven();if(this.isEven()&&w||T.signum()==0)return r.ZERO;for(var k=T.clone(),K=this.clone(),$=C(1),Y=C(0),ie=C(0),re=C(1);k.signum()!=0;){for(;k.isEven();)k.rShiftTo(1,k),w?((!$.isEven()||!Y.isEven())&&($.addTo(this,$),Y.subTo(T,Y)),$.rShiftTo(1,$)):Y.isEven()||Y.subTo(T,Y),Y.rShiftTo(1,Y);for(;K.isEven();)K.rShiftTo(1,K),w?((!ie.isEven()||!re.isEven())&&(ie.addTo(this,ie),re.subTo(T,re)),ie.rShiftTo(1,ie)):re.isEven()||re.subTo(T,re),re.rShiftTo(1,re);k.compareTo(K)>=0?(k.subTo(K,k),w&&$.subTo(ie,$),Y.subTo(re,Y)):(K.subTo(k,K),w&&ie.subTo($,ie),re.subTo(Y,re))}if(K.compareTo(r.ONE)!=0)return r.ZERO;if(re.compareTo(T)>=0)return re.subtract(T);if(re.signum()<0)re.addTo(T,re);else return re;return re.signum()<0?re.add(T):re}var ut=[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],ws=(1<<26)/ut[ut.length-1];function Ns(T){var w,k=this.abs();if(k.t==1&&k.data[0]<=ut[ut.length-1]){for(w=0;w<ut.length;++w)if(k.data[0]==ut[w])return!0;return!1}if(k.isEven())return!1;for(w=1;w<ut.length;){for(var K=ut[w],$=w+1;$<ut.length&&K<ws;)K*=ut[$++];for(K=k.modInt(K);w<$;)if(K%ut[w++]==0)return!1}return k.millerRabin(T)}function Rs(T){var w=this.subtract(r.ONE),k=w.getLowestSetBit();if(k<=0)return!1;for(var K=w.shiftRight(k),$=_s(),Y,ie=0;ie<T;++ie){do Y=new r(this.bitLength(),$);while(Y.compareTo(r.ONE)<=0||Y.compareTo(w)>=0);var re=Y.modPow(K,this);if(re.compareTo(r.ONE)!=0&&re.compareTo(w)!=0){for(var Se=1;Se++<k&&re.compareTo(w)!=0;)if(re=re.modPowInt(2,this),re.compareTo(r.ONE)==0)return!1;if(re.compareTo(w)!=0)return!1}}return!0}function _s(){return{nextBytes:function(T){for(var w=0;w<T.length;++w)T[w]=Math.floor(Math.random()*256)}}}return r.prototype.chunkSize=te,r.prototype.toRadix=Q,r.prototype.fromRadix=Z,r.prototype.fromNumber=ye,r.prototype.bitwiseTo=Te,r.prototype.changeBit=se,r.prototype.addTo=xe,r.prototype.dMultiply=Ge,r.prototype.dAddOffset=ze,r.prototype.multiplyLowerTo=ys,r.prototype.multiplyUpperTo=ms,r.prototype.modInt=Is,r.prototype.millerRabin=Rs,r.prototype.clone=I,r.prototype.intValue=O,r.prototype.byteValue=G,r.prototype.shortValue=ne,r.prototype.signum=z,r.prototype.toByteArray=pe,r.prototype.equals=Ce,r.prototype.min=Ue,r.prototype.max=Re,r.prototype.and=Ie,r.prototype.or=De,r.prototype.xor=Fe,r.prototype.andNot=je,r.prototype.not=Je,r.prototype.shiftLeft=et,r.prototype.shiftRight=rt,r.prototype.getLowestSetBit=ct,r.prototype.bitCount=yt,r.prototype.testBit=ae,r.prototype.setBit=ue,r.prototype.clearBit=oe,r.prototype.flipBit=de,r.prototype.add=we,r.prototype.subtract=Le,r.prototype.multiply=Pe,r.prototype.divide=Me,r.prototype.remainder=qe,r.prototype.divideAndRemainder=He,r.prototype.modPow=Ts,r.prototype.modInverse=Bs,r.prototype.pow=gs,r.prototype.gcd=As,r.prototype.isProbablePrime=Ns,r.prototype.square=Ne,Or}var Vr={exports:{}},Fr={exports:{}},tn;function $t(){if(tn)return Fr.exports;tn=1;var t=ve();xt(),Ee();var e=Fr.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){i||d();var c=null,a=t.util.createBuffer(),g=new Array(80),f={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return f.start=function(){f.messageLength=0,f.fullMessageLength=f.messageLength64=[];for(var S=f.messageLengthSize/4,P=0;P<S;++P)f.fullMessageLength.push(0);return a=t.util.createBuffer(),c={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},f},f.start(),f.update=function(S,P){P==="utf8"&&(S=t.util.encodeUtf8(S));var b=S.length;f.messageLength+=b,b=[b/4294967296>>>0,b>>>0];for(var l=f.fullMessageLength.length-1;l>=0;--l)f.fullMessageLength[l]+=b[1],b[1]=b[0]+(f.fullMessageLength[l]/4294967296>>>0),f.fullMessageLength[l]=f.fullMessageLength[l]>>>0,b[0]=b[1]/4294967296>>>0;return a.putBytes(S),v(c,g,a),(a.read>2048||a.length()===0)&&a.compact(),f},f.digest=function(){var S=t.util.createBuffer();S.putBytes(a.bytes());var P=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize,b=P&f.blockLength-1;S.putBytes(r.substr(0,f.blockLength-b));for(var l,m,x=f.fullMessageLength[0]*8,C=0;C<f.fullMessageLength.length-1;++C)l=f.fullMessageLength[C+1]*8,m=l/4294967296>>>0,x+=m,S.putInt32(x>>>0),x=l>>>0;S.putInt32(x);var o={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};v(o,g,S);var h=t.util.createBuffer();return h.putInt32(o.h0),h.putInt32(o.h1),h.putInt32(o.h2),h.putInt32(o.h3),h.putInt32(o.h4),h},f};var r=null,i=!1;function d(){r="€",r+=t.util.fillString("\0",64),i=!0}function v(c,a,g){for(var f,S,P,b,l,m,x,C,o=g.length();o>=64;){for(S=c.h0,P=c.h1,b=c.h2,l=c.h3,m=c.h4,C=0;C<16;++C)f=g.getInt32(),a[C]=f,x=l^P&(b^l),f=(S<<5|S>>>27)+x+m+1518500249+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;for(;C<20;++C)f=a[C-3]^a[C-8]^a[C-14]^a[C-16],f=f<<1|f>>>31,a[C]=f,x=l^P&(b^l),f=(S<<5|S>>>27)+x+m+1518500249+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;for(;C<32;++C)f=a[C-3]^a[C-8]^a[C-14]^a[C-16],f=f<<1|f>>>31,a[C]=f,x=P^b^l,f=(S<<5|S>>>27)+x+m+1859775393+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;for(;C<40;++C)f=a[C-6]^a[C-16]^a[C-28]^a[C-32],f=f<<2|f>>>30,a[C]=f,x=P^b^l,f=(S<<5|S>>>27)+x+m+1859775393+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;for(;C<60;++C)f=a[C-6]^a[C-16]^a[C-28]^a[C-32],f=f<<2|f>>>30,a[C]=f,x=P&b|l&(P^b),f=(S<<5|S>>>27)+x+m+2400959708+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;for(;C<80;++C)f=a[C-6]^a[C-16]^a[C-28]^a[C-32],f=f<<2|f>>>30,a[C]=f,x=P^b^l,f=(S<<5|S>>>27)+x+m+3395469782+f,m=l,l=b,b=(P<<30|P>>>2)>>>0,P=S,S=f;c.h0=c.h0+S|0,c.h1=c.h1+P|0,c.h2=c.h2+b|0,c.h3=c.h3+l|0,c.h4=c.h4+m|0,o-=64}}return Fr.exports}var rn;function ii(){if(rn)return Vr.exports;rn=1;var t=ve();Ee(),pt(),$t();var e=Vr.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(i,d,v){var c,a,g,f;typeof v=="string"?(c=v,a=arguments[3]||void 0,g=arguments[4]||void 0):v&&(c=v.label||void 0,a=v.seed||void 0,g=v.md||void 0,v.mgf1&&v.mgf1.md&&(f=v.mgf1.md)),g?g.start():g=t.md.sha1.create(),f||(f=g);var S=Math.ceil(i.n.bitLength()/8),P=S-2*g.digestLength-2;if(d.length>P){var b=new Error("RSAES-OAEP input message length is too long.");throw b.length=d.length,b.maxLength=P,b}c||(c=""),g.update(c,"raw");for(var l=g.digest(),m="",x=P-d.length,C=0;C<x;C++)m+="\0";var o=l.getBytes()+m+""+d;if(!a)a=t.random.getBytes(g.digestLength);else if(a.length!==g.digestLength){var b=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw b.seedLength=a.length,b.digestLength=g.digestLength,b}var h=r(a,S-g.digestLength-1,f),y=t.util.xorBytes(o,h,o.length),A=r(y,g.digestLength,f),_=t.util.xorBytes(a,A,a.length);return"\0"+_+y},e.decode_rsa_oaep=function(i,d,v){var c,a,g;typeof v=="string"?(c=v,a=arguments[3]||void 0):v&&(c=v.label||void 0,a=v.md||void 0,v.mgf1&&v.mgf1.md&&(g=v.mgf1.md));var f=Math.ceil(i.n.bitLength()/8);if(d.length!==f){var y=new Error("RSAES-OAEP encoded message length is invalid.");throw y.length=d.length,y.expectedLength=f,y}if(a===void 0?a=t.md.sha1.create():a.start(),g||(g=a),f<2*a.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");c||(c=""),a.update(c,"raw");for(var S=a.digest().getBytes(),P=d.charAt(0),b=d.substring(1,a.digestLength+1),l=d.substring(1+a.digestLength),m=r(l,a.digestLength,g),x=t.util.xorBytes(b,m,b.length),C=r(x,f-a.digestLength-1,g),o=t.util.xorBytes(l,C,l.length),h=o.substring(0,a.digestLength),y=P!=="\0",A=0;A<a.digestLength;++A)y|=S.charAt(A)!==h.charAt(A);for(var _=1,p=a.digestLength,s=a.digestLength;s<o.length;s++){var n=o.charCodeAt(s),B=n&1^1,D=_?65534:0;y|=n&D,_=_&B,p+=_}if(y||o.charCodeAt(p)!==1)throw new Error("Invalid RSAES-OAEP padding.");return o.substring(p+1)};function r(i,d,v){v||(v=t.md.sha1.create());for(var c="",a=Math.ceil(d/v.digestLength),g=0;g<a;++g){var f=String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,g&255);v.start(),v.update(i+f),c+=v.digest().getBytes()}return c.substring(0,d)}return Vr.exports}var Jt={exports:{}},an;function si(){if(an)return Jt.exports;an=1;var t=ve();return Ee(),lr(),pt(),(function(){if(t.prime){Jt.exports=t.prime;return}var e=Jt.exports=t.prime=t.prime||{},r=t.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],d=new r(null);d.fromInt(30);var v=function(b,l){return b|l};e.generateProbablePrime=function(b,l,m){typeof l=="function"&&(m=l,l={}),l=l||{};var x=l.algorithm||"PRIMEINC";typeof x=="string"&&(x={name:x}),x.options=x.options||{};var C=l.prng||t.random,o={nextBytes:function(h){for(var y=C.getBytesSync(h.length),A=0;A<h.length;++A)h[A]=y.charCodeAt(A)}};if(x.name==="PRIMEINC")return c(b,o,x.options,m);throw new Error("Invalid prime generation algorithm: "+x.name)};function c(b,l,m,x){return"workers"in m?f(b,l,m,x):a(b,l,m,x)}function a(b,l,m,x){var C=S(b,l),o=0,h=P(C.bitLength());"millerRabinTests"in m&&(h=m.millerRabinTests);var y=10;"maxBlockTime"in m&&(y=m.maxBlockTime),g(C,b,l,o,h,y,x)}function g(b,l,m,x,C,o,h){var y=+new Date;do{if(b.bitLength()>l&&(b=S(l,m)),b.isProbablePrime(C))return h(null,b);b.dAddOffset(i[x++%8],0)}while(o<0||+new Date-y<o);t.util.setImmediate(function(){g(b,l,m,x,C,o,h)})}function f(b,l,m,x){if(typeof Worker>"u")return a(b,l,m,x);var C=S(b,l),o=m.workers,h=m.workLoad||100,y=h*30/8,A=m.workerScript||"forge/prime.worker.js";if(o===-1)return t.util.estimateCores(function(p,s){p&&(s=2),o=s-1,_()});_();function _(){o=Math.max(1,o);for(var p=[],s=0;s<o;++s)p[s]=new Worker(A);for(var s=0;s<o;++s)p[s].addEventListener("message",B);var n=!1;function B(D){if(!n){var V=D.data;if(V.found){for(var U=0;U<p.length;++U)p[U].terminate();return n=!0,x(null,new r(V.prime,16))}C.bitLength()>b&&(C=S(b,l));var F=C.toString(16);D.target.postMessage({hex:F,workLoad:h}),C.dAddOffset(y,0)}}}}function S(b,l){var m=new r(b,l),x=b-1;return m.testBit(x)||m.bitwiseTo(r.ONE.shiftLeft(x),v,m),m.dAddOffset(31-m.mod(d).byteValue(),0),m}function P(b){return b<=100?27:b<=150?18:b<=200?15:b<=250?12:b<=300?9:b<=350?8:b<=400?7:b<=500?6:b<=600?5:b<=800?4:b<=1250?3:2}})(),Jt.exports}var Kr,nn;function dr(){if(nn)return Kr;nn=1;var t=ve();if(gt(),lr(),Lt(),ii(),si(),pt(),Ee(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.util.isNodejs?Ca:null,i=t.asn1,d=t.util;t.pki=t.pki||{},Kr=t.pki.rsa=t.rsa=t.rsa||{};var v=t.pki,c=[6,4,2,4,2,4,6,2],a={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"}]},g={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"}]},f={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"}]},S=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"}]}]},P={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"}]},b=function(s){var n;if(s.algorithm in v.oids)n=v.oids[s.algorithm];else{var B=new Error("Unknown message digest algorithm.");throw B.algorithm=s.algorithm,B}var D=i.oidToDer(n).getBytes(),V=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),U=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);U.value.push(i.create(i.Class.UNIVERSAL,i.Type.OID,!1,D)),U.value.push(i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,""));var F=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,s.digest().getBytes());return V.value.push(U),V.value.push(F),i.toDer(V).getBytes()},l=function(s,n,B){if(B)return s.modPow(n.e,n.n);if(!n.p||!n.q)return s.modPow(n.d,n.n);n.dP||(n.dP=n.d.mod(n.p.subtract(e.ONE))),n.dQ||(n.dQ=n.d.mod(n.q.subtract(e.ONE))),n.qInv||(n.qInv=n.q.modInverse(n.p));var D;do D=new e(t.util.bytesToHex(t.random.getBytes(n.n.bitLength()/8)),16);while(D.compareTo(n.n)>=0||!D.gcd(n.n).equals(e.ONE));s=s.multiply(D.modPow(n.e,n.n)).mod(n.n);for(var V=s.mod(n.p).modPow(n.dP,n.p),U=s.mod(n.q).modPow(n.dQ,n.q);V.compareTo(U)<0;)V=V.add(n.p);var F=V.subtract(U).multiply(n.qInv).mod(n.p).multiply(n.q).add(U);return F=F.multiply(D.modInverse(n.n)).mod(n.n),F};v.rsa.encrypt=function(s,n,B){var D=B,V,U=Math.ceil(n.n.bitLength()/8);B!==!1&&B!==!0?(D=B===2,V=m(s,n,B)):(V=t.util.createBuffer(),V.putBytes(s));for(var F=new e(V.toHex(),16),q=l(F,n,D),M=q.toString(16),H=t.util.createBuffer(),W=U-Math.ceil(M.length/2);W>0;)H.putByte(0),--W;return H.putBytes(t.util.hexToBytes(M)),H.getBytes()},v.rsa.decrypt=function(s,n,B,D){var V=Math.ceil(n.n.bitLength()/8);if(s.length!==V){var U=new Error("Encrypted message length is invalid.");throw U.length=s.length,U.expected=V,U}var F=new e(t.util.createBuffer(s).toHex(),16);if(F.compareTo(n.n)>=0)throw new Error("Encrypted message is invalid.");for(var q=l(F,n,B),M=q.toString(16),H=t.util.createBuffer(),W=V-Math.ceil(M.length/2);W>0;)H.putByte(0),--W;return H.putBytes(t.util.hexToBytes(M)),D!==!1?x(H.getBytes(),n,B):H.getBytes()},v.rsa.createKeyPairGenerationState=function(s,n,B){typeof s=="string"&&(s=parseInt(s,10)),s=s||2048,B=B||{};var D=B.prng||t.random,V={nextBytes:function(q){for(var M=D.getBytesSync(q.length),H=0;H<q.length;++H)q[H]=M.charCodeAt(H)}},U=B.algorithm||"PRIMEINC",F;if(U==="PRIMEINC")F={algorithm:U,state:0,bits:s,rng:V,eInt:n||65537,e:new e(null),p:null,q:null,qBits:s>>1,pBits:s-(s>>1),pqState:0,num:null,keys:null},F.e.fromInt(F.eInt);else throw new Error("Invalid key generation algorithm: "+U);return F},v.rsa.stepKeyPairGenerationState=function(s,n){"algorithm"in s||(s.algorithm="PRIMEINC");var B=new e(null);B.fromInt(30);for(var D=0,V=function(j,J){return j|J},U=+new Date,F,q=0;s.keys===null&&(n<=0||q<n);){if(s.state===0){var M=s.p===null?s.pBits:s.qBits,H=M-1;s.pqState===0?(s.num=new e(M,s.rng),s.num.testBit(H)||s.num.bitwiseTo(e.ONE.shiftLeft(H),V,s.num),s.num.dAddOffset(31-s.num.mod(B).byteValue(),0),D=0,++s.pqState):s.pqState===1?s.num.bitLength()>M?s.pqState=0:s.num.isProbablePrime(h(s.num.bitLength()))?++s.pqState:s.num.dAddOffset(c[D++%8],0):s.pqState===2?s.pqState=s.num.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)===0?3:0:s.pqState===3&&(s.pqState=0,s.p===null?s.p=s.num:s.q=s.num,s.p!==null&&s.q!==null&&++s.state,s.num=null)}else if(s.state===1)s.p.compareTo(s.q)<0&&(s.num=s.p,s.p=s.q,s.q=s.num),++s.state;else if(s.state===2)s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),++s.state;else if(s.state===3)s.phi.gcd(s.e).compareTo(e.ONE)===0?++s.state:(s.p=null,s.q=null,s.state=0);else if(s.state===4)s.n=s.p.multiply(s.q),s.n.bitLength()===s.bits?++s.state:(s.q=null,s.state=0);else if(s.state===5){var W=s.e.modInverse(s.phi);s.keys={privateKey:v.rsa.setPrivateKey(s.n,s.e,W,s.p,s.q,W.mod(s.p1),W.mod(s.q1),s.q.modInverse(s.p)),publicKey:v.rsa.setPublicKey(s.n,s.e)}}F=+new Date,q+=F-U,U=F}return s.keys!==null},v.rsa.generateKeyPair=function(s,n,B,D){if(arguments.length===1?typeof s=="object"?(B=s,s=void 0):typeof s=="function"&&(D=s,s=void 0):arguments.length===2?typeof s=="number"?typeof n=="function"?(D=n,n=void 0):typeof n!="number"&&(B=n,n=void 0):(B=s,D=n,s=void 0,n=void 0):arguments.length===3&&(typeof n=="number"?typeof B=="function"&&(D=B,B=void 0):(D=B,B=n,n=void 0)),B=B||{},s===void 0&&(s=B.bits||2048),n===void 0&&(n=B.e||65537),!t.options.usePureJavaScript&&!B.prng&&s>=256&&s<=16384&&(n===65537||n===3)){if(D){if(y("generateKeyPair"))return r.generateKeyPair("rsa",{modulusLength:s,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(q,M,H){if(q)return D(q);D(null,{privateKey:v.privateKeyFromPem(H),publicKey:v.publicKeyFromPem(M)})});if(A("generateKey")&&A("exportKey"))return d.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:p(n),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(q){return d.globalScope.crypto.subtle.exportKey("pkcs8",q.privateKey)}).then(void 0,function(q){D(q)}).then(function(q){if(q){var M=v.privateKeyFromAsn1(i.fromDer(t.util.createBuffer(q)));D(null,{privateKey:M,publicKey:v.setRsaPublicKey(M.n,M.e)})}});if(_("generateKey")&&_("exportKey")){var V=d.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:p(n),hash:{name:"SHA-256"}},!0,["sign","verify"]);V.oncomplete=function(q){var M=q.target.result,H=d.globalScope.msCrypto.subtle.exportKey("pkcs8",M.privateKey);H.oncomplete=function(W){var j=W.target.result,J=v.privateKeyFromAsn1(i.fromDer(t.util.createBuffer(j)));D(null,{privateKey:J,publicKey:v.setRsaPublicKey(J.n,J.e)})},H.onerror=function(W){D(W)}},V.onerror=function(q){D(q)};return}}else if(y("generateKeyPairSync")){var U=r.generateKeyPairSync("rsa",{modulusLength:s,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:v.privateKeyFromPem(U.privateKey),publicKey:v.publicKeyFromPem(U.publicKey)}}}var F=v.rsa.createKeyPairGenerationState(s,n,B);if(!D)return v.rsa.stepKeyPairGenerationState(F,0),F.keys;C(F,B,D)},v.setRsaPublicKey=v.rsa.setPublicKey=function(s,n){var B={n:s,e:n};return B.encrypt=function(D,V,U){if(typeof V=="string"?V=V.toUpperCase():V===void 0&&(V="RSAES-PKCS1-V1_5"),V==="RSAES-PKCS1-V1_5")V={encode:function(q,M,H){return m(q,M,2).getBytes()}};else if(V==="RSA-OAEP"||V==="RSAES-OAEP")V={encode:function(q,M){return t.pkcs1.encode_rsa_oaep(M,q,U)}};else if(["RAW","NONE","NULL",null].indexOf(V)!==-1)V={encode:function(q){return q}};else if(typeof V=="string")throw new Error('Unsupported encryption scheme: "'+V+'".');var F=V.encode(D,B,!0);return v.rsa.encrypt(F,B,!0)},B.verify=function(D,V,U,F){typeof U=="string"?U=U.toUpperCase():U===void 0&&(U="RSASSA-PKCS1-V1_5"),F===void 0&&(F={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in F||(F._parseAllDigestBytes=!0),"_skipPaddingChecks"in F||(F._skipPaddingChecks=!1),U==="RSASSA-PKCS1-V1_5"?U={verify:function(M,H){H=x(H,B,!0,void 0,F);var W=i.fromDer(H,{parseAllBytes:F._parseAllDigestBytes}),j={},J=[];if(!i.validate(W,P,j,J)||W.value.length!==2){var ce=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw ce.errors=J,ce}var fe=i.derToOid(j.algorithmIdentifier);if(!(fe===t.oids.md2||fe===t.oids.md5||fe===t.oids.sha1||fe===t.oids.sha224||fe===t.oids.sha256||fe===t.oids.sha384||fe===t.oids.sha512||fe===t.oids["sha512-224"]||fe===t.oids["sha512-256"])){var ce=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw ce.oid=fe,ce}if((fe===t.oids.md2||fe===t.oids.md5)&&!("parameters"in j))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return M===j.digest}}:(U==="NONE"||U==="NULL"||U===null)&&(U={verify:function(M,H){return H=x(H,B,!0,void 0,F),M===H}});var q=v.rsa.decrypt(V,B,!0,!1);return U.verify(D,q,B.n.bitLength())},B},v.setRsaPrivateKey=v.rsa.setPrivateKey=function(s,n,B,D,V,U,F,q){var M={n:s,e:n,d:B,p:D,q:V,dP:U,dQ:F,qInv:q};return M.decrypt=function(H,W,j){typeof W=="string"?W=W.toUpperCase():W===void 0&&(W="RSAES-PKCS1-V1_5");var J=v.rsa.decrypt(H,M,!1,!1);if(W==="RSAES-PKCS1-V1_5")W={decode:x};else if(W==="RSA-OAEP"||W==="RSAES-OAEP")W={decode:function(ce,fe){return t.pkcs1.decode_rsa_oaep(fe,ce,j)}};else if(["RAW","NONE","NULL",null].indexOf(W)!==-1)W={decode:function(ce){return ce}};else throw new Error('Unsupported encryption scheme: "'+W+'".');return W.decode(J,M,!1)},M.sign=function(H,W){var j=!1;typeof W=="string"&&(W=W.toUpperCase()),W===void 0||W==="RSASSA-PKCS1-V1_5"?(W={encode:b},j=1):(W==="NONE"||W==="NULL"||W===null)&&(W={encode:function(){return H}},j=1);var J=W.encode(H,M.n.bitLength());return v.rsa.encrypt(J,M,j)},M},v.wrapRsaPrivateKey=function(s){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(v.oids.rsaEncryption).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,i.toDer(s).getBytes())])},v.privateKeyFromAsn1=function(s){var n={},B=[];if(i.validate(s,a,n,B)&&(s=i.fromDer(t.util.createBuffer(n.privateKey))),n={},B=[],!i.validate(s,g,n,B)){var D=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw D.errors=B,D}var V,U,F,q,M,H,W,j;return V=t.util.createBuffer(n.privateKeyModulus).toHex(),U=t.util.createBuffer(n.privateKeyPublicExponent).toHex(),F=t.util.createBuffer(n.privateKeyPrivateExponent).toHex(),q=t.util.createBuffer(n.privateKeyPrime1).toHex(),M=t.util.createBuffer(n.privateKeyPrime2).toHex(),H=t.util.createBuffer(n.privateKeyExponent1).toHex(),W=t.util.createBuffer(n.privateKeyExponent2).toHex(),j=t.util.createBuffer(n.privateKeyCoefficient).toHex(),v.setRsaPrivateKey(new e(V,16),new e(U,16),new e(F,16),new e(q,16),new e(M,16),new e(H,16),new e(W,16),new e(j,16))},v.privateKeyToAsn1=v.privateKeyToRSAPrivateKey=function(s){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,o(s.n)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.e)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.d)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.p)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.q)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.dP)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.dQ)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.qInv))])},v.publicKeyFromAsn1=function(s){var n={},B=[];if(i.validate(s,S,n,B)){var D=i.derToOid(n.publicKeyOid);if(D!==v.oids.rsaEncryption){var V=new Error("Cannot read public key. Unknown OID.");throw V.oid=D,V}s=n.rsaPublicKey}if(B=[],!i.validate(s,f,n,B)){var V=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw V.errors=B,V}var U=t.util.createBuffer(n.publicKeyModulus).toHex(),F=t.util.createBuffer(n.publicKeyExponent).toHex();return v.setRsaPublicKey(new e(U,16),new e(F,16))},v.publicKeyToAsn1=v.publicKeyToSubjectPublicKeyInfo=function(s){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(v.oids.rsaEncryption).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,[v.publicKeyToRSAPublicKey(s)])])},v.publicKeyToRSAPublicKey=function(s){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.n)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,o(s.e))])};function m(s,n,B){var D=t.util.createBuffer(),V=Math.ceil(n.n.bitLength()/8);if(s.length>V-11){var U=new Error("Message is too long for PKCS#1 v1.5 padding.");throw U.length=s.length,U.max=V-11,U}D.putByte(0),D.putByte(B);var F=V-3-s.length,q;if(B===0||B===1){q=B===0?0:255;for(var M=0;M<F;++M)D.putByte(q)}else for(;F>0;){for(var H=0,W=t.random.getBytes(F),M=0;M<F;++M)q=W.charCodeAt(M),q===0?++H:D.putByte(q);F=H}return D.putByte(0),D.putBytes(s),D}function x(s,n,B,D,V){var U=Math.ceil(n.n.bitLength()/8),F=t.util.createBuffer(s),q=F.getByte(),M=F.getByte();if(q!==0||B&&M!==0&&M!==1||!B&&M!==2||B&&M===0&&typeof D>"u")throw new Error("Encryption block is invalid.");var H=0;if(M===0){H=U-3-D;for(var W=0;W<H;++W)if(F.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(M===1){for(H=0;F.length()>1;){if(F.getByte()!==255){--F.read;break}++H}if(H<8&&!(V&&V._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(M===2){for(H=0;F.length()>1;){if(F.getByte()===0){--F.read;break}++H}if(H<8&&!(V&&V._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var j=F.getByte();if(j!==0||H!==U-3-F.length())throw new Error("Encryption block is invalid.");return F.getBytes()}function C(s,n,B){typeof n=="function"&&(B=n,n={}),n=n||{};var D={algorithm:{name:n.algorithm||"PRIMEINC",options:{workers:n.workers||2,workLoad:n.workLoad||100,workerScript:n.workerScript}}};"prng"in n&&(D.prng=n.prng),V();function V(){U(s.pBits,function(q,M){if(q)return B(q);if(s.p=M,s.q!==null)return F(q,s.q);U(s.qBits,F)})}function U(q,M){t.prime.generateProbablePrime(q,D,M)}function F(q,M){if(q)return B(q);if(s.q=M,s.p.compareTo(s.q)<0){var H=s.p;s.p=s.q,s.q=H}if(s.p.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.p=null,V();return}if(s.q.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.q=null,U(s.qBits,F);return}if(s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),s.phi.gcd(s.e).compareTo(e.ONE)!==0){s.p=s.q=null,V();return}if(s.n=s.p.multiply(s.q),s.n.bitLength()!==s.bits){s.q=null,U(s.qBits,F);return}var W=s.e.modInverse(s.phi);s.keys={privateKey:v.rsa.setPrivateKey(s.n,s.e,W,s.p,s.q,W.mod(s.p1),W.mod(s.q1),s.q.modInverse(s.p)),publicKey:v.rsa.setPublicKey(s.n,s.e)},B(null,s.keys)}}function o(s){var n=s.toString(16);n[0]>="8"&&(n="00"+n);var B=t.util.hexToBytes(n);return B.length>1&&(B.charCodeAt(0)===0&&(B.charCodeAt(1)&128)===0||B.charCodeAt(0)===255&&(B.charCodeAt(1)&128)===128)?B.substr(1):B}function h(s){return s<=100?27:s<=150?18:s<=200?15:s<=250?12:s<=300?9:s<=350?8:s<=400?7:s<=500?6:s<=600?5:s<=800?4:s<=1250?3:2}function y(s){return t.util.isNodejs&&typeof r[s]=="function"}function A(s){return typeof d.globalScope<"u"&&typeof d.globalScope.crypto=="object"&&typeof d.globalScope.crypto.subtle=="object"&&typeof d.globalScope.crypto.subtle[s]=="function"}function _(s){return typeof d.globalScope<"u"&&typeof d.globalScope.msCrypto=="object"&&typeof d.globalScope.msCrypto.subtle=="object"&&typeof d.globalScope.msCrypto.subtle[s]=="function"}function p(s){for(var n=t.util.hexToBytes(s.toString(16)),B=new Uint8Array(n.length),D=0;D<n.length;++D)B[D]=n.charCodeAt(D);return B}return Kr}var Mr,sn;function oi(){if(sn)return Mr;sn=1;var t=ve();if(Dt(),gt(),fr(),xt(),Lt(),Ea(),Ot(),pt(),ni(),dr(),Ee(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.asn1,i=t.pki=t.pki||{};Mr=i.pbe=t.pbe=t.pbe||{};var d=i.oids,v={name:"EncryptedPrivateKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},a={name:"pkcs-12PbeParams",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"iterations"}]};i.encryptPrivateKeyInfo=function(b,l,m){m=m||{},m.saltSize=m.saltSize||8,m.count=m.count||2048,m.algorithm=m.algorithm||"aes128",m.prfAlgorithm=m.prfAlgorithm||"sha1";var x=t.random.getBytesSync(m.saltSize),C=m.count,o=r.integerToDer(C),h,y,A;if(m.algorithm.indexOf("aes")===0||m.algorithm==="des"){var _,p,s;switch(m.algorithm){case"aes128":h=16,_=16,p=d["aes128-CBC"],s=t.aes.createEncryptionCipher;break;case"aes192":h=24,_=16,p=d["aes192-CBC"],s=t.aes.createEncryptionCipher;break;case"aes256":h=32,_=16,p=d["aes256-CBC"],s=t.aes.createEncryptionCipher;break;case"des":h=8,_=8,p=d.desCBC,s=t.des.createEncryptionCipher;break;default:var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=m.algorithm,n}var B="hmacWith"+m.prfAlgorithm.toUpperCase(),D=S(B),V=t.pkcs5.pbkdf2(l,x,C,h,D),U=t.random.getBytesSync(_),F=s(V);F.start(U),F.update(r.toDer(b)),F.finish(),A=F.output.getBytes();var q=P(x,o,h,B);y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(d.pkcs5PBES2).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(d.pkcs5PBKDF2).getBytes()),q]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,U)])])])}else if(m.algorithm==="3des"){h=24;var M=new t.util.ByteBuffer(x),V=i.pbe.generatePkcs12Key(l,M,1,C,h),U=i.pbe.generatePkcs12Key(l,M,2,C,h),F=t.des.createEncryptionCipher(V);F.start(U),F.update(r.toDer(b)),F.finish(),A=F.output.getBytes(),y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(d["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,x),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,o.getBytes())])])}else{var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=m.algorithm,n}var H=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[y,r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,A)]);return H},i.decryptPrivateKeyInfo=function(b,l){var m=null,x={},C=[];if(!r.validate(b,v,x,C)){var o=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=C,o}var h=r.derToOid(x.encryptionOid),y=i.pbe.getCipher(h,x.encryptionParams,l),A=t.util.createBuffer(x.encryptedData);return y.update(A),y.finish()&&(m=r.fromDer(y.output)),m},i.encryptedPrivateKeyToPem=function(b,l){var m={type:"ENCRYPTED PRIVATE KEY",body:r.toDer(b).getBytes()};return t.pem.encode(m,{maxline:l})},i.encryptedPrivateKeyFromPem=function(b){var l=t.pem.decode(b)[0];if(l.type!=="ENCRYPTED PRIVATE KEY"){var m=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw m.headerType=l.type,m}if(l.procType&&l.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return r.fromDer(l.body)},i.encryptRsaPrivateKey=function(b,l,m){if(m=m||{},!m.legacy){var x=i.wrapRsaPrivateKey(i.privateKeyToAsn1(b));return x=i.encryptPrivateKeyInfo(x,l,m),i.encryptedPrivateKeyToPem(x)}var C,o,h,y;switch(m.algorithm){case"aes128":C="AES-128-CBC",h=16,o=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes192":C="AES-192-CBC",h=24,o=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes256":C="AES-256-CBC",h=32,o=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"3des":C="DES-EDE3-CBC",h=24,o=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;case"des":C="DES-CBC",h=8,o=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;default:var A=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+m.algorithm+'".');throw A.algorithm=m.algorithm,A}var _=t.pbe.opensslDeriveBytes(l,o.substr(0,8),h),p=y(_);p.start(o),p.update(r.toDer(i.privateKeyToAsn1(b))),p.finish();var s={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:C,parameters:t.util.bytesToHex(o).toUpperCase()},body:p.output.getBytes()};return t.pem.encode(s)},i.decryptRsaPrivateKey=function(b,l){var m=null,x=t.pem.decode(b)[0];if(x.type!=="ENCRYPTED PRIVATE KEY"&&x.type!=="PRIVATE KEY"&&x.type!=="RSA PRIVATE KEY"){var C=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw C.headerType=C,C}if(x.procType&&x.procType.type==="ENCRYPTED"){var o,h;switch(x.dekInfo.algorithm){case"DES-CBC":o=8,h=t.des.createDecryptionCipher;break;case"DES-EDE3-CBC":o=24,h=t.des.createDecryptionCipher;break;case"AES-128-CBC":o=16,h=t.aes.createDecryptionCipher;break;case"AES-192-CBC":o=24,h=t.aes.createDecryptionCipher;break;case"AES-256-CBC":o=32,h=t.aes.createDecryptionCipher;break;case"RC2-40-CBC":o=5,h=function(s){return t.rc2.createDecryptionCipher(s,40)};break;case"RC2-64-CBC":o=8,h=function(s){return t.rc2.createDecryptionCipher(s,64)};break;case"RC2-128-CBC":o=16,h=function(s){return t.rc2.createDecryptionCipher(s,128)};break;default:var C=new Error('Could not decrypt private key; unsupported encryption algorithm "'+x.dekInfo.algorithm+'".');throw C.algorithm=x.dekInfo.algorithm,C}var y=t.util.hexToBytes(x.dekInfo.parameters),A=t.pbe.opensslDeriveBytes(l,y.substr(0,8),o),_=h(A);if(_.start(y),_.update(t.util.createBuffer(x.body)),_.finish())m=_.output.getBytes();else return m}else m=x.body;return x.type==="ENCRYPTED PRIVATE KEY"?m=i.decryptPrivateKeyInfo(r.fromDer(m),l):m=r.fromDer(m),m!==null&&(m=i.privateKeyFromAsn1(m)),m},i.pbe.generatePkcs12Key=function(b,l,m,x,C,o){var h,y;if(typeof o>"u"||o===null){if(!("sha1"in t.md))throw new Error('"sha1" hash algorithm unavailable.');o=t.md.sha1.create()}var A=o.digestLength,_=o.blockLength,p=new t.util.ByteBuffer,s=new t.util.ByteBuffer;if(b!=null){for(y=0;y<b.length;y++)s.putInt16(b.charCodeAt(y));s.putInt16(0)}var n=s.length(),B=l.length(),D=new t.util.ByteBuffer;D.fillWithByte(m,_);var V=_*Math.ceil(B/_),U=new t.util.ByteBuffer;for(y=0;y<V;y++)U.putByte(l.at(y%B));var F=_*Math.ceil(n/_),q=new t.util.ByteBuffer;for(y=0;y<F;y++)q.putByte(s.at(y%n));var M=U;M.putBuffer(q);for(var H=Math.ceil(C/A),W=1;W<=H;W++){var j=new t.util.ByteBuffer;j.putBytes(D.bytes()),j.putBytes(M.bytes());for(var J=0;J<x;J++)o.start(),o.update(j.getBytes()),j=o.digest();var ce=new t.util.ByteBuffer;for(y=0;y<_;y++)ce.putByte(j.at(y%A));var fe=Math.ceil(B/_)+Math.ceil(n/_),me=new t.util.ByteBuffer;for(h=0;h<fe;h++){var be=new t.util.ByteBuffer(M.getBytes(_)),he=511;for(y=ce.length()-1;y>=0;y--)he=he>>8,he+=ce.at(y)+be.at(y),be.setAt(y,he&255);me.putBuffer(be)}M=me,p.putBuffer(j)}return p.truncate(p.length()-C),p},i.pbe.getCipher=function(b,l,m){switch(b){case i.oids.pkcs5PBES2:return i.pbe.getCipherForPBES2(b,l,m);case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case i.oids["pbewithSHAAnd40BitRC2-CBC"]:return i.pbe.getCipherForPKCS12PBE(b,l,m);default:var x=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw x.oid=b,x.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],x}},i.pbe.getCipherForPBES2=function(b,l,m){var x={},C=[];if(!r.validate(l,c,x,C)){var o=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=C,o}if(b=r.derToOid(x.kdfOid),b!==i.oids.pkcs5PBKDF2){var o=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw o.oid=b,o.supportedOids=["pkcs5PBKDF2"],o}if(b=r.derToOid(x.encOid),b!==i.oids["aes128-CBC"]&&b!==i.oids["aes192-CBC"]&&b!==i.oids["aes256-CBC"]&&b!==i.oids["des-EDE3-CBC"]&&b!==i.oids.desCBC){var o=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw o.oid=b,o.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],o}var h=x.kdfSalt,y=t.util.createBuffer(x.kdfIterationCount);y=y.getInt(y.length()<<3);var A,_;switch(i.oids[b]){case"aes128-CBC":A=16,_=t.aes.createDecryptionCipher;break;case"aes192-CBC":A=24,_=t.aes.createDecryptionCipher;break;case"aes256-CBC":A=32,_=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":A=24,_=t.des.createDecryptionCipher;break;case"desCBC":A=8,_=t.des.createDecryptionCipher;break}var p=f(x.prfOid),s=t.pkcs5.pbkdf2(m,h,y,A,p),n=x.encIv,B=_(s);return B.start(n),B},i.pbe.getCipherForPKCS12PBE=function(b,l,m){var x={},C=[];if(!r.validate(l,a,x,C)){var o=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=C,o}var h=t.util.createBuffer(x.salt),y=t.util.createBuffer(x.iterations);y=y.getInt(y.length()<<3);var A,_,p;switch(b){case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:A=24,_=8,p=t.des.startDecrypting;break;case i.oids["pbewithSHAAnd40BitRC2-CBC"]:A=5,_=8,p=function(V,U){var F=t.rc2.createDecryptionCipher(V,40);return F.start(U,null),F};break;default:var o=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw o.oid=b,o}var s=f(x.prfOid),n=i.pbe.generatePkcs12Key(m,h,1,y,A,s);s.start();var B=i.pbe.generatePkcs12Key(m,h,2,y,_,s);return p(n,B)},i.pbe.opensslDeriveBytes=function(b,l,m,x){if(typeof x>"u"||x===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');x=t.md.md5.create()}l===null&&(l="");for(var C=[g(x,b+l)],o=16,h=1;o<m;++h,o+=16)C.push(g(x,C[h-1]+b+l));return C.join("").substr(0,m)};function g(b,l){return b.start().update(l).digest().getBytes()}function f(b){var l;if(!b)l="hmacWithSHA1";else if(l=i.oids[r.derToOid(b)],!l){var m=new Error("Unsupported PRF OID.");throw m.oid=b,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}return S(l)}function S(b){var l=t.md;switch(b){case"hmacWithSHA224":l=t.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":b=b.substr(8).toLowerCase();break;default:var m=new Error("Unsupported PRF algorithm.");throw m.algorithm=b,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}if(!l||!(b in l))throw new Error("Unknown hash algorithm: "+b);return l[b].create()}function P(b,l,m,x){var C=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,b),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,l.getBytes())]);return x!=="hmacWithSHA1"&&C.value.push(r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,t.util.hexToBytes(m.toString(16))),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids[x]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")])),C}return Mr}var qr={exports:{}},Hr={exports:{}},on;function ci(){if(on)return Hr.exports;on=1;var t=ve();gt(),Ee();var e=t.asn1,r=Hr.exports=t.pkcs7asn1=t.pkcs7asn1||{};t.pkcs7=t.pkcs7||{},t.pkcs7.asn1=r;var i={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=i;var d={name:"EncryptedContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(d)},r.encryptedDataValidator={name:"EncryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"}].concat(d)};var v={name:"SignerInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};return r.signedDataValidator={name:"SignedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},i,{name:"SignedData.Certificates",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,capture:"signerInfos",optional:!0,value:[v]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]},Hr.exports}var Gr={exports:{}},zr={exports:{}},cn;function ui(){if(cn)return zr.exports;cn=1;var t=ve();Ee(),t.mgf=t.mgf||{};var e=zr.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};return e.create=function(r){var i={generate:function(d,v){for(var c=new t.util.ByteBuffer,a=Math.ceil(v/r.digestLength),g=0;g<a;g++){var f=new t.util.ByteBuffer;f.putInt32(g),r.start(),r.update(d+f.getBytes()),c.putBuffer(r.digest())}return c.truncate(c.length()-v),c.getBytes()}};return i},zr.exports}var Qr,un;function Ws(){if(un)return Qr;un=1;var t=ve();return ui(),Qr=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1,Qr}var $r={exports:{}},fn;function xa(){if(fn)return $r.exports;fn=1;var t=ve();pt(),Ee();var e=$r.exports=t.pss=t.pss||{};return e.create=function(r){arguments.length===3&&(r={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var i=r.md,d=r.mgf,v=i.digestLength,c=r.salt||null;typeof c=="string"&&(c=t.util.createBuffer(c));var a;if("saltLength"in r)a=r.saltLength;else if(c!==null)a=c.length();else throw new Error("Salt length not specified or specific salt not given.");if(c!==null&&c.length()!==a)throw new Error("Given salt length does not match length of given salt.");var g=r.prng||t.random,f={};return f.encode=function(S,P){var b,l=P-1,m=Math.ceil(l/8),x=S.digest().getBytes();if(m<v+a+2)throw new Error("Message is too long to encrypt.");var C;c===null?C=g.getBytesSync(a):C=c.bytes();var o=new t.util.ByteBuffer;o.fillWithByte(0,8),o.putBytes(x),o.putBytes(C),i.start(),i.update(o.getBytes());var h=i.digest().getBytes(),y=new t.util.ByteBuffer;y.fillWithByte(0,m-a-v-2),y.putByte(1),y.putBytes(C);var A=y.getBytes(),_=m-v-1,p=d.generate(h,_),s="";for(b=0;b<_;b++)s+=String.fromCharCode(A.charCodeAt(b)^p.charCodeAt(b));var n=65280>>8*m-l&255;return s=String.fromCharCode(s.charCodeAt(0)&~n)+s.substr(1),s+h+"¼"},f.verify=function(S,P,b){var l,m=b-1,x=Math.ceil(m/8);if(P=P.substr(-x),x<v+a+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(P.charCodeAt(x-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var C=x-v-1,o=P.substr(0,C),h=P.substr(C,v),y=65280>>8*x-m&255;if((o.charCodeAt(0)&y)!==0)throw new Error("Bits beyond keysize not zero as expected.");var A=d.generate(h,C),_="";for(l=0;l<C;l++)_+=String.fromCharCode(o.charCodeAt(l)^A.charCodeAt(l));_=String.fromCharCode(_.charCodeAt(0)&~y)+_.substr(1);var p=x-v-a-2;for(l=0;l<p;l++)if(_.charCodeAt(l)!==0)throw new Error("Leftmost octets not zero as expected");if(_.charCodeAt(p)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var s=_.substr(-a),n=new t.util.ByteBuffer;n.fillWithByte(0,8),n.putBytes(S),n.putBytes(s),i.start(),i.update(n.getBytes());var B=i.digest().getBytes();return h===B},f},$r.exports}var ln;function Sa(){if(ln)return Gr.exports;ln=1;var t=ve();Dt(),gt(),fr(),xt(),Ws(),Lt(),Ot(),xa(),dr(),Ee();var e=t.asn1,r=Gr.exports=t.pki=t.pki||{},i=r.oids,d={};d.CN=i.commonName,d.commonName="CN",d.C=i.countryName,d.countryName="C",d.L=i.localityName,d.localityName="L",d.ST=i.stateOrProvinceName,d.stateOrProvinceName="ST",d.O=i.organizationName,d.organizationName="O",d.OU=i.organizationalUnitName,d.organizationalUnitName="OU",d.E=i.emailAddress,d.emailAddress="E";var v=t.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},v,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},a={name:"rsapss",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},g={name:"CertificationRequestInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},v,{name:"CertificationRequestInfo.attributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0}]}]}]},f={name:"CertificationRequest",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[g,{name:"CertificationRequest.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};r.RDNAttributesAsArray=function(p,s){for(var n=[],B,D,V,U=0;U<p.value.length;++U){B=p.value[U];for(var F=0;F<B.value.length;++F)V={},D=B.value[F],V.type=e.derToOid(D.value[0].value),V.value=D.value[1].value,V.valueTagClass=D.value[1].type,V.type in i&&(V.name=i[V.type],V.name in d&&(V.shortName=d[V.name])),s&&(s.update(V.type),s.update(V.value)),n.push(V)}return n},r.CRIAttributesAsArray=function(p){for(var s=[],n=0;n<p.length;++n)for(var B=p[n],D=e.derToOid(B.value[0].value),V=B.value[1].value,U=0;U<V.length;++U){var F={};if(F.type=D,F.value=V[U].value,F.valueTagClass=V[U].type,F.type in i&&(F.name=i[F.type],F.name in d&&(F.shortName=d[F.name])),F.type===i.extensionRequest){F.extensions=[];for(var q=0;q<F.value.length;++q)F.extensions.push(r.certificateExtensionFromAsn1(F.value[q]))}s.push(F)}return s};function S(p,s){typeof s=="string"&&(s={shortName:s});for(var n=null,B,D=0;n===null&&D<p.attributes.length;++D)B=p.attributes[D],(s.type&&s.type===B.type||s.name&&s.name===B.name||s.shortName&&s.shortName===B.shortName)&&(n=B);return n}var P=function(p,s,n){var B={};if(p!==i["RSASSA-PSS"])return B;n&&(B={hash:{algorithmOid:i.sha1},mgf:{algorithmOid:i.mgf1,hash:{algorithmOid:i.sha1}},saltLength:20});var D={},V=[];if(!e.validate(s,a,D,V)){var U=new Error("Cannot read RSASSA-PSS parameter block.");throw U.errors=V,U}return D.hashOid!==void 0&&(B.hash=B.hash||{},B.hash.algorithmOid=e.derToOid(D.hashOid)),D.maskGenOid!==void 0&&(B.mgf=B.mgf||{},B.mgf.algorithmOid=e.derToOid(D.maskGenOid),B.mgf.hash=B.mgf.hash||{},B.mgf.hash.algorithmOid=e.derToOid(D.maskGenHashOid)),D.saltLength!==void 0&&(B.saltLength=D.saltLength.charCodeAt(0)),B},b=function(p){switch(i[p.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return t.md.sha1.create();case"md5WithRSAEncryption":return t.md.md5.create();case"sha256WithRSAEncryption":return t.md.sha256.create();case"sha384WithRSAEncryption":return t.md.sha384.create();case"sha512WithRSAEncryption":return t.md.sha512.create();case"RSASSA-PSS":return t.md.sha256.create();default:var s=new Error("Could not compute "+p.type+" digest. Unknown signature OID.");throw s.signatureOid=p.signatureOid,s}},l=function(p){var s=p.certificate,n;switch(s.signatureOid){case i.sha1WithRSAEncryption:case i.sha1WithRSASignature:break;case i["RSASSA-PSS"]:var B,D;if(B=i[s.signatureParameters.mgf.hash.algorithmOid],B===void 0||t.md[B]===void 0){var V=new Error("Unsupported MGF hash function.");throw V.oid=s.signatureParameters.mgf.hash.algorithmOid,V.name=B,V}if(D=i[s.signatureParameters.mgf.algorithmOid],D===void 0||t.mgf[D]===void 0){var V=new Error("Unsupported MGF function.");throw V.oid=s.signatureParameters.mgf.algorithmOid,V.name=D,V}if(D=t.mgf[D].create(t.md[B].create()),B=i[s.signatureParameters.hash.algorithmOid],B===void 0||t.md[B]===void 0){var V=new Error("Unsupported RSASSA-PSS hash function.");throw V.oid=s.signatureParameters.hash.algorithmOid,V.name=B,V}n=t.pss.create(t.md[B].create(),D,s.signatureParameters.saltLength);break}return s.publicKey.verify(p.md.digest().getBytes(),p.signature,n)};r.certificateFromPem=function(p,s,n){var B=t.pem.decode(p)[0];if(B.type!=="CERTIFICATE"&&B.type!=="X509 CERTIFICATE"&&B.type!=="TRUSTED CERTIFICATE"){var D=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw D.headerType=B.type,D}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var V=e.fromDer(B.body,n);return r.certificateFromAsn1(V,s)},r.certificateToPem=function(p,s){var n={type:"CERTIFICATE",body:e.toDer(r.certificateToAsn1(p)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyFromPem=function(p){var s=t.pem.decode(p)[0];if(s.type!=="PUBLIC KEY"&&s.type!=="RSA PUBLIC KEY"){var n=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw n.headerType=s.type,n}if(s.procType&&s.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var B=e.fromDer(s.body);return r.publicKeyFromAsn1(B)},r.publicKeyToPem=function(p,s){var n={type:"PUBLIC KEY",body:e.toDer(r.publicKeyToAsn1(p)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyToRSAPublicKeyPem=function(p,s){var n={type:"RSA PUBLIC KEY",body:e.toDer(r.publicKeyToRSAPublicKey(p)).getBytes()};return t.pem.encode(n,{maxline:s})},r.getPublicKeyFingerprint=function(p,s){s=s||{};var n=s.md||t.md.sha1.create(),B=s.type||"RSAPublicKey",D;switch(B){case"RSAPublicKey":D=e.toDer(r.publicKeyToRSAPublicKey(p)).getBytes();break;case"SubjectPublicKeyInfo":D=e.toDer(r.publicKeyToAsn1(p)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+s.type+'".')}n.start(),n.update(D);var V=n.digest();if(s.encoding==="hex"){var U=V.toHex();return s.delimiter?U.match(/.{2}/g).join(s.delimiter):U}else{if(s.encoding==="binary")return V.getBytes();if(s.encoding)throw new Error('Unknown encoding "'+s.encoding+'".')}return V},r.certificationRequestFromPem=function(p,s,n){var B=t.pem.decode(p)[0];if(B.type!=="CERTIFICATE REQUEST"){var D=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw D.headerType=B.type,D}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var V=e.fromDer(B.body,n);return r.certificationRequestFromAsn1(V,s)},r.certificationRequestToPem=function(p,s){var n={type:"CERTIFICATE REQUEST",body:e.toDer(r.certificationRequestToAsn1(p)).getBytes()};return t.pem.encode(n,{maxline:s})},r.createCertificate=function(){var p={};return p.version=2,p.serialNumber="00",p.signatureOid=null,p.signature=null,p.siginfo={},p.siginfo.algorithmOid=null,p.validity={},p.validity.notBefore=new Date,p.validity.notAfter=new Date,p.issuer={},p.issuer.getField=function(s){return S(p.issuer,s)},p.issuer.addField=function(s){x([s]),p.issuer.attributes.push(s)},p.issuer.attributes=[],p.issuer.hash=null,p.subject={},p.subject.getField=function(s){return S(p.subject,s)},p.subject.addField=function(s){x([s]),p.subject.attributes.push(s)},p.subject.attributes=[],p.subject.hash=null,p.extensions=[],p.publicKey=null,p.md=null,p.setSubject=function(s,n){x(s),p.subject.attributes=s,delete p.subject.uniqueId,n&&(p.subject.uniqueId=n),p.subject.hash=null},p.setIssuer=function(s,n){x(s),p.issuer.attributes=s,delete p.issuer.uniqueId,n&&(p.issuer.uniqueId=n),p.issuer.hash=null},p.setExtensions=function(s){for(var n=0;n<s.length;++n)C(s[n],{cert:p});p.extensions=s},p.getExtension=function(s){typeof s=="string"&&(s={name:s});for(var n=null,B,D=0;n===null&&D<p.extensions.length;++D)B=p.extensions[D],(s.id&&B.id===s.id||s.name&&B.name===s.name)&&(n=B);return n},p.sign=function(s,n){p.md=n||t.md.sha1.create();var B=i[p.md.algorithm+"WithRSAEncryption"];if(!B){var D=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw D.algorithm=p.md.algorithm,D}p.signatureOid=p.siginfo.algorithmOid=B,p.tbsCertificate=r.getTBSCertificate(p);var V=e.toDer(p.tbsCertificate);p.md.update(V.getBytes()),p.signature=s.sign(p.md)},p.verify=function(s){var n=!1;if(!p.issued(s)){var B=s.issuer,D=p.subject,V=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw V.expectedIssuer=D.attributes,V.actualIssuer=B.attributes,V}var U=s.md;if(U===null){U=b({signatureOid:s.signatureOid,type:"certificate"});var F=s.tbsCertificate||r.getTBSCertificate(s),q=e.toDer(F);U.update(q.getBytes())}return U!==null&&(n=l({certificate:p,md:U,signature:s.signature})),n},p.isIssuer=function(s){var n=!1,B=p.issuer,D=s.subject;if(B.hash&&D.hash)n=B.hash===D.hash;else if(B.attributes.length===D.attributes.length){n=!0;for(var V,U,F=0;n&&F<B.attributes.length;++F)V=B.attributes[F],U=D.attributes[F],(V.type!==U.type||V.value!==U.value)&&(n=!1)}return n},p.issued=function(s){return s.isIssuer(p)},p.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(p.publicKey,{type:"RSAPublicKey"})},p.verifySubjectKeyIdentifier=function(){for(var s=i.subjectKeyIdentifier,n=0;n<p.extensions.length;++n){var B=p.extensions[n];if(B.id===s){var D=p.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(B.subjectKeyIdentifier)===D}}return!1},p},r.certificateFromAsn1=function(p,s){var n={},B=[];if(!e.validate(p,c,n,B)){var D=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw D.errors=B,D}var V=e.derToOid(n.publicKeyOid);if(V!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var U=r.createCertificate();U.version=n.certVersion?n.certVersion.charCodeAt(0):0;var F=t.util.createBuffer(n.certSerialNumber);U.serialNumber=F.toHex(),U.signatureOid=t.asn1.derToOid(n.certSignatureOid),U.signatureParameters=P(U.signatureOid,n.certSignatureParams,!0),U.siginfo.algorithmOid=t.asn1.derToOid(n.certinfoSignatureOid),U.siginfo.parameters=P(U.siginfo.algorithmOid,n.certinfoSignatureParams,!1),U.signature=n.certSignature;var q=[];if(n.certValidity1UTCTime!==void 0&&q.push(e.utcTimeToDate(n.certValidity1UTCTime)),n.certValidity2GeneralizedTime!==void 0&&q.push(e.generalizedTimeToDate(n.certValidity2GeneralizedTime)),n.certValidity3UTCTime!==void 0&&q.push(e.utcTimeToDate(n.certValidity3UTCTime)),n.certValidity4GeneralizedTime!==void 0&&q.push(e.generalizedTimeToDate(n.certValidity4GeneralizedTime)),q.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(q.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(U.validity.notBefore=q[0],U.validity.notAfter=q[1],U.tbsCertificate=n.tbsCertificate,s){U.md=b({signatureOid:U.signatureOid,type:"certificate"});var M=e.toDer(U.tbsCertificate);U.md.update(M.getBytes())}var H=t.md.sha1.create(),W=e.toDer(n.certIssuer);H.update(W.getBytes()),U.issuer.getField=function(ce){return S(U.issuer,ce)},U.issuer.addField=function(ce){x([ce]),U.issuer.attributes.push(ce)},U.issuer.attributes=r.RDNAttributesAsArray(n.certIssuer),n.certIssuerUniqueId&&(U.issuer.uniqueId=n.certIssuerUniqueId),U.issuer.hash=H.digest().toHex();var j=t.md.sha1.create(),J=e.toDer(n.certSubject);return j.update(J.getBytes()),U.subject.getField=function(ce){return S(U.subject,ce)},U.subject.addField=function(ce){x([ce]),U.subject.attributes.push(ce)},U.subject.attributes=r.RDNAttributesAsArray(n.certSubject),n.certSubjectUniqueId&&(U.subject.uniqueId=n.certSubjectUniqueId),U.subject.hash=j.digest().toHex(),n.certExtensions?U.extensions=r.certificateExtensionsFromAsn1(n.certExtensions):U.extensions=[],U.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),U},r.certificateExtensionsFromAsn1=function(p){for(var s=[],n=0;n<p.value.length;++n)for(var B=p.value[n],D=0;D<B.value.length;++D)s.push(r.certificateExtensionFromAsn1(B.value[D]));return s},r.certificateExtensionFromAsn1=function(p){var s={};if(s.id=e.derToOid(p.value[0].value),s.critical=!1,p.value[1].type===e.Type.BOOLEAN?(s.critical=p.value[1].value.charCodeAt(0)!==0,s.value=p.value[2].value):s.value=p.value[1].value,s.id in i){if(s.name=i[s.id],s.name==="keyUsage"){var n=e.fromDer(s.value),B=0,D=0;n.value.length>1&&(B=n.value.charCodeAt(1),D=n.value.length>2?n.value.charCodeAt(2):0),s.digitalSignature=(B&128)===128,s.nonRepudiation=(B&64)===64,s.keyEncipherment=(B&32)===32,s.dataEncipherment=(B&16)===16,s.keyAgreement=(B&8)===8,s.keyCertSign=(B&4)===4,s.cRLSign=(B&2)===2,s.encipherOnly=(B&1)===1,s.decipherOnly=(D&128)===128}else if(s.name==="basicConstraints"){var n=e.fromDer(s.value);n.value.length>0&&n.value[0].type===e.Type.BOOLEAN?s.cA=n.value[0].value.charCodeAt(0)!==0:s.cA=!1;var V=null;n.value.length>0&&n.value[0].type===e.Type.INTEGER?V=n.value[0].value:n.value.length>1&&(V=n.value[1].value),V!==null&&(s.pathLenConstraint=e.derToInteger(V))}else if(s.name==="extKeyUsage")for(var n=e.fromDer(s.value),U=0;U<n.value.length;++U){var F=e.derToOid(n.value[U].value);F in i?s[i[F]]=!0:s[F]=!0}else if(s.name==="nsCertType"){var n=e.fromDer(s.value),B=0;n.value.length>1&&(B=n.value.charCodeAt(1)),s.client=(B&128)===128,s.server=(B&64)===64,s.email=(B&32)===32,s.objsign=(B&16)===16,s.reserved=(B&8)===8,s.sslCA=(B&4)===4,s.emailCA=(B&2)===2,s.objCA=(B&1)===1}else if(s.name==="subjectAltName"||s.name==="issuerAltName"){s.altNames=[];for(var q,n=e.fromDer(s.value),M=0;M<n.value.length;++M){q=n.value[M];var H={type:q.type,value:q.value};switch(s.altNames.push(H),q.type){case 1:case 2:case 6:break;case 7:H.ip=t.util.bytesToIP(q.value);break;case 8:H.oid=e.derToOid(q.value);break}}}else if(s.name==="subjectKeyIdentifier"){var n=e.fromDer(s.value);s.subjectKeyIdentifier=t.util.bytesToHex(n.value)}}return s},r.certificationRequestFromAsn1=function(p,s){var n={},B=[];if(!e.validate(p,f,n,B)){var D=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw D.errors=B,D}var V=e.derToOid(n.publicKeyOid);if(V!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var U=r.createCertificationRequest();if(U.version=n.csrVersion?n.csrVersion.charCodeAt(0):0,U.signatureOid=t.asn1.derToOid(n.csrSignatureOid),U.signatureParameters=P(U.signatureOid,n.csrSignatureParams,!0),U.siginfo.algorithmOid=t.asn1.derToOid(n.csrSignatureOid),U.siginfo.parameters=P(U.siginfo.algorithmOid,n.csrSignatureParams,!1),U.signature=n.csrSignature,U.certificationRequestInfo=n.certificationRequestInfo,s){U.md=b({signatureOid:U.signatureOid,type:"certification request"});var F=e.toDer(U.certificationRequestInfo);U.md.update(F.getBytes())}var q=t.md.sha1.create();return U.subject.getField=function(M){return S(U.subject,M)},U.subject.addField=function(M){x([M]),U.subject.attributes.push(M)},U.subject.attributes=r.RDNAttributesAsArray(n.certificationRequestInfoSubject,q),U.subject.hash=q.digest().toHex(),U.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),U.getAttribute=function(M){return S(U,M)},U.addAttribute=function(M){x([M]),U.attributes.push(M)},U.attributes=r.CRIAttributesAsArray(n.certificationRequestInfoAttributes||[]),U},r.createCertificationRequest=function(){var p={};return p.version=0,p.signatureOid=null,p.signature=null,p.siginfo={},p.siginfo.algorithmOid=null,p.subject={},p.subject.getField=function(s){return S(p.subject,s)},p.subject.addField=function(s){x([s]),p.subject.attributes.push(s)},p.subject.attributes=[],p.subject.hash=null,p.publicKey=null,p.attributes=[],p.getAttribute=function(s){return S(p,s)},p.addAttribute=function(s){x([s]),p.attributes.push(s)},p.md=null,p.setSubject=function(s){x(s),p.subject.attributes=s,p.subject.hash=null},p.setAttributes=function(s){x(s),p.attributes=s},p.sign=function(s,n){p.md=n||t.md.sha1.create();var B=i[p.md.algorithm+"WithRSAEncryption"];if(!B){var D=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw D.algorithm=p.md.algorithm,D}p.signatureOid=p.siginfo.algorithmOid=B,p.certificationRequestInfo=r.getCertificationRequestInfo(p);var V=e.toDer(p.certificationRequestInfo);p.md.update(V.getBytes()),p.signature=s.sign(p.md)},p.verify=function(){var s=!1,n=p.md;if(n===null){n=b({signatureOid:p.signatureOid,type:"certification request"});var B=p.certificationRequestInfo||r.getCertificationRequestInfo(p),D=e.toDer(B);n.update(D.getBytes())}return n!==null&&(s=l({certificate:p,md:n,signature:p.signature})),s},p};function m(p){for(var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),n,B,D=p.attributes,V=0;V<D.length;++V){n=D[V];var U=n.value,F=e.Type.PRINTABLESTRING;"valueTagClass"in n&&(F=n.valueTagClass,F===e.Type.UTF8&&(U=t.util.encodeUtf8(U))),B=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.type).getBytes()),e.create(e.Class.UNIVERSAL,F,!1,U)])]),s.value.push(B)}return s}function x(p){for(var s,n=0;n<p.length;++n){if(s=p[n],typeof s.name>"u"&&(s.type&&s.type in r.oids?s.name=r.oids[s.type]:s.shortName&&s.shortName in d&&(s.name=r.oids[d[s.shortName]])),typeof s.type>"u")if(s.name&&s.name in r.oids)s.type=r.oids[s.name];else{var B=new Error("Attribute type not specified.");throw B.attribute=s,B}if(typeof s.shortName>"u"&&s.name&&s.name in d&&(s.shortName=d[s.name]),s.type===i.extensionRequest&&(s.valueConstructed=!0,s.valueTagClass=e.Type.SEQUENCE,!s.value&&s.extensions)){s.value=[];for(var D=0;D<s.extensions.length;++D)s.value.push(r.certificateExtensionToAsn1(C(s.extensions[D])))}if(typeof s.value>"u"){var B=new Error("Attribute value not specified.");throw B.attribute=s,B}}}function C(p,s){if(s=s||{},typeof p.name>"u"&&p.id&&p.id in r.oids&&(p.name=r.oids[p.id]),typeof p.id>"u")if(p.name&&p.name in r.oids)p.id=r.oids[p.name];else{var n=new Error("Extension ID not specified.");throw n.extension=p,n}if(typeof p.value<"u")return p;if(p.name==="keyUsage"){var B=0,D=0,V=0;p.digitalSignature&&(D|=128,B=7),p.nonRepudiation&&(D|=64,B=6),p.keyEncipherment&&(D|=32,B=5),p.dataEncipherment&&(D|=16,B=4),p.keyAgreement&&(D|=8,B=3),p.keyCertSign&&(D|=4,B=2),p.cRLSign&&(D|=2,B=1),p.encipherOnly&&(D|=1,B=0),p.decipherOnly&&(V|=128,B=7);var U=String.fromCharCode(B);V!==0?U+=String.fromCharCode(D)+String.fromCharCode(V):D!==0&&(U+=String.fromCharCode(D)),p.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,U)}else if(p.name==="basicConstraints")p.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),p.cA&&p.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ")),"pathLenConstraint"in p&&p.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(p.pathLenConstraint).getBytes()));else if(p.name==="extKeyUsage"){p.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=p.value.value;for(var q in p)p[q]===!0&&(q in i?F.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i[q]).getBytes())):q.indexOf(".")!==-1&&F.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(q).getBytes())))}else if(p.name==="nsCertType"){var B=0,D=0;p.client&&(D|=128,B=7),p.server&&(D|=64,B=6),p.email&&(D|=32,B=5),p.objsign&&(D|=16,B=4),p.reserved&&(D|=8,B=3),p.sslCA&&(D|=4,B=2),p.emailCA&&(D|=2,B=1),p.objCA&&(D|=1,B=0);var U=String.fromCharCode(B);D!==0&&(U+=String.fromCharCode(D)),p.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,U)}else if(p.name==="subjectAltName"||p.name==="issuerAltName"){p.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var M,H=0;H<p.altNames.length;++H){M=p.altNames[H];var U=M.value;if(M.type===7&&M.ip){if(U=t.util.bytesFromIP(M.ip),U===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=p,n}}else M.type===8&&(M.oid?U=e.oidToDer(e.oidToDer(M.oid)):U=e.oidToDer(U));p.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,M.type,!1,U))}}else if(p.name==="nsComment"&&s.cert){if(!/^[\x00-\x7F]*$/.test(p.comment)||p.comment.length<1||p.comment.length>128)throw new Error('Invalid "nsComment" content.');p.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,p.comment)}else if(p.name==="subjectKeyIdentifier"&&s.cert){var W=s.cert.generateSubjectKeyIdentifier();p.subjectKeyIdentifier=W.toHex(),p.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,W.getBytes())}else if(p.name==="authorityKeyIdentifier"&&s.cert){p.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=p.value.value;if(p.keyIdentifier){var j=p.keyIdentifier===!0?s.cert.generateSubjectKeyIdentifier().getBytes():p.keyIdentifier;F.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,j))}if(p.authorityCertIssuer){var J=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[m(p.authorityCertIssuer===!0?s.cert.issuer:p.authorityCertIssuer)])];F.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,J))}if(p.serialNumber){var ce=t.util.hexToBytes(p.serialNumber===!0?s.cert.serialNumber:p.serialNumber);F.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,ce))}}else if(p.name==="cRLDistributionPoints"){p.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var F=p.value.value,fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),me=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),M,H=0;H<p.altNames.length;++H){M=p.altNames[H];var U=M.value;if(M.type===7&&M.ip){if(U=t.util.bytesFromIP(M.ip),U===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=p,n}}else M.type===8&&(M.oid?U=e.oidToDer(e.oidToDer(M.oid)):U=e.oidToDer(U));me.value.push(e.create(e.Class.CONTEXT_SPECIFIC,M.type,!1,U))}fe.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[me])),F.push(fe)}if(typeof p.value>"u"){var n=new Error("Extension value not specified.");throw n.extension=p,n}return p}function o(p,s){switch(p){case i["RSASSA-PSS"]:var n=[];return s.hash.algorithmOid!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])),s.mgf.algorithmOid!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])])),s.saltLength!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(s.saltLength).getBytes())])),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n);default:return e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")}}function h(p){var s=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(p.attributes.length===0)return s;for(var n=p.attributes,B=0;B<n.length;++B){var D=n[B],V=D.value,U=e.Type.UTF8;"valueTagClass"in D&&(U=D.valueTagClass),U===e.Type.UTF8&&(V=t.util.encodeUtf8(V));var F=!1;"valueConstructed"in D&&(F=D.valueConstructed);var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(D.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,U,F,V)])]);s.value.push(q)}return s}var y=new Date("1950-01-01T00:00:00Z"),A=new Date("2050-01-01T00:00:00Z");function _(p){return p>=y&&p<A?e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(p)):e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(p))}return r.getTBSCertificate=function(p){var s=_(p.validity.notBefore),n=_(p.validity.notAfter),B=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(p.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(p.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(p.siginfo.algorithmOid).getBytes()),o(p.siginfo.algorithmOid,p.siginfo.parameters)]),m(p.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,n]),m(p.subject),r.publicKeyToAsn1(p.publicKey)]);return p.issuer.uniqueId&&B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+p.issuer.uniqueId)])),p.subject.uniqueId&&B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+p.subject.uniqueId)])),p.extensions.length>0&&B.value.push(r.certificateExtensionsToAsn1(p.extensions)),B},r.getCertificationRequestInfo=function(p){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(p.version).getBytes()),m(p.subject),r.publicKeyToAsn1(p.publicKey),h(p)]);return s},r.distinguishedNameToAsn1=function(p){return m(p)},r.certificateToAsn1=function(p){var s=p.tbsCertificate||r.getTBSCertificate(p);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(p.signatureOid).getBytes()),o(p.signatureOid,p.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+p.signature)])},r.certificateExtensionsToAsn1=function(p){var s=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);s.value.push(n);for(var B=0;B<p.length;++B)n.value.push(r.certificateExtensionToAsn1(p[B]));return s},r.certificateExtensionToAsn1=function(p){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(p.id).getBytes())),p.critical&&s.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ"));var n=p.value;return typeof p.value!="string"&&(n=e.toDer(n).getBytes()),s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n)),s},r.certificationRequestToAsn1=function(p){var s=p.certificationRequestInfo||r.getCertificationRequestInfo(p);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(p.signatureOid).getBytes()),o(p.signatureOid,p.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+p.signature)])},r.createCaStore=function(p){var s={certs:{}};s.getIssuer=function(U){var F=n(U.issuer);return F},s.addCertificate=function(U){if(typeof U=="string"&&(U=t.pki.certificateFromPem(U)),B(U.subject),!s.hasCertificate(U))if(U.subject.hash in s.certs){var F=s.certs[U.subject.hash];t.util.isArray(F)||(F=[F]),F.push(U),s.certs[U.subject.hash]=F}else s.certs[U.subject.hash]=U},s.hasCertificate=function(U){typeof U=="string"&&(U=t.pki.certificateFromPem(U));var F=n(U.subject);if(!F)return!1;t.util.isArray(F)||(F=[F]);for(var q=e.toDer(r.certificateToAsn1(U)).getBytes(),M=0;M<F.length;++M){var H=e.toDer(r.certificateToAsn1(F[M])).getBytes();if(q===H)return!0}return!1},s.listAllCertificates=function(){var U=[];for(var F in s.certs)if(s.certs.hasOwnProperty(F)){var q=s.certs[F];if(!t.util.isArray(q))U.push(q);else for(var M=0;M<q.length;++M)U.push(q[M])}return U},s.removeCertificate=function(U){var F;if(typeof U=="string"&&(U=t.pki.certificateFromPem(U)),B(U.subject),!s.hasCertificate(U))return null;var q=n(U.subject);if(!t.util.isArray(q))return F=s.certs[U.subject.hash],delete s.certs[U.subject.hash],F;for(var M=e.toDer(r.certificateToAsn1(U)).getBytes(),H=0;H<q.length;++H){var W=e.toDer(r.certificateToAsn1(q[H])).getBytes();M===W&&(F=q[H],q.splice(H,1))}return q.length===0&&delete s.certs[U.subject.hash],F};function n(U){return B(U),s.certs[U.hash]||null}function B(U){if(!U.hash){var F=t.md.sha1.create();U.attributes=r.RDNAttributesAsArray(m(U),F),U.hash=F.digest().toHex()}}if(p)for(var D=0;D<p.length;++D){var V=p[D];s.addCertificate(V)}return s},r.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"},r.verifyCertificateChain=function(p,s,n){typeof n=="function"&&(n={verify:n}),n=n||{},s=s.slice(0);var B=s.slice(0),D=n.validityCheckDate;typeof D>"u"&&(D=new Date);var V=!0,U=null,F=0;do{var q=s.shift(),M=null,H=!1;if(D&&(D<q.validity.notBefore||D>q.validity.notAfter)&&(U={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:q.validity.notBefore,notAfter:q.validity.notAfter,now:D}),U===null){if(M=s[0]||p.getIssuer(q),M===null&&q.isIssuer(q)&&(H=!0,M=q),M){var W=M;t.util.isArray(W)||(W=[W]);for(var j=!1;!j&&W.length>0;){M=W.shift();try{j=M.verify(q)}catch{}}j||(U={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}U===null&&(!M||H)&&!p.hasCertificate(q)&&(U={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(U===null&&M&&!q.isIssuer(M)&&(U={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),U===null)for(var J={keyUsage:!0,basicConstraints:!0},ce=0;U===null&&ce<q.extensions.length;++ce){var fe=q.extensions[ce];fe.critical&&!(fe.name in J)&&(U={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(U===null&&(!V||s.length===0&&(!M||H))){var me=q.getExtension("basicConstraints"),be=q.getExtension("keyUsage");if(be!==null&&(!be.keyCertSign||me===null)&&(U={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:r.certificateError.bad_certificate}),U===null&&me===null&&(U={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:r.certificateError.bad_certificate}),U===null&&me!==null&&!me.cA&&(U={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),U===null&&be!==null&&"pathLenConstraint"in me){var he=F-1;he>me.pathLenConstraint&&(U={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}}var X=U===null?!0:U.error,ee=n.verify?n.verify(X,F,B):X;if(ee===!0)U=null;else throw X===!0&&(U={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(ee||ee===0)&&(typeof ee=="object"&&!t.util.isArray(ee)?(ee.message&&(U.message=ee.message),ee.error&&(U.error=ee.error)):typeof ee=="string"&&(U.error=ee)),U;V=!1,++F}while(s.length>0);return!0},Gr.exports}var dn;function fi(){if(dn)return qr.exports;dn=1;var t=ve();gt(),Qt(),Lt(),ci(),oi(),pt(),dr(),$t(),Ee(),Sa();var e=t.asn1,r=t.pki,i=qr.exports=t.pkcs12=t.pkcs12||{},d={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},v={name:"PFX",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},d,{name:"PFX.macData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:e.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},c={name:"SafeBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},a={name:"Attribute",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,capture:"values"}]},g={name:"CertBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:e.Class.UNIVERSAL,type:e.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function f(x,C,o,h){for(var y=[],A=0;A<x.length;A++)for(var _=0;_<x[A].safeBags.length;_++){var p=x[A].safeBags[_];if(!(h!==void 0&&p.type!==h)){if(C===null){y.push(p);continue}p.attributes[C]!==void 0&&p.attributes[C].indexOf(o)>=0&&y.push(p)}}return y}i.pkcs12FromAsn1=function(x,C,o){typeof C=="string"?(o=C,C=!0):C===void 0&&(C=!0);var h={},y=[];if(!e.validate(x,v,h,y)){var A=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw A.errors=A,A}var _={version:h.version.charCodeAt(0),safeContents:[],getBags:function(M){var H={},W;return"localKeyId"in M?W=M.localKeyId:"localKeyIdHex"in M&&(W=t.util.hexToBytes(M.localKeyIdHex)),W===void 0&&!("friendlyName"in M)&&"bagType"in M&&(H[M.bagType]=f(_.safeContents,null,null,M.bagType)),W!==void 0&&(H.localKeyId=f(_.safeContents,"localKeyId",W,M.bagType)),"friendlyName"in M&&(H.friendlyName=f(_.safeContents,"friendlyName",M.friendlyName,M.bagType)),H},getBagsByFriendlyName:function(M,H){return f(_.safeContents,"friendlyName",M,H)},getBagsByLocalKeyId:function(M,H){return f(_.safeContents,"localKeyId",M,H)}};if(h.version.charCodeAt(0)!==3){var A=new Error("PKCS#12 PFX of version other than 3 not supported.");throw A.version=h.version.charCodeAt(0),A}if(e.derToOid(h.contentType)!==r.oids.data){var A=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw A.oid=e.derToOid(h.contentType),A}var p=h.content.value[0];if(p.tagClass!==e.Class.UNIVERSAL||p.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(p=S(p),h.mac){var s=null,n=0,B=e.derToOid(h.macAlgorithm);switch(B){case r.oids.sha1:s=t.md.sha1.create(),n=20;break;case r.oids.sha256:s=t.md.sha256.create(),n=32;break;case r.oids.sha384:s=t.md.sha384.create(),n=48;break;case r.oids.sha512:s=t.md.sha512.create(),n=64;break;case r.oids.md5:s=t.md.md5.create(),n=16;break}if(s===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+B);var D=new t.util.ByteBuffer(h.macSalt),V="macIterations"in h?parseInt(t.util.bytesToHex(h.macIterations),16):1,U=i.generateKey(o,D,3,V,n,s),F=t.hmac.create();F.start(s,U),F.update(p.value);var q=F.getMac();if(q.getBytes()!==h.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(x.value)&&x.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return P(_,p.value,C,o),_};function S(x){if(x.composed||x.constructed){for(var C=t.util.createBuffer(),o=0;o<x.value.length;++o)C.putBytes(x.value[o].value);x.composed=x.constructed=!1,x.value=C.getBytes()}return x}function P(x,C,o,h){if(C=e.fromDer(C,o),C.tagClass!==e.Class.UNIVERSAL||C.type!==e.Type.SEQUENCE||C.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var y=0;y<C.value.length;y++){var A=C.value[y],_={},p=[];if(!e.validate(A,d,_,p)){var s=new Error("Cannot read ContentInfo.");throw s.errors=p,s}var n={encrypted:!1},B=null,D=_.content.value[0];switch(e.derToOid(_.contentType)){case r.oids.data:if(D.tagClass!==e.Class.UNIVERSAL||D.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");B=S(D).value;break;case r.oids.encryptedData:B=b(D,h),n.encrypted=!0;break;default:var s=new Error("Unsupported PKCS#12 contentType.");throw s.contentType=e.derToOid(_.contentType),s}n.safeBags=l(B,o,h),x.safeContents.push(n)}}function b(x,C){var o={},h=[];if(!e.validate(x,t.pkcs7.asn1.encryptedDataValidator,o,h)){var y=new Error("Cannot read EncryptedContentInfo.");throw y.errors=h,y}var A=e.derToOid(o.contentType);if(A!==r.oids.data){var y=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw y.oid=A,y}A=e.derToOid(o.encAlgorithm);var _=r.pbe.getCipher(A,o.encParameter,C),p=S(o.encryptedContentAsn1),s=t.util.createBuffer(p.value);if(_.update(s),!_.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return _.output.getBytes()}function l(x,C,o){if(!C&&x.length===0)return[];if(x=e.fromDer(x,C),x.tagClass!==e.Class.UNIVERSAL||x.type!==e.Type.SEQUENCE||x.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var h=[],y=0;y<x.value.length;y++){var A=x.value[y],_={},p=[];if(!e.validate(A,c,_,p)){var s=new Error("Cannot read SafeBag.");throw s.errors=p,s}var n={type:e.derToOid(_.bagId),attributes:m(_.bagAttributes)};h.push(n);var B,D,V=_.bagValue.value[0];switch(n.type){case r.oids.pkcs8ShroudedKeyBag:if(V=r.decryptPrivateKeyInfo(V,o),V===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{n.key=r.privateKeyFromAsn1(V)}catch{n.key=null,n.asn1=V}continue;case r.oids.certBag:B=g,D=function(){if(e.derToOid(_.certId)!==r.oids.x509Certificate){var F=new Error("Unsupported certificate type, only X.509 supported.");throw F.oid=e.derToOid(_.certId),F}var q=e.fromDer(_.cert,C);try{n.cert=r.certificateFromAsn1(q,!0)}catch{n.cert=null,n.asn1=q}};break;default:var s=new Error("Unsupported PKCS#12 SafeBag type.");throw s.oid=n.type,s}if(B!==void 0&&!e.validate(V,B,_,p)){var s=new Error("Cannot read PKCS#12 "+B.name);throw s.errors=p,s}D()}return h}function m(x){var C={};if(x!==void 0)for(var o=0;o<x.length;++o){var h={},y=[];if(!e.validate(x[o],a,h,y)){var A=new Error("Cannot read PKCS#12 BagAttribute.");throw A.errors=y,A}var _=e.derToOid(h.oid);if(r.oids[_]!==void 0){C[r.oids[_]]=[];for(var p=0;p<h.values.length;++p)C[r.oids[_]].push(h.values[p].value)}}return C}return i.toPkcs12Asn1=function(x,C,o,h){h=h||{},h.saltSize=h.saltSize||8,h.count=h.count||2048,h.algorithm=h.algorithm||h.encAlgorithm||"aes128","useMac"in h||(h.useMac=!0),"localKeyId"in h||(h.localKeyId=null),"generateLocalKeyId"in h||(h.generateLocalKeyId=!0);var y=h.localKeyId,A;if(y!==null)y=t.util.hexToBytes(y);else if(h.generateLocalKeyId)if(C){var _=t.util.isArray(C)?C[0]:C;typeof _=="string"&&(_=r.certificateFromPem(_));var p=t.md.sha1.create();p.update(e.toDer(r.certificateToAsn1(_)).getBytes()),y=p.digest().getBytes()}else y=t.random.getBytes(20);var s=[];y!==null&&s.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.localKeyId).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,y)])])),"friendlyName"in h&&s.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.friendlyName).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.BMPSTRING,!1,h.friendlyName)])])),s.length>0&&(A=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,s));var n=[],B=[];C!==null&&(t.util.isArray(C)?B=C:B=[C]);for(var D=[],V=0;V<B.length;++V){C=B[V],typeof C=="string"&&(C=r.certificateFromPem(C));var U=V===0?A:void 0,F=r.certificateToAsn1(C),q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.certBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.x509Certificate).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(F).getBytes())])])]),U]);D.push(q)}if(D.length>0){var M=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,D),H=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(M).getBytes())])]);n.push(H)}var W=null;if(x!==null){var j=r.wrapRsaPrivateKey(r.privateKeyToAsn1(x));o===null?W=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.keyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[j]),A]):W=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(j,o,h)]),A]);var J=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[W]),ce=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(J).getBytes())])]);n.push(ce)}var fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n),me;if(h.useMac){var p=t.md.sha1.create(),be=new t.util.ByteBuffer(t.random.getBytes(h.saltSize)),he=h.count,x=i.generateKey(o,be,3,he,20),X=t.hmac.create();X.start(p,x),X.update(e.toDer(fe).getBytes());var ee=X.getMac();me=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.sha1).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ee.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,be.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(he).getBytes())])}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(3).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(fe).getBytes())])]),me])},i.generateKey=t.pbe.generatePkcs12Key,qr.exports}var pn;function li(){if(pn)return _r.exports;pn=1;var t=ve();gt(),Lt(),oi(),Ot(),Ea(),fi(),xa(),dr(),Ee(),Sa();var e=t.asn1,r=_r.exports=t.pki=t.pki||{};return r.pemToDer=function(i){var d=t.pem.decode(i)[0];if(d.procType&&d.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(d.body)},r.privateKeyFromPem=function(i){var d=t.pem.decode(i)[0];if(d.type!=="PRIVATE KEY"&&d.type!=="RSA PRIVATE KEY"){var v=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw v.headerType=d.type,v}if(d.procType&&d.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var c=e.fromDer(d.body);return r.privateKeyFromAsn1(c)},r.privateKeyToPem=function(i,d){var v={type:"RSA PRIVATE KEY",body:e.toDer(r.privateKeyToAsn1(i)).getBytes()};return t.pem.encode(v,{maxline:d})},r.privateKeyInfoToPem=function(i,d){var v={type:"PRIVATE KEY",body:e.toDer(i).getBytes()};return t.pem.encode(v,{maxline:d})},_r.exports}var Wr,hn;function di(){if(hn)return Wr;hn=1;var t=ve();gt(),Qt(),ma(),Ot(),li(),pt(),$t(),Ee();var e=function(E,L,R,N){var u=t.util.createBuffer(),I=E.length>>1,O=I+(E.length&1),G=E.substr(0,O),ne=E.substr(I,O),te=t.util.createBuffer(),z=t.hmac.create();R=L+R;var Q=Math.ceil(N/16),Z=Math.ceil(N/20);z.start("MD5",G);var ye=t.util.createBuffer();te.putBytes(R);for(var pe=0;pe<Q;++pe)z.start(null,null),z.update(te.getBytes()),te.putBuffer(z.digest()),z.start(null,null),z.update(te.bytes()+R),ye.putBuffer(z.digest());z.start("SHA1",ne);var Ce=t.util.createBuffer();te.clear(),te.putBytes(R);for(var pe=0;pe<Z;++pe)z.start(null,null),z.update(te.getBytes()),te.putBuffer(z.digest()),z.start(null,null),z.update(te.bytes()+R),Ce.putBuffer(z.digest());return u.putBytes(t.util.xorBytes(ye.getBytes(),Ce.getBytes(),N)),u},r=function(E,L,R){var N=t.hmac.create();N.start("SHA1",E);var u=t.util.createBuffer();return u.putInt32(L[0]),u.putInt32(L[1]),u.putByte(R.type),u.putByte(R.version.major),u.putByte(R.version.minor),u.putInt16(R.length),u.putBytes(R.fragment.bytes()),N.update(u.getBytes()),N.digest().getBytes()},i=function(E,L,R){var N=!1;try{var u=E.deflate(L.fragment.getBytes());L.fragment=t.util.createBuffer(u),L.length=u.length,N=!0}catch{}return N},d=function(E,L,R){var N=!1;try{var u=E.inflate(L.fragment.getBytes());L.fragment=t.util.createBuffer(u),L.length=u.length,N=!0}catch{}return N},v=function(E,L){var R=0;switch(L){case 1:R=E.getByte();break;case 2:R=E.getInt16();break;case 3:R=E.getInt24();break;case 4:R=E.getInt32();break}return t.util.createBuffer(E.getBytes(R))},c=function(E,L,R){E.putInt(R.length(),L<<3),E.putBuffer(R)},a={};a.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},a.SupportedVersions=[a.Versions.TLS_1_1,a.Versions.TLS_1_0],a.Version=a.SupportedVersions[0],a.MaxFragment=15360,a.ConnectionEnd={server:0,client:1},a.PRFAlgorithm={tls_prf_sha256:0},a.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},a.CipherType={stream:0,block:1,aead:2},a.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},a.CompressionMethod={none:0,deflate:1},a.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},a.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},a.Alert={},a.Alert.Level={warning:1,fatal:2},a.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},a.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},a.CipherSuites={},a.getCipherSuite=function(E){var L=null;for(var R in a.CipherSuites){var N=a.CipherSuites[R];if(N.id[0]===E.charCodeAt(0)&&N.id[1]===E.charCodeAt(1)){L=N;break}}return L},a.handleUnexpected=function(E,L){var R=!E.open&&E.entity===a.ConnectionEnd.client;R||E.error(E,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unexpected_message}})},a.handleHelloRequest=function(E,L,R){!E.handshaking&&E.handshakes>0&&(a.queue(E,a.createAlert(E,{level:a.Alert.Level.warning,description:a.Alert.Description.no_renegotiation})),a.flush(E)),E.process()},a.parseHelloMessage=function(E,L,R){var N=null,u=E.entity===a.ConnectionEnd.client;if(R<38)E.error(E,{message:u?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});else{var I=L.fragment,O=I.length();if(N={version:{major:I.getByte(),minor:I.getByte()},random:t.util.createBuffer(I.getBytes(32)),session_id:v(I,1),extensions:[]},u?(N.cipher_suite=I.getBytes(2),N.compression_method=I.getByte()):(N.cipher_suites=v(I,2),N.compression_methods=v(I,1)),O=R-(O-I.length()),O>0){for(var G=v(I,2);G.length()>0;)N.extensions.push({type:[G.getByte(),G.getByte()],data:v(G,2)});if(!u)for(var ne=0;ne<N.extensions.length;++ne){var te=N.extensions[ne];if(te.type[0]===0&&te.type[1]===0)for(var z=v(te.data,2);z.length()>0;){var Q=z.getByte();if(Q!==0)break;E.session.extensions.server_name.serverNameList.push(v(z,2).getBytes())}}}if(E.session.version&&(N.version.major!==E.session.version.major||N.version.minor!==E.session.version.minor))return E.error(E,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});if(u)E.session.cipherSuite=a.getCipherSuite(N.cipher_suite);else for(var Z=t.util.createBuffer(N.cipher_suites.bytes());Z.length()>0&&(E.session.cipherSuite=a.getCipherSuite(Z.getBytes(2)),E.session.cipherSuite===null););if(E.session.cipherSuite===null)return E.error(E,{message:"No cipher suites in common.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure},cipherSuite:t.util.bytesToHex(N.cipher_suite)});u?E.session.compressionMethod=N.compression_method:E.session.compressionMethod=a.CompressionMethod.none}return N},a.createSecurityParameters=function(E,L){var R=E.entity===a.ConnectionEnd.client,N=L.random.bytes(),u=R?E.session.sp.client_random:N,I=R?N:a.createRandom().getBytes();E.session.sp={entity:E.entity,prf_algorithm:a.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:E.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:u,server_random:I}},a.handleServerHello=function(E,L,R){var N=a.parseHelloMessage(E,L,R);if(!E.fail){if(N.version.minor<=E.version.minor)E.version.minor=N.version.minor;else return E.error(E,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});E.session.version=E.version;var u=N.session_id.bytes();u.length>0&&u===E.session.id?(E.expect=l,E.session.resuming=!0,E.session.sp.server_random=N.random.bytes()):(E.expect=f,E.session.resuming=!1,a.createSecurityParameters(E,N)),E.session.id=u,E.process()}},a.handleClientHello=function(E,L,R){var N=a.parseHelloMessage(E,L,R);if(!E.fail){var u=N.session_id.bytes(),I=null;if(E.sessionCache&&(I=E.sessionCache.getSession(u),I===null?u="":(I.version.major!==N.version.major||I.version.minor>N.version.minor)&&(I=null,u="")),u.length===0&&(u=t.random.getBytes(32)),E.session.id=u,E.session.clientHelloVersion=N.version,E.session.sp={},I)E.version=E.session.version=I.version,E.session.sp=I.sp;else{for(var O,G=1;G<a.SupportedVersions.length&&(O=a.SupportedVersions[G],!(O.minor<=N.version.minor));++G);E.version={major:O.major,minor:O.minor},E.session.version=E.version}I!==null?(E.expect=_,E.session.resuming=!0,E.session.sp.client_random=N.random.bytes()):(E.expect=E.verifyClient!==!1?h:y,E.session.resuming=!1,a.createSecurityParameters(E,N)),E.open=!0,a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createServerHello(E)})),E.session.resuming?(a.queue(E,a.createRecord(E,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),E.state.pending=a.createConnectionState(E),E.state.current.write=E.state.pending.write,a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createFinished(E)}))):(a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createCertificate(E)})),E.fail||(a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createServerKeyExchange(E)})),E.verifyClient!==!1&&a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createCertificateRequest(E)})),a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createServerHelloDone(E)})))),a.flush(E),E.process()}},a.handleCertificate=function(E,L,R){if(R<3)return E.error(E,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=L.fragment,u={certificate_list:v(N,3)},I,O,G=[];try{for(;u.certificate_list.length()>0;)I=v(u.certificate_list,3),O=t.asn1.fromDer(I),I=t.pki.certificateFromAsn1(O,!0),G.push(I)}catch(te){return E.error(E,{message:"Could not parse certificate list.",cause:te,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var ne=E.entity===a.ConnectionEnd.client;(ne||E.verifyClient===!0)&&G.length===0?E.error(E,{message:ne?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}}):G.length===0?E.expect=ne?S:y:(ne?E.session.serverCertificate=G[0]:E.session.clientCertificate=G[0],a.verifyCertificateChain(E,G)&&(E.expect=ne?S:y)),E.process()},a.handleServerKeyExchange=function(E,L,R){if(R>0)return E.error(E,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});E.expect=P,E.process()},a.handleClientKeyExchange=function(E,L,R){if(R<48)return E.error(E,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});var N=L.fragment,u={enc_pre_master_secret:v(N,2).getBytes()},I=null;if(E.getPrivateKey)try{I=E.getPrivateKey(E,E.session.serverCertificate),I=t.pki.privateKeyFromPem(I)}catch(ne){E.error(E,{message:"Could not get private key.",cause:ne,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}if(I===null)return E.error(E,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}});try{var O=E.session.sp;O.pre_master_secret=I.decrypt(u.enc_pre_master_secret);var G=E.session.clientHelloVersion;if(G.major!==O.pre_master_secret.charCodeAt(0)||G.minor!==O.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{O.pre_master_secret=t.random.getBytes(48)}E.expect=_,E.session.clientCertificate!==null&&(E.expect=A),E.process()},a.handleCertificateRequest=function(E,L,R){if(R<3)return E.error(E,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=L.fragment,u={certificate_types:v(N,1),certificate_authorities:v(N,2)};E.session.certificateRequest=u,E.expect=b,E.process()},a.handleCertificateVerify=function(E,L,R){if(R<2)return E.error(E,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=L.fragment;N.read-=4;var u=N.bytes();N.read+=4;var I={signature:v(N,2).getBytes()},O=t.util.createBuffer();O.putBuffer(E.session.md5.digest()),O.putBuffer(E.session.sha1.digest()),O=O.getBytes();try{var G=E.session.clientCertificate;if(!G.publicKey.verify(O,I.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");E.session.md5.update(u),E.session.sha1.update(u)}catch{return E.error(E,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure}})}E.expect=_,E.process()},a.handleServerHelloDone=function(E,L,R){if(R>0)return E.error(E,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.record_overflow}});if(E.serverCertificate===null){var N={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.insufficient_security}},u=0,I=E.verify(E,N.alert.description,u,[]);if(I!==!0)return(I||I===0)&&(typeof I=="object"&&!t.util.isArray(I)?(I.message&&(N.message=I.message),I.alert&&(N.alert.description=I.alert)):typeof I=="number"&&(N.alert.description=I)),E.error(E,N)}E.session.certificateRequest!==null&&(L=a.createRecord(E,{type:a.ContentType.handshake,data:a.createCertificate(E)}),a.queue(E,L)),L=a.createRecord(E,{type:a.ContentType.handshake,data:a.createClientKeyExchange(E)}),a.queue(E,L),E.expect=C;var O=function(G,ne){G.session.certificateRequest!==null&&G.session.clientCertificate!==null&&a.queue(G,a.createRecord(G,{type:a.ContentType.handshake,data:a.createCertificateVerify(G,ne)})),a.queue(G,a.createRecord(G,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),G.state.pending=a.createConnectionState(G),G.state.current.write=G.state.pending.write,a.queue(G,a.createRecord(G,{type:a.ContentType.handshake,data:a.createFinished(G)})),G.expect=l,a.flush(G),G.process()};if(E.session.certificateRequest===null||E.session.clientCertificate===null)return O(E,null);a.getClientSignature(E,O)},a.handleChangeCipherSpec=function(E,L){if(L.fragment.getByte()!==1)return E.error(E,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var R=E.entity===a.ConnectionEnd.client;(E.session.resuming&&R||!E.session.resuming&&!R)&&(E.state.pending=a.createConnectionState(E)),E.state.current.read=E.state.pending.read,(!E.session.resuming&&R||E.session.resuming&&!R)&&(E.state.pending=null),E.expect=R?m:p,E.process()},a.handleFinished=function(E,L,R){var N=L.fragment;N.read-=4;var u=N.bytes();N.read+=4;var I=L.fragment.getBytes();N=t.util.createBuffer(),N.putBuffer(E.session.md5.digest()),N.putBuffer(E.session.sha1.digest());var O=E.entity===a.ConnectionEnd.client,G=O?"server finished":"client finished",ne=E.session.sp,te=12,z=e;if(N=z(ne.master_secret,G,N.getBytes(),te),N.getBytes()!==I)return E.error(E,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decrypt_error}});E.session.md5.update(u),E.session.sha1.update(u),(E.session.resuming&&O||!E.session.resuming&&!O)&&(a.queue(E,a.createRecord(E,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),E.state.current.write=E.state.pending.write,E.state.pending=null,a.queue(E,a.createRecord(E,{type:a.ContentType.handshake,data:a.createFinished(E)}))),E.expect=O?x:s,E.handshaking=!1,++E.handshakes,E.peerCertificate=O?E.session.serverCertificate:E.session.clientCertificate,a.flush(E),E.isConnected=!0,E.connected(E),E.process()},a.handleAlert=function(E,L){var R=L.fragment,N={level:R.getByte(),description:R.getByte()},u;switch(N.description){case a.Alert.Description.close_notify:u="Connection closed.";break;case a.Alert.Description.unexpected_message:u="Unexpected message.";break;case a.Alert.Description.bad_record_mac:u="Bad record MAC.";break;case a.Alert.Description.decryption_failed:u="Decryption failed.";break;case a.Alert.Description.record_overflow:u="Record overflow.";break;case a.Alert.Description.decompression_failure:u="Decompression failed.";break;case a.Alert.Description.handshake_failure:u="Handshake failure.";break;case a.Alert.Description.bad_certificate:u="Bad certificate.";break;case a.Alert.Description.unsupported_certificate:u="Unsupported certificate.";break;case a.Alert.Description.certificate_revoked:u="Certificate revoked.";break;case a.Alert.Description.certificate_expired:u="Certificate expired.";break;case a.Alert.Description.certificate_unknown:u="Certificate unknown.";break;case a.Alert.Description.illegal_parameter:u="Illegal parameter.";break;case a.Alert.Description.unknown_ca:u="Unknown certificate authority.";break;case a.Alert.Description.access_denied:u="Access denied.";break;case a.Alert.Description.decode_error:u="Decode error.";break;case a.Alert.Description.decrypt_error:u="Decrypt error.";break;case a.Alert.Description.export_restriction:u="Export restriction.";break;case a.Alert.Description.protocol_version:u="Unsupported protocol version.";break;case a.Alert.Description.insufficient_security:u="Insufficient security.";break;case a.Alert.Description.internal_error:u="Internal error.";break;case a.Alert.Description.user_canceled:u="User canceled.";break;case a.Alert.Description.no_renegotiation:u="Renegotiation not supported.";break;default:u="Unknown error.";break}if(N.description===a.Alert.Description.close_notify)return E.close();E.error(E,{message:u,send:!1,origin:E.entity===a.ConnectionEnd.client?"server":"client",alert:N}),E.process()},a.handleHandshake=function(E,L){var R=L.fragment,N=R.getByte(),u=R.getInt24();if(u>R.length())return E.fragmented=L,L.fragment=t.util.createBuffer(),R.read-=4,E.process();E.fragmented=null,R.read-=4;var I=R.bytes(u+4);R.read+=4,N in me[E.entity][E.expect]?(E.entity===a.ConnectionEnd.server&&!E.open&&!E.fail&&(E.handshaking=!0,E.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:t.md.md5.create(),sha1:t.md.sha1.create()}),N!==a.HandshakeType.hello_request&&N!==a.HandshakeType.certificate_verify&&N!==a.HandshakeType.finished&&(E.session.md5.update(I),E.session.sha1.update(I)),me[E.entity][E.expect][N](E,L,u)):a.handleUnexpected(E,L)},a.handleApplicationData=function(E,L){E.data.putBuffer(L.fragment),E.dataReady(E),E.process()},a.handleHeartbeat=function(E,L){var R=L.fragment,N=R.getByte(),u=R.getInt16(),I=R.getBytes(u);if(N===a.HeartbeatMessageType.heartbeat_request){if(E.handshaking||u>I.length)return E.process();a.queue(E,a.createRecord(E,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_response,I)})),a.flush(E)}else if(N===a.HeartbeatMessageType.heartbeat_response){if(I!==E.expectedHeartbeatPayload)return E.process();E.heartbeatReceived&&E.heartbeatReceived(E,t.util.createBuffer(I))}E.process()};var g=0,f=1,S=2,P=3,b=4,l=5,m=6,x=7,C=8,o=0,h=1,y=2,A=3,_=4,p=5,s=6,n=a.handleUnexpected,B=a.handleChangeCipherSpec,D=a.handleAlert,V=a.handleHandshake,U=a.handleApplicationData,F=a.handleHeartbeat,q=[];q[a.ConnectionEnd.client]=[[n,D,V,n,F],[n,D,V,n,F],[n,D,V,n,F],[n,D,V,n,F],[n,D,V,n,F],[B,D,n,n,F],[n,D,V,n,F],[n,D,V,U,F],[n,D,V,n,F]],q[a.ConnectionEnd.server]=[[n,D,V,n,F],[n,D,V,n,F],[n,D,V,n,F],[n,D,V,n,F],[B,D,n,n,F],[n,D,V,n,F],[n,D,V,U,F],[n,D,V,n,F]];var M=a.handleHelloRequest,H=a.handleServerHello,W=a.handleCertificate,j=a.handleServerKeyExchange,J=a.handleCertificateRequest,ce=a.handleServerHelloDone,fe=a.handleFinished,me=[];me[a.ConnectionEnd.client]=[[n,n,H,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,W,j,J,ce,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,j,J,ce,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,J,ce,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,ce,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,fe],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n]];var be=a.handleClientHello,he=a.handleClientKeyExchange,X=a.handleCertificateVerify;me[a.ConnectionEnd.server]=[[n,be,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,W,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,he,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,X,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,fe],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n]],a.generateKeys=function(E,L){var R=e,N=L.client_random+L.server_random;E.session.resuming||(L.master_secret=R(L.pre_master_secret,"master secret",N,48).bytes(),L.pre_master_secret=null),N=L.server_random+L.client_random;var u=2*L.mac_key_length+2*L.enc_key_length,I=E.version.major===a.Versions.TLS_1_0.major&&E.version.minor===a.Versions.TLS_1_0.minor;I&&(u+=2*L.fixed_iv_length);var O=R(L.master_secret,"key expansion",N,u),G={client_write_MAC_key:O.getBytes(L.mac_key_length),server_write_MAC_key:O.getBytes(L.mac_key_length),client_write_key:O.getBytes(L.enc_key_length),server_write_key:O.getBytes(L.enc_key_length)};return I&&(G.client_write_IV=O.getBytes(L.fixed_iv_length),G.server_write_IV=O.getBytes(L.fixed_iv_length)),G},a.createConnectionState=function(E){var L=E.entity===a.ConnectionEnd.client,R=function(){var I={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(O){return!0},compressionState:null,compressFunction:function(O){return!0},updateSequenceNumber:function(){I.sequenceNumber[1]===4294967295?(I.sequenceNumber[1]=0,++I.sequenceNumber[0]):++I.sequenceNumber[1]}};return I},N={read:R(),write:R()};if(N.read.update=function(I,O){return N.read.cipherFunction(O,N.read)?N.read.compressFunction(I,O,N.read)||I.error(I,{message:"Could not decompress record.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decompression_failure}}):I.error(I,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_record_mac}}),!I.fail},N.write.update=function(I,O){return N.write.compressFunction(I,O,N.write)?N.write.cipherFunction(O,N.write)||I.error(I,{message:"Could not encrypt record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):I.error(I,{message:"Could not compress record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}),!I.fail},E.session){var u=E.session.sp;switch(E.session.cipherSuite.initSecurityParameters(u),u.keys=a.generateKeys(E,u),N.read.macKey=L?u.keys.server_write_MAC_key:u.keys.client_write_MAC_key,N.write.macKey=L?u.keys.client_write_MAC_key:u.keys.server_write_MAC_key,E.session.cipherSuite.initConnectionState(N,E,u),u.compression_algorithm){case a.CompressionMethod.none:break;case a.CompressionMethod.deflate:N.read.compressFunction=d,N.write.compressFunction=i;break;default:throw new Error("Unsupported compression algorithm.")}}return N},a.createRandom=function(){var E=new Date,L=+E+E.getTimezoneOffset()*6e4,R=t.util.createBuffer();return R.putInt32(L),R.putBytes(t.random.getBytes(28)),R},a.createRecord=function(E,L){if(!L.data)return null;var R={type:L.type,version:{major:E.version.major,minor:E.version.minor},length:L.data.length(),fragment:L.data};return R},a.createAlert=function(E,L){var R=t.util.createBuffer();return R.putByte(L.level),R.putByte(L.description),a.createRecord(E,{type:a.ContentType.alert,data:R})},a.createClientHello=function(E){E.session.clientHelloVersion={major:E.version.major,minor:E.version.minor};for(var L=t.util.createBuffer(),R=0;R<E.cipherSuites.length;++R){var N=E.cipherSuites[R];L.putByte(N.id[0]),L.putByte(N.id[1])}var u=L.length(),I=t.util.createBuffer();I.putByte(a.CompressionMethod.none);var O=I.length(),G=t.util.createBuffer();if(E.virtualHost){var ne=t.util.createBuffer();ne.putByte(0),ne.putByte(0);var te=t.util.createBuffer();te.putByte(0),c(te,2,t.util.createBuffer(E.virtualHost));var z=t.util.createBuffer();c(z,2,te),c(ne,2,z),G.putBuffer(ne)}var Q=G.length();Q>0&&(Q+=2);var Z=E.session.id,ye=Z.length+1+2+4+28+2+u+1+O+Q,pe=t.util.createBuffer();return pe.putByte(a.HandshakeType.client_hello),pe.putInt24(ye),pe.putByte(E.version.major),pe.putByte(E.version.minor),pe.putBytes(E.session.sp.client_random),c(pe,1,t.util.createBuffer(Z)),c(pe,2,L),c(pe,1,I),Q>0&&c(pe,2,G),pe},a.createServerHello=function(E){var L=E.session.id,R=L.length+1+2+4+28+2+1,N=t.util.createBuffer();return N.putByte(a.HandshakeType.server_hello),N.putInt24(R),N.putByte(E.version.major),N.putByte(E.version.minor),N.putBytes(E.session.sp.server_random),c(N,1,t.util.createBuffer(L)),N.putByte(E.session.cipherSuite.id[0]),N.putByte(E.session.cipherSuite.id[1]),N.putByte(E.session.compressionMethod),N},a.createCertificate=function(E){var L=E.entity===a.ConnectionEnd.client,R=null;if(E.getCertificate){var N;L?N=E.session.certificateRequest:N=E.session.extensions.server_name.serverNameList,R=E.getCertificate(E,N)}var u=t.util.createBuffer();if(R!==null)try{t.util.isArray(R)||(R=[R]);for(var I=null,O=0;O<R.length;++O){var G=t.pem.decode(R[O])[0];if(G.type!=="CERTIFICATE"&&G.type!=="X509 CERTIFICATE"&&G.type!=="TRUSTED CERTIFICATE"){var ne=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw ne.headerType=G.type,ne}if(G.procType&&G.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var te=t.util.createBuffer(G.body);I===null&&(I=t.asn1.fromDer(te.bytes(),!1));var z=t.util.createBuffer();c(z,3,te),u.putBuffer(z)}R=t.pki.certificateFromAsn1(I),L?E.session.clientCertificate=R:E.session.serverCertificate=R}catch(ye){return E.error(E,{message:"Could not send certificate list.",cause:ye,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var Q=3+u.length(),Z=t.util.createBuffer();return Z.putByte(a.HandshakeType.certificate),Z.putInt24(Q),c(Z,3,u),Z},a.createClientKeyExchange=function(E){var L=t.util.createBuffer();L.putByte(E.session.clientHelloVersion.major),L.putByte(E.session.clientHelloVersion.minor),L.putBytes(t.random.getBytes(46));var R=E.session.sp;R.pre_master_secret=L.getBytes();var N=E.session.serverCertificate.publicKey;L=N.encrypt(R.pre_master_secret);var u=L.length+2,I=t.util.createBuffer();return I.putByte(a.HandshakeType.client_key_exchange),I.putInt24(u),I.putInt16(L.length),I.putBytes(L),I},a.createServerKeyExchange=function(E){var L=t.util.createBuffer();return L},a.getClientSignature=function(E,L){var R=t.util.createBuffer();R.putBuffer(E.session.md5.digest()),R.putBuffer(E.session.sha1.digest()),R=R.getBytes(),E.getSignature=E.getSignature||function(N,u,I){var O=null;if(N.getPrivateKey)try{O=N.getPrivateKey(N,N.session.clientCertificate),O=t.pki.privateKeyFromPem(O)}catch(G){N.error(N,{message:"Could not get private key.",cause:G,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}O===null?N.error(N,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):u=O.sign(u,null),I(N,u)},E.getSignature(E,R,L)},a.createCertificateVerify=function(E,L){var R=L.length+2,N=t.util.createBuffer();return N.putByte(a.HandshakeType.certificate_verify),N.putInt24(R),N.putInt16(L.length),N.putBytes(L),N},a.createCertificateRequest=function(E){var L=t.util.createBuffer();L.putByte(1);var R=t.util.createBuffer();for(var N in E.caStore.certs){var u=E.caStore.certs[N],I=t.pki.distinguishedNameToAsn1(u.subject),O=t.asn1.toDer(I);R.putInt16(O.length()),R.putBuffer(O)}var G=1+L.length()+2+R.length(),ne=t.util.createBuffer();return ne.putByte(a.HandshakeType.certificate_request),ne.putInt24(G),c(ne,1,L),c(ne,2,R),ne},a.createServerHelloDone=function(E){var L=t.util.createBuffer();return L.putByte(a.HandshakeType.server_hello_done),L.putInt24(0),L},a.createChangeCipherSpec=function(){var E=t.util.createBuffer();return E.putByte(1),E},a.createFinished=function(E){var L=t.util.createBuffer();L.putBuffer(E.session.md5.digest()),L.putBuffer(E.session.sha1.digest());var R=E.entity===a.ConnectionEnd.client,N=E.session.sp,u=12,I=e,O=R?"client finished":"server finished";L=I(N.master_secret,O,L.getBytes(),u);var G=t.util.createBuffer();return G.putByte(a.HandshakeType.finished),G.putInt24(L.length()),G.putBuffer(L),G},a.createHeartbeat=function(E,L,R){typeof R>"u"&&(R=L.length);var N=t.util.createBuffer();N.putByte(E),N.putInt16(R),N.putBytes(L);var u=N.length(),I=Math.max(16,u-R-3);return N.putBytes(t.random.getBytes(I)),N},a.queue=function(E,L){if(L&&!(L.fragment.length()===0&&(L.type===a.ContentType.handshake||L.type===a.ContentType.alert||L.type===a.ContentType.change_cipher_spec))){if(L.type===a.ContentType.handshake){var R=L.fragment.bytes();E.session.md5.update(R),E.session.sha1.update(R),R=null}var N;if(L.fragment.length()<=a.MaxFragment)N=[L];else{N=[];for(var u=L.fragment.bytes();u.length>a.MaxFragment;)N.push(a.createRecord(E,{type:L.type,data:t.util.createBuffer(u.slice(0,a.MaxFragment))})),u=u.slice(a.MaxFragment);u.length>0&&N.push(a.createRecord(E,{type:L.type,data:t.util.createBuffer(u)}))}for(var I=0;I<N.length&&!E.fail;++I){var O=N[I],G=E.state.current.write;G.update(E,O)&&E.records.push(O)}}},a.flush=function(E){for(var L=0;L<E.records.length;++L){var R=E.records[L];E.tlsData.putByte(R.type),E.tlsData.putByte(R.version.major),E.tlsData.putByte(R.version.minor),E.tlsData.putInt16(R.fragment.length()),E.tlsData.putBuffer(E.records[L].fragment)}return E.records=[],E.tlsDataReady(E)};var ee=function(E){switch(E){case!0:return!0;case t.pki.certificateError.bad_certificate:return a.Alert.Description.bad_certificate;case t.pki.certificateError.unsupported_certificate:return a.Alert.Description.unsupported_certificate;case t.pki.certificateError.certificate_revoked:return a.Alert.Description.certificate_revoked;case t.pki.certificateError.certificate_expired:return a.Alert.Description.certificate_expired;case t.pki.certificateError.certificate_unknown:return a.Alert.Description.certificate_unknown;case t.pki.certificateError.unknown_ca:return a.Alert.Description.unknown_ca;default:return a.Alert.Description.bad_certificate}},Ve=function(E){switch(E){case!0:return!0;case a.Alert.Description.bad_certificate:return t.pki.certificateError.bad_certificate;case a.Alert.Description.unsupported_certificate:return t.pki.certificateError.unsupported_certificate;case a.Alert.Description.certificate_revoked:return t.pki.certificateError.certificate_revoked;case a.Alert.Description.certificate_expired:return t.pki.certificateError.certificate_expired;case a.Alert.Description.certificate_unknown:return t.pki.certificateError.certificate_unknown;case a.Alert.Description.unknown_ca:return t.pki.certificateError.unknown_ca;default:return t.pki.certificateError.bad_certificate}};a.verifyCertificateChain=function(E,L){try{var R={};for(var N in E.verifyOptions)R[N]=E.verifyOptions[N];R.verify=function(I,O,G){var ne=ee(I),te=E.verify(E,I,O,G);if(te!==!0){if(typeof te=="object"&&!t.util.isArray(te)){var z=new Error("The application rejected the certificate.");throw z.send=!0,z.alert={level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate},te.message&&(z.message=te.message),te.alert&&(z.alert.description=te.alert),z}te!==I&&(te=Ve(te))}return te},t.pki.verifyCertificateChain(E.caStore,L,R)}catch(I){var u=I;(typeof u!="object"||t.util.isArray(u))&&(u={send:!0,alert:{level:a.Alert.Level.fatal,description:ee(I)}}),"send"in u||(u.send=!0),"alert"in u||(u.alert={level:a.Alert.Level.fatal,description:ee(u.error)}),E.error(E,u)}return!E.fail},a.createSessionCache=function(E,L){var R=null;if(E&&E.getSession&&E.setSession&&E.order)R=E;else{R={},R.cache=E||{},R.capacity=Math.max(L||100,1),R.order=[];for(var N in E)R.order.length<=L?R.order.push(N):delete E[N];R.getSession=function(u){var I=null,O=null;if(u?O=t.util.bytesToHex(u):R.order.length>0&&(O=R.order[0]),O!==null&&O in R.cache){I=R.cache[O],delete R.cache[O];for(var G in R.order)if(R.order[G]===O){R.order.splice(G,1);break}}return I},R.setSession=function(u,I){if(R.order.length===R.capacity){var O=R.order.shift();delete R.cache[O]}var O=t.util.bytesToHex(u);R.order.push(O),R.cache[O]=I}}return R},a.createConnection=function(E){var L=null;E.caStore?t.util.isArray(E.caStore)?L=t.pki.createCaStore(E.caStore):L=E.caStore:L=t.pki.createCaStore();var R=E.cipherSuites||null;if(R===null){R=[];for(var N in a.CipherSuites)R.push(a.CipherSuites[N])}var u=E.server?a.ConnectionEnd.server:a.ConnectionEnd.client,I=E.sessionCache?a.createSessionCache(E.sessionCache):null,O={version:{major:a.Version.major,minor:a.Version.minor},entity:u,sessionId:E.sessionId,caStore:L,sessionCache:I,cipherSuites:R,connected:E.connected,virtualHost:E.virtualHost||null,verifyClient:E.verifyClient||!1,verify:E.verify||function(z,Q,Z,ye){return Q},verifyOptions:E.verifyOptions||{},getCertificate:E.getCertificate||null,getPrivateKey:E.getPrivateKey||null,getSignature:E.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:E.tlsDataReady,dataReady:E.dataReady,heartbeatReceived:E.heartbeatReceived,closed:E.closed,error:function(z,Q){Q.origin=Q.origin||(z.entity===a.ConnectionEnd.client?"client":"server"),Q.send&&(a.queue(z,a.createAlert(z,Q.alert)),a.flush(z));var Z=Q.fatal!==!1;Z&&(z.fail=!0),E.error(z,Q),Z&&z.close(!1)},deflate:E.deflate||null,inflate:E.inflate||null};O.reset=function(z){O.version={major:a.Version.major,minor:a.Version.minor},O.record=null,O.session=null,O.peerCertificate=null,O.state={pending:null,current:null},O.expect=O.entity===a.ConnectionEnd.client?g:o,O.fragmented=null,O.records=[],O.open=!1,O.handshakes=0,O.handshaking=!1,O.isConnected=!1,O.fail=!(z||typeof z>"u"),O.input.clear(),O.tlsData.clear(),O.data.clear(),O.state.current=a.createConnectionState(O)},O.reset();var G=function(z,Q){var Z=Q.type-a.ContentType.change_cipher_spec,ye=q[z.entity][z.expect];Z in ye?ye[Z](z,Q):a.handleUnexpected(z,Q)},ne=function(z){var Q=0,Z=z.input,ye=Z.length();if(ye<5)Q=5-ye;else{z.record={type:Z.getByte(),version:{major:Z.getByte(),minor:Z.getByte()},length:Z.getInt16(),fragment:t.util.createBuffer(),ready:!1};var pe=z.record.version.major===z.version.major;pe&&z.session&&z.session.version&&(pe=z.record.version.minor===z.version.minor),pe||z.error(z,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}})}return Q},te=function(z){var Q=0,Z=z.input,ye=Z.length();if(ye<z.record.length)Q=z.record.length-ye;else{z.record.fragment.putBytes(Z.getBytes(z.record.length)),Z.compact();var pe=z.state.current.read;pe.update(z,z.record)&&(z.fragmented!==null&&(z.fragmented.type===z.record.type?(z.fragmented.fragment.putBuffer(z.record.fragment),z.record=z.fragmented):z.error(z,{message:"Invalid fragmented record.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unexpected_message}})),z.record.ready=!0)}return Q};return O.handshake=function(z){if(O.entity!==a.ConnectionEnd.client)O.error(O,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(O.handshaking)O.error(O,{message:"Handshake already in progress.",fatal:!1});else{O.fail&&!O.open&&O.handshakes===0&&(O.fail=!1),O.handshaking=!0,z=z||"";var Q=null;z.length>0&&(O.sessionCache&&(Q=O.sessionCache.getSession(z)),Q===null&&(z="")),z.length===0&&O.sessionCache&&(Q=O.sessionCache.getSession(),Q!==null&&(z=Q.id)),O.session={id:z,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:t.md.md5.create(),sha1:t.md.sha1.create()},Q&&(O.version=Q.version,O.session.sp=Q.sp),O.session.sp.client_random=a.createRandom().getBytes(),O.open=!0,a.queue(O,a.createRecord(O,{type:a.ContentType.handshake,data:a.createClientHello(O)})),a.flush(O)}},O.process=function(z){var Q=0;return z&&O.input.putBytes(z),O.fail||(O.record!==null&&O.record.ready&&O.record.fragment.isEmpty()&&(O.record=null),O.record===null&&(Q=ne(O)),!O.fail&&O.record!==null&&!O.record.ready&&(Q=te(O)),!O.fail&&O.record!==null&&O.record.ready&&G(O,O.record)),Q},O.prepare=function(z){return a.queue(O,a.createRecord(O,{type:a.ContentType.application_data,data:t.util.createBuffer(z)})),a.flush(O)},O.prepareHeartbeatRequest=function(z,Q){return z instanceof t.util.ByteBuffer&&(z=z.bytes()),typeof Q>"u"&&(Q=z.length),O.expectedHeartbeatPayload=z,a.queue(O,a.createRecord(O,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_request,z,Q)})),a.flush(O)},O.close=function(z){if(!O.fail&&O.sessionCache&&O.session){var Q={id:O.session.id,version:O.session.version,sp:O.session.sp};Q.sp.keys=null,O.sessionCache.setSession(Q.id,Q)}O.open&&(O.open=!1,O.input.clear(),(O.isConnected||O.handshaking)&&(O.isConnected=O.handshaking=!1,a.queue(O,a.createAlert(O,{level:a.Alert.Level.warning,description:a.Alert.Description.close_notify})),a.flush(O)),O.closed(O)),O.reset(z)},O},Wr=t.tls=t.tls||{};for(var Be in a)typeof a[Be]!="function"&&(t.tls[Be]=a[Be]);return t.tls.prf_tls1=e,t.tls.hmac_sha1=r,t.tls.createSessionCache=a.createSessionCache,t.tls.createConnection=a.createConnection,Wr}var vn;function Ys(){if(vn)return Tr.exports;vn=1;var t=ve();Dt(),di();var e=Tr.exports=t.tls;e.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,g.cipher_type=e.CipherType.block,g.enc_key_length=16,g.block_length=16,g.fixed_iv_length=16,g.record_iv_length=16,g.mac_algorithm=e.MACAlgorithm.hmac_sha1,g.mac_length=20,g.mac_key_length=20},initConnectionState:r},e.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,g.cipher_type=e.CipherType.block,g.enc_key_length=32,g.block_length=16,g.fixed_iv_length=16,g.record_iv_length=16,g.mac_algorithm=e.MACAlgorithm.hmac_sha1,g.mac_length=20,g.mac_key_length=20},initConnectionState:r};function r(g,f,S){var P=f.entity===t.tls.ConnectionEnd.client;g.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",P?S.keys.server_write_key:S.keys.client_write_key),iv:P?S.keys.server_write_IV:S.keys.client_write_IV},g.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",P?S.keys.client_write_key:S.keys.server_write_key),iv:P?S.keys.client_write_IV:S.keys.server_write_IV},g.read.cipherFunction=c,g.write.cipherFunction=i,g.read.macLength=g.write.macLength=S.mac_length,g.read.macFunction=g.write.macFunction=e.hmac_sha1}function i(g,f){var S=!1,P=f.macFunction(f.macKey,f.sequenceNumber,g);g.fragment.putBytes(P),f.updateSequenceNumber();var b;g.version.minor===e.Versions.TLS_1_0.minor?b=f.cipherState.init?null:f.cipherState.iv:b=t.random.getBytesSync(16),f.cipherState.init=!0;var l=f.cipherState.cipher;return l.start({iv:b}),g.version.minor>=e.Versions.TLS_1_1.minor&&l.output.putBytes(b),l.update(g.fragment),l.finish(d)&&(g.fragment=l.output,g.length=g.fragment.length(),S=!0),S}function d(g,f,S){if(!S){var P=g-f.length()%g;f.fillWithByte(P-1,P)}return!0}function v(g,f,S){var P=!0;if(S){for(var b=f.length(),l=f.last(),m=b-1-l;m<b-1;++m)P=P&&f.at(m)==l;P&&f.truncate(l+1)}return P}function c(g,f){var S=!1,P;g.version.minor===e.Versions.TLS_1_0.minor?P=f.cipherState.init?null:f.cipherState.iv:P=g.fragment.getBytes(16),f.cipherState.init=!0;var b=f.cipherState.cipher;b.start({iv:P}),b.update(g.fragment),S=b.finish(v);var l=f.macLength,m=t.random.getBytesSync(l),x=b.output.length();x>=l?(g.fragment=b.output.getBytes(x-l),m=b.output.getBytes(l)):g.fragment=b.output.getBytes(),g.fragment=t.util.createBuffer(g.fragment),g.length=g.fragment.length();var C=f.macFunction(f.macKey,f.sequenceNumber,g);return f.updateSequenceNumber(),S=a(f.macKey,m,C)&&S,S}function a(g,f,S){var P=t.hmac.create();return P.start("SHA1",g),P.update(f),f=P.digest().getBytes(),P.start(null,null),P.update(S),S=P.digest().getBytes(),f===S}return Tr.exports}var Yr={exports:{}},gn;function pi(){if(gn)return Yr.exports;gn=1;var t=ve();xt(),Ee();var e=Yr.exports=t.sha512=t.sha512||{};t.md.sha512=t.md.algorithms.sha512=e;var r=t.sha384=t.sha512.sha384=t.sha512.sha384||{};r.create=function(){return e.create("SHA-384")},t.md.sha384=t.md.algorithms.sha384=r,t.sha512.sha256=t.sha512.sha256||{create:function(){return e.create("SHA-512/256")}},t.md["sha512/256"]=t.md.algorithms["sha512/256"]=t.sha512.sha256,t.sha512.sha224=t.sha512.sha224||{create:function(){return e.create("SHA-512/224")}},t.md["sha512/224"]=t.md.algorithms["sha512/224"]=t.sha512.sha224,e.create=function(f){if(d||a(),typeof f>"u"&&(f="SHA-512"),!(f in c))throw new Error("Invalid SHA-512 algorithm: "+f);for(var S=c[f],P=null,b=t.util.createBuffer(),l=new Array(80),m=0;m<80;++m)l[m]=new Array(2);var x=64;switch(f){case"SHA-384":x=48;break;case"SHA-512/256":x=32;break;case"SHA-512/224":x=28;break}var C={algorithm:f.replace("-","").toLowerCase(),blockLength:128,digestLength:x,messageLength:0,fullMessageLength:null,messageLengthSize:16};return C.start=function(){C.messageLength=0,C.fullMessageLength=C.messageLength128=[];for(var o=C.messageLengthSize/4,h=0;h<o;++h)C.fullMessageLength.push(0);b=t.util.createBuffer(),P=new Array(S.length);for(var h=0;h<S.length;++h)P[h]=S[h].slice(0);return C},C.start(),C.update=function(o,h){h==="utf8"&&(o=t.util.encodeUtf8(o));var y=o.length;C.messageLength+=y,y=[y/4294967296>>>0,y>>>0];for(var A=C.fullMessageLength.length-1;A>=0;--A)C.fullMessageLength[A]+=y[1],y[1]=y[0]+(C.fullMessageLength[A]/4294967296>>>0),C.fullMessageLength[A]=C.fullMessageLength[A]>>>0,y[0]=y[1]/4294967296>>>0;return b.putBytes(o),g(P,l,b),(b.read>2048||b.length()===0)&&b.compact(),C},C.digest=function(){var o=t.util.createBuffer();o.putBytes(b.bytes());var h=C.fullMessageLength[C.fullMessageLength.length-1]+C.messageLengthSize,y=h&C.blockLength-1;o.putBytes(i.substr(0,C.blockLength-y));for(var A,_,p=C.fullMessageLength[0]*8,s=0;s<C.fullMessageLength.length-1;++s)A=C.fullMessageLength[s+1]*8,_=A/4294967296>>>0,p+=_,o.putInt32(p>>>0),p=A>>>0;o.putInt32(p);for(var n=new Array(P.length),s=0;s<P.length;++s)n[s]=P[s].slice(0);g(n,l,o);var B=t.util.createBuffer(),D;f==="SHA-512"?D=n.length:f==="SHA-384"?D=n.length-2:D=n.length-4;for(var s=0;s<D;++s)B.putInt32(n[s][0]),(s!==D-1||f!=="SHA-512/224")&&B.putInt32(n[s][1]);return B},C};var i=null,d=!1,v=null,c=null;function a(){i="€",i+=t.util.fillString("\0",128),v=[[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]],c={},c["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],d=!0}function g(f,S,P){for(var b,l,m,x,C,o,h,y,A,_,p,s,n,B,D,V,U,F,q,M,H,W,j,J,ce,fe,me,be,he,X,ee,Ve,Be,E,L,R=P.length();R>=128;){for(he=0;he<16;++he)S[he][0]=P.getInt32()>>>0,S[he][1]=P.getInt32()>>>0;for(;he<80;++he)Ve=S[he-2],X=Ve[0],ee=Ve[1],b=((X>>>19|ee<<13)^(ee>>>29|X<<3)^X>>>6)>>>0,l=((X<<13|ee>>>19)^(ee<<3|X>>>29)^(X<<26|ee>>>6))>>>0,E=S[he-15],X=E[0],ee=E[1],m=((X>>>1|ee<<31)^(X>>>8|ee<<24)^X>>>7)>>>0,x=((X<<31|ee>>>1)^(X<<24|ee>>>8)^(X<<25|ee>>>7))>>>0,Be=S[he-7],L=S[he-16],ee=l+Be[1]+x+L[1],S[he][0]=b+Be[0]+m+L[0]+(ee/4294967296>>>0)>>>0,S[he][1]=ee>>>0;for(n=f[0][0],B=f[0][1],D=f[1][0],V=f[1][1],U=f[2][0],F=f[2][1],q=f[3][0],M=f[3][1],H=f[4][0],W=f[4][1],j=f[5][0],J=f[5][1],ce=f[6][0],fe=f[6][1],me=f[7][0],be=f[7][1],he=0;he<80;++he)h=((H>>>14|W<<18)^(H>>>18|W<<14)^(W>>>9|H<<23))>>>0,y=((H<<18|W>>>14)^(H<<14|W>>>18)^(W<<23|H>>>9))>>>0,A=(ce^H&(j^ce))>>>0,_=(fe^W&(J^fe))>>>0,C=((n>>>28|B<<4)^(B>>>2|n<<30)^(B>>>7|n<<25))>>>0,o=((n<<4|B>>>28)^(B<<30|n>>>2)^(B<<25|n>>>7))>>>0,p=(n&D|U&(n^D))>>>0,s=(B&V|F&(B^V))>>>0,ee=be+y+_+v[he][1]+S[he][1],b=me+h+A+v[he][0]+S[he][0]+(ee/4294967296>>>0)>>>0,l=ee>>>0,ee=o+s,m=C+p+(ee/4294967296>>>0)>>>0,x=ee>>>0,me=ce,be=fe,ce=j,fe=J,j=H,J=W,ee=M+l,H=q+b+(ee/4294967296>>>0)>>>0,W=ee>>>0,q=U,M=F,U=D,F=V,D=n,V=B,ee=l+x,n=b+m+(ee/4294967296>>>0)>>>0,B=ee>>>0;ee=f[0][1]+B,f[0][0]=f[0][0]+n+(ee/4294967296>>>0)>>>0,f[0][1]=ee>>>0,ee=f[1][1]+V,f[1][0]=f[1][0]+D+(ee/4294967296>>>0)>>>0,f[1][1]=ee>>>0,ee=f[2][1]+F,f[2][0]=f[2][0]+U+(ee/4294967296>>>0)>>>0,f[2][1]=ee>>>0,ee=f[3][1]+M,f[3][0]=f[3][0]+q+(ee/4294967296>>>0)>>>0,f[3][1]=ee>>>0,ee=f[4][1]+W,f[4][0]=f[4][0]+H+(ee/4294967296>>>0)>>>0,f[4][1]=ee>>>0,ee=f[5][1]+J,f[5][0]=f[5][0]+j+(ee/4294967296>>>0)>>>0,f[5][1]=ee>>>0,ee=f[6][1]+fe,f[6][0]=f[6][0]+ce+(ee/4294967296>>>0)>>>0,f[6][1]=ee>>>0,ee=f[7][1]+be,f[7][0]=f[7][0]+me+(ee/4294967296>>>0)>>>0,f[7][1]=ee>>>0,R-=128}}return Yr.exports}var er={},yn;function js(){if(yn)return er;yn=1;var t=ve();gt();var e=t.asn1;return er.privateKeyValidator={name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},er.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]},er}var jr,mn;function Xs(){if(mn)return jr;mn=1;var t=ve();lr(),pt(),pi(),Ee();var e=js(),r=e.publicKeyValidator,i=e.privateKeyValidator;if(typeof d>"u")var d=t.jsbn.BigInteger;var v=t.util.ByteBuffer,c=typeof Buffer>"u"?Uint8Array:Buffer;t.pki=t.pki||{},jr=t.pki.ed25519=t.ed25519=t.ed25519||{};var a=t.ed25519;a.constants={},a.constants.PUBLIC_KEY_BYTE_LENGTH=32,a.constants.PRIVATE_KEY_BYTE_LENGTH=64,a.constants.SEED_BYTE_LENGTH=32,a.constants.SIGN_BYTE_LENGTH=64,a.constants.HASH_BYTE_LENGTH=64,a.generateKeyPair=function(L){L=L||{};var R=L.seed;if(R===void 0)R=t.random.getBytesSync(a.constants.SEED_BYTE_LENGTH);else if(typeof R=="string"){if(R.length!==a.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+a.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(R instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');R=g({message:R,encoding:"binary"});for(var N=new c(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=new c(a.constants.PRIVATE_KEY_BYTE_LENGTH),I=0;I<32;++I)u[I]=R[I];return h(N,u),{publicKey:N,privateKey:u}},a.privateKeyFromAsn1=function(L){var R={},N=[],u=t.asn1.validate(L,i,R,N);if(!u){var I=new Error("Invalid Key.");throw I.errors=N,I}var O=t.asn1.derToOid(R.privateKeyOid),G=t.oids.EdDSA25519;if(O!==G)throw new Error('Invalid OID "'+O+'"; OID must be "'+G+'".');var ne=R.privateKey,te=g({message:t.asn1.fromDer(ne).value,encoding:"binary"});return{privateKeyBytes:te}},a.publicKeyFromAsn1=function(L){var R={},N=[],u=t.asn1.validate(L,r,R,N);if(!u){var I=new Error("Invalid Key.");throw I.errors=N,I}var O=t.asn1.derToOid(R.publicKeyOid),G=t.oids.EdDSA25519;if(O!==G)throw new Error('Invalid OID "'+O+'"; OID must be "'+G+'".');var ne=R.ed25519PublicKey;if(ne.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return g({message:ne,encoding:"binary"})},a.publicKeyFromPrivateKey=function(L){L=L||{};var R=g({message:L.privateKey,encoding:"binary"});if(R.length!==a.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+a.constants.PRIVATE_KEY_BYTE_LENGTH);for(var N=new c(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=0;u<N.length;++u)N[u]=R[32+u];return N},a.sign=function(L){L=L||{};var R=g(L),N=g({message:L.privateKey,encoding:"binary"});if(N.length===a.constants.SEED_BYTE_LENGTH){var u=a.generateKeyPair({seed:N});N=u.privateKey}else if(N.length!==a.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+a.constants.SEED_BYTE_LENGTH+" or "+a.constants.PRIVATE_KEY_BYTE_LENGTH);var I=new c(a.constants.SIGN_BYTE_LENGTH+R.length);y(I,R,R.length,N);for(var O=new c(a.constants.SIGN_BYTE_LENGTH),G=0;G<O.length;++G)O[G]=I[G];return O},a.verify=function(L){L=L||{};var R=g(L);if(L.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var N=g({message:L.signature,encoding:"binary"});if(N.length!==a.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+a.constants.SIGN_BYTE_LENGTH);var u=g({message:L.publicKey,encoding:"binary"});if(u.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+a.constants.PUBLIC_KEY_BYTE_LENGTH);var I=new c(a.constants.SIGN_BYTE_LENGTH+R.length),O=new c(a.constants.SIGN_BYTE_LENGTH+R.length),G;for(G=0;G<a.constants.SIGN_BYTE_LENGTH;++G)I[G]=N[G];for(G=0;G<R.length;++G)I[G+a.constants.SIGN_BYTE_LENGTH]=R[G];return A(O,I,I.length,u)>=0};function g(L){var R=L.message;if(R instanceof Uint8Array||R instanceof c)return R;var N=L.encoding;if(R===void 0)if(L.md)R=L.md.digest().getBytes(),N="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof R=="string"&&!N)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof R=="string"){if(typeof Buffer<"u")return Buffer.from(R,N);R=new v(R,N)}else if(!(R instanceof v))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var u=new c(R.length()),I=0;I<u.length;++I)u[I]=R.at(I);return u}var f=X(),S=X([1]),P=X([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=X([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=X([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=X([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),x=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]),C=X([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function o(L,R){var N=t.md.sha512.create(),u=new v(L);N.update(u.getBytes(R),"binary");var I=N.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(I,"binary");for(var O=new c(a.constants.HASH_BYTE_LENGTH),G=0;G<64;++G)O[G]=I.charCodeAt(G);return O}function h(L,R){var N=[X(),X(),X(),X()],u,I=o(R,32);for(I[0]&=248,I[31]&=127,I[31]|=64,ce(N,I),D(L,N),u=0;u<32;++u)R[u+32]=L[u];return 0}function y(L,R,N,u){var I,O,G=new Float64Array(64),ne=[X(),X(),X(),X()],te=o(u,32);te[0]&=248,te[31]&=127,te[31]|=64;var z=N+64;for(I=0;I<N;++I)L[64+I]=R[I];for(I=0;I<32;++I)L[32+I]=te[32+I];var Q=o(L.subarray(32),N+32);for(s(Q),ce(ne,Q),D(L,ne),I=32;I<64;++I)L[I]=u[I];var Z=o(L,N+64);for(s(Z),I=32;I<64;++I)G[I]=0;for(I=0;I<32;++I)G[I]=Q[I];for(I=0;I<32;++I)for(O=0;O<32;O++)G[I+O]+=Z[I]*te[O];return p(L.subarray(32),G),z}function A(L,R,N,u){var I,O,G=new c(32),ne=[X(),X(),X(),X()],te=[X(),X(),X(),X()];if(O=-1,N<64||U(te,u)||!_(R,32))return-1;for(I=0;I<N;++I)L[I]=R[I];for(I=0;I<32;++I)L[I+32]=u[I];var z=o(L,N);if(s(z),J(ne,te,z),ce(te,R.subarray(32)),n(ne,te),D(G,ne),N-=64,H(R,0,G,0)){for(I=0;I<N;++I)L[I]=0;return-1}for(I=0;I<N;++I)L[I]=R[I+64];return O=N,O}function _(L,R){var N;for(N=31;N>=0;--N){if(L[R+N]<x[N])return!0;if(L[R+N]>x[N])return!1}return!1}function p(L,R){var N,u,I,O;for(u=63;u>=32;--u){for(N=0,I=u-32,O=u-12;I<O;++I)R[I]+=N-16*R[u]*x[I-(u-32)],N=R[I]+128>>8,R[I]-=N*256;R[I]+=N,R[u]=0}for(N=0,I=0;I<32;++I)R[I]+=N-(R[31]>>4)*x[I],N=R[I]>>8,R[I]&=255;for(I=0;I<32;++I)R[I]-=N*x[I];for(u=0;u<32;++u)R[u+1]+=R[u]>>8,L[u]=R[u]&255}function s(L){for(var R=new Float64Array(64),N=0;N<64;++N)R[N]=L[N],L[N]=0;p(L,R)}function n(L,R){var N=X(),u=X(),I=X(),O=X(),G=X(),ne=X(),te=X(),z=X(),Q=X();Ve(N,L[1],L[0]),Ve(Q,R[1],R[0]),E(N,N,Q),ee(u,L[0],L[1]),ee(Q,R[0],R[1]),E(u,u,Q),E(I,L[3],R[3]),E(I,I,b),E(O,L[2],R[2]),ee(O,O,O),Ve(G,u,N),Ve(ne,O,I),ee(te,O,I),ee(z,u,N),E(L[0],G,ne),E(L[1],z,te),E(L[2],te,ne),E(L[3],G,z)}function B(L,R,N){for(var u=0;u<4;++u)he(L[u],R[u],N)}function D(L,R){var N=X(),u=X(),I=X();me(I,R[2]),E(N,R[0],I),E(u,R[1],I),V(L,u),L[31]^=j(N)<<7}function V(L,R){var N,u,I,O=X(),G=X();for(N=0;N<16;++N)G[N]=R[N];for(be(G),be(G),be(G),u=0;u<2;++u){for(O[0]=G[0]-65517,N=1;N<15;++N)O[N]=G[N]-65535-(O[N-1]>>16&1),O[N-1]&=65535;O[15]=G[15]-32767-(O[14]>>16&1),I=O[15]>>16&1,O[14]&=65535,he(G,O,1-I)}for(N=0;N<16;N++)L[2*N]=G[N]&255,L[2*N+1]=G[N]>>8}function U(L,R){var N=X(),u=X(),I=X(),O=X(),G=X(),ne=X(),te=X();return fe(L[2],S),F(L[1],R),Be(I,L[1]),E(O,I,P),Ve(I,I,L[2]),ee(O,L[2],O),Be(G,O),Be(ne,G),E(te,ne,G),E(N,te,I),E(N,N,O),q(N,N),E(N,N,I),E(N,N,O),E(N,N,O),E(L[0],N,O),Be(u,L[0]),E(u,u,O),M(u,I)&&E(L[0],L[0],C),Be(u,L[0]),E(u,u,O),M(u,I)?-1:(j(L[0])===R[31]>>7&&Ve(L[0],f,L[0]),E(L[3],L[0],L[1]),0)}function F(L,R){var N;for(N=0;N<16;++N)L[N]=R[2*N]+(R[2*N+1]<<8);L[15]&=32767}function q(L,R){var N=X(),u;for(u=0;u<16;++u)N[u]=R[u];for(u=250;u>=0;--u)Be(N,N),u!==1&&E(N,N,R);for(u=0;u<16;++u)L[u]=N[u]}function M(L,R){var N=new c(32),u=new c(32);return V(N,L),V(u,R),H(N,0,u,0)}function H(L,R,N,u){return W(L,R,N,u,32)}function W(L,R,N,u,I){var O,G=0;for(O=0;O<I;++O)G|=L[R+O]^N[u+O];return(1&G-1>>>8)-1}function j(L){var R=new c(32);return V(R,L),R[0]&1}function J(L,R,N){var u,I;for(fe(L[0],f),fe(L[1],S),fe(L[2],S),fe(L[3],f),I=255;I>=0;--I)u=N[I/8|0]>>(I&7)&1,B(L,R,u),n(R,L),n(L,L),B(L,R,u)}function ce(L,R){var N=[X(),X(),X(),X()];fe(N[0],l),fe(N[1],m),fe(N[2],S),E(N[3],l,m),J(L,N,R)}function fe(L,R){var N;for(N=0;N<16;N++)L[N]=R[N]|0}function me(L,R){var N=X(),u;for(u=0;u<16;++u)N[u]=R[u];for(u=253;u>=0;--u)Be(N,N),u!==2&&u!==4&&E(N,N,R);for(u=0;u<16;++u)L[u]=N[u]}function be(L){var R,N,u=1;for(R=0;R<16;++R)N=L[R]+u+65535,u=Math.floor(N/65536),L[R]=N-u*65536;L[0]+=u-1+37*(u-1)}function he(L,R,N){for(var u,I=~(N-1),O=0;O<16;++O)u=I&(L[O]^R[O]),L[O]^=u,R[O]^=u}function X(L){var R,N=new Float64Array(16);if(L)for(R=0;R<L.length;++R)N[R]=L[R];return N}function ee(L,R,N){for(var u=0;u<16;++u)L[u]=R[u]+N[u]}function Ve(L,R,N){for(var u=0;u<16;++u)L[u]=R[u]-N[u]}function Be(L,R){E(L,R,R)}function E(L,R,N){var u,I,O=0,G=0,ne=0,te=0,z=0,Q=0,Z=0,ye=0,pe=0,Ce=0,Ue=0,Re=0,Te=0,Ae=0,Ie=0,ge=0,De=0,ke=0,Fe=0,Ke=0,je=0,Je=0,et=0,rt=0,st=0,ct=0,ht=0,yt=0,ae=0,se=0,ue=0,oe=N[0],de=N[1],xe=N[2],we=N[3],Le=N[4],Pe=N[5],Ne=N[6],Me=N[7],qe=N[8],He=N[9],Ge=N[10],ze=N[11],_e=N[12],Oe=N[13],Qe=N[14],$e=N[15];u=R[0],O+=u*oe,G+=u*de,ne+=u*xe,te+=u*we,z+=u*Le,Q+=u*Pe,Z+=u*Ne,ye+=u*Me,pe+=u*qe,Ce+=u*He,Ue+=u*Ge,Re+=u*ze,Te+=u*_e,Ae+=u*Oe,Ie+=u*Qe,ge+=u*$e,u=R[1],G+=u*oe,ne+=u*de,te+=u*xe,z+=u*we,Q+=u*Le,Z+=u*Pe,ye+=u*Ne,pe+=u*Me,Ce+=u*qe,Ue+=u*He,Re+=u*Ge,Te+=u*ze,Ae+=u*_e,Ie+=u*Oe,ge+=u*Qe,De+=u*$e,u=R[2],ne+=u*oe,te+=u*de,z+=u*xe,Q+=u*we,Z+=u*Le,ye+=u*Pe,pe+=u*Ne,Ce+=u*Me,Ue+=u*qe,Re+=u*He,Te+=u*Ge,Ae+=u*ze,Ie+=u*_e,ge+=u*Oe,De+=u*Qe,ke+=u*$e,u=R[3],te+=u*oe,z+=u*de,Q+=u*xe,Z+=u*we,ye+=u*Le,pe+=u*Pe,Ce+=u*Ne,Ue+=u*Me,Re+=u*qe,Te+=u*He,Ae+=u*Ge,Ie+=u*ze,ge+=u*_e,De+=u*Oe,ke+=u*Qe,Fe+=u*$e,u=R[4],z+=u*oe,Q+=u*de,Z+=u*xe,ye+=u*we,pe+=u*Le,Ce+=u*Pe,Ue+=u*Ne,Re+=u*Me,Te+=u*qe,Ae+=u*He,Ie+=u*Ge,ge+=u*ze,De+=u*_e,ke+=u*Oe,Fe+=u*Qe,Ke+=u*$e,u=R[5],Q+=u*oe,Z+=u*de,ye+=u*xe,pe+=u*we,Ce+=u*Le,Ue+=u*Pe,Re+=u*Ne,Te+=u*Me,Ae+=u*qe,Ie+=u*He,ge+=u*Ge,De+=u*ze,ke+=u*_e,Fe+=u*Oe,Ke+=u*Qe,je+=u*$e,u=R[6],Z+=u*oe,ye+=u*de,pe+=u*xe,Ce+=u*we,Ue+=u*Le,Re+=u*Pe,Te+=u*Ne,Ae+=u*Me,Ie+=u*qe,ge+=u*He,De+=u*Ge,ke+=u*ze,Fe+=u*_e,Ke+=u*Oe,je+=u*Qe,Je+=u*$e,u=R[7],ye+=u*oe,pe+=u*de,Ce+=u*xe,Ue+=u*we,Re+=u*Le,Te+=u*Pe,Ae+=u*Ne,Ie+=u*Me,ge+=u*qe,De+=u*He,ke+=u*Ge,Fe+=u*ze,Ke+=u*_e,je+=u*Oe,Je+=u*Qe,et+=u*$e,u=R[8],pe+=u*oe,Ce+=u*de,Ue+=u*xe,Re+=u*we,Te+=u*Le,Ae+=u*Pe,Ie+=u*Ne,ge+=u*Me,De+=u*qe,ke+=u*He,Fe+=u*Ge,Ke+=u*ze,je+=u*_e,Je+=u*Oe,et+=u*Qe,rt+=u*$e,u=R[9],Ce+=u*oe,Ue+=u*de,Re+=u*xe,Te+=u*we,Ae+=u*Le,Ie+=u*Pe,ge+=u*Ne,De+=u*Me,ke+=u*qe,Fe+=u*He,Ke+=u*Ge,je+=u*ze,Je+=u*_e,et+=u*Oe,rt+=u*Qe,st+=u*$e,u=R[10],Ue+=u*oe,Re+=u*de,Te+=u*xe,Ae+=u*we,Ie+=u*Le,ge+=u*Pe,De+=u*Ne,ke+=u*Me,Fe+=u*qe,Ke+=u*He,je+=u*Ge,Je+=u*ze,et+=u*_e,rt+=u*Oe,st+=u*Qe,ct+=u*$e,u=R[11],Re+=u*oe,Te+=u*de,Ae+=u*xe,Ie+=u*we,ge+=u*Le,De+=u*Pe,ke+=u*Ne,Fe+=u*Me,Ke+=u*qe,je+=u*He,Je+=u*Ge,et+=u*ze,rt+=u*_e,st+=u*Oe,ct+=u*Qe,ht+=u*$e,u=R[12],Te+=u*oe,Ae+=u*de,Ie+=u*xe,ge+=u*we,De+=u*Le,ke+=u*Pe,Fe+=u*Ne,Ke+=u*Me,je+=u*qe,Je+=u*He,et+=u*Ge,rt+=u*ze,st+=u*_e,ct+=u*Oe,ht+=u*Qe,yt+=u*$e,u=R[13],Ae+=u*oe,Ie+=u*de,ge+=u*xe,De+=u*we,ke+=u*Le,Fe+=u*Pe,Ke+=u*Ne,je+=u*Me,Je+=u*qe,et+=u*He,rt+=u*Ge,st+=u*ze,ct+=u*_e,ht+=u*Oe,yt+=u*Qe,ae+=u*$e,u=R[14],Ie+=u*oe,ge+=u*de,De+=u*xe,ke+=u*we,Fe+=u*Le,Ke+=u*Pe,je+=u*Ne,Je+=u*Me,et+=u*qe,rt+=u*He,st+=u*Ge,ct+=u*ze,ht+=u*_e,yt+=u*Oe,ae+=u*Qe,se+=u*$e,u=R[15],ge+=u*oe,De+=u*de,ke+=u*xe,Fe+=u*we,Ke+=u*Le,je+=u*Pe,Je+=u*Ne,et+=u*Me,rt+=u*qe,st+=u*He,ct+=u*Ge,ht+=u*ze,yt+=u*_e,ae+=u*Oe,se+=u*Qe,ue+=u*$e,O+=38*De,G+=38*ke,ne+=38*Fe,te+=38*Ke,z+=38*je,Q+=38*Je,Z+=38*et,ye+=38*rt,pe+=38*st,Ce+=38*ct,Ue+=38*ht,Re+=38*yt,Te+=38*ae,Ae+=38*se,Ie+=38*ue,I=1,u=O+I+65535,I=Math.floor(u/65536),O=u-I*65536,u=G+I+65535,I=Math.floor(u/65536),G=u-I*65536,u=ne+I+65535,I=Math.floor(u/65536),ne=u-I*65536,u=te+I+65535,I=Math.floor(u/65536),te=u-I*65536,u=z+I+65535,I=Math.floor(u/65536),z=u-I*65536,u=Q+I+65535,I=Math.floor(u/65536),Q=u-I*65536,u=Z+I+65535,I=Math.floor(u/65536),Z=u-I*65536,u=ye+I+65535,I=Math.floor(u/65536),ye=u-I*65536,u=pe+I+65535,I=Math.floor(u/65536),pe=u-I*65536,u=Ce+I+65535,I=Math.floor(u/65536),Ce=u-I*65536,u=Ue+I+65535,I=Math.floor(u/65536),Ue=u-I*65536,u=Re+I+65535,I=Math.floor(u/65536),Re=u-I*65536,u=Te+I+65535,I=Math.floor(u/65536),Te=u-I*65536,u=Ae+I+65535,I=Math.floor(u/65536),Ae=u-I*65536,u=Ie+I+65535,I=Math.floor(u/65536),Ie=u-I*65536,u=ge+I+65535,I=Math.floor(u/65536),ge=u-I*65536,O+=I-1+37*(I-1),I=1,u=O+I+65535,I=Math.floor(u/65536),O=u-I*65536,u=G+I+65535,I=Math.floor(u/65536),G=u-I*65536,u=ne+I+65535,I=Math.floor(u/65536),ne=u-I*65536,u=te+I+65535,I=Math.floor(u/65536),te=u-I*65536,u=z+I+65535,I=Math.floor(u/65536),z=u-I*65536,u=Q+I+65535,I=Math.floor(u/65536),Q=u-I*65536,u=Z+I+65535,I=Math.floor(u/65536),Z=u-I*65536,u=ye+I+65535,I=Math.floor(u/65536),ye=u-I*65536,u=pe+I+65535,I=Math.floor(u/65536),pe=u-I*65536,u=Ce+I+65535,I=Math.floor(u/65536),Ce=u-I*65536,u=Ue+I+65535,I=Math.floor(u/65536),Ue=u-I*65536,u=Re+I+65535,I=Math.floor(u/65536),Re=u-I*65536,u=Te+I+65535,I=Math.floor(u/65536),Te=u-I*65536,u=Ae+I+65535,I=Math.floor(u/65536),Ae=u-I*65536,u=Ie+I+65535,I=Math.floor(u/65536),Ie=u-I*65536,u=ge+I+65535,I=Math.floor(u/65536),ge=u-I*65536,O+=I-1+37*(I-1),L[0]=O,L[1]=G,L[2]=ne,L[3]=te,L[4]=z,L[5]=Q,L[6]=Z,L[7]=ye,L[8]=pe,L[9]=Ce,L[10]=Ue,L[11]=Re,L[12]=Te,L[13]=Ae,L[14]=Ie,L[15]=ge}return jr}var Xr,Cn;function Zs(){if(Cn)return Xr;Cn=1;var t=ve();Ee(),pt(),lr(),Xr=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(i,d){d=d||{};var v=d.prng||t.random,c={};return c.encrypt=function(a,g){var f=Math.ceil(a.n.bitLength()/8),S;do S=new e(t.util.bytesToHex(v.getBytesSync(f)),16).mod(a.n);while(S.compareTo(e.ONE)<=0);S=t.util.hexToBytes(S.toString(16));var P=f-S.length;P>0&&(S=t.util.fillString("\0",P)+S);var b=a.encrypt(S,"NONE"),l=i.generate(S,g);return{encapsulation:b,key:l}},c.decrypt=function(a,g,f){var S=a.decrypt(g,"NONE");return i.generate(S,f)},c},t.kem.kdf1=function(i,d){r(this,i,0,d||i.digestLength)},t.kem.kdf2=function(i,d){r(this,i,1,d||i.digestLength)};function r(i,d,v,c){i.generate=function(a,g){for(var f=new t.util.ByteBuffer,S=Math.ceil(g/c)+v,P=new t.util.ByteBuffer,b=v;b<S;++b){P.putInt32(b),d.start(),d.update(a+P.getBytes());var l=d.digest();f.putBytes(l.getBytes(c))}return f.truncate(f.length()-g),f.getBytes()}}return Xr}var Zr,En;function Js(){if(En)return Zr;En=1;var t=ve();Ee(),Zr=t.log=t.log||{},t.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},r=[],i=null;t.log.LEVEL_LOCKED=2,t.log.NO_LEVEL_CHECK=4,t.log.INTERPOLATE=8;for(var d=0;d<t.log.levels.length;++d){var v=t.log.levels[d];e[v]={index:d,name:v.toUpperCase()}}t.log.logMessage=function(b){for(var l=e[b.level].index,m=0;m<r.length;++m){var x=r[m];if(x.flags&t.log.NO_LEVEL_CHECK)x.f(b);else{var C=e[x.level].index;l<=C&&x.f(x,b)}}},t.log.prepareStandard=function(b){"standard"in b||(b.standard=e[b.level].name+" ["+b.category+"] "+b.message)},t.log.prepareFull=function(b){if(!("full"in b)){var l=[b.message];l=l.concat([]),b.full=t.util.format.apply(this,l)}},t.log.prepareStandardFull=function(b){"standardFull"in b||(t.log.prepareStandard(b),b.standardFull=b.standard)};for(var c=["error","warning","info","debug","verbose"],d=0;d<c.length;++d)(function(l){t.log[l]=function(m,x){var C=Array.prototype.slice.call(arguments).slice(2),o={timestamp:new Date,level:l,category:m,message:x,arguments:C};t.log.logMessage(o)}})(c[d]);if(t.log.makeLogger=function(b){var l={flags:0,f:b};return t.log.setLevel(l,"none"),l},t.log.setLevel=function(b,l){var m=!1;if(b&&!(b.flags&t.log.LEVEL_LOCKED))for(var x=0;x<t.log.levels.length;++x){var C=t.log.levels[x];if(l==C){b.level=l,m=!0;break}}return m},t.log.lock=function(b,l){typeof l>"u"||l?b.flags|=t.log.LEVEL_LOCKED:b.flags&=~t.log.LEVEL_LOCKED},t.log.addLogger=function(b){r.push(b)},typeof console<"u"&&"log"in console){var a;if(console.error&&console.warn&&console.info&&console.debug){var g={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},f=function(b,l){t.log.prepareStandard(l);var m=g[l.level],x=[l.standard];x=x.concat(l.arguments.slice()),m.apply(console,x)};a=t.log.makeLogger(f)}else{var f=function(l,m){t.log.prepareStandardFull(m),console.log(m.standardFull)};a=t.log.makeLogger(f)}t.log.setLevel(a,"debug"),t.log.addLogger(a),i=a}else console={log:function(){}};if(i!==null&&typeof window<"u"&&window.location){var S=new URL(window.location.href).searchParams;if(S.has("console.level")&&t.log.setLevel(i,S.get("console.level").slice(-1)[0]),S.has("console.lock")){var P=S.get("console.lock").slice(-1)[0];P=="true"&&t.log.lock(i)}}return t.log.consoleLogger=i,Zr}var Jr,xn;function eo(){return xn||(xn=1,Jr=xt(),ma(),$t(),ri(),pi()),Jr}var ea={exports:{}},Sn;function to(){if(Sn)return ea.exports;Sn=1;var t=ve();Dt(),gt(),fr(),Lt(),Ot(),ci(),pt(),Ee(),Sa();var e=t.asn1,r=ea.exports=t.pkcs7=t.pkcs7||{};r.messageFromPem=function(l){var m=t.pem.decode(l)[0];if(m.type!=="PKCS7"){var x=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw x.headerType=m.type,x}if(m.procType&&m.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var C=e.fromDer(m.body);return r.messageFromAsn1(C)},r.messageToPem=function(l,m){var x={type:"PKCS7",body:e.toDer(l.toAsn1()).getBytes()};return t.pem.encode(x,{maxline:m})},r.messageFromAsn1=function(l){var m={},x=[];if(!e.validate(l,r.asn1.contentInfoValidator,m,x)){var C=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw C.errors=x,C}var o=e.derToOid(m.contentType),h;switch(o){case t.pki.oids.envelopedData:h=r.createEnvelopedData();break;case t.pki.oids.encryptedData:h=r.createEncryptedData();break;case t.pki.oids.signedData:h=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+o+" is not (yet) supported.")}return h.fromAsn1(m.content.value[0]),h},r.createSignedData=function(){var l=null;return l={type:t.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(C){if(P(l,C,r.asn1.signedDataValidator),l.certificates=[],l.crls=[],l.digestAlgorithmIdentifiers=[],l.contentInfo=null,l.signerInfos=[],l.rawCapture.certificates)for(var o=l.rawCapture.certificates.value,h=0;h<o.length;++h)l.certificates.push(t.pki.certificateFromAsn1(o[h]))},toAsn1:function(){l.contentInfo||l.sign();for(var C=[],o=0;o<l.certificates.length;++o)C.push(t.pki.certificateToAsn1(l.certificates[o]));var h=[],y=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(l.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,l.digestAlgorithmIdentifiers),l.contentInfo])]);return C.length>0&&y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,C)),h.length>0&&y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,h)),y.value[0].value.push(e.create(e.Class.UNIVERSAL,e.Type.SET,!0,l.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.type).getBytes()),y])},addSigner:function(C){var o=C.issuer,h=C.serialNumber;if(C.certificate){var y=C.certificate;typeof y=="string"&&(y=t.pki.certificateFromPem(y)),o=y.issuer.attributes,h=y.serialNumber}var A=C.key;if(!A)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof A=="string"&&(A=t.pki.privateKeyFromPem(A));var _=C.digestAlgorithm||t.pki.oids.sha1;switch(_){case t.pki.oids.sha1:case t.pki.oids.sha256:case t.pki.oids.sha384:case t.pki.oids.sha512:case t.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+_)}var p=C.authenticatedAttributes||[];if(p.length>0){for(var s=!1,n=!1,B=0;B<p.length;++B){var D=p[B];if(!s&&D.type===t.pki.oids.contentType){if(s=!0,n)break;continue}if(!n&&D.type===t.pki.oids.messageDigest){if(n=!0,s)break;continue}}if(!s||!n)throw new 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.")}l.signers.push({key:A,version:1,issuer:o,serialNumber:h,digestAlgorithm:_,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:p,unauthenticatedAttributes:[]})},sign:function(C){if(C=C||{},(typeof l.content!="object"||l.contentInfo===null)&&(l.contentInfo=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes())]),"content"in l)){var o;l.content instanceof t.util.ByteBuffer?o=l.content.bytes():typeof l.content=="string"&&(o=t.util.encodeUtf8(l.content)),C.detached?l.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,o):l.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,o)]))}if(l.signers.length!==0){var h=m();x(h)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(C){typeof C=="string"&&(C=t.pki.certificateFromPem(C)),l.certificates.push(C)},addCertificateRevokationList:function(C){throw new Error("PKCS#7 CRL support not yet implemented.")}},l;function m(){for(var C={},o=0;o<l.signers.length;++o){var h=l.signers[o],y=h.digestAlgorithm;y in C||(C[y]=t.md[t.pki.oids[y]].create()),h.authenticatedAttributes.length===0?h.md=C[y]:h.md=t.md[t.pki.oids[y]].create()}l.digestAlgorithmIdentifiers=[];for(var y in C)l.digestAlgorithmIdentifiers.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(y).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]));return C}function x(C){var o;if(l.detachedContent?o=l.detachedContent:(o=l.contentInfo.value[1],o=o.value[0]),!o)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var h=e.derToOid(l.contentInfo.value[0].value),y=e.toDer(o);y.getByte(),e.getBerValueLength(y),y=y.getBytes();for(var A in C)C[A].start().update(y);for(var _=new Date,p=0;p<l.signers.length;++p){var s=l.signers[p];if(s.authenticatedAttributes.length===0){if(h!==t.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{s.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var n=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]),B=0;B<s.authenticatedAttributes.length;++B){var D=s.authenticatedAttributes[B];D.type===t.pki.oids.messageDigest?D.value=C[s.digestAlgorithm].digest():D.type===t.pki.oids.signingTime&&(D.value||(D.value=_)),n.value.push(f(D)),s.authenticatedAttributesAsn1.value.push(f(D))}y=e.toDer(n).getBytes(),s.md.start().update(y)}s.signature=s.key.sign(s.md,"RSASSA-PKCS1-V1_5")}l.signerInfos=g(l.signers)}},r.createEncryptedData=function(){var l=null;return l={type:t.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){P(l,m,r.asn1.encryptedDataValidator)},decrypt:function(m){m!==void 0&&(l.encryptedContent.key=m),b(l)}},l},r.createEnvelopedData=function(){var l=null;return l={type:t.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){var x=P(l,m,r.asn1.envelopedDataValidator);l.recipients=v(x.recipientInfos.value)},toAsn1:function(){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.type).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(l.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c(l.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,S(l.encryptedContent))])])])},findRecipient:function(m){for(var x=m.issuer.attributes,C=0;C<l.recipients.length;++C){var o=l.recipients[C],h=o.issuer;if(o.serialNumber===m.serialNumber&&h.length===x.length){for(var y=!0,A=0;A<x.length;++A)if(h[A].type!==x[A].type||h[A].value!==x[A].value){y=!1;break}if(y)return o}}return null},decrypt:function(m,x){if(l.encryptedContent.key===void 0&&m!==void 0&&x!==void 0)switch(m.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var C=x.decrypt(m.encryptedContent.content);l.encryptedContent.key=t.util.createBuffer(C);break;default:throw new Error("Unsupported asymmetric cipher, OID "+m.encryptedContent.algorithm)}b(l)},addRecipient:function(m){l.recipients.push({version:0,issuer:m.issuer.attributes,serialNumber:m.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:m.publicKey}})},encrypt:function(m,x){if(l.encryptedContent.content===void 0){x=x||l.encryptedContent.algorithm,m=m||l.encryptedContent.key;var C,o,h;switch(x){case t.pki.oids["aes128-CBC"]:C=16,o=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes192-CBC"]:C=24,o=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes256-CBC"]:C=32,o=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["des-EDE3-CBC"]:C=24,o=8,h=t.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+x)}if(m===void 0)m=t.util.createBuffer(t.random.getBytes(C));else if(m.length()!=C)throw new Error("Symmetric key has wrong length; got "+m.length()+" bytes, expected "+C+".");l.encryptedContent.algorithm=x,l.encryptedContent.key=m,l.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(o));var y=h(m);if(y.start(l.encryptedContent.parameter.copy()),y.update(l.content),!y.finish())throw new Error("Symmetric encryption failed.");l.encryptedContent.content=y.output}for(var A=0;A<l.recipients.length;++A){var _=l.recipients[A];if(_.encryptedContent.content===void 0)switch(_.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:_.encryptedContent.content=_.encryptedContent.key.encrypt(l.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+_.encryptedContent.algorithm)}}}},l};function i(l){var m={},x=[];if(!e.validate(l,r.asn1.recipientInfoValidator,m,x)){var C=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw C.errors=x,C}return{version:m.version.charCodeAt(0),issuer:t.pki.RDNAttributesAsArray(m.issuer),serialNumber:t.util.createBuffer(m.serial).toHex(),encryptedContent:{algorithm:e.derToOid(m.encAlgorithm),parameter:m.encParameter?m.encParameter.value:void 0,content:m.encKey}}}function d(l){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(l.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:l.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(l.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,l.encryptedContent.content)])}function v(l){for(var m=[],x=0;x<l.length;++x)m.push(i(l[x]));return m}function c(l){for(var m=[],x=0;x<l.length;++x)m.push(d(l[x]));return m}function a(l){var m=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(l.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:l.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(l.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(l.authenticatedAttributesAsn1&&m.value.push(l.authenticatedAttributesAsn1),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,l.signature)),l.unauthenticatedAttributes.length>0){for(var x=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]),C=0;C<l.unauthenticatedAttributes.length;++C){var o=l.unauthenticatedAttributes[C];x.values.push(f(o))}m.value.push(x)}return m}function g(l){for(var m=[],x=0;x<l.length;++x)m.push(a(l[x]));return m}function f(l){var m;if(l.type===t.pki.oids.contentType)m=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.value).getBytes());else if(l.type===t.pki.oids.messageDigest)m=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,l.value.bytes());else if(l.type===t.pki.oids.signingTime){var x=new Date("1950-01-01T00:00:00Z"),C=new Date("2050-01-01T00:00:00Z"),o=l.value;if(typeof o=="string"){var h=Date.parse(o);isNaN(h)?o.length===13?o=e.utcTimeToDate(o):o=e.generalizedTimeToDate(o):o=new Date(h)}o>=x&&o<C?m=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(o)):m=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(o))}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[m])])}function S(l){return[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(l.algorithm).getBytes()),l.parameter?e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,l.parameter.getBytes()):void 0]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,l.content.getBytes())])]}function P(l,m,x){var C={},o=[];if(!e.validate(m,x,C,o)){var h=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw h.errors=h,h}var y=e.derToOid(C.contentType);if(y!==t.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(C.encryptedContent){var A="";if(t.util.isArray(C.encryptedContent))for(var _=0;_<C.encryptedContent.length;++_){if(C.encryptedContent[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");A+=C.encryptedContent[_].value}else A=C.encryptedContent;l.encryptedContent={algorithm:e.derToOid(C.encAlgorithm),parameter:t.util.createBuffer(C.encParameter.value),content:t.util.createBuffer(A)}}if(C.content){var A="";if(t.util.isArray(C.content))for(var _=0;_<C.content.length;++_){if(C.content[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");A+=C.content[_].value}else A=C.content;l.content=t.util.createBuffer(A)}return l.version=C.version.charCodeAt(0),l.rawCapture=C,C}function b(l){if(l.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(l.content===void 0){var m;switch(l.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:m=t.aes.createDecryptionCipher(l.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:m=t.des.createDecryptionCipher(l.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+l.encryptedContent.algorithm)}if(m.start(l.encryptedContent.parameter),m.update(l.encryptedContent.content),!m.finish())throw new Error("Symmetric decryption failed.");l.content=m.output}}return ea.exports}var ta={exports:{}},bn;function ro(){if(bn)return ta.exports;bn=1;var t=ve();Dt(),Qt(),ma(),$t(),Ee();var e=ta.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(v,c,a){a=a||"",c=c||"";var g="ssh-rsa",f=c===""?"none":"aes256-cbc",S="PuTTY-User-Key-File-2: "+g+`\r
15
+ `;S+="Encryption: "+f+`\r
16
+ `,S+="Comment: "+a+`\r
17
+ `;var P=t.util.createBuffer();i(P,g),r(P,v.e),r(P,v.n);var b=t.util.encode64(P.bytes(),64),l=Math.floor(b.length/66)+1;S+="Public-Lines: "+l+`\r
18
+ `,S+=b;var m=t.util.createBuffer();r(m,v.d),r(m,v.p),r(m,v.q),r(m,v.qInv);var x;if(!c)x=t.util.encode64(m.bytes(),64);else{var C=m.length()+16-1;C-=C%16;var o=d(m.bytes());o.truncate(o.length()-C+m.length()),m.putBuffer(o);var h=t.util.createBuffer();h.putBuffer(d("\0\0\0\0",c)),h.putBuffer(d("\0\0\0",c));var y=t.aes.createEncryptionCipher(h.truncate(8),"CBC");y.start(t.util.createBuffer().fillWithByte(0,16)),y.update(m.copy()),y.finish();var A=y.output;A.truncate(16),x=t.util.encode64(A.bytes(),64)}l=Math.floor(x.length/66)+1,S+=`\r
19
+ Private-Lines: `+l+`\r
20
+ `,S+=x;var _=d("putty-private-key-file-mac-key",c),p=t.util.createBuffer();i(p,g),i(p,f),i(p,a),p.putInt32(P.length()),p.putBuffer(P),p.putInt32(m.length()),p.putBuffer(m);var s=t.hmac.create();return s.start("sha1",_),s.update(p.bytes()),S+=`\r
21
+ Private-MAC: `+s.digest().toHex()+`\r
22
+ `,S},e.publicKeyToOpenSSH=function(v,c){var a="ssh-rsa";c=c||"";var g=t.util.createBuffer();return i(g,a),r(g,v.e),r(g,v.n),a+" "+t.util.encode64(g.bytes())+" "+c},e.privateKeyToOpenSSH=function(v,c){return c?t.pki.encryptRsaPrivateKey(v,c,{legacy:!0,algorithm:"aes128"}):t.pki.privateKeyToPem(v)},e.getPublicKeyFingerprint=function(v,c){c=c||{};var a=c.md||t.md.md5.create(),g="ssh-rsa",f=t.util.createBuffer();i(f,g),r(f,v.e),r(f,v.n),a.start(),a.update(f.getBytes());var S=a.digest();if(c.encoding==="hex"){var P=S.toHex();return c.delimiter?P.match(/.{2}/g).join(c.delimiter):P}else{if(c.encoding==="binary")return S.getBytes();if(c.encoding)throw new Error('Unknown encoding "'+c.encoding+'".')}return S};function r(v,c){var a=c.toString(16);a[0]>="8"&&(a="00"+a);var g=t.util.hexToBytes(a);v.putInt32(g.length),v.putBytes(g)}function i(v,c){v.putInt32(c.length),v.putString(c)}function d(){for(var v=t.md.sha1.create(),c=arguments.length,a=0;a<c;++a)v.update(arguments[a]);return v.digest()}return ta.exports}var ra,Tn;function ao(){return Tn||(Tn=1,ra=ve(),Dt(),Ys(),gt(),ya(),fr(),Xs(),Qt(),Zs(),Js(),eo(),ui(),Ea(),Ot(),ii(),fi(),to(),li(),si(),ai(),xa(),pt(),ni(),ro(),di(),Ee()),ra}var no=ao();const wt=Pn(no),io={name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"};async function hi(t){if(!crypto.subtle)throw new Error("WebCrypto is not available in this browser.");const e=await crypto.subtle.generateKey(io,!0,["sign","verify"]),r=new Uint8Array(await crypto.subtle.exportKey("spki",e.publicKey)),i=Ht(uo(0),so(t),r,co(0,new Uint8Array)),d=new Uint8Array(await crypto.subtle.sign("RSASSA-PKCS1-v1_5",e.privateKey,Eo(i))),v=Ht(i,Ht(gi("1.2.840.113549.1.1.11"),fo()),ho(d)),c=new Uint8Array(await crypto.subtle.exportKey("pkcs8",e.privateKey));return{privateKey:e.privateKey,privateKeyPKCS8Base64:rr(c),publicKeySPKIBase64:rr(r),csrPEM:go("CERTIFICATE REQUEST",v),csrBase64:rr(v)}}function vi(t){if(!t.certificateBase64&&!t.certificatePEM)throw new Error("certificateBase64 or certificatePEM is required.");const e=wt.pki.privateKeyFromPem(yo("PRIVATE KEY",t.privateKeyPKCS8Base64)),r=t.certificatePEM?wt.pki.certificateFromPem(t.certificatePEM):wt.pki.certificateFromAsn1(wt.asn1.fromDer(wt.util.createBuffer(Co(t.certificateBase64)))),i=wt.pkcs12.toPkcs12Asn1(e,[r],t.password,{algorithm:"3des",friendlyName:t.friendlyName}),d=wt.asn1.toDer(i).getBytes();return mo(d)}function so(t){const e=[An("2.5.4.3",lo(t.commonName))];return t.emailAddress&&e.push(An("1.2.840.113549.1.9.1",po(t.emailAddress))),Ht(...e)}function An(t,e){return oo(Ht(gi(t),e))}function Ht(...t){return Bt(48,pr(...t))}function oo(...t){return Bt(49,pr(...t))}function co(t,e){return Bt(160+t,e)}function uo(t){return Bt(2,new Uint8Array([t]))}function fo(){return new Uint8Array([5,0])}function lo(t){return Bt(12,new TextEncoder().encode(t))}function po(t){return Bt(22,new TextEncoder().encode(t))}function ho(t){return Bt(3,pr(new Uint8Array([0]),t))}function gi(t){const e=t.split(".").map(i=>parseInt(i,10));if(e.length<2||e.some(i=>!Number.isFinite(i)))throw new Error(`Invalid OID: ${t}`);const r=[e[0]*40+e[1]];for(const i of e.slice(2)){const d=[i&127];let v=i>>7;for(;v>0;)d.unshift(v&127|128),v>>=7;r.push(...d)}return Bt(6,new Uint8Array(r))}function Bt(t,e){return pr(new Uint8Array([t]),vo(e.byteLength),e)}function vo(t){if(t<128)return new Uint8Array([t]);const e=[];let r=t;for(;r>0;)e.unshift(r&255),r>>=8;return new Uint8Array([128|e.length,...e])}function pr(...t){const e=t.reduce((d,v)=>d+v.byteLength,0),r=new Uint8Array(e);let i=0;for(const d of t)r.set(d,i),i+=d.byteLength;return r}function go(t,e){const i=rr(e).match(/.{1,64}/g)??[];return`-----BEGIN ${t}-----
23
+ ${i.join(`
24
+ `)}
25
+ -----END ${t}-----
26
+ `}function yo(t,e){const r=e.match(/.{1,64}/g)??[];return`-----BEGIN ${t}-----
27
+ ${r.join(`
28
+ `)}
29
+ -----END ${t}-----
30
+ `}function rr(t){let e="";for(const r of t)e+=String.fromCharCode(r);return btoa(e)}function mo(t){return btoa(t)}function Co(t){return atob(t)}function Eo(t){const e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}const yi="limbuild-device-pairing",mi=1,Ut="pairRecords",ba="limbuild-device-signing",Ta=1,Ct="signingAssets";function Tt(t){return(t??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")}function At(t){return(t??"").trim()}async function Ci(t){const e=Tt(t);if(!e)return;const r=await Wt(yi,mi,Ut,"udid");return Yt(r.transaction(Ut,"readonly").objectStore(Ut).get(e))}async function Ei(t,e={}){const r=Tt(t.udid);if(!r)throw new Error("Cannot store pair record without a UDID.");const i={...t,udid:r,productName:e.productName,updatedAt:new Date().toISOString()},d=await Wt(yi,mi,Ut,"udid");return await Yt(d.transaction(Ut,"readwrite").objectStore(Ut).put(i)),i}async function xi({deviceUDID:t,bundleID:e,signingMode:r="development"}){const i=At(e);if(!i)return;const d=Tt(t),v=await In(la("bundle",i,r));if(v)return v;if(d){const a=await In(la(d,i,r));if(a)return a}return(await bi(i,r))[0]}async function ar(t="development"){return(await wa()).filter(r=>(r.signingMode??"development")===t).sort((r,i)=>new Date(i.updatedAt).getTime()-new Date(r.updatedAt).getTime())[0]}async function Si(t,e="development"){return(await wa()).filter(i=>!i.certificateID||!i.certificateP12Base64||(i.signingMode??"development")!==e?!1:!t||!i.teamID||i.teamID===t).sort((i,d)=>new Date(d.updatedAt).getTime()-new Date(i.updatedAt).getTime())[0]}async function Aa(t){const e=At(t.bundleID);if(!e)throw new Error("Cannot store signing assets without a bundle ID.");const r=Tt(t.deviceUDID),i=t.signingMode??"development",d=la("bundle",e,i),v={...t,id:d,deviceUDID:r||void 0,signingMode:i,bundleID:e,updatedAt:new Date().toISOString()},c=await Wt(ba,Ta,Ct,"id");return await Yt(c.transaction(Ct,"readwrite").objectStore(Ct).put(v)),v}async function bi(t,e="development"){const r=At(t);return r?(await wa()).filter(d=>d.bundleID===r&&(d.signingMode??"development")===e):[]}function Gt(t,e){const r=Tt(e);return!!r&&t.provisionedDevices.some(i=>Tt(i)===r)}function Ia(t,e){const r=At(e),i=At(t.bundleID);if(!r||!i)return!1;if(i===r||i==="*")return!0;if(!i.endsWith(".*"))return!1;const d=i.slice(0,-1);return r.startsWith(d)}async function Ti(t){return Ba(new Uint8Array(await t.arrayBuffer()))}function Ai(t){const e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i+=1)r[i]=e.charCodeAt(i);return Ba(r)}function Ba(t){const e=new TextDecoder("latin1").decode(t),r=e.indexOf("<?xml"),i=e.indexOf("</plist>");if(r<0||i<r)throw new Error("Provisioning profile plist not found.");const d=e.slice(r,i+8),v=new DOMParser().parseFromString(d,"application/xml");if(v.querySelector("parsererror"))throw new Error("Provisioning profile plist could not be parsed.");const c=v.querySelector("plist > dict");if(!c)throw new Error("Provisioning profile plist dictionary not found.");const a=Na(c);if(!wn(a))throw new Error("Provisioning profile plist has an unexpected shape.");const g=wn(a.Entitlements)?a.Entitlements:{},f=Ft(g["application-identifier"]),S=xo(f);return{name:Ft(a.Name),uuid:Ft(a.UUID),teamID:Ft(g["com.apple.developer.team-identifier"])??Bn(a.TeamIdentifier)[0],applicationIdentifier:f,bundleID:S,provisionedDevices:Bn(a.ProvisionedDevices),getTaskAllow:bo(g["get-task-allow"]),expirationDate:Ft(a.ExpirationDate)}}async function In(t){if(!t)return;const e=await Wt(ba,Ta,Ct,"id");return Yt(e.transaction(Ct,"readonly").objectStore(Ct).get(t))}async function wa(){const t=await Wt(ba,Ta,Ct,"id");return Yt(t.transaction(Ct,"readonly").objectStore(Ct).getAll())}function la(t,e,r){return`${r}:${t}:${e}`}function xo(t){if(!t)return;const e=t.indexOf(".");return e>=0?t.slice(e+1):void 0}function Na(t){switch(t.tagName){case"dict":return So(t);case"array":return Array.from(t.children).map(Na);case"string":case"date":return t.textContent??"";default:return t.textContent??""}}function So(t){const e={},r=Array.from(t.children);for(let i=0;i<r.length;i+=2){const d=r[i],v=r[i+1];!d||d.tagName!=="key"||!v||(e[d.textContent??""]=Na(v))}return e}function Ft(t){return typeof t=="string"&&t?t:void 0}function Bn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function bo(t){return typeof t=="boolean"?t:void 0}function wn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wt(t,e,r,i){return new Promise((d,v)=>{const c=indexedDB.open(t,e);c.onupgradeneeded=()=>{const a=c.result;a.objectStoreNames.contains(r)||a.createObjectStore(r,{keyPath:i})},c.onsuccess=()=>d(c.result),c.onerror=()=>v(c.error??new Error("Open IndexedDB failed"))})}function Yt(t){return new Promise((e,r)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>r(t.error??new Error("IndexedDB request failed"))})}function Ii(){return{method:"POST",path:"/account/listTeams.action",payload:{}}}function Ra({bundleID:t,teamID:e=""}){return Vt("/account/ios/identifiers/listAppIds.action",e,{sort:"name=asc"})}function Bi({deviceUDID:t,teamID:e=""}){return Vt("/account/ios/device/listDevices.action",e,{sort:"name=asc",includeRemovedDevices:!1})}function wi(t=""){return Vt("/account/ios/certificate/listCertRequests.action",t,{sort:"name=asc",types:"83Q87W3TGH,5QPB9NHCEI"})}function Ni(t=""){return Vt("/account/ios/certificate/listCertRequests.action",t,{sort:"name=asc",types:"WXV89964HE,R58UK2EWSO"})}function Ri({bundleID:t,teamID:e=""}){return Vt("/account/ios/profile/listProvisioningProfiles.action",e,{search:t,sort:"name=asc"})}function _i({bundleID:t,teamID:e=""}){return Vt("/account/ios/profile/listProvisioningProfiles.action",e,{search:t,sort:"name=asc",distributionType:"adhoc"})}function Di({deviceUDID:t,teamID:e="",name:r="Limrun iPhone"}){return{method:"POST",path:"/account/ios/device/addDevices.action",payload:{teamId:e,deviceNames:r,deviceNumbers:Tt(t),deviceClasses:"iphone",register:"single"}}}function Li({bundleID:t,teamID:e="",name:r}){return{method:"POST",path:"/account/ios/identifiers/addAppId.action",payload:{teamId:e,name:r??t,identifier:t,type:"explicit"}}}function Pi({csrPEM:t,teamID:e=""}){return{method:"POST",path:"/account/ios/certificate/submitCertificateRequest.action",payload:{teamId:e,type:"83Q87W3TGH",csrContent:t}}}function Ui({csrPEM:t,teamID:e=""}){return{method:"POST",path:"/account/ios/certificate/submitCertificateRequest.action",payload:{teamId:e,type:"WXV89964HE",csrContent:t}}}function ki(t,e=""){return{method:"GET",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:e,certificateId:t,type:"83Q87W3TGH"}}}function Oi(t,e=""){return{method:"GET",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:e,certificateId:t,type:"WXV89964HE"}}}function Vi({bundleID:t,teamID:e="",appIDID:r,certificateID:i,deviceIDs:d,name:v}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:e,provisioningProfileName:v??`Limrun ${t}`,certificateIds:[i],appIdId:r,deviceIds:d,distributionType:"limited",subPlatform:"ios"}}}function Fi({bundleID:t,teamID:e="",appIDID:r,certificateID:i,deviceIDs:d,name:v}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:e,provisioningProfileName:v??`Limrun Ad Hoc ${t}`,certificateIds:[i],appIdId:r,deviceIds:d,distributionType:"adhoc",subPlatform:"ios"}}}function Ki(t,e=""){return{method:"GET",path:"/account/ios/profile/downloadProfileContent",payload:{teamId:e,provisioningProfileId:t}}}async function da({bundleID:t,deviceUDID:e,teamID:r,signingMode:i}){const d=await xi({bundleID:t,deviceUDID:e,signingMode:i});if(!(!d||!qi(d,{bundleID:t,deviceUDID:e,teamID:r,signingMode:i})))return d}async function Mi(t){return Aa({...t,certificateFileName:t.certificateID?`${t.certificateID}.p12`:`apple-${t.signingMode??"development"}.p12`,certificatePassword:t.certificatePassword||void 0,signingMode:t.signingMode,profileFileName:t.profile.uuid?`${t.profile.uuid}.mobileprovision`:`${t.signingMode??"development"}.mobileprovision`})}function qi(t,{bundleID:e,deviceUDID:r,teamID:i,signingMode:d="development"}){return(t.signingMode??"development")!==d||!Ia(t.profile,e)||i&&t.teamID&&t.teamID!==i||r&&!Gt(t.profile,r)||t.profile.expirationDate&&new Date(t.profile.expirationDate).getTime()<=Date.now()?!1:At(t.bundleID)===At(e)}function To(t){const e=t;return e?.teams?.[0]??e?.provider??e?.availableProviders?.[0]}function Ao(t){const e=t,r=[...e?.teams??[],...e?.provider?[e.provider]:[],...e?.availableProviders??[]],i=new Set;for(const d of r)for(const v of[d.teamId,d.providerId,d.publicProviderId])v!==void 0&&v!==""&&i.add(String(v));return[...i]}function Vt(t,e,r={}){const i={pageNumber:1,pageSize:200,...r};return e&&(i.teamId=e),{method:"POST",path:t,payload:i}}async function Hi(t,e){const r=new URL(`${t}/info`);e&&r.searchParams.set("token",e);const i=await fetch(r.toString(),{headers:e?{Authorization:`Bearer ${e}`}:void 0});if(!i.ok){const d=await i.text();throw new Error(`Info request failed: HTTP ${i.status} ${d}`)}return await i.json()}async function Gi({limbuildApiUrl:t,token:e,certificateP12Base64:r,certificatePassword:i,provisioningProfileBase64:d}){const v=new URL(`${t}/exec`);e&&v.searchParams.set("token",e);const c=await fetch(v.toString(),{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify({command:"xcodebuild",xcodebuild:{sdk:"iphoneos"},signing:{certificateP12Base64:r,...i?{certificatePassword:i}:{},provisioningProfileBase64:d}})});if(!c.ok){const a=await c.text();throw new Error(`Build request failed: HTTP ${c.status} ${a}`)}return await c.json()}async function zi({limbuildApiUrl:t,execId:e,token:r}){const i=new URL(`${t}/exec/${encodeURIComponent(e)}/ios/ota`);r&&i.searchParams.set("token",r);const d=await fetch(i.toString(),{headers:r?{Authorization:`Bearer ${r}`}:void 0});if(!d.ok){const v=await d.text();throw new Error(`OTA install metadata failed: HTTP ${d.status} ${v}`)}return await d.json()}function Qi({limbuildApiUrl:t,execId:e,token:r,onLine:i,onStatus:d,onError:v}){const c=new URL(`${t}/exec/${e}/events`);r&&c.searchParams.set("token",r);const a=new EventSource(c.toString());return d("running"),a.addEventListener("command",g=>i({type:"command",data:g.data})),a.addEventListener("stdout",g=>i({type:"stdout",data:g.data})),a.addEventListener("stderr",g=>i({type:"stderr",data:g.data})),a.addEventListener("exitCode",g=>{const f=parseInt(g.data,10);d(f===0?"succeeded":f<0?"cancelled":"failed"),a.close()}),a.onerror=()=>{a.close(),v?.(new Error("Build log stream closed before completion."))},()=>a.close()}const _a=1,_t=16,Xe={DeviceHello:1,OpenStream:2,OpenResult:3,StreamData:4,StreamClose:5,InstallProgress:6,Error:7,Ping:8,Pong:9,StartPairing:10,StartInstall:11,PairRecordReady:12};function $i(t){const e=new Uint8Array(_t+t.payload.byteLength),r=new DataView(e.buffer);return r.setUint8(0,_a),r.setUint8(1,t.type),r.setUint8(2,0),r.setUint8(3,0),r.setUint32(4,t.requestId),r.setUint32(8,t.streamId),r.setUint32(12,t.payload.byteLength),e.set(t.payload,_t),e}function Wi(t){if(t.byteLength<_t)throw new Error(`Relay frame too short: ${t.byteLength}`);const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint8(0);if(r!==_a)throw new Error(`Unsupported relay protocol version ${r}`);const i=e.getUint32(12);if(t.byteLength!==_t+i)throw new Error(`Relay frame length mismatch: got ${t.byteLength}, expected ${_t+i}`);return{type:e.getUint8(1),requestId:e.getUint32(4),streamId:e.getUint32(8),payload:t.slice(_t)}}function Nt(t){return new TextEncoder().encode(JSON.stringify(t))}function nr(t){return JSON.parse(new TextDecoder().decode(t))}async function Yi(){if(!navigator.usb)throw new Error("WebUSB is not available in this browser.");return navigator.usb.requestDevice({filters:[{vendorId:1452}]})}function ji(t){const e=[],r=t.configuration?.configurationValue,i=t.configurations.find(d=>d.configurationValue===r);i&&e.push(...Nn(i));for(const d of t.configurations)d.configurationValue!==r&&e.push(...Nn(d));return e}function Nn(t){const e=[];for(const r of t.interfaces)for(const i of r.alternates)i.interfaceClass===255&&i.interfaceSubclass===254&&i.interfaceProtocol===2&&e.push({configurationValue:t.configurationValue,interfaceNumber:r.interfaceNumber,alternateSetting:i.alternateSetting,endpoints:i.endpoints});return e}async function Xi(t,e){t.opened||await t.open(),(!t.configuration||t.configuration.configurationValue!==e.configurationValue)&&await t.selectConfiguration(e.configurationValue),await t.claimInterface(e.interfaceNumber),e.alternateSetting!==0&&await t.selectAlternateInterface(e.interfaceNumber,e.alternateSetting)}function Zi(t){const e=t.endpoints.find(i=>i.direction==="out"&&i.type==="bulk"),r=t.endpoints.find(i=>i.direction==="in"&&i.type==="bulk");if(!e||!r)throw new Error("Could not find usbmux bulk endpoints.");return{outEndpoint:e,inEndpoint:r}}async function Da(t,e,r){const i=await t.transferOut(e.endpointNumber,r);if(i.status!=="ok")throw new Error(`USB transferOut failed: ${i.status}`);r.byteLength%e.packetSize===0&&await t.transferOut(e.endpointNumber,new Uint8Array)}async function Ji(t,e,r=16384){const i=await t.transferIn(e.endpointNumber,r);if(i.status!=="ok"||!i.data)throw new Error(`USB transferIn failed: ${i.status}`);return new Uint8Array(i.data.buffer,i.data.byteOffset,i.data.byteLength)}const es=0,Io=2,ts=6,Bo=4277009102,pa=2,wo=4,qt=16,No=49152;async function rs(t,e){const{inEndpoint:r,outEndpoint:i}=Zi(e),d=new Uint8Array(12),v=new DataView(d.buffer);v.setUint32(0,2),v.setUint32(4,0),v.setUint32(8,0),await Da(t,i,cs(es,d));const c=await os(t,r,1),a=new DataView(c.payload.buffer,c.payload.byteOffset).getUint32(0),g={device:t,candidate:e,inEndpoint:r,outEndpoint:i,muxVersion:a,txSeq:0,rxSeq:65535,nextSport:No,streams:new Map,writeChain:Promise.resolve(),closed:!1};return a>=2&&await ss(g,Io,new Uint8Array([7])),Ro(g),g}async function as(t,e){if(t.closed)throw new Error("usbmux session is closed.");let r,i;const d={session:t,sport:t.nextSport++,dport:e,seq:0,ack:0,queue:[],waiters:[],opened:new Promise((v,c)=>{r=v,i=c}),resolveOpened:r,rejectOpened:i};return t.streams.set(ha(e,d.sport),d),await or(d,pa,new Uint8Array),await d.opened,d}async function ns(t,e){if(t.session.closed)throw new Error("usbmux session is closed.");await or(t,qt,e),t.seq+=e.byteLength}async function is(t){if(t.queue.length>0)return t.queue.shift();if(t.error)throw t.error;return new Promise(e=>{t.waiters.push(e)})}function La(t){t.closed=!0;for(const e of t.streams.values())for(e.error=new Error("usbmux session closed"),e.rejectOpened(e.error);e.waiters.length>0;)e.waiters.shift()(new Uint8Array);t.streams.clear()}async function or(t,e,r){const i=new Uint8Array(20+r.byteLength),d=new DataView(i.buffer);d.setUint16(0,t.sport),d.setUint16(2,t.dport),d.setUint32(4,t.seq),d.setUint32(8,t.ack),d.setUint8(12,80),d.setUint8(13,e),d.setUint16(14,512),i.set(r,20),await ss(t.session,ts,i)}async function ss(t,e,r){if(t.closed)throw new Error("usbmux session is closed.");return t.writeChain=t.writeChain.then(async()=>{if(t.closed)return;const i=t.muxVersion>=2?_o(e,r,t.txSeq++,t.rxSeq):cs(e,r);await Da(t.device,t.outEndpoint,i)}),t.writeChain}async function Ro(t){try{for(;;){if(t.closed)return;const e=await os(t.device,t.inEndpoint,t.muxVersion);if(t.closed)return;if(e.rxSeq!==void 0&&(t.rxSeq=e.rxSeq),e.protocol!==ts)continue;const r=Lo(e.payload),i=t.streams.get(ha(r.sport,r.dport));if(i){if(r.flags&wo){for(i.error=new Error(`Device reset stream ${i.dport}`),i.rejectOpened(i.error);i.waiters.length>0;)i.waiters.shift()(new Uint8Array);t.streams.delete(ha(i.dport,i.sport));continue}if((r.flags&(pa|qt))===(pa|qt)){i.seq+=1,i.ack=r.seq+1,await or(i,qt,new Uint8Array),i.resolveOpened();continue}r.payload.byteLength!==0&&(i.ack=r.seq+r.payload.byteLength,await or(i,qt,new Uint8Array),i.waiters.length>0?i.waiters.shift()(r.payload):i.queue.push(r.payload))}}}catch{t.closed||La(t)}}async function os(t,e,r){for(;;){const i=await Ji(t,e),d=Do(i,r);if(!(r===1&&d.protocol!==es))return d}}function cs(t,e){const r=new Uint8Array(8+e.byteLength),i=new DataView(r.buffer);return i.setUint32(0,t),i.setUint32(4,r.byteLength),r.set(e,8),r}function _o(t,e,r,i){const d=new Uint8Array(16+e.byteLength),v=new DataView(d.buffer);return v.setUint32(0,t),v.setUint32(4,d.byteLength),v.setUint32(8,Bo),v.setUint16(12,r),v.setUint16(14,i),d.set(e,16),d}function Do(t,e){const r=new DataView(t.buffer,t.byteOffset,t.byteLength),i=r.getUint32(0),d=r.getUint32(4),v=e>=2?16:8;return{protocol:i,length:d,rxSeq:e>=2?r.getUint16(14):void 0,payload:t.slice(v,d)}}function Lo(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=(e.getUint8(12)>>4)*4;return{sport:e.getUint16(0),dport:e.getUint16(2),seq:e.getUint32(4),ack:e.getUint32(8),flags:e.getUint8(13),payload:t.slice(r)}}function ha(t,e){return`${t}:${e}`}class us{constructor(e,r,i,d){this.webSocketUrl=e,this.session=r,this.deviceHello=i,this.log=d}socket;streams=new Map;frameQueue=Promise.resolve();closed=!1;pairRecordWaiter;async connect(){const e=new WebSocket(this.webSocketUrl);e.binaryType="arraybuffer",this.socket=e,e.onclose=()=>{this.closed=!0,this.log("Relay socket closed"),this.pairRecordWaiter&&(this.pairRecordWaiter.reject(new Error("Relay socket closed")),this.pairRecordWaiter=void 0)},await new Promise((r,i)=>{e.onopen=()=>r(),e.onerror=()=>i(new Error("WebSocket connection failed"))}),e.onmessage=r=>{const i=r.data instanceof ArrayBuffer?new Uint8Array(r.data):new Uint8Array;this.enqueueFrame(i)},await this.send({type:Xe.DeviceHello,requestId:0,streamId:0,payload:Nt(this.deviceHello)}),this.log("Connected WebSocket relay")}async startPairing(){const e=new Promise((r,i)=>{this.pairRecordWaiter={resolve:r,reject:i}});return await this.send({type:Xe.StartPairing,requestId:0,streamId:0,payload:Nt({})}),this.log("Pairing requested"),e}async startInstall(e){await this.send({type:Xe.StartInstall,requestId:0,streamId:0,payload:Nt(e)}),this.log("Installation requested")}close(){this.closed=!0,this.socket?.close()}enqueueFrame(e){this.frameQueue=this.frameQueue.then(()=>this.handleFrame(Wi(e))).catch(r=>{this.log("Relay frame handling failed",r instanceof Error?r.message:String(r))})}async handleFrame(e){switch(e.type){case Xe.OpenStream:await this.handleOpenStream(e.requestId,e.streamId,nr(e.payload).port);break;case Xe.StreamData:{const r=this.streams.get(e.streamId);if(!r)throw new Error(`Unknown stream ${e.streamId}`);await ns(r,e.payload);break}case Xe.StreamClose:this.streams.delete(e.streamId);break;case Xe.InstallProgress:this.log(Uo(nr(e.payload).message));break;case Xe.Error:this.handleError(e.payload);break;case Xe.PairRecordReady:this.handlePairRecordReady(nr(e.payload));break;case Xe.Ping:await this.send({type:Xe.Pong,requestId:e.requestId,streamId:0,payload:new Uint8Array});break}}handleError(e){const r=Po(e);this.log("Server error",r),this.pairRecordWaiter&&(this.pairRecordWaiter.reject(new Error(r)),this.pairRecordWaiter=void 0)}handlePairRecordReady(e){this.log("Pair record received",e.udid),this.pairRecordWaiter?.resolve(e),this.pairRecordWaiter=void 0}async handleOpenStream(e,r,i){try{const d=await as(this.session,i);this.streams.set(r,d),await this.send({type:Xe.OpenResult,requestId:e,streamId:r,payload:Nt({ok:!0})}),this.log(`Opened device stream ${r} to port ${i}`),this.pumpDeviceToServer(r,d)}catch(d){this.log(`Open device stream ${r} failed`,d instanceof Error?d.message:String(d)),await this.send({type:Xe.OpenResult,requestId:e,streamId:r,payload:Nt({ok:!1,error:d instanceof Error?d.message:String(d)})})}}async pumpDeviceToServer(e,r){try{for(;;){const i=await is(r);if(this.closed)return;await this.send({type:Xe.StreamData,requestId:0,streamId:e,payload:i})}}catch(i){this.log(`Device stream ${e} closed`,i instanceof Error?i.message:String(i)),await this.send({type:Xe.StreamClose,requestId:0,streamId:e,payload:Nt({reason:i instanceof Error?i.message:String(i)})})}}async send(e){if(!this.closed){if(!this.socket||this.socket.readyState!==WebSocket.OPEN){this.closed=!0;return}this.socket.send($i(e))}}}function Po(t){const e=new TextDecoder().decode(t);try{const r=JSON.parse(e);return Rn(r.error??e)}catch{return Rn(e)}}function Rn(t){return t.replace(/libimobiledevice/g,"").trim()}function Uo(t){const e="install status: ";if(!t.startsWith(e))return t;const r=t.slice(e.length),d=new DOMParser().parseFromString(r,"application/xml").querySelector("plist > dict");if(!d)return t;const v=ko(d),c=v.Status??"Unknown";return`Install progress: ${v.PercentComplete?`${v.PercentComplete}% `:""}${c}`}function ko(t){const e={},r=Array.from(t.children);for(let i=0;i<r.length;i+=2){const d=r[i],v=r[i+1];!d||d.tagName!=="key"||!v||(e[d.textContent??""]=v.textContent??"")}return e}async function fs({log:t}){t("Selecting USB device");const e=await Yi(),r=Vo(e);return t("Selected USB device",`${e.manufacturerName??""} ${e.productName??""} ${e.serialNumber??""}`.trim()),r}async function ls({limbuildApiUrl:t,token:e,log:r,target:i}){const d=Pa(t,e);let v;try{v=await ps(d,i,r);const c=await v.startPairing();return{relay:v,pairRecord:c,target:i}}catch(c){throw v?.close(),c}}async function ds({limbuildApiUrl:t,token:e,log:r,target:i,pairRecord:d}){const v=Pa(t,e);let c;try{return c=await ps(v,i,r),await c.startInstall(d),c}catch(a){throw c?.close(),a}}async function Rt(t,e){if(t){if(t.session&&(La(t.session),t.session=void 0),t.claimedInterfaceNumber!==void 0)try{await t.device.releaseInterface(t.claimedInterfaceNumber),e?.("Released usbmux interface")}catch(r){e?.("USB interface release failed",va(r))}finally{t.claimedInterfaceNumber=void 0}if(t.device.opened)try{await t.device.close(),e?.("Closed USB device")}catch(r){e?.("USB device close failed",va(r))}}}async function ps(t,e,r){await Oo(e,r);const i=new us(t,e.session,e.hello,r);return await i.connect(),i}async function Oo(t,e){if(!t.session)try{t.candidate=await Fo(t,e),t.session=await rs(t.device,t.candidate),e("Created usbmux session")}catch(r){throw await Rt(t,e),r}}function Vo(t){return{device:t,candidate:Ko(t),hello:{serialNumber:t.serialNumber,productName:t.productName,manufacturerName:t.manufacturerName,productId:t.productId,vendorId:t.vendorId}}}async function Fo(t,e){const r=hs(t.device);if(r.length===0)throw new Error("No Apple usbmux interface found.");let i;for(const d of r)for(const v of[1,2])try{return t.device.opened||await t.device.open(),e("Claiming usbmux interface",`configuration ${d.configurationValue}, interface ${d.interfaceNumber}, alternate ${d.alternateSetting}, attempt ${v}`),await Xi(t.device,d),t.claimedInterfaceNumber=d.interfaceNumber,e("Claimed usbmux interface",`configuration ${d.configurationValue}, interface ${d.interfaceNumber}`),d}catch(c){i=c,e("USB interface claim failed",`configuration ${d.configurationValue}, interface ${d.interfaceNumber}: ${va(c)}`),await Mo(t),await qo(250)}throw i instanceof Error?i:new Error("Unable to claim any Apple usbmux interface.")}function Ko(t){const e=hs(t)[0];if(!e)throw new Error("No Apple usbmux interface found.");return e}function hs(t){const e=ji(t),r=t.configuration?.configurationValue;return[...e.filter(i=>i.configurationValue===r),...e.filter(i=>i.configurationValue!==r)]}function Pa(t,e){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=`${r.pathname.replace(/\/$/,"")}/device/ws`,e&&r.searchParams.set("token",e),r.toString()}function va(t){return t instanceof Error?t.message:String(t)}async function Mo(t){if(t.claimedInterfaceNumber!==void 0){try{await t.device.releaseInterface(t.claimedInterfaceNumber)}catch{}t.claimedInterfaceNumber=void 0}if(t.device.opened)try{await t.device.close()}catch{}}function qo(t){return new Promise(e=>setTimeout(e,t))}const _n={signing:"idle",connect:"idle",build:"idle",install:"idle"};function Ho({apiUrl:t,token:e}){const[r,i]=le.useState("signing"),[d,v]=le.useState(_n),[c,a]=le.useState(),[g,f]=le.useState(),[S,P]=le.useState(),[b,l]=le.useState(["Ready. Prepare signing assets, build, connect and pair the iPhone, then install."]),[m,x]=le.useState([]),[C,o]=le.useState("idle"),[h,y]=le.useState("idle"),[A,_]=le.useState([]),[p,s]=le.useState([]),[n,B]=le.useState([]),[D,V]=le.useState("development"),[U,F]=le.useState([]),[q,M]=le.useState(),[H,W]=le.useState(),[j,J]=le.useState(""),[ce,fe]=le.useState(),[me,be]=le.useState(!1),[he,X]=le.useState(),[ee,Ve]=le.useState(),[Be,E]=le.useState(),[L,R]=le.useState(),[N,u]=le.useState(!1),[I,O]=le.useState({}),G=le.useRef(void 0),ne=le.useRef(void 0),te=le.useRef(void 0),z=le.useRef(void 0),Q=le.useCallback((ae,se)=>{const ue=se?`${ae}
31
+ ${se}`:ae;l(oe=>[ue,...oe].slice(0,100))},[]),Z=le.useCallback((ae,se)=>{v(ue=>({...ue,[ae]:se}))},[]),ye=le.useCallback(ae=>{O(se=>{const ue={...se,...ae},oe=!!ue.certificateFile&&!!ue.provisioningProfileFile;return Z("signing",oe?"complete":"active"),oe&&(y("assets-ready"),i("build")),ue}),P(void 0)},[Z]),pe=le.useCallback(ae=>{V(ae),P(void 0),X(void 0),i("signing"),v(_n),y("idle"),Q(ae==="adhoc"?"Using Ad Hoc signing mode":"Using development signing mode")},[Q]);le.useEffect(()=>{let ae=!1;return ar(D).then(se=>{ae||!se||(P(se),J(se.bundleID),y("using-cached-profile"),Z("signing","complete"),i("build"),Q("Using stored signing assets",se.bundleID))}),()=>{ae=!0}},[Q,Z,D]);const Ce=le.useCallback(()=>ur(A.find(ae=>cr(ae)===H)),[A,H]);le.useEffect(()=>{const ae=Ce();if(!ae){fe(void 0);return}let se=!1;return Go(ae,D).then(ue=>{se||fe(ue)}),()=>{se=!0}},[Ce,D]);const Re=!!(c?.hello.serialNumber?p.find(ae=>zt(ae.deviceNumber)===zt(c.hello.serialNumber)):void 0)?.deviceId,Te=!!I.certificateFile&&!!I.provisioningProfileFile,Ae=!!S||Te,Ie=c?.hello.serialNumber&&S?Gt(S.profile,c.hello.serialNumber):void 0;le.useEffect(()=>{ne.current=c},[c]);const ge=le.useCallback(async()=>{G.current?.close(),G.current=void 0,await Rt(ne.current,Q)},[Q]);le.useEffect(()=>()=>{te.current?.(),z.current?.close(),z.current=void 0,ge()},[ge]);const De=le.useCallback(async()=>{const ae=j.trim();if((!ae||S&&Ia(S.profile,ae))&&S)return Q("Using prepared signing assets",S.bundleID),S;const se=ae?void 0:t?await vs(t,e).catch(()=>{}):void 0,ue=ae||se?.lastBuildConfig?.bundleId;if(ue){const Ne=await da({bundleID:ue,deviceUDID:c?.hello.serialNumber,teamID:Ce(),signingMode:D});if(Ne)return y("using-cached-profile"),Q("Using cached Apple signing profile",Ne.bundleID),P(Ne),Ne}const oe=await ar(D);if(oe)return Q("Using stored signing assets",oe.bundleID),P(oe),oe;if(!I.certificateFile||!I.provisioningProfileFile)throw new Error("Upload a certificate and provisioning profile.");Q("Preparing signing assets");const[de,xe,we]=await Promise.all([Ln(I.certificateFile),Ln(I.provisioningProfileFile),Ti(I.provisioningProfileFile)]);if(c?.hello.serialNumber&&!Gt(we,c.hello.serialNumber))throw new Error("Provisioning profile does not include the selected iPhone.");if(D==="adhoc"&&we.getTaskAllow)throw new Error("Ad Hoc mode requires an Ad Hoc provisioning profile, not a development profile.");const Le=we.bundleID??we.applicationIdentifier??I.provisioningProfileFile.name,Pe=await Aa({deviceUDID:c?.hello.serialNumber,signingMode:D,bundleID:Le,certificateP12Base64:de,certificateFileName:I.certificateFile.name,certificatePassword:I.certificatePassword||void 0,provisioningProfileBase64:xe,profileFileName:I.provisioningProfileFile.name,profile:we});return P(Pe),Q("Signing assets stored locally",Le),Pe},[t,j,Q,Ce,c?.hello.serialNumber,S,I,D,e]),ke=le.useCallback(async({accountName:ae,password:se})=>{if(t){E("signing"),R(void 0),i("signing"),Z("signing","active"),y("authenticating");try{await z.current?.close().catch(()=>{});const ue=await ei({limbuildApiUrl:t,token:e,accountName:ae,password:se});if(z.current=ue,!ue.requiresTwoFactor){const oe=await ue.finalize().catch(()=>{}),de=await Dn(t,ue.appleSessionId,e,_,W,oe?.body);await aa(t,ue.appleSessionId,e,de,B,J),de&&await Kt({apiUrl:t,token:e,appleSessionId:ue.appleSessionId,teamID:de,setAppleDevices:s,setSelectedAppleDeviceIDs:F,log:Q}),await na(t,ue.appleSessionId,e,de,D,M,Q)}y(ue.requiresTwoFactor?"two-factor-required":"authenticated"),Q(ue.requiresTwoFactor?"Apple ID requires two-factor authentication":"Apple ID authenticated",ae)}catch(ue){const oe=dt(ue);R(oe),y("error"),Q("Apple ID authentication failed",oe)}finally{E(void 0)}}},[t,Q,Z,D,e]),Fe=le.useCallback(async ae=>{const se=z.current;if(!se)throw new Error("Start Apple ID login before submitting a two-factor code.");E("signing"),R(void 0),i("signing"),Z("signing","active");try{if(await se.finishTwoFactor(ae),t){const ue=await se.finalize().catch(()=>{}),oe=await Dn(t,se.appleSessionId,e,_,W,ue?.body);await aa(t,se.appleSessionId,e,oe,B,J),oe&&await Kt({apiUrl:t,token:e,appleSessionId:se.appleSessionId,teamID:oe,setAppleDevices:s,setSelectedAppleDeviceIDs:F,log:Q}),await na(t,se.appleSessionId,e,oe,D,M,Q)}y("authenticated"),Q("Apple ID two-factor authentication accepted")}catch(ue){const oe=dt(ue);R(oe),y("error"),Q("Apple ID two-factor authentication failed",oe)}finally{E(void 0)}},[t,Q,Z,D,e]),Ke=le.useCallback(()=>{z.current?.close(),z.current=void 0,_([]),s([]),B([]),F([]),M(void 0),W(void 0),fe(void 0),y("idle"),Z("signing","idle"),Q("Apple ID login state cleared")},[Q,Z]),je=le.useCallback(ae=>{W(ae),B([]),s([]),F([]),M(void 0),J(""),P(void 0);const se=z.current;if(!t||!se||!ae)return;const ue=ur(A.find(oe=>cr(oe)===ae));ue&&(async()=>{try{await aa(t,se.appleSessionId,e,ue,B,J),await na(t,se.appleSessionId,e,ue,D,M,Q),await Kt({apiUrl:t,token:e,appleSessionId:se.appleSessionId,teamID:ue,connectedUDID:ne.current?.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:F,log:Q})}catch(oe){const de=dt(oe);R(de),Q("Apple team refresh failed",de)}})()},[t,A,Q,D,e]),Je=le.useCallback(async()=>{const ae=Ce();if(!(!t||!z.current||!c?.hello.serialNumber||!ae)){E("signing"),R(void 0);try{const se=zt(c.hello.serialNumber),ue=await it(t,z.current.appleSessionId,Di({deviceUDID:se,teamID:ae,name:c.hello.productName??"Limrun iPhone"}),e);vt(ue.body,"Apple device registration"),await Kt({apiUrl:t,token:e,appleSessionId:z.current.appleSessionId,teamID:ae,connectedUDID:c.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:F,log:Q}),Q("Connected iPhone registered with Apple Developer",se)}catch(se){const ue=dt(se);R(ue),Q("Apple device registration failed",ue)}finally{E(void 0)}}},[t,Q,Ce,c?.hello.productName,c?.hello.serialNumber,e]),et=le.useCallback(async()=>{if(!t||!z.current)return;const ae=j.trim();if(!ae)throw new Error("Enter a bundle ID before preparing signing assets.");if(!H)throw new Error("Select an Apple Developer team before preparing signing assets.");const se=Ce();if(!se)throw new Error("Selected Apple team does not include a Developer Portal team ID.");if(U.length===0)throw new Error("Select at least one Apple Developer device before preparing signing assets.");const ue=p.find(de=>!!de.deviceNumber&&U.includes(de.deviceId??"")),oe=c?.hello.serialNumber??ue?.deviceNumber;E("signing"),R(void 0),i("signing"),Z("signing","active"),y("preparing-assets");try{const de=await da({bundleID:ae,deviceUDID:oe,teamID:se,signingMode:D});if(de){P(de),y("assets-ready"),Z("signing","complete"),i("build"),Q("Using cached Apple signing assets",ae);return}const xe=await Qo({apiUrl:t,token:e,appleSessionId:z.current.appleSessionId,teamID:se,bundleID:ae,deviceUDID:oe,deviceIDs:U,certificatePassword:I.certificatePassword||void 0,reusableCertificate:ce,signingMode:D});P(xe),y("assets-ready"),Z("signing","complete"),i("build"),Q("Apple signing assets stored locally",oe?`${ae} for ${oe}`:`${ae} for selected Apple devices`)}catch(de){const xe=dt(de);R(xe),y("error"),Q("Apple signing asset preparation failed",xe)}finally{E(void 0)}},[t,j,p,A,Q,H,U,Ce,c?.hello.serialNumber,Z,ce,I.certificatePassword,D,e]),rt=le.useCallback(async()=>{if(t){E("build"),R(void 0),i("build"),Z("build","active"),be(!0),x([]),o("queued"),X(void 0),Ve(void 0),te.current?.();try{const ae=await De();Q("Starting signed device build");const se=await Gi({limbuildApiUrl:t,token:e,certificateP12Base64:ae.certificateP12Base64,certificatePassword:ae.certificatePassword,provisioningProfileBase64:ae.provisioningProfileBase64});if(!se.execId)throw new Error("Build request did not return an exec ID.");const ue=se.execId;Ve(ue),Q("Signed device build started",ue),te.current=Qi({limbuildApiUrl:t,execId:ue,token:e,onLine:oe=>x(de=>[...de,oe]),onStatus:oe=>{o(oe),oe==="succeeded"?(Z("build","complete"),D==="adhoc"?(Z("connect","complete"),Z("install","active"),i("install"),zi({limbuildApiUrl:t,execId:ue,token:e}).then(de=>{X(de),Z("install","complete"),Q("Ad Hoc install QR is ready")}).catch(de=>{const xe=dt(de);R(xe),Z("install","error"),Q("Ad Hoc install metadata failed",xe)})):(Z("connect","active"),i("connect"))):(oe==="failed"||oe==="cancelled")&&Z("build","error")},onError:oe=>{const de=dt(oe);R(de),Q("Build log stream failed",de)}})}catch(ae){const se=dt(ae);R(se),o("failed"),Z("build","error"),Q("Signed device build failed",se)}finally{E(void 0)}}},[t,Q,De,Z,D,e]),st=le.useCallback(async()=>{E("usb"),R(void 0),i("connect"),Z("connect","active");let ae;try{await ge(),ae=await fs({log:Q}),u(!1);const se=await Ci(ae.hello.serialNumber),ue=S??(Te?void 0:await ar(D));if(ue){if(!Gt(ue.profile,ae.hello.serialNumber))throw new Error("Stored provisioning profile does not include the selected iPhone.");P(ue)}if(t&&z.current){const oe=Ce();oe&&await Kt({apiUrl:t,token:e,appleSessionId:z.current.appleSessionId,teamID:oe,connectedUDID:ae.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:F,log:Q})}a(ae),f(se),Z("connect",se?"complete":"active"),i(se?"install":"connect"),Q(se?"Pair record found":"No pair record found",ae.hello.serialNumber)}catch(se){await Rt(ae,Q),a(void 0),f(void 0);const ue=dt(se);R(ue),Z("connect","error"),Q("USB access failed",ue)}finally{E(void 0)}},[t,ge,Q,Te,Ce,Z,S,D,e]),ct=le.useCallback(async()=>{if(!(!t||!c)){E("pair"),R(void 0),u(!1),i("connect"),Z("connect","active");try{await ge();const ae=await ls({limbuildApiUrl:t,token:e,log:Q,target:c}),se=await Ei(ae.pairRecord,{productName:c.hello.productName});ae.relay.close(),await Rt(c,Q),f(se),u(!1),Z("connect","complete"),i("install"),Q("Device paired","The pair record was stored locally in this browser.")}catch(ae){await Rt(c,Q);const se=dt(ae);u(!0),R("Unlock the iPhone, tap Trust, then confirm the pair record."),Z("connect","error"),Q("Device pairing failed",se)}finally{E(void 0)}}},[t,ge,Q,c,Z,e]),ht=le.useCallback(async()=>{if(!(!t||!c||!g)){E("install"),R(void 0),i("install"),Z("install","active");try{await ge(),G.current=await ds({limbuildApiUrl:t,token:e,log:Q,target:c,pairRecord:g}),Z("install","complete"),Q("Device install started","Installation will continue through the connected iPhone.")}catch(ae){await Rt(c,Q);const se=dt(ae);R(se),Z("install","error"),Q("Device install relay failed",se)}finally{E(void 0)}}},[t,ge,Q,g,c,Z,e]),yt=le.useCallback(()=>{ge(),Q("Device relay stopped")},[ge,Q]);return{currentStep:r,stepStatuses:d,device:c?.hello,hasPairRecord:!!g,hasSigningAssets:!!S,hasSigningInputs:Ae,pairConfirmationRequired:N,logs:b,buildLogs:m,buildStatus:C,currentExecID:ee,appleSigningStatus:h,appleTeams:A,appleDevices:p,appleAppIDs:n,applePortalSummary:q,selectedAppleTeamID:H,selectedAppleDeviceIDs:U,signingMode:D,connectedAppleDeviceRegistered:Re,connectedDeviceInProfile:Ie,hasReusableAppleCertificate:!!ce,appleBundleID:j,otaInstall:he,buildLogPanelOpen:me,busyAction:Be,error:L,canBuild:!!t&&!Be&&Ae,canPrepareAppleSigningAssets:!!t&&!Be&&!!z.current&&!!j.trim()&&!!Ce()&&U.length>0,canRequestUSBAccess:D==="development"&&!Be&&C==="succeeded",canPairBrowser:D==="development"&&!!t&&!Be&&C==="succeeded"&&!!c,canInstall:D==="development"&&!!t&&!Be&&C==="succeeded"&&!!c&&!!g,setSigningFiles:ye,setAppleBundleID:J,setSelectedAppleDeviceIDs:F,setSigningMode:pe,setBuildLogPanelOpen:be,startAppleIDLogin:ke,submitAppleTwoFactorCode:Fe,setSelectedAppleTeamID:je,clearAppleIDLogin:Ke,registerConnectedAppleDevice:Je,prepareAppleSigningAssets:et,startDeviceBuild:rt,requestUSBAccess:st,pairBrowser:ct,startInstallation:ht,stopRelay:yt}}async function vs(t,e){return Hi(t,e)}async function Go(t,e){const r=await Si(t,e);if(!(!r?.certificateID||!r.certificateP12Base64))return{certificateID:r.certificateID,certificateP12Base64:r.certificateP12Base64,certificatePassword:r.certificatePassword,teamID:r.teamID}}async function Dn(t,e,r,i,d,v){const c=await it(t,e,Ii(),r);vt(c.body,"Apple Developer team list");const a=zo([...c.body?.teams??[]]);i(a);const g=a.find(S=>ur(S)),f=cr(g??a[0]);if(f&&d(f),a.length===0)throw new Error("Apple Developer account did not return any teams or providers.");return a.map(ur).find(S=>!!S)}function zo(t){const e=new Set,r=[];for(const i of t){const v=cr(i)??i.name??JSON.stringify(i);e.has(v)||(e.add(v),r.push(i))}return r}async function aa(t,e,r,i,d,v){if(!i)return;const c=await it(t,e,Ra({bundleID:"",teamID:i}),r);vt(c.body,"Apple bundle ID list");const a=c.body?.appIds??[];d(a);const g=Wo(a[0]);if(g){v(g);return}const f=await vs(t,r).catch(()=>{});f?.lastBuildConfig?.bundleId&&v(f.lastBuildConfig.bundleId)}async function na(t,e,r,i,d,v,c){const[a,g]=await Promise.all([it(t,e,d==="adhoc"?Ni(i??""):wi(i??""),r),it(t,e,d==="adhoc"?_i({bundleID:"",teamID:i??""}):Ri({bundleID:"",teamID:i??""}),r)]);vt(a.body,"Apple Developer certificate list"),vt(g.body,"Apple Developer profile list");const f={certificateCount:a.body?.certRequests?.length??0,profileCount:g.body?.provisioningProfiles?.length??0};v(f),c("Apple Developer resources fetched",`${f.certificateCount} certificates, ${f.profileCount} provisioning profiles`)}async function Kt({apiUrl:t,token:e,appleSessionId:r,teamID:i,connectedUDID:d,setAppleDevices:v,setSelectedAppleDeviceIDs:c,log:a}){const g=await it(t,r,Bi({deviceUDID:d??"",teamID:i}),e);vt(g.body,"Apple device list");const f=g.body?.devices??[];v(f);const S=f.find(b=>!!b.deviceId)?.deviceId;if(!d){c(S?[S]:[]),a("Apple Developer devices fetched",`${f.length} devices`);return}const P=f.find(b=>zt(b.deviceNumber)===zt(d));P?.deviceId?(c([P.deviceId]),a("Connected iPhone found in Apple Developer devices",P.name??P.deviceNumber)):(c(S?[S]:[]),a("Connected iPhone is not registered with Apple Developer",d))}async function Qo({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:d,deviceUDID:v,certificatePassword:c,deviceIDs:a,reusableCertificate:g,signingMode:f}){const S=v?.replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")??"",P=await $o({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:d});let b=g?.certificateID,l=g?.certificateP12Base64,m=g?.certificatePassword||void 0;if(!b||!l){const _=await hi({commonName:`Limrun ${d}`}),p=await it(t,r,f==="adhoc"?Ui({csrPEM:_.csrPEM,teamID:i}):Pi({csrPEM:_.csrPEM,teamID:i}),e);if(vt(p.body,f==="adhoc"?"Apple Distribution certificate creation":"Apple Development certificate creation"),b=tt(p.body?.certRequest,"certificateId")??tt(p.body?.certRequest,"certRequestId")??tt(p.body,"certificateId")??tt(p.body,"certRequestId"),!b)throw new Error("Apple certificate creation did not return a certificate ID.");const s=await it(t,r,f==="adhoc"?Oi(b,i):ki(b,i),e);if(s.status<200||s.status>=300||!s.rawBodyBase64)throw new Error(`Apple certificate download failed: HTTP ${s.status}`);l=vi({privateKeyPKCS8Base64:_.privateKeyPKCS8Base64,certificateBase64:s.rawBodyBase64,password:c??"",friendlyName:f==="adhoc"?`Apple Distribution ${d}`:`Apple Development ${d}`}),m=c||void 0}const x=f==="adhoc"?`Limrun Ad Hoc ${d}`:`Limrun ${d}`,C=await it(t,r,f==="adhoc"?Fi({bundleID:d,teamID:i,appIDID:P,certificateID:b,deviceIDs:a,name:x}):Vi({bundleID:d,teamID:i,appIDID:P,certificateID:b,deviceIDs:a,name:x}),e);vt(C.body,"Apple provisioning profile creation");const o=tt(C.body?.provisioningProfile,"provisioningProfileId")??tt(C.body,"provisioningProfileId");if(!o)throw new Error("Apple provisioning profile creation did not return a profile ID.");const h=await it(t,r,Ki(o,i),e);if(h.status<200||h.status>=300||!h.rawBodyBase64)throw new Error(`Apple provisioning profile download failed: HTTP ${h.status}`);const y=h.rawBodyBase64,A=Ai(y);if(f==="adhoc"&&A.getTaskAllow)throw new Error("Apple returned a development provisioning profile for Ad Hoc signing.");return Mi({bundleID:d,deviceUDID:S||void 0,teamID:i,signingMode:f,certificateID:b,certificateP12Base64:l,certificatePassword:m,provisioningProfileBase64:y,profile:A})}async function $o({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:d}){const v=await it(t,r,Ra({bundleID:d,teamID:i}),e);vt(v.body,"Apple bundle ID lookup");const c=v.body?.appIds?.find(S=>tt(S,"identifier")===d||tt(S,"bundleId")===d),a=tt(c,"appIdId")??tt(c,"appId");if(a)return a;const g=await it(t,r,Li({bundleID:d,teamID:i,name:d}),e);vt(g.body,"Apple bundle ID creation");const f=tt(g.body?.appId,"appIdId")??tt(g.body?.appId,"appId")??tt(g.body,"appIdId")??tt(g.body,"appId");if(!f)throw new Error("Apple bundle ID creation did not return an App ID.");return f}function vt(t,e){if(!t)throw new Error(`${e} returned an empty response.`);if(t.resultCode!==void 0&&t.resultCode!==0)throw new Error(`${e} failed: ${t.userString??t.resultString??t.resultCode}`)}function tt(t,e){const r=t?.[e];if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r)}function zt(t){return(t??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"").toUpperCase()}function cr(t){const e=t?.teamId??t?.providerId??t?.publicProviderId;return e===void 0||e===""?void 0:String(e)}function ur(t){return t?.teamId&&t.teamId!==""?t.teamId:void 0}function Wo(t){return t?.identifier||t?.bundleId||void 0}async function Ln(t){const e=await t.arrayBuffer();let r="";const i=new Uint8Array(e);for(const d of i)r+=String.fromCharCode(d);return btoa(r)}function dt(t){return t instanceof Error?t.message:String(t)}exports.AppleGsaSrpClient=qn;exports.RELAY_HEADER_BYTES=_t;exports.RELAY_PROTOCOL_VERSION=_a;exports.RelayClient=us;exports.RelayMessageType=Xe;exports.claimUsbmux=Xi;exports.closeDeviceRelayTarget=Rt;exports.closeUsbmuxSession=La;exports.createAdHocProfileRequest=Fi;exports.createAppleRelaySession=Hn;exports.createBundleIDRequest=Li;exports.createDevelopmentProfileRequest=Vi;exports.createUsbmuxSession=rs;exports.decodeFrame=Wi;exports.decodeJson=nr;exports.deleteAppleRelaySession=ua;exports.deviceRelayWebSocketUrl=Pa;exports.downloadCertificateRequest=ki;exports.downloadDistributionCertificateRequest=Oi;exports.downloadProfileRequest=Ki;exports.encodeFrame=$i;exports.encodeJson=Nt;exports.exportAppleCertificateP12=vi;exports.fetchAppleAccountSession=jn;exports.fetchLimbuildInfo=Hi;exports.findAdHocProfilesRequest=_i;exports.findBundleIDRequest=Ra;exports.findDevelopmentCertificatesRequest=wi;exports.findDevelopmentProfilesRequest=Ri;exports.findDeviceRequest=Bi;exports.findDistributionCertificatesRequest=Ni;exports.findSigningAssetsForBundle=bi;exports.findUsbmuxCandidates=ji;exports.generateAppleSigningKeyAndCSR=hi;exports.getBulkEndpoints=Zi;exports.getDefaultExportFromCjs=Pn;exports.getIOSOTAInstall=zi;exports.getLatestSigningAssets=ar;exports.getLatestSigningAssetsWithCertificate=Si;exports.getPairRecord=Ci;exports.getReusableAppleSigningAssets=da;exports.getSigningAssets=xi;exports.listTeamsRequest=Ii;exports.normalizeBundleID=At;exports.normalizeUDID=Tt;exports.openStream=as;exports.parseProvisioningProfile=Ti;exports.parseProvisioningProfileBase64=Ai;exports.parseProvisioningProfileBytes=Ba;exports.profileContainsDevice=Gt;exports.profileMatchesBundleID=Ia;exports.proxyPhoneTwoFactorCode=Yn;exports.proxyProvisioningRequest=it;exports.proxySrpComplete=zn;exports.proxySrpInit=Gn;exports.proxyTwoFactorCode=Wn;exports.putAppleGeneratedSigningAssets=Mi;exports.putPairRecord=Ei;exports.putSigningAssets=Aa;exports.receiveStreamData=is;exports.registerDeviceRequest=Di;exports.requestAppleDevice=Yi;exports.requestUSBAccess=fs;exports.selectDeveloperPortalTeam=To;exports.sendStreamData=ns;exports.startBrowserOwnedAppleIDLogin=ei;exports.startInstallRelay=ds;exports.startPairingRelay=ls;exports.startSignedDeviceBuild=Gi;exports.storedSigningAssetsReusable=qi;exports.submitDevelopmentCSRRequest=Pi;exports.submitDistributionCSRRequest=Ui;exports.teamIDCandidates=Ao;exports.transferIn=Ji;exports.transferOutWithZlp=Da;exports.triggerPhoneTwoFactor=$n;exports.triggerTrustedDeviceTwoFactor=Qn;exports.useDeviceInstall=Ho;exports.watchBuildLogEvents=Qi;