@limrun/ui 0.9.0-rc.12 → 0.9.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/components/device-install/device-install-dialog.d.ts +5 -0
- package/dist/components/device-install/index.d.ts +2 -0
- package/dist/core/device-install/apple/client.d.ts +17 -0
- package/dist/core/device-install/apple/crypto.d.ts +20 -0
- package/dist/core/device-install/apple/gsa-srp.d.ts +26 -0
- package/dist/core/device-install/apple/index.d.ts +5 -0
- package/dist/core/device-install/apple/provisioning.d.ts +161 -0
- package/dist/core/device-install/apple/relay.d.ts +29 -0
- package/dist/core/device-install/index.d.ts +4 -0
- package/dist/core/device-install/operations/index.d.ts +6 -0
- package/dist/core/device-install/operations/limbuild-client.d.ts +28 -0
- package/dist/core/device-install/operations/operations.d.ts +32 -0
- package/dist/core/device-install/operations/relay-client.d.ts +25 -0
- package/dist/core/device-install/operations/relay-protocol.d.ts +27 -0
- package/dist/core/device-install/operations/usbmux.d.ts +32 -0
- package/dist/core/device-install/operations/webusb.d.ts +21 -0
- package/dist/core/device-install/storage/browser-storage.d.ts +44 -0
- package/dist/core/device-install/storage/index.d.ts +1 -0
- package/dist/core/device-install/types.d.ts +48 -0
- package/dist/device-install/index.cjs +1 -0
- package/dist/device-install/index.d.ts +3 -0
- package/dist/device-install/index.js +78 -0
- package/dist/device-install/react.cjs +1 -0
- package/dist/device-install/react.d.ts +1 -0
- package/dist/device-install/react.js +4 -0
- package/dist/device-install-dialog-CjH25hnN.js +2 -0
- package/dist/device-install-dialog-W5Xv9kWL.mjs +443 -0
- package/dist/device-install-dialog.css +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-device-install.d.ts +73 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +568 -575
- package/dist/use-device-install-Y1u6vIBB.js +31 -0
- package/dist/use-device-install-sDVvby1V.mjs +13627 -0
- package/package.json +15 -2
- package/src/components/device-install/device-install-dialog.css +325 -0
- package/src/components/device-install/device-install-dialog.tsx +495 -0
- package/src/components/device-install/index.ts +2 -0
- package/src/core/device-install/apple/client.ts +152 -0
- package/src/core/device-install/apple/crypto.ts +202 -0
- package/src/core/device-install/apple/gsa-srp.ts +127 -0
- package/src/core/device-install/apple/index.ts +5 -0
- package/src/core/device-install/apple/provisioning.ts +298 -0
- package/src/core/device-install/apple/relay.ts +221 -0
- package/src/core/device-install/index.ts +4 -0
- package/src/core/device-install/operations/index.ts +6 -0
- package/src/core/device-install/operations/limbuild-client.ts +104 -0
- package/src/core/device-install/operations/operations.ts +217 -0
- package/src/core/device-install/operations/relay-client.ts +255 -0
- package/src/core/device-install/operations/relay-protocol.ts +71 -0
- package/src/core/device-install/operations/usbmux.ts +270 -0
- package/src/core/device-install/operations/webusb-dom.d.ts +54 -0
- package/src/core/device-install/operations/webusb.ts +105 -0
- package/src/core/device-install/storage/browser-storage.ts +263 -0
- package/src/core/device-install/storage/index.ts +1 -0
- package/src/core/device-install/types.ts +65 -0
- package/src/device-install/index.ts +3 -0
- package/src/device-install/react.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-device-install.ts +1221 -0
- package/src/index.ts +3 -0
- package/vite.config.ts +6 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";const de=require("react");var Ts=Object.defineProperty,As=(t,e)=>{for(var r in e)Ts(t,r,{get:e[r],enumerable:!0})},Kt=self.crypto,nr={};As(nr,{Hash:()=>ga,bigintFromBytes:()=>ir,bitLength:()=>Ln,byteLength:()=>Pn,bytesFromBigint:()=>et,concatBytes:()=>nt,constantTimeCompare:()=>kn,fromHex:()=>oa,hash:()=>Xe,hashInterleave:()=>Vn,modPow:()=>kt,randomBytes:()=>ia,toHex:()=>bt,xorBytes:()=>Un});function Ln(t){return t.toString(2).length}function Pn(t){return(Ln(t)+7)/8|0}function ir(t){let e=0n;for(let r of t.values())e=(e<<8n)+BigInt(r);return e}function et(t){let e=new Uint8Array(Pn(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 Kt.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 Is(t,e){if(t<1n||e<1n)throw new RangeError("a and b must be > 0");let r=0n,i=1n,p=1n,v=0n;for(;t!==0n;){let c=e/t,a=e%t,g=r-p*c,l=i-v*c;e=t,t=a,r=p,i=v,p=g,v=l}return{g:e,x:r,y:i}}function Bs(t,e){let r=Is(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 Bs(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 p of t)e+=p.byteLength;let r=new Uint8Array(e),i=0;for(let p of t)r.set(p,i),i+=p.byteLength;return r}function Un(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 p=0;p<r;p++)i[p]=t[p]^e[p];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 kn(t,e){if(t.length!==e.length)return!1;let r=t.length,i=0;for(let p=0;p<r;p++)i|=t[p]^e[p];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 Xe(t,e){switch(t){case 3:return Kt.subtle.digest("SHA-1",e);case 5:return Kt.subtle.digest("SHA-256",e);case 6:return Kt.subtle.digest("SHA-384",e);case 7:return Kt.subtle.digest("SHA-512",e)}}async function Vn(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 p=r.length/2,v=new Uint8Array(p),c=new Uint8Array(p);for(let x=0;x<r.length;x++)v[x]=r[x*2],c[x]=r[x*2+1];let a=new Uint8Array(await Xe(t,v)),g=new Uint8Array(await Xe(t,c)),l=new Uint8Array(a.byteLength*2);for(let x=0;x<a.byteLength;x++)l[x*2]=a[x],l[x*2+1]=g[x];return l}var On=(t=>(t[t.RFC2945=0]="RFC2945",t[t.SRPTools=1]="SRPTools",t[t.GoSRP=2]="GoSRP",t[t.GSA=3]="GSA",t))(On||{}),ws=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 Ns(t=0){t===0&&(t=2048);let e=ws.get(t);if(!e)throw new Error(`Invalid prime field size ${t}`);return e}function er(t,e){let r=et(t);if(r.length>=e)return r;let i=e-r.length,p=new Uint8Array(e);for(let v=0;v<i;v++)p[v]=0;return p.set(r,i),p}var Rs=class{constructor(t,e,r=0){this.m=t,this.h=e,this.pf=Ns(r)}pf;async hashInt(t){return ir(new Uint8Array(await Xe(this.h,t)))}async verifier(t,e,r){let i=this.m===2?new Uint8Array(await Xe(this.h,t)):t,p=this.m===2?new Uint8Array(await Xe(this.h,e)):e,v=this.pf;r||(r=ia(v.n));let c=this.m===2?await this.hashInt(nt(i,p,r)):await this.hashInt(nt(r,new Uint8Array(await Xe(this.h,nt(i,new Uint8Array([58]),p))))),a=kt(v.g,c,v.N);return new _s({i,s:r,v:et(a),h:this.h,pf:v})}async newClient(t,e,r){let i=this.pf;return r||(r=ir(ia(i.n))),new Ds({s:this,i:this.m===2?new Uint8Array(await Xe(this.h,t)):t,p:this.m===2?new Uint8Array(await Xe(this.h,e)):e,a:r,A:kt(i.g,r,i.N),k:await this.hashInt(nt(et(i.N),er(i.g,Number(i.n))))})}},_s=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]}},Ds=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(et(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=ir(e),i=this.s.pf;if(r%i.N===0n)throw new Error("Invalid server public key");let p=await this.s.hashInt(nt(er(this.A,i.n),er(r,i.n)));if(p===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 Xe(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+p*v,l=kt(a,g,i.N);return this._K=this.s.m===0?new Uint8Array(await Vn(this.s.h,et(l))):new Uint8Array(await Xe(this.s.h,et(l))),this.s.m===2?this._M=new Uint8Array(await Xe(this.s.h,nt(this._K,et(this.A),et(r),this.i,t,et(i.N),et(i.g)))):this._M=new Uint8Array(await Xe(this.s.h,nt(Un(new Uint8Array(await Xe(this.s.h,et(i.N))),new Uint8Array(await Xe(this.s.h,this.s.m==3?er(i.g,i.n):et(i.g)))),new Uint8Array(await Xe(this.s.h,this.i)),t,et(this.A),et(r),this._K))),bt(this._M)}async generateM2(){if(!this.M)throw new Error("M not generated");return new Uint8Array(await Xe(this.s.h,nt(et(this.A),this._M,this._K)))}async serverOk(t){let e=new TextEncoder,r=e.encode(bt(new Uint8Array(await Xe(this.s.h,nt(this._K,this.M))))),i=e.encode(t);return kn(r,i)}};const Fn=new Rs(On.GSA,ga.SHA256,2048);class Kn{constructor(e){this.accountName=e}srpClient;async init(){if(this.srpClient)throw new Error("SRP client is already initialized.");return this.srpClient=await Fn.newClient(ca(this.accountName),new Uint8Array),{accountName:this.accountName,protocols:["s2k","s2k_fo"],a:vr(nr.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),p=Ua(r.b),v=await Ls(r.protocol,e,i,r.iteration);this.srpClient.p=v,await this.srpClient.generate(i,p);const c=await this.srpClient.generateM2();return{accountName:this.accountName,c:r.c,m1:vr(this.srpClient._M),m2:vr(c)}}}async function Ls(t,e,r,i){let p=new Uint8Array(await nr.hash(Fn.h,gr(ca(e))));t==="s2k_fo"&&(p=ca(nr.toHex(p)));const v=await crypto.subtle.importKey("raw",gr(p),{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 Mn(t,e){const r=await fetch(Ct(t,"/apple/auth/session",e),{method:"POST",headers:Xn(e)});if(!r.ok)throw new Error(`Apple relay session failed: HTTP ${r.status} ${await r.text()}`);return await r.json()}async function fa(t,e,r){const i=await fetch(Ct(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 qn(t,e,r,i){return Yn(t,"/apple/auth/srp/init",e,r,i)}async function Hn(t,e,r,i){return Yn(t,"/apple/auth/srp/complete",e,r,i)}async function Gn(t,e,r){const i=await fetch(Ct(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 zn(t,e,r,i="sms",p){const v=await fetch(Ct(t,"/apple/auth/2fa/phone/trigger",p),{method:"POST",headers:It(p),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 Qn(t,e,r,i){const p=await fetch(Ct(t,"/apple/auth/2fa",i),{method:"POST",headers:It(i),body:JSON.stringify({appleSessionId:e,code:r})});if(!p.ok)throw new Error(`Apple 2FA proxy failed: HTTP ${p.status} ${await p.text()}`);return await p.json()}async function $n(t,e,r,i,p="sms",v){const c=await fetch(Ct(t,"/apple/auth/2fa/phone",v),{method:"POST",headers:It(v),body:JSON.stringify({appleSessionId:e,phoneNumberId:r,mode:p,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 Wn(t,e,r){const i=await fetch(Ct(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 p=await fetch(Ct(t,"/apple/provisioning",i),{method:"POST",headers:It(i),body:JSON.stringify({appleSessionId:e,...r})});if(!p.ok)throw new Error(`Apple provisioning proxy failed: HTTP ${p.status} ${await p.text()}`);return jn(await p.json())}async function Yn(t,e,r,i,p){const v=await fetch(Ct(t,e,p),{method:"POST",headers:It(p),body:JSON.stringify({appleSessionId:r,payload:i})});if(!v.ok)throw new Error(`Apple proxy ${e} failed: HTTP ${v.status} ${await v.text()}`);return jn(await v.json())}function jn(t){if(t.body!==void 0||!t.rawBody)return t;try{return{...t,body:JSON.parse(t.rawBody)}}catch{return t}}function Ct(t,e,r){const i=t.replace(/\/$/,""),p=e.startsWith("/")?e:`/${e}`,v=new URL(`${i}${p}`);return r&&v.searchParams.set("token",r),v}function It(t){return{"Content-Type":"application/json",...Xn(t)}}function Xn(t){return t?{Authorization:`Bearer ${t}`}:{}}async function Zn({limbuildApiUrl:t,accountName:e,password:r,token:i}){const{appleSessionId:p}=await Mn(t,i);try{const v=new Kn(e),c=await qn(t,p,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 Hn(t,p,{...a,rememberMe:!1,trustTokens:[]},i),l=g.status===409;let x,L={type:"trustedDevice"};if(l){x=await Gn(t,p,i);const b=Ps(x.body);if(b&&(L={type:"phone",phoneNumberId:b.id,mode:b.pushMode??"sms"}),x.status===412){if(!b)throw new Error("Apple requested phone verification but did not include a trusted phone number.");x=await zn(t,p,b.id,b.pushMode??"sms",i)}if(x.status<200||x.status>=300)throw new Error(`Apple two-factor challenge failed: HTTP ${x.status} ${x.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:p,completeResponse:g,twoFactorChallengeResponse:x,requiresTwoFactor:l,finishTwoFactor:async b=>{const u=L.type==="phone"?await $n(t,p,L.phoneNumberId,b,L.mode,i):await Qn(t,p,b,i);if(u.status<200||u.status>=300)throw new Error(`Apple two-factor code failed: HTTP ${u.status} ${u.rawBody??""}`.trim());return u},finalize:async()=>Wn(t,p,i),close:()=>fa(t,p,i)}}catch(v){throw await fa(t,p,i).catch(()=>{}),v}}function Ps(t){if(!ua(t))return;const e=ua(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 p=typeof r.pushMode=="string"?r.pushMode:typeof t.mode=="string"?t.mode:void 0;return{id:i,pushMode:p}}function yr(t){return ua(t)?t:void 0}function ua(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ks(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Vs(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function i(){var p=!1;try{p=this instanceof i}catch{}return p?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 p=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,p.get?p:{enumerable:!0,get:function(){return t[i]}})}),r}var mr,ka;function ge(){return ka||(ka=1,mr={options:{usePureJavaScript:!1}}),mr}var Cr={exports:{}},Er,Va;function Os(){if(Va)return Er;Va=1;var t={};Er=t;var e={};t.encode=function(i,p,v){if(typeof p!="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,p);else{var a=0,g=p.length,l=p.charAt(0),x=[0];for(a=0;a<i.length;++a){for(var L=0,b=i[a];L<x.length;++L)b+=x[L]<<8,x[L]=b%g,b=b/g|0;for(;b>0;)x.push(b%g),b=b/g|0}for(a=0;i[a]===0&&a<i.length-1;++a)c+=l;for(a=x.length-1;a>=0;--a)c+=p[x[a]]}if(v){var u=new RegExp(".{1,"+v+"}","g");c=c.match(u).join(`\r
|
|
2
|
+
`)}return c},t.decode=function(i,p){if(typeof i!="string")throw new TypeError('"input" must be a string.');if(typeof p!="string")throw new TypeError('"alphabet" must be a string.');var v=e[p];if(!v){v=e[p]=[];for(var c=0;c<p.length;++c)v[p.charCodeAt(c)]=c}i=i.replace(/\s/g,"");for(var a=p.length,g=p.charAt(0),l=[0],c=0;c<i.length;c++){var x=v[i.charCodeAt(c)];if(x===void 0)return;for(var L=0,b=x;L<l.length;++L)b+=l[L]*a,l[L]=b&255,b>>=8;for(;b>0;)l.push(b&255),b>>=8}for(var u=0;i[u]===g&&u<i.length-1;++u)l.push(0);return typeof Buffer<"u"?Buffer.from(l.reverse()):new Uint8Array(l.reverse())};function r(i,p){var v=0,c=p.length,a=p.charAt(0),g=[0];for(v=0;v<i.length();++v){for(var l=0,x=i.at(v);l<g.length;++l)x+=g[l]<<8,g[l]=x%c,x=x/c|0;for(;x>0;)g.push(x%c),x=x/c|0}var L="";for(v=0;i.at(v)===0&&v<i.length()-1;++v)L+=a;for(v=g.length-1;v>=0;--v)L+=p[g[v]];return L}return Er}var Oa;function Ce(){if(Oa)return Cr.exports;Oa=1;var t=ge(),e=Os(),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(P){P()})}};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(),I=!0,R=document.createElement("div"),h=[];new MutationObserver(function(){var n=h.slice();h.length=0,n.forEach(function(B){B()})}).observe(R,{attributes:!0});var d=r.setImmediate;r.setImmediate=function(n){Date.now()-y>15?(y=Date.now(),d(n)):(h.push(n),h.length===1&&R.setAttribute("a",I=!I))}}r.nextTick=r.setImmediate})(),r.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,r.globalScope=(function(){return r.isNodejs?Us: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=p;function p(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 p||typeof o=="object"&&typeof o.data=="string"&&typeof o.read=="number")&&(this.data=o.data,this.read=o.read);this._constructedStringLength=0}r.ByteStringBuffer=p;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),I=r.isArrayBufferView(o);if(y||I){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),I=new Uint8Array(this.length()+h);return I.set(y),this.data=new DataView(I.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),I=y.byteLength-y.byteOffset;this.accommodate(I);var R=new Uint8Array(this.data.buffer,this.write);return R.set(y),this.write+=I,this}if(r.isArrayBuffer(o)){var y=new Uint8Array(o);this.accommodate(y.byteLength);var R=new Uint8Array(this.data.buffer);return R.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 R=new Uint8Array(o.data.byteLength,this.write);return R.set(y),this.write+=y.byteLength,this}if(o instanceof r.ByteStringBuffer&&(o=o.data,h="binary"),h=h||"binary",typeof o=="string"){var d;if(h==="hex")return this.accommodate(Math.ceil(o.length/2)),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.hex.decode(o,d,this.write),this;if(h==="base64")return this.accommodate(Math.ceil(o.length/4)*3),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.base64.decode(o,d,this.write),this;if(h==="utf8"&&(o=r.encodeUtf8(o),h="binary"),h==="binary"||h==="raw")return this.accommodate(o.length),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.raw.decode(d),this;if(h==="utf16")return this.accommodate(o.length*2),d=new Uint16Array(this.data.buffer,this.write),this.write+=r.text.utf16.encode(d),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 I="",R="",d="",s=0,n=0;y>0;--y,++s)R=o.charCodeAt(s)^h.charCodeAt(s),n>=10&&(I+=d,d="",n=0),d+=String.fromCharCode(R),++n;return I+=d,I},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],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";r.encode64=function(o,h){for(var y="",I="",R,d,s,n=0;n<o.length;)R=o.charCodeAt(n++),d=o.charCodeAt(n++),s=o.charCodeAt(n++),y+=a.charAt(R>>2),y+=a.charAt((R&3)<<4|d>>4),isNaN(d)?y+="==":(y+=a.charAt((d&15)<<2|s>>6),y+=isNaN(s)?"=":a.charAt(s&63)),h&&y.length>h&&(I+=y.substr(0,h)+`\r
|
|
3
|
+
`,y=y.substr(h));return I+=y,I},r.decode64=function(o){o=o.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var h="",y,I,R,d,s=0;s<o.length;)y=g[o.charCodeAt(s++)-43],I=g[o.charCodeAt(s++)-43],R=g[o.charCodeAt(s++)-43],d=g[o.charCodeAt(s++)-43],h+=String.fromCharCode(y<<2|I>>4),R!==64&&(h+=String.fromCharCode((I&15)<<4|R>>2),d!==64&&(h+=String.fromCharCode((R&3)<<6|d)));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 I=h;I||(I=new Uint8Array(o.length)),y=y||0;for(var R=y,d=0;d<o.length;++d)I[R++]=o.charCodeAt(d);return h?R-y:I},r.binary.hex.encode=r.bytesToHex,r.binary.hex.decode=function(o,h,y){var I=h;I||(I=new Uint8Array(Math.ceil(o.length/2))),y=y||0;var R=0,d=y;for(o.length&1&&(R=1,I[d++]=parseInt(o[0],16));R<o.length;R+=2)I[d++]=parseInt(o.substr(R,2),16);return h?d-y:I},r.binary.base64.encode=function(o,h){for(var y="",I="",R,d,s,n=0;n<o.byteLength;)R=o[n++],d=o[n++],s=o[n++],y+=a.charAt(R>>2),y+=a.charAt((R&3)<<4|d>>4),isNaN(d)?y+="==":(y+=a.charAt((d&15)<<2|s>>6),y+=isNaN(s)?"=":a.charAt(s&63)),h&&y.length>h&&(I+=y.substr(0,h)+`\r
|
|
4
|
+
`,y=y.substr(h));return I+=y,I},r.binary.base64.decode=function(o,h,y){var I=h;I||(I=new Uint8Array(Math.ceil(o.length/4)*3)),o=o.replace(/[^A-Za-z0-9\+\/\=]/g,""),y=y||0;for(var R,d,s,n,B=0,P=y;B<o.length;)R=g[o.charCodeAt(B++)-43],d=g[o.charCodeAt(B++)-43],s=g[o.charCodeAt(B++)-43],n=g[o.charCodeAt(B++)-43],I[P++]=R<<2|d>>4,s!==64&&(I[P++]=(d&15)<<4|s>>2,n!==64&&(I[P++]=(s&3)<<6|n));return h?P-y:I.subarray(0,P)},r.binary.base58.encode=function(o,h){return r.binary.baseN.encode(o,l,h)},r.binary.base58.decode=function(o,h){return r.binary.baseN.decode(o,l,h)},r.text={utf8:{},utf16:{}},r.text.utf8.encode=function(o,h,y){o=r.encodeUtf8(o);var I=h;I||(I=new Uint8Array(o.length)),y=y||0;for(var R=y,d=0;d<o.length;++d)I[R++]=o.charCodeAt(d);return h?R-y:I},r.text.utf8.decode=function(o){return r.decodeUtf8(String.fromCharCode.apply(null,o))},r.text.utf16.encode=function(o,h,y){var I=h;I||(I=new Uint8Array(o.length*2));var R=new Uint16Array(I.buffer);y=y||0;for(var d=y,s=y,n=0;n<o.length;++n)R[s++]=o.charCodeAt(n),d+=2;return h?d-y:I},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 I=2,R=h.charCodeAt(1);R&32&&(I=6),h=h.substring(I,h.length-4)}return h},r.inflate=function(o,h,y){var I=o.inflate(r.encode64(h)).rval;return I===null?null:r.decode64(I)};var x=function(o,h,y){if(!o)throw new Error("WebStorage not available.");var I;if(y===null?I=o.removeItem(h):(y=r.encode64(JSON.stringify(y)),I=o.setItem(h,y)),typeof I<"u"&&I.rval!==!0){var R=new Error(I.error.message);throw R.id=I.error.id,R.name=I.error.name,R}},L=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 I=new Error(y.error.message);throw I.id=y.error.id,I.name=y.error.name,I}y=null}else y=y.rval;return y!==null&&(y=JSON.parse(r.decode64(y))),y},b=function(o,h,y,I){var R=L(o,h);R===null&&(R={}),R[y]=I,x(o,h,R)},u=function(o,h,y){var I=L(o,h);return I!==null&&(I=y in I?I[y]:null),I},m=function(o,h,y){var I=L(o,h);if(I!==null&&y in I){delete I[y];var R=!0;for(var d in I){R=!1;break}R&&(I=null),x(o,h,I)}},E=function(o,h){x(o,h,null)},C=function(o,h,y){var I=null;typeof y>"u"&&(y=["web","flash"]);var R,d=!1,s=null;for(var n in y){R=y[n];try{if(R==="flash"||R==="both"){if(h[0]===null)throw new Error("Flash local storage not available.");I=o.apply(this,h),d=R==="flash"}(R==="web"||R==="both")&&(h[0]=localStorage,I=o.apply(this,h),d=!0)}catch(B){s=B}if(d)break}if(!d)throw s;return I};return r.setItem=function(o,h,y,I,R){C(b,arguments,R)},r.getItem=function(o,h,y,I){return C(u,arguments,I)},r.removeItem=function(o,h,y,I){C(m,arguments,I)},r.clearItems=function(o,h,y){C(E,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,I,R=0,d=[],s=0;y=h.exec(o);){I=o.substring(s,h.lastIndex-2),I.length>0&&d.push(I),s=h.lastIndex;var n=y[0][1];switch(n){case"s":case"o":R<arguments.length?d.push(arguments[R+++1]):d.push("<?>");break;case"%":d.push("%");break;default:d.push("<%"+n+"?>")}}return d.push(o.substring(s)),d.join("")},r.formatNumber=function(o,h,y,I){var R=o,d=isNaN(h=Math.abs(h))?2:h,s=y===void 0?",":y,n=I===void 0?".":I,B=R<0?"-":"",P=parseInt(R=Math.abs(+R||0).toFixed(d),10)+"",O=P.length>3?P.length%3:0;return B+(O?P.substr(0,O)+n:"")+P.substr(O).replace(/(\d{3})(?=\d)/g,"$1"+n)+(d?s+Math.abs(R-P).toFixed(d).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 I=parseInt(o[y],10);if(isNaN(I))return null;h.putByte(I)}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,I=r.createBuffer(),R=0;R<8;++R){if(!o[R]||o[R].length===0){I.fillWithByte(0,y),y=0;continue}var d=r.hexToBytes(o[R]);d.length<2&&I.putByte(0),I.putBytes(d)}return I.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=[],I=0,R=0;R<o.length;R+=2){for(var d=r.bytesToHex(o[R]+o[R+1]);d[0]==="0"&&d!=="0";)d=d.substr(1);if(d==="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[I].end-y[I].start&&(I=y.length-1))}h.push(d)}if(y.length>0){var B=y[I];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"}));I([],5,16);function I(s,n,B){if(n===0){var P=Math.floor(s.reduce(function(O,U){return O+U},0)/s.length);return r.cores=Math.max(1,P),URL.revokeObjectURL(y),h(null,r.cores)}R(B,function(O,U){s.push(d(B,U)),I(s,n-1,B)})}function R(s,n){for(var B=[],P=[],O=0;O<s;++O){var U=new Worker(y);U.addEventListener("message",function(F){if(P.push(F.data),P.length===s){for(var q=0;q<s;++q)B[q].terminate();n(null,P)}}),B.push(U)}for(var O=0;O<s;++O)B[O].postMessage(O)}function d(s,n){for(var B=[],P=0;P<s;++P)for(var O=n[P],U=B[P]=[],F=0;F<s;++F)if(P!==F){var q=n[F];(O.st>q.st&&O.st<q.et||q.st>O.st&&q.st<O.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=ge();Ce(),xr=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(r,i){var p=r;if(typeof p=="string"&&(p=t.cipher.getAlgorithm(p),p&&(p=p())),!p)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:p,key:i,decrypt:!1})},t.cipher.createDecipher=function(r,i){var p=r;if(typeof p=="string"&&(p=t.cipher.getAlgorithm(p),p&&(p=p())),!p)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:p,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 p in r)i[p]=r[p];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(p){return r(this.blockSize,p,!1)},this.mode.unpad=function(p){return r(this.blockSize,p,!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 Jn(){if(Ka)return Sr.exports;Ka=1;var t=ge();Ce(),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 l=0;l<this._ints;++l)this._inBlock[l]=v.getInt32()^this._outBlock[l],c.putInt32(this._inBlock[l]);return}var x=(this.blockSize-g)%this.blockSize;x>0&&(x=this.blockSize-x),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=v.getInt32()^this._outBlock[l],this._partialOutput.putInt32(this._partialBlock[l]);if(x>0)v.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),x>0&&!a)return c.putBytes(this._partialOutput.getBytes(x-this._partialBytes)),this._partialBytes=x,!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 l=0;l<this._ints;++l)this._inBlock[l]=v.getInt32(),c.putInt32(this._inBlock[l]^this._outBlock[l]);return}var x=(this.blockSize-g)%this.blockSize;x>0&&(x=this.blockSize-x),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=v.getInt32(),this._partialOutput.putInt32(this._partialBlock[l]^this._outBlock[l]);if(x>0)v.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),x>0&&!a)return c.putBytes(this._partialOutput.getBytes(x-this._partialBytes)),this._partialBytes=x,!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 l=0;l<this._ints;++l)c.putInt32(v.getInt32()^this._outBlock[l]),this._inBlock[l]=this._outBlock[l];return}var x=(this.blockSize-g)%this.blockSize;x>0&&(x=this.blockSize-x),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(v.getInt32()^this._outBlock[l]);if(x>0)v.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._outBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),x>0&&!a)return c.putBytes(this._partialOutput.getBytes(x-this._partialBytes)),this._partialBytes=x,!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 l=0;l<this._ints;++l)c.putInt32(v.getInt32()^this._outBlock[l]);else{var x=(this.blockSize-g)%this.blockSize;x>0&&(x=this.blockSize-x),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(v.getInt32()^this._outBlock[l]);if(x>0&&(v.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),x>0&&!a)return c.putBytes(this._partialOutput.getBytes(x-this._partialBytes)),this._partialBytes=x,!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(p(g*8)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,a=t.util.createBuffer(a),this._aDataLength=p(a.length()*8);var l=a.length()%this.blockSize;for(l&&a.fillWithByte(0,this.blockSize-l),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 l=0;l<this._ints;++l)c.putInt32(this._outBlock[l]^=v.getInt32());this._cipherLength+=this.blockSize}else{var x=(this.blockSize-g)%this.blockSize;x>0&&(x=this.blockSize-x),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(v.getInt32()^this._outBlock[l]);if(x<=0||a){if(a){var L=g%this.blockSize;this._cipherLength+=L,this._partialOutput.truncate(this.blockSize-L)}else this._cipherLength+=this.blockSize;for(var l=0;l<this._ints;++l)this._outBlock[l]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),x>0&&!a)return v.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(x-this._partialBytes)),this._partialBytes=x,!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 l=0;l<this._ints;++l)c.putInt32(this._outBlock[l]^this._hashBlock[l]);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(p(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,g);var l=[];this.cipher.encrypt(this._j0,l);for(var x=0;x<this._ints;++x)this.tag.putInt32(this._s[x]^l[x]);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),l=0;l<128;++l){var x=v[l/32|0]&1<<31-l%32;x&&(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,l=v[g]>>>(7-a%8)*4&15,x=this._m[a][l];c[0]^=x[0],c[1]^=x[1],c[2]^=x[2],c[3]^=x[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,l=16*a,x=new Array(l),L=0;L<l;++L){var b=[0,0,0,0],u=L/g|0,m=(g-1-L%g)*c;b[u]=1<<c-1<<m,x[L]=this.generateSubHashTable(this.multiply(b,v),c)}return x},e.gcm.prototype.generateSubHashTable=function(v,c){var a=1<<c,g=a>>>1,l=new Array(a);l[g]=v.slice(0);for(var x=g>>>1;x>0;)this.pow(l[2*x],l[x]=[]),x>>=1;for(x=2;x<g;){for(var L=1;L<x;++L){var b=l[x],u=l[L];l[x+L]=[b[0]^u[0],b[1]^u[1],b[2]^u[2],b[3]^u[3]]}x*=2}for(l[0]=[0,0,0,0],x=g+1;x<a;++x){var m=l[x^g];l[x]=[v[0]^m[0],v[1]^m[1],v[2]^m[2],v[3]^m[3]]}return l};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 l=[],x=c/4,g=0;g<x;++g)l.push(v.getInt32());v=l}return v}function i(v){v[v.length-1]=v[v.length-1]+1&4294967295}function p(v){return[v/4294967296|0,v&4294967295]}return Sr.exports}var br,Ma;function Dt(){if(Ma)return br;Ma=1;var t=ge();ya(),Jn(),Ce(),br=t.aes=t.aes||{},t.aes.startEncrypting=function(u,m,E,C){var o=b({key:u,output:E,decrypt:!1,mode:C});return o.start(m),o},t.aes.createEncryptionCipher=function(u,m){return b({key:u,output:null,decrypt:!1,mode:m})},t.aes.startDecrypting=function(u,m,E,C){var o=b({key:u,output:E,decrypt:!0,mode:C});return o.start(m),o},t.aes.createDecryptionCipher=function(u,m){return b({key:u,output:null,decrypt:!0,mode:m})},t.aes.Algorithm=function(u,m){r||l();var E=this;E.name=u,E.mode=new m({blockSize:16,cipher:{encrypt:function(C,o){return L(E._w,C,o,!1)},decrypt:function(C,o){return L(E._w,C,o,!0)}}}),E._init=!1},t.aes.Algorithm.prototype.initialize=function(u){if(!this._init){var m=u.key,E;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)){E=m,m=t.util.createBuffer();for(var C=0;C<E.length;++C)m.putByte(E[C])}if(!t.util.isArray(m)){E=m,m=[];var o=E.length();if(o===16||o===24||o===32){o=o>>>2;for(var C=0;C<o;++C)m.push(E.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=x(m,u.decrypt&&!y),this._init=!0}},t.aes._expandKey=function(u,m){return r||l(),x(u,m)},t.aes._updateBlock=L,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(u,m){var E=function(){return new t.aes.Algorithm(u,m)};t.cipher.registerAlgorithm(u,E)}var r=!1,i=4,p,v,c,a,g;function l(){r=!0,c=[0,1,2,4,8,16,32,64,128,27,54];for(var u=new Array(256),m=0;m<128;++m)u[m]=m<<1,u[m+128]=m+128<<1^283;p=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 E=0,C=0,o,h,y,I,R,d,s,m=0;m<256;++m){I=C^C<<1^C<<2^C<<3^C<<4,I=I>>8^I&255^99,p[E]=I,v[I]=E,R=u[I],o=u[E],h=u[o],y=u[h],d=R<<24^I<<16^I<<8^(I^R),s=(o^h^y)<<24^(E^y)<<16^(E^h^y)<<8^(E^o^y);for(var n=0;n<4;++n)a[n][E]=d,g[n][I]=s,d=d<<24|d>>>8,s=s<<24|s>>>8;E===0?E=C=1:(E=o^u[u[u[o^y]]],C^=u[u[C]])}}function x(u,m){for(var E=u.slice(0),C,o=1,h=E.length,y=h+6+1,I=i*y,R=h;R<I;++R)C=E[R-1],R%h===0?(C=p[C>>>16&255]<<24^p[C>>>8&255]<<16^p[C&255]<<8^p[C>>>24]^c[o]<<24,o++):h>6&&R%h===4&&(C=p[C>>>24]<<24^p[C>>>16&255]<<16^p[C>>>8&255]<<8^p[C&255]),E[R]=E[R-h]^C;if(m){var d,s=g[0],n=g[1],B=g[2],P=g[3],O=E.slice(0);I=E.length;for(var R=0,U=I-i;R<I;R+=i,U-=i)if(R===0||R===I-i)O[R]=E[U],O[R+1]=E[U+3],O[R+2]=E[U+2],O[R+3]=E[U+1];else for(var F=0;F<i;++F)d=E[U+F],O[R+(3&-F)]=s[p[d>>>24]]^n[p[d>>>16&255]]^B[p[d>>>8&255]]^P[p[d&255]];E=O}return E}function L(u,m,E,C){var o=u.length/4-1,h,y,I,R,d;C?(h=g[0],y=g[1],I=g[2],R=g[3],d=v):(h=a[0],y=a[1],I=a[2],R=a[3],d=p);var s,n,B,P,O,U,F;s=m[0]^u[0],n=m[C?3:1]^u[1],B=m[2]^u[2],P=m[C?1:3]^u[3];for(var q=3,M=1;M<o;++M)O=h[s>>>24]^y[n>>>16&255]^I[B>>>8&255]^R[P&255]^u[++q],U=h[n>>>24]^y[B>>>16&255]^I[P>>>8&255]^R[s&255]^u[++q],F=h[B>>>24]^y[P>>>16&255]^I[s>>>8&255]^R[n&255]^u[++q],P=h[P>>>24]^y[s>>>16&255]^I[n>>>8&255]^R[B&255]^u[++q],s=O,n=U,B=F;E[0]=d[s>>>24]<<24^d[n>>>16&255]<<16^d[B>>>8&255]<<8^d[P&255]^u[++q],E[C?3:1]=d[n>>>24]<<24^d[B>>>16&255]<<16^d[P>>>8&255]<<8^d[s&255]^u[++q],E[2]=d[B>>>24]<<24^d[P>>>16&255]<<16^d[s>>>8&255]<<8^d[n&255]^u[++q],E[C?1:3]=d[P>>>24]<<24^d[s>>>16&255]<<16^d[n>>>8&255]<<8^d[B&255]^u[++q]}function b(u){u=u||{};var m=(u.mode||"CBC").toUpperCase(),E="AES-"+m,C;u.decrypt?C=t.cipher.createDecipher(E,u.key):C=t.cipher.createCipher(E,u.key);var o=C.start;return C.start=function(h,y){var I=null;y instanceof t.util.ByteBuffer&&(I=y,y={}),y=y||{},y.output=I,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=ge();t.pki=t.pki||{};var e=Ir.exports=t.pki.oids=t.oids=t.oids||{};function r(p,v){e[p]=v,e[v]=p}function i(p,v){e[p]=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 ht(){if(Ha)return Ar.exports;Ha=1;var t=ge();Ce(),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,l,x){if(t.util.isArray(l)){for(var L=[],b=0;b<l.length;++b)l[b]!==void 0&&L.push(l[b]);l=L}var u={tagClass:c,type:a,constructed:g,composed:g||t.util.isArray(l),value:l};return x&&"bitStringContents"in x&&(u.bitStringContents=x.bitStringContents,u.original=e.copy(u)),u},e.copy=function(c,a){var g;if(t.util.isArray(c)){g=[];for(var l=0;l<c.length;++l)g.push(e.copy(c[l],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 l=0;l<c.length;++l)if(!e.equals(c[l],a[l]))return!1;return!0}if(typeof c!=typeof a)return!1;if(typeof c=="string")return c===a;var x=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&&(x=x&&c.bitStringContents===a.bitStringContents),x},e.getBerValueLength=function(c){var a=c.getByte();if(a!==128){var g,l=a&128;return l?g=c.getInt((a&127)<<3):g=a,g}};function r(c,a,g){if(g>a){var l=new Error("Too few bytes to parse DER.");throw l.available=c.length(),l.remaining=a,l.requested=g,l}}var i=function(c,a){var g=c.getByte();if(a--,g!==128){var l,x=g&128;if(!x)l=g;else{var L=g&127;r(c,a,L),l=c.getInt(L<<3)}if(l<0)throw new Error("Negative length: "+l);return l}};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(),l=p(c,c.length(),0,a);if(a.parseAllBytes&&c.length()!==0){var x=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw x.byteCount=g,x.remaining=c.length(),x}return l};function p(c,a,g,l){if(g>=l.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var x;r(c,a,2);var L=c.getByte();a--;var b=L&192,u=L&31;x=c.length();var m=i(c,a);if(a-=x-c.length(),m!==void 0&&m>a){if(l.strict){var E=new Error("Too few bytes to read ASN.1 value.");throw E.available=c.length(),E.remaining=a,E.requested=m,E}m=a}var C,o,h=(L&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}x=c.length(),C.push(p(c,a,g+1,l)),a-=x-c.length()}else for(;m>0;)x=c.length(),C.push(p(c,m,g+1,l)),a-=x-c.length(),m-=x-c.length();if(C===void 0&&b===e.Class.UNIVERSAL&&u===e.Type.BITSTRING&&(o=c.bytes(m)),C===void 0&&l.decodeBitStrings&&b===e.Class.UNIVERSAL&&u===e.Type.BITSTRING&&m>1){var y=c.read,I=a,R=0;if(u===e.Type.BITSTRING&&(r(c,a,1),R=c.getByte(),a--),R===0)try{x=c.length();var d={strict:!0,decodeBitStrings:!0},s=p(c,a,g+1,d),n=x-c.length();a-=n,u==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=I)}if(C===void 0){if(m===void 0){if(l.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=a}if(u===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 P=o===void 0?null:{bitStringContents:o};return e.create(b,u,h,C,P)}e.toDer=function(c){var a=t.util.createBuffer(),g=c.tagClass|c.type,l=t.util.createBuffer(),x=!1;if("bitStringContents"in c&&(x=!0,c.original&&(x=e.equals(c,c.original))),x)l.putBytes(c.bitStringContents);else if(c.composed){c.constructed?g|=32:l.putByte(0);for(var L=0;L<c.value.length;++L)c.value[L]!==void 0&&l.putBuffer(e.toDer(c.value[L]))}else if(c.type===e.Type.BMPSTRING)for(var L=0;L<c.value.length;++L)l.putInt16(c.value.charCodeAt(L));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)?l.putBytes(c.value.substr(1)):l.putBytes(c.value);if(a.putByte(g),l.length()<=127)a.putByte(l.length()&127);else{var b=l.length(),u="";do u+=String.fromCharCode(b&255),b=b>>>8;while(b>0);a.putByte(u.length|128);for(var L=u.length-1;L>=0;--L)a.putByte(u.charCodeAt(L))}return a.putBuffer(l),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 l,x,L,b,u=2;u<a.length;++u){if(l=!0,x=[],L=parseInt(a[u],10),L>4294967295)throw new Error("OID value too large; max is 32-bits.");do b=L&127,L=L>>>7,l||(b|=128),x.push(b),l=!1;while(L>0);for(var m=x.length-1;m>=0;--m)g.putByte(x[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 l=0;c.length()>0;){if(l>70368744177663)throw new Error("OID value too large; max is 53-bits.");g=c.getByte(),l=l*128,g&128?l+=g&127:(a+="."+(l+g),l=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 l=parseInt(c.substr(2,2),10)-1,x=parseInt(c.substr(4,2),10),L=parseInt(c.substr(6,2),10),b=parseInt(c.substr(8,2),10),u=0;if(c.length>11){var m=c.charAt(10),E=10;m!=="+"&&m!=="-"&&(u=parseInt(c.substr(10,2),10),E+=2)}if(a.setUTCFullYear(g,l,x),a.setUTCHours(L,b,u,0),E&&(m=c.charAt(E),m==="+"||m==="-")){var C=parseInt(c.substr(E+1,2),10),o=parseInt(c.substr(E+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),l=parseInt(c.substr(4,2),10)-1,x=parseInt(c.substr(6,2),10),L=parseInt(c.substr(8,2),10),b=parseInt(c.substr(10,2),10),u=parseInt(c.substr(12,2),10),m=0,E=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),I=parseInt(c.substr(o+4,2),10);E=y*60+I,E*=6e4,h==="+"&&(E*=-1),C=!0}return c.charAt(14)==="."&&(m=parseFloat(c.substr(14),10)*1e3),C?(a.setUTCFullYear(g,l,x),a.setUTCHours(L,b,u,m),a.setTime(+a+E)):(a.setFullYear(g,l,x),a.setHours(L,b,u,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 l=0;l<g.length;++l)g[l].length<2&&(a+="0"),a+=g[l];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 l=0;l<g.length;++l)g[l].length<2&&(a+="0"),a+=g[l];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,l){var x=!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(x=!0,a.value&&t.util.isArray(a.value))for(var L=0,b=0;x&&b<a.value.length;++b){var u=a.value[b];x=!!u.optional;var m=c.value[L];if(!m){u.optional||(x=!1,l&&l.push("["+a.name+'] Missing required element. Expected tag class "'+u.tagClass+'", type "'+u.type+'"'));continue}var E=typeof u.tagClass<"u"&&typeof u.type<"u";if(E&&(m.tagClass!==u.tagClass||m.type!==u.type))if(u.optional){x=!0;continue}else{x=!1,l&&l.push("["+a.name+"] Tag mismatch. Expected ("+u.tagClass+","+u.type+"), got ("+m.tagClass+","+m.type+")");break}var C=e.validate(m,u,g,l);if(C)++L,x=!0;else if(u.optional)x=!0;else{x=!1;break}}if(x&&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 l&&l.push("["+a.name+'] Expected constructed "'+a.constructed+'", got "'+c.constructed+'"');else l&&(c.tagClass!==a.tagClass&&l.push("["+a.name+'] Expected tag class "'+a.tagClass+'", got "'+c.tagClass+'"'),c.type!==a.type&&l.push("["+a.name+'] Expected type "'+a.type+'", got "'+c.type+'"'));return x};var v=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(c,a,g){var l="";a=a||0,g=g||2,a>0&&(l+=`
|
|
5
|
+
`);for(var x="",L=0;L<a*g;++L)x+=" ";switch(l+=x+"Tag: ",c.tagClass){case e.Class.UNIVERSAL:l+="Universal:";break;case e.Class.APPLICATION:l+="Application:";break;case e.Class.CONTEXT_SPECIFIC:l+="Context-Specific:";break;case e.Class.PRIVATE:l+="Private:";break}if(c.tagClass===e.Class.UNIVERSAL)switch(l+=c.type,c.type){case e.Type.NONE:l+=" (None)";break;case e.Type.BOOLEAN:l+=" (Boolean)";break;case e.Type.INTEGER:l+=" (Integer)";break;case e.Type.BITSTRING:l+=" (Bit string)";break;case e.Type.OCTETSTRING:l+=" (Octet string)";break;case e.Type.NULL:l+=" (Null)";break;case e.Type.OID:l+=" (Object Identifier)";break;case e.Type.ODESC:l+=" (Object Descriptor)";break;case e.Type.EXTERNAL:l+=" (External or Instance of)";break;case e.Type.REAL:l+=" (Real)";break;case e.Type.ENUMERATED:l+=" (Enumerated)";break;case e.Type.EMBEDDED:l+=" (Embedded PDV)";break;case e.Type.UTF8:l+=" (UTF8)";break;case e.Type.ROID:l+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:l+=" (Sequence)";break;case e.Type.SET:l+=" (Set)";break;case e.Type.PRINTABLESTRING:l+=" (Printable String)";break;case e.Type.IA5String:l+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:l+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:l+=" (Generalized time)";break;case e.Type.BMPSTRING:l+=" (BMP String)";break}else l+=c.type;if(l+=`
|
|
6
|
+
`,l+=x+"Constructed: "+c.constructed+`
|
|
7
|
+
`,c.composed){for(var b=0,u="",L=0;L<c.value.length;++L)c.value[L]!==void 0&&(b+=1,u+=e.prettyPrint(c.value[L],a+1,g),L+1<c.value.length&&(u+=","));l+=x+"Sub values: "+b+u}else{if(l+=x+"Value: ",c.type===e.Type.OID){var m=e.derToOid(c.value);l+=m,t.pki&&t.pki.oids&&m in t.pki.oids&&(l+=" ("+t.pki.oids[m]+") ")}if(c.type===e.Type.INTEGER)try{l+=e.derToInteger(c.value)}catch{l+="0x"+t.util.bytesToHex(c.value)}else if(c.type===e.Type.BITSTRING){if(c.value.length>1?l+="0x"+t.util.bytesToHex(c.value.slice(1)):l+="(none)",c.value.length>0){var E=c.value.charCodeAt(0);E==1?l+=" (1 unused bit shown)":E>1&&(l+=" ("+E+" unused bits shown)")}}else if(c.type===e.Type.OCTETSTRING)v.test(c.value)||(l+="("+c.value+") "),l+="0x"+t.util.bytesToHex(c.value);else if(c.type===e.Type.UTF8)try{l+=t.util.decodeUtf8(c.value)}catch(C){if(C.message==="URI malformed")l+="0x"+t.util.bytesToHex(c.value)+" (malformed UTF8)";else throw C}else c.type===e.Type.PRINTABLESTRING||c.type===e.Type.IA5String?l+=c.value:v.test(c.value)?l+="0x"+t.util.bytesToHex(c.value):c.value.length===0?l+="[null]":l+=c.value}return l},Ar.exports}var Br={exports:{}},wr,Ga;function Et(){if(Ga)return wr;Ga=1;var t=ge();return wr=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},wr}var za;function zt(){if(za)return Br.exports;za=1;var t=ge();Et(),Ce();var e=Br.exports=t.hmac=t.hmac||{};return e.create=function(){var r=null,i=null,p=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 l=g;g=t.util.createBuffer();for(var x=0;x<l.length;++x)g.putByte(l[x])}var L=g.length();L>i.blockLength&&(i.start(),i.update(g.bytes()),g=i.digest()),p=t.util.createBuffer(),v=t.util.createBuffer(),L=g.length();for(var x=0;x<L;++x){var l=g.at(x);p.putByte(54^l),v.putByte(92^l)}if(L<i.blockLength)for(var l=i.blockLength-L,x=0;x<l;++x)p.putByte(54),v.putByte(92);r=g,p=p.bytes(),v=v.bytes()}i.start(),i.update(p)},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=ge();Et(),Ce();var e=Nr.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){c||a();var l=null,x=t.util.createBuffer(),L=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 u=b.messageLengthSize/4,m=0;m<u;++m)b.fullMessageLength.push(0);return x=t.util.createBuffer(),l={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},b},b.start(),b.update=function(u,m){m==="utf8"&&(u=t.util.encodeUtf8(u));var E=u.length;b.messageLength+=E,E=[E/4294967296>>>0,E>>>0];for(var C=b.fullMessageLength.length-1;C>=0;--C)b.fullMessageLength[C]+=E[1],E[1]=E[0]+(b.fullMessageLength[C]/4294967296>>>0),b.fullMessageLength[C]=b.fullMessageLength[C]>>>0,E[0]=E[1]/4294967296>>>0;return x.putBytes(u),g(l,L,x),(x.read>2048||x.length()===0)&&x.compact(),b},b.digest=function(){var u=t.util.createBuffer();u.putBytes(x.bytes());var m=b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize,E=m&b.blockLength-1;u.putBytes(r.substr(0,b.blockLength-E));for(var C,o=0,h=b.fullMessageLength.length-1;h>=0;--h)C=b.fullMessageLength[h]*8+o,o=C/4294967296>>>0,u.putInt32Le(C>>>0);var y={h0:l.h0,h1:l.h1,h2:l.h2,h3:l.h3};g(y,L,u);var I=t.util.createBuffer();return I.putInt32Le(y.h0),I.putInt32Le(y.h1),I.putInt32Le(y.h2),I.putInt32Le(y.h3),I},b};var r=null,i=null,p=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],p=[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 l=0;l<64;++l)v[l]=Math.floor(Math.abs(Math.sin(l+1))*4294967296);c=!0}function g(l,x,L){for(var b,u,m,E,C,o,h,y,I=L.length();I>=64;){for(u=l.h0,m=l.h1,E=l.h2,C=l.h3,y=0;y<16;++y)x[y]=L.getInt32Le(),o=C^m&(E^C),b=u+o+v[y]+x[y],h=p[y],u=C,C=E,E=m,m+=b<<h|b>>>32-h;for(;y<32;++y)o=E^C&(m^E),b=u+o+v[y]+x[i[y]],h=p[y],u=C,C=E,E=m,m+=b<<h|b>>>32-h;for(;y<48;++y)o=m^E^C,b=u+o+v[y]+x[i[y]],h=p[y],u=C,C=E,E=m,m+=b<<h|b>>>32-h;for(;y<64;++y)o=E^(m|~C),b=u+o+v[y]+x[i[y]],h=p[y],u=C,C=E,E=m,m+=b<<h|b>>>32-h;l.h0=l.h0+u|0,l.h1=l.h1+m|0,l.h2=l.h2+E|0,l.h3=l.h3+C|0,I-=64}}return Nr.exports}var Rr={exports:{}},$a;function Vt(){if($a)return Rr.exports;$a=1;var t=ge();Ce();var e=Rr.exports=t.pem=t.pem||{};e.encode=function(p,v){v=v||{};var c="-----BEGIN "+p.type+`-----\r
|
|
8
|
+
`,a;if(p.procType&&(a={name:"Proc-Type",values:[String(p.procType.version),p.procType.type]},c+=r(a)),p.contentDomain&&(a={name:"Content-Domain",values:[p.contentDomain]},c+=r(a)),p.dekInfo&&(a={name:"DEK-Info",values:[p.dekInfo.algorithm]},p.dekInfo.parameters&&a.values.push(p.dekInfo.parameters),c+=r(a)),p.headers)for(var g=0;g<p.headers.length;++g)c+=r(p.headers[g]);return p.procType&&(c+=`\r
|
|
9
|
+
`),c+=t.util.encode64(p.body,v.maxline||64)+`\r
|
|
10
|
+
`,c+="-----END "+p.type+`-----\r
|
|
11
|
+
`,c},e.decode=function(p){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/,l;l=c.exec(p),!!l;){var x=l[1];x==="NEW CERTIFICATE REQUEST"&&(x="CERTIFICATE REQUEST");var L={type:x,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(l[3])};if(v.push(L),!!l[2]){for(var b=l[2].split(g),u=0;l&&u<b.length;){for(var m=b[u].replace(/\s+$/,""),E=u+1;E<b.length;++E){var C=b[E];if(!/\s/.test(C[0]))break;m+=C,u=E}if(l=m.match(a),l){for(var o={name:l[1],values:[]},h=l[2].split(","),y=0;y<h.length;++y)o.values.push(i(h[y]));if(L.procType)if(!L.contentDomain&&o.name==="Content-Domain")L.contentDomain=h[0]||"";else if(!L.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.');L.dekInfo={algorithm:h[0],parameters:h[1]||null}}else L.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.');L.procType={version:h[0],type:h[1]}}}++u}if(L.procType==="ENCRYPTED"&&!L.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(p){for(var v=p.name+": ",c=[],a=function(b,u){return" "+u},g=0;g<p.values.length;++g)c.push(p.values[g].replace(/^(\S+\r\n)/,a));v+=c.join(",")+`\r
|
|
12
|
+
`;for(var l=0,x=-1,g=0;g<v.length;++g,++l)if(l>65&&x!==-1){var L=v[x];L===","?(++x,v=v.substr(0,x)+`\r
|
|
13
|
+
`+v.substr(x)):v=v.substr(0,x)+`\r
|
|
14
|
+
`+L+v.substr(x+1),l=g-x-1,x=-1,++g}else(v[g]===" "||v[g]===" "||v[g]===",")&&(x=g);return v}function i(p){return p.replace(/^\s+/,"")}return Rr.exports}var _r={exports:{}},Dr,Wa;function fr(){if(Wa)return Dr;Wa=1;var t=ge();ya(),Jn(),Ce(),Dr=t.des=t.des||{},t.des.startEncrypting=function(u,m,E,C){var o=b({key:u,output:E,decrypt:!1,mode:C||(m===null?"ECB":"CBC")});return o.start(m),o},t.des.createEncryptionCipher=function(u,m){return b({key:u,output:null,decrypt:!1,mode:m})},t.des.startDecrypting=function(u,m,E,C){var o=b({key:u,output:E,decrypt:!0,mode:C||(m===null?"ECB":"CBC")});return o.start(m),o},t.des.createDecryptionCipher=function(u,m){return b({key:u,output:null,decrypt:!0,mode:m})},t.des.Algorithm=function(u,m){var E=this;E.name=u,E.mode=new m({blockSize:8,cipher:{encrypt:function(C,o){return L(E._keys,C,o,!1)},decrypt:function(C,o){return L(E._keys,C,o,!0)}}}),E._init=!1},t.des.Algorithm.prototype.initialize=function(u){if(!this._init){var m=t.util.createBuffer(u.key);if(this.name.indexOf("3DES")===0&&m.length()!==24)throw new Error("Invalid Triple-DES key size: "+m.length()*8);this._keys=x(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(u,m){var E=function(){return new t.des.Algorithm(u,m)};t.cipher.registerAlgorithm(u,E)}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],p=[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],l=[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 x(u){for(var m=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],E=[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],I=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],R=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],d=[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],P=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],O=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],U=u.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,Q=0;Q<U;Q++){var j=u.getInt32(),ee=u.getInt32();H=(j>>>4^ee)&252645135,ee^=H,j^=H<<4,H=(ee>>>-16^j)&65535,j^=H,ee^=H<<-16,H=(j>>>2^ee)&858993459,ee^=H,j^=H<<2,H=(ee>>>-16^j)&65535,j^=H,ee^=H<<-16,H=(j>>>1^ee)&1431655765,ee^=H,j^=H<<1,H=(ee>>>8^j)&16711935,j^=H,ee^=H<<8,H=(j>>>1^ee)&1431655765,ee^=H,j^=H<<1,H=j<<8|ee>>>20&240,j=ee<<24|ee<<8&16711680|ee>>>8&65280|ee>>>24&240,ee=H;for(var oe=0;oe<q.length;++oe){q[oe]?(j=j<<2|j>>>26,ee=ee<<2|ee>>>26):(j=j<<1|j>>>27,ee=ee<<1|ee>>>27),j&=-15,ee&=-15;var ce=m[j>>>28]|E[j>>>24&15]|C[j>>>20&15]|o[j>>>16&15]|h[j>>>12&15]|y[j>>>8&15]|I[j>>>4&15],he=R[ee>>>28]|d[ee>>>24&15]|s[ee>>>20&15]|n[ee>>>16&15]|B[ee>>>12&15]|P[ee>>>8&15]|O[ee>>>4&15];H=(he>>>16^ce)&65535,F[M++]=ce^H,F[M++]=he^H<<16}}return F}function L(u,m,E,C){var o=u.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,I=m[0],R=m[1];y=(I>>>4^R)&252645135,R^=y,I^=y<<4,y=(I>>>16^R)&65535,R^=y,I^=y<<16,y=(R>>>2^I)&858993459,I^=y,R^=y<<2,y=(R>>>8^I)&16711935,I^=y,R^=y<<8,y=(I>>>1^R)&1431655765,R^=y,I^=y<<1,I=I<<1|I>>>31,R=R<<1|R>>>31;for(var d=0;d<o;d+=3){for(var s=h[d+1],n=h[d+2],B=h[d];B!=s;B+=n){var P=R^u[B],O=(R>>>4|R<<28)^u[B+1];y=I,I=R,R=y^(i[P>>>24&63]|v[P>>>16&63]|a[P>>>8&63]|l[P&63]|r[O>>>24&63]|p[O>>>16&63]|c[O>>>8&63]|g[O&63])}y=I,I=R,R=y}I=I>>>1|I<<31,R=R>>>1|R<<31,y=(I>>>1^R)&1431655765,R^=y,I^=y<<1,y=(R>>>8^I)&16711935,I^=y,R^=y<<8,y=(R>>>2^I)&858993459,I^=y,R^=y<<2,y=(I>>>16^R)&65535,R^=y,I^=y<<16,y=(I>>>4^R)&252645135,R^=y,I^=y<<4,E[0]=I,E[1]=R}function b(u){u=u||{};var m=(u.mode||"CBC").toUpperCase(),E="DES-"+m,C;u.decrypt?C=t.cipher.createDecipher(E,u.key):C=t.cipher.createCipher(E,u.key);var o=C.start;return C.start=function(h,y){var I=null;y instanceof t.util.ByteBuffer&&(I=y,y={}),y=y||{},y.output=I,y.iv=h,o.call(C,y)},C}return Dr}const Fs={},Ks=Object.freeze(Object.defineProperty({__proto__:null,default:Fs},Symbol.toStringTag,{value:"Module"})),Ca=Vs(Ks);var Lr,Ya;function Ea(){if(Ya)return Lr;Ya=1;var t=ge();zt(),Et(),Ce();var e=t.pkcs5=t.pkcs5||{},r;return t.util.isNodejs&&!t.options.usePureJavaScript&&(r=Ca),Lr=t.pbkdf2=e.pbkdf2=function(i,p,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"),p=Buffer.from(p,"binary"),g?r.pbkdf2Sync.length===4?r.pbkdf2(i,p,v,c,function(d,s){if(d)return g(d);g(null,s.toString("binary"))}):r.pbkdf2(i,p,v,c,a,function(d,s){if(d)return g(d);g(null,s.toString("binary"))}):r.pbkdf2Sync.length===4?r.pbkdf2Sync(i,p,v,c).toString("binary"):r.pbkdf2Sync(i,p,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 l=a.digestLength;if(c>4294967295*l){var x=new Error("Derived key is too long.");if(g)return g(x);throw x}var L=Math.ceil(c/l),b=c-(L-1)*l,u=t.hmac.create();u.start(a,i);var m="",E,C,o;if(!g){for(var h=1;h<=L;++h){u.start(null,null),u.update(p),u.update(t.util.int32ToBytes(h)),E=o=u.digest().getBytes();for(var y=2;y<=v;++y)u.start(null,null),u.update(o),C=u.digest().getBytes(),E=t.util.xorBytes(E,C,l),o=C;m+=h<L?E:E.substr(0,b)}return m}var h=1,y;function I(){if(h>L)return g(null,m);u.start(null,null),u.update(p),u.update(t.util.int32ToBytes(h)),E=o=u.digest().getBytes(),y=2,R()}function R(){if(y<=v)return u.start(null,null),u.update(o),C=u.digest().getBytes(),E=t.util.xorBytes(E,C,l),o=C,++y,t.util.setImmediate(R);m+=h<L?E:E.substr(0,b),++h,I()}I()},Lr}var Xt={exports:{}},Pr={exports:{}},ja;function ei(){if(ja)return Pr.exports;ja=1;var t=ge();Et(),Ce();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(),l=new Array(64),x={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return x.start=function(){x.messageLength=0,x.fullMessageLength=x.messageLength64=[];for(var L=x.messageLengthSize/4,b=0;b<L;++b)x.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},x},x.start(),x.update=function(L,b){b==="utf8"&&(L=t.util.encodeUtf8(L));var u=L.length;x.messageLength+=u,u=[u/4294967296>>>0,u>>>0];for(var m=x.fullMessageLength.length-1;m>=0;--m)x.fullMessageLength[m]+=u[1],u[1]=u[0]+(x.fullMessageLength[m]/4294967296>>>0),x.fullMessageLength[m]=x.fullMessageLength[m]>>>0,u[0]=u[1]/4294967296>>>0;return g.putBytes(L),c(a,l,g),(g.read>2048||g.length()===0)&&g.compact(),x},x.digest=function(){var L=t.util.createBuffer();L.putBytes(g.bytes());var b=x.fullMessageLength[x.fullMessageLength.length-1]+x.messageLengthSize,u=b&x.blockLength-1;L.putBytes(r.substr(0,x.blockLength-u));for(var m,E,C=x.fullMessageLength[0]*8,o=0;o<x.fullMessageLength.length-1;++o)m=x.fullMessageLength[o+1]*8,E=m/4294967296>>>0,C+=E,L.putInt32(C>>>0),C=m>>>0;L.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,l,L);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},x};var r=null,i=!1,p=null;function v(){r="",r+=t.util.fillString("\0",64),p=[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,l){for(var x,L,b,u,m,E,C,o,h,y,I,R,d,s,n,B=l.length();B>=64;){for(C=0;C<16;++C)g[C]=l.getInt32();for(;C<64;++C)x=g[C-2],x=(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10,L=g[C-15],L=(L>>>7|L<<25)^(L>>>18|L<<14)^L>>>3,g[C]=x+g[C-7]+L+g[C-16]|0;for(o=a.h0,h=a.h1,y=a.h2,I=a.h3,R=a.h4,d=a.h5,s=a.h6,n=a.h7,C=0;C<64;++C)u=(R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7),m=s^R&(d^s),b=(o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10),E=o&h|y&(o^h),x=n+u+m+p[C]+g[C],L=b+E,n=s,s=d,d=R,R=I+x>>>0,I=y,y=h,h=o,o=x+L>>>0;a.h0=a.h0+o|0,a.h1=a.h1+h|0,a.h2=a.h2+y|0,a.h3=a.h3+I|0,a.h4=a.h4+R|0,a.h5=a.h5+d|0,a.h6=a.h6+s|0,a.h7=a.h7+n|0,B-=64}}return Pr.exports}var Ur={exports:{}},Xa;function ti(){if(Xa)return Ur.exports;Xa=1;var t=ge();Ce();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 p={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();p.pools=c,p.pool=0,p.generate=function(b,u){if(!u)return p.generateSync(b);var m=p.plugin.cipher,E=p.plugin.increment,C=p.plugin.formatKey,o=p.plugin.formatSeed,h=t.util.createBuffer();p.key=null,y();function y(I){if(I)return u(I);if(h.length()>=b)return u(null,h.getBytes(b));if(p.generated>1048575&&(p.key=null),p.key===null)return t.util.nextTick(function(){g(y)});var R=m(p.key,p.seed);p.generated+=R.length,h.putBytes(R),p.key=C(m(p.key,E(p.seed))),p.seed=o(m(p.key,p.seed)),t.util.setImmediate(y)}},p.generateSync=function(b){var u=p.plugin.cipher,m=p.plugin.increment,E=p.plugin.formatKey,C=p.plugin.formatSeed;p.key=null;for(var o=t.util.createBuffer();o.length()<b;){p.generated>1048575&&(p.key=null),p.key===null&&l();var h=u(p.key,p.seed);p.generated+=h.length,o.putBytes(h),p.key=E(u(p.key,m(p.seed))),p.seed=C(u(p.key,p.seed))}return o.getBytes(b)};function g(b){if(p.pools[0].messageLength>=32)return x(),b();var u=32-p.pools[0].messageLength<<5;p.seedFile(u,function(m,E){if(m)return b(m);p.collect(E),x(),b()})}function l(){if(p.pools[0].messageLength>=32)return x();var b=32-p.pools[0].messageLength<<5;p.collect(p.seedFileSync(b)),x()}function x(){p.reseeds=p.reseeds===4294967295?0:p.reseeds+1;var b=p.plugin.md.create();b.update(p.keyBytes);for(var u=1,m=0;m<32;++m)p.reseeds%u===0&&(b.update(p.pools[m].digest().getBytes()),p.pools[m].start()),u=u<<1;p.keyBytes=b.digest().getBytes(),b.start(),b.update(p.keyBytes);var E=b.digest().getBytes();p.key=p.plugin.formatKey(p.keyBytes),p.seed=p.plugin.formatSeed(E),p.generated=0}function L(b){var u=null,m=t.util.globalScope,E=m.crypto||m.msCrypto;E&&E.getRandomValues&&(u=function(n){return E.getRandomValues(n)});var C=t.util.createBuffer();if(u)for(;C.length()<b;){var o=Math.max(1,Math.min(b-C.length(),65536)/4),h=new Uint32Array(Math.floor(o));try{u(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 I,R,d,s=Math.floor(Math.random()*65536);C.length()<b;){R=16807*(s&65535),I=16807*(s>>16),R+=(I&32767)<<16,R+=I>>15,R=(R&2147483647)+(R>>31),s=R&4294967295;for(var y=0;y<3;++y)d=s>>>(y<<3),d^=Math.floor(Math.random()*256),C.putByte(d&255)}return C.getBytes(b)}return e?(p.seedFile=function(b,u){e.randomBytes(b,function(m,E){if(m)return u(m);u(null,E.toString())})},p.seedFileSync=function(b){return e.randomBytes(b).toString()}):(p.seedFile=function(b,u){try{u(null,L(b))}catch(m){u(m)}},p.seedFileSync=L),p.collect=function(b){for(var u=b.length,m=0;m<u;++m)p.pools[p.pool].update(b.substr(m,1)),p.pool=p.pool===31?0:p.pool+1},p.collectInt=function(b,u){for(var m="",E=0;E<u;E+=8)m+=String.fromCharCode(b>>E&255);p.collect(m)},p.registerWorker=function(b){if(b===self)p.seedFile=function(m,E){function C(o){var h=o.data;h.forge&&h.forge.prng&&(self.removeEventListener("message",C),E(h.forge.prng.err,h.forge.prng.bytes))}self.addEventListener("message",C),self.postMessage({forge:{prng:{needed:m}}})};else{var u=function(m){var E=m.data;E.forge&&E.forge.prng&&p.seedFile(E.forge.prng.needed,function(C,o){b.postMessage({forge:{prng:{err:C,bytes:o}}})})};b.addEventListener("message",u)}},p},Ur.exports}var Za;function lt(){if(Za)return Xt.exports;Za=1;var t=ge();return Dt(),ei(),ti(),Ce(),(function(){if(t.random&&t.random.getBytes){Xt.exports=t.random;return}(function(e){var r={},i=new Array(4),p=t.util.createBuffer();r.formatKey=function(b){var u=t.util.createBuffer(b);return b=new Array(4),b[0]=u.getInt32(),b[1]=u.getInt32(),b[2]=u.getInt32(),b[3]=u.getInt32(),t.aes._expandKey(b,!1)},r.formatSeed=function(b){var u=t.util.createBuffer(b);return b=new Array(4),b[0]=u.getInt32(),b[1]=u.getInt32(),b[2]=u.getInt32(),b[3]=u.getInt32(),b},r.cipher=function(b,u){return t.aes._updateBlock(b,u,i,!1),p.putInt32(i[0]),p.putInt32(i[1]),p.putInt32(i[2]),p.putInt32(i[3]),p.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(u,m){return b.generate(u,m)},b.getBytesSync=function(u){return b.generate(u)},b}var c=v(),a=null,g=t.util.globalScope,l=g.crypto||g.msCrypto;if(l&&l.getRandomValues&&(a=function(b){return l.getRandomValues(b)}),t.options.usePureJavaScript||!t.util.isNodejs&&!a){if(c.collectInt(+new Date,32),typeof navigator<"u"){var x="";for(var L in navigator)try{typeof navigator[L]=="string"&&(x+=navigator[L])}catch{}c.collect(x),x=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 L in c)t.random[L]=c[L];t.random.createInstance=v,Xt.exports=t.random})(typeof jQuery<"u"?jQuery:null)})(),Xt.exports}var kr,Ja;function ri(){if(Ja)return kr;Ja=1;var t=ge();Ce();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},p=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,l=c.length(),x=a,L=Math.ceil(x/8),b=255>>(x&7),u;for(u=l;u<128;u++)g.putByte(e[g.at(u-1)+g.at(u-l)&255]);for(g.setAt(128-L,e[g.at(128-L)&b]),u=127-L;u>=0;u--)g.setAt(u,e[g.at(u+1)^g.at(u+L)]);return g};var v=function(c,a,g){var l=!1,x=null,L=null,b=null,u,m,E,C,o=[];for(c=t.rc2.expandKey(c,a),E=0;E<64;E++)o.push(c.getInt16Le());g?(u=function(I){for(E=0;E<4;E++)I[E]+=o[C]+(I[(E+3)%4]&I[(E+2)%4])+(~I[(E+3)%4]&I[(E+1)%4]),I[E]=i(I[E],r[E]),C++},m=function(I){for(E=0;E<4;E++)I[E]+=o[I[(E+3)%4]&63]}):(u=function(I){for(E=3;E>=0;E--)I[E]=p(I[E],r[E]),I[E]-=o[C]+(I[(E+3)%4]&I[(E+2)%4])+(~I[(E+3)%4]&I[(E+1)%4]),C--},m=function(I){for(E=3;E>=0;E--)I[E]-=o[I[(E+3)%4]&63]});var h=function(I){var R=[];for(E=0;E<4;E++){var d=x.getInt16Le();b!==null&&(g?d^=b.getInt16Le():b.putInt16Le(d)),R.push(d&65535)}C=g?0:63;for(var s=0;s<I.length;s++)for(var n=0;n<I[s][0];n++)I[s][1](R);for(E=0;E<4;E++)b!==null&&(g?b.putInt16Le(R[E]):R[E]^=b.getInt16Le()),L.putInt16Le(R[E])},y=null;return y={start:function(I,R){I&&typeof I=="string"&&(I=t.util.createBuffer(I)),l=!1,x=t.util.createBuffer(),L=R||new t.util.createBuffer,b=I,y.output=L},update:function(I){for(l||x.putBuffer(I);x.length()>=8;)h([[5,u],[1,m],[6,u],[1,m],[5,u]])},finish:function(I){var R=!0;if(g)if(I)R=I(8,x,!g);else{var d=x.length()===8?8:8-x.length();x.fillWithByte(d,d)}if(R&&(l=!0,y.update()),!g&&(R=x.length()===0,R))if(I)R=I(8,L,!g);else{var s=L.length(),n=L.at(s-1);n>s?R=!1:L.truncate(n)}return R}},y};return t.rc2.startEncrypting=function(c,a,g){var l=t.rc2.createEncryptionCipher(c,128);return l.start(a,g),l},t.rc2.createEncryptionCipher=function(c,a){return v(c,a,!0)},t.rc2.startDecrypting=function(c,a,g){var l=t.rc2.createDecryptionCipher(c,128);return l.start(a,g),l},t.rc2.createDecryptionCipher=function(c,a){return v(c,a,!1)},kr}var Vr,en;function ur(){if(en)return Vr;en=1;var t=ge();Vr=t.jsbn=t.jsbn||{};var e;function r(A,w,k){this.data=[],A!=null&&(typeof A=="number"?this.fromNumber(A,w,k):w==null&&typeof A!="string"?this.fromString(A,256):this.fromString(A,w))}t.jsbn.BigInteger=r;function i(){return new r(null)}function p(A,w,k,K,$,Y){for(;--Y>=0;){var se=w*this.data[A++]+k.data[K]+$;$=Math.floor(se/67108864),k.data[K++]=se&67108863}return $}function v(A,w,k,K,$,Y){for(var se=w&32767,ae=w>>15;--Y>=0;){var Se=this.data[A]&32767,je=this.data[A++]>>15,ot=ae*Se+je*se;Se=se*Se+((ot&32767)<<15)+k.data[K]+($&1073741823),$=(Se>>>30)+(ot>>>15)+ae*je+($>>>30),k.data[K++]=Se&1073741823}return $}function c(A,w,k,K,$,Y){for(var se=w&16383,ae=w>>14;--Y>=0;){var Se=this.data[A]&16383,je=this.data[A++]>>14,ot=ae*Se+je*se;Se=se*Se+((ot&16383)<<14)+k.data[K]+$,$=(Se>>28)+(ot>>14)+ae*je,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=p,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",l=new Array,x,L;for(x=48,L=0;L<=9;++L)l[x++]=L;for(x=97,L=10;L<36;++L)l[x++]=L;for(x=65,L=10;L<36;++L)l[x++]=L;function b(A){return g.charAt(A)}function u(A,w){var k=l[A.charCodeAt(w)];return k??-1}function m(A){for(var w=this.t-1;w>=0;--w)A.data[w]=this.data[w];A.t=this.t,A.s=this.s}function E(A){this.t=1,this.s=A<0?-1:0,A>0?this.data[0]=A:A<-1?this.data[0]=A+this.DV:this.t=0}function C(A){var w=i();return w.fromInt(A),w}function o(A,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(A,w);return}this.t=0,this.s=0;for(var K=A.length,$=!1,Y=0;--K>=0;){var se=k==8?A[K]&255:u(A,K);if(se<0){A.charAt(K)=="-"&&($=!0);continue}$=!1,Y==0?this.data[this.t++]=se:Y+k>this.DB?(this.data[this.t-1]|=(se&(1<<this.DB-Y)-1)<<Y,this.data[this.t++]=se>>this.DB-Y):this.data[this.t-1]|=se<<Y,Y+=k,Y>=this.DB&&(Y-=this.DB)}k==8&&(A[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 A=this.s&this.DM;this.t>0&&this.data[this.t-1]==A;)--this.t}function y(A){if(this.s<0)return"-"+this.negate().toString(A);var w;if(A==16)w=4;else if(A==8)w=3;else if(A==2)w=1;else if(A==32)w=5;else if(A==4)w=2;else return this.toRadix(A);var k=(1<<w)-1,K,$=!1,Y="",se=this.t,ae=this.DB-se*this.DB%w;if(se-- >0)for(ae<this.DB&&(K=this.data[se]>>ae)>0&&($=!0,Y=b(K));se>=0;)ae<w?(K=(this.data[se]&(1<<ae)-1)<<w-ae,K|=this.data[--se]>>(ae+=this.DB-w)):(K=this.data[se]>>(ae-=w)&k,ae<=0&&(ae+=this.DB,--se)),K>0&&($=!0),$&&(Y+=b(K));return $?Y:"0"}function I(){var A=i();return r.ZERO.subTo(this,A),A}function R(){return this.s<0?this.negate():this}function d(A){var w=this.s-A.s;if(w!=0)return w;var k=this.t;if(w=k-A.t,w!=0)return this.s<0?-w:w;for(;--k>=0;)if((w=this.data[k]-A.data[k])!=0)return w;return 0}function s(A){var w=1,k;return(k=A>>>16)!=0&&(A=k,w+=16),(k=A>>8)!=0&&(A=k,w+=8),(k=A>>4)!=0&&(A=k,w+=4),(k=A>>2)!=0&&(A=k,w+=2),(k=A>>1)!=0&&(A=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(A,w){var k;for(k=this.t-1;k>=0;--k)w.data[k+A]=this.data[k];for(k=A-1;k>=0;--k)w.data[k]=0;w.t=this.t+A,w.s=this.s}function P(A,w){for(var k=A;k<this.t;++k)w.data[k-A]=this.data[k];w.t=Math.max(this.t-A,0),w.s=this.s}function O(A,w){var k=A%this.DB,K=this.DB-k,$=(1<<K)-1,Y=Math.floor(A/this.DB),se=this.s<<k&this.DM,ae;for(ae=this.t-1;ae>=0;--ae)w.data[ae+Y+1]=this.data[ae]>>K|se,se=(this.data[ae]&$)<<k;for(ae=Y-1;ae>=0;--ae)w.data[ae]=0;w.data[Y]=se,w.t=this.t+Y+1,w.s=this.s,w.clamp()}function U(A,w){w.s=this.s;var k=Math.floor(A/this.DB);if(k>=this.t){w.t=0;return}var K=A%this.DB,$=this.DB-K,Y=(1<<K)-1;w.data[0]=this.data[k]>>K;for(var se=k+1;se<this.t;++se)w.data[se-k-1]|=(this.data[se]&Y)<<$,w.data[se-k]=this.data[se]>>K;K>0&&(w.data[this.t-k-1]|=(this.s&Y)<<$),w.t=this.t-k,w.clamp()}function F(A,w){for(var k=0,K=0,$=Math.min(A.t,this.t);k<$;)K+=this.data[k]-A.data[k],w.data[k++]=K&this.DM,K>>=this.DB;if(A.t<this.t){for(K-=A.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<A.t;)K-=A.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K-=A.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(A,w){var k=this.abs(),K=A.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!=A.s&&r.ZERO.subTo(w,w)}function M(A){for(var w=this.abs(),k=A.t=2*w.t;--k>=0;)A.data[k]=0;for(k=0;k<w.t-1;++k){var K=w.am(k,w.data[k],A,2*k,0,1);(A.data[k+w.t]+=w.am(k+1,2*w.data[k],A,2*k+1,K,w.t-k-1))>=w.DV&&(A.data[k+w.t]-=w.DV,A.data[k+w.t+1]=1)}A.t>0&&(A.data[A.t-1]+=w.am(k,w.data[k],A,2*k,0,1)),A.s=0,A.clamp()}function H(A,w,k){var K=A.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(),se=this.s,ae=A.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 je=Y.t,ot=Y.data[je-1];if(ot!=0){var at=ot*(1<<this.F1)+(je>1?Y.data[je-2]>>this.F2:0),yt=this.FV/at,Yt=(1<<this.F1)/at,ft=1<<this.F2,ut=k.t,jt=ut-je,St=w??i();for(Y.dlShiftTo(jt,St),k.compareTo(St)>=0&&(k.data[k.t++]=1,k.subTo(St,k)),r.ONE.dlShiftTo(je,St),St.subTo(Y,Y);Y.t<je;)Y.data[Y.t++]=0;for(;--jt>=0;){var hr=k.data[--ut]==ot?this.DM:Math.floor(k.data[ut]*yt+(k.data[ut-1]+ft)*Yt);if((k.data[ut]+=Y.am(0,hr,k,jt,0,je))<hr)for(Y.dlShiftTo(jt,St),k.subTo(St,k);k.data[ut]<--hr;)k.subTo(St,k)}w!=null&&(k.drShiftTo(je,w),se!=ae&&r.ZERO.subTo(w,w)),k.t=je,k.clamp(),Se>0&&k.rShiftTo(Se,k),se<0&&r.ZERO.subTo(k,k)}}}function Q(A){var w=i();return this.abs().divRemTo(A,null,w),this.s<0&&w.compareTo(r.ZERO)>0&&A.subTo(w,w),w}function j(A){this.m=A}function ee(A){return A.s<0||A.compareTo(this.m)>=0?A.mod(this.m):A}function oe(A){return A}function ce(A){A.divRemTo(this.m,null,A)}function he(A,w,k){A.multiplyTo(w,k),this.reduce(k)}function pe(A,w){A.squareTo(w),this.reduce(w)}j.prototype.convert=ee,j.prototype.revert=oe,j.prototype.reduce=ce,j.prototype.mulTo=he,j.prototype.sqrTo=pe;function ve(){if(this.t<1)return 0;var A=this.data[0];if((A&1)==0)return 0;var w=A&3;return w=w*(2-(A&15)*w)&15,w=w*(2-(A&255)*w)&255,w=w*(2-((A&65535)*w&65535))&65535,w=w*(2-A*w%this.DV)%this.DV,w>0?this.DV-w:-w}function W(A){this.m=A,this.mp=A.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<A.DB-15)-1,this.mt2=2*A.t}function X(A){var w=i();return A.abs().dlShiftTo(this.m.t,w),w.divRemTo(this.m,null,w),A.s<0&&w.compareTo(r.ZERO)>0&&this.m.subTo(w,w),w}function Re(A){var w=i();return A.copyTo(w),this.reduce(w),w}function ye(A){for(;A.t<=this.mt2;)A.data[A.t++]=0;for(var w=0;w<this.m.t;++w){var k=A.data[w]&32767,K=k*this.mpl+((k*this.mph+(A.data[w]>>15)*this.mpl&this.um)<<15)&A.DM;for(k=w+this.m.t,A.data[k]+=this.m.am(0,K,A,w,0,this.m.t);A.data[k]>=A.DV;)A.data[k]-=A.DV,A.data[++k]++}A.clamp(),A.drShiftTo(this.m.t,A),A.compareTo(this.m)>=0&&A.subTo(this.m,A)}function S(A,w){A.squareTo(w),this.reduce(w)}function D(A,w,k){A.multiplyTo(w,k),this.reduce(k)}W.prototype.convert=X,W.prototype.revert=Re,W.prototype.reduce=ye,W.prototype.mulTo=D,W.prototype.sqrTo=S;function _(){return(this.t>0?this.data[0]&1:this.s)==0}function N(A,w){if(A>4294967295||A<1)return r.ONE;var k=i(),K=i(),$=w.convert(this),Y=s(A)-1;for($.copyTo(k);--Y>=0;)if(w.sqrTo(k,K),(A&1<<Y)>0)w.mulTo(K,$,k);else{var se=k;k=K,K=se}return w.revert(k)}function f(A,w){var k;return A<256||w.isEven()?k=new j(w):k=new W(w),this.exp(A,k)}r.prototype.copyTo=m,r.prototype.fromInt=E,r.prototype.fromString=o,r.prototype.clamp=h,r.prototype.dlShiftTo=B,r.prototype.drShiftTo=P,r.prototype.lShiftTo=O,r.prototype.rShiftTo=U,r.prototype.subTo=F,r.prototype.multiplyTo=q,r.prototype.squareTo=M,r.prototype.divRemTo=H,r.prototype.invDigit=ve,r.prototype.isEven=_,r.prototype.exp=N,r.prototype.toString=y,r.prototype.negate=I,r.prototype.abs=R,r.prototype.compareTo=d,r.prototype.bitLength=n,r.prototype.mod=Q,r.prototype.modPowInt=f,r.ZERO=C(0),r.ONE=C(1);function T(){var A=i();return this.copyTo(A),A}function V(){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 Z(){return this.t==0?this.s:this.data[0]<<16>>16}function ne(A){return Math.floor(Math.LN2*this.DB/Math.log(A))}function z(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function J(A){if(A==null&&(A=10),this.signum()==0||A<2||A>36)return"0";var w=this.chunkSize(A),k=Math.pow(A,w),K=C(k),$=i(),Y=i(),se="";for(this.divRemTo(K,$,Y);$.signum()>0;)se=(k+Y.intValue()).toString(A).substr(1)+se,$.divRemTo(K,$,Y);return Y.intValue().toString(A)+se}function fe(A,w){this.fromInt(0),w==null&&(w=10);for(var k=this.chunkSize(w),K=Math.pow(w,k),$=!1,Y=0,se=0,ae=0;ae<A.length;++ae){var Se=u(A,ae);if(Se<0){A.charAt(ae)=="-"&&this.signum()==0&&($=!0);continue}se=w*se+Se,++Y>=k&&(this.dMultiply(K),this.dAddOffset(se,0),Y=0,se=0)}Y>0&&(this.dMultiply(Math.pow(w,Y)),this.dAddOffset(se,0)),$&&r.ZERO.subTo(this,this)}function me(A,w,k){if(typeof w=="number")if(A<2)this.fromInt(1);else for(this.fromNumber(A,k),this.testBit(A-1)||this.bitwiseTo(r.ONE.shiftLeft(A-1),Ee,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(w);)this.dAddOffset(2,0),this.bitLength()>A&&this.subTo(r.ONE.shiftLeft(A-1),this);else{var K=new Array,$=A&7;K.length=(A>>3)+1,w.nextBytes(K),$>0?K[0]&=(1<<$)-1:K[0]=0,this.fromString(K,256)}}function ue(){var A=this.t,w=new Array;w[0]=this.s;var k=this.DB-A*this.DB%8,K,$=0;if(A-- >0)for(k<this.DB&&(K=this.data[A]>>k)!=(this.s&this.DM)>>k&&(w[$++]=K|this.s<<this.DB-k);A>=0;)k<8?(K=(this.data[A]&(1<<k)-1)<<8-k,K|=this.data[--A]>>(k+=this.DB-8)):(K=this.data[A]>>(k-=8)&255,k<=0&&(k+=this.DB,--A)),(K&128)!=0&&(K|=-256),$==0&&(this.s&128)!=(K&128)&&++$,($>0||K!=this.s)&&(w[$++]=K);return w}function Te(A){return this.compareTo(A)==0}function Ne(A){return this.compareTo(A)<0?this:A}function Be(A){return this.compareTo(A)>0?this:A}function Ie(A,w,k){var K,$,Y=Math.min(A.t,this.t);for(K=0;K<Y;++K)k.data[K]=w(this.data[K],A.data[K]);if(A.t<this.t){for($=A.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<A.t;++K)k.data[K]=w($,A.data[K]);k.t=A.t}k.s=w(this.s,A.s),k.clamp()}function Ae(A,w){return A&w}function be(A){var w=i();return this.bitwiseTo(A,Ae,w),w}function Ee(A,w){return A|w}function _e(A){var w=i();return this.bitwiseTo(A,Ee,w),w}function De(A,w){return A^w}function Pe(A){var w=i();return this.bitwiseTo(A,De,w),w}function Ue(A,w){return A&~w}function Ze(A){var w=i();return this.bitwiseTo(A,Ue,w),w}function te(){for(var A=i(),w=0;w<this.t;++w)A.data[w]=this.DM&~this.data[w];return A.t=this.t,A.s=~this.s,A}function re(A){var w=i();return A<0?this.rShiftTo(-A,w):this.lShiftTo(A,w),w}function ie(A){var w=i();return A<0?this.lShiftTo(-A,w):this.rShiftTo(A,w),w}function le(A){if(A==0)return-1;var w=0;return(A&65535)==0&&(A>>=16,w+=16),(A&255)==0&&(A>>=8,w+=8),(A&15)==0&&(A>>=4,w+=4),(A&3)==0&&(A>>=2,w+=2),(A&1)==0&&++w,w}function xe(){for(var A=0;A<this.t;++A)if(this.data[A]!=0)return A*this.DB+le(this.data[A]);return this.s<0?this.t*this.DB:-1}function tt(A){for(var w=0;A!=0;)A&=A-1,++w;return w}function st(){for(var A=0,w=this.s&this.DM,k=0;k<this.t;++k)A+=tt(this.data[k]^w);return A}function vt(A){var w=Math.floor(A/this.DB);return w>=this.t?this.s!=0:(this.data[w]&1<<A%this.DB)!=0}function xt(A,w){var k=r.ONE.shiftLeft(A);return this.bitwiseTo(k,w,k),k}function gt(A){return this.changeBit(A,Ee)}function ke(A){return this.changeBit(A,Ue)}function Ve(A){return this.changeBit(A,De)}function Oe(A,w){for(var k=0,K=0,$=Math.min(A.t,this.t);k<$;)K+=this.data[k]+A.data[k],w.data[k++]=K&this.DM,K>>=this.DB;if(A.t<this.t){for(K+=A.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<A.t;)K+=A.data[k],w.data[k++]=K&this.DM,K>>=this.DB;K+=A.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 Fe(A){var w=i();return this.addTo(A,w),w}function Ke(A){var w=i();return this.subTo(A,w),w}function Me(A){var w=i();return this.multiplyTo(A,w),w}function qe(){var A=i();return this.squareTo(A),A}function He(A){var w=i();return this.divRemTo(A,w,null),w}function Ge(A){var w=i();return this.divRemTo(A,null,w),w}function ze(A){var w=i(),k=i();return this.divRemTo(A,w,k),new Array(w,k)}function Qe(A){this.data[this.t]=this.am(0,A-1,this,0,0,this.t),++this.t,this.clamp()}function $e(A,w){if(A!=0){for(;this.t<=w;)this.data[this.t++]=0;for(this.data[w]+=A;this.data[w]>=this.DV;)this.data[w]-=this.DV,++w>=this.t&&(this.data[this.t++]=0),++this.data[w]}}function we(){}function Le(A){return A}function We(A,w,k){A.multiplyTo(w,k)}function Ye(A,w){A.squareTo(w)}we.prototype.convert=Le,we.prototype.revert=Le,we.prototype.mulTo=We,we.prototype.sqrTo=Ye;function cs(A){return this.exp(A,new we)}function fs(A,w,k){var K=Math.min(this.t+A.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,A.data[K],k,K,0,this.t);for($=Math.min(A.t,w);K<$;++K)this.am(0,A.data[K],k,K,0,w-K);k.clamp()}function us(A,w,k){--w;var K=k.t=this.t+A.t-w;for(k.s=0;--K>=0;)k.data[K]=0;for(K=Math.max(w-this.t,0);K<A.t;++K)k.data[this.t+K-w]=this.am(w-K,A.data[K],k,0,0,this.t+K-w);k.clamp(),k.drShiftTo(1,k)}function Pt(A){this.r2=i(),this.q3=i(),r.ONE.dlShiftTo(2*A.t,this.r2),this.mu=this.r2.divide(A),this.m=A}function ls(A){if(A.s<0||A.t>2*this.m.t)return A.mod(this.m);if(A.compareTo(this.m)<0)return A;var w=i();return A.copyTo(w),this.reduce(w),w}function ds(A){return A}function ps(A){for(A.drShiftTo(this.m.t-1,this.r2),A.t>this.m.t+1&&(A.t=this.m.t+1,A.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);A.compareTo(this.r2)<0;)A.dAddOffset(1,this.m.t+1);for(A.subTo(this.r2,A);A.compareTo(this.m)>=0;)A.subTo(this.m,A)}function hs(A,w){A.squareTo(w),this.reduce(w)}function vs(A,w,k){A.multiplyTo(w,k),this.reduce(k)}Pt.prototype.convert=ls,Pt.prototype.revert=ds,Pt.prototype.reduce=ps,Pt.prototype.mulTo=vs,Pt.prototype.sqrTo=hs;function gs(A,w){var k=A.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 W(w);var se=new Array,ae=3,Se=K-1,je=(1<<K)-1;if(se[1]=Y.convert(this),K>1){var ot=i();for(Y.sqrTo(se[1],ot);ae<=je;)se[ae]=i(),Y.mulTo(ot,se[ae-2],se[ae]),ae+=2}var at=A.t-1,yt,Yt=!0,ft=i(),ut;for(k=s(A.data[at])-1;at>=0;){for(k>=Se?yt=A.data[at]>>k-Se&je:(yt=(A.data[at]&(1<<k+1)-1)<<Se-k,at>0&&(yt|=A.data[at-1]>>this.DB+k-Se)),ae=K;(yt&1)==0;)yt>>=1,--ae;if((k-=ae)<0&&(k+=this.DB,--at),Yt)se[yt].copyTo($),Yt=!1;else{for(;ae>1;)Y.sqrTo($,ft),Y.sqrTo(ft,$),ae-=2;ae>0?Y.sqrTo($,ft):(ut=$,$=ft,ft=ut),Y.mulTo(ft,se[yt],$)}for(;at>=0&&(A.data[at]&1<<k)==0;)Y.sqrTo($,ft),ut=$,$=ft,ft=ut,--k<0&&(k=this.DB-1,--at)}return Y.revert($)}function ys(A){var w=this.s<0?this.negate():this.clone(),k=A.s<0?A.negate():A.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 ms(A){if(A<=0)return 0;var w=this.DV%A,k=this.s<0?A-1:0;if(this.t>0)if(w==0)k=this.data[0]%A;else for(var K=this.t-1;K>=0;--K)k=(w*k+this.data[K])%A;return k}function Cs(A){if(this.signum()==0)return r.ZERO;var w=A.isEven();if(this.isEven()&&w||A.signum()==0)return r.ZERO;for(var k=A.clone(),K=this.clone(),$=C(1),Y=C(0),se=C(0),ae=C(1);k.signum()!=0;){for(;k.isEven();)k.rShiftTo(1,k),w?((!$.isEven()||!Y.isEven())&&($.addTo(this,$),Y.subTo(A,Y)),$.rShiftTo(1,$)):Y.isEven()||Y.subTo(A,Y),Y.rShiftTo(1,Y);for(;K.isEven();)K.rShiftTo(1,K),w?((!se.isEven()||!ae.isEven())&&(se.addTo(this,se),ae.subTo(A,ae)),se.rShiftTo(1,se)):ae.isEven()||ae.subTo(A,ae),ae.rShiftTo(1,ae);k.compareTo(K)>=0?(k.subTo(K,k),w&&$.subTo(se,$),Y.subTo(ae,Y)):(K.subTo(k,K),w&&se.subTo($,se),ae.subTo(Y,ae))}if(K.compareTo(r.ONE)!=0)return r.ZERO;if(ae.compareTo(A)>=0)return ae.subtract(A);if(ae.signum()<0)ae.addTo(A,ae);else return ae;return ae.signum()<0?ae.add(A):ae}var ct=[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],Es=(1<<26)/ct[ct.length-1];function xs(A){var w,k=this.abs();if(k.t==1&&k.data[0]<=ct[ct.length-1]){for(w=0;w<ct.length;++w)if(k.data[0]==ct[w])return!0;return!1}if(k.isEven())return!1;for(w=1;w<ct.length;){for(var K=ct[w],$=w+1;$<ct.length&&K<Es;)K*=ct[$++];for(K=k.modInt(K);w<$;)if(K%ct[w++]==0)return!1}return k.millerRabin(A)}function Ss(A){var w=this.subtract(r.ONE),k=w.getLowestSetBit();if(k<=0)return!1;for(var K=w.shiftRight(k),$=bs(),Y,se=0;se<A;++se){do Y=new r(this.bitLength(),$);while(Y.compareTo(r.ONE)<=0||Y.compareTo(w)>=0);var ae=Y.modPow(K,this);if(ae.compareTo(r.ONE)!=0&&ae.compareTo(w)!=0){for(var Se=1;Se++<k&&ae.compareTo(w)!=0;)if(ae=ae.modPowInt(2,this),ae.compareTo(r.ONE)==0)return!1;if(ae.compareTo(w)!=0)return!1}}return!0}function bs(){return{nextBytes:function(A){for(var w=0;w<A.length;++w)A[w]=Math.floor(Math.random()*256)}}}return r.prototype.chunkSize=ne,r.prototype.toRadix=J,r.prototype.fromRadix=fe,r.prototype.fromNumber=me,r.prototype.bitwiseTo=Ie,r.prototype.changeBit=xt,r.prototype.addTo=Oe,r.prototype.dMultiply=Qe,r.prototype.dAddOffset=$e,r.prototype.multiplyLowerTo=fs,r.prototype.multiplyUpperTo=us,r.prototype.modInt=ms,r.prototype.millerRabin=Ss,r.prototype.clone=T,r.prototype.intValue=V,r.prototype.byteValue=G,r.prototype.shortValue=Z,r.prototype.signum=z,r.prototype.toByteArray=ue,r.prototype.equals=Te,r.prototype.min=Ne,r.prototype.max=Be,r.prototype.and=be,r.prototype.or=_e,r.prototype.xor=Pe,r.prototype.andNot=Ze,r.prototype.not=te,r.prototype.shiftLeft=re,r.prototype.shiftRight=ie,r.prototype.getLowestSetBit=xe,r.prototype.bitCount=st,r.prototype.testBit=vt,r.prototype.setBit=gt,r.prototype.clearBit=ke,r.prototype.flipBit=Ve,r.prototype.add=Fe,r.prototype.subtract=Ke,r.prototype.multiply=Me,r.prototype.divide=He,r.prototype.remainder=Ge,r.prototype.divideAndRemainder=ze,r.prototype.modPow=gs,r.prototype.modInverse=Cs,r.prototype.pow=cs,r.prototype.gcd=ys,r.prototype.isProbablePrime=xs,r.prototype.square=qe,Vr}var Or={exports:{}},Fr={exports:{}},tn;function Qt(){if(tn)return Fr.exports;tn=1;var t=ge();Et(),Ce();var e=Fr.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){i||p();var c=null,a=t.util.createBuffer(),g=new Array(80),l={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return l.start=function(){l.messageLength=0,l.fullMessageLength=l.messageLength64=[];for(var x=l.messageLengthSize/4,L=0;L<x;++L)l.fullMessageLength.push(0);return a=t.util.createBuffer(),c={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},l},l.start(),l.update=function(x,L){L==="utf8"&&(x=t.util.encodeUtf8(x));var b=x.length;l.messageLength+=b,b=[b/4294967296>>>0,b>>>0];for(var u=l.fullMessageLength.length-1;u>=0;--u)l.fullMessageLength[u]+=b[1],b[1]=b[0]+(l.fullMessageLength[u]/4294967296>>>0),l.fullMessageLength[u]=l.fullMessageLength[u]>>>0,b[0]=b[1]/4294967296>>>0;return a.putBytes(x),v(c,g,a),(a.read>2048||a.length()===0)&&a.compact(),l},l.digest=function(){var x=t.util.createBuffer();x.putBytes(a.bytes());var L=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize,b=L&l.blockLength-1;x.putBytes(r.substr(0,l.blockLength-b));for(var u,m,E=l.fullMessageLength[0]*8,C=0;C<l.fullMessageLength.length-1;++C)u=l.fullMessageLength[C+1]*8,m=u/4294967296>>>0,E+=m,x.putInt32(E>>>0),E=u>>>0;x.putInt32(E);var o={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};v(o,g,x);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},l};var r=null,i=!1;function p(){r="",r+=t.util.fillString("\0",64),i=!0}function v(c,a,g){for(var l,x,L,b,u,m,E,C,o=g.length();o>=64;){for(x=c.h0,L=c.h1,b=c.h2,u=c.h3,m=c.h4,C=0;C<16;++C)l=g.getInt32(),a[C]=l,E=u^L&(b^u),l=(x<<5|x>>>27)+E+m+1518500249+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;for(;C<20;++C)l=a[C-3]^a[C-8]^a[C-14]^a[C-16],l=l<<1|l>>>31,a[C]=l,E=u^L&(b^u),l=(x<<5|x>>>27)+E+m+1518500249+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;for(;C<32;++C)l=a[C-3]^a[C-8]^a[C-14]^a[C-16],l=l<<1|l>>>31,a[C]=l,E=L^b^u,l=(x<<5|x>>>27)+E+m+1859775393+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;for(;C<40;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=L^b^u,l=(x<<5|x>>>27)+E+m+1859775393+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;for(;C<60;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=L&b|u&(L^b),l=(x<<5|x>>>27)+E+m+2400959708+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;for(;C<80;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=L^b^u,l=(x<<5|x>>>27)+E+m+3395469782+l,m=u,u=b,b=(L<<30|L>>>2)>>>0,L=x,x=l;c.h0=c.h0+x|0,c.h1=c.h1+L|0,c.h2=c.h2+b|0,c.h3=c.h3+u|0,c.h4=c.h4+m|0,o-=64}}return Fr.exports}var rn;function ai(){if(rn)return Or.exports;rn=1;var t=ge();Ce(),lt(),Qt();var e=Or.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(i,p,v){var c,a,g,l;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&&(l=v.mgf1.md)),g?g.start():g=t.md.sha1.create(),l||(l=g);var x=Math.ceil(i.n.bitLength()/8),L=x-2*g.digestLength-2;if(p.length>L){var b=new Error("RSAES-OAEP input message length is too long.");throw b.length=p.length,b.maxLength=L,b}c||(c=""),g.update(c,"raw");for(var u=g.digest(),m="",E=L-p.length,C=0;C<E;C++)m+="\0";var o=u.getBytes()+m+""+p;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,x-g.digestLength-1,l),y=t.util.xorBytes(o,h,o.length),I=r(y,g.digestLength,l),R=t.util.xorBytes(a,I,a.length);return"\0"+R+y},e.decode_rsa_oaep=function(i,p,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 l=Math.ceil(i.n.bitLength()/8);if(p.length!==l){var y=new Error("RSAES-OAEP encoded message length is invalid.");throw y.length=p.length,y.expectedLength=l,y}if(a===void 0?a=t.md.sha1.create():a.start(),g||(g=a),l<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 x=a.digest().getBytes(),L=p.charAt(0),b=p.substring(1,a.digestLength+1),u=p.substring(1+a.digestLength),m=r(u,a.digestLength,g),E=t.util.xorBytes(b,m,b.length),C=r(E,l-a.digestLength-1,g),o=t.util.xorBytes(u,C,u.length),h=o.substring(0,a.digestLength),y=L!=="\0",I=0;I<a.digestLength;++I)y|=x.charAt(I)!==h.charAt(I);for(var R=1,d=a.digestLength,s=a.digestLength;s<o.length;s++){var n=o.charCodeAt(s),B=n&1^1,P=R?65534:0;y|=n&P,R=R&B,d+=R}if(y||o.charCodeAt(d)!==1)throw new Error("Invalid RSAES-OAEP padding.");return o.substring(d+1)};function r(i,p,v){v||(v=t.md.sha1.create());for(var c="",a=Math.ceil(p/v.digestLength),g=0;g<a;++g){var l=String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,g&255);v.start(),v.update(i+l),c+=v.digest().getBytes()}return c.substring(0,p)}return Or.exports}var Zt={exports:{}},an;function ni(){if(an)return Zt.exports;an=1;var t=ge();return Ce(),ur(),lt(),(function(){if(t.prime){Zt.exports=t.prime;return}var e=Zt.exports=t.prime=t.prime||{},r=t.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],p=new r(null);p.fromInt(30);var v=function(b,u){return b|u};e.generateProbablePrime=function(b,u,m){typeof u=="function"&&(m=u,u={}),u=u||{};var E=u.algorithm||"PRIMEINC";typeof E=="string"&&(E={name:E}),E.options=E.options||{};var C=u.prng||t.random,o={nextBytes:function(h){for(var y=C.getBytesSync(h.length),I=0;I<h.length;++I)h[I]=y.charCodeAt(I)}};if(E.name==="PRIMEINC")return c(b,o,E.options,m);throw new Error("Invalid prime generation algorithm: "+E.name)};function c(b,u,m,E){return"workers"in m?l(b,u,m,E):a(b,u,m,E)}function a(b,u,m,E){var C=x(b,u),o=0,h=L(C.bitLength());"millerRabinTests"in m&&(h=m.millerRabinTests);var y=10;"maxBlockTime"in m&&(y=m.maxBlockTime),g(C,b,u,o,h,y,E)}function g(b,u,m,E,C,o,h){var y=+new Date;do{if(b.bitLength()>u&&(b=x(u,m)),b.isProbablePrime(C))return h(null,b);b.dAddOffset(i[E++%8],0)}while(o<0||+new Date-y<o);t.util.setImmediate(function(){g(b,u,m,E,C,o,h)})}function l(b,u,m,E){if(typeof Worker>"u")return a(b,u,m,E);var C=x(b,u),o=m.workers,h=m.workLoad||100,y=h*30/8,I=m.workerScript||"forge/prime.worker.js";if(o===-1)return t.util.estimateCores(function(d,s){d&&(s=2),o=s-1,R()});R();function R(){o=Math.max(1,o);for(var d=[],s=0;s<o;++s)d[s]=new Worker(I);for(var s=0;s<o;++s)d[s].addEventListener("message",B);var n=!1;function B(P){if(!n){var O=P.data;if(O.found){for(var U=0;U<d.length;++U)d[U].terminate();return n=!0,E(null,new r(O.prime,16))}C.bitLength()>b&&(C=x(b,u));var F=C.toString(16);P.target.postMessage({hex:F,workLoad:h}),C.dAddOffset(y,0)}}}}function x(b,u){var m=new r(b,u),E=b-1;return m.testBit(E)||m.bitwiseTo(r.ONE.shiftLeft(E),v,m),m.dAddOffset(31-m.mod(p).byteValue(),0),m}function L(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}})(),Zt.exports}var Kr,nn;function lr(){if(nn)return Kr;nn=1;var t=ge();if(ht(),ur(),Lt(),ai(),ni(),lt(),Ce(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.util.isNodejs?Ca:null,i=t.asn1,p=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"}]},l={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"}]},x=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"}]}]},L={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 P=i.oidToDer(n).getBytes(),O=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,P)),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 O.value.push(U),O.value.push(F),i.toDer(O).getBytes()},u=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 P;do P=new e(t.util.bytesToHex(t.random.getBytes(n.n.bitLength()/8)),16);while(P.compareTo(n.n)>=0||!P.gcd(n.n).equals(e.ONE));s=s.multiply(P.modPow(n.e,n.n)).mod(n.n);for(var O=s.mod(n.p).modPow(n.dP,n.p),U=s.mod(n.q).modPow(n.dQ,n.q);O.compareTo(U)<0;)O=O.add(n.p);var F=O.subtract(U).multiply(n.qInv).mod(n.p).multiply(n.q).add(U);return F=F.multiply(P.modInverse(n.n)).mod(n.n),F};v.rsa.encrypt=function(s,n,B){var P=B,O,U=Math.ceil(n.n.bitLength()/8);B!==!1&&B!==!0?(P=B===2,O=m(s,n,B)):(O=t.util.createBuffer(),O.putBytes(s));for(var F=new e(O.toHex(),16),q=u(F,n,P),M=q.toString(16),H=t.util.createBuffer(),Q=U-Math.ceil(M.length/2);Q>0;)H.putByte(0),--Q;return H.putBytes(t.util.hexToBytes(M)),H.getBytes()},v.rsa.decrypt=function(s,n,B,P){var O=Math.ceil(n.n.bitLength()/8);if(s.length!==O){var U=new Error("Encrypted message length is invalid.");throw U.length=s.length,U.expected=O,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=u(F,n,B),M=q.toString(16),H=t.util.createBuffer(),Q=O-Math.ceil(M.length/2);Q>0;)H.putByte(0),--Q;return H.putBytes(t.util.hexToBytes(M)),P!==!1?E(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 P=B.prng||t.random,O={nextBytes:function(q){for(var M=P.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:O,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 P=0,O=function(j,ee){return j|ee},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),O,s.num),s.num.dAddOffset(31-s.num.mod(B).byteValue(),0),P=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[P++%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 Q=s.e.modInverse(s.phi);s.keys={privateKey:v.rsa.setPrivateKey(s.n,s.e,Q,s.p,s.q,Q.mod(s.p1),Q.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,P){if(arguments.length===1?typeof s=="object"?(B=s,s=void 0):typeof s=="function"&&(P=s,s=void 0):arguments.length===2?typeof s=="number"?typeof n=="function"?(P=n,n=void 0):typeof n!="number"&&(B=n,n=void 0):(B=s,P=n,s=void 0,n=void 0):arguments.length===3&&(typeof n=="number"?typeof B=="function"&&(P=B,B=void 0):(P=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(P){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 P(q);P(null,{privateKey:v.privateKeyFromPem(H),publicKey:v.publicKeyFromPem(M)})});if(I("generateKey")&&I("exportKey"))return p.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(q){return p.globalScope.crypto.subtle.exportKey("pkcs8",q.privateKey)}).then(void 0,function(q){P(q)}).then(function(q){if(q){var M=v.privateKeyFromAsn1(i.fromDer(t.util.createBuffer(q)));P(null,{privateKey:M,publicKey:v.setRsaPublicKey(M.n,M.e)})}});if(R("generateKey")&&R("exportKey")){var O=p.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]);O.oncomplete=function(q){var M=q.target.result,H=p.globalScope.msCrypto.subtle.exportKey("pkcs8",M.privateKey);H.oncomplete=function(Q){var j=Q.target.result,ee=v.privateKeyFromAsn1(i.fromDer(t.util.createBuffer(j)));P(null,{privateKey:ee,publicKey:v.setRsaPublicKey(ee.n,ee.e)})},H.onerror=function(Q){P(Q)}},O.onerror=function(q){P(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(!P)return v.rsa.stepKeyPairGenerationState(F,0),F.keys;C(F,B,P)},v.setRsaPublicKey=v.rsa.setPublicKey=function(s,n){var B={n:s,e:n};return B.encrypt=function(P,O,U){if(typeof O=="string"?O=O.toUpperCase():O===void 0&&(O="RSAES-PKCS1-V1_5"),O==="RSAES-PKCS1-V1_5")O={encode:function(q,M,H){return m(q,M,2).getBytes()}};else if(O==="RSA-OAEP"||O==="RSAES-OAEP")O={encode:function(q,M){return t.pkcs1.encode_rsa_oaep(M,q,U)}};else if(["RAW","NONE","NULL",null].indexOf(O)!==-1)O={encode:function(q){return q}};else if(typeof O=="string")throw new Error('Unsupported encryption scheme: "'+O+'".');var F=O.encode(P,B,!0);return v.rsa.encrypt(F,B,!0)},B.verify=function(P,O,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=E(H,B,!0,void 0,F);var Q=i.fromDer(H,{parseAllBytes:F._parseAllDigestBytes}),j={},ee=[];if(!i.validate(Q,L,j,ee)||Q.value.length!==2){var oe=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw oe.errors=ee,oe}var ce=i.derToOid(j.algorithmIdentifier);if(!(ce===t.oids.md2||ce===t.oids.md5||ce===t.oids.sha1||ce===t.oids.sha224||ce===t.oids.sha256||ce===t.oids.sha384||ce===t.oids.sha512||ce===t.oids["sha512-224"]||ce===t.oids["sha512-256"])){var oe=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw oe.oid=ce,oe}if((ce===t.oids.md2||ce===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=E(H,B,!0,void 0,F),M===H}});var q=v.rsa.decrypt(O,B,!0,!1);return U.verify(P,q,B.n.bitLength())},B},v.setRsaPrivateKey=v.rsa.setPrivateKey=function(s,n,B,P,O,U,F,q){var M={n:s,e:n,d:B,p:P,q:O,dP:U,dQ:F,qInv:q};return M.decrypt=function(H,Q,j){typeof Q=="string"?Q=Q.toUpperCase():Q===void 0&&(Q="RSAES-PKCS1-V1_5");var ee=v.rsa.decrypt(H,M,!1,!1);if(Q==="RSAES-PKCS1-V1_5")Q={decode:E};else if(Q==="RSA-OAEP"||Q==="RSAES-OAEP")Q={decode:function(oe,ce){return t.pkcs1.decode_rsa_oaep(ce,oe,j)}};else if(["RAW","NONE","NULL",null].indexOf(Q)!==-1)Q={decode:function(oe){return oe}};else throw new Error('Unsupported encryption scheme: "'+Q+'".');return Q.decode(ee,M,!1)},M.sign=function(H,Q){var j=!1;typeof Q=="string"&&(Q=Q.toUpperCase()),Q===void 0||Q==="RSASSA-PKCS1-V1_5"?(Q={encode:b},j=1):(Q==="NONE"||Q==="NULL"||Q===null)&&(Q={encode:function(){return H}},j=1);var ee=Q.encode(H,M.n.bitLength());return v.rsa.encrypt(ee,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 P=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw P.errors=B,P}var O,U,F,q,M,H,Q,j;return O=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(),Q=t.util.createBuffer(n.privateKeyExponent2).toHex(),j=t.util.createBuffer(n.privateKeyCoefficient).toHex(),v.setRsaPrivateKey(new e(O,16),new e(U,16),new e(F,16),new e(q,16),new e(M,16),new e(H,16),new e(Q,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,x,n,B)){var P=i.derToOid(n.publicKeyOid);if(P!==v.oids.rsaEncryption){var O=new Error("Cannot read public key. Unknown OID.");throw O.oid=P,O}s=n.rsaPublicKey}if(B=[],!i.validate(s,l,n,B)){var O=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw O.errors=B,O}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 P=t.util.createBuffer(),O=Math.ceil(n.n.bitLength()/8);if(s.length>O-11){var U=new Error("Message is too long for PKCS#1 v1.5 padding.");throw U.length=s.length,U.max=O-11,U}P.putByte(0),P.putByte(B);var F=O-3-s.length,q;if(B===0||B===1){q=B===0?0:255;for(var M=0;M<F;++M)P.putByte(q)}else for(;F>0;){for(var H=0,Q=t.random.getBytes(F),M=0;M<F;++M)q=Q.charCodeAt(M),q===0?++H:P.putByte(q);F=H}return P.putByte(0),P.putBytes(s),P}function E(s,n,B,P,O){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 P>"u")throw new Error("Encryption block is invalid.");var H=0;if(M===0){H=U-3-P;for(var Q=0;Q<H;++Q)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&&!(O&&O._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&&!(O&&O._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 P={algorithm:{name:n.algorithm||"PRIMEINC",options:{workers:n.workers||2,workLoad:n.workLoad||100,workerScript:n.workerScript}}};"prng"in n&&(P.prng=n.prng),O();function O(){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,P,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,O();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,O();return}if(s.n=s.p.multiply(s.q),s.n.bitLength()!==s.bits){s.q=null,U(s.qBits,F);return}var Q=s.e.modInverse(s.phi);s.keys={privateKey:v.rsa.setPrivateKey(s.n,s.e,Q,s.p,s.q,Q.mod(s.p1),Q.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 I(s){return typeof p.globalScope<"u"&&typeof p.globalScope.crypto=="object"&&typeof p.globalScope.crypto.subtle=="object"&&typeof p.globalScope.crypto.subtle[s]=="function"}function R(s){return typeof p.globalScope<"u"&&typeof p.globalScope.msCrypto=="object"&&typeof p.globalScope.msCrypto.subtle=="object"&&typeof p.globalScope.msCrypto.subtle[s]=="function"}function d(s){for(var n=t.util.hexToBytes(s.toString(16)),B=new Uint8Array(n.length),P=0;P<n.length;++P)B[P]=n.charCodeAt(P);return B}return Kr}var Mr,sn;function ii(){if(sn)return Mr;sn=1;var t=ge();if(Dt(),ht(),fr(),Et(),Lt(),Ea(),Vt(),lt(),ri(),lr(),Ce(),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 p=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,u,m){m=m||{},m.saltSize=m.saltSize||8,m.count=m.count||2048,m.algorithm=m.algorithm||"aes128",m.prfAlgorithm=m.prfAlgorithm||"sha1";var E=t.random.getBytesSync(m.saltSize),C=m.count,o=r.integerToDer(C),h,y,I;if(m.algorithm.indexOf("aes")===0||m.algorithm==="des"){var R,d,s;switch(m.algorithm){case"aes128":h=16,R=16,d=p["aes128-CBC"],s=t.aes.createEncryptionCipher;break;case"aes192":h=24,R=16,d=p["aes192-CBC"],s=t.aes.createEncryptionCipher;break;case"aes256":h=32,R=16,d=p["aes256-CBC"],s=t.aes.createEncryptionCipher;break;case"des":h=8,R=8,d=p.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(),P=x(B),O=t.pkcs5.pbkdf2(u,E,C,h,P),U=t.random.getBytesSync(R),F=s(O);F.start(U),F.update(r.toDer(b)),F.finish(),I=F.output.getBytes();var q=L(E,o,h,B);y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p.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(p.pkcs5PBKDF2).getBytes()),q]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(d).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,U)])])])}else if(m.algorithm==="3des"){h=24;var M=new t.util.ByteBuffer(E),O=i.pbe.generatePkcs12Key(u,M,1,C,h),U=i.pbe.generatePkcs12Key(u,M,2,C,h),F=t.des.createEncryptionCipher(O);F.start(U),F.update(r.toDer(b)),F.finish(),I=F.output.getBytes(),y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,E),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,I)]);return H},i.decryptPrivateKeyInfo=function(b,u){var m=null,E={},C=[];if(!r.validate(b,v,E,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(E.encryptionOid),y=i.pbe.getCipher(h,E.encryptionParams,u),I=t.util.createBuffer(E.encryptedData);return y.update(I),y.finish()&&(m=r.fromDer(y.output)),m},i.encryptedPrivateKeyToPem=function(b,u){var m={type:"ENCRYPTED PRIVATE KEY",body:r.toDer(b).getBytes()};return t.pem.encode(m,{maxline:u})},i.encryptedPrivateKeyFromPem=function(b){var u=t.pem.decode(b)[0];if(u.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=u.type,m}if(u.procType&&u.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return r.fromDer(u.body)},i.encryptRsaPrivateKey=function(b,u,m){if(m=m||{},!m.legacy){var E=i.wrapRsaPrivateKey(i.privateKeyToAsn1(b));return E=i.encryptPrivateKeyInfo(E,u,m),i.encryptedPrivateKeyToPem(E)}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 I=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+m.algorithm+'".');throw I.algorithm=m.algorithm,I}var R=t.pbe.opensslDeriveBytes(u,o.substr(0,8),h),d=y(R);d.start(o),d.update(r.toDer(i.privateKeyToAsn1(b))),d.finish();var s={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:C,parameters:t.util.bytesToHex(o).toUpperCase()},body:d.output.getBytes()};return t.pem.encode(s)},i.decryptRsaPrivateKey=function(b,u){var m=null,E=t.pem.decode(b)[0];if(E.type!=="ENCRYPTED PRIVATE KEY"&&E.type!=="PRIVATE KEY"&&E.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(E.procType&&E.procType.type==="ENCRYPTED"){var o,h;switch(E.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 "'+E.dekInfo.algorithm+'".');throw C.algorithm=E.dekInfo.algorithm,C}var y=t.util.hexToBytes(E.dekInfo.parameters),I=t.pbe.opensslDeriveBytes(u,y.substr(0,8),o),R=h(I);if(R.start(y),R.update(t.util.createBuffer(E.body)),R.finish())m=R.output.getBytes();else return m}else m=E.body;return E.type==="ENCRYPTED PRIVATE KEY"?m=i.decryptPrivateKeyInfo(r.fromDer(m),u):m=r.fromDer(m),m!==null&&(m=i.privateKeyFromAsn1(m)),m},i.pbe.generatePkcs12Key=function(b,u,m,E,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 I=o.digestLength,R=o.blockLength,d=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=u.length(),P=new t.util.ByteBuffer;P.fillWithByte(m,R);var O=R*Math.ceil(B/R),U=new t.util.ByteBuffer;for(y=0;y<O;y++)U.putByte(u.at(y%B));var F=R*Math.ceil(n/R),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/I),Q=1;Q<=H;Q++){var j=new t.util.ByteBuffer;j.putBytes(P.bytes()),j.putBytes(M.bytes());for(var ee=0;ee<E;ee++)o.start(),o.update(j.getBytes()),j=o.digest();var oe=new t.util.ByteBuffer;for(y=0;y<R;y++)oe.putByte(j.at(y%I));var ce=Math.ceil(B/R)+Math.ceil(n/R),he=new t.util.ByteBuffer;for(h=0;h<ce;h++){var pe=new t.util.ByteBuffer(M.getBytes(R)),ve=511;for(y=oe.length()-1;y>=0;y--)ve=ve>>8,ve+=oe.at(y)+pe.at(y),pe.setAt(y,ve&255);he.putBuffer(pe)}M=he,d.putBuffer(j)}return d.truncate(d.length()-C),d},i.pbe.getCipher=function(b,u,m){switch(b){case i.oids.pkcs5PBES2:return i.pbe.getCipherForPBES2(b,u,m);case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case i.oids["pbewithSHAAnd40BitRC2-CBC"]:return i.pbe.getCipherForPKCS12PBE(b,u,m);default:var E=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw E.oid=b,E.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],E}},i.pbe.getCipherForPBES2=function(b,u,m){var E={},C=[];if(!r.validate(u,c,E,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(E.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(E.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=E.kdfSalt,y=t.util.createBuffer(E.kdfIterationCount);y=y.getInt(y.length()<<3);var I,R;switch(i.oids[b]){case"aes128-CBC":I=16,R=t.aes.createDecryptionCipher;break;case"aes192-CBC":I=24,R=t.aes.createDecryptionCipher;break;case"aes256-CBC":I=32,R=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":I=24,R=t.des.createDecryptionCipher;break;case"desCBC":I=8,R=t.des.createDecryptionCipher;break}var d=l(E.prfOid),s=t.pkcs5.pbkdf2(m,h,y,I,d),n=E.encIv,B=R(s);return B.start(n),B},i.pbe.getCipherForPKCS12PBE=function(b,u,m){var E={},C=[];if(!r.validate(u,a,E,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(E.salt),y=t.util.createBuffer(E.iterations);y=y.getInt(y.length()<<3);var I,R,d;switch(b){case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:I=24,R=8,d=t.des.startDecrypting;break;case i.oids["pbewithSHAAnd40BitRC2-CBC"]:I=5,R=8,d=function(O,U){var F=t.rc2.createDecryptionCipher(O,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=l(E.prfOid),n=i.pbe.generatePkcs12Key(m,h,1,y,I,s);s.start();var B=i.pbe.generatePkcs12Key(m,h,2,y,R,s);return d(n,B)},i.pbe.opensslDeriveBytes=function(b,u,m,E){if(typeof E>"u"||E===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');E=t.md.md5.create()}u===null&&(u="");for(var C=[g(E,b+u)],o=16,h=1;o<m;++h,o+=16)C.push(g(E,C[h-1]+b+u));return C.join("").substr(0,m)};function g(b,u){return b.start().update(u).digest().getBytes()}function l(b){var u;if(!b)u="hmacWithSHA1";else if(u=i.oids[r.derToOid(b)],!u){var m=new Error("Unsupported PRF OID.");throw m.oid=b,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}return x(u)}function x(b){var u=t.md;switch(b){case"hmacWithSHA224":u=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(!u||!(b in u))throw new Error("Unknown hash algorithm: "+b);return u[b].create()}function L(b,u,m,E){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,u.getBytes())]);return E!=="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[E]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")])),C}return Mr}var qr={exports:{}},Hr={exports:{}},on;function si(){if(on)return Hr.exports;on=1;var t=ge();ht(),Ce();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 p={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(p)},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(p)};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 oi(){if(cn)return zr.exports;cn=1;var t=ge();Ce(),t.mgf=t.mgf||{};var e=zr.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};return e.create=function(r){var i={generate:function(p,v){for(var c=new t.util.ByteBuffer,a=Math.ceil(v/r.digestLength),g=0;g<a;g++){var l=new t.util.ByteBuffer;l.putInt32(g),r.start(),r.update(p+l.getBytes()),c.putBuffer(r.digest())}return c.truncate(c.length()-v),c.getBytes()}};return i},zr.exports}var Qr,fn;function Ms(){if(fn)return Qr;fn=1;var t=ge();return oi(),Qr=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1,Qr}var $r={exports:{}},un;function xa(){if(un)return $r.exports;un=1;var t=ge();lt(),Ce();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,p=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,l={};return l.encode=function(x,L){var b,u=L-1,m=Math.ceil(u/8),E=x.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(E),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 I=y.getBytes(),R=m-v-1,d=p.generate(h,R),s="";for(b=0;b<R;b++)s+=String.fromCharCode(I.charCodeAt(b)^d.charCodeAt(b));var n=65280>>8*m-u&255;return s=String.fromCharCode(s.charCodeAt(0)&~n)+s.substr(1),s+h+"¼"},l.verify=function(x,L,b){var u,m=b-1,E=Math.ceil(m/8);if(L=L.substr(-E),E<v+a+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(L.charCodeAt(E-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var C=E-v-1,o=L.substr(0,C),h=L.substr(C,v),y=65280>>8*E-m&255;if((o.charCodeAt(0)&y)!==0)throw new Error("Bits beyond keysize not zero as expected.");var I=p.generate(h,C),R="";for(u=0;u<C;u++)R+=String.fromCharCode(o.charCodeAt(u)^I.charCodeAt(u));R=String.fromCharCode(R.charCodeAt(0)&~y)+R.substr(1);var d=E-v-a-2;for(u=0;u<d;u++)if(R.charCodeAt(u)!==0)throw new Error("Leftmost octets not zero as expected");if(R.charCodeAt(d)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var s=R.substr(-a),n=new t.util.ByteBuffer;n.fillWithByte(0,8),n.putBytes(x),n.putBytes(s),i.start(),i.update(n.getBytes());var B=i.digest().getBytes();return h===B},l},$r.exports}var ln;function Sa(){if(ln)return Gr.exports;ln=1;var t=ge();Dt(),ht(),fr(),Et(),Ms(),Lt(),Vt(),xa(),lr(),Ce();var e=t.asn1,r=Gr.exports=t.pki=t.pki||{},i=r.oids,p={};p.CN=i.commonName,p.commonName="CN",p.C=i.countryName,p.countryName="C",p.L=i.localityName,p.localityName="L",p.ST=i.stateOrProvinceName,p.stateOrProvinceName="ST",p.O=i.organizationName,p.organizationName="O",p.OU=i.organizationalUnitName,p.organizationalUnitName="OU",p.E=i.emailAddress,p.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}]}]}]},l={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(d,s){for(var n=[],B,P,O,U=0;U<d.value.length;++U){B=d.value[U];for(var F=0;F<B.value.length;++F)O={},P=B.value[F],O.type=e.derToOid(P.value[0].value),O.value=P.value[1].value,O.valueTagClass=P.value[1].type,O.type in i&&(O.name=i[O.type],O.name in p&&(O.shortName=p[O.name])),s&&(s.update(O.type),s.update(O.value)),n.push(O)}return n},r.CRIAttributesAsArray=function(d){for(var s=[],n=0;n<d.length;++n)for(var B=d[n],P=e.derToOid(B.value[0].value),O=B.value[1].value,U=0;U<O.length;++U){var F={};if(F.type=P,F.value=O[U].value,F.valueTagClass=O[U].type,F.type in i&&(F.name=i[F.type],F.name in p&&(F.shortName=p[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 x(d,s){typeof s=="string"&&(s={shortName:s});for(var n=null,B,P=0;n===null&&P<d.attributes.length;++P)B=d.attributes[P],(s.type&&s.type===B.type||s.name&&s.name===B.name||s.shortName&&s.shortName===B.shortName)&&(n=B);return n}var L=function(d,s,n){var B={};if(d!==i["RSASSA-PSS"])return B;n&&(B={hash:{algorithmOid:i.sha1},mgf:{algorithmOid:i.mgf1,hash:{algorithmOid:i.sha1}},saltLength:20});var P={},O=[];if(!e.validate(s,a,P,O)){var U=new Error("Cannot read RSASSA-PSS parameter block.");throw U.errors=O,U}return P.hashOid!==void 0&&(B.hash=B.hash||{},B.hash.algorithmOid=e.derToOid(P.hashOid)),P.maskGenOid!==void 0&&(B.mgf=B.mgf||{},B.mgf.algorithmOid=e.derToOid(P.maskGenOid),B.mgf.hash=B.mgf.hash||{},B.mgf.hash.algorithmOid=e.derToOid(P.maskGenHashOid)),P.saltLength!==void 0&&(B.saltLength=P.saltLength.charCodeAt(0)),B},b=function(d){switch(i[d.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 "+d.type+" digest. Unknown signature OID.");throw s.signatureOid=d.signatureOid,s}},u=function(d){var s=d.certificate,n;switch(s.signatureOid){case i.sha1WithRSAEncryption:case i.sha1WithRSASignature:break;case i["RSASSA-PSS"]:var B,P;if(B=i[s.signatureParameters.mgf.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported MGF hash function.");throw O.oid=s.signatureParameters.mgf.hash.algorithmOid,O.name=B,O}if(P=i[s.signatureParameters.mgf.algorithmOid],P===void 0||t.mgf[P]===void 0){var O=new Error("Unsupported MGF function.");throw O.oid=s.signatureParameters.mgf.algorithmOid,O.name=P,O}if(P=t.mgf[P].create(t.md[B].create()),B=i[s.signatureParameters.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported RSASSA-PSS hash function.");throw O.oid=s.signatureParameters.hash.algorithmOid,O.name=B,O}n=t.pss.create(t.md[B].create(),P,s.signatureParameters.saltLength);break}return s.publicKey.verify(d.md.digest().getBytes(),d.signature,n)};r.certificateFromPem=function(d,s,n){var B=t.pem.decode(d)[0];if(B.type!=="CERTIFICATE"&&B.type!=="X509 CERTIFICATE"&&B.type!=="TRUSTED CERTIFICATE"){var P=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw P.headerType=B.type,P}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=e.fromDer(B.body,n);return r.certificateFromAsn1(O,s)},r.certificateToPem=function(d,s){var n={type:"CERTIFICATE",body:e.toDer(r.certificateToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyFromPem=function(d){var s=t.pem.decode(d)[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(d,s){var n={type:"PUBLIC KEY",body:e.toDer(r.publicKeyToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyToRSAPublicKeyPem=function(d,s){var n={type:"RSA PUBLIC KEY",body:e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.getPublicKeyFingerprint=function(d,s){s=s||{};var n=s.md||t.md.sha1.create(),B=s.type||"RSAPublicKey",P;switch(B){case"RSAPublicKey":P=e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes();break;case"SubjectPublicKeyInfo":P=e.toDer(r.publicKeyToAsn1(d)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+s.type+'".')}n.start(),n.update(P);var O=n.digest();if(s.encoding==="hex"){var U=O.toHex();return s.delimiter?U.match(/.{2}/g).join(s.delimiter):U}else{if(s.encoding==="binary")return O.getBytes();if(s.encoding)throw new Error('Unknown encoding "'+s.encoding+'".')}return O},r.certificationRequestFromPem=function(d,s,n){var B=t.pem.decode(d)[0];if(B.type!=="CERTIFICATE REQUEST"){var P=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw P.headerType=B.type,P}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var O=e.fromDer(B.body,n);return r.certificationRequestFromAsn1(O,s)},r.certificationRequestToPem=function(d,s){var n={type:"CERTIFICATE REQUEST",body:e.toDer(r.certificationRequestToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.createCertificate=function(){var d={};return d.version=2,d.serialNumber="00",d.signatureOid=null,d.signature=null,d.siginfo={},d.siginfo.algorithmOid=null,d.validity={},d.validity.notBefore=new Date,d.validity.notAfter=new Date,d.issuer={},d.issuer.getField=function(s){return x(d.issuer,s)},d.issuer.addField=function(s){E([s]),d.issuer.attributes.push(s)},d.issuer.attributes=[],d.issuer.hash=null,d.subject={},d.subject.getField=function(s){return x(d.subject,s)},d.subject.addField=function(s){E([s]),d.subject.attributes.push(s)},d.subject.attributes=[],d.subject.hash=null,d.extensions=[],d.publicKey=null,d.md=null,d.setSubject=function(s,n){E(s),d.subject.attributes=s,delete d.subject.uniqueId,n&&(d.subject.uniqueId=n),d.subject.hash=null},d.setIssuer=function(s,n){E(s),d.issuer.attributes=s,delete d.issuer.uniqueId,n&&(d.issuer.uniqueId=n),d.issuer.hash=null},d.setExtensions=function(s){for(var n=0;n<s.length;++n)C(s[n],{cert:d});d.extensions=s},d.getExtension=function(s){typeof s=="string"&&(s={name:s});for(var n=null,B,P=0;n===null&&P<d.extensions.length;++P)B=d.extensions[P],(s.id&&B.id===s.id||s.name&&B.name===s.name)&&(n=B);return n},d.sign=function(s,n){d.md=n||t.md.sha1.create();var B=i[d.md.algorithm+"WithRSAEncryption"];if(!B){var P=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw P.algorithm=d.md.algorithm,P}d.signatureOid=d.siginfo.algorithmOid=B,d.tbsCertificate=r.getTBSCertificate(d);var O=e.toDer(d.tbsCertificate);d.md.update(O.getBytes()),d.signature=s.sign(d.md)},d.verify=function(s){var n=!1;if(!d.issued(s)){var B=s.issuer,P=d.subject,O=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 O.expectedIssuer=P.attributes,O.actualIssuer=B.attributes,O}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=u({certificate:d,md:U,signature:s.signature})),n},d.isIssuer=function(s){var n=!1,B=d.issuer,P=s.subject;if(B.hash&&P.hash)n=B.hash===P.hash;else if(B.attributes.length===P.attributes.length){n=!0;for(var O,U,F=0;n&&F<B.attributes.length;++F)O=B.attributes[F],U=P.attributes[F],(O.type!==U.type||O.value!==U.value)&&(n=!1)}return n},d.issued=function(s){return s.isIssuer(d)},d.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(d.publicKey,{type:"RSAPublicKey"})},d.verifySubjectKeyIdentifier=function(){for(var s=i.subjectKeyIdentifier,n=0;n<d.extensions.length;++n){var B=d.extensions[n];if(B.id===s){var P=d.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(B.subjectKeyIdentifier)===P}}return!1},d},r.certificateFromAsn1=function(d,s){var n={},B=[];if(!e.validate(d,c,n,B)){var P=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw P.errors=B,P}var O=e.derToOid(n.publicKeyOid);if(O!==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=L(U.signatureOid,n.certSignatureParams,!0),U.siginfo.algorithmOid=t.asn1.derToOid(n.certinfoSignatureOid),U.siginfo.parameters=L(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(),Q=e.toDer(n.certIssuer);H.update(Q.getBytes()),U.issuer.getField=function(oe){return x(U.issuer,oe)},U.issuer.addField=function(oe){E([oe]),U.issuer.attributes.push(oe)},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(),ee=e.toDer(n.certSubject);return j.update(ee.getBytes()),U.subject.getField=function(oe){return x(U.subject,oe)},U.subject.addField=function(oe){E([oe]),U.subject.attributes.push(oe)},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(d){for(var s=[],n=0;n<d.value.length;++n)for(var B=d.value[n],P=0;P<B.value.length;++P)s.push(r.certificateExtensionFromAsn1(B.value[P]));return s},r.certificateExtensionFromAsn1=function(d){var s={};if(s.id=e.derToOid(d.value[0].value),s.critical=!1,d.value[1].type===e.Type.BOOLEAN?(s.critical=d.value[1].value.charCodeAt(0)!==0,s.value=d.value[2].value):s.value=d.value[1].value,s.id in i){if(s.name=i[s.id],s.name==="keyUsage"){var n=e.fromDer(s.value),B=0,P=0;n.value.length>1&&(B=n.value.charCodeAt(1),P=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=(P&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 O=null;n.value.length>0&&n.value[0].type===e.Type.INTEGER?O=n.value[0].value:n.value.length>1&&(O=n.value[1].value),O!==null&&(s.pathLenConstraint=e.derToInteger(O))}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(d,s){var n={},B=[];if(!e.validate(d,l,n,B)){var P=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw P.errors=B,P}var O=e.derToOid(n.publicKeyOid);if(O!==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=L(U.signatureOid,n.csrSignatureParams,!0),U.siginfo.algorithmOid=t.asn1.derToOid(n.csrSignatureOid),U.siginfo.parameters=L(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 x(U.subject,M)},U.subject.addField=function(M){E([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 x(U,M)},U.addAttribute=function(M){E([M]),U.attributes.push(M)},U.attributes=r.CRIAttributesAsArray(n.certificationRequestInfoAttributes||[]),U},r.createCertificationRequest=function(){var d={};return d.version=0,d.signatureOid=null,d.signature=null,d.siginfo={},d.siginfo.algorithmOid=null,d.subject={},d.subject.getField=function(s){return x(d.subject,s)},d.subject.addField=function(s){E([s]),d.subject.attributes.push(s)},d.subject.attributes=[],d.subject.hash=null,d.publicKey=null,d.attributes=[],d.getAttribute=function(s){return x(d,s)},d.addAttribute=function(s){E([s]),d.attributes.push(s)},d.md=null,d.setSubject=function(s){E(s),d.subject.attributes=s,d.subject.hash=null},d.setAttributes=function(s){E(s),d.attributes=s},d.sign=function(s,n){d.md=n||t.md.sha1.create();var B=i[d.md.algorithm+"WithRSAEncryption"];if(!B){var P=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw P.algorithm=d.md.algorithm,P}d.signatureOid=d.siginfo.algorithmOid=B,d.certificationRequestInfo=r.getCertificationRequestInfo(d);var O=e.toDer(d.certificationRequestInfo);d.md.update(O.getBytes()),d.signature=s.sign(d.md)},d.verify=function(){var s=!1,n=d.md;if(n===null){n=b({signatureOid:d.signatureOid,type:"certification request"});var B=d.certificationRequestInfo||r.getCertificationRequestInfo(d),P=e.toDer(B);n.update(P.getBytes())}return n!==null&&(s=u({certificate:d,md:n,signature:d.signature})),s},d};function m(d){for(var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),n,B,P=d.attributes,O=0;O<P.length;++O){n=P[O];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 E(d){for(var s,n=0;n<d.length;++n){if(s=d[n],typeof s.name>"u"&&(s.type&&s.type in r.oids?s.name=r.oids[s.type]:s.shortName&&s.shortName in p&&(s.name=r.oids[p[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 p&&(s.shortName=p[s.name]),s.type===i.extensionRequest&&(s.valueConstructed=!0,s.valueTagClass=e.Type.SEQUENCE,!s.value&&s.extensions)){s.value=[];for(var P=0;P<s.extensions.length;++P)s.value.push(r.certificateExtensionToAsn1(C(s.extensions[P])))}if(typeof s.value>"u"){var B=new Error("Attribute value not specified.");throw B.attribute=s,B}}}function C(d,s){if(s=s||{},typeof d.name>"u"&&d.id&&d.id in r.oids&&(d.name=r.oids[d.id]),typeof d.id>"u")if(d.name&&d.name in r.oids)d.id=r.oids[d.name];else{var n=new Error("Extension ID not specified.");throw n.extension=d,n}if(typeof d.value<"u")return d;if(d.name==="keyUsage"){var B=0,P=0,O=0;d.digitalSignature&&(P|=128,B=7),d.nonRepudiation&&(P|=64,B=6),d.keyEncipherment&&(P|=32,B=5),d.dataEncipherment&&(P|=16,B=4),d.keyAgreement&&(P|=8,B=3),d.keyCertSign&&(P|=4,B=2),d.cRLSign&&(P|=2,B=1),d.encipherOnly&&(P|=1,B=0),d.decipherOnly&&(O|=128,B=7);var U=String.fromCharCode(B);O!==0?U+=String.fromCharCode(P)+String.fromCharCode(O):P!==0&&(U+=String.fromCharCode(P)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,U)}else if(d.name==="basicConstraints")d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),d.cA&&d.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ")),"pathLenConstraint"in d&&d.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.pathLenConstraint).getBytes()));else if(d.name==="extKeyUsage"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=d.value.value;for(var q in d)d[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(d.name==="nsCertType"){var B=0,P=0;d.client&&(P|=128,B=7),d.server&&(P|=64,B=6),d.email&&(P|=32,B=5),d.objsign&&(P|=16,B=4),d.reserved&&(P|=8,B=3),d.sslCA&&(P|=4,B=2),d.emailCA&&(P|=2,B=1),d.objCA&&(P|=1,B=0);var U=String.fromCharCode(B);P!==0&&(U+=String.fromCharCode(P)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,U)}else if(d.name==="subjectAltName"||d.name==="issuerAltName"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var M,H=0;H<d.altNames.length;++H){M=d.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=d,n}}else M.type===8&&(M.oid?U=e.oidToDer(e.oidToDer(M.oid)):U=e.oidToDer(U));d.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,M.type,!1,U))}}else if(d.name==="nsComment"&&s.cert){if(!/^[\x00-\x7F]*$/.test(d.comment)||d.comment.length<1||d.comment.length>128)throw new Error('Invalid "nsComment" content.');d.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,d.comment)}else if(d.name==="subjectKeyIdentifier"&&s.cert){var Q=s.cert.generateSubjectKeyIdentifier();d.subjectKeyIdentifier=Q.toHex(),d.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,Q.getBytes())}else if(d.name==="authorityKeyIdentifier"&&s.cert){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=d.value.value;if(d.keyIdentifier){var j=d.keyIdentifier===!0?s.cert.generateSubjectKeyIdentifier().getBytes():d.keyIdentifier;F.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,j))}if(d.authorityCertIssuer){var ee=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[m(d.authorityCertIssuer===!0?s.cert.issuer:d.authorityCertIssuer)])];F.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,ee))}if(d.serialNumber){var oe=t.util.hexToBytes(d.serialNumber===!0?s.cert.serialNumber:d.serialNumber);F.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,oe))}}else if(d.name==="cRLDistributionPoints"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var F=d.value.value,ce=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),he=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),M,H=0;H<d.altNames.length;++H){M=d.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=d,n}}else M.type===8&&(M.oid?U=e.oidToDer(e.oidToDer(M.oid)):U=e.oidToDer(U));he.value.push(e.create(e.Class.CONTEXT_SPECIFIC,M.type,!1,U))}ce.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[he])),F.push(ce)}if(typeof d.value>"u"){var n=new Error("Extension value not specified.");throw n.extension=d,n}return d}function o(d,s){switch(d){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(d){var s=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(d.attributes.length===0)return s;for(var n=d.attributes,B=0;B<n.length;++B){var P=n[B],O=P.value,U=e.Type.UTF8;"valueTagClass"in P&&(U=P.valueTagClass),U===e.Type.UTF8&&(O=t.util.encodeUtf8(O));var F=!1;"valueConstructed"in P&&(F=P.valueConstructed);var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(P.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,U,F,O)])]);s.value.push(q)}return s}var y=new Date("1950-01-01T00:00:00Z"),I=new Date("2050-01-01T00:00:00Z");function R(d){return d>=y&&d<I?e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(d)):e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(d))}return r.getTBSCertificate=function(d){var s=R(d.validity.notBefore),n=R(d.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(d.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(d.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.siginfo.algorithmOid).getBytes()),o(d.siginfo.algorithmOid,d.siginfo.parameters)]),m(d.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,n]),m(d.subject),r.publicKeyToAsn1(d.publicKey)]);return d.issuer.uniqueId&&B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.issuer.uniqueId)])),d.subject.uniqueId&&B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.subject.uniqueId)])),d.extensions.length>0&&B.value.push(r.certificateExtensionsToAsn1(d.extensions)),B},r.getCertificationRequestInfo=function(d){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.version).getBytes()),m(d.subject),r.publicKeyToAsn1(d.publicKey),h(d)]);return s},r.distinguishedNameToAsn1=function(d){return m(d)},r.certificateToAsn1=function(d){var s=d.tbsCertificate||r.getTBSCertificate(d);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(d.signatureOid).getBytes()),o(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.certificateExtensionsToAsn1=function(d){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<d.length;++B)n.value.push(r.certificateExtensionToAsn1(d[B]));return s},r.certificateExtensionToAsn1=function(d){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(d.id).getBytes())),d.critical&&s.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ"));var n=d.value;return typeof d.value!="string"&&(n=e.toDer(n).getBytes()),s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n)),s},r.certificationRequestToAsn1=function(d){var s=d.certificationRequestInfo||r.getCertificationRequestInfo(d);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(d.signatureOid).getBytes()),o(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.createCaStore=function(d){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 Q=e.toDer(r.certificateToAsn1(q[H])).getBytes();M===Q&&(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(d)for(var P=0;P<d.length;++P){var O=d[P];s.addCertificate(O)}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(d,s,n){typeof n=="function"&&(n={verify:n}),n=n||{},s=s.slice(0);var B=s.slice(0),P=n.validityCheckDate;typeof P>"u"&&(P=new Date);var O=!0,U=null,F=0;do{var q=s.shift(),M=null,H=!1;if(P&&(P<q.validity.notBefore||P>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:P}),U===null){if(M=s[0]||d.getIssuer(q),M===null&&q.isIssuer(q)&&(H=!0,M=q),M){var Q=M;t.util.isArray(Q)||(Q=[Q]);for(var j=!1;!j&&Q.length>0;){M=Q.shift();try{j=M.verify(q)}catch{}}j||(U={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}U===null&&(!M||H)&&!d.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 ee={keyUsage:!0,basicConstraints:!0},oe=0;U===null&&oe<q.extensions.length;++oe){var ce=q.extensions[oe];ce.critical&&!(ce.name in ee)&&(U={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(U===null&&(!O||s.length===0&&(!M||H))){var he=q.getExtension("basicConstraints"),pe=q.getExtension("keyUsage");if(pe!==null&&(!pe.keyCertSign||he===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&&he===null&&(U={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:r.certificateError.bad_certificate}),U===null&&he!==null&&!he.cA&&(U={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),U===null&&pe!==null&&"pathLenConstraint"in he){var ve=F-1;ve>he.pathLenConstraint&&(U={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}}var W=U===null?!0:U.error,X=n.verify?n.verify(W,F,B):W;if(X===!0)U=null;else throw W===!0&&(U={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(X||X===0)&&(typeof X=="object"&&!t.util.isArray(X)?(X.message&&(U.message=X.message),X.error&&(U.error=X.error)):typeof X=="string"&&(U.error=X)),U;O=!1,++F}while(s.length>0);return!0},Gr.exports}var dn;function ci(){if(dn)return qr.exports;dn=1;var t=ge();ht(),zt(),Lt(),si(),ii(),lt(),lr(),Qt(),Ce(),Sa();var e=t.asn1,r=t.pki,i=qr.exports=t.pkcs12=t.pkcs12||{},p={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"},p,{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 l(E,C,o,h){for(var y=[],I=0;I<E.length;I++)for(var R=0;R<E[I].safeBags.length;R++){var d=E[I].safeBags[R];if(!(h!==void 0&&d.type!==h)){if(C===null){y.push(d);continue}d.attributes[C]!==void 0&&d.attributes[C].indexOf(o)>=0&&y.push(d)}}return y}i.pkcs12FromAsn1=function(E,C,o){typeof C=="string"?(o=C,C=!0):C===void 0&&(C=!0);var h={},y=[];if(!e.validate(E,v,h,y)){var I=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw I.errors=I,I}var R={version:h.version.charCodeAt(0),safeContents:[],getBags:function(M){var H={},Q;return"localKeyId"in M?Q=M.localKeyId:"localKeyIdHex"in M&&(Q=t.util.hexToBytes(M.localKeyIdHex)),Q===void 0&&!("friendlyName"in M)&&"bagType"in M&&(H[M.bagType]=l(R.safeContents,null,null,M.bagType)),Q!==void 0&&(H.localKeyId=l(R.safeContents,"localKeyId",Q,M.bagType)),"friendlyName"in M&&(H.friendlyName=l(R.safeContents,"friendlyName",M.friendlyName,M.bagType)),H},getBagsByFriendlyName:function(M,H){return l(R.safeContents,"friendlyName",M,H)},getBagsByLocalKeyId:function(M,H){return l(R.safeContents,"localKeyId",M,H)}};if(h.version.charCodeAt(0)!==3){var I=new Error("PKCS#12 PFX of version other than 3 not supported.");throw I.version=h.version.charCodeAt(0),I}if(e.derToOid(h.contentType)!==r.oids.data){var I=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw I.oid=e.derToOid(h.contentType),I}var d=h.content.value[0];if(d.tagClass!==e.Class.UNIVERSAL||d.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(d=x(d),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 P=new t.util.ByteBuffer(h.macSalt),O="macIterations"in h?parseInt(t.util.bytesToHex(h.macIterations),16):1,U=i.generateKey(o,P,3,O,n,s),F=t.hmac.create();F.start(s,U),F.update(d.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(E.value)&&E.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return L(R,d.value,C,o),R};function x(E){if(E.composed||E.constructed){for(var C=t.util.createBuffer(),o=0;o<E.value.length;++o)C.putBytes(E.value[o].value);E.composed=E.constructed=!1,E.value=C.getBytes()}return E}function L(E,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 I=C.value[y],R={},d=[];if(!e.validate(I,p,R,d)){var s=new Error("Cannot read ContentInfo.");throw s.errors=d,s}var n={encrypted:!1},B=null,P=R.content.value[0];switch(e.derToOid(R.contentType)){case r.oids.data:if(P.tagClass!==e.Class.UNIVERSAL||P.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");B=x(P).value;break;case r.oids.encryptedData:B=b(P,h),n.encrypted=!0;break;default:var s=new Error("Unsupported PKCS#12 contentType.");throw s.contentType=e.derToOid(R.contentType),s}n.safeBags=u(B,o,h),E.safeContents.push(n)}}function b(E,C){var o={},h=[];if(!e.validate(E,t.pkcs7.asn1.encryptedDataValidator,o,h)){var y=new Error("Cannot read EncryptedContentInfo.");throw y.errors=h,y}var I=e.derToOid(o.contentType);if(I!==r.oids.data){var y=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw y.oid=I,y}I=e.derToOid(o.encAlgorithm);var R=r.pbe.getCipher(I,o.encParameter,C),d=x(o.encryptedContentAsn1),s=t.util.createBuffer(d.value);if(R.update(s),!R.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return R.output.getBytes()}function u(E,C,o){if(!C&&E.length===0)return[];if(E=e.fromDer(E,C),E.tagClass!==e.Class.UNIVERSAL||E.type!==e.Type.SEQUENCE||E.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var h=[],y=0;y<E.value.length;y++){var I=E.value[y],R={},d=[];if(!e.validate(I,c,R,d)){var s=new Error("Cannot read SafeBag.");throw s.errors=d,s}var n={type:e.derToOid(R.bagId),attributes:m(R.bagAttributes)};h.push(n);var B,P,O=R.bagValue.value[0];switch(n.type){case r.oids.pkcs8ShroudedKeyBag:if(O=r.decryptPrivateKeyInfo(O,o),O===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{n.key=r.privateKeyFromAsn1(O)}catch{n.key=null,n.asn1=O}continue;case r.oids.certBag:B=g,P=function(){if(e.derToOid(R.certId)!==r.oids.x509Certificate){var F=new Error("Unsupported certificate type, only X.509 supported.");throw F.oid=e.derToOid(R.certId),F}var q=e.fromDer(R.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(O,B,R,d)){var s=new Error("Cannot read PKCS#12 "+B.name);throw s.errors=d,s}P()}return h}function m(E){var C={};if(E!==void 0)for(var o=0;o<E.length;++o){var h={},y=[];if(!e.validate(E[o],a,h,y)){var I=new Error("Cannot read PKCS#12 BagAttribute.");throw I.errors=y,I}var R=e.derToOid(h.oid);if(r.oids[R]!==void 0){C[r.oids[R]]=[];for(var d=0;d<h.values.length;++d)C[r.oids[R]].push(h.values[d].value)}}return C}return i.toPkcs12Asn1=function(E,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,I;if(y!==null)y=t.util.hexToBytes(y);else if(h.generateLocalKeyId)if(C){var R=t.util.isArray(C)?C[0]:C;typeof R=="string"&&(R=r.certificateFromPem(R));var d=t.md.sha1.create();d.update(e.toDer(r.certificateToAsn1(R)).getBytes()),y=d.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&&(I=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 P=[],O=0;O<B.length;++O){C=B[O],typeof C=="string"&&(C=r.certificateFromPem(C));var U=O===0?I: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]);P.push(q)}if(P.length>0){var M=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,P),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 Q=null;if(E!==null){var j=r.wrapRsaPrivateKey(r.privateKeyToAsn1(E));o===null?Q=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]),I]):Q=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)]),I]);var ee=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[Q]),oe=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(ee).getBytes())])]);n.push(oe)}var ce=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n),he;if(h.useMac){var d=t.md.sha1.create(),pe=new t.util.ByteBuffer(t.random.getBytes(h.saltSize)),ve=h.count,E=i.generateKey(o,pe,3,ve,20),W=t.hmac.create();W.start(d,E),W.update(e.toDer(ce).getBytes());var X=W.getMac();he=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,X.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,pe.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(ve).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(ce).getBytes())])]),he])},i.generateKey=t.pbe.generatePkcs12Key,qr.exports}var pn;function fi(){if(pn)return _r.exports;pn=1;var t=ge();ht(),Lt(),ii(),Vt(),Ea(),ci(),xa(),lr(),Ce(),Sa();var e=t.asn1,r=_r.exports=t.pki=t.pki||{};return r.pemToDer=function(i){var p=t.pem.decode(i)[0];if(p.procType&&p.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(p.body)},r.privateKeyFromPem=function(i){var p=t.pem.decode(i)[0];if(p.type!=="PRIVATE KEY"&&p.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=p.type,v}if(p.procType&&p.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var c=e.fromDer(p.body);return r.privateKeyFromAsn1(c)},r.privateKeyToPem=function(i,p){var v={type:"RSA PRIVATE KEY",body:e.toDer(r.privateKeyToAsn1(i)).getBytes()};return t.pem.encode(v,{maxline:p})},r.privateKeyInfoToPem=function(i,p){var v={type:"PRIVATE KEY",body:e.toDer(i).getBytes()};return t.pem.encode(v,{maxline:p})},_r.exports}var Wr,hn;function ui(){if(hn)return Wr;hn=1;var t=ge();ht(),zt(),ma(),Vt(),fi(),lt(),Qt(),Ce();var e=function(S,D,_,N){var f=t.util.createBuffer(),T=S.length>>1,V=T+(S.length&1),G=S.substr(0,V),Z=S.substr(T,V),ne=t.util.createBuffer(),z=t.hmac.create();_=D+_;var J=Math.ceil(N/16),fe=Math.ceil(N/20);z.start("MD5",G);var me=t.util.createBuffer();ne.putBytes(_);for(var ue=0;ue<J;++ue)z.start(null,null),z.update(ne.getBytes()),ne.putBuffer(z.digest()),z.start(null,null),z.update(ne.bytes()+_),me.putBuffer(z.digest());z.start("SHA1",Z);var Te=t.util.createBuffer();ne.clear(),ne.putBytes(_);for(var ue=0;ue<fe;++ue)z.start(null,null),z.update(ne.getBytes()),ne.putBuffer(z.digest()),z.start(null,null),z.update(ne.bytes()+_),Te.putBuffer(z.digest());return f.putBytes(t.util.xorBytes(me.getBytes(),Te.getBytes(),N)),f},r=function(S,D,_){var N=t.hmac.create();N.start("SHA1",S);var f=t.util.createBuffer();return f.putInt32(D[0]),f.putInt32(D[1]),f.putByte(_.type),f.putByte(_.version.major),f.putByte(_.version.minor),f.putInt16(_.length),f.putBytes(_.fragment.bytes()),N.update(f.getBytes()),N.digest().getBytes()},i=function(S,D,_){var N=!1;try{var f=S.deflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(f),D.length=f.length,N=!0}catch{}return N},p=function(S,D,_){var N=!1;try{var f=S.inflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(f),D.length=f.length,N=!0}catch{}return N},v=function(S,D){var _=0;switch(D){case 1:_=S.getByte();break;case 2:_=S.getInt16();break;case 3:_=S.getInt24();break;case 4:_=S.getInt32();break}return t.util.createBuffer(S.getBytes(_))},c=function(S,D,_){S.putInt(_.length(),D<<3),S.putBuffer(_)},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(S){var D=null;for(var _ in a.CipherSuites){var N=a.CipherSuites[_];if(N.id[0]===S.charCodeAt(0)&&N.id[1]===S.charCodeAt(1)){D=N;break}}return D},a.handleUnexpected=function(S,D){var _=!S.open&&S.entity===a.ConnectionEnd.client;_||S.error(S,{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(S,D,_){!S.handshaking&&S.handshakes>0&&(a.queue(S,a.createAlert(S,{level:a.Alert.Level.warning,description:a.Alert.Description.no_renegotiation})),a.flush(S)),S.process()},a.parseHelloMessage=function(S,D,_){var N=null,f=S.entity===a.ConnectionEnd.client;if(_<38)S.error(S,{message:f?"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 T=D.fragment,V=T.length();if(N={version:{major:T.getByte(),minor:T.getByte()},random:t.util.createBuffer(T.getBytes(32)),session_id:v(T,1),extensions:[]},f?(N.cipher_suite=T.getBytes(2),N.compression_method=T.getByte()):(N.cipher_suites=v(T,2),N.compression_methods=v(T,1)),V=_-(V-T.length()),V>0){for(var G=v(T,2);G.length()>0;)N.extensions.push({type:[G.getByte(),G.getByte()],data:v(G,2)});if(!f)for(var Z=0;Z<N.extensions.length;++Z){var ne=N.extensions[Z];if(ne.type[0]===0&&ne.type[1]===0)for(var z=v(ne.data,2);z.length()>0;){var J=z.getByte();if(J!==0)break;S.session.extensions.server_name.serverNameList.push(v(z,2).getBytes())}}}if(S.session.version&&(N.version.major!==S.session.version.major||N.version.minor!==S.session.version.minor))return S.error(S,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});if(f)S.session.cipherSuite=a.getCipherSuite(N.cipher_suite);else for(var fe=t.util.createBuffer(N.cipher_suites.bytes());fe.length()>0&&(S.session.cipherSuite=a.getCipherSuite(fe.getBytes(2)),S.session.cipherSuite===null););if(S.session.cipherSuite===null)return S.error(S,{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)});f?S.session.compressionMethod=N.compression_method:S.session.compressionMethod=a.CompressionMethod.none}return N},a.createSecurityParameters=function(S,D){var _=S.entity===a.ConnectionEnd.client,N=D.random.bytes(),f=_?S.session.sp.client_random:N,T=_?N:a.createRandom().getBytes();S.session.sp={entity:S.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:S.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:f,server_random:T}},a.handleServerHello=function(S,D,_){var N=a.parseHelloMessage(S,D,_);if(!S.fail){if(N.version.minor<=S.version.minor)S.version.minor=N.version.minor;else return S.error(S,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});S.session.version=S.version;var f=N.session_id.bytes();f.length>0&&f===S.session.id?(S.expect=u,S.session.resuming=!0,S.session.sp.server_random=N.random.bytes()):(S.expect=l,S.session.resuming=!1,a.createSecurityParameters(S,N)),S.session.id=f,S.process()}},a.handleClientHello=function(S,D,_){var N=a.parseHelloMessage(S,D,_);if(!S.fail){var f=N.session_id.bytes(),T=null;if(S.sessionCache&&(T=S.sessionCache.getSession(f),T===null?f="":(T.version.major!==N.version.major||T.version.minor>N.version.minor)&&(T=null,f="")),f.length===0&&(f=t.random.getBytes(32)),S.session.id=f,S.session.clientHelloVersion=N.version,S.session.sp={},T)S.version=S.session.version=T.version,S.session.sp=T.sp;else{for(var V,G=1;G<a.SupportedVersions.length&&(V=a.SupportedVersions[G],!(V.minor<=N.version.minor));++G);S.version={major:V.major,minor:V.minor},S.session.version=S.version}T!==null?(S.expect=R,S.session.resuming=!0,S.session.sp.client_random=N.random.bytes()):(S.expect=S.verifyClient!==!1?h:y,S.session.resuming=!1,a.createSecurityParameters(S,N)),S.open=!0,a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createServerHello(S)})),S.session.resuming?(a.queue(S,a.createRecord(S,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),S.state.pending=a.createConnectionState(S),S.state.current.write=S.state.pending.write,a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createFinished(S)}))):(a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createCertificate(S)})),S.fail||(a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createServerKeyExchange(S)})),S.verifyClient!==!1&&a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createCertificateRequest(S)})),a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createServerHelloDone(S)})))),a.flush(S),S.process()}},a.handleCertificate=function(S,D,_){if(_<3)return S.error(S,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment,f={certificate_list:v(N,3)},T,V,G=[];try{for(;f.certificate_list.length()>0;)T=v(f.certificate_list,3),V=t.asn1.fromDer(T),T=t.pki.certificateFromAsn1(V,!0),G.push(T)}catch(ne){return S.error(S,{message:"Could not parse certificate list.",cause:ne,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var Z=S.entity===a.ConnectionEnd.client;(Z||S.verifyClient===!0)&&G.length===0?S.error(S,{message:Z?"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?S.expect=Z?x:y:(Z?S.session.serverCertificate=G[0]:S.session.clientCertificate=G[0],a.verifyCertificateChain(S,G)&&(S.expect=Z?x:y)),S.process()},a.handleServerKeyExchange=function(S,D,_){if(_>0)return S.error(S,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});S.expect=L,S.process()},a.handleClientKeyExchange=function(S,D,_){if(_<48)return S.error(S,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});var N=D.fragment,f={enc_pre_master_secret:v(N,2).getBytes()},T=null;if(S.getPrivateKey)try{T=S.getPrivateKey(S,S.session.serverCertificate),T=t.pki.privateKeyFromPem(T)}catch(Z){S.error(S,{message:"Could not get private key.",cause:Z,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}if(T===null)return S.error(S,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}});try{var V=S.session.sp;V.pre_master_secret=T.decrypt(f.enc_pre_master_secret);var G=S.session.clientHelloVersion;if(G.major!==V.pre_master_secret.charCodeAt(0)||G.minor!==V.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{V.pre_master_secret=t.random.getBytes(48)}S.expect=R,S.session.clientCertificate!==null&&(S.expect=I),S.process()},a.handleCertificateRequest=function(S,D,_){if(_<3)return S.error(S,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment,f={certificate_types:v(N,1),certificate_authorities:v(N,2)};S.session.certificateRequest=f,S.expect=b,S.process()},a.handleCertificateVerify=function(S,D,_){if(_<2)return S.error(S,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment;N.read-=4;var f=N.bytes();N.read+=4;var T={signature:v(N,2).getBytes()},V=t.util.createBuffer();V.putBuffer(S.session.md5.digest()),V.putBuffer(S.session.sha1.digest()),V=V.getBytes();try{var G=S.session.clientCertificate;if(!G.publicKey.verify(V,T.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");S.session.md5.update(f),S.session.sha1.update(f)}catch{return S.error(S,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure}})}S.expect=R,S.process()},a.handleServerHelloDone=function(S,D,_){if(_>0)return S.error(S,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.record_overflow}});if(S.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}},f=0,T=S.verify(S,N.alert.description,f,[]);if(T!==!0)return(T||T===0)&&(typeof T=="object"&&!t.util.isArray(T)?(T.message&&(N.message=T.message),T.alert&&(N.alert.description=T.alert)):typeof T=="number"&&(N.alert.description=T)),S.error(S,N)}S.session.certificateRequest!==null&&(D=a.createRecord(S,{type:a.ContentType.handshake,data:a.createCertificate(S)}),a.queue(S,D)),D=a.createRecord(S,{type:a.ContentType.handshake,data:a.createClientKeyExchange(S)}),a.queue(S,D),S.expect=C;var V=function(G,Z){G.session.certificateRequest!==null&&G.session.clientCertificate!==null&&a.queue(G,a.createRecord(G,{type:a.ContentType.handshake,data:a.createCertificateVerify(G,Z)})),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=u,a.flush(G),G.process()};if(S.session.certificateRequest===null||S.session.clientCertificate===null)return V(S,null);a.getClientSignature(S,V)},a.handleChangeCipherSpec=function(S,D){if(D.fragment.getByte()!==1)return S.error(S,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var _=S.entity===a.ConnectionEnd.client;(S.session.resuming&&_||!S.session.resuming&&!_)&&(S.state.pending=a.createConnectionState(S)),S.state.current.read=S.state.pending.read,(!S.session.resuming&&_||S.session.resuming&&!_)&&(S.state.pending=null),S.expect=_?m:d,S.process()},a.handleFinished=function(S,D,_){var N=D.fragment;N.read-=4;var f=N.bytes();N.read+=4;var T=D.fragment.getBytes();N=t.util.createBuffer(),N.putBuffer(S.session.md5.digest()),N.putBuffer(S.session.sha1.digest());var V=S.entity===a.ConnectionEnd.client,G=V?"server finished":"client finished",Z=S.session.sp,ne=12,z=e;if(N=z(Z.master_secret,G,N.getBytes(),ne),N.getBytes()!==T)return S.error(S,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decrypt_error}});S.session.md5.update(f),S.session.sha1.update(f),(S.session.resuming&&V||!S.session.resuming&&!V)&&(a.queue(S,a.createRecord(S,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),S.state.current.write=S.state.pending.write,S.state.pending=null,a.queue(S,a.createRecord(S,{type:a.ContentType.handshake,data:a.createFinished(S)}))),S.expect=V?E:s,S.handshaking=!1,++S.handshakes,S.peerCertificate=V?S.session.serverCertificate:S.session.clientCertificate,a.flush(S),S.isConnected=!0,S.connected(S),S.process()},a.handleAlert=function(S,D){var _=D.fragment,N={level:_.getByte(),description:_.getByte()},f;switch(N.description){case a.Alert.Description.close_notify:f="Connection closed.";break;case a.Alert.Description.unexpected_message:f="Unexpected message.";break;case a.Alert.Description.bad_record_mac:f="Bad record MAC.";break;case a.Alert.Description.decryption_failed:f="Decryption failed.";break;case a.Alert.Description.record_overflow:f="Record overflow.";break;case a.Alert.Description.decompression_failure:f="Decompression failed.";break;case a.Alert.Description.handshake_failure:f="Handshake failure.";break;case a.Alert.Description.bad_certificate:f="Bad certificate.";break;case a.Alert.Description.unsupported_certificate:f="Unsupported certificate.";break;case a.Alert.Description.certificate_revoked:f="Certificate revoked.";break;case a.Alert.Description.certificate_expired:f="Certificate expired.";break;case a.Alert.Description.certificate_unknown:f="Certificate unknown.";break;case a.Alert.Description.illegal_parameter:f="Illegal parameter.";break;case a.Alert.Description.unknown_ca:f="Unknown certificate authority.";break;case a.Alert.Description.access_denied:f="Access denied.";break;case a.Alert.Description.decode_error:f="Decode error.";break;case a.Alert.Description.decrypt_error:f="Decrypt error.";break;case a.Alert.Description.export_restriction:f="Export restriction.";break;case a.Alert.Description.protocol_version:f="Unsupported protocol version.";break;case a.Alert.Description.insufficient_security:f="Insufficient security.";break;case a.Alert.Description.internal_error:f="Internal error.";break;case a.Alert.Description.user_canceled:f="User canceled.";break;case a.Alert.Description.no_renegotiation:f="Renegotiation not supported.";break;default:f="Unknown error.";break}if(N.description===a.Alert.Description.close_notify)return S.close();S.error(S,{message:f,send:!1,origin:S.entity===a.ConnectionEnd.client?"server":"client",alert:N}),S.process()},a.handleHandshake=function(S,D){var _=D.fragment,N=_.getByte(),f=_.getInt24();if(f>_.length())return S.fragmented=D,D.fragment=t.util.createBuffer(),_.read-=4,S.process();S.fragmented=null,_.read-=4;var T=_.bytes(f+4);_.read+=4,N in he[S.entity][S.expect]?(S.entity===a.ConnectionEnd.server&&!S.open&&!S.fail&&(S.handshaking=!0,S.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&&(S.session.md5.update(T),S.session.sha1.update(T)),he[S.entity][S.expect][N](S,D,f)):a.handleUnexpected(S,D)},a.handleApplicationData=function(S,D){S.data.putBuffer(D.fragment),S.dataReady(S),S.process()},a.handleHeartbeat=function(S,D){var _=D.fragment,N=_.getByte(),f=_.getInt16(),T=_.getBytes(f);if(N===a.HeartbeatMessageType.heartbeat_request){if(S.handshaking||f>T.length)return S.process();a.queue(S,a.createRecord(S,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_response,T)})),a.flush(S)}else if(N===a.HeartbeatMessageType.heartbeat_response){if(T!==S.expectedHeartbeatPayload)return S.process();S.heartbeatReceived&&S.heartbeatReceived(S,t.util.createBuffer(T))}S.process()};var g=0,l=1,x=2,L=3,b=4,u=5,m=6,E=7,C=8,o=0,h=1,y=2,I=3,R=4,d=5,s=6,n=a.handleUnexpected,B=a.handleChangeCipherSpec,P=a.handleAlert,O=a.handleHandshake,U=a.handleApplicationData,F=a.handleHeartbeat,q=[];q[a.ConnectionEnd.client]=[[n,P,O,n,F],[n,P,O,n,F],[n,P,O,n,F],[n,P,O,n,F],[n,P,O,n,F],[B,P,n,n,F],[n,P,O,n,F],[n,P,O,U,F],[n,P,O,n,F]],q[a.ConnectionEnd.server]=[[n,P,O,n,F],[n,P,O,n,F],[n,P,O,n,F],[n,P,O,n,F],[B,P,n,n,F],[n,P,O,n,F],[n,P,O,U,F],[n,P,O,n,F]];var M=a.handleHelloRequest,H=a.handleServerHello,Q=a.handleCertificate,j=a.handleServerKeyExchange,ee=a.handleCertificateRequest,oe=a.handleServerHelloDone,ce=a.handleFinished,he=[];he[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,Q,j,ee,oe,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,j,ee,oe,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,ee,oe,n,n,n,n,n,n],[M,n,n,n,n,n,n,n,n,n,n,n,n,n,oe,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,ce],[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 pe=a.handleClientHello,ve=a.handleClientKeyExchange,W=a.handleCertificateVerify;he[a.ConnectionEnd.server]=[[n,pe,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,Q,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,ve,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,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,ce],[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(S,D){var _=e,N=D.client_random+D.server_random;S.session.resuming||(D.master_secret=_(D.pre_master_secret,"master secret",N,48).bytes(),D.pre_master_secret=null),N=D.server_random+D.client_random;var f=2*D.mac_key_length+2*D.enc_key_length,T=S.version.major===a.Versions.TLS_1_0.major&&S.version.minor===a.Versions.TLS_1_0.minor;T&&(f+=2*D.fixed_iv_length);var V=_(D.master_secret,"key expansion",N,f),G={client_write_MAC_key:V.getBytes(D.mac_key_length),server_write_MAC_key:V.getBytes(D.mac_key_length),client_write_key:V.getBytes(D.enc_key_length),server_write_key:V.getBytes(D.enc_key_length)};return T&&(G.client_write_IV=V.getBytes(D.fixed_iv_length),G.server_write_IV=V.getBytes(D.fixed_iv_length)),G},a.createConnectionState=function(S){var D=S.entity===a.ConnectionEnd.client,_=function(){var T={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(V){return!0},compressionState:null,compressFunction:function(V){return!0},updateSequenceNumber:function(){T.sequenceNumber[1]===4294967295?(T.sequenceNumber[1]=0,++T.sequenceNumber[0]):++T.sequenceNumber[1]}};return T},N={read:_(),write:_()};if(N.read.update=function(T,V){return N.read.cipherFunction(V,N.read)?N.read.compressFunction(T,V,N.read)||T.error(T,{message:"Could not decompress record.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decompression_failure}}):T.error(T,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_record_mac}}),!T.fail},N.write.update=function(T,V){return N.write.compressFunction(T,V,N.write)?N.write.cipherFunction(V,N.write)||T.error(T,{message:"Could not encrypt record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):T.error(T,{message:"Could not compress record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}),!T.fail},S.session){var f=S.session.sp;switch(S.session.cipherSuite.initSecurityParameters(f),f.keys=a.generateKeys(S,f),N.read.macKey=D?f.keys.server_write_MAC_key:f.keys.client_write_MAC_key,N.write.macKey=D?f.keys.client_write_MAC_key:f.keys.server_write_MAC_key,S.session.cipherSuite.initConnectionState(N,S,f),f.compression_algorithm){case a.CompressionMethod.none:break;case a.CompressionMethod.deflate:N.read.compressFunction=p,N.write.compressFunction=i;break;default:throw new Error("Unsupported compression algorithm.")}}return N},a.createRandom=function(){var S=new Date,D=+S+S.getTimezoneOffset()*6e4,_=t.util.createBuffer();return _.putInt32(D),_.putBytes(t.random.getBytes(28)),_},a.createRecord=function(S,D){if(!D.data)return null;var _={type:D.type,version:{major:S.version.major,minor:S.version.minor},length:D.data.length(),fragment:D.data};return _},a.createAlert=function(S,D){var _=t.util.createBuffer();return _.putByte(D.level),_.putByte(D.description),a.createRecord(S,{type:a.ContentType.alert,data:_})},a.createClientHello=function(S){S.session.clientHelloVersion={major:S.version.major,minor:S.version.minor};for(var D=t.util.createBuffer(),_=0;_<S.cipherSuites.length;++_){var N=S.cipherSuites[_];D.putByte(N.id[0]),D.putByte(N.id[1])}var f=D.length(),T=t.util.createBuffer();T.putByte(a.CompressionMethod.none);var V=T.length(),G=t.util.createBuffer();if(S.virtualHost){var Z=t.util.createBuffer();Z.putByte(0),Z.putByte(0);var ne=t.util.createBuffer();ne.putByte(0),c(ne,2,t.util.createBuffer(S.virtualHost));var z=t.util.createBuffer();c(z,2,ne),c(Z,2,z),G.putBuffer(Z)}var J=G.length();J>0&&(J+=2);var fe=S.session.id,me=fe.length+1+2+4+28+2+f+1+V+J,ue=t.util.createBuffer();return ue.putByte(a.HandshakeType.client_hello),ue.putInt24(me),ue.putByte(S.version.major),ue.putByte(S.version.minor),ue.putBytes(S.session.sp.client_random),c(ue,1,t.util.createBuffer(fe)),c(ue,2,D),c(ue,1,T),J>0&&c(ue,2,G),ue},a.createServerHello=function(S){var D=S.session.id,_=D.length+1+2+4+28+2+1,N=t.util.createBuffer();return N.putByte(a.HandshakeType.server_hello),N.putInt24(_),N.putByte(S.version.major),N.putByte(S.version.minor),N.putBytes(S.session.sp.server_random),c(N,1,t.util.createBuffer(D)),N.putByte(S.session.cipherSuite.id[0]),N.putByte(S.session.cipherSuite.id[1]),N.putByte(S.session.compressionMethod),N},a.createCertificate=function(S){var D=S.entity===a.ConnectionEnd.client,_=null;if(S.getCertificate){var N;D?N=S.session.certificateRequest:N=S.session.extensions.server_name.serverNameList,_=S.getCertificate(S,N)}var f=t.util.createBuffer();if(_!==null)try{t.util.isArray(_)||(_=[_]);for(var T=null,V=0;V<_.length;++V){var G=t.pem.decode(_[V])[0];if(G.type!=="CERTIFICATE"&&G.type!=="X509 CERTIFICATE"&&G.type!=="TRUSTED CERTIFICATE"){var Z=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw Z.headerType=G.type,Z}if(G.procType&&G.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var ne=t.util.createBuffer(G.body);T===null&&(T=t.asn1.fromDer(ne.bytes(),!1));var z=t.util.createBuffer();c(z,3,ne),f.putBuffer(z)}_=t.pki.certificateFromAsn1(T),D?S.session.clientCertificate=_:S.session.serverCertificate=_}catch(me){return S.error(S,{message:"Could not send certificate list.",cause:me,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var J=3+f.length(),fe=t.util.createBuffer();return fe.putByte(a.HandshakeType.certificate),fe.putInt24(J),c(fe,3,f),fe},a.createClientKeyExchange=function(S){var D=t.util.createBuffer();D.putByte(S.session.clientHelloVersion.major),D.putByte(S.session.clientHelloVersion.minor),D.putBytes(t.random.getBytes(46));var _=S.session.sp;_.pre_master_secret=D.getBytes();var N=S.session.serverCertificate.publicKey;D=N.encrypt(_.pre_master_secret);var f=D.length+2,T=t.util.createBuffer();return T.putByte(a.HandshakeType.client_key_exchange),T.putInt24(f),T.putInt16(D.length),T.putBytes(D),T},a.createServerKeyExchange=function(S){var D=t.util.createBuffer();return D},a.getClientSignature=function(S,D){var _=t.util.createBuffer();_.putBuffer(S.session.md5.digest()),_.putBuffer(S.session.sha1.digest()),_=_.getBytes(),S.getSignature=S.getSignature||function(N,f,T){var V=null;if(N.getPrivateKey)try{V=N.getPrivateKey(N,N.session.clientCertificate),V=t.pki.privateKeyFromPem(V)}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}})}V===null?N.error(N,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):f=V.sign(f,null),T(N,f)},S.getSignature(S,_,D)},a.createCertificateVerify=function(S,D){var _=D.length+2,N=t.util.createBuffer();return N.putByte(a.HandshakeType.certificate_verify),N.putInt24(_),N.putInt16(D.length),N.putBytes(D),N},a.createCertificateRequest=function(S){var D=t.util.createBuffer();D.putByte(1);var _=t.util.createBuffer();for(var N in S.caStore.certs){var f=S.caStore.certs[N],T=t.pki.distinguishedNameToAsn1(f.subject),V=t.asn1.toDer(T);_.putInt16(V.length()),_.putBuffer(V)}var G=1+D.length()+2+_.length(),Z=t.util.createBuffer();return Z.putByte(a.HandshakeType.certificate_request),Z.putInt24(G),c(Z,1,D),c(Z,2,_),Z},a.createServerHelloDone=function(S){var D=t.util.createBuffer();return D.putByte(a.HandshakeType.server_hello_done),D.putInt24(0),D},a.createChangeCipherSpec=function(){var S=t.util.createBuffer();return S.putByte(1),S},a.createFinished=function(S){var D=t.util.createBuffer();D.putBuffer(S.session.md5.digest()),D.putBuffer(S.session.sha1.digest());var _=S.entity===a.ConnectionEnd.client,N=S.session.sp,f=12,T=e,V=_?"client finished":"server finished";D=T(N.master_secret,V,D.getBytes(),f);var G=t.util.createBuffer();return G.putByte(a.HandshakeType.finished),G.putInt24(D.length()),G.putBuffer(D),G},a.createHeartbeat=function(S,D,_){typeof _>"u"&&(_=D.length);var N=t.util.createBuffer();N.putByte(S),N.putInt16(_),N.putBytes(D);var f=N.length(),T=Math.max(16,f-_-3);return N.putBytes(t.random.getBytes(T)),N},a.queue=function(S,D){if(D&&!(D.fragment.length()===0&&(D.type===a.ContentType.handshake||D.type===a.ContentType.alert||D.type===a.ContentType.change_cipher_spec))){if(D.type===a.ContentType.handshake){var _=D.fragment.bytes();S.session.md5.update(_),S.session.sha1.update(_),_=null}var N;if(D.fragment.length()<=a.MaxFragment)N=[D];else{N=[];for(var f=D.fragment.bytes();f.length>a.MaxFragment;)N.push(a.createRecord(S,{type:D.type,data:t.util.createBuffer(f.slice(0,a.MaxFragment))})),f=f.slice(a.MaxFragment);f.length>0&&N.push(a.createRecord(S,{type:D.type,data:t.util.createBuffer(f)}))}for(var T=0;T<N.length&&!S.fail;++T){var V=N[T],G=S.state.current.write;G.update(S,V)&&S.records.push(V)}}},a.flush=function(S){for(var D=0;D<S.records.length;++D){var _=S.records[D];S.tlsData.putByte(_.type),S.tlsData.putByte(_.version.major),S.tlsData.putByte(_.version.minor),S.tlsData.putInt16(_.fragment.length()),S.tlsData.putBuffer(S.records[D].fragment)}return S.records=[],S.tlsDataReady(S)};var X=function(S){switch(S){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}},Re=function(S){switch(S){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(S,D){try{var _={};for(var N in S.verifyOptions)_[N]=S.verifyOptions[N];_.verify=function(T,V,G){var Z=X(T),ne=S.verify(S,T,V,G);if(ne!==!0){if(typeof ne=="object"&&!t.util.isArray(ne)){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},ne.message&&(z.message=ne.message),ne.alert&&(z.alert.description=ne.alert),z}ne!==T&&(ne=Re(ne))}return ne},t.pki.verifyCertificateChain(S.caStore,D,_)}catch(T){var f=T;(typeof f!="object"||t.util.isArray(f))&&(f={send:!0,alert:{level:a.Alert.Level.fatal,description:X(T)}}),"send"in f||(f.send=!0),"alert"in f||(f.alert={level:a.Alert.Level.fatal,description:X(f.error)}),S.error(S,f)}return!S.fail},a.createSessionCache=function(S,D){var _=null;if(S&&S.getSession&&S.setSession&&S.order)_=S;else{_={},_.cache=S||{},_.capacity=Math.max(D||100,1),_.order=[];for(var N in S)_.order.length<=D?_.order.push(N):delete S[N];_.getSession=function(f){var T=null,V=null;if(f?V=t.util.bytesToHex(f):_.order.length>0&&(V=_.order[0]),V!==null&&V in _.cache){T=_.cache[V],delete _.cache[V];for(var G in _.order)if(_.order[G]===V){_.order.splice(G,1);break}}return T},_.setSession=function(f,T){if(_.order.length===_.capacity){var V=_.order.shift();delete _.cache[V]}var V=t.util.bytesToHex(f);_.order.push(V),_.cache[V]=T}}return _},a.createConnection=function(S){var D=null;S.caStore?t.util.isArray(S.caStore)?D=t.pki.createCaStore(S.caStore):D=S.caStore:D=t.pki.createCaStore();var _=S.cipherSuites||null;if(_===null){_=[];for(var N in a.CipherSuites)_.push(a.CipherSuites[N])}var f=S.server?a.ConnectionEnd.server:a.ConnectionEnd.client,T=S.sessionCache?a.createSessionCache(S.sessionCache):null,V={version:{major:a.Version.major,minor:a.Version.minor},entity:f,sessionId:S.sessionId,caStore:D,sessionCache:T,cipherSuites:_,connected:S.connected,virtualHost:S.virtualHost||null,verifyClient:S.verifyClient||!1,verify:S.verify||function(z,J,fe,me){return J},verifyOptions:S.verifyOptions||{},getCertificate:S.getCertificate||null,getPrivateKey:S.getPrivateKey||null,getSignature:S.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:S.tlsDataReady,dataReady:S.dataReady,heartbeatReceived:S.heartbeatReceived,closed:S.closed,error:function(z,J){J.origin=J.origin||(z.entity===a.ConnectionEnd.client?"client":"server"),J.send&&(a.queue(z,a.createAlert(z,J.alert)),a.flush(z));var fe=J.fatal!==!1;fe&&(z.fail=!0),S.error(z,J),fe&&z.close(!1)},deflate:S.deflate||null,inflate:S.inflate||null};V.reset=function(z){V.version={major:a.Version.major,minor:a.Version.minor},V.record=null,V.session=null,V.peerCertificate=null,V.state={pending:null,current:null},V.expect=V.entity===a.ConnectionEnd.client?g:o,V.fragmented=null,V.records=[],V.open=!1,V.handshakes=0,V.handshaking=!1,V.isConnected=!1,V.fail=!(z||typeof z>"u"),V.input.clear(),V.tlsData.clear(),V.data.clear(),V.state.current=a.createConnectionState(V)},V.reset();var G=function(z,J){var fe=J.type-a.ContentType.change_cipher_spec,me=q[z.entity][z.expect];fe in me?me[fe](z,J):a.handleUnexpected(z,J)},Z=function(z){var J=0,fe=z.input,me=fe.length();if(me<5)J=5-me;else{z.record={type:fe.getByte(),version:{major:fe.getByte(),minor:fe.getByte()},length:fe.getInt16(),fragment:t.util.createBuffer(),ready:!1};var ue=z.record.version.major===z.version.major;ue&&z.session&&z.session.version&&(ue=z.record.version.minor===z.version.minor),ue||z.error(z,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}})}return J},ne=function(z){var J=0,fe=z.input,me=fe.length();if(me<z.record.length)J=z.record.length-me;else{z.record.fragment.putBytes(fe.getBytes(z.record.length)),fe.compact();var ue=z.state.current.read;ue.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 J};return V.handshake=function(z){if(V.entity!==a.ConnectionEnd.client)V.error(V,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(V.handshaking)V.error(V,{message:"Handshake already in progress.",fatal:!1});else{V.fail&&!V.open&&V.handshakes===0&&(V.fail=!1),V.handshaking=!0,z=z||"";var J=null;z.length>0&&(V.sessionCache&&(J=V.sessionCache.getSession(z)),J===null&&(z="")),z.length===0&&V.sessionCache&&(J=V.sessionCache.getSession(),J!==null&&(z=J.id)),V.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()},J&&(V.version=J.version,V.session.sp=J.sp),V.session.sp.client_random=a.createRandom().getBytes(),V.open=!0,a.queue(V,a.createRecord(V,{type:a.ContentType.handshake,data:a.createClientHello(V)})),a.flush(V)}},V.process=function(z){var J=0;return z&&V.input.putBytes(z),V.fail||(V.record!==null&&V.record.ready&&V.record.fragment.isEmpty()&&(V.record=null),V.record===null&&(J=Z(V)),!V.fail&&V.record!==null&&!V.record.ready&&(J=ne(V)),!V.fail&&V.record!==null&&V.record.ready&&G(V,V.record)),J},V.prepare=function(z){return a.queue(V,a.createRecord(V,{type:a.ContentType.application_data,data:t.util.createBuffer(z)})),a.flush(V)},V.prepareHeartbeatRequest=function(z,J){return z instanceof t.util.ByteBuffer&&(z=z.bytes()),typeof J>"u"&&(J=z.length),V.expectedHeartbeatPayload=z,a.queue(V,a.createRecord(V,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_request,z,J)})),a.flush(V)},V.close=function(z){if(!V.fail&&V.sessionCache&&V.session){var J={id:V.session.id,version:V.session.version,sp:V.session.sp};J.sp.keys=null,V.sessionCache.setSession(J.id,J)}V.open&&(V.open=!1,V.input.clear(),(V.isConnected||V.handshaking)&&(V.isConnected=V.handshaking=!1,a.queue(V,a.createAlert(V,{level:a.Alert.Level.warning,description:a.Alert.Description.close_notify})),a.flush(V)),V.closed(V)),V.reset(z)},V},Wr=t.tls=t.tls||{};for(var ye in a)typeof a[ye]!="function"&&(t.tls[ye]=a[ye]);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 qs(){if(vn)return Tr.exports;vn=1;var t=ge();Dt(),ui();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,l,x){var L=l.entity===t.tls.ConnectionEnd.client;g.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",L?x.keys.server_write_key:x.keys.client_write_key),iv:L?x.keys.server_write_IV:x.keys.client_write_IV},g.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",L?x.keys.client_write_key:x.keys.server_write_key),iv:L?x.keys.client_write_IV:x.keys.server_write_IV},g.read.cipherFunction=c,g.write.cipherFunction=i,g.read.macLength=g.write.macLength=x.mac_length,g.read.macFunction=g.write.macFunction=e.hmac_sha1}function i(g,l){var x=!1,L=l.macFunction(l.macKey,l.sequenceNumber,g);g.fragment.putBytes(L),l.updateSequenceNumber();var b;g.version.minor===e.Versions.TLS_1_0.minor?b=l.cipherState.init?null:l.cipherState.iv:b=t.random.getBytesSync(16),l.cipherState.init=!0;var u=l.cipherState.cipher;return u.start({iv:b}),g.version.minor>=e.Versions.TLS_1_1.minor&&u.output.putBytes(b),u.update(g.fragment),u.finish(p)&&(g.fragment=u.output,g.length=g.fragment.length(),x=!0),x}function p(g,l,x){if(!x){var L=g-l.length()%g;l.fillWithByte(L-1,L)}return!0}function v(g,l,x){var L=!0;if(x){for(var b=l.length(),u=l.last(),m=b-1-u;m<b-1;++m)L=L&&l.at(m)==u;L&&l.truncate(u+1)}return L}function c(g,l){var x=!1,L;g.version.minor===e.Versions.TLS_1_0.minor?L=l.cipherState.init?null:l.cipherState.iv:L=g.fragment.getBytes(16),l.cipherState.init=!0;var b=l.cipherState.cipher;b.start({iv:L}),b.update(g.fragment),x=b.finish(v);var u=l.macLength,m=t.random.getBytesSync(u),E=b.output.length();E>=u?(g.fragment=b.output.getBytes(E-u),m=b.output.getBytes(u)):g.fragment=b.output.getBytes(),g.fragment=t.util.createBuffer(g.fragment),g.length=g.fragment.length();var C=l.macFunction(l.macKey,l.sequenceNumber,g);return l.updateSequenceNumber(),x=a(l.macKey,m,C)&&x,x}function a(g,l,x){var L=t.hmac.create();return L.start("SHA1",g),L.update(l),l=L.digest().getBytes(),L.start(null,null),L.update(x),x=L.digest().getBytes(),l===x}return Tr.exports}var Yr={exports:{}},gn;function li(){if(gn)return Yr.exports;gn=1;var t=ge();Et(),Ce();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(l){if(p||a(),typeof l>"u"&&(l="SHA-512"),!(l in c))throw new Error("Invalid SHA-512 algorithm: "+l);for(var x=c[l],L=null,b=t.util.createBuffer(),u=new Array(80),m=0;m<80;++m)u[m]=new Array(2);var E=64;switch(l){case"SHA-384":E=48;break;case"SHA-512/256":E=32;break;case"SHA-512/224":E=28;break}var C={algorithm:l.replace("-","").toLowerCase(),blockLength:128,digestLength:E,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(),L=new Array(x.length);for(var h=0;h<x.length;++h)L[h]=x[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 I=C.fullMessageLength.length-1;I>=0;--I)C.fullMessageLength[I]+=y[1],y[1]=y[0]+(C.fullMessageLength[I]/4294967296>>>0),C.fullMessageLength[I]=C.fullMessageLength[I]>>>0,y[0]=y[1]/4294967296>>>0;return b.putBytes(o),g(L,u,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 I,R,d=C.fullMessageLength[0]*8,s=0;s<C.fullMessageLength.length-1;++s)I=C.fullMessageLength[s+1]*8,R=I/4294967296>>>0,d+=R,o.putInt32(d>>>0),d=I>>>0;o.putInt32(d);for(var n=new Array(L.length),s=0;s<L.length;++s)n[s]=L[s].slice(0);g(n,u,o);var B=t.util.createBuffer(),P;l==="SHA-512"?P=n.length:l==="SHA-384"?P=n.length-2:P=n.length-4;for(var s=0;s<P;++s)B.putInt32(n[s][0]),(s!==P-1||l!=="SHA-512/224")&&B.putInt32(n[s][1]);return B},C};var i=null,p=!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]],p=!0}function g(l,x,L){for(var b,u,m,E,C,o,h,y,I,R,d,s,n,B,P,O,U,F,q,M,H,Q,j,ee,oe,ce,he,pe,ve,W,X,Re,ye,S,D,_=L.length();_>=128;){for(ve=0;ve<16;++ve)x[ve][0]=L.getInt32()>>>0,x[ve][1]=L.getInt32()>>>0;for(;ve<80;++ve)Re=x[ve-2],W=Re[0],X=Re[1],b=((W>>>19|X<<13)^(X>>>29|W<<3)^W>>>6)>>>0,u=((W<<13|X>>>19)^(X<<3|W>>>29)^(W<<26|X>>>6))>>>0,S=x[ve-15],W=S[0],X=S[1],m=((W>>>1|X<<31)^(W>>>8|X<<24)^W>>>7)>>>0,E=((W<<31|X>>>1)^(W<<24|X>>>8)^(W<<25|X>>>7))>>>0,ye=x[ve-7],D=x[ve-16],X=u+ye[1]+E+D[1],x[ve][0]=b+ye[0]+m+D[0]+(X/4294967296>>>0)>>>0,x[ve][1]=X>>>0;for(n=l[0][0],B=l[0][1],P=l[1][0],O=l[1][1],U=l[2][0],F=l[2][1],q=l[3][0],M=l[3][1],H=l[4][0],Q=l[4][1],j=l[5][0],ee=l[5][1],oe=l[6][0],ce=l[6][1],he=l[7][0],pe=l[7][1],ve=0;ve<80;++ve)h=((H>>>14|Q<<18)^(H>>>18|Q<<14)^(Q>>>9|H<<23))>>>0,y=((H<<18|Q>>>14)^(H<<14|Q>>>18)^(Q<<23|H>>>9))>>>0,I=(oe^H&(j^oe))>>>0,R=(ce^Q&(ee^ce))>>>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,d=(n&P|U&(n^P))>>>0,s=(B&O|F&(B^O))>>>0,X=pe+y+R+v[ve][1]+x[ve][1],b=he+h+I+v[ve][0]+x[ve][0]+(X/4294967296>>>0)>>>0,u=X>>>0,X=o+s,m=C+d+(X/4294967296>>>0)>>>0,E=X>>>0,he=oe,pe=ce,oe=j,ce=ee,j=H,ee=Q,X=M+u,H=q+b+(X/4294967296>>>0)>>>0,Q=X>>>0,q=U,M=F,U=P,F=O,P=n,O=B,X=u+E,n=b+m+(X/4294967296>>>0)>>>0,B=X>>>0;X=l[0][1]+B,l[0][0]=l[0][0]+n+(X/4294967296>>>0)>>>0,l[0][1]=X>>>0,X=l[1][1]+O,l[1][0]=l[1][0]+P+(X/4294967296>>>0)>>>0,l[1][1]=X>>>0,X=l[2][1]+F,l[2][0]=l[2][0]+U+(X/4294967296>>>0)>>>0,l[2][1]=X>>>0,X=l[3][1]+M,l[3][0]=l[3][0]+q+(X/4294967296>>>0)>>>0,l[3][1]=X>>>0,X=l[4][1]+Q,l[4][0]=l[4][0]+H+(X/4294967296>>>0)>>>0,l[4][1]=X>>>0,X=l[5][1]+ee,l[5][0]=l[5][0]+j+(X/4294967296>>>0)>>>0,l[5][1]=X>>>0,X=l[6][1]+ce,l[6][0]=l[6][0]+oe+(X/4294967296>>>0)>>>0,l[6][1]=X>>>0,X=l[7][1]+pe,l[7][0]=l[7][0]+he+(X/4294967296>>>0)>>>0,l[7][1]=X>>>0,_-=128}}return Yr.exports}var Jt={},yn;function Hs(){if(yn)return Jt;yn=1;var t=ge();ht();var e=t.asn1;return Jt.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"}]},Jt.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"}]},Jt}var jr,mn;function Gs(){if(mn)return jr;mn=1;var t=ge();ur(),lt(),li(),Ce();var e=Hs(),r=e.publicKeyValidator,i=e.privateKeyValidator;if(typeof p>"u")var p=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(D){D=D||{};var _=D.seed;if(_===void 0)_=t.random.getBytesSync(a.constants.SEED_BYTE_LENGTH);else if(typeof _=="string"){if(_.length!==a.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+a.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(_ instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');_=g({message:_,encoding:"binary"});for(var N=new c(a.constants.PUBLIC_KEY_BYTE_LENGTH),f=new c(a.constants.PRIVATE_KEY_BYTE_LENGTH),T=0;T<32;++T)f[T]=_[T];return h(N,f),{publicKey:N,privateKey:f}},a.privateKeyFromAsn1=function(D){var _={},N=[],f=t.asn1.validate(D,i,_,N);if(!f){var T=new Error("Invalid Key.");throw T.errors=N,T}var V=t.asn1.derToOid(_.privateKeyOid),G=t.oids.EdDSA25519;if(V!==G)throw new Error('Invalid OID "'+V+'"; OID must be "'+G+'".');var Z=_.privateKey,ne=g({message:t.asn1.fromDer(Z).value,encoding:"binary"});return{privateKeyBytes:ne}},a.publicKeyFromAsn1=function(D){var _={},N=[],f=t.asn1.validate(D,r,_,N);if(!f){var T=new Error("Invalid Key.");throw T.errors=N,T}var V=t.asn1.derToOid(_.publicKeyOid),G=t.oids.EdDSA25519;if(V!==G)throw new Error('Invalid OID "'+V+'"; OID must be "'+G+'".');var Z=_.ed25519PublicKey;if(Z.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return g({message:Z,encoding:"binary"})},a.publicKeyFromPrivateKey=function(D){D=D||{};var _=g({message:D.privateKey,encoding:"binary"});if(_.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),f=0;f<N.length;++f)N[f]=_[32+f];return N},a.sign=function(D){D=D||{};var _=g(D),N=g({message:D.privateKey,encoding:"binary"});if(N.length===a.constants.SEED_BYTE_LENGTH){var f=a.generateKeyPair({seed:N});N=f.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 T=new c(a.constants.SIGN_BYTE_LENGTH+_.length);y(T,_,_.length,N);for(var V=new c(a.constants.SIGN_BYTE_LENGTH),G=0;G<V.length;++G)V[G]=T[G];return V},a.verify=function(D){D=D||{};var _=g(D);if(D.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:D.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 f=g({message:D.publicKey,encoding:"binary"});if(f.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 T=new c(a.constants.SIGN_BYTE_LENGTH+_.length),V=new c(a.constants.SIGN_BYTE_LENGTH+_.length),G;for(G=0;G<a.constants.SIGN_BYTE_LENGTH;++G)T[G]=N[G];for(G=0;G<_.length;++G)T[G+a.constants.SIGN_BYTE_LENGTH]=_[G];return I(V,T,T.length,f)>=0};function g(D){var _=D.message;if(_ instanceof Uint8Array||_ instanceof c)return _;var N=D.encoding;if(_===void 0)if(D.md)_=D.md.digest().getBytes(),N="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof _=="string"&&!N)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof _=="string"){if(typeof Buffer<"u")return Buffer.from(_,N);_=new v(_,N)}else if(!(_ 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 f=new c(_.length()),T=0;T<f.length;++T)f[T]=_.at(T);return f}var l=W(),x=W([1]),L=W([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=W([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=W([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=W([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),E=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=W([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function o(D,_){var N=t.md.sha512.create(),f=new v(D);N.update(f.getBytes(_),"binary");var T=N.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(T,"binary");for(var V=new c(a.constants.HASH_BYTE_LENGTH),G=0;G<64;++G)V[G]=T.charCodeAt(G);return V}function h(D,_){var N=[W(),W(),W(),W()],f,T=o(_,32);for(T[0]&=248,T[31]&=127,T[31]|=64,oe(N,T),P(D,N),f=0;f<32;++f)_[f+32]=D[f];return 0}function y(D,_,N,f){var T,V,G=new Float64Array(64),Z=[W(),W(),W(),W()],ne=o(f,32);ne[0]&=248,ne[31]&=127,ne[31]|=64;var z=N+64;for(T=0;T<N;++T)D[64+T]=_[T];for(T=0;T<32;++T)D[32+T]=ne[32+T];var J=o(D.subarray(32),N+32);for(s(J),oe(Z,J),P(D,Z),T=32;T<64;++T)D[T]=f[T];var fe=o(D,N+64);for(s(fe),T=32;T<64;++T)G[T]=0;for(T=0;T<32;++T)G[T]=J[T];for(T=0;T<32;++T)for(V=0;V<32;V++)G[T+V]+=fe[T]*ne[V];return d(D.subarray(32),G),z}function I(D,_,N,f){var T,V,G=new c(32),Z=[W(),W(),W(),W()],ne=[W(),W(),W(),W()];if(V=-1,N<64||U(ne,f)||!R(_,32))return-1;for(T=0;T<N;++T)D[T]=_[T];for(T=0;T<32;++T)D[T+32]=f[T];var z=o(D,N);if(s(z),ee(Z,ne,z),oe(ne,_.subarray(32)),n(Z,ne),P(G,Z),N-=64,H(_,0,G,0)){for(T=0;T<N;++T)D[T]=0;return-1}for(T=0;T<N;++T)D[T]=_[T+64];return V=N,V}function R(D,_){var N;for(N=31;N>=0;--N){if(D[_+N]<E[N])return!0;if(D[_+N]>E[N])return!1}return!1}function d(D,_){var N,f,T,V;for(f=63;f>=32;--f){for(N=0,T=f-32,V=f-12;T<V;++T)_[T]+=N-16*_[f]*E[T-(f-32)],N=_[T]+128>>8,_[T]-=N*256;_[T]+=N,_[f]=0}for(N=0,T=0;T<32;++T)_[T]+=N-(_[31]>>4)*E[T],N=_[T]>>8,_[T]&=255;for(T=0;T<32;++T)_[T]-=N*E[T];for(f=0;f<32;++f)_[f+1]+=_[f]>>8,D[f]=_[f]&255}function s(D){for(var _=new Float64Array(64),N=0;N<64;++N)_[N]=D[N],D[N]=0;d(D,_)}function n(D,_){var N=W(),f=W(),T=W(),V=W(),G=W(),Z=W(),ne=W(),z=W(),J=W();Re(N,D[1],D[0]),Re(J,_[1],_[0]),S(N,N,J),X(f,D[0],D[1]),X(J,_[0],_[1]),S(f,f,J),S(T,D[3],_[3]),S(T,T,b),S(V,D[2],_[2]),X(V,V,V),Re(G,f,N),Re(Z,V,T),X(ne,V,T),X(z,f,N),S(D[0],G,Z),S(D[1],z,ne),S(D[2],ne,Z),S(D[3],G,z)}function B(D,_,N){for(var f=0;f<4;++f)ve(D[f],_[f],N)}function P(D,_){var N=W(),f=W(),T=W();he(T,_[2]),S(N,_[0],T),S(f,_[1],T),O(D,f),D[31]^=j(N)<<7}function O(D,_){var N,f,T,V=W(),G=W();for(N=0;N<16;++N)G[N]=_[N];for(pe(G),pe(G),pe(G),f=0;f<2;++f){for(V[0]=G[0]-65517,N=1;N<15;++N)V[N]=G[N]-65535-(V[N-1]>>16&1),V[N-1]&=65535;V[15]=G[15]-32767-(V[14]>>16&1),T=V[15]>>16&1,V[14]&=65535,ve(G,V,1-T)}for(N=0;N<16;N++)D[2*N]=G[N]&255,D[2*N+1]=G[N]>>8}function U(D,_){var N=W(),f=W(),T=W(),V=W(),G=W(),Z=W(),ne=W();return ce(D[2],x),F(D[1],_),ye(T,D[1]),S(V,T,L),Re(T,T,D[2]),X(V,D[2],V),ye(G,V),ye(Z,G),S(ne,Z,G),S(N,ne,T),S(N,N,V),q(N,N),S(N,N,T),S(N,N,V),S(N,N,V),S(D[0],N,V),ye(f,D[0]),S(f,f,V),M(f,T)&&S(D[0],D[0],C),ye(f,D[0]),S(f,f,V),M(f,T)?-1:(j(D[0])===_[31]>>7&&Re(D[0],l,D[0]),S(D[3],D[0],D[1]),0)}function F(D,_){var N;for(N=0;N<16;++N)D[N]=_[2*N]+(_[2*N+1]<<8);D[15]&=32767}function q(D,_){var N=W(),f;for(f=0;f<16;++f)N[f]=_[f];for(f=250;f>=0;--f)ye(N,N),f!==1&&S(N,N,_);for(f=0;f<16;++f)D[f]=N[f]}function M(D,_){var N=new c(32),f=new c(32);return O(N,D),O(f,_),H(N,0,f,0)}function H(D,_,N,f){return Q(D,_,N,f,32)}function Q(D,_,N,f,T){var V,G=0;for(V=0;V<T;++V)G|=D[_+V]^N[f+V];return(1&G-1>>>8)-1}function j(D){var _=new c(32);return O(_,D),_[0]&1}function ee(D,_,N){var f,T;for(ce(D[0],l),ce(D[1],x),ce(D[2],x),ce(D[3],l),T=255;T>=0;--T)f=N[T/8|0]>>(T&7)&1,B(D,_,f),n(_,D),n(D,D),B(D,_,f)}function oe(D,_){var N=[W(),W(),W(),W()];ce(N[0],u),ce(N[1],m),ce(N[2],x),S(N[3],u,m),ee(D,N,_)}function ce(D,_){var N;for(N=0;N<16;N++)D[N]=_[N]|0}function he(D,_){var N=W(),f;for(f=0;f<16;++f)N[f]=_[f];for(f=253;f>=0;--f)ye(N,N),f!==2&&f!==4&&S(N,N,_);for(f=0;f<16;++f)D[f]=N[f]}function pe(D){var _,N,f=1;for(_=0;_<16;++_)N=D[_]+f+65535,f=Math.floor(N/65536),D[_]=N-f*65536;D[0]+=f-1+37*(f-1)}function ve(D,_,N){for(var f,T=~(N-1),V=0;V<16;++V)f=T&(D[V]^_[V]),D[V]^=f,_[V]^=f}function W(D){var _,N=new Float64Array(16);if(D)for(_=0;_<D.length;++_)N[_]=D[_];return N}function X(D,_,N){for(var f=0;f<16;++f)D[f]=_[f]+N[f]}function Re(D,_,N){for(var f=0;f<16;++f)D[f]=_[f]-N[f]}function ye(D,_){S(D,_,_)}function S(D,_,N){var f,T,V=0,G=0,Z=0,ne=0,z=0,J=0,fe=0,me=0,ue=0,Te=0,Ne=0,Be=0,Ie=0,Ae=0,be=0,Ee=0,_e=0,De=0,Pe=0,Ue=0,Ze=0,te=0,re=0,ie=0,le=0,xe=0,tt=0,st=0,vt=0,xt=0,gt=0,ke=N[0],Ve=N[1],Oe=N[2],Fe=N[3],Ke=N[4],Me=N[5],qe=N[6],He=N[7],Ge=N[8],ze=N[9],Qe=N[10],$e=N[11],we=N[12],Le=N[13],We=N[14],Ye=N[15];f=_[0],V+=f*ke,G+=f*Ve,Z+=f*Oe,ne+=f*Fe,z+=f*Ke,J+=f*Me,fe+=f*qe,me+=f*He,ue+=f*Ge,Te+=f*ze,Ne+=f*Qe,Be+=f*$e,Ie+=f*we,Ae+=f*Le,be+=f*We,Ee+=f*Ye,f=_[1],G+=f*ke,Z+=f*Ve,ne+=f*Oe,z+=f*Fe,J+=f*Ke,fe+=f*Me,me+=f*qe,ue+=f*He,Te+=f*Ge,Ne+=f*ze,Be+=f*Qe,Ie+=f*$e,Ae+=f*we,be+=f*Le,Ee+=f*We,_e+=f*Ye,f=_[2],Z+=f*ke,ne+=f*Ve,z+=f*Oe,J+=f*Fe,fe+=f*Ke,me+=f*Me,ue+=f*qe,Te+=f*He,Ne+=f*Ge,Be+=f*ze,Ie+=f*Qe,Ae+=f*$e,be+=f*we,Ee+=f*Le,_e+=f*We,De+=f*Ye,f=_[3],ne+=f*ke,z+=f*Ve,J+=f*Oe,fe+=f*Fe,me+=f*Ke,ue+=f*Me,Te+=f*qe,Ne+=f*He,Be+=f*Ge,Ie+=f*ze,Ae+=f*Qe,be+=f*$e,Ee+=f*we,_e+=f*Le,De+=f*We,Pe+=f*Ye,f=_[4],z+=f*ke,J+=f*Ve,fe+=f*Oe,me+=f*Fe,ue+=f*Ke,Te+=f*Me,Ne+=f*qe,Be+=f*He,Ie+=f*Ge,Ae+=f*ze,be+=f*Qe,Ee+=f*$e,_e+=f*we,De+=f*Le,Pe+=f*We,Ue+=f*Ye,f=_[5],J+=f*ke,fe+=f*Ve,me+=f*Oe,ue+=f*Fe,Te+=f*Ke,Ne+=f*Me,Be+=f*qe,Ie+=f*He,Ae+=f*Ge,be+=f*ze,Ee+=f*Qe,_e+=f*$e,De+=f*we,Pe+=f*Le,Ue+=f*We,Ze+=f*Ye,f=_[6],fe+=f*ke,me+=f*Ve,ue+=f*Oe,Te+=f*Fe,Ne+=f*Ke,Be+=f*Me,Ie+=f*qe,Ae+=f*He,be+=f*Ge,Ee+=f*ze,_e+=f*Qe,De+=f*$e,Pe+=f*we,Ue+=f*Le,Ze+=f*We,te+=f*Ye,f=_[7],me+=f*ke,ue+=f*Ve,Te+=f*Oe,Ne+=f*Fe,Be+=f*Ke,Ie+=f*Me,Ae+=f*qe,be+=f*He,Ee+=f*Ge,_e+=f*ze,De+=f*Qe,Pe+=f*$e,Ue+=f*we,Ze+=f*Le,te+=f*We,re+=f*Ye,f=_[8],ue+=f*ke,Te+=f*Ve,Ne+=f*Oe,Be+=f*Fe,Ie+=f*Ke,Ae+=f*Me,be+=f*qe,Ee+=f*He,_e+=f*Ge,De+=f*ze,Pe+=f*Qe,Ue+=f*$e,Ze+=f*we,te+=f*Le,re+=f*We,ie+=f*Ye,f=_[9],Te+=f*ke,Ne+=f*Ve,Be+=f*Oe,Ie+=f*Fe,Ae+=f*Ke,be+=f*Me,Ee+=f*qe,_e+=f*He,De+=f*Ge,Pe+=f*ze,Ue+=f*Qe,Ze+=f*$e,te+=f*we,re+=f*Le,ie+=f*We,le+=f*Ye,f=_[10],Ne+=f*ke,Be+=f*Ve,Ie+=f*Oe,Ae+=f*Fe,be+=f*Ke,Ee+=f*Me,_e+=f*qe,De+=f*He,Pe+=f*Ge,Ue+=f*ze,Ze+=f*Qe,te+=f*$e,re+=f*we,ie+=f*Le,le+=f*We,xe+=f*Ye,f=_[11],Be+=f*ke,Ie+=f*Ve,Ae+=f*Oe,be+=f*Fe,Ee+=f*Ke,_e+=f*Me,De+=f*qe,Pe+=f*He,Ue+=f*Ge,Ze+=f*ze,te+=f*Qe,re+=f*$e,ie+=f*we,le+=f*Le,xe+=f*We,tt+=f*Ye,f=_[12],Ie+=f*ke,Ae+=f*Ve,be+=f*Oe,Ee+=f*Fe,_e+=f*Ke,De+=f*Me,Pe+=f*qe,Ue+=f*He,Ze+=f*Ge,te+=f*ze,re+=f*Qe,ie+=f*$e,le+=f*we,xe+=f*Le,tt+=f*We,st+=f*Ye,f=_[13],Ae+=f*ke,be+=f*Ve,Ee+=f*Oe,_e+=f*Fe,De+=f*Ke,Pe+=f*Me,Ue+=f*qe,Ze+=f*He,te+=f*Ge,re+=f*ze,ie+=f*Qe,le+=f*$e,xe+=f*we,tt+=f*Le,st+=f*We,vt+=f*Ye,f=_[14],be+=f*ke,Ee+=f*Ve,_e+=f*Oe,De+=f*Fe,Pe+=f*Ke,Ue+=f*Me,Ze+=f*qe,te+=f*He,re+=f*Ge,ie+=f*ze,le+=f*Qe,xe+=f*$e,tt+=f*we,st+=f*Le,vt+=f*We,xt+=f*Ye,f=_[15],Ee+=f*ke,_e+=f*Ve,De+=f*Oe,Pe+=f*Fe,Ue+=f*Ke,Ze+=f*Me,te+=f*qe,re+=f*He,ie+=f*Ge,le+=f*ze,xe+=f*Qe,tt+=f*$e,st+=f*we,vt+=f*Le,xt+=f*We,gt+=f*Ye,V+=38*_e,G+=38*De,Z+=38*Pe,ne+=38*Ue,z+=38*Ze,J+=38*te,fe+=38*re,me+=38*ie,ue+=38*le,Te+=38*xe,Ne+=38*tt,Be+=38*st,Ie+=38*vt,Ae+=38*xt,be+=38*gt,T=1,f=V+T+65535,T=Math.floor(f/65536),V=f-T*65536,f=G+T+65535,T=Math.floor(f/65536),G=f-T*65536,f=Z+T+65535,T=Math.floor(f/65536),Z=f-T*65536,f=ne+T+65535,T=Math.floor(f/65536),ne=f-T*65536,f=z+T+65535,T=Math.floor(f/65536),z=f-T*65536,f=J+T+65535,T=Math.floor(f/65536),J=f-T*65536,f=fe+T+65535,T=Math.floor(f/65536),fe=f-T*65536,f=me+T+65535,T=Math.floor(f/65536),me=f-T*65536,f=ue+T+65535,T=Math.floor(f/65536),ue=f-T*65536,f=Te+T+65535,T=Math.floor(f/65536),Te=f-T*65536,f=Ne+T+65535,T=Math.floor(f/65536),Ne=f-T*65536,f=Be+T+65535,T=Math.floor(f/65536),Be=f-T*65536,f=Ie+T+65535,T=Math.floor(f/65536),Ie=f-T*65536,f=Ae+T+65535,T=Math.floor(f/65536),Ae=f-T*65536,f=be+T+65535,T=Math.floor(f/65536),be=f-T*65536,f=Ee+T+65535,T=Math.floor(f/65536),Ee=f-T*65536,V+=T-1+37*(T-1),T=1,f=V+T+65535,T=Math.floor(f/65536),V=f-T*65536,f=G+T+65535,T=Math.floor(f/65536),G=f-T*65536,f=Z+T+65535,T=Math.floor(f/65536),Z=f-T*65536,f=ne+T+65535,T=Math.floor(f/65536),ne=f-T*65536,f=z+T+65535,T=Math.floor(f/65536),z=f-T*65536,f=J+T+65535,T=Math.floor(f/65536),J=f-T*65536,f=fe+T+65535,T=Math.floor(f/65536),fe=f-T*65536,f=me+T+65535,T=Math.floor(f/65536),me=f-T*65536,f=ue+T+65535,T=Math.floor(f/65536),ue=f-T*65536,f=Te+T+65535,T=Math.floor(f/65536),Te=f-T*65536,f=Ne+T+65535,T=Math.floor(f/65536),Ne=f-T*65536,f=Be+T+65535,T=Math.floor(f/65536),Be=f-T*65536,f=Ie+T+65535,T=Math.floor(f/65536),Ie=f-T*65536,f=Ae+T+65535,T=Math.floor(f/65536),Ae=f-T*65536,f=be+T+65535,T=Math.floor(f/65536),be=f-T*65536,f=Ee+T+65535,T=Math.floor(f/65536),Ee=f-T*65536,V+=T-1+37*(T-1),D[0]=V,D[1]=G,D[2]=Z,D[3]=ne,D[4]=z,D[5]=J,D[6]=fe,D[7]=me,D[8]=ue,D[9]=Te,D[10]=Ne,D[11]=Be,D[12]=Ie,D[13]=Ae,D[14]=be,D[15]=Ee}return jr}var Xr,Cn;function zs(){if(Cn)return Xr;Cn=1;var t=ge();Ce(),lt(),ur(),Xr=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(i,p){p=p||{};var v=p.prng||t.random,c={};return c.encrypt=function(a,g){var l=Math.ceil(a.n.bitLength()/8),x;do x=new e(t.util.bytesToHex(v.getBytesSync(l)),16).mod(a.n);while(x.compareTo(e.ONE)<=0);x=t.util.hexToBytes(x.toString(16));var L=l-x.length;L>0&&(x=t.util.fillString("\0",L)+x);var b=a.encrypt(x,"NONE"),u=i.generate(x,g);return{encapsulation:b,key:u}},c.decrypt=function(a,g,l){var x=a.decrypt(g,"NONE");return i.generate(x,l)},c},t.kem.kdf1=function(i,p){r(this,i,0,p||i.digestLength)},t.kem.kdf2=function(i,p){r(this,i,1,p||i.digestLength)};function r(i,p,v,c){i.generate=function(a,g){for(var l=new t.util.ByteBuffer,x=Math.ceil(g/c)+v,L=new t.util.ByteBuffer,b=v;b<x;++b){L.putInt32(b),p.start(),p.update(a+L.getBytes());var u=p.digest();l.putBytes(u.getBytes(c))}return l.truncate(l.length()-g),l.getBytes()}}return Xr}var Zr,En;function Qs(){if(En)return Zr;En=1;var t=ge();Ce(),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 p=0;p<t.log.levels.length;++p){var v=t.log.levels[p];e[v]={index:p,name:v.toUpperCase()}}t.log.logMessage=function(b){for(var u=e[b.level].index,m=0;m<r.length;++m){var E=r[m];if(E.flags&t.log.NO_LEVEL_CHECK)E.f(b);else{var C=e[E.level].index;u<=C&&E.f(E,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 u=[b.message];u=u.concat([]),b.full=t.util.format.apply(this,u)}},t.log.prepareStandardFull=function(b){"standardFull"in b||(t.log.prepareStandard(b),b.standardFull=b.standard)};for(var c=["error","warning","info","debug","verbose"],p=0;p<c.length;++p)(function(u){t.log[u]=function(m,E){var C=Array.prototype.slice.call(arguments).slice(2),o={timestamp:new Date,level:u,category:m,message:E,arguments:C};t.log.logMessage(o)}})(c[p]);if(t.log.makeLogger=function(b){var u={flags:0,f:b};return t.log.setLevel(u,"none"),u},t.log.setLevel=function(b,u){var m=!1;if(b&&!(b.flags&t.log.LEVEL_LOCKED))for(var E=0;E<t.log.levels.length;++E){var C=t.log.levels[E];if(u==C){b.level=u,m=!0;break}}return m},t.log.lock=function(b,u){typeof u>"u"||u?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},l=function(b,u){t.log.prepareStandard(u);var m=g[u.level],E=[u.standard];E=E.concat(u.arguments.slice()),m.apply(console,E)};a=t.log.makeLogger(l)}else{var l=function(u,m){t.log.prepareStandardFull(m),console.log(m.standardFull)};a=t.log.makeLogger(l)}t.log.setLevel(a,"debug"),t.log.addLogger(a),i=a}else console={log:function(){}};if(i!==null&&typeof window<"u"&&window.location){var x=new URL(window.location.href).searchParams;if(x.has("console.level")&&t.log.setLevel(i,x.get("console.level").slice(-1)[0]),x.has("console.lock")){var L=x.get("console.lock").slice(-1)[0];L=="true"&&t.log.lock(i)}}return t.log.consoleLogger=i,Zr}var Jr,xn;function $s(){return xn||(xn=1,Jr=Et(),ma(),Qt(),ei(),li()),Jr}var ea={exports:{}},Sn;function Ws(){if(Sn)return ea.exports;Sn=1;var t=ge();Dt(),ht(),fr(),Lt(),Vt(),si(),lt(),Ce(),Sa();var e=t.asn1,r=ea.exports=t.pkcs7=t.pkcs7||{};r.messageFromPem=function(u){var m=t.pem.decode(u)[0];if(m.type!=="PKCS7"){var E=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw E.headerType=m.type,E}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(u,m){var E={type:"PKCS7",body:e.toDer(u.toAsn1()).getBytes()};return t.pem.encode(E,{maxline:m})},r.messageFromAsn1=function(u){var m={},E=[];if(!e.validate(u,r.asn1.contentInfoValidator,m,E)){var C=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw C.errors=E,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 u=null;return u={type:t.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(C){if(L(u,C,r.asn1.signedDataValidator),u.certificates=[],u.crls=[],u.digestAlgorithmIdentifiers=[],u.contentInfo=null,u.signerInfos=[],u.rawCapture.certificates)for(var o=u.rawCapture.certificates.value,h=0;h<o.length;++h)u.certificates.push(t.pki.certificateFromAsn1(o[h]))},toAsn1:function(){u.contentInfo||u.sign();for(var C=[],o=0;o<u.certificates.length;++o)C.push(t.pki.certificateToAsn1(u.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(u.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,u.digestAlgorithmIdentifiers),u.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,u.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(u.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 I=C.key;if(!I)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof I=="string"&&(I=t.pki.privateKeyFromPem(I));var R=C.digestAlgorithm||t.pki.oids.sha1;switch(R){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: "+R)}var d=C.authenticatedAttributes||[];if(d.length>0){for(var s=!1,n=!1,B=0;B<d.length;++B){var P=d[B];if(!s&&P.type===t.pki.oids.contentType){if(s=!0,n)break;continue}if(!n&&P.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.")}u.signers.push({key:I,version:1,issuer:o,serialNumber:h,digestAlgorithm:R,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:d,unauthenticatedAttributes:[]})},sign:function(C){if(C=C||{},(typeof u.content!="object"||u.contentInfo===null)&&(u.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 u)){var o;u.content instanceof t.util.ByteBuffer?o=u.content.bytes():typeof u.content=="string"&&(o=t.util.encodeUtf8(u.content)),C.detached?u.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,o):u.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,o)]))}if(u.signers.length!==0){var h=m();E(h)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(C){typeof C=="string"&&(C=t.pki.certificateFromPem(C)),u.certificates.push(C)},addCertificateRevokationList:function(C){throw new Error("PKCS#7 CRL support not yet implemented.")}},u;function m(){for(var C={},o=0;o<u.signers.length;++o){var h=u.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()}u.digestAlgorithmIdentifiers=[];for(var y in C)u.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 E(C){var o;if(u.detachedContent?o=u.detachedContent:(o=u.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(u.contentInfo.value[0].value),y=e.toDer(o);y.getByte(),e.getBerValueLength(y),y=y.getBytes();for(var I in C)C[I].start().update(y);for(var R=new Date,d=0;d<u.signers.length;++d){var s=u.signers[d];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 P=s.authenticatedAttributes[B];P.type===t.pki.oids.messageDigest?P.value=C[s.digestAlgorithm].digest():P.type===t.pki.oids.signingTime&&(P.value||(P.value=R)),n.value.push(l(P)),s.authenticatedAttributesAsn1.value.push(l(P))}y=e.toDer(n).getBytes(),s.md.start().update(y)}s.signature=s.key.sign(s.md,"RSASSA-PKCS1-V1_5")}u.signerInfos=g(u.signers)}},r.createEncryptedData=function(){var u=null;return u={type:t.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){L(u,m,r.asn1.encryptedDataValidator)},decrypt:function(m){m!==void 0&&(u.encryptedContent.key=m),b(u)}},u},r.createEnvelopedData=function(){var u=null;return u={type:t.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){var E=L(u,m,r.asn1.envelopedDataValidator);u.recipients=v(E.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(u.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(u.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c(u.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,x(u.encryptedContent))])])])},findRecipient:function(m){for(var E=m.issuer.attributes,C=0;C<u.recipients.length;++C){var o=u.recipients[C],h=o.issuer;if(o.serialNumber===m.serialNumber&&h.length===E.length){for(var y=!0,I=0;I<E.length;++I)if(h[I].type!==E[I].type||h[I].value!==E[I].value){y=!1;break}if(y)return o}}return null},decrypt:function(m,E){if(u.encryptedContent.key===void 0&&m!==void 0&&E!==void 0)switch(m.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var C=E.decrypt(m.encryptedContent.content);u.encryptedContent.key=t.util.createBuffer(C);break;default:throw new Error("Unsupported asymmetric cipher, OID "+m.encryptedContent.algorithm)}b(u)},addRecipient:function(m){u.recipients.push({version:0,issuer:m.issuer.attributes,serialNumber:m.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:m.publicKey}})},encrypt:function(m,E){if(u.encryptedContent.content===void 0){E=E||u.encryptedContent.algorithm,m=m||u.encryptedContent.key;var C,o,h;switch(E){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 "+E)}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+".");u.encryptedContent.algorithm=E,u.encryptedContent.key=m,u.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(o));var y=h(m);if(y.start(u.encryptedContent.parameter.copy()),y.update(u.content),!y.finish())throw new Error("Symmetric encryption failed.");u.encryptedContent.content=y.output}for(var I=0;I<u.recipients.length;++I){var R=u.recipients[I];if(R.encryptedContent.content===void 0)switch(R.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:R.encryptedContent.content=R.encryptedContent.key.encrypt(u.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+R.encryptedContent.algorithm)}}}},u};function i(u){var m={},E=[];if(!e.validate(u,r.asn1.recipientInfoValidator,m,E)){var C=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw C.errors=E,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 p(u){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(u.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:u.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(u.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(u.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u.encryptedContent.content)])}function v(u){for(var m=[],E=0;E<u.length;++E)m.push(i(u[E]));return m}function c(u){for(var m=[],E=0;E<u.length;++E)m.push(p(u[E]));return m}function a(u){var m=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(u.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:u.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(u.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(u.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(u.authenticatedAttributesAsn1&&m.value.push(u.authenticatedAttributesAsn1),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(u.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u.signature)),u.unauthenticatedAttributes.length>0){for(var E=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]),C=0;C<u.unauthenticatedAttributes.length;++C){var o=u.unauthenticatedAttributes[C];E.values.push(l(o))}m.value.push(E)}return m}function g(u){for(var m=[],E=0;E<u.length;++E)m.push(a(u[E]));return m}function l(u){var m;if(u.type===t.pki.oids.contentType)m=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(u.value).getBytes());else if(u.type===t.pki.oids.messageDigest)m=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u.value.bytes());else if(u.type===t.pki.oids.signingTime){var E=new Date("1950-01-01T00:00:00Z"),C=new Date("2050-01-01T00:00:00Z"),o=u.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>=E&&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(u.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[m])])}function x(u){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(u.algorithm).getBytes()),u.parameter?e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u.parameter.getBytes()):void 0]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,u.content.getBytes())])]}function L(u,m,E){var C={},o=[];if(!e.validate(m,E,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 I="";if(t.util.isArray(C.encryptedContent))for(var R=0;R<C.encryptedContent.length;++R){if(C.encryptedContent[R].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");I+=C.encryptedContent[R].value}else I=C.encryptedContent;u.encryptedContent={algorithm:e.derToOid(C.encAlgorithm),parameter:t.util.createBuffer(C.encParameter.value),content:t.util.createBuffer(I)}}if(C.content){var I="";if(t.util.isArray(C.content))for(var R=0;R<C.content.length;++R){if(C.content[R].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");I+=C.content[R].value}else I=C.content;u.content=t.util.createBuffer(I)}return u.version=C.version.charCodeAt(0),u.rawCapture=C,C}function b(u){if(u.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(u.content===void 0){var m;switch(u.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:m=t.aes.createDecryptionCipher(u.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:m=t.des.createDecryptionCipher(u.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+u.encryptedContent.algorithm)}if(m.start(u.encryptedContent.parameter),m.update(u.encryptedContent.content),!m.finish())throw new Error("Symmetric decryption failed.");u.content=m.output}}return ea.exports}var ta={exports:{}},bn;function Ys(){if(bn)return ta.exports;bn=1;var t=ge();Dt(),zt(),ma(),Qt(),Ce();var e=ta.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(v,c,a){a=a||"",c=c||"";var g="ssh-rsa",l=c===""?"none":"aes256-cbc",x="PuTTY-User-Key-File-2: "+g+`\r
|
|
15
|
+
`;x+="Encryption: "+l+`\r
|
|
16
|
+
`,x+="Comment: "+a+`\r
|
|
17
|
+
`;var L=t.util.createBuffer();i(L,g),r(L,v.e),r(L,v.n);var b=t.util.encode64(L.bytes(),64),u=Math.floor(b.length/66)+1;x+="Public-Lines: "+u+`\r
|
|
18
|
+
`,x+=b;var m=t.util.createBuffer();r(m,v.d),r(m,v.p),r(m,v.q),r(m,v.qInv);var E;if(!c)E=t.util.encode64(m.bytes(),64);else{var C=m.length()+16-1;C-=C%16;var o=p(m.bytes());o.truncate(o.length()-C+m.length()),m.putBuffer(o);var h=t.util.createBuffer();h.putBuffer(p("\0\0\0\0",c)),h.putBuffer(p("\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 I=y.output;I.truncate(16),E=t.util.encode64(I.bytes(),64)}u=Math.floor(E.length/66)+1,x+=`\r
|
|
19
|
+
Private-Lines: `+u+`\r
|
|
20
|
+
`,x+=E;var R=p("putty-private-key-file-mac-key",c),d=t.util.createBuffer();i(d,g),i(d,l),i(d,a),d.putInt32(L.length()),d.putBuffer(L),d.putInt32(m.length()),d.putBuffer(m);var s=t.hmac.create();return s.start("sha1",R),s.update(d.bytes()),x+=`\r
|
|
21
|
+
Private-MAC: `+s.digest().toHex()+`\r
|
|
22
|
+
`,x},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",l=t.util.createBuffer();i(l,g),r(l,v.e),r(l,v.n),a.start(),a.update(l.getBytes());var x=a.digest();if(c.encoding==="hex"){var L=x.toHex();return c.delimiter?L.match(/.{2}/g).join(c.delimiter):L}else{if(c.encoding==="binary")return x.getBytes();if(c.encoding)throw new Error('Unknown encoding "'+c.encoding+'".')}return x};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 p(){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 js(){return Tn||(Tn=1,ra=ge(),Dt(),qs(),ht(),ya(),fr(),Gs(),zt(),zs(),Qs(),$s(),oi(),Ea(),Vt(),ai(),ci(),Ws(),fi(),ni(),ti(),xa(),lt(),ri(),Ys(),ui(),Ce()),ra}var Xs=js();const wt=ks(Xs),Zs={name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"};async function di(t){if(!crypto.subtle)throw new Error("WebCrypto is not available in this browser.");const e=await crypto.subtle.generateKey(Zs,!0,["sign","verify"]),r=new Uint8Array(await crypto.subtle.exportKey("spki",e.publicKey)),i=qt(ro(0),Js(t),r,to(0,new Uint8Array)),p=new Uint8Array(await crypto.subtle.sign("RSASSA-PKCS1-v1_5",e.privateKey,po(i))),v=qt(i,qt(hi("1.2.840.113549.1.1.11"),ao()),so(p)),c=new Uint8Array(await crypto.subtle.exportKey("pkcs8",e.privateKey));return{privateKey:e.privateKey,privateKeyPKCS8Base64:tr(c),publicKeySPKIBase64:tr(r),csrPEM:co("CERTIFICATE REQUEST",v),csrBase64:tr(v)}}function pi(t){if(!t.certificateBase64&&!t.certificatePEM)throw new Error("certificateBase64 or certificatePEM is required.");const e=wt.pki.privateKeyFromPem(fo("PRIVATE KEY",t.privateKeyPKCS8Base64)),r=t.certificatePEM?wt.pki.certificateFromPem(t.certificatePEM):wt.pki.certificateFromAsn1(wt.asn1.fromDer(wt.util.createBuffer(lo(t.certificateBase64)))),i=wt.pkcs12.toPkcs12Asn1(e,[r],t.password,{algorithm:"3des",friendlyName:t.friendlyName}),p=wt.asn1.toDer(i).getBytes();return uo(p)}function Js(t){const e=[An("2.5.4.3",no(t.commonName))];return t.emailAddress&&e.push(An("1.2.840.113549.1.9.1",io(t.emailAddress))),qt(...e)}function An(t,e){return eo(qt(hi(t),e))}function qt(...t){return Bt(48,dr(...t))}function eo(...t){return Bt(49,dr(...t))}function to(t,e){return Bt(160+t,e)}function ro(t){return Bt(2,new Uint8Array([t]))}function ao(){return new Uint8Array([5,0])}function no(t){return Bt(12,new TextEncoder().encode(t))}function io(t){return Bt(22,new TextEncoder().encode(t))}function so(t){return Bt(3,dr(new Uint8Array([0]),t))}function hi(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 p=[i&127];let v=i>>7;for(;v>0;)p.unshift(v&127|128),v>>=7;r.push(...p)}return Bt(6,new Uint8Array(r))}function Bt(t,e){return dr(new Uint8Array([t]),oo(e.byteLength),e)}function oo(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 dr(...t){const e=t.reduce((p,v)=>p+v.byteLength,0),r=new Uint8Array(e);let i=0;for(const p of t)r.set(p,i),i+=p.byteLength;return r}function co(t,e){const i=tr(e).match(/.{1,64}/g)??[];return`-----BEGIN ${t}-----
|
|
23
|
+
${i.join(`
|
|
24
|
+
`)}
|
|
25
|
+
-----END ${t}-----
|
|
26
|
+
`}function fo(t,e){const r=e.match(/.{1,64}/g)??[];return`-----BEGIN ${t}-----
|
|
27
|
+
${r.join(`
|
|
28
|
+
`)}
|
|
29
|
+
-----END ${t}-----
|
|
30
|
+
`}function tr(t){let e="";for(const r of t)e+=String.fromCharCode(r);return btoa(e)}function uo(t){return btoa(t)}function lo(t){return atob(t)}function po(t){const e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}const vi="limbuild-device-pairing",gi=1,Ut="pairRecords",ba="limbuild-device-signing",Ta=1,mt="signingAssets";function Tt(t){return(t??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")}function At(t){return(t??"").trim()}async function yi(t){const e=Tt(t);if(!e)return;const r=await $t(vi,gi,Ut,"udid");return Wt(r.transaction(Ut,"readonly").objectStore(Ut).get(e))}async function mi(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()},p=await $t(vi,gi,Ut,"udid");return await Wt(p.transaction(Ut,"readwrite").objectStore(Ut).put(i)),i}async function Ci({deviceUDID:t,bundleID:e}){const r=At(e);if(!r)return;const i=Tt(t),p=await In(la("bundle",r));if(p)return p;if(i){const c=await In(la(i,r));if(c)return c}return(await xi(r))[0]}async function rr(){return(await wa()).sort((e,r)=>new Date(r.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]}async function Ei(t){return(await wa()).filter(r=>!r.certificateID||!r.certificateP12Base64||!r.certificatePassword?!1:!t||!r.teamID||r.teamID===t).sort((r,i)=>new Date(i.updatedAt).getTime()-new Date(r.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=la("bundle",e),p={...t,id:i,deviceUDID:r||void 0,bundleID:e,updatedAt:new Date().toISOString()},v=await $t(ba,Ta,mt,"id");return await Wt(v.transaction(mt,"readwrite").objectStore(mt).put(p)),p}async function xi(t){const e=At(t);return e?(await wa()).filter(i=>i.bundleID===e):[]}function Ht(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 p=i.slice(0,-1);return r.startsWith(p)}async function Si(t){return Ba(new Uint8Array(await t.arrayBuffer()))}function bi(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 p=e.slice(r,i+8),v=new DOMParser().parseFromString(p,"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:{},l=Ot(g["application-identifier"]),x=ho(l);return{name:Ot(a.Name),uuid:Ot(a.UUID),teamID:Ot(g["com.apple.developer.team-identifier"])??Bn(a.TeamIdentifier)[0],applicationIdentifier:l,bundleID:x,provisionedDevices:Bn(a.ProvisionedDevices),expirationDate:Ot(a.ExpirationDate)}}async function In(t){if(!t)return;const e=await $t(ba,Ta,mt,"id");return Wt(e.transaction(mt,"readonly").objectStore(mt).get(t))}async function wa(){const t=await $t(ba,Ta,mt,"id");return Wt(t.transaction(mt,"readonly").objectStore(mt).getAll())}function la(t,e){return`${t}:${e}`}function ho(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 vo(t);case"array":return Array.from(t.children).map(Na);case"string":case"date":return t.textContent??"";default:return t.textContent??""}}function vo(t){const e={},r=Array.from(t.children);for(let i=0;i<r.length;i+=2){const p=r[i],v=r[i+1];!p||p.tagName!=="key"||!v||(e[p.textContent??""]=Na(v))}return e}function Ot(t){return typeof t=="string"&&t?t:void 0}function Bn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function wn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $t(t,e,r,i){return new Promise((p,v)=>{const c=indexedDB.open(t,e);c.onupgradeneeded=()=>{const a=c.result;a.objectStoreNames.contains(r)||a.createObjectStore(r,{keyPath:i})},c.onsuccess=()=>p(c.result),c.onerror=()=>v(c.error??new Error("Open IndexedDB failed"))})}function Wt(t){return new Promise((e,r)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>r(t.error??new Error("IndexedDB request failed"))})}function Ti(){return{method:"POST",path:"/account/listTeams.action",payload:{}}}function Ra({bundleID:t,teamID:e=""}){return pr("/account/ios/identifiers/listAppIds.action",e,{sort:"name=asc"})}function Ai({deviceUDID:t,teamID:e=""}){return pr("/account/ios/device/listDevices.action",e,{sort:"name=asc",includeRemovedDevices:!1})}function Ii(t=""){return pr("/account/ios/certificate/listCertRequests.action",t,{sort:"name=asc",types:"83Q87W3TGH,5QPB9NHCEI"})}function Bi({bundleID:t,teamID:e=""}){return pr("/account/ios/profile/listProvisioningProfiles.action",e,{search:t,sort:"name=asc"})}function wi({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 Ni({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 Ri({csrPEM:t,teamID:e=""}){return{method:"POST",path:"/account/ios/certificate/submitCertificateRequest.action",payload:{teamId:e,type:"83Q87W3TGH",csrContent:t}}}function _i(t,e=""){return{method:"GET",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:e,certificateId:t,type:"83Q87W3TGH"}}}function Di({bundleID:t,teamID:e="",appIDID:r,certificateID:i,deviceIDs:p,name:v}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:e,provisioningProfileName:v??`Limrun ${t}`,certificateIds:[i],appIdId:r,deviceIds:p,distributionType:"limited",subPlatform:"ios"}}}function Li(t,e=""){return{method:"GET",path:"/account/ios/profile/downloadProfileContent",payload:{teamId:e,provisioningProfileId:t}}}async function da({bundleID:t,deviceUDID:e,teamID:r}){const i=await Ci({bundleID:t,deviceUDID:e});if(!(!i||!Ui(i,{bundleID:t,deviceUDID:e,teamID:r})))return i}async function Pi(t){return Aa({...t,certificateFileName:t.certificateID?`${t.certificateID}.p12`:"apple-development.p12",profileFileName:t.profile.uuid?`${t.profile.uuid}.mobileprovision`:"apple-development.mobileprovision"})}function Ui(t,{bundleID:e,deviceUDID:r,teamID:i}){return!Ia(t.profile,e)||i&&t.teamID&&t.teamID!==i||r&&!Ht(t.profile,r)||t.profile.expirationDate&&new Date(t.profile.expirationDate).getTime()<=Date.now()?!1:At(t.bundleID)===At(e)}function go(t){const e=t;return e?.teams?.[0]??e?.provider??e?.availableProviders?.[0]}function yo(t){const e=t,r=[...e?.teams??[],...e?.provider?[e.provider]:[],...e?.availableProviders??[]],i=new Set;for(const p of r)for(const v of[p.teamId,p.providerId,p.publicProviderId])v!==void 0&&v!==""&&i.add(String(v));return[...i]}function pr(t,e,r={}){const i={pageNumber:1,pageSize:200,...r};return e&&(i.teamId=e),{method:"POST",path:t,payload:i}}async function ki(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 p=await i.text();throw new Error(`Info request failed: HTTP ${i.status} ${p}`)}return await i.json()}async function Vi({limbuildApiUrl:t,token:e,certificateP12Base64:r,certificatePassword:i,provisioningProfileBase64:p}){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,certificatePassword:i,provisioningProfileBase64:p}})});if(!c.ok){const a=await c.text();throw new Error(`Build request failed: HTTP ${c.status} ${a}`)}return await c.json()}function Oi({limbuildApiUrl:t,execId:e,token:r,onLine:i,onStatus:p,onError:v}){const c=new URL(`${t}/exec/${e}/events`);r&&c.searchParams.set("token",r);const a=new EventSource(c.toString());return p("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 l=parseInt(g.data,10);p(l===0?"succeeded":l<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,Je={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 Fi(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 Ki(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 ar(t){return JSON.parse(new TextDecoder().decode(t))}async function Mi(){if(!navigator.usb)throw new Error("WebUSB is not available in this browser.");return navigator.usb.requestDevice({filters:[{vendorId:1452}]})}function qi(t){const e=[],r=t.configuration?.configurationValue,i=t.configurations.find(p=>p.configurationValue===r);i&&e.push(...Nn(i));for(const p of t.configurations)p.configurationValue!==r&&e.push(...Nn(p));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 Hi(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 Gi(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 zi(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 Qi=0,mo=2,$i=6,Co=4277009102,pa=2,Eo=4,Mt=16,xo=49152;async function Wi(t,e){const{inEndpoint:r,outEndpoint:i}=Gi(e),p=new Uint8Array(12),v=new DataView(p.buffer);v.setUint32(0,2),v.setUint32(4,0),v.setUint32(8,0),await Da(t,i,es(Qi,p));const c=await Ji(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:xo,streams:new Map,writeChain:Promise.resolve(),closed:!1};return a>=2&&await Zi(g,mo,new Uint8Array([7])),So(g),g}async function Yi(t,e){if(t.closed)throw new Error("usbmux session is closed.");let r,i;const p={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,p.sport),p),await sr(p,pa,new Uint8Array),await p.opened,p}async function ji(t,e){if(t.session.closed)throw new Error("usbmux session is closed.");await sr(t,Mt,e),t.seq+=e.byteLength}async function Xi(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 sr(t,e,r){const i=new Uint8Array(20+r.byteLength),p=new DataView(i.buffer);p.setUint16(0,t.sport),p.setUint16(2,t.dport),p.setUint32(4,t.seq),p.setUint32(8,t.ack),p.setUint8(12,80),p.setUint8(13,e),p.setUint16(14,512),i.set(r,20),await Zi(t.session,$i,i)}async function Zi(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?bo(e,r,t.txSeq++,t.rxSeq):es(e,r);await Da(t.device,t.outEndpoint,i)}),t.writeChain}async function So(t){try{for(;;){if(t.closed)return;const e=await Ji(t.device,t.inEndpoint,t.muxVersion);if(t.closed)return;if(e.rxSeq!==void 0&&(t.rxSeq=e.rxSeq),e.protocol!==$i)continue;const r=Ao(e.payload),i=t.streams.get(ha(r.sport,r.dport));if(i){if(r.flags&Eo){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|Mt))===(pa|Mt)){i.seq+=1,i.ack=r.seq+1,await sr(i,Mt,new Uint8Array),i.resolveOpened();continue}r.payload.byteLength!==0&&(i.ack=r.seq+r.payload.byteLength,await sr(i,Mt,new Uint8Array),i.waiters.length>0?i.waiters.shift()(r.payload):i.queue.push(r.payload))}}}catch{t.closed||La(t)}}async function Ji(t,e,r){for(;;){const i=await zi(t,e),p=To(i,r);if(!(r===1&&p.protocol!==Qi))return p}}function es(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 bo(t,e,r,i){const p=new Uint8Array(16+e.byteLength),v=new DataView(p.buffer);return v.setUint32(0,t),v.setUint32(4,p.byteLength),v.setUint32(8,Co),v.setUint16(12,r),v.setUint16(14,i),p.set(e,16),p}function To(t,e){const r=new DataView(t.buffer,t.byteOffset,t.byteLength),i=r.getUint32(0),p=r.getUint32(4),v=e>=2?16:8;return{protocol:i,length:p,rxSeq:e>=2?r.getUint16(14):void 0,payload:t.slice(v,p)}}function Ao(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 ts{constructor(e,r,i,p){this.webSocketUrl=e,this.session=r,this.deviceHello=i,this.log=p}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:Je.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:Je.StartPairing,requestId:0,streamId:0,payload:Nt({})}),this.log("Pairing requested"),e}async startInstall(e){await this.send({type:Je.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(Ki(e))).catch(r=>{this.log("Relay frame handling failed",r instanceof Error?r.message:String(r))})}async handleFrame(e){switch(e.type){case Je.OpenStream:await this.handleOpenStream(e.requestId,e.streamId,ar(e.payload).port);break;case Je.StreamData:{const r=this.streams.get(e.streamId);if(!r)throw new Error(`Unknown stream ${e.streamId}`);await ji(r,e.payload);break}case Je.StreamClose:this.streams.delete(e.streamId);break;case Je.InstallProgress:this.log(Bo(ar(e.payload).message));break;case Je.Error:this.handleError(e.payload);break;case Je.PairRecordReady:this.handlePairRecordReady(ar(e.payload));break;case Je.Ping:await this.send({type:Je.Pong,requestId:e.requestId,streamId:0,payload:new Uint8Array});break}}handleError(e){const r=Io(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 p=await Yi(this.session,i);this.streams.set(r,p),await this.send({type:Je.OpenResult,requestId:e,streamId:r,payload:Nt({ok:!0})}),this.log(`Opened device stream ${r} to port ${i}`),this.pumpDeviceToServer(r,p)}catch(p){this.log(`Open device stream ${r} failed`,p instanceof Error?p.message:String(p)),await this.send({type:Je.OpenResult,requestId:e,streamId:r,payload:Nt({ok:!1,error:p instanceof Error?p.message:String(p)})})}}async pumpDeviceToServer(e,r){try{for(;;){const i=await Xi(r);if(this.closed)return;await this.send({type:Je.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:Je.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(Fi(e))}}}function Io(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 Bo(t){const e="install status: ";if(!t.startsWith(e))return t;const r=t.slice(e.length),p=new DOMParser().parseFromString(r,"application/xml").querySelector("plist > dict");if(!p)return t;const v=wo(p),c=v.Status??"Unknown";return`Install progress: ${v.PercentComplete?`${v.PercentComplete}% `:""}${c}`}function wo(t){const e={},r=Array.from(t.children);for(let i=0;i<r.length;i+=2){const p=r[i],v=r[i+1];!p||p.tagName!=="key"||!v||(e[p.textContent??""]=v.textContent??"")}return e}async function rs({log:t}){t("Selecting USB device");const e=await Mi(),r=Ro(e);return t("Selected USB device",`${e.manufacturerName??""} ${e.productName??""} ${e.serialNumber??""}`.trim()),r}async function as({limbuildApiUrl:t,token:e,log:r,target:i}){const p=Pa(t,e);let v;try{v=await is(p,i,r);const c=await v.startPairing();return{relay:v,pairRecord:c,target:i}}catch(c){throw v?.close(),c}}async function ns({limbuildApiUrl:t,token:e,log:r,target:i,pairRecord:p}){const v=Pa(t,e);let c;try{return c=await is(v,i,r),await c.startInstall(p),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 is(t,e,r){await No(e,r);const i=new ts(t,e.session,e.hello,r);return await i.connect(),i}async function No(t,e){if(!t.session)try{t.candidate=await _o(t,e),t.session=await Wi(t.device,t.candidate),e("Created usbmux session")}catch(r){throw await Rt(t,e),r}}function Ro(t){return{device:t,candidate:Do(t),hello:{serialNumber:t.serialNumber,productName:t.productName,manufacturerName:t.manufacturerName,productId:t.productId,vendorId:t.vendorId}}}async function _o(t,e){const r=ss(t.device);if(r.length===0)throw new Error("No Apple usbmux interface found.");let i;for(const p of r)for(const v of[1,2])try{return t.device.opened||await t.device.open(),e("Claiming usbmux interface",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}, alternate ${p.alternateSetting}, attempt ${v}`),await Hi(t.device,p),t.claimedInterfaceNumber=p.interfaceNumber,e("Claimed usbmux interface",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}`),p}catch(c){i=c,e("USB interface claim failed",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}: ${va(c)}`),await Lo(t),await Po(250)}throw i instanceof Error?i:new Error("Unable to claim any Apple usbmux interface.")}function Do(t){const e=ss(t)[0];if(!e)throw new Error("No Apple usbmux interface found.");return e}function ss(t){const e=qi(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 Lo(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 Po(t){return new Promise(e=>setTimeout(e,t))}const Uo={signing:"idle",connect:"idle",build:"idle",install:"idle"};function ko({apiUrl:t,token:e}){const[r,i]=de.useState("signing"),[p,v]=de.useState(Uo),[c,a]=de.useState(),[g,l]=de.useState(),[x,L]=de.useState(),[b,u]=de.useState(["Ready. Prepare signing assets, build, connect and pair the iPhone, then install."]),[m,E]=de.useState([]),[C,o]=de.useState("idle"),[h,y]=de.useState("idle"),[I,R]=de.useState([]),[d,s]=de.useState([]),[n,B]=de.useState([]),[P,O]=de.useState([]),[U,F]=de.useState(),[q,M]=de.useState(),[H,Q]=de.useState(""),[j,ee]=de.useState(),[oe,ce]=de.useState(!1),[he,pe]=de.useState(),[ve,W]=de.useState(),[X,Re]=de.useState(!1),[ye,S]=de.useState({}),D=de.useRef(void 0),_=de.useRef(void 0),N=de.useRef(void 0),f=de.useRef(void 0),T=de.useCallback((te,re)=>{const ie=re?`${te}
|
|
31
|
+
${re}`:te;u(le=>[ie,...le].slice(0,100))},[]),V=de.useCallback((te,re)=>{v(ie=>({...ie,[te]:re}))},[]),G=de.useCallback(te=>{S(re=>{const ie={...re,...te},le=!!ie.certificateFile&&!!ie.provisioningProfileFile&&!!ie.certificatePassword;return V("signing",le?"complete":"active"),le&&(y("assets-ready"),i("build")),ie}),L(void 0)},[V]);de.useEffect(()=>{let te=!1;return rr().then(re=>{te||!re||(L(re),Q(re.bundleID),y("using-cached-profile"),V("signing","complete"),i("build"),T("Using stored signing assets",re.bundleID))}),()=>{te=!0}},[T,V]);const Z=de.useCallback(()=>cr(I.find(te=>or(te)===q)),[I,q]);de.useEffect(()=>{const te=Z();if(!te){ee(void 0);return}let re=!1;return Vo(te).then(ie=>{re||ee(ie)}),()=>{re=!0}},[Z]);const z=!!(c?.hello.serialNumber?d.find(te=>Gt(te.deviceNumber)===Gt(c.hello.serialNumber)):void 0)?.deviceId,J=!!ye.certificateFile&&!!ye.provisioningProfileFile&&!!ye.certificatePassword,fe=!!x||J,me=c?.hello.serialNumber&&x?Ht(x.profile,c.hello.serialNumber):void 0;de.useEffect(()=>{_.current=c},[c]);const ue=de.useCallback(async()=>{D.current?.close(),D.current=void 0,await Rt(_.current,T)},[T]);de.useEffect(()=>()=>{N.current?.(),f.current?.close(),f.current=void 0,ue()},[ue]);const Te=de.useCallback(async()=>{const te=H.trim();if((!te||x&&Ia(x.profile,te))&&x)return T("Using prepared signing assets",x.bundleID),x;const re=te?void 0:t?await os(t,e).catch(()=>{}):void 0,ie=te||re?.lastBuildConfig?.bundleId;if(ie){const gt=await da({bundleID:ie,deviceUDID:c?.hello.serialNumber,teamID:Z()});if(gt)return y("using-cached-profile"),T("Using cached Apple signing profile",gt.bundleID),L(gt),gt}const le=await rr();if(le)return T("Using stored signing assets",le.bundleID),L(le),le;if(!ye.certificateFile||!ye.provisioningProfileFile||!ye.certificatePassword)throw new Error("Upload a certificate, provisioning profile, and certificate password.");T("Preparing signing assets");const[xe,tt,st]=await Promise.all([Dn(ye.certificateFile),Dn(ye.provisioningProfileFile),Si(ye.provisioningProfileFile)]);if(c?.hello.serialNumber&&!Ht(st,c.hello.serialNumber))throw new Error("Provisioning profile does not include the selected iPhone.");const vt=st.bundleID??st.applicationIdentifier??ye.provisioningProfileFile.name,xt=await Aa({deviceUDID:c?.hello.serialNumber,bundleID:vt,certificateP12Base64:xe,certificateFileName:ye.certificateFile.name,certificatePassword:ye.certificatePassword,provisioningProfileBase64:tt,profileFileName:ye.provisioningProfileFile.name,profile:st});return L(xt),T("Signing assets stored locally",vt),xt},[t,H,T,Z,c?.hello.serialNumber,x,ye,e]),Ne=de.useCallback(async({accountName:te,password:re})=>{if(t){pe("signing"),W(void 0),i("signing"),V("signing","active"),y("authenticating");try{await f.current?.close().catch(()=>{});const ie=await Zn({limbuildApiUrl:t,token:e,accountName:te,password:re});if(f.current=ie,!ie.requiresTwoFactor){const le=await ie.finalize().catch(()=>{}),xe=await _n(t,ie.appleSessionId,e,R,M,le?.body);await aa(t,ie.appleSessionId,e,xe,B,Q),xe&&await Ft({apiUrl:t,token:e,appleSessionId:ie.appleSessionId,teamID:xe,setAppleDevices:s,setSelectedAppleDeviceIDs:O,log:T}),await na(t,ie.appleSessionId,e,xe,F,T)}y(ie.requiresTwoFactor?"two-factor-required":"authenticated"),T(ie.requiresTwoFactor?"Apple ID requires two-factor authentication":"Apple ID authenticated",te)}catch(ie){const le=dt(ie);W(le),y("error"),T("Apple ID authentication failed",le)}finally{pe(void 0)}}},[t,T,V,e]),Be=de.useCallback(async te=>{const re=f.current;if(!re)throw new Error("Start Apple ID login before submitting a two-factor code.");pe("signing"),W(void 0),i("signing"),V("signing","active");try{if(await re.finishTwoFactor(te),t){const ie=await re.finalize().catch(()=>{}),le=await _n(t,re.appleSessionId,e,R,M,ie?.body);await aa(t,re.appleSessionId,e,le,B,Q),le&&await Ft({apiUrl:t,token:e,appleSessionId:re.appleSessionId,teamID:le,setAppleDevices:s,setSelectedAppleDeviceIDs:O,log:T}),await na(t,re.appleSessionId,e,le,F,T)}y("authenticated"),T("Apple ID two-factor authentication accepted")}catch(ie){const le=dt(ie);W(le),y("error"),T("Apple ID two-factor authentication failed",le)}finally{pe(void 0)}},[t,T,V,e]),Ie=de.useCallback(()=>{f.current?.close(),f.current=void 0,R([]),s([]),B([]),O([]),F(void 0),M(void 0),ee(void 0),y("idle"),V("signing","idle"),T("Apple ID login state cleared")},[T,V]),Ae=de.useCallback(te=>{M(te),B([]),s([]),O([]),F(void 0),Q(""),L(void 0);const re=f.current;if(!t||!re||!te)return;const ie=cr(I.find(le=>or(le)===te));ie&&(async()=>{try{await aa(t,re.appleSessionId,e,ie,B,Q),await na(t,re.appleSessionId,e,ie,F,T),await Ft({apiUrl:t,token:e,appleSessionId:re.appleSessionId,teamID:ie,connectedUDID:_.current?.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:O,log:T})}catch(le){const xe=dt(le);W(xe),T("Apple team refresh failed",xe)}})()},[t,I,T,e]),be=de.useCallback(async()=>{const te=Z();if(!(!t||!f.current||!c?.hello.serialNumber||!te)){pe("signing"),W(void 0);try{const re=Gt(c.hello.serialNumber),ie=await it(t,f.current.appleSessionId,wi({deviceUDID:re,teamID:te,name:c.hello.productName??"Limrun iPhone"}),e);pt(ie.body,"Apple device registration"),await Ft({apiUrl:t,token:e,appleSessionId:f.current.appleSessionId,teamID:te,connectedUDID:c.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:O,log:T}),T("Connected iPhone registered with Apple Developer",re)}catch(re){const ie=dt(re);W(ie),T("Apple device registration failed",ie)}finally{pe(void 0)}}},[t,T,Z,c?.hello.productName,c?.hello.serialNumber,e]),Ee=de.useCallback(async()=>{if(!t||!f.current)return;const te=H.trim();if(!te)throw new Error("Enter a bundle ID before preparing signing assets.");if(!q)throw new Error("Select an Apple Developer team before preparing signing assets.");const re=Z();if(!re)throw new Error("Selected Apple team does not include a Developer Portal team ID.");if(P.length===0)throw new Error("Select at least one Apple Developer device before preparing signing assets.");if(!j&&!ye.certificatePassword)throw new Error("Enter a .p12 password before preparing signing assets.");const ie=d.find(xe=>!!xe.deviceNumber&&P.includes(xe.deviceId??"")),le=c?.hello.serialNumber??ie?.deviceNumber;pe("signing"),W(void 0),i("signing"),V("signing","active"),y("preparing-assets");try{const xe=await da({bundleID:te,deviceUDID:le,teamID:re});if(xe){L(xe),y("assets-ready"),V("signing","complete"),i("build"),T("Using cached Apple signing assets",te);return}const tt=await Fo({apiUrl:t,token:e,appleSessionId:f.current.appleSessionId,teamID:re,bundleID:te,deviceUDID:le,deviceIDs:P,certificatePassword:ye.certificatePassword,reusableCertificate:j});L(tt),y("assets-ready"),V("signing","complete"),i("build"),T("Apple signing assets stored locally",le?`${te} for ${le}`:`${te} for selected Apple devices`)}catch(xe){const tt=dt(xe);W(tt),y("error"),T("Apple signing asset preparation failed",tt)}finally{pe(void 0)}},[t,H,d,I,T,q,P,Z,c?.hello.serialNumber,V,j,ye.certificatePassword,e]),_e=de.useCallback(async()=>{if(t){pe("build"),W(void 0),i("build"),V("build","active"),ce(!0),E([]),o("queued"),N.current?.();try{const te=await Te();T("Starting signed device build");const re=await Vi({limbuildApiUrl:t,token:e,certificateP12Base64:te.certificateP12Base64,certificatePassword:te.certificatePassword,provisioningProfileBase64:te.provisioningProfileBase64});if(!re.execId)throw new Error("Build request did not return an exec ID.");T("Signed device build started",re.execId),N.current=Oi({limbuildApiUrl:t,execId:re.execId,token:e,onLine:ie=>E(le=>[...le,ie]),onStatus:ie=>{o(ie),ie==="succeeded"?(V("build","complete"),V("connect","active"),i("connect")):(ie==="failed"||ie==="cancelled")&&V("build","error")},onError:ie=>{const le=dt(ie);W(le),T("Build log stream failed",le)}})}catch(te){const re=dt(te);W(re),o("failed"),V("build","error"),T("Signed device build failed",re)}finally{pe(void 0)}}},[t,T,Te,V,e]),De=de.useCallback(async()=>{pe("usb"),W(void 0),i("connect"),V("connect","active");let te;try{await ue(),te=await rs({log:T}),Re(!1);const re=await yi(te.hello.serialNumber),ie=x??(J?void 0:await rr());if(ie){if(!Ht(ie.profile,te.hello.serialNumber))throw new Error("Stored provisioning profile does not include the selected iPhone.");L(ie)}if(t&&f.current){const le=Z();le&&await Ft({apiUrl:t,token:e,appleSessionId:f.current.appleSessionId,teamID:le,connectedUDID:te.hello.serialNumber,setAppleDevices:s,setSelectedAppleDeviceIDs:O,log:T})}a(te),l(re),V("connect",re?"complete":"active"),i(re?"install":"connect"),T(re?"Pair record found":"No pair record found",te.hello.serialNumber)}catch(re){await Rt(te,T),a(void 0),l(void 0);const ie=dt(re);W(ie),V("connect","error"),T("USB access failed",ie)}finally{pe(void 0)}},[t,ue,T,J,Z,V,x,e]),Pe=de.useCallback(async()=>{if(!(!t||!c)){pe("pair"),W(void 0),Re(!1),i("connect"),V("connect","active");try{await ue();const te=await as({limbuildApiUrl:t,token:e,log:T,target:c}),re=await mi(te.pairRecord,{productName:c.hello.productName});te.relay.close(),await Rt(c,T),l(re),Re(!1),V("connect","complete"),i("install"),T("Device paired","The pair record was stored locally in this browser.")}catch(te){await Rt(c,T);const re=dt(te);Re(!0),W("Unlock the iPhone, tap Trust, then confirm the pair record."),V("connect","error"),T("Device pairing failed",re)}finally{pe(void 0)}}},[t,ue,T,c,V,e]),Ue=de.useCallback(async()=>{if(!(!t||!c||!g)){pe("install"),W(void 0),i("install"),V("install","active");try{await ue(),D.current=await ns({limbuildApiUrl:t,token:e,log:T,target:c,pairRecord:g}),V("install","complete"),T("Device install started","Installation will continue through the connected iPhone.")}catch(te){await Rt(c,T);const re=dt(te);W(re),V("install","error"),T("Device install relay failed",re)}finally{pe(void 0)}}},[t,ue,T,g,c,V,e]),Ze=de.useCallback(()=>{ue(),T("Device relay stopped")},[ue,T]);return{currentStep:r,stepStatuses:p,device:c?.hello,hasPairRecord:!!g,hasSigningAssets:!!x,hasSigningInputs:fe,pairConfirmationRequired:X,logs:b,buildLogs:m,buildStatus:C,appleSigningStatus:h,appleTeams:I,appleDevices:d,appleAppIDs:n,applePortalSummary:U,selectedAppleTeamID:q,selectedAppleDeviceIDs:P,connectedAppleDeviceRegistered:z,connectedDeviceInProfile:me,hasReusableAppleCertificate:!!j,appleBundleID:H,buildLogPanelOpen:oe,busyAction:he,error:ve,canBuild:!!t&&!he&&fe,canPrepareAppleSigningAssets:!!t&&!he&&!!f.current&&!!H.trim()&&!!Z()&&P.length>0&&(!!j||!!ye.certificatePassword),canRequestUSBAccess:!he&&C==="succeeded",canPairBrowser:!!t&&!he&&C==="succeeded"&&!!c,canInstall:!!t&&!he&&C==="succeeded"&&!!c&&!!g,setSigningFiles:G,setAppleBundleID:Q,setSelectedAppleDeviceIDs:O,setBuildLogPanelOpen:ce,startAppleIDLogin:Ne,submitAppleTwoFactorCode:Be,setSelectedAppleTeamID:Ae,clearAppleIDLogin:Ie,registerConnectedAppleDevice:be,prepareAppleSigningAssets:Ee,startDeviceBuild:_e,requestUSBAccess:De,pairBrowser:Pe,startInstallation:Ue,stopRelay:Ze}}async function os(t,e){return ki(t,e)}async function Vo(t){const e=await Ei(t);if(!(!e?.certificateID||!e.certificateP12Base64||!e.certificatePassword))return{certificateID:e.certificateID,certificateP12Base64:e.certificateP12Base64,certificatePassword:e.certificatePassword,teamID:e.teamID}}async function _n(t,e,r,i,p,v){const c=await it(t,e,Ti(),r);pt(c.body,"Apple Developer team list");const a=Oo([...c.body?.teams??[]]);i(a);const g=a.find(x=>cr(x)),l=or(g??a[0]);if(l&&p(l),a.length===0)throw new Error("Apple Developer account did not return any teams or providers.");return a.map(cr).find(x=>!!x)}function Oo(t){const e=new Set,r=[];for(const i of t){const v=or(i)??i.name??JSON.stringify(i);e.has(v)||(e.add(v),r.push(i))}return r}async function aa(t,e,r,i,p,v){if(!i)return;const c=await it(t,e,Ra({bundleID:"",teamID:i}),r);pt(c.body,"Apple bundle ID list");const a=c.body?.appIds??[];p(a);const g=Mo(a[0]);if(g){v(g);return}const l=await os(t,r).catch(()=>{});l?.lastBuildConfig?.bundleId&&v(l.lastBuildConfig.bundleId)}async function na(t,e,r,i,p,v){const[c,a]=await Promise.all([it(t,e,Ii(i??""),r),it(t,e,Bi({bundleID:"",teamID:i??""}),r)]);pt(c.body,"Apple Developer certificate list"),pt(a.body,"Apple Developer profile list");const g={certificateCount:c.body?.certRequests?.length??0,profileCount:a.body?.provisioningProfiles?.length??0};p(g),v("Apple Developer resources fetched",`${g.certificateCount} certificates, ${g.profileCount} provisioning profiles`)}async function Ft({apiUrl:t,token:e,appleSessionId:r,teamID:i,connectedUDID:p,setAppleDevices:v,setSelectedAppleDeviceIDs:c,log:a}){const g=await it(t,r,Ai({deviceUDID:p??"",teamID:i}),e);pt(g.body,"Apple device list");const l=g.body?.devices??[];v(l);const x=l.find(b=>!!b.deviceId)?.deviceId;if(!p){c(x?[x]:[]),a("Apple Developer devices fetched",`${l.length} devices`);return}const L=l.find(b=>Gt(b.deviceNumber)===Gt(p));L?.deviceId?(c([L.deviceId]),a("Connected iPhone found in Apple Developer devices",L.name??L.deviceNumber)):(c(x?[x]:[]),a("Connected iPhone is not registered with Apple Developer",p))}async function Fo({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:p,deviceUDID:v,certificatePassword:c,deviceIDs:a,reusableCertificate:g}){const l=v?.replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")??"",x=await Ko({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:p});let L=g?.certificateID,b=g?.certificateP12Base64,u=g?.certificatePassword;if(!L||!b||!u){if(!c)throw new Error("Enter a .p12 password before preparing signing assets.");const I=await di({commonName:`Limrun ${p}`}),R=await it(t,r,Ri({csrPEM:I.csrPEM,teamID:i}),e);if(pt(R.body,"Apple Development certificate creation"),L=rt(R.body?.certRequest,"certificateId")??rt(R.body?.certRequest,"certRequestId")??rt(R.body,"certificateId")??rt(R.body,"certRequestId"),!L)throw new Error("Apple certificate creation did not return a certificate ID.");const d=await it(t,r,_i(L,i),e);if(d.status<200||d.status>=300||!d.rawBodyBase64)throw new Error(`Apple certificate download failed: HTTP ${d.status}`);b=pi({privateKeyPKCS8Base64:I.privateKeyPKCS8Base64,certificateBase64:d.rawBodyBase64,password:c,friendlyName:`Apple Development ${p}`}),u=c}const m=`Limrun ${p}`,E=await it(t,r,Di({bundleID:p,teamID:i,appIDID:x,certificateID:L,deviceIDs:a,name:m}),e);pt(E.body,"Apple provisioning profile creation");const C=rt(E.body?.provisioningProfile,"provisioningProfileId")??rt(E.body,"provisioningProfileId");if(!C)throw new Error("Apple provisioning profile creation did not return a profile ID.");const o=await it(t,r,Li(C,i),e);if(o.status<200||o.status>=300||!o.rawBodyBase64)throw new Error(`Apple provisioning profile download failed: HTTP ${o.status}`);const h=o.rawBodyBase64,y=bi(h);return Pi({bundleID:p,deviceUDID:l||void 0,teamID:i,certificateID:L,certificateP12Base64:b,certificatePassword:u,provisioningProfileBase64:h,profile:y})}async function Ko({apiUrl:t,token:e,appleSessionId:r,teamID:i,bundleID:p}){const v=await it(t,r,Ra({bundleID:p,teamID:i}),e);pt(v.body,"Apple bundle ID lookup");const c=v.body?.appIds?.find(x=>rt(x,"identifier")===p||rt(x,"bundleId")===p),a=rt(c,"appIdId")??rt(c,"appId");if(a)return a;const g=await it(t,r,Ni({bundleID:p,teamID:i,name:p}),e);pt(g.body,"Apple bundle ID creation");const l=rt(g.body?.appId,"appIdId")??rt(g.body?.appId,"appId")??rt(g.body,"appIdId")??rt(g.body,"appId");if(!l)throw new Error("Apple bundle ID creation did not return an App ID.");return l}function pt(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 rt(t,e){const r=t?.[e];if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r)}function Gt(t){return(t??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"").toUpperCase()}function or(t){const e=t?.teamId??t?.providerId??t?.publicProviderId;return e===void 0||e===""?void 0:String(e)}function cr(t){return t?.teamId&&t.teamId!==""?t.teamId:void 0}function Mo(t){return t?.identifier||t?.bundleId||void 0}async function Dn(t){const e=await t.arrayBuffer();let r="";const i=new Uint8Array(e);for(const p of i)r+=String.fromCharCode(p);return btoa(r)}function dt(t){return t instanceof Error?t.message:String(t)}exports.AppleGsaSrpClient=Kn;exports.RELAY_HEADER_BYTES=_t;exports.RELAY_PROTOCOL_VERSION=_a;exports.RelayClient=ts;exports.RelayMessageType=Je;exports.claimUsbmux=Hi;exports.closeDeviceRelayTarget=Rt;exports.closeUsbmuxSession=La;exports.createAppleRelaySession=Mn;exports.createBundleIDRequest=Ni;exports.createDevelopmentProfileRequest=Di;exports.createUsbmuxSession=Wi;exports.decodeFrame=Ki;exports.decodeJson=ar;exports.deleteAppleRelaySession=fa;exports.deviceRelayWebSocketUrl=Pa;exports.downloadCertificateRequest=_i;exports.downloadProfileRequest=Li;exports.encodeFrame=Fi;exports.encodeJson=Nt;exports.exportAppleCertificateP12=pi;exports.fetchAppleAccountSession=Wn;exports.fetchLimbuildInfo=ki;exports.findBundleIDRequest=Ra;exports.findDevelopmentCertificatesRequest=Ii;exports.findDevelopmentProfilesRequest=Bi;exports.findDeviceRequest=Ai;exports.findSigningAssetsForBundle=xi;exports.findUsbmuxCandidates=qi;exports.generateAppleSigningKeyAndCSR=di;exports.getBulkEndpoints=Gi;exports.getLatestSigningAssets=rr;exports.getLatestSigningAssetsWithCertificate=Ei;exports.getPairRecord=yi;exports.getReusableAppleSigningAssets=da;exports.getSigningAssets=Ci;exports.listTeamsRequest=Ti;exports.normalizeBundleID=At;exports.normalizeUDID=Tt;exports.openStream=Yi;exports.parseProvisioningProfile=Si;exports.parseProvisioningProfileBase64=bi;exports.parseProvisioningProfileBytes=Ba;exports.profileContainsDevice=Ht;exports.profileMatchesBundleID=Ia;exports.proxyPhoneTwoFactorCode=$n;exports.proxyProvisioningRequest=it;exports.proxySrpComplete=Hn;exports.proxySrpInit=qn;exports.proxyTwoFactorCode=Qn;exports.putAppleGeneratedSigningAssets=Pi;exports.putPairRecord=mi;exports.putSigningAssets=Aa;exports.receiveStreamData=Xi;exports.registerDeviceRequest=wi;exports.requestAppleDevice=Mi;exports.requestUSBAccess=rs;exports.selectDeveloperPortalTeam=go;exports.sendStreamData=ji;exports.startBrowserOwnedAppleIDLogin=Zn;exports.startInstallRelay=ns;exports.startPairingRelay=as;exports.startSignedDeviceBuild=Vi;exports.storedSigningAssetsReusable=Ui;exports.submitDevelopmentCSRRequest=Ri;exports.teamIDCandidates=yo;exports.transferIn=zi;exports.transferOutWithZlp=Da;exports.triggerPhoneTwoFactor=zn;exports.triggerTrustedDeviceTwoFactor=Gn;exports.useDeviceInstall=ko;exports.watchBuildLogEvents=Oi;
|