oioxo-mcp 0.5.66 → 0.5.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bundle/cli.js +28 -19
  2. package/package.json +1 -1
package/bundle/cli.js CHANGED
@@ -631,7 +631,15 @@ Fix them.`},files:p};let y=r.lint?await r.lint(p).catch(()=>[]):[],v=y.length?`
631
631
  `).trim();if(w){let S=p.content.replace(/\r\n/g,`
632
632
  `),C=0,k=0,T;for(;(T=S.indexOf(w,k))>=0;)C++,k=T+w.length;if(C>1)return{result:{ok:!1,output:`Edit REJECTED \u2014 the SEARCH text matches ${C} places in ${c}. Add more surrounding lines so it matches exactly ONE.`},files:a}}}let x=_we(d,a,c);if(!x.edits.length)return{result:{ok:!1,output:`Edit did not apply \u2014 the SEARCH text wasn't found in ${c}. readFile it and copy the exact lines.`},files:a};let y=XP(a,x.edits),v=await r.typecheck(y);return v.length?{result:{ok:!1,output:`Edit REJECTED \u2014 it breaks the type-check:
633
633
  ${v.slice(0,5).join(`
634
- `)}`},files:a}:(y=await Swe(y,c,r),{result:{ok:!0,output:`Applied edit to ${c}. Type-check clean.`},files:y})}case"deleteFile":{let c=String(s.path??"").trim();if(!c)return{result:{ok:!1,output:'deleteFile needs a "path".'},files:a};if(!a.some(x=>x.path===c))return{result:{ok:!1,output:`No file "${c}" in the project.`},files:a};let d=a.filter(x=>x.path!==c);if(r.removePath)try{await r.removePath(c)}catch{}let h=await r.typecheck(d).catch(()=>[]),p=h.length?` (heads up \u2014 this now breaks: ${h.slice(0,3).join("; ")})`:"";return{result:{ok:!0,output:`Deleted ${c}.${p}`},files:d}}case"renameFile":case"moveFile":{let c=String(s.from??s.path??"").trim(),d=String(s.to??s.newPath??s.dest??"").trim();if(!c||!d)return{result:{ok:!1,output:`${i} needs "from" and "to" paths.`},files:a};if(!a.find(v=>v.path===c))return{result:{ok:!1,output:`No file "${c}" in the project.`},files:a};if(a.some(v=>v.path===d))return{result:{ok:!1,output:`"${d}" already exists \u2014 pick a new path or delete it first.`},files:a};let p=a.map(v=>v.path===c?{path:d,content:v.content}:v);if(r.removePath)try{await r.removePath(c)}catch{}let x=await r.typecheck(p).catch(()=>[]),y=x.length?` (imports may need updating: ${x.slice(0,3).join("; ")})`:"";return{result:{ok:!0,output:`Moved ${c} \u2192 ${d}.${y} Remember to update any imports that referenced the old path.`},files:p}}case"typecheck":{let c=await r.typecheck(a);return{result:{ok:c.length===0,output:c.length?c.join(`
634
+ `)}`},files:a}:(y=await Swe(y,c,r),{result:{ok:!0,output:`Applied edit to ${c}. Type-check clean.`},files:y})}case"deleteFile":{let c=String(s.path??"").trim();if(!c)return{result:{ok:!1,output:'deleteFile needs a "path".'},files:a};if(!a.some(x=>x.path===c))return{result:{ok:!1,output:`No file "${c}" in the project.`},files:a};let d=a.filter(x=>x.path!==c);if(r.removePath)try{await r.removePath(c)}catch{}let h=await r.typecheck(d).catch(()=>[]),p=h.length?` (heads up \u2014 this now breaks: ${h.slice(0,3).join("; ")})`:"";return{result:{ok:!0,output:`Deleted ${c}.${p}`},files:d}}case"renameFile":case"moveFile":{let c=String(s.from??s.path??"").trim(),d=String(s.to??s.newPath??s.dest??"").trim();if(!c||!d)return{result:{ok:!1,output:`${i} needs "from" and "to" paths.`},files:a};if(!a.find(v=>v.path===c))return{result:{ok:!1,output:`No file "${c}" in the project.`},files:a};if(a.some(v=>v.path===d))return{result:{ok:!1,output:`"${d}" already exists \u2014 pick a new path or delete it first.`},files:a};let p=a.map(v=>v.path===c?{path:d,content:v.content}:v);if(r.removePath)try{await r.removePath(c)}catch{}let x=await r.typecheck(p).catch(()=>[]),y=x.length?` (imports may need updating: ${x.slice(0,3).join("; ")})`:"";return{result:{ok:!0,output:`Moved ${c} \u2192 ${d}.${y} Remember to update any imports that referenced the old path.`},files:p}}case"debug":{if(!r.debug)return{result:{ok:!1,output:"The debugger isn't available on this surface. Add print/log statements and use runTests/shell to inspect, or run the app with the browser tool."},files:a};let c=String(s.path??"").trim();if(!c)return{result:{ok:!1,output:'debug needs a "path" and "breakpoints".'},files:a};let d=s.breakpoints??s.lines??s.breakpoint??s.line,h=(Array.isArray(d)?d:[d]).map(x=>Number(x)).filter(x=>Number.isFinite(x)&&x>=1);if(!h.length)return{result:{ok:!1,output:'debug needs at least one breakpoint line number, e.g. {"path":"lib/calc.py","breakpoints":[42]}.'},files:a};let p=Array.isArray(s.watch)?s.watch.map(String).slice(0,8):void 0;if(!a.some(x=>x.path===c))return{result:{ok:!1,output:`No file "${c}" in the project.`},files:a};try{let x=await r.debug({path:c,breakpoints:h,watch:p,files:a});if(x.error&&!x.hits.length)return{result:{ok:!1,output:`Debug run failed: ${x.error}${x.output?`
635
+ `+x.output.slice(0,1e3):""}`},files:a};let y=x.hits.slice(0,12).map(w=>{let S=Object.entries(w.vars||{}).slice(0,20).map(([T,E])=>`${T} = ${JSON.stringify(E)?.slice(0,120)}`).join(", "),C=w.watch&&Object.keys(w.watch).length?`
636
+ watch: ${Object.entries(w.watch).map(([T,E])=>`${T}=${JSON.stringify(E)?.slice(0,80)}`).join(", ")}`:"",k=w.stack&&w.stack.length?`
637
+ stack: ${w.stack.slice(0,6).map(T=>`${T.name}:${T.line}`).join(" \u2190 ")}`:"";return` line ${w.line}${w.func?` (${w.func})`:""}: ${S}${C}${k}`}).join(`
638
+ `);return{result:{ok:!0,output:`Debugged ${c} \u2014 ${x.hits.length} breakpoint hit(s), real runtime values:
639
+ ${y||" (breakpoints not reached \u2014 check they're on executable lines / the code path runs)"}${x.output?`
640
+ --- program output ---
641
+ ${x.output.slice(0,1500)}`:""}${x.error?`
642
+ (note: ${x.error})`:""}`},files:a}}catch(x){return{result:{ok:!1,output:`debug failed: ${x instanceof Error?x.message:String(x)}`},files:a}}}case"typecheck":{let c=await r.typecheck(a);return{result:{ok:c.length===0,output:c.length?c.join(`
635
643
  `):"No type errors."},files:a}}case"runTests":{if(!r.run)return{result:{ok:!1,output:"runTests is not available here."},files:a};let c=await r.run(a);return{result:{ok:c.ok,output:(c.ok?`PASS
636
644
  `:`FAIL
637
645
  `)+(c.errors||c.output).slice(0,4e3)},files:a}}case"webSearch":{if(!r.webSearch)return{result:{ok:!1,output:"webSearch is not available here."},files:a};try{let c=await r.webSearch(String(s.query??""));return{result:{ok:!0,output:c.length?c.map((d,h)=>`${h+1}. ${d.title}
@@ -698,6 +706,7 @@ Tools:
698
706
  - rename {"from":"oldName","to":"newName"} \u2192 rename a symbol everywhere it appears across all files, then type-check (the multi-file refactor; rejected if it breaks the build)
699
707
  - git {"command":"diff"} \u2192 read-only git on CLI/desktop: status / diff / log / show / blame \u2014 reason over history + your own changes (to commit, use openPr)
700
708
  - typecheck {} \u2192 check for errors
709
+ - debug {"path":"...","breakpoints":[42],"watch":["total"]} \u2192 REAL debugging: set breakpoint line(s), run, and read the ACTUAL variable values + call stack at each hit (Python/JS). Diagnose a bug from real runtime state instead of guessing \u2014 better than adding print statements.
701
710
  - runTests {} \u2192 run the project/tests (if available)
702
711
  - shell {"command":"..."} \u2192 run a real command in the project (CLI/desktop only \u2014 e.g. pip install, npm test, python main.py, ruff check, git status). On the web this is sandboxed; use runTests/typecheck instead. Use it to install deps, run the app, and verify like a developer.
703
712
  - spawn {"task":"..."} \u2192 delegate a SELF-CONTAINED sub-task to a fresh sub-agent that works in its own context and reports back a short result (the files it writes merge into the project). Use it for a big INDEPENDENT chunk so your own context stays focused \u2014 e.g. spawn {"task":"Build and unit-test the lexer: write calclang/lexer.py and tests/test_lexer.py, run them, return a one-line status."}. Give it ONE clear, bounded job with a definite deliverable. Don't spawn for tiny edits (just do them); don't spawn vague tasks.
@@ -991,26 +1000,26 @@ Session saved (.oioxo/sessions/${C}.json) \u2014 resume with \`oioxo sessions\`.
991
1000
  `);e+=`
992
1001
  `}let n=this.body.toString("base64"),i=0;for(;i<n.length;)e+=n.slice(i,i+F3e)+`
993
1002
  `,i+=F3e;return e+=jQ+this.type+kk+`
994
- `,e}toBuffer(){return Buffer.from(this.toString(),"utf8")}valueOf(){return this.body}toJSON(){return{type:this.type,body:this.body,headers:this.headers}}[I3e.inspect.custom](e,r){return`<${this.constructor.name} ${I3e.inspect(this.toJSON(),r)}>`}};qQ.PEM=bO;function i_t(t){let e=t.shift();if(e==null||!e.startsWith($Q)||!e.endsWith(kk))throw new Error("pem: invalid BEGIN line");let r=e.slice($Q.length,e.length-kk.length);if(r==="")throw new Error("pem: invalid type");let n=[];for(e=t.shift();e!=null&&e.includes(": ");){let a=e.split(": ");if(a.length!==2||a[0]===""||a[1]==="")throw new Error("pem: invalid Header line");n.push(a),e=t.shift()}let i="";for(;e!=null&&!e.startsWith(jQ);)i+=e,e=t.shift();if(e==null||e!==`${jQ}${r}${kk}`)throw new Error("pem: invalid END line");let s=new bO(r,Buffer.from(i,"base64"));if(i===""||s.body.toString("base64")!==i)throw new Error("pem: invalid base64 body");for(let a of n)s.setHeader(a[0],a[1]);return s}});var B3e=L(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});var R3e=Kr("util"),_O=MQ(),ca;(function(t){t[t.UNIVERSAL=0]="UNIVERSAL",t[t.APPLICATION=64]="APPLICATION",t[t.CONTEXT_SPECIFIC=128]="CONTEXT_SPECIFIC",t[t.PRIVATE=192]="PRIVATE"})(ca=zm.Class||(zm.Class={}));var jn;(function(t){t[t.NONE=0]="NONE",t[t.BOOLEAN=1]="BOOLEAN",t[t.INTEGER=2]="INTEGER",t[t.BITSTRING=3]="BITSTRING",t[t.OCTETSTRING=4]="OCTETSTRING",t[t.NULL=5]="NULL",t[t.OID=6]="OID",t[t.ENUMERATED=10]="ENUMERATED",t[t.UTF8=12]="UTF8",t[t.SEQUENCE=16]="SEQUENCE",t[t.SET=17]="SET",t[t.NUMERICSTRING=18]="NUMERICSTRING",t[t.PRINTABLESTRING=19]="PRINTABLESTRING",t[t.T61STRING=20]="T61STRING",t[t.IA5STRING=22]="IA5STRING",t[t.UTCTIME=23]="UTCTIME",t[t.GENERALIZEDTIME=24]="GENERALIZEDTIME",t[t.GENERALSTRING=27]="GENERALSTRING"})(jn=zm.Tag||(zm.Tag={}));var Dk=class{constructor(e,r){this.buf=e,this.bitLen=r}at(e){if(e<0||e>=this.bitLen||!Number.isInteger(e))return 0;let r=Math.floor(e/8),n=7-e%8;return this.buf[r]>>n&1}rightAlign(){let e=8-this.bitLen%8;if(e===8||this.buf.length===0)return this.buf;let r=Buffer.alloc(this.buf.length);r[0]=this.buf[0]>>e;for(let n=1;n<this.buf.length;n++)r[n]=this.buf[n-1]<<8-e,r[n]|=this.buf[n]>>e;return r}};zm.BitString=Dk;var zQ=class t{static Bool(e){let r=new t(ca.UNIVERSAL,jn.BOOLEAN,Buffer.from([e?255:0]));return r._value=e,r}static parseBool(e){if(!(e instanceof Buffer)||e.length!==1)throw new Error("ASN1 syntax error: invalid boolean");switch(e[0]){case 0:return!1;case 255:return!0;default:throw new Error("ASN1 syntax error: invalid boolean")}}static Integer(e){if(e instanceof Buffer){let i=new t(ca.UNIVERSAL,jn.INTEGER,e);return i._value=e.toString("hex"),i}if(!Number.isSafeInteger(e))throw new Error("ASN1 syntax error: invalid integer");let r;if(e>=-128&&e<128)r=Buffer.alloc(1),r.writeInt8(e,0);else if(e>=-32768&&e<32768)r=Buffer.alloc(2),r.writeIntBE(e,0,2);else if(e>=-8388608&&e<8388608)r=Buffer.alloc(3),r.writeIntBE(e,0,3);else if(e>=-2147483648&&e<2147483648)r=Buffer.alloc(4),r.writeIntBE(e,0,4);else if(e>=-549755813888&&e<549755813888)r=Buffer.alloc(5),r.writeIntBE(e,0,5);else if(e>=-0x800000000000&&e<0x800000000000)r=Buffer.alloc(6),r.writeIntBE(e,0,6);else throw new Error("ASN1 syntax error: invalid Integer");let n=new t(ca.UNIVERSAL,jn.INTEGER,r);return n._value=e,n}static parseInteger(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Integer");return e.length>6?e.toString("hex"):e.readIntBE(0,e.length)}static parseIntegerNum(e){let r=t.parseInteger(e);if(typeof r!="number")throw new Error("ASN1 syntax error: invalid Integer number");return r}static parseIntegerStr(e){let r=t.parseInteger(e);return typeof r=="number"?r.toString(16):r}static BitString(e){e instanceof Buffer&&(e=new Dk(e,e.length*8));let r=e.buf.length*8-e.bitLen,n=Buffer.alloc(e.buf.length+1);return n.writeInt8(r,0),e.buf.copy(n,1),new t(ca.UNIVERSAL,jn.BITSTRING,n)}static parseBitString(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid BitString");let r=e[0];if(r>7||e.length===1&&r>0||(e[e.length-1]&(1<<e[0])-1)!==0)throw new Error("ASN1 syntax error: invalid padding bits in BIT STRING");return new Dk(e.slice(1),(e.length-1)*8-r)}static Null(){let e=new t(ca.UNIVERSAL,jn.NULL,Buffer.alloc(0));return e._value=null,e}static parseNull(e){if(!(e instanceof Buffer)||e.length!==0)throw new Error("ASN1 syntax error: invalid null");return null}static OID(e){let r=e.split(".");if(r.length===0)throw new Error("ASN1 syntax error: invalid Object Identifier");let n=[];n.push(40*qa(r[0])+qa(r[1]));let i=[];for(let a=2;a<r.length;++a){let c=qa(r[a]);for(i.length=0,i.push(c&127);c>127;)c=c>>>7,i.unshift(c&127|128);n.push(...i)}let s=new t(ca.UNIVERSAL,jn.OID,Buffer.from(n));return s._value=e,s}static parseOID(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid OID");let r=Math.floor(e[0]/40)+"."+e[0]%40,n=0;for(let i=1;i<e.length;i++)e[i]>=128?(n+=e[i]&127,n=n<<7):(r+="."+(n+e[i]),n=0);return r}static UTF8(e){let r=new t(ca.UNIVERSAL,jn.UTF8,Buffer.from(e,"utf8"));return r._value=e,r}static parseUTF8(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static NumericString(e){if(!O3e(e))throw new Error("ASN1 syntax error: invalid NumericString");let r=new t(ca.UNIVERSAL,jn.NUMERICSTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseNumericString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");let r=e.toString("utf8");if(!O3e(r))throw new Error("ASN1 syntax error: invalid NumericString");return r}static PrintableString(e){let r=new t(ca.UNIVERSAL,jn.PRINTABLESTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parsePrintableString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static IA5String(e){if(!N3e(e))throw new Error("ASN1 syntax error: invalid IA5String");let r=new t(ca.UNIVERSAL,jn.IA5STRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseIA5String(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");let r=e.toString("utf8");if(!N3e(r))throw new Error("ASN1 syntax error: invalid IA5String");return r}static T61String(e){let r=new t(ca.UNIVERSAL,jn.T61STRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseT61String(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static GeneralString(e){let r=new t(ca.UNIVERSAL,jn.GENERALSTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseGeneralString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static UTCTime(e){let r="",n=[];n.push((""+e.getUTCFullYear()).substr(2)),n.push(""+(e.getUTCMonth()+1)),n.push(""+e.getUTCDate()),n.push(""+e.getUTCHours()),n.push(""+e.getUTCMinutes()),n.push(""+e.getUTCSeconds());for(let s of n)s.length<2&&(r+="0"),r+=s;r+="Z";let i=new t(ca.UNIVERSAL,jn.UTCTIME,Buffer.from(r,"utf8"));return i._value=e,i}static parseUTCTime(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid UTC Time");let r=e.toString("utf8"),n=new Date,i=qa(r.substr(0,2));i=i>=50?1900+i:2e3+i;let s=qa(r.substr(2,2))-1,a=qa(r.substr(4,2)),c=qa(r.substr(6,2)),d=qa(r.substr(8,2)),h=0,p=0,x="";if(r.length>11&&(p=10,x=r.charAt(p),x!=="+"&&x!=="-"&&(h=qa(r.substr(10,2)),p+=2)),n.setUTCFullYear(i,s,a),n.setUTCHours(c,d,h,0),p>0&&(x=r.charAt(p),x==="+"||x==="-")){let y=qa(r.substr(p+1,2)),v=qa(r.substr(p+4,2)),w=y*60+v;w*=6e4,x==="+"?n.setTime(+n-w):n.setTime(+n+w)}return n}static GeneralizedTime(e){let r="",n=[];n.push(""+e.getUTCFullYear()),n.push(""+(e.getUTCMonth()+1)),n.push(""+e.getUTCDate()),n.push(""+e.getUTCHours()),n.push(""+e.getUTCMinutes()),n.push(""+e.getUTCSeconds());for(let s of n)s.length<2&&(r+="0"),r+=s;r+="Z";let i=new t(ca.UNIVERSAL,jn.GENERALIZEDTIME,Buffer.from(r,"utf8"));return i._value=e,i}static parseGeneralizedTime(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Generalized Time");let r=e.toString("utf8"),n=new Date,i=qa(r.substr(0,4)),s=qa(r.substr(4,2))-1,a=qa(r.substr(6,2)),c=qa(r.substr(8,2)),d=qa(r.substr(10,2)),h=qa(r.substr(12,2)),p=0,x=0,y=!1;r.charAt(r.length-1)==="Z"&&(y=!0);let v=r.length-5,w=r.charAt(v);if(w==="+"||w==="-"){let S=qa(r.substr(v+1,2)),C=qa(r.substr(v+4,2));x=S*60+C,x*=6e4,w==="+"&&(x*=-1),y=!0}return r.charAt(14)==="."&&(p=parseFloat(r.substr(14))*1e3),y?(n.setUTCFullYear(i,s,a),n.setUTCHours(c,d,h,p),n.setTime(+n+x)):(n.setFullYear(i,s,a),n.setHours(c,d,h,p)),n}static parseTime(e,r){switch(e){case jn.UTCTIME:return t.parseUTCTime(r);case jn.GENERALIZEDTIME:return t.parseGeneralizedTime(r);default:throw new Error("Invalid ASN1 time tag")}}static Set(e){let r=new t(ca.UNIVERSAL,jn.SET,Buffer.concat(e.map(n=>n.toDER())));return r._value=e,r}static Seq(e){let r=new t(ca.UNIVERSAL,jn.SEQUENCE,Buffer.concat(e.map(n=>n.toDER())));return r._value=e,r}static Spec(e,r,n=!0){let i=Array.isArray(r)?Buffer.concat(r.map(a=>a.toDER())):r.toDER();Array.isArray(r)&&(n=!0);let s=new t(ca.CONTEXT_SPECIFIC,e,i,n);return s._value=r,s}static fromDER(e,r=!1){return t._fromDER(new _O.BufferVisitor(e),r)}static parseDER(e,r,n){let i=t._fromDER(new _O.BufferVisitor(e),!1);if(i.class!==r&&i.tag!==n)throw new Error(`invalid ASN.1 DER for class ${r} and tag ${n}`);return i}static parseDERWithTemplate(e,r){let n=t._fromDER(new _O.BufferVisitor(e),!0),i={},s=n.validate(r,i);if(s!=null)throw s.data=n,s;return i}static _parseCompound(e,r){let n=[],i=e.length,s=new _O.BufferVisitor(e),a=0;for(;a<i;){let c=s.end;n.push(t._fromDER(s,r)),a+=s.end-c}return n}static _fromDER(e,r){if(!(e.buf instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Generalized Time");e.mustWalk(1,"Too few bytes to read ASN.1 tag.");let n=e.start,i=e.buf[n],s=i&192,a=i&31,c=s_t(e);if(e.mustHas(c),c!==0&&a===jn.NULL)throw new Error("invalid value length or NULL tag.");e.mustWalk(c);let d=(i&32)===32,h=new t(s,a,e.buf.slice(e.start,e.end),d);return d&&r&&(h._value=t._parseCompound(h.bytes,r)),h._der=e.buf.slice(n,e.end),h}constructor(e,r,n,i=!1){this.class=e,this.tag=r,this.bytes=n,this.isCompound=i||r===jn.SEQUENCE||r===jn.SET,this._value=void 0,this._der=null}get value(){return this._value===void 0&&(this._value=this.valueOf()),this._value}get DER(){return this._der==null&&(this._der=this.toDER()),this._der}mustCompound(e="asn1 object value is not compound"){if(!this.isCompound||!Array.isArray(this.value)){let r=new Error(e);throw r.data=this.toJSON(),r}return this.value}equals(e){return!(!(e instanceof t)||this.class!==e.class||this.tag!==e.tag||this.isCompound!==e.isCompound||!this.bytes.equals(e.bytes))}toDER(){let e=this.class|this.tag;this.isCompound&&(e|=32);let r=a_t(this.bytes.length),n=Buffer.allocUnsafe(2+r+this.bytes.length);return n.writeInt8(e,0),r===0?(n.writeUInt8(this.bytes.length,1),this.bytes.copy(n,2)):(n.writeUInt8(r|128,1),n.writeUIntBE(this.bytes.length,2,r),this.bytes.copy(n,2+r)),n}valueOf(){if(this.isCompound)return t._parseCompound(this.bytes,!1);if(this.class!==ca.UNIVERSAL)return this.bytes;switch(this.tag){case jn.BOOLEAN:return t.parseBool(this.bytes);case jn.INTEGER:return t.parseInteger(this.bytes);case jn.BITSTRING:return t.parseBitString(this.bytes);case jn.NULL:return t.parseNull(this.bytes);case jn.OID:return t.parseOID(this.bytes);case jn.UTF8:return t.parseUTF8(this.bytes);case jn.NUMERICSTRING:return t.parseNumericString(this.bytes);case jn.PRINTABLESTRING:return t.parsePrintableString(this.bytes);case jn.T61STRING:return t.parseT61String(this.bytes);case jn.IA5STRING:return t.parseIA5String(this.bytes);case jn.GENERALSTRING:return t.parseGeneralString(this.bytes);case jn.UTCTIME:return t.parseUTCTime(this.bytes);case jn.GENERALIZEDTIME:return t.parseGeneralizedTime(this.bytes);default:return this.bytes}}validate(e,r={}){if(this.class!==e.class)return new Error(`ASN.1 object validate failure for ${e.name} : error class ${ca[this.class]}`);if(!(Array.isArray(e.tag)?e.tag:[e.tag]).includes(this.tag))return new Error(`ASN.1 object validate failure for ${e.name}: error tag ${jn[this.tag]}`);if(e.capture!=null&&(r[e.capture]=this),Array.isArray(e.value)){let i=this.mustCompound(`${e.name} need compound ASN1 value`);for(let s=0,a=0;s<e.value.length;s++)if(i[a]!=null){let c=i[a].validate(e.value[s],r);if(c==null)a++;else if(e.value[s].optional!==!0)return c}else if(e.value[s].optional!==!0)return new Error(`ASN.1 object validate failure for ${e.value[s].name}: not exists`)}else if(e.value!=null){let i=this.tag===jn.BITSTRING?this.bytes.slice(1):this.bytes;return t.fromDER(i).validate(e.value,r)}return null}toJSON(){let e=this.value;return Array.isArray(e)&&(e=e.map(r=>r.toJSON())),{class:ca[this.class],tag:this.class===ca.UNIVERSAL?jn[this.tag]:this.tag,value:e}}[R3e.inspect.custom](e,r){return r.depth<=2&&(r.depth=10),`<${this.constructor.name} ${R3e.inspect(this.toJSON(),r)}>`}};zm.ASN1=zQ;function s_t(t){t.mustWalk(1,"Too few bytes to read ASN.1 value length.");let e=t.buf[t.start];if((e&128)===0)return e;let r=e&127;return t.mustWalk(r,"Too few bytes to read ASN.1 value length."),t.buf.readUIntBE(t.start,r)}function a_t(t){if(t<=127)return 0;if(t<=255)return 1;if(t<=65535)return 2;if(t<=16777215)return 3;if(t<=4294967295)return 4;if(t<=0xffffffffff)return 5;if(t<=0xffffffffffff)return 6;throw new Error("invalid value length")}function O3e(t){for(let e of t){let r=e.charCodeAt(0);if(r!==32&&(r<48||r>57))return!1}return!0}function N3e(t){for(let e of t)if(e.charCodeAt(0)>=128)return!1;return!0}function qa(t,e=10){let r=parseInt(t,e);if(Number.isNaN(r))throw new Error(`Invalid numeric string "${t}" in radix ${e}.`);return r}});var WQ=L(Wm=>{"use strict";Object.defineProperty(Wm,"__esModule",{value:!0});var o_t=MQ();Wm.BufferVisitor=o_t.BufferVisitor;var c_t=P3e();Wm.PEM=c_t.PEM;var wO=B3e();Wm.ASN1=wO.ASN1;Wm.Class=wO.Class;Wm.Tag=wO.Tag;Wm.BitString=wO.BitString});var KQ=L(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});var Vm=Kr("util"),Ik=Kr("crypto"),GQ=vO(),zt=WQ(),dc=xO();Jd.publicKeyValidator={name:"PublicKeyInfo",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,capture:"publicKeyInfo",value:[{name:"PublicKeyInfo.AlgorithmIdentifier",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"PublicKeyAlgorithmIdentifier.algorithm",class:zt.Class.UNIVERSAL,tag:zt.Tag.OID,capture:"publicKeyOID"}]},{name:"PublicKeyInfo.PublicKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.BITSTRING,capture:"publicKey"}]};Jd.privateKeyValidator={name:"PrivateKeyInfo",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,capture:"privateKeyInfo",value:[{name:"PrivateKeyInfo.Version",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.AlgorithmIdentifier",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"PrivateKeyAlgorithmIdentifier.algorithm",class:zt.Class.UNIVERSAL,tag:zt.Tag.OID,capture:"privateKeyOID"}]},{name:"PrivateKeyInfo.PrivateKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.OCTETSTRING,capture:"privateKey"}]};var u_t={name:"RSAPublicKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"RSAPublicKey.modulus",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"publicKeyExponent"}]},l_t={name:"RSAPrivateKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"RSAPrivateKey.version",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyCoefficient"}]},f_t=[dc.getOID("X25519"),dc.getOID("X448"),dc.getOID("Ed25519"),dc.getOID("Ed448")],__=class t{constructor(e){let r={},n=e.validate(Jd.publicKeyValidator,r);if(n!=null)throw new Error("Cannot read X.509 public key: "+n.message);this.oid=zt.ASN1.parseOID(r.publicKeyOID.bytes),this.algo=dc.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=zt.ASN1.parseBitString(r.publicKey.bytes).buf,this._finalKey=this._keyRaw,this._finalPEM=""}static fromPEM(e){let r=zt.PEM.parse(e)[0];if(r.procType.includes("ENCRYPTED"))throw new Error("Could not convert public key from PEM, PEM is encrypted.");let n=zt.ASN1.fromDER(r.body,!0);switch(r.type){case"PUBLIC KEY":return new t(n);case"RSA PUBLIC KEY":let i=zt.ASN1.Seq([zt.ASN1.Seq([zt.ASN1.OID(dc.getOID("rsaEncryption")),zt.ASN1.Null()]),zt.ASN1.BitString(n.DER)]);return new t(i);default:throw new Error("Could not convert public key from PEM, recommend PKCS#8 PEM")}}static addVerifier(e,r){if(e=dc.getOID(e),e==="")throw new Error(`Invalid object identifier: ${e}`);if(t._verifiers[e]!=null)throw new Error(`Verifier ${e} exists`);t._verifiers[e]=r}get keyRaw(){return this._finalKey}verify(e,r,n){let i=t._verifiers[this.oid];if(i!=null){let a=Ik.createHash(n).update(e).digest();return i.call(this,a,r)}let s=Ik.createVerify(n);return s.update(e),s.verify(this.toPEM(),r)}getFingerprint(e,r="PublicKey"){let n;switch(r){case"PublicKeyInfo":n=this._pkcs8.DER;break;case"PublicKey":n=this._keyRaw;break;default:throw new Error(`Unknown fingerprint type "${r}".`)}let i=Ik.createHash(e);return i.update(n),i.digest()}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("PUBLIC KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{oid:this.oid,algo:this.algo,publicKey:this._keyRaw}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};__._verifiers=Object.create(null);Jd.PublicKey=__;var w_=class t{constructor(e){let r=Object.create(null),n=e.validate(Jd.privateKeyValidator,r);if(n!=null)throw new Error("Cannot read X.509 private key: "+n.message);if(this.version=zt.ASN1.parseIntegerNum(r.privateKeyVersion.bytes)+1,this.oid=zt.ASN1.parseOID(r.privateKeyOID.bytes),this.algo=dc.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=r.privateKey.bytes,this._publicKeyRaw=null,this._finalKey=this._keyRaw,this._finalPEM="",f_t.includes(this.oid)){if(this._finalKey=this._keyRaw=zt.ASN1.parseDER(this._keyRaw,zt.Class.UNIVERSAL,zt.Tag.OCTETSTRING).bytes,this.oid==="1.3.101.112"){let i=GQ.sign.keyPair.fromSeed(this._keyRaw);this._publicKeyRaw=Buffer.from(i.publicKey),this._finalKey=Buffer.from(i.secretKey)}else if(this.version===2)for(let i of e.mustCompound())i.class===zt.Class.CONTEXT_SPECIFIC&&i.tag===1&&(this._publicKeyRaw=zt.ASN1.parseBitString(i.bytes).buf,this._finalKey=Buffer.concat([this._keyRaw,this._publicKeyRaw]))}}static fromPEM(e){let r=zt.PEM.parse(e)[0];if(r.procType.includes("ENCRYPTED"))throw new Error("Could not convert private key from PEM, PEM is encrypted.");let n=zt.ASN1.fromDER(r.body,!0);switch(r.type){case"PRIVATE KEY":return new t(n);case"RSA PRIVATE KEY":return n=zt.ASN1.Seq([n.value[0],zt.ASN1.Seq([zt.ASN1.OID(dc.getOID("rsaEncryption")),zt.ASN1.Null()]),new zt.ASN1(zt.Class.UNIVERSAL,zt.Tag.OCTETSTRING,n.DER)]),new t(n);default:throw new Error("Could not convert private key from PEM, recommend PKCS#8 PEM")}}static addSigner(e,r){if(e=dc.getOID(e),e==="")throw new Error(`Invalid object identifier: ${e}`);if(t._signers[e]!=null)throw new Error(`Signer ${e} exists`);t._signers[e]=r}get keyRaw(){return this._finalKey}get publicKeyRaw(){return this._publicKeyRaw}sign(e,r){let n=t._signers[this.oid];if(n!=null){let s=Ik.createHash(r).update(e).digest();return n.call(this,s)}let i=Ik.createSign(r);return i.update(e),i.sign(this.toPEM())}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("PRIVATE KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,privateKey:this._keyRaw,publicKey:this._publicKeyRaw}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};w_._signers=Object.create(null);Jd.PrivateKey=w_;var HQ=class t extends __{static fromPublicKey(e){return new t(e.toASN1())}constructor(e){if(super(e),dc.getOID(this.oid)!==dc.getOID("rsaEncryption"))throw new Error(`Invalid RSA public key, unknown OID: ${this.oid}`);let r=Object.create(null);this._pkcs1=zt.ASN1.fromDER(this._keyRaw,!0);let n=this._pkcs1.validate(u_t,r);if(n!=null)throw new Error("Cannot read RSA public key: "+n.message);this.modulus=zt.ASN1.parseIntegerStr(r.publicKeyModulus.bytes),this.exponent=zt.ASN1.parseIntegerNum(r.publicKeyExponent.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("RSA PUBLIC KEY",this._keyRaw).toString()),this._finalPEM}toPublicKeyPEM(){return new zt.PEM("PUBLIC KEY",this._pkcs8.DER).toString()}toJSON(){return{oid:this.oid,algo:this.algo,modulus:Hm(this.modulus),exponent:this.exponent}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};Jd.RSAPublicKey=HQ;var VQ=class t extends w_{static fromPrivateKey(e){return new t(e.toASN1())}constructor(e){if(super(e),dc.getOID(this.oid)!==dc.getOID("rsaEncryption"))throw new Error(`Invalid RSA private key, unknown OID: ${this.oid}`);let r=Object.create(null);this._pkcs1=zt.ASN1.fromDER(this._keyRaw,!0);let n=this._pkcs1.validate(l_t,r);if(n!=null)throw new Error("Cannot read RSA private key: "+n.message);this.publicExponent=zt.ASN1.parseIntegerNum(r.privateKeyPublicExponent.bytes),this.privateExponent=zt.ASN1.parseIntegerStr(r.privateKeyPrivateExponent.bytes),this.modulus=zt.ASN1.parseIntegerStr(r.privateKeyModulus.bytes),this.prime1=zt.ASN1.parseIntegerStr(r.privateKeyPrime1.bytes),this.prime2=zt.ASN1.parseIntegerStr(r.privateKeyPrime2.bytes),this.exponent1=zt.ASN1.parseIntegerStr(r.privateKeyExponent1.bytes),this.exponent2=zt.ASN1.parseIntegerStr(r.privateKeyExponent2.bytes),this.coefficient=zt.ASN1.parseIntegerStr(r.privateKeyCoefficient.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("RSA PRIVATE KEY",this._keyRaw).toString()),this._finalPEM}toPrivateKeyPEM(){return new zt.PEM("PRIVATE KEY",this._pkcs8.DER).toString()}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,publicExponent:this.publicExponent,privateExponent:Hm(this.privateExponent),modulus:Hm(this.modulus),prime1:Hm(this.prime1),prime2:Hm(this.prime2),exponent1:Hm(this.exponent1),exponent2:Hm(this.exponent2),coefficient:Hm(this.coefficient)}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};Jd.RSAPrivateKey=VQ;function Hm(t){return t.length%8!==0&&t.startsWith("00")?t.slice(2):t}__.addVerifier(dc.getOID("Ed25519"),function(t,e){return GQ.sign.detached.verify(t,e,this.keyRaw)});w_.addSigner(dc.getOID("Ed25519"),function(t){let e=this.keyRaw;if(e.length!==64)throw new Error("Invalid signing key.");return Buffer.from(GQ.sign.detached(t,e))})});var q3e=L(SO=>{"use strict";Object.defineProperty(SO,"__esModule",{value:!0});var U3e=Kr("util"),d_t=Kr("crypto"),It=WQ(),hc=xO(),j3e=KQ(),za=Object.create(null);za.CN=hc.getOID("commonName");za.commonName="CN";za.C=hc.getOID("countryName");za.countryName="C";za.L=hc.getOID("localityName");za.localityName="L";za.ST=hc.getOID("stateOrProvinceName");za.stateOrProvinceName="ST";za.O=hc.getOID("organizationName");za.organizationName="O";za.OU=hc.getOID("organizationalUnitName");za.organizationalUnitName="OU";za.E=hc.getOID("emailAddress");za.emailAddress="E";function h_t(t){return za[t]==null?"":za[t]}var p_t={name:"Certificate",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.NONE,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",class:It.Class.UNIVERSAL,tag:It.Tag.INTEGER,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",class:It.Class.UNIVERSAL,tag:It.Tag.INTEGER,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate.signature.algorithm",class:It.Class.UNIVERSAL,tag:It.Tag.OID,capture:"certinfoSignatureOID"},{name:"Certificate.TBSCertificate.signature.parameters",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,optional:!0,capture:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"certIssuer"},{name:"Certificate.TBSCertificate.validity",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate.validity.notBefore",class:It.Class.UNIVERSAL,tag:[It.Tag.UTCTIME,It.Tag.GENERALIZEDTIME],capture:"certValidityNotBefore"},{name:"Certificate.TBSCertificate.validity.notAfter",class:It.Class.UNIVERSAL,tag:[It.Tag.UTCTIME,It.Tag.GENERALIZEDTIME],capture:"certValidityNotAfter"}]},{name:"Certificate.TBSCertificate.subject",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"certSubject"},j3e.publicKeyValidator,{name:"Certificate.TBSCertificate.issuerUniqueID",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.BOOLEAN,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.INTEGER,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.BITSTRING,capture:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.signatureAlgorithm.algorithm",class:It.Class.UNIVERSAL,tag:It.Tag.OID,capture:"certSignatureOID"},{name:"Certificate.TBSCertificate.signature.parameters",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,optional:!0,capture:"certSignatureParams"}]},{name:"Certificate.signatureValue",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certSignature"}]},Fk=class{constructor(){this.attributes=[],this.uniqueId=null}get commonName(){return this.getFieldValue("commonName")}get organizationName(){return this.getFieldValue("organizationName")}get organizationalUnitName(){return this.getFieldValue("organizationalUnitName")}get countryName(){return this.getFieldValue("countryName")}get localityName(){return this.getFieldValue("localityName")}get serialName(){return this.getFieldValue("serialName")}getHash(){let e=d_t.createHash("sha1");for(let r of this.attributes)e.update(r.oid),e.update(r.value);return e.digest()}getField(e){for(let r of this.attributes)if(e===r.oid||e===r.name||e===r.shortName)return r;return null}addField(e){L3e([e]),this.attributes.push(e)}setAttrs(e){L3e(e),this.attributes=e}toJSON(){let e={};for(let r of this.attributes){let n=r.shortName;typeof n=="string"&&n!==""&&(e[n]=r.value)}return e.uniqueId=this.uniqueId,e.attributes=this.attributes,e}getFieldValue(e){let r=this.getField(e);return r!=null?r.value:""}};SO.DistinguishedName=Fk;var ZQ=class t{static fromPEMs(e){let r=[],n=It.PEM.parse(e);for(let i of n){if(i.type!=="CERTIFICATE"&&i.type!=="X509 CERTIFICATE"&&i.type!=="TRUSTED CERTIFICATE")throw new Error("Could not convert certificate from PEM: invalid type");if(i.procType.includes("ENCRYPTED"))throw new Error("Could not convert certificate from PEM: PEM is encrypted.");let s=It.ASN1.fromDER(i.body);r.push(new t(s))}if(r.length===0)throw new Error("No Certificate");return r}static fromPEM(e){return t.fromPEMs(e)[0]}constructor(e){let r=Object.create(null),n=e.validate(p_t,r);if(n!=null)throw new Error("Cannot read X.509 certificate: "+n.message);if(this.raw=e.DER,this.version=r.certVersion==null?0:It.ASN1.parseIntegerNum(r.certVersion.bytes)+1,this.serialNumber=It.ASN1.parseIntegerStr(r.certSerialNumber.bytes),this.signatureOID=It.ASN1.parseOID(r.certSignatureOID.bytes),this.signatureAlgorithm=hc.getOIDName(this.signatureOID),this.infoSignatureOID=It.ASN1.parseOID(r.certinfoSignatureOID.bytes),this.signature=It.ASN1.parseBitString(r.certSignature.bytes).buf,this.validFrom=It.ASN1.parseTime(r.certValidityNotBefore.tag,r.certValidityNotBefore.bytes),this.validTo=It.ASN1.parseTime(r.certValidityNotAfter.tag,r.certValidityNotAfter.bytes),this.issuer=new Fk,this.issuer.setAttrs($3e(r.certIssuer)),r.certIssuerUniqueId!=null&&(this.issuer.uniqueId=It.ASN1.parseBitString(r.certIssuerUniqueId.bytes)),this.subject=new Fk,this.subject.setAttrs($3e(r.certSubject)),r.certSubjectUniqueId!=null&&(this.subject.uniqueId=It.ASN1.parseBitString(r.certSubjectUniqueId.bytes)),this.extensions=[],this.subjectKeyIdentifier="",this.authorityKeyIdentifier="",this.ocspServer="",this.issuingCertificateURL="",this.isCA=!1,this.maxPathLen=-1,this.basicConstraintsValid=!1,this.keyUsage=0,this.dnsNames=[],this.emailAddresses=[],this.ipAddresses=[],this.uris=[],r.certExtensions!=null){this.extensions=m_t(r.certExtensions);for(let i of this.extensions)if(typeof i.subjectKeyIdentifier=="string"&&(this.subjectKeyIdentifier=i.subjectKeyIdentifier),typeof i.authorityKeyIdentifier=="string"&&(this.authorityKeyIdentifier=i.authorityKeyIdentifier),typeof i.authorityInfoAccessOcsp=="string"&&(this.ocspServer=i.authorityInfoAccessOcsp),typeof i.authorityInfoAccessIssuers=="string"&&(this.issuingCertificateURL=i.authorityInfoAccessIssuers),typeof i.basicConstraintsValid=="boolean"&&(this.isCA=i.isCA,this.maxPathLen=i.maxPathLen,this.basicConstraintsValid=i.basicConstraintsValid),typeof i.keyUsage=="number"&&(this.keyUsage=i.keyUsage),Array.isArray(i.altNames))for(let s of i.altNames)s.dnsName!=null&&this.dnsNames.push(s.dnsName),s.email!=null&&this.emailAddresses.push(s.email),s.ip!=null&&this.ipAddresses.push(s.ip),s.uri!=null&&this.uris.push(s.uri)}this.publicKey=new j3e.PublicKey(r.publicKeyInfo),this.publicKeyRaw=this.publicKey.toDER(),this.tbsCertificate=r.tbsCertificate}getExtension(e,r=""){for(let n of this.extensions)if(e===n.oid||e===n.name)return r===""?n:n[r];return null}checkSignature(e){if(this.version===3&&!this.basicConstraintsValid||this.basicConstraintsValid&&!this.isCA)return new Error("The parent constraint violation error");if(this.getExtension("keyUsage","keyCertSign")!==!0)return new Error("The parent constraint violation error");if(!e.isIssuer(this))return new Error("The parent certificate did not issue the given child certificate");let r=C_t(e.signatureOID);return r===""?new Error("Unknown child signature OID."):this.publicKey.verify(e.tbsCertificate.DER,e.signature,r)===!1?new Error("Child signature not matched"):null}isIssuer(e){return this.issuer.getHash().equals(e.subject.getHash())}verifySubjectKeyIdentifier(){return this.publicKey.getFingerprint("sha1","PublicKey").toString("hex")===this.subjectKeyIdentifier}toJSON(){let e={};for(let r of Object.keys(this))e[r]=k_t(this[r]);return delete e.tbsCertificate,e}[U3e.inspect.custom](e,r){return r.depth<=2&&(r.depth=10),`<${this.constructor.name} ${U3e.inspect(this.toJSON(),r)}>`}};SO.Certificate=ZQ;function m_t(t){let e=[];for(let r of t.mustCompound())for(let n of r.mustCompound())e.push(g_t(n));return e}function g_t(t){let e={};switch(e.oid=It.ASN1.parseOID(t.value[0].bytes),e.critical=!1,t.value[1].tag===It.Tag.BOOLEAN?(e.critical=It.ASN1.parseBool(t.value[1].bytes),e.value=t.value[2].bytes):e.value=t.value[1].bytes,e.name=hc.getOIDName(e.oid),e.name){case"keyUsage":x_t(e);break;case"basicConstraints":y_t(e);break;case"extKeyUsage":v_t(e);break;case"nsCertType":b_t(e);break;case"subjectAltName":M3e(e);break;case"issuerAltName":M3e(e);break;case"subjectKeyIdentifier":w_t(e);break;case"authorityKeyIdentifier":A_t(e);break;case"authorityInfoAccess":T_t(e);break}return e}function x_t(t){let e=It.ASN1.parseBitString(It.ASN1.fromDER(t.value).bytes),r=0,n=0;t.keyUsage=0;for(let i=0;i<9;i++)e.at(i)!==0&&(t.keyUsage|=1<<i);e.buf.length>0&&(r=e.buf[0],n=e.buf.length>1?e.buf[1]:0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}function y_t(t){let r=It.ASN1.fromDER(t.value).mustCompound();r.length>0&&r[0].tag===It.Tag.BOOLEAN?t.isCA=It.ASN1.parseBool(r[0].bytes):t.isCA=!1;let n=null;r.length>0&&r[0].tag===It.Tag.INTEGER?n=r[0].bytes:r.length>1&&(n=r[1].bytes),n!==null?t.maxPathLen=It.ASN1.parseInteger(n):t.maxPathLen=-1,t.basicConstraintsValid=!0}function v_t(t){let r=It.ASN1.fromDER(t.value).mustCompound();for(let n of r)t[hc.getOIDName(It.ASN1.parseOID(n.bytes))]=!0}function b_t(t){let e=It.ASN1.parseBitString(It.ASN1.fromDER(t.value).bytes),r=0;e.buf.length>0&&(r=e.buf[0]),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}function M3e(t){t.altNames=[];let r=It.ASN1.fromDER(t.value).mustCompound();for(let n of r){let i={tag:n.tag,value:n.bytes};switch(t.altNames.push(i),n.tag){case 1:i.email=n.bytes.toString();break;case 2:i.dnsName=n.bytes.toString();break;case 6:i.uri=n.bytes.toString();break;case 7:i.ip=hc.bytesToIP(n.bytes);break;case 8:i.oid=It.ASN1.parseOID(n.bytes);break;default:}}}var __t={name:"subjectKeyIdentifier",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,capture:"subjectKeyIdentifier"};function w_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,__t);t.subjectKeyIdentifier=e.subjectKeyIdentifier.bytes.toString("hex")}var S_t={name:"authorityKeyIdentifier",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"authorityKeyIdentifier.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.NONE,capture:"authorityKeyIdentifier"}]};function A_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,S_t);t.authorityKeyIdentifier=e.authorityKeyIdentifier.bytes.toString("hex")}var E_t={name:"authorityInfoAccess",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"authorityInfoAccess.authorityInfoAccessOcsp",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,optional:!0,value:[{name:"authorityInfoAccess.authorityInfoAccessOcsp.oid",class:It.Class.UNIVERSAL,tag:It.Tag.OID},{name:"authorityInfoAccess.authorityInfoAccessOcsp.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.OID,capture:"authorityInfoAccessOcsp"}]},{name:"authorityInfoAccess.authorityInfoAccessIssuers",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,optional:!0,value:[{name:"authorityInfoAccess.authorityInfoAccessIssuers.oid",class:It.Class.UNIVERSAL,tag:It.Tag.OID},{name:"authorityInfoAccess.authorityInfoAccessIssuers.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.OID,capture:"authorityInfoAccessIssuers"}]}]};function T_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,E_t);e.authorityInfoAccessOcsp!=null&&(t.authorityInfoAccessOcsp=e.authorityInfoAccessOcsp.bytes.toString()),e.authorityInfoAccessIssuers!=null&&(t.authorityInfoAccessIssuers=e.authorityInfoAccessIssuers.bytes.toString())}function L3e(t){for(let e of t){if((e.name==null||e.name==="")&&(e.oid!=null&&(e.name=hc.getOIDName(e.oid)),e.name===""&&e.shortName!=null&&(e.name=hc.getOIDName(za[e.shortName]))),e.oid==null||e.oid==="")if(e.name!=="")e.oid=hc.getOID(e.name);else throw new Error("Attribute oid not specified.");if((e.shortName==null||e.shortName==="")&&(e.shortName=za[e.name]==null?"":za[e.name]),e.value==null)throw new Error("Attribute value not specified.")}}function C_t(t){switch(hc.getOIDName(t)){case"sha1WithRsaEncryption":return"sha1";case"md5WithRsaEncryption":return"md5";case"sha256WithRsaEncryption":return"sha256";case"sha384WithRsaEncryption":return"sha384";case"sha512WithRsaEncryption":return"sha512";case"RSASSA-PSS":return"sha256";case"ecdsaWithSha1":return"sha1";case"ecdsaWithSha256":return"sha256";case"ecdsaWithSha384":return"sha384";case"ecdsaWithSha512":return"sha512";case"dsaWithSha1":return"sha1";case"dsaWithSha256":return"sha256";default:return""}}function $3e(t){let e=[];for(let r of t.mustCompound())for(let n of r.mustCompound()){let i=n.mustCompound(),s={};s.oid=It.ASN1.parseOID(i[0].bytes),s.value=i[1].value,s.valueTag=i[1].tag,s.name=hc.getOIDName(s.oid),s.shortName=h_t(s.name),e.push(s)}return e}function k_t(t){return t!=null&&!(t instanceof Buffer)&&typeof t.toJSON=="function"?t.toJSON():t}});var XQ=L(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var AO=xO();Wl.bytesFromIP=AO.bytesFromIP;Wl.bytesToIP=AO.bytesToIP;Wl.getOID=AO.getOID;Wl.getOIDName=AO.getOIDName;var EO=KQ();Wl.PublicKey=EO.PublicKey;Wl.PrivateKey=EO.PrivateKey;Wl.RSAPublicKey=EO.RSAPublicKey;Wl.RSAPrivateKey=EO.RSAPrivateKey;var z3e=q3e();Wl.Certificate=z3e.Certificate;Wl.DistinguishedName=z3e.DistinguishedName});var H3e=L(()=>{var W3e;(function(t){(function(e){var r=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(t);typeof r.Reflect<"u"&&(n=i(r.Reflect,n)),e(n,r),typeof r.Reflect>"u"&&(r.Reflect=t);function i(d,h){return function(p,x){Object.defineProperty(d,p,{configurable:!0,writable:!0,value:x}),h&&h(p,x)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,r){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",d={__proto__:[]}instanceof Array,h=!c&&!d,p={create:c?function(){return Zr(Object.create(null))}:d?function(){return Zr({__proto__:null})}:function(){return Zr({})},has:h?function(Fe,Me){return n.call(Fe,Me)}:function(Fe,Me){return Me in Fe},get:h?function(Fe,Me){return n.call(Fe,Me)?Fe[Me]:void 0}:function(Fe,Me){return Fe[Me]}},x=Object.getPrototypeOf(Function),y=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:kr(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Fi(),w=typeof WeakMap=="function"?WeakMap:_i(),S=i?Symbol.for("@reflect-metadata:registry"):void 0,C=$e(),k=We(C);function T(Fe,Me,nt,Et){if(J(nt)){if(!lr(Fe))throw new TypeError;if(!pt(Me))throw new TypeError;return te(Fe,Me)}else{if(!lr(Fe))throw new TypeError;if(!fe(Me))throw new TypeError;if(!fe(Et)&&!J(Et)&&!se(Et))throw new TypeError;return se(Et)&&(Et=void 0),nt=Xe(nt),Q(Fe,Me,nt,Et)}}e("decorate",T);function E(Fe,Me){function nt(Et,Tr){if(!fe(Et))throw new TypeError;if(!J(Tr)&&!Ct(Tr))throw new TypeError;X(Fe,Me,Et,Tr)}return nt}e("metadata",E);function I(Fe,Me,nt,Et){if(!fe(nt))throw new TypeError;return J(Et)||(Et=Xe(Et)),X(Fe,Me,nt,Et)}e("defineMetadata",I);function R(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),ee(Fe,Me,nt)}e("hasMetadata",R);function U(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),pe(Fe,Me,nt)}e("hasOwnMetadata",U);function B(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),H(Fe,Me,nt)}e("getMetadata",B);function z(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),oe(Fe,Me,nt)}e("getOwnMetadata",z);function K(Fe,Me){if(!fe(Fe))throw new TypeError;return J(Me)||(Me=Xe(Me)),N(Fe,Me)}e("getMetadataKeys",K);function Ae(Fe,Me){if(!fe(Fe))throw new TypeError;return J(Me)||(Me=Xe(Me)),Z(Fe,Me)}e("getOwnMetadataKeys",Ae);function de(Fe,Me,nt){if(!fe(Me))throw new TypeError;if(J(nt)||(nt=Xe(nt)),!fe(Me))throw new TypeError;J(nt)||(nt=Xe(nt));var Et=Pt(Me,nt,!1);return J(Et)?!1:Et.OrdinaryDeleteMetadata(Fe,Me,nt)}e("deleteMetadata",de);function te(Fe,Me){for(var nt=Fe.length-1;nt>=0;--nt){var Et=Fe[nt],Tr=Et(Me);if(!J(Tr)&&!se(Tr)){if(!pt(Tr))throw new TypeError;Me=Tr}}return Me}function Q(Fe,Me,nt,Et){for(var Tr=Fe.length-1;Tr>=0;--Tr){var Ei=Fe[Tr],Ki=Ei(Me,nt,Et);if(!J(Ki)&&!se(Ki)){if(!fe(Ki))throw new TypeError;Et=Ki}}return Et}function ee(Fe,Me,nt){var Et=pe(Fe,Me,nt);if(Et)return!0;var Tr=ra(Me);return se(Tr)?!1:ee(Fe,Tr,nt)}function pe(Fe,Me,nt){var Et=Pt(Me,nt,!1);return J(Et)?!1:Ft(Et.OrdinaryHasOwnMetadata(Fe,Me,nt))}function H(Fe,Me,nt){var Et=pe(Fe,Me,nt);if(Et)return oe(Fe,Me,nt);var Tr=ra(Me);if(!se(Tr))return H(Fe,Tr,nt)}function oe(Fe,Me,nt){var Et=Pt(Me,nt,!1);if(!J(Et))return Et.OrdinaryGetOwnMetadata(Fe,Me,nt)}function X(Fe,Me,nt,Et){var Tr=Pt(nt,Et,!0);Tr.OrdinaryDefineOwnMetadata(Fe,Me,nt,Et)}function N(Fe,Me){var nt=Z(Fe,Me),Et=ra(Fe);if(Et===null)return nt;var Tr=N(Et,Me);if(Tr.length<=0)return nt;if(nt.length<=0)return Tr;for(var Ei=new v,Ki=[],Ur=0,Yt=nt;Ur<Yt.length;Ur++){var cr=Yt[Ur],vr=Ei.has(cr);vr||(Ei.add(cr),Ki.push(cr))}for(var Dr=0,Mr=Tr;Dr<Mr.length;Dr++){var cr=Mr[Dr],vr=Ei.has(cr);vr||(Ei.add(cr),Ki.push(cr))}return Ki}function Z(Fe,Me){var nt=Pt(Fe,Me,!1);return nt?nt.OrdinaryOwnMetadataKeys(Fe,Me):[]}function ae(Fe){if(Fe===null)return 1;switch(typeof Fe){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return Fe===null?1:6;default:return 6}}function J(Fe){return Fe===void 0}function se(Fe){return Fe===null}function Se(Fe){return typeof Fe=="symbol"}function fe(Fe){return typeof Fe=="object"?Fe!==null:typeof Fe=="function"}function ze(Fe,Me){switch(ae(Fe)){case 0:return Fe;case 1:return Fe;case 2:return Fe;case 3:return Fe;case 4:return Fe;case 5:return Fe}var nt=Me===3?"string":Me===5?"number":"default",Et=rn(Fe,s);if(Et!==void 0){var Tr=Et.call(Fe,nt);if(fe(Tr))throw new TypeError;return Tr}return Ue(Fe,nt==="default"?"number":nt)}function Ue(Fe,Me){if(Me==="string"){var nt=Fe.toString;if(Ce(nt)){var Et=nt.call(Fe);if(!fe(Et))return Et}var Tr=Fe.valueOf;if(Ce(Tr)){var Et=Tr.call(Fe);if(!fe(Et))return Et}}else{var Tr=Fe.valueOf;if(Ce(Tr)){var Et=Tr.call(Fe);if(!fe(Et))return Et}var Ei=Fe.toString;if(Ce(Ei)){var Et=Ei.call(Fe);if(!fe(Et))return Et}}throw new TypeError}function Ft(Fe){return!!Fe}function Ht(Fe){return""+Fe}function Xe(Fe){var Me=ze(Fe,3);return Se(Me)?Me:Ht(Me)}function lr(Fe){return Array.isArray?Array.isArray(Fe):Fe instanceof Object?Fe instanceof Array:Object.prototype.toString.call(Fe)==="[object Array]"}function Ce(Fe){return typeof Fe=="function"}function pt(Fe){return typeof Fe=="function"}function Ct(Fe){switch(ae(Fe)){case 3:return!0;case 4:return!0;default:return!1}}function ar(Fe,Me){return Fe===Me||Fe!==Fe&&Me!==Me}function rn(Fe,Me){var nt=Fe[Me];if(nt!=null){if(!Ce(nt))throw new TypeError;return nt}}function Sn(Fe){var Me=rn(Fe,a);if(!Ce(Me))throw new TypeError;var nt=Me.call(Fe);if(!fe(nt))throw new TypeError;return nt}function An(Fe){return Fe.value}function Ai(Fe){var Me=Fe.next();return Me.done?!1:Me}function Ii(Fe){var Me=Fe.return;Me&&Me.call(Fe)}function ra(Fe){var Me=Object.getPrototypeOf(Fe);if(typeof Fe!="function"||Fe===x||Me!==x)return Me;var nt=Fe.prototype,Et=nt&&Object.getPrototypeOf(nt);if(Et==null||Et===Object.prototype)return Me;var Tr=Et.constructor;return typeof Tr!="function"||Tr===Fe?Me:Tr}function Bn(){var Fe;!J(S)&&typeof r.Reflect<"u"&&!(S in r.Reflect)&&typeof r.Reflect.defineMetadata=="function"&&(Fe=Tt(r.Reflect));var Me,nt,Et,Tr=new w,Ei={registerProvider:Ki,getProvider:Yt,setProvider:vr};return Ei;function Ki(Dr){if(!Object.isExtensible(Ei))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case Fe===Dr:break;case J(Me):Me=Dr;break;case Me===Dr:break;case J(nt):nt=Dr;break;case nt===Dr:break;default:Et===void 0&&(Et=new v),Et.add(Dr);break}}function Ur(Dr,Mr){if(!J(Me)){if(Me.isProviderFor(Dr,Mr))return Me;if(!J(nt)){if(nt.isProviderFor(Dr,Mr))return Me;if(!J(Et))for(var ti=Sn(Et);;){var Pi=Ai(ti);if(!Pi)return;var Xa=An(Pi);if(Xa.isProviderFor(Dr,Mr))return Ii(ti),Xa}}}if(!J(Fe)&&Fe.isProviderFor(Dr,Mr))return Fe}function Yt(Dr,Mr){var ti=Tr.get(Dr),Pi;return J(ti)||(Pi=ti.get(Mr)),J(Pi)&&(Pi=Ur(Dr,Mr),J(Pi)||(J(ti)&&(ti=new y,Tr.set(Dr,ti)),ti.set(Mr,Pi))),Pi}function cr(Dr){if(J(Dr))throw new TypeError;return Me===Dr||nt===Dr||!J(Et)&&Et.has(Dr)}function vr(Dr,Mr,ti){if(!cr(ti))throw new Error("Metadata provider not registered.");var Pi=Yt(Dr,Mr);if(Pi!==ti){if(!J(Pi))return!1;var Xa=Tr.get(Dr);J(Xa)&&(Xa=new y,Tr.set(Dr,Xa)),Xa.set(Mr,ti)}return!0}}function $e(){var Fe;return!J(S)&&fe(r.Reflect)&&Object.isExtensible(r.Reflect)&&(Fe=r.Reflect[S]),J(Fe)&&(Fe=Bn()),!J(S)&&fe(r.Reflect)&&Object.isExtensible(r.Reflect)&&Object.defineProperty(r.Reflect,S,{enumerable:!1,configurable:!1,writable:!1,value:Fe}),Fe}function We(Fe){var Me=new w,nt={isProviderFor:function(cr,vr){var Dr=Me.get(cr);return J(Dr)?!1:Dr.has(vr)},OrdinaryDefineOwnMetadata:Ki,OrdinaryHasOwnMetadata:Tr,OrdinaryGetOwnMetadata:Ei,OrdinaryOwnMetadataKeys:Ur,OrdinaryDeleteMetadata:Yt};return C.registerProvider(nt),nt;function Et(cr,vr,Dr){var Mr=Me.get(cr),ti=!1;if(J(Mr)){if(!Dr)return;Mr=new y,Me.set(cr,Mr),ti=!0}var Pi=Mr.get(vr);if(J(Pi)){if(!Dr)return;if(Pi=new y,Mr.set(vr,Pi),!Fe.setProvider(cr,vr,nt))throw Mr.delete(vr),ti&&Me.delete(cr),new Error("Wrong provider for target.")}return Pi}function Tr(cr,vr,Dr){var Mr=Et(vr,Dr,!1);return J(Mr)?!1:Ft(Mr.has(cr))}function Ei(cr,vr,Dr){var Mr=Et(vr,Dr,!1);if(!J(Mr))return Mr.get(cr)}function Ki(cr,vr,Dr,Mr){var ti=Et(Dr,Mr,!0);ti.set(cr,vr)}function Ur(cr,vr){var Dr=[],Mr=Et(cr,vr,!1);if(J(Mr))return Dr;for(var ti=Mr.keys(),Pi=Sn(ti),Xa=0;;){var xo=Ai(Pi);if(!xo)return Dr.length=Xa,Dr;var Hc=An(xo);try{Dr[Xa]=Hc}catch(YS){try{Ii(Pi)}finally{throw YS}}Xa++}}function Yt(cr,vr,Dr){var Mr=Et(vr,Dr,!1);if(J(Mr)||!Mr.delete(cr))return!1;if(Mr.size===0){var ti=Me.get(vr);J(ti)||(ti.delete(Dr),ti.size===0&&Me.delete(ti))}return!0}}function Tt(Fe){var Me=Fe.defineMetadata,nt=Fe.hasOwnMetadata,Et=Fe.getOwnMetadata,Tr=Fe.getOwnMetadataKeys,Ei=Fe.deleteMetadata,Ki=new w,Ur={isProviderFor:function(Yt,cr){var vr=Ki.get(Yt);return!J(vr)&&vr.has(cr)?!0:Tr(Yt,cr).length?(J(vr)&&(vr=new v,Ki.set(Yt,vr)),vr.add(cr),!0):!1},OrdinaryDefineOwnMetadata:Me,OrdinaryHasOwnMetadata:nt,OrdinaryGetOwnMetadata:Et,OrdinaryOwnMetadataKeys:Tr,OrdinaryDeleteMetadata:Ei};return Ur}function Pt(Fe,Me,nt){var Et=C.getProvider(Fe,Me);if(!J(Et))return Et;if(nt){if(C.setProvider(Fe,Me,k))return k;throw new Error("Illegal state.")}}function kr(){var Fe={},Me=[],nt=(function(){function Ur(Yt,cr,vr){this._index=0,this._keys=Yt,this._values=cr,this._selector=vr}return Ur.prototype["@@iterator"]=function(){return this},Ur.prototype[a]=function(){return this},Ur.prototype.next=function(){var Yt=this._index;if(Yt>=0&&Yt<this._keys.length){var cr=this._selector(this._keys[Yt],this._values[Yt]);return Yt+1>=this._keys.length?(this._index=-1,this._keys=Me,this._values=Me):this._index++,{value:cr,done:!1}}return{value:void 0,done:!0}},Ur.prototype.throw=function(Yt){throw this._index>=0&&(this._index=-1,this._keys=Me,this._values=Me),Yt},Ur.prototype.return=function(Yt){return this._index>=0&&(this._index=-1,this._keys=Me,this._values=Me),{value:Yt,done:!0}},Ur})(),Et=(function(){function Ur(){this._keys=[],this._values=[],this._cacheKey=Fe,this._cacheIndex=-2}return Object.defineProperty(Ur.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ur.prototype.has=function(Yt){return this._find(Yt,!1)>=0},Ur.prototype.get=function(Yt){var cr=this._find(Yt,!1);return cr>=0?this._values[cr]:void 0},Ur.prototype.set=function(Yt,cr){var vr=this._find(Yt,!0);return this._values[vr]=cr,this},Ur.prototype.delete=function(Yt){var cr=this._find(Yt,!1);if(cr>=0){for(var vr=this._keys.length,Dr=cr+1;Dr<vr;Dr++)this._keys[Dr-1]=this._keys[Dr],this._values[Dr-1]=this._values[Dr];return this._keys.length--,this._values.length--,ar(Yt,this._cacheKey)&&(this._cacheKey=Fe,this._cacheIndex=-2),!0}return!1},Ur.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=Fe,this._cacheIndex=-2},Ur.prototype.keys=function(){return new nt(this._keys,this._values,Tr)},Ur.prototype.values=function(){return new nt(this._keys,this._values,Ei)},Ur.prototype.entries=function(){return new nt(this._keys,this._values,Ki)},Ur.prototype["@@iterator"]=function(){return this.entries()},Ur.prototype[a]=function(){return this.entries()},Ur.prototype._find=function(Yt,cr){if(!ar(this._cacheKey,Yt)){this._cacheIndex=-1;for(var vr=0;vr<this._keys.length;vr++)if(ar(this._keys[vr],Yt)){this._cacheIndex=vr;break}}return this._cacheIndex<0&&cr&&(this._cacheIndex=this._keys.length,this._keys.push(Yt),this._values.push(void 0)),this._cacheIndex},Ur})();return Et;function Tr(Ur,Yt){return Ur}function Ei(Ur,Yt){return Yt}function Ki(Ur,Yt){return[Ur,Yt]}}function Fi(){var Fe=(function(){function Me(){this._map=new y}return Object.defineProperty(Me.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),Me.prototype.has=function(nt){return this._map.has(nt)},Me.prototype.add=function(nt){return this._map.set(nt,nt),this},Me.prototype.delete=function(nt){return this._map.delete(nt)},Me.prototype.clear=function(){this._map.clear()},Me.prototype.keys=function(){return this._map.keys()},Me.prototype.values=function(){return this._map.keys()},Me.prototype.entries=function(){return this._map.entries()},Me.prototype["@@iterator"]=function(){return this.keys()},Me.prototype[a]=function(){return this.keys()},Me})();return Fe}function _i(){var Fe=16,Me=p.create(),nt=Et();return(function(){function Yt(){this._key=Et()}return Yt.prototype.has=function(cr){var vr=Tr(cr,!1);return vr!==void 0?p.has(vr,this._key):!1},Yt.prototype.get=function(cr){var vr=Tr(cr,!1);return vr!==void 0?p.get(vr,this._key):void 0},Yt.prototype.set=function(cr,vr){var Dr=Tr(cr,!0);return Dr[this._key]=vr,this},Yt.prototype.delete=function(cr){var vr=Tr(cr,!1);return vr!==void 0?delete vr[this._key]:!1},Yt.prototype.clear=function(){this._key=Et()},Yt})();function Et(){var Yt;do Yt="@@WeakMap@@"+Ur();while(p.has(Me,Yt));return Me[Yt]=!0,Yt}function Tr(Yt,cr){if(!n.call(Yt,nt)){if(!cr)return;Object.defineProperty(Yt,nt,{value:p.create()})}return Yt[nt]}function Ei(Yt,cr){for(var vr=0;vr<cr;++vr)Yt[vr]=Math.random()*255|0;return Yt}function Ki(Yt){if(typeof Uint8Array=="function"){var cr=new Uint8Array(Yt);return typeof crypto<"u"?crypto.getRandomValues(cr):typeof msCrypto<"u"?msCrypto.getRandomValues(cr):Ei(cr,Yt),cr}return Ei(new Array(Yt),Yt)}function Ur(){var Yt=Ki(Fe);Yt[6]=Yt[6]&79|64,Yt[8]=Yt[8]&191|128;for(var cr="",vr=0;vr<Fe;++vr){var Dr=Yt[vr];(vr===4||vr===6||vr===8)&&(cr+="-"),Dr<16&&(cr+="0"),cr+=Dr.toString(16).toLowerCase()}return cr}}function Zr(Fe){return Fe.__=void 0,delete Fe.__,Fe}})})(W3e||(W3e={}))});var st={};yi(st,{__addDisposableResource:()=>g6e,__assign:()=>TO,__asyncDelegator:()=>c6e,__asyncGenerator:()=>o6e,__asyncValues:()=>u6e,__await:()=>S_,__awaiter:()=>t6e,__classPrivateFieldGet:()=>h6e,__classPrivateFieldIn:()=>m6e,__classPrivateFieldSet:()=>p6e,__createBinding:()=>kO,__decorate:()=>K3e,__disposeResources:()=>x6e,__esDecorate:()=>X3e,__exportStar:()=>n6e,__extends:()=>V3e,__generator:()=>r6e,__importDefault:()=>d6e,__importStar:()=>f6e,__makeTemplateObject:()=>l6e,__metadata:()=>e6e,__param:()=>Z3e,__propKey:()=>J3e,__read:()=>QQ,__rest:()=>G3e,__rewriteRelativeImportExtension:()=>y6e,__runInitializers:()=>Y3e,__setFunctionName:()=>Q3e,__spread:()=>i6e,__spreadArray:()=>a6e,__spreadArrays:()=>s6e,__values:()=>CO,default:()=>F_t});function V3e(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");YQ(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function G3e(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function K3e(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Z3e(t,e){return function(r,n){e(r,n,t)}}function X3e(t,e,r,n,i,s){function a(k){if(k!==void 0&&typeof k!="function")throw new TypeError("Function expected");return k}for(var c=n.kind,d=c==="getter"?"get":c==="setter"?"set":"value",h=!e&&t?n.static?t:t.prototype:null,p=e||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),x,y=!1,v=r.length-1;v>=0;v--){var w={};for(var S in n)w[S]=S==="access"?{}:n[S];for(var S in n.access)w.access[S]=n.access[S];w.addInitializer=function(k){if(y)throw new TypeError("Cannot add initializers after decoration has completed");s.push(a(k||null))};var C=(0,r[v])(c==="accessor"?{get:p.get,set:p.set}:p[d],w);if(c==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(x=a(C.get))&&(p.get=x),(x=a(C.set))&&(p.set=x),(x=a(C.init))&&i.unshift(x)}else(x=a(C))&&(c==="field"?i.unshift(x):p[d]=x)}h&&Object.defineProperty(h,n.name,p),y=!0}function Y3e(t,e,r){for(var n=arguments.length>2,i=0;i<e.length;i++)r=n?e[i].call(t,r):e[i].call(t);return n?r:void 0}function J3e(t){return typeof t=="symbol"?t:"".concat(t)}function Q3e(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function e6e(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function t6e(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function c(p){try{h(n.next(p))}catch(x){a(x)}}function d(p){try{h(n.throw(p))}catch(x){a(x)}}function h(p){p.done?s(p.value):i(p.value).then(c,d)}h((n=n.apply(t,e||[])).next())})}function r6e(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(h){return function(p){return d([h,p])}}function d(h){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,h[0]&&(r=0)),r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(p){h=[6,p],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function n6e(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&kO(e,t,r)}function CO(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function QQ(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function i6e(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(QQ(arguments[e]));return t}function s6e(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)n[i]=s[a];return n}function a6e(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function S_(t){return this instanceof S_?(this.v=t,this):new S_(t)}function o6e(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(w){return Promise.resolve(w).then(v,x)}}function c(v,w){n[v]&&(i[v]=function(S){return new Promise(function(C,k){s.push([v,S,C,k])>1||d(v,S)})},w&&(i[v]=w(i[v])))}function d(v,w){try{h(n[v](w))}catch(S){y(s[0][3],S)}}function h(v){v.value instanceof S_?Promise.resolve(v.value.v).then(p,x):y(s[0][2],v)}function p(v){d("next",v)}function x(v){d("throw",v)}function y(v,w){v(w),s.shift(),s.length&&d(s[0][0],s[0][1])}}function c6e(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(a){return(r=!r)?{value:S_(t[i](a)),done:!1}:s?s(a):a}:s}}function u6e(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof CO=="function"?CO(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(a){return new Promise(function(c,d){a=t[s](a),i(c,d,a.done,a.value)})}}function i(s,a,c,d){Promise.resolve(d).then(function(h){s({value:h,done:c})},a)}}function l6e(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function f6e(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=JQ(t),n=0;n<r.length;n++)r[n]!=="default"&&kO(e,t,r[n]);return D_t(e,t),e}function d6e(t){return t&&t.__esModule?t:{default:t}}function h6e(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function p6e(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function m6e(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function g6e(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(i=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(s){return Promise.reject(s)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}function x6e(t){function e(s){t.error=t.hasError?new I_t(s,t.error,"An error was suppressed during disposal."):s,t.hasError=!0}var r,n=0;function i(){for(;r=t.stack.pop();)try{if(!r.async&&n===1)return n=0,t.stack.push(r),Promise.resolve().then(i);if(r.dispose){var s=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(s).then(i,function(a){return e(a),i()})}else n|=1}catch(a){e(a)}if(n===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return i()}function y6e(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,i,s,a){return n?e?".jsx":".js":i&&(!s||!a)?r:i+s+"."+a.toLowerCase()+"js"}):t}var YQ,TO,kO,D_t,JQ,I_t,F_t,at=ce(()=>{YQ=function(t,e){return YQ=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},YQ(t,e)};TO=function(){return TO=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},TO.apply(this,arguments)};kO=Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]});D_t=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},JQ=function(t){return JQ=Object.getOwnPropertyNames||function(e){var r=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[r.length]=n);return r},JQ(t)};I_t=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};F_t={__extends:V3e,__assign:TO,__rest:G3e,__decorate:K3e,__param:Z3e,__esDecorate:X3e,__runInitializers:Y3e,__propKey:J3e,__setFunctionName:Q3e,__metadata:e6e,__awaiter:t6e,__generator:r6e,__createBinding:kO,__exportStar:n6e,__values:CO,__read:QQ,__spread:i6e,__spreadArrays:s6e,__spreadArray:a6e,__await:S_,__asyncGenerator:o6e,__asyncDelegator:c6e,__asyncValues:u6e,__makeTemplateObject:l6e,__importStar:f6e,__importDefault:d6e,__classPrivateFieldGet:h6e,__classPrivateFieldSet:p6e,__classPrivateFieldIn:m6e,__addDisposableResource:g6e,__disposeResources:x6e,__rewriteRelativeImportExtension:y6e}});var tee=L(A_=>{"use strict";var P_t="[object ArrayBuffer]",O0=class t{static isArrayBuffer(e){return Object.prototype.toString.call(e)===P_t}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,r){if(e.constructor===r)return e;if(this.isArrayBuffer(e))return new r(e);if(this.isArrayBufferView(e))return new r(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){let n=t.toUint8Array(e),i=t.toUint8Array(r);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let r;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?r=e[0]:e[e.length-1]instanceof Function?r=e.slice(0,e.length-1):r=e;let n=0;for(let a of r)n+=a.byteLength;let i=new Uint8Array(n),s=0;for(let a of r){let c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}},eee="string",R_t=/^[0-9a-f\s]+$/i,O_t=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,N_t=/^[a-zA-Z0-9-_]+$/,DO=class{static fromString(e){let r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n.buffer}static toString(e){let r=O0.toUint8Array(e),n="";for(let s=0;s<r.length;s++)n+=String.fromCharCode(r[s]);return decodeURIComponent(escape(n))}},Hl=class{static toString(e,r=!1){let n=O0.toArrayBuffer(e),i=new DataView(n),s="";for(let a=0;a<n.byteLength;a+=2){let c=i.getUint16(a,r);s+=String.fromCharCode(c)}return s}static fromString(e,r=!1){let n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),r);return n}},IO=class t{static isHex(e){return typeof e===eee&&R_t.test(e)}static isBase64(e){return typeof e===eee&&O_t.test(e)}static isBase64Url(e){return typeof e===eee&&N_t.test(e)}static ToString(e,r="utf8"){let n=O0.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Hl.toString(n,!0);case"utf16":case"utf16be":return Hl.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,r="utf8"){if(!e)return new ArrayBuffer(0);switch(r.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Hl.fromString(e,!0);case"utf16":case"utf16be":return Hl.fromString(e);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToBase64(e){let r=O0.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(r,"binary");return btoa(n)}else return Buffer.from(r).toString("base64")}static FromBase64(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(r)):new Uint8Array(Buffer.from(r,"base64")).buffer}static FromBase64Url(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64Url(r))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(r.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.FromBinary(e);case"utf8":return DO.fromString(e);case"utf16":case"utf16be":return Hl.fromString(e);case"utf16le":case"usc2":return Hl.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.ToBinary(e);case"utf8":return DO.toString(e);case"utf16":case"utf16be":return Hl.toString(e);case"utf16le":case"usc2":return Hl.toString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromBinary(e){let r=e.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){let r=O0.toUint8Array(e),n="";for(let i=0;i<r.length;i++)n+=String.fromCharCode(r[i]);return n}static ToHex(e){let r=O0.toUint8Array(e),n="",i=r.length;for(let s=0;s<i;s++){let a=r[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isHex(r))throw new TypeError("Argument 'hexString' is not HEX encoded");r.length%2&&(r=`0${r}`);let n=new Uint8Array(r.length/2);for(let i=0;i<r.length;i=i+2){let s=r.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,r=!1){return Hl.toString(e,r)}static FromUtf16String(e,r=!1){return Hl.fromString(e,r)}static Base64Padding(e){let r=4-e.length%4;if(r<4)for(let n=0;n<r;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};IO.DEFAULT_UTF8_ENCODING="utf8";function B_t(t,...e){let r=arguments[0];for(let n=1;n<arguments.length;n++){let i=arguments[n];for(let s in i)r[s]=i[s]}return r}function U_t(...t){let e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),r=new Uint8Array(e),n=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(let s of i)r[n++]=s}),r.buffer}function M_t(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(r[i]!==n[i])return!1;return!0}A_.BufferSourceConverter=O0;A_.Convert=IO;A_.assign=B_t;A_.combine=U_t;A_.isEqual=M_t});var _6e=L(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});function L_t(t){return new Date(t.getTime()+t.getTimezoneOffset()*6e4)}function $_t(t,e,r){var n;return t instanceof Object&&(n=t[e])!==null&&n!==void 0?n:r}function j_t(t,e=0,r=t.byteLength-e,n=!1){let i="";for(let s of new Uint8Array(t,e,r)){let a=s.toString(16).toUpperCase();a.length===1&&(i+="0"),i+=a,n&&(i+=" ")}return i.trim()}function q_t(t,e,r,n){return e instanceof ArrayBuffer?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error='Wrong parameter: inputBuffer must be "ArrayBuffer"',!1)}function ree(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function nee(t,e,r=-1){let n=r,i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let d;if(n<0)d=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);d=new ArrayBuffer(n),s=n}let h=new Uint8Array(d);for(let p=c-1;p>=0;p--){let x=Math.pow(2,p*e);h[s-p-1]=Math.floor(i/x),i-=h[s-p-1]*x}return d}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function z_t(...t){let e=0,r=0;for(let s of t)e+=s.byteLength;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of t)i.set(new Uint8Array(s),r),r+=s.byteLength;return n}function W_t(...t){let e=0,r=0;for(let s of t)e+=s.length;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of t)i.set(s,r),r+=s.length;return i}function H_t(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let c=t[0]===255&&t[1]&128,d=t[0]===0&&(t[1]&128)===0;(c||d)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)r[c]=0;r[0]=t[0]&128;let n=ree(r,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,ree(s,8)-n}function V_t(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let a=r-e,c=nee(a,8,n),d=new Uint8Array(c);return d[0]|=128,c}let i=nee(e,8,n),s=new Uint8Array(i);if(s[0]&128){let a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let d=0;d<a.byteLength;d++)s[d+1]=c[d];s[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function G_t(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}function K_t(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(r)}var v6e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b6e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function Z_t(t,e=!1,r=!1,n=!1){let i=0,s=0,a=0,c="",d=e?b6e:v6e;if(n){let h=0;for(let p=0;p<t.length;p++)if(t.charCodeAt(p)!==0){h=p;break}t=t.slice(h)}for(;i<t.length;){let h=t.charCodeAt(i++);i>=t.length&&(s=1);let p=t.charCodeAt(i++);i>=t.length&&(a=1);let x=t.charCodeAt(i++),y=h>>2,v=(h&3)<<4|p>>4,w=(p&15)<<2|x>>6,S=x&63;s===1?w=S=64:a===1&&(S=64),r?w===64?c+=`${d.charAt(y)}${d.charAt(v)}`:S===64?c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}`:c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}${d.charAt(S)}`:c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}${d.charAt(S)}`}return c}function X_t(t,e=!1,r=!1){let n=e?b6e:v6e;function i(d){for(let h=0;h<64;h++)if(n.charAt(h)===d)return h;return 64}function s(d){return d===64?0:d}let a=0,c="";for(;a<t.length;){let d=i(t.charAt(a++)),h=a>=t.length?0:i(t.charAt(a++)),p=a>=t.length?0:i(t.charAt(a++)),x=a>=t.length?0:i(t.charAt(a++)),y=s(d)<<2|s(h)>>4,v=(s(h)&15)<<4|s(p)>>2,w=(s(p)&3)<<6|s(x);c+=String.fromCharCode(y),p!==64&&(c+=String.fromCharCode(v)),x!==64&&(c+=String.fromCharCode(w))}if(r){let d=c.length,h=-1;for(let p=d-1;p>=0;p--)if(c.charCodeAt(p)!==0){h=p;break}h!==-1?c=c.slice(0,h+1):c=""}return c}function Y_t(t){let e="",r=new Uint8Array(t);for(let n of r)e+=String.fromCharCode(n);return e}function J_t(t){let e=t.length,r=new ArrayBuffer(e),n=new Uint8Array(r);for(let i=0;i<e;i++)n[i]=t.charCodeAt(i);return r}var Q_t=Math.log(2);function ewt(t){let e=Math.log(t)/Q_t,r=Math.floor(e),n=Math.round(e);return r===n?r:n}function twt(t,e){for(let r of e)delete t[r]}Fa.arrayBufferToString=Y_t;Fa.bufferToHexCodes=j_t;Fa.checkBufferParams=q_t;Fa.clearProps=twt;Fa.fromBase64=X_t;Fa.getParametersValue=$_t;Fa.getUTCDate=L_t;Fa.isEqualBuffer=G_t;Fa.nearestPowerOf2=ewt;Fa.padNumber=K_t;Fa.stringToArrayBuffer=J_t;Fa.toBase64=Z_t;Fa.utilConcatBuf=z_t;Fa.utilConcatView=W_t;Fa.utilDecodeTC=H_t;Fa.utilEncodeTC=V_t;Fa.utilFromBase=ree;Fa.utilToBase=nee});var Gm=L(un=>{"use strict";var rwt=tee(),nwt=_6e();function E6e(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var Zn=E6e(rwt),Hi=E6e(nwt);function FO(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function aee(t){let e=0,r=0;for(let i=0;i<t.length;i++){let s=t[i];e+=s.byteLength}let n=new Uint8Array(e);for(let i=0;i<t.length;i++){let s=t[i];n.set(new Uint8Array(s),r),r+=s.byteLength}return n.buffer}function U0(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var T_=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return aee(this.items)}},Pk=[new Uint8Array([1])],w6e="0123456789",iee="name",S6e="valueHexView",iwt="isHexOnly",swt="idBlock",awt="tagClass",owt="tagNumber",cwt="isConstructed",uwt="fromBER",lwt="toBER",fwt="local",yu="",th=new ArrayBuffer(0),GO=new Uint8Array(0),Ok="EndOfContent",T6e="OCTET STRING",C6e="BIT STRING";function rh(t){var e;return e=class extends t{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var i;super(...n);let s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?Zn.BufferSourceConverter.toUint8Array(s.valueHex):GO}fromBER(n,i,s,a){let c=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!U0(this,c,i,s))return-1;let d=i+s;return this.valueHexView=c.subarray(i,d),this.valueHexView.length?(this.blockLength=s,d):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",th)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Zn.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var N0=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:r=yu,warnings:n=[],valueBeforeDecode:i=GO}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=Zn.BufferSourceConverter.toUint8Array(i)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Zn.Convert.ToHex(this.valueBeforeDecodeView)}}};N0.NAME="baseBlock";var lo=class extends N0{fromBER(e,r,n,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};lo.NAME="valueBlock";var PO=class extends rh(N0){constructor({idBlock:e={}}={}){var r,n,i,s;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?Zn.BufferSourceConverter.toUint8Array(e.valueHex):GO,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",th}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,r|=s,i[0]=r}return i.buffer}if(!this.isHexOnly){let i=Hi.utilToBase(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=r|31,!e){for(let d=0;d<a-1;d++)c[d+1]=s[d]|128;c[a]=s[a-1]}return c.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=r|31,!e){let i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;let c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let d=0;for(;;){let p=d+1;if(p>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(d++,(s[p]&128)===0)break}this.blockLength=d+1;let h=this.valueHexView=new Uint8Array(d);for(let p=0;p<d;p++)h[p]=s[p+1]&127;this.blockLength<=9?this.tagNumber=Hi.utilFromBase(h,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};PO.NAME="identificationBlock";var RO=class extends N0{constructor({lenBlock:e={}}={}){var r,n,i;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,r+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,r+this.blockLength;let a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let c=r+1,d=i.subarray(c,c+a);return d[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Hi.utilFromBase(d,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let i=Hi.utilToBase(this.length,8);if(i.byteLength>127)return this.error="Too big length",th;if(r=new ArrayBuffer(i.byteLength+1),e)return r;let s=new Uint8Array(i);n=new Uint8Array(r),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};RO.NAME="lengthBlock";var xr={},Wa=class extends N0{constructor({name:e=yu,optional:r=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new PO(i),this.lenBlock=new RO(i),this.valueBlock=s?new s(i):new lo(i)}fromBER(e,r,n,i){let s=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,i);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,r){let n=r||new T_;r||k6e(this);let i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return r?th:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Zn.Convert.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,r=Zn.Convert.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${r}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let r=this.toBER(),n=e.toBER();return Hi.isEqualBuffer(r,n)}};Wa.NAME="BaseBlock";function k6e(t){var e;if(t instanceof xr.Constructed)for(let r of t.valueBlock.value)k6e(r)&&(t.lenBlock.isIndefiniteForm=!0);return!!(!((e=t.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}var Nk=class extends Wa{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=yu,...r}={},n){super(r,n),e&&this.fromString(e)}fromBER(e,r,n){let i=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Nk.NAME="BaseStringBlock";var OO=class extends rh(lo){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};OO.NAME="PrimitiveValueBlock";var D6e,Bk=class extends Wa{constructor(e={}){super(e,OO),this.idBlock.isConstructed=!1}};D6e=Bk;xr.Primitive=D6e;Bk.NAME="PRIMITIVE";var I6e=100,F6e=1e4,P6e=16*1024*1024,dwt="Maximum ASN.1 nesting depth exceeded",hwt="Maximum ASN.1 node count exceeded",pwt="Maximum ASN.1 content length exceeded";function h4(t={}){var e,r,n;return{depth:0,maxDepth:(e=t.maxDepth)!==null&&e!==void 0?e:I6e,nodesCount:0,maxNodes:(r=t.maxNodes)!==null&&r!==void 0?r:F6e,maxContentLength:(n=t.maxContentLength)!==null&&n!==void 0?n:P6e}}function mwt(t){let e=new Wa({},lo);return e.error=t,{offset:-1,result:e}}function gwt(t){if(t.nodesCount+=1,t.nodesCount>t.maxNodes)return hwt}function xwt(t,e){if(t>e.maxContentLength)return pwt}function oee(t,e,r,n){let i=n.depth+1;if(i>n.maxDepth)return mwt(dwt);n.depth=i;try{return KO(t,e,r,n)}finally{n.depth-=1}}function ywt(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function KO(t,e=0,r=t.length,n=h4()){let i=e,s=new Wa({},lo),a=new N0;if(!U0(a,t,e,r))return s.error=a.error,{offset:-1,result:s};if(!t.subarray(e,e+r).length)return s.error="Zero buffer length",{offset:-1,result:s};let d=gwt(n);if(d)return s.error=d,{offset:-1,result:s};let h=s.idBlock.fromBER(t,e,r);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),h===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=h,r-=s.idBlock.blockLength,h=s.lenBlock.fromBER(t,e,r),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),h===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};e=h,r-=s.lenBlock.blockLength;let p=s.lenBlock.isIndefiniteForm?r:s.lenBlock.length,x=xwt(p,n);if(x)return s.error=x,{offset:-1,result:s};if(!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let y=Wa;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};y=xr.EndOfContent;break;case 1:y=xr.Boolean;break;case 2:y=xr.Integer;break;case 3:y=xr.BitString;break;case 4:y=xr.OctetString;break;case 5:y=xr.Null;break;case 6:y=xr.ObjectIdentifier;break;case 10:y=xr.Enumerated;break;case 12:y=xr.Utf8String;break;case 13:y=xr.RelativeObjectIdentifier;break;case 14:y=xr.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:y=xr.Sequence;break;case 17:y=xr.Set;break;case 18:y=xr.NumericString;break;case 19:y=xr.PrintableString;break;case 20:y=xr.TeletexString;break;case 21:y=xr.VideotexString;break;case 22:y=xr.IA5String;break;case 23:y=xr.UTCTime;break;case 24:y=xr.GeneralizedTime;break;case 25:y=xr.GraphicString;break;case 26:y=xr.VisibleString;break;case 27:y=xr.GeneralString;break;case 28:y=xr.UniversalString;break;case 29:y=xr.CharacterString;break;case 30:y=xr.BmpString;break;case 31:y=xr.DATE;break;case 32:y=xr.TimeOfDay;break;case 33:y=xr.DateTime;break;case 34:y=xr.Duration;break;default:{let v=s.idBlock.isConstructed?new xr.Constructed:new xr.Primitive;v.idBlock=s.idBlock,v.lenBlock=s.lenBlock,v.warnings=s.warnings,s=v}}break;default:y=s.idBlock.isConstructed?xr.Constructed:xr.Primitive}return s=ywt(s,y),h=s.fromBER(t,e,p,n),s.valueBeforeDecodeView=t.subarray(i,i+s.blockLength),{offset:h,result:s}}function vwt(t,e={}){if(!t.byteLength){let r=new Wa({},lo);return r.error="Input buffer has zero length",{offset:-1,result:r}}return KO(Zn.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength,h4(e))}function bwt(t,e){return t?1:e}var Qd=class extends lo{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n,i){let s=Zn.BufferSourceConverter.toUint8Array(e),a=i??h4();if(!U0(this,s,r,n))return-1;if(this.valueBeforeDecodeView=s.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let c=r;for(;bwt(this.isIndefiniteForm,n)>0;){let d=oee(s,c,n,a);if(d.offset===-1)return this.error=d.result.error,this.warnings.concat(d.result.warnings),-1;if(c=d.offset,this.blockLength+=d.result.blockLength,n-=d.result.blockLength,this.value.push(d.result),this.isIndefiniteForm&&d.result.constructor.NAME===Ok)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Ok?this.value.pop():this.warnings.push("No EndOfContent block encoded")),c}toBER(e,r){let n=r||new T_;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return r?th:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};Qd.NAME="ConstructedValueBlock";var R6e,B0=class extends Wa{constructor(e={}){super(e,Qd),this.idBlock.isConstructed=!0}fromBER(e,r,n,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,i);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
1003
+ `,e}toBuffer(){return Buffer.from(this.toString(),"utf8")}valueOf(){return this.body}toJSON(){return{type:this.type,body:this.body,headers:this.headers}}[I3e.inspect.custom](e,r){return`<${this.constructor.name} ${I3e.inspect(this.toJSON(),r)}>`}};qQ.PEM=bO;function i_t(t){let e=t.shift();if(e==null||!e.startsWith($Q)||!e.endsWith(kk))throw new Error("pem: invalid BEGIN line");let r=e.slice($Q.length,e.length-kk.length);if(r==="")throw new Error("pem: invalid type");let n=[];for(e=t.shift();e!=null&&e.includes(": ");){let a=e.split(": ");if(a.length!==2||a[0]===""||a[1]==="")throw new Error("pem: invalid Header line");n.push(a),e=t.shift()}let i="";for(;e!=null&&!e.startsWith(jQ);)i+=e,e=t.shift();if(e==null||e!==`${jQ}${r}${kk}`)throw new Error("pem: invalid END line");let s=new bO(r,Buffer.from(i,"base64"));if(i===""||s.body.toString("base64")!==i)throw new Error("pem: invalid base64 body");for(let a of n)s.setHeader(a[0],a[1]);return s}});var B3e=L(zm=>{"use strict";Object.defineProperty(zm,"__esModule",{value:!0});var R3e=Kr("util"),_O=MQ(),ca;(function(t){t[t.UNIVERSAL=0]="UNIVERSAL",t[t.APPLICATION=64]="APPLICATION",t[t.CONTEXT_SPECIFIC=128]="CONTEXT_SPECIFIC",t[t.PRIVATE=192]="PRIVATE"})(ca=zm.Class||(zm.Class={}));var jn;(function(t){t[t.NONE=0]="NONE",t[t.BOOLEAN=1]="BOOLEAN",t[t.INTEGER=2]="INTEGER",t[t.BITSTRING=3]="BITSTRING",t[t.OCTETSTRING=4]="OCTETSTRING",t[t.NULL=5]="NULL",t[t.OID=6]="OID",t[t.ENUMERATED=10]="ENUMERATED",t[t.UTF8=12]="UTF8",t[t.SEQUENCE=16]="SEQUENCE",t[t.SET=17]="SET",t[t.NUMERICSTRING=18]="NUMERICSTRING",t[t.PRINTABLESTRING=19]="PRINTABLESTRING",t[t.T61STRING=20]="T61STRING",t[t.IA5STRING=22]="IA5STRING",t[t.UTCTIME=23]="UTCTIME",t[t.GENERALIZEDTIME=24]="GENERALIZEDTIME",t[t.GENERALSTRING=27]="GENERALSTRING"})(jn=zm.Tag||(zm.Tag={}));var Dk=class{constructor(e,r){this.buf=e,this.bitLen=r}at(e){if(e<0||e>=this.bitLen||!Number.isInteger(e))return 0;let r=Math.floor(e/8),n=7-e%8;return this.buf[r]>>n&1}rightAlign(){let e=8-this.bitLen%8;if(e===8||this.buf.length===0)return this.buf;let r=Buffer.alloc(this.buf.length);r[0]=this.buf[0]>>e;for(let n=1;n<this.buf.length;n++)r[n]=this.buf[n-1]<<8-e,r[n]|=this.buf[n]>>e;return r}};zm.BitString=Dk;var zQ=class t{static Bool(e){let r=new t(ca.UNIVERSAL,jn.BOOLEAN,Buffer.from([e?255:0]));return r._value=e,r}static parseBool(e){if(!(e instanceof Buffer)||e.length!==1)throw new Error("ASN1 syntax error: invalid boolean");switch(e[0]){case 0:return!1;case 255:return!0;default:throw new Error("ASN1 syntax error: invalid boolean")}}static Integer(e){if(e instanceof Buffer){let i=new t(ca.UNIVERSAL,jn.INTEGER,e);return i._value=e.toString("hex"),i}if(!Number.isSafeInteger(e))throw new Error("ASN1 syntax error: invalid integer");let r;if(e>=-128&&e<128)r=Buffer.alloc(1),r.writeInt8(e,0);else if(e>=-32768&&e<32768)r=Buffer.alloc(2),r.writeIntBE(e,0,2);else if(e>=-8388608&&e<8388608)r=Buffer.alloc(3),r.writeIntBE(e,0,3);else if(e>=-2147483648&&e<2147483648)r=Buffer.alloc(4),r.writeIntBE(e,0,4);else if(e>=-549755813888&&e<549755813888)r=Buffer.alloc(5),r.writeIntBE(e,0,5);else if(e>=-0x800000000000&&e<0x800000000000)r=Buffer.alloc(6),r.writeIntBE(e,0,6);else throw new Error("ASN1 syntax error: invalid Integer");let n=new t(ca.UNIVERSAL,jn.INTEGER,r);return n._value=e,n}static parseInteger(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Integer");return e.length>6?e.toString("hex"):e.readIntBE(0,e.length)}static parseIntegerNum(e){let r=t.parseInteger(e);if(typeof r!="number")throw new Error("ASN1 syntax error: invalid Integer number");return r}static parseIntegerStr(e){let r=t.parseInteger(e);return typeof r=="number"?r.toString(16):r}static BitString(e){e instanceof Buffer&&(e=new Dk(e,e.length*8));let r=e.buf.length*8-e.bitLen,n=Buffer.alloc(e.buf.length+1);return n.writeInt8(r,0),e.buf.copy(n,1),new t(ca.UNIVERSAL,jn.BITSTRING,n)}static parseBitString(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid BitString");let r=e[0];if(r>7||e.length===1&&r>0||(e[e.length-1]&(1<<e[0])-1)!==0)throw new Error("ASN1 syntax error: invalid padding bits in BIT STRING");return new Dk(e.slice(1),(e.length-1)*8-r)}static Null(){let e=new t(ca.UNIVERSAL,jn.NULL,Buffer.alloc(0));return e._value=null,e}static parseNull(e){if(!(e instanceof Buffer)||e.length!==0)throw new Error("ASN1 syntax error: invalid null");return null}static OID(e){let r=e.split(".");if(r.length===0)throw new Error("ASN1 syntax error: invalid Object Identifier");let n=[];n.push(40*qa(r[0])+qa(r[1]));let i=[];for(let a=2;a<r.length;++a){let c=qa(r[a]);for(i.length=0,i.push(c&127);c>127;)c=c>>>7,i.unshift(c&127|128);n.push(...i)}let s=new t(ca.UNIVERSAL,jn.OID,Buffer.from(n));return s._value=e,s}static parseOID(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid OID");let r=Math.floor(e[0]/40)+"."+e[0]%40,n=0;for(let i=1;i<e.length;i++)e[i]>=128?(n+=e[i]&127,n=n<<7):(r+="."+(n+e[i]),n=0);return r}static UTF8(e){let r=new t(ca.UNIVERSAL,jn.UTF8,Buffer.from(e,"utf8"));return r._value=e,r}static parseUTF8(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static NumericString(e){if(!O3e(e))throw new Error("ASN1 syntax error: invalid NumericString");let r=new t(ca.UNIVERSAL,jn.NUMERICSTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseNumericString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");let r=e.toString("utf8");if(!O3e(r))throw new Error("ASN1 syntax error: invalid NumericString");return r}static PrintableString(e){let r=new t(ca.UNIVERSAL,jn.PRINTABLESTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parsePrintableString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static IA5String(e){if(!N3e(e))throw new Error("ASN1 syntax error: invalid IA5String");let r=new t(ca.UNIVERSAL,jn.IA5STRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseIA5String(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");let r=e.toString("utf8");if(!N3e(r))throw new Error("ASN1 syntax error: invalid IA5String");return r}static T61String(e){let r=new t(ca.UNIVERSAL,jn.T61STRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseT61String(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static GeneralString(e){let r=new t(ca.UNIVERSAL,jn.GENERALSTRING,Buffer.from(e,"utf8"));return r._value=e,r}static parseGeneralString(e){if(!(e instanceof Buffer))throw new Error("parse ASN1 error: invalid Buffer");return e.toString("utf8")}static UTCTime(e){let r="",n=[];n.push((""+e.getUTCFullYear()).substr(2)),n.push(""+(e.getUTCMonth()+1)),n.push(""+e.getUTCDate()),n.push(""+e.getUTCHours()),n.push(""+e.getUTCMinutes()),n.push(""+e.getUTCSeconds());for(let s of n)s.length<2&&(r+="0"),r+=s;r+="Z";let i=new t(ca.UNIVERSAL,jn.UTCTIME,Buffer.from(r,"utf8"));return i._value=e,i}static parseUTCTime(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid UTC Time");let r=e.toString("utf8"),n=new Date,i=qa(r.substr(0,2));i=i>=50?1900+i:2e3+i;let s=qa(r.substr(2,2))-1,a=qa(r.substr(4,2)),c=qa(r.substr(6,2)),d=qa(r.substr(8,2)),h=0,p=0,x="";if(r.length>11&&(p=10,x=r.charAt(p),x!=="+"&&x!=="-"&&(h=qa(r.substr(10,2)),p+=2)),n.setUTCFullYear(i,s,a),n.setUTCHours(c,d,h,0),p>0&&(x=r.charAt(p),x==="+"||x==="-")){let y=qa(r.substr(p+1,2)),v=qa(r.substr(p+4,2)),w=y*60+v;w*=6e4,x==="+"?n.setTime(+n-w):n.setTime(+n+w)}return n}static GeneralizedTime(e){let r="",n=[];n.push(""+e.getUTCFullYear()),n.push(""+(e.getUTCMonth()+1)),n.push(""+e.getUTCDate()),n.push(""+e.getUTCHours()),n.push(""+e.getUTCMinutes()),n.push(""+e.getUTCSeconds());for(let s of n)s.length<2&&(r+="0"),r+=s;r+="Z";let i=new t(ca.UNIVERSAL,jn.GENERALIZEDTIME,Buffer.from(r,"utf8"));return i._value=e,i}static parseGeneralizedTime(e){if(!(e instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Generalized Time");let r=e.toString("utf8"),n=new Date,i=qa(r.substr(0,4)),s=qa(r.substr(4,2))-1,a=qa(r.substr(6,2)),c=qa(r.substr(8,2)),d=qa(r.substr(10,2)),h=qa(r.substr(12,2)),p=0,x=0,y=!1;r.charAt(r.length-1)==="Z"&&(y=!0);let v=r.length-5,w=r.charAt(v);if(w==="+"||w==="-"){let S=qa(r.substr(v+1,2)),C=qa(r.substr(v+4,2));x=S*60+C,x*=6e4,w==="+"&&(x*=-1),y=!0}return r.charAt(14)==="."&&(p=parseFloat(r.substr(14))*1e3),y?(n.setUTCFullYear(i,s,a),n.setUTCHours(c,d,h,p),n.setTime(+n+x)):(n.setFullYear(i,s,a),n.setHours(c,d,h,p)),n}static parseTime(e,r){switch(e){case jn.UTCTIME:return t.parseUTCTime(r);case jn.GENERALIZEDTIME:return t.parseGeneralizedTime(r);default:throw new Error("Invalid ASN1 time tag")}}static Set(e){let r=new t(ca.UNIVERSAL,jn.SET,Buffer.concat(e.map(n=>n.toDER())));return r._value=e,r}static Seq(e){let r=new t(ca.UNIVERSAL,jn.SEQUENCE,Buffer.concat(e.map(n=>n.toDER())));return r._value=e,r}static Spec(e,r,n=!0){let i=Array.isArray(r)?Buffer.concat(r.map(a=>a.toDER())):r.toDER();Array.isArray(r)&&(n=!0);let s=new t(ca.CONTEXT_SPECIFIC,e,i,n);return s._value=r,s}static fromDER(e,r=!1){return t._fromDER(new _O.BufferVisitor(e),r)}static parseDER(e,r,n){let i=t._fromDER(new _O.BufferVisitor(e),!1);if(i.class!==r&&i.tag!==n)throw new Error(`invalid ASN.1 DER for class ${r} and tag ${n}`);return i}static parseDERWithTemplate(e,r){let n=t._fromDER(new _O.BufferVisitor(e),!0),i={},s=n.validate(r,i);if(s!=null)throw s.data=n,s;return i}static _parseCompound(e,r){let n=[],i=e.length,s=new _O.BufferVisitor(e),a=0;for(;a<i;){let c=s.end;n.push(t._fromDER(s,r)),a+=s.end-c}return n}static _fromDER(e,r){if(!(e.buf instanceof Buffer)||e.length===0)throw new Error("ASN1 syntax error: invalid Generalized Time");e.mustWalk(1,"Too few bytes to read ASN.1 tag.");let n=e.start,i=e.buf[n],s=i&192,a=i&31,c=s_t(e);if(e.mustHas(c),c!==0&&a===jn.NULL)throw new Error("invalid value length or NULL tag.");e.mustWalk(c);let d=(i&32)===32,h=new t(s,a,e.buf.slice(e.start,e.end),d);return d&&r&&(h._value=t._parseCompound(h.bytes,r)),h._der=e.buf.slice(n,e.end),h}constructor(e,r,n,i=!1){this.class=e,this.tag=r,this.bytes=n,this.isCompound=i||r===jn.SEQUENCE||r===jn.SET,this._value=void 0,this._der=null}get value(){return this._value===void 0&&(this._value=this.valueOf()),this._value}get DER(){return this._der==null&&(this._der=this.toDER()),this._der}mustCompound(e="asn1 object value is not compound"){if(!this.isCompound||!Array.isArray(this.value)){let r=new Error(e);throw r.data=this.toJSON(),r}return this.value}equals(e){return!(!(e instanceof t)||this.class!==e.class||this.tag!==e.tag||this.isCompound!==e.isCompound||!this.bytes.equals(e.bytes))}toDER(){let e=this.class|this.tag;this.isCompound&&(e|=32);let r=a_t(this.bytes.length),n=Buffer.allocUnsafe(2+r+this.bytes.length);return n.writeInt8(e,0),r===0?(n.writeUInt8(this.bytes.length,1),this.bytes.copy(n,2)):(n.writeUInt8(r|128,1),n.writeUIntBE(this.bytes.length,2,r),this.bytes.copy(n,2+r)),n}valueOf(){if(this.isCompound)return t._parseCompound(this.bytes,!1);if(this.class!==ca.UNIVERSAL)return this.bytes;switch(this.tag){case jn.BOOLEAN:return t.parseBool(this.bytes);case jn.INTEGER:return t.parseInteger(this.bytes);case jn.BITSTRING:return t.parseBitString(this.bytes);case jn.NULL:return t.parseNull(this.bytes);case jn.OID:return t.parseOID(this.bytes);case jn.UTF8:return t.parseUTF8(this.bytes);case jn.NUMERICSTRING:return t.parseNumericString(this.bytes);case jn.PRINTABLESTRING:return t.parsePrintableString(this.bytes);case jn.T61STRING:return t.parseT61String(this.bytes);case jn.IA5STRING:return t.parseIA5String(this.bytes);case jn.GENERALSTRING:return t.parseGeneralString(this.bytes);case jn.UTCTIME:return t.parseUTCTime(this.bytes);case jn.GENERALIZEDTIME:return t.parseGeneralizedTime(this.bytes);default:return this.bytes}}validate(e,r={}){if(this.class!==e.class)return new Error(`ASN.1 object validate failure for ${e.name} : error class ${ca[this.class]}`);if(!(Array.isArray(e.tag)?e.tag:[e.tag]).includes(this.tag))return new Error(`ASN.1 object validate failure for ${e.name}: error tag ${jn[this.tag]}`);if(e.capture!=null&&(r[e.capture]=this),Array.isArray(e.value)){let i=this.mustCompound(`${e.name} need compound ASN1 value`);for(let s=0,a=0;s<e.value.length;s++)if(i[a]!=null){let c=i[a].validate(e.value[s],r);if(c==null)a++;else if(e.value[s].optional!==!0)return c}else if(e.value[s].optional!==!0)return new Error(`ASN.1 object validate failure for ${e.value[s].name}: not exists`)}else if(e.value!=null){let i=this.tag===jn.BITSTRING?this.bytes.slice(1):this.bytes;return t.fromDER(i).validate(e.value,r)}return null}toJSON(){let e=this.value;return Array.isArray(e)&&(e=e.map(r=>r.toJSON())),{class:ca[this.class],tag:this.class===ca.UNIVERSAL?jn[this.tag]:this.tag,value:e}}[R3e.inspect.custom](e,r){return r.depth<=2&&(r.depth=10),`<${this.constructor.name} ${R3e.inspect(this.toJSON(),r)}>`}};zm.ASN1=zQ;function s_t(t){t.mustWalk(1,"Too few bytes to read ASN.1 value length.");let e=t.buf[t.start];if((e&128)===0)return e;let r=e&127;return t.mustWalk(r,"Too few bytes to read ASN.1 value length."),t.buf.readUIntBE(t.start,r)}function a_t(t){if(t<=127)return 0;if(t<=255)return 1;if(t<=65535)return 2;if(t<=16777215)return 3;if(t<=4294967295)return 4;if(t<=0xffffffffff)return 5;if(t<=0xffffffffffff)return 6;throw new Error("invalid value length")}function O3e(t){for(let e of t){let r=e.charCodeAt(0);if(r!==32&&(r<48||r>57))return!1}return!0}function N3e(t){for(let e of t)if(e.charCodeAt(0)>=128)return!1;return!0}function qa(t,e=10){let r=parseInt(t,e);if(Number.isNaN(r))throw new Error(`Invalid numeric string "${t}" in radix ${e}.`);return r}});var WQ=L(Wm=>{"use strict";Object.defineProperty(Wm,"__esModule",{value:!0});var o_t=MQ();Wm.BufferVisitor=o_t.BufferVisitor;var c_t=P3e();Wm.PEM=c_t.PEM;var wO=B3e();Wm.ASN1=wO.ASN1;Wm.Class=wO.Class;Wm.Tag=wO.Tag;Wm.BitString=wO.BitString});var KQ=L(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});var Vm=Kr("util"),Ik=Kr("crypto"),GQ=vO(),zt=WQ(),dc=xO();Jd.publicKeyValidator={name:"PublicKeyInfo",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,capture:"publicKeyInfo",value:[{name:"PublicKeyInfo.AlgorithmIdentifier",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"PublicKeyAlgorithmIdentifier.algorithm",class:zt.Class.UNIVERSAL,tag:zt.Tag.OID,capture:"publicKeyOID"}]},{name:"PublicKeyInfo.PublicKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.BITSTRING,capture:"publicKey"}]};Jd.privateKeyValidator={name:"PrivateKeyInfo",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,capture:"privateKeyInfo",value:[{name:"PrivateKeyInfo.Version",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.AlgorithmIdentifier",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"PrivateKeyAlgorithmIdentifier.algorithm",class:zt.Class.UNIVERSAL,tag:zt.Tag.OID,capture:"privateKeyOID"}]},{name:"PrivateKeyInfo.PrivateKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.OCTETSTRING,capture:"privateKey"}]};var u_t={name:"RSAPublicKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"RSAPublicKey.modulus",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"publicKeyExponent"}]},l_t={name:"RSAPrivateKey",class:zt.Class.UNIVERSAL,tag:zt.Tag.SEQUENCE,value:[{name:"RSAPrivateKey.version",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",class:zt.Class.UNIVERSAL,tag:zt.Tag.INTEGER,capture:"privateKeyCoefficient"}]},f_t=[dc.getOID("X25519"),dc.getOID("X448"),dc.getOID("Ed25519"),dc.getOID("Ed448")],__=class t{constructor(e){let r={},n=e.validate(Jd.publicKeyValidator,r);if(n!=null)throw new Error("Cannot read X.509 public key: "+n.message);this.oid=zt.ASN1.parseOID(r.publicKeyOID.bytes),this.algo=dc.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=zt.ASN1.parseBitString(r.publicKey.bytes).buf,this._finalKey=this._keyRaw,this._finalPEM=""}static fromPEM(e){let r=zt.PEM.parse(e)[0];if(r.procType.includes("ENCRYPTED"))throw new Error("Could not convert public key from PEM, PEM is encrypted.");let n=zt.ASN1.fromDER(r.body,!0);switch(r.type){case"PUBLIC KEY":return new t(n);case"RSA PUBLIC KEY":let i=zt.ASN1.Seq([zt.ASN1.Seq([zt.ASN1.OID(dc.getOID("rsaEncryption")),zt.ASN1.Null()]),zt.ASN1.BitString(n.DER)]);return new t(i);default:throw new Error("Could not convert public key from PEM, recommend PKCS#8 PEM")}}static addVerifier(e,r){if(e=dc.getOID(e),e==="")throw new Error(`Invalid object identifier: ${e}`);if(t._verifiers[e]!=null)throw new Error(`Verifier ${e} exists`);t._verifiers[e]=r}get keyRaw(){return this._finalKey}verify(e,r,n){let i=t._verifiers[this.oid];if(i!=null){let a=Ik.createHash(n).update(e).digest();return i.call(this,a,r)}let s=Ik.createVerify(n);return s.update(e),s.verify(this.toPEM(),r)}getFingerprint(e,r="PublicKey"){let n;switch(r){case"PublicKeyInfo":n=this._pkcs8.DER;break;case"PublicKey":n=this._keyRaw;break;default:throw new Error(`Unknown fingerprint type "${r}".`)}let i=Ik.createHash(e);return i.update(n),i.digest()}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("PUBLIC KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{oid:this.oid,algo:this.algo,publicKey:this._keyRaw}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};__._verifiers=Object.create(null);Jd.PublicKey=__;var w_=class t{constructor(e){let r=Object.create(null),n=e.validate(Jd.privateKeyValidator,r);if(n!=null)throw new Error("Cannot read X.509 private key: "+n.message);if(this.version=zt.ASN1.parseIntegerNum(r.privateKeyVersion.bytes)+1,this.oid=zt.ASN1.parseOID(r.privateKeyOID.bytes),this.algo=dc.getOIDName(this.oid),this._pkcs8=e,this._keyRaw=r.privateKey.bytes,this._publicKeyRaw=null,this._finalKey=this._keyRaw,this._finalPEM="",f_t.includes(this.oid)){if(this._finalKey=this._keyRaw=zt.ASN1.parseDER(this._keyRaw,zt.Class.UNIVERSAL,zt.Tag.OCTETSTRING).bytes,this.oid==="1.3.101.112"){let i=GQ.sign.keyPair.fromSeed(this._keyRaw);this._publicKeyRaw=Buffer.from(i.publicKey),this._finalKey=Buffer.from(i.secretKey)}else if(this.version===2)for(let i of e.mustCompound())i.class===zt.Class.CONTEXT_SPECIFIC&&i.tag===1&&(this._publicKeyRaw=zt.ASN1.parseBitString(i.bytes).buf,this._finalKey=Buffer.concat([this._keyRaw,this._publicKeyRaw]))}}static fromPEM(e){let r=zt.PEM.parse(e)[0];if(r.procType.includes("ENCRYPTED"))throw new Error("Could not convert private key from PEM, PEM is encrypted.");let n=zt.ASN1.fromDER(r.body,!0);switch(r.type){case"PRIVATE KEY":return new t(n);case"RSA PRIVATE KEY":return n=zt.ASN1.Seq([n.value[0],zt.ASN1.Seq([zt.ASN1.OID(dc.getOID("rsaEncryption")),zt.ASN1.Null()]),new zt.ASN1(zt.Class.UNIVERSAL,zt.Tag.OCTETSTRING,n.DER)]),new t(n);default:throw new Error("Could not convert private key from PEM, recommend PKCS#8 PEM")}}static addSigner(e,r){if(e=dc.getOID(e),e==="")throw new Error(`Invalid object identifier: ${e}`);if(t._signers[e]!=null)throw new Error(`Signer ${e} exists`);t._signers[e]=r}get keyRaw(){return this._finalKey}get publicKeyRaw(){return this._publicKeyRaw}sign(e,r){let n=t._signers[this.oid];if(n!=null){let s=Ik.createHash(r).update(e).digest();return n.call(this,s)}let i=Ik.createSign(r);return i.update(e),i.sign(this.toPEM())}toASN1(){return this._pkcs8}toDER(){return this._pkcs8.DER}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("PRIVATE KEY",this._pkcs8.DER).toString()),this._finalPEM}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,privateKey:this._keyRaw,publicKey:this._publicKeyRaw}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};w_._signers=Object.create(null);Jd.PrivateKey=w_;var HQ=class t extends __{static fromPublicKey(e){return new t(e.toASN1())}constructor(e){if(super(e),dc.getOID(this.oid)!==dc.getOID("rsaEncryption"))throw new Error(`Invalid RSA public key, unknown OID: ${this.oid}`);let r=Object.create(null);this._pkcs1=zt.ASN1.fromDER(this._keyRaw,!0);let n=this._pkcs1.validate(u_t,r);if(n!=null)throw new Error("Cannot read RSA public key: "+n.message);this.modulus=zt.ASN1.parseIntegerStr(r.publicKeyModulus.bytes),this.exponent=zt.ASN1.parseIntegerNum(r.publicKeyExponent.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("RSA PUBLIC KEY",this._keyRaw).toString()),this._finalPEM}toPublicKeyPEM(){return new zt.PEM("PUBLIC KEY",this._pkcs8.DER).toString()}toJSON(){return{oid:this.oid,algo:this.algo,modulus:Hm(this.modulus),exponent:this.exponent}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};Jd.RSAPublicKey=HQ;var VQ=class t extends w_{static fromPrivateKey(e){return new t(e.toASN1())}constructor(e){if(super(e),dc.getOID(this.oid)!==dc.getOID("rsaEncryption"))throw new Error(`Invalid RSA private key, unknown OID: ${this.oid}`);let r=Object.create(null);this._pkcs1=zt.ASN1.fromDER(this._keyRaw,!0);let n=this._pkcs1.validate(l_t,r);if(n!=null)throw new Error("Cannot read RSA private key: "+n.message);this.publicExponent=zt.ASN1.parseIntegerNum(r.privateKeyPublicExponent.bytes),this.privateExponent=zt.ASN1.parseIntegerStr(r.privateKeyPrivateExponent.bytes),this.modulus=zt.ASN1.parseIntegerStr(r.privateKeyModulus.bytes),this.prime1=zt.ASN1.parseIntegerStr(r.privateKeyPrime1.bytes),this.prime2=zt.ASN1.parseIntegerStr(r.privateKeyPrime2.bytes),this.exponent1=zt.ASN1.parseIntegerStr(r.privateKeyExponent1.bytes),this.exponent2=zt.ASN1.parseIntegerStr(r.privateKeyExponent2.bytes),this.coefficient=zt.ASN1.parseIntegerStr(r.privateKeyCoefficient.bytes)}toASN1(){return this._pkcs1}toDER(){return this._keyRaw}toPEM(){return this._finalPEM===""&&(this._finalPEM=new zt.PEM("RSA PRIVATE KEY",this._keyRaw).toString()),this._finalPEM}toPrivateKeyPEM(){return new zt.PEM("PRIVATE KEY",this._pkcs8.DER).toString()}toJSON(){return{version:this.version,oid:this.oid,algo:this.algo,publicExponent:this.publicExponent,privateExponent:Hm(this.privateExponent),modulus:Hm(this.modulus),prime1:Hm(this.prime1),prime2:Hm(this.prime2),exponent1:Hm(this.exponent1),exponent2:Hm(this.exponent2),coefficient:Hm(this.coefficient)}}[Vm.inspect.custom](e,r){return`<${this.constructor.name} ${Vm.inspect(this.toJSON(),r)}>`}};Jd.RSAPrivateKey=VQ;function Hm(t){return t.length%8!==0&&t.startsWith("00")?t.slice(2):t}__.addVerifier(dc.getOID("Ed25519"),function(t,e){return GQ.sign.detached.verify(t,e,this.keyRaw)});w_.addSigner(dc.getOID("Ed25519"),function(t){let e=this.keyRaw;if(e.length!==64)throw new Error("Invalid signing key.");return Buffer.from(GQ.sign.detached(t,e))})});var q3e=L(SO=>{"use strict";Object.defineProperty(SO,"__esModule",{value:!0});var U3e=Kr("util"),d_t=Kr("crypto"),It=WQ(),hc=xO(),j3e=KQ(),za=Object.create(null);za.CN=hc.getOID("commonName");za.commonName="CN";za.C=hc.getOID("countryName");za.countryName="C";za.L=hc.getOID("localityName");za.localityName="L";za.ST=hc.getOID("stateOrProvinceName");za.stateOrProvinceName="ST";za.O=hc.getOID("organizationName");za.organizationName="O";za.OU=hc.getOID("organizationalUnitName");za.organizationalUnitName="OU";za.E=hc.getOID("emailAddress");za.emailAddress="E";function h_t(t){return za[t]==null?"":za[t]}var p_t={name:"Certificate",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.NONE,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",class:It.Class.UNIVERSAL,tag:It.Tag.INTEGER,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",class:It.Class.UNIVERSAL,tag:It.Tag.INTEGER,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate.signature.algorithm",class:It.Class.UNIVERSAL,tag:It.Tag.OID,capture:"certinfoSignatureOID"},{name:"Certificate.TBSCertificate.signature.parameters",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,optional:!0,capture:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"certIssuer"},{name:"Certificate.TBSCertificate.validity",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.TBSCertificate.validity.notBefore",class:It.Class.UNIVERSAL,tag:[It.Tag.UTCTIME,It.Tag.GENERALIZEDTIME],capture:"certValidityNotBefore"},{name:"Certificate.TBSCertificate.validity.notAfter",class:It.Class.UNIVERSAL,tag:[It.Tag.UTCTIME,It.Tag.GENERALIZEDTIME],capture:"certValidityNotAfter"}]},{name:"Certificate.TBSCertificate.subject",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,capture:"certSubject"},j3e.publicKeyValidator,{name:"Certificate.TBSCertificate.issuerUniqueID",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.BOOLEAN,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.INTEGER,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.BITSTRING,capture:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"Certificate.signatureAlgorithm.algorithm",class:It.Class.UNIVERSAL,tag:It.Tag.OID,capture:"certSignatureOID"},{name:"Certificate.TBSCertificate.signature.parameters",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,optional:!0,capture:"certSignatureParams"}]},{name:"Certificate.signatureValue",class:It.Class.UNIVERSAL,tag:It.Tag.BITSTRING,capture:"certSignature"}]},Fk=class{constructor(){this.attributes=[],this.uniqueId=null}get commonName(){return this.getFieldValue("commonName")}get organizationName(){return this.getFieldValue("organizationName")}get organizationalUnitName(){return this.getFieldValue("organizationalUnitName")}get countryName(){return this.getFieldValue("countryName")}get localityName(){return this.getFieldValue("localityName")}get serialName(){return this.getFieldValue("serialName")}getHash(){let e=d_t.createHash("sha1");for(let r of this.attributes)e.update(r.oid),e.update(r.value);return e.digest()}getField(e){for(let r of this.attributes)if(e===r.oid||e===r.name||e===r.shortName)return r;return null}addField(e){L3e([e]),this.attributes.push(e)}setAttrs(e){L3e(e),this.attributes=e}toJSON(){let e={};for(let r of this.attributes){let n=r.shortName;typeof n=="string"&&n!==""&&(e[n]=r.value)}return e.uniqueId=this.uniqueId,e.attributes=this.attributes,e}getFieldValue(e){let r=this.getField(e);return r!=null?r.value:""}};SO.DistinguishedName=Fk;var ZQ=class t{static fromPEMs(e){let r=[],n=It.PEM.parse(e);for(let i of n){if(i.type!=="CERTIFICATE"&&i.type!=="X509 CERTIFICATE"&&i.type!=="TRUSTED CERTIFICATE")throw new Error("Could not convert certificate from PEM: invalid type");if(i.procType.includes("ENCRYPTED"))throw new Error("Could not convert certificate from PEM: PEM is encrypted.");let s=It.ASN1.fromDER(i.body);r.push(new t(s))}if(r.length===0)throw new Error("No Certificate");return r}static fromPEM(e){return t.fromPEMs(e)[0]}constructor(e){let r=Object.create(null),n=e.validate(p_t,r);if(n!=null)throw new Error("Cannot read X.509 certificate: "+n.message);if(this.raw=e.DER,this.version=r.certVersion==null?0:It.ASN1.parseIntegerNum(r.certVersion.bytes)+1,this.serialNumber=It.ASN1.parseIntegerStr(r.certSerialNumber.bytes),this.signatureOID=It.ASN1.parseOID(r.certSignatureOID.bytes),this.signatureAlgorithm=hc.getOIDName(this.signatureOID),this.infoSignatureOID=It.ASN1.parseOID(r.certinfoSignatureOID.bytes),this.signature=It.ASN1.parseBitString(r.certSignature.bytes).buf,this.validFrom=It.ASN1.parseTime(r.certValidityNotBefore.tag,r.certValidityNotBefore.bytes),this.validTo=It.ASN1.parseTime(r.certValidityNotAfter.tag,r.certValidityNotAfter.bytes),this.issuer=new Fk,this.issuer.setAttrs($3e(r.certIssuer)),r.certIssuerUniqueId!=null&&(this.issuer.uniqueId=It.ASN1.parseBitString(r.certIssuerUniqueId.bytes)),this.subject=new Fk,this.subject.setAttrs($3e(r.certSubject)),r.certSubjectUniqueId!=null&&(this.subject.uniqueId=It.ASN1.parseBitString(r.certSubjectUniqueId.bytes)),this.extensions=[],this.subjectKeyIdentifier="",this.authorityKeyIdentifier="",this.ocspServer="",this.issuingCertificateURL="",this.isCA=!1,this.maxPathLen=-1,this.basicConstraintsValid=!1,this.keyUsage=0,this.dnsNames=[],this.emailAddresses=[],this.ipAddresses=[],this.uris=[],r.certExtensions!=null){this.extensions=m_t(r.certExtensions);for(let i of this.extensions)if(typeof i.subjectKeyIdentifier=="string"&&(this.subjectKeyIdentifier=i.subjectKeyIdentifier),typeof i.authorityKeyIdentifier=="string"&&(this.authorityKeyIdentifier=i.authorityKeyIdentifier),typeof i.authorityInfoAccessOcsp=="string"&&(this.ocspServer=i.authorityInfoAccessOcsp),typeof i.authorityInfoAccessIssuers=="string"&&(this.issuingCertificateURL=i.authorityInfoAccessIssuers),typeof i.basicConstraintsValid=="boolean"&&(this.isCA=i.isCA,this.maxPathLen=i.maxPathLen,this.basicConstraintsValid=i.basicConstraintsValid),typeof i.keyUsage=="number"&&(this.keyUsage=i.keyUsage),Array.isArray(i.altNames))for(let s of i.altNames)s.dnsName!=null&&this.dnsNames.push(s.dnsName),s.email!=null&&this.emailAddresses.push(s.email),s.ip!=null&&this.ipAddresses.push(s.ip),s.uri!=null&&this.uris.push(s.uri)}this.publicKey=new j3e.PublicKey(r.publicKeyInfo),this.publicKeyRaw=this.publicKey.toDER(),this.tbsCertificate=r.tbsCertificate}getExtension(e,r=""){for(let n of this.extensions)if(e===n.oid||e===n.name)return r===""?n:n[r];return null}checkSignature(e){if(this.version===3&&!this.basicConstraintsValid||this.basicConstraintsValid&&!this.isCA)return new Error("The parent constraint violation error");if(this.getExtension("keyUsage","keyCertSign")!==!0)return new Error("The parent constraint violation error");if(!e.isIssuer(this))return new Error("The parent certificate did not issue the given child certificate");let r=C_t(e.signatureOID);return r===""?new Error("Unknown child signature OID."):this.publicKey.verify(e.tbsCertificate.DER,e.signature,r)===!1?new Error("Child signature not matched"):null}isIssuer(e){return this.issuer.getHash().equals(e.subject.getHash())}verifySubjectKeyIdentifier(){return this.publicKey.getFingerprint("sha1","PublicKey").toString("hex")===this.subjectKeyIdentifier}toJSON(){let e={};for(let r of Object.keys(this))e[r]=k_t(this[r]);return delete e.tbsCertificate,e}[U3e.inspect.custom](e,r){return r.depth<=2&&(r.depth=10),`<${this.constructor.name} ${U3e.inspect(this.toJSON(),r)}>`}};SO.Certificate=ZQ;function m_t(t){let e=[];for(let r of t.mustCompound())for(let n of r.mustCompound())e.push(g_t(n));return e}function g_t(t){let e={};switch(e.oid=It.ASN1.parseOID(t.value[0].bytes),e.critical=!1,t.value[1].tag===It.Tag.BOOLEAN?(e.critical=It.ASN1.parseBool(t.value[1].bytes),e.value=t.value[2].bytes):e.value=t.value[1].bytes,e.name=hc.getOIDName(e.oid),e.name){case"keyUsage":x_t(e);break;case"basicConstraints":y_t(e);break;case"extKeyUsage":v_t(e);break;case"nsCertType":b_t(e);break;case"subjectAltName":M3e(e);break;case"issuerAltName":M3e(e);break;case"subjectKeyIdentifier":w_t(e);break;case"authorityKeyIdentifier":A_t(e);break;case"authorityInfoAccess":T_t(e);break}return e}function x_t(t){let e=It.ASN1.parseBitString(It.ASN1.fromDER(t.value).bytes),r=0,n=0;t.keyUsage=0;for(let i=0;i<9;i++)e.at(i)!==0&&(t.keyUsage|=1<<i);e.buf.length>0&&(r=e.buf[0],n=e.buf.length>1?e.buf[1]:0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}function y_t(t){let r=It.ASN1.fromDER(t.value).mustCompound();r.length>0&&r[0].tag===It.Tag.BOOLEAN?t.isCA=It.ASN1.parseBool(r[0].bytes):t.isCA=!1;let n=null;r.length>0&&r[0].tag===It.Tag.INTEGER?n=r[0].bytes:r.length>1&&(n=r[1].bytes),n!==null?t.maxPathLen=It.ASN1.parseInteger(n):t.maxPathLen=-1,t.basicConstraintsValid=!0}function v_t(t){let r=It.ASN1.fromDER(t.value).mustCompound();for(let n of r)t[hc.getOIDName(It.ASN1.parseOID(n.bytes))]=!0}function b_t(t){let e=It.ASN1.parseBitString(It.ASN1.fromDER(t.value).bytes),r=0;e.buf.length>0&&(r=e.buf[0]),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}function M3e(t){t.altNames=[];let r=It.ASN1.fromDER(t.value).mustCompound();for(let n of r){let i={tag:n.tag,value:n.bytes};switch(t.altNames.push(i),n.tag){case 1:i.email=n.bytes.toString();break;case 2:i.dnsName=n.bytes.toString();break;case 6:i.uri=n.bytes.toString();break;case 7:i.ip=hc.bytesToIP(n.bytes);break;case 8:i.oid=It.ASN1.parseOID(n.bytes);break;default:}}}var __t={name:"subjectKeyIdentifier",class:It.Class.UNIVERSAL,tag:It.Tag.OCTETSTRING,capture:"subjectKeyIdentifier"};function w_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,__t);t.subjectKeyIdentifier=e.subjectKeyIdentifier.bytes.toString("hex")}var S_t={name:"authorityKeyIdentifier",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"authorityKeyIdentifier.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.NONE,capture:"authorityKeyIdentifier"}]};function A_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,S_t);t.authorityKeyIdentifier=e.authorityKeyIdentifier.bytes.toString("hex")}var E_t={name:"authorityInfoAccess",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,value:[{name:"authorityInfoAccess.authorityInfoAccessOcsp",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,optional:!0,value:[{name:"authorityInfoAccess.authorityInfoAccessOcsp.oid",class:It.Class.UNIVERSAL,tag:It.Tag.OID},{name:"authorityInfoAccess.authorityInfoAccessOcsp.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.OID,capture:"authorityInfoAccessOcsp"}]},{name:"authorityInfoAccess.authorityInfoAccessIssuers",class:It.Class.UNIVERSAL,tag:It.Tag.SEQUENCE,optional:!0,value:[{name:"authorityInfoAccess.authorityInfoAccessIssuers.oid",class:It.Class.UNIVERSAL,tag:It.Tag.OID},{name:"authorityInfoAccess.authorityInfoAccessIssuers.value",class:It.Class.CONTEXT_SPECIFIC,tag:It.Tag.OID,capture:"authorityInfoAccessIssuers"}]}]};function T_t(t){let e=It.ASN1.parseDERWithTemplate(t.value,E_t);e.authorityInfoAccessOcsp!=null&&(t.authorityInfoAccessOcsp=e.authorityInfoAccessOcsp.bytes.toString()),e.authorityInfoAccessIssuers!=null&&(t.authorityInfoAccessIssuers=e.authorityInfoAccessIssuers.bytes.toString())}function L3e(t){for(let e of t){if((e.name==null||e.name==="")&&(e.oid!=null&&(e.name=hc.getOIDName(e.oid)),e.name===""&&e.shortName!=null&&(e.name=hc.getOIDName(za[e.shortName]))),e.oid==null||e.oid==="")if(e.name!=="")e.oid=hc.getOID(e.name);else throw new Error("Attribute oid not specified.");if((e.shortName==null||e.shortName==="")&&(e.shortName=za[e.name]==null?"":za[e.name]),e.value==null)throw new Error("Attribute value not specified.")}}function C_t(t){switch(hc.getOIDName(t)){case"sha1WithRsaEncryption":return"sha1";case"md5WithRsaEncryption":return"md5";case"sha256WithRsaEncryption":return"sha256";case"sha384WithRsaEncryption":return"sha384";case"sha512WithRsaEncryption":return"sha512";case"RSASSA-PSS":return"sha256";case"ecdsaWithSha1":return"sha1";case"ecdsaWithSha256":return"sha256";case"ecdsaWithSha384":return"sha384";case"ecdsaWithSha512":return"sha512";case"dsaWithSha1":return"sha1";case"dsaWithSha256":return"sha256";default:return""}}function $3e(t){let e=[];for(let r of t.mustCompound())for(let n of r.mustCompound()){let i=n.mustCompound(),s={};s.oid=It.ASN1.parseOID(i[0].bytes),s.value=i[1].value,s.valueTag=i[1].tag,s.name=hc.getOIDName(s.oid),s.shortName=h_t(s.name),e.push(s)}return e}function k_t(t){return t!=null&&!(t instanceof Buffer)&&typeof t.toJSON=="function"?t.toJSON():t}});var XQ=L(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var AO=xO();Wl.bytesFromIP=AO.bytesFromIP;Wl.bytesToIP=AO.bytesToIP;Wl.getOID=AO.getOID;Wl.getOIDName=AO.getOIDName;var EO=KQ();Wl.PublicKey=EO.PublicKey;Wl.PrivateKey=EO.PrivateKey;Wl.RSAPublicKey=EO.RSAPublicKey;Wl.RSAPrivateKey=EO.RSAPrivateKey;var z3e=q3e();Wl.Certificate=z3e.Certificate;Wl.DistinguishedName=z3e.DistinguishedName});var H3e=L(()=>{var W3e;(function(t){(function(e){var r=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(t);typeof r.Reflect<"u"&&(n=i(r.Reflect,n)),e(n,r),typeof r.Reflect>"u"&&(r.Reflect=t);function i(d,h){return function(p,x){Object.defineProperty(d,p,{configurable:!0,writable:!0,value:x}),h&&h(p,x)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,r){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",d={__proto__:[]}instanceof Array,h=!c&&!d,p={create:c?function(){return Zr(Object.create(null))}:d?function(){return Zr({__proto__:null})}:function(){return Zr({})},has:h?function(Fe,Me){return n.call(Fe,Me)}:function(Fe,Me){return Me in Fe},get:h?function(Fe,Me){return n.call(Fe,Me)?Fe[Me]:void 0}:function(Fe,Me){return Fe[Me]}},x=Object.getPrototypeOf(Function),y=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:kr(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Fi(),w=typeof WeakMap=="function"?WeakMap:_i(),S=i?Symbol.for("@reflect-metadata:registry"):void 0,C=$e(),k=We(C);function T(Fe,Me,nt,Et){if(J(nt)){if(!lr(Fe))throw new TypeError;if(!pt(Me))throw new TypeError;return te(Fe,Me)}else{if(!lr(Fe))throw new TypeError;if(!fe(Me))throw new TypeError;if(!fe(Et)&&!J(Et)&&!se(Et))throw new TypeError;return se(Et)&&(Et=void 0),nt=Xe(nt),Q(Fe,Me,nt,Et)}}e("decorate",T);function E(Fe,Me){function nt(Et,Tr){if(!fe(Et))throw new TypeError;if(!J(Tr)&&!Ct(Tr))throw new TypeError;X(Fe,Me,Et,Tr)}return nt}e("metadata",E);function I(Fe,Me,nt,Et){if(!fe(nt))throw new TypeError;return J(Et)||(Et=Xe(Et)),X(Fe,Me,nt,Et)}e("defineMetadata",I);function R(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),ee(Fe,Me,nt)}e("hasMetadata",R);function U(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),pe(Fe,Me,nt)}e("hasOwnMetadata",U);function B(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),H(Fe,Me,nt)}e("getMetadata",B);function z(Fe,Me,nt){if(!fe(Me))throw new TypeError;return J(nt)||(nt=Xe(nt)),oe(Fe,Me,nt)}e("getOwnMetadata",z);function K(Fe,Me){if(!fe(Fe))throw new TypeError;return J(Me)||(Me=Xe(Me)),N(Fe,Me)}e("getMetadataKeys",K);function Ae(Fe,Me){if(!fe(Fe))throw new TypeError;return J(Me)||(Me=Xe(Me)),Z(Fe,Me)}e("getOwnMetadataKeys",Ae);function de(Fe,Me,nt){if(!fe(Me))throw new TypeError;if(J(nt)||(nt=Xe(nt)),!fe(Me))throw new TypeError;J(nt)||(nt=Xe(nt));var Et=Pt(Me,nt,!1);return J(Et)?!1:Et.OrdinaryDeleteMetadata(Fe,Me,nt)}e("deleteMetadata",de);function te(Fe,Me){for(var nt=Fe.length-1;nt>=0;--nt){var Et=Fe[nt],Tr=Et(Me);if(!J(Tr)&&!se(Tr)){if(!pt(Tr))throw new TypeError;Me=Tr}}return Me}function Q(Fe,Me,nt,Et){for(var Tr=Fe.length-1;Tr>=0;--Tr){var Ei=Fe[Tr],Ki=Ei(Me,nt,Et);if(!J(Ki)&&!se(Ki)){if(!fe(Ki))throw new TypeError;Et=Ki}}return Et}function ee(Fe,Me,nt){var Et=pe(Fe,Me,nt);if(Et)return!0;var Tr=ra(Me);return se(Tr)?!1:ee(Fe,Tr,nt)}function pe(Fe,Me,nt){var Et=Pt(Me,nt,!1);return J(Et)?!1:Ft(Et.OrdinaryHasOwnMetadata(Fe,Me,nt))}function H(Fe,Me,nt){var Et=pe(Fe,Me,nt);if(Et)return oe(Fe,Me,nt);var Tr=ra(Me);if(!se(Tr))return H(Fe,Tr,nt)}function oe(Fe,Me,nt){var Et=Pt(Me,nt,!1);if(!J(Et))return Et.OrdinaryGetOwnMetadata(Fe,Me,nt)}function X(Fe,Me,nt,Et){var Tr=Pt(nt,Et,!0);Tr.OrdinaryDefineOwnMetadata(Fe,Me,nt,Et)}function N(Fe,Me){var nt=Z(Fe,Me),Et=ra(Fe);if(Et===null)return nt;var Tr=N(Et,Me);if(Tr.length<=0)return nt;if(nt.length<=0)return Tr;for(var Ei=new v,Ki=[],Ur=0,Yt=nt;Ur<Yt.length;Ur++){var cr=Yt[Ur],vr=Ei.has(cr);vr||(Ei.add(cr),Ki.push(cr))}for(var Dr=0,Mr=Tr;Dr<Mr.length;Dr++){var cr=Mr[Dr],vr=Ei.has(cr);vr||(Ei.add(cr),Ki.push(cr))}return Ki}function Z(Fe,Me){var nt=Pt(Fe,Me,!1);return nt?nt.OrdinaryOwnMetadataKeys(Fe,Me):[]}function ae(Fe){if(Fe===null)return 1;switch(typeof Fe){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return Fe===null?1:6;default:return 6}}function J(Fe){return Fe===void 0}function se(Fe){return Fe===null}function Se(Fe){return typeof Fe=="symbol"}function fe(Fe){return typeof Fe=="object"?Fe!==null:typeof Fe=="function"}function ze(Fe,Me){switch(ae(Fe)){case 0:return Fe;case 1:return Fe;case 2:return Fe;case 3:return Fe;case 4:return Fe;case 5:return Fe}var nt=Me===3?"string":Me===5?"number":"default",Et=rn(Fe,s);if(Et!==void 0){var Tr=Et.call(Fe,nt);if(fe(Tr))throw new TypeError;return Tr}return Ue(Fe,nt==="default"?"number":nt)}function Ue(Fe,Me){if(Me==="string"){var nt=Fe.toString;if(Ce(nt)){var Et=nt.call(Fe);if(!fe(Et))return Et}var Tr=Fe.valueOf;if(Ce(Tr)){var Et=Tr.call(Fe);if(!fe(Et))return Et}}else{var Tr=Fe.valueOf;if(Ce(Tr)){var Et=Tr.call(Fe);if(!fe(Et))return Et}var Ei=Fe.toString;if(Ce(Ei)){var Et=Ei.call(Fe);if(!fe(Et))return Et}}throw new TypeError}function Ft(Fe){return!!Fe}function Ht(Fe){return""+Fe}function Xe(Fe){var Me=ze(Fe,3);return Se(Me)?Me:Ht(Me)}function lr(Fe){return Array.isArray?Array.isArray(Fe):Fe instanceof Object?Fe instanceof Array:Object.prototype.toString.call(Fe)==="[object Array]"}function Ce(Fe){return typeof Fe=="function"}function pt(Fe){return typeof Fe=="function"}function Ct(Fe){switch(ae(Fe)){case 3:return!0;case 4:return!0;default:return!1}}function ar(Fe,Me){return Fe===Me||Fe!==Fe&&Me!==Me}function rn(Fe,Me){var nt=Fe[Me];if(nt!=null){if(!Ce(nt))throw new TypeError;return nt}}function Sn(Fe){var Me=rn(Fe,a);if(!Ce(Me))throw new TypeError;var nt=Me.call(Fe);if(!fe(nt))throw new TypeError;return nt}function An(Fe){return Fe.value}function Ai(Fe){var Me=Fe.next();return Me.done?!1:Me}function Ii(Fe){var Me=Fe.return;Me&&Me.call(Fe)}function ra(Fe){var Me=Object.getPrototypeOf(Fe);if(typeof Fe!="function"||Fe===x||Me!==x)return Me;var nt=Fe.prototype,Et=nt&&Object.getPrototypeOf(nt);if(Et==null||Et===Object.prototype)return Me;var Tr=Et.constructor;return typeof Tr!="function"||Tr===Fe?Me:Tr}function Bn(){var Fe;!J(S)&&typeof r.Reflect<"u"&&!(S in r.Reflect)&&typeof r.Reflect.defineMetadata=="function"&&(Fe=Tt(r.Reflect));var Me,nt,Et,Tr=new w,Ei={registerProvider:Ki,getProvider:Yt,setProvider:vr};return Ei;function Ki(Dr){if(!Object.isExtensible(Ei))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case Fe===Dr:break;case J(Me):Me=Dr;break;case Me===Dr:break;case J(nt):nt=Dr;break;case nt===Dr:break;default:Et===void 0&&(Et=new v),Et.add(Dr);break}}function Ur(Dr,Mr){if(!J(Me)){if(Me.isProviderFor(Dr,Mr))return Me;if(!J(nt)){if(nt.isProviderFor(Dr,Mr))return Me;if(!J(Et))for(var ti=Sn(Et);;){var Pi=Ai(ti);if(!Pi)return;var Xa=An(Pi);if(Xa.isProviderFor(Dr,Mr))return Ii(ti),Xa}}}if(!J(Fe)&&Fe.isProviderFor(Dr,Mr))return Fe}function Yt(Dr,Mr){var ti=Tr.get(Dr),Pi;return J(ti)||(Pi=ti.get(Mr)),J(Pi)&&(Pi=Ur(Dr,Mr),J(Pi)||(J(ti)&&(ti=new y,Tr.set(Dr,ti)),ti.set(Mr,Pi))),Pi}function cr(Dr){if(J(Dr))throw new TypeError;return Me===Dr||nt===Dr||!J(Et)&&Et.has(Dr)}function vr(Dr,Mr,ti){if(!cr(ti))throw new Error("Metadata provider not registered.");var Pi=Yt(Dr,Mr);if(Pi!==ti){if(!J(Pi))return!1;var Xa=Tr.get(Dr);J(Xa)&&(Xa=new y,Tr.set(Dr,Xa)),Xa.set(Mr,ti)}return!0}}function $e(){var Fe;return!J(S)&&fe(r.Reflect)&&Object.isExtensible(r.Reflect)&&(Fe=r.Reflect[S]),J(Fe)&&(Fe=Bn()),!J(S)&&fe(r.Reflect)&&Object.isExtensible(r.Reflect)&&Object.defineProperty(r.Reflect,S,{enumerable:!1,configurable:!1,writable:!1,value:Fe}),Fe}function We(Fe){var Me=new w,nt={isProviderFor:function(cr,vr){var Dr=Me.get(cr);return J(Dr)?!1:Dr.has(vr)},OrdinaryDefineOwnMetadata:Ki,OrdinaryHasOwnMetadata:Tr,OrdinaryGetOwnMetadata:Ei,OrdinaryOwnMetadataKeys:Ur,OrdinaryDeleteMetadata:Yt};return C.registerProvider(nt),nt;function Et(cr,vr,Dr){var Mr=Me.get(cr),ti=!1;if(J(Mr)){if(!Dr)return;Mr=new y,Me.set(cr,Mr),ti=!0}var Pi=Mr.get(vr);if(J(Pi)){if(!Dr)return;if(Pi=new y,Mr.set(vr,Pi),!Fe.setProvider(cr,vr,nt))throw Mr.delete(vr),ti&&Me.delete(cr),new Error("Wrong provider for target.")}return Pi}function Tr(cr,vr,Dr){var Mr=Et(vr,Dr,!1);return J(Mr)?!1:Ft(Mr.has(cr))}function Ei(cr,vr,Dr){var Mr=Et(vr,Dr,!1);if(!J(Mr))return Mr.get(cr)}function Ki(cr,vr,Dr,Mr){var ti=Et(Dr,Mr,!0);ti.set(cr,vr)}function Ur(cr,vr){var Dr=[],Mr=Et(cr,vr,!1);if(J(Mr))return Dr;for(var ti=Mr.keys(),Pi=Sn(ti),Xa=0;;){var xo=Ai(Pi);if(!xo)return Dr.length=Xa,Dr;var Hc=An(xo);try{Dr[Xa]=Hc}catch(YS){try{Ii(Pi)}finally{throw YS}}Xa++}}function Yt(cr,vr,Dr){var Mr=Et(vr,Dr,!1);if(J(Mr)||!Mr.delete(cr))return!1;if(Mr.size===0){var ti=Me.get(vr);J(ti)||(ti.delete(Dr),ti.size===0&&Me.delete(ti))}return!0}}function Tt(Fe){var Me=Fe.defineMetadata,nt=Fe.hasOwnMetadata,Et=Fe.getOwnMetadata,Tr=Fe.getOwnMetadataKeys,Ei=Fe.deleteMetadata,Ki=new w,Ur={isProviderFor:function(Yt,cr){var vr=Ki.get(Yt);return!J(vr)&&vr.has(cr)?!0:Tr(Yt,cr).length?(J(vr)&&(vr=new v,Ki.set(Yt,vr)),vr.add(cr),!0):!1},OrdinaryDefineOwnMetadata:Me,OrdinaryHasOwnMetadata:nt,OrdinaryGetOwnMetadata:Et,OrdinaryOwnMetadataKeys:Tr,OrdinaryDeleteMetadata:Ei};return Ur}function Pt(Fe,Me,nt){var Et=C.getProvider(Fe,Me);if(!J(Et))return Et;if(nt){if(C.setProvider(Fe,Me,k))return k;throw new Error("Illegal state.")}}function kr(){var Fe={},Me=[],nt=(function(){function Ur(Yt,cr,vr){this._index=0,this._keys=Yt,this._values=cr,this._selector=vr}return Ur.prototype["@@iterator"]=function(){return this},Ur.prototype[a]=function(){return this},Ur.prototype.next=function(){var Yt=this._index;if(Yt>=0&&Yt<this._keys.length){var cr=this._selector(this._keys[Yt],this._values[Yt]);return Yt+1>=this._keys.length?(this._index=-1,this._keys=Me,this._values=Me):this._index++,{value:cr,done:!1}}return{value:void 0,done:!0}},Ur.prototype.throw=function(Yt){throw this._index>=0&&(this._index=-1,this._keys=Me,this._values=Me),Yt},Ur.prototype.return=function(Yt){return this._index>=0&&(this._index=-1,this._keys=Me,this._values=Me),{value:Yt,done:!0}},Ur})(),Et=(function(){function Ur(){this._keys=[],this._values=[],this._cacheKey=Fe,this._cacheIndex=-2}return Object.defineProperty(Ur.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ur.prototype.has=function(Yt){return this._find(Yt,!1)>=0},Ur.prototype.get=function(Yt){var cr=this._find(Yt,!1);return cr>=0?this._values[cr]:void 0},Ur.prototype.set=function(Yt,cr){var vr=this._find(Yt,!0);return this._values[vr]=cr,this},Ur.prototype.delete=function(Yt){var cr=this._find(Yt,!1);if(cr>=0){for(var vr=this._keys.length,Dr=cr+1;Dr<vr;Dr++)this._keys[Dr-1]=this._keys[Dr],this._values[Dr-1]=this._values[Dr];return this._keys.length--,this._values.length--,ar(Yt,this._cacheKey)&&(this._cacheKey=Fe,this._cacheIndex=-2),!0}return!1},Ur.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=Fe,this._cacheIndex=-2},Ur.prototype.keys=function(){return new nt(this._keys,this._values,Tr)},Ur.prototype.values=function(){return new nt(this._keys,this._values,Ei)},Ur.prototype.entries=function(){return new nt(this._keys,this._values,Ki)},Ur.prototype["@@iterator"]=function(){return this.entries()},Ur.prototype[a]=function(){return this.entries()},Ur.prototype._find=function(Yt,cr){if(!ar(this._cacheKey,Yt)){this._cacheIndex=-1;for(var vr=0;vr<this._keys.length;vr++)if(ar(this._keys[vr],Yt)){this._cacheIndex=vr;break}}return this._cacheIndex<0&&cr&&(this._cacheIndex=this._keys.length,this._keys.push(Yt),this._values.push(void 0)),this._cacheIndex},Ur})();return Et;function Tr(Ur,Yt){return Ur}function Ei(Ur,Yt){return Yt}function Ki(Ur,Yt){return[Ur,Yt]}}function Fi(){var Fe=(function(){function Me(){this._map=new y}return Object.defineProperty(Me.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),Me.prototype.has=function(nt){return this._map.has(nt)},Me.prototype.add=function(nt){return this._map.set(nt,nt),this},Me.prototype.delete=function(nt){return this._map.delete(nt)},Me.prototype.clear=function(){this._map.clear()},Me.prototype.keys=function(){return this._map.keys()},Me.prototype.values=function(){return this._map.keys()},Me.prototype.entries=function(){return this._map.entries()},Me.prototype["@@iterator"]=function(){return this.keys()},Me.prototype[a]=function(){return this.keys()},Me})();return Fe}function _i(){var Fe=16,Me=p.create(),nt=Et();return(function(){function Yt(){this._key=Et()}return Yt.prototype.has=function(cr){var vr=Tr(cr,!1);return vr!==void 0?p.has(vr,this._key):!1},Yt.prototype.get=function(cr){var vr=Tr(cr,!1);return vr!==void 0?p.get(vr,this._key):void 0},Yt.prototype.set=function(cr,vr){var Dr=Tr(cr,!0);return Dr[this._key]=vr,this},Yt.prototype.delete=function(cr){var vr=Tr(cr,!1);return vr!==void 0?delete vr[this._key]:!1},Yt.prototype.clear=function(){this._key=Et()},Yt})();function Et(){var Yt;do Yt="@@WeakMap@@"+Ur();while(p.has(Me,Yt));return Me[Yt]=!0,Yt}function Tr(Yt,cr){if(!n.call(Yt,nt)){if(!cr)return;Object.defineProperty(Yt,nt,{value:p.create()})}return Yt[nt]}function Ei(Yt,cr){for(var vr=0;vr<cr;++vr)Yt[vr]=Math.random()*255|0;return Yt}function Ki(Yt){if(typeof Uint8Array=="function"){var cr=new Uint8Array(Yt);return typeof crypto<"u"?crypto.getRandomValues(cr):typeof msCrypto<"u"?msCrypto.getRandomValues(cr):Ei(cr,Yt),cr}return Ei(new Array(Yt),Yt)}function Ur(){var Yt=Ki(Fe);Yt[6]=Yt[6]&79|64,Yt[8]=Yt[8]&191|128;for(var cr="",vr=0;vr<Fe;++vr){var Dr=Yt[vr];(vr===4||vr===6||vr===8)&&(cr+="-"),Dr<16&&(cr+="0"),cr+=Dr.toString(16).toLowerCase()}return cr}}function Zr(Fe){return Fe.__=void 0,delete Fe.__,Fe}})})(W3e||(W3e={}))});var st={};yi(st,{__addDisposableResource:()=>gDe,__assign:()=>TO,__asyncDelegator:()=>cDe,__asyncGenerator:()=>oDe,__asyncValues:()=>uDe,__await:()=>S_,__awaiter:()=>tDe,__classPrivateFieldGet:()=>hDe,__classPrivateFieldIn:()=>mDe,__classPrivateFieldSet:()=>pDe,__createBinding:()=>kO,__decorate:()=>K3e,__disposeResources:()=>xDe,__esDecorate:()=>X3e,__exportStar:()=>nDe,__extends:()=>V3e,__generator:()=>rDe,__importDefault:()=>dDe,__importStar:()=>fDe,__makeTemplateObject:()=>lDe,__metadata:()=>eDe,__param:()=>Z3e,__propKey:()=>J3e,__read:()=>QQ,__rest:()=>G3e,__rewriteRelativeImportExtension:()=>yDe,__runInitializers:()=>Y3e,__setFunctionName:()=>Q3e,__spread:()=>iDe,__spreadArray:()=>aDe,__spreadArrays:()=>sDe,__values:()=>CO,default:()=>F_t});function V3e(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");YQ(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function G3e(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function K3e(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Z3e(t,e){return function(r,n){e(r,n,t)}}function X3e(t,e,r,n,i,s){function a(k){if(k!==void 0&&typeof k!="function")throw new TypeError("Function expected");return k}for(var c=n.kind,d=c==="getter"?"get":c==="setter"?"set":"value",h=!e&&t?n.static?t:t.prototype:null,p=e||(h?Object.getOwnPropertyDescriptor(h,n.name):{}),x,y=!1,v=r.length-1;v>=0;v--){var w={};for(var S in n)w[S]=S==="access"?{}:n[S];for(var S in n.access)w.access[S]=n.access[S];w.addInitializer=function(k){if(y)throw new TypeError("Cannot add initializers after decoration has completed");s.push(a(k||null))};var C=(0,r[v])(c==="accessor"?{get:p.get,set:p.set}:p[d],w);if(c==="accessor"){if(C===void 0)continue;if(C===null||typeof C!="object")throw new TypeError("Object expected");(x=a(C.get))&&(p.get=x),(x=a(C.set))&&(p.set=x),(x=a(C.init))&&i.unshift(x)}else(x=a(C))&&(c==="field"?i.unshift(x):p[d]=x)}h&&Object.defineProperty(h,n.name,p),y=!0}function Y3e(t,e,r){for(var n=arguments.length>2,i=0;i<e.length;i++)r=n?e[i].call(t,r):e[i].call(t);return n?r:void 0}function J3e(t){return typeof t=="symbol"?t:"".concat(t)}function Q3e(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function eDe(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function tDe(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function c(p){try{h(n.next(p))}catch(x){a(x)}}function d(p){try{h(n.throw(p))}catch(x){a(x)}}function h(p){p.done?s(p.value):i(p.value).then(c,d)}h((n=n.apply(t,e||[])).next())})}function rDe(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(h){return function(p){return d([h,p])}}function d(h){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,h[0]&&(r=0)),r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(p){h=[6,p],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function nDe(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&kO(e,t,r)}function CO(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function QQ(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function iDe(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(QQ(arguments[e]));return t}function sDe(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)n[i]=s[a];return n}function aDe(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function S_(t){return this instanceof S_?(this.v=t,this):new S_(t)}function oDe(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(w){return Promise.resolve(w).then(v,x)}}function c(v,w){n[v]&&(i[v]=function(S){return new Promise(function(C,k){s.push([v,S,C,k])>1||d(v,S)})},w&&(i[v]=w(i[v])))}function d(v,w){try{h(n[v](w))}catch(S){y(s[0][3],S)}}function h(v){v.value instanceof S_?Promise.resolve(v.value.v).then(p,x):y(s[0][2],v)}function p(v){d("next",v)}function x(v){d("throw",v)}function y(v,w){v(w),s.shift(),s.length&&d(s[0][0],s[0][1])}}function cDe(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(a){return(r=!r)?{value:S_(t[i](a)),done:!1}:s?s(a):a}:s}}function uDe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof CO=="function"?CO(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(a){return new Promise(function(c,d){a=t[s](a),i(c,d,a.done,a.value)})}}function i(s,a,c,d){Promise.resolve(d).then(function(h){s({value:h,done:c})},a)}}function lDe(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function fDe(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=JQ(t),n=0;n<r.length;n++)r[n]!=="default"&&kO(e,t,r[n]);return D_t(e,t),e}function dDe(t){return t&&t.__esModule?t:{default:t}}function hDe(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function pDe(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function mDe(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function gDe(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var n,i;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],r&&(i=n)}if(typeof n!="function")throw new TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(s){return Promise.reject(s)}}),t.stack.push({value:e,dispose:n,async:r})}else r&&t.stack.push({async:!0});return e}function xDe(t){function e(s){t.error=t.hasError?new I_t(s,t.error,"An error was suppressed during disposal."):s,t.hasError=!0}var r,n=0;function i(){for(;r=t.stack.pop();)try{if(!r.async&&n===1)return n=0,t.stack.push(r),Promise.resolve().then(i);if(r.dispose){var s=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(s).then(i,function(a){return e(a),i()})}else n|=1}catch(a){e(a)}if(n===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return i()}function yDe(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,i,s,a){return n?e?".jsx":".js":i&&(!s||!a)?r:i+s+"."+a.toLowerCase()+"js"}):t}var YQ,TO,kO,D_t,JQ,I_t,F_t,at=ce(()=>{YQ=function(t,e){return YQ=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},YQ(t,e)};TO=function(){return TO=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},TO.apply(this,arguments)};kO=Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]});D_t=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},JQ=function(t){return JQ=Object.getOwnPropertyNames||function(e){var r=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[r.length]=n);return r},JQ(t)};I_t=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var n=new Error(r);return n.name="SuppressedError",n.error=t,n.suppressed=e,n};F_t={__extends:V3e,__assign:TO,__rest:G3e,__decorate:K3e,__param:Z3e,__esDecorate:X3e,__runInitializers:Y3e,__propKey:J3e,__setFunctionName:Q3e,__metadata:eDe,__awaiter:tDe,__generator:rDe,__createBinding:kO,__exportStar:nDe,__values:CO,__read:QQ,__spread:iDe,__spreadArrays:sDe,__spreadArray:aDe,__await:S_,__asyncGenerator:oDe,__asyncDelegator:cDe,__asyncValues:uDe,__makeTemplateObject:lDe,__importStar:fDe,__importDefault:dDe,__classPrivateFieldGet:hDe,__classPrivateFieldSet:pDe,__classPrivateFieldIn:mDe,__addDisposableResource:gDe,__disposeResources:xDe,__rewriteRelativeImportExtension:yDe}});var tee=L(A_=>{"use strict";var P_t="[object ArrayBuffer]",O0=class t{static isArrayBuffer(e){return Object.prototype.toString.call(e)===P_t}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,r){if(e.constructor===r)return e;if(this.isArrayBuffer(e))return new r(e);if(this.isArrayBufferView(e))return new r(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){let n=t.toUint8Array(e),i=t.toUint8Array(r);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let r;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?r=e[0]:e[e.length-1]instanceof Function?r=e.slice(0,e.length-1):r=e;let n=0;for(let a of r)n+=a.byteLength;let i=new Uint8Array(n),s=0;for(let a of r){let c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}},eee="string",R_t=/^[0-9a-f\s]+$/i,O_t=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,N_t=/^[a-zA-Z0-9-_]+$/,DO=class{static fromString(e){let r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return n.buffer}static toString(e){let r=O0.toUint8Array(e),n="";for(let s=0;s<r.length;s++)n+=String.fromCharCode(r[s]);return decodeURIComponent(escape(n))}},Hl=class{static toString(e,r=!1){let n=O0.toArrayBuffer(e),i=new DataView(n),s="";for(let a=0;a<n.byteLength;a+=2){let c=i.getUint16(a,r);s+=String.fromCharCode(c)}return s}static fromString(e,r=!1){let n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),r);return n}},IO=class t{static isHex(e){return typeof e===eee&&R_t.test(e)}static isBase64(e){return typeof e===eee&&O_t.test(e)}static isBase64Url(e){return typeof e===eee&&N_t.test(e)}static ToString(e,r="utf8"){let n=O0.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Hl.toString(n,!0);case"utf16":case"utf16be":return Hl.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,r="utf8"){if(!e)return new ArrayBuffer(0);switch(r.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Hl.fromString(e,!0);case"utf16":case"utf16be":return Hl.fromString(e);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToBase64(e){let r=O0.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(r,"binary");return btoa(n)}else return Buffer.from(r).toString("base64")}static FromBase64(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(r)):new Uint8Array(Buffer.from(r,"base64")).buffer}static FromBase64Url(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64Url(r))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(r.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.FromBinary(e);case"utf8":return DO.fromString(e);case"utf16":case"utf16be":return Hl.fromString(e);case"utf16le":case"usc2":return Hl.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.ToBinary(e);case"utf8":return DO.toString(e);case"utf16":case"utf16be":return Hl.toString(e);case"utf16le":case"usc2":return Hl.toString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromBinary(e){let r=e.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){let r=O0.toUint8Array(e),n="";for(let i=0;i<r.length;i++)n+=String.fromCharCode(r[i]);return n}static ToHex(e){let r=O0.toUint8Array(e),n="",i=r.length;for(let s=0;s<i;s++){let a=r[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isHex(r))throw new TypeError("Argument 'hexString' is not HEX encoded");r.length%2&&(r=`0${r}`);let n=new Uint8Array(r.length/2);for(let i=0;i<r.length;i=i+2){let s=r.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,r=!1){return Hl.toString(e,r)}static FromUtf16String(e,r=!1){return Hl.fromString(e,r)}static Base64Padding(e){let r=4-e.length%4;if(r<4)for(let n=0;n<r;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};IO.DEFAULT_UTF8_ENCODING="utf8";function B_t(t,...e){let r=arguments[0];for(let n=1;n<arguments.length;n++){let i=arguments[n];for(let s in i)r[s]=i[s]}return r}function U_t(...t){let e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),r=new Uint8Array(e),n=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(let s of i)r[n++]=s}),r.buffer}function M_t(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(r[i]!==n[i])return!1;return!0}A_.BufferSourceConverter=O0;A_.Convert=IO;A_.assign=B_t;A_.combine=U_t;A_.isEqual=M_t});var _De=L(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});function L_t(t){return new Date(t.getTime()+t.getTimezoneOffset()*6e4)}function $_t(t,e,r){var n;return t instanceof Object&&(n=t[e])!==null&&n!==void 0?n:r}function j_t(t,e=0,r=t.byteLength-e,n=!1){let i="";for(let s of new Uint8Array(t,e,r)){let a=s.toString(16).toUpperCase();a.length===1&&(i+="0"),i+=a,n&&(i+=" ")}return i.trim()}function q_t(t,e,r,n){return e instanceof ArrayBuffer?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error='Wrong parameter: inputBuffer must be "ArrayBuffer"',!1)}function ree(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function nee(t,e,r=-1){let n=r,i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let d;if(n<0)d=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);d=new ArrayBuffer(n),s=n}let h=new Uint8Array(d);for(let p=c-1;p>=0;p--){let x=Math.pow(2,p*e);h[s-p-1]=Math.floor(i/x),i-=h[s-p-1]*x}return d}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function z_t(...t){let e=0,r=0;for(let s of t)e+=s.byteLength;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of t)i.set(new Uint8Array(s),r),r+=s.byteLength;return n}function W_t(...t){let e=0,r=0;for(let s of t)e+=s.length;let n=new ArrayBuffer(e),i=new Uint8Array(n);for(let s of t)i.set(s,r),r+=s.length;return i}function H_t(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let c=t[0]===255&&t[1]&128,d=t[0]===0&&(t[1]&128)===0;(c||d)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)r[c]=0;r[0]=t[0]&128;let n=ree(r,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,ree(s,8)-n}function V_t(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let a=r-e,c=nee(a,8,n),d=new Uint8Array(c);return d[0]|=128,c}let i=nee(e,8,n),s=new Uint8Array(i);if(s[0]&128){let a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let d=0;d<a.byteLength;d++)s[d+1]=c[d];s[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function G_t(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}function K_t(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(r)}var vDe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bDe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function Z_t(t,e=!1,r=!1,n=!1){let i=0,s=0,a=0,c="",d=e?bDe:vDe;if(n){let h=0;for(let p=0;p<t.length;p++)if(t.charCodeAt(p)!==0){h=p;break}t=t.slice(h)}for(;i<t.length;){let h=t.charCodeAt(i++);i>=t.length&&(s=1);let p=t.charCodeAt(i++);i>=t.length&&(a=1);let x=t.charCodeAt(i++),y=h>>2,v=(h&3)<<4|p>>4,w=(p&15)<<2|x>>6,S=x&63;s===1?w=S=64:a===1&&(S=64),r?w===64?c+=`${d.charAt(y)}${d.charAt(v)}`:S===64?c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}`:c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}${d.charAt(S)}`:c+=`${d.charAt(y)}${d.charAt(v)}${d.charAt(w)}${d.charAt(S)}`}return c}function X_t(t,e=!1,r=!1){let n=e?bDe:vDe;function i(d){for(let h=0;h<64;h++)if(n.charAt(h)===d)return h;return 64}function s(d){return d===64?0:d}let a=0,c="";for(;a<t.length;){let d=i(t.charAt(a++)),h=a>=t.length?0:i(t.charAt(a++)),p=a>=t.length?0:i(t.charAt(a++)),x=a>=t.length?0:i(t.charAt(a++)),y=s(d)<<2|s(h)>>4,v=(s(h)&15)<<4|s(p)>>2,w=(s(p)&3)<<6|s(x);c+=String.fromCharCode(y),p!==64&&(c+=String.fromCharCode(v)),x!==64&&(c+=String.fromCharCode(w))}if(r){let d=c.length,h=-1;for(let p=d-1;p>=0;p--)if(c.charCodeAt(p)!==0){h=p;break}h!==-1?c=c.slice(0,h+1):c=""}return c}function Y_t(t){let e="",r=new Uint8Array(t);for(let n of r)e+=String.fromCharCode(n);return e}function J_t(t){let e=t.length,r=new ArrayBuffer(e),n=new Uint8Array(r);for(let i=0;i<e;i++)n[i]=t.charCodeAt(i);return r}var Q_t=Math.log(2);function ewt(t){let e=Math.log(t)/Q_t,r=Math.floor(e),n=Math.round(e);return r===n?r:n}function twt(t,e){for(let r of e)delete t[r]}Fa.arrayBufferToString=Y_t;Fa.bufferToHexCodes=j_t;Fa.checkBufferParams=q_t;Fa.clearProps=twt;Fa.fromBase64=X_t;Fa.getParametersValue=$_t;Fa.getUTCDate=L_t;Fa.isEqualBuffer=G_t;Fa.nearestPowerOf2=ewt;Fa.padNumber=K_t;Fa.stringToArrayBuffer=J_t;Fa.toBase64=Z_t;Fa.utilConcatBuf=z_t;Fa.utilConcatView=W_t;Fa.utilDecodeTC=H_t;Fa.utilEncodeTC=V_t;Fa.utilFromBase=ree;Fa.utilToBase=nee});var Gm=L(un=>{"use strict";var rwt=tee(),nwt=_De();function EDe(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var Zn=EDe(rwt),Hi=EDe(nwt);function FO(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function aee(t){let e=0,r=0;for(let i=0;i<t.length;i++){let s=t[i];e+=s.byteLength}let n=new Uint8Array(e);for(let i=0;i<t.length;i++){let s=t[i];n.set(new Uint8Array(s),r),r+=s.byteLength}return n.buffer}function U0(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var T_=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return aee(this.items)}},Pk=[new Uint8Array([1])],wDe="0123456789",iee="name",SDe="valueHexView",iwt="isHexOnly",swt="idBlock",awt="tagClass",owt="tagNumber",cwt="isConstructed",uwt="fromBER",lwt="toBER",fwt="local",yu="",th=new ArrayBuffer(0),GO=new Uint8Array(0),Ok="EndOfContent",TDe="OCTET STRING",CDe="BIT STRING";function rh(t){var e;return e=class extends t{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var i;super(...n);let s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?Zn.BufferSourceConverter.toUint8Array(s.valueHex):GO}fromBER(n,i,s,a){let c=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!U0(this,c,i,s))return-1;let d=i+s;return this.valueHexView=c.subarray(i,d),this.valueHexView.length?(this.blockLength=s,d):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",th)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Zn.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var N0=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:r=yu,warnings:n=[],valueBeforeDecode:i=GO}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=Zn.BufferSourceConverter.toUint8Array(i)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:Zn.Convert.ToHex(this.valueBeforeDecodeView)}}};N0.NAME="baseBlock";var lo=class extends N0{fromBER(e,r,n,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};lo.NAME="valueBlock";var PO=class extends rh(N0){constructor({idBlock:e={}}={}){var r,n,i,s;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?Zn.BufferSourceConverter.toUint8Array(e.valueHex):GO,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",th}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,r|=s,i[0]=r}return i.buffer}if(!this.isHexOnly){let i=Hi.utilToBase(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=r|31,!e){for(let d=0;d<a-1;d++)c[d+1]=s[d]|128;c[a]=s[a-1]}return c.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=r|31,!e){let i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;let c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let d=0;for(;;){let p=d+1;if(p>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(d++,(s[p]&128)===0)break}this.blockLength=d+1;let h=this.valueHexView=new Uint8Array(d);for(let p=0;p<d;p++)h[p]=s[p+1]&127;this.blockLength<=9?this.tagNumber=Hi.utilFromBase(h,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};PO.NAME="identificationBlock";var RO=class extends N0{constructor({lenBlock:e={}}={}){var r,n,i;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,r+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,r+this.blockLength;let a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let c=r+1,d=i.subarray(c,c+a);return d[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Hi.utilFromBase(d,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let i=Hi.utilToBase(this.length,8);if(i.byteLength>127)return this.error="Too big length",th;if(r=new ArrayBuffer(i.byteLength+1),e)return r;let s=new Uint8Array(i);n=new Uint8Array(r),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};RO.NAME="lengthBlock";var xr={},Wa=class extends N0{constructor({name:e=yu,optional:r=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new PO(i),this.lenBlock=new RO(i),this.valueBlock=s?new s(i):new lo(i)}fromBER(e,r,n,i){let s=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,i);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,r){let n=r||new T_;r||kDe(this);let i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return r?th:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():Zn.Convert.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,r=Zn.Convert.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${r}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let r=this.toBER(),n=e.toBER();return Hi.isEqualBuffer(r,n)}};Wa.NAME="BaseBlock";function kDe(t){var e;if(t instanceof xr.Constructed)for(let r of t.valueBlock.value)kDe(r)&&(t.lenBlock.isIndefiniteForm=!0);return!!(!((e=t.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}var Nk=class extends Wa{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=yu,...r}={},n){super(r,n),e&&this.fromString(e)}fromBER(e,r,n){let i=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Nk.NAME="BaseStringBlock";var OO=class extends rh(lo){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};OO.NAME="PrimitiveValueBlock";var DDe,Bk=class extends Wa{constructor(e={}){super(e,OO),this.idBlock.isConstructed=!1}};DDe=Bk;xr.Primitive=DDe;Bk.NAME="PRIMITIVE";var IDe=100,FDe=1e4,PDe=16*1024*1024,dwt="Maximum ASN.1 nesting depth exceeded",hwt="Maximum ASN.1 node count exceeded",pwt="Maximum ASN.1 content length exceeded";function h4(t={}){var e,r,n;return{depth:0,maxDepth:(e=t.maxDepth)!==null&&e!==void 0?e:IDe,nodesCount:0,maxNodes:(r=t.maxNodes)!==null&&r!==void 0?r:FDe,maxContentLength:(n=t.maxContentLength)!==null&&n!==void 0?n:PDe}}function mwt(t){let e=new Wa({},lo);return e.error=t,{offset:-1,result:e}}function gwt(t){if(t.nodesCount+=1,t.nodesCount>t.maxNodes)return hwt}function xwt(t,e){if(t>e.maxContentLength)return pwt}function oee(t,e,r,n){let i=n.depth+1;if(i>n.maxDepth)return mwt(dwt);n.depth=i;try{return KO(t,e,r,n)}finally{n.depth-=1}}function ywt(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function KO(t,e=0,r=t.length,n=h4()){let i=e,s=new Wa({},lo),a=new N0;if(!U0(a,t,e,r))return s.error=a.error,{offset:-1,result:s};if(!t.subarray(e,e+r).length)return s.error="Zero buffer length",{offset:-1,result:s};let d=gwt(n);if(d)return s.error=d,{offset:-1,result:s};let h=s.idBlock.fromBER(t,e,r);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),h===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=h,r-=s.idBlock.blockLength,h=s.lenBlock.fromBER(t,e,r),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),h===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};e=h,r-=s.lenBlock.blockLength;let p=s.lenBlock.isIndefiniteForm?r:s.lenBlock.length,x=xwt(p,n);if(x)return s.error=x,{offset:-1,result:s};if(!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let y=Wa;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};y=xr.EndOfContent;break;case 1:y=xr.Boolean;break;case 2:y=xr.Integer;break;case 3:y=xr.BitString;break;case 4:y=xr.OctetString;break;case 5:y=xr.Null;break;case 6:y=xr.ObjectIdentifier;break;case 10:y=xr.Enumerated;break;case 12:y=xr.Utf8String;break;case 13:y=xr.RelativeObjectIdentifier;break;case 14:y=xr.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:y=xr.Sequence;break;case 17:y=xr.Set;break;case 18:y=xr.NumericString;break;case 19:y=xr.PrintableString;break;case 20:y=xr.TeletexString;break;case 21:y=xr.VideotexString;break;case 22:y=xr.IA5String;break;case 23:y=xr.UTCTime;break;case 24:y=xr.GeneralizedTime;break;case 25:y=xr.GraphicString;break;case 26:y=xr.VisibleString;break;case 27:y=xr.GeneralString;break;case 28:y=xr.UniversalString;break;case 29:y=xr.CharacterString;break;case 30:y=xr.BmpString;break;case 31:y=xr.DATE;break;case 32:y=xr.TimeOfDay;break;case 33:y=xr.DateTime;break;case 34:y=xr.Duration;break;default:{let v=s.idBlock.isConstructed?new xr.Constructed:new xr.Primitive;v.idBlock=s.idBlock,v.lenBlock=s.lenBlock,v.warnings=s.warnings,s=v}}break;default:y=s.idBlock.isConstructed?xr.Constructed:xr.Primitive}return s=ywt(s,y),h=s.fromBER(t,e,p,n),s.valueBeforeDecodeView=t.subarray(i,i+s.blockLength),{offset:h,result:s}}function vwt(t,e={}){if(!t.byteLength){let r=new Wa({},lo);return r.error="Input buffer has zero length",{offset:-1,result:r}}return KO(Zn.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength,h4(e))}function bwt(t,e){return t?1:e}var Qd=class extends lo{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n,i){let s=Zn.BufferSourceConverter.toUint8Array(e),a=i??h4();if(!U0(this,s,r,n))return-1;if(this.valueBeforeDecodeView=s.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let c=r;for(;bwt(this.isIndefiniteForm,n)>0;){let d=oee(s,c,n,a);if(d.offset===-1)return this.error=d.result.error,this.warnings.concat(d.result.warnings),-1;if(c=d.offset,this.blockLength+=d.result.blockLength,n-=d.result.blockLength,this.value.push(d.result),this.isIndefiniteForm&&d.result.constructor.NAME===Ok)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Ok?this.value.pop():this.warnings.push("No EndOfContent block encoded")),c}toBER(e,r){let n=r||new T_;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return r?th:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};Qd.NAME="ConstructedValueBlock";var RDe,B0=class extends Wa{constructor(e={}){super(e,Qd),this.idBlock.isConstructed=!0}fromBER(e,r,n,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,r,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,i);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
995
1004
  `).map(i=>` ${i}`).join(`
996
1005
  `));let r=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${r} :
997
1006
  ${e.join(`
998
- `)}`:`${r} :`}};R6e=B0;xr.Constructed=R6e;B0.NAME="CONSTRUCTED";var NO=class extends lo{fromBER(e,r,n){return r}toBER(e){return th}};NO.override="EndOfContentValueBlock";var O6e,Uk=class extends Wa{constructor(e={}){super(e,NO),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};O6e=Uk;xr.EndOfContent=O6e;Uk.NAME=Ok;var N6e,Mk=class extends Wa{constructor(e={}){super(e,lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let i=new Uint8Array(n);i[0]=5,i[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};N6e=Mk;xr.Null=N6e;Mk.NAME="NULL";var BO=class extends rh(lo){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=Zn.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);return U0(this,i,r,n)?(this.valueHexView=i.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hi.utilDecodeTC.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};BO.NAME="BooleanValueBlock";var B6e,Lk=class extends Wa{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,BO),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};B6e=Lk;xr.Boolean=B6e;Lk.NAME="BOOLEAN";var UO=class extends rh(Qd){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n,i){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Qd.prototype.fromBER.call(this,e,r,n,i),s===-1)return s;for(let a=0;a<this.value.length;a++){let c=this.value[a].constructor.NAME;if(c===Ok){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(c!==T6e)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,r,n),this.blockLength=n;return s}toBER(e,r){return this.isConstructed?Qd.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};UO.NAME="OctetStringValueBlock";var cee,$k=class extends Wa{constructor({idBlock:e={},lenBlock:r={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},UO),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let a=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(a.byteLength){let c=i??h4(),d=oee(a,0,a.byteLength,c);d.offset!==-1&&d.offset===n&&(this.valueBlock.value=[d.result])}}catch{}}return super.fromBER(e,r,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return B0.prototype.onAsciiEncoding.call(this);let e=this.constructor.NAME,r=Zn.Convert.ToHex(this.valueBlock.valueHexView);return`${e} : ${r}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof cee&&e.push(r.valueBlock.valueHexView);return Zn.BufferSourceConverter.concat(e)}};cee=$k;xr.OctetString=cee;$k.NAME=T6e;var MO=class extends rh(Qd){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n,i){if(!n)return r;let s=-1;if(this.isConstructed){if(s=Qd.prototype.fromBER.call(this,e,r,n,i),s===-1)return s;for(let d of this.value){let h=d.constructor.NAME;if(h===Ok){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(h!==C6e)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let p=d.valueBlock;if(this.unusedBits>0&&p.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=p.unusedBits}return s}let a=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,a,r,n))return-1;let c=a.subarray(r,r+n);if(this.unusedBits=c[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let d=c.subarray(1);try{if(d.byteLength){let h=i??h4(),p=oee(d,0,d.byteLength,h);p.offset!==-1&&p.offset===n-1&&(this.value=[p.result])}}catch{}}return this.valueHexView=c.subarray(1),this.blockLength=c.length,r+n}toBER(e,r){if(this.isConstructed)return Qd.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let i=new Uint8Array(1);return i[0]=0,i.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};MO.NAME="BitStringValueBlock";var U6e,jk=class extends Wa{constructor({idBlock:e={},lenBlock:r={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},MO),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return B0.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let a of r)e.push(a.toString(2).padStart(8,"0"));let n=e.join(""),i=this.constructor.NAME,s=n.substring(0,n.length-this.valueBlock.unusedBits);return`${i} : ${s}`}}};U6e=jk;xr.BitString=U6e;jk.NAME=C6e;var M6e;function _wt(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,c=i.slice(0),d=c.length-1,h=0,p=d<a?a:d,x=0;for(let y=p;y>=0;y--,x++)!0===x<c.length?h=s[a-x]+c[d-x]+r[0]:h=s[a-x]+r[0],r[0]=h/10,!0===x>=s.length?s=Hi.utilConcatView(new Uint8Array([h%10]),s):s[a-x]=h%10;return r[0]>0&&(s=Hi.utilConcatView(r,s)),s}function A6e(t){if(t>=Pk.length)for(let e=Pk.length;e<=t;e++){let r=new Uint8Array([0]),n=Pk[e-1].slice(0);for(let i=n.length-1;i>=0;i--){let s=new Uint8Array([(n[i]<<1)+r[0]]);r[0]=s[0]/10,n[i]=s[0]%10}r[0]>0&&(n=Hi.utilConcatView(r,n)),Pk.push(n)}return Pk[t]}function wwt(t,e){let r=0,n=new Uint8Array(t),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,c=i.slice(0),d=c.length-1,h,p=0;for(let x=d;x>=0;x--,p++)h=s[a-p]-c[d-p]-r,!0===h<0?(r=1,s[a-p]=h+10):(r=0,s[a-p]=h);if(r>0)for(let x=a-d+1;x>=0;x--,p++)if(h=s[a-p]-r,h<0)r=1,s[a-p]=h+10;else{r=0,s[a-p]=h;break}return s.slice()}var qk=class extends rh(lo){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Hi.utilDecodeTC.call(this)))}constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Hi.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,i=0){let s=this.fromBER(e,r,n);if(s===-1)return s;let a=this.valueHexView;return a[0]===0&&(a[1]&128)!==0?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let i=super.fromBER(e,r,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,i,s=this.valueHexView,a="",c=!1;for(let d=s.byteLength-1;d>=0;d--){i=s[d];for(let h=0;h<8;h++)(i&1)===1&&(n===e?(r=wwt(A6e(n),r),a="-"):r=_wt(r,A6e(n))),n++,i>>=1}for(let d=0;d<r.length;d++)r[d]&&(c=!0),c&&(a+=w6e.charAt(r[d]));return c===!1&&(a+=w6e.charAt(0)),a}};M6e=qk;qk.NAME="IntegerValueBlock";Object.defineProperty(M6e.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Rk,C_=class extends Wa{constructor(e={}){super(e,qk),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return FO(),BigInt(this.valueBlock.toString())}static fromBigInt(e){FO();let r=BigInt(e),n=new T_,i=r.toString(16).replace(/^-/,""),s=new Uint8Array(Zn.Convert.FromHex(i));if(r<0){let c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;let h=BigInt(`0x${Zn.Convert.ToHex(c)}`)+r,p=Zn.BufferSourceConverter.toUint8Array(Zn.Convert.FromHex(h.toString(16)));p[0]|=128,n.write(p)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Rk({valueHex:n.final()})}convertToDER(){let e=new Rk({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Rk({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Rk=C_;xr.Integer=Rk;C_.NAME="INTEGER";var L6e,zk=class extends C_{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};L6e=zk;xr.Enumerated=L6e;zk.NAME="ENUMERATED";var Wk=class extends rh(lo){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,(s[c]&128)!==0);c++);let a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Hi.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){FO();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(r.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}let r=Hi.utilToBase(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",th;let n=new Uint8Array(r.byteLength);if(!e){let i=new Uint8Array(r),s=r.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=Zn.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Wk.NAME="sidBlock";var LO=class extends lo{constructor({value:e=yu,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let i=r;for(;n>0;){let s=new Wk;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,th;r.push(i)}return aee(r)}fromString(e){this.value=[];let r=0,n=0,i="",s=!1;do if(n=e.indexOf(".",r),n===-1?i=e.substring(r):i=e.substring(r,n),r=n+1,s){let a=this.value[0],c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}let d=parseInt(i,10);if(isNaN(d))return;a.valueDec=d+c,s=!1}else{let a=new Wk;if(i>Number.MAX_SAFE_INTEGER){FO();let c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),r?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};LO.NAME="ObjectIdentifierValueBlock";var $6e,Hk=class extends Wa{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,LO),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};$6e=Hk;xr.ObjectIdentifier=$6e;Hk.NAME="OBJECT IDENTIFIER";var Vk=class extends rh(N0){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,(s[c]&128)!==0);c++);let a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Hi.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}let r=Hi.utilToBase(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",th;let n=new Uint8Array(r.byteLength);if(!e){let i=new Uint8Array(r),s=r.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Zn.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Vk.NAME="relativeSidBlock";var $O=class extends lo{constructor({value:e=yu,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let i=r;for(;n>0;){let s=new Vk;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,r){let n=[];for(let i=0;i<this.value.length;i++){let s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,th;n.push(s)}return aee(n)}fromString(e){this.value=[];let r=0,n=0,i="";do{n=e.indexOf(".",r),n===-1?i=e.substring(r):i=e.substring(r,n),r=n+1;let s=new Vk;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(i=`{${i}}`),e+=i}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};$O.NAME="RelativeObjectIdentifierValueBlock";var j6e,Gk=class extends Wa{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,$O),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};j6e=Gk;xr.RelativeObjectIdentifier=j6e;Gk.NAME="RelativeObjectIdentifier";var q6e,Kk=class extends B0{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};q6e=Kk;xr.Sequence=q6e;Kk.NAME="SEQUENCE";var z6e,Zk=class extends B0{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};z6e=Zk;xr.Set=z6e;Zk.NAME="SET";var jO=class extends rh(lo){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=yu}toJSON(){return{...super.toJSON(),value:this.value}}};jO.NAME="StringValueBlock";var qO=class extends jO{};qO.NAME="SimpleStringValueBlock";var Uc=class extends Nk{constructor({...e}={}){super(e,qO)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Zn.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}};Uc.NAME="SIMPLE STRING";var zO=class extends Uc{fromBuffer(e){this.valueBlock.valueHexView=Zn.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Zn.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=Zn.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Zn.Convert.FromUtf8String(e)),this.valueBlock.value=e}};zO.NAME="Utf8StringValueBlock";var W6e,eh=class extends zO{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};W6e=eh;xr.Utf8String=W6e;eh.NAME="UTF8String";var WO=class extends Uc{fromBuffer(e){this.valueBlock.value=Zn.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Zn.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Zn.Convert.FromUtf16String(e))}};WO.NAME="BmpStringValueBlock";var H6e,Xk=class extends WO{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};H6e=Xk;xr.BmpString=H6e;Xk.NAME="BMPString";var HO=class extends Uc{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let i=0;i<r;i++){let s=Hi.utilToBase(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;let c=4-a.length;for(let d=a.length-1;d>=0;d--)n[i*4+d+c]=a[d]}this.valueBlock.value=e}};HO.NAME="UniversalStringValueBlock";var V6e,Yk=class extends HO{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};V6e=Yk;xr.UniversalString=V6e;Yk.NAME="UniversalString";var G6e,Jk=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};G6e=Jk;xr.NumericString=G6e;Jk.NAME="NumericString";var K6e,Qk=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};K6e=Qk;xr.PrintableString=K6e;Qk.NAME="PrintableString";var Z6e,e4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Z6e=e4;xr.TeletexString=Z6e;e4.NAME="TeletexString";var X6e,t4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};X6e=t4;xr.VideotexString=X6e;t4.NAME="VideotexString";var Y6e,r4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Y6e=r4;xr.IA5String=Y6e;r4.NAME="IA5String";var J6e,n4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};J6e=n4;xr.GraphicString=J6e;n4.NAME="GraphicString";var Q6e,k_=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Q6e=k_;xr.VisibleString=Q6e;k_.NAME="VisibleString";var eDe,i4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};eDe=i4;xr.GeneralString=eDe;i4.NAME="GeneralString";var tDe,s4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};tDe=s4;xr.CharacterString=tDe;s4.NAME="CharacterString";var rDe,D_=class extends k_{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Zn.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Hi.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Hi.padNumber(this.month,2),r[2]=Hi.padNumber(this.day,2),r[3]=Hi.padNumber(this.hour,2),r[4]=Hi.padNumber(this.minute,2),r[5]=Hi.padNumber(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};rDe=D_;xr.UTCTime=rDe;D_.NAME="UTCTime";var nDe,a4=class extends D_{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let r=!1,n="",i="",s=0,a,c=0,d=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let x=new Number(e[e.length-1]);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let x=1,y=n.indexOf("+"),v="";if(y===-1&&(y=n.indexOf("-"),x=-1),y!==-1){if(v=n.substring(y+1),n=n.substring(0,y),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let w=parseInt(v.substring(0,2),10);if(isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");if(c=x*w,v.length===4){if(w=parseInt(v.substring(2,4),10),isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");d=x*w}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){let x=new Number(`0${n.substring(h)}`);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");s=x.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.minute=Math.floor(x),x=60*(x-this.minute),this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=1e3*s;this.millisecond=Math.floor(x)}break;default:throw new Error("Wrong input string for conversion")}let p=a.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let x=1;x<p.length;x++)switch(x){case 1:this.year=parseInt(p[x],10);break;case 2:this.month=parseInt(p[x],10);break;case 3:this.day=parseInt(p[x],10);break;case 4:this.hour=parseInt(p[x],10)+c;break;case 5:this.minute=parseInt(p[x],10)+d;break;case 6:this.second=parseInt(p[x],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let x=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=x.getUTCFullYear(),this.month=x.getUTCMonth(),this.day=x.getUTCDay(),this.hour=x.getUTCHours(),this.minute=x.getUTCMinutes(),this.second=x.getUTCSeconds(),this.millisecond=x.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Hi.padNumber(this.year,4)),r.push(Hi.padNumber(this.month,2)),r.push(Hi.padNumber(this.day,2)),r.push(Hi.padNumber(this.hour,2)),r.push(Hi.padNumber(this.minute,2)),r.push(Hi.padNumber(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Hi.padNumber(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};nDe=a4;xr.GeneralizedTime=nDe;a4.NAME="GeneralizedTime";var iDe,o4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};iDe=o4;xr.DATE=iDe;o4.NAME="DATE";var sDe,c4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};sDe=c4;xr.TimeOfDay=sDe;c4.NAME="TimeOfDay";var aDe,u4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};aDe=u4;xr.DateTime=aDe;u4.NAME="DateTime";var oDe,l4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};oDe=l4;xr.Duration=oDe;l4.NAME="Duration";var cDe,f4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};cDe=f4;xr.TIME=cDe;f4.NAME="TIME";var qx=class{constructor({name:e=yu,optional:r=!1}={}){this.name=e,this.optional=r}},VO=class extends qx{constructor({value:e=[],...r}={}){super(r),this.value=e}},d4=class extends qx{constructor({value:e=new qx,local:r=!1,...n}={}){super(n),this.value=e,this.local=r}},see=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=Zn.BufferSourceConverter.toUint8Array(e)}constructor({data:e=GO}={}){this.dataView=Zn.BufferSourceConverter.toUint8Array(e)}fromBER(e,r,n){let i=r+n;return this.dataView=Zn.BufferSourceConverter.toUint8Array(e).subarray(r,i),i}toBER(e){return this.dataView.slice().buffer}};function E_(t,e,r){if(r instanceof VO){for(let s of r.value)if(E_(t,e,s).verified)return{verified:!0,result:t};{let s={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(iee)&&(s.name=r.name),s}}if(r instanceof qx)return r.hasOwnProperty(iee)&&(t[r.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(swt in r))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(uwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(lwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let n=r.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(r.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(r.idBlock.hasOwnProperty(awt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(r.idBlock.hasOwnProperty(owt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(r.idBlock.hasOwnProperty(cwt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(iwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(r.idBlock.isHexOnly){if(!(S6e in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let s=r.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(t[r.name]=e)),r instanceof xr.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=r.valueBlock.value.length;if(c>0&&r.valueBlock.value[0]instanceof d4&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&r.valueBlock.value.length!==0){let d=!0;for(let h=0;h<r.valueBlock.value.length;h++)d=d&&(r.valueBlock.value[h].optional||!1);return d?{verified:!0,result:t}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let d=0;d<c;d++)if(d-s>=e.valueBlock.value.length){if(r.valueBlock.value[d].optional===!1){let h={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],h.name=r.name)),h}}else if(r.valueBlock.value[0]instanceof d4){if(a=E_(t,e.valueBlock.value[d],r.valueBlock.value[0].value),a.verified===!1)if(r.valueBlock.value[0].optional)s++;else return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),a;if(iee in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let h={};fwt in r.valueBlock.value[0]&&r.valueBlock.value[0].local?h=e:h=t,typeof h[r.valueBlock.value[0].name]>"u"&&(h[r.valueBlock.value[0].name]=[]),h[r.valueBlock.value[0].name].push(e.valueBlock.value[d])}}else if(a=E_(t,e.valueBlock.value[d-s],r.valueBlock.value[d]),a.verified===!1)if(r.valueBlock.value[d].optional)s++;else return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),a;if(a.verified===!1){let d={verified:!1,result:t};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],d.name=r.name)),d}return{verified:!0,result:t}}if(r.primitiveSchema&&S6e in e.valueBlock){let s=KO(e.valueBlock.valueHexView);if(s.offset===-1){let a={verified:!1,result:s.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],a.name=r.name)),a}return E_(t,s.result,r.primitiveSchema)}return{verified:!0,result:t}}function Swt(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};let r=KO(Zn.BufferSourceConverter.toUint8Array(t));return r.offset===-1?{verified:!1,result:r.result}:E_(r.result,r.result,e)}un.Any=qx;un.BaseBlock=Wa;un.BaseStringBlock=Nk;un.BitString=jk;un.BmpString=Xk;un.Boolean=Lk;un.CharacterString=s4;un.Choice=VO;un.Constructed=B0;un.DATE=o4;un.DEFAULT_MAX_CONTENT_LENGTH=P6e;un.DEFAULT_MAX_DEPTH=I6e;un.DEFAULT_MAX_NODES=F6e;un.DateTime=u4;un.Duration=l4;un.EndOfContent=Uk;un.Enumerated=zk;un.GeneralString=i4;un.GeneralizedTime=a4;un.GraphicString=n4;un.HexBlock=rh;un.IA5String=r4;un.Integer=C_;un.Null=Mk;un.NumericString=Jk;un.ObjectIdentifier=Hk;un.OctetString=$k;un.Primitive=Bk;un.PrintableString=Qk;un.RawData=see;un.RelativeObjectIdentifier=Gk;un.Repeated=d4;un.Sequence=Kk;un.Set=Zk;un.TIME=f4;un.TeletexString=e4;un.TimeOfDay=c4;un.UTCTime=D_;un.UniversalString=Yk;un.Utf8String=eh;un.ValueBlock=lo;un.VideotexString=t4;un.ViewWriter=T_;un.VisibleString=k_;un.compareSchema=E_;un.fromBER=vwt;un.verifySchema=Swt});var g4=L(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});vu.isArrayBuffer=uee;vu.isSharedArrayBuffer=dDe;vu.isArrayBufferLike=p4;vu.isArrayBufferView=hDe;vu.isBufferSource=pDe;vu.assertBufferSource=m4;vu.toUint8Array=ZO;vu.toUint8ArrayCopy=mDe;vu.toArrayBuffer=kwt;vu.toArrayBufferLike=Dwt;vu.toView=gDe;vu.toViewCopy=Iwt;var Awt="[object ArrayBuffer]",Ewt="[object SharedArrayBuffer]";function uDe(t){return Object.prototype.toString.call(t)}function lDe(t){return t===DataView||t.prototype instanceof DataView}function Twt(t){return lDe(t)?1:t.BYTES_PER_ELEMENT??1}function Cwt(t){if(ArrayBuffer.isView(t))return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.byteOffset=="number"&&typeof e.byteLength=="number"&&p4(e.buffer)}function fDe(t){let e=ZO(t),r=new Uint8Array(e.byteLength);return r.set(e),r}function uee(t){return uDe(t)===Awt}function dDe(t){return typeof SharedArrayBuffer<"u"&&uDe(t)===Ewt}function p4(t){return uee(t)||dDe(t)}function hDe(t){return Cwt(t)}function pDe(t){return p4(t)||hDe(t)}function m4(t){if(!pDe(t))throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView")}function ZO(t){return m4(t),p4(t)?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function mDe(t){return fDe(t)}function kwt(t){if(m4(t),uee(t))return t;let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(ZO(t)),e}function Dwt(t){return m4(t),p4(t)?t:t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:fDe(t).buffer}function gDe(t,e){if(m4(t),ArrayBuffer.isView(t)&&t.constructor===e)return t;let r=ZO(t),n=Twt(e);if(r.byteOffset%n!==0||r.byteLength%n!==0)throw new RangeError(`Cannot create ${e.name} over unaligned byte range`);return lDe(e)?new e(r.buffer,r.byteOffset,r.byteLength):new e(r.buffer,r.byteOffset,r.byteLength/n)}function Iwt(t,e){let r=mDe(t);return gDe(r,e)}});var yDe=L(YO=>{"use strict";Object.defineProperty(YO,"__esModule",{value:!0});YO.concatToUint8Array=xDe;YO.concat=Fwt;var XO=g4();function xDe(t){let e=[],r=0;for(let s of t){let a=(0,XO.toUint8Array)(s);e.push(a),r+=a.byteLength}let n=new Uint8Array(r),i=0;for(let s of e)n.set(s,i),i+=s.byteLength;return n}function Fwt(t,e,...r){let n,i;typeof e=="function"?(n=Array.from(t),i=e):(0,XO.isBufferSource)(t)?n=[t,e,...r].filter(XO.isBufferSource):(n=Array.from(t),e&&n.push(e),n.push(...r));let s=xDe(n);return i?(0,XO.toView)(s,i):s.buffer}});var bDe=L(lee=>{"use strict";Object.defineProperty(lee,"__esModule",{value:!0});lee.equal=Pwt;var vDe=g4();function Pwt(t,e,r={}){let n=(0,vDe.toUint8Array)(t),i=(0,vDe.toUint8Array)(e);if(!r.constantTime&&n.byteLength!==i.byteLength)return!1;let s=Math.max(n.byteLength,i.byteLength),a=n.byteLength^i.byteLength;for(let c=0;c<s;c++)a|=(n[c]??0)^(i[c]??0);return a===0}});var SDe=L(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.indexOf=wDe;Of.lastIndexOf=Uwt;Of.includes=Mwt;Of.startsWith=Lwt;Of.endsWith=$wt;Of.slice=jwt;Of.tail=qwt;Of.copy=zwt;Of.compare=Wwt;var nh=g4();function JO(t,e,r){let n=Number.isFinite(t)?Math.trunc(t):e;return n<=0?0:n>=r?r:n}function Rwt(t,e){let r=JO(e?.start,0,t),n=JO(e?.end,t,t);return n>=r?[r,n]:[r,r]}function Owt(t,e){let r=JO(e?.start,t,t),n=JO(e?.end,0,t);return r>=n?[n,r]:[r,r]}function _De(t,e,r){let n=Number.isFinite(t)?Math.trunc(t):e;return n<0?Math.max(r+n,0):n>r?r:n}function Nwt(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r)&255;return e}function Bwt(t){return new TextEncoder().encode(t)}function QO(t,e){return typeof t=="string"?e?.encoding==="utf8"?Bwt(t):Nwt(t):(0,nh.toUint8Array)(t)}function eN(t,e,r){for(let n=0;n<e.byteLength;n++)if(t[r+n]!==e[n])return!1;return!0}function wDe(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r),[s,a]=Rwt(n.byteLength,r);if(i.byteLength===0)return s;let c=a-i.byteLength;if(c<s)return-1;for(let d=s;d<=c;d++)if(eN(n,i,d))return d;return-1}function Uwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r),[s,a]=Owt(n.byteLength,r);if(i.byteLength===0)return a;let c=a-i.byteLength;if(c<s)return-1;for(let d=c;d>=s;d--)if(eN(n,i,d))return d;return-1}function Mwt(t,e,r){return wDe(t,e,r)!==-1}function Lwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r);return i.byteLength>n.byteLength?!1:eN(n,i,0)}function $wt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r);return i.byteLength>n.byteLength?!1:eN(n,i,n.byteLength-i.byteLength)}function jwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=_De(e,0,n.byteLength),s=_De(r,n.byteLength,n.byteLength);return s<=i?n.subarray(i,i):n.subarray(i,s)}function qwt(t,e){let r=(0,nh.toUint8Array)(t),n=Number.isFinite(e)?Math.max(0,Math.trunc(e)):0;return n>=r.byteLength?r:r.subarray(r.byteLength-n)}function zwt(t){return(0,nh.toUint8ArrayCopy)(t)}function Wwt(t,e){let r=(0,nh.toUint8Array)(t),n=(0,nh.toUint8Array)(e),i=Math.min(r.byteLength,n.byteLength);for(let s=0;s<i;s++){if(r[s]<n[s])return-1;if(r[s]>n[s])return 1}return r.byteLength<n.byteLength?-1:r.byteLength>n.byteLength?1:0}});var el=L(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.tail=tn.startsWith=tn.slice=tn.lastIndexOf=tn.indexOf=tn.includes=tn.endsWith=tn.copy=tn.compare=tn.equal=tn.concatToUint8Array=tn.concat=tn.toViewCopy=tn.toView=tn.toUint8ArrayCopy=tn.toUint8Array=tn.toArrayBufferLike=tn.toArrayBuffer=tn.isSharedArrayBuffer=tn.isBufferSource=tn.isArrayBufferView=tn.isArrayBufferLike=tn.isArrayBuffer=tn.assertBufferSource=void 0;var Vl=g4();Object.defineProperty(tn,"assertBufferSource",{enumerable:!0,get:function(){return Vl.assertBufferSource}});Object.defineProperty(tn,"isArrayBuffer",{enumerable:!0,get:function(){return Vl.isArrayBuffer}});Object.defineProperty(tn,"isArrayBufferLike",{enumerable:!0,get:function(){return Vl.isArrayBufferLike}});Object.defineProperty(tn,"isArrayBufferView",{enumerable:!0,get:function(){return Vl.isArrayBufferView}});Object.defineProperty(tn,"isBufferSource",{enumerable:!0,get:function(){return Vl.isBufferSource}});Object.defineProperty(tn,"isSharedArrayBuffer",{enumerable:!0,get:function(){return Vl.isSharedArrayBuffer}});Object.defineProperty(tn,"toArrayBuffer",{enumerable:!0,get:function(){return Vl.toArrayBuffer}});Object.defineProperty(tn,"toArrayBufferLike",{enumerable:!0,get:function(){return Vl.toArrayBufferLike}});Object.defineProperty(tn,"toUint8Array",{enumerable:!0,get:function(){return Vl.toUint8Array}});Object.defineProperty(tn,"toUint8ArrayCopy",{enumerable:!0,get:function(){return Vl.toUint8ArrayCopy}});Object.defineProperty(tn,"toView",{enumerable:!0,get:function(){return Vl.toView}});Object.defineProperty(tn,"toViewCopy",{enumerable:!0,get:function(){return Vl.toViewCopy}});var ADe=yDe();Object.defineProperty(tn,"concat",{enumerable:!0,get:function(){return ADe.concat}});Object.defineProperty(tn,"concatToUint8Array",{enumerable:!0,get:function(){return ADe.concatToUint8Array}});var Hwt=bDe();Object.defineProperty(tn,"equal",{enumerable:!0,get:function(){return Hwt.equal}});var M0=SDe();Object.defineProperty(tn,"compare",{enumerable:!0,get:function(){return M0.compare}});Object.defineProperty(tn,"copy",{enumerable:!0,get:function(){return M0.copy}});Object.defineProperty(tn,"endsWith",{enumerable:!0,get:function(){return M0.endsWith}});Object.defineProperty(tn,"includes",{enumerable:!0,get:function(){return M0.includes}});Object.defineProperty(tn,"indexOf",{enumerable:!0,get:function(){return M0.indexOf}});Object.defineProperty(tn,"lastIndexOf",{enumerable:!0,get:function(){return M0.lastIndexOf}});Object.defineProperty(tn,"slice",{enumerable:!0,get:function(){return M0.slice}});Object.defineProperty(tn,"startsWith",{enumerable:!0,get:function(){return M0.startsWith}});Object.defineProperty(tn,"tail",{enumerable:!0,get:function(){return M0.tail}})});var zx=L(I_=>{"use strict";Object.defineProperty(I_,"__esModule",{value:!0});I_.AsnPropTypes=I_.AsnTypeTypes=void 0;var EDe;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(EDe||(I_.AsnTypeTypes=EDe={}));var TDe;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(TDe||(I_.AsnPropTypes=TDe={}))});var CDe=L(tN=>{"use strict";Object.defineProperty(tN,"__esModule",{value:!0});tN.BitString=void 0;var Vwt=(at(),He(st)),fee=Vwt.__importStar(Gm()),dee=el(),hee=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,r=0){if(e)if(typeof e=="number")this.fromNumber(e);else if((0,dee.isBufferSource)(e))this.unusedBits=r,this.value=(0,dee.toArrayBuffer)(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof fee.BitString))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,dee.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new fee.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new fee.BitString({name:e})}toNumber(){let e="",r=new Uint8Array(this.value);for(let n of r)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let r=e.toString(2),n=r.length+7>>3;this.unusedBits=(n<<3)-r.length;let i=new Uint8Array(n);r=r.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(r.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}};tN.BitString=hee});var kDe=L(rN=>{"use strict";Object.defineProperty(rN,"__esModule",{value:!0});rN.OctetString=void 0;var Gwt=(at(),He(st)),pee=Gwt.__importStar(Gm()),mee=el(),gee=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):(0,mee.isBufferSource)(e)?this.buffer=(0,mee.toArrayBuffer)(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof pee.OctetString))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=(0,mee.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new pee.OctetString({valueHex:this.buffer})}toSchema(e){return new pee.OctetString({name:e})}};rN.OctetString=gee});var xee=L(nN=>{"use strict";Object.defineProperty(nN,"__esModule",{value:!0});var DDe=(at(),He(st));DDe.__exportStar(CDe(),nN);DDe.__exportStar(kDe(),nN)});var x4=L(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.AsnNullConverter=nr.AsnGeneralizedTimeConverter=nr.AsnUTCTimeConverter=nr.AsnCharacterStringConverter=nr.AsnGeneralStringConverter=nr.AsnVisibleStringConverter=nr.AsnGraphicStringConverter=nr.AsnIA5StringConverter=nr.AsnVideotexStringConverter=nr.AsnTeletexStringConverter=nr.AsnPrintableStringConverter=nr.AsnNumericStringConverter=nr.AsnUniversalStringConverter=nr.AsnBmpStringConverter=nr.AsnUtf8StringConverter=nr.AsnConstructedOctetStringConverter=nr.AsnOctetStringConverter=nr.AsnBooleanConverter=nr.AsnObjectIdentifierConverter=nr.AsnBitStringConverter=nr.AsnIntegerBigIntConverter=nr.AsnIntegerArrayBufferConverter=nr.AsnEnumeratedConverter=nr.AsnIntegerConverter=nr.AsnAnyConverter=void 0;nr.defaultConverter=Xwt;var Kwt=(at(),He(st)),ys=Kwt.__importStar(Gm()),iN=el(),ua=zx(),Zwt=xee();nr.AsnAnyConverter={fromASN:t=>t instanceof ys.Null?null:(0,iN.toArrayBuffer)(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new ys.Null;let e=ys.fromBER(t);if(e.result.error)throw new Error(e.result.error);return e.result}};nr.AsnIntegerConverter={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new ys.Integer({value:+t})};nr.AsnEnumeratedConverter={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ys.Enumerated({value:t})};nr.AsnIntegerArrayBufferConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.Integer({valueHex:t})};nr.AsnIntegerBigIntConverter={fromASN:t=>t.toBigInt(),toASN:t=>ys.Integer.fromBigInt(t)};nr.AsnBitStringConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.BitString({valueHex:t})};nr.AsnObjectIdentifierConverter={fromASN:t=>t.valueBlock.toString(),toASN:t=>new ys.ObjectIdentifier({value:t})};nr.AsnBooleanConverter={fromASN:t=>t.valueBlock.value,toASN:t=>new ys.Boolean({value:t})};nr.AsnOctetStringConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.OctetString({valueHex:t})};nr.AsnConstructedOctetStringConverter={fromASN:t=>new Zwt.OctetString(t.getValue()),toASN:t=>t.toASN()};function Gl(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}nr.AsnUtf8StringConverter=Gl(ys.Utf8String);nr.AsnBmpStringConverter=Gl(ys.BmpString);nr.AsnUniversalStringConverter=Gl(ys.UniversalString);nr.AsnNumericStringConverter=Gl(ys.NumericString);nr.AsnPrintableStringConverter=Gl(ys.PrintableString);nr.AsnTeletexStringConverter=Gl(ys.TeletexString);nr.AsnVideotexStringConverter=Gl(ys.VideotexString);nr.AsnIA5StringConverter=Gl(ys.IA5String);nr.AsnGraphicStringConverter=Gl(ys.GraphicString);nr.AsnVisibleStringConverter=Gl(ys.VisibleString);nr.AsnGeneralStringConverter=Gl(ys.GeneralString);nr.AsnCharacterStringConverter=Gl(ys.CharacterString);nr.AsnUTCTimeConverter={fromASN:t=>t.toDate(),toASN:t=>new ys.UTCTime({valueDate:t})};nr.AsnGeneralizedTimeConverter={fromASN:t=>t.toDate(),toASN:t=>new ys.GeneralizedTime({valueDate:t})};nr.AsnNullConverter={fromASN:()=>null,toASN:()=>new ys.Null};function Xwt(t){switch(t){case ua.AsnPropTypes.Any:return nr.AsnAnyConverter;case ua.AsnPropTypes.BitString:return nr.AsnBitStringConverter;case ua.AsnPropTypes.BmpString:return nr.AsnBmpStringConverter;case ua.AsnPropTypes.Boolean:return nr.AsnBooleanConverter;case ua.AsnPropTypes.CharacterString:return nr.AsnCharacterStringConverter;case ua.AsnPropTypes.Enumerated:return nr.AsnEnumeratedConverter;case ua.AsnPropTypes.GeneralString:return nr.AsnGeneralStringConverter;case ua.AsnPropTypes.GeneralizedTime:return nr.AsnGeneralizedTimeConverter;case ua.AsnPropTypes.GraphicString:return nr.AsnGraphicStringConverter;case ua.AsnPropTypes.IA5String:return nr.AsnIA5StringConverter;case ua.AsnPropTypes.Integer:return nr.AsnIntegerConverter;case ua.AsnPropTypes.Null:return nr.AsnNullConverter;case ua.AsnPropTypes.NumericString:return nr.AsnNumericStringConverter;case ua.AsnPropTypes.ObjectIdentifier:return nr.AsnObjectIdentifierConverter;case ua.AsnPropTypes.OctetString:return nr.AsnOctetStringConverter;case ua.AsnPropTypes.PrintableString:return nr.AsnPrintableStringConverter;case ua.AsnPropTypes.TeletexString:return nr.AsnTeletexStringConverter;case ua.AsnPropTypes.UTCTime:return nr.AsnUTCTimeConverter;case ua.AsnPropTypes.UniversalString:return nr.AsnUniversalStringConverter;case ua.AsnPropTypes.Utf8String:return nr.AsnUtf8StringConverter;case ua.AsnPropTypes.VideotexString:return nr.AsnVideotexStringConverter;case ua.AsnPropTypes.VisibleString:return nr.AsnVisibleStringConverter;default:return null}}});var sN=L(y4=>{"use strict";Object.defineProperty(y4,"__esModule",{value:!0});y4.isConvertible=IDe;y4.isTypeOfArray=FDe;y4.isArrayEqual=Ywt;function IDe(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:IDe(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function FDe(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?!0:FDe(e)}return!1}function Ywt(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(r[i]!==n[i])return!1;return!0}});var RDe=L(aN=>{"use strict";Object.defineProperty(aN,"__esModule",{value:!0});aN.AsnSchemaStorage=void 0;var Jwt=(at(),He(st)),tl=Jwt.__importStar(Gm()),F_=zx(),PDe=sN(),yee=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,r=!1){let n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(r&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let r=this.get(e);r.schema||(r.schema=this.create(e,!0))}createDefault(e){let r={type:F_.AsnTypeTypes.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(r,n),r.items=Object.assign({},r.items,n.items)),r}create(e,r){let n=this.items.get(e)||this.createDefault(e),i=[];for(let s in n.items){let a=n.items[s],c=r?s:"",d;if(typeof a.type=="number"){let p=F_.AsnPropTypes[a.type],x=tl[p];if(!x)throw new Error(`Cannot get ASN1 class by name '${p}'`);d=new x({name:c})}else(0,PDe.isConvertible)(a.type)?d=new a.type().toSchema(c):a.optional?this.get(a.type).type===F_.AsnTypeTypes.Choice?d=new tl.Any({name:c}):(d=this.create(a.type,!1),d.name=c):d=new tl.Any({name:c});let h=!!a.optional||a.defaultValue!==void 0;if(a.repeated){d.name="";let p=a.repeated==="set"?tl.Set:tl.Sequence;d=new p({name:"",value:[new tl.Repeated({name:c,value:d})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||(0,PDe.isConvertible)(a.type)){let p=a.repeated?tl.Constructed:tl.Primitive;i.push(new p({name:c,optional:h,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);let p=!!a.repeated,x=p?d:this.get(a.type,!0).schema;x="valueBlock"in x?x.valueBlock.value:x.value,i.push(new tl.Constructed({name:p?"":c,optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:x}))}else i.push(new tl.Constructed({optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:[d]}));else d.optional=h,i.push(d)}switch(n.type){case F_.AsnTypeTypes.Sequence:return new tl.Sequence({value:i,name:""});case F_.AsnTypeTypes.Set:return new tl.Set({value:i,name:""});case F_.AsnTypeTypes.Choice:return new tl.Choice({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,r){return this.items.set(e,r),this}findParentSchema(e){let r=Object.getPrototypeOf(e);return r?this.items.get(r)||this.findParentSchema(r):null}};aN.AsnSchemaStorage=yee});var cN=L(oN=>{"use strict";Object.defineProperty(oN,"__esModule",{value:!0});oN.schemaStorage=void 0;var Qwt=RDe();oN.schemaStorage=new Qwt.AsnSchemaStorage});var ODe=L(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.AsnProp=Mc.AsnSequenceType=Mc.AsnSetType=Mc.AsnChoiceType=Mc.AsnType=void 0;var eSt=(at(),He(st)),tSt=eSt.__importStar(x4()),vee=zx(),Km=cN(),rSt=t=>e=>{let r;Km.schemaStorage.has(e)?r=Km.schemaStorage.get(e):(r=Km.schemaStorage.createDefault(e),Km.schemaStorage.set(e,r)),Object.assign(r,t)};Mc.AsnType=rSt;var nSt=()=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Choice});Mc.AsnChoiceType=nSt;var iSt=t=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Set,...t});Mc.AsnSetType=iSt;var sSt=t=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Sequence,...t});Mc.AsnSequenceType=sSt;var aSt=t=>(e,r)=>{let n;Km.schemaStorage.has(e.constructor)?n=Km.schemaStorage.get(e.constructor):(n=Km.schemaStorage.createDefault(e.constructor),Km.schemaStorage.set(e.constructor,n));let i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){let s=tSt.defaultConverter(t.type);if(!s)throw new Error(`Cannot get default converter for property '${r}' of ${e.constructor.name}`);i.converter=s}i.raw=t.raw,n.items[r]=i};Mc.AsnProp=aSt});var NDe=L(uN=>{"use strict";Object.defineProperty(uN,"__esModule",{value:!0});uN.AsnSchemaValidationError=void 0;var bee=class extends Error{schemas=[]};uN.AsnSchemaValidationError=bee});var wee=L(_ee=>{"use strict";Object.defineProperty(_ee,"__esModule",{value:!0});var oSt=(at(),He(st));oSt.__exportStar(NDe(),_ee)});var Eee=L(lN=>{"use strict";Object.defineProperty(lN,"__esModule",{value:!0});lN.AsnParser=void 0;var BDe=(at(),He(st)),bu=BDe.__importStar(Gm()),cSt=el(),Zm=zx(),See=BDe.__importStar(x4()),v4=wee(),b4=sN(),Wx=cN(),Aee=class{static parse(e,r,n){let i=bu.fromBER((0,cSt.toArrayBuffer)(e),n?.berOptions);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,r,n)}static fromASN(e,r,n){try{if((0,b4.isConvertible)(r))return new r().fromASN(e);let i=Wx.schemaStorage.get(r);Wx.schemaStorage.cache(r);let s=i.schema,a=this.handleChoiceTypes(e,i,r,s,n);if(a?.result)return a.result;a?.targetSchema&&(s=a.targetSchema);let c=this.handleSequenceTypes(e,i,r,s),d=new r;return(0,b4.isTypeOfArray)(r)?this.handleArrayTypes(e,i,r,n):(this.processSchemaItems(i,c,d,n),d)}catch(i){throw i instanceof v4.AsnSchemaValidationError&&i.schemas.push(r.name),i}}static handleChoiceTypes(e,r,n,i,s){if(e.constructor===bu.Constructed&&r.type===Zm.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let a in r.items){let c=r.items[a];if(c.context===e.idBlock.tagNumber&&c.implicit&&typeof c.type=="function"&&Wx.schemaStorage.has(c.type)){let d=Wx.schemaStorage.get(c.type);if(d&&d.type===Zm.AsnTypeTypes.Sequence){let h=new bu.Sequence;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in h.valueBlock){h.valueBlock.value=e.valueBlock.value;let p=this.fromASN(h,c.type,s),x=new n;return x[a]=p,{result:x}}}}}else if(e.constructor===bu.Constructed&&r.type!==Zm.AsnTypeTypes.Choice){let a=new bu.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(let c in r.items)delete e[c];return{targetSchema:a}}return null}static handleSequenceTypes(e,r,n,i){if(r.type===Zm.AsnTypeTypes.Sequence){let s=bu.compareSchema({},e,i);if(!s.verified)throw new v4.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}else{let s=bu.compareSchema({},e,i);if(!s.verified)throw new v4.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}}static processRepeatedField(e,r,n){let i=e.slice(r);if(i.length===1&&i[0].constructor.name==="Sequence"){let s=i[0];s.valueBlock&&s.valueBlock.value&&Array.isArray(s.valueBlock.value)&&(i=s.valueBlock.value)}if(typeof n.type=="number"){let s=See.defaultConverter(n.type);if(!s)throw new Error(`No converter for ASN.1 type ${n.type}`);return i.filter(a=>a&&a.valueBlock).map(a=>{try{return s.fromASN(a)}catch{return}}).filter(a=>a!==void 0)}else return i.filter(s=>s&&s.valueBlock).map(s=>{try{return this.fromASN(s,n.type)}catch{return}}).filter(s=>s!==void 0)}static processPrimitiveField(e,r){let n=See.defaultConverter(r.type);if(!n)throw new Error(`No converter for ASN.1 type ${r.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Wx.schemaStorage.has(e.type)&&Wx.schemaStorage.get(e.type).type===Zm.AsnTypeTypes.Choice}static processOptionalChoiceField(e,r){try{return{processed:!0,value:this.fromASN(e,r.type)}}catch(n){if(n instanceof v4.AsnSchemaValidationError&&/Wrong values for Choice type/.test(n.message))return{processed:!1};throw n}}static handleArrayTypes(e,r,n,i){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let s=r.itemType;if(typeof s=="number"){let a=See.defaultConverter(s);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,c=>a.fromASN(c))}else return n.from(e.valueBlock.value,a=>this.fromASN(a,s,i))}static processSchemaItems(e,r,n,i){for(let s in e.items){let a=r.result[s];if(!a)continue;let c=e.items[s],d=c.type,h;typeof d=="number"||(0,b4.isConvertible)(d)?h=this.processPrimitiveSchemaItem(a,c,d,i):h=this.processComplexSchemaItem(a,c,d,i),h&&typeof h=="object"&&"value"in h&&"raw"in h?(n[s]=h.value,n[`${s}Raw`]=h.raw):n[s]=h}}static processPrimitiveSchemaItem(e,r,n,i){let s=r.converter??((0,b4.isConvertible)(n)?new n:null);if(!s)throw new Error("Converter is empty");return r.repeated?this.processRepeatedPrimitiveItem(e,r,s,i):this.processSinglePrimitiveItem(e,r,n,s,i)}static processRepeatedPrimitiveItem(e,r,n,i){if(r.implicit){let s=r.repeated==="sequence"?bu.Sequence:bu.Set,a=new s;a.valueBlock=e.valueBlock;let c=bu.fromBER(a.toBER(!1),i?.berOptions);if(c.offset===-1)throw new Error(`Cannot parse the child item. ${c.result.error}`);if(!("value"in c.result.valueBlock&&Array.isArray(c.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let d=c.result.valueBlock.value;return Array.from(d,h=>n.fromASN(h))}else return Array.from(e,s=>n.fromASN(s))}static processSinglePrimitiveItem(e,r,n,i,s){let a=e;if(r.implicit){let c;if((0,b4.isConvertible)(n))c=new n().toSchema("");else{let d=Zm.AsnPropTypes[n],h=bu[d];if(!h)throw new Error(`Cannot get '${d}' class from asn1js module`);c=new h}c.valueBlock=a.valueBlock,a=bu.fromBER(c.toBER(!1),s?.berOptions).result}return i.fromASN(a)}static processComplexSchemaItem(e,r,n,i){if(r.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,s=>this.fromASN(s,n,i))}else{let s=this.handleImplicitTagging(e,r,n);if(this.isOptionalChoiceField(r))try{return this.fromASN(s,n,i)}catch(a){if(a instanceof v4.AsnSchemaValidationError&&/Wrong values for Choice type/.test(a.message))return;throw a}else{let a=this.fromASN(s,n,i);return r.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,r,n){if(r.implicit&&typeof r.context=="number"){let i=Wx.schemaStorage.get(n);if(i.type===Zm.AsnTypeTypes.Sequence){let s=new bu.Sequence;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in s.valueBlock)return s.valueBlock.value=e.valueBlock.value,s}else if(i.type===Zm.AsnTypeTypes.Set){let s=new bu.Set;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in s.valueBlock)return s.valueBlock.value=e.valueBlock.value,s}}return e}};lN.AsnParser=Aee});var kee=L(dN=>{"use strict";Object.defineProperty(dN,"__esModule",{value:!0});dN.AsnSerializer=void 0;var MDe=(at(),He(st)),Nf=MDe.__importStar(Gm()),uSt=el(),lSt=MDe.__importStar(x4()),fN=zx(),Tee=sN(),UDe=cN(),Cee=class t{static serialize(e){return e instanceof Nf.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&(0,Tee.isConvertible)(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let r=e.constructor,n=UDe.schemaStorage.get(r);UDe.schemaStorage.cache(r);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){let a=lSt.defaultConverter(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",r,a))}else for(let a in n.items){let c=n.items[a],d=e[a];if(d===void 0||c.defaultValue===d||typeof c.defaultValue=="object"&&typeof d=="object"&&(0,Tee.isArrayEqual)(this.serialize(c.defaultValue),this.serialize(d)))continue;let h=t.toAsnItem(c,a,r,d);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||(0,Tee.isConvertible)(c.type))){let p={};p.valueHex=h instanceof Nf.Null?(0,uSt.toArrayBuffer)(h.valueBeforeDecodeView):h.valueBlock.toBER(),i.push(new Nf.Primitive({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new Nf.Constructed({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new Nf.Constructed({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case fN.AsnTypeTypes.Sequence:s=new Nf.Sequence({value:i});break;case fN.AsnTypeTypes.Set:s=new Nf.Set({value:i});break;case fN.AsnTypeTypes.Choice:if(!i[0])throw new Error(`Schema '${r.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,r,n,i){let s;if(typeof e.type=="number"){let a=e.converter;if(!a)throw new Error(`Property '${r}' doesn't have converter for type ${fN.AsnPropTypes[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");let c=Array.from(i,h=>a.toASN(h)),d=e.repeated==="sequence"?Nf.Sequence:Nf.Set;s=new d({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(i,d=>this.toASN(d)),c=e.repeated==="sequence"?Nf.Sequence:Nf.Set;s=new c({value:a})}else s=this.toASN(i);return s}};dN.AsnSerializer=Cee});var LDe=L(hN=>{"use strict";Object.defineProperty(hN,"__esModule",{value:!0});hN.AsnArray=void 0;var Dee=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(let r of e)this.push(r)}}};hN.AsnArray=Dee});var jDe=L(pN=>{"use strict";Object.defineProperty(pN,"__esModule",{value:!0});pN.AsnConvert=void 0;var fSt=(at(),He(st)),dSt=fSt.__importStar(Gm()),$De=el(),hSt=Eee(),pSt=kee(),Iee=class t{static serialize(e){return pSt.AsnSerializer.serialize(e)}static parse(e,r,n){return hSt.AsnParser.parse(e,r,n)}static toString(e,r){let n=(0,$De.isBufferSource)(e)?(0,$De.toArrayBuffer)(e):t.serialize(e),i=dSt.fromBER(n,r?.berOptions);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}};pN.AsnConvert=Iee});var bt=L(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});Ds.AsnSerializer=Ds.AsnParser=Ds.AsnPropTypes=Ds.AsnTypeTypes=Ds.AsnSetType=Ds.AsnSequenceType=Ds.AsnChoiceType=Ds.AsnType=Ds.AsnProp=void 0;var _4=(at(),He(st));_4.__exportStar(x4(),Ds);_4.__exportStar(xee(),Ds);var w4=ODe();Object.defineProperty(Ds,"AsnProp",{enumerable:!0,get:function(){return w4.AsnProp}});Object.defineProperty(Ds,"AsnType",{enumerable:!0,get:function(){return w4.AsnType}});Object.defineProperty(Ds,"AsnChoiceType",{enumerable:!0,get:function(){return w4.AsnChoiceType}});Object.defineProperty(Ds,"AsnSequenceType",{enumerable:!0,get:function(){return w4.AsnSequenceType}});Object.defineProperty(Ds,"AsnSetType",{enumerable:!0,get:function(){return w4.AsnSetType}});var qDe=zx();Object.defineProperty(Ds,"AsnTypeTypes",{enumerable:!0,get:function(){return qDe.AsnTypeTypes}});Object.defineProperty(Ds,"AsnPropTypes",{enumerable:!0,get:function(){return qDe.AsnPropTypes}});var mSt=Eee();Object.defineProperty(Ds,"AsnParser",{enumerable:!0,get:function(){return mSt.AsnParser}});var gSt=kee();Object.defineProperty(Ds,"AsnSerializer",{enumerable:!0,get:function(){return gSt.AsnSerializer}});_4.__exportStar(wee(),Ds);_4.__exportStar(LDe(),Ds);_4.__exportStar(jDe(),Ds)});var Fee=L(Hx=>{"use strict";Object.defineProperty(Hx,"__esModule",{value:!0});Hx.binary=void 0;Hx.encode=zDe;Hx.decode=WDe;Hx.is=HDe;var xSt=el();function zDe(t){let e=(0,xSt.toUint8Array)(t),r="";for(let n of e)r+=String.fromCharCode(n);return r}function WDe(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r)&255;return e}function HDe(t){return typeof t=="string"}Hx.binary={encode:zDe,decode:WDe,is:HDe}});var YDe=L(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.hex=rl.formats=void 0;rl.normalize=S4;rl.is=KDe;rl.encode=Pee;rl.decode=Ree;rl.parse=ZDe;rl.format=XDe;var ySt=el(),vSt=/^[0-9a-f]$/i,bSt=[" "," ",`
1007
+ `)}`:`${r} :`}};RDe=B0;xr.Constructed=RDe;B0.NAME="CONSTRUCTED";var NO=class extends lo{fromBER(e,r,n){return r}toBER(e){return th}};NO.override="EndOfContentValueBlock";var ODe,Uk=class extends Wa{constructor(e={}){super(e,NO),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};ODe=Uk;xr.EndOfContent=ODe;Uk.NAME=Ok;var NDe,Mk=class extends Wa{constructor(e={}){super(e,lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let i=new Uint8Array(n);i[0]=5,i[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};NDe=Mk;xr.Null=NDe;Mk.NAME="NULL";var BO=class extends rh(lo){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=Zn.BufferSourceConverter.toUint8Array(r.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,r,n){let i=Zn.BufferSourceConverter.toUint8Array(e);return U0(this,i,r,n)?(this.valueHexView=i.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hi.utilDecodeTC.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};BO.NAME="BooleanValueBlock";var BDe,Lk=class extends Wa{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,BO),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};BDe=Lk;xr.Boolean=BDe;Lk.NAME="BOOLEAN";var UO=class extends rh(Qd){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n,i){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Qd.prototype.fromBER.call(this,e,r,n,i),s===-1)return s;for(let a=0;a<this.value.length;a++){let c=this.value[a].constructor.NAME;if(c===Ok){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(c!==TDe)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,r,n),this.blockLength=n;return s}toBER(e,r){return this.isConstructed?Qd.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};UO.NAME="OctetStringValueBlock";var cee,$k=class extends Wa{constructor({idBlock:e={},lenBlock:r={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},UO),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,n,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),r;if(!this.valueBlock.isConstructed){let a=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(a.byteLength){let c=i??h4(),d=oee(a,0,a.byteLength,c);d.offset!==-1&&d.offset===n&&(this.valueBlock.value=[d.result])}}catch{}}return super.fromBER(e,r,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return B0.prototype.onAsciiEncoding.call(this);let e=this.constructor.NAME,r=Zn.Convert.ToHex(this.valueBlock.valueHexView);return`${e} : ${r}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let r of this.valueBlock.value)r instanceof cee&&e.push(r.valueBlock.valueHexView);return Zn.BufferSourceConverter.concat(e)}};cee=$k;xr.OctetString=cee;$k.NAME=TDe;var MO=class extends rh(Qd){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n,i){if(!n)return r;let s=-1;if(this.isConstructed){if(s=Qd.prototype.fromBER.call(this,e,r,n,i),s===-1)return s;for(let d of this.value){let h=d.constructor.NAME;if(h===Ok){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(h!==CDe)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let p=d.valueBlock;if(this.unusedBits>0&&p.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=p.unusedBits}return s}let a=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,a,r,n))return-1;let c=a.subarray(r,r+n);if(this.unusedBits=c[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let d=c.subarray(1);try{if(d.byteLength){let h=i??h4(),p=oee(d,0,d.byteLength,h);p.offset!==-1&&p.offset===n-1&&(this.value=[p.result])}}catch{}}return this.valueHexView=c.subarray(1),this.blockLength=c.length,r+n}toBER(e,r){if(this.isConstructed)return Qd.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let i=new Uint8Array(1);return i[0]=0,i.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};MO.NAME="BitStringValueBlock";var UDe,jk=class extends Wa{constructor({idBlock:e={},lenBlock:r={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},MO),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return B0.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let a of r)e.push(a.toString(2).padStart(8,"0"));let n=e.join(""),i=this.constructor.NAME,s=n.substring(0,n.length-this.valueBlock.unusedBits);return`${i} : ${s}`}}};UDe=jk;xr.BitString=UDe;jk.NAME=CDe;var MDe;function _wt(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,c=i.slice(0),d=c.length-1,h=0,p=d<a?a:d,x=0;for(let y=p;y>=0;y--,x++)!0===x<c.length?h=s[a-x]+c[d-x]+r[0]:h=s[a-x]+r[0],r[0]=h/10,!0===x>=s.length?s=Hi.utilConcatView(new Uint8Array([h%10]),s):s[a-x]=h%10;return r[0]>0&&(s=Hi.utilConcatView(r,s)),s}function ADe(t){if(t>=Pk.length)for(let e=Pk.length;e<=t;e++){let r=new Uint8Array([0]),n=Pk[e-1].slice(0);for(let i=n.length-1;i>=0;i--){let s=new Uint8Array([(n[i]<<1)+r[0]]);r[0]=s[0]/10,n[i]=s[0]%10}r[0]>0&&(n=Hi.utilConcatView(r,n)),Pk.push(n)}return Pk[t]}function wwt(t,e){let r=0,n=new Uint8Array(t),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,c=i.slice(0),d=c.length-1,h,p=0;for(let x=d;x>=0;x--,p++)h=s[a-p]-c[d-p]-r,!0===h<0?(r=1,s[a-p]=h+10):(r=0,s[a-p]=h);if(r>0)for(let x=a-d+1;x>=0;x--,p++)if(h=s[a-p]-r,h<0)r=1,s[a-p]=h+10;else{r=0,s[a-p]=h;break}return s.slice()}var qk=class extends rh(lo){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Hi.utilDecodeTC.call(this)))}constructor({value:e,...r}={}){super(r),this._valueDec=0,r.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Hi.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,i=0){let s=this.fromBER(e,r,n);if(s===-1)return s;let a=this.valueHexView;return a[0]===0&&(a[1]&128)!==0?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){let r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let i=super.fromBER(e,r,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,r=new Uint8Array(this.valueHexView.length*8/3),n=0,i,s=this.valueHexView,a="",c=!1;for(let d=s.byteLength-1;d>=0;d--){i=s[d];for(let h=0;h<8;h++)(i&1)===1&&(n===e?(r=wwt(ADe(n),r),a="-"):r=_wt(r,ADe(n))),n++,i>>=1}for(let d=0;d<r.length;d++)r[d]&&(c=!0),c&&(a+=wDe.charAt(r[d]));return c===!1&&(a+=wDe.charAt(0)),a}};MDe=qk;qk.NAME="IntegerValueBlock";Object.defineProperty(MDe.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Rk,C_=class extends Wa{constructor(e={}){super(e,qk),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return FO(),BigInt(this.valueBlock.toString())}static fromBigInt(e){FO();let r=BigInt(e),n=new T_,i=r.toString(16).replace(/^-/,""),s=new Uint8Array(Zn.Convert.FromHex(i));if(r<0){let c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;let h=BigInt(`0x${Zn.Convert.ToHex(c)}`)+r,p=Zn.BufferSourceConverter.toUint8Array(Zn.Convert.FromHex(h.toString(16)));p[0]|=128,n.write(p)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Rk({valueHex:n.final()})}convertToDER(){let e=new Rk({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Rk({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Rk=C_;xr.Integer=Rk;C_.NAME="INTEGER";var LDe,zk=class extends C_{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};LDe=zk;xr.Enumerated=LDe;zk.NAME="ENUMERATED";var Wk=class extends rh(lo){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,(s[c]&128)!==0);c++);let a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Hi.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){FO();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(r.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}let r=Hi.utilToBase(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",th;let n=new Uint8Array(r.byteLength);if(!e){let i=new Uint8Array(r),s=r.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=Zn.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Wk.NAME="sidBlock";var LO=class extends lo{constructor({value:e=yu,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let i=r;for(;n>0;){let s=new Wk;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){let r=[];for(let n=0;n<this.value.length;n++){let i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,th;r.push(i)}return aee(r)}fromString(e){this.value=[];let r=0,n=0,i="",s=!1;do if(n=e.indexOf(".",r),n===-1?i=e.substring(r):i=e.substring(r,n),r=n+1,s){let a=this.value[0],c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}let d=parseInt(i,10);if(isNaN(d))return;a.valueDec=d+c,s=!1}else{let a=new Wk;if(i>Number.MAX_SAFE_INTEGER){FO();let c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),r?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};LO.NAME="ObjectIdentifierValueBlock";var $De,Hk=class extends Wa{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,LO),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};$De=Hk;xr.ObjectIdentifier=$De;Hk.NAME="OBJECT IDENTIFIER";var Vk=class extends rh(N0){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let i=Zn.BufferSourceConverter.toUint8Array(e);if(!U0(this,i,r,n))return-1;let s=i.subarray(r,r+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,(s[c]&128)!==0);c++);let a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Hi.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}let r=Hi.utilToBase(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",th;let n=new Uint8Array(r.byteLength);if(!e){let i=new Uint8Array(r),s=r.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=Zn.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Vk.NAME="relativeSidBlock";var $O=class extends lo{constructor({value:e=yu,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let i=r;for(;n>0;){let s=new Vk;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,r){let n=[];for(let i=0;i<this.value.length;i++){let s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,th;n.push(s)}return aee(n)}fromString(e){this.value=[];let r=0,n=0,i="";do{n=e.indexOf(".",r),n===-1?i=e.substring(r):i=e.substring(r,n),r=n+1;let s=new Vk;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(i=`{${i}}`),e+=i}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};$O.NAME="RelativeObjectIdentifierValueBlock";var jDe,Gk=class extends Wa{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,$O),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};jDe=Gk;xr.RelativeObjectIdentifier=jDe;Gk.NAME="RelativeObjectIdentifier";var qDe,Kk=class extends B0{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};qDe=Kk;xr.Sequence=qDe;Kk.NAME="SEQUENCE";var zDe,Zk=class extends B0{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};zDe=Zk;xr.Set=zDe;Zk.NAME="SET";var jO=class extends rh(lo){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=yu}toJSON(){return{...super.toJSON(),value:this.value}}};jO.NAME="StringValueBlock";var qO=class extends jO{};qO.NAME="SimpleStringValueBlock";var Uc=class extends Nk{constructor({...e}={}){super(e,qO)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Zn.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}};Uc.NAME="SIMPLE STRING";var zO=class extends Uc{fromBuffer(e){this.valueBlock.valueHexView=Zn.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Zn.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, using raw string`),this.valueBlock.value=Zn.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Zn.Convert.FromUtf8String(e)),this.valueBlock.value=e}};zO.NAME="Utf8StringValueBlock";var WDe,eh=class extends zO{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};WDe=eh;xr.Utf8String=WDe;eh.NAME="UTF8String";var WO=class extends Uc{fromBuffer(e){this.valueBlock.value=Zn.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Zn.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Zn.Convert.FromUtf16String(e))}};WO.NAME="BmpStringValueBlock";var HDe,Xk=class extends WO{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};HDe=Xk;xr.BmpString=HDe;Xk.NAME="BMPString";var HO=class extends Uc{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let i=0;i<r;i++){let s=Hi.utilToBase(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;let c=4-a.length;for(let d=a.length-1;d>=0;d--)n[i*4+d+c]=a[d]}this.valueBlock.value=e}};HO.NAME="UniversalStringValueBlock";var VDe,Yk=class extends HO{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};VDe=Yk;xr.UniversalString=VDe;Yk.NAME="UniversalString";var GDe,Jk=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};GDe=Jk;xr.NumericString=GDe;Jk.NAME="NumericString";var KDe,Qk=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};KDe=Qk;xr.PrintableString=KDe;Qk.NAME="PrintableString";var ZDe,e4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};ZDe=e4;xr.TeletexString=ZDe;e4.NAME="TeletexString";var XDe,t4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};XDe=t4;xr.VideotexString=XDe;t4.NAME="VideotexString";var YDe,r4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};YDe=r4;xr.IA5String=YDe;r4.NAME="IA5String";var JDe,n4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};JDe=n4;xr.GraphicString=JDe;n4.NAME="GraphicString";var QDe,k_=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};QDe=k_;xr.VisibleString=QDe;k_.NAME="VisibleString";var e6e,i4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};e6e=i4;xr.GeneralString=e6e;i4.NAME="GeneralString";var t6e,s4=class extends Uc{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};t6e=s4;xr.CharacterString=t6e;s4.NAME="CharacterString";var r6e,D_=class extends k_{constructor({value:e,valueDate:r,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}r&&(this.fromDate(r),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,Zn.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return r}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let r=new Array(7);return r[0]=Hi.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Hi.padNumber(this.month,2),r[2]=Hi.padNumber(this.day,2),r[3]=Hi.padNumber(this.hour,2),r[4]=Hi.padNumber(this.minute,2),r[5]=Hi.padNumber(this.second,2),r[6]="Z",r.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};r6e=D_;xr.UTCTime=r6e;D_.NAME="UTCTime";var n6e,a4=class extends D_{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let r=!1,n="",i="",s=0,a,c=0,d=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!0;else{let x=new Number(e[e.length-1]);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let x=1,y=n.indexOf("+"),v="";if(y===-1&&(y=n.indexOf("-"),x=-1),y!==-1){if(v=n.substring(y+1),n=n.substring(0,y),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let w=parseInt(v.substring(0,2),10);if(isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");if(c=x*w,v.length===4){if(w=parseInt(v.substring(2,4),10),isNaN(w.valueOf()))throw new Error("Wrong input string for conversion");d=x*w}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){let x=new Number(`0${n.substring(h)}`);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");s=x.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.minute=Math.floor(x),x=60*(x-this.minute),this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=1e3*s;this.millisecond=Math.floor(x)}break;default:throw new Error("Wrong input string for conversion")}let p=a.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let x=1;x<p.length;x++)switch(x){case 1:this.year=parseInt(p[x],10);break;case 2:this.month=parseInt(p[x],10);break;case 3:this.day=parseInt(p[x],10);break;case 4:this.hour=parseInt(p[x],10)+c;break;case 5:this.minute=parseInt(p[x],10)+d;break;case 6:this.second=parseInt(p[x],10);break;default:throw new Error("Wrong input string for conversion")}if(r===!1){let x=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=x.getUTCFullYear(),this.month=x.getUTCMonth(),this.day=x.getUTCDay(),this.hour=x.getUTCHours(),this.minute=x.getUTCMinutes(),this.second=x.getUTCSeconds(),this.millisecond=x.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let r=[];return r.push(Hi.padNumber(this.year,4)),r.push(Hi.padNumber(this.month,2)),r.push(Hi.padNumber(this.day,2)),r.push(Hi.padNumber(this.hour,2)),r.push(Hi.padNumber(this.minute,2)),r.push(Hi.padNumber(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Hi.padNumber(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};n6e=a4;xr.GeneralizedTime=n6e;a4.NAME="GeneralizedTime";var i6e,o4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};i6e=o4;xr.DATE=i6e;o4.NAME="DATE";var s6e,c4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};s6e=c4;xr.TimeOfDay=s6e;c4.NAME="TimeOfDay";var a6e,u4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};a6e=u4;xr.DateTime=a6e;u4.NAME="DateTime";var o6e,l4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};o6e=l4;xr.Duration=o6e;l4.NAME="Duration";var c6e,f4=class extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};c6e=f4;xr.TIME=c6e;f4.NAME="TIME";var qx=class{constructor({name:e=yu,optional:r=!1}={}){this.name=e,this.optional=r}},VO=class extends qx{constructor({value:e=[],...r}={}){super(r),this.value=e}},d4=class extends qx{constructor({value:e=new qx,local:r=!1,...n}={}){super(n),this.value=e,this.local=r}},see=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=Zn.BufferSourceConverter.toUint8Array(e)}constructor({data:e=GO}={}){this.dataView=Zn.BufferSourceConverter.toUint8Array(e)}fromBER(e,r,n){let i=r+n;return this.dataView=Zn.BufferSourceConverter.toUint8Array(e).subarray(r,i),i}toBER(e){return this.dataView.slice().buffer}};function E_(t,e,r){if(r instanceof VO){for(let s of r.value)if(E_(t,e,s).verified)return{verified:!0,result:t};{let s={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(iee)&&(s.name=r.name),s}}if(r instanceof qx)return r.hasOwnProperty(iee)&&(t[r.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(swt in r))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(uwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(lwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let n=r.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(r.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(r.idBlock.hasOwnProperty(awt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(r.idBlock.hasOwnProperty(owt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(r.idBlock.hasOwnProperty(cwt)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(iwt in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(r.idBlock.isHexOnly){if(!(SDe in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let s=r.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(t[r.name]=e)),r instanceof xr.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=r.valueBlock.value.length;if(c>0&&r.valueBlock.value[0]instanceof d4&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&r.valueBlock.value.length!==0){let d=!0;for(let h=0;h<r.valueBlock.value.length;h++)d=d&&(r.valueBlock.value[h].optional||!1);return d?{verified:!0,result:t}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let d=0;d<c;d++)if(d-s>=e.valueBlock.value.length){if(r.valueBlock.value[d].optional===!1){let h={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],h.name=r.name)),h}}else if(r.valueBlock.value[0]instanceof d4){if(a=E_(t,e.valueBlock.value[d],r.valueBlock.value[0].value),a.verified===!1)if(r.valueBlock.value[0].optional)s++;else return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),a;if(iee in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let h={};fwt in r.valueBlock.value[0]&&r.valueBlock.value[0].local?h=e:h=t,typeof h[r.valueBlock.value[0].name]>"u"&&(h[r.valueBlock.value[0].name]=[]),h[r.valueBlock.value[0].name].push(e.valueBlock.value[d])}}else if(a=E_(t,e.valueBlock.value[d-s],r.valueBlock.value[d]),a.verified===!1)if(r.valueBlock.value[d].optional)s++;else return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&delete t[r.name]),a;if(a.verified===!1){let d={verified:!1,result:t};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],d.name=r.name)),d}return{verified:!0,result:t}}if(r.primitiveSchema&&SDe in e.valueBlock){let s=KO(e.valueBlock.valueHexView);if(s.offset===-1){let a={verified:!1,result:s.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,yu),r.name&&(delete t[r.name],a.name=r.name)),a}return E_(t,s.result,r.primitiveSchema)}return{verified:!0,result:t}}function Swt(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};let r=KO(Zn.BufferSourceConverter.toUint8Array(t));return r.offset===-1?{verified:!1,result:r.result}:E_(r.result,r.result,e)}un.Any=qx;un.BaseBlock=Wa;un.BaseStringBlock=Nk;un.BitString=jk;un.BmpString=Xk;un.Boolean=Lk;un.CharacterString=s4;un.Choice=VO;un.Constructed=B0;un.DATE=o4;un.DEFAULT_MAX_CONTENT_LENGTH=PDe;un.DEFAULT_MAX_DEPTH=IDe;un.DEFAULT_MAX_NODES=FDe;un.DateTime=u4;un.Duration=l4;un.EndOfContent=Uk;un.Enumerated=zk;un.GeneralString=i4;un.GeneralizedTime=a4;un.GraphicString=n4;un.HexBlock=rh;un.IA5String=r4;un.Integer=C_;un.Null=Mk;un.NumericString=Jk;un.ObjectIdentifier=Hk;un.OctetString=$k;un.Primitive=Bk;un.PrintableString=Qk;un.RawData=see;un.RelativeObjectIdentifier=Gk;un.Repeated=d4;un.Sequence=Kk;un.Set=Zk;un.TIME=f4;un.TeletexString=e4;un.TimeOfDay=c4;un.UTCTime=D_;un.UniversalString=Yk;un.Utf8String=eh;un.ValueBlock=lo;un.VideotexString=t4;un.ViewWriter=T_;un.VisibleString=k_;un.compareSchema=E_;un.fromBER=vwt;un.verifySchema=Swt});var g4=L(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});vu.isArrayBuffer=uee;vu.isSharedArrayBuffer=d6e;vu.isArrayBufferLike=p4;vu.isArrayBufferView=h6e;vu.isBufferSource=p6e;vu.assertBufferSource=m4;vu.toUint8Array=ZO;vu.toUint8ArrayCopy=m6e;vu.toArrayBuffer=kwt;vu.toArrayBufferLike=Dwt;vu.toView=g6e;vu.toViewCopy=Iwt;var Awt="[object ArrayBuffer]",Ewt="[object SharedArrayBuffer]";function u6e(t){return Object.prototype.toString.call(t)}function l6e(t){return t===DataView||t.prototype instanceof DataView}function Twt(t){return l6e(t)?1:t.BYTES_PER_ELEMENT??1}function Cwt(t){if(ArrayBuffer.isView(t))return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.byteOffset=="number"&&typeof e.byteLength=="number"&&p4(e.buffer)}function f6e(t){let e=ZO(t),r=new Uint8Array(e.byteLength);return r.set(e),r}function uee(t){return u6e(t)===Awt}function d6e(t){return typeof SharedArrayBuffer<"u"&&u6e(t)===Ewt}function p4(t){return uee(t)||d6e(t)}function h6e(t){return Cwt(t)}function p6e(t){return p4(t)||h6e(t)}function m4(t){if(!p6e(t))throw new TypeError("Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView")}function ZO(t){return m4(t),p4(t)?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function m6e(t){return f6e(t)}function kwt(t){if(m4(t),uee(t))return t;let e=new ArrayBuffer(t.byteLength);return new Uint8Array(e).set(ZO(t)),e}function Dwt(t){return m4(t),p4(t)?t:t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:f6e(t).buffer}function g6e(t,e){if(m4(t),ArrayBuffer.isView(t)&&t.constructor===e)return t;let r=ZO(t),n=Twt(e);if(r.byteOffset%n!==0||r.byteLength%n!==0)throw new RangeError(`Cannot create ${e.name} over unaligned byte range`);return l6e(e)?new e(r.buffer,r.byteOffset,r.byteLength):new e(r.buffer,r.byteOffset,r.byteLength/n)}function Iwt(t,e){let r=m6e(t);return g6e(r,e)}});var y6e=L(YO=>{"use strict";Object.defineProperty(YO,"__esModule",{value:!0});YO.concatToUint8Array=x6e;YO.concat=Fwt;var XO=g4();function x6e(t){let e=[],r=0;for(let s of t){let a=(0,XO.toUint8Array)(s);e.push(a),r+=a.byteLength}let n=new Uint8Array(r),i=0;for(let s of e)n.set(s,i),i+=s.byteLength;return n}function Fwt(t,e,...r){let n,i;typeof e=="function"?(n=Array.from(t),i=e):(0,XO.isBufferSource)(t)?n=[t,e,...r].filter(XO.isBufferSource):(n=Array.from(t),e&&n.push(e),n.push(...r));let s=x6e(n);return i?(0,XO.toView)(s,i):s.buffer}});var b6e=L(lee=>{"use strict";Object.defineProperty(lee,"__esModule",{value:!0});lee.equal=Pwt;var v6e=g4();function Pwt(t,e,r={}){let n=(0,v6e.toUint8Array)(t),i=(0,v6e.toUint8Array)(e);if(!r.constantTime&&n.byteLength!==i.byteLength)return!1;let s=Math.max(n.byteLength,i.byteLength),a=n.byteLength^i.byteLength;for(let c=0;c<s;c++)a|=(n[c]??0)^(i[c]??0);return a===0}});var S6e=L(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});Of.indexOf=w6e;Of.lastIndexOf=Uwt;Of.includes=Mwt;Of.startsWith=Lwt;Of.endsWith=$wt;Of.slice=jwt;Of.tail=qwt;Of.copy=zwt;Of.compare=Wwt;var nh=g4();function JO(t,e,r){let n=Number.isFinite(t)?Math.trunc(t):e;return n<=0?0:n>=r?r:n}function Rwt(t,e){let r=JO(e?.start,0,t),n=JO(e?.end,t,t);return n>=r?[r,n]:[r,r]}function Owt(t,e){let r=JO(e?.start,t,t),n=JO(e?.end,0,t);return r>=n?[n,r]:[r,r]}function _6e(t,e,r){let n=Number.isFinite(t)?Math.trunc(t):e;return n<0?Math.max(r+n,0):n>r?r:n}function Nwt(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r)&255;return e}function Bwt(t){return new TextEncoder().encode(t)}function QO(t,e){return typeof t=="string"?e?.encoding==="utf8"?Bwt(t):Nwt(t):(0,nh.toUint8Array)(t)}function eN(t,e,r){for(let n=0;n<e.byteLength;n++)if(t[r+n]!==e[n])return!1;return!0}function w6e(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r),[s,a]=Rwt(n.byteLength,r);if(i.byteLength===0)return s;let c=a-i.byteLength;if(c<s)return-1;for(let d=s;d<=c;d++)if(eN(n,i,d))return d;return-1}function Uwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r),[s,a]=Owt(n.byteLength,r);if(i.byteLength===0)return a;let c=a-i.byteLength;if(c<s)return-1;for(let d=c;d>=s;d--)if(eN(n,i,d))return d;return-1}function Mwt(t,e,r){return w6e(t,e,r)!==-1}function Lwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r);return i.byteLength>n.byteLength?!1:eN(n,i,0)}function $wt(t,e,r){let n=(0,nh.toUint8Array)(t),i=QO(e,r);return i.byteLength>n.byteLength?!1:eN(n,i,n.byteLength-i.byteLength)}function jwt(t,e,r){let n=(0,nh.toUint8Array)(t),i=_6e(e,0,n.byteLength),s=_6e(r,n.byteLength,n.byteLength);return s<=i?n.subarray(i,i):n.subarray(i,s)}function qwt(t,e){let r=(0,nh.toUint8Array)(t),n=Number.isFinite(e)?Math.max(0,Math.trunc(e)):0;return n>=r.byteLength?r:r.subarray(r.byteLength-n)}function zwt(t){return(0,nh.toUint8ArrayCopy)(t)}function Wwt(t,e){let r=(0,nh.toUint8Array)(t),n=(0,nh.toUint8Array)(e),i=Math.min(r.byteLength,n.byteLength);for(let s=0;s<i;s++){if(r[s]<n[s])return-1;if(r[s]>n[s])return 1}return r.byteLength<n.byteLength?-1:r.byteLength>n.byteLength?1:0}});var el=L(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.tail=tn.startsWith=tn.slice=tn.lastIndexOf=tn.indexOf=tn.includes=tn.endsWith=tn.copy=tn.compare=tn.equal=tn.concatToUint8Array=tn.concat=tn.toViewCopy=tn.toView=tn.toUint8ArrayCopy=tn.toUint8Array=tn.toArrayBufferLike=tn.toArrayBuffer=tn.isSharedArrayBuffer=tn.isBufferSource=tn.isArrayBufferView=tn.isArrayBufferLike=tn.isArrayBuffer=tn.assertBufferSource=void 0;var Vl=g4();Object.defineProperty(tn,"assertBufferSource",{enumerable:!0,get:function(){return Vl.assertBufferSource}});Object.defineProperty(tn,"isArrayBuffer",{enumerable:!0,get:function(){return Vl.isArrayBuffer}});Object.defineProperty(tn,"isArrayBufferLike",{enumerable:!0,get:function(){return Vl.isArrayBufferLike}});Object.defineProperty(tn,"isArrayBufferView",{enumerable:!0,get:function(){return Vl.isArrayBufferView}});Object.defineProperty(tn,"isBufferSource",{enumerable:!0,get:function(){return Vl.isBufferSource}});Object.defineProperty(tn,"isSharedArrayBuffer",{enumerable:!0,get:function(){return Vl.isSharedArrayBuffer}});Object.defineProperty(tn,"toArrayBuffer",{enumerable:!0,get:function(){return Vl.toArrayBuffer}});Object.defineProperty(tn,"toArrayBufferLike",{enumerable:!0,get:function(){return Vl.toArrayBufferLike}});Object.defineProperty(tn,"toUint8Array",{enumerable:!0,get:function(){return Vl.toUint8Array}});Object.defineProperty(tn,"toUint8ArrayCopy",{enumerable:!0,get:function(){return Vl.toUint8ArrayCopy}});Object.defineProperty(tn,"toView",{enumerable:!0,get:function(){return Vl.toView}});Object.defineProperty(tn,"toViewCopy",{enumerable:!0,get:function(){return Vl.toViewCopy}});var A6e=y6e();Object.defineProperty(tn,"concat",{enumerable:!0,get:function(){return A6e.concat}});Object.defineProperty(tn,"concatToUint8Array",{enumerable:!0,get:function(){return A6e.concatToUint8Array}});var Hwt=b6e();Object.defineProperty(tn,"equal",{enumerable:!0,get:function(){return Hwt.equal}});var M0=S6e();Object.defineProperty(tn,"compare",{enumerable:!0,get:function(){return M0.compare}});Object.defineProperty(tn,"copy",{enumerable:!0,get:function(){return M0.copy}});Object.defineProperty(tn,"endsWith",{enumerable:!0,get:function(){return M0.endsWith}});Object.defineProperty(tn,"includes",{enumerable:!0,get:function(){return M0.includes}});Object.defineProperty(tn,"indexOf",{enumerable:!0,get:function(){return M0.indexOf}});Object.defineProperty(tn,"lastIndexOf",{enumerable:!0,get:function(){return M0.lastIndexOf}});Object.defineProperty(tn,"slice",{enumerable:!0,get:function(){return M0.slice}});Object.defineProperty(tn,"startsWith",{enumerable:!0,get:function(){return M0.startsWith}});Object.defineProperty(tn,"tail",{enumerable:!0,get:function(){return M0.tail}})});var zx=L(I_=>{"use strict";Object.defineProperty(I_,"__esModule",{value:!0});I_.AsnPropTypes=I_.AsnTypeTypes=void 0;var E6e;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(E6e||(I_.AsnTypeTypes=E6e={}));var T6e;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(T6e||(I_.AsnPropTypes=T6e={}))});var C6e=L(tN=>{"use strict";Object.defineProperty(tN,"__esModule",{value:!0});tN.BitString=void 0;var Vwt=(at(),He(st)),fee=Vwt.__importStar(Gm()),dee=el(),hee=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,r=0){if(e)if(typeof e=="number")this.fromNumber(e);else if((0,dee.isBufferSource)(e))this.unusedBits=r,this.value=(0,dee.toArrayBuffer)(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof fee.BitString))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,dee.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new fee.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new fee.BitString({name:e})}toNumber(){let e="",r=new Uint8Array(this.value);for(let n of r)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let r=e.toString(2),n=r.length+7>>3;this.unusedBits=(n<<3)-r.length;let i=new Uint8Array(n);r=r.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(r.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}};tN.BitString=hee});var k6e=L(rN=>{"use strict";Object.defineProperty(rN,"__esModule",{value:!0});rN.OctetString=void 0;var Gwt=(at(),He(st)),pee=Gwt.__importStar(Gm()),mee=el(),gee=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):(0,mee.isBufferSource)(e)?this.buffer=(0,mee.toArrayBuffer)(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof pee.OctetString))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=(0,mee.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new pee.OctetString({valueHex:this.buffer})}toSchema(e){return new pee.OctetString({name:e})}};rN.OctetString=gee});var xee=L(nN=>{"use strict";Object.defineProperty(nN,"__esModule",{value:!0});var D6e=(at(),He(st));D6e.__exportStar(C6e(),nN);D6e.__exportStar(k6e(),nN)});var x4=L(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.AsnNullConverter=nr.AsnGeneralizedTimeConverter=nr.AsnUTCTimeConverter=nr.AsnCharacterStringConverter=nr.AsnGeneralStringConverter=nr.AsnVisibleStringConverter=nr.AsnGraphicStringConverter=nr.AsnIA5StringConverter=nr.AsnVideotexStringConverter=nr.AsnTeletexStringConverter=nr.AsnPrintableStringConverter=nr.AsnNumericStringConverter=nr.AsnUniversalStringConverter=nr.AsnBmpStringConverter=nr.AsnUtf8StringConverter=nr.AsnConstructedOctetStringConverter=nr.AsnOctetStringConverter=nr.AsnBooleanConverter=nr.AsnObjectIdentifierConverter=nr.AsnBitStringConverter=nr.AsnIntegerBigIntConverter=nr.AsnIntegerArrayBufferConverter=nr.AsnEnumeratedConverter=nr.AsnIntegerConverter=nr.AsnAnyConverter=void 0;nr.defaultConverter=Xwt;var Kwt=(at(),He(st)),ys=Kwt.__importStar(Gm()),iN=el(),ua=zx(),Zwt=xee();nr.AsnAnyConverter={fromASN:t=>t instanceof ys.Null?null:(0,iN.toArrayBuffer)(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new ys.Null;let e=ys.fromBER(t);if(e.result.error)throw new Error(e.result.error);return e.result}};nr.AsnIntegerConverter={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new ys.Integer({value:+t})};nr.AsnEnumeratedConverter={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ys.Enumerated({value:t})};nr.AsnIntegerArrayBufferConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.Integer({valueHex:t})};nr.AsnIntegerBigIntConverter={fromASN:t=>t.toBigInt(),toASN:t=>ys.Integer.fromBigInt(t)};nr.AsnBitStringConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.BitString({valueHex:t})};nr.AsnObjectIdentifierConverter={fromASN:t=>t.valueBlock.toString(),toASN:t=>new ys.ObjectIdentifier({value:t})};nr.AsnBooleanConverter={fromASN:t=>t.valueBlock.value,toASN:t=>new ys.Boolean({value:t})};nr.AsnOctetStringConverter={fromASN:t=>(0,iN.toArrayBuffer)(t.valueBlock.valueHexView),toASN:t=>new ys.OctetString({valueHex:t})};nr.AsnConstructedOctetStringConverter={fromASN:t=>new Zwt.OctetString(t.getValue()),toASN:t=>t.toASN()};function Gl(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}nr.AsnUtf8StringConverter=Gl(ys.Utf8String);nr.AsnBmpStringConverter=Gl(ys.BmpString);nr.AsnUniversalStringConverter=Gl(ys.UniversalString);nr.AsnNumericStringConverter=Gl(ys.NumericString);nr.AsnPrintableStringConverter=Gl(ys.PrintableString);nr.AsnTeletexStringConverter=Gl(ys.TeletexString);nr.AsnVideotexStringConverter=Gl(ys.VideotexString);nr.AsnIA5StringConverter=Gl(ys.IA5String);nr.AsnGraphicStringConverter=Gl(ys.GraphicString);nr.AsnVisibleStringConverter=Gl(ys.VisibleString);nr.AsnGeneralStringConverter=Gl(ys.GeneralString);nr.AsnCharacterStringConverter=Gl(ys.CharacterString);nr.AsnUTCTimeConverter={fromASN:t=>t.toDate(),toASN:t=>new ys.UTCTime({valueDate:t})};nr.AsnGeneralizedTimeConverter={fromASN:t=>t.toDate(),toASN:t=>new ys.GeneralizedTime({valueDate:t})};nr.AsnNullConverter={fromASN:()=>null,toASN:()=>new ys.Null};function Xwt(t){switch(t){case ua.AsnPropTypes.Any:return nr.AsnAnyConverter;case ua.AsnPropTypes.BitString:return nr.AsnBitStringConverter;case ua.AsnPropTypes.BmpString:return nr.AsnBmpStringConverter;case ua.AsnPropTypes.Boolean:return nr.AsnBooleanConverter;case ua.AsnPropTypes.CharacterString:return nr.AsnCharacterStringConverter;case ua.AsnPropTypes.Enumerated:return nr.AsnEnumeratedConverter;case ua.AsnPropTypes.GeneralString:return nr.AsnGeneralStringConverter;case ua.AsnPropTypes.GeneralizedTime:return nr.AsnGeneralizedTimeConverter;case ua.AsnPropTypes.GraphicString:return nr.AsnGraphicStringConverter;case ua.AsnPropTypes.IA5String:return nr.AsnIA5StringConverter;case ua.AsnPropTypes.Integer:return nr.AsnIntegerConverter;case ua.AsnPropTypes.Null:return nr.AsnNullConverter;case ua.AsnPropTypes.NumericString:return nr.AsnNumericStringConverter;case ua.AsnPropTypes.ObjectIdentifier:return nr.AsnObjectIdentifierConverter;case ua.AsnPropTypes.OctetString:return nr.AsnOctetStringConverter;case ua.AsnPropTypes.PrintableString:return nr.AsnPrintableStringConverter;case ua.AsnPropTypes.TeletexString:return nr.AsnTeletexStringConverter;case ua.AsnPropTypes.UTCTime:return nr.AsnUTCTimeConverter;case ua.AsnPropTypes.UniversalString:return nr.AsnUniversalStringConverter;case ua.AsnPropTypes.Utf8String:return nr.AsnUtf8StringConverter;case ua.AsnPropTypes.VideotexString:return nr.AsnVideotexStringConverter;case ua.AsnPropTypes.VisibleString:return nr.AsnVisibleStringConverter;default:return null}}});var sN=L(y4=>{"use strict";Object.defineProperty(y4,"__esModule",{value:!0});y4.isConvertible=I6e;y4.isTypeOfArray=F6e;y4.isArrayEqual=Ywt;function I6e(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:I6e(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function F6e(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?!0:F6e(e)}return!1}function Ywt(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(r[i]!==n[i])return!1;return!0}});var R6e=L(aN=>{"use strict";Object.defineProperty(aN,"__esModule",{value:!0});aN.AsnSchemaStorage=void 0;var Jwt=(at(),He(st)),tl=Jwt.__importStar(Gm()),F_=zx(),P6e=sN(),yee=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,r=!1){let n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(r&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let r=this.get(e);r.schema||(r.schema=this.create(e,!0))}createDefault(e){let r={type:F_.AsnTypeTypes.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(r,n),r.items=Object.assign({},r.items,n.items)),r}create(e,r){let n=this.items.get(e)||this.createDefault(e),i=[];for(let s in n.items){let a=n.items[s],c=r?s:"",d;if(typeof a.type=="number"){let p=F_.AsnPropTypes[a.type],x=tl[p];if(!x)throw new Error(`Cannot get ASN1 class by name '${p}'`);d=new x({name:c})}else(0,P6e.isConvertible)(a.type)?d=new a.type().toSchema(c):a.optional?this.get(a.type).type===F_.AsnTypeTypes.Choice?d=new tl.Any({name:c}):(d=this.create(a.type,!1),d.name=c):d=new tl.Any({name:c});let h=!!a.optional||a.defaultValue!==void 0;if(a.repeated){d.name="";let p=a.repeated==="set"?tl.Set:tl.Sequence;d=new p({name:"",value:[new tl.Repeated({name:c,value:d})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||(0,P6e.isConvertible)(a.type)){let p=a.repeated?tl.Constructed:tl.Primitive;i.push(new p({name:c,optional:h,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);let p=!!a.repeated,x=p?d:this.get(a.type,!0).schema;x="valueBlock"in x?x.valueBlock.value:x.value,i.push(new tl.Constructed({name:p?"":c,optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:x}))}else i.push(new tl.Constructed({optional:h,idBlock:{tagClass:3,tagNumber:a.context},value:[d]}));else d.optional=h,i.push(d)}switch(n.type){case F_.AsnTypeTypes.Sequence:return new tl.Sequence({value:i,name:""});case F_.AsnTypeTypes.Set:return new tl.Set({value:i,name:""});case F_.AsnTypeTypes.Choice:return new tl.Choice({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,r){return this.items.set(e,r),this}findParentSchema(e){let r=Object.getPrototypeOf(e);return r?this.items.get(r)||this.findParentSchema(r):null}};aN.AsnSchemaStorage=yee});var cN=L(oN=>{"use strict";Object.defineProperty(oN,"__esModule",{value:!0});oN.schemaStorage=void 0;var Qwt=R6e();oN.schemaStorage=new Qwt.AsnSchemaStorage});var O6e=L(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.AsnProp=Mc.AsnSequenceType=Mc.AsnSetType=Mc.AsnChoiceType=Mc.AsnType=void 0;var eSt=(at(),He(st)),tSt=eSt.__importStar(x4()),vee=zx(),Km=cN(),rSt=t=>e=>{let r;Km.schemaStorage.has(e)?r=Km.schemaStorage.get(e):(r=Km.schemaStorage.createDefault(e),Km.schemaStorage.set(e,r)),Object.assign(r,t)};Mc.AsnType=rSt;var nSt=()=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Choice});Mc.AsnChoiceType=nSt;var iSt=t=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Set,...t});Mc.AsnSetType=iSt;var sSt=t=>(0,Mc.AsnType)({type:vee.AsnTypeTypes.Sequence,...t});Mc.AsnSequenceType=sSt;var aSt=t=>(e,r)=>{let n;Km.schemaStorage.has(e.constructor)?n=Km.schemaStorage.get(e.constructor):(n=Km.schemaStorage.createDefault(e.constructor),Km.schemaStorage.set(e.constructor,n));let i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){let s=tSt.defaultConverter(t.type);if(!s)throw new Error(`Cannot get default converter for property '${r}' of ${e.constructor.name}`);i.converter=s}i.raw=t.raw,n.items[r]=i};Mc.AsnProp=aSt});var N6e=L(uN=>{"use strict";Object.defineProperty(uN,"__esModule",{value:!0});uN.AsnSchemaValidationError=void 0;var bee=class extends Error{schemas=[]};uN.AsnSchemaValidationError=bee});var wee=L(_ee=>{"use strict";Object.defineProperty(_ee,"__esModule",{value:!0});var oSt=(at(),He(st));oSt.__exportStar(N6e(),_ee)});var Eee=L(lN=>{"use strict";Object.defineProperty(lN,"__esModule",{value:!0});lN.AsnParser=void 0;var B6e=(at(),He(st)),bu=B6e.__importStar(Gm()),cSt=el(),Zm=zx(),See=B6e.__importStar(x4()),v4=wee(),b4=sN(),Wx=cN(),Aee=class{static parse(e,r,n){let i=bu.fromBER((0,cSt.toArrayBuffer)(e),n?.berOptions);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,r,n)}static fromASN(e,r,n){try{if((0,b4.isConvertible)(r))return new r().fromASN(e);let i=Wx.schemaStorage.get(r);Wx.schemaStorage.cache(r);let s=i.schema,a=this.handleChoiceTypes(e,i,r,s,n);if(a?.result)return a.result;a?.targetSchema&&(s=a.targetSchema);let c=this.handleSequenceTypes(e,i,r,s),d=new r;return(0,b4.isTypeOfArray)(r)?this.handleArrayTypes(e,i,r,n):(this.processSchemaItems(i,c,d,n),d)}catch(i){throw i instanceof v4.AsnSchemaValidationError&&i.schemas.push(r.name),i}}static handleChoiceTypes(e,r,n,i,s){if(e.constructor===bu.Constructed&&r.type===Zm.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let a in r.items){let c=r.items[a];if(c.context===e.idBlock.tagNumber&&c.implicit&&typeof c.type=="function"&&Wx.schemaStorage.has(c.type)){let d=Wx.schemaStorage.get(c.type);if(d&&d.type===Zm.AsnTypeTypes.Sequence){let h=new bu.Sequence;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in h.valueBlock){h.valueBlock.value=e.valueBlock.value;let p=this.fromASN(h,c.type,s),x=new n;return x[a]=p,{result:x}}}}}else if(e.constructor===bu.Constructed&&r.type!==Zm.AsnTypeTypes.Choice){let a=new bu.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(let c in r.items)delete e[c];return{targetSchema:a}}return null}static handleSequenceTypes(e,r,n,i){if(r.type===Zm.AsnTypeTypes.Sequence){let s=bu.compareSchema({},e,i);if(!s.verified)throw new v4.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}else{let s=bu.compareSchema({},e,i);if(!s.verified)throw new v4.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}}static processRepeatedField(e,r,n){let i=e.slice(r);if(i.length===1&&i[0].constructor.name==="Sequence"){let s=i[0];s.valueBlock&&s.valueBlock.value&&Array.isArray(s.valueBlock.value)&&(i=s.valueBlock.value)}if(typeof n.type=="number"){let s=See.defaultConverter(n.type);if(!s)throw new Error(`No converter for ASN.1 type ${n.type}`);return i.filter(a=>a&&a.valueBlock).map(a=>{try{return s.fromASN(a)}catch{return}}).filter(a=>a!==void 0)}else return i.filter(s=>s&&s.valueBlock).map(s=>{try{return this.fromASN(s,n.type)}catch{return}}).filter(s=>s!==void 0)}static processPrimitiveField(e,r){let n=See.defaultConverter(r.type);if(!n)throw new Error(`No converter for ASN.1 type ${r.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Wx.schemaStorage.has(e.type)&&Wx.schemaStorage.get(e.type).type===Zm.AsnTypeTypes.Choice}static processOptionalChoiceField(e,r){try{return{processed:!0,value:this.fromASN(e,r.type)}}catch(n){if(n instanceof v4.AsnSchemaValidationError&&/Wrong values for Choice type/.test(n.message))return{processed:!1};throw n}}static handleArrayTypes(e,r,n,i){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let s=r.itemType;if(typeof s=="number"){let a=See.defaultConverter(s);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,c=>a.fromASN(c))}else return n.from(e.valueBlock.value,a=>this.fromASN(a,s,i))}static processSchemaItems(e,r,n,i){for(let s in e.items){let a=r.result[s];if(!a)continue;let c=e.items[s],d=c.type,h;typeof d=="number"||(0,b4.isConvertible)(d)?h=this.processPrimitiveSchemaItem(a,c,d,i):h=this.processComplexSchemaItem(a,c,d,i),h&&typeof h=="object"&&"value"in h&&"raw"in h?(n[s]=h.value,n[`${s}Raw`]=h.raw):n[s]=h}}static processPrimitiveSchemaItem(e,r,n,i){let s=r.converter??((0,b4.isConvertible)(n)?new n:null);if(!s)throw new Error("Converter is empty");return r.repeated?this.processRepeatedPrimitiveItem(e,r,s,i):this.processSinglePrimitiveItem(e,r,n,s,i)}static processRepeatedPrimitiveItem(e,r,n,i){if(r.implicit){let s=r.repeated==="sequence"?bu.Sequence:bu.Set,a=new s;a.valueBlock=e.valueBlock;let c=bu.fromBER(a.toBER(!1),i?.berOptions);if(c.offset===-1)throw new Error(`Cannot parse the child item. ${c.result.error}`);if(!("value"in c.result.valueBlock&&Array.isArray(c.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let d=c.result.valueBlock.value;return Array.from(d,h=>n.fromASN(h))}else return Array.from(e,s=>n.fromASN(s))}static processSinglePrimitiveItem(e,r,n,i,s){let a=e;if(r.implicit){let c;if((0,b4.isConvertible)(n))c=new n().toSchema("");else{let d=Zm.AsnPropTypes[n],h=bu[d];if(!h)throw new Error(`Cannot get '${d}' class from asn1js module`);c=new h}c.valueBlock=a.valueBlock,a=bu.fromBER(c.toBER(!1),s?.berOptions).result}return i.fromASN(a)}static processComplexSchemaItem(e,r,n,i){if(r.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,s=>this.fromASN(s,n,i))}else{let s=this.handleImplicitTagging(e,r,n);if(this.isOptionalChoiceField(r))try{return this.fromASN(s,n,i)}catch(a){if(a instanceof v4.AsnSchemaValidationError&&/Wrong values for Choice type/.test(a.message))return;throw a}else{let a=this.fromASN(s,n,i);return r.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,r,n){if(r.implicit&&typeof r.context=="number"){let i=Wx.schemaStorage.get(n);if(i.type===Zm.AsnTypeTypes.Sequence){let s=new bu.Sequence;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in s.valueBlock)return s.valueBlock.value=e.valueBlock.value,s}else if(i.type===Zm.AsnTypeTypes.Set){let s=new bu.Set;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in s.valueBlock)return s.valueBlock.value=e.valueBlock.value,s}}return e}};lN.AsnParser=Aee});var kee=L(dN=>{"use strict";Object.defineProperty(dN,"__esModule",{value:!0});dN.AsnSerializer=void 0;var M6e=(at(),He(st)),Nf=M6e.__importStar(Gm()),uSt=el(),lSt=M6e.__importStar(x4()),fN=zx(),Tee=sN(),U6e=cN(),Cee=class t{static serialize(e){return e instanceof Nf.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&(0,Tee.isConvertible)(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let r=e.constructor,n=U6e.schemaStorage.get(r);U6e.schemaStorage.cache(r);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){let a=lSt.defaultConverter(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",r,a))}else for(let a in n.items){let c=n.items[a],d=e[a];if(d===void 0||c.defaultValue===d||typeof c.defaultValue=="object"&&typeof d=="object"&&(0,Tee.isArrayEqual)(this.serialize(c.defaultValue),this.serialize(d)))continue;let h=t.toAsnItem(c,a,r,d);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||(0,Tee.isConvertible)(c.type))){let p={};p.valueHex=h instanceof Nf.Null?(0,uSt.toArrayBuffer)(h.valueBeforeDecodeView):h.valueBlock.toBER(),i.push(new Nf.Primitive({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new Nf.Constructed({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new Nf.Constructed({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case fN.AsnTypeTypes.Sequence:s=new Nf.Sequence({value:i});break;case fN.AsnTypeTypes.Set:s=new Nf.Set({value:i});break;case fN.AsnTypeTypes.Choice:if(!i[0])throw new Error(`Schema '${r.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,r,n,i){let s;if(typeof e.type=="number"){let a=e.converter;if(!a)throw new Error(`Property '${r}' doesn't have converter for type ${fN.AsnPropTypes[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");let c=Array.from(i,h=>a.toASN(h)),d=e.repeated==="sequence"?Nf.Sequence:Nf.Set;s=new d({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(i,d=>this.toASN(d)),c=e.repeated==="sequence"?Nf.Sequence:Nf.Set;s=new c({value:a})}else s=this.toASN(i);return s}};dN.AsnSerializer=Cee});var L6e=L(hN=>{"use strict";Object.defineProperty(hN,"__esModule",{value:!0});hN.AsnArray=void 0;var Dee=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(let r of e)this.push(r)}}};hN.AsnArray=Dee});var j6e=L(pN=>{"use strict";Object.defineProperty(pN,"__esModule",{value:!0});pN.AsnConvert=void 0;var fSt=(at(),He(st)),dSt=fSt.__importStar(Gm()),$6e=el(),hSt=Eee(),pSt=kee(),Iee=class t{static serialize(e){return pSt.AsnSerializer.serialize(e)}static parse(e,r,n){return hSt.AsnParser.parse(e,r,n)}static toString(e,r){let n=(0,$6e.isBufferSource)(e)?(0,$6e.toArrayBuffer)(e):t.serialize(e),i=dSt.fromBER(n,r?.berOptions);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}};pN.AsnConvert=Iee});var bt=L(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:!0});Ds.AsnSerializer=Ds.AsnParser=Ds.AsnPropTypes=Ds.AsnTypeTypes=Ds.AsnSetType=Ds.AsnSequenceType=Ds.AsnChoiceType=Ds.AsnType=Ds.AsnProp=void 0;var _4=(at(),He(st));_4.__exportStar(x4(),Ds);_4.__exportStar(xee(),Ds);var w4=O6e();Object.defineProperty(Ds,"AsnProp",{enumerable:!0,get:function(){return w4.AsnProp}});Object.defineProperty(Ds,"AsnType",{enumerable:!0,get:function(){return w4.AsnType}});Object.defineProperty(Ds,"AsnChoiceType",{enumerable:!0,get:function(){return w4.AsnChoiceType}});Object.defineProperty(Ds,"AsnSequenceType",{enumerable:!0,get:function(){return w4.AsnSequenceType}});Object.defineProperty(Ds,"AsnSetType",{enumerable:!0,get:function(){return w4.AsnSetType}});var q6e=zx();Object.defineProperty(Ds,"AsnTypeTypes",{enumerable:!0,get:function(){return q6e.AsnTypeTypes}});Object.defineProperty(Ds,"AsnPropTypes",{enumerable:!0,get:function(){return q6e.AsnPropTypes}});var mSt=Eee();Object.defineProperty(Ds,"AsnParser",{enumerable:!0,get:function(){return mSt.AsnParser}});var gSt=kee();Object.defineProperty(Ds,"AsnSerializer",{enumerable:!0,get:function(){return gSt.AsnSerializer}});_4.__exportStar(wee(),Ds);_4.__exportStar(L6e(),Ds);_4.__exportStar(j6e(),Ds)});var Fee=L(Hx=>{"use strict";Object.defineProperty(Hx,"__esModule",{value:!0});Hx.binary=void 0;Hx.encode=z6e;Hx.decode=W6e;Hx.is=H6e;var xSt=el();function z6e(t){let e=(0,xSt.toUint8Array)(t),r="";for(let n of e)r+=String.fromCharCode(n);return r}function W6e(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r)&255;return e}function H6e(t){return typeof t=="string"}Hx.binary={encode:z6e,decode:W6e,is:H6e}});var Y6e=L(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.hex=rl.formats=void 0;rl.normalize=S4;rl.is=K6e;rl.encode=Pee;rl.decode=Ree;rl.parse=Z6e;rl.format=X6e;var ySt=el(),vSt=/^[0-9a-f]$/i,bSt=[" "," ",`
999
1008
  `,"\r",":","-","."];function _St(t){return t.separators==="none"?[]:!t.separators||t.separators==="common"?bSt:t.separators}function wSt(t){if(!t)throw new TypeError("Hex separators must be non-empty strings")}function SSt(t,e,r){for(let n of r)if(t.startsWith(n,e))return n}function ASt(t){let e=/[A-F]/.test(t),r=/[a-f]/.test(t);return e&&!r?"upper":"lower"}function ESt(t){let e=/\r\n|\n/.exec(t);if(e)return e[0]===`\r
1000
1009
  `?`\r
1001
1010
  `:`
1002
- `}function VDe(t){return t.replace(/[^0-9a-f]/gi,"")}function TSt(t){let e=t.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g)??[];if(e.length<3)return;let r=e.filter((a,c)=>c%2===0),n=e.filter((a,c)=>c%2===1),i=n[0];if(!i||n.some(a=>a!==i)||r.some(a=>a.length===0||a.length%2!==0))return;let s=r[0]?.length??0;if(s&&!r.slice(0,-1).some(a=>a.length!==s)&&!((r[r.length-1]?.length??0)>s))return{size:s/2,separator:i}}function CSt(t){let e=t.trim(),r=/^0x/i.test(e)?"0x":"",n=r?e.slice(2):e,i=ESt(n),s=n.split(/\r\n|\n/).filter(h=>h.length>0),a=s[0]?.trim()??"",c=TSt(a),d={case:ASt(e),prefix:r};if(c&&(d.group=c),i&&s.length>1){let h=VDe(s[0]??"").length/2;h>0&&s.slice(0,-1).every(p=>VDe(p).length/2===h)&&(d.line={bytesPerLine:h,separator:i})}return d}function kSt(t,e){let r=e.allowPrefix??!0,n=[..._St(e)].sort((c,d)=>d.length-c.length);for(let c of n)wSt(c);let i=t.trim();if(/^0x/i.test(i)){if(!r)throw new TypeError("Hexadecimal text must not include a 0x prefix");i=i.slice(2)}let s="",a=!1;for(let c=0;c<i.length;){let d=i[c]??"";if(vSt.test(d)){s+=d,a=!1,c+=1;continue}let h=SSt(i,c,n);if(!h)throw new TypeError("Input is not valid hexadecimal text");if(e.strict&&(a||s.length===0))throw new TypeError("Hexadecimal text contains misplaced separators");a=!0,c+=h.length}if(e.strict&&a&&s.length>0)throw new TypeError("Hexadecimal text must not end with a separator");if(s.length%2!==0){if(!e.allowOddLength)throw new TypeError("Hexadecimal text must contain an even number of characters");s=`0${s}`}return s.toLowerCase()}function GDe(t,e){if(!e)return t.join("");if(!Number.isInteger(e.size)||e.size<1)throw new RangeError("Hex group size must be a positive integer");let r=[];for(let n=0;n<t.length;n+=e.size)r.push(t.slice(n,n+e.size).join(""));return r.join(e.separator)}function S4(t,e={}){return kSt(t,e)}function KDe(t,e={}){if(typeof t!="string")return!1;try{return S4(t,e),!0}catch{return!1}}function Pee(t,e={}){let r=(0,ySt.toUint8Array)(t),n=e.case??"lower",i=Array.from(r,a=>{let c=a.toString(16).padStart(2,"0");return n==="upper"?c.toUpperCase():c}),s="";if(e.line){let a=e.line.bytesPerLine;if(!Number.isInteger(a)||a<1)throw new RangeError("Hex bytesPerLine must be a positive integer");let c=e.line.separator??`
1003
- `,d=[];for(let h=0;h<i.length;h+=a)d.push(GDe(i.slice(h,h+a),e.group));s=d.join(c)}else s=GDe(i,e.group);return`${e.prefix??""}${s}`}function Ree(t,e={}){let r=S4(t,e),n=new Uint8Array(r.length/2);for(let i=0;i<r.length;i+=2)n[i/2]=Number.parseInt(r.slice(i,i+2),16);return n}function ZDe(t,e={}){let r=S4(t,e);return{bytes:Ree(r),format:CSt(t),normalized:r}}function XDe(t,e){return Pee(t,e)}rl.formats={compact:Object.freeze({}),upper:Object.freeze({case:"upper"}),colon:Object.freeze({group:{size:1,separator:":"}}),colonUpper:Object.freeze({case:"upper",group:{size:1,separator:":"}}),groupsOf4:Object.freeze({group:{size:4,separator:" "}}),prefixed:Object.freeze({prefix:"0x"})};rl.hex={encode:Pee,decode:Ree,format:XDe,formats:rl.formats,is:KDe,normalize:S4,parse:ZDe}});var e8e=L(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});P_.utf8=void 0;P_.encode=JDe;P_.decode=QDe;var DSt=el();function JDe(t){return new TextEncoder().encode(t)}function QDe(t){return new TextDecoder("utf-8",{fatal:!1}).decode((0,DSt.toUint8Array)(t))}P_.utf8={encode:JDe,decode:QDe}});var n8e=L(R_=>{"use strict";Object.defineProperty(R_,"__esModule",{value:!0});R_.utf16=void 0;R_.encode=t8e;R_.decode=r8e;var ISt=el();function t8e(t,e={}){let r=new ArrayBuffer(t.length*2),n=new DataView(r);for(let i=0;i<t.length;i++)n.setUint16(i*2,t.charCodeAt(i),e.littleEndian??!1);return new Uint8Array(r)}function r8e(t,e={}){let r=(0,ISt.toArrayBuffer)(t),n=new DataView(r),i="";for(let s=0;s<r.byteLength;s+=2)i+=String.fromCharCode(n.getUint16(s,e.littleEndian??!1));return i}R_.utf16={encode:t8e,decode:r8e}});var Nee=L(L0=>{"use strict";Object.defineProperty(L0,"__esModule",{value:!0});L0.base64=void 0;L0.normalize=mN;L0.pad=a8e;L0.is=Oee;L0.encode=o8e;L0.decode=c8e;var FSt=el(),i8e=Fee(),PSt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function s8e(){return globalThis.Buffer}function mN(t){return t.replace(/[\n\r\t ]/g,"")}function a8e(t){let e=t.length%4;return e?t+"=".repeat(4-e):t}function Oee(t){if(typeof t!="string")return!1;let e=mN(t);return e===""||PSt.test(e)}function o8e(t,e){let r=(0,FSt.toUint8Array)(t),n=s8e();return n?n.from(r).toString("base64"):btoa((0,i8e.encode)(r))}function c8e(t,e){let r=mN(t);if(!Oee(r))throw new TypeError("Input is not valid Base64 text");let n=s8e();return n?new Uint8Array(n.from(r,"base64")):(0,i8e.decode)(atob(r))}L0.base64={encode:o8e,decode:c8e,is:Oee,normalize:mN,pad:a8e}});var f8e=L(Xm=>{"use strict";Object.defineProperty(Xm,"__esModule",{value:!0});Xm.base64url=void 0;Xm.normalize=gN;Xm.is=Uee;Xm.encode=u8e;Xm.decode=l8e;var Bee=Nee(),RSt=/^[A-Za-z0-9_-]*$/;function gN(t){return t.replace(/[\n\r\t ]/g,"")}function Uee(t){return typeof t=="string"&&RSt.test(gN(t))}function u8e(t,e){return Bee.base64.encode(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function l8e(t,e){let r=gN(t);if(!Uee(r))throw new TypeError("Input is not valid Base64Url text");return Bee.base64.decode(Bee.base64.pad(r.replace(/-/g,"+").replace(/_/g,"/")))}Xm.base64url={encode:u8e,decode:l8e,is:Uee,normalize:gN}});var Mee=L(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.base64url=_u.base64=_u.utf16=_u.utf8=_u.hex=_u.binary=void 0;var O_=(at(),He(st));_u.binary=O_.__importStar(Fee());_u.hex=O_.__importStar(YDe());_u.utf8=O_.__importStar(e8e());_u.utf16=O_.__importStar(n8e());_u.base64=O_.__importStar(Nee());_u.base64url=O_.__importStar(f8e())});var d8e=L(xN=>{"use strict";Object.defineProperty(xN,"__esModule",{value:!0});xN.IpConverter=void 0;var OSt=Mee(),Lee=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let r=e.split(".");if(r.length!==4)throw new Error("Invalid IPv4 address");return r.map(n=>{let i=parseInt(n,10);if(isNaN(i)||i<0||i>255)throw new Error("Invalid IPv4 address part");return i})}static parseIPv6(e){let n=this.expandIPv6(e).split(":");if(n.length!==8)throw new Error("Invalid IPv6 address");return n.reduce((i,s)=>{let a=parseInt(s,16);if(isNaN(a)||a<0||a>65535)throw new Error("Invalid IPv6 address part");return i.push(a>>8&255),i.push(a&255),i},[])}static expandIPv6(e){if(!e.includes("::"))return e;let r=e.split("::");if(r.length>2)throw new Error("Invalid IPv6 address");let n=r[0]?r[0].split(":"):[],i=r[1]?r[1].split(":"):[],s=8-(n.length+i.length);if(s<0)throw new Error("Invalid IPv6 address");return[...n,...Array(s).fill("0"),...i].join(":")}static formatIPv6(e){let r=[];for(let n=0;n<16;n+=2)r.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(r.join(":"))}static compressIPv6(e){let r=e.split(":"),n=-1,i=0,s=-1,a=0;for(let c=0;c<r.length;c++)r[c]==="0"?(s===-1&&(s=c),a++):(a>i&&(n=s,i=a),s=-1,a=0);if(a>i&&(n=s,i=a),i>1){let c=r.slice(0,n).join(":"),d=r.slice(n+i).join(":");return`${c}::${d}`}return e}static parseCIDR(e){let[r,n]=e.split("/"),i=parseInt(n,10);if(this.isIPv4(r)){if(i<0||i>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(r),i]}else{if(i<0||i>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(r),i]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;let r=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0),n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${r}`}static toString(e){let r=new Uint8Array(e);if(r.length===4)return Array.from(r).join(".");if(r.length===16)return this.formatIPv6(r);if(r.length===8||r.length===32){let n=r.length/2,i=r.slice(0,n),s=r.slice(n);if(r.every(d=>d===0))return r.length===8?"0.0.0.0/0":"::/0";let c=s.reduce((d,h)=>d+(h.toString(2).match(/1/g)||[]).length,0);return r.length===8?`${Array.from(i).join(".")}/${c}`:`${this.formatIPv6(i)}/${c}`}return this.decodeIP(OSt.hex.encode(e))}static fromString(e){if(e.includes("/")){let[n,i]=this.parseCIDR(e),s=new Uint8Array(n.length),a=i;for(let d=0;d<s.length;d++)a>=8?(s[d]=255,a-=8):a>0&&(s[d]=255<<8-a,a=0);let c=new Uint8Array(n.length*2);return c.set(n,0),c.set(s,n.length),c.buffer}let r=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(r).buffer}};xN.IpConverter=Lee});var B_=L(Ha=>{"use strict";var $ee,jee,qee;Object.defineProperty(Ha,"__esModule",{value:!0});Ha.Name=Ha.RDNSequence=Ha.RelativeDistinguishedName=Ha.AttributeTypeAndValue=Ha.AttributeValue=Ha.DirectoryString=void 0;var wu=(at(),He(st)),Vi=bt(),NSt=Mee(),$0=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};Ha.DirectoryString=$0;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.TeletexString})],$0.prototype,"teletexString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.PrintableString})],$0.prototype,"printableString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.UniversalString})],$0.prototype,"universalString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.Utf8String})],$0.prototype,"utf8String",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.BmpString})],$0.prototype,"bmpString",void 0);Ha.DirectoryString=$0=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Choice})],$0);var Vx=class extends $0{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?NSt.hex.encode(this.anyValue):super.toString())}};Ha.AttributeValue=Vx;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.IA5String})],Vx.prototype,"ia5String",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.Any})],Vx.prototype,"anyValue",void 0);Ha.AttributeValue=Vx=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Choice})],Vx);var N_=class{type="";value=new Vx;constructor(e={}){Object.assign(this,e)}};Ha.AttributeTypeAndValue=N_;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.ObjectIdentifier})],N_.prototype,"type",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vx})],N_.prototype,"value",void 0);var yN=$ee=class extends Vi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,$ee.prototype)}};Ha.RelativeDistinguishedName=yN;Ha.RelativeDistinguishedName=yN=$ee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Set,itemType:N_})],yN);var vN=jee=class extends Vi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,jee.prototype)}};Ha.RDNSequence=vN;Ha.RDNSequence=vN=jee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Sequence,itemType:yN})],vN);var zee=qee=class extends vN{constructor(e){super(e),Object.setPrototypeOf(this,qee.prototype)}};Ha.Name=zee;Ha.Name=zee=qee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Sequence})],zee)});var Gx=L(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.GeneralName=Kl.EDIPartyName=Kl.OtherName=Kl.AsnIpConverter=void 0;var Su=(at(),He(st)),Is=bt(),h8e=d8e(),bN=B_();Kl.AsnIpConverter={fromASN:t=>h8e.IpConverter.toString(Is.AsnOctetStringConverter.fromASN(t)),toASN:t=>Is.AsnOctetStringConverter.toASN(h8e.IpConverter.fromString(t))};var U_=class{typeId="";value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Kl.OtherName=U_;Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.ObjectIdentifier})],U_.prototype,"typeId",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.Any,context:0})],U_.prototype,"value",void 0);var M_=class{nameAssigner;partyName=new bN.DirectoryString;constructor(e={}){Object.assign(this,e)}};Kl.EDIPartyName=M_;Su.__decorate([(0,Is.AsnProp)({type:bN.DirectoryString,optional:!0,context:0,implicit:!0})],M_.prototype,"nameAssigner",void 0);Su.__decorate([(0,Is.AsnProp)({type:bN.DirectoryString,context:1,implicit:!0})],M_.prototype,"partyName",void 0);var Zl=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};Kl.GeneralName=Zl;Su.__decorate([(0,Is.AsnProp)({type:U_,context:0,implicit:!0})],Zl.prototype,"otherName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:1,implicit:!0})],Zl.prototype,"rfc822Name",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:2,implicit:!0})],Zl.prototype,"dNSName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.Any,context:3,implicit:!0})],Zl.prototype,"x400Address",void 0);Su.__decorate([(0,Is.AsnProp)({type:bN.Name,context:4,implicit:!1})],Zl.prototype,"directoryName",void 0);Su.__decorate([(0,Is.AsnProp)({type:M_,context:5})],Zl.prototype,"ediPartyName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:6,implicit:!0})],Zl.prototype,"uniformResourceIdentifier",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.OctetString,context:7,implicit:!0,converter:Kl.AsnIpConverter})],Zl.prototype,"iPAddress",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],Zl.prototype,"registeredID",void 0);Kl.GeneralName=Zl=Su.__decorate([(0,Is.AsnType)({type:Is.AsnTypeTypes.Choice})],Zl)});var vs=L(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.id_ce=Qn.id_ad_caRepository=Qn.id_ad_timeStamping=Qn.id_ad_caIssuers=Qn.id_ad_ocsp=Qn.id_qt_unotice=Qn.id_qt_csp=Qn.id_ad=Qn.id_kp=Qn.id_qt=Qn.id_pe=Qn.id_pkix=void 0;Qn.id_pkix="1.3.6.1.5.5.7";Qn.id_pe=`${Qn.id_pkix}.1`;Qn.id_qt=`${Qn.id_pkix}.2`;Qn.id_kp=`${Qn.id_pkix}.3`;Qn.id_ad=`${Qn.id_pkix}.48`;Qn.id_qt_csp=`${Qn.id_qt}.1`;Qn.id_qt_unotice=`${Qn.id_qt}.2`;Qn.id_ad_ocsp=`${Qn.id_ad}.1`;Qn.id_ad_caIssuers=`${Qn.id_ad}.2`;Qn.id_ad_timeStamping=`${Qn.id_ad}.3`;Qn.id_ad_caRepository=`${Qn.id_ad}.5`;Qn.id_ce="2.5.29"});var Gee=L(j0=>{"use strict";var Wee;Object.defineProperty(j0,"__esModule",{value:!0});j0.AuthorityInfoAccessSyntax=j0.AccessDescription=j0.id_pe_authorityInfoAccess=void 0;var Vee=(at(),He(st)),L_=bt(),p8e=Gx(),BSt=vs();j0.id_pe_authorityInfoAccess=`${BSt.id_pe}.1`;var $_=class{accessMethod="";accessLocation=new p8e.GeneralName;constructor(e={}){Object.assign(this,e)}};j0.AccessDescription=$_;Vee.__decorate([(0,L_.AsnProp)({type:L_.AsnPropTypes.ObjectIdentifier})],$_.prototype,"accessMethod",void 0);Vee.__decorate([(0,L_.AsnProp)({type:p8e.GeneralName})],$_.prototype,"accessLocation",void 0);var Hee=Wee=class extends L_.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Wee.prototype)}};j0.AuthorityInfoAccessSyntax=Hee;j0.AuthorityInfoAccessSyntax=Hee=Wee=Vee.__decorate([(0,L_.AsnType)({type:L_.AsnTypeTypes.Sequence,itemType:$_})],Hee)});var Zee=L(Ym=>{"use strict";Object.defineProperty(Ym,"__esModule",{value:!0});Ym.AuthorityKeyIdentifier=Ym.KeyIdentifier=Ym.id_ce_authorityKeyIdentifier=void 0;var Kee=(at(),He(st)),j_=bt(),USt=Gx(),MSt=vs();Ym.id_ce_authorityKeyIdentifier=`${MSt.id_ce}.35`;var _N=class extends j_.OctetString{};Ym.KeyIdentifier=_N;var q_=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};Ym.AuthorityKeyIdentifier=q_;Kee.__decorate([(0,j_.AsnProp)({type:_N,context:0,optional:!0,implicit:!0})],q_.prototype,"keyIdentifier",void 0);Kee.__decorate([(0,j_.AsnProp)({type:USt.GeneralName,context:1,optional:!0,implicit:!0,repeated:"sequence"})],q_.prototype,"authorityCertIssuer",void 0);Kee.__decorate([(0,j_.AsnProp)({type:j_.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:j_.AsnIntegerArrayBufferConverter})],q_.prototype,"authorityCertSerialNumber",void 0)});var g8e=L(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});z_.BasicConstraints=z_.id_ce_basicConstraints=void 0;var m8e=(at(),He(st)),wN=bt(),LSt=vs();z_.id_ce_basicConstraints=`${LSt.id_ce}.19`;var A4=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};z_.BasicConstraints=A4;m8e.__decorate([(0,wN.AsnProp)({type:wN.AsnPropTypes.Boolean,defaultValue:!1})],A4.prototype,"cA",void 0);m8e.__decorate([(0,wN.AsnProp)({type:wN.AsnPropTypes.Integer,optional:!0})],A4.prototype,"pathLenConstraint",void 0)});var T4=L(E4=>{"use strict";var Xee;Object.defineProperty(E4,"__esModule",{value:!0});E4.GeneralNames=void 0;var $St=(at(),He(st)),Yee=bt(),jSt=Gx(),Jee=Xee=class extends Yee.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Xee.prototype)}};E4.GeneralNames=Jee;E4.GeneralNames=Jee=Xee=$St.__decorate([(0,Yee.AsnType)({type:Yee.AsnTypeTypes.Sequence,itemType:jSt.GeneralName})],Jee)});var y8e=L(Kx=>{"use strict";var Qee;Object.defineProperty(Kx,"__esModule",{value:!0});Kx.CertificateIssuer=Kx.id_ce_certificateIssuer=void 0;var qSt=(at(),He(st)),x8e=bt(),zSt=T4(),WSt=vs();Kx.id_ce_certificateIssuer=`${WSt.id_ce}.29`;var ete=Qee=class extends zSt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,Qee.prototype)}};Kx.CertificateIssuer=ete;Kx.CertificateIssuer=ete=Qee=qSt.__decorate([(0,x8e.AsnType)({type:x8e.AsnTypeTypes.Sequence})],ete)});var v8e=L(Ws=>{"use strict";var tte;Object.defineProperty(Ws,"__esModule",{value:!0});Ws.CertificatePolicies=Ws.PolicyInformation=Ws.PolicyQualifierInfo=Ws.Qualifier=Ws.UserNotice=Ws.NoticeReference=Ws.DisplayText=Ws.id_ce_certificatePolicies_anyPolicy=Ws.id_ce_certificatePolicies=void 0;var No=(at(),He(st)),Ui=bt(),HSt=vs();Ws.id_ce_certificatePolicies=`${HSt.id_ce}.32`;Ws.id_ce_certificatePolicies_anyPolicy=`${Ws.id_ce_certificatePolicies}.0`;var ih=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};Ws.DisplayText=ih;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.IA5String})],ih.prototype,"ia5String",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.VisibleString})],ih.prototype,"visibleString",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.BmpString})],ih.prototype,"bmpString",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Utf8String})],ih.prototype,"utf8String",void 0);Ws.DisplayText=ih=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Choice})],ih);var W_=class{organization=new ih;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};Ws.NoticeReference=W_;No.__decorate([(0,Ui.AsnProp)({type:ih})],W_.prototype,"organization",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Integer,repeated:"sequence"})],W_.prototype,"noticeNumbers",void 0);var H_=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};Ws.UserNotice=H_;No.__decorate([(0,Ui.AsnProp)({type:W_,optional:!0})],H_.prototype,"noticeRef",void 0);No.__decorate([(0,Ui.AsnProp)({type:ih,optional:!0})],H_.prototype,"explicitText",void 0);var C4=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};Ws.Qualifier=C4;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.IA5String})],C4.prototype,"cPSuri",void 0);No.__decorate([(0,Ui.AsnProp)({type:H_})],C4.prototype,"userNotice",void 0);Ws.Qualifier=C4=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Choice})],C4);var V_=class{policyQualifierId="";qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Ws.PolicyQualifierInfo=V_;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.ObjectIdentifier})],V_.prototype,"policyQualifierId",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Any})],V_.prototype,"qualifier",void 0);var G_=class{policyIdentifier="";policyQualifiers;constructor(e={}){Object.assign(this,e)}};Ws.PolicyInformation=G_;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.ObjectIdentifier})],G_.prototype,"policyIdentifier",void 0);No.__decorate([(0,Ui.AsnProp)({type:V_,repeated:"sequence",optional:!0})],G_.prototype,"policyQualifiers",void 0);var rte=tte=class extends Ui.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,tte.prototype)}};Ws.CertificatePolicies=rte;Ws.CertificatePolicies=rte=tte=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Sequence,itemType:G_})],rte)});var nte=L(Zx=>{"use strict";Object.defineProperty(Zx,"__esModule",{value:!0});Zx.CRLNumber=Zx.id_ce_cRLNumber=void 0;var b8e=(at(),He(st)),SN=bt(),VSt=vs();Zx.id_ce_cRLNumber=`${VSt.id_ce}.20`;var AN=class{value;constructor(e=0){this.value=e}};Zx.CRLNumber=AN;b8e.__decorate([(0,SN.AsnProp)({type:SN.AsnPropTypes.Integer})],AN.prototype,"value",void 0);Zx.CRLNumber=AN=b8e.__decorate([(0,SN.AsnType)({type:SN.AsnTypeTypes.Choice})],AN)});var w8e=L(Xx=>{"use strict";Object.defineProperty(Xx,"__esModule",{value:!0});Xx.BaseCRLNumber=Xx.id_ce_deltaCRLIndicator=void 0;var GSt=(at(),He(st)),_8e=bt(),KSt=vs(),ZSt=nte();Xx.id_ce_deltaCRLIndicator=`${KSt.id_ce}.27`;var ite=class extends ZSt.CRLNumber{};Xx.BaseCRLNumber=ite;Xx.BaseCRLNumber=ite=GSt.__decorate([(0,_8e.AsnType)({type:_8e.AsnTypeTypes.Choice})],ite)});var TN=L(pc=>{"use strict";var ste;Object.defineProperty(pc,"__esModule",{value:!0});pc.CRLDistributionPoints=pc.DistributionPoint=pc.DistributionPointName=pc.Reason=pc.ReasonFlags=pc.id_ce_cRLDistributionPoints=void 0;var Jx=(at(),He(st)),Uf=bt(),XSt=B_(),S8e=Gx(),YSt=vs();pc.id_ce_cRLDistributionPoints=`${YSt.id_ce}.31`;var Bf;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(Bf||(pc.ReasonFlags=Bf={}));var EN=class extends Uf.BitString{toJSON(){let e=[],r=this.toNumber();return r&Bf.aACompromise&&e.push("aACompromise"),r&Bf.affiliationChanged&&e.push("affiliationChanged"),r&Bf.cACompromise&&e.push("cACompromise"),r&Bf.certificateHold&&e.push("certificateHold"),r&Bf.cessationOfOperation&&e.push("cessationOfOperation"),r&Bf.keyCompromise&&e.push("keyCompromise"),r&Bf.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Bf.superseded&&e.push("superseded"),r&Bf.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}};pc.Reason=EN;var K_=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};pc.DistributionPointName=K_;Jx.__decorate([(0,Uf.AsnProp)({type:S8e.GeneralName,context:0,repeated:"sequence",implicit:!0})],K_.prototype,"fullName",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:XSt.RelativeDistinguishedName,context:1,implicit:!0})],K_.prototype,"nameRelativeToCRLIssuer",void 0);pc.DistributionPointName=K_=Jx.__decorate([(0,Uf.AsnType)({type:Uf.AsnTypeTypes.Choice})],K_);var Yx=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};pc.DistributionPoint=Yx;Jx.__decorate([(0,Uf.AsnProp)({type:K_,context:0,optional:!0})],Yx.prototype,"distributionPoint",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:EN,context:1,optional:!0,implicit:!0})],Yx.prototype,"reasons",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:S8e.GeneralName,context:2,optional:!0,repeated:"sequence",implicit:!0})],Yx.prototype,"cRLIssuer",void 0);var ate=ste=class extends Uf.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,ste.prototype)}};pc.CRLDistributionPoints=ate;pc.CRLDistributionPoints=ate=ste=Jx.__decorate([(0,Uf.AsnType)({type:Uf.AsnTypeTypes.Sequence,itemType:Yx})],ate)});var T8e=L(Qx=>{"use strict";var ote;Object.defineProperty(Qx,"__esModule",{value:!0});Qx.FreshestCRL=Qx.id_ce_freshestCRL=void 0;var JSt=(at(),He(st)),A8e=bt(),QSt=vs(),E8e=TN();Qx.id_ce_freshestCRL=`${QSt.id_ce}.46`;var cte=ote=class extends E8e.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,ote.prototype)}};Qx.FreshestCRL=cte;Qx.FreshestCRL=cte=ote=JSt.__decorate([(0,A8e.AsnType)({type:A8e.AsnTypeTypes.Sequence,itemType:E8e.DistributionPoint})],cte)});var k8e=L(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});Z_.IssuingDistributionPoint=Z_.id_ce_issuingDistributionPoint=void 0;var X_=(at(),He(st)),sh=bt(),eAt=vs(),C8e=TN();Z_.id_ce_issuingDistributionPoint=`${eAt.id_ce}.28`;var nl=class t{static ONLY=!1;distributionPoint;onlyContainsUserCerts=t.ONLY;onlyContainsCACerts=t.ONLY;onlySomeReasons;indirectCRL=t.ONLY;onlyContainsAttributeCerts=t.ONLY;constructor(e={}){Object.assign(this,e)}};Z_.IssuingDistributionPoint=nl;X_.__decorate([(0,sh.AsnProp)({type:C8e.DistributionPointName,context:0,optional:!0})],nl.prototype,"distributionPoint",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:1,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsUserCerts",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:2,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsCACerts",void 0);X_.__decorate([(0,sh.AsnProp)({type:C8e.Reason,context:3,optional:!0,implicit:!0})],nl.prototype,"onlySomeReasons",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:4,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"indirectCRL",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:5,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsAttributeCerts",void 0)});var I8e=L(q0=>{"use strict";Object.defineProperty(q0,"__esModule",{value:!0});q0.CRLReason=q0.CRLReasons=q0.id_ce_cRLReasons=void 0;var D8e=(at(),He(st)),CN=bt(),tAt=vs();q0.id_ce_cRLReasons=`${tAt.id_ce}.21`;var k4;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(k4||(q0.CRLReasons=k4={}));var kN=class{reason=k4.unspecified;constructor(e=k4.unspecified){this.reason=e}toJSON(){return k4[this.reason]}toString(){return this.toJSON()}};q0.CRLReason=kN;D8e.__decorate([(0,CN.AsnProp)({type:CN.AsnPropTypes.Enumerated})],kN.prototype,"reason",void 0);q0.CRLReason=kN=D8e.__decorate([(0,CN.AsnType)({type:CN.AsnTypeTypes.Choice})],kN)});var F8e=L(la=>{"use strict";var ute;Object.defineProperty(la,"__esModule",{value:!0});la.id_kp_OCSPSigning=la.id_kp_timeStamping=la.id_kp_emailProtection=la.id_kp_codeSigning=la.id_kp_clientAuth=la.id_kp_serverAuth=la.anyExtendedKeyUsage=la.ExtendedKeyUsage=la.id_ce_extKeyUsage=void 0;var rAt=(at(),He(st)),DN=bt(),ey=vs();la.id_ce_extKeyUsage=`${ey.id_ce}.37`;var lte=ute=class extends DN.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,ute.prototype)}};la.ExtendedKeyUsage=lte;la.ExtendedKeyUsage=lte=ute=rAt.__decorate([(0,DN.AsnType)({type:DN.AsnTypeTypes.Sequence,itemType:DN.AsnPropTypes.ObjectIdentifier})],lte);la.anyExtendedKeyUsage=`${la.id_ce_extKeyUsage}.0`;la.id_kp_serverAuth=`${ey.id_kp}.1`;la.id_kp_clientAuth=`${ey.id_kp}.2`;la.id_kp_codeSigning=`${ey.id_kp}.3`;la.id_kp_emailProtection=`${ey.id_kp}.4`;la.id_kp_timeStamping=`${ey.id_kp}.8`;la.id_kp_OCSPSigning=`${ey.id_kp}.9`});var R8e=L(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.InhibitAnyPolicy=ty.id_ce_inhibitAnyPolicy=void 0;var P8e=(at(),He(st)),D4=bt(),nAt=vs();ty.id_ce_inhibitAnyPolicy=`${nAt.id_ce}.54`;var IN=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};ty.InhibitAnyPolicy=IN;P8e.__decorate([(0,D4.AsnProp)({type:D4.AsnPropTypes.Integer,converter:D4.AsnIntegerArrayBufferConverter})],IN.prototype,"value",void 0);ty.InhibitAnyPolicy=IN=P8e.__decorate([(0,D4.AsnType)({type:D4.AsnTypeTypes.Choice})],IN)});var N8e=L(ry=>{"use strict";Object.defineProperty(ry,"__esModule",{value:!0});ry.InvalidityDate=ry.id_ce_invalidityDate=void 0;var O8e=(at(),He(st)),FN=bt(),iAt=vs();ry.id_ce_invalidityDate=`${iAt.id_ce}.24`;var PN=class{value=new Date;constructor(e){e&&(this.value=e)}};ry.InvalidityDate=PN;O8e.__decorate([(0,FN.AsnProp)({type:FN.AsnPropTypes.GeneralizedTime})],PN.prototype,"value",void 0);ry.InvalidityDate=PN=O8e.__decorate([(0,FN.AsnType)({type:FN.AsnTypeTypes.Choice})],PN)});var U8e=L(ny=>{"use strict";var fte;Object.defineProperty(ny,"__esModule",{value:!0});ny.IssueAlternativeName=ny.id_ce_issuerAltName=void 0;var sAt=(at(),He(st)),B8e=bt(),aAt=T4(),oAt=vs();ny.id_ce_issuerAltName=`${oAt.id_ce}.18`;var dte=fte=class extends aAt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,fte.prototype)}};ny.IssueAlternativeName=dte;ny.IssueAlternativeName=dte=fte=sAt.__decorate([(0,B8e.AsnType)({type:B8e.AsnTypeTypes.Sequence})],dte)});var M8e=L(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.KeyUsage=Jm.KeyUsageFlags=Jm.id_ce_keyUsage=void 0;var cAt=bt(),uAt=vs();Jm.id_ce_keyUsage=`${uAt.id_ce}.15`;var Mf;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Mf||(Jm.KeyUsageFlags=Mf={}));var hte=class extends cAt.BitString{toJSON(){let e=this.toNumber(),r=[];return e&Mf.cRLSign&&r.push("crlSign"),e&Mf.dataEncipherment&&r.push("dataEncipherment"),e&Mf.decipherOnly&&r.push("decipherOnly"),e&Mf.digitalSignature&&r.push("digitalSignature"),e&Mf.encipherOnly&&r.push("encipherOnly"),e&Mf.keyAgreement&&r.push("keyAgreement"),e&Mf.keyCertSign&&r.push("keyCertSign"),e&Mf.keyEncipherment&&r.push("keyEncipherment"),e&Mf.nonRepudiation&&r.push("nonRepudiation"),r}toString(){return`[${this.toJSON().join(", ")}]`}};Jm.KeyUsage=hte});var $8e=L(Lf=>{"use strict";var pte;Object.defineProperty(Lf,"__esModule",{value:!0});Lf.NameConstraints=Lf.GeneralSubtrees=Lf.GeneralSubtree=Lf.id_ce_nameConstraints=void 0;var Y_=(at(),He(st)),ah=bt(),L8e=Gx(),lAt=vs();Lf.id_ce_nameConstraints=`${lAt.id_ce}.30`;var iy=class{base=new L8e.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};Lf.GeneralSubtree=iy;Y_.__decorate([(0,ah.AsnProp)({type:L8e.GeneralName})],iy.prototype,"base",void 0);Y_.__decorate([(0,ah.AsnProp)({type:ah.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],iy.prototype,"minimum",void 0);Y_.__decorate([(0,ah.AsnProp)({type:ah.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],iy.prototype,"maximum",void 0);var I4=pte=class extends ah.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,pte.prototype)}};Lf.GeneralSubtrees=I4;Lf.GeneralSubtrees=I4=pte=Y_.__decorate([(0,ah.AsnType)({type:ah.AsnTypeTypes.Sequence,itemType:iy})],I4);var F4=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};Lf.NameConstraints=F4;Y_.__decorate([(0,ah.AsnProp)({type:I4,context:0,optional:!0,implicit:!0})],F4.prototype,"permittedSubtrees",void 0);Y_.__decorate([(0,ah.AsnProp)({type:I4,context:1,optional:!0,implicit:!0})],F4.prototype,"excludedSubtrees",void 0)});var q8e=L(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});Q_.PolicyConstraints=Q_.id_ce_policyConstraints=void 0;var j8e=(at(),He(st)),J_=bt(),fAt=vs();Q_.id_ce_policyConstraints=`${fAt.id_ce}.36`;var P4=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};Q_.PolicyConstraints=P4;j8e.__decorate([(0,J_.AsnProp)({type:J_.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:J_.AsnIntegerArrayBufferConverter})],P4.prototype,"requireExplicitPolicy",void 0);j8e.__decorate([(0,J_.AsnProp)({type:J_.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:J_.AsnIntegerArrayBufferConverter})],P4.prototype,"inhibitPolicyMapping",void 0)});var z8e=L(z0=>{"use strict";var mte;Object.defineProperty(z0,"__esModule",{value:!0});z0.PolicyMappings=z0.PolicyMapping=z0.id_ce_policyMappings=void 0;var xte=(at(),He(st)),sy=bt(),dAt=vs();z0.id_ce_policyMappings=`${dAt.id_ce}.33`;var ew=class{issuerDomainPolicy="";subjectDomainPolicy="";constructor(e={}){Object.assign(this,e)}};z0.PolicyMapping=ew;xte.__decorate([(0,sy.AsnProp)({type:sy.AsnPropTypes.ObjectIdentifier})],ew.prototype,"issuerDomainPolicy",void 0);xte.__decorate([(0,sy.AsnProp)({type:sy.AsnPropTypes.ObjectIdentifier})],ew.prototype,"subjectDomainPolicy",void 0);var gte=mte=class extends sy.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,mte.prototype)}};z0.PolicyMappings=gte;z0.PolicyMappings=gte=mte=xte.__decorate([(0,sy.AsnType)({type:sy.AsnTypeTypes.Sequence,itemType:ew})],gte)});var H8e=L(ay=>{"use strict";var yte;Object.defineProperty(ay,"__esModule",{value:!0});ay.SubjectAlternativeName=ay.id_ce_subjectAltName=void 0;var hAt=(at(),He(st)),W8e=bt(),pAt=T4(),mAt=vs();ay.id_ce_subjectAltName=`${mAt.id_ce}.17`;var vte=yte=class extends pAt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,yte.prototype)}};ay.SubjectAlternativeName=vte;ay.SubjectAlternativeName=vte=yte=hAt.__decorate([(0,W8e.AsnType)({type:W8e.AsnTypeTypes.Sequence})],vte)});var bte=L(ON=>{"use strict";Object.defineProperty(ON,"__esModule",{value:!0});ON.Attribute=void 0;var V8e=(at(),He(st)),RN=bt(),R4=class{type="";values=[];constructor(e={}){Object.assign(this,e)}};ON.Attribute=R4;V8e.__decorate([(0,RN.AsnProp)({type:RN.AsnPropTypes.ObjectIdentifier})],R4.prototype,"type",void 0);V8e.__decorate([(0,RN.AsnProp)({type:RN.AsnPropTypes.Any,repeated:"set"})],R4.prototype,"values",void 0)});var G8e=L(oy=>{"use strict";var _te;Object.defineProperty(oy,"__esModule",{value:!0});oy.SubjectDirectoryAttributes=oy.id_ce_subjectDirectoryAttributes=void 0;var gAt=(at(),He(st)),wte=bt(),xAt=bte(),yAt=vs();oy.id_ce_subjectDirectoryAttributes=`${yAt.id_ce}.9`;var Ste=_te=class extends wte.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,_te.prototype)}};oy.SubjectDirectoryAttributes=Ste;oy.SubjectDirectoryAttributes=Ste=_te=gAt.__decorate([(0,wte.AsnType)({type:wte.AsnTypeTypes.Sequence,itemType:xAt.Attribute})],Ste)});var K8e=L(tw=>{"use strict";Object.defineProperty(tw,"__esModule",{value:!0});tw.SubjectKeyIdentifier=tw.id_ce_subjectKeyIdentifier=void 0;var vAt=vs(),bAt=Zee();tw.id_ce_subjectKeyIdentifier=`${vAt.id_ce}.14`;var Ate=class extends bAt.KeyIdentifier{};tw.SubjectKeyIdentifier=Ate});var X8e=L(rw=>{"use strict";Object.defineProperty(rw,"__esModule",{value:!0});rw.PrivateKeyUsagePeriod=rw.id_ce_privateKeyUsagePeriod=void 0;var Z8e=(at(),He(st)),NN=bt(),_At=vs();rw.id_ce_privateKeyUsagePeriod=`${_At.id_ce}.16`;var O4=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};rw.PrivateKeyUsagePeriod=O4;Z8e.__decorate([(0,NN.AsnProp)({type:NN.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],O4.prototype,"notBefore",void 0);Z8e.__decorate([(0,NN.AsnProp)({type:NN.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],O4.prototype,"notAfter",void 0)});var J8e=L(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});oh.EntrustVersionInfo=oh.EntrustInfo=oh.EntrustInfoFlags=oh.id_entrust_entrustVersInfo=void 0;var Y8e=(at(),He(st)),BN=bt();oh.id_entrust_entrustVersInfo="1.2.840.113533.7.65.0";var N4;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(N4||(oh.EntrustInfoFlags=N4={}));var B4=class extends BN.BitString{toJSON(){let e=[],r=this.toNumber();return r&N4.pKIXCertificate&&e.push("pKIXCertificate"),r&N4.newExtensions&&e.push("newExtensions"),r&N4.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}};oh.EntrustInfo=B4;var U4=class{entrustVers="";entrustInfoFlags=new B4;constructor(e={}){Object.assign(this,e)}};oh.EntrustVersionInfo=U4;Y8e.__decorate([(0,BN.AsnProp)({type:BN.AsnPropTypes.GeneralString})],U4.prototype,"entrustVers",void 0);Y8e.__decorate([(0,BN.AsnProp)({type:B4})],U4.prototype,"entrustInfoFlags",void 0)});var Q8e=L(cy=>{"use strict";var Ete;Object.defineProperty(cy,"__esModule",{value:!0});cy.SubjectInfoAccessSyntax=cy.id_pe_subjectInfoAccess=void 0;var wAt=(at(),He(st)),Tte=bt(),SAt=vs(),AAt=Gee();cy.id_pe_subjectInfoAccess=`${SAt.id_pe}.11`;var Cte=Ete=class extends Tte.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Ete.prototype)}};cy.SubjectInfoAccessSyntax=Cte;cy.SubjectInfoAccessSyntax=Cte=Ete=wAt.__decorate([(0,Tte.AsnType)({type:Tte.AsnTypeTypes.Sequence,itemType:AAt.AccessDescription})],Cte)});var e5e=L(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});var Fs=(at(),He(st));Fs.__exportStar(Gee(),os);Fs.__exportStar(Zee(),os);Fs.__exportStar(g8e(),os);Fs.__exportStar(y8e(),os);Fs.__exportStar(v8e(),os);Fs.__exportStar(w8e(),os);Fs.__exportStar(TN(),os);Fs.__exportStar(T8e(),os);Fs.__exportStar(k8e(),os);Fs.__exportStar(nte(),os);Fs.__exportStar(I8e(),os);Fs.__exportStar(F8e(),os);Fs.__exportStar(R8e(),os);Fs.__exportStar(N8e(),os);Fs.__exportStar(U8e(),os);Fs.__exportStar(M8e(),os);Fs.__exportStar($8e(),os);Fs.__exportStar(q8e(),os);Fs.__exportStar(z8e(),os);Fs.__exportStar(H8e(),os);Fs.__exportStar(G8e(),os);Fs.__exportStar(K8e(),os);Fs.__exportStar(X8e(),os);Fs.__exportStar(J8e(),os);Fs.__exportStar(Q8e(),os)});var uy=L(MN=>{"use strict";Object.defineProperty(MN,"__esModule",{value:!0});MN.AlgorithmIdentifier=void 0;var t5e=(at(),He(st)),UN=bt(),EAt=el(),M4=class t{algorithm="";parameters;constructor(e={}){Object.assign(this,e)}isEqual(e){return e instanceof t&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&(0,EAt.equal)(e.parameters,this.parameters)||e.parameters===this.parameters)}};MN.AlgorithmIdentifier=M4;t5e.__decorate([(0,UN.AsnProp)({type:UN.AsnPropTypes.ObjectIdentifier})],M4.prototype,"algorithm",void 0);t5e.__decorate([(0,UN.AsnProp)({type:UN.AsnPropTypes.Any,optional:!0})],M4.prototype,"parameters",void 0)});var Dte=L(LN=>{"use strict";Object.defineProperty(LN,"__esModule",{value:!0});LN.SubjectPublicKeyInfo=void 0;var r5e=(at(),He(st)),kte=bt(),n5e=uy(),L4=class{algorithm=new n5e.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};LN.SubjectPublicKeyInfo=L4;r5e.__decorate([(0,kte.AsnProp)({type:n5e.AlgorithmIdentifier})],L4.prototype,"algorithm",void 0);r5e.__decorate([(0,kte.AsnProp)({type:kte.AsnPropTypes.BitString})],L4.prototype,"subjectPublicKey",void 0)});var $N=L(j4=>{"use strict";Object.defineProperty(j4,"__esModule",{value:!0});j4.Time=void 0;var Ite=(at(),He(st)),nw=bt(),$4=class{utcTime;generalTime;constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){let r=new Date(e);r.setMilliseconds(0),r.getUTCFullYear()>2049?this.generalTime=r:this.utcTime=r}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};j4.Time=$4;Ite.__decorate([(0,nw.AsnProp)({type:nw.AsnPropTypes.UTCTime})],$4.prototype,"utcTime",void 0);Ite.__decorate([(0,nw.AsnProp)({type:nw.AsnPropTypes.GeneralizedTime})],$4.prototype,"generalTime",void 0);j4.Time=$4=Ite.__decorate([(0,nw.AsnType)({type:nw.AsnTypeTypes.Choice})],$4)});var Fte=L(jN=>{"use strict";Object.defineProperty(jN,"__esModule",{value:!0});jN.Validity=void 0;var i5e=(at(),He(st)),s5e=bt(),iw=$N(),q4=class{notBefore=new iw.Time(new Date);notAfter=new iw.Time(new Date);constructor(e){e&&(this.notBefore=new iw.Time(e.notBefore),this.notAfter=new iw.Time(e.notAfter))}};jN.Validity=q4;i5e.__decorate([(0,s5e.AsnProp)({type:iw.Time})],q4.prototype,"notBefore",void 0);i5e.__decorate([(0,s5e.AsnProp)({type:iw.Time})],q4.prototype,"notAfter",void 0)});var zN=L(ly=>{"use strict";var Pte;Object.defineProperty(ly,"__esModule",{value:!0});ly.Extensions=ly.Extension=void 0;var qN=(at(),He(st)),ch=bt(),Qm=class t{static CRITICAL=!1;extnID="";critical=t.CRITICAL;extnValue=new ch.OctetString;constructor(e={}){Object.assign(this,e)}};ly.Extension=Qm;qN.__decorate([(0,ch.AsnProp)({type:ch.AsnPropTypes.ObjectIdentifier})],Qm.prototype,"extnID",void 0);qN.__decorate([(0,ch.AsnProp)({type:ch.AsnPropTypes.Boolean,defaultValue:Qm.CRITICAL})],Qm.prototype,"critical",void 0);qN.__decorate([(0,ch.AsnProp)({type:ch.OctetString})],Qm.prototype,"extnValue",void 0);var Rte=Pte=class extends ch.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Pte.prototype)}};ly.Extensions=Rte;ly.Extensions=Rte=Pte=qN.__decorate([(0,ch.AsnType)({type:ch.AsnTypeTypes.Sequence,itemType:Qm})],Rte)});var Ote=L(WN=>{"use strict";Object.defineProperty(WN,"__esModule",{value:!0});WN.Version=void 0;var a5e;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(a5e||(WN.Version=a5e={}))});var Nte=L(VN=>{"use strict";Object.defineProperty(VN,"__esModule",{value:!0});VN.TBSCertificate=void 0;var uh=(at(),He(st)),Lc=bt(),o5e=uy(),HN=B_(),c5e=Dte(),u5e=Fte(),TAt=zN(),l5e=Ote(),il=class{version=l5e.Version.v1;serialNumber=new ArrayBuffer(0);signature=new o5e.AlgorithmIdentifier;issuer=new HN.Name;validity=new u5e.Validity;subject=new HN.Name;subjectPublicKeyInfo=new c5e.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};VN.TBSCertificate=il;uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.Integer,context:0,defaultValue:l5e.Version.v1})],il.prototype,"version",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.Integer,converter:Lc.AsnIntegerArrayBufferConverter})],il.prototype,"serialNumber",void 0);uh.__decorate([(0,Lc.AsnProp)({type:o5e.AlgorithmIdentifier})],il.prototype,"signature",void 0);uh.__decorate([(0,Lc.AsnProp)({type:HN.Name})],il.prototype,"issuer",void 0);uh.__decorate([(0,Lc.AsnProp)({type:u5e.Validity})],il.prototype,"validity",void 0);uh.__decorate([(0,Lc.AsnProp)({type:HN.Name})],il.prototype,"subject",void 0);uh.__decorate([(0,Lc.AsnProp)({type:c5e.SubjectPublicKeyInfo})],il.prototype,"subjectPublicKeyInfo",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],il.prototype,"issuerUniqueID",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],il.prototype,"subjectUniqueID",void 0);uh.__decorate([(0,Lc.AsnProp)({type:TAt.Extensions,context:3,optional:!0})],il.prototype,"extensions",void 0)});var h5e=L(KN=>{"use strict";Object.defineProperty(KN,"__esModule",{value:!0});KN.Certificate=void 0;var Bte=(at(),He(st)),GN=bt(),f5e=uy(),d5e=Nte(),sw=class{tbsCertificate=new d5e.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new f5e.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};KN.Certificate=sw;Bte.__decorate([(0,GN.AsnProp)({type:d5e.TBSCertificate,raw:!0})],sw.prototype,"tbsCertificate",void 0);Bte.__decorate([(0,GN.AsnProp)({type:f5e.AlgorithmIdentifier})],sw.prototype,"signatureAlgorithm",void 0);Bte.__decorate([(0,GN.AsnProp)({type:GN.AsnPropTypes.BitString})],sw.prototype,"signatureValue",void 0)});var Ute=L(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});aw.TBSCertList=aw.RevokedCertificate=void 0;var fh=(at(),He(st)),sl=bt(),p5e=uy(),m5e=B_(),z4=$N(),g5e=zN(),fy=class{userCertificate=new ArrayBuffer(0);revocationDate=new z4.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};aw.RevokedCertificate=fy;fh.__decorate([(0,sl.AsnProp)({type:sl.AsnPropTypes.Integer,converter:sl.AsnIntegerArrayBufferConverter})],fy.prototype,"userCertificate",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time})],fy.prototype,"revocationDate",void 0);fh.__decorate([(0,sl.AsnProp)({type:g5e.Extension,optional:!0,repeated:"sequence"})],fy.prototype,"crlEntryExtensions",void 0);var lh=class{version;signature=new p5e.AlgorithmIdentifier;issuer=new m5e.Name;thisUpdate=new z4.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};aw.TBSCertList=lh;fh.__decorate([(0,sl.AsnProp)({type:sl.AsnPropTypes.Integer,optional:!0})],lh.prototype,"version",void 0);fh.__decorate([(0,sl.AsnProp)({type:p5e.AlgorithmIdentifier})],lh.prototype,"signature",void 0);fh.__decorate([(0,sl.AsnProp)({type:m5e.Name})],lh.prototype,"issuer",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time})],lh.prototype,"thisUpdate",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time,optional:!0})],lh.prototype,"nextUpdate",void 0);fh.__decorate([(0,sl.AsnProp)({type:fy,repeated:"sequence",optional:!0})],lh.prototype,"revokedCertificates",void 0);fh.__decorate([(0,sl.AsnProp)({type:g5e.Extension,optional:!0,context:0,repeated:"sequence"})],lh.prototype,"crlExtensions",void 0)});var v5e=L(XN=>{"use strict";Object.defineProperty(XN,"__esModule",{value:!0});XN.CertificateList=void 0;var Mte=(at(),He(st)),ZN=bt(),x5e=uy(),y5e=Ute(),ow=class{tbsCertList=new y5e.TBSCertList;tbsCertListRaw;signatureAlgorithm=new x5e.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};XN.CertificateList=ow;Mte.__decorate([(0,ZN.AsnProp)({type:y5e.TBSCertList,raw:!0})],ow.prototype,"tbsCertList",void 0);Mte.__decorate([(0,ZN.AsnProp)({type:x5e.AlgorithmIdentifier})],ow.prototype,"signatureAlgorithm",void 0);Mte.__decorate([(0,ZN.AsnProp)({type:ZN.AsnPropTypes.BitString})],ow.prototype,"signature",void 0)});var hi=L(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});var mc=(at(),He(st));mc.__exportStar(e5e(),fo);mc.__exportStar(uy(),fo);mc.__exportStar(bte(),fo);mc.__exportStar(h5e(),fo);mc.__exportStar(v5e(),fo);mc.__exportStar(zN(),fo);mc.__exportStar(Gx(),fo);mc.__exportStar(T4(),fo);mc.__exportStar(B_(),fo);mc.__exportStar(vs(),fo);mc.__exportStar(Dte(),fo);mc.__exportStar(Ute(),fo);mc.__exportStar(Nte(),fo);mc.__exportStar($N(),fo);mc.__exportStar(Ote(),fo);mc.__exportStar(Fte(),fo)});var H4=L(JN=>{"use strict";Object.defineProperty(JN,"__esModule",{value:!0});JN.IssuerAndSerialNumber=void 0;var b5e=(at(),He(st)),YN=bt(),_5e=hi(),W4=class{issuer=new _5e.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};JN.IssuerAndSerialNumber=W4;b5e.__decorate([(0,YN.AsnProp)({type:_5e.Name})],W4.prototype,"issuer",void 0);b5e.__decorate([(0,YN.AsnProp)({type:YN.AsnPropTypes.Integer,converter:YN.AsnIntegerArrayBufferConverter})],W4.prototype,"serialNumber",void 0)});var $te=L(G4=>{"use strict";Object.defineProperty(G4,"__esModule",{value:!0});G4.SignerIdentifier=void 0;var Lte=(at(),He(st)),QN=bt(),CAt=hi(),kAt=H4(),V4=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};G4.SignerIdentifier=V4;Lte.__decorate([(0,QN.AsnProp)({type:CAt.SubjectKeyIdentifier,context:0,implicit:!0})],V4.prototype,"subjectKeyIdentifier",void 0);Lte.__decorate([(0,QN.AsnProp)({type:kAt.IssuerAndSerialNumber})],V4.prototype,"issuerAndSerialNumber",void 0);G4.SignerIdentifier=V4=Lte.__decorate([(0,QN.AsnType)({type:QN.AsnTypeTypes.Choice})],V4)});var dh=L(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.KeyDerivationAlgorithmIdentifier=fa.MessageAuthenticationCodeAlgorithm=fa.ContentEncryptionAlgorithmIdentifier=fa.KeyEncryptionAlgorithmIdentifier=fa.SignatureAlgorithmIdentifier=fa.DigestAlgorithmIdentifier=fa.CMSVersion=void 0;var cw=(at(),He(st)),uw=hi(),Xl=bt(),w5e;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(w5e||(fa.CMSVersion=w5e={}));var jte=class extends uw.AlgorithmIdentifier{};fa.DigestAlgorithmIdentifier=jte;fa.DigestAlgorithmIdentifier=jte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],jte);var qte=class extends uw.AlgorithmIdentifier{};fa.SignatureAlgorithmIdentifier=qte;fa.SignatureAlgorithmIdentifier=qte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],qte);var zte=class extends uw.AlgorithmIdentifier{};fa.KeyEncryptionAlgorithmIdentifier=zte;fa.KeyEncryptionAlgorithmIdentifier=zte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],zte);var Wte=class extends uw.AlgorithmIdentifier{};fa.ContentEncryptionAlgorithmIdentifier=Wte;fa.ContentEncryptionAlgorithmIdentifier=Wte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Wte);var Hte=class extends uw.AlgorithmIdentifier{};fa.MessageAuthenticationCodeAlgorithm=Hte;fa.MessageAuthenticationCodeAlgorithm=Hte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Hte);var Vte=class extends uw.AlgorithmIdentifier{};fa.KeyDerivationAlgorithmIdentifier=Vte;fa.KeyDerivationAlgorithmIdentifier=Vte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Vte)});var r7=L(t7=>{"use strict";Object.defineProperty(t7,"__esModule",{value:!0});t7.Attribute=void 0;var S5e=(at(),He(st)),e7=bt(),K4=class{attrType="";attrValues=[];constructor(e={}){Object.assign(this,e)}};t7.Attribute=K4;S5e.__decorate([(0,e7.AsnProp)({type:e7.AsnPropTypes.ObjectIdentifier})],K4.prototype,"attrType",void 0);S5e.__decorate([(0,e7.AsnProp)({type:e7.AsnPropTypes.Any,repeated:"set"})],K4.prototype,"attrValues",void 0)});var n7=L(dy=>{"use strict";var Gte;Object.defineProperty(dy,"__esModule",{value:!0});dy.SignerInfos=dy.SignerInfo=void 0;var eg=(at(),He(st)),al=bt(),A5e=$te(),Z4=dh(),E5e=r7(),$f=class{version=Z4.CMSVersion.v0;sid=new A5e.SignerIdentifier;digestAlgorithm=new Z4.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new Z4.SignatureAlgorithmIdentifier;signature=new al.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};dy.SignerInfo=$f;eg.__decorate([(0,al.AsnProp)({type:al.AsnPropTypes.Integer})],$f.prototype,"version",void 0);eg.__decorate([(0,al.AsnProp)({type:A5e.SignerIdentifier})],$f.prototype,"sid",void 0);eg.__decorate([(0,al.AsnProp)({type:Z4.DigestAlgorithmIdentifier})],$f.prototype,"digestAlgorithm",void 0);eg.__decorate([(0,al.AsnProp)({type:E5e.Attribute,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],$f.prototype,"signedAttrs",void 0);eg.__decorate([(0,al.AsnProp)({type:Z4.SignatureAlgorithmIdentifier})],$f.prototype,"signatureAlgorithm",void 0);eg.__decorate([(0,al.AsnProp)({type:al.OctetString})],$f.prototype,"signature",void 0);eg.__decorate([(0,al.AsnProp)({type:E5e.Attribute,repeated:"set",context:1,implicit:!0,optional:!0})],$f.prototype,"unsignedAttrs",void 0);var Kte=Gte=class extends al.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Gte.prototype)}};dy.SignerInfos=Kte;dy.SignerInfos=Kte=Gte=eg.__decorate([(0,al.AsnType)({type:al.AsnTypeTypes.Set,itemType:$f})],Kte)});var C5e=L(hy=>{"use strict";Object.defineProperty(hy,"__esModule",{value:!0});hy.CounterSignature=hy.id_counterSignature=void 0;var DAt=(at(),He(st)),T5e=bt(),IAt=n7();hy.id_counterSignature="1.2.840.113549.1.9.6";var Zte=class extends IAt.SignerInfo{};hy.CounterSignature=Zte;hy.CounterSignature=Zte=DAt.__decorate([(0,T5e.AsnType)({type:T5e.AsnTypeTypes.Sequence})],Zte)});var k5e=L(lw=>{"use strict";Object.defineProperty(lw,"__esModule",{value:!0});lw.MessageDigest=lw.id_messageDigest=void 0;var FAt=bt();lw.id_messageDigest="1.2.840.113549.1.9.4";var Xte=class extends FAt.OctetString{};lw.MessageDigest=Xte});var I5e=L(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});py.SigningTime=py.id_signingTime=void 0;var PAt=(at(),He(st)),RAt=hi(),D5e=bt();py.id_signingTime="1.2.840.113549.1.9.5";var Yte=class extends RAt.Time{};py.SigningTime=Yte;py.SigningTime=Yte=PAt.__decorate([(0,D5e.AsnType)({type:D5e.AsnTypeTypes.Choice})],Yte)});var F5e=L(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});my.id_contentType=void 0;var Jte=(at(),He(st));Jte.__exportStar(C5e(),my);Jte.__exportStar(k5e(),my);Jte.__exportStar(I5e(),my);my.id_contentType="1.2.840.113549.1.9.3"});var P5e=L(s7=>{"use strict";Object.defineProperty(s7,"__esModule",{value:!0});s7.ACClearAttrs=void 0;var Qte=(at(),He(st)),i7=bt(),ere=hi(),fw=class{acIssuer=new ere.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};s7.ACClearAttrs=fw;Qte.__decorate([(0,i7.AsnProp)({type:ere.GeneralName})],fw.prototype,"acIssuer",void 0);Qte.__decorate([(0,i7.AsnProp)({type:i7.AsnPropTypes.Integer})],fw.prototype,"acSerial",void 0);Qte.__decorate([(0,i7.AsnProp)({type:ere.Attribute,repeated:"sequence"})],fw.prototype,"attrs",void 0)});var nre=L(X4=>{"use strict";var tre;Object.defineProperty(X4,"__esModule",{value:!0});X4.AttrSpec=void 0;var OAt=(at(),He(st)),a7=bt(),rre=tre=class extends a7.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,tre.prototype)}};X4.AttrSpec=rre;X4.AttrSpec=rre=tre=OAt.__decorate([(0,a7.AsnType)({type:a7.AsnTypeTypes.Sequence,itemType:a7.AsnPropTypes.ObjectIdentifier})],rre)});var O5e=L(c7=>{"use strict";Object.defineProperty(c7,"__esModule",{value:!0});c7.AAControls=void 0;var o7=(at(),He(st)),dw=bt(),R5e=nre(),gy=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};c7.AAControls=gy;o7.__decorate([(0,dw.AsnProp)({type:dw.AsnPropTypes.Integer,optional:!0})],gy.prototype,"pathLenConstraint",void 0);o7.__decorate([(0,dw.AsnProp)({type:R5e.AttrSpec,implicit:!0,context:0,optional:!0})],gy.prototype,"permittedAttrs",void 0);o7.__decorate([(0,dw.AsnProp)({type:R5e.AttrSpec,implicit:!0,context:1,optional:!0})],gy.prototype,"excludedAttrs",void 0);o7.__decorate([(0,dw.AsnProp)({type:dw.AsnPropTypes.Boolean,defaultValue:!0})],gy.prototype,"permitUnSpecified",void 0)});var Y4=L(u7=>{"use strict";Object.defineProperty(u7,"__esModule",{value:!0});u7.IssuerSerial=void 0;var ire=(at(),He(st)),hw=bt(),N5e=hi(),pw=class{issuer=new N5e.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};u7.IssuerSerial=pw;ire.__decorate([(0,hw.AsnProp)({type:N5e.GeneralNames})],pw.prototype,"issuer",void 0);ire.__decorate([(0,hw.AsnProp)({type:hw.AsnPropTypes.Integer,converter:hw.AsnIntegerArrayBufferConverter})],pw.prototype,"serial",void 0);ire.__decorate([(0,hw.AsnProp)({type:hw.AsnPropTypes.BitString,optional:!0})],pw.prototype,"issuerUID",void 0)});var J4=L(mw=>{"use strict";Object.defineProperty(mw,"__esModule",{value:!0});mw.ObjectDigestInfo=mw.DigestedObjectType=void 0;var l7=(at(),He(st)),xy=bt(),B5e=hi(),sre;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(sre||(mw.DigestedObjectType=sre={}));var yy=class{digestedObjectType=sre.publicKey;otherObjectTypeID;digestAlgorithm=new B5e.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};mw.ObjectDigestInfo=yy;l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.Enumerated})],yy.prototype,"digestedObjectType",void 0);l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.ObjectIdentifier,optional:!0})],yy.prototype,"otherObjectTypeID",void 0);l7.__decorate([(0,xy.AsnProp)({type:B5e.AlgorithmIdentifier})],yy.prototype,"digestAlgorithm",void 0);l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.BitString})],yy.prototype,"objectDigest",void 0)});var cre=L(f7=>{"use strict";Object.defineProperty(f7,"__esModule",{value:!0});f7.V2Form=void 0;var are=(at(),He(st)),ore=bt(),NAt=hi(),BAt=Y4(),UAt=J4(),gw=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};f7.V2Form=gw;are.__decorate([(0,ore.AsnProp)({type:NAt.GeneralNames,optional:!0})],gw.prototype,"issuerName",void 0);are.__decorate([(0,ore.AsnProp)({type:BAt.IssuerSerial,context:0,implicit:!0,optional:!0})],gw.prototype,"baseCertificateID",void 0);are.__decorate([(0,ore.AsnProp)({type:UAt.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],gw.prototype,"objectDigestInfo",void 0)});var lre=L(e3=>{"use strict";Object.defineProperty(e3,"__esModule",{value:!0});e3.AttCertIssuer=void 0;var ure=(at(),He(st)),d7=bt(),MAt=hi(),LAt=cre(),Q4=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e3.AttCertIssuer=Q4;ure.__decorate([(0,d7.AsnProp)({type:MAt.GeneralName,repeated:"sequence"})],Q4.prototype,"v1Form",void 0);ure.__decorate([(0,d7.AsnProp)({type:LAt.V2Form,context:0,implicit:!0})],Q4.prototype,"v2Form",void 0);e3.AttCertIssuer=Q4=ure.__decorate([(0,d7.AsnType)({type:d7.AsnTypeTypes.Choice})],Q4)});var fre=L(p7=>{"use strict";Object.defineProperty(p7,"__esModule",{value:!0});p7.AttCertValidityPeriod=void 0;var U5e=(at(),He(st)),h7=bt(),t3=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};p7.AttCertValidityPeriod=t3;U5e.__decorate([(0,h7.AsnProp)({type:h7.AsnPropTypes.GeneralizedTime})],t3.prototype,"notBeforeTime",void 0);U5e.__decorate([(0,h7.AsnProp)({type:h7.AsnPropTypes.GeneralizedTime})],t3.prototype,"notAfterTime",void 0)});var pre=L(m7=>{"use strict";Object.defineProperty(m7,"__esModule",{value:!0});m7.Holder=void 0;var dre=(at(),He(st)),hre=bt(),$At=hi(),jAt=Y4(),qAt=J4(),xw=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};m7.Holder=xw;dre.__decorate([(0,hre.AsnProp)({type:jAt.IssuerSerial,implicit:!0,context:0,optional:!0})],xw.prototype,"baseCertificateID",void 0);dre.__decorate([(0,hre.AsnProp)({type:$At.GeneralNames,implicit:!0,context:1,optional:!0})],xw.prototype,"entityName",void 0);dre.__decorate([(0,hre.AsnProp)({type:qAt.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],xw.prototype,"objectDigestInfo",void 0)});var gre=L(yw=>{"use strict";Object.defineProperty(yw,"__esModule",{value:!0});yw.AttributeCertificateInfo=yw.AttCertVersion=void 0;var W0=(at(),He(st)),ol=bt(),g7=hi(),M5e=pre(),L5e=lre(),$5e=fre(),mre;(function(t){t[t.v2=1]="v2"})(mre||(yw.AttCertVersion=mre={}));var Yl=class{version=mre.v2;holder=new M5e.Holder;issuer=new L5e.AttCertIssuer;signature=new g7.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new $5e.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};yw.AttributeCertificateInfo=Yl;W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.Integer})],Yl.prototype,"version",void 0);W0.__decorate([(0,ol.AsnProp)({type:M5e.Holder})],Yl.prototype,"holder",void 0);W0.__decorate([(0,ol.AsnProp)({type:L5e.AttCertIssuer})],Yl.prototype,"issuer",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.AlgorithmIdentifier})],Yl.prototype,"signature",void 0);W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.Integer,converter:ol.AsnIntegerArrayBufferConverter})],Yl.prototype,"serialNumber",void 0);W0.__decorate([(0,ol.AsnProp)({type:$5e.AttCertValidityPeriod})],Yl.prototype,"attrCertValidityPeriod",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.Attribute,repeated:"sequence"})],Yl.prototype,"attributes",void 0);W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.BitString,optional:!0})],Yl.prototype,"issuerUniqueID",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.Extensions,optional:!0})],Yl.prototype,"extensions",void 0)});var z5e=L(y7=>{"use strict";Object.defineProperty(y7,"__esModule",{value:!0});y7.AttributeCertificate=void 0;var xre=(at(),He(st)),x7=bt(),j5e=hi(),q5e=gre(),vw=class{acinfo=new q5e.AttributeCertificateInfo;signatureAlgorithm=new j5e.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};y7.AttributeCertificate=vw;xre.__decorate([(0,x7.AsnProp)({type:q5e.AttributeCertificateInfo})],vw.prototype,"acinfo",void 0);xre.__decorate([(0,x7.AsnProp)({type:j5e.AlgorithmIdentifier})],vw.prototype,"signatureAlgorithm",void 0);xre.__decorate([(0,x7.AsnProp)({type:x7.AsnPropTypes.BitString})],vw.prototype,"signatureValue",void 0)});var vre=L(bw=>{"use strict";Object.defineProperty(bw,"__esModule",{value:!0});bw.ClassList=bw.ClassListFlags=void 0;var zAt=bt(),W5e;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(W5e||(bw.ClassListFlags=W5e={}));var yre=class extends zAt.BitString{};bw.ClassList=yre});var bre=L(b7=>{"use strict";Object.defineProperty(b7,"__esModule",{value:!0});b7.SecurityCategory=void 0;var H5e=(at(),He(st)),v7=bt(),r3=class{type="";value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};b7.SecurityCategory=r3;H5e.__decorate([(0,v7.AsnProp)({type:v7.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],r3.prototype,"type",void 0);H5e.__decorate([(0,v7.AsnProp)({type:v7.AsnPropTypes.Any,implicit:!0,context:1})],r3.prototype,"value",void 0)});var V5e=L(w7=>{"use strict";Object.defineProperty(w7,"__esModule",{value:!0});w7.Clearance=void 0;var _re=(at(),He(st)),_7=bt(),n3=vre(),WAt=bre(),_w=class{policyId="";classList=new n3.ClassList(n3.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};w7.Clearance=_w;_re.__decorate([(0,_7.AsnProp)({type:_7.AsnPropTypes.ObjectIdentifier})],_w.prototype,"policyId",void 0);_re.__decorate([(0,_7.AsnProp)({type:n3.ClassList,defaultValue:new n3.ClassList(n3.ClassListFlags.unclassified)})],_w.prototype,"classList",void 0);_re.__decorate([(0,_7.AsnProp)({type:WAt.SecurityCategory,repeated:"set"})],_w.prototype,"securityCategories",void 0)});var G5e=L(ww=>{"use strict";Object.defineProperty(ww,"__esModule",{value:!0});ww.IetfAttrSyntax=ww.IetfAttrSyntaxValueChoices=void 0;var s3=(at(),He(st)),tg=bt(),HAt=hi(),vy=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};ww.IetfAttrSyntaxValueChoices=vy;s3.__decorate([(0,tg.AsnProp)({type:tg.OctetString})],vy.prototype,"cotets",void 0);s3.__decorate([(0,tg.AsnProp)({type:tg.AsnPropTypes.ObjectIdentifier})],vy.prototype,"oid",void 0);s3.__decorate([(0,tg.AsnProp)({type:tg.AsnPropTypes.Utf8String})],vy.prototype,"string",void 0);var i3=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};ww.IetfAttrSyntax=i3;s3.__decorate([(0,tg.AsnProp)({type:HAt.GeneralNames,implicit:!0,context:0,optional:!0})],i3.prototype,"policyAuthority",void 0);s3.__decorate([(0,tg.AsnProp)({type:vy,repeated:"sequence"})],i3.prototype,"values",void 0)});var K5e=L(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.id_at_clearance=pi.id_at_role=pi.id_at=pi.id_aca_encAttrs=pi.id_aca_group=pi.id_aca_chargingIdentity=pi.id_aca_accessIdentity=pi.id_aca_authenticationInfo=pi.id_aca=pi.id_ce_targetInformation=pi.id_pe_ac_proxying=pi.id_pe_aaControls=pi.id_pe_ac_auditIdentity=void 0;var a3=hi();pi.id_pe_ac_auditIdentity=`${a3.id_pe}.4`;pi.id_pe_aaControls=`${a3.id_pe}.6`;pi.id_pe_ac_proxying=`${a3.id_pe}.10`;pi.id_ce_targetInformation=`${a3.id_ce}.55`;pi.id_aca=`${a3.id_pkix}.10`;pi.id_aca_authenticationInfo=`${pi.id_aca}.1`;pi.id_aca_accessIdentity=`${pi.id_aca}.2`;pi.id_aca_chargingIdentity=`${pi.id_aca}.3`;pi.id_aca_group=`${pi.id_aca}.4`;pi.id_aca_encAttrs=`${pi.id_aca}.6`;pi.id_at="2.5.4";pi.id_at_role=`${pi.id_at}.72`;pi.id_at_clearance="2.5.1.5.55"});var Ere=L(hh=>{"use strict";var wre;Object.defineProperty(hh,"__esModule",{value:!0});hh.Targets=hh.Target=hh.TargetCert=void 0;var rg=(at(),He(st)),jf=bt(),Are=hi(),Z5e=Y4(),VAt=J4(),by=class{targetCertificate=new Z5e.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};hh.TargetCert=by;rg.__decorate([(0,jf.AsnProp)({type:Z5e.IssuerSerial})],by.prototype,"targetCertificate",void 0);rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,optional:!0})],by.prototype,"targetName",void 0);rg.__decorate([(0,jf.AsnProp)({type:VAt.ObjectDigestInfo,optional:!0})],by.prototype,"certDigestInfo",void 0);var _y=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};hh.Target=_y;rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,context:0,implicit:!0})],_y.prototype,"targetName",void 0);rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,context:1,implicit:!0})],_y.prototype,"targetGroup",void 0);rg.__decorate([(0,jf.AsnProp)({type:by,context:2,implicit:!0})],_y.prototype,"targetCert",void 0);hh.Target=_y=rg.__decorate([(0,jf.AsnType)({type:jf.AsnTypeTypes.Choice})],_y);var Sre=wre=class extends jf.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,wre.prototype)}};hh.Targets=Sre;hh.Targets=Sre=wre=rg.__decorate([(0,jf.AsnType)({type:jf.AsnTypeTypes.Sequence,itemType:_y})],Sre)});var X5e=L(o3=>{"use strict";var Tre;Object.defineProperty(o3,"__esModule",{value:!0});o3.ProxyInfo=void 0;var GAt=(at(),He(st)),Cre=bt(),KAt=Ere(),kre=Tre=class extends Cre.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Tre.prototype)}};o3.ProxyInfo=kre;o3.ProxyInfo=kre=Tre=GAt.__decorate([(0,Cre.AsnType)({type:Cre.AsnTypeTypes.Sequence,itemType:KAt.Targets})],kre)});var eIe=L(S7=>{"use strict";Object.defineProperty(S7,"__esModule",{value:!0});S7.RoleSyntax=void 0;var Y5e=(at(),He(st)),J5e=bt(),Q5e=hi(),c3=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};S7.RoleSyntax=c3;Y5e.__decorate([(0,J5e.AsnProp)({type:Q5e.GeneralNames,implicit:!0,context:0,optional:!0})],c3.prototype,"roleAuthority",void 0);Y5e.__decorate([(0,J5e.AsnProp)({type:Q5e.GeneralName,implicit:!0,context:1})],c3.prototype,"roleName",void 0)});var tIe=L(T7=>{"use strict";Object.defineProperty(T7,"__esModule",{value:!0});T7.SvceAuthInfo=void 0;var Dre=(at(),He(st)),A7=bt(),E7=hi(),Sw=class{service=new E7.GeneralName;ident=new E7.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};T7.SvceAuthInfo=Sw;Dre.__decorate([(0,A7.AsnProp)({type:E7.GeneralName})],Sw.prototype,"service",void 0);Dre.__decorate([(0,A7.AsnProp)({type:E7.GeneralName})],Sw.prototype,"ident",void 0);Dre.__decorate([(0,A7.AsnProp)({type:A7.OctetString,optional:!0})],Sw.prototype,"authInfo",void 0)});var Ire=L(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});var Pa=(at(),He(st));Pa.__exportStar(P5e(),da);Pa.__exportStar(O5e(),da);Pa.__exportStar(lre(),da);Pa.__exportStar(fre(),da);Pa.__exportStar(nre(),da);Pa.__exportStar(z5e(),da);Pa.__exportStar(gre(),da);Pa.__exportStar(vre(),da);Pa.__exportStar(V5e(),da);Pa.__exportStar(pre(),da);Pa.__exportStar(G5e(),da);Pa.__exportStar(Y4(),da);Pa.__exportStar(J4(),da);Pa.__exportStar(K5e(),da);Pa.__exportStar(X5e(),da);Pa.__exportStar(eIe(),da);Pa.__exportStar(bre(),da);Pa.__exportStar(tIe(),da);Pa.__exportStar(Ere(),da);Pa.__exportStar(cre(),da)});var C7=L(ph=>{"use strict";var Fre;Object.defineProperty(ph,"__esModule",{value:!0});ph.CertificateSet=ph.CertificateChoices=ph.OtherCertificateFormat=void 0;var Sy=(at(),He(st)),Jl=bt(),ZAt=hi(),XAt=Ire(),Aw=class{otherCertFormat="";otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};ph.OtherCertificateFormat=Aw;Sy.__decorate([(0,Jl.AsnProp)({type:Jl.AsnPropTypes.ObjectIdentifier})],Aw.prototype,"otherCertFormat",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:Jl.AsnPropTypes.Any})],Aw.prototype,"otherCert",void 0);var wy=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};ph.CertificateChoices=wy;Sy.__decorate([(0,Jl.AsnProp)({type:ZAt.Certificate})],wy.prototype,"certificate",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:XAt.AttributeCertificate,context:2,implicit:!0})],wy.prototype,"v2AttrCert",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:Aw,context:3,implicit:!0})],wy.prototype,"other",void 0);ph.CertificateChoices=wy=Sy.__decorate([(0,Jl.AsnType)({type:Jl.AsnTypeTypes.Choice})],wy);var Pre=Fre=class extends Jl.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Fre.prototype)}};ph.CertificateSet=Pre;ph.CertificateSet=Pre=Fre=Sy.__decorate([(0,Jl.AsnType)({type:Jl.AsnTypeTypes.Set,itemType:wy})],Pre)});var nIe=L(D7=>{"use strict";Object.defineProperty(D7,"__esModule",{value:!0});D7.ContentInfo=void 0;var rIe=(at(),He(st)),k7=bt(),u3=class{contentType="";content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};D7.ContentInfo=u3;rIe.__decorate([(0,k7.AsnProp)({type:k7.AsnPropTypes.ObjectIdentifier})],u3.prototype,"contentType",void 0);rIe.__decorate([(0,k7.AsnProp)({type:k7.AsnPropTypes.Any,context:0})],u3.prototype,"content",void 0)});var Rre=L(Ay=>{"use strict";Object.defineProperty(Ay,"__esModule",{value:!0});Ay.EncapsulatedContentInfo=Ay.EncapsulatedContent=void 0;var f3=(at(),He(st)),H0=bt(),Ew=class{single;any;constructor(e={}){Object.assign(this,e)}};Ay.EncapsulatedContent=Ew;f3.__decorate([(0,H0.AsnProp)({type:H0.OctetString})],Ew.prototype,"single",void 0);f3.__decorate([(0,H0.AsnProp)({type:H0.AsnPropTypes.Any})],Ew.prototype,"any",void 0);Ay.EncapsulatedContent=Ew=f3.__decorate([(0,H0.AsnType)({type:H0.AsnTypeTypes.Choice})],Ew);var l3=class{eContentType="";eContent;constructor(e={}){Object.assign(this,e)}};Ay.EncapsulatedContentInfo=l3;f3.__decorate([(0,H0.AsnProp)({type:H0.AsnPropTypes.ObjectIdentifier})],l3.prototype,"eContentType",void 0);f3.__decorate([(0,H0.AsnProp)({type:Ew,context:0,optional:!0})],l3.prototype,"eContent",void 0)});var Ore=L(Ey=>{"use strict";Object.defineProperty(Ey,"__esModule",{value:!0});Ey.EncryptedContentInfo=Ey.EncryptedContent=void 0;var kw=(at(),He(st)),qf=bt(),iIe=dh(),Tw=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};Ey.EncryptedContent=Tw;kw.__decorate([(0,qf.AsnProp)({type:qf.OctetString,context:0,implicit:!0,optional:!0})],Tw.prototype,"value",void 0);kw.__decorate([(0,qf.AsnProp)({type:qf.OctetString,converter:qf.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Tw.prototype,"constructedValue",void 0);Ey.EncryptedContent=Tw=kw.__decorate([(0,qf.AsnType)({type:qf.AsnTypeTypes.Choice})],Tw);var Cw=class{contentType="";contentEncryptionAlgorithm=new iIe.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};Ey.EncryptedContentInfo=Cw;kw.__decorate([(0,qf.AsnProp)({type:qf.AsnPropTypes.ObjectIdentifier})],Cw.prototype,"contentType",void 0);kw.__decorate([(0,qf.AsnProp)({type:iIe.ContentEncryptionAlgorithmIdentifier})],Cw.prototype,"contentEncryptionAlgorithm",void 0);kw.__decorate([(0,qf.AsnProp)({type:Tw,optional:!0})],Cw.prototype,"encryptedContent",void 0)});var Nre=L(F7=>{"use strict";Object.defineProperty(F7,"__esModule",{value:!0});F7.OtherKeyAttribute=void 0;var sIe=(at(),He(st)),I7=bt(),d3=class{keyAttrId="";keyAttr;constructor(e={}){Object.assign(this,e)}};F7.OtherKeyAttribute=d3;sIe.__decorate([(0,I7.AsnProp)({type:I7.AsnPropTypes.ObjectIdentifier})],d3.prototype,"keyAttrId",void 0);sIe.__decorate([(0,I7.AsnProp)({type:I7.AsnPropTypes.Any,optional:!0})],d3.prototype,"keyAttr",void 0)});var Mre=L(Va=>{"use strict";var Bre;Object.defineProperty(Va,"__esModule",{value:!0});Va.KeyAgreeRecipientInfo=Va.OriginatorIdentifierOrKey=Va.OriginatorPublicKey=Va.RecipientEncryptedKeys=Va.RecipientEncryptedKey=Va.KeyAgreeRecipientIdentifier=Va.RecipientKeyIdentifier=void 0;var Ra=(at(),He(st)),Mi=bt(),p3=hi(),Ure=dh(),aIe=H4(),YAt=Nre(),Ty=class{subjectKeyIdentifier=new p3.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};Va.RecipientKeyIdentifier=Ty;Ra.__decorate([(0,Mi.AsnProp)({type:p3.SubjectKeyIdentifier})],Ty.prototype,"subjectKeyIdentifier",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.GeneralizedTime,optional:!0})],Ty.prototype,"date",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:YAt.OtherKeyAttribute,optional:!0})],Ty.prototype,"other",void 0);var Cy=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Va.KeyAgreeRecipientIdentifier=Cy;Ra.__decorate([(0,Mi.AsnProp)({type:Ty,context:0,implicit:!0,optional:!0})],Cy.prototype,"rKeyId",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:aIe.IssuerAndSerialNumber,optional:!0})],Cy.prototype,"issuerAndSerialNumber",void 0);Va.KeyAgreeRecipientIdentifier=Cy=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Choice})],Cy);var Dw=class{rid=new Cy;encryptedKey=new Mi.OctetString;constructor(e={}){Object.assign(this,e)}};Va.RecipientEncryptedKey=Dw;Ra.__decorate([(0,Mi.AsnProp)({type:Cy})],Dw.prototype,"rid",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.OctetString})],Dw.prototype,"encryptedKey",void 0);var h3=Bre=class extends Mi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Bre.prototype)}};Va.RecipientEncryptedKeys=h3;Va.RecipientEncryptedKeys=h3=Bre=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Sequence,itemType:Dw})],h3);var Iw=class{algorithm=new p3.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Va.OriginatorPublicKey=Iw;Ra.__decorate([(0,Mi.AsnProp)({type:p3.AlgorithmIdentifier})],Iw.prototype,"algorithm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.BitString})],Iw.prototype,"publicKey",void 0);var ng=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Va.OriginatorIdentifierOrKey=ng;Ra.__decorate([(0,Mi.AsnProp)({type:p3.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],ng.prototype,"subjectKeyIdentifier",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Iw,context:1,implicit:!0,optional:!0})],ng.prototype,"originatorKey",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:aIe.IssuerAndSerialNumber,optional:!0})],ng.prototype,"issuerAndSerialNumber",void 0);Va.OriginatorIdentifierOrKey=ng=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Choice})],ng);var ig=class{version=Ure.CMSVersion.v3;originator=new ng;ukm;keyEncryptionAlgorithm=new Ure.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new h3;constructor(e={}){Object.assign(this,e)}};Va.KeyAgreeRecipientInfo=ig;Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.Integer})],ig.prototype,"version",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:ng,context:0})],ig.prototype,"originator",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.OctetString,context:1,optional:!0})],ig.prototype,"ukm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Ure.KeyEncryptionAlgorithmIdentifier})],ig.prototype,"keyEncryptionAlgorithm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:h3})],ig.prototype,"recipientEncryptedKeys",void 0)});var $re=L(Iy=>{"use strict";Object.defineProperty(Iy,"__esModule",{value:!0});Iy.KeyTransRecipientInfo=Iy.RecipientIdentifier=void 0;var Fy=(at(),He(st)),zf=bt(),JAt=hi(),Lre=dh(),QAt=H4(),ky=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Iy.RecipientIdentifier=ky;Fy.__decorate([(0,zf.AsnProp)({type:JAt.SubjectKeyIdentifier,context:0,implicit:!0})],ky.prototype,"subjectKeyIdentifier",void 0);Fy.__decorate([(0,zf.AsnProp)({type:QAt.IssuerAndSerialNumber})],ky.prototype,"issuerAndSerialNumber",void 0);Iy.RecipientIdentifier=ky=Fy.__decorate([(0,zf.AsnType)({type:zf.AsnTypeTypes.Choice})],ky);var Dy=class{version=Lre.CMSVersion.v0;rid=new ky;keyEncryptionAlgorithm=new Lre.KeyEncryptionAlgorithmIdentifier;encryptedKey=new zf.OctetString;constructor(e={}){Object.assign(this,e)}};Iy.KeyTransRecipientInfo=Dy;Fy.__decorate([(0,zf.AsnProp)({type:zf.AsnPropTypes.Integer})],Dy.prototype,"version",void 0);Fy.__decorate([(0,zf.AsnProp)({type:ky})],Dy.prototype,"rid",void 0);Fy.__decorate([(0,zf.AsnProp)({type:Lre.KeyEncryptionAlgorithmIdentifier})],Dy.prototype,"keyEncryptionAlgorithm",void 0);Fy.__decorate([(0,zf.AsnProp)({type:zf.OctetString})],Dy.prototype,"encryptedKey",void 0)});var qre=L(Fw=>{"use strict";Object.defineProperty(Fw,"__esModule",{value:!0});Fw.KEKRecipientInfo=Fw.KEKIdentifier=void 0;var Ry=(at(),He(st)),cl=bt(),eEt=Nre(),jre=dh(),sg=class{keyIdentifier=new cl.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};Fw.KEKIdentifier=sg;Ry.__decorate([(0,cl.AsnProp)({type:cl.OctetString})],sg.prototype,"keyIdentifier",void 0);Ry.__decorate([(0,cl.AsnProp)({type:cl.AsnPropTypes.GeneralizedTime,optional:!0})],sg.prototype,"date",void 0);Ry.__decorate([(0,cl.AsnProp)({type:eEt.OtherKeyAttribute,optional:!0})],sg.prototype,"other",void 0);var Py=class{version=jre.CMSVersion.v4;kekid=new sg;keyEncryptionAlgorithm=new jre.KeyEncryptionAlgorithmIdentifier;encryptedKey=new cl.OctetString;constructor(e={}){Object.assign(this,e)}};Fw.KEKRecipientInfo=Py;Ry.__decorate([(0,cl.AsnProp)({type:cl.AsnPropTypes.Integer})],Py.prototype,"version",void 0);Ry.__decorate([(0,cl.AsnProp)({type:sg})],Py.prototype,"kekid",void 0);Ry.__decorate([(0,cl.AsnProp)({type:jre.KeyEncryptionAlgorithmIdentifier})],Py.prototype,"keyEncryptionAlgorithm",void 0);Ry.__decorate([(0,cl.AsnProp)({type:cl.OctetString})],Py.prototype,"encryptedKey",void 0)});var zre=L(O7=>{"use strict";Object.defineProperty(O7,"__esModule",{value:!0});O7.PasswordRecipientInfo=void 0;var R7=(at(),He(st)),Oy=bt(),P7=dh(),Ny=class{version=P7.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new P7.KeyEncryptionAlgorithmIdentifier;encryptedKey=new Oy.OctetString;constructor(e={}){Object.assign(this,e)}};O7.PasswordRecipientInfo=Ny;R7.__decorate([(0,Oy.AsnProp)({type:Oy.AsnPropTypes.Integer})],Ny.prototype,"version",void 0);R7.__decorate([(0,Oy.AsnProp)({type:P7.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],Ny.prototype,"keyDerivationAlgorithm",void 0);R7.__decorate([(0,Oy.AsnProp)({type:P7.KeyEncryptionAlgorithmIdentifier})],Ny.prototype,"keyEncryptionAlgorithm",void 0);R7.__decorate([(0,Oy.AsnProp)({type:Oy.OctetString})],Ny.prototype,"encryptedKey",void 0)});var Wre=L(By=>{"use strict";Object.defineProperty(By,"__esModule",{value:!0});By.RecipientInfo=By.OtherRecipientInfo=void 0;var og=(at(),He(st)),Wf=bt(),tEt=Mre(),rEt=$re(),nEt=qre(),iEt=zre(),Pw=class{oriType="";oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};By.OtherRecipientInfo=Pw;og.__decorate([(0,Wf.AsnProp)({type:Wf.AsnPropTypes.ObjectIdentifier})],Pw.prototype,"oriType",void 0);og.__decorate([(0,Wf.AsnProp)({type:Wf.AsnPropTypes.Any})],Pw.prototype,"oriValue",void 0);var ag=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};By.RecipientInfo=ag;og.__decorate([(0,Wf.AsnProp)({type:rEt.KeyTransRecipientInfo,optional:!0})],ag.prototype,"ktri",void 0);og.__decorate([(0,Wf.AsnProp)({type:tEt.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],ag.prototype,"kari",void 0);og.__decorate([(0,Wf.AsnProp)({type:nEt.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],ag.prototype,"kekri",void 0);og.__decorate([(0,Wf.AsnProp)({type:iEt.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],ag.prototype,"pwri",void 0);og.__decorate([(0,Wf.AsnProp)({type:Pw,context:4,implicit:!0,optional:!0})],ag.prototype,"ori",void 0);By.RecipientInfo=ag=og.__decorate([(0,Wf.AsnType)({type:Wf.AsnTypeTypes.Choice})],ag)});var Kre=L(m3=>{"use strict";var Hre;Object.defineProperty(m3,"__esModule",{value:!0});m3.RecipientInfos=void 0;var sEt=(at(),He(st)),Vre=bt(),aEt=Wre(),Gre=Hre=class extends Vre.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Hre.prototype)}};m3.RecipientInfos=Gre;m3.RecipientInfos=Gre=Hre=sEt.__decorate([(0,Vre.AsnType)({type:Vre.AsnTypeTypes.Set,itemType:aEt.RecipientInfo})],Gre)});var N7=L(ho=>{"use strict";var Zre;Object.defineProperty(ho,"__esModule",{value:!0});ho.RevocationInfoChoices=ho.RevocationInfoChoice=ho.OtherRevocationInfoFormat=ho.id_ri_scvp=ho.id_ri_ocsp_response=ho.id_ri=void 0;var x3=(at(),He(st)),mh=bt(),oEt=hi();ho.id_ri=`${oEt.id_pkix}.16`;ho.id_ri_ocsp_response=`${ho.id_ri}.2`;ho.id_ri_scvp=`${ho.id_ri}.4`;var Uy=class{otherRevInfoFormat="";otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};ho.OtherRevocationInfoFormat=Uy;x3.__decorate([(0,mh.AsnProp)({type:mh.AsnPropTypes.ObjectIdentifier})],Uy.prototype,"otherRevInfoFormat",void 0);x3.__decorate([(0,mh.AsnProp)({type:mh.AsnPropTypes.Any})],Uy.prototype,"otherRevInfo",void 0);var g3=class{other=new Uy;constructor(e={}){Object.assign(this,e)}};ho.RevocationInfoChoice=g3;x3.__decorate([(0,mh.AsnProp)({type:Uy,context:1,implicit:!0})],g3.prototype,"other",void 0);ho.RevocationInfoChoice=g3=x3.__decorate([(0,mh.AsnType)({type:mh.AsnTypeTypes.Choice})],g3);var Xre=Zre=class extends mh.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Zre.prototype)}};ho.RevocationInfoChoices=Xre;ho.RevocationInfoChoices=Xre=Zre=x3.__decorate([(0,mh.AsnType)({type:mh.AsnTypeTypes.Set,itemType:g3})],Xre)});var Yre=L(B7=>{"use strict";Object.defineProperty(B7,"__esModule",{value:!0});B7.OriginatorInfo=void 0;var oIe=(at(),He(st)),cIe=bt(),cEt=C7(),uEt=N7(),y3=class{certs;crls;constructor(e={}){Object.assign(this,e)}};B7.OriginatorInfo=y3;oIe.__decorate([(0,cIe.AsnProp)({type:cEt.CertificateSet,context:0,implicit:!0,optional:!0})],y3.prototype,"certs",void 0);oIe.__decorate([(0,cIe.AsnProp)({type:uEt.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],y3.prototype,"crls",void 0)});var fIe=L(My=>{"use strict";var Jre;Object.defineProperty(My,"__esModule",{value:!0});My.EnvelopedData=My.UnprotectedAttributes=void 0;var Rw=(at(),He(st)),V0=bt(),lEt=dh(),fEt=r7(),uIe=Kre(),dEt=Yre(),lIe=Ore(),U7=Jre=class extends V0.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Jre.prototype)}};My.UnprotectedAttributes=U7;My.UnprotectedAttributes=U7=Jre=Rw.__decorate([(0,V0.AsnType)({type:V0.AsnTypeTypes.Set,itemType:fEt.Attribute})],U7);var cg=class{version=lEt.CMSVersion.v0;originatorInfo;recipientInfos=new uIe.RecipientInfos;encryptedContentInfo=new lIe.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};My.EnvelopedData=cg;Rw.__decorate([(0,V0.AsnProp)({type:V0.AsnPropTypes.Integer})],cg.prototype,"version",void 0);Rw.__decorate([(0,V0.AsnProp)({type:dEt.OriginatorInfo,context:0,implicit:!0,optional:!0})],cg.prototype,"originatorInfo",void 0);Rw.__decorate([(0,V0.AsnProp)({type:uIe.RecipientInfos})],cg.prototype,"recipientInfos",void 0);Rw.__decorate([(0,V0.AsnProp)({type:lIe.EncryptedContentInfo})],cg.prototype,"encryptedContentInfo",void 0);Rw.__decorate([(0,V0.AsnProp)({type:U7,context:1,implicit:!0,optional:!0})],cg.prototype,"unprotectedAttrs",void 0)});var dIe=L(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.id_authData=gc.id_encryptedData=gc.id_digestedData=gc.id_envelopedData=gc.id_signedData=gc.id_data=gc.id_ct_contentInfo=void 0;gc.id_ct_contentInfo="1.2.840.113549.1.9.16.1.6";gc.id_data="1.2.840.113549.1.7.1";gc.id_signedData="1.2.840.113549.1.7.2";gc.id_envelopedData="1.2.840.113549.1.7.3";gc.id_digestedData="1.2.840.113549.1.7.5";gc.id_encryptedData="1.2.840.113549.1.7.6";gc.id_authData="1.2.840.113549.1.9.16.1.2"});var gIe=L(Ly=>{"use strict";var Qre;Object.defineProperty(Ly,"__esModule",{value:!0});Ly.SignedData=Ly.DigestAlgorithmIdentifiers=void 0;var $y=(at(),He(st)),gh=bt(),hEt=C7(),hIe=dh(),pIe=Rre(),pEt=N7(),mIe=n7(),v3=Qre=class extends gh.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Qre.prototype)}};Ly.DigestAlgorithmIdentifiers=v3;Ly.DigestAlgorithmIdentifiers=v3=Qre=$y.__decorate([(0,gh.AsnType)({type:gh.AsnTypeTypes.Set,itemType:hIe.DigestAlgorithmIdentifier})],v3);var G0=class{version=hIe.CMSVersion.v0;digestAlgorithms=new v3;encapContentInfo=new pIe.EncapsulatedContentInfo;certificates;crls;signerInfos=new mIe.SignerInfos;constructor(e={}){Object.assign(this,e)}};Ly.SignedData=G0;$y.__decorate([(0,gh.AsnProp)({type:gh.AsnPropTypes.Integer})],G0.prototype,"version",void 0);$y.__decorate([(0,gh.AsnProp)({type:v3})],G0.prototype,"digestAlgorithms",void 0);$y.__decorate([(0,gh.AsnProp)({type:pIe.EncapsulatedContentInfo})],G0.prototype,"encapContentInfo",void 0);$y.__decorate([(0,gh.AsnProp)({type:hEt.CertificateSet,context:0,implicit:!0,optional:!0})],G0.prototype,"certificates",void 0);$y.__decorate([(0,gh.AsnProp)({type:pEt.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],G0.prototype,"crls",void 0);$y.__decorate([(0,gh.AsnProp)({type:mIe.SignerInfos})],G0.prototype,"signerInfos",void 0)});var b3=L(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var va=(at(),He(st));va.__exportStar(F5e(),ea);va.__exportStar(r7(),ea);va.__exportStar(C7(),ea);va.__exportStar(nIe(),ea);va.__exportStar(Rre(),ea);va.__exportStar(Ore(),ea);va.__exportStar(fIe(),ea);va.__exportStar(H4(),ea);va.__exportStar(qre(),ea);va.__exportStar(Mre(),ea);va.__exportStar($re(),ea);va.__exportStar(dIe(),ea);va.__exportStar(Yre(),ea);va.__exportStar(zre(),ea);va.__exportStar(Wre(),ea);va.__exportStar(Kre(),ea);va.__exportStar(N7(),ea);va.__exportStar(gIe(),ea);va.__exportStar($te(),ea);va.__exportStar(n7(),ea);va.__exportStar(dh(),ea)});var ene=L(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.id_sect571r1=ln.id_sect571k1=ln.id_secp521r1=ln.id_sect409r1=ln.id_sect409k1=ln.id_secp384r1=ln.id_sect283r1=ln.id_sect283k1=ln.id_secp256r1=ln.id_sect233r1=ln.id_sect233k1=ln.id_secp224r1=ln.id_sect163r2=ln.id_sect163k1=ln.id_secp192r1=ln.id_ecdsaWithSHA512=ln.id_ecdsaWithSHA384=ln.id_ecdsaWithSHA256=ln.id_ecdsaWithSHA224=ln.id_ecdsaWithSHA1=ln.id_ecMQV=ln.id_ecDH=ln.id_ecPublicKey=void 0;ln.id_ecPublicKey="1.2.840.10045.2.1";ln.id_ecDH="1.3.132.1.12";ln.id_ecMQV="1.3.132.1.13";ln.id_ecdsaWithSHA1="1.2.840.10045.4.1";ln.id_ecdsaWithSHA224="1.2.840.10045.4.3.1";ln.id_ecdsaWithSHA256="1.2.840.10045.4.3.2";ln.id_ecdsaWithSHA384="1.2.840.10045.4.3.3";ln.id_ecdsaWithSHA512="1.2.840.10045.4.3.4";ln.id_secp192r1="1.2.840.10045.3.1.1";ln.id_sect163k1="1.3.132.0.1";ln.id_sect163r2="1.3.132.0.15";ln.id_secp224r1="1.3.132.0.33";ln.id_sect233k1="1.3.132.0.26";ln.id_sect233r1="1.3.132.0.27";ln.id_secp256r1="1.2.840.10045.3.1.7";ln.id_sect283k1="1.3.132.0.16";ln.id_sect283r1="1.3.132.0.17";ln.id_secp384r1="1.3.132.0.34";ln.id_sect409k1="1.3.132.0.36";ln.id_sect409r1="1.3.132.0.37";ln.id_secp521r1="1.3.132.0.35";ln.id_sect571k1="1.3.132.0.38";ln.id_sect571r1="1.3.132.0.39"});var xIe=L(Ql=>{"use strict";Object.defineProperty(Ql,"__esModule",{value:!0});Ql.ecdsaWithSHA512=Ql.ecdsaWithSHA384=Ql.ecdsaWithSHA256=Ql.ecdsaWithSHA224=Ql.ecdsaWithSHA1=void 0;var mEt=(at(),He(st)),gEt=hi(),_3=mEt.__importStar(ene());function w3(t){return new gEt.AlgorithmIdentifier({algorithm:t})}Ql.ecdsaWithSHA1=w3(_3.id_ecdsaWithSHA1);Ql.ecdsaWithSHA224=w3(_3.id_ecdsaWithSHA224);Ql.ecdsaWithSHA256=w3(_3.id_ecdsaWithSHA256);Ql.ecdsaWithSHA384=w3(_3.id_ecdsaWithSHA384);Ql.ecdsaWithSHA512=w3(_3.id_ecdsaWithSHA512)});var nne=L(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.SpecifiedECDomain=Bo.ECPVer=Bo.Curve=Bo.FieldElement=Bo.ECPoint=Bo.FieldID=void 0;var Au=(at(),He(st)),ts=bt(),Ow=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};Bo.FieldID=Ow;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.ObjectIdentifier})],Ow.prototype,"fieldType",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Any})],Ow.prototype,"parameters",void 0);Bo.FieldID=Ow=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],Ow);var M7=class extends ts.OctetString{};Bo.ECPoint=M7;var tne=class extends ts.OctetString{};Bo.FieldElement=tne;var jy=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};Bo.Curve=jy;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.OctetString})],jy.prototype,"a",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.OctetString})],jy.prototype,"b",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.BitString,optional:!0})],jy.prototype,"seed",void 0);Bo.Curve=jy=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],jy);var rne;(function(t){t[t.ecpVer1=1]="ecpVer1"})(rne||(Bo.ECPVer=rne={}));var K0=class{version=rne.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};Bo.SpecifiedECDomain=K0;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer})],K0.prototype,"version",void 0);Au.__decorate([(0,ts.AsnProp)({type:Ow})],K0.prototype,"fieldID",void 0);Au.__decorate([(0,ts.AsnProp)({type:jy})],K0.prototype,"curve",void 0);Au.__decorate([(0,ts.AsnProp)({type:M7})],K0.prototype,"base",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer,converter:ts.AsnIntegerArrayBufferConverter})],K0.prototype,"order",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer,optional:!0})],K0.prototype,"cofactor",void 0);Bo.SpecifiedECDomain=K0=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],K0)});var ine=L(S3=>{"use strict";Object.defineProperty(S3,"__esModule",{value:!0});S3.ECParameters=void 0;var L7=(at(),He(st)),qy=bt(),xEt=nne(),Nw=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};S3.ECParameters=Nw;L7.__decorate([(0,qy.AsnProp)({type:qy.AsnPropTypes.ObjectIdentifier})],Nw.prototype,"namedCurve",void 0);L7.__decorate([(0,qy.AsnProp)({type:qy.AsnPropTypes.Null})],Nw.prototype,"implicitCurve",void 0);L7.__decorate([(0,qy.AsnProp)({type:xEt.SpecifiedECDomain})],Nw.prototype,"specifiedCurve",void 0);S3.ECParameters=Nw=L7.__decorate([(0,qy.AsnType)({type:qy.AsnTypeTypes.Choice})],Nw)});var yIe=L(j7=>{"use strict";Object.defineProperty(j7,"__esModule",{value:!0});j7.ECPrivateKey=void 0;var $7=(at(),He(st)),ug=bt(),yEt=ine(),zy=class{version=1;privateKey=new ug.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};j7.ECPrivateKey=zy;$7.__decorate([(0,ug.AsnProp)({type:ug.AsnPropTypes.Integer})],zy.prototype,"version",void 0);$7.__decorate([(0,ug.AsnProp)({type:ug.OctetString})],zy.prototype,"privateKey",void 0);$7.__decorate([(0,ug.AsnProp)({type:yEt.ECParameters,context:0,optional:!0})],zy.prototype,"parameters",void 0);$7.__decorate([(0,ug.AsnProp)({type:ug.AsnPropTypes.BitString,context:1,optional:!0})],zy.prototype,"publicKey",void 0)});var bIe=L(q7=>{"use strict";Object.defineProperty(q7,"__esModule",{value:!0});q7.ECDSASigValue=void 0;var vIe=(at(),He(st)),Bw=bt(),A3=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};q7.ECDSASigValue=A3;vIe.__decorate([(0,Bw.AsnProp)({type:Bw.AsnPropTypes.Integer,converter:Bw.AsnIntegerArrayBufferConverter})],A3.prototype,"r",void 0);vIe.__decorate([(0,Bw.AsnProp)({type:Bw.AsnPropTypes.Integer,converter:Bw.AsnIntegerArrayBufferConverter})],A3.prototype,"s",void 0)});var _Ie=L(lg=>{"use strict";Object.defineProperty(lg,"__esModule",{value:!0});var Uw=(at(),He(st));Uw.__exportStar(xIe(),lg);Uw.__exportStar(ine(),lg);Uw.__exportStar(yIe(),lg);Uw.__exportStar(bIe(),lg);Uw.__exportStar(ene(),lg);Uw.__exportStar(nne(),lg)});var E3=L(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.id_mgf1=Sr.id_md5=Sr.id_md2=Sr.id_sha512_256=Sr.id_sha512_224=Sr.id_sha512=Sr.id_sha384=Sr.id_sha256=Sr.id_sha224=Sr.id_sha1=Sr.id_sha512_256WithRSAEncryption=Sr.id_sha512_224WithRSAEncryption=Sr.id_sha512WithRSAEncryption=Sr.id_sha384WithRSAEncryption=Sr.id_sha256WithRSAEncryption=Sr.id_ssha224WithRSAEncryption=Sr.id_sha224WithRSAEncryption=Sr.id_sha1WithRSAEncryption=Sr.id_md5WithRSAEncryption=Sr.id_md2WithRSAEncryption=Sr.id_RSASSA_PSS=Sr.id_pSpecified=Sr.id_RSAES_OAEP=Sr.id_rsaEncryption=Sr.id_pkcs_1=void 0;Sr.id_pkcs_1="1.2.840.113549.1.1";Sr.id_rsaEncryption=`${Sr.id_pkcs_1}.1`;Sr.id_RSAES_OAEP=`${Sr.id_pkcs_1}.7`;Sr.id_pSpecified=`${Sr.id_pkcs_1}.9`;Sr.id_RSASSA_PSS=`${Sr.id_pkcs_1}.10`;Sr.id_md2WithRSAEncryption=`${Sr.id_pkcs_1}.2`;Sr.id_md5WithRSAEncryption=`${Sr.id_pkcs_1}.4`;Sr.id_sha1WithRSAEncryption=`${Sr.id_pkcs_1}.5`;Sr.id_sha224WithRSAEncryption=`${Sr.id_pkcs_1}.14`;Sr.id_ssha224WithRSAEncryption=Sr.id_sha224WithRSAEncryption;Sr.id_sha256WithRSAEncryption=`${Sr.id_pkcs_1}.11`;Sr.id_sha384WithRSAEncryption=`${Sr.id_pkcs_1}.12`;Sr.id_sha512WithRSAEncryption=`${Sr.id_pkcs_1}.13`;Sr.id_sha512_224WithRSAEncryption=`${Sr.id_pkcs_1}.15`;Sr.id_sha512_256WithRSAEncryption=`${Sr.id_pkcs_1}.16`;Sr.id_sha1="1.3.14.3.2.26";Sr.id_sha224="2.16.840.1.101.3.4.2.4";Sr.id_sha256="2.16.840.1.101.3.4.2.1";Sr.id_sha384="2.16.840.1.101.3.4.2.2";Sr.id_sha512="2.16.840.1.101.3.4.2.3";Sr.id_sha512_224="2.16.840.1.101.3.4.2.5";Sr.id_sha512_256="2.16.840.1.101.3.4.2.6";Sr.id_md2="1.2.840.113549.2.2";Sr.id_md5="1.2.840.113549.2.5";Sr.id_mgf1=`${Sr.id_pkcs_1}.8`});var z7=L(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.sha512_256WithRSAEncryption=xn.sha512_224WithRSAEncryption=xn.sha512WithRSAEncryption=xn.sha384WithRSAEncryption=xn.sha256WithRSAEncryption=xn.sha224WithRSAEncryption=xn.sha1WithRSAEncryption=xn.md5WithRSAEncryption=xn.md2WithRSAEncryption=xn.rsaEncryption=xn.pSpecifiedEmpty=xn.mgf1SHA1=xn.sha512_256=xn.sha512_224=xn.sha512=xn.sha384=xn.sha256=xn.sha224=xn.sha1=xn.md4=xn.md2=void 0;var vEt=(at(),He(st)),sne=bt(),ane=hi(),ba=vEt.__importStar(E3());function Ga(t){return new ane.AlgorithmIdentifier({algorithm:t,parameters:null})}xn.md2=Ga(ba.id_md2);xn.md4=Ga(ba.id_md5);xn.sha1=Ga(ba.id_sha1);xn.sha224=Ga(ba.id_sha224);xn.sha256=Ga(ba.id_sha256);xn.sha384=Ga(ba.id_sha384);xn.sha512=Ga(ba.id_sha512);xn.sha512_224=Ga(ba.id_sha512_224);xn.sha512_256=Ga(ba.id_sha512_256);xn.mgf1SHA1=new ane.AlgorithmIdentifier({algorithm:ba.id_mgf1,parameters:sne.AsnConvert.serialize(xn.sha1)});xn.pSpecifiedEmpty=new ane.AlgorithmIdentifier({algorithm:ba.id_pSpecified,parameters:sne.AsnConvert.serialize(sne.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});xn.rsaEncryption=Ga(ba.id_rsaEncryption);xn.md2WithRSAEncryption=Ga(ba.id_md2WithRSAEncryption);xn.md5WithRSAEncryption=Ga(ba.id_md5WithRSAEncryption);xn.sha1WithRSAEncryption=Ga(ba.id_sha1WithRSAEncryption);xn.sha224WithRSAEncryption=Ga(ba.id_sha512_224WithRSAEncryption);xn.sha256WithRSAEncryption=Ga(ba.id_sha512_256WithRSAEncryption);xn.sha384WithRSAEncryption=Ga(ba.id_sha384WithRSAEncryption);xn.sha512WithRSAEncryption=Ga(ba.id_sha512WithRSAEncryption);xn.sha512_224WithRSAEncryption=Ga(ba.id_sha512_224WithRSAEncryption);xn.sha512_256WithRSAEncryption=Ga(ba.id_sha512_256WithRSAEncryption)});var SIe=L(Lw=>{"use strict";Object.defineProperty(Lw,"__esModule",{value:!0});Lw.RSAES_OAEP=Lw.RsaEsOaepParams=void 0;var one=(at(),He(st)),T3=bt(),Wy=hi(),wIe=E3(),Mw=z7(),Hy=class{hashAlgorithm=new Wy.AlgorithmIdentifier(Mw.sha1);maskGenAlgorithm=new Wy.AlgorithmIdentifier({algorithm:wIe.id_mgf1,parameters:T3.AsnConvert.serialize(Mw.sha1)});pSourceAlgorithm=new Wy.AlgorithmIdentifier(Mw.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};Lw.RsaEsOaepParams=Hy;one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:0,defaultValue:Mw.sha1})],Hy.prototype,"hashAlgorithm",void 0);one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:1,defaultValue:Mw.mgf1SHA1})],Hy.prototype,"maskGenAlgorithm",void 0);one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:2,defaultValue:Mw.pSpecifiedEmpty})],Hy.prototype,"pSourceAlgorithm",void 0);Lw.RSAES_OAEP=new Wy.AlgorithmIdentifier({algorithm:wIe.id_RSAES_OAEP,parameters:T3.AsnConvert.serialize(new Hy)})});var EIe=L($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});$w.RSASSA_PSS=$w.RsaSaPssParams=void 0;var H7=(at(),He(st)),fg=bt(),C3=hi(),AIe=E3(),W7=z7(),dg=class{hashAlgorithm=new C3.AlgorithmIdentifier(W7.sha1);maskGenAlgorithm=new C3.AlgorithmIdentifier({algorithm:AIe.id_mgf1,parameters:fg.AsnConvert.serialize(W7.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};$w.RsaSaPssParams=dg;H7.__decorate([(0,fg.AsnProp)({type:C3.AlgorithmIdentifier,context:0,defaultValue:W7.sha1})],dg.prototype,"hashAlgorithm",void 0);H7.__decorate([(0,fg.AsnProp)({type:C3.AlgorithmIdentifier,context:1,defaultValue:W7.mgf1SHA1})],dg.prototype,"maskGenAlgorithm",void 0);H7.__decorate([(0,fg.AsnProp)({type:fg.AsnPropTypes.Integer,context:2,defaultValue:20})],dg.prototype,"saltLength",void 0);H7.__decorate([(0,fg.AsnProp)({type:fg.AsnPropTypes.Integer,context:3,defaultValue:1})],dg.prototype,"trailerField",void 0);$w.RSASSA_PSS=new C3.AlgorithmIdentifier({algorithm:AIe.id_RSASSA_PSS,parameters:fg.AsnConvert.serialize(new dg)})});var kIe=L(G7=>{"use strict";Object.defineProperty(G7,"__esModule",{value:!0});G7.DigestInfo=void 0;var TIe=(at(),He(st)),CIe=hi(),V7=bt(),k3=class{digestAlgorithm=new CIe.AlgorithmIdentifier;digest=new V7.OctetString;constructor(e={}){Object.assign(this,e)}};G7.DigestInfo=k3;TIe.__decorate([(0,V7.AsnProp)({type:CIe.AlgorithmIdentifier})],k3.prototype,"digestAlgorithm",void 0);TIe.__decorate([(0,V7.AsnProp)({type:V7.OctetString})],k3.prototype,"digest",void 0)});var DIe=L(D3=>{"use strict";Object.defineProperty(D3,"__esModule",{value:!0});var cne=(at(),He(st));cne.__exportStar(SIe(),D3);cne.__exportStar(EIe(),D3);cne.__exportStar(kIe(),D3)});var fne=L(Gy=>{"use strict";var une;Object.defineProperty(Gy,"__esModule",{value:!0});Gy.OtherPrimeInfos=Gy.OtherPrimeInfo=void 0;var K7=(at(),He(st)),ef=bt(),Vy=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Gy.OtherPrimeInfo=Vy;K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"prime",void 0);K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"exponent",void 0);K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"coefficient",void 0);var lne=une=class extends ef.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,une.prototype)}};Gy.OtherPrimeInfos=lne;Gy.OtherPrimeInfos=lne=une=K7.__decorate([(0,ef.AsnType)({type:ef.AsnTypeTypes.Sequence,itemType:Vy})],lne)});var IIe=L(Z7=>{"use strict";Object.defineProperty(Z7,"__esModule",{value:!0});Z7.RSAPrivateKey=void 0;var xh=(at(),He(st)),cs=bt(),bEt=fne(),ul=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};Z7.RSAPrivateKey=ul;xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer})],ul.prototype,"version",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"modulus",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"publicExponent",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"privateExponent",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"prime1",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"prime2",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"exponent1",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"exponent2",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"coefficient",void 0);xh.__decorate([(0,cs.AsnProp)({type:bEt.OtherPrimeInfos,optional:!0})],ul.prototype,"otherPrimeInfos",void 0)});var PIe=L(X7=>{"use strict";Object.defineProperty(X7,"__esModule",{value:!0});X7.RSAPublicKey=void 0;var FIe=(at(),He(st)),jw=bt(),I3=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};X7.RSAPublicKey=I3;FIe.__decorate([(0,jw.AsnProp)({type:jw.AsnPropTypes.Integer,converter:jw.AsnIntegerArrayBufferConverter})],I3.prototype,"modulus",void 0);FIe.__decorate([(0,jw.AsnProp)({type:jw.AsnPropTypes.Integer,converter:jw.AsnIntegerArrayBufferConverter})],I3.prototype,"publicExponent",void 0)});var dne=L(hg=>{"use strict";Object.defineProperty(hg,"__esModule",{value:!0});var qw=(at(),He(st));qw.__exportStar(DIe(),hg);qw.__exportStar(z7(),hg);qw.__exportStar(E3(),hg);qw.__exportStar(fne(),hg);qw.__exportStar(IIe(),hg);qw.__exportStar(PIe(),hg)});var Y7={};yi(Y7,{__assign:()=>pne,__asyncDelegator:()=>REt,__asyncGenerator:()=>PEt,__asyncValues:()=>OEt,__await:()=>F3,__awaiter:()=>TEt,__classPrivateFieldGet:()=>MEt,__classPrivateFieldSet:()=>LEt,__createBinding:()=>kEt,__decorate:()=>SEt,__exportStar:()=>DEt,__extends:()=>_Et,__generator:()=>CEt,__importDefault:()=>UEt,__importStar:()=>BEt,__makeTemplateObject:()=>NEt,__metadata:()=>EEt,__param:()=>AEt,__read:()=>RIe,__rest:()=>wEt,__spread:()=>IEt,__spreadArrays:()=>FEt,__values:()=>mne});function _Et(t,e){hne(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function wEt(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function SEt(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function AEt(t,e){return function(r,n){e(r,n,t)}}function EEt(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function TEt(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function c(p){try{h(n.next(p))}catch(x){a(x)}}function d(p){try{h(n.throw(p))}catch(x){a(x)}}function h(p){p.done?s(p.value):i(p.value).then(c,d)}h((n=n.apply(t,e||[])).next())})}function CEt(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(h){return function(p){return d([h,p])}}function d(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(p){h=[6,p],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function kEt(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function DEt(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function mne(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function RIe(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function IEt(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(RIe(arguments[e]));return t}function FEt(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)n[i]=s[a];return n}function F3(t){return this instanceof F3?(this.v=t,this):new F3(t)}function PEt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(y){n[y]&&(i[y]=function(v){return new Promise(function(w,S){s.push([y,v,w,S])>1||c(y,v)})})}function c(y,v){try{d(n[y](v))}catch(w){x(s[0][3],w)}}function d(y){y.value instanceof F3?Promise.resolve(y.value.v).then(h,p):x(s[0][2],y)}function h(y){c("next",y)}function p(y){c("throw",y)}function x(y,v){y(v),s.shift(),s.length&&c(s[0][0],s[0][1])}}function REt(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(a){return(r=!r)?{value:F3(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function OEt(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof mne=="function"?mne(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(a){return new Promise(function(c,d){a=t[s](a),i(c,d,a.done,a.value)})}}function i(s,a,c,d){Promise.resolve(d).then(function(h){s({value:h,done:c})},a)}}function NEt(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function BEt(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function UEt(t){return t&&t.__esModule?t:{default:t}}function MEt(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function LEt(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var hne,pne,J7=ce(()=>{hne=function(t,e){return hne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},hne(t,e)};pne=function(){return pne=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},pne.apply(this,arguments)}});var yne=L(xne=>{"use strict";Object.defineProperty(xne,"__esModule",{value:!0});var gne;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(gne||(gne={}));xne.default=gne});var OIe=L(vne=>{"use strict";Object.defineProperty(vne,"__esModule",{value:!0});var $Et=yne();Object.defineProperty(vne,"Lifecycle",{enumerable:!0,get:function(){return $Et.default}})});var Ky=L(Hf=>{"use strict";Object.defineProperty(Hf,"__esModule",{value:!0});Hf.defineInjectionTokenMetadata=Hf.getParamInfo=Hf.INJECTION_TOKEN_METADATA_KEY=void 0;Hf.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function jEt(t){let e=Reflect.getMetadata("design:paramtypes",t)||[],r=Reflect.getOwnMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(n=>{e[+n]=r[n]}),e}Hf.getParamInfo=jEt;function qEt(t,e){return function(r,n,i){let s=Reflect.getOwnMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,r)||{};s[i]=e?{token:t,transform:e.transformToken,transformArgs:e.args||[]}:t,Reflect.defineMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,s,r)}}Hf.defineInjectionTokenMetadata=qEt});var bne=L(Q7=>{"use strict";Object.defineProperty(Q7,"__esModule",{value:!0});Q7.isClassProvider=void 0;function zEt(t){return!!t.useClass}Q7.isClassProvider=zEt});var _ne=L(eB=>{"use strict";Object.defineProperty(eB,"__esModule",{value:!0});eB.isFactoryProvider=void 0;function WEt(t){return!!t.useFactory}eB.isFactoryProvider=WEt});var rB=L(zw=>{"use strict";Object.defineProperty(zw,"__esModule",{value:!0});zw.delay=zw.DelayedConstructor=void 0;var tB=class{constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let r={},n=!1,i,s=()=>(n||(i=e(this.wrap()),n=!0),i);return new Proxy(r,this.createHandler(s))}createHandler(e){let r={},n=i=>{r[i]=(...s)=>{s[0]=e();let a=Reflect[i];return a(...s)}};return this.reflectMethods.forEach(n),r}};zw.DelayedConstructor=tB;function HEt(t){if(typeof t>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new tB(t)}zw.delay=HEt});var nB=L(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});yh.isConstructorToken=yh.isTransformDescriptor=yh.isTokenDescriptor=yh.isNormalToken=void 0;var VEt=rB();function GEt(t){return typeof t=="string"||typeof t=="symbol"}yh.isNormalToken=GEt;function KEt(t){return typeof t=="object"&&"token"in t&&"multiple"in t}yh.isTokenDescriptor=KEt;function ZEt(t){return typeof t=="object"&&"token"in t&&"transform"in t}yh.isTransformDescriptor=ZEt;function XEt(t){return typeof t=="function"||t instanceof VEt.DelayedConstructor}yh.isConstructorToken=XEt});var wne=L(iB=>{"use strict";Object.defineProperty(iB,"__esModule",{value:!0});iB.isTokenProvider=void 0;function YEt(t){return!!t.useToken}iB.isTokenProvider=YEt});var Sne=L(sB=>{"use strict";Object.defineProperty(sB,"__esModule",{value:!0});sB.isValueProvider=void 0;function JEt(t){return t.useValue!=null}sB.isValueProvider=JEt});var Ane=L(Zy=>{"use strict";Object.defineProperty(Zy,"__esModule",{value:!0});var QEt=bne();Object.defineProperty(Zy,"isClassProvider",{enumerable:!0,get:function(){return QEt.isClassProvider}});var eTt=_ne();Object.defineProperty(Zy,"isFactoryProvider",{enumerable:!0,get:function(){return eTt.isFactoryProvider}});var tTt=nB();Object.defineProperty(Zy,"isNormalToken",{enumerable:!0,get:function(){return tTt.isNormalToken}});var rTt=wne();Object.defineProperty(Zy,"isTokenProvider",{enumerable:!0,get:function(){return rTt.isTokenProvider}});var nTt=Sne();Object.defineProperty(Zy,"isValueProvider",{enumerable:!0,get:function(){return nTt.isValueProvider}})});var NIe=L(aB=>{"use strict";Object.defineProperty(aB,"__esModule",{value:!0});aB.isProvider=void 0;var iTt=bne(),sTt=Sne(),aTt=wne(),oTt=_ne();function cTt(t){return iTt.isClassProvider(t)||sTt.isValueProvider(t)||aTt.isTokenProvider(t)||oTt.isFactoryProvider(t)}aB.isProvider=cTt});var Cne=L(Tne=>{"use strict";Object.defineProperty(Tne,"__esModule",{value:!0});var Ene=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let r=this._registryMap.get(e);return r[r.length-1]||null}set(e,r){this.ensure(e),this._registryMap.get(e).push(r)}setAll(e,r){this._registryMap.set(e,r)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}};Tne.default=Ene});var BIe=L(Dne=>{"use strict";Object.defineProperty(Dne,"__esModule",{value:!0});var uTt=Cne(),kne=class extends uTt.default{};Dne.default=kne});var UIe=L(Fne=>{"use strict";Object.defineProperty(Fne,"__esModule",{value:!0});var Ine=class{constructor(){this.scopedResolutions=new Map}};Fne.default=Ine});var Pne=L(oB=>{"use strict";Object.defineProperty(oB,"__esModule",{value:!0});oB.formatErrorCtor=void 0;function lTt(t,e){return t===null?`at position #${e}`:`"${t.split(",")[e].trim()}" at position #${e}`}function fTt(t,e,r=" "){return[t,...e.message.split(`
1011
+ `}function V6e(t){return t.replace(/[^0-9a-f]/gi,"")}function TSt(t){let e=t.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g)??[];if(e.length<3)return;let r=e.filter((a,c)=>c%2===0),n=e.filter((a,c)=>c%2===1),i=n[0];if(!i||n.some(a=>a!==i)||r.some(a=>a.length===0||a.length%2!==0))return;let s=r[0]?.length??0;if(s&&!r.slice(0,-1).some(a=>a.length!==s)&&!((r[r.length-1]?.length??0)>s))return{size:s/2,separator:i}}function CSt(t){let e=t.trim(),r=/^0x/i.test(e)?"0x":"",n=r?e.slice(2):e,i=ESt(n),s=n.split(/\r\n|\n/).filter(h=>h.length>0),a=s[0]?.trim()??"",c=TSt(a),d={case:ASt(e),prefix:r};if(c&&(d.group=c),i&&s.length>1){let h=V6e(s[0]??"").length/2;h>0&&s.slice(0,-1).every(p=>V6e(p).length/2===h)&&(d.line={bytesPerLine:h,separator:i})}return d}function kSt(t,e){let r=e.allowPrefix??!0,n=[..._St(e)].sort((c,d)=>d.length-c.length);for(let c of n)wSt(c);let i=t.trim();if(/^0x/i.test(i)){if(!r)throw new TypeError("Hexadecimal text must not include a 0x prefix");i=i.slice(2)}let s="",a=!1;for(let c=0;c<i.length;){let d=i[c]??"";if(vSt.test(d)){s+=d,a=!1,c+=1;continue}let h=SSt(i,c,n);if(!h)throw new TypeError("Input is not valid hexadecimal text");if(e.strict&&(a||s.length===0))throw new TypeError("Hexadecimal text contains misplaced separators");a=!0,c+=h.length}if(e.strict&&a&&s.length>0)throw new TypeError("Hexadecimal text must not end with a separator");if(s.length%2!==0){if(!e.allowOddLength)throw new TypeError("Hexadecimal text must contain an even number of characters");s=`0${s}`}return s.toLowerCase()}function G6e(t,e){if(!e)return t.join("");if(!Number.isInteger(e.size)||e.size<1)throw new RangeError("Hex group size must be a positive integer");let r=[];for(let n=0;n<t.length;n+=e.size)r.push(t.slice(n,n+e.size).join(""));return r.join(e.separator)}function S4(t,e={}){return kSt(t,e)}function K6e(t,e={}){if(typeof t!="string")return!1;try{return S4(t,e),!0}catch{return!1}}function Pee(t,e={}){let r=(0,ySt.toUint8Array)(t),n=e.case??"lower",i=Array.from(r,a=>{let c=a.toString(16).padStart(2,"0");return n==="upper"?c.toUpperCase():c}),s="";if(e.line){let a=e.line.bytesPerLine;if(!Number.isInteger(a)||a<1)throw new RangeError("Hex bytesPerLine must be a positive integer");let c=e.line.separator??`
1012
+ `,d=[];for(let h=0;h<i.length;h+=a)d.push(G6e(i.slice(h,h+a),e.group));s=d.join(c)}else s=G6e(i,e.group);return`${e.prefix??""}${s}`}function Ree(t,e={}){let r=S4(t,e),n=new Uint8Array(r.length/2);for(let i=0;i<r.length;i+=2)n[i/2]=Number.parseInt(r.slice(i,i+2),16);return n}function Z6e(t,e={}){let r=S4(t,e);return{bytes:Ree(r),format:CSt(t),normalized:r}}function X6e(t,e){return Pee(t,e)}rl.formats={compact:Object.freeze({}),upper:Object.freeze({case:"upper"}),colon:Object.freeze({group:{size:1,separator:":"}}),colonUpper:Object.freeze({case:"upper",group:{size:1,separator:":"}}),groupsOf4:Object.freeze({group:{size:4,separator:" "}}),prefixed:Object.freeze({prefix:"0x"})};rl.hex={encode:Pee,decode:Ree,format:X6e,formats:rl.formats,is:K6e,normalize:S4,parse:Z6e}});var e8e=L(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});P_.utf8=void 0;P_.encode=J6e;P_.decode=Q6e;var DSt=el();function J6e(t){return new TextEncoder().encode(t)}function Q6e(t){return new TextDecoder("utf-8",{fatal:!1}).decode((0,DSt.toUint8Array)(t))}P_.utf8={encode:J6e,decode:Q6e}});var n8e=L(R_=>{"use strict";Object.defineProperty(R_,"__esModule",{value:!0});R_.utf16=void 0;R_.encode=t8e;R_.decode=r8e;var ISt=el();function t8e(t,e={}){let r=new ArrayBuffer(t.length*2),n=new DataView(r);for(let i=0;i<t.length;i++)n.setUint16(i*2,t.charCodeAt(i),e.littleEndian??!1);return new Uint8Array(r)}function r8e(t,e={}){let r=(0,ISt.toArrayBuffer)(t),n=new DataView(r),i="";for(let s=0;s<r.byteLength;s+=2)i+=String.fromCharCode(n.getUint16(s,e.littleEndian??!1));return i}R_.utf16={encode:t8e,decode:r8e}});var Nee=L(L0=>{"use strict";Object.defineProperty(L0,"__esModule",{value:!0});L0.base64=void 0;L0.normalize=mN;L0.pad=a8e;L0.is=Oee;L0.encode=o8e;L0.decode=c8e;var FSt=el(),i8e=Fee(),PSt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function s8e(){return globalThis.Buffer}function mN(t){return t.replace(/[\n\r\t ]/g,"")}function a8e(t){let e=t.length%4;return e?t+"=".repeat(4-e):t}function Oee(t){if(typeof t!="string")return!1;let e=mN(t);return e===""||PSt.test(e)}function o8e(t,e){let r=(0,FSt.toUint8Array)(t),n=s8e();return n?n.from(r).toString("base64"):btoa((0,i8e.encode)(r))}function c8e(t,e){let r=mN(t);if(!Oee(r))throw new TypeError("Input is not valid Base64 text");let n=s8e();return n?new Uint8Array(n.from(r,"base64")):(0,i8e.decode)(atob(r))}L0.base64={encode:o8e,decode:c8e,is:Oee,normalize:mN,pad:a8e}});var f8e=L(Xm=>{"use strict";Object.defineProperty(Xm,"__esModule",{value:!0});Xm.base64url=void 0;Xm.normalize=gN;Xm.is=Uee;Xm.encode=u8e;Xm.decode=l8e;var Bee=Nee(),RSt=/^[A-Za-z0-9_-]*$/;function gN(t){return t.replace(/[\n\r\t ]/g,"")}function Uee(t){return typeof t=="string"&&RSt.test(gN(t))}function u8e(t,e){return Bee.base64.encode(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function l8e(t,e){let r=gN(t);if(!Uee(r))throw new TypeError("Input is not valid Base64Url text");return Bee.base64.decode(Bee.base64.pad(r.replace(/-/g,"+").replace(/_/g,"/")))}Xm.base64url={encode:u8e,decode:l8e,is:Uee,normalize:gN}});var Mee=L(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.base64url=_u.base64=_u.utf16=_u.utf8=_u.hex=_u.binary=void 0;var O_=(at(),He(st));_u.binary=O_.__importStar(Fee());_u.hex=O_.__importStar(Y6e());_u.utf8=O_.__importStar(e8e());_u.utf16=O_.__importStar(n8e());_u.base64=O_.__importStar(Nee());_u.base64url=O_.__importStar(f8e())});var d8e=L(xN=>{"use strict";Object.defineProperty(xN,"__esModule",{value:!0});xN.IpConverter=void 0;var OSt=Mee(),Lee=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let r=e.split(".");if(r.length!==4)throw new Error("Invalid IPv4 address");return r.map(n=>{let i=parseInt(n,10);if(isNaN(i)||i<0||i>255)throw new Error("Invalid IPv4 address part");return i})}static parseIPv6(e){let n=this.expandIPv6(e).split(":");if(n.length!==8)throw new Error("Invalid IPv6 address");return n.reduce((i,s)=>{let a=parseInt(s,16);if(isNaN(a)||a<0||a>65535)throw new Error("Invalid IPv6 address part");return i.push(a>>8&255),i.push(a&255),i},[])}static expandIPv6(e){if(!e.includes("::"))return e;let r=e.split("::");if(r.length>2)throw new Error("Invalid IPv6 address");let n=r[0]?r[0].split(":"):[],i=r[1]?r[1].split(":"):[],s=8-(n.length+i.length);if(s<0)throw new Error("Invalid IPv6 address");return[...n,...Array(s).fill("0"),...i].join(":")}static formatIPv6(e){let r=[];for(let n=0;n<16;n+=2)r.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(r.join(":"))}static compressIPv6(e){let r=e.split(":"),n=-1,i=0,s=-1,a=0;for(let c=0;c<r.length;c++)r[c]==="0"?(s===-1&&(s=c),a++):(a>i&&(n=s,i=a),s=-1,a=0);if(a>i&&(n=s,i=a),i>1){let c=r.slice(0,n).join(":"),d=r.slice(n+i).join(":");return`${c}::${d}`}return e}static parseCIDR(e){let[r,n]=e.split("/"),i=parseInt(n,10);if(this.isIPv4(r)){if(i<0||i>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(r),i]}else{if(i<0||i>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(r),i]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;let r=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0),n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${r}`}static toString(e){let r=new Uint8Array(e);if(r.length===4)return Array.from(r).join(".");if(r.length===16)return this.formatIPv6(r);if(r.length===8||r.length===32){let n=r.length/2,i=r.slice(0,n),s=r.slice(n);if(r.every(d=>d===0))return r.length===8?"0.0.0.0/0":"::/0";let c=s.reduce((d,h)=>d+(h.toString(2).match(/1/g)||[]).length,0);return r.length===8?`${Array.from(i).join(".")}/${c}`:`${this.formatIPv6(i)}/${c}`}return this.decodeIP(OSt.hex.encode(e))}static fromString(e){if(e.includes("/")){let[n,i]=this.parseCIDR(e),s=new Uint8Array(n.length),a=i;for(let d=0;d<s.length;d++)a>=8?(s[d]=255,a-=8):a>0&&(s[d]=255<<8-a,a=0);let c=new Uint8Array(n.length*2);return c.set(n,0),c.set(s,n.length),c.buffer}let r=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(r).buffer}};xN.IpConverter=Lee});var B_=L(Ha=>{"use strict";var $ee,jee,qee;Object.defineProperty(Ha,"__esModule",{value:!0});Ha.Name=Ha.RDNSequence=Ha.RelativeDistinguishedName=Ha.AttributeTypeAndValue=Ha.AttributeValue=Ha.DirectoryString=void 0;var wu=(at(),He(st)),Vi=bt(),NSt=Mee(),$0=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};Ha.DirectoryString=$0;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.TeletexString})],$0.prototype,"teletexString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.PrintableString})],$0.prototype,"printableString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.UniversalString})],$0.prototype,"universalString",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.Utf8String})],$0.prototype,"utf8String",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.BmpString})],$0.prototype,"bmpString",void 0);Ha.DirectoryString=$0=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Choice})],$0);var Vx=class extends $0{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?NSt.hex.encode(this.anyValue):super.toString())}};Ha.AttributeValue=Vx;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.IA5String})],Vx.prototype,"ia5String",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.Any})],Vx.prototype,"anyValue",void 0);Ha.AttributeValue=Vx=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Choice})],Vx);var N_=class{type="";value=new Vx;constructor(e={}){Object.assign(this,e)}};Ha.AttributeTypeAndValue=N_;wu.__decorate([(0,Vi.AsnProp)({type:Vi.AsnPropTypes.ObjectIdentifier})],N_.prototype,"type",void 0);wu.__decorate([(0,Vi.AsnProp)({type:Vx})],N_.prototype,"value",void 0);var yN=$ee=class extends Vi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,$ee.prototype)}};Ha.RelativeDistinguishedName=yN;Ha.RelativeDistinguishedName=yN=$ee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Set,itemType:N_})],yN);var vN=jee=class extends Vi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,jee.prototype)}};Ha.RDNSequence=vN;Ha.RDNSequence=vN=jee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Sequence,itemType:yN})],vN);var zee=qee=class extends vN{constructor(e){super(e),Object.setPrototypeOf(this,qee.prototype)}};Ha.Name=zee;Ha.Name=zee=qee=wu.__decorate([(0,Vi.AsnType)({type:Vi.AsnTypeTypes.Sequence})],zee)});var Gx=L(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.GeneralName=Kl.EDIPartyName=Kl.OtherName=Kl.AsnIpConverter=void 0;var Su=(at(),He(st)),Is=bt(),h8e=d8e(),bN=B_();Kl.AsnIpConverter={fromASN:t=>h8e.IpConverter.toString(Is.AsnOctetStringConverter.fromASN(t)),toASN:t=>Is.AsnOctetStringConverter.toASN(h8e.IpConverter.fromString(t))};var U_=class{typeId="";value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Kl.OtherName=U_;Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.ObjectIdentifier})],U_.prototype,"typeId",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.Any,context:0})],U_.prototype,"value",void 0);var M_=class{nameAssigner;partyName=new bN.DirectoryString;constructor(e={}){Object.assign(this,e)}};Kl.EDIPartyName=M_;Su.__decorate([(0,Is.AsnProp)({type:bN.DirectoryString,optional:!0,context:0,implicit:!0})],M_.prototype,"nameAssigner",void 0);Su.__decorate([(0,Is.AsnProp)({type:bN.DirectoryString,context:1,implicit:!0})],M_.prototype,"partyName",void 0);var Zl=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};Kl.GeneralName=Zl;Su.__decorate([(0,Is.AsnProp)({type:U_,context:0,implicit:!0})],Zl.prototype,"otherName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:1,implicit:!0})],Zl.prototype,"rfc822Name",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:2,implicit:!0})],Zl.prototype,"dNSName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.Any,context:3,implicit:!0})],Zl.prototype,"x400Address",void 0);Su.__decorate([(0,Is.AsnProp)({type:bN.Name,context:4,implicit:!1})],Zl.prototype,"directoryName",void 0);Su.__decorate([(0,Is.AsnProp)({type:M_,context:5})],Zl.prototype,"ediPartyName",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.IA5String,context:6,implicit:!0})],Zl.prototype,"uniformResourceIdentifier",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.OctetString,context:7,implicit:!0,converter:Kl.AsnIpConverter})],Zl.prototype,"iPAddress",void 0);Su.__decorate([(0,Is.AsnProp)({type:Is.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],Zl.prototype,"registeredID",void 0);Kl.GeneralName=Zl=Su.__decorate([(0,Is.AsnType)({type:Is.AsnTypeTypes.Choice})],Zl)});var vs=L(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.id_ce=Qn.id_ad_caRepository=Qn.id_ad_timeStamping=Qn.id_ad_caIssuers=Qn.id_ad_ocsp=Qn.id_qt_unotice=Qn.id_qt_csp=Qn.id_ad=Qn.id_kp=Qn.id_qt=Qn.id_pe=Qn.id_pkix=void 0;Qn.id_pkix="1.3.6.1.5.5.7";Qn.id_pe=`${Qn.id_pkix}.1`;Qn.id_qt=`${Qn.id_pkix}.2`;Qn.id_kp=`${Qn.id_pkix}.3`;Qn.id_ad=`${Qn.id_pkix}.48`;Qn.id_qt_csp=`${Qn.id_qt}.1`;Qn.id_qt_unotice=`${Qn.id_qt}.2`;Qn.id_ad_ocsp=`${Qn.id_ad}.1`;Qn.id_ad_caIssuers=`${Qn.id_ad}.2`;Qn.id_ad_timeStamping=`${Qn.id_ad}.3`;Qn.id_ad_caRepository=`${Qn.id_ad}.5`;Qn.id_ce="2.5.29"});var Gee=L(j0=>{"use strict";var Wee;Object.defineProperty(j0,"__esModule",{value:!0});j0.AuthorityInfoAccessSyntax=j0.AccessDescription=j0.id_pe_authorityInfoAccess=void 0;var Vee=(at(),He(st)),L_=bt(),p8e=Gx(),BSt=vs();j0.id_pe_authorityInfoAccess=`${BSt.id_pe}.1`;var $_=class{accessMethod="";accessLocation=new p8e.GeneralName;constructor(e={}){Object.assign(this,e)}};j0.AccessDescription=$_;Vee.__decorate([(0,L_.AsnProp)({type:L_.AsnPropTypes.ObjectIdentifier})],$_.prototype,"accessMethod",void 0);Vee.__decorate([(0,L_.AsnProp)({type:p8e.GeneralName})],$_.prototype,"accessLocation",void 0);var Hee=Wee=class extends L_.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Wee.prototype)}};j0.AuthorityInfoAccessSyntax=Hee;j0.AuthorityInfoAccessSyntax=Hee=Wee=Vee.__decorate([(0,L_.AsnType)({type:L_.AsnTypeTypes.Sequence,itemType:$_})],Hee)});var Zee=L(Ym=>{"use strict";Object.defineProperty(Ym,"__esModule",{value:!0});Ym.AuthorityKeyIdentifier=Ym.KeyIdentifier=Ym.id_ce_authorityKeyIdentifier=void 0;var Kee=(at(),He(st)),j_=bt(),USt=Gx(),MSt=vs();Ym.id_ce_authorityKeyIdentifier=`${MSt.id_ce}.35`;var _N=class extends j_.OctetString{};Ym.KeyIdentifier=_N;var q_=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};Ym.AuthorityKeyIdentifier=q_;Kee.__decorate([(0,j_.AsnProp)({type:_N,context:0,optional:!0,implicit:!0})],q_.prototype,"keyIdentifier",void 0);Kee.__decorate([(0,j_.AsnProp)({type:USt.GeneralName,context:1,optional:!0,implicit:!0,repeated:"sequence"})],q_.prototype,"authorityCertIssuer",void 0);Kee.__decorate([(0,j_.AsnProp)({type:j_.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:j_.AsnIntegerArrayBufferConverter})],q_.prototype,"authorityCertSerialNumber",void 0)});var g8e=L(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});z_.BasicConstraints=z_.id_ce_basicConstraints=void 0;var m8e=(at(),He(st)),wN=bt(),LSt=vs();z_.id_ce_basicConstraints=`${LSt.id_ce}.19`;var A4=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};z_.BasicConstraints=A4;m8e.__decorate([(0,wN.AsnProp)({type:wN.AsnPropTypes.Boolean,defaultValue:!1})],A4.prototype,"cA",void 0);m8e.__decorate([(0,wN.AsnProp)({type:wN.AsnPropTypes.Integer,optional:!0})],A4.prototype,"pathLenConstraint",void 0)});var T4=L(E4=>{"use strict";var Xee;Object.defineProperty(E4,"__esModule",{value:!0});E4.GeneralNames=void 0;var $St=(at(),He(st)),Yee=bt(),jSt=Gx(),Jee=Xee=class extends Yee.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Xee.prototype)}};E4.GeneralNames=Jee;E4.GeneralNames=Jee=Xee=$St.__decorate([(0,Yee.AsnType)({type:Yee.AsnTypeTypes.Sequence,itemType:jSt.GeneralName})],Jee)});var y8e=L(Kx=>{"use strict";var Qee;Object.defineProperty(Kx,"__esModule",{value:!0});Kx.CertificateIssuer=Kx.id_ce_certificateIssuer=void 0;var qSt=(at(),He(st)),x8e=bt(),zSt=T4(),WSt=vs();Kx.id_ce_certificateIssuer=`${WSt.id_ce}.29`;var ete=Qee=class extends zSt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,Qee.prototype)}};Kx.CertificateIssuer=ete;Kx.CertificateIssuer=ete=Qee=qSt.__decorate([(0,x8e.AsnType)({type:x8e.AsnTypeTypes.Sequence})],ete)});var v8e=L(Ws=>{"use strict";var tte;Object.defineProperty(Ws,"__esModule",{value:!0});Ws.CertificatePolicies=Ws.PolicyInformation=Ws.PolicyQualifierInfo=Ws.Qualifier=Ws.UserNotice=Ws.NoticeReference=Ws.DisplayText=Ws.id_ce_certificatePolicies_anyPolicy=Ws.id_ce_certificatePolicies=void 0;var No=(at(),He(st)),Ui=bt(),HSt=vs();Ws.id_ce_certificatePolicies=`${HSt.id_ce}.32`;Ws.id_ce_certificatePolicies_anyPolicy=`${Ws.id_ce_certificatePolicies}.0`;var ih=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};Ws.DisplayText=ih;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.IA5String})],ih.prototype,"ia5String",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.VisibleString})],ih.prototype,"visibleString",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.BmpString})],ih.prototype,"bmpString",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Utf8String})],ih.prototype,"utf8String",void 0);Ws.DisplayText=ih=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Choice})],ih);var W_=class{organization=new ih;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};Ws.NoticeReference=W_;No.__decorate([(0,Ui.AsnProp)({type:ih})],W_.prototype,"organization",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Integer,repeated:"sequence"})],W_.prototype,"noticeNumbers",void 0);var H_=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};Ws.UserNotice=H_;No.__decorate([(0,Ui.AsnProp)({type:W_,optional:!0})],H_.prototype,"noticeRef",void 0);No.__decorate([(0,Ui.AsnProp)({type:ih,optional:!0})],H_.prototype,"explicitText",void 0);var C4=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};Ws.Qualifier=C4;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.IA5String})],C4.prototype,"cPSuri",void 0);No.__decorate([(0,Ui.AsnProp)({type:H_})],C4.prototype,"userNotice",void 0);Ws.Qualifier=C4=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Choice})],C4);var V_=class{policyQualifierId="";qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Ws.PolicyQualifierInfo=V_;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.ObjectIdentifier})],V_.prototype,"policyQualifierId",void 0);No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.Any})],V_.prototype,"qualifier",void 0);var G_=class{policyIdentifier="";policyQualifiers;constructor(e={}){Object.assign(this,e)}};Ws.PolicyInformation=G_;No.__decorate([(0,Ui.AsnProp)({type:Ui.AsnPropTypes.ObjectIdentifier})],G_.prototype,"policyIdentifier",void 0);No.__decorate([(0,Ui.AsnProp)({type:V_,repeated:"sequence",optional:!0})],G_.prototype,"policyQualifiers",void 0);var rte=tte=class extends Ui.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,tte.prototype)}};Ws.CertificatePolicies=rte;Ws.CertificatePolicies=rte=tte=No.__decorate([(0,Ui.AsnType)({type:Ui.AsnTypeTypes.Sequence,itemType:G_})],rte)});var nte=L(Zx=>{"use strict";Object.defineProperty(Zx,"__esModule",{value:!0});Zx.CRLNumber=Zx.id_ce_cRLNumber=void 0;var b8e=(at(),He(st)),SN=bt(),VSt=vs();Zx.id_ce_cRLNumber=`${VSt.id_ce}.20`;var AN=class{value;constructor(e=0){this.value=e}};Zx.CRLNumber=AN;b8e.__decorate([(0,SN.AsnProp)({type:SN.AsnPropTypes.Integer})],AN.prototype,"value",void 0);Zx.CRLNumber=AN=b8e.__decorate([(0,SN.AsnType)({type:SN.AsnTypeTypes.Choice})],AN)});var w8e=L(Xx=>{"use strict";Object.defineProperty(Xx,"__esModule",{value:!0});Xx.BaseCRLNumber=Xx.id_ce_deltaCRLIndicator=void 0;var GSt=(at(),He(st)),_8e=bt(),KSt=vs(),ZSt=nte();Xx.id_ce_deltaCRLIndicator=`${KSt.id_ce}.27`;var ite=class extends ZSt.CRLNumber{};Xx.BaseCRLNumber=ite;Xx.BaseCRLNumber=ite=GSt.__decorate([(0,_8e.AsnType)({type:_8e.AsnTypeTypes.Choice})],ite)});var TN=L(pc=>{"use strict";var ste;Object.defineProperty(pc,"__esModule",{value:!0});pc.CRLDistributionPoints=pc.DistributionPoint=pc.DistributionPointName=pc.Reason=pc.ReasonFlags=pc.id_ce_cRLDistributionPoints=void 0;var Jx=(at(),He(st)),Uf=bt(),XSt=B_(),S8e=Gx(),YSt=vs();pc.id_ce_cRLDistributionPoints=`${YSt.id_ce}.31`;var Bf;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(Bf||(pc.ReasonFlags=Bf={}));var EN=class extends Uf.BitString{toJSON(){let e=[],r=this.toNumber();return r&Bf.aACompromise&&e.push("aACompromise"),r&Bf.affiliationChanged&&e.push("affiliationChanged"),r&Bf.cACompromise&&e.push("cACompromise"),r&Bf.certificateHold&&e.push("certificateHold"),r&Bf.cessationOfOperation&&e.push("cessationOfOperation"),r&Bf.keyCompromise&&e.push("keyCompromise"),r&Bf.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Bf.superseded&&e.push("superseded"),r&Bf.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}};pc.Reason=EN;var K_=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};pc.DistributionPointName=K_;Jx.__decorate([(0,Uf.AsnProp)({type:S8e.GeneralName,context:0,repeated:"sequence",implicit:!0})],K_.prototype,"fullName",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:XSt.RelativeDistinguishedName,context:1,implicit:!0})],K_.prototype,"nameRelativeToCRLIssuer",void 0);pc.DistributionPointName=K_=Jx.__decorate([(0,Uf.AsnType)({type:Uf.AsnTypeTypes.Choice})],K_);var Yx=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};pc.DistributionPoint=Yx;Jx.__decorate([(0,Uf.AsnProp)({type:K_,context:0,optional:!0})],Yx.prototype,"distributionPoint",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:EN,context:1,optional:!0,implicit:!0})],Yx.prototype,"reasons",void 0);Jx.__decorate([(0,Uf.AsnProp)({type:S8e.GeneralName,context:2,optional:!0,repeated:"sequence",implicit:!0})],Yx.prototype,"cRLIssuer",void 0);var ate=ste=class extends Uf.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,ste.prototype)}};pc.CRLDistributionPoints=ate;pc.CRLDistributionPoints=ate=ste=Jx.__decorate([(0,Uf.AsnType)({type:Uf.AsnTypeTypes.Sequence,itemType:Yx})],ate)});var T8e=L(Qx=>{"use strict";var ote;Object.defineProperty(Qx,"__esModule",{value:!0});Qx.FreshestCRL=Qx.id_ce_freshestCRL=void 0;var JSt=(at(),He(st)),A8e=bt(),QSt=vs(),E8e=TN();Qx.id_ce_freshestCRL=`${QSt.id_ce}.46`;var cte=ote=class extends E8e.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,ote.prototype)}};Qx.FreshestCRL=cte;Qx.FreshestCRL=cte=ote=JSt.__decorate([(0,A8e.AsnType)({type:A8e.AsnTypeTypes.Sequence,itemType:E8e.DistributionPoint})],cte)});var k8e=L(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});Z_.IssuingDistributionPoint=Z_.id_ce_issuingDistributionPoint=void 0;var X_=(at(),He(st)),sh=bt(),eAt=vs(),C8e=TN();Z_.id_ce_issuingDistributionPoint=`${eAt.id_ce}.28`;var nl=class t{static ONLY=!1;distributionPoint;onlyContainsUserCerts=t.ONLY;onlyContainsCACerts=t.ONLY;onlySomeReasons;indirectCRL=t.ONLY;onlyContainsAttributeCerts=t.ONLY;constructor(e={}){Object.assign(this,e)}};Z_.IssuingDistributionPoint=nl;X_.__decorate([(0,sh.AsnProp)({type:C8e.DistributionPointName,context:0,optional:!0})],nl.prototype,"distributionPoint",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:1,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsUserCerts",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:2,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsCACerts",void 0);X_.__decorate([(0,sh.AsnProp)({type:C8e.Reason,context:3,optional:!0,implicit:!0})],nl.prototype,"onlySomeReasons",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:4,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"indirectCRL",void 0);X_.__decorate([(0,sh.AsnProp)({type:sh.AsnPropTypes.Boolean,context:5,defaultValue:nl.ONLY,implicit:!0})],nl.prototype,"onlyContainsAttributeCerts",void 0)});var I8e=L(q0=>{"use strict";Object.defineProperty(q0,"__esModule",{value:!0});q0.CRLReason=q0.CRLReasons=q0.id_ce_cRLReasons=void 0;var D8e=(at(),He(st)),CN=bt(),tAt=vs();q0.id_ce_cRLReasons=`${tAt.id_ce}.21`;var k4;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(k4||(q0.CRLReasons=k4={}));var kN=class{reason=k4.unspecified;constructor(e=k4.unspecified){this.reason=e}toJSON(){return k4[this.reason]}toString(){return this.toJSON()}};q0.CRLReason=kN;D8e.__decorate([(0,CN.AsnProp)({type:CN.AsnPropTypes.Enumerated})],kN.prototype,"reason",void 0);q0.CRLReason=kN=D8e.__decorate([(0,CN.AsnType)({type:CN.AsnTypeTypes.Choice})],kN)});var F8e=L(la=>{"use strict";var ute;Object.defineProperty(la,"__esModule",{value:!0});la.id_kp_OCSPSigning=la.id_kp_timeStamping=la.id_kp_emailProtection=la.id_kp_codeSigning=la.id_kp_clientAuth=la.id_kp_serverAuth=la.anyExtendedKeyUsage=la.ExtendedKeyUsage=la.id_ce_extKeyUsage=void 0;var rAt=(at(),He(st)),DN=bt(),ey=vs();la.id_ce_extKeyUsage=`${ey.id_ce}.37`;var lte=ute=class extends DN.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,ute.prototype)}};la.ExtendedKeyUsage=lte;la.ExtendedKeyUsage=lte=ute=rAt.__decorate([(0,DN.AsnType)({type:DN.AsnTypeTypes.Sequence,itemType:DN.AsnPropTypes.ObjectIdentifier})],lte);la.anyExtendedKeyUsage=`${la.id_ce_extKeyUsage}.0`;la.id_kp_serverAuth=`${ey.id_kp}.1`;la.id_kp_clientAuth=`${ey.id_kp}.2`;la.id_kp_codeSigning=`${ey.id_kp}.3`;la.id_kp_emailProtection=`${ey.id_kp}.4`;la.id_kp_timeStamping=`${ey.id_kp}.8`;la.id_kp_OCSPSigning=`${ey.id_kp}.9`});var R8e=L(ty=>{"use strict";Object.defineProperty(ty,"__esModule",{value:!0});ty.InhibitAnyPolicy=ty.id_ce_inhibitAnyPolicy=void 0;var P8e=(at(),He(st)),D4=bt(),nAt=vs();ty.id_ce_inhibitAnyPolicy=`${nAt.id_ce}.54`;var IN=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};ty.InhibitAnyPolicy=IN;P8e.__decorate([(0,D4.AsnProp)({type:D4.AsnPropTypes.Integer,converter:D4.AsnIntegerArrayBufferConverter})],IN.prototype,"value",void 0);ty.InhibitAnyPolicy=IN=P8e.__decorate([(0,D4.AsnType)({type:D4.AsnTypeTypes.Choice})],IN)});var N8e=L(ry=>{"use strict";Object.defineProperty(ry,"__esModule",{value:!0});ry.InvalidityDate=ry.id_ce_invalidityDate=void 0;var O8e=(at(),He(st)),FN=bt(),iAt=vs();ry.id_ce_invalidityDate=`${iAt.id_ce}.24`;var PN=class{value=new Date;constructor(e){e&&(this.value=e)}};ry.InvalidityDate=PN;O8e.__decorate([(0,FN.AsnProp)({type:FN.AsnPropTypes.GeneralizedTime})],PN.prototype,"value",void 0);ry.InvalidityDate=PN=O8e.__decorate([(0,FN.AsnType)({type:FN.AsnTypeTypes.Choice})],PN)});var U8e=L(ny=>{"use strict";var fte;Object.defineProperty(ny,"__esModule",{value:!0});ny.IssueAlternativeName=ny.id_ce_issuerAltName=void 0;var sAt=(at(),He(st)),B8e=bt(),aAt=T4(),oAt=vs();ny.id_ce_issuerAltName=`${oAt.id_ce}.18`;var dte=fte=class extends aAt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,fte.prototype)}};ny.IssueAlternativeName=dte;ny.IssueAlternativeName=dte=fte=sAt.__decorate([(0,B8e.AsnType)({type:B8e.AsnTypeTypes.Sequence})],dte)});var M8e=L(Jm=>{"use strict";Object.defineProperty(Jm,"__esModule",{value:!0});Jm.KeyUsage=Jm.KeyUsageFlags=Jm.id_ce_keyUsage=void 0;var cAt=bt(),uAt=vs();Jm.id_ce_keyUsage=`${uAt.id_ce}.15`;var Mf;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Mf||(Jm.KeyUsageFlags=Mf={}));var hte=class extends cAt.BitString{toJSON(){let e=this.toNumber(),r=[];return e&Mf.cRLSign&&r.push("crlSign"),e&Mf.dataEncipherment&&r.push("dataEncipherment"),e&Mf.decipherOnly&&r.push("decipherOnly"),e&Mf.digitalSignature&&r.push("digitalSignature"),e&Mf.encipherOnly&&r.push("encipherOnly"),e&Mf.keyAgreement&&r.push("keyAgreement"),e&Mf.keyCertSign&&r.push("keyCertSign"),e&Mf.keyEncipherment&&r.push("keyEncipherment"),e&Mf.nonRepudiation&&r.push("nonRepudiation"),r}toString(){return`[${this.toJSON().join(", ")}]`}};Jm.KeyUsage=hte});var $8e=L(Lf=>{"use strict";var pte;Object.defineProperty(Lf,"__esModule",{value:!0});Lf.NameConstraints=Lf.GeneralSubtrees=Lf.GeneralSubtree=Lf.id_ce_nameConstraints=void 0;var Y_=(at(),He(st)),ah=bt(),L8e=Gx(),lAt=vs();Lf.id_ce_nameConstraints=`${lAt.id_ce}.30`;var iy=class{base=new L8e.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};Lf.GeneralSubtree=iy;Y_.__decorate([(0,ah.AsnProp)({type:L8e.GeneralName})],iy.prototype,"base",void 0);Y_.__decorate([(0,ah.AsnProp)({type:ah.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],iy.prototype,"minimum",void 0);Y_.__decorate([(0,ah.AsnProp)({type:ah.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],iy.prototype,"maximum",void 0);var I4=pte=class extends ah.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,pte.prototype)}};Lf.GeneralSubtrees=I4;Lf.GeneralSubtrees=I4=pte=Y_.__decorate([(0,ah.AsnType)({type:ah.AsnTypeTypes.Sequence,itemType:iy})],I4);var F4=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};Lf.NameConstraints=F4;Y_.__decorate([(0,ah.AsnProp)({type:I4,context:0,optional:!0,implicit:!0})],F4.prototype,"permittedSubtrees",void 0);Y_.__decorate([(0,ah.AsnProp)({type:I4,context:1,optional:!0,implicit:!0})],F4.prototype,"excludedSubtrees",void 0)});var q8e=L(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});Q_.PolicyConstraints=Q_.id_ce_policyConstraints=void 0;var j8e=(at(),He(st)),J_=bt(),fAt=vs();Q_.id_ce_policyConstraints=`${fAt.id_ce}.36`;var P4=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};Q_.PolicyConstraints=P4;j8e.__decorate([(0,J_.AsnProp)({type:J_.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:J_.AsnIntegerArrayBufferConverter})],P4.prototype,"requireExplicitPolicy",void 0);j8e.__decorate([(0,J_.AsnProp)({type:J_.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:J_.AsnIntegerArrayBufferConverter})],P4.prototype,"inhibitPolicyMapping",void 0)});var z8e=L(z0=>{"use strict";var mte;Object.defineProperty(z0,"__esModule",{value:!0});z0.PolicyMappings=z0.PolicyMapping=z0.id_ce_policyMappings=void 0;var xte=(at(),He(st)),sy=bt(),dAt=vs();z0.id_ce_policyMappings=`${dAt.id_ce}.33`;var ew=class{issuerDomainPolicy="";subjectDomainPolicy="";constructor(e={}){Object.assign(this,e)}};z0.PolicyMapping=ew;xte.__decorate([(0,sy.AsnProp)({type:sy.AsnPropTypes.ObjectIdentifier})],ew.prototype,"issuerDomainPolicy",void 0);xte.__decorate([(0,sy.AsnProp)({type:sy.AsnPropTypes.ObjectIdentifier})],ew.prototype,"subjectDomainPolicy",void 0);var gte=mte=class extends sy.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,mte.prototype)}};z0.PolicyMappings=gte;z0.PolicyMappings=gte=mte=xte.__decorate([(0,sy.AsnType)({type:sy.AsnTypeTypes.Sequence,itemType:ew})],gte)});var H8e=L(ay=>{"use strict";var yte;Object.defineProperty(ay,"__esModule",{value:!0});ay.SubjectAlternativeName=ay.id_ce_subjectAltName=void 0;var hAt=(at(),He(st)),W8e=bt(),pAt=T4(),mAt=vs();ay.id_ce_subjectAltName=`${mAt.id_ce}.17`;var vte=yte=class extends pAt.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,yte.prototype)}};ay.SubjectAlternativeName=vte;ay.SubjectAlternativeName=vte=yte=hAt.__decorate([(0,W8e.AsnType)({type:W8e.AsnTypeTypes.Sequence})],vte)});var bte=L(ON=>{"use strict";Object.defineProperty(ON,"__esModule",{value:!0});ON.Attribute=void 0;var V8e=(at(),He(st)),RN=bt(),R4=class{type="";values=[];constructor(e={}){Object.assign(this,e)}};ON.Attribute=R4;V8e.__decorate([(0,RN.AsnProp)({type:RN.AsnPropTypes.ObjectIdentifier})],R4.prototype,"type",void 0);V8e.__decorate([(0,RN.AsnProp)({type:RN.AsnPropTypes.Any,repeated:"set"})],R4.prototype,"values",void 0)});var G8e=L(oy=>{"use strict";var _te;Object.defineProperty(oy,"__esModule",{value:!0});oy.SubjectDirectoryAttributes=oy.id_ce_subjectDirectoryAttributes=void 0;var gAt=(at(),He(st)),wte=bt(),xAt=bte(),yAt=vs();oy.id_ce_subjectDirectoryAttributes=`${yAt.id_ce}.9`;var Ste=_te=class extends wte.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,_te.prototype)}};oy.SubjectDirectoryAttributes=Ste;oy.SubjectDirectoryAttributes=Ste=_te=gAt.__decorate([(0,wte.AsnType)({type:wte.AsnTypeTypes.Sequence,itemType:xAt.Attribute})],Ste)});var K8e=L(tw=>{"use strict";Object.defineProperty(tw,"__esModule",{value:!0});tw.SubjectKeyIdentifier=tw.id_ce_subjectKeyIdentifier=void 0;var vAt=vs(),bAt=Zee();tw.id_ce_subjectKeyIdentifier=`${vAt.id_ce}.14`;var Ate=class extends bAt.KeyIdentifier{};tw.SubjectKeyIdentifier=Ate});var X8e=L(rw=>{"use strict";Object.defineProperty(rw,"__esModule",{value:!0});rw.PrivateKeyUsagePeriod=rw.id_ce_privateKeyUsagePeriod=void 0;var Z8e=(at(),He(st)),NN=bt(),_At=vs();rw.id_ce_privateKeyUsagePeriod=`${_At.id_ce}.16`;var O4=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};rw.PrivateKeyUsagePeriod=O4;Z8e.__decorate([(0,NN.AsnProp)({type:NN.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],O4.prototype,"notBefore",void 0);Z8e.__decorate([(0,NN.AsnProp)({type:NN.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],O4.prototype,"notAfter",void 0)});var J8e=L(oh=>{"use strict";Object.defineProperty(oh,"__esModule",{value:!0});oh.EntrustVersionInfo=oh.EntrustInfo=oh.EntrustInfoFlags=oh.id_entrust_entrustVersInfo=void 0;var Y8e=(at(),He(st)),BN=bt();oh.id_entrust_entrustVersInfo="1.2.840.113533.7.65.0";var N4;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(N4||(oh.EntrustInfoFlags=N4={}));var B4=class extends BN.BitString{toJSON(){let e=[],r=this.toNumber();return r&N4.pKIXCertificate&&e.push("pKIXCertificate"),r&N4.newExtensions&&e.push("newExtensions"),r&N4.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}};oh.EntrustInfo=B4;var U4=class{entrustVers="";entrustInfoFlags=new B4;constructor(e={}){Object.assign(this,e)}};oh.EntrustVersionInfo=U4;Y8e.__decorate([(0,BN.AsnProp)({type:BN.AsnPropTypes.GeneralString})],U4.prototype,"entrustVers",void 0);Y8e.__decorate([(0,BN.AsnProp)({type:B4})],U4.prototype,"entrustInfoFlags",void 0)});var Q8e=L(cy=>{"use strict";var Ete;Object.defineProperty(cy,"__esModule",{value:!0});cy.SubjectInfoAccessSyntax=cy.id_pe_subjectInfoAccess=void 0;var wAt=(at(),He(st)),Tte=bt(),SAt=vs(),AAt=Gee();cy.id_pe_subjectInfoAccess=`${SAt.id_pe}.11`;var Cte=Ete=class extends Tte.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Ete.prototype)}};cy.SubjectInfoAccessSyntax=Cte;cy.SubjectInfoAccessSyntax=Cte=Ete=wAt.__decorate([(0,Tte.AsnType)({type:Tte.AsnTypeTypes.Sequence,itemType:AAt.AccessDescription})],Cte)});var e5e=L(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});var Fs=(at(),He(st));Fs.__exportStar(Gee(),os);Fs.__exportStar(Zee(),os);Fs.__exportStar(g8e(),os);Fs.__exportStar(y8e(),os);Fs.__exportStar(v8e(),os);Fs.__exportStar(w8e(),os);Fs.__exportStar(TN(),os);Fs.__exportStar(T8e(),os);Fs.__exportStar(k8e(),os);Fs.__exportStar(nte(),os);Fs.__exportStar(I8e(),os);Fs.__exportStar(F8e(),os);Fs.__exportStar(R8e(),os);Fs.__exportStar(N8e(),os);Fs.__exportStar(U8e(),os);Fs.__exportStar(M8e(),os);Fs.__exportStar($8e(),os);Fs.__exportStar(q8e(),os);Fs.__exportStar(z8e(),os);Fs.__exportStar(H8e(),os);Fs.__exportStar(G8e(),os);Fs.__exportStar(K8e(),os);Fs.__exportStar(X8e(),os);Fs.__exportStar(J8e(),os);Fs.__exportStar(Q8e(),os)});var uy=L(MN=>{"use strict";Object.defineProperty(MN,"__esModule",{value:!0});MN.AlgorithmIdentifier=void 0;var t5e=(at(),He(st)),UN=bt(),EAt=el(),M4=class t{algorithm="";parameters;constructor(e={}){Object.assign(this,e)}isEqual(e){return e instanceof t&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&(0,EAt.equal)(e.parameters,this.parameters)||e.parameters===this.parameters)}};MN.AlgorithmIdentifier=M4;t5e.__decorate([(0,UN.AsnProp)({type:UN.AsnPropTypes.ObjectIdentifier})],M4.prototype,"algorithm",void 0);t5e.__decorate([(0,UN.AsnProp)({type:UN.AsnPropTypes.Any,optional:!0})],M4.prototype,"parameters",void 0)});var Dte=L(LN=>{"use strict";Object.defineProperty(LN,"__esModule",{value:!0});LN.SubjectPublicKeyInfo=void 0;var r5e=(at(),He(st)),kte=bt(),n5e=uy(),L4=class{algorithm=new n5e.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};LN.SubjectPublicKeyInfo=L4;r5e.__decorate([(0,kte.AsnProp)({type:n5e.AlgorithmIdentifier})],L4.prototype,"algorithm",void 0);r5e.__decorate([(0,kte.AsnProp)({type:kte.AsnPropTypes.BitString})],L4.prototype,"subjectPublicKey",void 0)});var $N=L(j4=>{"use strict";Object.defineProperty(j4,"__esModule",{value:!0});j4.Time=void 0;var Ite=(at(),He(st)),nw=bt(),$4=class{utcTime;generalTime;constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){let r=new Date(e);r.setMilliseconds(0),r.getUTCFullYear()>2049?this.generalTime=r:this.utcTime=r}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};j4.Time=$4;Ite.__decorate([(0,nw.AsnProp)({type:nw.AsnPropTypes.UTCTime})],$4.prototype,"utcTime",void 0);Ite.__decorate([(0,nw.AsnProp)({type:nw.AsnPropTypes.GeneralizedTime})],$4.prototype,"generalTime",void 0);j4.Time=$4=Ite.__decorate([(0,nw.AsnType)({type:nw.AsnTypeTypes.Choice})],$4)});var Fte=L(jN=>{"use strict";Object.defineProperty(jN,"__esModule",{value:!0});jN.Validity=void 0;var i5e=(at(),He(st)),s5e=bt(),iw=$N(),q4=class{notBefore=new iw.Time(new Date);notAfter=new iw.Time(new Date);constructor(e){e&&(this.notBefore=new iw.Time(e.notBefore),this.notAfter=new iw.Time(e.notAfter))}};jN.Validity=q4;i5e.__decorate([(0,s5e.AsnProp)({type:iw.Time})],q4.prototype,"notBefore",void 0);i5e.__decorate([(0,s5e.AsnProp)({type:iw.Time})],q4.prototype,"notAfter",void 0)});var zN=L(ly=>{"use strict";var Pte;Object.defineProperty(ly,"__esModule",{value:!0});ly.Extensions=ly.Extension=void 0;var qN=(at(),He(st)),ch=bt(),Qm=class t{static CRITICAL=!1;extnID="";critical=t.CRITICAL;extnValue=new ch.OctetString;constructor(e={}){Object.assign(this,e)}};ly.Extension=Qm;qN.__decorate([(0,ch.AsnProp)({type:ch.AsnPropTypes.ObjectIdentifier})],Qm.prototype,"extnID",void 0);qN.__decorate([(0,ch.AsnProp)({type:ch.AsnPropTypes.Boolean,defaultValue:Qm.CRITICAL})],Qm.prototype,"critical",void 0);qN.__decorate([(0,ch.AsnProp)({type:ch.OctetString})],Qm.prototype,"extnValue",void 0);var Rte=Pte=class extends ch.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Pte.prototype)}};ly.Extensions=Rte;ly.Extensions=Rte=Pte=qN.__decorate([(0,ch.AsnType)({type:ch.AsnTypeTypes.Sequence,itemType:Qm})],Rte)});var Ote=L(WN=>{"use strict";Object.defineProperty(WN,"__esModule",{value:!0});WN.Version=void 0;var a5e;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(a5e||(WN.Version=a5e={}))});var Nte=L(VN=>{"use strict";Object.defineProperty(VN,"__esModule",{value:!0});VN.TBSCertificate=void 0;var uh=(at(),He(st)),Lc=bt(),o5e=uy(),HN=B_(),c5e=Dte(),u5e=Fte(),TAt=zN(),l5e=Ote(),il=class{version=l5e.Version.v1;serialNumber=new ArrayBuffer(0);signature=new o5e.AlgorithmIdentifier;issuer=new HN.Name;validity=new u5e.Validity;subject=new HN.Name;subjectPublicKeyInfo=new c5e.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};VN.TBSCertificate=il;uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.Integer,context:0,defaultValue:l5e.Version.v1})],il.prototype,"version",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.Integer,converter:Lc.AsnIntegerArrayBufferConverter})],il.prototype,"serialNumber",void 0);uh.__decorate([(0,Lc.AsnProp)({type:o5e.AlgorithmIdentifier})],il.prototype,"signature",void 0);uh.__decorate([(0,Lc.AsnProp)({type:HN.Name})],il.prototype,"issuer",void 0);uh.__decorate([(0,Lc.AsnProp)({type:u5e.Validity})],il.prototype,"validity",void 0);uh.__decorate([(0,Lc.AsnProp)({type:HN.Name})],il.prototype,"subject",void 0);uh.__decorate([(0,Lc.AsnProp)({type:c5e.SubjectPublicKeyInfo})],il.prototype,"subjectPublicKeyInfo",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],il.prototype,"issuerUniqueID",void 0);uh.__decorate([(0,Lc.AsnProp)({type:Lc.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],il.prototype,"subjectUniqueID",void 0);uh.__decorate([(0,Lc.AsnProp)({type:TAt.Extensions,context:3,optional:!0})],il.prototype,"extensions",void 0)});var h5e=L(KN=>{"use strict";Object.defineProperty(KN,"__esModule",{value:!0});KN.Certificate=void 0;var Bte=(at(),He(st)),GN=bt(),f5e=uy(),d5e=Nte(),sw=class{tbsCertificate=new d5e.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new f5e.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};KN.Certificate=sw;Bte.__decorate([(0,GN.AsnProp)({type:d5e.TBSCertificate,raw:!0})],sw.prototype,"tbsCertificate",void 0);Bte.__decorate([(0,GN.AsnProp)({type:f5e.AlgorithmIdentifier})],sw.prototype,"signatureAlgorithm",void 0);Bte.__decorate([(0,GN.AsnProp)({type:GN.AsnPropTypes.BitString})],sw.prototype,"signatureValue",void 0)});var Ute=L(aw=>{"use strict";Object.defineProperty(aw,"__esModule",{value:!0});aw.TBSCertList=aw.RevokedCertificate=void 0;var fh=(at(),He(st)),sl=bt(),p5e=uy(),m5e=B_(),z4=$N(),g5e=zN(),fy=class{userCertificate=new ArrayBuffer(0);revocationDate=new z4.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};aw.RevokedCertificate=fy;fh.__decorate([(0,sl.AsnProp)({type:sl.AsnPropTypes.Integer,converter:sl.AsnIntegerArrayBufferConverter})],fy.prototype,"userCertificate",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time})],fy.prototype,"revocationDate",void 0);fh.__decorate([(0,sl.AsnProp)({type:g5e.Extension,optional:!0,repeated:"sequence"})],fy.prototype,"crlEntryExtensions",void 0);var lh=class{version;signature=new p5e.AlgorithmIdentifier;issuer=new m5e.Name;thisUpdate=new z4.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};aw.TBSCertList=lh;fh.__decorate([(0,sl.AsnProp)({type:sl.AsnPropTypes.Integer,optional:!0})],lh.prototype,"version",void 0);fh.__decorate([(0,sl.AsnProp)({type:p5e.AlgorithmIdentifier})],lh.prototype,"signature",void 0);fh.__decorate([(0,sl.AsnProp)({type:m5e.Name})],lh.prototype,"issuer",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time})],lh.prototype,"thisUpdate",void 0);fh.__decorate([(0,sl.AsnProp)({type:z4.Time,optional:!0})],lh.prototype,"nextUpdate",void 0);fh.__decorate([(0,sl.AsnProp)({type:fy,repeated:"sequence",optional:!0})],lh.prototype,"revokedCertificates",void 0);fh.__decorate([(0,sl.AsnProp)({type:g5e.Extension,optional:!0,context:0,repeated:"sequence"})],lh.prototype,"crlExtensions",void 0)});var v5e=L(XN=>{"use strict";Object.defineProperty(XN,"__esModule",{value:!0});XN.CertificateList=void 0;var Mte=(at(),He(st)),ZN=bt(),x5e=uy(),y5e=Ute(),ow=class{tbsCertList=new y5e.TBSCertList;tbsCertListRaw;signatureAlgorithm=new x5e.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};XN.CertificateList=ow;Mte.__decorate([(0,ZN.AsnProp)({type:y5e.TBSCertList,raw:!0})],ow.prototype,"tbsCertList",void 0);Mte.__decorate([(0,ZN.AsnProp)({type:x5e.AlgorithmIdentifier})],ow.prototype,"signatureAlgorithm",void 0);Mte.__decorate([(0,ZN.AsnProp)({type:ZN.AsnPropTypes.BitString})],ow.prototype,"signature",void 0)});var hi=L(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});var mc=(at(),He(st));mc.__exportStar(e5e(),fo);mc.__exportStar(uy(),fo);mc.__exportStar(bte(),fo);mc.__exportStar(h5e(),fo);mc.__exportStar(v5e(),fo);mc.__exportStar(zN(),fo);mc.__exportStar(Gx(),fo);mc.__exportStar(T4(),fo);mc.__exportStar(B_(),fo);mc.__exportStar(vs(),fo);mc.__exportStar(Dte(),fo);mc.__exportStar(Ute(),fo);mc.__exportStar(Nte(),fo);mc.__exportStar($N(),fo);mc.__exportStar(Ote(),fo);mc.__exportStar(Fte(),fo)});var H4=L(JN=>{"use strict";Object.defineProperty(JN,"__esModule",{value:!0});JN.IssuerAndSerialNumber=void 0;var b5e=(at(),He(st)),YN=bt(),_5e=hi(),W4=class{issuer=new _5e.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};JN.IssuerAndSerialNumber=W4;b5e.__decorate([(0,YN.AsnProp)({type:_5e.Name})],W4.prototype,"issuer",void 0);b5e.__decorate([(0,YN.AsnProp)({type:YN.AsnPropTypes.Integer,converter:YN.AsnIntegerArrayBufferConverter})],W4.prototype,"serialNumber",void 0)});var $te=L(G4=>{"use strict";Object.defineProperty(G4,"__esModule",{value:!0});G4.SignerIdentifier=void 0;var Lte=(at(),He(st)),QN=bt(),CAt=hi(),kAt=H4(),V4=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};G4.SignerIdentifier=V4;Lte.__decorate([(0,QN.AsnProp)({type:CAt.SubjectKeyIdentifier,context:0,implicit:!0})],V4.prototype,"subjectKeyIdentifier",void 0);Lte.__decorate([(0,QN.AsnProp)({type:kAt.IssuerAndSerialNumber})],V4.prototype,"issuerAndSerialNumber",void 0);G4.SignerIdentifier=V4=Lte.__decorate([(0,QN.AsnType)({type:QN.AsnTypeTypes.Choice})],V4)});var dh=L(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.KeyDerivationAlgorithmIdentifier=fa.MessageAuthenticationCodeAlgorithm=fa.ContentEncryptionAlgorithmIdentifier=fa.KeyEncryptionAlgorithmIdentifier=fa.SignatureAlgorithmIdentifier=fa.DigestAlgorithmIdentifier=fa.CMSVersion=void 0;var cw=(at(),He(st)),uw=hi(),Xl=bt(),w5e;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(w5e||(fa.CMSVersion=w5e={}));var jte=class extends uw.AlgorithmIdentifier{};fa.DigestAlgorithmIdentifier=jte;fa.DigestAlgorithmIdentifier=jte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],jte);var qte=class extends uw.AlgorithmIdentifier{};fa.SignatureAlgorithmIdentifier=qte;fa.SignatureAlgorithmIdentifier=qte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],qte);var zte=class extends uw.AlgorithmIdentifier{};fa.KeyEncryptionAlgorithmIdentifier=zte;fa.KeyEncryptionAlgorithmIdentifier=zte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],zte);var Wte=class extends uw.AlgorithmIdentifier{};fa.ContentEncryptionAlgorithmIdentifier=Wte;fa.ContentEncryptionAlgorithmIdentifier=Wte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Wte);var Hte=class extends uw.AlgorithmIdentifier{};fa.MessageAuthenticationCodeAlgorithm=Hte;fa.MessageAuthenticationCodeAlgorithm=Hte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Hte);var Vte=class extends uw.AlgorithmIdentifier{};fa.KeyDerivationAlgorithmIdentifier=Vte;fa.KeyDerivationAlgorithmIdentifier=Vte=cw.__decorate([(0,Xl.AsnType)({type:Xl.AsnTypeTypes.Sequence})],Vte)});var r7=L(t7=>{"use strict";Object.defineProperty(t7,"__esModule",{value:!0});t7.Attribute=void 0;var S5e=(at(),He(st)),e7=bt(),K4=class{attrType="";attrValues=[];constructor(e={}){Object.assign(this,e)}};t7.Attribute=K4;S5e.__decorate([(0,e7.AsnProp)({type:e7.AsnPropTypes.ObjectIdentifier})],K4.prototype,"attrType",void 0);S5e.__decorate([(0,e7.AsnProp)({type:e7.AsnPropTypes.Any,repeated:"set"})],K4.prototype,"attrValues",void 0)});var n7=L(dy=>{"use strict";var Gte;Object.defineProperty(dy,"__esModule",{value:!0});dy.SignerInfos=dy.SignerInfo=void 0;var eg=(at(),He(st)),al=bt(),A5e=$te(),Z4=dh(),E5e=r7(),$f=class{version=Z4.CMSVersion.v0;sid=new A5e.SignerIdentifier;digestAlgorithm=new Z4.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new Z4.SignatureAlgorithmIdentifier;signature=new al.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};dy.SignerInfo=$f;eg.__decorate([(0,al.AsnProp)({type:al.AsnPropTypes.Integer})],$f.prototype,"version",void 0);eg.__decorate([(0,al.AsnProp)({type:A5e.SignerIdentifier})],$f.prototype,"sid",void 0);eg.__decorate([(0,al.AsnProp)({type:Z4.DigestAlgorithmIdentifier})],$f.prototype,"digestAlgorithm",void 0);eg.__decorate([(0,al.AsnProp)({type:E5e.Attribute,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],$f.prototype,"signedAttrs",void 0);eg.__decorate([(0,al.AsnProp)({type:Z4.SignatureAlgorithmIdentifier})],$f.prototype,"signatureAlgorithm",void 0);eg.__decorate([(0,al.AsnProp)({type:al.OctetString})],$f.prototype,"signature",void 0);eg.__decorate([(0,al.AsnProp)({type:E5e.Attribute,repeated:"set",context:1,implicit:!0,optional:!0})],$f.prototype,"unsignedAttrs",void 0);var Kte=Gte=class extends al.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Gte.prototype)}};dy.SignerInfos=Kte;dy.SignerInfos=Kte=Gte=eg.__decorate([(0,al.AsnType)({type:al.AsnTypeTypes.Set,itemType:$f})],Kte)});var C5e=L(hy=>{"use strict";Object.defineProperty(hy,"__esModule",{value:!0});hy.CounterSignature=hy.id_counterSignature=void 0;var DAt=(at(),He(st)),T5e=bt(),IAt=n7();hy.id_counterSignature="1.2.840.113549.1.9.6";var Zte=class extends IAt.SignerInfo{};hy.CounterSignature=Zte;hy.CounterSignature=Zte=DAt.__decorate([(0,T5e.AsnType)({type:T5e.AsnTypeTypes.Sequence})],Zte)});var k5e=L(lw=>{"use strict";Object.defineProperty(lw,"__esModule",{value:!0});lw.MessageDigest=lw.id_messageDigest=void 0;var FAt=bt();lw.id_messageDigest="1.2.840.113549.1.9.4";var Xte=class extends FAt.OctetString{};lw.MessageDigest=Xte});var I5e=L(py=>{"use strict";Object.defineProperty(py,"__esModule",{value:!0});py.SigningTime=py.id_signingTime=void 0;var PAt=(at(),He(st)),RAt=hi(),D5e=bt();py.id_signingTime="1.2.840.113549.1.9.5";var Yte=class extends RAt.Time{};py.SigningTime=Yte;py.SigningTime=Yte=PAt.__decorate([(0,D5e.AsnType)({type:D5e.AsnTypeTypes.Choice})],Yte)});var F5e=L(my=>{"use strict";Object.defineProperty(my,"__esModule",{value:!0});my.id_contentType=void 0;var Jte=(at(),He(st));Jte.__exportStar(C5e(),my);Jte.__exportStar(k5e(),my);Jte.__exportStar(I5e(),my);my.id_contentType="1.2.840.113549.1.9.3"});var P5e=L(s7=>{"use strict";Object.defineProperty(s7,"__esModule",{value:!0});s7.ACClearAttrs=void 0;var Qte=(at(),He(st)),i7=bt(),ere=hi(),fw=class{acIssuer=new ere.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};s7.ACClearAttrs=fw;Qte.__decorate([(0,i7.AsnProp)({type:ere.GeneralName})],fw.prototype,"acIssuer",void 0);Qte.__decorate([(0,i7.AsnProp)({type:i7.AsnPropTypes.Integer})],fw.prototype,"acSerial",void 0);Qte.__decorate([(0,i7.AsnProp)({type:ere.Attribute,repeated:"sequence"})],fw.prototype,"attrs",void 0)});var nre=L(X4=>{"use strict";var tre;Object.defineProperty(X4,"__esModule",{value:!0});X4.AttrSpec=void 0;var OAt=(at(),He(st)),a7=bt(),rre=tre=class extends a7.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,tre.prototype)}};X4.AttrSpec=rre;X4.AttrSpec=rre=tre=OAt.__decorate([(0,a7.AsnType)({type:a7.AsnTypeTypes.Sequence,itemType:a7.AsnPropTypes.ObjectIdentifier})],rre)});var O5e=L(c7=>{"use strict";Object.defineProperty(c7,"__esModule",{value:!0});c7.AAControls=void 0;var o7=(at(),He(st)),dw=bt(),R5e=nre(),gy=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};c7.AAControls=gy;o7.__decorate([(0,dw.AsnProp)({type:dw.AsnPropTypes.Integer,optional:!0})],gy.prototype,"pathLenConstraint",void 0);o7.__decorate([(0,dw.AsnProp)({type:R5e.AttrSpec,implicit:!0,context:0,optional:!0})],gy.prototype,"permittedAttrs",void 0);o7.__decorate([(0,dw.AsnProp)({type:R5e.AttrSpec,implicit:!0,context:1,optional:!0})],gy.prototype,"excludedAttrs",void 0);o7.__decorate([(0,dw.AsnProp)({type:dw.AsnPropTypes.Boolean,defaultValue:!0})],gy.prototype,"permitUnSpecified",void 0)});var Y4=L(u7=>{"use strict";Object.defineProperty(u7,"__esModule",{value:!0});u7.IssuerSerial=void 0;var ire=(at(),He(st)),hw=bt(),N5e=hi(),pw=class{issuer=new N5e.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};u7.IssuerSerial=pw;ire.__decorate([(0,hw.AsnProp)({type:N5e.GeneralNames})],pw.prototype,"issuer",void 0);ire.__decorate([(0,hw.AsnProp)({type:hw.AsnPropTypes.Integer,converter:hw.AsnIntegerArrayBufferConverter})],pw.prototype,"serial",void 0);ire.__decorate([(0,hw.AsnProp)({type:hw.AsnPropTypes.BitString,optional:!0})],pw.prototype,"issuerUID",void 0)});var J4=L(mw=>{"use strict";Object.defineProperty(mw,"__esModule",{value:!0});mw.ObjectDigestInfo=mw.DigestedObjectType=void 0;var l7=(at(),He(st)),xy=bt(),B5e=hi(),sre;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(sre||(mw.DigestedObjectType=sre={}));var yy=class{digestedObjectType=sre.publicKey;otherObjectTypeID;digestAlgorithm=new B5e.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};mw.ObjectDigestInfo=yy;l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.Enumerated})],yy.prototype,"digestedObjectType",void 0);l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.ObjectIdentifier,optional:!0})],yy.prototype,"otherObjectTypeID",void 0);l7.__decorate([(0,xy.AsnProp)({type:B5e.AlgorithmIdentifier})],yy.prototype,"digestAlgorithm",void 0);l7.__decorate([(0,xy.AsnProp)({type:xy.AsnPropTypes.BitString})],yy.prototype,"objectDigest",void 0)});var cre=L(f7=>{"use strict";Object.defineProperty(f7,"__esModule",{value:!0});f7.V2Form=void 0;var are=(at(),He(st)),ore=bt(),NAt=hi(),BAt=Y4(),UAt=J4(),gw=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};f7.V2Form=gw;are.__decorate([(0,ore.AsnProp)({type:NAt.GeneralNames,optional:!0})],gw.prototype,"issuerName",void 0);are.__decorate([(0,ore.AsnProp)({type:BAt.IssuerSerial,context:0,implicit:!0,optional:!0})],gw.prototype,"baseCertificateID",void 0);are.__decorate([(0,ore.AsnProp)({type:UAt.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],gw.prototype,"objectDigestInfo",void 0)});var lre=L(e3=>{"use strict";Object.defineProperty(e3,"__esModule",{value:!0});e3.AttCertIssuer=void 0;var ure=(at(),He(st)),d7=bt(),MAt=hi(),LAt=cre(),Q4=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e3.AttCertIssuer=Q4;ure.__decorate([(0,d7.AsnProp)({type:MAt.GeneralName,repeated:"sequence"})],Q4.prototype,"v1Form",void 0);ure.__decorate([(0,d7.AsnProp)({type:LAt.V2Form,context:0,implicit:!0})],Q4.prototype,"v2Form",void 0);e3.AttCertIssuer=Q4=ure.__decorate([(0,d7.AsnType)({type:d7.AsnTypeTypes.Choice})],Q4)});var fre=L(p7=>{"use strict";Object.defineProperty(p7,"__esModule",{value:!0});p7.AttCertValidityPeriod=void 0;var U5e=(at(),He(st)),h7=bt(),t3=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};p7.AttCertValidityPeriod=t3;U5e.__decorate([(0,h7.AsnProp)({type:h7.AsnPropTypes.GeneralizedTime})],t3.prototype,"notBeforeTime",void 0);U5e.__decorate([(0,h7.AsnProp)({type:h7.AsnPropTypes.GeneralizedTime})],t3.prototype,"notAfterTime",void 0)});var pre=L(m7=>{"use strict";Object.defineProperty(m7,"__esModule",{value:!0});m7.Holder=void 0;var dre=(at(),He(st)),hre=bt(),$At=hi(),jAt=Y4(),qAt=J4(),xw=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};m7.Holder=xw;dre.__decorate([(0,hre.AsnProp)({type:jAt.IssuerSerial,implicit:!0,context:0,optional:!0})],xw.prototype,"baseCertificateID",void 0);dre.__decorate([(0,hre.AsnProp)({type:$At.GeneralNames,implicit:!0,context:1,optional:!0})],xw.prototype,"entityName",void 0);dre.__decorate([(0,hre.AsnProp)({type:qAt.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],xw.prototype,"objectDigestInfo",void 0)});var gre=L(yw=>{"use strict";Object.defineProperty(yw,"__esModule",{value:!0});yw.AttributeCertificateInfo=yw.AttCertVersion=void 0;var W0=(at(),He(st)),ol=bt(),g7=hi(),M5e=pre(),L5e=lre(),$5e=fre(),mre;(function(t){t[t.v2=1]="v2"})(mre||(yw.AttCertVersion=mre={}));var Yl=class{version=mre.v2;holder=new M5e.Holder;issuer=new L5e.AttCertIssuer;signature=new g7.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new $5e.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};yw.AttributeCertificateInfo=Yl;W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.Integer})],Yl.prototype,"version",void 0);W0.__decorate([(0,ol.AsnProp)({type:M5e.Holder})],Yl.prototype,"holder",void 0);W0.__decorate([(0,ol.AsnProp)({type:L5e.AttCertIssuer})],Yl.prototype,"issuer",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.AlgorithmIdentifier})],Yl.prototype,"signature",void 0);W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.Integer,converter:ol.AsnIntegerArrayBufferConverter})],Yl.prototype,"serialNumber",void 0);W0.__decorate([(0,ol.AsnProp)({type:$5e.AttCertValidityPeriod})],Yl.prototype,"attrCertValidityPeriod",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.Attribute,repeated:"sequence"})],Yl.prototype,"attributes",void 0);W0.__decorate([(0,ol.AsnProp)({type:ol.AsnPropTypes.BitString,optional:!0})],Yl.prototype,"issuerUniqueID",void 0);W0.__decorate([(0,ol.AsnProp)({type:g7.Extensions,optional:!0})],Yl.prototype,"extensions",void 0)});var z5e=L(y7=>{"use strict";Object.defineProperty(y7,"__esModule",{value:!0});y7.AttributeCertificate=void 0;var xre=(at(),He(st)),x7=bt(),j5e=hi(),q5e=gre(),vw=class{acinfo=new q5e.AttributeCertificateInfo;signatureAlgorithm=new j5e.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};y7.AttributeCertificate=vw;xre.__decorate([(0,x7.AsnProp)({type:q5e.AttributeCertificateInfo})],vw.prototype,"acinfo",void 0);xre.__decorate([(0,x7.AsnProp)({type:j5e.AlgorithmIdentifier})],vw.prototype,"signatureAlgorithm",void 0);xre.__decorate([(0,x7.AsnProp)({type:x7.AsnPropTypes.BitString})],vw.prototype,"signatureValue",void 0)});var vre=L(bw=>{"use strict";Object.defineProperty(bw,"__esModule",{value:!0});bw.ClassList=bw.ClassListFlags=void 0;var zAt=bt(),W5e;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(W5e||(bw.ClassListFlags=W5e={}));var yre=class extends zAt.BitString{};bw.ClassList=yre});var bre=L(b7=>{"use strict";Object.defineProperty(b7,"__esModule",{value:!0});b7.SecurityCategory=void 0;var H5e=(at(),He(st)),v7=bt(),r3=class{type="";value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};b7.SecurityCategory=r3;H5e.__decorate([(0,v7.AsnProp)({type:v7.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],r3.prototype,"type",void 0);H5e.__decorate([(0,v7.AsnProp)({type:v7.AsnPropTypes.Any,implicit:!0,context:1})],r3.prototype,"value",void 0)});var V5e=L(w7=>{"use strict";Object.defineProperty(w7,"__esModule",{value:!0});w7.Clearance=void 0;var _re=(at(),He(st)),_7=bt(),n3=vre(),WAt=bre(),_w=class{policyId="";classList=new n3.ClassList(n3.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};w7.Clearance=_w;_re.__decorate([(0,_7.AsnProp)({type:_7.AsnPropTypes.ObjectIdentifier})],_w.prototype,"policyId",void 0);_re.__decorate([(0,_7.AsnProp)({type:n3.ClassList,defaultValue:new n3.ClassList(n3.ClassListFlags.unclassified)})],_w.prototype,"classList",void 0);_re.__decorate([(0,_7.AsnProp)({type:WAt.SecurityCategory,repeated:"set"})],_w.prototype,"securityCategories",void 0)});var G5e=L(ww=>{"use strict";Object.defineProperty(ww,"__esModule",{value:!0});ww.IetfAttrSyntax=ww.IetfAttrSyntaxValueChoices=void 0;var s3=(at(),He(st)),tg=bt(),HAt=hi(),vy=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};ww.IetfAttrSyntaxValueChoices=vy;s3.__decorate([(0,tg.AsnProp)({type:tg.OctetString})],vy.prototype,"cotets",void 0);s3.__decorate([(0,tg.AsnProp)({type:tg.AsnPropTypes.ObjectIdentifier})],vy.prototype,"oid",void 0);s3.__decorate([(0,tg.AsnProp)({type:tg.AsnPropTypes.Utf8String})],vy.prototype,"string",void 0);var i3=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};ww.IetfAttrSyntax=i3;s3.__decorate([(0,tg.AsnProp)({type:HAt.GeneralNames,implicit:!0,context:0,optional:!0})],i3.prototype,"policyAuthority",void 0);s3.__decorate([(0,tg.AsnProp)({type:vy,repeated:"sequence"})],i3.prototype,"values",void 0)});var K5e=L(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.id_at_clearance=pi.id_at_role=pi.id_at=pi.id_aca_encAttrs=pi.id_aca_group=pi.id_aca_chargingIdentity=pi.id_aca_accessIdentity=pi.id_aca_authenticationInfo=pi.id_aca=pi.id_ce_targetInformation=pi.id_pe_ac_proxying=pi.id_pe_aaControls=pi.id_pe_ac_auditIdentity=void 0;var a3=hi();pi.id_pe_ac_auditIdentity=`${a3.id_pe}.4`;pi.id_pe_aaControls=`${a3.id_pe}.6`;pi.id_pe_ac_proxying=`${a3.id_pe}.10`;pi.id_ce_targetInformation=`${a3.id_ce}.55`;pi.id_aca=`${a3.id_pkix}.10`;pi.id_aca_authenticationInfo=`${pi.id_aca}.1`;pi.id_aca_accessIdentity=`${pi.id_aca}.2`;pi.id_aca_chargingIdentity=`${pi.id_aca}.3`;pi.id_aca_group=`${pi.id_aca}.4`;pi.id_aca_encAttrs=`${pi.id_aca}.6`;pi.id_at="2.5.4";pi.id_at_role=`${pi.id_at}.72`;pi.id_at_clearance="2.5.1.5.55"});var Ere=L(hh=>{"use strict";var wre;Object.defineProperty(hh,"__esModule",{value:!0});hh.Targets=hh.Target=hh.TargetCert=void 0;var rg=(at(),He(st)),jf=bt(),Are=hi(),Z5e=Y4(),VAt=J4(),by=class{targetCertificate=new Z5e.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};hh.TargetCert=by;rg.__decorate([(0,jf.AsnProp)({type:Z5e.IssuerSerial})],by.prototype,"targetCertificate",void 0);rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,optional:!0})],by.prototype,"targetName",void 0);rg.__decorate([(0,jf.AsnProp)({type:VAt.ObjectDigestInfo,optional:!0})],by.prototype,"certDigestInfo",void 0);var _y=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};hh.Target=_y;rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,context:0,implicit:!0})],_y.prototype,"targetName",void 0);rg.__decorate([(0,jf.AsnProp)({type:Are.GeneralName,context:1,implicit:!0})],_y.prototype,"targetGroup",void 0);rg.__decorate([(0,jf.AsnProp)({type:by,context:2,implicit:!0})],_y.prototype,"targetCert",void 0);hh.Target=_y=rg.__decorate([(0,jf.AsnType)({type:jf.AsnTypeTypes.Choice})],_y);var Sre=wre=class extends jf.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,wre.prototype)}};hh.Targets=Sre;hh.Targets=Sre=wre=rg.__decorate([(0,jf.AsnType)({type:jf.AsnTypeTypes.Sequence,itemType:_y})],Sre)});var X5e=L(o3=>{"use strict";var Tre;Object.defineProperty(o3,"__esModule",{value:!0});o3.ProxyInfo=void 0;var GAt=(at(),He(st)),Cre=bt(),KAt=Ere(),kre=Tre=class extends Cre.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Tre.prototype)}};o3.ProxyInfo=kre;o3.ProxyInfo=kre=Tre=GAt.__decorate([(0,Cre.AsnType)({type:Cre.AsnTypeTypes.Sequence,itemType:KAt.Targets})],kre)});var eIe=L(S7=>{"use strict";Object.defineProperty(S7,"__esModule",{value:!0});S7.RoleSyntax=void 0;var Y5e=(at(),He(st)),J5e=bt(),Q5e=hi(),c3=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};S7.RoleSyntax=c3;Y5e.__decorate([(0,J5e.AsnProp)({type:Q5e.GeneralNames,implicit:!0,context:0,optional:!0})],c3.prototype,"roleAuthority",void 0);Y5e.__decorate([(0,J5e.AsnProp)({type:Q5e.GeneralName,implicit:!0,context:1})],c3.prototype,"roleName",void 0)});var tIe=L(T7=>{"use strict";Object.defineProperty(T7,"__esModule",{value:!0});T7.SvceAuthInfo=void 0;var Dre=(at(),He(st)),A7=bt(),E7=hi(),Sw=class{service=new E7.GeneralName;ident=new E7.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};T7.SvceAuthInfo=Sw;Dre.__decorate([(0,A7.AsnProp)({type:E7.GeneralName})],Sw.prototype,"service",void 0);Dre.__decorate([(0,A7.AsnProp)({type:E7.GeneralName})],Sw.prototype,"ident",void 0);Dre.__decorate([(0,A7.AsnProp)({type:A7.OctetString,optional:!0})],Sw.prototype,"authInfo",void 0)});var Ire=L(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});var Pa=(at(),He(st));Pa.__exportStar(P5e(),da);Pa.__exportStar(O5e(),da);Pa.__exportStar(lre(),da);Pa.__exportStar(fre(),da);Pa.__exportStar(nre(),da);Pa.__exportStar(z5e(),da);Pa.__exportStar(gre(),da);Pa.__exportStar(vre(),da);Pa.__exportStar(V5e(),da);Pa.__exportStar(pre(),da);Pa.__exportStar(G5e(),da);Pa.__exportStar(Y4(),da);Pa.__exportStar(J4(),da);Pa.__exportStar(K5e(),da);Pa.__exportStar(X5e(),da);Pa.__exportStar(eIe(),da);Pa.__exportStar(bre(),da);Pa.__exportStar(tIe(),da);Pa.__exportStar(Ere(),da);Pa.__exportStar(cre(),da)});var C7=L(ph=>{"use strict";var Fre;Object.defineProperty(ph,"__esModule",{value:!0});ph.CertificateSet=ph.CertificateChoices=ph.OtherCertificateFormat=void 0;var Sy=(at(),He(st)),Jl=bt(),ZAt=hi(),XAt=Ire(),Aw=class{otherCertFormat="";otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};ph.OtherCertificateFormat=Aw;Sy.__decorate([(0,Jl.AsnProp)({type:Jl.AsnPropTypes.ObjectIdentifier})],Aw.prototype,"otherCertFormat",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:Jl.AsnPropTypes.Any})],Aw.prototype,"otherCert",void 0);var wy=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};ph.CertificateChoices=wy;Sy.__decorate([(0,Jl.AsnProp)({type:ZAt.Certificate})],wy.prototype,"certificate",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:XAt.AttributeCertificate,context:2,implicit:!0})],wy.prototype,"v2AttrCert",void 0);Sy.__decorate([(0,Jl.AsnProp)({type:Aw,context:3,implicit:!0})],wy.prototype,"other",void 0);ph.CertificateChoices=wy=Sy.__decorate([(0,Jl.AsnType)({type:Jl.AsnTypeTypes.Choice})],wy);var Pre=Fre=class extends Jl.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Fre.prototype)}};ph.CertificateSet=Pre;ph.CertificateSet=Pre=Fre=Sy.__decorate([(0,Jl.AsnType)({type:Jl.AsnTypeTypes.Set,itemType:wy})],Pre)});var nIe=L(D7=>{"use strict";Object.defineProperty(D7,"__esModule",{value:!0});D7.ContentInfo=void 0;var rIe=(at(),He(st)),k7=bt(),u3=class{contentType="";content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};D7.ContentInfo=u3;rIe.__decorate([(0,k7.AsnProp)({type:k7.AsnPropTypes.ObjectIdentifier})],u3.prototype,"contentType",void 0);rIe.__decorate([(0,k7.AsnProp)({type:k7.AsnPropTypes.Any,context:0})],u3.prototype,"content",void 0)});var Rre=L(Ay=>{"use strict";Object.defineProperty(Ay,"__esModule",{value:!0});Ay.EncapsulatedContentInfo=Ay.EncapsulatedContent=void 0;var f3=(at(),He(st)),H0=bt(),Ew=class{single;any;constructor(e={}){Object.assign(this,e)}};Ay.EncapsulatedContent=Ew;f3.__decorate([(0,H0.AsnProp)({type:H0.OctetString})],Ew.prototype,"single",void 0);f3.__decorate([(0,H0.AsnProp)({type:H0.AsnPropTypes.Any})],Ew.prototype,"any",void 0);Ay.EncapsulatedContent=Ew=f3.__decorate([(0,H0.AsnType)({type:H0.AsnTypeTypes.Choice})],Ew);var l3=class{eContentType="";eContent;constructor(e={}){Object.assign(this,e)}};Ay.EncapsulatedContentInfo=l3;f3.__decorate([(0,H0.AsnProp)({type:H0.AsnPropTypes.ObjectIdentifier})],l3.prototype,"eContentType",void 0);f3.__decorate([(0,H0.AsnProp)({type:Ew,context:0,optional:!0})],l3.prototype,"eContent",void 0)});var Ore=L(Ey=>{"use strict";Object.defineProperty(Ey,"__esModule",{value:!0});Ey.EncryptedContentInfo=Ey.EncryptedContent=void 0;var kw=(at(),He(st)),qf=bt(),iIe=dh(),Tw=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};Ey.EncryptedContent=Tw;kw.__decorate([(0,qf.AsnProp)({type:qf.OctetString,context:0,implicit:!0,optional:!0})],Tw.prototype,"value",void 0);kw.__decorate([(0,qf.AsnProp)({type:qf.OctetString,converter:qf.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Tw.prototype,"constructedValue",void 0);Ey.EncryptedContent=Tw=kw.__decorate([(0,qf.AsnType)({type:qf.AsnTypeTypes.Choice})],Tw);var Cw=class{contentType="";contentEncryptionAlgorithm=new iIe.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};Ey.EncryptedContentInfo=Cw;kw.__decorate([(0,qf.AsnProp)({type:qf.AsnPropTypes.ObjectIdentifier})],Cw.prototype,"contentType",void 0);kw.__decorate([(0,qf.AsnProp)({type:iIe.ContentEncryptionAlgorithmIdentifier})],Cw.prototype,"contentEncryptionAlgorithm",void 0);kw.__decorate([(0,qf.AsnProp)({type:Tw,optional:!0})],Cw.prototype,"encryptedContent",void 0)});var Nre=L(F7=>{"use strict";Object.defineProperty(F7,"__esModule",{value:!0});F7.OtherKeyAttribute=void 0;var sIe=(at(),He(st)),I7=bt(),d3=class{keyAttrId="";keyAttr;constructor(e={}){Object.assign(this,e)}};F7.OtherKeyAttribute=d3;sIe.__decorate([(0,I7.AsnProp)({type:I7.AsnPropTypes.ObjectIdentifier})],d3.prototype,"keyAttrId",void 0);sIe.__decorate([(0,I7.AsnProp)({type:I7.AsnPropTypes.Any,optional:!0})],d3.prototype,"keyAttr",void 0)});var Mre=L(Va=>{"use strict";var Bre;Object.defineProperty(Va,"__esModule",{value:!0});Va.KeyAgreeRecipientInfo=Va.OriginatorIdentifierOrKey=Va.OriginatorPublicKey=Va.RecipientEncryptedKeys=Va.RecipientEncryptedKey=Va.KeyAgreeRecipientIdentifier=Va.RecipientKeyIdentifier=void 0;var Ra=(at(),He(st)),Mi=bt(),p3=hi(),Ure=dh(),aIe=H4(),YAt=Nre(),Ty=class{subjectKeyIdentifier=new p3.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};Va.RecipientKeyIdentifier=Ty;Ra.__decorate([(0,Mi.AsnProp)({type:p3.SubjectKeyIdentifier})],Ty.prototype,"subjectKeyIdentifier",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.GeneralizedTime,optional:!0})],Ty.prototype,"date",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:YAt.OtherKeyAttribute,optional:!0})],Ty.prototype,"other",void 0);var Cy=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Va.KeyAgreeRecipientIdentifier=Cy;Ra.__decorate([(0,Mi.AsnProp)({type:Ty,context:0,implicit:!0,optional:!0})],Cy.prototype,"rKeyId",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:aIe.IssuerAndSerialNumber,optional:!0})],Cy.prototype,"issuerAndSerialNumber",void 0);Va.KeyAgreeRecipientIdentifier=Cy=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Choice})],Cy);var Dw=class{rid=new Cy;encryptedKey=new Mi.OctetString;constructor(e={}){Object.assign(this,e)}};Va.RecipientEncryptedKey=Dw;Ra.__decorate([(0,Mi.AsnProp)({type:Cy})],Dw.prototype,"rid",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.OctetString})],Dw.prototype,"encryptedKey",void 0);var h3=Bre=class extends Mi.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Bre.prototype)}};Va.RecipientEncryptedKeys=h3;Va.RecipientEncryptedKeys=h3=Bre=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Sequence,itemType:Dw})],h3);var Iw=class{algorithm=new p3.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Va.OriginatorPublicKey=Iw;Ra.__decorate([(0,Mi.AsnProp)({type:p3.AlgorithmIdentifier})],Iw.prototype,"algorithm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.BitString})],Iw.prototype,"publicKey",void 0);var ng=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Va.OriginatorIdentifierOrKey=ng;Ra.__decorate([(0,Mi.AsnProp)({type:p3.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],ng.prototype,"subjectKeyIdentifier",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Iw,context:1,implicit:!0,optional:!0})],ng.prototype,"originatorKey",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:aIe.IssuerAndSerialNumber,optional:!0})],ng.prototype,"issuerAndSerialNumber",void 0);Va.OriginatorIdentifierOrKey=ng=Ra.__decorate([(0,Mi.AsnType)({type:Mi.AsnTypeTypes.Choice})],ng);var ig=class{version=Ure.CMSVersion.v3;originator=new ng;ukm;keyEncryptionAlgorithm=new Ure.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new h3;constructor(e={}){Object.assign(this,e)}};Va.KeyAgreeRecipientInfo=ig;Ra.__decorate([(0,Mi.AsnProp)({type:Mi.AsnPropTypes.Integer})],ig.prototype,"version",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:ng,context:0})],ig.prototype,"originator",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Mi.OctetString,context:1,optional:!0})],ig.prototype,"ukm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:Ure.KeyEncryptionAlgorithmIdentifier})],ig.prototype,"keyEncryptionAlgorithm",void 0);Ra.__decorate([(0,Mi.AsnProp)({type:h3})],ig.prototype,"recipientEncryptedKeys",void 0)});var $re=L(Iy=>{"use strict";Object.defineProperty(Iy,"__esModule",{value:!0});Iy.KeyTransRecipientInfo=Iy.RecipientIdentifier=void 0;var Fy=(at(),He(st)),zf=bt(),JAt=hi(),Lre=dh(),QAt=H4(),ky=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};Iy.RecipientIdentifier=ky;Fy.__decorate([(0,zf.AsnProp)({type:JAt.SubjectKeyIdentifier,context:0,implicit:!0})],ky.prototype,"subjectKeyIdentifier",void 0);Fy.__decorate([(0,zf.AsnProp)({type:QAt.IssuerAndSerialNumber})],ky.prototype,"issuerAndSerialNumber",void 0);Iy.RecipientIdentifier=ky=Fy.__decorate([(0,zf.AsnType)({type:zf.AsnTypeTypes.Choice})],ky);var Dy=class{version=Lre.CMSVersion.v0;rid=new ky;keyEncryptionAlgorithm=new Lre.KeyEncryptionAlgorithmIdentifier;encryptedKey=new zf.OctetString;constructor(e={}){Object.assign(this,e)}};Iy.KeyTransRecipientInfo=Dy;Fy.__decorate([(0,zf.AsnProp)({type:zf.AsnPropTypes.Integer})],Dy.prototype,"version",void 0);Fy.__decorate([(0,zf.AsnProp)({type:ky})],Dy.prototype,"rid",void 0);Fy.__decorate([(0,zf.AsnProp)({type:Lre.KeyEncryptionAlgorithmIdentifier})],Dy.prototype,"keyEncryptionAlgorithm",void 0);Fy.__decorate([(0,zf.AsnProp)({type:zf.OctetString})],Dy.prototype,"encryptedKey",void 0)});var qre=L(Fw=>{"use strict";Object.defineProperty(Fw,"__esModule",{value:!0});Fw.KEKRecipientInfo=Fw.KEKIdentifier=void 0;var Ry=(at(),He(st)),cl=bt(),eEt=Nre(),jre=dh(),sg=class{keyIdentifier=new cl.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};Fw.KEKIdentifier=sg;Ry.__decorate([(0,cl.AsnProp)({type:cl.OctetString})],sg.prototype,"keyIdentifier",void 0);Ry.__decorate([(0,cl.AsnProp)({type:cl.AsnPropTypes.GeneralizedTime,optional:!0})],sg.prototype,"date",void 0);Ry.__decorate([(0,cl.AsnProp)({type:eEt.OtherKeyAttribute,optional:!0})],sg.prototype,"other",void 0);var Py=class{version=jre.CMSVersion.v4;kekid=new sg;keyEncryptionAlgorithm=new jre.KeyEncryptionAlgorithmIdentifier;encryptedKey=new cl.OctetString;constructor(e={}){Object.assign(this,e)}};Fw.KEKRecipientInfo=Py;Ry.__decorate([(0,cl.AsnProp)({type:cl.AsnPropTypes.Integer})],Py.prototype,"version",void 0);Ry.__decorate([(0,cl.AsnProp)({type:sg})],Py.prototype,"kekid",void 0);Ry.__decorate([(0,cl.AsnProp)({type:jre.KeyEncryptionAlgorithmIdentifier})],Py.prototype,"keyEncryptionAlgorithm",void 0);Ry.__decorate([(0,cl.AsnProp)({type:cl.OctetString})],Py.prototype,"encryptedKey",void 0)});var zre=L(O7=>{"use strict";Object.defineProperty(O7,"__esModule",{value:!0});O7.PasswordRecipientInfo=void 0;var R7=(at(),He(st)),Oy=bt(),P7=dh(),Ny=class{version=P7.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new P7.KeyEncryptionAlgorithmIdentifier;encryptedKey=new Oy.OctetString;constructor(e={}){Object.assign(this,e)}};O7.PasswordRecipientInfo=Ny;R7.__decorate([(0,Oy.AsnProp)({type:Oy.AsnPropTypes.Integer})],Ny.prototype,"version",void 0);R7.__decorate([(0,Oy.AsnProp)({type:P7.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],Ny.prototype,"keyDerivationAlgorithm",void 0);R7.__decorate([(0,Oy.AsnProp)({type:P7.KeyEncryptionAlgorithmIdentifier})],Ny.prototype,"keyEncryptionAlgorithm",void 0);R7.__decorate([(0,Oy.AsnProp)({type:Oy.OctetString})],Ny.prototype,"encryptedKey",void 0)});var Wre=L(By=>{"use strict";Object.defineProperty(By,"__esModule",{value:!0});By.RecipientInfo=By.OtherRecipientInfo=void 0;var og=(at(),He(st)),Wf=bt(),tEt=Mre(),rEt=$re(),nEt=qre(),iEt=zre(),Pw=class{oriType="";oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};By.OtherRecipientInfo=Pw;og.__decorate([(0,Wf.AsnProp)({type:Wf.AsnPropTypes.ObjectIdentifier})],Pw.prototype,"oriType",void 0);og.__decorate([(0,Wf.AsnProp)({type:Wf.AsnPropTypes.Any})],Pw.prototype,"oriValue",void 0);var ag=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};By.RecipientInfo=ag;og.__decorate([(0,Wf.AsnProp)({type:rEt.KeyTransRecipientInfo,optional:!0})],ag.prototype,"ktri",void 0);og.__decorate([(0,Wf.AsnProp)({type:tEt.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],ag.prototype,"kari",void 0);og.__decorate([(0,Wf.AsnProp)({type:nEt.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],ag.prototype,"kekri",void 0);og.__decorate([(0,Wf.AsnProp)({type:iEt.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],ag.prototype,"pwri",void 0);og.__decorate([(0,Wf.AsnProp)({type:Pw,context:4,implicit:!0,optional:!0})],ag.prototype,"ori",void 0);By.RecipientInfo=ag=og.__decorate([(0,Wf.AsnType)({type:Wf.AsnTypeTypes.Choice})],ag)});var Kre=L(m3=>{"use strict";var Hre;Object.defineProperty(m3,"__esModule",{value:!0});m3.RecipientInfos=void 0;var sEt=(at(),He(st)),Vre=bt(),aEt=Wre(),Gre=Hre=class extends Vre.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Hre.prototype)}};m3.RecipientInfos=Gre;m3.RecipientInfos=Gre=Hre=sEt.__decorate([(0,Vre.AsnType)({type:Vre.AsnTypeTypes.Set,itemType:aEt.RecipientInfo})],Gre)});var N7=L(ho=>{"use strict";var Zre;Object.defineProperty(ho,"__esModule",{value:!0});ho.RevocationInfoChoices=ho.RevocationInfoChoice=ho.OtherRevocationInfoFormat=ho.id_ri_scvp=ho.id_ri_ocsp_response=ho.id_ri=void 0;var x3=(at(),He(st)),mh=bt(),oEt=hi();ho.id_ri=`${oEt.id_pkix}.16`;ho.id_ri_ocsp_response=`${ho.id_ri}.2`;ho.id_ri_scvp=`${ho.id_ri}.4`;var Uy=class{otherRevInfoFormat="";otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};ho.OtherRevocationInfoFormat=Uy;x3.__decorate([(0,mh.AsnProp)({type:mh.AsnPropTypes.ObjectIdentifier})],Uy.prototype,"otherRevInfoFormat",void 0);x3.__decorate([(0,mh.AsnProp)({type:mh.AsnPropTypes.Any})],Uy.prototype,"otherRevInfo",void 0);var g3=class{other=new Uy;constructor(e={}){Object.assign(this,e)}};ho.RevocationInfoChoice=g3;x3.__decorate([(0,mh.AsnProp)({type:Uy,context:1,implicit:!0})],g3.prototype,"other",void 0);ho.RevocationInfoChoice=g3=x3.__decorate([(0,mh.AsnType)({type:mh.AsnTypeTypes.Choice})],g3);var Xre=Zre=class extends mh.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Zre.prototype)}};ho.RevocationInfoChoices=Xre;ho.RevocationInfoChoices=Xre=Zre=x3.__decorate([(0,mh.AsnType)({type:mh.AsnTypeTypes.Set,itemType:g3})],Xre)});var Yre=L(B7=>{"use strict";Object.defineProperty(B7,"__esModule",{value:!0});B7.OriginatorInfo=void 0;var oIe=(at(),He(st)),cIe=bt(),cEt=C7(),uEt=N7(),y3=class{certs;crls;constructor(e={}){Object.assign(this,e)}};B7.OriginatorInfo=y3;oIe.__decorate([(0,cIe.AsnProp)({type:cEt.CertificateSet,context:0,implicit:!0,optional:!0})],y3.prototype,"certs",void 0);oIe.__decorate([(0,cIe.AsnProp)({type:uEt.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],y3.prototype,"crls",void 0)});var fIe=L(My=>{"use strict";var Jre;Object.defineProperty(My,"__esModule",{value:!0});My.EnvelopedData=My.UnprotectedAttributes=void 0;var Rw=(at(),He(st)),V0=bt(),lEt=dh(),fEt=r7(),uIe=Kre(),dEt=Yre(),lIe=Ore(),U7=Jre=class extends V0.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Jre.prototype)}};My.UnprotectedAttributes=U7;My.UnprotectedAttributes=U7=Jre=Rw.__decorate([(0,V0.AsnType)({type:V0.AsnTypeTypes.Set,itemType:fEt.Attribute})],U7);var cg=class{version=lEt.CMSVersion.v0;originatorInfo;recipientInfos=new uIe.RecipientInfos;encryptedContentInfo=new lIe.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};My.EnvelopedData=cg;Rw.__decorate([(0,V0.AsnProp)({type:V0.AsnPropTypes.Integer})],cg.prototype,"version",void 0);Rw.__decorate([(0,V0.AsnProp)({type:dEt.OriginatorInfo,context:0,implicit:!0,optional:!0})],cg.prototype,"originatorInfo",void 0);Rw.__decorate([(0,V0.AsnProp)({type:uIe.RecipientInfos})],cg.prototype,"recipientInfos",void 0);Rw.__decorate([(0,V0.AsnProp)({type:lIe.EncryptedContentInfo})],cg.prototype,"encryptedContentInfo",void 0);Rw.__decorate([(0,V0.AsnProp)({type:U7,context:1,implicit:!0,optional:!0})],cg.prototype,"unprotectedAttrs",void 0)});var dIe=L(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.id_authData=gc.id_encryptedData=gc.id_digestedData=gc.id_envelopedData=gc.id_signedData=gc.id_data=gc.id_ct_contentInfo=void 0;gc.id_ct_contentInfo="1.2.840.113549.1.9.16.1.6";gc.id_data="1.2.840.113549.1.7.1";gc.id_signedData="1.2.840.113549.1.7.2";gc.id_envelopedData="1.2.840.113549.1.7.3";gc.id_digestedData="1.2.840.113549.1.7.5";gc.id_encryptedData="1.2.840.113549.1.7.6";gc.id_authData="1.2.840.113549.1.9.16.1.2"});var gIe=L(Ly=>{"use strict";var Qre;Object.defineProperty(Ly,"__esModule",{value:!0});Ly.SignedData=Ly.DigestAlgorithmIdentifiers=void 0;var $y=(at(),He(st)),gh=bt(),hEt=C7(),hIe=dh(),pIe=Rre(),pEt=N7(),mIe=n7(),v3=Qre=class extends gh.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Qre.prototype)}};Ly.DigestAlgorithmIdentifiers=v3;Ly.DigestAlgorithmIdentifiers=v3=Qre=$y.__decorate([(0,gh.AsnType)({type:gh.AsnTypeTypes.Set,itemType:hIe.DigestAlgorithmIdentifier})],v3);var G0=class{version=hIe.CMSVersion.v0;digestAlgorithms=new v3;encapContentInfo=new pIe.EncapsulatedContentInfo;certificates;crls;signerInfos=new mIe.SignerInfos;constructor(e={}){Object.assign(this,e)}};Ly.SignedData=G0;$y.__decorate([(0,gh.AsnProp)({type:gh.AsnPropTypes.Integer})],G0.prototype,"version",void 0);$y.__decorate([(0,gh.AsnProp)({type:v3})],G0.prototype,"digestAlgorithms",void 0);$y.__decorate([(0,gh.AsnProp)({type:pIe.EncapsulatedContentInfo})],G0.prototype,"encapContentInfo",void 0);$y.__decorate([(0,gh.AsnProp)({type:hEt.CertificateSet,context:0,implicit:!0,optional:!0})],G0.prototype,"certificates",void 0);$y.__decorate([(0,gh.AsnProp)({type:pEt.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],G0.prototype,"crls",void 0);$y.__decorate([(0,gh.AsnProp)({type:mIe.SignerInfos})],G0.prototype,"signerInfos",void 0)});var b3=L(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var va=(at(),He(st));va.__exportStar(F5e(),ea);va.__exportStar(r7(),ea);va.__exportStar(C7(),ea);va.__exportStar(nIe(),ea);va.__exportStar(Rre(),ea);va.__exportStar(Ore(),ea);va.__exportStar(fIe(),ea);va.__exportStar(H4(),ea);va.__exportStar(qre(),ea);va.__exportStar(Mre(),ea);va.__exportStar($re(),ea);va.__exportStar(dIe(),ea);va.__exportStar(Yre(),ea);va.__exportStar(zre(),ea);va.__exportStar(Wre(),ea);va.__exportStar(Kre(),ea);va.__exportStar(N7(),ea);va.__exportStar(gIe(),ea);va.__exportStar($te(),ea);va.__exportStar(n7(),ea);va.__exportStar(dh(),ea)});var ene=L(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.id_sect571r1=ln.id_sect571k1=ln.id_secp521r1=ln.id_sect409r1=ln.id_sect409k1=ln.id_secp384r1=ln.id_sect283r1=ln.id_sect283k1=ln.id_secp256r1=ln.id_sect233r1=ln.id_sect233k1=ln.id_secp224r1=ln.id_sect163r2=ln.id_sect163k1=ln.id_secp192r1=ln.id_ecdsaWithSHA512=ln.id_ecdsaWithSHA384=ln.id_ecdsaWithSHA256=ln.id_ecdsaWithSHA224=ln.id_ecdsaWithSHA1=ln.id_ecMQV=ln.id_ecDH=ln.id_ecPublicKey=void 0;ln.id_ecPublicKey="1.2.840.10045.2.1";ln.id_ecDH="1.3.132.1.12";ln.id_ecMQV="1.3.132.1.13";ln.id_ecdsaWithSHA1="1.2.840.10045.4.1";ln.id_ecdsaWithSHA224="1.2.840.10045.4.3.1";ln.id_ecdsaWithSHA256="1.2.840.10045.4.3.2";ln.id_ecdsaWithSHA384="1.2.840.10045.4.3.3";ln.id_ecdsaWithSHA512="1.2.840.10045.4.3.4";ln.id_secp192r1="1.2.840.10045.3.1.1";ln.id_sect163k1="1.3.132.0.1";ln.id_sect163r2="1.3.132.0.15";ln.id_secp224r1="1.3.132.0.33";ln.id_sect233k1="1.3.132.0.26";ln.id_sect233r1="1.3.132.0.27";ln.id_secp256r1="1.2.840.10045.3.1.7";ln.id_sect283k1="1.3.132.0.16";ln.id_sect283r1="1.3.132.0.17";ln.id_secp384r1="1.3.132.0.34";ln.id_sect409k1="1.3.132.0.36";ln.id_sect409r1="1.3.132.0.37";ln.id_secp521r1="1.3.132.0.35";ln.id_sect571k1="1.3.132.0.38";ln.id_sect571r1="1.3.132.0.39"});var xIe=L(Ql=>{"use strict";Object.defineProperty(Ql,"__esModule",{value:!0});Ql.ecdsaWithSHA512=Ql.ecdsaWithSHA384=Ql.ecdsaWithSHA256=Ql.ecdsaWithSHA224=Ql.ecdsaWithSHA1=void 0;var mEt=(at(),He(st)),gEt=hi(),_3=mEt.__importStar(ene());function w3(t){return new gEt.AlgorithmIdentifier({algorithm:t})}Ql.ecdsaWithSHA1=w3(_3.id_ecdsaWithSHA1);Ql.ecdsaWithSHA224=w3(_3.id_ecdsaWithSHA224);Ql.ecdsaWithSHA256=w3(_3.id_ecdsaWithSHA256);Ql.ecdsaWithSHA384=w3(_3.id_ecdsaWithSHA384);Ql.ecdsaWithSHA512=w3(_3.id_ecdsaWithSHA512)});var nne=L(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.SpecifiedECDomain=Bo.ECPVer=Bo.Curve=Bo.FieldElement=Bo.ECPoint=Bo.FieldID=void 0;var Au=(at(),He(st)),ts=bt(),Ow=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};Bo.FieldID=Ow;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.ObjectIdentifier})],Ow.prototype,"fieldType",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Any})],Ow.prototype,"parameters",void 0);Bo.FieldID=Ow=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],Ow);var M7=class extends ts.OctetString{};Bo.ECPoint=M7;var tne=class extends ts.OctetString{};Bo.FieldElement=tne;var jy=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};Bo.Curve=jy;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.OctetString})],jy.prototype,"a",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.OctetString})],jy.prototype,"b",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.BitString,optional:!0})],jy.prototype,"seed",void 0);Bo.Curve=jy=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],jy);var rne;(function(t){t[t.ecpVer1=1]="ecpVer1"})(rne||(Bo.ECPVer=rne={}));var K0=class{version=rne.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};Bo.SpecifiedECDomain=K0;Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer})],K0.prototype,"version",void 0);Au.__decorate([(0,ts.AsnProp)({type:Ow})],K0.prototype,"fieldID",void 0);Au.__decorate([(0,ts.AsnProp)({type:jy})],K0.prototype,"curve",void 0);Au.__decorate([(0,ts.AsnProp)({type:M7})],K0.prototype,"base",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer,converter:ts.AsnIntegerArrayBufferConverter})],K0.prototype,"order",void 0);Au.__decorate([(0,ts.AsnProp)({type:ts.AsnPropTypes.Integer,optional:!0})],K0.prototype,"cofactor",void 0);Bo.SpecifiedECDomain=K0=Au.__decorate([(0,ts.AsnType)({type:ts.AsnTypeTypes.Sequence})],K0)});var ine=L(S3=>{"use strict";Object.defineProperty(S3,"__esModule",{value:!0});S3.ECParameters=void 0;var L7=(at(),He(st)),qy=bt(),xEt=nne(),Nw=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};S3.ECParameters=Nw;L7.__decorate([(0,qy.AsnProp)({type:qy.AsnPropTypes.ObjectIdentifier})],Nw.prototype,"namedCurve",void 0);L7.__decorate([(0,qy.AsnProp)({type:qy.AsnPropTypes.Null})],Nw.prototype,"implicitCurve",void 0);L7.__decorate([(0,qy.AsnProp)({type:xEt.SpecifiedECDomain})],Nw.prototype,"specifiedCurve",void 0);S3.ECParameters=Nw=L7.__decorate([(0,qy.AsnType)({type:qy.AsnTypeTypes.Choice})],Nw)});var yIe=L(j7=>{"use strict";Object.defineProperty(j7,"__esModule",{value:!0});j7.ECPrivateKey=void 0;var $7=(at(),He(st)),ug=bt(),yEt=ine(),zy=class{version=1;privateKey=new ug.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};j7.ECPrivateKey=zy;$7.__decorate([(0,ug.AsnProp)({type:ug.AsnPropTypes.Integer})],zy.prototype,"version",void 0);$7.__decorate([(0,ug.AsnProp)({type:ug.OctetString})],zy.prototype,"privateKey",void 0);$7.__decorate([(0,ug.AsnProp)({type:yEt.ECParameters,context:0,optional:!0})],zy.prototype,"parameters",void 0);$7.__decorate([(0,ug.AsnProp)({type:ug.AsnPropTypes.BitString,context:1,optional:!0})],zy.prototype,"publicKey",void 0)});var bIe=L(q7=>{"use strict";Object.defineProperty(q7,"__esModule",{value:!0});q7.ECDSASigValue=void 0;var vIe=(at(),He(st)),Bw=bt(),A3=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};q7.ECDSASigValue=A3;vIe.__decorate([(0,Bw.AsnProp)({type:Bw.AsnPropTypes.Integer,converter:Bw.AsnIntegerArrayBufferConverter})],A3.prototype,"r",void 0);vIe.__decorate([(0,Bw.AsnProp)({type:Bw.AsnPropTypes.Integer,converter:Bw.AsnIntegerArrayBufferConverter})],A3.prototype,"s",void 0)});var _Ie=L(lg=>{"use strict";Object.defineProperty(lg,"__esModule",{value:!0});var Uw=(at(),He(st));Uw.__exportStar(xIe(),lg);Uw.__exportStar(ine(),lg);Uw.__exportStar(yIe(),lg);Uw.__exportStar(bIe(),lg);Uw.__exportStar(ene(),lg);Uw.__exportStar(nne(),lg)});var E3=L(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.id_mgf1=Sr.id_md5=Sr.id_md2=Sr.id_sha512_256=Sr.id_sha512_224=Sr.id_sha512=Sr.id_sha384=Sr.id_sha256=Sr.id_sha224=Sr.id_sha1=Sr.id_sha512_256WithRSAEncryption=Sr.id_sha512_224WithRSAEncryption=Sr.id_sha512WithRSAEncryption=Sr.id_sha384WithRSAEncryption=Sr.id_sha256WithRSAEncryption=Sr.id_ssha224WithRSAEncryption=Sr.id_sha224WithRSAEncryption=Sr.id_sha1WithRSAEncryption=Sr.id_md5WithRSAEncryption=Sr.id_md2WithRSAEncryption=Sr.id_RSASSA_PSS=Sr.id_pSpecified=Sr.id_RSAES_OAEP=Sr.id_rsaEncryption=Sr.id_pkcs_1=void 0;Sr.id_pkcs_1="1.2.840.113549.1.1";Sr.id_rsaEncryption=`${Sr.id_pkcs_1}.1`;Sr.id_RSAES_OAEP=`${Sr.id_pkcs_1}.7`;Sr.id_pSpecified=`${Sr.id_pkcs_1}.9`;Sr.id_RSASSA_PSS=`${Sr.id_pkcs_1}.10`;Sr.id_md2WithRSAEncryption=`${Sr.id_pkcs_1}.2`;Sr.id_md5WithRSAEncryption=`${Sr.id_pkcs_1}.4`;Sr.id_sha1WithRSAEncryption=`${Sr.id_pkcs_1}.5`;Sr.id_sha224WithRSAEncryption=`${Sr.id_pkcs_1}.14`;Sr.id_ssha224WithRSAEncryption=Sr.id_sha224WithRSAEncryption;Sr.id_sha256WithRSAEncryption=`${Sr.id_pkcs_1}.11`;Sr.id_sha384WithRSAEncryption=`${Sr.id_pkcs_1}.12`;Sr.id_sha512WithRSAEncryption=`${Sr.id_pkcs_1}.13`;Sr.id_sha512_224WithRSAEncryption=`${Sr.id_pkcs_1}.15`;Sr.id_sha512_256WithRSAEncryption=`${Sr.id_pkcs_1}.16`;Sr.id_sha1="1.3.14.3.2.26";Sr.id_sha224="2.16.840.1.101.3.4.2.4";Sr.id_sha256="2.16.840.1.101.3.4.2.1";Sr.id_sha384="2.16.840.1.101.3.4.2.2";Sr.id_sha512="2.16.840.1.101.3.4.2.3";Sr.id_sha512_224="2.16.840.1.101.3.4.2.5";Sr.id_sha512_256="2.16.840.1.101.3.4.2.6";Sr.id_md2="1.2.840.113549.2.2";Sr.id_md5="1.2.840.113549.2.5";Sr.id_mgf1=`${Sr.id_pkcs_1}.8`});var z7=L(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.sha512_256WithRSAEncryption=xn.sha512_224WithRSAEncryption=xn.sha512WithRSAEncryption=xn.sha384WithRSAEncryption=xn.sha256WithRSAEncryption=xn.sha224WithRSAEncryption=xn.sha1WithRSAEncryption=xn.md5WithRSAEncryption=xn.md2WithRSAEncryption=xn.rsaEncryption=xn.pSpecifiedEmpty=xn.mgf1SHA1=xn.sha512_256=xn.sha512_224=xn.sha512=xn.sha384=xn.sha256=xn.sha224=xn.sha1=xn.md4=xn.md2=void 0;var vEt=(at(),He(st)),sne=bt(),ane=hi(),ba=vEt.__importStar(E3());function Ga(t){return new ane.AlgorithmIdentifier({algorithm:t,parameters:null})}xn.md2=Ga(ba.id_md2);xn.md4=Ga(ba.id_md5);xn.sha1=Ga(ba.id_sha1);xn.sha224=Ga(ba.id_sha224);xn.sha256=Ga(ba.id_sha256);xn.sha384=Ga(ba.id_sha384);xn.sha512=Ga(ba.id_sha512);xn.sha512_224=Ga(ba.id_sha512_224);xn.sha512_256=Ga(ba.id_sha512_256);xn.mgf1SHA1=new ane.AlgorithmIdentifier({algorithm:ba.id_mgf1,parameters:sne.AsnConvert.serialize(xn.sha1)});xn.pSpecifiedEmpty=new ane.AlgorithmIdentifier({algorithm:ba.id_pSpecified,parameters:sne.AsnConvert.serialize(sne.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});xn.rsaEncryption=Ga(ba.id_rsaEncryption);xn.md2WithRSAEncryption=Ga(ba.id_md2WithRSAEncryption);xn.md5WithRSAEncryption=Ga(ba.id_md5WithRSAEncryption);xn.sha1WithRSAEncryption=Ga(ba.id_sha1WithRSAEncryption);xn.sha224WithRSAEncryption=Ga(ba.id_sha512_224WithRSAEncryption);xn.sha256WithRSAEncryption=Ga(ba.id_sha512_256WithRSAEncryption);xn.sha384WithRSAEncryption=Ga(ba.id_sha384WithRSAEncryption);xn.sha512WithRSAEncryption=Ga(ba.id_sha512WithRSAEncryption);xn.sha512_224WithRSAEncryption=Ga(ba.id_sha512_224WithRSAEncryption);xn.sha512_256WithRSAEncryption=Ga(ba.id_sha512_256WithRSAEncryption)});var SIe=L(Lw=>{"use strict";Object.defineProperty(Lw,"__esModule",{value:!0});Lw.RSAES_OAEP=Lw.RsaEsOaepParams=void 0;var one=(at(),He(st)),T3=bt(),Wy=hi(),wIe=E3(),Mw=z7(),Hy=class{hashAlgorithm=new Wy.AlgorithmIdentifier(Mw.sha1);maskGenAlgorithm=new Wy.AlgorithmIdentifier({algorithm:wIe.id_mgf1,parameters:T3.AsnConvert.serialize(Mw.sha1)});pSourceAlgorithm=new Wy.AlgorithmIdentifier(Mw.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};Lw.RsaEsOaepParams=Hy;one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:0,defaultValue:Mw.sha1})],Hy.prototype,"hashAlgorithm",void 0);one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:1,defaultValue:Mw.mgf1SHA1})],Hy.prototype,"maskGenAlgorithm",void 0);one.__decorate([(0,T3.AsnProp)({type:Wy.AlgorithmIdentifier,context:2,defaultValue:Mw.pSpecifiedEmpty})],Hy.prototype,"pSourceAlgorithm",void 0);Lw.RSAES_OAEP=new Wy.AlgorithmIdentifier({algorithm:wIe.id_RSAES_OAEP,parameters:T3.AsnConvert.serialize(new Hy)})});var EIe=L($w=>{"use strict";Object.defineProperty($w,"__esModule",{value:!0});$w.RSASSA_PSS=$w.RsaSaPssParams=void 0;var H7=(at(),He(st)),fg=bt(),C3=hi(),AIe=E3(),W7=z7(),dg=class{hashAlgorithm=new C3.AlgorithmIdentifier(W7.sha1);maskGenAlgorithm=new C3.AlgorithmIdentifier({algorithm:AIe.id_mgf1,parameters:fg.AsnConvert.serialize(W7.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};$w.RsaSaPssParams=dg;H7.__decorate([(0,fg.AsnProp)({type:C3.AlgorithmIdentifier,context:0,defaultValue:W7.sha1})],dg.prototype,"hashAlgorithm",void 0);H7.__decorate([(0,fg.AsnProp)({type:C3.AlgorithmIdentifier,context:1,defaultValue:W7.mgf1SHA1})],dg.prototype,"maskGenAlgorithm",void 0);H7.__decorate([(0,fg.AsnProp)({type:fg.AsnPropTypes.Integer,context:2,defaultValue:20})],dg.prototype,"saltLength",void 0);H7.__decorate([(0,fg.AsnProp)({type:fg.AsnPropTypes.Integer,context:3,defaultValue:1})],dg.prototype,"trailerField",void 0);$w.RSASSA_PSS=new C3.AlgorithmIdentifier({algorithm:AIe.id_RSASSA_PSS,parameters:fg.AsnConvert.serialize(new dg)})});var kIe=L(G7=>{"use strict";Object.defineProperty(G7,"__esModule",{value:!0});G7.DigestInfo=void 0;var TIe=(at(),He(st)),CIe=hi(),V7=bt(),k3=class{digestAlgorithm=new CIe.AlgorithmIdentifier;digest=new V7.OctetString;constructor(e={}){Object.assign(this,e)}};G7.DigestInfo=k3;TIe.__decorate([(0,V7.AsnProp)({type:CIe.AlgorithmIdentifier})],k3.prototype,"digestAlgorithm",void 0);TIe.__decorate([(0,V7.AsnProp)({type:V7.OctetString})],k3.prototype,"digest",void 0)});var DIe=L(D3=>{"use strict";Object.defineProperty(D3,"__esModule",{value:!0});var cne=(at(),He(st));cne.__exportStar(SIe(),D3);cne.__exportStar(EIe(),D3);cne.__exportStar(kIe(),D3)});var fne=L(Gy=>{"use strict";var une;Object.defineProperty(Gy,"__esModule",{value:!0});Gy.OtherPrimeInfos=Gy.OtherPrimeInfo=void 0;var K7=(at(),He(st)),ef=bt(),Vy=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Gy.OtherPrimeInfo=Vy;K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"prime",void 0);K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"exponent",void 0);K7.__decorate([(0,ef.AsnProp)({type:ef.AsnPropTypes.Integer,converter:ef.AsnIntegerArrayBufferConverter})],Vy.prototype,"coefficient",void 0);var lne=une=class extends ef.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,une.prototype)}};Gy.OtherPrimeInfos=lne;Gy.OtherPrimeInfos=lne=une=K7.__decorate([(0,ef.AsnType)({type:ef.AsnTypeTypes.Sequence,itemType:Vy})],lne)});var IIe=L(Z7=>{"use strict";Object.defineProperty(Z7,"__esModule",{value:!0});Z7.RSAPrivateKey=void 0;var xh=(at(),He(st)),cs=bt(),bEt=fne(),ul=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};Z7.RSAPrivateKey=ul;xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer})],ul.prototype,"version",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"modulus",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"publicExponent",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"privateExponent",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"prime1",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"prime2",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"exponent1",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"exponent2",void 0);xh.__decorate([(0,cs.AsnProp)({type:cs.AsnPropTypes.Integer,converter:cs.AsnIntegerArrayBufferConverter})],ul.prototype,"coefficient",void 0);xh.__decorate([(0,cs.AsnProp)({type:bEt.OtherPrimeInfos,optional:!0})],ul.prototype,"otherPrimeInfos",void 0)});var PIe=L(X7=>{"use strict";Object.defineProperty(X7,"__esModule",{value:!0});X7.RSAPublicKey=void 0;var FIe=(at(),He(st)),jw=bt(),I3=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};X7.RSAPublicKey=I3;FIe.__decorate([(0,jw.AsnProp)({type:jw.AsnPropTypes.Integer,converter:jw.AsnIntegerArrayBufferConverter})],I3.prototype,"modulus",void 0);FIe.__decorate([(0,jw.AsnProp)({type:jw.AsnPropTypes.Integer,converter:jw.AsnIntegerArrayBufferConverter})],I3.prototype,"publicExponent",void 0)});var dne=L(hg=>{"use strict";Object.defineProperty(hg,"__esModule",{value:!0});var qw=(at(),He(st));qw.__exportStar(DIe(),hg);qw.__exportStar(z7(),hg);qw.__exportStar(E3(),hg);qw.__exportStar(fne(),hg);qw.__exportStar(IIe(),hg);qw.__exportStar(PIe(),hg)});var Y7={};yi(Y7,{__assign:()=>pne,__asyncDelegator:()=>REt,__asyncGenerator:()=>PEt,__asyncValues:()=>OEt,__await:()=>F3,__awaiter:()=>TEt,__classPrivateFieldGet:()=>MEt,__classPrivateFieldSet:()=>LEt,__createBinding:()=>kEt,__decorate:()=>SEt,__exportStar:()=>DEt,__extends:()=>_Et,__generator:()=>CEt,__importDefault:()=>UEt,__importStar:()=>BEt,__makeTemplateObject:()=>NEt,__metadata:()=>EEt,__param:()=>AEt,__read:()=>RIe,__rest:()=>wEt,__spread:()=>IEt,__spreadArrays:()=>FEt,__values:()=>mne});function _Et(t,e){hne(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function wEt(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function SEt(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,r,s):a(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function AEt(t,e){return function(r,n){e(r,n,t)}}function EEt(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function TEt(t,e,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function c(p){try{h(n.next(p))}catch(x){a(x)}}function d(p){try{h(n.throw(p))}catch(x){a(x)}}function h(p){p.done?s(p.value):i(p.value).then(c,d)}h((n=n.apply(t,e||[])).next())})}function CEt(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(h){return function(p){return d([h,p])}}function d(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(p){h=[6,p],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function kEt(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}function DEt(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function mne(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function RIe(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return s}function IEt(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(RIe(arguments[e]));return t}function FEt(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],a=0,c=s.length;a<c;a++,i++)n[i]=s[a];return n}function F3(t){return this instanceof F3?(this.v=t,this):new F3(t)}function PEt(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(y){n[y]&&(i[y]=function(v){return new Promise(function(w,S){s.push([y,v,w,S])>1||c(y,v)})})}function c(y,v){try{d(n[y](v))}catch(w){x(s[0][3],w)}}function d(y){y.value instanceof F3?Promise.resolve(y.value.v).then(h,p):x(s[0][2],y)}function h(y){c("next",y)}function p(y){c("throw",y)}function x(y,v){y(v),s.shift(),s.length&&c(s[0][0],s[0][1])}}function REt(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(a){return(r=!r)?{value:F3(t[i](a)),done:i==="return"}:s?s(a):a}:s}}function OEt(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof mne=="function"?mne(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(a){return new Promise(function(c,d){a=t[s](a),i(c,d,a.done,a.value)})}}function i(s,a,c,d){Promise.resolve(d).then(function(h){s({value:h,done:c})},a)}}function NEt(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function BEt(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function UEt(t){return t&&t.__esModule?t:{default:t}}function MEt(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function LEt(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var hne,pne,J7=ce(()=>{hne=function(t,e){return hne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},hne(t,e)};pne=function(){return pne=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},pne.apply(this,arguments)}});var yne=L(xne=>{"use strict";Object.defineProperty(xne,"__esModule",{value:!0});var gne;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(gne||(gne={}));xne.default=gne});var OIe=L(vne=>{"use strict";Object.defineProperty(vne,"__esModule",{value:!0});var $Et=yne();Object.defineProperty(vne,"Lifecycle",{enumerable:!0,get:function(){return $Et.default}})});var Ky=L(Hf=>{"use strict";Object.defineProperty(Hf,"__esModule",{value:!0});Hf.defineInjectionTokenMetadata=Hf.getParamInfo=Hf.INJECTION_TOKEN_METADATA_KEY=void 0;Hf.INJECTION_TOKEN_METADATA_KEY="injectionTokens";function jEt(t){let e=Reflect.getMetadata("design:paramtypes",t)||[],r=Reflect.getOwnMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(n=>{e[+n]=r[n]}),e}Hf.getParamInfo=jEt;function qEt(t,e){return function(r,n,i){let s=Reflect.getOwnMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,r)||{};s[i]=e?{token:t,transform:e.transformToken,transformArgs:e.args||[]}:t,Reflect.defineMetadata(Hf.INJECTION_TOKEN_METADATA_KEY,s,r)}}Hf.defineInjectionTokenMetadata=qEt});var bne=L(Q7=>{"use strict";Object.defineProperty(Q7,"__esModule",{value:!0});Q7.isClassProvider=void 0;function zEt(t){return!!t.useClass}Q7.isClassProvider=zEt});var _ne=L(eB=>{"use strict";Object.defineProperty(eB,"__esModule",{value:!0});eB.isFactoryProvider=void 0;function WEt(t){return!!t.useFactory}eB.isFactoryProvider=WEt});var rB=L(zw=>{"use strict";Object.defineProperty(zw,"__esModule",{value:!0});zw.delay=zw.DelayedConstructor=void 0;var tB=class{constructor(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}createProxy(e){let r={},n=!1,i,s=()=>(n||(i=e(this.wrap()),n=!0),i);return new Proxy(r,this.createHandler(s))}createHandler(e){let r={},n=i=>{r[i]=(...s)=>{s[0]=e();let a=Reflect[i];return a(...s)}};return this.reflectMethods.forEach(n),r}};zw.DelayedConstructor=tB;function HEt(t){if(typeof t>"u")throw new Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new tB(t)}zw.delay=HEt});var nB=L(yh=>{"use strict";Object.defineProperty(yh,"__esModule",{value:!0});yh.isConstructorToken=yh.isTransformDescriptor=yh.isTokenDescriptor=yh.isNormalToken=void 0;var VEt=rB();function GEt(t){return typeof t=="string"||typeof t=="symbol"}yh.isNormalToken=GEt;function KEt(t){return typeof t=="object"&&"token"in t&&"multiple"in t}yh.isTokenDescriptor=KEt;function ZEt(t){return typeof t=="object"&&"token"in t&&"transform"in t}yh.isTransformDescriptor=ZEt;function XEt(t){return typeof t=="function"||t instanceof VEt.DelayedConstructor}yh.isConstructorToken=XEt});var wne=L(iB=>{"use strict";Object.defineProperty(iB,"__esModule",{value:!0});iB.isTokenProvider=void 0;function YEt(t){return!!t.useToken}iB.isTokenProvider=YEt});var Sne=L(sB=>{"use strict";Object.defineProperty(sB,"__esModule",{value:!0});sB.isValueProvider=void 0;function JEt(t){return t.useValue!=null}sB.isValueProvider=JEt});var Ane=L(Zy=>{"use strict";Object.defineProperty(Zy,"__esModule",{value:!0});var QEt=bne();Object.defineProperty(Zy,"isClassProvider",{enumerable:!0,get:function(){return QEt.isClassProvider}});var eTt=_ne();Object.defineProperty(Zy,"isFactoryProvider",{enumerable:!0,get:function(){return eTt.isFactoryProvider}});var tTt=nB();Object.defineProperty(Zy,"isNormalToken",{enumerable:!0,get:function(){return tTt.isNormalToken}});var rTt=wne();Object.defineProperty(Zy,"isTokenProvider",{enumerable:!0,get:function(){return rTt.isTokenProvider}});var nTt=Sne();Object.defineProperty(Zy,"isValueProvider",{enumerable:!0,get:function(){return nTt.isValueProvider}})});var NIe=L(aB=>{"use strict";Object.defineProperty(aB,"__esModule",{value:!0});aB.isProvider=void 0;var iTt=bne(),sTt=Sne(),aTt=wne(),oTt=_ne();function cTt(t){return iTt.isClassProvider(t)||sTt.isValueProvider(t)||aTt.isTokenProvider(t)||oTt.isFactoryProvider(t)}aB.isProvider=cTt});var Cne=L(Tne=>{"use strict";Object.defineProperty(Tne,"__esModule",{value:!0});var Ene=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let r=this._registryMap.get(e);return r[r.length-1]||null}set(e,r){this.ensure(e),this._registryMap.get(e).push(r)}setAll(e,r){this._registryMap.set(e,r)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}};Tne.default=Ene});var BIe=L(Dne=>{"use strict";Object.defineProperty(Dne,"__esModule",{value:!0});var uTt=Cne(),kne=class extends uTt.default{};Dne.default=kne});var UIe=L(Fne=>{"use strict";Object.defineProperty(Fne,"__esModule",{value:!0});var Ine=class{constructor(){this.scopedResolutions=new Map}};Fne.default=Ine});var Pne=L(oB=>{"use strict";Object.defineProperty(oB,"__esModule",{value:!0});oB.formatErrorCtor=void 0;function lTt(t,e){return t===null?`at position #${e}`:`"${t.split(",")[e].trim()}" at position #${e}`}function fTt(t,e,r=" "){return[t,...e.message.split(`
1004
1013
  `).map(n=>r+n)].join(`
1005
- `)}function dTt(t,e,r){let[,n=null]=t.toString().match(/constructor\(([\w, ]+)\)/)||[],i=lTt(n,e);return fTt(`Cannot inject the dependency ${i} of "${t.name}" constructor. Reason:`,r)}oB.formatErrorCtor=dTt});var MIe=L(cB=>{"use strict";Object.defineProperty(cB,"__esModule",{value:!0});cB.isDisposable=void 0;function hTt(t){return!(typeof t.dispose!="function"||t.dispose.length>0)}cB.isDisposable=hTt});var $Ie=L(Xy=>{"use strict";Object.defineProperty(Xy,"__esModule",{value:!0});Xy.PostResolutionInterceptors=Xy.PreResolutionInterceptors=void 0;var LIe=Cne(),uB=class extends LIe.default{};Xy.PreResolutionInterceptors=uB;var lB=class extends LIe.default{};Xy.PostResolutionInterceptors=lB;var Rne=class{constructor(){this.preResolution=new uB,this.postResolution=new lB}};Xy.default=Rne});var pg=L(Z0=>{"use strict";Object.defineProperty(Z0,"__esModule",{value:!0});Z0.instance=Z0.typeInfo=void 0;var pTt=(J7(),He(Y7)),$c=Ane(),mTt=NIe(),fB=nB(),gTt=BIe(),Eu=yne(),dB=UIe(),xTt=Pne(),yTt=rB(),vTt=MIe(),bTt=$Ie();Z0.typeInfo=new Map;var One=class t{constructor(e){this.parent=e,this._registry=new gTt.default,this.interceptors=new bTt.default,this.disposed=!1,this.disposables=new Set}register(e,r,n={lifecycle:Eu.default.Transient}){this.ensureNotDisposed();let i;if(mTt.isProvider(r)?i=r:i={useClass:r},$c.isTokenProvider(i)){let s=[e],a=i;for(;a!=null;){let c=a.useToken;if(s.includes(c))throw new Error(`Token registration cycle detected! ${[...s,c].join(" -> ")}`);s.push(c);let d=this._registry.get(c);d&&$c.isTokenProvider(d.provider)?a=d.provider:a=null}}if((n.lifecycle===Eu.default.Singleton||n.lifecycle==Eu.default.ContainerScoped||n.lifecycle==Eu.default.ResolutionScoped)&&($c.isValueProvider(i)||$c.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Eu.default[n.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:n}),this}registerType(e,r){return this.ensureNotDisposed(),$c.isNormalToken(r)?this.register(e,{useToken:r}):this.register(e,{useClass:r})}registerInstance(e,r){return this.ensureNotDisposed(),this.register(e,{useValue:r})}registerSingleton(e,r){if(this.ensureNotDisposed(),$c.isNormalToken(e)){if($c.isNormalToken(r))return this.register(e,{useToken:r},{lifecycle:Eu.default.Singleton});if(r)return this.register(e,{useClass:r},{lifecycle:Eu.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let n=e;return r&&!$c.isNormalToken(r)&&(n=r),this.register(e,{useClass:n},{lifecycle:Eu.default.Singleton})}resolve(e,r=new dB.default,n=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&$c.isNormalToken(e)){if(n)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,r);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(fB.isConstructorToken(e)){let s=this.construct(e,r);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,r){if(this.interceptors.preResolution.has(e)){let n=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&n.push(i),i.callback(e,r);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,r,n){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,r,n);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,r){if(this.ensureNotDisposed(),e.options.lifecycle===Eu.default.ResolutionScoped&&r.scopedResolutions.has(e))return r.scopedResolutions.get(e);let n=e.options.lifecycle===Eu.default.Singleton,i=e.options.lifecycle===Eu.default.ContainerScoped,s=n||i,a;return $c.isValueProvider(e.provider)?a=e.provider.useValue:$c.isTokenProvider(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,r)):this.resolve(e.provider.useToken,r):$c.isClassProvider(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,r)):this.construct(e.provider.useClass,r):$c.isFactoryProvider(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,r),e.options.lifecycle===Eu.default.ResolutionScoped&&r.scopedResolutions.set(e,a),a}resolveAll(e,r=new dB.default,n=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&$c.isNormalToken(e)){if(n)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let a=i.map(c=>this.resolveRegistration(c,r));return this.executePostResolutionInterceptor(e,a,"All"),a}let s=[this.construct(e,r)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,r=!1){return this.ensureNotDisposed(),this._registry.has(e)||r&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,r]of this._registry.entries())this._registry.setAll(e,r.filter(n=>!$c.isValueProvider(n.provider)).map(n=>(n.instance=void 0,n)))}createChildContainer(){this.ensureNotDisposed();let e=new t(this);for(let[r,n]of this._registry.entries())n.some(({options:i})=>i.lifecycle===Eu.default.ContainerScoped)&&e._registry.setAll(r,n.map(i=>i.options.lifecycle===Eu.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,r,n={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:r,options:n})}afterResolution(e,r,n={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:r,options:n})}dispose(){return pTt.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(r=>{let n=r.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,r){if(e instanceof yTt.DelayedConstructor)return e.createProxy(i=>this.resolve(i,r));let n=(()=>{let i=Z0.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(r,e));return new e(...s)})();return vTt.isDisposable(n)&&this.disposables.add(n),n}resolveParams(e,r){return(n,i)=>{try{return fB.isTokenDescriptor(n)?fB.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new dB.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new dB.default,n.isOptional):this.resolve(n.token,e,n.isOptional):fB.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(s){throw new Error(xTt.formatErrorCtor(r,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Z0.instance=new One;Z0.default=Z0.instance});var jIe=L(Bne=>{"use strict";Object.defineProperty(Bne,"__esModule",{value:!0});var _Tt=Ky(),X0=pg(),Nne=nB(),wTt=Pne();function STt(){return function(t){let e=_Tt.getParamInfo(t);return class extends t{constructor(...r){super(...r.concat(e.slice(r.length).map((n,i)=>{try{return Nne.isTokenDescriptor(n)?Nne.isTransformDescriptor(n)?n.multiple?X0.instance.resolve(n.transform).transform(X0.instance.resolveAll(n.token),...n.transformArgs):X0.instance.resolve(n.transform).transform(X0.instance.resolve(n.token),...n.transformArgs):n.multiple?X0.instance.resolveAll(n.token):X0.instance.resolve(n.token):Nne.isTransformDescriptor(n)?X0.instance.resolve(n.transform).transform(X0.instance.resolve(n.token),...n.transformArgs):X0.instance.resolve(n)}catch(s){let a=i+r.length;throw new Error(wTt.formatErrorCtor(t,a,s))}})))}}}}Bne.default=STt});var qIe=L(Une=>{"use strict";Object.defineProperty(Une,"__esModule",{value:!0});var ATt=Ky();function ETt(t,e){let r={token:t,multiple:!1,isOptional:e&&e.isOptional};return ATt.defineInjectionTokenMetadata(r)}Une.default=ETt});var hB=L(Mne=>{"use strict";Object.defineProperty(Mne,"__esModule",{value:!0});var TTt=Ky(),CTt=pg(),zIe=pg();function kTt(t){return function(e){CTt.typeInfo.set(e,TTt.getParamInfo(e)),t&&t.token&&(Array.isArray(t.token)?t.token.forEach(r=>{zIe.instance.register(r,e)}):zIe.instance.register(t.token,e))}}Mne.default=kTt});var WIe=L(Lne=>{"use strict";Object.defineProperty(Lne,"__esModule",{value:!0});var DTt=(J7(),He(Y7)),ITt=pg();function FTt(t=[]){return function(e){return t.forEach(r=>{var{token:n,options:i}=r,s=DTt.__rest(r,["token","options"]);return ITt.instance.register(n,s,i)}),e}}Lne.default=FTt});var HIe=L($ne=>{"use strict";Object.defineProperty($ne,"__esModule",{value:!0});var PTt=hB(),RTt=pg();function OTt(){return function(t){PTt.default()(t),RTt.instance.registerSingleton(t)}}$ne.default=OTt});var VIe=L(jne=>{"use strict";Object.defineProperty(jne,"__esModule",{value:!0});var NTt=Ky();function BTt(t,e){let r={token:t,multiple:!0,isOptional:e&&e.isOptional};return NTt.defineInjectionTokenMetadata(r)}jne.default=BTt});var GIe=L(qne=>{"use strict";Object.defineProperty(qne,"__esModule",{value:!0});var UTt=Ky();function MTt(t,e,...r){let n={token:t,multiple:!0,transform:e,transformArgs:r};return UTt.defineInjectionTokenMetadata(n)}qne.default=MTt});var KIe=L(zne=>{"use strict";Object.defineProperty(zne,"__esModule",{value:!0});var LTt=Ky();function $Tt(t,e,...r){return LTt.defineInjectionTokenMetadata(t,{transformToken:e,args:r})}zne.default=$Tt});var ZIe=L(Wne=>{"use strict";Object.defineProperty(Wne,"__esModule",{value:!0});var jTt=hB(),qTt=pg();function zTt(t,e){return function(r){jTt.default()(r),qTt.instance.register(e||r,r,{lifecycle:t})}}Wne.default=zTt});var XIe=L(Vf=>{"use strict";Object.defineProperty(Vf,"__esModule",{value:!0});var WTt=jIe();Object.defineProperty(Vf,"autoInjectable",{enumerable:!0,get:function(){return WTt.default}});var HTt=qIe();Object.defineProperty(Vf,"inject",{enumerable:!0,get:function(){return HTt.default}});var VTt=hB();Object.defineProperty(Vf,"injectable",{enumerable:!0,get:function(){return VTt.default}});var GTt=WIe();Object.defineProperty(Vf,"registry",{enumerable:!0,get:function(){return GTt.default}});var KTt=HIe();Object.defineProperty(Vf,"singleton",{enumerable:!0,get:function(){return KTt.default}});var ZTt=VIe();Object.defineProperty(Vf,"injectAll",{enumerable:!0,get:function(){return ZTt.default}});var XTt=GIe();Object.defineProperty(Vf,"injectAllWithTransform",{enumerable:!0,get:function(){return XTt.default}});var YTt=KIe();Object.defineProperty(Vf,"injectWithTransform",{enumerable:!0,get:function(){return YTt.default}});var JTt=ZIe();Object.defineProperty(Vf,"scoped",{enumerable:!0,get:function(){return JTt.default}})});var YIe=L(Hne=>{"use strict";Object.defineProperty(Hne,"__esModule",{value:!0});function QTt(t){let e;return r=>(e==null&&(e=t(r)),e)}Hne.default=QTt});var JIe=L(Vne=>{"use strict";Object.defineProperty(Vne,"__esModule",{value:!0});function eCt(t){let e=new WeakMap;return r=>{let n=e.get(r);return n==null&&(n=t(r),e.set(r,n)),n}}Vne.default=eCt});var QIe=L(Gne=>{"use strict";Object.defineProperty(Gne,"__esModule",{value:!0});function tCt(t,e,r,n=!0){let i,s;return a=>{let c=t(a);return(!n||s!==c)&&((s=c)?i=a.resolve(e):i=a.resolve(r)),i}}Gne.default=tCt});var eFe=L(P3=>{"use strict";Object.defineProperty(P3,"__esModule",{value:!0});var rCt=YIe();Object.defineProperty(P3,"instanceCachingFactory",{enumerable:!0,get:function(){return rCt.default}});var nCt=JIe();Object.defineProperty(P3,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return nCt.default}});var iCt=QIe();Object.defineProperty(P3,"predicateAwareClassFactory",{enumerable:!0,get:function(){return iCt.default}})});var tFe=L(mg=>{"use strict";Object.defineProperty(mg,"__esModule",{value:!0});var Kne=(J7(),He(Y7));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var sCt=OIe();Object.defineProperty(mg,"Lifecycle",{enumerable:!0,get:function(){return sCt.Lifecycle}});Kne.__exportStar(XIe(),mg);Kne.__exportStar(eFe(),mg);Kne.__exportStar(Ane(),mg);var aCt=rB();Object.defineProperty(mg,"delay",{enumerable:!0,get:function(){return aCt.delay}});var oCt=pg();Object.defineProperty(mg,"container",{enumerable:!0,get:function(){return oCt.instance}})});var Jne=L(Jy=>{"use strict";var Zne;Object.defineProperty(Jy,"__esModule",{value:!0});Jy.PKCS12AttrSet=Jy.PKCS12Attribute=void 0;var Yne=(at(),He(st)),Yy=bt(),Ww=class{attrId="";attrValues=[];constructor(e={}){Object.assign(e)}};Jy.PKCS12Attribute=Ww;Yne.__decorate([(0,Yy.AsnProp)({type:Yy.AsnPropTypes.ObjectIdentifier})],Ww.prototype,"attrId",void 0);Yne.__decorate([(0,Yy.AsnProp)({type:Yy.AsnPropTypes.Any,repeated:"set"})],Ww.prototype,"attrValues",void 0);var Xne=Zne=class extends Yy.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Zne.prototype)}};Jy.PKCS12AttrSet=Xne;Jy.PKCS12AttrSet=Xne=Zne=Yne.__decorate([(0,Yy.AsnType)({type:Yy.AsnTypeTypes.Sequence,itemType:Ww})],Xne)});var rFe=L(R3=>{"use strict";var Qne;Object.defineProperty(R3,"__esModule",{value:!0});R3.AuthenticatedSafe=void 0;var cCt=(at(),He(st)),eie=bt(),uCt=b3(),tie=Qne=class extends eie.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Qne.prototype)}};R3.AuthenticatedSafe=tie;R3.AuthenticatedSafe=tie=Qne=cCt.__decorate([(0,eie.AsnType)({type:eie.AsnTypeTypes.Sequence,itemType:uCt.ContentInfo})],tie)});var rie=L(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.id_bagtypes=mi.id_pbewithSHAAnd40BitRC2_CBC=mi.id_pbeWithSHAAnd128BitRC2_CBC=mi.id_pbeWithSHAAnd2_KeyTripleDES_CBC=mi.id_pbeWithSHAAnd3_KeyTripleDES_CBC=mi.id_pbeWithSHAAnd40BitRC4=mi.id_pbeWithSHAAnd128BitRC4=mi.id_pkcs_12PbeIds=mi.id_pkcs_12=mi.id_pkcs=mi.id_rsadsi=void 0;mi.id_rsadsi="1.2.840.113549";mi.id_pkcs=`${mi.id_rsadsi}.1`;mi.id_pkcs_12=`${mi.id_pkcs}.12`;mi.id_pkcs_12PbeIds=`${mi.id_pkcs_12}.1`;mi.id_pbeWithSHAAnd128BitRC4=`${mi.id_pkcs_12PbeIds}.1`;mi.id_pbeWithSHAAnd40BitRC4=`${mi.id_pkcs_12PbeIds}.2`;mi.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${mi.id_pkcs_12PbeIds}.3`;mi.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${mi.id_pkcs_12PbeIds}.4`;mi.id_pbeWithSHAAnd128BitRC2_CBC=`${mi.id_pkcs_12PbeIds}.5`;mi.id_pbewithSHAAnd40BitRC2_CBC=`${mi.id_pkcs_12PbeIds}.6`;mi.id_bagtypes=`${mi.id_pkcs_12}.10.1`});var pB=L(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.id_pkcs_9=xc.id_SafeContents=xc.id_SecretBag=xc.id_CRLBag=xc.id_certBag=xc.id_pkcs8ShroudedKeyBag=xc.id_keyBag=void 0;var Hw=rie();xc.id_keyBag=`${Hw.id_bagtypes}.1`;xc.id_pkcs8ShroudedKeyBag=`${Hw.id_bagtypes}.2`;xc.id_certBag=`${Hw.id_bagtypes}.3`;xc.id_CRLBag=`${Hw.id_bagtypes}.4`;xc.id_SecretBag=`${Hw.id_bagtypes}.5`;xc.id_SafeContents=`${Hw.id_bagtypes}.6`;xc.id_pkcs_9="1.2.840.113549.1.9"});var iFe=L(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.id_sdsiCertificate=tf.id_x509Certificate=tf.id_certTypes=tf.CertBag=void 0;var nFe=(at(),He(st)),mB=bt(),lCt=pB(),O3=class{certId="";certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};tf.CertBag=O3;nFe.__decorate([(0,mB.AsnProp)({type:mB.AsnPropTypes.ObjectIdentifier})],O3.prototype,"certId",void 0);nFe.__decorate([(0,mB.AsnProp)({type:mB.AsnPropTypes.Any,context:0})],O3.prototype,"certValue",void 0);tf.id_certTypes=`${lCt.id_pkcs_9}.22`;tf.id_x509Certificate=`${tf.id_certTypes}.1`;tf.id_sdsiCertificate=`${tf.id_certTypes}.2`});var aFe=L(Y0=>{"use strict";Object.defineProperty(Y0,"__esModule",{value:!0});Y0.id_x509CRL=Y0.id_crlTypes=Y0.CRLBag=void 0;var sFe=(at(),He(st)),gB=bt(),fCt=pB(),N3=class{crlId="";crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Y0.CRLBag=N3;sFe.__decorate([(0,gB.AsnProp)({type:gB.AsnPropTypes.ObjectIdentifier})],N3.prototype,"crlId",void 0);sFe.__decorate([(0,gB.AsnProp)({type:gB.AsnPropTypes.Any,context:0})],N3.prototype,"crltValue",void 0);Y0.id_crlTypes=`${fCt.id_pkcs_9}.23`;Y0.id_x509CRL=`${Y0.id_crlTypes}.1`});var uFe=L(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});Vw.EncryptedPrivateKeyInfo=Vw.EncryptedData=void 0;var oFe=(at(),He(st)),nie=bt(),cFe=hi(),B3=class extends nie.OctetString{};Vw.EncryptedData=B3;var U3=class{encryptionAlgorithm=new cFe.AlgorithmIdentifier;encryptedData=new B3;constructor(e={}){Object.assign(this,e)}};Vw.EncryptedPrivateKeyInfo=U3;oFe.__decorate([(0,nie.AsnProp)({type:cFe.AlgorithmIdentifier})],U3.prototype,"encryptionAlgorithm",void 0);oFe.__decorate([(0,nie.AsnProp)({type:B3})],U3.prototype,"encryptedData",void 0)});var lFe=L(Gf=>{"use strict";var iie;Object.defineProperty(Gf,"__esModule",{value:!0});Gf.PrivateKeyInfo=Gf.Attributes=Gf.PrivateKey=Gf.Version=void 0;var L3=(at(),He(st)),J0=bt(),aie=hi(),sie;(function(t){t[t.v1=0]="v1"})(sie||(Gf.Version=sie={}));var M3=class extends J0.OctetString{};Gf.PrivateKey=M3;var xB=iie=class extends J0.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,iie.prototype)}};Gf.Attributes=xB;Gf.Attributes=xB=iie=L3.__decorate([(0,J0.AsnType)({type:J0.AsnTypeTypes.Sequence,itemType:aie.Attribute})],xB);var Qy=class{version=sie.v1;privateKeyAlgorithm=new aie.AlgorithmIdentifier;privateKey=new M3;attributes;constructor(e={}){Object.assign(this,e)}};Gf.PrivateKeyInfo=Qy;L3.__decorate([(0,J0.AsnProp)({type:J0.AsnPropTypes.Integer})],Qy.prototype,"version",void 0);L3.__decorate([(0,J0.AsnProp)({type:aie.AlgorithmIdentifier})],Qy.prototype,"privateKeyAlgorithm",void 0);L3.__decorate([(0,J0.AsnProp)({type:M3})],Qy.prototype,"privateKey",void 0);L3.__decorate([(0,J0.AsnProp)({type:xB,implicit:!0,context:0,optional:!0})],Qy.prototype,"attributes",void 0)});var vB=L(yB=>{"use strict";Object.defineProperty(yB,"__esModule",{value:!0});var fFe=(at(),He(st));fFe.__exportStar(uFe(),yB);fFe.__exportStar(lFe(),yB)});var hFe=L($3=>{"use strict";Object.defineProperty($3,"__esModule",{value:!0});$3.KeyBag=void 0;var dCt=(at(),He(st)),hCt=vB(),dFe=bt(),oie=class extends hCt.PrivateKeyInfo{};$3.KeyBag=oie;$3.KeyBag=oie=dCt.__decorate([(0,dFe.AsnType)({type:dFe.AsnTypeTypes.Sequence})],oie)});var mFe=L(j3=>{"use strict";Object.defineProperty(j3,"__esModule",{value:!0});j3.PKCS8ShroudedKeyBag=void 0;var pCt=(at(),He(st)),mCt=vB(),pFe=bt(),cie=class extends mCt.EncryptedPrivateKeyInfo{};j3.PKCS8ShroudedKeyBag=cie;j3.PKCS8ShroudedKeyBag=cie=pCt.__decorate([(0,pFe.AsnType)({type:pFe.AsnTypeTypes.Sequence})],cie)});var xFe=L(_B=>{"use strict";Object.defineProperty(_B,"__esModule",{value:!0});_B.SecretBag=void 0;var gFe=(at(),He(st)),bB=bt(),q3=class{secretTypeId="";secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};_B.SecretBag=q3;gFe.__decorate([(0,bB.AsnProp)({type:bB.AsnPropTypes.ObjectIdentifier})],q3.prototype,"secretTypeId",void 0);gFe.__decorate([(0,bB.AsnProp)({type:bB.AsnPropTypes.Any,context:0})],q3.prototype,"secretValue",void 0)});var yFe=L(gg=>{"use strict";Object.defineProperty(gg,"__esModule",{value:!0});var Gw=(at(),He(st));Gw.__exportStar(iFe(),gg);Gw.__exportStar(aFe(),gg);Gw.__exportStar(hFe(),gg);Gw.__exportStar(mFe(),gg);Gw.__exportStar(xFe(),gg);Gw.__exportStar(pB(),gg)});var lie=L(wB=>{"use strict";Object.defineProperty(wB,"__esModule",{value:!0});wB.MacData=void 0;var uie=(at(),He(st)),vFe=dne(),Kw=bt(),Zw=class{mac=new vFe.DigestInfo;macSalt=new Kw.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};wB.MacData=Zw;uie.__decorate([(0,Kw.AsnProp)({type:vFe.DigestInfo})],Zw.prototype,"mac",void 0);uie.__decorate([(0,Kw.AsnProp)({type:Kw.OctetString})],Zw.prototype,"macSalt",void 0);uie.__decorate([(0,Kw.AsnProp)({type:Kw.AsnPropTypes.Integer,defaultValue:1})],Zw.prototype,"iterations",void 0)});var wFe=L(AB=>{"use strict";Object.defineProperty(AB,"__esModule",{value:!0});AB.PFX=void 0;var fie=(at(),He(st)),SB=bt(),bFe=b3(),_Fe=lie(),Xw=class{version=3;authSafe=new bFe.ContentInfo;macData=new _Fe.MacData;constructor(e={}){Object.assign(this,e)}};AB.PFX=Xw;fie.__decorate([(0,SB.AsnProp)({type:SB.AsnPropTypes.Integer})],Xw.prototype,"version",void 0);fie.__decorate([(0,SB.AsnProp)({type:bFe.ContentInfo})],Xw.prototype,"authSafe",void 0);fie.__decorate([(0,SB.AsnProp)({type:_Fe.MacData,optional:!0})],Xw.prototype,"macData",void 0)});var SFe=L(tv=>{"use strict";var die;Object.defineProperty(tv,"__esModule",{value:!0});tv.SafeContents=tv.SafeBag=void 0;var EB=(at(),He(st)),xg=bt(),gCt=Jne(),ev=class{bagId="";bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};tv.SafeBag=ev;EB.__decorate([(0,xg.AsnProp)({type:xg.AsnPropTypes.ObjectIdentifier})],ev.prototype,"bagId",void 0);EB.__decorate([(0,xg.AsnProp)({type:xg.AsnPropTypes.Any,context:0})],ev.prototype,"bagValue",void 0);EB.__decorate([(0,xg.AsnProp)({type:gCt.PKCS12Attribute,repeated:"set",optional:!0})],ev.prototype,"bagAttributes",void 0);var hie=die=class extends xg.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,die.prototype)}};tv.SafeContents=hie;tv.SafeContents=hie=die=EB.__decorate([(0,xg.AsnType)({type:xg.AsnTypeTypes.Sequence,itemType:ev})],hie)});var AFe=L(Q0=>{"use strict";Object.defineProperty(Q0,"__esModule",{value:!0});var rv=(at(),He(st));rv.__exportStar(Jne(),Q0);rv.__exportStar(rFe(),Q0);rv.__exportStar(yFe(),Q0);rv.__exportStar(lie(),Q0);rv.__exportStar(rie(),Q0);rv.__exportStar(wFe(),Q0);rv.__exportStar(SFe(),Q0)});var EFe=L(Ie=>{"use strict";var pie,mie,gie;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.DateOfBirth=Ie.UnstructuredAddress=Ie.UnstructuredName=Ie.EmailAddress=Ie.EncryptedPrivateKeyInfo=Ie.UserPKCS12=Ie.Pkcs7PDU=Ie.PKCS9String=Ie.id_at_pseudonym=Ie.crlTypes=Ie.id_certTypes=Ie.id_smime=Ie.id_pkcs9_mr_signingTimeMatch=Ie.id_pkcs9_mr_caseIgnoreMatch=Ie.id_pkcs9_sx_signingTime=Ie.id_pkcs9_sx_pkcs9String=Ie.id_pkcs9_at_countryOfResidence=Ie.id_pkcs9_at_countryOfCitizenship=Ie.id_pkcs9_at_gender=Ie.id_pkcs9_at_placeOfBirth=Ie.id_pkcs9_at_dateOfBirth=Ie.id_ietf_at=Ie.id_pkcs9_at_pkcs7PDU=Ie.id_pkcs9_at_sequenceNumber=Ie.id_pkcs9_at_randomNonce=Ie.id_pkcs9_at_encryptedPrivateKeyInfo=Ie.id_pkcs9_at_pkcs15Token=Ie.id_pkcs9_at_userPKCS12=Ie.id_pkcs9_at_localKeyId=Ie.id_pkcs9_at_friendlyName=Ie.id_pkcs9_at_smimeCapabilities=Ie.id_pkcs9_at_extensionRequest=Ie.id_pkcs9_at_signingDescription=Ie.id_pkcs9_at_extendedCertificateAttributes=Ie.id_pkcs9_at_unstructuredAddress=Ie.id_pkcs9_at_challengePassword=Ie.id_pkcs9_at_counterSignature=Ie.id_pkcs9_at_signingTime=Ie.id_pkcs9_at_messageDigest=Ie.id_pkcs9_at_contentType=Ie.id_pkcs9_at_unstructuredName=Ie.id_pkcs9_at_emailAddress=Ie.id_pkcs9_oc_naturalPerson=Ie.id_pkcs9_oc_pkcsEntity=Ie.id_pkcs9_mr=Ie.id_pkcs9_sx=Ie.id_pkcs9_at=Ie.id_pkcs9_oc=Ie.id_pkcs9_mo=Ie.id_pkcs9=void 0;Ie.SMIMECapabilities=Ie.SMIMECapability=Ie.SigningDescription=Ie.LocalKeyId=Ie.FriendlyName=Ie.ExtendedCertificateAttributes=Ie.ExtensionRequest=Ie.ChallengePassword=Ie.CounterSignature=Ie.SequenceNumber=Ie.RandomNonce=Ie.SigningTime=Ie.MessageDigest=Ie.ContentType=Ie.Pseudonym=Ie.CountryOfResidence=Ie.CountryOfCitizenship=Ie.Gender=Ie.PlaceOfBirth=void 0;var ei=(at(),He(st)),Ar=bt(),Nie=ei.__importStar(b3()),xCt=ei.__importStar(AFe()),yCt=ei.__importStar(vB()),ep=ei.__importStar(hi()),vCt=ei.__importStar(Ire());Ie.id_pkcs9="1.2.840.113549.1.9";Ie.id_pkcs9_mo=`${Ie.id_pkcs9}.0`;Ie.id_pkcs9_oc=`${Ie.id_pkcs9}.24`;Ie.id_pkcs9_at=`${Ie.id_pkcs9}.25`;Ie.id_pkcs9_sx=`${Ie.id_pkcs9}.26`;Ie.id_pkcs9_mr=`${Ie.id_pkcs9}.27`;Ie.id_pkcs9_oc_pkcsEntity=`${Ie.id_pkcs9_oc}.1`;Ie.id_pkcs9_oc_naturalPerson=`${Ie.id_pkcs9_oc}.2`;Ie.id_pkcs9_at_emailAddress=`${Ie.id_pkcs9}.1`;Ie.id_pkcs9_at_unstructuredName=`${Ie.id_pkcs9}.2`;Ie.id_pkcs9_at_contentType=`${Ie.id_pkcs9}.3`;Ie.id_pkcs9_at_messageDigest=`${Ie.id_pkcs9}.4`;Ie.id_pkcs9_at_signingTime=`${Ie.id_pkcs9}.5`;Ie.id_pkcs9_at_counterSignature=`${Ie.id_pkcs9}.6`;Ie.id_pkcs9_at_challengePassword=`${Ie.id_pkcs9}.7`;Ie.id_pkcs9_at_unstructuredAddress=`${Ie.id_pkcs9}.8`;Ie.id_pkcs9_at_extendedCertificateAttributes=`${Ie.id_pkcs9}.9`;Ie.id_pkcs9_at_signingDescription=`${Ie.id_pkcs9}.13`;Ie.id_pkcs9_at_extensionRequest=`${Ie.id_pkcs9}.14`;Ie.id_pkcs9_at_smimeCapabilities=`${Ie.id_pkcs9}.15`;Ie.id_pkcs9_at_friendlyName=`${Ie.id_pkcs9}.20`;Ie.id_pkcs9_at_localKeyId=`${Ie.id_pkcs9}.21`;Ie.id_pkcs9_at_userPKCS12="2.16.840.1.113730.3.1.216";Ie.id_pkcs9_at_pkcs15Token=`${Ie.id_pkcs9_at}.1`;Ie.id_pkcs9_at_encryptedPrivateKeyInfo=`${Ie.id_pkcs9_at}.2`;Ie.id_pkcs9_at_randomNonce=`${Ie.id_pkcs9_at}.3`;Ie.id_pkcs9_at_sequenceNumber=`${Ie.id_pkcs9_at}.4`;Ie.id_pkcs9_at_pkcs7PDU=`${Ie.id_pkcs9_at}.5`;Ie.id_ietf_at="1.3.6.1.5.5.7.9";Ie.id_pkcs9_at_dateOfBirth=`${Ie.id_ietf_at}.1`;Ie.id_pkcs9_at_placeOfBirth=`${Ie.id_ietf_at}.2`;Ie.id_pkcs9_at_gender=`${Ie.id_ietf_at}.3`;Ie.id_pkcs9_at_countryOfCitizenship=`${Ie.id_ietf_at}.4`;Ie.id_pkcs9_at_countryOfResidence=`${Ie.id_ietf_at}.5`;Ie.id_pkcs9_sx_pkcs9String=`${Ie.id_pkcs9_sx}.1`;Ie.id_pkcs9_sx_signingTime=`${Ie.id_pkcs9_sx}.2`;Ie.id_pkcs9_mr_caseIgnoreMatch=`${Ie.id_pkcs9_mr}.1`;Ie.id_pkcs9_mr_signingTimeMatch=`${Ie.id_pkcs9_mr}.2`;Ie.id_smime=`${Ie.id_pkcs9}.16`;Ie.id_certTypes=`${Ie.id_pkcs9}.22`;Ie.crlTypes=`${Ie.id_pkcs9}.23`;Ie.id_at_pseudonym=`${vCt.id_at}.65`;var z3=class extends ep.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};Ie.PKCS9String=z3;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.IA5String})],z3.prototype,"ia5String",void 0);Ie.PKCS9String=z3=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],z3);var xie=class extends Nie.ContentInfo{};Ie.Pkcs7PDU=xie;Ie.Pkcs7PDU=xie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],xie);var yie=class extends xCt.PFX{};Ie.UserPKCS12=yie;Ie.UserPKCS12=yie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],yie);var vie=class extends yCt.EncryptedPrivateKeyInfo{};Ie.EncryptedPrivateKeyInfo=vie;Ie.EncryptedPrivateKeyInfo=vie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],vie);var TB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.EmailAddress=TB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.IA5String})],TB.prototype,"value",void 0);Ie.EmailAddress=TB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],TB);var bie=class extends z3{};Ie.UnstructuredName=bie;Ie.UnstructuredName=bie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],bie);var _ie=class extends ep.DirectoryString{};Ie.UnstructuredAddress=_ie;Ie.UnstructuredAddress=_ie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],_ie);var CB=class{value;constructor(e=new Date){this.value=e}};Ie.DateOfBirth=CB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.GeneralizedTime})],CB.prototype,"value",void 0);Ie.DateOfBirth=CB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],CB);var wie=class extends ep.DirectoryString{};Ie.PlaceOfBirth=wie;Ie.PlaceOfBirth=wie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],wie);var kB=class{value;constructor(e="M"){this.value=e}toString(){return this.value}};Ie.Gender=kB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.PrintableString})],kB.prototype,"value",void 0);Ie.Gender=kB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],kB);var W3=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.CountryOfCitizenship=W3;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.PrintableString})],W3.prototype,"value",void 0);Ie.CountryOfCitizenship=W3=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],W3);var Sie=class extends W3{};Ie.CountryOfResidence=Sie;Ie.CountryOfResidence=Sie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Sie);var Aie=class extends ep.DirectoryString{};Ie.Pseudonym=Aie;Ie.Pseudonym=Aie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Aie);var DB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.ContentType=DB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.ObjectIdentifier})],DB.prototype,"value",void 0);Ie.ContentType=DB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],DB);var Eie=class extends Ar.OctetString{};Ie.MessageDigest=Eie;var Tie=class extends ep.Time{};Ie.SigningTime=Tie;Ie.SigningTime=Tie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Tie);var Cie=class extends Ar.OctetString{};Ie.RandomNonce=Cie;var IB=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};Ie.SequenceNumber=IB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.Integer})],IB.prototype,"value",void 0);Ie.SequenceNumber=IB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],IB);var kie=class extends Nie.SignerInfo{};Ie.CounterSignature=kie;Ie.CounterSignature=kie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],kie);var Die=class extends ep.DirectoryString{};Ie.ChallengePassword=Die;Ie.ChallengePassword=Die=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Die);var Iie=pie=class extends ep.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,pie.prototype)}};Ie.ExtensionRequest=Iie;Ie.ExtensionRequest=Iie=pie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],Iie);var Fie=mie=class extends Ar.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,mie.prototype)}};Ie.ExtendedCertificateAttributes=Fie;Ie.ExtendedCertificateAttributes=Fie=mie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Set,itemType:Nie.Attribute})],Fie);var FB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.FriendlyName=FB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.BmpString})],FB.prototype,"value",void 0);Ie.FriendlyName=FB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],FB);var Pie=class extends Ar.OctetString{};Ie.LocalKeyId=Pie;var Rie=class extends ep.DirectoryString{};Ie.SigningDescription=Rie;var PB=class extends ep.AlgorithmIdentifier{};Ie.SMIMECapability=PB;Ie.SMIMECapability=PB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],PB);var Oie=gie=class extends Ar.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,gie.prototype)}};Ie.SMIMECapabilities=Oie;Ie.SMIMECapabilities=Oie=gie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence,itemType:PB})],Oie)});var Lie=L(H3=>{"use strict";var Bie;Object.defineProperty(H3,"__esModule",{value:!0});H3.Attributes=void 0;var bCt=(at(),He(st)),Uie=bt(),_Ct=hi(),Mie=Bie=class extends Uie.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Bie.prototype)}};H3.Attributes=Mie;H3.Attributes=Mie=Bie=bCt.__decorate([(0,Uie.AsnType)({type:Uie.AsnTypeTypes.Sequence,itemType:_Ct.Attribute})],Mie)});var $ie=L(NB=>{"use strict";Object.defineProperty(NB,"__esModule",{value:!0});NB.CertificationRequestInfo=void 0;var OB=(at(),He(st)),V3=bt(),RB=hi(),TFe=Lie(),nv=class{version=0;subject=new RB.Name;subjectPKInfo=new RB.SubjectPublicKeyInfo;attributes=new TFe.Attributes;constructor(e={}){Object.assign(this,e)}};NB.CertificationRequestInfo=nv;OB.__decorate([(0,V3.AsnProp)({type:V3.AsnPropTypes.Integer})],nv.prototype,"version",void 0);OB.__decorate([(0,V3.AsnProp)({type:RB.Name})],nv.prototype,"subject",void 0);OB.__decorate([(0,V3.AsnProp)({type:RB.SubjectPublicKeyInfo})],nv.prototype,"subjectPKInfo",void 0);OB.__decorate([(0,V3.AsnProp)({type:TFe.Attributes,implicit:!0,context:0,optional:!0})],nv.prototype,"attributes",void 0)});var DFe=L(UB=>{"use strict";Object.defineProperty(UB,"__esModule",{value:!0});UB.CertificationRequest=void 0;var jie=(at(),He(st)),BB=bt(),CFe=hi(),kFe=$ie(),Yw=class{certificationRequestInfo=new kFe.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new CFe.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};UB.CertificationRequest=Yw;jie.__decorate([(0,BB.AsnProp)({type:kFe.CertificationRequestInfo,raw:!0})],Yw.prototype,"certificationRequestInfo",void 0);jie.__decorate([(0,BB.AsnProp)({type:CFe.AlgorithmIdentifier})],Yw.prototype,"signatureAlgorithm",void 0);jie.__decorate([(0,BB.AsnProp)({type:BB.AsnPropTypes.BitString})],Yw.prototype,"signature",void 0)});var IFe=L(G3=>{"use strict";Object.defineProperty(G3,"__esModule",{value:!0});var qie=(at(),He(st));qie.__exportStar(Lie(),G3);qie.__exportStar(DFe(),G3);qie.__exportStar($ie(),G3)});var pPe=L(Wt=>{"use strict";H3e();var gt=bt(),Fr=hi(),Ot=tee(),yt=(at(),He(st)),wCt=b3(),YB=_Ie(),Cu=dne(),ls=tFe(),Zie=EFe(),JB=IFe();function B6(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var mt=B6(Fr),Tu=B6(wCt),Ps=B6(YB),us=B6(Cu),sS=B6(Zie),lS="crypto.algorithm",QB=class{getAlgorithms(){return ls.container.resolveAll(lS)}toAsnAlgorithm(e){({...e});for(let r of this.getAlgorithms()){let n=r.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let r=new Fr.AlgorithmIdentifier({algorithm:e.name});if("parameters"in e){let n=e;r.parameters=n.parameters}return r}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(let n of this.getAlgorithms()){let i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}},Xf="crypto.algorithmProvider";ls.container.registerSingleton(Xf,QB);var $B,Fu="1.3.36.3.3.2.8.1.1",FFe=`${Fu}.1`,PFe=`${Fu}.2`,RFe=`${Fu}.3`,OFe=`${Fu}.4`,NFe=`${Fu}.5`,BFe=`${Fu}.6`,UFe=`${Fu}.7`,MFe=`${Fu}.8`,LFe=`${Fu}.9`,$Fe=`${Fu}.10`,jFe=`${Fu}.11`,qFe=`${Fu}.12`,zFe=`${Fu}.13`,WFe=`${Fu}.14`,HFe="brainpoolP160r1",VFe="brainpoolP160t1",GFe="brainpoolP192r1",KFe="brainpoolP192t1",ZFe="brainpoolP224r1",XFe="brainpoolP224t1",YFe="brainpoolP256r1",JFe="brainpoolP256t1",QFe="brainpoolP320r1",ePe="brainpoolP320t1",tPe="brainpoolP384r1",rPe="brainpoolP384t1",nPe="brainpoolP512r1",iPe="brainpoolP512t1",ta="ECDSA";Wt.EcAlgorithm=$B=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ta.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Ps.ecdsaWithSHA1;case"sha-256":return Ps.ecdsaWithSHA256;case"sha-384":return Ps.ecdsaWithSHA384;case"sha-512":return Ps.ecdsaWithSHA512}else if("namedCurve"in e){let r="";switch(e.namedCurve){case"P-256":r=Ps.id_secp256r1;break;case"K-256":r=$B.SECP256K1;break;case"P-384":r=Ps.id_secp384r1;break;case"P-521":r=Ps.id_secp521r1;break;case HFe:r=FFe;break;case VFe:r=PFe;break;case GFe:r=RFe;break;case KFe:r=OFe;break;case ZFe:r=NFe;break;case XFe:r=BFe;break;case YFe:r=UFe;break;case JFe:r=MFe;break;case QFe:r=LFe;break;case ePe:r=$Fe;break;case tPe:r=jFe;break;case rPe:r=qFe;break;case nPe:r=zFe;break;case iPe:r=WFe;break}if(r)return new Fr.AlgorithmIdentifier({algorithm:Ps.id_ecPublicKey,parameters:gt.AsnConvert.serialize(new Ps.ECParameters({namedCurve:r}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Ps.id_ecdsaWithSHA1:return{name:ta,hash:{name:"SHA-1"}};case Ps.id_ecdsaWithSHA256:return{name:ta,hash:{name:"SHA-256"}};case Ps.id_ecdsaWithSHA384:return{name:ta,hash:{name:"SHA-384"}};case Ps.id_ecdsaWithSHA512:return{name:ta,hash:{name:"SHA-512"}};case Ps.id_ecPublicKey:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(gt.AsnConvert.parse(e.parameters,Ps.ECParameters).namedCurve){case Ps.id_secp256r1:return{name:ta,namedCurve:"P-256"};case $B.SECP256K1:return{name:ta,namedCurve:"K-256"};case Ps.id_secp384r1:return{name:ta,namedCurve:"P-384"};case Ps.id_secp521r1:return{name:ta,namedCurve:"P-521"};case FFe:return{name:ta,namedCurve:HFe};case PFe:return{name:ta,namedCurve:VFe};case RFe:return{name:ta,namedCurve:GFe};case OFe:return{name:ta,namedCurve:KFe};case NFe:return{name:ta,namedCurve:ZFe};case BFe:return{name:ta,namedCurve:XFe};case UFe:return{name:ta,namedCurve:YFe};case MFe:return{name:ta,namedCurve:JFe};case LFe:return{name:ta,namedCurve:QFe};case $Fe:return{name:ta,namedCurve:ePe};case jFe:return{name:ta,namedCurve:tPe};case qFe:return{name:ta,namedCurve:rPe};case zFe:return{name:ta,namedCurve:nPe};case WFe:return{name:ta,namedCurve:iPe}}}}return null}};Wt.EcAlgorithm.SECP256K1="1.3.132.0.10";Wt.EcAlgorithm=$B=yt.__decorate([ls.injectable()],Wt.EcAlgorithm);ls.container.registerSingleton(lS,Wt.EcAlgorithm);var lPe=Symbol("name"),fPe=Symbol("value"),qn=class{constructor(e,r={},n=""){this[lPe]=e,this[fPe]=n;for(let i in r)this[i]=r[i]}};qn.NAME=lPe;qn.VALUE=fPe;var eU=class{static toTextObject(e){let r=new qn("Algorithm Identifier",{},rf.toString(e.algorithm));if(e.parameters)if(e.algorithm===Ps.id_ecPublicKey){let n=new Wt.EcAlgorithm().toWebAlgorithm(e);n&&"namedCurve"in n?r["Named Curve"]=n.namedCurve:r.Parameters=e.parameters}else r.Parameters=e.parameters;return r}},rf=class{static toString(e){let r=this.items[e];return r||e}};rf.items={[us.id_sha1]:"sha1",[us.id_sha224]:"sha224",[us.id_sha256]:"sha256",[us.id_sha384]:"sha384",[us.id_sha512]:"sha512",[us.id_rsaEncryption]:"rsaEncryption",[us.id_sha1WithRSAEncryption]:"sha1WithRSAEncryption",[us.id_sha224WithRSAEncryption]:"sha224WithRSAEncryption",[us.id_sha256WithRSAEncryption]:"sha256WithRSAEncryption",[us.id_sha384WithRSAEncryption]:"sha384WithRSAEncryption",[us.id_sha512WithRSAEncryption]:"sha512WithRSAEncryption",[Ps.id_ecPublicKey]:"ecPublicKey",[Ps.id_ecdsaWithSHA1]:"ecdsaWithSHA1",[Ps.id_ecdsaWithSHA224]:"ecdsaWithSHA224",[Ps.id_ecdsaWithSHA256]:"ecdsaWithSHA256",[Ps.id_ecdsaWithSHA384]:"ecdsaWithSHA384",[Ps.id_ecdsaWithSHA512]:"ecdsaWithSHA512",[mt.id_kp_serverAuth]:"TLS WWW server authentication",[mt.id_kp_clientAuth]:"TLS WWW client authentication",[mt.id_kp_codeSigning]:"Code Signing",[mt.id_kp_emailProtection]:"E-mail Protection",[mt.id_kp_timeStamping]:"Time Stamping",[mt.id_kp_OCSPSigning]:"OCSP Signing",[Tu.id_signedData]:"Signed Data"};var Yf=class{static serialize(e){return this.serializeObj(e).join(`
1006
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,r=0){let n=[],i=this.pad(r++),s="",a=e[qn.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[qn.NAME]}:${s}`),i=this.pad(r);for(let c in e){if(typeof c=="symbol")continue;let d=e[c],h=c?`${c}: `:"";if(typeof d=="string"||typeof d=="number"||typeof d=="boolean")n.push(`${i}${h}${d}`);else if(d instanceof Date)n.push(`${i}${h}${d.toUTCString()}`);else if(Array.isArray(d))for(let p of d)p[qn.NAME]=c,n.push(...this.serializeObj(p,r));else if(d instanceof qn)d[qn.NAME]=c,n.push(...this.serializeObj(d,r));else if(Ot.BufferSourceConverter.isBufferSource(d))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(d,r+1))):n.push(...this.serializeBufferSource(d,r));else if("toTextObject"in d){let p=d.toTextObject();p[qn.NAME]=c,n.push(...this.serializeObj(p,r))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,r=0){let n=this.pad(r),i=Ot.BufferSourceConverter.toUint8Array(e),s=[];for(let a=0;a<i.length;){let c=[];for(let d=0;d<16&&a<i.length;d++){d===8&&c.push("");let h=i[a++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};Yf.oidSerializer=rf;Yf.algorithmSerializer=eU;var Jw,vh=class t{get rawData(){return yt.__classPrivateFieldGet(this,Jw,"f")||yt.__classPrivateFieldSet(this,Jw,gt.AsnConvert.serialize(this.asn),"f"),yt.__classPrivateFieldGet(this,Jw,"f")}constructor(...e){Jw.set(this,void 0),Ot.BufferSourceConverter.isBufferSource(e[0])?(this.asn=gt.AsnConvert.parse(e[0],e[1]),yt.__classPrivateFieldSet(this,Jw,Ot.BufferSourceConverter.toArrayBuffer(e[0]),"f"),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(e){return e instanceof t?Ot.isEqual(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return gt.AsnConvert.toString(this.rawData);case"text":return Yf.serialize(this.toTextObject());case"hex":return Ot.Convert.ToHex(this.rawData);case"base64":return Ot.Convert.ToBase64(this.rawData);case"base64url":return Ot.Convert.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new qn(this.getTextName(),{},e)}};Jw=new WeakMap;vh.NAME="ASN";var ku=class t extends vh{constructor(...e){let r;Ot.BufferSourceConverter.isBufferSource(e[0])?r=Ot.BufferSourceConverter.toArrayBuffer(e[0]):r=gt.AsnConvert.serialize(new Fr.Extension({extnID:e[0],critical:e[1],extnValue:new gt.OctetString(Ot.BufferSourceConverter.toArrayBuffer(e[2]))})),super(r,Fr.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[qn.NAME]===t.NAME&&(e[qn.NAME]=rf.toString(this.type)),e}},dPe,aS=class t{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[dPe]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(t.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(t.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,r){return this.items.forEach(e,r)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=t.DEFAULT){let r=this.items.get(e.toLowerCase());if(!r)throw new Error(`Cannot get Crypto by name '${e}'`);return r}set(e,r){if(typeof e=="string"){if(!r)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),r)}else this.items.set(t.DEFAULT,e);return this}};dPe=Symbol.toStringTag;aS.DEFAULT="default";var Rs=new aS,SCt=/^[0-2](?:\.[1-9][0-9]*)+$/;function ACt(t){return new RegExp(SCt).test(t)}var w6=class{constructor(e={}){this.items={};for(let r in e)this.register(r,e[r])}get(e){return this.items[e]||null}findId(e){return ACt(e)?e:this.get(e)}register(e,r){this.items[e]=r,this.items[r]=e}},Du=new w6;Du.register("CN","2.5.4.3");Du.register("L","2.5.4.7");Du.register("ST","2.5.4.8");Du.register("O","2.5.4.10");Du.register("OU","2.5.4.11");Du.register("C","2.5.4.6");Du.register("DC","0.9.2342.19200300.100.1.25");Du.register("E","1.2.840.113549.1.9.1");Du.register("G","2.5.4.42");Du.register("I","2.5.4.43");Du.register("SN","2.5.4.4");Du.register("T","2.5.4.12");function ECt(t,e){return`\\${Ot.Convert.ToHex(Ot.Convert.FromUtf8String(e)).toUpperCase()}`}function TCt(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,ECt)}var Ka=class t{static isASCII(e){for(let r=0;r<e.length;r++)if(e.charCodeAt(r)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,r={}){this.extraNames=new w6,this.asn=new Fr.Name;for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)){let i=r[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof Fr.Name?this.asn=e:Ot.BufferSourceConverter.isBufferSource(e)?this.asn=gt.AsnConvert.parse(e,Fr.Name):this.asn=this.fromJSON(e)}getField(e){let r=this.extraNames.findId(e)||Du.findId(e),n=[];for(let i of this.asn)for(let s of i)s.type===r&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||Du.get(e)}toString(){return this.asn.map(e=>e.map(r=>{let n=this.getName(r.type)||r.type,i=r.value.anyValue?`#${Ot.Convert.ToHex(r.value.anyValue)}`:TCt(r.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;let r=[];for(let n of this.asn){let i={};for(let s of n){let a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${Ot.Convert.ToHex(s.value.anyValue)}`:s.value.toString())}r.push(i)}return r}fromString(e){let r=new Fr.Name,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,c]=i,d=c[c.length-1];(d===","||d==="+")&&(c=c.slice(0,c.length-1),i[3]=d);let h=i[3];a=this.getTypeOid(a);let p=this.createAttribute(a,c);s==="+"?r[r.length-1].push(p):r.push(new Fr.RelativeDistinguishedName([p])),s=h}return r}fromJSON(e){let r=new Fr.Name;for(let n of e){let i=new Fr.RelativeDistinguishedName;for(let s in n){let a=this.getTypeOid(s),c=n[s];for(let d of c){let h=this.createAttribute(a,d);i.push(h)}}r.push(i)}return r}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,r){let n=new Fr.AttributeTypeAndValue({type:e});if(typeof r=="object")for(let i in r)switch(i){case"ia5String":n.value.ia5String=r[i];break;case"utf8String":n.value.utf8String=r[i];break;case"universalString":n.value.universalString=r[i];break;case"bmpString":n.value.bmpString=r[i];break;case"printableString":n.value.printableString=r[i];break}else if(r[0]==="#")n.value.anyValue=Ot.Convert.FromHex(r.slice(1));else{let i=this.processStringValue(r);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:t.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){let r=/"(.*?[^\\])?"/.exec(e);return r&&(e=r[1]),e.replace(/\\0a/ig,`
1007
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return gt.AsnConvert.serialize(this.asn)}async getThumbprint(...e){var r;let n,i="SHA-1";return e.length>=1&&!(!((r=e[0])===null||r===void 0)&&r.subtle)?(i=e[0]||i,n=e[1]||Rs.get()):n=e[0]||Rs.get(),await n.subtle.digest(i,this.toArrayBuffer())}},hPe="Cannot initialize GeneralName from ASN.1 data.",sPe=`${hPe} Unsupported string format in use.`,CCt=`${hPe} Value doesn't match to GUID regular expression.`,aPe=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,oPe="1.3.6.1.4.1.311.25.1",cPe="1.3.6.1.4.1.311.20.2.3",jB="dns",qB="dn",zB="email",WB="ip",HB="url",VB="guid",GB="upn",K3="id",Kf=class extends vh{constructor(...e){let r;if(e.length===2)switch(e[0]){case qB:{let n=new Ka(e[1]).toArrayBuffer(),i=gt.AsnConvert.parse(n,mt.Name);r=new mt.GeneralName({directoryName:i});break}case jB:r=new mt.GeneralName({dNSName:e[1]});break;case zB:r=new mt.GeneralName({rfc822Name:e[1]});break;case VB:{let n=new RegExp(aPe,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");let i=n.slice(1).map((s,a)=>a<3?Ot.Convert.ToHex(new Uint8Array(Ot.Convert.FromHex(s)).reverse()):s).join("");r=new mt.GeneralName({otherName:new mt.OtherName({typeId:oPe,value:gt.AsnConvert.serialize(new gt.OctetString(Ot.Convert.FromHex(i)))})});break}case WB:r=new mt.GeneralName({iPAddress:e[1]});break;case K3:r=new mt.GeneralName({registeredID:e[1]});break;case GB:{r=new mt.GeneralName({otherName:new mt.OtherName({typeId:cPe,value:gt.AsnConvert.serialize(gt.AsnUtf8StringConverter.toASN(e[1]))})});break}case HB:r=new mt.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else Ot.BufferSourceConverter.isBufferSource(e[0])?r=gt.AsnConvert.parse(e[0],mt.GeneralName):r=e[0];super(r)}onInit(e){if(e.dNSName!=null)this.type=jB,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=zB,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=WB,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=HB,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=K3,this.value=e.registeredID;else if(e.directoryName!=null)this.type=qB,this.value=new Ka(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===oPe){this.type=VB;let r=gt.AsnConvert.parse(e.otherName.value,gt.OctetString),n=new RegExp(aPe,"i").exec(Ot.Convert.ToHex(r));if(!n)throw new Error(CCt);this.value=n.slice(1).map((i,s)=>s<3?Ot.Convert.ToHex(new Uint8Array(Ot.Convert.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===cPe)this.type=GB,this.value=gt.AsnConvert.parse(e.otherName.value,mt.DirectoryString).toString();else throw new Error(sPe);else throw new Error(sPe)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case qB:case jB:case VB:case WB:case K3:case GB:case HB:e=this.type.toUpperCase();break;case zB:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let r=this.value;return this.type===K3&&(r=rf.toString(r)),new qn(e,void 0,r)}},bh=class extends vh{constructor(e){let r;if(e instanceof mt.GeneralNames)r=e;else if(Array.isArray(e)){let n=[];for(let i of e)if(i instanceof mt.GeneralName)n.push(i);else{let s=gt.AsnConvert.parse(new Kf(i.type,i.value).rawData,mt.GeneralName);n.push(s)}r=new mt.GeneralNames(n)}else if(Ot.BufferSourceConverter.isBufferSource(e))r=gt.AsnConvert.parse(e,mt.GeneralNames);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(r)}onInit(e){let r=[];for(let n of e){let i=null;try{i=new Kf(n)}catch{continue}r.push(i)}this.items=r}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let r of this.items){let n=r.toTextObject(),i=e[n[qn.NAME]];Array.isArray(i)||(i=[],e[n[qn.NAME]]=i),i.push(n)}return e}};bh.NAME="GeneralNames";var _6="-{5}",S6="\\n",kCt=`[^${S6}]+`,DCt=`${_6}BEGIN (${kCt}(?=${_6}))${_6}`,ICt=`${_6}END \\1${_6}`,oS="\\n",FCt=`[^:${S6}]+`,PCt=`(?:[^${S6}]+${oS}(?: +[^${S6}]+${oS})*)`,RCt="[a-zA-Z0-9=+/]+",OCt=`(?:${RCt}${oS})+`,uPe=`${DCt}${oS}(?:((?:${FCt}: ${PCt})+))?${oS}?(${OCt})${ICt}`,po=class{static isPem(e){return typeof e=="string"&&new RegExp(uPe,"g").test(e.replace(/\r/g,""))}static decodeWithHeaders(e){e=e.replace(/\r/g,"");let r=new RegExp(uPe,"g"),n=[],i=null;for(;i=r.exec(e);){let s=i[3].replace(new RegExp(`[${S6}]+`,"g"),""),a={type:i[1],headers:[],rawData:Ot.Convert.FromBase64(s)},c=i[2];if(c){let d=c.split(new RegExp(oS,"g")),h=null;for(let p of d){let[x,y]=p.split(/:(.*)/);if(y===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=x.trim()}else h&&a.headers.push(h),h={key:x,value:y.trim()}}h&&a.headers.push(h)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){let r=this.decode(e);if(!r.length)throw new RangeError("PEM string doesn't contain any objects");return r[0]}static encode(e,r){if(Array.isArray(e)){let n=new Array;return r?e.forEach(i=>{if(!Ot.BufferSourceConverter.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:r,rawData:Ot.BufferSourceConverter.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
1014
+ `)}function dTt(t,e,r){let[,n=null]=t.toString().match(/constructor\(([\w, ]+)\)/)||[],i=lTt(n,e);return fTt(`Cannot inject the dependency ${i} of "${t.name}" constructor. Reason:`,r)}oB.formatErrorCtor=dTt});var MIe=L(cB=>{"use strict";Object.defineProperty(cB,"__esModule",{value:!0});cB.isDisposable=void 0;function hTt(t){return!(typeof t.dispose!="function"||t.dispose.length>0)}cB.isDisposable=hTt});var $Ie=L(Xy=>{"use strict";Object.defineProperty(Xy,"__esModule",{value:!0});Xy.PostResolutionInterceptors=Xy.PreResolutionInterceptors=void 0;var LIe=Cne(),uB=class extends LIe.default{};Xy.PreResolutionInterceptors=uB;var lB=class extends LIe.default{};Xy.PostResolutionInterceptors=lB;var Rne=class{constructor(){this.preResolution=new uB,this.postResolution=new lB}};Xy.default=Rne});var pg=L(Z0=>{"use strict";Object.defineProperty(Z0,"__esModule",{value:!0});Z0.instance=Z0.typeInfo=void 0;var pTt=(J7(),He(Y7)),$c=Ane(),mTt=NIe(),fB=nB(),gTt=BIe(),Eu=yne(),dB=UIe(),xTt=Pne(),yTt=rB(),vTt=MIe(),bTt=$Ie();Z0.typeInfo=new Map;var One=class t{constructor(e){this.parent=e,this._registry=new gTt.default,this.interceptors=new bTt.default,this.disposed=!1,this.disposables=new Set}register(e,r,n={lifecycle:Eu.default.Transient}){this.ensureNotDisposed();let i;if(mTt.isProvider(r)?i=r:i={useClass:r},$c.isTokenProvider(i)){let s=[e],a=i;for(;a!=null;){let c=a.useToken;if(s.includes(c))throw new Error(`Token registration cycle detected! ${[...s,c].join(" -> ")}`);s.push(c);let d=this._registry.get(c);d&&$c.isTokenProvider(d.provider)?a=d.provider:a=null}}if((n.lifecycle===Eu.default.Singleton||n.lifecycle==Eu.default.ContainerScoped||n.lifecycle==Eu.default.ResolutionScoped)&&($c.isValueProvider(i)||$c.isFactoryProvider(i)))throw new Error(`Cannot use lifecycle "${Eu.default[n.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:i,options:n}),this}registerType(e,r){return this.ensureNotDisposed(),$c.isNormalToken(r)?this.register(e,{useToken:r}):this.register(e,{useClass:r})}registerInstance(e,r){return this.ensureNotDisposed(),this.register(e,{useValue:r})}registerSingleton(e,r){if(this.ensureNotDisposed(),$c.isNormalToken(e)){if($c.isNormalToken(r))return this.register(e,{useToken:r},{lifecycle:Eu.default.Singleton});if(r)return this.register(e,{useClass:r},{lifecycle:Eu.default.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}let n=e;return r&&!$c.isNormalToken(r)&&(n=r),this.register(e,{useClass:n},{lifecycle:Eu.default.Singleton})}resolve(e,r=new dB.default,n=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&$c.isNormalToken(e)){if(n)return;throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"Single"),i){let s=this.resolveRegistration(i,r);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(fB.isConstructorToken(e)){let s=this.construct(e,r);return this.executePostResolutionInterceptor(e,s,"Single"),s}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,r){if(this.interceptors.preResolution.has(e)){let n=[];for(let i of this.interceptors.preResolution.getAll(e))i.options.frequency!="Once"&&n.push(i),i.callback(e,r);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,r,n){if(this.interceptors.postResolution.has(e)){let i=[];for(let s of this.interceptors.postResolution.getAll(e))s.options.frequency!="Once"&&i.push(s),s.callback(e,r,n);this.interceptors.postResolution.setAll(e,i)}}resolveRegistration(e,r){if(this.ensureNotDisposed(),e.options.lifecycle===Eu.default.ResolutionScoped&&r.scopedResolutions.has(e))return r.scopedResolutions.get(e);let n=e.options.lifecycle===Eu.default.Singleton,i=e.options.lifecycle===Eu.default.ContainerScoped,s=n||i,a;return $c.isValueProvider(e.provider)?a=e.provider.useValue:$c.isTokenProvider(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,r)):this.resolve(e.provider.useToken,r):$c.isClassProvider(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,r)):this.construct(e.provider.useClass,r):$c.isFactoryProvider(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,r),e.options.lifecycle===Eu.default.ResolutionScoped&&r.scopedResolutions.set(e,a),a}resolveAll(e,r=new dB.default,n=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&$c.isNormalToken(e)){if(n)return[];throw new Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,"All"),i){let a=i.map(c=>this.resolveRegistration(c,r));return this.executePostResolutionInterceptor(e,a,"All"),a}let s=[this.construct(e,r)];return this.executePostResolutionInterceptor(e,s,"All"),s}isRegistered(e,r=!1){return this.ensureNotDisposed(),this._registry.has(e)||r&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,r]of this._registry.entries())this._registry.setAll(e,r.filter(n=>!$c.isValueProvider(n.provider)).map(n=>(n.instance=void 0,n)))}createChildContainer(){this.ensureNotDisposed();let e=new t(this);for(let[r,n]of this._registry.entries())n.some(({options:i})=>i.lifecycle===Eu.default.ContainerScoped)&&e._registry.setAll(r,n.map(i=>i.options.lifecycle===Eu.default.ContainerScoped?{provider:i.provider,options:i.options}:i));return e}beforeResolution(e,r,n={frequency:"Always"}){this.interceptors.preResolution.set(e,{callback:r,options:n})}afterResolution(e,r,n={frequency:"Always"}){this.interceptors.postResolution.set(e,{callback:r,options:n})}dispose(){return pTt.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(r=>{let n=r.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(e,r){if(e instanceof yTt.DelayedConstructor)return e.createProxy(i=>this.resolve(i,r));let n=(()=>{let i=Z0.typeInfo.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error(`TypeInfo not known for "${e.name}"`)}let s=i.map(this.resolveParams(r,e));return new e(...s)})();return vTt.isDisposable(n)&&this.disposables.add(n),n}resolveParams(e,r){return(n,i)=>{try{return fB.isTokenDescriptor(n)?fB.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new dB.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new dB.default,n.isOptional):this.resolve(n.token,e,n.isOptional):fB.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(s){throw new Error(xTt.formatErrorCtor(r,i,s))}}}ensureNotDisposed(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")}};Z0.instance=new One;Z0.default=Z0.instance});var jIe=L(Bne=>{"use strict";Object.defineProperty(Bne,"__esModule",{value:!0});var _Tt=Ky(),X0=pg(),Nne=nB(),wTt=Pne();function STt(){return function(t){let e=_Tt.getParamInfo(t);return class extends t{constructor(...r){super(...r.concat(e.slice(r.length).map((n,i)=>{try{return Nne.isTokenDescriptor(n)?Nne.isTransformDescriptor(n)?n.multiple?X0.instance.resolve(n.transform).transform(X0.instance.resolveAll(n.token),...n.transformArgs):X0.instance.resolve(n.transform).transform(X0.instance.resolve(n.token),...n.transformArgs):n.multiple?X0.instance.resolveAll(n.token):X0.instance.resolve(n.token):Nne.isTransformDescriptor(n)?X0.instance.resolve(n.transform).transform(X0.instance.resolve(n.token),...n.transformArgs):X0.instance.resolve(n)}catch(s){let a=i+r.length;throw new Error(wTt.formatErrorCtor(t,a,s))}})))}}}}Bne.default=STt});var qIe=L(Une=>{"use strict";Object.defineProperty(Une,"__esModule",{value:!0});var ATt=Ky();function ETt(t,e){let r={token:t,multiple:!1,isOptional:e&&e.isOptional};return ATt.defineInjectionTokenMetadata(r)}Une.default=ETt});var hB=L(Mne=>{"use strict";Object.defineProperty(Mne,"__esModule",{value:!0});var TTt=Ky(),CTt=pg(),zIe=pg();function kTt(t){return function(e){CTt.typeInfo.set(e,TTt.getParamInfo(e)),t&&t.token&&(Array.isArray(t.token)?t.token.forEach(r=>{zIe.instance.register(r,e)}):zIe.instance.register(t.token,e))}}Mne.default=kTt});var WIe=L(Lne=>{"use strict";Object.defineProperty(Lne,"__esModule",{value:!0});var DTt=(J7(),He(Y7)),ITt=pg();function FTt(t=[]){return function(e){return t.forEach(r=>{var{token:n,options:i}=r,s=DTt.__rest(r,["token","options"]);return ITt.instance.register(n,s,i)}),e}}Lne.default=FTt});var HIe=L($ne=>{"use strict";Object.defineProperty($ne,"__esModule",{value:!0});var PTt=hB(),RTt=pg();function OTt(){return function(t){PTt.default()(t),RTt.instance.registerSingleton(t)}}$ne.default=OTt});var VIe=L(jne=>{"use strict";Object.defineProperty(jne,"__esModule",{value:!0});var NTt=Ky();function BTt(t,e){let r={token:t,multiple:!0,isOptional:e&&e.isOptional};return NTt.defineInjectionTokenMetadata(r)}jne.default=BTt});var GIe=L(qne=>{"use strict";Object.defineProperty(qne,"__esModule",{value:!0});var UTt=Ky();function MTt(t,e,...r){let n={token:t,multiple:!0,transform:e,transformArgs:r};return UTt.defineInjectionTokenMetadata(n)}qne.default=MTt});var KIe=L(zne=>{"use strict";Object.defineProperty(zne,"__esModule",{value:!0});var LTt=Ky();function $Tt(t,e,...r){return LTt.defineInjectionTokenMetadata(t,{transformToken:e,args:r})}zne.default=$Tt});var ZIe=L(Wne=>{"use strict";Object.defineProperty(Wne,"__esModule",{value:!0});var jTt=hB(),qTt=pg();function zTt(t,e){return function(r){jTt.default()(r),qTt.instance.register(e||r,r,{lifecycle:t})}}Wne.default=zTt});var XIe=L(Vf=>{"use strict";Object.defineProperty(Vf,"__esModule",{value:!0});var WTt=jIe();Object.defineProperty(Vf,"autoInjectable",{enumerable:!0,get:function(){return WTt.default}});var HTt=qIe();Object.defineProperty(Vf,"inject",{enumerable:!0,get:function(){return HTt.default}});var VTt=hB();Object.defineProperty(Vf,"injectable",{enumerable:!0,get:function(){return VTt.default}});var GTt=WIe();Object.defineProperty(Vf,"registry",{enumerable:!0,get:function(){return GTt.default}});var KTt=HIe();Object.defineProperty(Vf,"singleton",{enumerable:!0,get:function(){return KTt.default}});var ZTt=VIe();Object.defineProperty(Vf,"injectAll",{enumerable:!0,get:function(){return ZTt.default}});var XTt=GIe();Object.defineProperty(Vf,"injectAllWithTransform",{enumerable:!0,get:function(){return XTt.default}});var YTt=KIe();Object.defineProperty(Vf,"injectWithTransform",{enumerable:!0,get:function(){return YTt.default}});var JTt=ZIe();Object.defineProperty(Vf,"scoped",{enumerable:!0,get:function(){return JTt.default}})});var YIe=L(Hne=>{"use strict";Object.defineProperty(Hne,"__esModule",{value:!0});function QTt(t){let e;return r=>(e==null&&(e=t(r)),e)}Hne.default=QTt});var JIe=L(Vne=>{"use strict";Object.defineProperty(Vne,"__esModule",{value:!0});function eCt(t){let e=new WeakMap;return r=>{let n=e.get(r);return n==null&&(n=t(r),e.set(r,n)),n}}Vne.default=eCt});var QIe=L(Gne=>{"use strict";Object.defineProperty(Gne,"__esModule",{value:!0});function tCt(t,e,r,n=!0){let i,s;return a=>{let c=t(a);return(!n||s!==c)&&((s=c)?i=a.resolve(e):i=a.resolve(r)),i}}Gne.default=tCt});var eFe=L(P3=>{"use strict";Object.defineProperty(P3,"__esModule",{value:!0});var rCt=YIe();Object.defineProperty(P3,"instanceCachingFactory",{enumerable:!0,get:function(){return rCt.default}});var nCt=JIe();Object.defineProperty(P3,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return nCt.default}});var iCt=QIe();Object.defineProperty(P3,"predicateAwareClassFactory",{enumerable:!0,get:function(){return iCt.default}})});var tFe=L(mg=>{"use strict";Object.defineProperty(mg,"__esModule",{value:!0});var Kne=(J7(),He(Y7));if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var sCt=OIe();Object.defineProperty(mg,"Lifecycle",{enumerable:!0,get:function(){return sCt.Lifecycle}});Kne.__exportStar(XIe(),mg);Kne.__exportStar(eFe(),mg);Kne.__exportStar(Ane(),mg);var aCt=rB();Object.defineProperty(mg,"delay",{enumerable:!0,get:function(){return aCt.delay}});var oCt=pg();Object.defineProperty(mg,"container",{enumerable:!0,get:function(){return oCt.instance}})});var Jne=L(Jy=>{"use strict";var Zne;Object.defineProperty(Jy,"__esModule",{value:!0});Jy.PKCS12AttrSet=Jy.PKCS12Attribute=void 0;var Yne=(at(),He(st)),Yy=bt(),Ww=class{attrId="";attrValues=[];constructor(e={}){Object.assign(e)}};Jy.PKCS12Attribute=Ww;Yne.__decorate([(0,Yy.AsnProp)({type:Yy.AsnPropTypes.ObjectIdentifier})],Ww.prototype,"attrId",void 0);Yne.__decorate([(0,Yy.AsnProp)({type:Yy.AsnPropTypes.Any,repeated:"set"})],Ww.prototype,"attrValues",void 0);var Xne=Zne=class extends Yy.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Zne.prototype)}};Jy.PKCS12AttrSet=Xne;Jy.PKCS12AttrSet=Xne=Zne=Yne.__decorate([(0,Yy.AsnType)({type:Yy.AsnTypeTypes.Sequence,itemType:Ww})],Xne)});var rFe=L(R3=>{"use strict";var Qne;Object.defineProperty(R3,"__esModule",{value:!0});R3.AuthenticatedSafe=void 0;var cCt=(at(),He(st)),eie=bt(),uCt=b3(),tie=Qne=class extends eie.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Qne.prototype)}};R3.AuthenticatedSafe=tie;R3.AuthenticatedSafe=tie=Qne=cCt.__decorate([(0,eie.AsnType)({type:eie.AsnTypeTypes.Sequence,itemType:uCt.ContentInfo})],tie)});var rie=L(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.id_bagtypes=mi.id_pbewithSHAAnd40BitRC2_CBC=mi.id_pbeWithSHAAnd128BitRC2_CBC=mi.id_pbeWithSHAAnd2_KeyTripleDES_CBC=mi.id_pbeWithSHAAnd3_KeyTripleDES_CBC=mi.id_pbeWithSHAAnd40BitRC4=mi.id_pbeWithSHAAnd128BitRC4=mi.id_pkcs_12PbeIds=mi.id_pkcs_12=mi.id_pkcs=mi.id_rsadsi=void 0;mi.id_rsadsi="1.2.840.113549";mi.id_pkcs=`${mi.id_rsadsi}.1`;mi.id_pkcs_12=`${mi.id_pkcs}.12`;mi.id_pkcs_12PbeIds=`${mi.id_pkcs_12}.1`;mi.id_pbeWithSHAAnd128BitRC4=`${mi.id_pkcs_12PbeIds}.1`;mi.id_pbeWithSHAAnd40BitRC4=`${mi.id_pkcs_12PbeIds}.2`;mi.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${mi.id_pkcs_12PbeIds}.3`;mi.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${mi.id_pkcs_12PbeIds}.4`;mi.id_pbeWithSHAAnd128BitRC2_CBC=`${mi.id_pkcs_12PbeIds}.5`;mi.id_pbewithSHAAnd40BitRC2_CBC=`${mi.id_pkcs_12PbeIds}.6`;mi.id_bagtypes=`${mi.id_pkcs_12}.10.1`});var pB=L(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.id_pkcs_9=xc.id_SafeContents=xc.id_SecretBag=xc.id_CRLBag=xc.id_certBag=xc.id_pkcs8ShroudedKeyBag=xc.id_keyBag=void 0;var Hw=rie();xc.id_keyBag=`${Hw.id_bagtypes}.1`;xc.id_pkcs8ShroudedKeyBag=`${Hw.id_bagtypes}.2`;xc.id_certBag=`${Hw.id_bagtypes}.3`;xc.id_CRLBag=`${Hw.id_bagtypes}.4`;xc.id_SecretBag=`${Hw.id_bagtypes}.5`;xc.id_SafeContents=`${Hw.id_bagtypes}.6`;xc.id_pkcs_9="1.2.840.113549.1.9"});var iFe=L(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.id_sdsiCertificate=tf.id_x509Certificate=tf.id_certTypes=tf.CertBag=void 0;var nFe=(at(),He(st)),mB=bt(),lCt=pB(),O3=class{certId="";certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};tf.CertBag=O3;nFe.__decorate([(0,mB.AsnProp)({type:mB.AsnPropTypes.ObjectIdentifier})],O3.prototype,"certId",void 0);nFe.__decorate([(0,mB.AsnProp)({type:mB.AsnPropTypes.Any,context:0})],O3.prototype,"certValue",void 0);tf.id_certTypes=`${lCt.id_pkcs_9}.22`;tf.id_x509Certificate=`${tf.id_certTypes}.1`;tf.id_sdsiCertificate=`${tf.id_certTypes}.2`});var aFe=L(Y0=>{"use strict";Object.defineProperty(Y0,"__esModule",{value:!0});Y0.id_x509CRL=Y0.id_crlTypes=Y0.CRLBag=void 0;var sFe=(at(),He(st)),gB=bt(),fCt=pB(),N3=class{crlId="";crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};Y0.CRLBag=N3;sFe.__decorate([(0,gB.AsnProp)({type:gB.AsnPropTypes.ObjectIdentifier})],N3.prototype,"crlId",void 0);sFe.__decorate([(0,gB.AsnProp)({type:gB.AsnPropTypes.Any,context:0})],N3.prototype,"crltValue",void 0);Y0.id_crlTypes=`${fCt.id_pkcs_9}.23`;Y0.id_x509CRL=`${Y0.id_crlTypes}.1`});var uFe=L(Vw=>{"use strict";Object.defineProperty(Vw,"__esModule",{value:!0});Vw.EncryptedPrivateKeyInfo=Vw.EncryptedData=void 0;var oFe=(at(),He(st)),nie=bt(),cFe=hi(),B3=class extends nie.OctetString{};Vw.EncryptedData=B3;var U3=class{encryptionAlgorithm=new cFe.AlgorithmIdentifier;encryptedData=new B3;constructor(e={}){Object.assign(this,e)}};Vw.EncryptedPrivateKeyInfo=U3;oFe.__decorate([(0,nie.AsnProp)({type:cFe.AlgorithmIdentifier})],U3.prototype,"encryptionAlgorithm",void 0);oFe.__decorate([(0,nie.AsnProp)({type:B3})],U3.prototype,"encryptedData",void 0)});var lFe=L(Gf=>{"use strict";var iie;Object.defineProperty(Gf,"__esModule",{value:!0});Gf.PrivateKeyInfo=Gf.Attributes=Gf.PrivateKey=Gf.Version=void 0;var L3=(at(),He(st)),J0=bt(),aie=hi(),sie;(function(t){t[t.v1=0]="v1"})(sie||(Gf.Version=sie={}));var M3=class extends J0.OctetString{};Gf.PrivateKey=M3;var xB=iie=class extends J0.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,iie.prototype)}};Gf.Attributes=xB;Gf.Attributes=xB=iie=L3.__decorate([(0,J0.AsnType)({type:J0.AsnTypeTypes.Sequence,itemType:aie.Attribute})],xB);var Qy=class{version=sie.v1;privateKeyAlgorithm=new aie.AlgorithmIdentifier;privateKey=new M3;attributes;constructor(e={}){Object.assign(this,e)}};Gf.PrivateKeyInfo=Qy;L3.__decorate([(0,J0.AsnProp)({type:J0.AsnPropTypes.Integer})],Qy.prototype,"version",void 0);L3.__decorate([(0,J0.AsnProp)({type:aie.AlgorithmIdentifier})],Qy.prototype,"privateKeyAlgorithm",void 0);L3.__decorate([(0,J0.AsnProp)({type:M3})],Qy.prototype,"privateKey",void 0);L3.__decorate([(0,J0.AsnProp)({type:xB,implicit:!0,context:0,optional:!0})],Qy.prototype,"attributes",void 0)});var vB=L(yB=>{"use strict";Object.defineProperty(yB,"__esModule",{value:!0});var fFe=(at(),He(st));fFe.__exportStar(uFe(),yB);fFe.__exportStar(lFe(),yB)});var hFe=L($3=>{"use strict";Object.defineProperty($3,"__esModule",{value:!0});$3.KeyBag=void 0;var dCt=(at(),He(st)),hCt=vB(),dFe=bt(),oie=class extends hCt.PrivateKeyInfo{};$3.KeyBag=oie;$3.KeyBag=oie=dCt.__decorate([(0,dFe.AsnType)({type:dFe.AsnTypeTypes.Sequence})],oie)});var mFe=L(j3=>{"use strict";Object.defineProperty(j3,"__esModule",{value:!0});j3.PKCS8ShroudedKeyBag=void 0;var pCt=(at(),He(st)),mCt=vB(),pFe=bt(),cie=class extends mCt.EncryptedPrivateKeyInfo{};j3.PKCS8ShroudedKeyBag=cie;j3.PKCS8ShroudedKeyBag=cie=pCt.__decorate([(0,pFe.AsnType)({type:pFe.AsnTypeTypes.Sequence})],cie)});var xFe=L(_B=>{"use strict";Object.defineProperty(_B,"__esModule",{value:!0});_B.SecretBag=void 0;var gFe=(at(),He(st)),bB=bt(),q3=class{secretTypeId="";secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};_B.SecretBag=q3;gFe.__decorate([(0,bB.AsnProp)({type:bB.AsnPropTypes.ObjectIdentifier})],q3.prototype,"secretTypeId",void 0);gFe.__decorate([(0,bB.AsnProp)({type:bB.AsnPropTypes.Any,context:0})],q3.prototype,"secretValue",void 0)});var yFe=L(gg=>{"use strict";Object.defineProperty(gg,"__esModule",{value:!0});var Gw=(at(),He(st));Gw.__exportStar(iFe(),gg);Gw.__exportStar(aFe(),gg);Gw.__exportStar(hFe(),gg);Gw.__exportStar(mFe(),gg);Gw.__exportStar(xFe(),gg);Gw.__exportStar(pB(),gg)});var lie=L(wB=>{"use strict";Object.defineProperty(wB,"__esModule",{value:!0});wB.MacData=void 0;var uie=(at(),He(st)),vFe=dne(),Kw=bt(),Zw=class{mac=new vFe.DigestInfo;macSalt=new Kw.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};wB.MacData=Zw;uie.__decorate([(0,Kw.AsnProp)({type:vFe.DigestInfo})],Zw.prototype,"mac",void 0);uie.__decorate([(0,Kw.AsnProp)({type:Kw.OctetString})],Zw.prototype,"macSalt",void 0);uie.__decorate([(0,Kw.AsnProp)({type:Kw.AsnPropTypes.Integer,defaultValue:1})],Zw.prototype,"iterations",void 0)});var wFe=L(AB=>{"use strict";Object.defineProperty(AB,"__esModule",{value:!0});AB.PFX=void 0;var fie=(at(),He(st)),SB=bt(),bFe=b3(),_Fe=lie(),Xw=class{version=3;authSafe=new bFe.ContentInfo;macData=new _Fe.MacData;constructor(e={}){Object.assign(this,e)}};AB.PFX=Xw;fie.__decorate([(0,SB.AsnProp)({type:SB.AsnPropTypes.Integer})],Xw.prototype,"version",void 0);fie.__decorate([(0,SB.AsnProp)({type:bFe.ContentInfo})],Xw.prototype,"authSafe",void 0);fie.__decorate([(0,SB.AsnProp)({type:_Fe.MacData,optional:!0})],Xw.prototype,"macData",void 0)});var SFe=L(tv=>{"use strict";var die;Object.defineProperty(tv,"__esModule",{value:!0});tv.SafeContents=tv.SafeBag=void 0;var EB=(at(),He(st)),xg=bt(),gCt=Jne(),ev=class{bagId="";bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};tv.SafeBag=ev;EB.__decorate([(0,xg.AsnProp)({type:xg.AsnPropTypes.ObjectIdentifier})],ev.prototype,"bagId",void 0);EB.__decorate([(0,xg.AsnProp)({type:xg.AsnPropTypes.Any,context:0})],ev.prototype,"bagValue",void 0);EB.__decorate([(0,xg.AsnProp)({type:gCt.PKCS12Attribute,repeated:"set",optional:!0})],ev.prototype,"bagAttributes",void 0);var hie=die=class extends xg.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,die.prototype)}};tv.SafeContents=hie;tv.SafeContents=hie=die=EB.__decorate([(0,xg.AsnType)({type:xg.AsnTypeTypes.Sequence,itemType:ev})],hie)});var AFe=L(Q0=>{"use strict";Object.defineProperty(Q0,"__esModule",{value:!0});var rv=(at(),He(st));rv.__exportStar(Jne(),Q0);rv.__exportStar(rFe(),Q0);rv.__exportStar(yFe(),Q0);rv.__exportStar(lie(),Q0);rv.__exportStar(rie(),Q0);rv.__exportStar(wFe(),Q0);rv.__exportStar(SFe(),Q0)});var EFe=L(Ie=>{"use strict";var pie,mie,gie;Object.defineProperty(Ie,"__esModule",{value:!0});Ie.DateOfBirth=Ie.UnstructuredAddress=Ie.UnstructuredName=Ie.EmailAddress=Ie.EncryptedPrivateKeyInfo=Ie.UserPKCS12=Ie.Pkcs7PDU=Ie.PKCS9String=Ie.id_at_pseudonym=Ie.crlTypes=Ie.id_certTypes=Ie.id_smime=Ie.id_pkcs9_mr_signingTimeMatch=Ie.id_pkcs9_mr_caseIgnoreMatch=Ie.id_pkcs9_sx_signingTime=Ie.id_pkcs9_sx_pkcs9String=Ie.id_pkcs9_at_countryOfResidence=Ie.id_pkcs9_at_countryOfCitizenship=Ie.id_pkcs9_at_gender=Ie.id_pkcs9_at_placeOfBirth=Ie.id_pkcs9_at_dateOfBirth=Ie.id_ietf_at=Ie.id_pkcs9_at_pkcs7PDU=Ie.id_pkcs9_at_sequenceNumber=Ie.id_pkcs9_at_randomNonce=Ie.id_pkcs9_at_encryptedPrivateKeyInfo=Ie.id_pkcs9_at_pkcs15Token=Ie.id_pkcs9_at_userPKCS12=Ie.id_pkcs9_at_localKeyId=Ie.id_pkcs9_at_friendlyName=Ie.id_pkcs9_at_smimeCapabilities=Ie.id_pkcs9_at_extensionRequest=Ie.id_pkcs9_at_signingDescription=Ie.id_pkcs9_at_extendedCertificateAttributes=Ie.id_pkcs9_at_unstructuredAddress=Ie.id_pkcs9_at_challengePassword=Ie.id_pkcs9_at_counterSignature=Ie.id_pkcs9_at_signingTime=Ie.id_pkcs9_at_messageDigest=Ie.id_pkcs9_at_contentType=Ie.id_pkcs9_at_unstructuredName=Ie.id_pkcs9_at_emailAddress=Ie.id_pkcs9_oc_naturalPerson=Ie.id_pkcs9_oc_pkcsEntity=Ie.id_pkcs9_mr=Ie.id_pkcs9_sx=Ie.id_pkcs9_at=Ie.id_pkcs9_oc=Ie.id_pkcs9_mo=Ie.id_pkcs9=void 0;Ie.SMIMECapabilities=Ie.SMIMECapability=Ie.SigningDescription=Ie.LocalKeyId=Ie.FriendlyName=Ie.ExtendedCertificateAttributes=Ie.ExtensionRequest=Ie.ChallengePassword=Ie.CounterSignature=Ie.SequenceNumber=Ie.RandomNonce=Ie.SigningTime=Ie.MessageDigest=Ie.ContentType=Ie.Pseudonym=Ie.CountryOfResidence=Ie.CountryOfCitizenship=Ie.Gender=Ie.PlaceOfBirth=void 0;var ei=(at(),He(st)),Ar=bt(),Nie=ei.__importStar(b3()),xCt=ei.__importStar(AFe()),yCt=ei.__importStar(vB()),ep=ei.__importStar(hi()),vCt=ei.__importStar(Ire());Ie.id_pkcs9="1.2.840.113549.1.9";Ie.id_pkcs9_mo=`${Ie.id_pkcs9}.0`;Ie.id_pkcs9_oc=`${Ie.id_pkcs9}.24`;Ie.id_pkcs9_at=`${Ie.id_pkcs9}.25`;Ie.id_pkcs9_sx=`${Ie.id_pkcs9}.26`;Ie.id_pkcs9_mr=`${Ie.id_pkcs9}.27`;Ie.id_pkcs9_oc_pkcsEntity=`${Ie.id_pkcs9_oc}.1`;Ie.id_pkcs9_oc_naturalPerson=`${Ie.id_pkcs9_oc}.2`;Ie.id_pkcs9_at_emailAddress=`${Ie.id_pkcs9}.1`;Ie.id_pkcs9_at_unstructuredName=`${Ie.id_pkcs9}.2`;Ie.id_pkcs9_at_contentType=`${Ie.id_pkcs9}.3`;Ie.id_pkcs9_at_messageDigest=`${Ie.id_pkcs9}.4`;Ie.id_pkcs9_at_signingTime=`${Ie.id_pkcs9}.5`;Ie.id_pkcs9_at_counterSignature=`${Ie.id_pkcs9}.6`;Ie.id_pkcs9_at_challengePassword=`${Ie.id_pkcs9}.7`;Ie.id_pkcs9_at_unstructuredAddress=`${Ie.id_pkcs9}.8`;Ie.id_pkcs9_at_extendedCertificateAttributes=`${Ie.id_pkcs9}.9`;Ie.id_pkcs9_at_signingDescription=`${Ie.id_pkcs9}.13`;Ie.id_pkcs9_at_extensionRequest=`${Ie.id_pkcs9}.14`;Ie.id_pkcs9_at_smimeCapabilities=`${Ie.id_pkcs9}.15`;Ie.id_pkcs9_at_friendlyName=`${Ie.id_pkcs9}.20`;Ie.id_pkcs9_at_localKeyId=`${Ie.id_pkcs9}.21`;Ie.id_pkcs9_at_userPKCS12="2.16.840.1.113730.3.1.216";Ie.id_pkcs9_at_pkcs15Token=`${Ie.id_pkcs9_at}.1`;Ie.id_pkcs9_at_encryptedPrivateKeyInfo=`${Ie.id_pkcs9_at}.2`;Ie.id_pkcs9_at_randomNonce=`${Ie.id_pkcs9_at}.3`;Ie.id_pkcs9_at_sequenceNumber=`${Ie.id_pkcs9_at}.4`;Ie.id_pkcs9_at_pkcs7PDU=`${Ie.id_pkcs9_at}.5`;Ie.id_ietf_at="1.3.6.1.5.5.7.9";Ie.id_pkcs9_at_dateOfBirth=`${Ie.id_ietf_at}.1`;Ie.id_pkcs9_at_placeOfBirth=`${Ie.id_ietf_at}.2`;Ie.id_pkcs9_at_gender=`${Ie.id_ietf_at}.3`;Ie.id_pkcs9_at_countryOfCitizenship=`${Ie.id_ietf_at}.4`;Ie.id_pkcs9_at_countryOfResidence=`${Ie.id_ietf_at}.5`;Ie.id_pkcs9_sx_pkcs9String=`${Ie.id_pkcs9_sx}.1`;Ie.id_pkcs9_sx_signingTime=`${Ie.id_pkcs9_sx}.2`;Ie.id_pkcs9_mr_caseIgnoreMatch=`${Ie.id_pkcs9_mr}.1`;Ie.id_pkcs9_mr_signingTimeMatch=`${Ie.id_pkcs9_mr}.2`;Ie.id_smime=`${Ie.id_pkcs9}.16`;Ie.id_certTypes=`${Ie.id_pkcs9}.22`;Ie.crlTypes=`${Ie.id_pkcs9}.23`;Ie.id_at_pseudonym=`${vCt.id_at}.65`;var z3=class extends ep.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};Ie.PKCS9String=z3;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.IA5String})],z3.prototype,"ia5String",void 0);Ie.PKCS9String=z3=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],z3);var xie=class extends Nie.ContentInfo{};Ie.Pkcs7PDU=xie;Ie.Pkcs7PDU=xie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],xie);var yie=class extends xCt.PFX{};Ie.UserPKCS12=yie;Ie.UserPKCS12=yie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],yie);var vie=class extends yCt.EncryptedPrivateKeyInfo{};Ie.EncryptedPrivateKeyInfo=vie;Ie.EncryptedPrivateKeyInfo=vie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],vie);var TB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.EmailAddress=TB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.IA5String})],TB.prototype,"value",void 0);Ie.EmailAddress=TB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],TB);var bie=class extends z3{};Ie.UnstructuredName=bie;Ie.UnstructuredName=bie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],bie);var _ie=class extends ep.DirectoryString{};Ie.UnstructuredAddress=_ie;Ie.UnstructuredAddress=_ie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],_ie);var CB=class{value;constructor(e=new Date){this.value=e}};Ie.DateOfBirth=CB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.GeneralizedTime})],CB.prototype,"value",void 0);Ie.DateOfBirth=CB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],CB);var wie=class extends ep.DirectoryString{};Ie.PlaceOfBirth=wie;Ie.PlaceOfBirth=wie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],wie);var kB=class{value;constructor(e="M"){this.value=e}toString(){return this.value}};Ie.Gender=kB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.PrintableString})],kB.prototype,"value",void 0);Ie.Gender=kB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],kB);var W3=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.CountryOfCitizenship=W3;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.PrintableString})],W3.prototype,"value",void 0);Ie.CountryOfCitizenship=W3=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],W3);var Sie=class extends W3{};Ie.CountryOfResidence=Sie;Ie.CountryOfResidence=Sie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Sie);var Aie=class extends ep.DirectoryString{};Ie.Pseudonym=Aie;Ie.Pseudonym=Aie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Aie);var DB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.ContentType=DB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.ObjectIdentifier})],DB.prototype,"value",void 0);Ie.ContentType=DB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],DB);var Eie=class extends Ar.OctetString{};Ie.MessageDigest=Eie;var Tie=class extends ep.Time{};Ie.SigningTime=Tie;Ie.SigningTime=Tie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Tie);var Cie=class extends Ar.OctetString{};Ie.RandomNonce=Cie;var IB=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};Ie.SequenceNumber=IB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.Integer})],IB.prototype,"value",void 0);Ie.SequenceNumber=IB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],IB);var kie=class extends Nie.SignerInfo{};Ie.CounterSignature=kie;Ie.CounterSignature=kie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],kie);var Die=class extends ep.DirectoryString{};Ie.ChallengePassword=Die;Ie.ChallengePassword=Die=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],Die);var Iie=pie=class extends ep.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,pie.prototype)}};Ie.ExtensionRequest=Iie;Ie.ExtensionRequest=Iie=pie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],Iie);var Fie=mie=class extends Ar.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,mie.prototype)}};Ie.ExtendedCertificateAttributes=Fie;Ie.ExtendedCertificateAttributes=Fie=mie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Set,itemType:Nie.Attribute})],Fie);var FB=class{value;constructor(e=""){this.value=e}toString(){return this.value}};Ie.FriendlyName=FB;ei.__decorate([(0,Ar.AsnProp)({type:Ar.AsnPropTypes.BmpString})],FB.prototype,"value",void 0);Ie.FriendlyName=FB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Choice})],FB);var Pie=class extends Ar.OctetString{};Ie.LocalKeyId=Pie;var Rie=class extends ep.DirectoryString{};Ie.SigningDescription=Rie;var PB=class extends ep.AlgorithmIdentifier{};Ie.SMIMECapability=PB;Ie.SMIMECapability=PB=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence})],PB);var Oie=gie=class extends Ar.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,gie.prototype)}};Ie.SMIMECapabilities=Oie;Ie.SMIMECapabilities=Oie=gie=ei.__decorate([(0,Ar.AsnType)({type:Ar.AsnTypeTypes.Sequence,itemType:PB})],Oie)});var Lie=L(H3=>{"use strict";var Bie;Object.defineProperty(H3,"__esModule",{value:!0});H3.Attributes=void 0;var bCt=(at(),He(st)),Uie=bt(),_Ct=hi(),Mie=Bie=class extends Uie.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,Bie.prototype)}};H3.Attributes=Mie;H3.Attributes=Mie=Bie=bCt.__decorate([(0,Uie.AsnType)({type:Uie.AsnTypeTypes.Sequence,itemType:_Ct.Attribute})],Mie)});var $ie=L(NB=>{"use strict";Object.defineProperty(NB,"__esModule",{value:!0});NB.CertificationRequestInfo=void 0;var OB=(at(),He(st)),V3=bt(),RB=hi(),TFe=Lie(),nv=class{version=0;subject=new RB.Name;subjectPKInfo=new RB.SubjectPublicKeyInfo;attributes=new TFe.Attributes;constructor(e={}){Object.assign(this,e)}};NB.CertificationRequestInfo=nv;OB.__decorate([(0,V3.AsnProp)({type:V3.AsnPropTypes.Integer})],nv.prototype,"version",void 0);OB.__decorate([(0,V3.AsnProp)({type:RB.Name})],nv.prototype,"subject",void 0);OB.__decorate([(0,V3.AsnProp)({type:RB.SubjectPublicKeyInfo})],nv.prototype,"subjectPKInfo",void 0);OB.__decorate([(0,V3.AsnProp)({type:TFe.Attributes,implicit:!0,context:0,optional:!0})],nv.prototype,"attributes",void 0)});var DFe=L(UB=>{"use strict";Object.defineProperty(UB,"__esModule",{value:!0});UB.CertificationRequest=void 0;var jie=(at(),He(st)),BB=bt(),CFe=hi(),kFe=$ie(),Yw=class{certificationRequestInfo=new kFe.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new CFe.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};UB.CertificationRequest=Yw;jie.__decorate([(0,BB.AsnProp)({type:kFe.CertificationRequestInfo,raw:!0})],Yw.prototype,"certificationRequestInfo",void 0);jie.__decorate([(0,BB.AsnProp)({type:CFe.AlgorithmIdentifier})],Yw.prototype,"signatureAlgorithm",void 0);jie.__decorate([(0,BB.AsnProp)({type:BB.AsnPropTypes.BitString})],Yw.prototype,"signature",void 0)});var IFe=L(G3=>{"use strict";Object.defineProperty(G3,"__esModule",{value:!0});var qie=(at(),He(st));qie.__exportStar(Lie(),G3);qie.__exportStar(DFe(),G3);qie.__exportStar($ie(),G3)});var pPe=L(Wt=>{"use strict";H3e();var gt=bt(),Fr=hi(),Ot=tee(),yt=(at(),He(st)),wCt=b3(),YB=_Ie(),Cu=dne(),ls=tFe(),Zie=EFe(),JB=IFe();function BD(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var mt=BD(Fr),Tu=BD(wCt),Ps=BD(YB),us=BD(Cu),sS=BD(Zie),lS="crypto.algorithm",QB=class{getAlgorithms(){return ls.container.resolveAll(lS)}toAsnAlgorithm(e){({...e});for(let r of this.getAlgorithms()){let n=r.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let r=new Fr.AlgorithmIdentifier({algorithm:e.name});if("parameters"in e){let n=e;r.parameters=n.parameters}return r}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(let n of this.getAlgorithms()){let i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}},Xf="crypto.algorithmProvider";ls.container.registerSingleton(Xf,QB);var $B,Fu="1.3.36.3.3.2.8.1.1",FFe=`${Fu}.1`,PFe=`${Fu}.2`,RFe=`${Fu}.3`,OFe=`${Fu}.4`,NFe=`${Fu}.5`,BFe=`${Fu}.6`,UFe=`${Fu}.7`,MFe=`${Fu}.8`,LFe=`${Fu}.9`,$Fe=`${Fu}.10`,jFe=`${Fu}.11`,qFe=`${Fu}.12`,zFe=`${Fu}.13`,WFe=`${Fu}.14`,HFe="brainpoolP160r1",VFe="brainpoolP160t1",GFe="brainpoolP192r1",KFe="brainpoolP192t1",ZFe="brainpoolP224r1",XFe="brainpoolP224t1",YFe="brainpoolP256r1",JFe="brainpoolP256t1",QFe="brainpoolP320r1",ePe="brainpoolP320t1",tPe="brainpoolP384r1",rPe="brainpoolP384t1",nPe="brainpoolP512r1",iPe="brainpoolP512t1",ta="ECDSA";Wt.EcAlgorithm=$B=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ta.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Ps.ecdsaWithSHA1;case"sha-256":return Ps.ecdsaWithSHA256;case"sha-384":return Ps.ecdsaWithSHA384;case"sha-512":return Ps.ecdsaWithSHA512}else if("namedCurve"in e){let r="";switch(e.namedCurve){case"P-256":r=Ps.id_secp256r1;break;case"K-256":r=$B.SECP256K1;break;case"P-384":r=Ps.id_secp384r1;break;case"P-521":r=Ps.id_secp521r1;break;case HFe:r=FFe;break;case VFe:r=PFe;break;case GFe:r=RFe;break;case KFe:r=OFe;break;case ZFe:r=NFe;break;case XFe:r=BFe;break;case YFe:r=UFe;break;case JFe:r=MFe;break;case QFe:r=LFe;break;case ePe:r=$Fe;break;case tPe:r=jFe;break;case rPe:r=qFe;break;case nPe:r=zFe;break;case iPe:r=WFe;break}if(r)return new Fr.AlgorithmIdentifier({algorithm:Ps.id_ecPublicKey,parameters:gt.AsnConvert.serialize(new Ps.ECParameters({namedCurve:r}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Ps.id_ecdsaWithSHA1:return{name:ta,hash:{name:"SHA-1"}};case Ps.id_ecdsaWithSHA256:return{name:ta,hash:{name:"SHA-256"}};case Ps.id_ecdsaWithSHA384:return{name:ta,hash:{name:"SHA-384"}};case Ps.id_ecdsaWithSHA512:return{name:ta,hash:{name:"SHA-512"}};case Ps.id_ecPublicKey:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(gt.AsnConvert.parse(e.parameters,Ps.ECParameters).namedCurve){case Ps.id_secp256r1:return{name:ta,namedCurve:"P-256"};case $B.SECP256K1:return{name:ta,namedCurve:"K-256"};case Ps.id_secp384r1:return{name:ta,namedCurve:"P-384"};case Ps.id_secp521r1:return{name:ta,namedCurve:"P-521"};case FFe:return{name:ta,namedCurve:HFe};case PFe:return{name:ta,namedCurve:VFe};case RFe:return{name:ta,namedCurve:GFe};case OFe:return{name:ta,namedCurve:KFe};case NFe:return{name:ta,namedCurve:ZFe};case BFe:return{name:ta,namedCurve:XFe};case UFe:return{name:ta,namedCurve:YFe};case MFe:return{name:ta,namedCurve:JFe};case LFe:return{name:ta,namedCurve:QFe};case $Fe:return{name:ta,namedCurve:ePe};case jFe:return{name:ta,namedCurve:tPe};case qFe:return{name:ta,namedCurve:rPe};case zFe:return{name:ta,namedCurve:nPe};case WFe:return{name:ta,namedCurve:iPe}}}}return null}};Wt.EcAlgorithm.SECP256K1="1.3.132.0.10";Wt.EcAlgorithm=$B=yt.__decorate([ls.injectable()],Wt.EcAlgorithm);ls.container.registerSingleton(lS,Wt.EcAlgorithm);var lPe=Symbol("name"),fPe=Symbol("value"),qn=class{constructor(e,r={},n=""){this[lPe]=e,this[fPe]=n;for(let i in r)this[i]=r[i]}};qn.NAME=lPe;qn.VALUE=fPe;var eU=class{static toTextObject(e){let r=new qn("Algorithm Identifier",{},rf.toString(e.algorithm));if(e.parameters)if(e.algorithm===Ps.id_ecPublicKey){let n=new Wt.EcAlgorithm().toWebAlgorithm(e);n&&"namedCurve"in n?r["Named Curve"]=n.namedCurve:r.Parameters=e.parameters}else r.Parameters=e.parameters;return r}},rf=class{static toString(e){let r=this.items[e];return r||e}};rf.items={[us.id_sha1]:"sha1",[us.id_sha224]:"sha224",[us.id_sha256]:"sha256",[us.id_sha384]:"sha384",[us.id_sha512]:"sha512",[us.id_rsaEncryption]:"rsaEncryption",[us.id_sha1WithRSAEncryption]:"sha1WithRSAEncryption",[us.id_sha224WithRSAEncryption]:"sha224WithRSAEncryption",[us.id_sha256WithRSAEncryption]:"sha256WithRSAEncryption",[us.id_sha384WithRSAEncryption]:"sha384WithRSAEncryption",[us.id_sha512WithRSAEncryption]:"sha512WithRSAEncryption",[Ps.id_ecPublicKey]:"ecPublicKey",[Ps.id_ecdsaWithSHA1]:"ecdsaWithSHA1",[Ps.id_ecdsaWithSHA224]:"ecdsaWithSHA224",[Ps.id_ecdsaWithSHA256]:"ecdsaWithSHA256",[Ps.id_ecdsaWithSHA384]:"ecdsaWithSHA384",[Ps.id_ecdsaWithSHA512]:"ecdsaWithSHA512",[mt.id_kp_serverAuth]:"TLS WWW server authentication",[mt.id_kp_clientAuth]:"TLS WWW client authentication",[mt.id_kp_codeSigning]:"Code Signing",[mt.id_kp_emailProtection]:"E-mail Protection",[mt.id_kp_timeStamping]:"Time Stamping",[mt.id_kp_OCSPSigning]:"OCSP Signing",[Tu.id_signedData]:"Signed Data"};var Yf=class{static serialize(e){return this.serializeObj(e).join(`
1015
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,r=0){let n=[],i=this.pad(r++),s="",a=e[qn.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[qn.NAME]}:${s}`),i=this.pad(r);for(let c in e){if(typeof c=="symbol")continue;let d=e[c],h=c?`${c}: `:"";if(typeof d=="string"||typeof d=="number"||typeof d=="boolean")n.push(`${i}${h}${d}`);else if(d instanceof Date)n.push(`${i}${h}${d.toUTCString()}`);else if(Array.isArray(d))for(let p of d)p[qn.NAME]=c,n.push(...this.serializeObj(p,r));else if(d instanceof qn)d[qn.NAME]=c,n.push(...this.serializeObj(d,r));else if(Ot.BufferSourceConverter.isBufferSource(d))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(d,r+1))):n.push(...this.serializeBufferSource(d,r));else if("toTextObject"in d){let p=d.toTextObject();p[qn.NAME]=c,n.push(...this.serializeObj(p,r))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,r=0){let n=this.pad(r),i=Ot.BufferSourceConverter.toUint8Array(e),s=[];for(let a=0;a<i.length;){let c=[];for(let d=0;d<16&&a<i.length;d++){d===8&&c.push("");let h=i[a++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};Yf.oidSerializer=rf;Yf.algorithmSerializer=eU;var Jw,vh=class t{get rawData(){return yt.__classPrivateFieldGet(this,Jw,"f")||yt.__classPrivateFieldSet(this,Jw,gt.AsnConvert.serialize(this.asn),"f"),yt.__classPrivateFieldGet(this,Jw,"f")}constructor(...e){Jw.set(this,void 0),Ot.BufferSourceConverter.isBufferSource(e[0])?(this.asn=gt.AsnConvert.parse(e[0],e[1]),yt.__classPrivateFieldSet(this,Jw,Ot.BufferSourceConverter.toArrayBuffer(e[0]),"f"),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(e){return e instanceof t?Ot.isEqual(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return gt.AsnConvert.toString(this.rawData);case"text":return Yf.serialize(this.toTextObject());case"hex":return Ot.Convert.ToHex(this.rawData);case"base64":return Ot.Convert.ToBase64(this.rawData);case"base64url":return Ot.Convert.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new qn(this.getTextName(),{},e)}};Jw=new WeakMap;vh.NAME="ASN";var ku=class t extends vh{constructor(...e){let r;Ot.BufferSourceConverter.isBufferSource(e[0])?r=Ot.BufferSourceConverter.toArrayBuffer(e[0]):r=gt.AsnConvert.serialize(new Fr.Extension({extnID:e[0],critical:e[1],extnValue:new gt.OctetString(Ot.BufferSourceConverter.toArrayBuffer(e[2]))})),super(r,Fr.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[qn.NAME]===t.NAME&&(e[qn.NAME]=rf.toString(this.type)),e}},dPe,aS=class t{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[dPe]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(t.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(t.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,r){return this.items.forEach(e,r)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=t.DEFAULT){let r=this.items.get(e.toLowerCase());if(!r)throw new Error(`Cannot get Crypto by name '${e}'`);return r}set(e,r){if(typeof e=="string"){if(!r)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),r)}else this.items.set(t.DEFAULT,e);return this}};dPe=Symbol.toStringTag;aS.DEFAULT="default";var Rs=new aS,SCt=/^[0-2](?:\.[1-9][0-9]*)+$/;function ACt(t){return new RegExp(SCt).test(t)}var wD=class{constructor(e={}){this.items={};for(let r in e)this.register(r,e[r])}get(e){return this.items[e]||null}findId(e){return ACt(e)?e:this.get(e)}register(e,r){this.items[e]=r,this.items[r]=e}},Du=new wD;Du.register("CN","2.5.4.3");Du.register("L","2.5.4.7");Du.register("ST","2.5.4.8");Du.register("O","2.5.4.10");Du.register("OU","2.5.4.11");Du.register("C","2.5.4.6");Du.register("DC","0.9.2342.19200300.100.1.25");Du.register("E","1.2.840.113549.1.9.1");Du.register("G","2.5.4.42");Du.register("I","2.5.4.43");Du.register("SN","2.5.4.4");Du.register("T","2.5.4.12");function ECt(t,e){return`\\${Ot.Convert.ToHex(Ot.Convert.FromUtf8String(e)).toUpperCase()}`}function TCt(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,ECt)}var Ka=class t{static isASCII(e){for(let r=0;r<e.length;r++)if(e.charCodeAt(r)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,r={}){this.extraNames=new wD,this.asn=new Fr.Name;for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)){let i=r[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof Fr.Name?this.asn=e:Ot.BufferSourceConverter.isBufferSource(e)?this.asn=gt.AsnConvert.parse(e,Fr.Name):this.asn=this.fromJSON(e)}getField(e){let r=this.extraNames.findId(e)||Du.findId(e),n=[];for(let i of this.asn)for(let s of i)s.type===r&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||Du.get(e)}toString(){return this.asn.map(e=>e.map(r=>{let n=this.getName(r.type)||r.type,i=r.value.anyValue?`#${Ot.Convert.ToHex(r.value.anyValue)}`:TCt(r.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;let r=[];for(let n of this.asn){let i={};for(let s of n){let a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${Ot.Convert.ToHex(s.value.anyValue)}`:s.value.toString())}r.push(i)}return r}fromString(e){let r=new Fr.Name,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,c]=i,d=c[c.length-1];(d===","||d==="+")&&(c=c.slice(0,c.length-1),i[3]=d);let h=i[3];a=this.getTypeOid(a);let p=this.createAttribute(a,c);s==="+"?r[r.length-1].push(p):r.push(new Fr.RelativeDistinguishedName([p])),s=h}return r}fromJSON(e){let r=new Fr.Name;for(let n of e){let i=new Fr.RelativeDistinguishedName;for(let s in n){let a=this.getTypeOid(s),c=n[s];for(let d of c){let h=this.createAttribute(a,d);i.push(h)}}r.push(i)}return r}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,r){let n=new Fr.AttributeTypeAndValue({type:e});if(typeof r=="object")for(let i in r)switch(i){case"ia5String":n.value.ia5String=r[i];break;case"utf8String":n.value.utf8String=r[i];break;case"universalString":n.value.universalString=r[i];break;case"bmpString":n.value.bmpString=r[i];break;case"printableString":n.value.printableString=r[i];break}else if(r[0]==="#")n.value.anyValue=Ot.Convert.FromHex(r.slice(1));else{let i=this.processStringValue(r);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:t.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){let r=/"(.*?[^\\])?"/.exec(e);return r&&(e=r[1]),e.replace(/\\0a/ig,`
1016
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return gt.AsnConvert.serialize(this.asn)}async getThumbprint(...e){var r;let n,i="SHA-1";return e.length>=1&&!(!((r=e[0])===null||r===void 0)&&r.subtle)?(i=e[0]||i,n=e[1]||Rs.get()):n=e[0]||Rs.get(),await n.subtle.digest(i,this.toArrayBuffer())}},hPe="Cannot initialize GeneralName from ASN.1 data.",sPe=`${hPe} Unsupported string format in use.`,CCt=`${hPe} Value doesn't match to GUID regular expression.`,aPe=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,oPe="1.3.6.1.4.1.311.25.1",cPe="1.3.6.1.4.1.311.20.2.3",jB="dns",qB="dn",zB="email",WB="ip",HB="url",VB="guid",GB="upn",K3="id",Kf=class extends vh{constructor(...e){let r;if(e.length===2)switch(e[0]){case qB:{let n=new Ka(e[1]).toArrayBuffer(),i=gt.AsnConvert.parse(n,mt.Name);r=new mt.GeneralName({directoryName:i});break}case jB:r=new mt.GeneralName({dNSName:e[1]});break;case zB:r=new mt.GeneralName({rfc822Name:e[1]});break;case VB:{let n=new RegExp(aPe,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");let i=n.slice(1).map((s,a)=>a<3?Ot.Convert.ToHex(new Uint8Array(Ot.Convert.FromHex(s)).reverse()):s).join("");r=new mt.GeneralName({otherName:new mt.OtherName({typeId:oPe,value:gt.AsnConvert.serialize(new gt.OctetString(Ot.Convert.FromHex(i)))})});break}case WB:r=new mt.GeneralName({iPAddress:e[1]});break;case K3:r=new mt.GeneralName({registeredID:e[1]});break;case GB:{r=new mt.GeneralName({otherName:new mt.OtherName({typeId:cPe,value:gt.AsnConvert.serialize(gt.AsnUtf8StringConverter.toASN(e[1]))})});break}case HB:r=new mt.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else Ot.BufferSourceConverter.isBufferSource(e[0])?r=gt.AsnConvert.parse(e[0],mt.GeneralName):r=e[0];super(r)}onInit(e){if(e.dNSName!=null)this.type=jB,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=zB,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=WB,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=HB,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=K3,this.value=e.registeredID;else if(e.directoryName!=null)this.type=qB,this.value=new Ka(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===oPe){this.type=VB;let r=gt.AsnConvert.parse(e.otherName.value,gt.OctetString),n=new RegExp(aPe,"i").exec(Ot.Convert.ToHex(r));if(!n)throw new Error(CCt);this.value=n.slice(1).map((i,s)=>s<3?Ot.Convert.ToHex(new Uint8Array(Ot.Convert.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===cPe)this.type=GB,this.value=gt.AsnConvert.parse(e.otherName.value,mt.DirectoryString).toString();else throw new Error(sPe);else throw new Error(sPe)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case qB:case jB:case VB:case WB:case K3:case GB:case HB:e=this.type.toUpperCase();break;case zB:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let r=this.value;return this.type===K3&&(r=rf.toString(r)),new qn(e,void 0,r)}},bh=class extends vh{constructor(e){let r;if(e instanceof mt.GeneralNames)r=e;else if(Array.isArray(e)){let n=[];for(let i of e)if(i instanceof mt.GeneralName)n.push(i);else{let s=gt.AsnConvert.parse(new Kf(i.type,i.value).rawData,mt.GeneralName);n.push(s)}r=new mt.GeneralNames(n)}else if(Ot.BufferSourceConverter.isBufferSource(e))r=gt.AsnConvert.parse(e,mt.GeneralNames);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(r)}onInit(e){let r=[];for(let n of e){let i=null;try{i=new Kf(n)}catch{continue}r.push(i)}this.items=r}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let r of this.items){let n=r.toTextObject(),i=e[n[qn.NAME]];Array.isArray(i)||(i=[],e[n[qn.NAME]]=i),i.push(n)}return e}};bh.NAME="GeneralNames";var _D="-{5}",SD="\\n",kCt=`[^${SD}]+`,DCt=`${_D}BEGIN (${kCt}(?=${_D}))${_D}`,ICt=`${_D}END \\1${_D}`,oS="\\n",FCt=`[^:${SD}]+`,PCt=`(?:[^${SD}]+${oS}(?: +[^${SD}]+${oS})*)`,RCt="[a-zA-Z0-9=+/]+",OCt=`(?:${RCt}${oS})+`,uPe=`${DCt}${oS}(?:((?:${FCt}: ${PCt})+))?${oS}?(${OCt})${ICt}`,po=class{static isPem(e){return typeof e=="string"&&new RegExp(uPe,"g").test(e.replace(/\r/g,""))}static decodeWithHeaders(e){e=e.replace(/\r/g,"");let r=new RegExp(uPe,"g"),n=[],i=null;for(;i=r.exec(e);){let s=i[3].replace(new RegExp(`[${SD}]+`,"g"),""),a={type:i[1],headers:[],rawData:Ot.Convert.FromBase64(s)},c=i[2];if(c){let d=c.split(new RegExp(oS,"g")),h=null;for(let p of d){let[x,y]=p.split(/:(.*)/);if(y===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=x.trim()}else h&&a.headers.push(h),h={key:x,value:y.trim()}}h&&a.headers.push(h)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){let r=this.decode(e);if(!r.length)throw new RangeError("PEM string doesn't contain any objects");return r[0]}static encode(e,r){if(Array.isArray(e)){let n=new Array;return r?e.forEach(i=>{if(!Ot.BufferSourceConverter.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:r,rawData:Ot.BufferSourceConverter.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
1008
1017
  `)}else{if(!r)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:r,rawData:Ot.BufferSourceConverter.toArrayBuffer(e)})}}static encodeStruct(e){var r;let n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((r=e.headers)===null||r===void 0)&&r.length){for(let h of e.headers)i.push(`${h.key}: ${h.value}`);i.push("")}let s=Ot.Convert.ToBase64(e.rawData),a,c=0,d=Array();for(;c<s.length&&(s.length-c<64?a=s.substring(c):(a=s.substring(c,c+64),c+=64),a.length!==0);)if(d.push(a),a.length<64)break;return i.push(...d),i.push(`-----END ${n}-----`),i.join(`
1009
- `)}};po.CertificateTag="CERTIFICATE";po.CrlTag="CRL";po.CertificateRequestTag="CERTIFICATE REQUEST";po.PublicKeyTag="PUBLIC KEY";po.PrivateKeyTag="PRIVATE KEY";var Iu=class t extends vh{static isAsnEncoded(e){return Ot.BufferSourceConverter.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(po.isPem(e))return po.decode(e)[0];if(Ot.Convert.isHex(e))return Ot.Convert.FromHex(e);if(Ot.Convert.isBase64(e))return Ot.Convert.FromBase64(e);if(Ot.Convert.isBase64Url(e))return Ot.Convert.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{let r=Ot.BufferSourceConverter.toUint8Array(e);if(r.length>0&&r[0]===48)return Ot.BufferSourceConverter.toArrayBuffer(e);let n=Ot.Convert.ToBinary(e);if(po.isPem(n))return po.decode(n)[0];if(Ot.Convert.isHex(n))return Ot.Convert.FromHex(n);if(Ot.Convert.isBase64(n))return Ot.Convert.FromBase64(n);if(Ot.Convert.isBase64Url(n))return Ot.Convert.FromBase64Url(n);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){t.isAsnEncoded(e[0])?super(t.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){return e==="pem"?po.encode(this.rawData,this.tag):super.toString(e)}},Zf=class t extends Iu{static async create(e,r=Rs.get()){if(e instanceof t)return e;if(aS.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");let n=await r.subtle.exportKey("spki",e);return new t(n)}else{if(e.publicKey)return e.publicKey;if(Ot.BufferSourceConverter.isBufferSource(e))return new t(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Iu.isAsnEncoded(e)?super(e,Fr.SubjectPublicKeyInfo):super(e),this.tag=po.PublicKeyTag}async export(...e){let r,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,r=e[2]||Rs.get()):r=e[0]||Rs.get();let s=this.rawData,a=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);return a.algorithm.algorithm===Cu.id_RSASSA_PSS&&(s=NCt(a,s)),r.subtle.importKey("spki",s,i,!0,n)}onInit(e){let r=ls.container.resolve(Xf),n=this.algorithm=r.toWebAlgorithm(e.algorithm);if(e.algorithm.algorithm===Cu.id_rsaEncryption){let i=gt.AsnConvert.parse(e.subjectPublicKey,Cu.RSAPublicKey),s=Ot.BufferSourceConverter.toUint8Array(i.modulus);n.publicExponent=Ot.BufferSourceConverter.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3}}async getThumbprint(...e){var r;let n,i="SHA-1";return e.length>=1&&!(!((r=e[0])===null||r===void 0)&&r.subtle)?(i=e[0]||i,n=e[1]||Rs.get()):n=e[0]||Rs.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let r,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],r=Rs.get()):r=e[0]:e.length===2?(n=e[0],r=e[1]):r=Rs.get();let i=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);return await r.subtle.digest(n,i.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);switch(e.Algorithm=Yf.serializeAlgorithm(r.algorithm),r.algorithm.algorithm){case YB.id_ecPublicKey:e["EC Point"]=r.subjectPublicKey;break;case Cu.id_rsaEncryption:default:e["Raw Data"]=r.subjectPublicKey}return e}};function NCt(t,e){return t.algorithm=new Fr.AlgorithmIdentifier({algorithm:Cu.id_rsaEncryption,parameters:null}),e=gt.AsnConvert.serialize(t),e}var A6=class t extends ku{static async create(e,r=!1,n=Rs.get()){if("name"in e&&"serialNumber"in e)return new t(e,r);let s=await(await Zf.create(e,n)).getKeyIdentifier(n);return new t(Ot.Convert.ToHex(s),r)}constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){let r=new mt.AuthorityKeyIdentifier({keyIdentifier:new mt.KeyIdentifier(Ot.Convert.FromHex(e[0]))});super(mt.id_ce_authorityKeyIdentifier,e[1],gt.AsnConvert.serialize(r))}else{let r=e[0],n=r.name instanceof bh?gt.AsnConvert.parse(r.name.rawData,mt.GeneralNames):r.name,i=new mt.AuthorityKeyIdentifier({authorityCertIssuer:n,authorityCertSerialNumber:Ot.Convert.FromHex(r.serialNumber)});super(mt.id_ce_authorityKeyIdentifier,e[1],gt.AsnConvert.serialize(i))}}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.AuthorityKeyIdentifier);r.keyIdentifier&&(this.keyId=Ot.Convert.ToHex(r.keyIdentifier)),(r.authorityCertIssuer||r.authorityCertSerialNumber)&&(this.certId={name:r.authorityCertIssuer||[],serialNumber:r.authorityCertSerialNumber?Ot.Convert.ToHex(r.authorityCertSerialNumber):""})}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,mt.AuthorityKeyIdentifier);return r.authorityCertIssuer&&(e["Authority Issuer"]=new bh(r.authorityCertIssuer).toTextObject()),r.authorityCertSerialNumber&&(e["Authority Serial Number"]=r.authorityCertSerialNumber),r.keyIdentifier&&(e[""]=r.keyIdentifier),e}};A6.NAME="Authority Key Identifier";var E6=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,Fr.BasicConstraints);this.ca=r.cA,this.pathLength=r.pathLenConstraint}else{let r=new Fr.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(Fr.id_ce_basicConstraints,e[2],gt.AsnConvert.serialize(r)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}};E6.NAME="Basic Constraints";Wt.ExtendedKeyUsage=void 0;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(Wt.ExtendedKeyUsage||(Wt.ExtendedKeyUsage={}));var T6=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,mt.ExtendedKeyUsage);this.usages=r.map(n=>n)}else{let r=new mt.ExtendedKeyUsage(e[0]);super(mt.id_ce_extKeyUsage,e[1],gt.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(r=>rf.toString(r)).join(", "),e}};T6.NAME="Extended Key Usages";Wt.KeyUsageFlags=void 0;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Wt.KeyUsageFlags||(Wt.KeyUsageFlags={}));var C6=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,Fr.KeyUsage);this.usages=r.toNumber()}else{let r=new Fr.KeyUsage(e[0]);super(Fr.id_ce_keyUsage,e[1],gt.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,Fr.KeyUsage);return e[""]=r.toJSON().join(", "),e}};C6.NAME="Key Usages";var k6=class t extends ku{static async create(e,r=!1,n=Rs.get()){let s=await(await Zf.create(e,n)).getKeyIdentifier(n);return new t(Ot.Convert.ToHex(s),r)}constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,mt.SubjectKeyIdentifier);this.keyId=Ot.Convert.ToHex(r)}else{let r=typeof e[0]=="string"?Ot.Convert.FromHex(e[0]):e[0],n=new mt.SubjectKeyIdentifier(r);super(mt.id_ce_subjectKeyIdentifier,e[1],gt.AsnConvert.serialize(n)),this.keyId=Ot.Convert.ToHex(r)}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,mt.SubjectKeyIdentifier);return e[""]=r,e}};k6.NAME="Subject Key Identifier";var D6=class extends ku{constructor(...e){Ot.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(mt.id_ce_subjectAltName,e[1],new bh(e[0]||[]).rawData)}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.SubjectAlternativeName);this.names=new bh(r)}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.names.toTextObject();for(let n in r)e[n]=r[n];return e}};D6.NAME="Subject Alternative Name";var mo=class{static register(e,r){this.items.set(e,r)}static create(e){let r=new ku(e),n=this.items.get(r.type);return n?new n(e):r}};mo.items=new Map;var I6=class extends ku{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=gt.AsnConvert.parse(this.value,mt.CertificatePolicies);this.policies=n.map(i=>i.policyIdentifier)}else{let n=e[0],i=(r=e[1])!==null&&r!==void 0?r:!1,s=new mt.CertificatePolicies(n.map(a=>new mt.PolicyInformation({policyIdentifier:a})));super(mt.id_ce_certificatePolicies,i,gt.AsnConvert.serialize(s)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(r=>new qn("",{},rf.toString(r))),e}};I6.NAME="Certificate Policies";mo.register(mt.id_ce_certificatePolicies,I6);var F6=class extends ku{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){let i=e[0].map(a=>new mt.DistributionPoint({distributionPoint:new mt.DistributionPointName({fullName:[new mt.GeneralName({uniformResourceIdentifier:a})]})})),s=new mt.CRLDistributionPoints(i);super(mt.id_ce_cRLDistributionPoints,e[1],gt.AsnConvert.serialize(s))}else{let n=new mt.CRLDistributionPoints(e[0]);super(mt.id_ce_cRLDistributionPoints,e[1],gt.AsnConvert.serialize(n))}(r=this.distributionPoints)!==null&&r!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.CRLDistributionPoints);this.distributionPoints=r}toTextObject(){let e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(r=>{var n;let i={};return r.distributionPoint&&(i[""]=(n=r.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Kf(s).toString()).join(", ")),r.reasons&&(i.Reasons=r.reasons.toString()),r.cRLIssuer&&(i["CRL Issuer"]=r.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}};F6.NAME="CRL Distribution Points";var P6=class extends ku{constructor(...e){var r,n,i,s;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof mt.AuthorityInfoAccessSyntax){let a=new mt.AuthorityInfoAccessSyntax(e[0]);super(mt.id_pe_authorityInfoAccess,e[1],gt.AsnConvert.serialize(a))}else{let a=e[0],c=new mt.AuthorityInfoAccessSyntax;LB(c,a,mt.id_ad_ocsp,"ocsp"),LB(c,a,mt.id_ad_caIssuers,"caIssuers"),LB(c,a,mt.id_ad_timeStamping,"timeStamping"),LB(c,a,mt.id_ad_caRepository,"caRepository"),super(mt.id_pe_authorityInfoAccess,e[1],gt.AsnConvert.serialize(c))}(r=this.ocsp)!==null&&r!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],gt.AsnConvert.parse(e.extnValue,mt.AuthorityInfoAccessSyntax).forEach(n=>{switch(n.accessMethod){case mt.id_ad_ocsp:this.ocsp.push(new Kf(n.accessLocation));break;case mt.id_ad_caIssuers:this.caIssuers.push(new Kf(n.accessLocation));break;case mt.id_ad_timeStamping:this.timeStamping.push(new Kf(n.accessLocation));break;case mt.id_ad_caRepository:this.caRepository.push(new Kf(n.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&MB(e,"OCSP",this.ocsp),this.caIssuers.length&&MB(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&MB(e,"Time Stamping",this.timeStamping),this.caRepository.length&&MB(e,"CA Repository",this.caRepository),e}};P6.NAME="Authority Info Access";function MB(t,e,r){if(r.length===1)t[e]=r[0].toTextObject();else{let n=new qn("");r.forEach((i,s)=>{let a=i.toTextObject(),c=`${a[qn.NAME]} ${s+1}`,d=n[c];Array.isArray(d)||(d=[],n[c]=d),d.push(a)}),t[e]=n}}function LB(t,e,r,n){let i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Kf("url",a)),t.push(new mt.AccessDescription({accessMethod:r,accessLocation:gt.AsnConvert.parse(a.rawData,mt.GeneralName)}))})}var R6=class extends ku{constructor(...e){Ot.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(mt.id_ce_issuerAltName,e[1],new bh(e[0]||[]).rawData)}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.GeneralNames);this.names=new bh(r)}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.names.toTextObject();for(let n in r)e[n]=r[n];return e}};R6.NAME="Issuer Alternative Name";var iv=class t extends vh{constructor(...e){let r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))r=Ot.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],i=Array.isArray(e[1])?e[1].map(s=>Ot.BufferSourceConverter.toArrayBuffer(s)):[];r=gt.AsnConvert.serialize(new Fr.Attribute({type:n,values:i}))}super(r,Fr.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(r=>new qn("",{"":r})),e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty();return e[qn.NAME]===t.NAME&&(e[qn.NAME]=rf.toString(this.type)),e}};iv.NAME="Attribute";var O6=class extends iv{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new sS.ChallengePassword({printableString:e[0]});super(sS.id_pkcs9_at_challengePassword,[gt.AsnConvert.serialize(n)])}(r=this.password)!==null&&r!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){let r=gt.AsnConvert.parse(this.values[0],sS.ChallengePassword);this.password=r.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[qn.VALUE]=this.password,e}};O6.NAME="Challenge Password";var cS=class extends iv{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],i=new mt.Extensions;for(let s of n)i.push(gt.AsnConvert.parse(s.rawData,mt.Extension));super(sS.id_pkcs9_at_extensionRequest,[gt.AsnConvert.serialize(i)])}(r=this.items)!==null&&r!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){let r=gt.AsnConvert.parse(this.values[0],mt.Extensions);this.items=r.map(n=>mo.create(gt.AsnConvert.serialize(n)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.items.map(n=>n.toTextObject());for(let n of r)e[n[qn.NAME]]=n;return e}};cS.NAME="Extensions";var sv=class{static register(e,r){this.items.set(e,r)}static create(e){let r=new iv(e),n=this.items.get(r.type);return n?new n(e):r}};sv.items=new Map;var tp="crypto.signatureFormatter",tU=class{toAsnSignature(e,r){return Ot.BufferSourceConverter.toArrayBuffer(r)}toWebSignature(e,r){return Ot.BufferSourceConverter.toArrayBuffer(r)}},KB;Wt.RsaAlgorithm=KB=class{static createPssParams(e,r){let n=KB.getHashAlgorithm(e);return n?new us.RsaSaPssParams({hashAlgorithm:n,maskGenAlgorithm:new Fr.AlgorithmIdentifier({algorithm:us.id_mgf1,parameters:gt.AsnConvert.serialize(n)}),saltLength:r}):null}static getHashAlgorithm(e){let r=ls.container.resolve(Xf);return typeof e=="string"?r.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?r.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let r;if(typeof e.hash=="string")r=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")r=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(r.toLowerCase()){case"sha-1":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha1WithRSAEncryption,parameters:null});case"sha-256":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha256WithRSAEncryption,parameters:null});case"sha-384":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha384WithRSAEncryption,parameters:null});case"sha-512":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha512WithRSAEncryption,parameters:null})}}else return new Fr.AlgorithmIdentifier({algorithm:us.id_rsaEncryption,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");let r=KB.createPssParams(e.hash,e.saltLength);if(!r)throw new Error("Cannot create PSS parameters");return new Fr.AlgorithmIdentifier({algorithm:us.id_RSASSA_PSS,parameters:gt.AsnConvert.serialize(r)})}else return new Fr.AlgorithmIdentifier({algorithm:us.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us.id_rsaEncryption:return{name:"RSASSA-PKCS1-v1_5"};case us.id_sha1WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case us.id_sha256WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case us.id_sha384WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case us.id_sha512WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case us.id_RSASSA_PSS:if(e.parameters){let r=gt.AsnConvert.parse(e.parameters,us.RsaSaPssParams);return{name:"RSA-PSS",hash:ls.container.resolve(Xf).toWebAlgorithm(r.hashAlgorithm),saltLength:r.saltLength}}else return{name:"RSA-PSS"}}return null}};Wt.RsaAlgorithm=KB=yt.__decorate([ls.injectable()],Wt.RsaAlgorithm);ls.container.registerSingleton(lS,Wt.RsaAlgorithm);Wt.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha1});case"sha-256":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha256});case"sha-384":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha384});case"sha-512":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case Cu.id_sha1:return{name:"SHA-1"};case Cu.id_sha256:return{name:"SHA-256"};case Cu.id_sha384:return{name:"SHA-384"};case Cu.id_sha512:return{name:"SHA-512"}}return null}};Wt.ShaAlgorithm=yt.__decorate([ls.injectable()],Wt.ShaAlgorithm);ls.container.registerSingleton(lS,Wt.ShaAlgorithm);var _h=class t{addPadding(e,r){let n=Ot.BufferSourceConverter.toUint8Array(r),i=new Uint8Array(e);return i.set(n,e-n.length),i.buffer}removePadding(e,r=!1){let n=Ot.BufferSourceConverter.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(r&&n[0]>127){let i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,r){if(e.name==="ECDSA"){let n=e.namedCurve,i=t.namedCurveSize.get(n)||t.defaultNamedCurveSize,s=new YB.ECDSASigValue,a=Ot.BufferSourceConverter.toUint8Array(r);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),gt.AsnConvert.serialize(s)}return null}toWebSignature(e,r){if(e.name==="ECDSA"){let n=gt.AsnConvert.parse(r,YB.ECDSASigValue),i=e.namedCurve,s=t.namedCurveSize.get(i)||t.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return Ot.combine(a,c)}return null}};_h.namedCurveSize=new Map;_h.defaultNamedCurveSize=32;var ZB="1.3.101.110",zie="1.3.101.111",XB="1.3.101.112",Wie="1.3.101.113";Wt.EdAlgorithm=class{toAsnAlgorithm(e){let r=null;switch(e.name.toLowerCase()){case"ed25519":r=XB;break;case"x25519":r=ZB;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":r=XB;break;case"ed448":r=Wie;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":r=ZB;break;case"x448":r=zie;break}}return r?new Fr.AlgorithmIdentifier({algorithm:r}):null}toWebAlgorithm(e){switch(e.algorithm){case XB:return{name:"Ed25519"};case Wie:return{name:"EdDSA",namedCurve:"Ed448"};case ZB:return{name:"X25519"};case zie:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wt.EdAlgorithm=yt.__decorate([ls.injectable()],Wt.EdAlgorithm);ls.container.registerSingleton(lS,Wt.EdAlgorithm);var Z3,X3,Y3,J3,Q3,e6,t6,Qw,N6=class extends Iu{get subjectName(){return yt.__classPrivateFieldGet(this,X3,"f")||yt.__classPrivateFieldSet(this,X3,new Ka(this.asn.certificationRequestInfo.subject),"f"),yt.__classPrivateFieldGet(this,X3,"f")}get subject(){return yt.__classPrivateFieldGet(this,Y3,"f")||yt.__classPrivateFieldSet(this,Y3,this.subjectName.toString(),"f"),yt.__classPrivateFieldGet(this,Y3,"f")}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,J3,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,J3,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,J3,"f")}get signature(){return yt.__classPrivateFieldGet(this,Q3,"f")||yt.__classPrivateFieldSet(this,Q3,this.asn.signature,"f"),yt.__classPrivateFieldGet(this,Q3,"f")}get publicKey(){return yt.__classPrivateFieldGet(this,e6,"f")||yt.__classPrivateFieldSet(this,e6,new Zf(this.asn.certificationRequestInfo.subjectPKInfo),"f"),yt.__classPrivateFieldGet(this,e6,"f")}get attributes(){return yt.__classPrivateFieldGet(this,t6,"f")||yt.__classPrivateFieldSet(this,t6,this.asn.certificationRequestInfo.attributes.map(e=>sv.create(gt.AsnConvert.serialize(e))),"f"),yt.__classPrivateFieldGet(this,t6,"f")}get extensions(){if(!yt.__classPrivateFieldGet(this,Qw,"f")){yt.__classPrivateFieldSet(this,Qw,[],"f");let e=this.getAttribute(Zie.id_pkcs9_at_extensionRequest);e instanceof cS&&yt.__classPrivateFieldSet(this,Qw,e.items,"f")}return yt.__classPrivateFieldGet(this,Qw,"f")}get tbs(){return yt.__classPrivateFieldGet(this,Z3,"f")||yt.__classPrivateFieldSet(this,Z3,this.asn.certificationRequestInfoRaw||gt.AsnConvert.serialize(this.asn.certificationRequestInfo),"f"),yt.__classPrivateFieldGet(this,Z3,"f")}constructor(e){let r=Iu.isAsnEncoded(e)?[e,JB.CertificationRequest]:[e];super(r[0],r[1]),Z3.set(this,void 0),X3.set(this,void 0),Y3.set(this,void 0),J3.set(this,void 0),Q3.set(this,void 0),e6.set(this,void 0),t6.set(this,void 0),Qw.set(this,void 0),this.tag=po.CertificateRequestTag}onInit(e){}getAttribute(e){for(let r of this.attributes)if(r.type===e)return r;return null}getAttributes(e){return this.attributes.filter(r=>r.type===e)}getExtension(e){for(let r of this.extensions)if(r.type===e)return r;return null}getExtensions(e){return this.extensions.filter(r=>r.type===e)}async verify(e=Rs.get()){let r={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(r,["verify"],e),i=ls.container.resolveAll(tp).reverse(),s=null;for(let c of i)if(s=c.toWebSignature(r,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,JB.CertificationRequest),n=r.certificationRequestInfo,i=new qn("",{Version:`${Fr.Version[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let s=new qn("");for(let a of this.attributes){let c=a.toTextObject();s[c[qn.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new qn("",{Algorithm:Yf.serializeAlgorithm(r.signatureAlgorithm),"":r.signature}),e}};Z3=new WeakMap,X3=new WeakMap,Y3=new WeakMap,J3=new WeakMap,Q3=new WeakMap,e6=new WeakMap,t6=new WeakMap,Qw=new WeakMap;N6.NAME="PKCS#10 Certificate Request";var Hie=class{static async create(e,r=Rs.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");let n=await r.subtle.exportKey("spki",e.keys.publicKey),i=new JB.CertificationRequest({certificationRequestInfo:new JB.CertificationRequestInfo({subjectPKInfo:gt.AsnConvert.parse(n,Fr.SubjectPublicKeyInfo)})});if(e.name){let x=e.name instanceof Ka?e.name:new Ka(e.name);i.certificationRequestInfo.subject=gt.AsnConvert.parse(x.toArrayBuffer(),Fr.Name)}if(e.attributes)for(let x of e.attributes)i.certificationRequestInfo.attributes.push(gt.AsnConvert.parse(x.rawData,Fr.Attribute));if(e.extensions&&e.extensions.length){let x=new Fr.Attribute({type:Zie.id_pkcs9_at_extensionRequest}),y=new Fr.Extensions;for(let v of e.extensions)y.push(gt.AsnConvert.parse(v.rawData,Fr.Extension));x.values.push(gt.AsnConvert.serialize(y)),i.certificationRequestInfo.attributes.push(x)}let s={...e.signingAlgorithm,...e.keys.privateKey.algorithm},a=ls.container.resolve(Xf);i.signatureAlgorithm=a.toAsnAlgorithm(s);let c=gt.AsnConvert.serialize(i.certificationRequestInfo),d=await r.subtle.sign(s,e.keys.privateKey,c),h=ls.container.resolveAll(tp).reverse(),p=null;for(let x of h)if(p=x.toAsnSignature(s,d),p)break;if(!p)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return i.signature=p,new N6(gt.AsnConvert.serialize(i))}},r6,n6,i6,s6,a6,o6,c6,u6,l6,f6,eS,d6,yg=class extends Iu{get publicKey(){return yt.__classPrivateFieldGet(this,d6,"f")||yt.__classPrivateFieldSet(this,d6,new Zf(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),yt.__classPrivateFieldGet(this,d6,"f")}get serialNumber(){if(!yt.__classPrivateFieldGet(this,n6,"f")){let e=this.asn.tbsCertificate,r=new Uint8Array(e.serialNumber);r.length>1&&r[0]===0&&r[1]>127&&(r=r.slice(1)),yt.__classPrivateFieldSet(this,n6,Ot.Convert.ToHex(r),"f")}return yt.__classPrivateFieldGet(this,n6,"f")}get subjectName(){return yt.__classPrivateFieldGet(this,i6,"f")||yt.__classPrivateFieldSet(this,i6,new Ka(this.asn.tbsCertificate.subject),"f"),yt.__classPrivateFieldGet(this,i6,"f")}get subject(){return yt.__classPrivateFieldGet(this,s6,"f")||yt.__classPrivateFieldSet(this,s6,this.subjectName.toString(),"f"),yt.__classPrivateFieldGet(this,s6,"f")}get issuerName(){return yt.__classPrivateFieldGet(this,a6,"f")||yt.__classPrivateFieldSet(this,a6,new Ka(this.asn.tbsCertificate.issuer),"f"),yt.__classPrivateFieldGet(this,a6,"f")}get issuer(){return yt.__classPrivateFieldGet(this,o6,"f")||yt.__classPrivateFieldSet(this,o6,this.issuerName.toString(),"f"),yt.__classPrivateFieldGet(this,o6,"f")}get notBefore(){if(!yt.__classPrivateFieldGet(this,c6,"f")){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");yt.__classPrivateFieldSet(this,c6,e,"f")}return yt.__classPrivateFieldGet(this,c6,"f")}get notAfter(){if(!yt.__classPrivateFieldGet(this,u6,"f")){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");yt.__classPrivateFieldSet(this,u6,e,"f")}return yt.__classPrivateFieldGet(this,u6,"f")}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,l6,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,l6,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,l6,"f")}get signature(){return yt.__classPrivateFieldGet(this,f6,"f")||yt.__classPrivateFieldSet(this,f6,this.asn.signatureValue,"f"),yt.__classPrivateFieldGet(this,f6,"f")}get extensions(){return yt.__classPrivateFieldGet(this,eS,"f")||(yt.__classPrivateFieldSet(this,eS,[],"f"),this.asn.tbsCertificate.extensions&&yt.__classPrivateFieldSet(this,eS,this.asn.tbsCertificate.extensions.map(e=>mo.create(gt.AsnConvert.serialize(e))),"f")),yt.__classPrivateFieldGet(this,eS,"f")}get tbs(){return yt.__classPrivateFieldGet(this,r6,"f")||yt.__classPrivateFieldSet(this,r6,this.asn.tbsCertificateRaw||gt.AsnConvert.serialize(this.asn.tbsCertificate),"f"),yt.__classPrivateFieldGet(this,r6,"f")}constructor(e){let r=Iu.isAsnEncoded(e)?[e,Fr.Certificate]:[e];super(r[0],r[1]),r6.set(this,void 0),n6.set(this,void 0),i6.set(this,void 0),s6.set(this,void 0),a6.set(this,void 0),o6.set(this,void 0),c6.set(this,void 0),u6.set(this,void 0),l6.set(this,void 0),f6.set(this,void 0),eS.set(this,void 0),d6.set(this,void 0),this.tag=po.CertificateTag}onInit(e){}getExtension(e){for(let r of this.extensions)if(typeof e=="string"){if(r.type===e)return r}else if(r instanceof e)return r;return null}getExtensions(e){return this.extensions.filter(r=>typeof e=="string"?r.type===e:r instanceof e)}async verify(e={},r=Rs.get()){let n,i,s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],r);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],r);else if(s instanceof Zf)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],r);else if(Ot.BufferSourceConverter.isBufferSource(s)){let h=new Zf(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],r)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}let a=ls.container.resolveAll(tp).reverse(),c=null;for(let h of a)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");let d=await r.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return d;{let p=(e.date||new Date).getTime();return d&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let r,n="SHA-1";return e[0]&&(e[0].subtle?r=e[0]:(n=e[0]||n,r=e[1])),r??(r=Rs.get()),await r.subtle.digest(n,this.rawData)}async isSelfSigned(e=Rs.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,Fr.Certificate),n=r.tbsCertificate,i=new qn("",{Version:`${Fr.Version[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Yf.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new qn("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){let s=new qn("");for(let a of this.extensions){let c=a.toTextObject();s[c[qn.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new qn("",{Algorithm:Yf.serializeAlgorithm(r.signatureAlgorithm),"":r.signatureValue}),e}};r6=new WeakMap,n6=new WeakMap,i6=new WeakMap,s6=new WeakMap,a6=new WeakMap,o6=new WeakMap,c6=new WeakMap,u6=new WeakMap,l6=new WeakMap,f6=new WeakMap,eS=new WeakMap,d6=new WeakMap;yg.NAME="Certificate";var rU=class extends Array{constructor(e){if(super(),Iu.isAsnEncoded(e))this.import(e);else if(e instanceof yg)this.push(e);else if(Array.isArray(e))for(let r of e)this.push(r)}export(e){let r=new Tu.SignedData;r.version=1,r.encapContentInfo.eContentType=Tu.id_data,r.encapContentInfo.eContent=new Tu.EncapsulatedContent({single:new gt.OctetString}),r.certificates=new Tu.CertificateSet(this.map(s=>new Tu.CertificateChoices({certificate:gt.AsnConvert.parse(s.rawData,Fr.Certificate)})));let n=new Tu.ContentInfo({contentType:Tu.id_signedData,content:gt.AsnConvert.serialize(r)}),i=gt.AsnConvert.serialize(n);return e==="raw"?i:this.toString(e)}import(e){let r=Iu.toArrayBuffer(e),n=gt.AsnConvert.parse(r,Tu.ContentInfo);if(n.contentType!==Tu.id_signedData)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");let i=gt.AsnConvert.parse(n.content,Tu.SignedData);this.clear();for(let s of i.certificates||[])s.certificate&&this.push(new yg(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){let r=this.export("raw");switch(e){case"pem":return po.encode(r,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
1010
- `);case"asn":return gt.AsnConvert.toString(r);case"hex":return Ot.Convert.ToHex(r);case"base64":return Ot.Convert.ToBase64(r);case"base64url":return Ot.Convert.ToBase64Url(r);case"text":return Yf.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){let e=gt.AsnConvert.parse(this.export("raw"),Tu.ContentInfo),r=gt.AsnConvert.parse(e.content,Tu.SignedData);return new qn("X509Certificates",{"Content Type":rf.toString(e.contentType),Content:new qn("",{Version:`${Tu.CMSVersion[r.version]} (${r.version})`,Certificates:new qn("",{Certificate:this.map(i=>i.toTextObject())})})})}},Vie=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,r=Rs.get()){let n=new rU(e),i=e;for(;i=await this.findIssuer(i,r);){let s=await i.getThumbprint(r);for(let a of n){let c=await a.getThumbprint(r);if(Ot.isEqual(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,r=Rs.get()){if(!await e.isSelfSigned(r)){let n=e.getExtension(mt.id_ce_authorityKeyIdentifier);for(let i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){let s=i.getExtension(mt.id_ce_subjectKeyIdentifier);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){let s=i.getExtension(mt.id_ce_subjectAltName);if(s&&!(n.certId.serialNumber===i.serialNumber&&Ot.isEqual(gt.AsnConvert.serialize(n.certId.name),gt.AsnConvert.serialize(s))))continue}}try{let s={...i.publicKey.algorithm,...e.signatureAlgorithm},a=await i.publicKey.export(s,["verify"],r);if(!await e.verify({publicKey:a,signatureOnly:!0},r))continue}catch{continue}return i}}return null}};function Xie(t,e=Rs.get()){let r=Ot.BufferSourceConverter.toUint8Array(Ot.Convert.FromHex(t||"")),n=r&&r.length&&r.some(s=>s>0)?new Uint8Array(r):void 0;n||(n=e.getRandomValues(new Uint8Array(16)));let i=0;for(;i<n.length-1&&n[i]===0;)i++;if(n=n.slice(i),n[0]>127){let s=new Uint8Array(n.length+1);s[0]=0,s.set(n,1),n=s}return n.buffer}var Gie=class{static async createSelfSigned(e,r=Rs.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},r)}static async create(e,r=Rs.get()){var n;let i;e.publicKey instanceof Zf?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:Ot.BufferSourceConverter.isBufferSource(e.publicKey)?i=e.publicKey:i=await r.subtle.exportKey("spki",e.publicKey);let s=Xie(e.serialNumber,r),a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),d=new mt.Certificate({tbsCertificate:new mt.TBSCertificate({version:mt.Version.v3,serialNumber:s,validity:new mt.Validity({notBefore:a,notAfter:c}),extensions:new mt.Extensions(((n=e.extensions)===null||n===void 0?void 0:n.map(C=>gt.AsnConvert.parse(C.rawData,mt.Extension)))||[]),subjectPublicKeyInfo:gt.AsnConvert.parse(i,mt.SubjectPublicKeyInfo)})});if(e.subject){let C=e.subject instanceof Ka?e.subject:new Ka(e.subject);d.tbsCertificate.subject=gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)}if(e.issuer){let C=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer);d.tbsCertificate.issuer=gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)}let h={hash:"SHA-256"},p="signingKey"in e?{...h,...e.signingAlgorithm,...e.signingKey.algorithm}:{...h,...e.signingAlgorithm},x=ls.container.resolve(Xf);d.tbsCertificate.signature=d.signatureAlgorithm=x.toAsnAlgorithm(p);let y=gt.AsnConvert.serialize(d.tbsCertificate),v="signingKey"in e?await r.subtle.sign(p,e.signingKey,y):e.signature,w=ls.container.resolveAll(tp).reverse(),S=null;for(let C of w)if(S=C.toAsnSignature(p,v),S)break;if(!S)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return d.signatureValue=S,new yg(gt.AsnConvert.serialize(d))}},h6,p6,tS,rS,nS;Wt.X509CrlReason=void 0;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Wt.X509CrlReason||(Wt.X509CrlReason={}));var uS=class extends vh{get serialNumber(){return yt.__classPrivateFieldGet(this,h6,"f")||yt.__classPrivateFieldSet(this,h6,Ot.Convert.ToHex(this.asn.userCertificate),"f"),yt.__classPrivateFieldGet(this,h6,"f")}get revocationDate(){return yt.__classPrivateFieldGet(this,p6,"f")||yt.__classPrivateFieldSet(this,p6,this.asn.revocationDate.getTime(),"f"),yt.__classPrivateFieldGet(this,p6,"f")}get reason(){return yt.__classPrivateFieldGet(this,tS,"f")===void 0&&this.extensions,yt.__classPrivateFieldGet(this,tS,"f")}get invalidity(){return yt.__classPrivateFieldGet(this,rS,"f")===void 0&&this.extensions,yt.__classPrivateFieldGet(this,rS,"f")}get extensions(){return yt.__classPrivateFieldGet(this,nS,"f")||(yt.__classPrivateFieldSet(this,nS,[],"f"),this.asn.crlEntryExtensions&&yt.__classPrivateFieldSet(this,nS,this.asn.crlEntryExtensions.map(e=>{let r=mo.create(gt.AsnConvert.serialize(e));switch(r.type){case Fr.id_ce_cRLReasons:yt.__classPrivateFieldGet(this,tS,"f")===void 0&&yt.__classPrivateFieldSet(this,tS,gt.AsnConvert.parse(r.value,Fr.CRLReason).reason,"f");break;case Fr.id_ce_invalidityDate:yt.__classPrivateFieldGet(this,rS,"f")===void 0&&yt.__classPrivateFieldSet(this,rS,gt.AsnConvert.parse(r.value,Fr.InvalidityDate).value,"f");break}return r}),"f")),yt.__classPrivateFieldGet(this,nS,"f")}constructor(...e){let r;if(Ot.BufferSourceConverter.isBufferSource(e[0])?r=Ot.BufferSourceConverter.toArrayBuffer(e[0]):typeof e[0]=="string"?r=gt.AsnConvert.serialize(new Fr.RevokedCertificate({userCertificate:Xie(e[0]),revocationDate:new Fr.Time(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Fr.RevokedCertificate&&(r=e[0]),!r)throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments.");super(r,Fr.RevokedCertificate),h6.set(this,void 0),p6.set(this,void 0),tS.set(this,void 0),rS.set(this,void 0),nS.set(this,void 0)}onInit(e){}};h6=new WeakMap,p6=new WeakMap,tS=new WeakMap,rS=new WeakMap,nS=new WeakMap;var m6,g6,x6,y6,v6,b6,iS,nU=class extends Iu{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,g6,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,g6,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,g6,"f")}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return yt.__classPrivateFieldGet(this,x6,"f")||yt.__classPrivateFieldSet(this,x6,new Ka(this.asn.tbsCertList.issuer),"f"),yt.__classPrivateFieldGet(this,x6,"f")}get thisUpdate(){if(!yt.__classPrivateFieldGet(this,y6,"f")){let e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw new Error("Cannot get 'thisUpdate' value");yt.__classPrivateFieldSet(this,y6,e,"f")}return yt.__classPrivateFieldGet(this,y6,"f")}get nextUpdate(){var e;return yt.__classPrivateFieldGet(this,v6,"f")===void 0&&yt.__classPrivateFieldSet(this,v6,((e=this.asn.tbsCertList.nextUpdate)===null||e===void 0?void 0:e.getTime())||void 0,"f"),yt.__classPrivateFieldGet(this,v6,"f")}get entries(){var e;return yt.__classPrivateFieldGet(this,b6,"f")||yt.__classPrivateFieldSet(this,b6,((e=this.asn.tbsCertList.revokedCertificates)===null||e===void 0?void 0:e.map(r=>new uS(r)))||[],"f"),yt.__classPrivateFieldGet(this,b6,"f")}get extensions(){return yt.__classPrivateFieldGet(this,iS,"f")||(yt.__classPrivateFieldSet(this,iS,[],"f"),this.asn.tbsCertList.crlExtensions&&yt.__classPrivateFieldSet(this,iS,this.asn.tbsCertList.crlExtensions.map(e=>mo.create(gt.AsnConvert.serialize(e))),"f")),yt.__classPrivateFieldGet(this,iS,"f")}get tbs(){return yt.__classPrivateFieldGet(this,m6,"f")||yt.__classPrivateFieldSet(this,m6,this.asn.tbsCertListRaw||gt.AsnConvert.serialize(this.asn.tbsCertList),"f"),yt.__classPrivateFieldGet(this,m6,"f")}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,Iu.isAsnEncoded(e)?Fr.CertificateList:void 0),this.tag=po.CrlTag,m6.set(this,void 0),g6.set(this,void 0),x6.set(this,void 0),y6.set(this,void 0),v6.set(this,void 0),b6.set(this,void 0),iS.set(this,void 0)}onInit(e){}getExtension(e){for(let r of this.extensions)if(typeof e=="string"){if(r.type===e)return r}else if(r instanceof e)return r;return null}getExtensions(e){return this.extensions.filter(r=>typeof e=="string"?r.type===e:r instanceof e)}async verify(e,r=Rs.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch");let n,i,s=e.publicKey;try{s instanceof yg?(n={...s.publicKey.algorithm,...s.signatureAlgorithm},i=await s.publicKey.export(n,["verify"])):s instanceof Zf?(n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"])):(n={...s.algorithm,...this.signatureAlgorithm},i=s)}catch{return!1}let a=ls.container.resolveAll(tp).reverse(),c=null;for(let d of a)if(c=d.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return await r.subtle.verify(this.signatureAlgorithm,i,c,this.tbs)}async getThumbprint(...e){let r,n="SHA-1";return e[0]&&(e[0].subtle?r=e[0]:(n=e[0]||n,r=e[1])),r??(r=Rs.get()),await r.subtle.digest(n,this.rawData)}findRevoked(e){let r=typeof e=="string"?e:e.serialNumber,n=Xie(r);for(let i of this.asn.tbsCertList.revokedCertificates||[])if(Ot.BufferSourceConverter.isEqual(i.userCertificate,n))return new uS(gt.AsnConvert.serialize(i));return null}};m6=new WeakMap,g6=new WeakMap,x6=new WeakMap,y6=new WeakMap,v6=new WeakMap,b6=new WeakMap,iS=new WeakMap;var Kie=class{static async create(e,r=Rs.get()){var n;let i=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer),s=new mt.CertificateList({tbsCertList:new mt.TBSCertList({version:mt.Version.v2,issuer:gt.AsnConvert.parse(i.toArrayBuffer(),mt.Name),thisUpdate:new Fr.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(s.tbsCertList.nextUpdate=new Fr.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(s.tbsCertList.crlExtensions=new mt.Extensions(e.extensions.map(y=>gt.AsnConvert.parse(y.rawData,mt.Extension))||[])),e.entries&&e.entries.length){s.tbsCertList.revokedCertificates=[];for(let y of e.entries){let v=Iu.toArrayBuffer(y.serialNumber);if(s.tbsCertList.revokedCertificates.findIndex(C=>Ot.isEqual(C.userCertificate,v))>-1)throw new Error(`Certificate serial number ${y.serialNumber} already exists in tbsCertList`);let S=new Fr.RevokedCertificate({userCertificate:v,revocationDate:new Fr.Time(y.revocationDate||new Date)});if("extensions"in y&&(!((n=y.extensions)===null||n===void 0)&&n.length)?S.crlEntryExtensions=y.extensions.map(C=>gt.AsnConvert.parse(C.rawData,mt.Extension)):S.crlEntryExtensions=[],!(y instanceof uS)&&(y.reason&&S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_cRLReasons,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(new mt.CRLReason(y.reason)))})),y.invalidity&&S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_invalidityDate,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(new mt.InvalidityDate(y.invalidity)))})),y.issuer)){let C=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer);S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_certificateIssuer,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)))}))}s.tbsCertList.revokedCertificates.push(S)}}let a={...e.signingAlgorithm,...e.signingKey.algorithm},c=ls.container.resolve(Xf);s.tbsCertList.signature=s.signatureAlgorithm=c.toAsnAlgorithm(a);let d=gt.AsnConvert.serialize(s.tbsCertList),h=await r.subtle.sign(a,e.signingKey,d),p=ls.container.resolveAll(tp).reverse(),x=null;for(let y of p)if(x=y.toAsnSignature(a,h),x)break;if(!x)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return s.signature=x,new nU(gt.AsnConvert.serialize(s))}};mo.register(mt.id_ce_basicConstraints,E6);mo.register(mt.id_ce_extKeyUsage,T6);mo.register(mt.id_ce_keyUsage,C6);mo.register(mt.id_ce_subjectKeyIdentifier,k6);mo.register(mt.id_ce_authorityKeyIdentifier,A6);mo.register(mt.id_ce_subjectAltName,D6);mo.register(mt.id_ce_cRLDistributionPoints,F6);mo.register(mt.id_pe_authorityInfoAccess,P6);mo.register(mt.id_ce_issuerAltName,R6);sv.register(sS.id_pkcs9_at_challengePassword,O6);sv.register(sS.id_pkcs9_at_extensionRequest,cS);ls.container.registerSingleton(tp,tU);ls.container.registerSingleton(tp,_h);_h.namedCurveSize.set("P-256",32);_h.namedCurveSize.set("K-256",32);_h.namedCurveSize.set("P-384",48);_h.namedCurveSize.set("P-521",66);Wt.AlgorithmProvider=QB;Wt.AsnData=vh;Wt.AsnDefaultSignatureFormatter=tU;Wt.AsnEcSignatureFormatter=_h;Wt.Attribute=iv;Wt.AttributeFactory=sv;Wt.AuthorityInfoAccessExtension=P6;Wt.AuthorityKeyIdentifierExtension=A6;Wt.BasicConstraintsExtension=E6;Wt.CRLDistributionPointsExtension=F6;Wt.CertificatePolicyExtension=I6;Wt.ChallengePasswordAttribute=O6;Wt.CryptoProvider=aS;Wt.DN=qB;Wt.DNS=jB;Wt.DefaultAlgorithmSerializer=eU;Wt.EMAIL=zB;Wt.ExtendedKeyUsageExtension=T6;Wt.Extension=ku;Wt.ExtensionFactory=mo;Wt.ExtensionsAttribute=cS;Wt.GUID=VB;Wt.GeneralName=Kf;Wt.GeneralNames=bh;Wt.IP=WB;Wt.IssuerAlternativeNameExtension=R6;Wt.KeyUsagesExtension=C6;Wt.Name=Ka;Wt.NameIdentifier=w6;Wt.OidSerializer=rf;Wt.PemConverter=po;Wt.PemData=Iu;Wt.Pkcs10CertificateRequest=N6;Wt.Pkcs10CertificateRequestGenerator=Hie;Wt.PublicKey=Zf;Wt.REGISTERED_ID=K3;Wt.SubjectAlternativeNameExtension=D6;Wt.SubjectKeyIdentifierExtension=k6;Wt.TextConverter=Yf;Wt.TextObject=qn;Wt.UPN=GB;Wt.URL=HB;Wt.X509Certificate=yg;Wt.X509CertificateGenerator=Gie;Wt.X509Certificates=rU;Wt.X509ChainBuilder=Vie;Wt.X509Crl=nU;Wt.X509CrlEntry=uS;Wt.X509CrlGenerator=Kie;Wt.cryptoProvider=Rs;Wt.diAlgorithm=lS;Wt.diAlgorithmProvider=Xf;Wt.diAsnSignatureFormatter=tp;Wt.idEd25519=XB;Wt.idEd448=Wie;Wt.idX25519=ZB;Wt.idX448=zie});var gPe=L((Cir,mPe)=>{"use strict";function BCt(t){return/^[$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]*$/.test(t)}mPe.exports=BCt});var U6=L((kir,EPe)=>{var xPe=Kr("util"),_Pe=gPe(),yPe=/[\{\[]/,vPe=/[\}\]]/,bPe=["do","if","in","for","let","new","try","var","case","else","enum","eval","null","this","true","void","with","await","break","catch","class","const","false","super","throw","while","yield","delete","export","import","public","return","static","switch","typeof","default","extends","finally","package","private","continue","debugger","function","arguments","interface","protected","implements","instanceof","NaN","undefined"],wPe={};for(iU=0;iU<bPe.length;iU++)wPe[bPe[iU]]=!0;var iU,UCt=function(t){return _Pe(t)&&!wPe.hasOwnProperty(t)},SPe={s:function(t){return""+t},d:function(t){return""+Number(t)},o:function(t){return JSON.stringify(t)}},APe=function(){var t=[],e=0,r={},n=function(a){for(var c="";c.length<e*2;)c+=" ";t.push(c+a)},i=function(a){if(vPe.test(a.trim()[0])&&yPe.test(a[a.length-1])){e--,n(a),e++;return}if(yPe.test(a[a.length-1])){n(a),e++;return}if(vPe.test(a.trim()[0])){e--,n(a);return}n(a)},s=function(a){if(!a)return s;if(arguments.length===1&&a.indexOf(`
1018
+ `)}};po.CertificateTag="CERTIFICATE";po.CrlTag="CRL";po.CertificateRequestTag="CERTIFICATE REQUEST";po.PublicKeyTag="PUBLIC KEY";po.PrivateKeyTag="PRIVATE KEY";var Iu=class t extends vh{static isAsnEncoded(e){return Ot.BufferSourceConverter.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(po.isPem(e))return po.decode(e)[0];if(Ot.Convert.isHex(e))return Ot.Convert.FromHex(e);if(Ot.Convert.isBase64(e))return Ot.Convert.FromBase64(e);if(Ot.Convert.isBase64Url(e))return Ot.Convert.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{let r=Ot.BufferSourceConverter.toUint8Array(e);if(r.length>0&&r[0]===48)return Ot.BufferSourceConverter.toArrayBuffer(e);let n=Ot.Convert.ToBinary(e);if(po.isPem(n))return po.decode(n)[0];if(Ot.Convert.isHex(n))return Ot.Convert.FromHex(n);if(Ot.Convert.isBase64(n))return Ot.Convert.FromBase64(n);if(Ot.Convert.isBase64Url(n))return Ot.Convert.FromBase64Url(n);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){t.isAsnEncoded(e[0])?super(t.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){return e==="pem"?po.encode(this.rawData,this.tag):super.toString(e)}},Zf=class t extends Iu{static async create(e,r=Rs.get()){if(e instanceof t)return e;if(aS.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");let n=await r.subtle.exportKey("spki",e);return new t(n)}else{if(e.publicKey)return e.publicKey;if(Ot.BufferSourceConverter.isBufferSource(e))return new t(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Iu.isAsnEncoded(e)?super(e,Fr.SubjectPublicKeyInfo):super(e),this.tag=po.PublicKeyTag}async export(...e){let r,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,r=e[2]||Rs.get()):r=e[0]||Rs.get();let s=this.rawData,a=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);return a.algorithm.algorithm===Cu.id_RSASSA_PSS&&(s=NCt(a,s)),r.subtle.importKey("spki",s,i,!0,n)}onInit(e){let r=ls.container.resolve(Xf),n=this.algorithm=r.toWebAlgorithm(e.algorithm);if(e.algorithm.algorithm===Cu.id_rsaEncryption){let i=gt.AsnConvert.parse(e.subjectPublicKey,Cu.RSAPublicKey),s=Ot.BufferSourceConverter.toUint8Array(i.modulus);n.publicExponent=Ot.BufferSourceConverter.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3}}async getThumbprint(...e){var r;let n,i="SHA-1";return e.length>=1&&!(!((r=e[0])===null||r===void 0)&&r.subtle)?(i=e[0]||i,n=e[1]||Rs.get()):n=e[0]||Rs.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let r,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],r=Rs.get()):r=e[0]:e.length===2?(n=e[0],r=e[1]):r=Rs.get();let i=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);return await r.subtle.digest(n,i.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,Fr.SubjectPublicKeyInfo);switch(e.Algorithm=Yf.serializeAlgorithm(r.algorithm),r.algorithm.algorithm){case YB.id_ecPublicKey:e["EC Point"]=r.subjectPublicKey;break;case Cu.id_rsaEncryption:default:e["Raw Data"]=r.subjectPublicKey}return e}};function NCt(t,e){return t.algorithm=new Fr.AlgorithmIdentifier({algorithm:Cu.id_rsaEncryption,parameters:null}),e=gt.AsnConvert.serialize(t),e}var AD=class t extends ku{static async create(e,r=!1,n=Rs.get()){if("name"in e&&"serialNumber"in e)return new t(e,r);let s=await(await Zf.create(e,n)).getKeyIdentifier(n);return new t(Ot.Convert.ToHex(s),r)}constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){let r=new mt.AuthorityKeyIdentifier({keyIdentifier:new mt.KeyIdentifier(Ot.Convert.FromHex(e[0]))});super(mt.id_ce_authorityKeyIdentifier,e[1],gt.AsnConvert.serialize(r))}else{let r=e[0],n=r.name instanceof bh?gt.AsnConvert.parse(r.name.rawData,mt.GeneralNames):r.name,i=new mt.AuthorityKeyIdentifier({authorityCertIssuer:n,authorityCertSerialNumber:Ot.Convert.FromHex(r.serialNumber)});super(mt.id_ce_authorityKeyIdentifier,e[1],gt.AsnConvert.serialize(i))}}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.AuthorityKeyIdentifier);r.keyIdentifier&&(this.keyId=Ot.Convert.ToHex(r.keyIdentifier)),(r.authorityCertIssuer||r.authorityCertSerialNumber)&&(this.certId={name:r.authorityCertIssuer||[],serialNumber:r.authorityCertSerialNumber?Ot.Convert.ToHex(r.authorityCertSerialNumber):""})}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,mt.AuthorityKeyIdentifier);return r.authorityCertIssuer&&(e["Authority Issuer"]=new bh(r.authorityCertIssuer).toTextObject()),r.authorityCertSerialNumber&&(e["Authority Serial Number"]=r.authorityCertSerialNumber),r.keyIdentifier&&(e[""]=r.keyIdentifier),e}};AD.NAME="Authority Key Identifier";var ED=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,Fr.BasicConstraints);this.ca=r.cA,this.pathLength=r.pathLenConstraint}else{let r=new Fr.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(Fr.id_ce_basicConstraints,e[2],gt.AsnConvert.serialize(r)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}};ED.NAME="Basic Constraints";Wt.ExtendedKeyUsage=void 0;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(Wt.ExtendedKeyUsage||(Wt.ExtendedKeyUsage={}));var TD=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,mt.ExtendedKeyUsage);this.usages=r.map(n=>n)}else{let r=new mt.ExtendedKeyUsage(e[0]);super(mt.id_ce_extKeyUsage,e[1],gt.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(r=>rf.toString(r)).join(", "),e}};TD.NAME="Extended Key Usages";Wt.KeyUsageFlags=void 0;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Wt.KeyUsageFlags||(Wt.KeyUsageFlags={}));var CD=class extends ku{constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,Fr.KeyUsage);this.usages=r.toNumber()}else{let r=new Fr.KeyUsage(e[0]);super(Fr.id_ce_keyUsage,e[1],gt.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,Fr.KeyUsage);return e[""]=r.toJSON().join(", "),e}};CD.NAME="Key Usages";var kD=class t extends ku{static async create(e,r=!1,n=Rs.get()){let s=await(await Zf.create(e,n)).getKeyIdentifier(n);return new t(Ot.Convert.ToHex(s),r)}constructor(...e){if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=gt.AsnConvert.parse(this.value,mt.SubjectKeyIdentifier);this.keyId=Ot.Convert.ToHex(r)}else{let r=typeof e[0]=="string"?Ot.Convert.FromHex(e[0]):e[0],n=new mt.SubjectKeyIdentifier(r);super(mt.id_ce_subjectKeyIdentifier,e[1],gt.AsnConvert.serialize(n)),this.keyId=Ot.Convert.ToHex(r)}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=gt.AsnConvert.parse(this.value,mt.SubjectKeyIdentifier);return e[""]=r,e}};kD.NAME="Subject Key Identifier";var DD=class extends ku{constructor(...e){Ot.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(mt.id_ce_subjectAltName,e[1],new bh(e[0]||[]).rawData)}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.SubjectAlternativeName);this.names=new bh(r)}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.names.toTextObject();for(let n in r)e[n]=r[n];return e}};DD.NAME="Subject Alternative Name";var mo=class{static register(e,r){this.items.set(e,r)}static create(e){let r=new ku(e),n=this.items.get(r.type);return n?new n(e):r}};mo.items=new Map;var ID=class extends ku{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=gt.AsnConvert.parse(this.value,mt.CertificatePolicies);this.policies=n.map(i=>i.policyIdentifier)}else{let n=e[0],i=(r=e[1])!==null&&r!==void 0?r:!1,s=new mt.CertificatePolicies(n.map(a=>new mt.PolicyInformation({policyIdentifier:a})));super(mt.id_ce_certificatePolicies,i,gt.AsnConvert.serialize(s)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(r=>new qn("",{},rf.toString(r))),e}};ID.NAME="Certificate Policies";mo.register(mt.id_ce_certificatePolicies,ID);var FD=class extends ku{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){let i=e[0].map(a=>new mt.DistributionPoint({distributionPoint:new mt.DistributionPointName({fullName:[new mt.GeneralName({uniformResourceIdentifier:a})]})})),s=new mt.CRLDistributionPoints(i);super(mt.id_ce_cRLDistributionPoints,e[1],gt.AsnConvert.serialize(s))}else{let n=new mt.CRLDistributionPoints(e[0]);super(mt.id_ce_cRLDistributionPoints,e[1],gt.AsnConvert.serialize(n))}(r=this.distributionPoints)!==null&&r!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.CRLDistributionPoints);this.distributionPoints=r}toTextObject(){let e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(r=>{var n;let i={};return r.distributionPoint&&(i[""]=(n=r.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Kf(s).toString()).join(", ")),r.reasons&&(i.Reasons=r.reasons.toString()),r.cRLIssuer&&(i["CRL Issuer"]=r.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}};FD.NAME="CRL Distribution Points";var PD=class extends ku{constructor(...e){var r,n,i,s;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof mt.AuthorityInfoAccessSyntax){let a=new mt.AuthorityInfoAccessSyntax(e[0]);super(mt.id_pe_authorityInfoAccess,e[1],gt.AsnConvert.serialize(a))}else{let a=e[0],c=new mt.AuthorityInfoAccessSyntax;LB(c,a,mt.id_ad_ocsp,"ocsp"),LB(c,a,mt.id_ad_caIssuers,"caIssuers"),LB(c,a,mt.id_ad_timeStamping,"timeStamping"),LB(c,a,mt.id_ad_caRepository,"caRepository"),super(mt.id_pe_authorityInfoAccess,e[1],gt.AsnConvert.serialize(c))}(r=this.ocsp)!==null&&r!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],gt.AsnConvert.parse(e.extnValue,mt.AuthorityInfoAccessSyntax).forEach(n=>{switch(n.accessMethod){case mt.id_ad_ocsp:this.ocsp.push(new Kf(n.accessLocation));break;case mt.id_ad_caIssuers:this.caIssuers.push(new Kf(n.accessLocation));break;case mt.id_ad_timeStamping:this.timeStamping.push(new Kf(n.accessLocation));break;case mt.id_ad_caRepository:this.caRepository.push(new Kf(n.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&MB(e,"OCSP",this.ocsp),this.caIssuers.length&&MB(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&MB(e,"Time Stamping",this.timeStamping),this.caRepository.length&&MB(e,"CA Repository",this.caRepository),e}};PD.NAME="Authority Info Access";function MB(t,e,r){if(r.length===1)t[e]=r[0].toTextObject();else{let n=new qn("");r.forEach((i,s)=>{let a=i.toTextObject(),c=`${a[qn.NAME]} ${s+1}`,d=n[c];Array.isArray(d)||(d=[],n[c]=d),d.push(a)}),t[e]=n}}function LB(t,e,r,n){let i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Kf("url",a)),t.push(new mt.AccessDescription({accessMethod:r,accessLocation:gt.AsnConvert.parse(a.rawData,mt.GeneralName)}))})}var RD=class extends ku{constructor(...e){Ot.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(mt.id_ce_issuerAltName,e[1],new bh(e[0]||[]).rawData)}onInit(e){super.onInit(e);let r=gt.AsnConvert.parse(e.extnValue,mt.GeneralNames);this.names=new bh(r)}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.names.toTextObject();for(let n in r)e[n]=r[n];return e}};RD.NAME="Issuer Alternative Name";var iv=class t extends vh{constructor(...e){let r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))r=Ot.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],i=Array.isArray(e[1])?e[1].map(s=>Ot.BufferSourceConverter.toArrayBuffer(s)):[];r=gt.AsnConvert.serialize(new Fr.Attribute({type:n,values:i}))}super(r,Fr.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(r=>new qn("",{"":r})),e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty();return e[qn.NAME]===t.NAME&&(e[qn.NAME]=rf.toString(this.type)),e}};iv.NAME="Attribute";var OD=class extends iv{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new sS.ChallengePassword({printableString:e[0]});super(sS.id_pkcs9_at_challengePassword,[gt.AsnConvert.serialize(n)])}(r=this.password)!==null&&r!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){let r=gt.AsnConvert.parse(this.values[0],sS.ChallengePassword);this.password=r.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[qn.VALUE]=this.password,e}};OD.NAME="Challenge Password";var cS=class extends iv{constructor(...e){var r;if(Ot.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],i=new mt.Extensions;for(let s of n)i.push(gt.AsnConvert.parse(s.rawData,mt.Extension));super(sS.id_pkcs9_at_extensionRequest,[gt.AsnConvert.serialize(i)])}(r=this.items)!==null&&r!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){let r=gt.AsnConvert.parse(this.values[0],mt.Extensions);this.items=r.map(n=>mo.create(gt.AsnConvert.serialize(n)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),r=this.items.map(n=>n.toTextObject());for(let n of r)e[n[qn.NAME]]=n;return e}};cS.NAME="Extensions";var sv=class{static register(e,r){this.items.set(e,r)}static create(e){let r=new iv(e),n=this.items.get(r.type);return n?new n(e):r}};sv.items=new Map;var tp="crypto.signatureFormatter",tU=class{toAsnSignature(e,r){return Ot.BufferSourceConverter.toArrayBuffer(r)}toWebSignature(e,r){return Ot.BufferSourceConverter.toArrayBuffer(r)}},KB;Wt.RsaAlgorithm=KB=class{static createPssParams(e,r){let n=KB.getHashAlgorithm(e);return n?new us.RsaSaPssParams({hashAlgorithm:n,maskGenAlgorithm:new Fr.AlgorithmIdentifier({algorithm:us.id_mgf1,parameters:gt.AsnConvert.serialize(n)}),saltLength:r}):null}static getHashAlgorithm(e){let r=ls.container.resolve(Xf);return typeof e=="string"?r.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?r.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let r;if(typeof e.hash=="string")r=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")r=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(r.toLowerCase()){case"sha-1":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha1WithRSAEncryption,parameters:null});case"sha-256":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha256WithRSAEncryption,parameters:null});case"sha-384":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha384WithRSAEncryption,parameters:null});case"sha-512":return new Fr.AlgorithmIdentifier({algorithm:us.id_sha512WithRSAEncryption,parameters:null})}}else return new Fr.AlgorithmIdentifier({algorithm:us.id_rsaEncryption,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");let r=KB.createPssParams(e.hash,e.saltLength);if(!r)throw new Error("Cannot create PSS parameters");return new Fr.AlgorithmIdentifier({algorithm:us.id_RSASSA_PSS,parameters:gt.AsnConvert.serialize(r)})}else return new Fr.AlgorithmIdentifier({algorithm:us.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us.id_rsaEncryption:return{name:"RSASSA-PKCS1-v1_5"};case us.id_sha1WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case us.id_sha256WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case us.id_sha384WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case us.id_sha512WithRSAEncryption:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case us.id_RSASSA_PSS:if(e.parameters){let r=gt.AsnConvert.parse(e.parameters,us.RsaSaPssParams);return{name:"RSA-PSS",hash:ls.container.resolve(Xf).toWebAlgorithm(r.hashAlgorithm),saltLength:r.saltLength}}else return{name:"RSA-PSS"}}return null}};Wt.RsaAlgorithm=KB=yt.__decorate([ls.injectable()],Wt.RsaAlgorithm);ls.container.registerSingleton(lS,Wt.RsaAlgorithm);Wt.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha1});case"sha-256":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha256});case"sha-384":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha384});case"sha-512":return new Fr.AlgorithmIdentifier({algorithm:Cu.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case Cu.id_sha1:return{name:"SHA-1"};case Cu.id_sha256:return{name:"SHA-256"};case Cu.id_sha384:return{name:"SHA-384"};case Cu.id_sha512:return{name:"SHA-512"}}return null}};Wt.ShaAlgorithm=yt.__decorate([ls.injectable()],Wt.ShaAlgorithm);ls.container.registerSingleton(lS,Wt.ShaAlgorithm);var _h=class t{addPadding(e,r){let n=Ot.BufferSourceConverter.toUint8Array(r),i=new Uint8Array(e);return i.set(n,e-n.length),i.buffer}removePadding(e,r=!1){let n=Ot.BufferSourceConverter.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(r&&n[0]>127){let i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,r){if(e.name==="ECDSA"){let n=e.namedCurve,i=t.namedCurveSize.get(n)||t.defaultNamedCurveSize,s=new YB.ECDSASigValue,a=Ot.BufferSourceConverter.toUint8Array(r);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),gt.AsnConvert.serialize(s)}return null}toWebSignature(e,r){if(e.name==="ECDSA"){let n=gt.AsnConvert.parse(r,YB.ECDSASigValue),i=e.namedCurve,s=t.namedCurveSize.get(i)||t.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return Ot.combine(a,c)}return null}};_h.namedCurveSize=new Map;_h.defaultNamedCurveSize=32;var ZB="1.3.101.110",zie="1.3.101.111",XB="1.3.101.112",Wie="1.3.101.113";Wt.EdAlgorithm=class{toAsnAlgorithm(e){let r=null;switch(e.name.toLowerCase()){case"ed25519":r=XB;break;case"x25519":r=ZB;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":r=XB;break;case"ed448":r=Wie;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":r=ZB;break;case"x448":r=zie;break}}return r?new Fr.AlgorithmIdentifier({algorithm:r}):null}toWebAlgorithm(e){switch(e.algorithm){case XB:return{name:"Ed25519"};case Wie:return{name:"EdDSA",namedCurve:"Ed448"};case ZB:return{name:"X25519"};case zie:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wt.EdAlgorithm=yt.__decorate([ls.injectable()],Wt.EdAlgorithm);ls.container.registerSingleton(lS,Wt.EdAlgorithm);var Z3,X3,Y3,J3,Q3,eD,tD,Qw,ND=class extends Iu{get subjectName(){return yt.__classPrivateFieldGet(this,X3,"f")||yt.__classPrivateFieldSet(this,X3,new Ka(this.asn.certificationRequestInfo.subject),"f"),yt.__classPrivateFieldGet(this,X3,"f")}get subject(){return yt.__classPrivateFieldGet(this,Y3,"f")||yt.__classPrivateFieldSet(this,Y3,this.subjectName.toString(),"f"),yt.__classPrivateFieldGet(this,Y3,"f")}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,J3,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,J3,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,J3,"f")}get signature(){return yt.__classPrivateFieldGet(this,Q3,"f")||yt.__classPrivateFieldSet(this,Q3,this.asn.signature,"f"),yt.__classPrivateFieldGet(this,Q3,"f")}get publicKey(){return yt.__classPrivateFieldGet(this,eD,"f")||yt.__classPrivateFieldSet(this,eD,new Zf(this.asn.certificationRequestInfo.subjectPKInfo),"f"),yt.__classPrivateFieldGet(this,eD,"f")}get attributes(){return yt.__classPrivateFieldGet(this,tD,"f")||yt.__classPrivateFieldSet(this,tD,this.asn.certificationRequestInfo.attributes.map(e=>sv.create(gt.AsnConvert.serialize(e))),"f"),yt.__classPrivateFieldGet(this,tD,"f")}get extensions(){if(!yt.__classPrivateFieldGet(this,Qw,"f")){yt.__classPrivateFieldSet(this,Qw,[],"f");let e=this.getAttribute(Zie.id_pkcs9_at_extensionRequest);e instanceof cS&&yt.__classPrivateFieldSet(this,Qw,e.items,"f")}return yt.__classPrivateFieldGet(this,Qw,"f")}get tbs(){return yt.__classPrivateFieldGet(this,Z3,"f")||yt.__classPrivateFieldSet(this,Z3,this.asn.certificationRequestInfoRaw||gt.AsnConvert.serialize(this.asn.certificationRequestInfo),"f"),yt.__classPrivateFieldGet(this,Z3,"f")}constructor(e){let r=Iu.isAsnEncoded(e)?[e,JB.CertificationRequest]:[e];super(r[0],r[1]),Z3.set(this,void 0),X3.set(this,void 0),Y3.set(this,void 0),J3.set(this,void 0),Q3.set(this,void 0),eD.set(this,void 0),tD.set(this,void 0),Qw.set(this,void 0),this.tag=po.CertificateRequestTag}onInit(e){}getAttribute(e){for(let r of this.attributes)if(r.type===e)return r;return null}getAttributes(e){return this.attributes.filter(r=>r.type===e)}getExtension(e){for(let r of this.extensions)if(r.type===e)return r;return null}getExtensions(e){return this.extensions.filter(r=>r.type===e)}async verify(e=Rs.get()){let r={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(r,["verify"],e),i=ls.container.resolveAll(tp).reverse(),s=null;for(let c of i)if(s=c.toWebSignature(r,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,JB.CertificationRequest),n=r.certificationRequestInfo,i=new qn("",{Version:`${Fr.Version[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let s=new qn("");for(let a of this.attributes){let c=a.toTextObject();s[c[qn.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new qn("",{Algorithm:Yf.serializeAlgorithm(r.signatureAlgorithm),"":r.signature}),e}};Z3=new WeakMap,X3=new WeakMap,Y3=new WeakMap,J3=new WeakMap,Q3=new WeakMap,eD=new WeakMap,tD=new WeakMap,Qw=new WeakMap;ND.NAME="PKCS#10 Certificate Request";var Hie=class{static async create(e,r=Rs.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");let n=await r.subtle.exportKey("spki",e.keys.publicKey),i=new JB.CertificationRequest({certificationRequestInfo:new JB.CertificationRequestInfo({subjectPKInfo:gt.AsnConvert.parse(n,Fr.SubjectPublicKeyInfo)})});if(e.name){let x=e.name instanceof Ka?e.name:new Ka(e.name);i.certificationRequestInfo.subject=gt.AsnConvert.parse(x.toArrayBuffer(),Fr.Name)}if(e.attributes)for(let x of e.attributes)i.certificationRequestInfo.attributes.push(gt.AsnConvert.parse(x.rawData,Fr.Attribute));if(e.extensions&&e.extensions.length){let x=new Fr.Attribute({type:Zie.id_pkcs9_at_extensionRequest}),y=new Fr.Extensions;for(let v of e.extensions)y.push(gt.AsnConvert.parse(v.rawData,Fr.Extension));x.values.push(gt.AsnConvert.serialize(y)),i.certificationRequestInfo.attributes.push(x)}let s={...e.signingAlgorithm,...e.keys.privateKey.algorithm},a=ls.container.resolve(Xf);i.signatureAlgorithm=a.toAsnAlgorithm(s);let c=gt.AsnConvert.serialize(i.certificationRequestInfo),d=await r.subtle.sign(s,e.keys.privateKey,c),h=ls.container.resolveAll(tp).reverse(),p=null;for(let x of h)if(p=x.toAsnSignature(s,d),p)break;if(!p)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return i.signature=p,new ND(gt.AsnConvert.serialize(i))}},rD,nD,iD,sD,aD,oD,cD,uD,lD,fD,eS,dD,yg=class extends Iu{get publicKey(){return yt.__classPrivateFieldGet(this,dD,"f")||yt.__classPrivateFieldSet(this,dD,new Zf(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),yt.__classPrivateFieldGet(this,dD,"f")}get serialNumber(){if(!yt.__classPrivateFieldGet(this,nD,"f")){let e=this.asn.tbsCertificate,r=new Uint8Array(e.serialNumber);r.length>1&&r[0]===0&&r[1]>127&&(r=r.slice(1)),yt.__classPrivateFieldSet(this,nD,Ot.Convert.ToHex(r),"f")}return yt.__classPrivateFieldGet(this,nD,"f")}get subjectName(){return yt.__classPrivateFieldGet(this,iD,"f")||yt.__classPrivateFieldSet(this,iD,new Ka(this.asn.tbsCertificate.subject),"f"),yt.__classPrivateFieldGet(this,iD,"f")}get subject(){return yt.__classPrivateFieldGet(this,sD,"f")||yt.__classPrivateFieldSet(this,sD,this.subjectName.toString(),"f"),yt.__classPrivateFieldGet(this,sD,"f")}get issuerName(){return yt.__classPrivateFieldGet(this,aD,"f")||yt.__classPrivateFieldSet(this,aD,new Ka(this.asn.tbsCertificate.issuer),"f"),yt.__classPrivateFieldGet(this,aD,"f")}get issuer(){return yt.__classPrivateFieldGet(this,oD,"f")||yt.__classPrivateFieldSet(this,oD,this.issuerName.toString(),"f"),yt.__classPrivateFieldGet(this,oD,"f")}get notBefore(){if(!yt.__classPrivateFieldGet(this,cD,"f")){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");yt.__classPrivateFieldSet(this,cD,e,"f")}return yt.__classPrivateFieldGet(this,cD,"f")}get notAfter(){if(!yt.__classPrivateFieldGet(this,uD,"f")){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");yt.__classPrivateFieldSet(this,uD,e,"f")}return yt.__classPrivateFieldGet(this,uD,"f")}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,lD,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,lD,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,lD,"f")}get signature(){return yt.__classPrivateFieldGet(this,fD,"f")||yt.__classPrivateFieldSet(this,fD,this.asn.signatureValue,"f"),yt.__classPrivateFieldGet(this,fD,"f")}get extensions(){return yt.__classPrivateFieldGet(this,eS,"f")||(yt.__classPrivateFieldSet(this,eS,[],"f"),this.asn.tbsCertificate.extensions&&yt.__classPrivateFieldSet(this,eS,this.asn.tbsCertificate.extensions.map(e=>mo.create(gt.AsnConvert.serialize(e))),"f")),yt.__classPrivateFieldGet(this,eS,"f")}get tbs(){return yt.__classPrivateFieldGet(this,rD,"f")||yt.__classPrivateFieldSet(this,rD,this.asn.tbsCertificateRaw||gt.AsnConvert.serialize(this.asn.tbsCertificate),"f"),yt.__classPrivateFieldGet(this,rD,"f")}constructor(e){let r=Iu.isAsnEncoded(e)?[e,Fr.Certificate]:[e];super(r[0],r[1]),rD.set(this,void 0),nD.set(this,void 0),iD.set(this,void 0),sD.set(this,void 0),aD.set(this,void 0),oD.set(this,void 0),cD.set(this,void 0),uD.set(this,void 0),lD.set(this,void 0),fD.set(this,void 0),eS.set(this,void 0),dD.set(this,void 0),this.tag=po.CertificateTag}onInit(e){}getExtension(e){for(let r of this.extensions)if(typeof e=="string"){if(r.type===e)return r}else if(r instanceof e)return r;return null}getExtensions(e){return this.extensions.filter(r=>typeof e=="string"?r.type===e:r instanceof e)}async verify(e={},r=Rs.get()){let n,i,s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],r);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],r);else if(s instanceof Zf)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],r);else if(Ot.BufferSourceConverter.isBufferSource(s)){let h=new Zf(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],r)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}let a=ls.container.resolveAll(tp).reverse(),c=null;for(let h of a)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");let d=await r.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return d;{let p=(e.date||new Date).getTime();return d&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let r,n="SHA-1";return e[0]&&(e[0].subtle?r=e[0]:(n=e[0]||n,r=e[1])),r??(r=Rs.get()),await r.subtle.digest(n,this.rawData)}async isSelfSigned(e=Rs.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),r=gt.AsnConvert.parse(this.rawData,Fr.Certificate),n=r.tbsCertificate,i=new qn("",{Version:`${Fr.Version[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Yf.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new qn("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){let s=new qn("");for(let a of this.extensions){let c=a.toTextObject();s[c[qn.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new qn("",{Algorithm:Yf.serializeAlgorithm(r.signatureAlgorithm),"":r.signatureValue}),e}};rD=new WeakMap,nD=new WeakMap,iD=new WeakMap,sD=new WeakMap,aD=new WeakMap,oD=new WeakMap,cD=new WeakMap,uD=new WeakMap,lD=new WeakMap,fD=new WeakMap,eS=new WeakMap,dD=new WeakMap;yg.NAME="Certificate";var rU=class extends Array{constructor(e){if(super(),Iu.isAsnEncoded(e))this.import(e);else if(e instanceof yg)this.push(e);else if(Array.isArray(e))for(let r of e)this.push(r)}export(e){let r=new Tu.SignedData;r.version=1,r.encapContentInfo.eContentType=Tu.id_data,r.encapContentInfo.eContent=new Tu.EncapsulatedContent({single:new gt.OctetString}),r.certificates=new Tu.CertificateSet(this.map(s=>new Tu.CertificateChoices({certificate:gt.AsnConvert.parse(s.rawData,Fr.Certificate)})));let n=new Tu.ContentInfo({contentType:Tu.id_signedData,content:gt.AsnConvert.serialize(r)}),i=gt.AsnConvert.serialize(n);return e==="raw"?i:this.toString(e)}import(e){let r=Iu.toArrayBuffer(e),n=gt.AsnConvert.parse(r,Tu.ContentInfo);if(n.contentType!==Tu.id_signedData)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");let i=gt.AsnConvert.parse(n.content,Tu.SignedData);this.clear();for(let s of i.certificates||[])s.certificate&&this.push(new yg(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){let r=this.export("raw");switch(e){case"pem":return po.encode(r,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
1019
+ `);case"asn":return gt.AsnConvert.toString(r);case"hex":return Ot.Convert.ToHex(r);case"base64":return Ot.Convert.ToBase64(r);case"base64url":return Ot.Convert.ToBase64Url(r);case"text":return Yf.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){let e=gt.AsnConvert.parse(this.export("raw"),Tu.ContentInfo),r=gt.AsnConvert.parse(e.content,Tu.SignedData);return new qn("X509Certificates",{"Content Type":rf.toString(e.contentType),Content:new qn("",{Version:`${Tu.CMSVersion[r.version]} (${r.version})`,Certificates:new qn("",{Certificate:this.map(i=>i.toTextObject())})})})}},Vie=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,r=Rs.get()){let n=new rU(e),i=e;for(;i=await this.findIssuer(i,r);){let s=await i.getThumbprint(r);for(let a of n){let c=await a.getThumbprint(r);if(Ot.isEqual(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,r=Rs.get()){if(!await e.isSelfSigned(r)){let n=e.getExtension(mt.id_ce_authorityKeyIdentifier);for(let i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){let s=i.getExtension(mt.id_ce_subjectKeyIdentifier);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){let s=i.getExtension(mt.id_ce_subjectAltName);if(s&&!(n.certId.serialNumber===i.serialNumber&&Ot.isEqual(gt.AsnConvert.serialize(n.certId.name),gt.AsnConvert.serialize(s))))continue}}try{let s={...i.publicKey.algorithm,...e.signatureAlgorithm},a=await i.publicKey.export(s,["verify"],r);if(!await e.verify({publicKey:a,signatureOnly:!0},r))continue}catch{continue}return i}}return null}};function Xie(t,e=Rs.get()){let r=Ot.BufferSourceConverter.toUint8Array(Ot.Convert.FromHex(t||"")),n=r&&r.length&&r.some(s=>s>0)?new Uint8Array(r):void 0;n||(n=e.getRandomValues(new Uint8Array(16)));let i=0;for(;i<n.length-1&&n[i]===0;)i++;if(n=n.slice(i),n[0]>127){let s=new Uint8Array(n.length+1);s[0]=0,s.set(n,1),n=s}return n.buffer}var Gie=class{static async createSelfSigned(e,r=Rs.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},r)}static async create(e,r=Rs.get()){var n;let i;e.publicKey instanceof Zf?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:Ot.BufferSourceConverter.isBufferSource(e.publicKey)?i=e.publicKey:i=await r.subtle.exportKey("spki",e.publicKey);let s=Xie(e.serialNumber,r),a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),d=new mt.Certificate({tbsCertificate:new mt.TBSCertificate({version:mt.Version.v3,serialNumber:s,validity:new mt.Validity({notBefore:a,notAfter:c}),extensions:new mt.Extensions(((n=e.extensions)===null||n===void 0?void 0:n.map(C=>gt.AsnConvert.parse(C.rawData,mt.Extension)))||[]),subjectPublicKeyInfo:gt.AsnConvert.parse(i,mt.SubjectPublicKeyInfo)})});if(e.subject){let C=e.subject instanceof Ka?e.subject:new Ka(e.subject);d.tbsCertificate.subject=gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)}if(e.issuer){let C=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer);d.tbsCertificate.issuer=gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)}let h={hash:"SHA-256"},p="signingKey"in e?{...h,...e.signingAlgorithm,...e.signingKey.algorithm}:{...h,...e.signingAlgorithm},x=ls.container.resolve(Xf);d.tbsCertificate.signature=d.signatureAlgorithm=x.toAsnAlgorithm(p);let y=gt.AsnConvert.serialize(d.tbsCertificate),v="signingKey"in e?await r.subtle.sign(p,e.signingKey,y):e.signature,w=ls.container.resolveAll(tp).reverse(),S=null;for(let C of w)if(S=C.toAsnSignature(p,v),S)break;if(!S)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return d.signatureValue=S,new yg(gt.AsnConvert.serialize(d))}},hD,pD,tS,rS,nS;Wt.X509CrlReason=void 0;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Wt.X509CrlReason||(Wt.X509CrlReason={}));var uS=class extends vh{get serialNumber(){return yt.__classPrivateFieldGet(this,hD,"f")||yt.__classPrivateFieldSet(this,hD,Ot.Convert.ToHex(this.asn.userCertificate),"f"),yt.__classPrivateFieldGet(this,hD,"f")}get revocationDate(){return yt.__classPrivateFieldGet(this,pD,"f")||yt.__classPrivateFieldSet(this,pD,this.asn.revocationDate.getTime(),"f"),yt.__classPrivateFieldGet(this,pD,"f")}get reason(){return yt.__classPrivateFieldGet(this,tS,"f")===void 0&&this.extensions,yt.__classPrivateFieldGet(this,tS,"f")}get invalidity(){return yt.__classPrivateFieldGet(this,rS,"f")===void 0&&this.extensions,yt.__classPrivateFieldGet(this,rS,"f")}get extensions(){return yt.__classPrivateFieldGet(this,nS,"f")||(yt.__classPrivateFieldSet(this,nS,[],"f"),this.asn.crlEntryExtensions&&yt.__classPrivateFieldSet(this,nS,this.asn.crlEntryExtensions.map(e=>{let r=mo.create(gt.AsnConvert.serialize(e));switch(r.type){case Fr.id_ce_cRLReasons:yt.__classPrivateFieldGet(this,tS,"f")===void 0&&yt.__classPrivateFieldSet(this,tS,gt.AsnConvert.parse(r.value,Fr.CRLReason).reason,"f");break;case Fr.id_ce_invalidityDate:yt.__classPrivateFieldGet(this,rS,"f")===void 0&&yt.__classPrivateFieldSet(this,rS,gt.AsnConvert.parse(r.value,Fr.InvalidityDate).value,"f");break}return r}),"f")),yt.__classPrivateFieldGet(this,nS,"f")}constructor(...e){let r;if(Ot.BufferSourceConverter.isBufferSource(e[0])?r=Ot.BufferSourceConverter.toArrayBuffer(e[0]):typeof e[0]=="string"?r=gt.AsnConvert.serialize(new Fr.RevokedCertificate({userCertificate:Xie(e[0]),revocationDate:new Fr.Time(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Fr.RevokedCertificate&&(r=e[0]),!r)throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments.");super(r,Fr.RevokedCertificate),hD.set(this,void 0),pD.set(this,void 0),tS.set(this,void 0),rS.set(this,void 0),nS.set(this,void 0)}onInit(e){}};hD=new WeakMap,pD=new WeakMap,tS=new WeakMap,rS=new WeakMap,nS=new WeakMap;var mD,gD,xD,yD,vD,bD,iS,nU=class extends Iu{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!yt.__classPrivateFieldGet(this,gD,"f")){let e=ls.container.resolve(Xf);yt.__classPrivateFieldSet(this,gD,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return yt.__classPrivateFieldGet(this,gD,"f")}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return yt.__classPrivateFieldGet(this,xD,"f")||yt.__classPrivateFieldSet(this,xD,new Ka(this.asn.tbsCertList.issuer),"f"),yt.__classPrivateFieldGet(this,xD,"f")}get thisUpdate(){if(!yt.__classPrivateFieldGet(this,yD,"f")){let e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw new Error("Cannot get 'thisUpdate' value");yt.__classPrivateFieldSet(this,yD,e,"f")}return yt.__classPrivateFieldGet(this,yD,"f")}get nextUpdate(){var e;return yt.__classPrivateFieldGet(this,vD,"f")===void 0&&yt.__classPrivateFieldSet(this,vD,((e=this.asn.tbsCertList.nextUpdate)===null||e===void 0?void 0:e.getTime())||void 0,"f"),yt.__classPrivateFieldGet(this,vD,"f")}get entries(){var e;return yt.__classPrivateFieldGet(this,bD,"f")||yt.__classPrivateFieldSet(this,bD,((e=this.asn.tbsCertList.revokedCertificates)===null||e===void 0?void 0:e.map(r=>new uS(r)))||[],"f"),yt.__classPrivateFieldGet(this,bD,"f")}get extensions(){return yt.__classPrivateFieldGet(this,iS,"f")||(yt.__classPrivateFieldSet(this,iS,[],"f"),this.asn.tbsCertList.crlExtensions&&yt.__classPrivateFieldSet(this,iS,this.asn.tbsCertList.crlExtensions.map(e=>mo.create(gt.AsnConvert.serialize(e))),"f")),yt.__classPrivateFieldGet(this,iS,"f")}get tbs(){return yt.__classPrivateFieldGet(this,mD,"f")||yt.__classPrivateFieldSet(this,mD,this.asn.tbsCertListRaw||gt.AsnConvert.serialize(this.asn.tbsCertList),"f"),yt.__classPrivateFieldGet(this,mD,"f")}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,Iu.isAsnEncoded(e)?Fr.CertificateList:void 0),this.tag=po.CrlTag,mD.set(this,void 0),gD.set(this,void 0),xD.set(this,void 0),yD.set(this,void 0),vD.set(this,void 0),bD.set(this,void 0),iS.set(this,void 0)}onInit(e){}getExtension(e){for(let r of this.extensions)if(typeof e=="string"){if(r.type===e)return r}else if(r instanceof e)return r;return null}getExtensions(e){return this.extensions.filter(r=>typeof e=="string"?r.type===e:r instanceof e)}async verify(e,r=Rs.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch");let n,i,s=e.publicKey;try{s instanceof yg?(n={...s.publicKey.algorithm,...s.signatureAlgorithm},i=await s.publicKey.export(n,["verify"])):s instanceof Zf?(n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"])):(n={...s.algorithm,...this.signatureAlgorithm},i=s)}catch{return!1}let a=ls.container.resolveAll(tp).reverse(),c=null;for(let d of a)if(c=d.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return await r.subtle.verify(this.signatureAlgorithm,i,c,this.tbs)}async getThumbprint(...e){let r,n="SHA-1";return e[0]&&(e[0].subtle?r=e[0]:(n=e[0]||n,r=e[1])),r??(r=Rs.get()),await r.subtle.digest(n,this.rawData)}findRevoked(e){let r=typeof e=="string"?e:e.serialNumber,n=Xie(r);for(let i of this.asn.tbsCertList.revokedCertificates||[])if(Ot.BufferSourceConverter.isEqual(i.userCertificate,n))return new uS(gt.AsnConvert.serialize(i));return null}};mD=new WeakMap,gD=new WeakMap,xD=new WeakMap,yD=new WeakMap,vD=new WeakMap,bD=new WeakMap,iS=new WeakMap;var Kie=class{static async create(e,r=Rs.get()){var n;let i=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer),s=new mt.CertificateList({tbsCertList:new mt.TBSCertList({version:mt.Version.v2,issuer:gt.AsnConvert.parse(i.toArrayBuffer(),mt.Name),thisUpdate:new Fr.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(s.tbsCertList.nextUpdate=new Fr.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(s.tbsCertList.crlExtensions=new mt.Extensions(e.extensions.map(y=>gt.AsnConvert.parse(y.rawData,mt.Extension))||[])),e.entries&&e.entries.length){s.tbsCertList.revokedCertificates=[];for(let y of e.entries){let v=Iu.toArrayBuffer(y.serialNumber);if(s.tbsCertList.revokedCertificates.findIndex(C=>Ot.isEqual(C.userCertificate,v))>-1)throw new Error(`Certificate serial number ${y.serialNumber} already exists in tbsCertList`);let S=new Fr.RevokedCertificate({userCertificate:v,revocationDate:new Fr.Time(y.revocationDate||new Date)});if("extensions"in y&&(!((n=y.extensions)===null||n===void 0)&&n.length)?S.crlEntryExtensions=y.extensions.map(C=>gt.AsnConvert.parse(C.rawData,mt.Extension)):S.crlEntryExtensions=[],!(y instanceof uS)&&(y.reason&&S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_cRLReasons,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(new mt.CRLReason(y.reason)))})),y.invalidity&&S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_invalidityDate,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(new mt.InvalidityDate(y.invalidity)))})),y.issuer)){let C=e.issuer instanceof Ka?e.issuer:new Ka(e.issuer);S.crlEntryExtensions.push(new mt.Extension({extnID:mt.id_ce_certificateIssuer,critical:!1,extnValue:new gt.OctetString(gt.AsnConvert.serialize(gt.AsnConvert.parse(C.toArrayBuffer(),mt.Name)))}))}s.tbsCertList.revokedCertificates.push(S)}}let a={...e.signingAlgorithm,...e.signingKey.algorithm},c=ls.container.resolve(Xf);s.tbsCertList.signature=s.signatureAlgorithm=c.toAsnAlgorithm(a);let d=gt.AsnConvert.serialize(s.tbsCertList),h=await r.subtle.sign(a,e.signingKey,d),p=ls.container.resolveAll(tp).reverse(),x=null;for(let y of p)if(x=y.toAsnSignature(a,h),x)break;if(!x)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return s.signature=x,new nU(gt.AsnConvert.serialize(s))}};mo.register(mt.id_ce_basicConstraints,ED);mo.register(mt.id_ce_extKeyUsage,TD);mo.register(mt.id_ce_keyUsage,CD);mo.register(mt.id_ce_subjectKeyIdentifier,kD);mo.register(mt.id_ce_authorityKeyIdentifier,AD);mo.register(mt.id_ce_subjectAltName,DD);mo.register(mt.id_ce_cRLDistributionPoints,FD);mo.register(mt.id_pe_authorityInfoAccess,PD);mo.register(mt.id_ce_issuerAltName,RD);sv.register(sS.id_pkcs9_at_challengePassword,OD);sv.register(sS.id_pkcs9_at_extensionRequest,cS);ls.container.registerSingleton(tp,tU);ls.container.registerSingleton(tp,_h);_h.namedCurveSize.set("P-256",32);_h.namedCurveSize.set("K-256",32);_h.namedCurveSize.set("P-384",48);_h.namedCurveSize.set("P-521",66);Wt.AlgorithmProvider=QB;Wt.AsnData=vh;Wt.AsnDefaultSignatureFormatter=tU;Wt.AsnEcSignatureFormatter=_h;Wt.Attribute=iv;Wt.AttributeFactory=sv;Wt.AuthorityInfoAccessExtension=PD;Wt.AuthorityKeyIdentifierExtension=AD;Wt.BasicConstraintsExtension=ED;Wt.CRLDistributionPointsExtension=FD;Wt.CertificatePolicyExtension=ID;Wt.ChallengePasswordAttribute=OD;Wt.CryptoProvider=aS;Wt.DN=qB;Wt.DNS=jB;Wt.DefaultAlgorithmSerializer=eU;Wt.EMAIL=zB;Wt.ExtendedKeyUsageExtension=TD;Wt.Extension=ku;Wt.ExtensionFactory=mo;Wt.ExtensionsAttribute=cS;Wt.GUID=VB;Wt.GeneralName=Kf;Wt.GeneralNames=bh;Wt.IP=WB;Wt.IssuerAlternativeNameExtension=RD;Wt.KeyUsagesExtension=CD;Wt.Name=Ka;Wt.NameIdentifier=wD;Wt.OidSerializer=rf;Wt.PemConverter=po;Wt.PemData=Iu;Wt.Pkcs10CertificateRequest=ND;Wt.Pkcs10CertificateRequestGenerator=Hie;Wt.PublicKey=Zf;Wt.REGISTERED_ID=K3;Wt.SubjectAlternativeNameExtension=DD;Wt.SubjectKeyIdentifierExtension=kD;Wt.TextConverter=Yf;Wt.TextObject=qn;Wt.UPN=GB;Wt.URL=HB;Wt.X509Certificate=yg;Wt.X509CertificateGenerator=Gie;Wt.X509Certificates=rU;Wt.X509ChainBuilder=Vie;Wt.X509Crl=nU;Wt.X509CrlEntry=uS;Wt.X509CrlGenerator=Kie;Wt.cryptoProvider=Rs;Wt.diAlgorithm=lS;Wt.diAlgorithmProvider=Xf;Wt.diAsnSignatureFormatter=tp;Wt.idEd25519=XB;Wt.idEd448=Wie;Wt.idX25519=ZB;Wt.idX448=zie});var gPe=L((Cir,mPe)=>{"use strict";function BCt(t){return/^[$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][$A-Z\_a-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc0-9\u0300-\u036f\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19b0-\u19c0\u19c8\u19c9\u19d0-\u19d9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f]*$/.test(t)}mPe.exports=BCt});var UD=L((kir,EPe)=>{var xPe=Kr("util"),_Pe=gPe(),yPe=/[\{\[]/,vPe=/[\}\]]/,bPe=["do","if","in","for","let","new","try","var","case","else","enum","eval","null","this","true","void","with","await","break","catch","class","const","false","super","throw","while","yield","delete","export","import","public","return","static","switch","typeof","default","extends","finally","package","private","continue","debugger","function","arguments","interface","protected","implements","instanceof","NaN","undefined"],wPe={};for(iU=0;iU<bPe.length;iU++)wPe[bPe[iU]]=!0;var iU,UCt=function(t){return _Pe(t)&&!wPe.hasOwnProperty(t)},SPe={s:function(t){return""+t},d:function(t){return""+Number(t)},o:function(t){return JSON.stringify(t)}},APe=function(){var t=[],e=0,r={},n=function(a){for(var c="";c.length<e*2;)c+=" ";t.push(c+a)},i=function(a){if(vPe.test(a.trim()[0])&&yPe.test(a[a.length-1])){e--,n(a),e++;return}if(yPe.test(a[a.length-1])){n(a),e++;return}if(vPe.test(a.trim()[0])){e--,n(a);return}n(a)},s=function(a){if(!a)return s;if(arguments.length===1&&a.indexOf(`
1011
1020
  `)>-1)for(var c=a.trim().split(`
1012
1021
  `),d=0;d<c.length;d++)i(c[d].trim());else i(xPe.format.apply(xPe,arguments));return s};return s.scope={},s.formats=SPe,s.sym=function(a){return(!a||!UCt(a))&&(a="tmp"),r[a]||(r[a]=0),a+(r[a]++||"")},s.property=function(a,c){return arguments.length===1&&(c=a,a=""),c=c+"",_Pe(c)?a?a+"."+c:c:a?a+"["+JSON.stringify(c)+"]":JSON.stringify(c)},s.toString=function(){return t.join(`
1013
- `)},s.toFunction=function(a){a||(a={});var c="return ("+s.toString()+")";Object.keys(s.scope).forEach(function(p){a[p]||(a[p]=s.scope[p])});var d=Object.keys(a).map(function(p){return p}),h=d.map(function(p){return a[p]});return Function.apply(null,d.concat(c)).apply(null,h)},arguments.length&&s.apply(null,arguments),s};APe.formats=SPe;EPe.exports=APe});var CPe=L((Dir,TPe)=>{"use strict";var aU=class{constructor(){this.next=null,this.buffer=null}};TPe.exports=class sU{constructor(){this.head=null,this.tail=null,this.length=0,this.count=0}push(e){let r=new aU;r.buffer=e,this.length>0?this.tail.next=r:this.head=r,this.tail=r,this.length+=e.length,this.count+=1}unshift(e){let r=new aU;r.buffer=e,r.next=this.head,this.isEmpty()&&(this.tail=r),this.head=r,this.length+=e.length,this.count+=1}shift(){if(this.isEmpty())return null;let e=this.head.buffer;return this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,this.length-=e.length,this.length=Math.max(this.length,0),this.count-=1,e}get first(){return this.isEmpty()?null:this.head.buffer}get last(){return this.isEmpty()?null:this.tail.buffer}isEmpty(){return this.length===0}clear(){this.head=null,this.tail=null,this.length=0,this.count=0}slice(e,r){if(e<0||e>=this.length)return new sU;if(r<0||r>this.length||r<e)return new sU;let n=new sU,i=this.head,s=e,a=r;for(;i;){if(i.buffer.length>s){s===0&&i.buffer.length<=a?n.push(i.buffer):i.buffer.length>=a?n.push(i.buffer.slice(s,a)):n.push(i.buffer.slice(s));break}s-=i.buffer.length,a-=i.buffer.length,i=i.next}if(i.buffer.length<a)for(;i;){if(i.buffer.length===a){n.push(i.buffer);break}else if(i.buffer.length>a){n.push(i.buffer.slice(0,a));break}else s<0&&i.buffer.length<a&&n.push(i.buffer);s-=i.buffer.length,a-=i.buffer.length,i=i.next}return n}}});var FPe=L((Iir,IPe)=>{"use strict";var oU=U6(),MCt=CPe(),av=class t{constructor(){this.queue=new MCt,this.offset=0}get length(){return this.queue.length-this.offset}append(e){if(Buffer.isBuffer(e)){if(this.offset>0){let r=this.queue.shift();this.queue.unshift(r.slice(this.offset)),this.offset=0}this.queue.push(e)}else if(Array.isArray(e))for(let r=0;r<e.length;r+=1)this.append(e[r]);else if(e instanceof t){if(this.offset>0){let n=this.queue.shift();this.queue.unshift(n.slice(this.offset)),this.offset=0}if(e.offset>0){let n=e.queue.shift();e.queue.unshift(n.slice(e.offset)),e.offset=0}let r=e.queue.head;for(;r;)this.queue.push(r.buffer),r=r.next}}get(e){let r=e;for(;r>=this.length;)r-=this.length;for(;r<0;)r+=this.length;let n=this.queue.head,{offset:i}=this;for(;n;){if(n.buffer.length-i>r)return n.buffer[r+i];r-=n.buffer.length-i,i=0,n=n.next}}slice(e,r){for(typeof e!="number"&&(e=0),typeof r!="number"&&(r=this.length);e<0;)e+=this.length;for(;r<0;)r+=this.length;if(r=Math.min(r,this.length),e>=this.length||r===0)return Buffer.alloc(0);let n=e;e=Math.min(n,r),r=Math.max(n,r);let i=this.queue.slice(e+this.offset,r+this.offset);if(i.count===1)return i.first;let s=i.head,a=Buffer.allocUnsafe(i.length),c=0;for(let d=0;d<i.count;d+=1)a.set(s.buffer,c),c+=s.buffer.length,s=s.next;return a}toString(e,r,n){return this.slice(r,n).toString(e)}consume(e){let r=e;for(;this.length>0;){let n=this.queue.first.length-this.offset;if(r>=n)this.queue.shift(),r-=n,this.offset=0;else{this.offset+=r;break}}}indexOf(e,r=0){if(!Number.isInteger(e))throw new TypeError("Invalid argument 1");if(e<0||e>255)throw new Error("Invalid argument 1");for(Number.isInteger(r)||(r=0);r>=this.length;)r-=this.length;for(;r<0;)r+=this.length;let n=this.queue.head,i=0,s=()=>{i+=n.buffer.length,n=n.next};for(;n;){let a=0;if(n===this.queue.head&&(a+=this.offset),r>=n.buffer.length-a){r-=n.buffer.length-a,s();continue}r<n.buffer.length&&(a+=r);let c=n.buffer.indexOf(e,a);if(c>-1)return c+i-this.offset;s(),a>this.offset&&(r=0)}return-1}},kPe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};Object.keys(kPe).forEach(t=>{let e=oU();e(`
1022
+ `)},s.toFunction=function(a){a||(a={});var c="return ("+s.toString()+")";Object.keys(s.scope).forEach(function(p){a[p]||(a[p]=s.scope[p])});var d=Object.keys(a).map(function(p){return p}),h=d.map(function(p){return a[p]});return Function.apply(null,d.concat(c)).apply(null,h)},arguments.length&&s.apply(null,arguments),s};APe.formats=SPe;EPe.exports=APe});var CPe=L((Dir,TPe)=>{"use strict";var aU=class{constructor(){this.next=null,this.buffer=null}};TPe.exports=class sU{constructor(){this.head=null,this.tail=null,this.length=0,this.count=0}push(e){let r=new aU;r.buffer=e,this.length>0?this.tail.next=r:this.head=r,this.tail=r,this.length+=e.length,this.count+=1}unshift(e){let r=new aU;r.buffer=e,r.next=this.head,this.isEmpty()&&(this.tail=r),this.head=r,this.length+=e.length,this.count+=1}shift(){if(this.isEmpty())return null;let e=this.head.buffer;return this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,this.length-=e.length,this.length=Math.max(this.length,0),this.count-=1,e}get first(){return this.isEmpty()?null:this.head.buffer}get last(){return this.isEmpty()?null:this.tail.buffer}isEmpty(){return this.length===0}clear(){this.head=null,this.tail=null,this.length=0,this.count=0}slice(e,r){if(e<0||e>=this.length)return new sU;if(r<0||r>this.length||r<e)return new sU;let n=new sU,i=this.head,s=e,a=r;for(;i;){if(i.buffer.length>s){s===0&&i.buffer.length<=a?n.push(i.buffer):i.buffer.length>=a?n.push(i.buffer.slice(s,a)):n.push(i.buffer.slice(s));break}s-=i.buffer.length,a-=i.buffer.length,i=i.next}if(i.buffer.length<a)for(;i;){if(i.buffer.length===a){n.push(i.buffer);break}else if(i.buffer.length>a){n.push(i.buffer.slice(0,a));break}else s<0&&i.buffer.length<a&&n.push(i.buffer);s-=i.buffer.length,a-=i.buffer.length,i=i.next}return n}}});var FPe=L((Iir,IPe)=>{"use strict";var oU=UD(),MCt=CPe(),av=class t{constructor(){this.queue=new MCt,this.offset=0}get length(){return this.queue.length-this.offset}append(e){if(Buffer.isBuffer(e)){if(this.offset>0){let r=this.queue.shift();this.queue.unshift(r.slice(this.offset)),this.offset=0}this.queue.push(e)}else if(Array.isArray(e))for(let r=0;r<e.length;r+=1)this.append(e[r]);else if(e instanceof t){if(this.offset>0){let n=this.queue.shift();this.queue.unshift(n.slice(this.offset)),this.offset=0}if(e.offset>0){let n=e.queue.shift();e.queue.unshift(n.slice(e.offset)),e.offset=0}let r=e.queue.head;for(;r;)this.queue.push(r.buffer),r=r.next}}get(e){let r=e;for(;r>=this.length;)r-=this.length;for(;r<0;)r+=this.length;let n=this.queue.head,{offset:i}=this;for(;n;){if(n.buffer.length-i>r)return n.buffer[r+i];r-=n.buffer.length-i,i=0,n=n.next}}slice(e,r){for(typeof e!="number"&&(e=0),typeof r!="number"&&(r=this.length);e<0;)e+=this.length;for(;r<0;)r+=this.length;if(r=Math.min(r,this.length),e>=this.length||r===0)return Buffer.alloc(0);let n=e;e=Math.min(n,r),r=Math.max(n,r);let i=this.queue.slice(e+this.offset,r+this.offset);if(i.count===1)return i.first;let s=i.head,a=Buffer.allocUnsafe(i.length),c=0;for(let d=0;d<i.count;d+=1)a.set(s.buffer,c),c+=s.buffer.length,s=s.next;return a}toString(e,r,n){return this.slice(r,n).toString(e)}consume(e){let r=e;for(;this.length>0;){let n=this.queue.first.length-this.offset;if(r>=n)this.queue.shift(),r-=n,this.offset=0;else{this.offset+=r;break}}}indexOf(e,r=0){if(!Number.isInteger(e))throw new TypeError("Invalid argument 1");if(e<0||e>255)throw new Error("Invalid argument 1");for(Number.isInteger(r)||(r=0);r>=this.length;)r-=this.length;for(;r<0;)r+=this.length;let n=this.queue.head,i=0,s=()=>{i+=n.buffer.length,n=n.next};for(;n;){let a=0;if(n===this.queue.head&&(a+=this.offset),r>=n.buffer.length-a){r-=n.buffer.length-a,s();continue}r<n.buffer.length&&(a+=r);let c=n.buffer.indexOf(e,a);if(c>-1)return c+i-this.offset;s(),a>this.offset&&(r=0)}return-1}},kPe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};Object.keys(kPe).forEach(t=>{let e=oU();e(`
1014
1023
  function bufferlist_${t}(offset = 0) {
1015
1024
  const start = offset + this.offset;
1016
1025
  const head = this.queue.first;
@@ -1044,7 +1053,7 @@ ${e.join(`
1044
1053
  buf.${t}(value, 0, size);
1045
1054
  this.append(buf);
1046
1055
  }
1047
- `),av.prototype[t]=e.toFunction()});IPe.exports=av});var fS=L((Pir,PPe)=>{"use strict";PPe.exports=class extends Error{constructor(e,r){let n=`requested ${e} bytes but only ${r} available`;super(n),this.name="NotEnoughDataError"}}});var M6=L((Rir,NPe)=>{"use strict";var{Transform:jCt}=Kr("stream"),cU=U6(),qCt=FPe(),zCt=fS(),RPe=Symbol("buffer"),ov=class extends jCt{constructor(e={}){super(e),this[RPe]=new qCt}get buffer(){return this[RPe]}get length(){return this.buffer.length}append(e){this.buffer.append(e)}get(e){return this.buffer.get(e)}slice(e,r){return this.buffer.slice(e,r)}consume(e){this.buffer.consume(e)}toString(e,r,n){return this.buffer.toString(e,r,n)}indexOf(e,r=0){return this.buffer.indexOf(e,r)}readBuffer(e){Yie(e,this.length);let r=this.slice(0,e);return this.consume(e),r}writeBuffer(e){this.append(e)}},OPe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1},WCt=["readIntBE","readIntLE","readUIntBE","readUIntLE"];Object.keys(OPe).forEach(t=>{let e=cU();e(`
1056
+ `),av.prototype[t]=e.toFunction()});IPe.exports=av});var fS=L((Pir,PPe)=>{"use strict";PPe.exports=class extends Error{constructor(e,r){let n=`requested ${e} bytes but only ${r} available`;super(n),this.name="NotEnoughDataError"}}});var MD=L((Rir,NPe)=>{"use strict";var{Transform:jCt}=Kr("stream"),cU=UD(),qCt=FPe(),zCt=fS(),RPe=Symbol("buffer"),ov=class extends jCt{constructor(e={}){super(e),this[RPe]=new qCt}get buffer(){return this[RPe]}get length(){return this.buffer.length}append(e){this.buffer.append(e)}get(e){return this.buffer.get(e)}slice(e,r){return this.buffer.slice(e,r)}consume(e){this.buffer.consume(e)}toString(e,r,n){return this.buffer.toString(e,r,n)}indexOf(e,r=0){return this.buffer.indexOf(e,r)}readBuffer(e){Yie(e,this.length);let r=this.slice(0,e);return this.consume(e),r}writeBuffer(e){this.append(e)}},OPe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1},WCt=["readIntBE","readIntLE","readUIntBE","readUIntLE"];Object.keys(OPe).forEach(t=>{let e=cU();e(`
1048
1057
  function binary_${t}() {
1049
1058
  const bytes = ${e.formats.d(OPe[t])};
1050
1059
  assertSize(bytes, this.length);
@@ -1070,7 +1079,7 @@ ${e.join(`
1070
1079
  function binary_${t}(value, size) {
1071
1080
  this.buffer.${t}(value, size);
1072
1081
  }
1073
- `),ov.prototype[t]=e.toFunction()});function Yie(t,e){if(t>e)throw new zCt(t,e)}NPe.exports=ov});var UPe=L((Oir,BPe)=>{"use strict";BPe.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var $Pe=L((Nir,LPe)=>{"use strict";var GCt=UPe();function MPe(t){return GCt(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}LPe.exports=function(e){var r,n;return!(MPe(e)===!1||(r=e.constructor,typeof r!="function")||(n=r.prototype,MPe(n)===!1)||n.hasOwnProperty("isPrototypeOf")===!1)}});var wh=L((Bir,jPe)=>{"use strict";var KCt=$Pe();jPe.exports={isType:ZCt,isUserType:KCt,isFunction:L6,isDecodeType:XCt,isEncodeType:YCt};function ZCt(t){return Jie(t)&&L6(t.encode)&&L6(t.decode)}function L6(t){return typeof t=="function"}function Jie(t){return typeof t=="object"&&t!==null}function XCt(t){return Jie(t)&&L6(t.decode)}function YCt(t){return Jie(t)&&L6(t.encode)}});var vg=L((Uir,qPe)=>{"use strict";var JCt=Symbol("skip"),QCt=Symbol("bytes");qPe.exports={skip:JCt,bytes:QCt}});var bg=L((Mir,WPe)=>{"use strict";var zPe=vg();WPe.exports=class uU{constructor(){this[zPe.bytes]=0,this.node=void 0,this.current=void 0}get bytes(){return this[zPe.bytes]}static clone(e){let r=new uU;return e instanceof uU&&(r.node=e.node,r.current=e.current),r}static clean(e){e instanceof uU&&(e.node=void 0,e.current=void 0)}}});var dS=L((Lir,ZPe)=>{"use strict";var{isType:ekt,isUserType:tkt,isDecodeType:rkt}=wh(),nkt=M6(),Qie=vg(),HPe=bg();ZPe.exports={decode:VPe,decodeCommon:GPe};function VPe(t,e){let r=t;Buffer.isBuffer(t)&&(r=new nkt,r.append(t));let n=new HPe,i=GPe(r,e,n);return VPe.bytes=n.bytes,HPe.clean(n),i}function GPe(t,e,r){if(ekt(e)){let n=e.decode.call(r,t);return r[Qie.bytes]+=e.decode.bytes,n}return KPe(t,e,r)}function KPe(t,e,r){ikt(e);let n=Object.create(null);r.node===void 0&&(r.node=n),r.current=n;let i=Object.keys(e);for(let s=0;s<i.length;s+=1){let a=i[s],c=e[a];if(!rkt(c)){n[a]=KPe(t,c,r),r.current=n;continue}let d=c.decode.call(r,t);r[Qie.bytes]+=c.decode.bytes,c[Qie.skip]!==!0&&(n[a]=d)}return n}function ikt(t){if(!tkt(t))throw new TypeError("Argument #2 should be a plain object.")}});var $6=L(($ir,tRe)=>{"use strict";var{isUserType:skt,isEncodeType:akt,isType:okt}=wh(),YPe=vg(),XPe=bg(),ese=M6();tRe.exports={encode:JPe,encodeCommon:QPe};function JPe(t,e,r){let n=new XPe;if(e instanceof ese){let i=r;r=e,e=i}return r instanceof ese||(r=new ese),QPe(t,r,e,n),JPe.bytes=n.bytes,XPe.clean(n),r}function QPe(t,e,r,n){okt(r)?(r.encode.call(n,t,e),n[YPe.bytes]+=r.encode.bytes):eRe(t,e,r,n)}function eRe(t,e,r,n){ckt(r),n.node===void 0&&(n.node=t),n.current=t;let i=Object.keys(r);for(let s=0;s<i.length;s+=1){let a=i[s],c=r[a],d=t[a];if(!akt(c)){eRe(d,e,c,n),n.current=t;continue}c.encode.call(n,d,e),n[YPe.bytes]+=c.encode.bytes}}function ckt(t){if(!skt(t))throw new TypeError("Argument `schema` should be a plain object.")}});var j6=L((jir,oRe)=>{"use strict";var{isUserType:ukt,isType:nRe}=wh(),rRe=bg(),iRe=vg();oRe.exports={encodingLength:lkt,encodingLengthCommon:sRe};function lkt(t,e){let r=new rRe;return sRe(t,e,r),rRe.clean(r),r.bytes}function sRe(t,e,r){nRe(e)?r[iRe.bytes]+=e.encodingLength.call(r,t):aRe(t,e,r)}function aRe(t,e,r){if(!ukt(e))throw new TypeError("Argument `schema` should be a plain object.");r.node===void 0&&(r.node=t),r.current=t;let n=Object.keys(e);for(let i=0;i<n.length;i+=1){let s=n[i],a=e[s],c=t[s];if(!nRe(a)){aRe(c,a,r),r.current=t;continue}r[iRe.bytes]+=a.encodingLength.call(r,c)}}});var mRe=L((qir,pRe)=>{"use strict";var{decodeCommon:hRe}=dS(),{encodeCommon:fkt}=$6(),{encodingLengthCommon:cRe}=j6(),{isType:uRe,isUserType:dkt,isFunction:hkt}=wh(),_g=bg();pRe.exports=pkt;function pkt(t,e,r="count"){if(!uRe(t)&&!dkt(t))throw new TypeError("Argument #1 should be a valid type.");let n=r==="bytes",i=typeof e=="number",s=uRe(e),a=hkt(e);if(!i&&!s&&!a)throw new TypeError("Unknown type of argument #1.");return{encode:c,decode:d,encodingLength:h};function c(p,x){lRe(p);let y=_g.clone(this);c.bytes=0;let v=0;if(s?v=p.length:i?v=e:a&&(v=e(y),fRe(v)),n||dRe(v,p.length),n){let w=_g.clone(y);for(let S of p)cRe(S,t,w);s&&(v=w.bytes),dRe(w.bytes,v),_g.clean(w)}s&&(e.encode.call(y,v,x),c.bytes+=e.encode.bytes),p.forEach(w=>{fkt(w,x,t,y)}),c.bytes+=y.bytes,_g.clean(y)}function d(p){let x=0;d.bytes=0;let y=_g.clone(this);i?x=e:s?(x=e.decode.call(y,p),d.bytes+=e.decode.bytes):a&&(x=e(y)),fRe(x);let v;return n?v=mkt(t,x,p,y):v=gkt(t,x,p,y),d.bytes+=y.bytes,_g.clean(y),v}function h(p){lRe(p);let x=_g.clone(this),y=0;if(i&&n)return e;s&&!n&&(y=e.encodingLength(p.length));for(let v of p)cRe(v,t,x);return _g.clean(x),y+=x.bytes,s&&n&&(y+=e.encodingLength(y)),y}}function lRe(t){if(!Array.isArray(t))throw new TypeError("Argument #1 should be an Array.")}function fRe(t){if(typeof t!="number")throw new TypeError("Length of an array should be a number.")}function dRe(t,e){if(t!==e)throw new Error(`Argument #1 required length ${t} instead of ${e}`)}function mkt(t,e,r,n){let i=[],s=n.bytes,a=0;for(;a<e;)i.push(hRe(r,t,n)),a=n.bytes-s;if(a>e)throw new Error("Incorrect length of an array.");return i}function gkt(t,e,r,n){let i=new Array(e);for(let s=0;s<e;s+=1)i[s]=hRe(r,t,n);return i}});var vRe=L((zir,yRe)=>{"use strict";var{isType:xkt,isFunction:ykt}=wh(),vkt=fS(),bkt=M6();yRe.exports=_kt;function _kt(t){let e=typeof t=="number",r=xkt(t),n=ykt(t),i=t===null;if(!e&&!r&&!n&&!i)throw new TypeError("Unknown type of argument #1.");return{encode:s,decode:a,encodingLength:c};function s(d,h){gRe(d),s.bytes=0;let p=this;if(e&&xRe(t,d.length),r&&(t.encode.call(p,d.length,h),s.bytes+=t.encode.bytes),n){let x=t(p);tse(x),xRe(x,d.length)}h.writeBuffer(Buffer.isBuffer(d)?d:d.buffer),s.bytes+=d.length,i&&(h.writeUInt8(0),s.bytes+=1)}function a(d){let h=0;a.bytes=0;let p=this;if(e)h=t;else if(r)h=t.decode.call(p,d),a.bytes+=t.decode.bytes,tse(h);else if(n)h=t(p),tse(h);else if(i&&(h=d.indexOf(0),h===-1))throw new vkt(d.length+1,d.length);let x=d.readBuffer(h);return a.bytes+=h,i&&(a.bytes+=1,d.consume(1)),x}function c(d){gRe(d);let h=0;return e?t:(i?h=1:r&&(h=t.encodingLength(d.length)),h+d.length)}}function gRe(t){if(!Buffer.isBuffer(t)&&!(t instanceof bkt))throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.")}function xRe(t,e){if(t!==e)throw new Error(`Buffer required length ${t} instead of ${e}`)}function tse(t){if(typeof t!="number")throw new TypeError("Length of a buffer should be a number.")}});var _Re=L((Wir,bRe)=>{"use strict";var{isType:wkt}=wh();bRe.exports=Skt;function Skt(t){if(!wkt(t))throw new TypeError("Argument #1 should be valid type.");function e(n){let i=this,s=t.decode.call(i,n);return e.bytes=t.decode.bytes,!!s}function r(n,i){let s=this;t.encode.call(s,n?1:0,i),r.bytes=t.encode.bytes}return{encode:r,decode:e,encodingLength:t.encodingLength}}});var SRe=L((Hir,wRe)=>{"use strict";var{decodeCommon:Akt}=dS(),{encodeCommon:Ekt}=$6(),{encodingLengthCommon:Tkt}=j6(),{isType:Ckt,isFunction:lU}=wh(),kkt=vg(),wg=bg();wRe.exports=Dkt;function Dkt(t,e=1){if(!Ckt(t))throw new TypeError("Invalid data type.");if(!Number.isInteger(e)&&!lU(e))throw new TypeError("Argument #2 should be a valid integer or function.");return{[kkt.skip]:!0,encodingLength:r,decode:n,encode:i};function r(s){let a=wg.clone(this),c=lU(e)?e(a):e;return Tkt(s,t,a),wg.clean(a),a.bytes*c}function n(s){let a=wg.clone(this);n.bytes=0;let c=lU(e)?e(a):e;if(c===0){wg.clean(a);return}for(let d=c;d>0;d-=1)Akt(s,t,a);n.bytes=a.bytes,wg.clean(a)}function i(s,a){i.bytes=0;let c=wg.clone(this),d=lU(e)?e(c):e;if(d===0){wg.clean(c);return}for(let h=d;h>0;h-=1)Ekt(0,a,t,c);i.bytes=c.bytes,wg.clean(c)}}});var TRe=L((Vir,ERe)=>{"use strict";var{isType:Ikt}=wh(),Fkt=fS();ERe.exports=Pkt;function Pkt(t,e="ascii"){if(!Buffer.isEncoding(e))throw new Error("Argument #2 should be an encoding name.");if(typeof t=="number")return{encode:Nkt(t,e),decode:Bkt(t,e),encodingLength:()=>t};if(Ikt(t))return{encode:Ukt(t,e),decode:Mkt(t,e),encodingLength:Lkt(t,e)};if(t===null)return{encode:Rkt(e),decode:Okt(e),encodingLength(r){return Buffer.byteLength(r,e)+1}};if(typeof t=="function")return{encode:$kt(t,e),decode:jkt(t,e),encodingLength(r){return Buffer.byteLength(r,e)}};throw new TypeError("Unknown type of argument #1.")}function Rkt(t){return function e(r,n){let i=Buffer.from(r.toString(),t);n.writeBuffer(i),n.writeInt8(0),e.bytes=i.length+1}}function Okt(t){return function e(r){let n=r.indexOf(0);if(n===-1)throw new Fkt(r.length+1,r.length);let i=n+1,s=r.readBuffer(i);return e.bytes=i,s.toString(t,0,n)}}function Nkt(t,e){return function r(n,i){if(n=n.toString(),Buffer.byteLength(n,e)!==t)throw new Error(`Size of string should be ${t} in bytes.`);let s=Buffer.from(n,e);i.writeBuffer(s),r.bytes=s.length}}function Bkt(t,e){return function r(n){let i=n.readBuffer(t);return r.bytes=t,i.toString(e)}}function Ukt(t,e){return function r(n,i){n=n.toString();let s=this;t.encode.call(s,Buffer.byteLength(n,e),i),r.bytes=t.encode.bytes;let a=Buffer.from(n,e);i.writeBuffer(a),r.bytes+=a.length}}function Mkt(t,e){return function r(n){let i=t.decode.call(this,n);if(typeof i!="number")throw new TypeError("Size of a string should be a number.");let s=n.readBuffer(i);return r.bytes=t.decode.bytes+s.length,s.toString(e)}}function Lkt(t,e){return function(n){let i=Buffer.byteLength(n,e);return t.encodingLength(i)+i}}function $kt(t,e){return function r(n,i){r.bytes=0;let a=t(this),c=Buffer.from(n.toString(),e);ARe(a),qkt(a,c.length),i.writeBuffer(c),r.bytes+=c.length}}function jkt(t,e){return function r(n){let i=t(this);ARe(i);let s=n.readBuffer(i);return r.bytes=i,s.toString(e)}}function ARe(t){if(typeof t!="number")throw new TypeError("Length of a buffer should be a number.")}function qkt(t,e){if(t!==e)throw new Error(`Buffer required length ${t} instead of ${e}`)}});var kRe=L((Gir,CRe)=>{"use strict";var fU=U6();CRe.exports={doublebe:Pu(8,"writeDoubleBE","readDoubleBE"),doublele:Pu(8,"writeDoubleLE","readDoubleLE"),floatbe:Pu(4,"writeFloatBE","readFloatBE"),floatle:Pu(4,"writeFloatLE","readFloatLE"),int8:Pu(1,"writeInt8","readInt8"),uint8:Pu(1,"writeUInt8","readUInt8"),int16be:Pu(2,"writeInt16BE","readInt16BE"),uint16be:Pu(2,"writeUInt16BE","readUInt16BE"),int16le:Pu(2,"writeInt16LE","readInt16LE"),uint16le:Pu(2,"writeUInt16LE","readUInt16LE"),int32be:Pu(4,"writeInt32BE","readInt32BE"),uint32be:Pu(4,"writeUInt32BE","readUInt32BE"),int32le:Pu(4,"writeInt32LE","readInt32LE"),uint32le:Pu(4,"writeUInt32LE","readUInt32LE"),int24be:nf(3,"writeIntBE","readIntBE"),uint24be:nf(3,"writeUIntBE","readUIntBE"),int24le:nf(3,"writeIntLE","readIntLE"),uint24le:nf(3,"writeUIntLE","readUIntLE"),int40be:nf(5,"writeIntBE","readIntBE"),uint40be:nf(5,"writeUIntBE","readUIntBE"),int40le:nf(5,"writeIntLE","readIntLE"),uint40le:nf(5,"writeUIntLE","readUIntLE"),int48be:nf(6,"writeIntBE","readIntBE"),uint48be:nf(6,"writeUIntBE","readUIntBE"),int48le:nf(6,"writeIntLE","readIntLE"),uint48le:nf(6,"writeUIntLE","readUIntLE")};function Pu(t,e,r){let n=fU(),i=fU();return n(`
1082
+ `),ov.prototype[t]=e.toFunction()});function Yie(t,e){if(t>e)throw new zCt(t,e)}NPe.exports=ov});var UPe=L((Oir,BPe)=>{"use strict";BPe.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var $Pe=L((Nir,LPe)=>{"use strict";var GCt=UPe();function MPe(t){return GCt(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}LPe.exports=function(e){var r,n;return!(MPe(e)===!1||(r=e.constructor,typeof r!="function")||(n=r.prototype,MPe(n)===!1)||n.hasOwnProperty("isPrototypeOf")===!1)}});var wh=L((Bir,jPe)=>{"use strict";var KCt=$Pe();jPe.exports={isType:ZCt,isUserType:KCt,isFunction:LD,isDecodeType:XCt,isEncodeType:YCt};function ZCt(t){return Jie(t)&&LD(t.encode)&&LD(t.decode)}function LD(t){return typeof t=="function"}function Jie(t){return typeof t=="object"&&t!==null}function XCt(t){return Jie(t)&&LD(t.decode)}function YCt(t){return Jie(t)&&LD(t.encode)}});var vg=L((Uir,qPe)=>{"use strict";var JCt=Symbol("skip"),QCt=Symbol("bytes");qPe.exports={skip:JCt,bytes:QCt}});var bg=L((Mir,WPe)=>{"use strict";var zPe=vg();WPe.exports=class uU{constructor(){this[zPe.bytes]=0,this.node=void 0,this.current=void 0}get bytes(){return this[zPe.bytes]}static clone(e){let r=new uU;return e instanceof uU&&(r.node=e.node,r.current=e.current),r}static clean(e){e instanceof uU&&(e.node=void 0,e.current=void 0)}}});var dS=L((Lir,ZPe)=>{"use strict";var{isType:ekt,isUserType:tkt,isDecodeType:rkt}=wh(),nkt=MD(),Qie=vg(),HPe=bg();ZPe.exports={decode:VPe,decodeCommon:GPe};function VPe(t,e){let r=t;Buffer.isBuffer(t)&&(r=new nkt,r.append(t));let n=new HPe,i=GPe(r,e,n);return VPe.bytes=n.bytes,HPe.clean(n),i}function GPe(t,e,r){if(ekt(e)){let n=e.decode.call(r,t);return r[Qie.bytes]+=e.decode.bytes,n}return KPe(t,e,r)}function KPe(t,e,r){ikt(e);let n=Object.create(null);r.node===void 0&&(r.node=n),r.current=n;let i=Object.keys(e);for(let s=0;s<i.length;s+=1){let a=i[s],c=e[a];if(!rkt(c)){n[a]=KPe(t,c,r),r.current=n;continue}let d=c.decode.call(r,t);r[Qie.bytes]+=c.decode.bytes,c[Qie.skip]!==!0&&(n[a]=d)}return n}function ikt(t){if(!tkt(t))throw new TypeError("Argument #2 should be a plain object.")}});var $D=L(($ir,tRe)=>{"use strict";var{isUserType:skt,isEncodeType:akt,isType:okt}=wh(),YPe=vg(),XPe=bg(),ese=MD();tRe.exports={encode:JPe,encodeCommon:QPe};function JPe(t,e,r){let n=new XPe;if(e instanceof ese){let i=r;r=e,e=i}return r instanceof ese||(r=new ese),QPe(t,r,e,n),JPe.bytes=n.bytes,XPe.clean(n),r}function QPe(t,e,r,n){okt(r)?(r.encode.call(n,t,e),n[YPe.bytes]+=r.encode.bytes):eRe(t,e,r,n)}function eRe(t,e,r,n){ckt(r),n.node===void 0&&(n.node=t),n.current=t;let i=Object.keys(r);for(let s=0;s<i.length;s+=1){let a=i[s],c=r[a],d=t[a];if(!akt(c)){eRe(d,e,c,n),n.current=t;continue}c.encode.call(n,d,e),n[YPe.bytes]+=c.encode.bytes}}function ckt(t){if(!skt(t))throw new TypeError("Argument `schema` should be a plain object.")}});var jD=L((jir,oRe)=>{"use strict";var{isUserType:ukt,isType:nRe}=wh(),rRe=bg(),iRe=vg();oRe.exports={encodingLength:lkt,encodingLengthCommon:sRe};function lkt(t,e){let r=new rRe;return sRe(t,e,r),rRe.clean(r),r.bytes}function sRe(t,e,r){nRe(e)?r[iRe.bytes]+=e.encodingLength.call(r,t):aRe(t,e,r)}function aRe(t,e,r){if(!ukt(e))throw new TypeError("Argument `schema` should be a plain object.");r.node===void 0&&(r.node=t),r.current=t;let n=Object.keys(e);for(let i=0;i<n.length;i+=1){let s=n[i],a=e[s],c=t[s];if(!nRe(a)){aRe(c,a,r),r.current=t;continue}r[iRe.bytes]+=a.encodingLength.call(r,c)}}});var mRe=L((qir,pRe)=>{"use strict";var{decodeCommon:hRe}=dS(),{encodeCommon:fkt}=$D(),{encodingLengthCommon:cRe}=jD(),{isType:uRe,isUserType:dkt,isFunction:hkt}=wh(),_g=bg();pRe.exports=pkt;function pkt(t,e,r="count"){if(!uRe(t)&&!dkt(t))throw new TypeError("Argument #1 should be a valid type.");let n=r==="bytes",i=typeof e=="number",s=uRe(e),a=hkt(e);if(!i&&!s&&!a)throw new TypeError("Unknown type of argument #1.");return{encode:c,decode:d,encodingLength:h};function c(p,x){lRe(p);let y=_g.clone(this);c.bytes=0;let v=0;if(s?v=p.length:i?v=e:a&&(v=e(y),fRe(v)),n||dRe(v,p.length),n){let w=_g.clone(y);for(let S of p)cRe(S,t,w);s&&(v=w.bytes),dRe(w.bytes,v),_g.clean(w)}s&&(e.encode.call(y,v,x),c.bytes+=e.encode.bytes),p.forEach(w=>{fkt(w,x,t,y)}),c.bytes+=y.bytes,_g.clean(y)}function d(p){let x=0;d.bytes=0;let y=_g.clone(this);i?x=e:s?(x=e.decode.call(y,p),d.bytes+=e.decode.bytes):a&&(x=e(y)),fRe(x);let v;return n?v=mkt(t,x,p,y):v=gkt(t,x,p,y),d.bytes+=y.bytes,_g.clean(y),v}function h(p){lRe(p);let x=_g.clone(this),y=0;if(i&&n)return e;s&&!n&&(y=e.encodingLength(p.length));for(let v of p)cRe(v,t,x);return _g.clean(x),y+=x.bytes,s&&n&&(y+=e.encodingLength(y)),y}}function lRe(t){if(!Array.isArray(t))throw new TypeError("Argument #1 should be an Array.")}function fRe(t){if(typeof t!="number")throw new TypeError("Length of an array should be a number.")}function dRe(t,e){if(t!==e)throw new Error(`Argument #1 required length ${t} instead of ${e}`)}function mkt(t,e,r,n){let i=[],s=n.bytes,a=0;for(;a<e;)i.push(hRe(r,t,n)),a=n.bytes-s;if(a>e)throw new Error("Incorrect length of an array.");return i}function gkt(t,e,r,n){let i=new Array(e);for(let s=0;s<e;s+=1)i[s]=hRe(r,t,n);return i}});var vRe=L((zir,yRe)=>{"use strict";var{isType:xkt,isFunction:ykt}=wh(),vkt=fS(),bkt=MD();yRe.exports=_kt;function _kt(t){let e=typeof t=="number",r=xkt(t),n=ykt(t),i=t===null;if(!e&&!r&&!n&&!i)throw new TypeError("Unknown type of argument #1.");return{encode:s,decode:a,encodingLength:c};function s(d,h){gRe(d),s.bytes=0;let p=this;if(e&&xRe(t,d.length),r&&(t.encode.call(p,d.length,h),s.bytes+=t.encode.bytes),n){let x=t(p);tse(x),xRe(x,d.length)}h.writeBuffer(Buffer.isBuffer(d)?d:d.buffer),s.bytes+=d.length,i&&(h.writeUInt8(0),s.bytes+=1)}function a(d){let h=0;a.bytes=0;let p=this;if(e)h=t;else if(r)h=t.decode.call(p,d),a.bytes+=t.decode.bytes,tse(h);else if(n)h=t(p),tse(h);else if(i&&(h=d.indexOf(0),h===-1))throw new vkt(d.length+1,d.length);let x=d.readBuffer(h);return a.bytes+=h,i&&(a.bytes+=1,d.consume(1)),x}function c(d){gRe(d);let h=0;return e?t:(i?h=1:r&&(h=t.encodingLength(d.length)),h+d.length)}}function gRe(t){if(!Buffer.isBuffer(t)&&!(t instanceof bkt))throw new TypeError("Argument 1 should be a Buffer or a BinaryStream.")}function xRe(t,e){if(t!==e)throw new Error(`Buffer required length ${t} instead of ${e}`)}function tse(t){if(typeof t!="number")throw new TypeError("Length of a buffer should be a number.")}});var _Re=L((Wir,bRe)=>{"use strict";var{isType:wkt}=wh();bRe.exports=Skt;function Skt(t){if(!wkt(t))throw new TypeError("Argument #1 should be valid type.");function e(n){let i=this,s=t.decode.call(i,n);return e.bytes=t.decode.bytes,!!s}function r(n,i){let s=this;t.encode.call(s,n?1:0,i),r.bytes=t.encode.bytes}return{encode:r,decode:e,encodingLength:t.encodingLength}}});var SRe=L((Hir,wRe)=>{"use strict";var{decodeCommon:Akt}=dS(),{encodeCommon:Ekt}=$D(),{encodingLengthCommon:Tkt}=jD(),{isType:Ckt,isFunction:lU}=wh(),kkt=vg(),wg=bg();wRe.exports=Dkt;function Dkt(t,e=1){if(!Ckt(t))throw new TypeError("Invalid data type.");if(!Number.isInteger(e)&&!lU(e))throw new TypeError("Argument #2 should be a valid integer or function.");return{[kkt.skip]:!0,encodingLength:r,decode:n,encode:i};function r(s){let a=wg.clone(this),c=lU(e)?e(a):e;return Tkt(s,t,a),wg.clean(a),a.bytes*c}function n(s){let a=wg.clone(this);n.bytes=0;let c=lU(e)?e(a):e;if(c===0){wg.clean(a);return}for(let d=c;d>0;d-=1)Akt(s,t,a);n.bytes=a.bytes,wg.clean(a)}function i(s,a){i.bytes=0;let c=wg.clone(this),d=lU(e)?e(c):e;if(d===0){wg.clean(c);return}for(let h=d;h>0;h-=1)Ekt(0,a,t,c);i.bytes=c.bytes,wg.clean(c)}}});var TRe=L((Vir,ERe)=>{"use strict";var{isType:Ikt}=wh(),Fkt=fS();ERe.exports=Pkt;function Pkt(t,e="ascii"){if(!Buffer.isEncoding(e))throw new Error("Argument #2 should be an encoding name.");if(typeof t=="number")return{encode:Nkt(t,e),decode:Bkt(t,e),encodingLength:()=>t};if(Ikt(t))return{encode:Ukt(t,e),decode:Mkt(t,e),encodingLength:Lkt(t,e)};if(t===null)return{encode:Rkt(e),decode:Okt(e),encodingLength(r){return Buffer.byteLength(r,e)+1}};if(typeof t=="function")return{encode:$kt(t,e),decode:jkt(t,e),encodingLength(r){return Buffer.byteLength(r,e)}};throw new TypeError("Unknown type of argument #1.")}function Rkt(t){return function e(r,n){let i=Buffer.from(r.toString(),t);n.writeBuffer(i),n.writeInt8(0),e.bytes=i.length+1}}function Okt(t){return function e(r){let n=r.indexOf(0);if(n===-1)throw new Fkt(r.length+1,r.length);let i=n+1,s=r.readBuffer(i);return e.bytes=i,s.toString(t,0,n)}}function Nkt(t,e){return function r(n,i){if(n=n.toString(),Buffer.byteLength(n,e)!==t)throw new Error(`Size of string should be ${t} in bytes.`);let s=Buffer.from(n,e);i.writeBuffer(s),r.bytes=s.length}}function Bkt(t,e){return function r(n){let i=n.readBuffer(t);return r.bytes=t,i.toString(e)}}function Ukt(t,e){return function r(n,i){n=n.toString();let s=this;t.encode.call(s,Buffer.byteLength(n,e),i),r.bytes=t.encode.bytes;let a=Buffer.from(n,e);i.writeBuffer(a),r.bytes+=a.length}}function Mkt(t,e){return function r(n){let i=t.decode.call(this,n);if(typeof i!="number")throw new TypeError("Size of a string should be a number.");let s=n.readBuffer(i);return r.bytes=t.decode.bytes+s.length,s.toString(e)}}function Lkt(t,e){return function(n){let i=Buffer.byteLength(n,e);return t.encodingLength(i)+i}}function $kt(t,e){return function r(n,i){r.bytes=0;let a=t(this),c=Buffer.from(n.toString(),e);ARe(a),qkt(a,c.length),i.writeBuffer(c),r.bytes+=c.length}}function jkt(t,e){return function r(n){let i=t(this);ARe(i);let s=n.readBuffer(i);return r.bytes=i,s.toString(e)}}function ARe(t){if(typeof t!="number")throw new TypeError("Length of a buffer should be a number.")}function qkt(t,e){if(t!==e)throw new Error(`Buffer required length ${t} instead of ${e}`)}});var kRe=L((Gir,CRe)=>{"use strict";var fU=UD();CRe.exports={doublebe:Pu(8,"writeDoubleBE","readDoubleBE"),doublele:Pu(8,"writeDoubleLE","readDoubleLE"),floatbe:Pu(4,"writeFloatBE","readFloatBE"),floatle:Pu(4,"writeFloatLE","readFloatLE"),int8:Pu(1,"writeInt8","readInt8"),uint8:Pu(1,"writeUInt8","readUInt8"),int16be:Pu(2,"writeInt16BE","readInt16BE"),uint16be:Pu(2,"writeUInt16BE","readUInt16BE"),int16le:Pu(2,"writeInt16LE","readInt16LE"),uint16le:Pu(2,"writeUInt16LE","readUInt16LE"),int32be:Pu(4,"writeInt32BE","readInt32BE"),uint32be:Pu(4,"writeUInt32BE","readUInt32BE"),int32le:Pu(4,"writeInt32LE","readInt32LE"),uint32le:Pu(4,"writeUInt32LE","readUInt32LE"),int24be:nf(3,"writeIntBE","readIntBE"),uint24be:nf(3,"writeUIntBE","readUIntBE"),int24le:nf(3,"writeIntLE","readIntLE"),uint24le:nf(3,"writeUIntLE","readUIntLE"),int40be:nf(5,"writeIntBE","readIntBE"),uint40be:nf(5,"writeUIntBE","readUIntBE"),int40le:nf(5,"writeIntLE","readIntLE"),uint40le:nf(5,"writeUIntLE","readUIntLE"),int48be:nf(6,"writeIntBE","readIntBE"),uint48be:nf(6,"writeUIntBE","readUIntBE"),int48le:nf(6,"writeIntLE","readIntLE"),uint48le:nf(6,"writeUIntLE","readUIntLE")};function Pu(t,e,r){let n=fU(),i=fU();return n(`
1074
1083
  function decode_${r}(rstream) {
1075
1084
  decode_${r}.bytes = ${n.formats.d(t)};
1076
1085
  return rstream.${r}()
@@ -1090,27 +1099,27 @@ ${e.join(`
1090
1099
  wstream.${e}(value, ${n.formats.d(t)});
1091
1100
  encode_${e}.bytes = ${n.formats.d(t)};
1092
1101
  }
1093
- `),{encodingLength:()=>t,encode:i.toFunction(),decode:n.toFunction()}}});var IRe=L((Kir,DRe)=>{"use strict";var{isType:zkt,isFunction:rse,isUserType:Wkt}=wh(),nse=vg(),{decodeCommon:Hkt}=dS(),{encodeCommon:Vkt}=$6(),{encodingLengthCommon:Gkt}=j6(),Sg=bg();DRe.exports=Kkt;function Kkt(t,e){if(!zkt(e)&&!Wkt(e))throw new TypeError("Argument #2 should be a valid type.");let r={encode:n,decode:i,encodingLength:s,[nse.skip]:!1};return r;function n(a,c){let d=Sg.clone(this);n.bytes=0;let h=rse(t)?!!t(d):!!t;if(r[nse.skip]=!h,!h){Sg.clean(d);return}Vkt(a,c,e,d),n.bytes=d.bytes,Sg.clean(d)}function i(a){let c=Sg.clone(this);i.bytes=0;let d=rse(t)?!!t(c):!!t;if(r[nse.skip]=!d,!d){Sg.clean(c);return}let h=Hkt(a,e,c);return i.bytes=c.bytes,Sg.clean(c),h}function s(a){let c=Sg.clone(this);return(rse(t)?t(c):t)&&Gkt(a,e,c),Sg.clean(c),c.bytes}}});var RRe=L((Zir,PRe)=>{"use strict";var dU=vg(),{decodeCommon:Zkt}=dS(),FRe=bg();PRe.exports=Xkt;function Xkt(...t){if(t.length===0)throw new TypeError("You should set at least one condition type.");let e={decode:r,encode:()=>{},[dU.skip]:!0};return e;function r(n){r.bytes=0;let i=FRe.clone(this);for(let s of t){let a=Zkt(n,s,i);if(s[dU.skip]!==!0)return r.bytes=i.bytes,FRe.clean(i),e[dU.skip]=!1,a}e[dU.skip]=!0}}});var URe=L((Xir,BRe)=>{"use strict";var NRe=U6(),Ykt=fS(),q6=class{constructor(e){this.stream=e,this.index=0}append(e){this.stream.append(e)}commit(){this.stream.consume(this.index)}get(e=0){return this.stream.get(this.index+e)}get length(){return this.stream.length}slice(e,r){return this.stream.slice(e,r)}toString(e,r,n){return this.stream.toString(e,r,n)}readBuffer(e){ise(this.index+e,this.length);let r=this.stream.slice(this.index,this.index+e);return this.index+=e,r}indexOf(e,r=0){return this.stream.indexOf(e,this.index+r)-this.index}},ORe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};Object.keys(ORe).forEach(t=>{let e=NRe(),r=ORe[t];e(`
1102
+ `),{encodingLength:()=>t,encode:i.toFunction(),decode:n.toFunction()}}});var IRe=L((Kir,DRe)=>{"use strict";var{isType:zkt,isFunction:rse,isUserType:Wkt}=wh(),nse=vg(),{decodeCommon:Hkt}=dS(),{encodeCommon:Vkt}=$D(),{encodingLengthCommon:Gkt}=jD(),Sg=bg();DRe.exports=Kkt;function Kkt(t,e){if(!zkt(e)&&!Wkt(e))throw new TypeError("Argument #2 should be a valid type.");let r={encode:n,decode:i,encodingLength:s,[nse.skip]:!1};return r;function n(a,c){let d=Sg.clone(this);n.bytes=0;let h=rse(t)?!!t(d):!!t;if(r[nse.skip]=!h,!h){Sg.clean(d);return}Vkt(a,c,e,d),n.bytes=d.bytes,Sg.clean(d)}function i(a){let c=Sg.clone(this);i.bytes=0;let d=rse(t)?!!t(c):!!t;if(r[nse.skip]=!d,!d){Sg.clean(c);return}let h=Hkt(a,e,c);return i.bytes=c.bytes,Sg.clean(c),h}function s(a){let c=Sg.clone(this);return(rse(t)?t(c):t)&&Gkt(a,e,c),Sg.clean(c),c.bytes}}});var RRe=L((Zir,PRe)=>{"use strict";var dU=vg(),{decodeCommon:Zkt}=dS(),FRe=bg();PRe.exports=Xkt;function Xkt(...t){if(t.length===0)throw new TypeError("You should set at least one condition type.");let e={decode:r,encode:()=>{},[dU.skip]:!0};return e;function r(n){r.bytes=0;let i=FRe.clone(this);for(let s of t){let a=Zkt(n,s,i);if(s[dU.skip]!==!0)return r.bytes=i.bytes,FRe.clean(i),e[dU.skip]=!1,a}e[dU.skip]=!0}}});var URe=L((Xir,BRe)=>{"use strict";var NRe=UD(),Ykt=fS(),qD=class{constructor(e){this.stream=e,this.index=0}append(e){this.stream.append(e)}commit(){this.stream.consume(this.index)}get(e=0){return this.stream.get(this.index+e)}get length(){return this.stream.length}slice(e,r){return this.stream.slice(e,r)}toString(e,r,n){return this.stream.toString(e,r,n)}readBuffer(e){ise(this.index+e,this.length);let r=this.stream.slice(this.index,this.index+e);return this.index+=e,r}indexOf(e,r=0){return this.stream.indexOf(e,this.index+r)-this.index}},ORe={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1};Object.keys(ORe).forEach(t=>{let e=NRe(),r=ORe[t];e(`
1094
1103
  function transaction_${t}() {
1095
1104
  assertSize(this.index + ${e.formats.d(r)}, this.length);
1096
1105
  const value = this.stream.buffer.${t}(this.index);
1097
1106
  this.index += ${e.formats.d(r)};
1098
1107
  return value;
1099
1108
  }
1100
- `),q6.prototype[t]=e.toFunction({assertSize:ise})});["readIntBE","readIntLE","readUIntBE","readUIntLE"].forEach(t=>{let e=NRe();e(`
1109
+ `),qD.prototype[t]=e.toFunction({assertSize:ise})});["readIntBE","readIntLE","readUIntBE","readUIntLE"].forEach(t=>{let e=NRe();e(`
1101
1110
  function transaction_${t}(bytes) {
1102
1111
  assertSize(this.index + bytes, this.length);
1103
1112
  const value = this.stream.buffer.${t}(bytes, this.index);
1104
1113
  this.index += bytes;
1105
1114
  return value;
1106
1115
  }
1107
- `),q6.prototype[t]=e.toFunction({assertSize:ise})});BRe.exports=q6;function ise(t,e){if(t>e)throw new Ykt(t,e)}});var Hs=L((Yir,HRe)=>{"use strict";var sse=M6(),Jkt=mRe(),Qkt=vRe(),e4t=_Re(),t4t=SRe(),r4t=TRe(),MRe=kRe(),n4t=IRe(),i4t=RRe(),{encode:jRe}=$6(),{decode:qRe}=dS(),{encodingLength:s4t}=j6(),a4t=URe(),zRe=fS(),WRe={array:Jkt,bool:e4t,buffer:Qkt,reserved:t4t,string:r4t,when:n4t,select:i4t};for(let t of Object.keys(MRe))WRe[t]=MRe[t];var hU=Symbol("schema");function LRe(t){let e=new sse({readableObjectMode:!1,writableObjectMode:!0,transform:o4t});return e[hU]=t,e}function $Re(t){let e=null,r=Buffer.isBuffer(t);r||(e=t);let n=new sse({transform:c4t,readableObjectMode:!0,writableObjectMode:!1});return n[hU]=e,r&&n.append(t),n}function o4t(t,e,r){try{jRe(t,this[hU],this);let n=this.slice();this.consume(n.length),r(null,n)}catch(n){r(n)}}function c4t(t,e,r){this.append(t);try{for(;this.length>0;){let n=new a4t(this),i=qRe(n,this[hU]);n.commit(),this.push(i)}r()}catch(n){n instanceof zRe?r():r(n)}}HRe.exports={createEncodeStream:LRe,createDecodeStream:$Re,encode:jRe,decode:qRe,encodingLength:s4t,createEncode:LRe,createDecode:$Re,types:WRe,BinaryStream:sse,NotEnoughDataError:zRe}});import*as rp from"node:crypto";var cv,VRe=ce(()=>{cv=rp&&typeof rp=="object"&&"webcrypto"in rp?rp.webcrypto:rp&&typeof rp=="object"&&"randomBytes"in rp?rp:void 0});function uv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function z6(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Jf(t,...e){if(!uv(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function pU(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");z6(t.outputLen),z6(t.blockLen)}function pS(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function KRe(t,e){Jf(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ip(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function mU(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Qf(t,e){return t<<32-e|t>>>e}function sp(t){if(Jf(t),ZRe)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=u4t[t[r]];return e}function GRe(t){if(t>=np._0&&t<=np._9)return t-np._0;if(t>=np.A&&t<=np.F)return t-(np.A-10);if(t>=np.a&&t<=np.f)return t-(np.a-10)}function lv(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ZRe)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=GRe(t.charCodeAt(s)),c=GRe(t.charCodeAt(s+1));if(a===void 0||c===void 0){let d=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+s)}n[i]=a*16+c}return n}function XRe(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function W6(t){return typeof t=="string"&&(t=XRe(t)),Jf(t),t}function ed(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Jf(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function gU(t){let e=n=>t().update(W6(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function xU(t=32){if(cv&&typeof cv.getRandomValues=="function")return cv.getRandomValues(new Uint8Array(t));if(cv&&typeof cv.randomBytes=="function")return Uint8Array.from(cv.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}var ZRe,u4t,np,hS,fv=ce(()=>{VRe();ZRe=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",u4t=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));np={_0:48,_9:57,A:65,F:70,a:97,f:102};hS=class{}});function H6(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ag(t,e,r=""){let n=uv(t),i=t?.length,s=e!==void 0;if(!n||s&&i!==e){let a=r&&`"${r}" `,c=s?` of length ${e}`:"",d=n?`length=${i}`:`type=${typeof t}`;throw new Error(a+"expected Uint8Array"+c+", got "+d)}return t}function V6(t){let e=t.toString(16);return e.length&1?"0"+e:e}function YRe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?cse:BigInt("0x"+t)}function mS(t){return YRe(sp(t))}function use(t){return Jf(t),YRe(sp(Uint8Array.from(t).reverse()))}function yU(t,e){return lv(t.toString(16).padStart(e*2,"0"))}function lse(t,e){return yU(t,e).reverse()}function yc(t,e,r){let n;if(typeof e=="string")try{n=lv(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(uv(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function JRe(t,e,r){return ase(t)&&ase(e)&&ase(r)&&e<=t&&t<r}function QRe(t,e,r,n){if(!JRe(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function vU(t){let e;for(e=0;t>cse;t>>=ose,e+=1);return e}function e9e(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),i=v=>Uint8Array.of(v),s=n(t),a=n(t),c=0,d=()=>{s.fill(1),a.fill(0),c=0},h=(...v)=>r(a,s,...v),p=(v=n(0))=>{a=h(i(0),v),s=h(),v.length!==0&&(a=h(i(1),v),s=h())},x=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let v=0,w=[];for(;v<e;){s=h();let S=s.slice();w.push(S),v+=s.length}return ed(...w)};return(v,w)=>{d(),p(v);let S;for(;!(S=w(x()));)p();return d(),S}}function G6(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,a){let c=t[i];if(a&&c===void 0)return;let d=typeof c;if(d!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${d}`)}Object.entries(e).forEach(([i,s])=>n(i,s,!1)),Object.entries(r).forEach(([i,s])=>n(i,s,!0))}function fse(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}var cse,ose,ase,Eg,bU=ce(()=>{fv();fv();cse=BigInt(0),ose=BigInt(1);ase=t=>typeof t=="bigint"&&cse<=t;Eg=t=>(ose<<BigInt(t))-ose});function td(t,e){let r=t%e;return r>=Ru?r:e+r}function t9e(t,e){if(t===Ru)throw new Error("invert: expected non-zero number");if(e<=Ru)throw new Error("invert: expected positive modulus, got "+e);let r=td(t,e),n=e,i=Ru,s=vc,a=vc,c=Ru;for(;r!==Ru;){let h=n/r,p=n%r,x=i-a*h,y=s-c*h;n=r,r=p,i=a,s=c,a=x,c=y}if(n!==vc)throw new Error("invert: does not exist");return td(i,e)}function dse(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function c9e(t,e){let r=(t.ORDER+vc)/i9e,n=t.pow(e,r);return dse(t,n,e),n}function d4t(t,e){let r=(t.ORDER-s9e)/a9e,n=t.mul(e,dv),i=t.pow(n,r),s=t.mul(e,i),a=t.mul(t.mul(s,dv),i),c=t.mul(s,t.sub(a,t.ONE));return dse(t,c,e),c}function h4t(t){let e=Sh(t),r=u9e(t),n=r(e,e.neg(e.ONE)),i=r(e,n),s=r(e,e.neg(n)),a=(t+l4t)/o9e;return(c,d)=>{let h=c.pow(d,a),p=c.mul(h,n),x=c.mul(h,i),y=c.mul(h,s),v=c.eql(c.sqr(p),d),w=c.eql(c.sqr(x),d);h=c.cmov(h,p,v),p=c.cmov(y,x,w);let S=c.eql(c.sqr(p),d),C=c.cmov(h,p,S);return dse(c,C,d),C}}function u9e(t){if(t<n9e)throw new Error("sqrt is not defined for small field");let e=t-vc,r=0;for(;e%dv===Ru;)e/=dv,r++;let n=dv,i=Sh(t);for(;r9e(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return c9e;let s=i.pow(n,e),a=(e+vc)/dv;return function(d,h){if(d.is0(h))return h;if(r9e(d,h)!==1)throw new Error("Cannot find square root");let p=r,x=d.mul(d.ONE,s),y=d.pow(h,e),v=d.pow(h,a);for(;!d.eql(y,d.ONE);){if(d.is0(y))return d.ZERO;let w=1,S=d.sqr(y);for(;!d.eql(S,d.ONE);)if(w++,S=d.sqr(S),w===p)throw new Error("Cannot find square root");let C=vc<<BigInt(p-w-1),k=d.pow(x,C);p=w,x=d.sqr(k),y=d.mul(y,x),v=d.mul(v,k)}return v}}function p4t(t){return t%i9e===n9e?c9e:t%a9e===s9e?d4t:t%o9e===f4t?h4t(t):u9e(t)}function hse(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=m4t.reduce((n,i)=>(n[i]="function",n),e);return G6(t,r),t}function g4t(t,e,r){if(r<Ru)throw new Error("invalid exponent, negatives unsupported");if(r===Ru)return t.ONE;if(r===vc)return e;let n=t.ONE,i=e;for(;r>Ru;)r&vc&&(n=t.mul(n,i)),i=t.sqr(i),r>>=vc;return n}function _U(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((a,c,d)=>t.is0(c)?a:(n[d]=a,t.mul(a,c)),t.ONE),s=t.inv(i);return e.reduceRight((a,c,d)=>t.is0(c)?a:(n[d]=t.mul(a,n[d]),t.mul(a,c)),s),n}function r9e(t,e){let r=(t.ORDER-vc)/dv,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),a=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function wU(t,e){e!==void 0&&z6(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Sh(t,e,r=!1,n={}){if(t<=Ru)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,s,a=!1,c;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let y=e;y.BITS&&(i=y.BITS),y.sqrt&&(s=y.sqrt),typeof y.isLE=="boolean"&&(r=y.isLE),typeof y.modFromBytes=="boolean"&&(a=y.modFromBytes),c=y.allowedLengths}else typeof e=="number"&&(i=e),n.sqrt&&(s=n.sqrt);let{nBitLength:d,nByteLength:h}=wU(t,i);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let p,x=Object.freeze({ORDER:t,isLE:r,BITS:d,BYTES:h,MASK:Eg(d),ZERO:Ru,ONE:vc,allowedLengths:c,create:y=>td(y,t),isValid:y=>{if(typeof y!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof y);return Ru<=y&&y<t},is0:y=>y===Ru,isValidNot0:y=>!x.is0(y)&&x.isValid(y),isOdd:y=>(y&vc)===vc,neg:y=>td(-y,t),eql:(y,v)=>y===v,sqr:y=>td(y*y,t),add:(y,v)=>td(y+v,t),sub:(y,v)=>td(y-v,t),mul:(y,v)=>td(y*v,t),pow:(y,v)=>g4t(x,y,v),div:(y,v)=>td(y*t9e(v,t),t),sqrN:y=>y*y,addN:(y,v)=>y+v,subN:(y,v)=>y-v,mulN:(y,v)=>y*v,inv:y=>t9e(y,t),sqrt:s||(y=>(p||(p=p4t(t)),p(x,y))),toBytes:y=>r?lse(y,h):yU(y,h),fromBytes:(y,v=!0)=>{if(c){if(!c.includes(y.length)||y.length>h)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+y.length);let S=new Uint8Array(h);S.set(y,r?0:S.length-y.length),y=S}if(y.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+y.length);let w=r?use(y):mS(y);if(a&&(w=td(w,t)),!v&&!x.isValid(w))throw new Error("invalid field element: outside of range 0..ORDER");return w},invertBatch:y=>_U(x,y),cmov:(y,v,w)=>w?v:y});return Object.freeze(x)}function l9e(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function pse(t){let e=l9e(t);return e+Math.ceil(e/2)}function f9e(t,e,r=!1){let n=t.length,i=l9e(e),s=pse(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let a=r?use(t):mS(t),c=td(a,e-vc)+vc;return r?lse(c,i):yU(c,i)}var Ru,vc,dv,n9e,i9e,s9e,l4t,a9e,f4t,o9e,m4t,SU=ce(()=>{bU();Ru=BigInt(0),vc=BigInt(1),dv=BigInt(2),n9e=BigInt(3),i9e=BigInt(4),s9e=BigInt(5),l4t=BigInt(7),a9e=BigInt(8),f4t=BigInt(9),o9e=BigInt(16);m4t=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function x4t(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),c=Number(r&s),d=n?4:0,h=n?0:4;t.setUint32(e+d,a,n),t.setUint32(e+h,c,n)}function d9e(t,e,r){return t&e^~t&r}function h9e(t,e,r){return t&e^t&r^e&r}var K6,ap,Uo,Mo,p9e=ce(()=>{fv();K6=class extends hS{constructor(e,r,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=mU(this.buffer)}update(e){pS(this),e=W6(e),Jf(e);let{view:r,buffer:n,blockLen:i}=this,s=e.length;for(let a=0;a<s;){let c=Math.min(i-this.pos,s-a);if(c===i){let d=mU(e);for(;i<=s-a;a+=i)this.process(d,a);continue}n.set(e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pS(this),KRe(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,ip(this.buffer.subarray(a)),this.padOffset>i-a&&(this.process(n,0),a=0);for(let x=a;x<i;x++)r[x]=0;x4t(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=mU(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=d/4,p=this.get();if(h>p.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x<h;x++)c.setUint32(4*x,p[x],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:c}=this;return e.destroyed=a,e.finished=s,e.length=i,e.pos=c,i%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ap=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Uo=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Mo=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function y4t(t,e=!1){return e?{h:Number(t&AU),l:Number(t>>m9e&AU)}:{h:Number(t>>m9e&AU)|0,l:Number(t&AU)|0}}function g9e(t,e=!1){let r=t.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){let{h:a,l:c}=y4t(t[s],e);[n[s],i[s]]=[a,c]}return[n,i]}function Ah(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var AU,m9e,mse,gse,hv,pv,Z6,X6,x9e,y9e,v9e,b9e,_9e,w9e,S9e=ce(()=>{AU=BigInt(4294967295),m9e=BigInt(32);mse=(t,e,r)=>t>>>r,gse=(t,e,r)=>t<<32-r|e>>>r,hv=(t,e,r)=>t>>>r|e<<32-r,pv=(t,e,r)=>t<<32-r|e>>>r,Z6=(t,e,r)=>t<<64-r|e>>>r-32,X6=(t,e,r)=>t>>>r-32|e<<64-r;x9e=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),y9e=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,v9e=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),b9e=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,_9e=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),w9e=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0});var b4t,Tg,xse,A9e,_4t,w4t,Cg,kg,EU,yse,E9e,T9e,C9e,k9e=ce(()=>{p9e();S9e();fv();b4t=Uint32Array.from([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]),Tg=new Uint32Array(64),xse=class extends K6{constructor(e=32){super(64,e,8,!1),this.A=ap[0]|0,this.B=ap[1]|0,this.C=ap[2]|0,this.D=ap[3]|0,this.E=ap[4]|0,this.F=ap[5]|0,this.G=ap[6]|0,this.H=ap[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:a,G:c,H:d}=this;return[e,r,n,i,s,a,c,d]}set(e,r,n,i,s,a,c,d){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=d|0}process(e,r){for(let x=0;x<16;x++,r+=4)Tg[x]=e.getUint32(r,!1);for(let x=16;x<64;x++){let y=Tg[x-15],v=Tg[x-2],w=Qf(y,7)^Qf(y,18)^y>>>3,S=Qf(v,17)^Qf(v,19)^v>>>10;Tg[x]=S+Tg[x-7]+w+Tg[x-16]|0}let{A:n,B:i,C:s,D:a,E:c,F:d,G:h,H:p}=this;for(let x=0;x<64;x++){let y=Qf(c,6)^Qf(c,11)^Qf(c,25),v=p+y+d9e(c,d,h)+b4t[x]+Tg[x]|0,S=(Qf(n,2)^Qf(n,13)^Qf(n,22))+h9e(n,i,s)|0;p=h,h=d,d=c,c=a+v|0,a=s,s=i,i=n,n=v+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,d=d+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(n,i,s,a,c,d,h,p)}roundClean(){ip(Tg)}destroy(){this.set(0,0,0,0,0,0,0,0),ip(this.buffer)}},A9e=g9e(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),_4t=A9e[0],w4t=A9e[1],Cg=new Uint32Array(80),kg=new Uint32Array(80),EU=class extends K6{constructor(e=64){super(128,e,16,!1),this.Ah=Mo[0]|0,this.Al=Mo[1]|0,this.Bh=Mo[2]|0,this.Bl=Mo[3]|0,this.Ch=Mo[4]|0,this.Cl=Mo[5]|0,this.Dh=Mo[6]|0,this.Dl=Mo[7]|0,this.Eh=Mo[8]|0,this.El=Mo[9]|0,this.Fh=Mo[10]|0,this.Fl=Mo[11]|0,this.Gh=Mo[12]|0,this.Gl=Mo[13]|0,this.Hh=Mo[14]|0,this.Hl=Mo[15]|0}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:d,Eh:h,El:p,Fh:x,Fl:y,Gh:v,Gl:w,Hh:S,Hl:C}=this;return[e,r,n,i,s,a,c,d,h,p,x,y,v,w,S,C]}set(e,r,n,i,s,a,c,d,h,p,x,y,v,w,S,C){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=c|0,this.Dl=d|0,this.Eh=h|0,this.El=p|0,this.Fh=x|0,this.Fl=y|0,this.Gh=v|0,this.Gl=w|0,this.Hh=S|0,this.Hl=C|0}process(e,r){for(let E=0;E<16;E++,r+=4)Cg[E]=e.getUint32(r),kg[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let I=Cg[E-15]|0,R=kg[E-15]|0,U=hv(I,R,1)^hv(I,R,8)^mse(I,R,7),B=pv(I,R,1)^pv(I,R,8)^gse(I,R,7),z=Cg[E-2]|0,K=kg[E-2]|0,Ae=hv(z,K,19)^Z6(z,K,61)^mse(z,K,6),de=pv(z,K,19)^X6(z,K,61)^gse(z,K,6),te=v9e(B,de,kg[E-7],kg[E-16]),Q=b9e(te,U,Ae,Cg[E-7],Cg[E-16]);Cg[E]=Q|0,kg[E]=te|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:c,Cl:d,Dh:h,Dl:p,Eh:x,El:y,Fh:v,Fl:w,Gh:S,Gl:C,Hh:k,Hl:T}=this;for(let E=0;E<80;E++){let I=hv(x,y,14)^hv(x,y,18)^Z6(x,y,41),R=pv(x,y,14)^pv(x,y,18)^X6(x,y,41),U=x&v^~x&S,B=y&w^~y&C,z=_9e(T,R,B,w4t[E],kg[E]),K=w9e(z,k,I,U,_4t[E],Cg[E]),Ae=z|0,de=hv(n,i,28)^Z6(n,i,34)^Z6(n,i,39),te=pv(n,i,28)^X6(n,i,34)^X6(n,i,39),Q=n&s^n&c^s&c,ee=i&a^i&d^a&d;k=S|0,T=C|0,S=v|0,C=w|0,v=x|0,w=y|0,{h:x,l:y}=Ah(h|0,p|0,K|0,Ae|0),h=c|0,p=d|0,c=s|0,d=a|0,s=n|0,a=i|0;let pe=x9e(Ae,te,ee);n=y9e(pe,K,de,Q),i=pe|0}({h:n,l:i}=Ah(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=Ah(this.Bh|0,this.Bl|0,s|0,a|0),{h:c,l:d}=Ah(this.Ch|0,this.Cl|0,c|0,d|0),{h,l:p}=Ah(this.Dh|0,this.Dl|0,h|0,p|0),{h:x,l:y}=Ah(this.Eh|0,this.El|0,x|0,y|0),{h:v,l:w}=Ah(this.Fh|0,this.Fl|0,v|0,w|0),{h:S,l:C}=Ah(this.Gh|0,this.Gl|0,S|0,C|0),{h:k,l:T}=Ah(this.Hh|0,this.Hl|0,k|0,T|0),this.set(n,i,s,a,c,d,h,p,x,y,v,w,S,C,k,T)}roundClean(){ip(Cg,kg)}destroy(){ip(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},yse=class extends EU{constructor(){super(48),this.Ah=Uo[0]|0,this.Al=Uo[1]|0,this.Bh=Uo[2]|0,this.Bl=Uo[3]|0,this.Ch=Uo[4]|0,this.Cl=Uo[5]|0,this.Dh=Uo[6]|0,this.Dl=Uo[7]|0,this.Eh=Uo[8]|0,this.El=Uo[9]|0,this.Fh=Uo[10]|0,this.Fl=Uo[11]|0,this.Gh=Uo[12]|0,this.Gl=Uo[13]|0,this.Hh=Uo[14]|0,this.Hl=Uo[15]|0}},E9e=gU(()=>new xse),T9e=gU(()=>new EU),C9e=gU(()=>new yse)});var TU,vse,D9e=ce(()=>{fv();TU=class extends hS{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,pU(e);let n=W6(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let a=0;a<s.length;a++)s[a]^=54;this.iHash.update(s),this.oHash=e.create();for(let a=0;a<s.length;a++)s[a]^=106;this.oHash.update(s),ip(s)}update(e){return pS(this),this.iHash.update(e),this}digestInto(e){pS(this),Jf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:s,blockLen:a,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=a,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vse=(t,e,r)=>new TU(t,e).update(r).digest();vse.create=(t,e)=>new TU(t,e)});function Y6(t,e){let r=e.negate();return t?r:e}function kU(t,e){let r=_U(t.Fp,e.map(n=>n.Z));return e.map((n,i)=>t.fromAffine(n.toAffine(r[i])))}function R9e(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function bse(t,e){R9e(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),i=2**t,s=Eg(t),a=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:i,shiftBy:a}}function I9e(t,e,r){let{windowSize:n,mask:i,maxNumber:s,shiftBy:a}=r,c=Number(t&i),d=t>>a;c>n&&(c-=s,d+=mv);let h=e*n,p=h+Math.abs(c)-1,x=c===0,y=c<0,v=e%2!==0;return{nextN:d,offset:p,isZero:x,isNeg:y,isNegF:v,offsetF:h}}function S4t(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function A4t(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}function wse(t){return O9e.get(t)||1}function F9e(t){if(t!==gS)throw new Error("invalid wNAF")}function N9e(t,e,r,n){let i=e,s=t.ZERO,a=t.ZERO;for(;r>gS||n>gS;)r&mv&&(s=s.add(i)),n&mv&&(a=a.add(i)),i=i.double(),r>>=mv,n>>=mv;return{p1:s,p2:a}}function B9e(t,e,r,n){S4t(r,t),A4t(n,e);let i=r.length,s=n.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");let a=t.ZERO,c=vU(BigInt(i)),d=1;c>12?d=c-3:c>4?d=c-2:c>0&&(d=2);let h=Eg(d),p=new Array(Number(h)+1).fill(a),x=Math.floor((e.BITS-1)/d)*d,y=a;for(let v=x;v>=0;v-=d){p.fill(a);for(let S=0;S<s;S++){let C=n[S],k=Number(C>>BigInt(v)&h);p[k]=p[k].add(r[S])}let w=a;for(let S=p.length-1,C=a;S>0;S--)C=C.add(p[S]),w=w.add(C);if(y=y.add(w),v!==0)for(let S=0;S<d;S++)y=y.double()}return y}function P9e(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return hse(e),e}else return Sh(t,{isLE:r})}function U9e(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let d of["p","n","h"]){let h=e[d];if(!(typeof h=="bigint"&&h>gS))throw new Error(`CURVE.${d} must be positive bigint`)}let i=P9e(e.p,r.Fp,n),s=P9e(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let d of c)if(!i.isValid(e[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:s}}var gS,mv,_se,O9e,CU,M9e=ce(()=>{bU();SU();gS=BigInt(0),mv=BigInt(1);_se=new WeakMap,O9e=new WeakMap;CU=class{constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let i=e;for(;r>gS;)r&mv&&(n=n.add(i)),i=i.double(),r>>=mv;return n}precomputeWindow(e,r){let{windows:n,windowSize:i}=bse(r,this.bits),s=[],a=e,c=a;for(let d=0;d<n;d++){c=a,s.push(c);for(let h=1;h<i;h++)c=c.add(a),s.push(c);a=c.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,s=this.BASE,a=bse(e,this.bits);for(let c=0;c<a.windows;c++){let{nextN:d,offset:h,isZero:p,isNeg:x,isNegF:y,offsetF:v}=I9e(n,c,a);n=d,p?s=s.add(Y6(y,r[v])):i=i.add(Y6(x,r[h]))}return F9e(n),{p:i,f:s}}wNAFUnsafe(e,r,n,i=this.ZERO){let s=bse(e,this.bits);for(let a=0;a<s.windows&&n!==gS;a++){let{nextN:c,offset:d,isZero:h,isNeg:p}=I9e(n,a,s);if(n=c,!h){let x=r[d];i=i.add(p?x.negate():x)}}return F9e(n),i}getPrecomputes(e,r,n){let i=_se.get(r);return i||(i=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(i=n(i)),_se.set(r,i))),i}cached(e,r,n){let i=wse(e);return this.wNAF(i,this.getPrecomputes(i,e,n),r)}unsafe(e,r,n,i){let s=wse(e);return s===1?this._unsafeLadder(e,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,i)}createCache(e,r){R9e(r,this.bits),O9e.set(e,r),_se.delete(e)}hasCache(e){return wse(e)!==1}}});function E4t(t,e,r){let[[n,i],[s,a]]=e,c=L9e(a*t,r),d=L9e(-i*t,r),h=t-c*n-d*s,p=-c*i-d*a,x=h<cp,y=p<cp;x&&(h=-h),y&&(p=-p);let v=Eg(Math.ceil(vU(r)/2))+yS;if(h<cp||h>=v||p<cp||p>=v)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:x,k1:h,k2neg:y,k2:p}}function Ase(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Sse(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return H6(r.lowS,"lowS"),H6(r.prehash,"prehash"),r.format!==void 0&&Ase(r.format),r}function xS(t,e){let{BYTES:r}=t,n;if(typeof e=="bigint")n=e;else{let i=yc("private key",e);try{n=t.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function C4t(t,e={}){let r=U9e("weierstrass",t,e),{Fp:n,Fn:i}=r,s=r.CURVE,{h:a,n:c}=s;G6(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:d}=e;if(d&&(!n.is0(s.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let h=q9e(n,i);function p(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function x(te,Q,ee){let{x:pe,y:H}=Q.toAffine(),oe=n.toBytes(pe);if(H6(ee,"isCompressed"),ee){p();let X=!n.isOdd(H);return ed(j9e(X),oe)}else return ed(Uint8Array.of(4),oe,n.toBytes(H))}function y(te){Ag(te,void 0,"Point");let{publicKey:Q,publicKeyUncompressed:ee}=h,pe=te.length,H=te[0],oe=te.subarray(1);if(pe===Q&&(H===2||H===3)){let X=n.fromBytes(oe);if(!n.isValid(X))throw new Error("bad point: is not on curve, wrong x");let N=S(X),Z;try{Z=n.sqrt(N)}catch(se){let Se=se instanceof Error?": "+se.message:"";throw new Error("bad point: is not on curve, sqrt error"+Se)}p();let ae=n.isOdd(Z);return(H&1)===1!==ae&&(Z=n.neg(Z)),{x:X,y:Z}}else if(pe===ee&&H===4){let X=n.BYTES,N=n.fromBytes(oe.subarray(0,X)),Z=n.fromBytes(oe.subarray(X,X*2));if(!C(N,Z))throw new Error("bad point: is not on curve");return{x:N,y:Z}}else throw new Error(`bad point: got length ${pe}, expected compressed=${Q} or uncompressed=${ee}`)}let v=e.toBytes||x,w=e.fromBytes||y;function S(te){let Q=n.sqr(te),ee=n.mul(Q,te);return n.add(n.add(ee,n.mul(te,s.a)),s.b)}function C(te,Q){let ee=n.sqr(Q),pe=S(te);return n.eql(ee,pe)}if(!C(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let k=n.mul(n.pow(s.a,DU),T4t),T=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(k,T)))throw new Error("bad curve params: a or b");function E(te,Q,ee=!1){if(!n.isValid(Q)||ee&&n.is0(Q))throw new Error(`bad point coordinate ${te}`);return Q}function I(te){if(!(te instanceof K))throw new Error("ProjectivePoint expected")}function R(te){if(!d||!d.basises)throw new Error("no endo");return E4t(te,d.basises,i.ORDER)}let U=fse((te,Q)=>{let{X:ee,Y:pe,Z:H}=te;if(n.eql(H,n.ONE))return{x:ee,y:pe};let oe=te.is0();Q==null&&(Q=oe?n.ONE:n.inv(H));let X=n.mul(ee,Q),N=n.mul(pe,Q),Z=n.mul(H,Q);if(oe)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:X,y:N}}),B=fse(te=>{if(te.is0()){if(e.allowInfinityPoint&&!n.is0(te.Y))return;throw new Error("bad point: ZERO")}let{x:Q,y:ee}=te.toAffine();if(!n.isValid(Q)||!n.isValid(ee))throw new Error("bad point: x or y not field elements");if(!C(Q,ee))throw new Error("bad point: equation left != right");if(!te.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function z(te,Q,ee,pe,H){return ee=new K(n.mul(ee.X,te),ee.Y,ee.Z),Q=Y6(pe,Q),ee=Y6(H,ee),Q.add(ee)}class K{constructor(Q,ee,pe){this.X=E("x",Q),this.Y=E("y",ee,!0),this.Z=E("z",pe),Object.freeze(this)}static CURVE(){return s}static fromAffine(Q){let{x:ee,y:pe}=Q||{};if(!Q||!n.isValid(ee)||!n.isValid(pe))throw new Error("invalid affine point");if(Q instanceof K)throw new Error("projective point not allowed");return n.is0(ee)&&n.is0(pe)?K.ZERO:new K(ee,pe,n.ONE)}static fromBytes(Q){let ee=K.fromAffine(w(Ag(Q,void 0,"point")));return ee.assertValidity(),ee}static fromHex(Q){return K.fromBytes(yc("pointHex",Q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Q=8,ee=!0){return de.createCache(this,Q),ee||this.multiply(DU),this}assertValidity(){B(this)}hasEvenY(){let{y:Q}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(Q)}equals(Q){I(Q);let{X:ee,Y:pe,Z:H}=this,{X:oe,Y:X,Z:N}=Q,Z=n.eql(n.mul(ee,N),n.mul(oe,H)),ae=n.eql(n.mul(pe,N),n.mul(X,H));return Z&&ae}negate(){return new K(this.X,n.neg(this.Y),this.Z)}double(){let{a:Q,b:ee}=s,pe=n.mul(ee,DU),{X:H,Y:oe,Z:X}=this,N=n.ZERO,Z=n.ZERO,ae=n.ZERO,J=n.mul(H,H),se=n.mul(oe,oe),Se=n.mul(X,X),fe=n.mul(H,oe);return fe=n.add(fe,fe),ae=n.mul(H,X),ae=n.add(ae,ae),N=n.mul(Q,ae),Z=n.mul(pe,Se),Z=n.add(N,Z),N=n.sub(se,Z),Z=n.add(se,Z),Z=n.mul(N,Z),N=n.mul(fe,N),ae=n.mul(pe,ae),Se=n.mul(Q,Se),fe=n.sub(J,Se),fe=n.mul(Q,fe),fe=n.add(fe,ae),ae=n.add(J,J),J=n.add(ae,J),J=n.add(J,Se),J=n.mul(J,fe),Z=n.add(Z,J),Se=n.mul(oe,X),Se=n.add(Se,Se),J=n.mul(Se,fe),N=n.sub(N,J),ae=n.mul(Se,se),ae=n.add(ae,ae),ae=n.add(ae,ae),new K(N,Z,ae)}add(Q){I(Q);let{X:ee,Y:pe,Z:H}=this,{X:oe,Y:X,Z:N}=Q,Z=n.ZERO,ae=n.ZERO,J=n.ZERO,se=s.a,Se=n.mul(s.b,DU),fe=n.mul(ee,oe),ze=n.mul(pe,X),Ue=n.mul(H,N),Ft=n.add(ee,pe),Ht=n.add(oe,X);Ft=n.mul(Ft,Ht),Ht=n.add(fe,ze),Ft=n.sub(Ft,Ht),Ht=n.add(ee,H);let Xe=n.add(oe,N);return Ht=n.mul(Ht,Xe),Xe=n.add(fe,Ue),Ht=n.sub(Ht,Xe),Xe=n.add(pe,H),Z=n.add(X,N),Xe=n.mul(Xe,Z),Z=n.add(ze,Ue),Xe=n.sub(Xe,Z),J=n.mul(se,Ht),Z=n.mul(Se,Ue),J=n.add(Z,J),Z=n.sub(ze,J),J=n.add(ze,J),ae=n.mul(Z,J),ze=n.add(fe,fe),ze=n.add(ze,fe),Ue=n.mul(se,Ue),Ht=n.mul(Se,Ht),ze=n.add(ze,Ue),Ue=n.sub(fe,Ue),Ue=n.mul(se,Ue),Ht=n.add(Ht,Ue),fe=n.mul(ze,Ht),ae=n.add(ae,fe),fe=n.mul(Xe,Ht),Z=n.mul(Ft,Z),Z=n.sub(Z,fe),fe=n.mul(Ft,ze),J=n.mul(Xe,J),J=n.add(J,fe),new K(Z,ae,J)}subtract(Q){return this.add(Q.negate())}is0(){return this.equals(K.ZERO)}multiply(Q){let{endo:ee}=e;if(!i.isValidNot0(Q))throw new Error("invalid scalar: out of range");let pe,H,oe=X=>de.cached(this,X,N=>kU(K,N));if(ee){let{k1neg:X,k1:N,k2neg:Z,k2:ae}=R(Q),{p:J,f:se}=oe(N),{p:Se,f:fe}=oe(ae);H=se.add(fe),pe=z(ee.beta,J,Se,X,Z)}else{let{p:X,f:N}=oe(Q);pe=X,H=N}return kU(K,[pe,H])[0]}multiplyUnsafe(Q){let{endo:ee}=e,pe=this;if(!i.isValid(Q))throw new Error("invalid scalar: out of range");if(Q===cp||pe.is0())return K.ZERO;if(Q===yS)return pe;if(de.hasCache(this))return this.multiply(Q);if(ee){let{k1neg:H,k1:oe,k2neg:X,k2:N}=R(Q),{p1:Z,p2:ae}=N9e(K,pe,oe,N);return z(ee.beta,Z,ae,H,X)}else return de.unsafe(pe,Q)}multiplyAndAddUnsafe(Q,ee,pe){let H=this.multiplyUnsafe(ee).add(Q.multiplyUnsafe(pe));return H.is0()?void 0:H}toAffine(Q){return U(this,Q)}isTorsionFree(){let{isTorsionFree:Q}=e;return a===yS?!0:Q?Q(K,this):de.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:Q}=e;return a===yS?this:Q?Q(K,this):this.multiplyUnsafe(a)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}toBytes(Q=!0){return H6(Q,"isCompressed"),this.assertValidity(),v(K,this,Q)}toHex(Q=!0){return sp(this.toBytes(Q))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Q=!0){return this.toBytes(Q)}_setWindowSize(Q){this.precompute(Q)}static normalizeZ(Q){return kU(K,Q)}static msm(Q,ee){return B9e(K,i,Q,ee)}static fromPrivateKey(Q){return K.BASE.multiply(xS(i,Q))}}K.BASE=new K(s.Gx,s.Gy,n.ONE),K.ZERO=new K(n.ZERO,n.ONE,n.ZERO),K.Fp=n,K.Fn=i;let Ae=i.BITS,de=new CU(K,e.endo?Math.ceil(Ae/2):Ae);return K.BASE.precompute(8),K}function j9e(t){return Uint8Array.of(t?2:3)}function q9e(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function k4t(t,e={}){let{Fn:r}=t,n=e.randomBytes||xU,i=Object.assign(q9e(t.Fp,r),{seed:pse(r.ORDER)});function s(v){try{return!!xS(r,v)}catch{return!1}}function a(v,w){let{publicKey:S,publicKeyUncompressed:C}=i;try{let k=v.length;return w===!0&&k!==S||w===!1&&k!==C?!1:!!t.fromBytes(v)}catch{return!1}}function c(v=n(i.seed)){return f9e(Ag(v,i.seed,"seed"),r.ORDER)}function d(v,w=!0){return t.BASE.multiply(xS(r,v)).toBytes(w)}function h(v){let w=c(v);return{secretKey:w,publicKey:d(w)}}function p(v){if(typeof v=="bigint")return!1;if(v instanceof t)return!0;let{secretKey:w,publicKey:S,publicKeyUncompressed:C}=i;if(r.allowedLengths||w===S)return;let k=yc("key",v).length;return k===S||k===C}function x(v,w,S=!0){if(p(v)===!0)throw new Error("first arg must be private key");if(p(w)===!1)throw new Error("second arg must be public key");let C=xS(r,v);return t.fromHex(w).multiply(C).toBytes(S)}return Object.freeze({getPublicKey:d,getSharedSecret:x,keygen:h,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:a,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:v=>xS(r,v),precompute(v=8,w=t.BASE){return w.precompute(v,!1)}},lengths:i})}function D4t(t,e,r={}){pU(e),G6(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||xU,i=r.hmac||((ee,...pe)=>vse(e,ee,ed(...pe))),{Fp:s,Fn:a}=t,{ORDER:c,BITS:d}=a,{keygen:h,getPublicKey:p,getSharedSecret:x,utils:y,lengths:v}=k4t(t,r),w={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},S="compact";function C(ee){let pe=c>>yS;return ee>pe}function k(ee,pe){if(!a.isValidNot0(pe))throw new Error(`invalid signature ${ee}: out of range 1..Point.Fn.ORDER`);return pe}function T(ee,pe){Ase(pe);let H=v.signature,oe=pe==="compact"?H:pe==="recovered"?H+1:void 0;return Ag(ee,oe,`${pe} signature`)}class E{constructor(pe,H,oe){this.r=k("r",pe),this.s=k("s",H),oe!=null&&(this.recovery=oe),Object.freeze(this)}static fromBytes(pe,H=S){T(pe,H);let oe;if(H==="der"){let{r:ae,s:J}=op.toSig(Ag(pe));return new E(ae,J)}H==="recovered"&&(oe=pe[0],H="compact",pe=pe.subarray(1));let X=a.BYTES,N=pe.subarray(0,X),Z=pe.subarray(X,X*2);return new E(a.fromBytes(N),a.fromBytes(Z),oe)}static fromHex(pe,H){return this.fromBytes(lv(pe),H)}addRecoveryBit(pe){return new E(this.r,this.s,pe)}recoverPublicKey(pe){let H=s.ORDER,{r:oe,s:X,recovery:N}=this;if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");if(c*$9e<H&&N>1)throw new Error("recovery id is ambiguous for h>1 curve");let ae=N===2||N===3?oe+c:oe;if(!s.isValid(ae))throw new Error("recovery id 2 or 3 invalid");let J=s.toBytes(ae),se=t.fromBytes(ed(j9e((N&1)===0),J)),Se=a.inv(ae),fe=R(yc("msgHash",pe)),ze=a.create(-fe*Se),Ue=a.create(X*Se),Ft=t.BASE.multiplyUnsafe(ze).add(se.multiplyUnsafe(Ue));if(Ft.is0())throw new Error("point at infinify");return Ft.assertValidity(),Ft}hasHighS(){return C(this.s)}toBytes(pe=S){if(Ase(pe),pe==="der")return lv(op.hexFromSig(this));let H=a.toBytes(this.r),oe=a.toBytes(this.s);if(pe==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return ed(Uint8Array.of(this.recovery),H,oe)}return ed(H,oe)}toHex(pe){return sp(this.toBytes(pe))}assertValidity(){}static fromCompact(pe){return E.fromBytes(yc("sig",pe),"compact")}static fromDER(pe){return E.fromBytes(yc("sig",pe),"der")}normalizeS(){return this.hasHighS()?new E(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return sp(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return sp(this.toBytes("compact"))}}let I=r.bits2int||function(pe){if(pe.length>8192)throw new Error("input is too large");let H=mS(pe),oe=pe.length*8-d;return oe>0?H>>BigInt(oe):H},R=r.bits2int_modN||function(pe){return a.create(I(pe))},U=Eg(d);function B(ee){return QRe("num < 2^"+d,ee,cp,U),a.toBytes(ee)}function z(ee,pe){return Ag(ee,void 0,"message"),pe?Ag(e(ee),void 0,"prehashed message"):ee}function K(ee,pe,H){if(["recovered","canonical"].some(ze=>ze in H))throw new Error("sign() legacy options not supported");let{lowS:oe,prehash:X,extraEntropy:N}=Sse(H,w);ee=z(ee,X);let Z=R(ee),ae=xS(a,pe),J=[B(ae),B(Z)];if(N!=null&&N!==!1){let ze=N===!0?n(v.secretKey):N;J.push(yc("extraEntropy",ze))}let se=ed(...J),Se=Z;function fe(ze){let Ue=I(ze);if(!a.isValidNot0(Ue))return;let Ft=a.inv(Ue),Ht=t.BASE.multiply(Ue).toAffine(),Xe=a.create(Ht.x);if(Xe===cp)return;let lr=a.create(Ft*a.create(Se+Xe*ae));if(lr===cp)return;let Ce=(Ht.x===Xe?0:2)|Number(Ht.y&yS),pt=lr;return oe&&C(lr)&&(pt=a.neg(lr),Ce^=1),new E(Xe,pt,Ce)}return{seed:se,k2sig:fe}}function Ae(ee,pe,H={}){ee=yc("message",ee);let{seed:oe,k2sig:X}=K(ee,pe,H);return e9e(e.outputLen,a.BYTES,i)(oe,X)}function de(ee){let pe,H=typeof ee=="string"||uv(ee),oe=!H&&ee!==null&&typeof ee=="object"&&typeof ee.r=="bigint"&&typeof ee.s=="bigint";if(!H&&!oe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(oe)pe=new E(ee.r,ee.s);else if(H){try{pe=E.fromBytes(yc("sig",ee),"der")}catch(X){if(!(X instanceof op.Err))throw X}if(!pe)try{pe=E.fromBytes(yc("sig",ee),"compact")}catch{return!1}}return pe||!1}function te(ee,pe,H,oe={}){let{lowS:X,prehash:N,format:Z}=Sse(oe,w);if(H=yc("publicKey",H),pe=z(yc("message",pe),N),"strict"in oe)throw new Error("options.strict was renamed to lowS");let ae=Z===void 0?de(ee):E.fromBytes(yc("sig",ee),Z);if(ae===!1)return!1;try{let J=t.fromBytes(H);if(X&&ae.hasHighS())return!1;let{r:se,s:Se}=ae,fe=R(pe),ze=a.inv(Se),Ue=a.create(fe*ze),Ft=a.create(se*ze),Ht=t.BASE.multiplyUnsafe(Ue).add(J.multiplyUnsafe(Ft));return Ht.is0()?!1:a.create(Ht.x)===se}catch{return!1}}function Q(ee,pe,H={}){let{prehash:oe}=Sse(H,w);return pe=z(pe,oe),E.fromBytes(ee,"recovered").recoverPublicKey(pe).toBytes()}return Object.freeze({keygen:h,getPublicKey:p,getSharedSecret:x,utils:y,lengths:v,Point:t,sign:Ae,verify:te,recoverPublicKey:Q,Signature:E,hash:e})}function I4t(t){let e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp,n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(a=>Math.ceil(a/2)))):void 0,i=Sh(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),s={Fp:r,Fn:i,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:s}}function F4t(t){let{CURVE:e,curveOpts:r}=I4t(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}function P4t(t,e){let r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,wU(r.Fn.ORDER,r.Fn.BITS))})}function z9e(t){let{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=F4t(t),s=C4t(e,r),a=D4t(s,n,i);return P4t(t,a)}var L9e,Ese,op,cp,yS,$9e,DU,T4t,W9e=ce(()=>{D9e();fv();bU();M9e();SU();L9e=(t,e)=>(t+(t>=0?e:-e)/$9e)/e;Ese=class extends Error{constructor(e=""){super(e)}},op={Err:Ese,_tlv:{encode:(t,e)=>{let{Err:r}=op;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=V6(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?V6(i.length/2|128):"";return V6(t)+s+i+e},decode(t,e){let{Err:r}=op,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),a=0;if(!s)a=i;else{let d=i&127;if(!d)throw new r("tlv.decode(long): indefinite length not supported");if(d>4)throw new r("tlv.decode(long): byte length is too big");let h=e.subarray(n,n+d);if(h.length!==d)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of h)a=a<<8|p;if(n+=d,a<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+a);if(c.length!==a)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+a)}}},_int:{encode(t){let{Err:e}=op;if(t<cp)throw new e("integer: negative integers are not allowed");let r=V6(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=op;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return mS(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=op,i=yc("signature",t),{v:s,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:d}=n.decode(2,s),{v:h,l:p}=n.decode(2,d);if(p.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(h)}},hexFromSig(t){let{_tlv:e,_int:r}=op,n=e.encode(2,r.encode(t.r)),i=e.encode(2,r.encode(t.s)),s=n+i;return e.encode(48,s)}},cp=BigInt(0),yS=BigInt(1),$9e=BigInt(2),DU=BigInt(3),T4t=BigInt(4)});function IU(t,e){let r=n=>z9e({...t,hash:n});return{...r(e),create:r}}var H9e=ce(()=>{W9e();});var V9e,G9e,K9e,R4t,O4t,N4t,Z9e,Isr,Fsr,X9e=ce(()=>{k9e();H9e();SU();V9e={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},G9e={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},K9e={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},R4t=Sh(V9e.p),O4t=Sh(G9e.p),N4t=Sh(K9e.p),Z9e=IU({...V9e,Fp:R4t,lowS:!1},E9e),Isr=IU({...G9e,Fp:O4t,lowS:!1},C9e),Fsr=IU({...K9e,Fp:N4t,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},T9e)});var FU,Y9e=ce(()=>{X9e();FU=Z9e});var Q9e=L(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0});Dg.LEB128=Dg.SignedLEB128=Dg.UnsignedLEB128=void 0;var vS;(function(t){t[t.LOWER_7=127]="LOWER_7",t[t.UPPER_1=128]="UPPER_1"})(vS||(vS={}));var J9e=t=>Number.isSafeInteger(t),gv=class{static decode(e,r=0){let n=this.$scanForNullBytes(e,r),i=0,s=0;for(let a=0;a<=n-r;a++){let c=e[r+a]&vS.LOWER_7;i|=c<<s,s+=7}return i}static encode(e){if(this.check(e),e<0)throw new Error(`An unsigned number must NOT be negative, ${e} is!`);let r=[],n=e;do{let i=n&vS.LOWER_7;n>>=7,n&&(i=i|vS.UPPER_1),r.push(i)}while(n);return Uint8Array.from(r)}static check(e){if(!J9e(e))throw new Error(`${e} is not a safe integer!`)}static $scanForNullBytes(e,r=0){let n=r,i=0;do{if(n>=e.byteLength)throw new Error("This is not a LEB128-encoded Uint8Array, no ending found!");i=e.slice(n,n+1)[0],n++}while(i&vS.UPPER_1);return n-1}static getLength(e,r=0){return this.$scanForNullBytes(e,r)-r}};Dg.UnsignedLEB128=gv;var J6=class{static $ceil7mul(e){let r=e;for(;r%7;)r++;return r}static check(e){if(!J9e(e))throw new Error(`${e} is not a safe integer!`)}static encode(e){if(this.check(e),e>=0)throw new Error(`A signed number must be negative, ${e} isn't!`);let r=Math.ceil(Math.log2(-e));return gv.encode((1<<this.$ceil7mul(r))+e)}static decode(e,r=0){let n=gv.decode(e,r);return-((1<<Math.ceil(Math.log2(n)))-n)}};Dg.SignedLEB128=J6;var Q6=class{};Dg.LEB128=Q6;Q6.encode=t=>(t>=0?gv:J6).encode(t);Q6.decode=(t,e=0,r=!1)=>(r?J6:gv).decode(t,e)});var tOe=L((Tse,eOe)=>{(function(t){"use strict";function e(N){return parseInt(N)===N}function r(N){if(!e(N.length))return!1;for(var Z=0;Z<N.length;Z++)if(!e(N[Z])||N[Z]<0||N[Z]>255)return!1;return!0}function n(N,Z){if(N.buffer&&N.name==="Uint8Array")return Z&&(N.slice?N=N.slice():N=Array.prototype.slice.call(N)),N;if(Array.isArray(N)){if(!r(N))throw new Error("Array contains invalid value: "+N);return new Uint8Array(N)}if(e(N.length)&&r(N))return new Uint8Array(N);throw new Error("unsupported array-like object")}function i(N){return new Uint8Array(N)}function s(N,Z,ae,J,se){(J!=null||se!=null)&&(N.slice?N=N.slice(J,se):N=Array.prototype.slice.call(N,J,se)),Z.set(N,ae)}var a=(function(){function N(ae){var J=[],se=0;for(ae=encodeURI(ae);se<ae.length;){var Se=ae.charCodeAt(se++);Se===37?(J.push(parseInt(ae.substr(se,2),16)),se+=2):J.push(Se)}return n(J)}function Z(ae){for(var J=[],se=0;se<ae.length;){var Se=ae[se];Se<128?(J.push(String.fromCharCode(Se)),se++):Se>191&&Se<224?(J.push(String.fromCharCode((Se&31)<<6|ae[se+1]&63)),se+=2):(J.push(String.fromCharCode((Se&15)<<12|(ae[se+1]&63)<<6|ae[se+2]&63)),se+=3)}return J.join("")}return{toBytes:N,fromBytes:Z}})(),c=(function(){function N(J){for(var se=[],Se=0;Se<J.length;Se+=2)se.push(parseInt(J.substr(Se,2),16));return se}var Z="0123456789abcdef";function ae(J){for(var se=[],Se=0;Se<J.length;Se++){var fe=J[Se];se.push(Z[(fe&240)>>4]+Z[fe&15])}return se.join("")}return{toBytes:N,fromBytes:ae}})(),d={16:10,24:12,32:14},h=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],p=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],x=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],y=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],v=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],w=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],S=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],C=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],k=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],T=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],I=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],R=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],U=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],B=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function z(N){for(var Z=[],ae=0;ae<N.length;ae+=4)Z.push(N[ae]<<24|N[ae+1]<<16|N[ae+2]<<8|N[ae+3]);return Z}var K=function(N){if(!(this instanceof K))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:n(N,!0)}),this._prepare()};K.prototype._prepare=function(){var N=d[this.key.length];if(N==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var Z=0;Z<=N;Z++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var ae=(N+1)*4,J=this.key.length/4,se=z(this.key),Se,Z=0;Z<J;Z++)Se=Z>>2,this._Ke[Se][Z%4]=se[Z],this._Kd[N-Se][Z%4]=se[Z];for(var fe=0,ze=J,Ue;ze<ae;){if(Ue=se[J-1],se[0]^=p[Ue>>16&255]<<24^p[Ue>>8&255]<<16^p[Ue&255]<<8^p[Ue>>24&255]^h[fe]<<24,fe+=1,J!=8)for(var Z=1;Z<J;Z++)se[Z]^=se[Z-1];else{for(var Z=1;Z<J/2;Z++)se[Z]^=se[Z-1];Ue=se[J/2-1],se[J/2]^=p[Ue&255]^p[Ue>>8&255]<<8^p[Ue>>16&255]<<16^p[Ue>>24&255]<<24;for(var Z=J/2+1;Z<J;Z++)se[Z]^=se[Z-1]}for(var Z=0,Ft,Ht;Z<J&&ze<ae;)Ft=ze>>2,Ht=ze%4,this._Ke[Ft][Ht]=se[Z],this._Kd[N-Ft][Ht]=se[Z++],ze++}for(var Ft=1;Ft<N;Ft++)for(var Ht=0;Ht<4;Ht++)Ue=this._Kd[Ft][Ht],this._Kd[Ft][Ht]=I[Ue>>24&255]^R[Ue>>16&255]^U[Ue>>8&255]^B[Ue&255]},K.prototype.encrypt=function(N){if(N.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var Z=this._Ke.length-1,ae=[0,0,0,0],J=z(N),se=0;se<4;se++)J[se]^=this._Ke[0][se];for(var Se=1;Se<Z;Se++){for(var se=0;se<4;se++)ae[se]=y[J[se]>>24&255]^v[J[(se+1)%4]>>16&255]^w[J[(se+2)%4]>>8&255]^S[J[(se+3)%4]&255]^this._Ke[Se][se];J=ae.slice()}for(var fe=i(16),ze,se=0;se<4;se++)ze=this._Ke[Z][se],fe[4*se]=(p[J[se]>>24&255]^ze>>24)&255,fe[4*se+1]=(p[J[(se+1)%4]>>16&255]^ze>>16)&255,fe[4*se+2]=(p[J[(se+2)%4]>>8&255]^ze>>8)&255,fe[4*se+3]=(p[J[(se+3)%4]&255]^ze)&255;return fe},K.prototype.decrypt=function(N){if(N.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var Z=this._Kd.length-1,ae=[0,0,0,0],J=z(N),se=0;se<4;se++)J[se]^=this._Kd[0][se];for(var Se=1;Se<Z;Se++){for(var se=0;se<4;se++)ae[se]=C[J[se]>>24&255]^k[J[(se+3)%4]>>16&255]^T[J[(se+2)%4]>>8&255]^E[J[(se+1)%4]&255]^this._Kd[Se][se];J=ae.slice()}for(var fe=i(16),ze,se=0;se<4;se++)ze=this._Kd[Z][se],fe[4*se]=(x[J[se]>>24&255]^ze>>24)&255,fe[4*se+1]=(x[J[(se+3)%4]>>16&255]^ze>>16)&255,fe[4*se+2]=(x[J[(se+2)%4]>>8&255]^ze>>8)&255,fe[4*se+3]=(x[J[(se+1)%4]&255]^ze)&255;return fe};var Ae=function(N){if(!(this instanceof Ae))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new K(N)};Ae.prototype.encrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16)s(N,ae,0,J,J+16),ae=this._aes.encrypt(ae),s(ae,Z,J);return Z},Ae.prototype.decrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16)s(N,ae,0,J,J+16),ae=this._aes.decrypt(ae),s(ae,Z,J);return Z};var de=function(N,Z){if(!(this instanceof de))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=n(Z,!0),this._aes=new K(N)};de.prototype.encrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16){s(N,ae,0,J,J+16);for(var se=0;se<16;se++)ae[se]^=this._lastCipherblock[se];this._lastCipherblock=this._aes.encrypt(ae),s(this._lastCipherblock,Z,J)}return Z},de.prototype.decrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16){s(N,ae,0,J,J+16),ae=this._aes.decrypt(ae);for(var se=0;se<16;se++)Z[J+se]=ae[se]^this._lastCipherblock[se];s(N,this._lastCipherblock,0,J,J+16)}return Z};var te=function(N,Z,ae){if(!(this instanceof te))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");ae||(ae=1),this.segmentSize=ae,this._shiftRegister=n(Z,!0),this._aes=new K(N)};te.prototype.encrypt=function(N){if(N.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var Z=n(N,!0),ae,J=0;J<Z.length;J+=this.segmentSize){ae=this._aes.encrypt(this._shiftRegister);for(var se=0;se<this.segmentSize;se++)Z[J+se]^=ae[se];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(Z,this._shiftRegister,16-this.segmentSize,J,J+this.segmentSize)}return Z},te.prototype.decrypt=function(N){if(N.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var Z=n(N,!0),ae,J=0;J<Z.length;J+=this.segmentSize){ae=this._aes.encrypt(this._shiftRegister);for(var se=0;se<this.segmentSize;se++)Z[J+se]^=ae[se];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(N,this._shiftRegister,16-this.segmentSize,J,J+this.segmentSize)}return Z};var Q=function(N,Z){if(!(this instanceof Q))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=n(Z,!0),this._lastPrecipherIndex=16,this._aes=new K(N)};Q.prototype.encrypt=function(N){for(var Z=n(N,!0),ae=0;ae<Z.length;ae++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),Z[ae]^=this._lastPrecipher[this._lastPrecipherIndex++];return Z},Q.prototype.decrypt=Q.prototype.encrypt;var ee=function(N){if(!(this instanceof ee))throw Error("Counter must be instanitated with `new`");N!==0&&!N&&(N=1),typeof N=="number"?(this._counter=i(16),this.setValue(N)):this.setBytes(N)};ee.prototype.setValue=function(N){if(typeof N!="number"||parseInt(N)!=N)throw new Error("invalid counter value (must be an integer)");if(N>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var Z=15;Z>=0;--Z)this._counter[Z]=N%256,N=parseInt(N/256)},ee.prototype.setBytes=function(N){if(N=n(N,!0),N.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=N},ee.prototype.increment=function(){for(var N=15;N>=0;N--)if(this._counter[N]===255)this._counter[N]=0;else{this._counter[N]++;break}};var pe=function(N,Z){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",Z instanceof ee||(Z=new ee(Z)),this._counter=Z,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new K(N)};pe.prototype.encrypt=function(N){for(var Z=n(N,!0),ae=0;ae<Z.length;ae++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),Z[ae]^=this._remainingCounter[this._remainingCounterIndex++];return Z},pe.prototype.decrypt=pe.prototype.encrypt;function H(N){N=n(N,!0);var Z=16-N.length%16,ae=i(N.length+Z);s(N,ae);for(var J=N.length;J<ae.length;J++)ae[J]=Z;return ae}function oe(N){if(N=n(N,!0),N.length<16)throw new Error("PKCS#7 invalid length");var Z=N[N.length-1];if(Z>16)throw new Error("PKCS#7 padding byte out of range");for(var ae=N.length-Z,J=0;J<Z;J++)if(N[ae+J]!==Z)throw new Error("PKCS#7 invalid padding byte");var se=i(ae);return s(N,se,0,0,ae),se}var X={AES:K,Counter:ee,ModeOfOperation:{ecb:Ae,cbc:de,cfb:te,ofb:Q,ctr:pe},utils:{hex:c,utf8:a},padding:{pkcs7:{pad:H,strip:oe}},_arrayTest:{coerceArray:n,createArray:i,copyArray:s}};typeof Tse<"u"?eOe.exports=X:typeof define=="function"&&define.amd?define([],function(){return X}):(t.aesjs&&(X._aesjs=t.aesjs),t.aesjs=X)})(Tse)});function iOe(t,e,r){var n=e?0:4,i=e?4:0,s=e?0:3,a=e?1:2,c=e?2:1,d=e?3:0,h=e?$4t:q4t,p=e?j4t:z4t,x=w.prototype,y="is"+t,v="_"+y;return x.buffer=void 0,x.offset=0,x[v]=!0,x.toNumber=T,x.toString=E,x.toJSON=T,x.toArray=M4t,wS&&(x.toBuffer=L4t),_S&&(x.toArrayBuffer=sOe),w[y]=S,w;function w(U,B,z,K){return this instanceof w?C(this,U,B,z,K):new w(U,B,z,K)}function S(U){return!!(U&&U[v])}function C(U,B,z,K,Ae){if(_S&&PU&&(B instanceof PU&&(B=new _S(B)),K instanceof PU&&(K=new _S(K))),!B&&!z&&!K&&!SS){U.buffer=aOe(rOe,0);return}if(!nOe(B,z)){var de=SS||Array;Ae=z,K=B,z=0,B=SS===wS?wS.alloc(8):new de(8)}U.buffer=B,U.offset=z|=0,RU!==typeof K&&(typeof K=="string"?k(B,z,K,Ae||10):nOe(K,Ae)?Cse(B,z,K,Ae):typeof Ae=="number"?(I(B,z+n,K),I(B,z+i,Ae)):K>0?h(B,z,K):K<0?p(B,z,K):Cse(B,z,rOe,0))}function k(U,B,z,K){var Ae=0,de=z.length,te=0,Q=0;z[0]==="-"&&Ae++;for(var ee=Ae;Ae<de;){var pe=parseInt(z[Ae++],K);if(!(pe>=0))break;Q=Q*K+pe,te=te*K+Math.floor(Q/bS),Q%=bS}ee&&(te=~te,Q?Q=bS-Q:te++),I(U,B+n,te),I(U,B+i,Q)}function T(){var U=this.buffer,B=this.offset,z=R(U,B+n),K=R(U,B+i);return r||(z|=0),z?z*bS+K:K}function E(U){var B=this.buffer,z=this.offset,K=R(B,z+n),Ae=R(B,z+i),de="",te=!r&&K&2147483648;for(te&&(K=~K,Ae=bS-Ae),U=U||10;;){var Q=K%U*bS+Ae;if(K=Math.floor(K/U),Ae=Math.floor(Q/U),de=(Q%U).toString(U)+de,!K&&!Ae)break}return te&&(de="-"+de),de}function I(U,B,z){U[B+d]=z&255,z=z>>8,U[B+c]=z&255,z=z>>8,U[B+a]=z&255,z=z>>8,U[B+s]=z&255}function R(U,B){return U[B+s]*U4t+(U[B+a]<<16)+(U[B+c]<<8)+U[B+d]}}function M4t(t){var e=this.buffer,r=this.offset;return SS=null,t!==!1&&B4t(e)?e.length===8?e:e.slice(r,r+8):aOe(e,r)}function L4t(t){var e=this.buffer,r=this.offset;return SS=wS,t!==!1&&wS.isBuffer(e)?e.length===8?e:e.slice(r,r+8):wS.from(sOe.call(this,t))}function sOe(t){var e=this.buffer,r=this.offset,n=e.buffer;if(SS=_S,t!==!1&&!e.offset&&n instanceof PU)return n.byteLength===8?n:n.slice(r,r+8);var i=new _S(8);return Cse(i,0,e,r),i.buffer}function nOe(t,e){var r=t&&t.length;return e|=0,r&&e+8<=r&&typeof t[e]!="string"}function Cse(t,e,r,n){e|=0,n|=0;for(var i=0;i<8;i++)t[e++]=r[n++]&255}function aOe(t,e){return Array.prototype.slice.call(t,e,e+8)}function $4t(t,e,r){for(var n=e+8;n>e;)t[--n]=r&255,r/=256}function j4t(t,e,r){var n=e+8;for(r++;n>e;)t[--n]=-r&255^255,r/=256}function q4t(t,e,r){for(var n=e+8;e<n;)t[e++]=r&255,r/=256}function z4t(t,e,r){var n=e+8;for(r++;e<n;)t[e++]=-r&255^255,r/=256}function W4t(t){return!!t&&Object.prototype.toString.call(t)=="[object Array]"}var RU,wS,_S,PU,rOe,B4t,bS,U4t,SS,OU,kse,NU=ce(()=>{RU="undefined",wS=RU!==typeof Buffer&&Buffer,_S=RU!==typeof Uint8Array&&Uint8Array,PU=RU!==typeof ArrayBuffer&&ArrayBuffer,rOe=[0,0,0,0,0,0,0,0],B4t=Array.isArray||W4t,bS=4294967296,U4t=16777216,OU=iOe("Uint64BE",!0,!0),kse=iOe("Int64BE",!0,!1)});var Ise=L(oOe=>{var Wr=oOe,{Buffer:BU}=Kr("buffer"),H4t=Kr("os");Wr.toBuffer=function(t,e,r){r=~~r;let n;if(this.isV4Format(t))n=e||BU.alloc(r+4),t.split(/\./g).map(i=>{n[r++]=parseInt(i,10)&255});else if(this.isV6Format(t)){let i=t.split(":",8),s;for(s=0;s<i.length;s++){let a=this.isV4Format(i[s]),c;a&&(c=this.toBuffer(i[s]),i[s]=c.slice(0,2).toString("hex")),c&&++s<8&&i.splice(s,0,c.slice(2,4).toString("hex"))}if(i[0]==="")for(;i.length<8;)i.unshift("0");else if(i[i.length-1]==="")for(;i.length<8;)i.push("0");else if(i.length<8){for(s=0;s<i.length&&i[s]!=="";s++);let a=[s,1];for(s=9-i.length;s>0;s--)a.push("0");i.splice(...a)}for(n=e||BU.alloc(r+16),s=0;s<i.length;s++){let a=parseInt(i[s],16);n[r++]=a>>8&255,n[r++]=a&255}}if(!n)throw Error(`Invalid ip address: ${t}`);return n};Wr.toString=function(t,e,r){e=~~e,r=r||t.length-e;let n=[];if(r===4){for(let i=0;i<r;i++)n.push(t[e+i]);n=n.join(".")}else if(r===16){for(let i=0;i<r;i+=2)n.push(t.readUInt16BE(e+i).toString(16));n=n.join(":"),n=n.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),n=n.replace(/:{3,4}/,"::")}return n};var V4t=/^(\d{1,3}\.){3,3}\d{1,3}$/,G4t=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;Wr.isV4Format=function(t){return V4t.test(t)};Wr.isV6Format=function(t){return G4t.test(t)};function eD(t){return t===4?"ipv4":t===6?"ipv6":t?t.toLowerCase():"ipv4"}Wr.fromPrefixLen=function(t,e){t>32?e="ipv6":e=eD(e);let r=4;e==="ipv6"&&(r=16);let n=BU.alloc(r);for(let i=0,s=n.length;i<s;++i){let a=8;t<8&&(a=t),t-=a,n[i]=~(255>>a)&255}return Wr.toString(n)};Wr.mask=function(t,e){t=Wr.toBuffer(t),e=Wr.toBuffer(e);let r=BU.alloc(Math.max(t.length,e.length)),n;if(t.length===e.length)for(n=0;n<t.length;n++)r[n]=t[n]&e[n];else if(e.length===4)for(n=0;n<e.length;n++)r[n]=t[t.length-4+n]&e[n];else{for(n=0;n<r.length-6;n++)r[n]=0;for(r[10]=255,r[11]=255,n=0;n<t.length;n++)r[n+12]=t[n]&e[n+12];n+=12}for(;n<r.length;n++)r[n]=0;return Wr.toString(r)};Wr.cidr=function(t){let e=t.split("/"),r=e[0];if(e.length!==2)throw new Error(`invalid CIDR subnet: ${r}`);let n=Wr.fromPrefixLen(parseInt(e[1],10));return Wr.mask(r,n)};Wr.subnet=function(t,e){let r=Wr.toLong(Wr.mask(t,e)),n=Wr.toBuffer(e),i=0;for(let a=0;a<n.length;a++)if(n[a]===255)i+=8;else{let c=n[a]&255;for(;c;)c=c<<1&255,i++}let s=2**(32-i);return{networkAddress:Wr.fromLong(r),firstAddress:s<=2?Wr.fromLong(r):Wr.fromLong(r+1),lastAddress:s<=2?Wr.fromLong(r+s-1):Wr.fromLong(r+s-2),broadcastAddress:Wr.fromLong(r+s-1),subnetMask:e,subnetMaskLength:i,numHosts:s<=2?s:s-2,length:s,contains(a){return r===Wr.toLong(Wr.mask(a,e))}}};Wr.cidrSubnet=function(t){let e=t.split("/"),r=e[0];if(e.length!==2)throw new Error(`invalid CIDR subnet: ${r}`);let n=Wr.fromPrefixLen(parseInt(e[1],10));return Wr.subnet(r,n)};Wr.not=function(t){let e=Wr.toBuffer(t);for(let r=0;r<e.length;r++)e[r]=255^e[r];return Wr.toString(e)};Wr.or=function(t,e){if(t=Wr.toBuffer(t),e=Wr.toBuffer(e),t.length===e.length){for(let s=0;s<t.length;++s)t[s]|=e[s];return Wr.toString(t)}let r=t,n=e;e.length>t.length&&(r=e,n=t);let i=r.length-n.length;for(let s=i;s<r.length;++s)r[s]|=n[s-i];return Wr.toString(r)};Wr.isEqual=function(t,e){if(t=Wr.toBuffer(t),e=Wr.toBuffer(e),t.length===e.length){for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}if(e.length===4){let n=e;e=t,t=n}for(let n=0;n<10;n++)if(e[n]!==0)return!1;let r=e.readUInt16BE(10);if(r!==0&&r!==65535)return!1;for(let n=0;n<4;n++)if(t[n]!==e[n+12])return!1;return!0};Wr.isPrivate=function(t){if(Wr.isLoopback(t))return!0;if(!Wr.isV6Format(t)){let e=Wr.normalizeToLong(t);if(e<0)throw new Error("invalid ipv4 address");t=Wr.fromLong(e)}return/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||/^fe80:/i.test(t)||/^::1$/.test(t)||/^::$/.test(t)};Wr.isPublic=function(t){return!Wr.isPrivate(t)};Wr.isLoopback=function(t){return!/\./.test(t)&&!/:/.test(t)&&(t=Wr.fromLong(Number(t))),/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(t)||/^0177\./.test(t)||/^0x7f\./i.test(t)||/^fe80::1$/i.test(t)||/^::1$/.test(t)||/^::$/.test(t)};Wr.loopback=function(t){if(t=eD(t),t!=="ipv4"&&t!=="ipv6")throw new Error("family must be ipv4 or ipv6");return t==="ipv4"?"127.0.0.1":"fe80::1"};Wr.address=function(t,e){let r=H4t.networkInterfaces();if(e=eD(e),t&&t!=="private"&&t!=="public"){let i=r[t].filter(s=>eD(s.family)===e);return i.length===0?void 0:i[0].address}let n=Object.keys(r).map(i=>{let s=r[i].filter(a=>(a.family=eD(a.family),a.family!==e||Wr.isLoopback(a.address)?!1:t?t==="public"?Wr.isPrivate(a.address):Wr.isPublic(a.address):!0));return s.length?s[0].address:void 0}).filter(Boolean);return n.length?n[0]:Wr.loopback(e)};Wr.toLong=function(t){let e=0;return t.split(".").forEach(r=>{e<<=8,e+=parseInt(r)}),e>>>0};Wr.fromLong=function(t){return`${t>>>24}.${t>>16&255}.${t>>8&255}.${t&255}`};Wr.normalizeToLong=function(t){let e=t.split(".").map(i=>i.startsWith("0x")||i.startsWith("0X")?parseInt(i,16):i.startsWith("0")&&i!=="0"&&/^[0-7]+$/.test(i)?parseInt(i,8):/^[1-9]\d*$/.test(i)||i==="0"?parseInt(i,10):NaN);if(e.some(isNaN))return-1;let r=0;switch(e.length){case 1:r=e[0];break;case 2:if(e[0]>255||e[1]>16777215)return-1;r=e[0]<<24|e[1]&16777215;break;case 3:if(e[0]>255||e[1]>255||e[2]>65535)return-1;r=e[0]<<24|e[1]<<16|e[2]&65535;break;case 4:if(e.some(i=>i>255))return-1;r=e[0]<<24|e[1]<<16|e[2]<<8|e[3];break;default:return-1}return r>>>0}});var cOe=L(Fse=>{"use strict";Fse.toString=function(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t};Fse.toType=function(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var uOe=L(Pse=>{"use strict";Pse.toString=function(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t};Pse.toRcode=function(t){switch(t.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var lOe=L(Rse=>{"use strict";Rse.toString=function(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t};Rse.toOpcode=function(t){switch(t.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var fOe=L(Ose=>{"use strict";Ose.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Ose.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var dOe=L(Nse=>{"use strict";Nse.toString=function(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`};Nse.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var mOe=L((pOe,Bse)=>{var hOe=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=x,t.encode=p,t.familyOf=h,t.name=void 0,t.sizeOf=d,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,s={name:"v4",size:r,isFormat:y=>e.test(y),encode(y,v,w){w=~~w,v=v||new Uint8Array(w+r);let S=y.length,C=0;for(let k=0;k<S;){let T=y.charCodeAt(k++);T===46?(v[w++]=C,C=0):C=C*10+(T-48)}return v[w]=C,v},decode(y,v){return v=~~v,`${y[v++]}.${y[v++]}.${y[v++]}.${y[v]}`}};t.v4=s;let a={name:"v6",size:i,isFormat:y=>y.length>0&&n.test(y),encode(y,v,w){w=~~w;let S=w+i,C=-1,k=0,T=0,E=!0,I=!1;v=v||new Uint8Array(w+i);for(let R=0;R<y.length;R++){let U=y.charCodeAt(R);U===58?(E?C!==-1?(w<S&&(v[w]=0),w<S-1&&(v[w+1]=0),w+=2):w<S&&(C=w):(I===!0?(w<S&&(v[w]=T),w++):(w<S&&(v[w]=k>>8),w<S-1&&(v[w+1]=k&255),w+=2),k=0,T=0),E=!0,I=!1):U===46?(w<S&&(v[w]=T),w++,T=0,k=0,E=!1,I=!0):(E=!1,U>=97?U-=87:U>=65?U-=55:(U-=48,T=T*10+U),k=(k<<4)+U)}if(E===!1)I===!0?(w<S&&(v[w]=T),w++):(w<S&&(v[w]=k>>8),w<S-1&&(v[w+1]=k&255),w+=2);else if(C===0)w<S&&(v[w]=0),w<S-1&&(v[w+1]=0),w+=2;else if(C!==-1){w+=2;for(let R=Math.min(w-1,S-1);R>=C+2;R--)v[R]=v[R-2];v[C]=0,v[C+1]=0,C=w}if(C!==w&&C!==-1)for(w>S-2&&(w=S-2);S>C;)v[--S]=w<S&&w>C?v[--w]:0;else for(;w<S;)v[w++]=0;return v},decode(y,v){v=~~v;let w="";for(let S=0;S<i;S+=2)S!==0&&(w+=":"),w+=(y[v+S]<<8|y[v+S+1]).toString(16);return w.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=a;let c="ip";t.name=c;function d(y){if(s.isFormat(y))return s.size;if(a.isFormat(y))return a.size;throw Error(`Invalid ip address: ${y}`)}function h(y){return d(y)===s.size?1:2}function p(y,v,w){w=~~w;let S=d(y);return typeof v=="function"&&(v=v(w+S)),S===s.size?s.encode(y,v,w):a.encode(y,v,w)}function x(y,v,w){if(v=~~v,w=w||y.length-v,w===s.size)return s.decode(y,v,w);if(w===a.size)return a.decode(y,v,w);throw Error(`Invalid buffer size needs to be ${s.size} for v4 or ${a.size} for v6.`)}return"default"in t?t.default:t})({});typeof define=="function"&&define.amd?define([],function(){return hOe}):typeof Bse=="object"&&typeof pOe=="object"&&(Bse.exports=hOe)});var yOe=L(Hr=>{"use strict";var Vr=Kr("buffer").Buffer,yp=cOe(),K4t=uOe(),Z4t=lOe(),MU=fOe(),Use=dOe(),xv=mOe(),X4t=0,gOe=32768,Mse=32768,Y4t=~Mse,xOe=32768,J4t=~xOe,or=Hr.name={};or.encode=function(t,e,r,{mail:n=!1}={}){e||(e=Vr.alloc(or.encodingLength(t))),r||(r=0);let i=r,s=t.replace(/^\.|\.$/gm,"");if(s.length){let a=[];if(n){let c="";s.split(".").forEach(d=>{d.endsWith("\\")?c+=(c.length?".":"")+d.slice(0,-1):a.length===0&&c.length?a.push(c+"."+d):a.push(d)})}else a=s.split(".");for(let c=0;c<a.length;c++){let d=e.write(a[c],r+1);e[r]=d,r+=d+1}}return e[r++]=0,or.encode.bytes=r-i,e};or.encode.bytes=0;or.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],i=e,s=0,a=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let d=t[e++];if(a+=c?0:1,d===0)break;if((d&192)===0){if(e+d>t.length)throw new Error("Cannot decode name (buffer overflow)");if(s+=d+1,s>254)throw new Error("Cannot decode name (name too long)");let h=t.toString("utf-8",e,e+d);r&&(h=h.replace(/\./g,"\\.")),n.push(h),e+=d,a+=c?0:d}else if((d&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let h=t.readUInt16BE(e-1)-49152;if(h>=i)throw new Error("Cannot decode name (bad pointer)");e=h,i=h,a+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return or.decode.bytes=a,n.length===0?".":n.join(".")};or.decode.bytes=0;or.encodingLength=function(t){return t==="."||t===".."?1:Vr.byteLength(t.replace(/^\.|\.$/gm,""))+2};var Nn={};Nn.encode=function(t,e,r){e||(e=Vr.alloc(Nn.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,Nn.encode.bytes=n+1,e};Nn.encode.bytes=0;Nn.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return Nn.decode.bytes=r+1,n};Nn.decode.bytes=0;Nn.encodingLength=function(t){return Vr.byteLength(t)+1};var id={};id.encode=function(t,e,r){e||(e=id.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?gOe:X4t;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|i,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};id.encode.bytes=12;id.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&gOe?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Z4t.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:K4t.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};id.decode.bytes=12;id.encodingLength=function(){return 12};var up=Hr.unknown={};up.encode=function(t,e,r){return e||(e=Vr.alloc(up.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),up.encode.bytes=t.length+2,e};up.encode.bytes=0;up.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return up.decode.bytes=r+2,n};up.decode.bytes=0;up.encodingLength=function(t){return t.length+2};var lp=Hr.ns={};lp.encode=function(t,e,r){return e||(e=Vr.alloc(lp.encodingLength(t))),r||(r=0),or.encode(t,e,r+2),e.writeUInt16BE(or.encode.bytes,r),lp.encode.bytes=or.encode.bytes+2,e};lp.encode.bytes=0;lp.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=or.decode(t,e+2);return lp.decode.bytes=r+2,n};lp.decode.bytes=0;lp.encodingLength=function(t){return or.encodingLength(t)+2};var fp=Hr.soa={};fp.encode=function(t,e,r){e||(e=Vr.alloc(fp.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.mname,e,r),r+=or.encode.bytes,or.encode(t.rname,e,r,{mail:!0}),r+=or.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),fp.encode.bytes=r-n,e};fp.encode.bytes=0;fp.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=or.decode(t,e),e+=or.decode.bytes,n.rname=or.decode(t,e,{mail:!0}),e+=or.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,fp.decode.bytes=e-r,n};fp.decode.bytes=0;fp.encodingLength=function(t){return 22+or.encodingLength(t.mname)+or.encodingLength(t.rname)};var dp=Hr.txt={};dp.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i<t.length;i++)if(typeof t[i]=="string"&&(t[i]=Vr.from(t[i])),!Vr.isBuffer(t[i]))throw new Error("Must be a Buffer");e||(e=Vr.alloc(dp.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(i){e[r++]=i.length,i.copy(e,r,0,i.length),r+=i.length}),e.writeUInt16BE(r-n-2,n),dp.encode.bytes=r-n,e};dp.encode.bytes=0;dp.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let s=t[e++];if(--n,n<s)throw new Error("Buffer overflow");i.push(t.slice(e,e+s)),e+=s,n-=s}return dp.decode.bytes=e-r,i};dp.decode.bytes=0;dp.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=Vr.byteLength(r)+1:e+=r.length+1}),e};var hp=Hr.null={};hp.encode=function(t,e,r){e||(e=Vr.alloc(hp.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=Vr.from(t)),t||(t=Vr.alloc(0));let n=r;r+=2;let i=t.length;return t.copy(e,r,0,i),r+=i,e.writeUInt16BE(r-n-2,n),hp.encode.bytes=r-n,e};hp.encode.bytes=0;hp.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=t.slice(e,e+n);return e+=n,hp.decode.bytes=e-r,i};hp.decode.bytes=0;hp.encodingLength=function(t){return t?(Vr.isBuffer(t)?t.length:Vr.byteLength(t))+2:2};var pp=Hr.hinfo={};pp.encode=function(t,e,r){e||(e=Vr.alloc(pp.encodingLength(t))),r||(r=0);let n=r;return r+=2,Nn.encode(t.cpu,e,r),r+=Nn.encode.bytes,Nn.encode(t.os,e,r),r+=Nn.encode.bytes,e.writeUInt16BE(r-n-2,n),pp.encode.bytes=r-n,e};pp.encode.bytes=0;pp.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=Nn.decode(t,e),e+=Nn.decode.bytes,n.os=Nn.decode(t,e),e+=Nn.decode.bytes,pp.decode.bytes=e-r,n};pp.decode.bytes=0;pp.encodingLength=function(t){return Nn.encodingLength(t.cpu)+Nn.encodingLength(t.os)+2};var rd=Hr.ptr={},Q4t=Hr.cname=rd,e3t=Hr.dname=rd;rd.encode=function(t,e,r){return e||(e=Vr.alloc(rd.encodingLength(t))),r||(r=0),or.encode(t,e,r+2),e.writeUInt16BE(or.encode.bytes,r),rd.encode.bytes=or.encode.bytes+2,e};rd.encode.bytes=0;rd.decode=function(t,e){e||(e=0);let r=or.decode(t,e+2);return rd.decode.bytes=or.decode.bytes+2,r};rd.decode.bytes=0;rd.encodingLength=function(t){return or.encodingLength(t)+2};var mp=Hr.srv={};mp.encode=function(t,e,r){e||(e=Vr.alloc(mp.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),or.encode(t.target,e,r+8);let n=or.encode.bytes+6;return e.writeUInt16BE(n,r),mp.encode.bytes=n+2,e};mp.encode.bytes=0;mp.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=or.decode(t,e+8),mp.decode.bytes=r+2,n};mp.decode.bytes=0;mp.encodingLength=function(t){return 8+or.encodingLength(t.target)};var ll=Hr.caa={};ll.ISSUER_CRITICAL=128;ll.encode=function(t,e,r){let n=ll.encodingLength(t);return e||(e=Vr.alloc(ll.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=ll.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,Nn.encode(t.tag,e,r),r+=Nn.encode.bytes,e.write(t.value,r),r+=Vr.byteLength(t.value),ll.encode.bytes=n,e};ll.encode.bytes=0;ll.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=t.readUInt8(e),e+=1,i.tag=Nn.decode(t,e),e+=Nn.decode.bytes,i.value=t.toString("utf-8",e,n+r),i.issuerCritical=!!(i.flags&ll.ISSUER_CRITICAL),ll.decode.bytes=r+2,i};ll.decode.bytes=0;ll.encodingLength=function(t){return Nn.encodingLength(t.tag)+Nn.encodingLength(t.value)+2};var Ig=Hr.mx={};Ig.encode=function(t,e,r){e||(e=Vr.alloc(Ig.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,or.encode(t.exchange,e,r),r+=or.encode.bytes,e.writeUInt16BE(r-n-2,n),Ig.encode.bytes=r-n,e};Ig.encode.bytes=0;Ig.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=or.decode(t,e),e+=or.decode.bytes,Ig.decode.bytes=e-r,n};Ig.encodingLength=function(t){return 4+or.encodingLength(t.exchange)};var gp=Hr.a={};gp.encode=function(t,e,r){return e||(e=Vr.alloc(gp.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xv.v4.encode(t,e,r),gp.encode.bytes=6,e};gp.encode.bytes=0;gp.decode=function(t,e){e||(e=0),e+=2;let r=xv.v4.decode(t,e);return gp.decode.bytes=6,r};gp.decode.bytes=0;gp.encodingLength=function(){return 6};var xp=Hr.aaaa={};xp.encode=function(t,e,r){return e||(e=Vr.alloc(xp.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xv.v6.encode(t,e,r),xp.encode.bytes=18,e};xp.encode.bytes=0;xp.decode=function(t,e){e||(e=0),e+=2;let r=xv.v6.decode(t,e);return xp.decode.bytes=18,r};xp.decode.bytes=0;xp.encodingLength=function(){return 18};var Ou=Hr.option={};Ou.encode=function(t,e,r){e||(e=Vr.alloc(Ou.encodingLength(t))),r||(r=0);let n=r,i=Use.toCode(t.code);if(e.writeUInt16BE(i,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(i){case 8:let s=t.sourcePrefixLength||0,a=t.family||xv.familyOf(t.ip),c=xv.encode(t.ip,Vr.alloc),d=Math.ceil(s/8);e.writeUInt16BE(d+4,r),r+=2,e.writeUInt16BE(a,r),r+=2,e.writeUInt8(s,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,d),r+=d;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let h=t.length||0;e.writeUInt16BE(h,r),r+=2,e.fill(0,r,r+h),r+=h;break;case 14:let p=t.tags.length*2;e.writeUInt16BE(p,r),r+=2;for(let x of t.tags)e.writeUInt16BE(x,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return Ou.encode.bytes=r-n,e};Ou.encode.bytes=0;Ou.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Use.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let i=Vr.alloc(r.family===1?4:16);t.copy(i,0,e,e+n-4),r.ip=xv.decode(i);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let s=0;s<n;s+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return Ou.decode.bytes=n+4,r};Ou.decode.bytes=0;Ou.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Use.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var dl=Hr.opt={};dl.encode=function(t,e,r){e||(e=Vr.alloc(dl.encodingLength(t))),r||(r=0);let n=r,i=AS(t,Ou);return e.writeUInt16BE(i,r),r=tD(t,Ou,e,r+2),dl.encode.bytes=r-n,e};dl.encode.bytes=0;dl.decode=function(t,e){e||(e=0);let r=e,n=[],i=t.readUInt16BE(e);e+=2;let s=0;for(;i>0;)n[s++]=Ou.decode(t,e),e+=Ou.decode.bytes,i-=Ou.decode.bytes;return dl.decode.bytes=e-r,n};dl.decode.bytes=0;dl.encodingLength=function(t){return 2+AS(t||[],Ou)};var jc=Hr.dnskey={};jc.PROTOCOL_DNSSEC=3;jc.ZONE_KEY=128;jc.SECURE_ENTRYPOINT=32768;jc.encode=function(t,e,r){e||(e=Vr.alloc(jc.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Vr.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(jc.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,jc.encode.bytes=r-n,e.writeUInt16BE(jc.encode.bytes-2,n),e};jc.encode.bytes=0;jc.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==jc.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,jc.decode.bytes=e-r,n};jc.decode.bytes=0;jc.encodingLength=function(t){return 6+Vr.byteLength(t.key)};var Eh=Hr.rrsig={};Eh.encode=function(t,e,r){e||(e=Vr.alloc(Eh.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Vr.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(yp.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,or.encode(t.signersName,e,r),r+=or.encode.bytes,i.copy(e,r,0,i.length),r+=i.length,Eh.encode.bytes=r-n,e.writeUInt16BE(Eh.encode.bytes-2,n),e};Eh.encode.bytes=0;Eh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.typeCovered=yp.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=or.decode(t,e),e+=or.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,Eh.decode.bytes=e-r,n};Eh.decode.bytes=0;Eh.encodingLength=function(t){return 20+or.encodingLength(t.signersName)+Vr.byteLength(t.signature)};var Th=Hr.rp={};Th.encode=function(t,e,r){e||(e=Vr.alloc(Th.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.mbox||".",e,r,{mail:!0}),r+=or.encode.bytes,or.encode(t.txt||".",e,r),r+=or.encode.bytes,Th.encode.bytes=r-n,e.writeUInt16BE(Th.encode.bytes-2,n),e};Th.encode.bytes=0;Th.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=or.decode(t,e,{mail:!0})||".",e+=or.decode.bytes,n.txt=or.decode(t,e)||".",e+=or.decode.bytes,Th.decode.bytes=e-r,n};Th.decode.bytes=0;Th.encodingLength=function(t){return 2+or.encodingLength(t.mbox||".")+or.encodingLength(t.txt||".")};var go={};go.encode=function(t,e,r){e||(e=Vr.alloc(go.encodingLength(t))),r||(r=0);let n=r;for(var i=[],s=0;s<t.length;s++){var a=yp.toType(t[s]);i[a>>8]===void 0&&(i[a>>8]=[]),i[a>>8][a>>3&31]|=1<<7-(a&7)}for(s=0;s<i.length;s++)if(i[s]!==void 0){var c=Vr.from(i[s]);e.writeUInt8(s,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return go.encode.bytes=r-n,e};go.encode.bytes=0;go.decode=function(t,e,r){e||(e=0);let n=e;for(var i=[];e-n<r;){var s=t.readUInt8(e);e+=1;var a=t.readUInt8(e);e+=1;for(var c=0;c<a;c++)for(var d=t.readUInt8(e+c),h=0;h<8;h++)if(d&1<<7-h){var p=yp.toString(s<<8|c<<3|h);i.push(p)}e+=a}return go.decode.bytes=e-n,i};go.decode.bytes=0;go.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=yp.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(i+=2+Math.ceil((e[r]+1)/8));return i};var Ch=Hr.nsec={};Ch.encode=function(t,e,r){e||(e=Vr.alloc(Ch.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.nextDomain,e,r),r+=or.encode.bytes,go.encode(t.rrtypes,e,r),r+=go.encode.bytes,Ch.encode.bytes=r-n,e.writeUInt16BE(Ch.encode.bytes-2,n),e};Ch.encode.bytes=0;Ch.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.nextDomain=or.decode(t,e),e+=or.decode.bytes,n.rrtypes=go.decode(t,e,i-(e-r)),e+=go.decode.bytes,Ch.decode.bytes=e-r,n};Ch.decode.bytes=0;Ch.encodingLength=function(t){return 2+or.encodingLength(t.nextDomain)+go.encodingLength(t.rrtypes)};var kh=Hr.nsec3={};kh.encode=function(t,e,r){e||(e=Vr.alloc(kh.encodingLength(t))),r||(r=0);let n=r,i=t.salt;if(!Vr.isBuffer(i))throw new Error("salt must be a Buffer");let s=t.nextDomain;if(!Vr.isBuffer(s))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,e.writeUInt8(s.length,r),r+=1,s.copy(e,r,0,s.length),r+=s.length,go.encode(t.rrtypes,e,r),r+=go.encode.bytes,kh.encode.bytes=r-n,e.writeUInt16BE(kh.encode.bytes-2,n),e};kh.encode.bytes=0;kh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let s=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+s),e+=s;let a=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+a),e+=a,n.rrtypes=go.decode(t,e,i-(e-r)),e+=go.decode.bytes,kh.decode.bytes=e-r,n};kh.decode.bytes=0;kh.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+go.encodingLength(t.rrtypes)};var Dh=Hr.ds={};Dh.encode=function(t,e,r){e||(e=Vr.alloc(Dh.encodingLength(t))),r||(r=0);let n=r,i=t.digest;if(!Vr.isBuffer(i))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,Dh.encode.bytes=r-n,e.writeUInt16BE(Dh.encode.bytes-2,n),e};Dh.encode.bytes=0;Dh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+i+2),e+=n.digest.length,Dh.decode.bytes=e-r,n};Dh.decode.bytes=0;Dh.encodingLength=function(t){return 6+Vr.byteLength(t.digest)};var fl=Hr.sshfp={};fl.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};fl.encode=function(e,r,n){r||(r=Vr.alloc(fl.encodingLength(e))),n||(n=0);let i=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let s=Vr.from(e.fingerprint.toUpperCase(),"hex");if(s.length!==fl.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return s.copy(r,n),n+=s.byteLength,fl.encode.bytes=n-i,r.writeUInt16BE(fl.encode.bytes-2,i),r};fl.encode.bytes=0;fl.decode=function(e,r){r||(r=0);let n=r,i={};r+=2,i.algorithm=e[r],r+=1,i.hash=e[r],r+=1;let s=fl.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(r,r+s).toString("hex").toUpperCase(),r+=s,fl.decode.bytes=r-n,i};fl.decode.bytes=0;fl.encodingLength=function(t){return 4+Vr.from(t.fingerprint,"hex").byteLength};var Ih=Hr.naptr={};Ih.encode=function(t,e,r){e||(e=Vr.alloc(Ih.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,Nn.encode(t.flags,e,r),r+=Nn.encode.bytes,Nn.encode(t.services,e,r),r+=Nn.encode.bytes,Nn.encode(t.regexp,e,r),r+=Nn.encode.bytes,or.encode(t.replacement,e,r),r+=or.encode.bytes,Ih.encode.bytes=r-n,e.writeUInt16BE(Ih.encode.bytes-2,n),e};Ih.encode.bytes=0;Ih.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=Nn.decode(t,e),e+=Nn.decode.bytes,n.services=Nn.decode(t,e),e+=Nn.decode.bytes,n.regexp=Nn.decode(t,e),e+=Nn.decode.bytes,n.replacement=or.decode(t,e),e+=or.decode.bytes,Ih.decode.bytes=e-r,n};Ih.decode.bytes=0;Ih.encodingLength=function(t){return Nn.encodingLength(t.flags)+Nn.encodingLength(t.services)+Nn.encodingLength(t.regexp)+or.encodingLength(t.replacement)+6};var Fh=Hr.tlsa={};Fh.encode=function(t,e,r){e||(e=Vr.alloc(Fh.encodingLength(t))),r||(r=0);let n=r,i=t.certificate;if(!Vr.isBuffer(i))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,Fh.encode.bytes=r-n,e.writeUInt16BE(Fh.encode.bytes-2,n),e};Fh.encode.bytes=0;Fh.decode=function(t,e){e||(e=0);let r=e,n={},i=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+i+2),e+=n.certificate.length,Fh.decode.bytes=e-r,n};Fh.decode.bytes=0;Fh.encodingLength=function(t){return 5+Vr.byteLength(t.certificate)};var Lse=Hr.record=function(t){switch(t.toUpperCase()){case"A":return gp;case"PTR":return rd;case"CNAME":return Q4t;case"DNAME":return e3t;case"TXT":return dp;case"NULL":return hp;case"AAAA":return xp;case"SRV":return mp;case"HINFO":return pp;case"CAA":return ll;case"NS":return lp;case"SOA":return fp;case"MX":return Ig;case"OPT":return dl;case"DNSKEY":return jc;case"RRSIG":return Eh;case"RP":return Th;case"NSEC":return Ch;case"NSEC3":return kh;case"SSHFP":return fl;case"DS":return Dh;case"NAPTR":return Ih;case"TLSA":return Fh}return up},Lo=Hr.answer={};Lo.encode=function(t,e,r){e||(e=Vr.alloc(Lo.encodingLength(t))),r||(r=0);let n=r;if(or.encode(t.name,e,r),r+=or.encode.bytes,e.writeUInt16BE(yp.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,dl.encode(t.options||[],e,r),r+=dl.encode.bytes}else{let i=MU.toClass(t.class===void 0?"IN":t.class);t.flush&&(i|=Mse),e.writeUInt16BE(i,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let s=Lse(t.type);s.encode(t.data,e,r),r+=s.encode.bytes}return Lo.encode.bytes=r-n,e};Lo.encode.bytes=0;Lo.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=or.decode(t,e),e+=or.decode.bytes,r.type=yp.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=dl.decode(t,e+8),e+=8+dl.decode.bytes;else{let i=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=MU.toString(i&Y4t),r.flush=!!(i&Mse);let s=Lse(r.type);r.data=s.decode(t,e+8),e+=8+s.decode.bytes}return Lo.decode.bytes=e-n,r};Lo.decode.bytes=0;Lo.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return or.encodingLength(t.name)+8+Lse(t.type).encodingLength(e)};var nd=Hr.question={};nd.encode=function(t,e,r){e||(e=Vr.alloc(nd.encodingLength(t))),r||(r=0);let n=r;return or.encode(t.name,e,r),r+=or.encode.bytes,e.writeUInt16BE(yp.toType(t.type),r),r+=2,e.writeUInt16BE(MU.toClass(t.class===void 0?"IN":t.class),r),r+=2,nd.encode.bytes=r-n,t};nd.encode.bytes=0;nd.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=or.decode(t,e),e+=or.decode.bytes,n.type=yp.toString(t.readUInt16BE(e)),e+=2,n.class=MU.toString(t.readUInt16BE(e)),e+=2,n.class&xOe&&(n.class&=J4t),nd.decode.bytes=e-r,n};nd.decode.bytes=0;nd.encodingLength=function(t){return or.encodingLength(t.name)+4};Hr.AUTHORITATIVE_ANSWER=1024;Hr.TRUNCATED_RESPONSE=512;Hr.RECURSION_DESIRED=256;Hr.RECURSION_AVAILABLE=128;Hr.AUTHENTIC_DATA=32;Hr.CHECKING_DISABLED=16;Hr.DNSSEC_OK=32768;Hr.encode=function(t,e,r){let n=!e;n&&(e=Vr.alloc(Hr.encodingLength(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),id.encode(t,e,r),r+=id.encode.bytes,r=tD(t.questions,nd,e,r),r=tD(t.answers,Lo,e,r),r=tD(t.authorities,Lo,e,r),r=tD(t.additionals,Lo,e,r),Hr.encode.bytes=r-i,n&&Hr.encode.bytes!==e.length?e.slice(0,Hr.encode.bytes):e};Hr.encode.bytes=0;Hr.decode=function(t,e){e||(e=0);let r=e,n=id.decode(t,e);return e+=id.decode.bytes,e=UU(n.questions,nd,t,e),e=UU(n.answers,Lo,t,e),e=UU(n.authorities,Lo,t,e),e=UU(n.additionals,Lo,t,e),Hr.decode.bytes=e-r,n};Hr.decode.bytes=0;Hr.encodingLength=function(t){return id.encodingLength(t)+AS(t.questions||[],nd)+AS(t.answers||[],Lo)+AS(t.authorities||[],Lo)+AS(t.additionals||[],Lo)};Hr.streamEncode=function(t){let e=Hr.encode(t),r=Vr.alloc(2);r.writeUInt16BE(e.byteLength);let n=Vr.concat([r,e]);return Hr.streamEncode.bytes=n.byteLength,n};Hr.streamEncode.bytes=0;Hr.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=Hr.decode(t.slice(2));return Hr.streamDecode.bytes=Hr.decode.bytes,r};Hr.streamDecode.bytes=0;function AS(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function tD(t,e,r,n){for(let i=0;i<t.length;i++)e.encode(t[i],r,n),n+=e.encode.bytes;return n}function UU(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e.decode(r,n),n+=e.decode.bytes;return n}});var _Oe=L((Wsr,bOe)=>{"use strict";var vOe=a3t;process.nextTick(s3t,42);bOe.exports=t3t;function t3t(t){var e=n;return r;function r(i){e(i||n3t)}function n(i){var s=[i];e=a,t(c);function a(d){s.push(d)}function c(d){var h=arguments;for(e=r3t(d)?n:p;s.length;)p(s.shift());function p(x){vOe(i3t,x,h)}}}}function r3t(t){return Object.prototype.toString.call(t)==="[object Error]"}function n3t(){}function i3t(t,e){t.apply(null,e)}function s3t(t){t===42&&(vOe=process.nextTick)}function a3t(t,e,r){process.nextTick(function(){t(e,r)})}});var AOe=L((Hsr,SOe)=>{var $se=yOe(),o3t=Kr("dgram"),c3t=_Oe(),u3t=Kr("events"),qse=Kr("os"),jse=function(){};SOe.exports=function(t){t||(t={});var e=new u3t.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",i=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),s={address:i,port:r},a={},c=!1,d=null;if(n==="udp6"&&(!i||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var h=t.socket||o3t.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});h.on("error",function(x){x.code==="EACCES"||x.code==="EADDRINUSE"?e.emit("error",x):e.emit("warning",x)}),h.on("message",function(x,y){try{x=$se.decode(x)}catch(v){e.emit("warning",v);return}e.emit("packet",x,y),x.type==="query"&&e.emit("query",x,y),x.type==="response"&&e.emit("response",x,y)}),h.on("listening",function(){r||(r=s.port=h.address().port),t.multicast!==!1&&(e.update(),d=setInterval(e.update,5e3),h.setMulticastTTL(t.ttl||255),h.setMulticastLoopback(t.loopback!==!1))});var p=c3t(function(x){if(!r||t.bind===!1)return x(null);h.once("error",x),h.bind(r,t.bind||t.interface,function(){h.removeListener("error",x),x(null)})});return p(function(x){if(x)return e.emit("error",x);e.emit("ready")}),e.send=function(x,y,v){if(typeof y=="function")return e.send(x,null,y);v||(v=jse),y?!y.host&&!y.address&&(y.address=s.address):y=s,p(w);function w(S){if(c)return v();if(S)return v(S);var C=$se.encode(x);h.send(C,0,C.length,y.port,y.address||y.host,v)}},e.response=e.respond=function(x,y,v){Array.isArray(x)&&(x={answers:x}),x.type="response",x.flags=(x.flags||0)|$se.AUTHORITATIVE_ANSWER,e.send(x,y,v)},e.query=function(x,y,v,w){if(typeof y=="function")return e.query(x,null,null,y);if(typeof y=="object"&&y&&y.port)return e.query(x,null,y,v);if(typeof v=="function")return e.query(x,y,null,v);w||(w=jse),typeof x=="string"&&(x=[{name:x,type:y||"ANY"}]),Array.isArray(x)&&(x={type:"query",questions:x}),x.type="query",e.send(x,v,w)},e.destroy=function(x){if(x||(x=jse),c)return process.nextTick(x);c=!0,clearInterval(d);for(var y in a)try{h.dropMembership(i,y)}catch{}a={},h.close(x)},e.update=function(){for(var x=t.interface?[].concat(t.interface):f3t(),y=!1,v=0;v<x.length;v++){var w=x[v];if(!a[w])try{h.addMembership(i,w),a[w]=!0,y=!0}catch(S){e.emit("warning",S)}}if(y){if(h.setMulticastInterface)try{h.setMulticastInterface(t.interface||l3t())}catch(S){e.emit("warning",S)}e.emit("networkInterface")}},e};function l3t(){for(var t=qse.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],i=0;i<n.length;i++){var s=n[i];if(wOe(s.family)&&!s.internal)return qse.platform()==="darwin"&&e[r]==="en0"?s.address:"0.0.0.0"}return"127.0.0.1"}function f3t(){for(var t=qse.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var i=t[e[n]],s=0;s<i.length;s++){var a=i[s];if(wOe(a.family)){r.push(a.address);break}}return r}function wOe(t){return t===4||t==="IPv4"}});var gMe={};yi(gMe,{AV1Obu:()=>R7e,AV1RtpPayload:()=>hae,AttributeKeys:()=>G6t,BitStream:()=>Ug,BitWriter:()=>CD,BitWriter2:()=>bM,BufferChain:()=>m3t,CONSENT_FAILURES:()=>Uae,CONSENT_INTERVAL:()=>rUe,COOKIE:()=>DM,Candidate:()=>$g,CandidatePair:()=>Nae,CandidatePairState:()=>nUe,CipherContext:()=>FD,CipherSuite:()=>oM,CipherSuiteList:()=>n7e,Connection:()=>fUe,ConnectionStates:()=>V8t,CurveType:()=>doe,DEFAULT_MAX_MESSAGE_SIZE:()=>RS,DePacketizerBase:()=>x6t,Directions:()=>XU,DtlsClient:()=>Dae,DtlsServer:()=>RBe,DtlsSocket:()=>woe,DtlsStates:()=>n8t,Event:()=>yr,EventDisposer:()=>JNe,ExtensionProfiles:()=>Ng,FINGERPRINT_LENGTH:()=>OBe,FINGERPRINT_XOR:()=>NBe,GenericNack:()=>UD,GroupDescription:()=>US,H264RtpPayload:()=>U7e,HEADER_LENGTH:()=>_p,HashAlgorithm:()=>ID,ICE_COMPLETED:()=>Bae,ICE_FAILED:()=>_D,INTEGRITY_LENGTH:()=>Soe,IPV4_PROTOCOL:()=>Aoe,IPV6_PROTOCOL:()=>Eoe,IceCandidate:()=>Koe,IceGathererStates:()=>l8t,IceTransportStates:()=>u8t,Inactive:()=>SUe,Int:()=>OD,MediaDescription:()=>yM,MediaStream:()=>EUe,MediaStreamTrack:()=>qD,MediaStreamTrackFactory:()=>VDt,Message:()=>sf,NalUnitType:()=>Og,NamedCurveAlgorithm:()=>Ep,NamedCurveAlgorithmList:()=>foe,OpusRtpPayload:()=>L7e,PacketChunk:()=>Y7e,PacketResult:()=>Q7e,PacketStatus:()=>J7e,PictureLossIndication:()=>ND,Profiles:()=>f6t,PromiseQueue:()=>S3t,ProtectionProfileAeadAes128Gcm:()=>Fv,ProtectionProfileAes128CmHmacSha1_80:()=>HS,RETRY_MAX:()=>BBe,RETRY_RTO:()=>UBe,RTCCertificate:()=>Goe,RTCDataChannel:()=>Poe,RTCDataChannelParameters:()=>Roe,RTCDtlsFingerprint:()=>mM,RTCDtlsParameters:()=>gM,RTCDtlsTransport:()=>qae,RTCIceCandidate:()=>BUe,RTCIceGatherer:()=>OUe,RTCIceParameters:()=>Zoe,RTCIceTransport:()=>RUe,RTCP_HEADER_SIZE:()=>lM,RTCPeerConnection:()=>q8t,RTCRtcpFeedback:()=>pUe,RTCRtcpParameters:()=>bDt,RTCRtpCodecParameters:()=>jg,RTCRtpCodingParameters:()=>gUe,RTCRtpHeaderExtensionParameters:()=>Mh,RTCRtpReceiver:()=>ece,RTCRtpRtxParameters:()=>mUe,RTCRtpSender:()=>dMe,RTCRtpSimulcastParameters:()=>Ooe,RTCRtpTransceiver:()=>wUe,RTCSctpCapabilities:()=>Yoe,RTCSctpTransport:()=>oMe,RTCSessionDescription:()=>lMe,RTCStatsReport:()=>_Ue,RTP_EXTENSION_URI:()=>Os,ReceiverEstimatedMaxBitrate:()=>BD,RecvDelta:()=>AD,Recvonly:()=>$oe,Red:()=>voe,RedEncoder:()=>vBe,RedHandler:()=>bBe,RedHeader:()=>Eae,RtcpHeader:()=>kp,RtcpPacketConverter:()=>iBe,RtcpPayloadSpecificFeedback:()=>LS,RtcpReceiverInfo:()=>kM,RtcpRrPacket:()=>$S,RtcpSenderInfo:()=>yoe,RtcpSourceDescriptionPacket:()=>LD,RtcpSrPacket:()=>Cv,RtcpTransportLayerFeedback:()=>Tv,RtpBuilder:()=>B6t,RtpHeader:()=>Tp,RtpPacket:()=>Cp,RtpRouter:()=>fMe,RunLengthChunk:()=>BS,SDPManager:()=>hMe,Sendonly:()=>Loe,Sendrecv:()=>joe,SessionDescription:()=>TD,SignalingStates:()=>H8t,SignatureAlgorithm:()=>Uh,SignatureScheme:()=>sae,SourceDescriptionChunk:()=>goe,SourceDescriptionItem:()=>xoe,SrtcpSession:()=>IBe,SrtpAuthenticationError:()=>kv,SrtpContext:()=>PD,SrtpSession:()=>FBe,SsrcDescription:()=>vM,StatusVectorChunk:()=>Z7e,StunOverTurnProtocol:()=>KBe,StunProtocol:()=>fM,TcpTransport:()=>t7e,TransceiverManager:()=>mMe,TransportWideCC:()=>MD,TurnProtocol:()=>XBe,UdpTransport:()=>aM,Vp8RtpPayload:()=>j7e,Vp9RtpPayload:()=>z7e,WeriftError:()=>E3t,addSDPHeader:()=>ioe,andDirection:()=>Woe,buffer2ArrayBuffer:()=>x3t,bufferArrayXor:()=>h3t,bufferReader:()=>zc,bufferWriter:()=>Vs,bufferWriterLE:()=>$Ne,bufferXor:()=>d3t,candidateFoundation:()=>dM,candidateFromIce:()=>qS,candidateFromSdp:()=>Qoe,candidatePairPriority:()=>hM,candidatePriority:()=>ED,candidateToIce:()=>NUe,candidateToSdp:()=>Joe,certificateTypes:()=>i7e,classes:()=>Toe,codecParametersFromString:()=>HD,codecParametersToString:()=>R8t,compactNtp:()=>Voe,crc32:()=>VNe,crc32c:()=>uoe,createBufferWriter:()=>SD,createSelfSignedCertificate:()=>HDt,createStunOverTurnClient:()=>Rae,createTurnClient:()=>JBe,dePacketizeRtpPackets:()=>y6t,debug:()=>_n,deepMerge:()=>FUe,defaultOptions:()=>iUe,defaultPeerConfig:()=>z8t,depacketizerCodecs:()=>v6t,deserializeAbsSendTime:()=>pBe,deserializeAudioLevelIndication:()=>mBe,deserializeString:()=>dBe,deserializeUint16BE:()=>hBe,deserializeVideoOrientation:()=>gBe,dumpBuffer:()=>g3t,enumerate:()=>b6t,findCodecByMimeType:()=>aoe,findPort:()=>XNe,fingerprint:()=>qoe,generateStatsId:()=>rs,getBit:()=>ir,getDataChannelMessageSize:()=>dUe,getGlobalIp:()=>pDt,getHostAddresses:()=>lUe,getStatsTimestamp:()=>qg,growBufferSize:()=>pae,int:()=>OS,interfaceAddress:()=>wM,isDtls:()=>TUe,isLinkLocalAddress:()=>uUe,isMedia:()=>H7e,isRtcp:()=>sBe,keyLength:()=>D7e,leb128decode:()=>N7e,makeIntegrityKey:()=>QBe,methods:()=>Coe,microTime:()=>kUe,milliTime:()=>Hoe,nodeIpAddress:()=>$ae,normalizeFamilyNodeV18:()=>DD,normalizeFingerprintAlgorithm:()=>zoe,normalizeFingerprintValue:()=>pM,ntpTime:()=>DUe,ntpTime2Sec:()=>nBe,paddingBits:()=>p3t,paddingByte:()=>kD,paddingLength:()=>Fae,parseGroup:()=>iM,parseIceServers:()=>IUe,parseMessage:()=>IM,random16:()=>coe,random32:()=>sM,randomPort:()=>loe,randomPorts:()=>A3t,reverseDirection:()=>CUe,reverseSimulcastDirection:()=>zDt,rtpHeaderExtensionsParser:()=>aBe,saltLength:()=>I7e,serializeAbsSendTime:()=>fBe,serializeAudioLevelIndication:()=>T6t,serializeRepairedRtpStreamId:()=>uBe,serializeSdesMid:()=>oBe,serializeSdesRTPStreamID:()=>cBe,serializeTransportWideCC:()=>lBe,serverReflexiveCandidate:()=>aUe,signatures:()=>hoe,sortCandidatePairs:()=>sUe,supportedAudioCodecs:()=>wDt,supportedCodecs:()=>Moe,supportedVideoCodecs:()=>_Dt,timer:()=>_6t,timestampSeconds:()=>zD,uint16Add:()=>jo,uint16Gt:()=>_M,uint16Gte:()=>w3t,uint24:()=>KNe,uint32Add:()=>bv,uint32Gt:()=>Oh,uint32Gte:()=>PS,uint8Add:()=>GNe,unwrapRtx:()=>wBe,url2Address:()=>mDt,useAV1X:()=>vUe,useAbsSendTime:()=>CDt,useAudioLevelIndication:()=>DDt,useDependencyDescriptor:()=>kDt,useFIR:()=>vDt,useH264:()=>xUe,useNACK:()=>QD,useOPUS:()=>Boe,usePCMU:()=>Uoe,usePLI:()=>GS,useREMB:()=>e8,useRepairedRtpStreamId:()=>EDt,useSdesMid:()=>SDt,useSdesRTPStreamId:()=>ADt,useTWCC:()=>hUe,useTransportWideCC:()=>TDt,useVP8:()=>Noe,useVP9:()=>yUe,useVideoOrientation:()=>IDt,validateAddress:()=>Lae,validateRemoteCandidate:()=>Mae,wrapRtx:()=>SBe});import{randomBytes as LNe}from"crypto";import{createSocket as ZNe}from"dgram";import{createSocket as T3t}from"dgram";import*as QNe from"node:net";import{connect as C3t}from"node:net";import{createSign as k3t,randomBytes as D3t,webcrypto as I3t}from"crypto";import{createHash as F3t,createHmac as P3t}from"crypto";import{randomBytes as K3t}from"crypto";import{setTimeout as Z3t}from"timers/promises";import{createCipheriv as a6t,createDecipheriv as o6t}from"crypto";import{createHmac as Wse}from"crypto";import{createCipheriv as LOe,createDecipheriv as $Oe,createHmac as jOe,timingSafeEqual as D6t}from"crypto";import{createCipheriv as HOe,createDecipheriv as VOe}from"crypto";import{setTimeout as M6t}from"timers/promises";import{randomBytes as z6t}from"crypto";import{createHmac as MBe}from"crypto";import{randomBytes as LBe}from"crypto";import{createHash as nDt}from"crypto";import{setTimeout as iDt}from"timers/promises";import{createHash as cDt}from"crypto";import{isIPv4 as cNe}from"net";import{randomBytes as uDt}from"crypto";import{isIPv4 as uNe}from"net";import*as Oae from"node:timers/promises";import{randomUUID as fDt}from"crypto";import*as oUe from"node:os";import{EventEmitter as xDt}from"node:events";import{randomUUID as FDt}from"crypto";import{setTimeout as Qse}from"timers/promises";import{createHash as PDt}from"crypto";import{createSocket as RDt}from"dgram";import{performance as dNe}from"perf_hooks";import{randomUUID as ODt}from"crypto";import{randomUUID as AUe}from"crypto";import{setTimeout as ZDt}from"timers/promises";import{randomBytes as QDt}from"crypto";import{isIPv4 as e8t}from"net";import{randomUUID as t8t}from"crypto";import{setTimeout as r8t}from"timers/promises";import{randomUUID as c8t}from"crypto";import{randomUUID as f8t}from"crypto";import{createHmac as SNe,randomBytes as d8t}from"crypto";import{randomBytes as ONe}from"crypto";import{randomUUID as NNe}from"crypto";import{setTimeout as BNe}from"timers/promises";import{randomUUID as U8t}from"crypto";function coe(){return ooe.jspack.Unpack("!H",LNe(2))[0]}function sM(){return ooe.jspack.Unpack("!L",LNe(4))[0]}function d3t(t,e){if(t.length!==e.length)throw new TypeError("[webrtc-stun] You can not XOR buffers which length are different");let r=t.length,n=Buffer.allocUnsafe(r);for(let i=0;i<r;i++)n[i]=t[i]^e[i];return n}function h3t(t){let e=[...t].sort((n,i)=>n.length-i.length).reverse()[0].length,r=Buffer.allocUnsafe(e);for(let n=0;n<e;n++)r[n]=0,t.forEach(i=>{r[n]^=i[n]??0});return r}function ir(t,e,r=1){let n=t.toString(2).split("");n=[...Array(8-n.length).fill("0"),...n];let i=n.slice(e,e+r).join("");return Number.parseInt(i,2)}function kD(t){let e=t.toString(2).split("");return[...[...Array(8-e.length)].map(()=>"0"),...e].join("")}function p3t(t,e){let r=t.toString(2);return[...[...Array(e-r.length)].map(()=>"0"),...r].join("")}function Vs(t,e){return SD(t)(e)}function SD(t,e){let r=t.reduce((i,s)=>i+s,0),n=e?Buffer.alloc(r):void 0;return i=>{let s=n||Buffer.alloc(r),a=0;return i.forEach((c,d)=>{let h=t[d];h===8?s.writeBigUInt64BE(c,a):s.writeUIntBE(c,a,h),a+=h}),s}}function $Ne(t,e){let r=t.reduce((s,a)=>s+a,0),n=Buffer.alloc(r),i=0;return e.forEach((s,a)=>{let c=t[a];c===8?n.writeBigUInt64LE(s,i):n.writeUIntLE(s,i,c),i+=c}),n}function zc(t,e){let r=0;return e.map(n=>{let i;return n===8?i=t.readBigUInt64BE(r):i=t.readUIntBE(r,n),r+=n,i})}function x3t(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function jNe(t){return typeof t!="string"}function qNe(t){let e=new Array(256),r=0;for(let n=0;n<256;++n)r=n,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,e[n]=r;return new Int32Array(e)}function zNe(t){let e=new Int32Array(4096),r=0,n=0,i=0;for(i=0;i<256;++i)e[i]=t[i];for(i=0;i<256;++i)for(n=t[i],r=256+i;r<4096;r+=256)n=e[r]=n>>>8^t[n&255];let s=[];for(i=1;i<16;++i)s[i-1]=e.subarray(i*256,i*256+256);return s}function WNe(t,e,r){let n=e^-1,i=0,s=t.length,a=0,c=0;for(;i<s;)a=t.charCodeAt(i++),a<128?n=n>>>8^r[(n^a)&255]:a<2048?(n=n>>>8^r[(n^(192|a>>6&31))&255],n=n>>>8^r[(n^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,c=t.charCodeAt(i++)&1023,n=n>>>8^r[(n^(240|a>>8&7))&255],n=n>>>8^r[(n^(128|a>>2&63))&255],n=n>>>8^r[(n^(128|c>>6&15|(a&3)<<4))&255],n=n>>>8^r[(n^(128|c&63))&255]):(n=n>>>8^r[(n^(224|a>>12&15))&255],n=n>>>8^r[(n^(128|a>>6&63))&255],n=n>>>8^r[(n^(128|a&63))&255]);return~n>>>0}function HNe(t,e,r,n){let[i,s,a,c,d,h,p,x,y,v,w,S,C,k,T]=n,E=e^-1,I=0,R=t.length-15;for(;I<R;)E=T[t[I++]^E&255]^k[t[I++]^E>>>8&255]^C[t[I++]^E>>>16&255]^S[t[I++]^E>>>24]^w[t[I++]]^v[t[I++]]^y[t[I++]]^x[t[I++]]^p[t[I++]]^h[t[I++]]^d[t[I++]]^c[t[I++]]^a[t[I++]]^s[t[I++]]^i[t[I++]]^r[t[I++]];for(R+=15;I<R;)E=E>>>8^r[(E^t[I++])&255];return~E>>>0}function VNe(t,e=0){return jNe(t)?HNe(t,e,nae,b3t):WNe(t,e,nae)}function uoe(t,e=0){return jNe(t)?HNe(t,e,iae,_3t):WNe(t,e,iae)}function GNe(t,e){return t+e&255}function jo(t,e){return t+e&65535}function bv(t,e){return Number(BigInt(t)+BigInt(e)&0xffffffffn)}function KNe(t){return t&16777215}function _M(t,e){return t<e&&e-t>32768||t>e&&t-e<32768}function w3t(t,e){return t===e||_M(t,e)}function Oh(t,e){return t<e&&e-t>2147483648||t>e&&t-e<2147483648}function PS(t,e){return t===e||Oh(t,e)}async function loe(t="udp4",e){let r=ZNe(t);setImmediate(()=>r.bind({port:0,address:wM(t,e)})),await new Promise(i=>{r.once("error",i),r.once("listening",i)});let n=r.address()?.port;return await new Promise(i=>r.close(()=>i())),n}async function A3t(t,e="udp4",r){return Promise.all([...Array(t)].map(()=>loe(e,r)))}async function XNe(t,e,r="udp4",n){let i;for(let s=t;s<=e;s++){let a=ZNe(r);if(setImmediate(()=>a.bind({port:s,address:wM(r,n)})),await new Promise(d=>{a.once("error",h=>d(h)),a.once("listening",()=>d())})){await new Promise(d=>a.close(()=>d()));continue}if(i=a.address()?.port,await new Promise(d=>a.close(()=>d())),t<=i&&i<=e)break}if(!i)throw new Error("port not found");return i}function DD(t){return t==="IPv4"?4:t==="IPv6"?6:t}function o7e(t,e,r){switch(r){case Ep.secp256r1_23:return O3t({publicKey:t,privateKey:e});case Ep.x25519_29:return Buffer.from(a7e.default.scalarMult(e,t));default:throw new Error}}function TOe(t,e,r){let n=P3t(t,e);return n.update(r),n.digest()}function VD(t,e,r,n="sha256"){let i=r,s=[],a=e;do{a=TOe(n,t,a);let c=TOe(n,t,Buffer.concat([a,e]));s.push(c),r-=c.length}while(r>0);return Buffer.concat(s,i)}function c7e(t,e,r){let n=Buffer.concat([Buffer.from("master secret"),e,r]);return VD(t,n,48)}function u7e(t,e){let r=l7e("sha256",e);return VD(t,Buffer.concat([Buffer.from("extended master secret"),r]),48)}function N3t(t,e,r,n,i,s){let a=s?n:i,c=s?i:n,d=Buffer.concat([Buffer.from(t),a,c]);return VD(r,d,e)}function l7e(t,e){return F3t(t).update(e).digest()}function f7e(t,e,r,n=12){let i=l7e("sha256",e);return VD(t,Buffer.concat([Buffer.from(r),i]),n)}function B3t(t,e){return f7e(t,e,"client finished")}function U3t(t,e){return f7e(t,e,"server finished")}function M3t(t,e,r,n,i,s,a="sha256"){let c=n*2+i*2,d=t,h=Buffer.concat([r,e]),p=VD(d,Buffer.concat([Buffer.from("key expansion"),h]),c,a),x=(0,s7e.createDecode)(p),y=x.readBuffer(n),v=x.readBuffer(n),w=x.readBuffer(i),S=x.readBuffer(i),C=Buffer.alloc(s,0),k=Buffer.alloc(s,0);return w.copy(C,0),S.copy(k,0),{clientWriteKey:y,serverWriteKey:v,clientNonce:C,serverNonce:k}}function t6t(){let t=new YD;return t.id=XD.RSA,t.name="RSA",t.keyType=ZD.RSA,t}function r6t(){let t=new YD;return t.id=XD.ECDHE_RSA,t.name="ECDHE_RSA",t.signType=AM.ECDHE,t.keyType=ZD.RSA,t}function n6t(){let t=new YD;return t.id=XD.ECDHE_ECDSA,t.name="ECDHE_ECDSA",t.signType=AM.ECDHE,t.keyType=ZD.ECDSA,t}function i6t(){let t=new YD;return t.id=XD.PSK,t.name="PSK",t.signType=AM.NULL,t.keyType=ZD.PSK,t}function s6t(){let t=new YD;return t.id=XD.ECDHE_PSK,t.name="ECDHE_PSK",t.signType=AM.ECDHE,t.keyType=ZD.PSK,t}function y7e(t){switch(t){case Oa.TLS_RSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_RSA_WITH_AES_128_GCM_SHA256,"TLS_RSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",COe,rD);case Oa.TLS_RSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_RSA_WITH_AES_256_GCM_SHA384,"TLS_RSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",COe,nD,"sha384");case Oa.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",kOe,rD);case Oa.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",kOe,nD,"sha384");case Oa.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",DOe,rD);case Oa.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",DOe,nD,"sha384");case Oa.TLS_PSK_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_PSK_WITH_AES_128_GCM_SHA256,"TLS_PSK_WITH_AES_128_GCM_SHA256","aes-128-gcm",IOe,rD,"sha256");case Oa.TLS_PSK_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_PSK_WITH_AES_256_GCM_SHA384,"TLS_PSK_WITH_AES_256_GCM_SHA384","aes-256-gcm",IOe,nD,"sha384");case Oa.TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256","aes-128-gcm",FOe,rD,"sha256");case Oa.TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384","aes-256-gcm",FOe,nD,"sha384");default:break}return null}function Ph(t,e,r,n,i,s="sha256"){let a=new u6t;return a.id=t,a.name=e,a.blockAlgorithm=r,a.kx=n,a.hashAlgorithm=s,a.keyLength=i.K_LEN,a.nonceLength=i.N_MAX,a.nonceImplicitLength=4,a.nonceExplicitLength=8,a.ivLength=a.nonceImplicitLength,a.authTagLength=16,a}function b7e(t){switch(t){case Ep.secp256r1_23:{let{privateKey:e,publicKey:r}=R3t();return{curve:t,privateKey:e,publicKey:r}}case Ep.x25519_29:{let e=v7e.default.box.keyPair();return{curve:t,privateKey:Buffer.from(e.secretKey.buffer),publicKey:Buffer.from(e.publicKey.buffer)}}default:throw new Error}}function l6t(t,e){return Buffer.from((0,C7e.encode)(t,e).slice())}function N7e(t){let e=0,r=0;for(let n=0;n<8;n++){let i=t.readUInt8(n);if(e|=(i&127)<<n*7,r++,!(i&128))break}return[e,r]}function y6t(t,e,r){let n=i=>{let s=[];for(let d of e){let h=i.deSerialize(d.payload,r);h.fragment?(r??=Buffer.alloc(0),r=h.fragment):h.payload&&(r=void 0),s.push(h)}let a=!!s.find(d=>d.isKeyframe),c=Buffer.concat(s.map(d=>d.payload).filter(d=>d));return{isKeyframe:a,data:c,sequence:e.at(-1)?.header.sequenceNumber??0,timestamp:e.at(-1)?.header.timestamp??0,frameFragmentBuffer:r}};switch(t.toUpperCase()){case"AV1":{let i=e.map(c=>hae.deSerialize(c.payload)),s=!!i.find(c=>c.isKeyframe),a=hae.getFrame(i);return{isKeyframe:s,data:a,sequence:e.at(-1)?.header.sequenceNumber??0,timestamp:e.at(-1)?.header.timestamp??0}}case"MPEG4/ISO/AVC":return n(U7e);case"VP8":return n(j7e);case"VP9":return n(z7e);case"OPUS":return n(L7e);default:throw new Error}}function b6t(t){return t.map((e,r)=>[r,e])}function pae(t,e){let r=Buffer.alloc(e);return t.copy(r),r}function OD(t){return Number.parseInt(t.toString(),10)}function H7e(t){let e=t[0];return e>127&&e<192}function ROe(t){return t%4==0?0:4-t%4}function sBe(t){return t.length>=2&&t[1]>=192&&t[1]<=208}function aBe(t,e){return t.map(r=>{let n=e[r.id];if(!n)return{uri:"unknown",value:r.payload};switch(n){case Os.sdesMid:case Os.sdesRTPStreamID:case Os.repairedRtpStreamId:return{uri:n,value:dBe(r.payload)};case Os.transportWideCC:return{uri:n,value:hBe(r.payload)};case Os.absSendTime:return{uri:n,value:pBe(r.payload)};case Os.audioLevelIndication:return{uri:n,value:mBe(r.payload)};case Os.videoOrientation:return{uri:n,value:gBe(r.payload)};default:return{uri:n,value:r.payload}}}).reduce((r,n)=>(n&&(r[n.uri]=n.value),r),{})}function oBe(t){return Buffer.from(t)}function cBe(t){return Buffer.from(t)}function uBe(t){return Buffer.from(t)}function lBe(t){return Vs([2],[t])}function fBe(t){let e=Buffer.alloc(3),r=t>>14n&0x00ffffffn;return e.writeUIntBE(Number(r),0,3),e}function T6t(t){let e=new Ug(Buffer.alloc(1));return e.writeBits(1,1),e.writeBits(7,t),e.uint8Array}function dBe(t){return t.toString()}function hBe(t){return t.readUInt16BE()}function pBe(t){return zc(t,[3])[0]}function mBe(t){let e=new Ug(t);return{v:e.readBits(1)===1,level:e.readBits(7)}}function gBe(t){let e=new Ug(t);return e.readBits(4),{c:e.readBits(1),f:e.readBits(1),r1:e.readBits(1),r0:e.readBits(1)}}function wBe(t,e,r){return new Cp(new Tp({payloadType:e,marker:t.header.marker,sequenceNumber:boe.jspack.Unpack("!H",t.payload.subarray(0,2))[0],timestamp:t.header.timestamp,ssrc:r}),t.payload.subarray(2))}function SBe(t,e,r,n){return new Cp(new Tp({payloadType:e,marker:t.header.marker,sequenceNumber:r,timestamp:t.header.timestamp,ssrc:n,csrc:t.header.csrc,extensions:t.header.extensions}),Buffer.concat([Buffer.from(boe.jspack.Pack("!H",[t.header.sequenceNumber])),t.payload]))}function _oe(t,e,r="Failed to authenticate SRTP packet"){let n=t.length-e;$D(t.length>=qOe+e,r);let i=TBe(()=>Tp.deSerialize(t.subarray(0,n)),r);return i.paddingSize=0,$D(i.payloadOffset>=qOe&&i.payloadOffset<=n,r),i}function EBe(t,e,r,n="Failed to authenticate SRTCP packet"){return $D(t.length>=I6t+e+r,n),TBe(()=>kp.deSerialize(t.subarray(0,lM)),n)}function $D(t,e){if(!t)throw new kv(e)}function TBe(t,e){try{return t()}catch{throw new kv(e)}}function CBe(t,e,r="Failed to authenticate SRTP packet"){if(!t.padding)return t.paddingSize=0,t;$D(e.length>t.payloadOffset,r);let n=e[e.length-1];return $D(n>0&&n<=e.length-t.payloadOffset,r),t.paddingSize=n,t}function WOe(t,e,r){if(t.length!==e.length||!D6t(t,e))throw new kv(r)}function KOe(t,e){try{t.final()}catch{throw new kv(`Failed to authenticate ${e} packet`)}}function sD(t){return LBe(t).toString("hex").substring(0,t)}function $Be(){return LBe(12)}function DS(t){let[e]=t,r=jD.default.isV4Format(e)?Aoe:Eoe,n=Buffer.alloc(4);return n.writeUInt8(0,0),n.writeUInt8(r,1),n.writeUInt16BE(t[1],2),Buffer.concat([n,jD.default.toBuffer(e)])}function K6t(t){if(t.length<4)throw new Error("STUN error code is less than 4 bytes");let e=t.readUInt8(2),r=t.readUInt8(3),n=t.slice(4).toString("utf8");return[e*100+r,n]}function IS(t){if(t.length<4)throw new Error("STUN address length is less than 4 bytes");let e=t.readUInt8(1),r=t.readUInt16BE(2),n=t.slice(4);switch(e){case Aoe:if(n.length!=4)throw new Error("STUN address has invalid length for IPv4");return[jD.default.toString(n),r];case Eoe:if(n.length!=16)throw new Error("STUN address has invalid length for IPv6");return[jD.default.toString(n),r];default:throw new Error("STUN address has unknown protocol")}}function jBe(t,e){let r=[...koe,...e],n=t.slice(0,2);for(let i=2;i<t.length;i++){let s=t[i]^r[i-2],a=Buffer.alloc(1);a.writeUIntBE(s,0,1),n=Buffer.concat([n,a])}return n}function VU(t,e){return IS(jBe(t,e))}function Z6t(t){let e=Buffer.alloc(4);e.writeUInt16BE(0,0),e.writeUInt8(Math.floor(t[0]/100),2),e.writeUInt8(t[0]%100,3);let r=Buffer.from(t[1],"utf8");return Buffer.concat([e,r])}function GU(t,e){return jBe(DS(t),e)}function IM(t,e){if(t.length<_p)return;let r=t.readUint16BE(2);if(t.length!==_p+r)return;let n=t.readUint16BE(0),i=Buffer.from(t.slice(_p-12,_p)),s=new zBe;for(let c=_p;c<=t.length-4;){let d=t.readUInt16BE(c),h=t.readUInt16BE(c+2),p=t.slice(c+4,c+4+h),x=4*Math.floor((h+3)/4)-h;if(Object.keys(sNe).includes(d.toString())){let[,v,,w]=sNe[d];if(w.name===VU.name?s.setAttribute(v,w(p,i)):s.setAttribute(v,w(p)),v==="FINGERPRINT"){let S=WBe(t.slice(0,c));if(s.getAttributeValue("FINGERPRINT")!==S)return}else if(v==="MESSAGE-INTEGRITY"&&e){let S=tDt(t.slice(0,c),e),C=s.getAttributeValue("MESSAGE-INTEGRITY");if(!S.equals(C))return}}c+=4+h+x}let a=s.getAttributes();return s.clear(),new sf(n&16111,n&272,i,a)}function WBe(t){let e=Doe(t,t.length-_p+OBe);return(VNe(e)^NBe)>>>0}function tDt(t,e){let r=Doe(t,t.length-_p+Soe);return Buffer.from(MBe("sha1",e).update(r).digest("hex"),"hex")}function Fae(t){let e=t%4;return e===0?0:4-e}async function JBe({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a}={}){n??=aDt,a??="udp";let c=a==="udp"?await aM.init("udp4",{portRange:i,interfaceAddresses:s}):await t7e.init(t),d=new XBe(t,e,r,n,c);return await d.connectionMade(),d}async function Rae({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a}={}){let c=await JBe({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a});return new KBe(c)}function QBe(t,e,r){return nDt("md5").update(Buffer.from([t,e,r].join(":"))).digest()}function oNe(t){return(t[0]&192)==64}function dM(t,e,r){let n=`${t}|${e}|${r}`;return cDt("md5").update(n,"ascii").digest("hex").slice(7)}function ED(t,e=65535){let n=0;return t==="host"?n=126:t==="prflx"?n=110:t==="srflx"?n=100:n=0,(1<<24)*n+256*e+255}function Mae(t){if(!["host","relay","srflx"].includes(t.type))throw new Error(`Unexpected candidate type "${t.type}"`);return t}function sUe(t,e){return t.sort((r,n)=>hM(r.localCandidate,r.remoteCandidate,e)-hM(n.localCandidate,n.remoteCandidate,e)).reverse()}function hM(t,e,r){let n=r&&t.priority||e.priority,i=r&&e.priority||t.priority;return 1*Math.min(n,i)+2*Math.max(n,i)+(n>i?1:0)}async function aUe(t,e){let r=new sf(1,0);try{let[n]=await t.request(r,e),i=t.localCandidate;if(!i)throw new Error("not exist");return new $g(dM("srflx","udp",i.host),i.component,i.transport,ED("srflx"),n.getAttributeValue("XOR-MAPPED-ADDRESS")[0],n.getAttributeValue("XOR-MAPPED-ADDRESS")[1],"srflx",i.host,i.port)}catch(n){dDt("error serverReflexiveCandidate",n)}}function Lae(t){return t&&Number.isNaN(t[1])?[t[0],443]:t}async function pDt(t,e){let r=new fM;await r.connectionMade(!0,void 0,e);let n=new sf(1,0),[i]=await r.request(n,t??["stun.l.google.com",19302]);return await r.close(),i.getAttributeValue("XOR-MAPPED-ADDRESS")[0]}function uUe(t){return DD(t.family)===4&&t.address?.startsWith("169.254.")||DD(t.family)===6&&t.address?.startsWith("fe80::")}function $ae(t,{useLinkLocalAddress:e}={}){let r=["ipsec","tun","utun","tap"],n=["vmnet","veth"],i=oUe.networkInterfaces();hDt(i);let s=Object.keys(i).map(a=>{for(let d of[...r,...n])if(a.startsWith(d))return{nic:a,addresses:[]};let c=i[a].filter(d=>DD(d.family)===t&&!cUe.default.isLoopback(d.address)&&(e?!0:!uUe(d)));return{nic:a,addresses:c.map(d=>d.address)}}).filter(a=>!!a);return s.sort((a,c)=>a.nic.localeCompare(c.nic)),Object.values(s).flatMap(a=>a.addresses)}function lUe(t,e,r={}){let n=[];return t&&n.push(...$ae(4,r)),e&&n.push(...$ae(6,r)),n}function fNe(t){return t.map((e,r)=>[r,e])}function bp(t,e){let r=t.split(e);return[r[0],r.slice(1).join(e)]}function dUe(t){return Buffer.isBuffer(t)?t.length:Buffer.byteLength(t)}function SDt(){return new Mh({uri:Os.sdesMid})}function ADt(){return new Mh({uri:Os.sdesRTPStreamID})}function EDt(){return new Mh({uri:Os.repairedRtpStreamId})}function TDt(){return new Mh({uri:Os.transportWideCC})}function CDt(){return new Mh({uri:Os.absSendTime})}function kDt(){return new Mh({uri:Os.dependencyDescriptor})}function DDt(){return new Mh({uri:Os.audioLevelIndication})}function IDt(){return new Mh({uri:Os.videoOrientation})}function rs(t,...e){let r=e.filter(n=>n!==void 0);return`${t}_${r.join("_")}`}function qg(){return performance.now()}function qoe(t,e){let r=s=>s.toUpperCase(),n=s=>s.match(/(.{2})/g).join(":"),i=PDt(e).update(t).digest("hex");return n(r(i))}function zoe(t){return qDt[t.trim().toLowerCase()]}function pM(t){return t.replace(/[^0-9a-f]/gi,"").toLowerCase()}function TUe(t){let e=t[0];return e>19&&e<64}function zDt(t){return t==="recv"?"send":"recv"}function CUe(t){return t==="sendonly"?"recvonly":t==="recvonly"?"sendonly":t}function IUe(t){let e=c=>{if(!c)return;let[d,h]=c.split(":");return[d,Number.parseInt(h)]},r=e(t.find(({urls:c})=>c.includes("stun:"))?.urls.slice(5)),n=e(t.find(({urls:c})=>c.includes("turn:"))?.urls.slice(5)),{credential:i,username:s}=t.find(({urls:c})=>c.includes("turn:"))||{},a={stunServer:r,turnServer:n,turnUsername:s,turnPassword:i};return jDt("iceOptions",a),a}function qS(t){let e=new Koe(t.component,t.foundation,t.host,t.port,t.priority,t.transport,t.type,t.generation,t.ufrag);return e.relatedAddress=t.relatedAddress,e.relatedPort=t.relatedPort,e.tcpType=t.tcptype,e}function NUe(t){return new $g(t.foundation,t.component,t.protocol,t.priority,t.ip,t.port,t.type,t.relatedAddress,t.relatedPort,t.tcpType,t.generation,t.ufrag)}function r8(t){let e=t%4;return e?4-e:0}function nMe(t){let e=Buffer.from(""),r=Buffer.from("");return t.forEach(([n,i])=>{let s=i.length+4,a=Buffer.alloc(4);a.writeUInt16BE(n,0),a.writeUInt16BE(s,2),e=Buffer.concat([e,r,a,i]),r=Buffer.concat([...Array(r8(s))].map(()=>Buffer.from("\0")))}),e}function iMe(t){let e=[],r=0;for(;r<=t.length-4;){let n=t.readUInt16BE(r),i=t.readUInt16BE(r+2);e.push([n,t.slice(r+4,r+i)]),r+=i+r8(i)}return e}function g8t(t){if(t.length<12)throw new Error("SCTP packet length is less than 12 bytes");let e=t.readUInt16BE(0),r=t.readUInt16BE(2),n=t.readUInt32BE(4),i=t.readUInt32LE(8),s=uoe(Buffer.concat([t.slice(0,8),Buffer.from("\0\0\0\0"),t.slice(12)]));if(i!==s)throw new Error("SCTP packet has invalid checksum");let a=[],c=12;for(;c+4<=t.length;){let d=t.readUInt8(c),h=t.readUInt8(c+1),p=t.readUInt16BE(c+2),x=t.slice(c+4,c+p),y=m8t[d.toString()];if(y)a.push(new y(h,x));else throw new Error("unknown");c+=p+r8(p)}return[e,r,n,a]}function x8t(t,e,r,n){let i=Buffer.alloc(8);i.writeUInt16BE(t,0),i.writeUInt16BE(e,2),i.writeUInt32BE(r,4);let s=n.bytes,a=uoe(Buffer.concat([i,Buffer.from("\0\0\0\0"),s])),c=Buffer.alloc(4);return c.writeUInt32LE(a,0),Buffer.concat([i,c,s])}function y8t(t){return t.map((e,r)=>[r,e])}function v8t(t){return t.reduce((e,r)=>(e[r]=new yr,e),{})}function yv(t){return(t-1)%xM}function FS(t){return(t+1)%xM}function eae(t){let e=t.match(/^IN (IP4|IP6) ([^ ]+)$/);if(!e)throw new Error("exception");return e[2]}function noe(t){return`IN IP${e8t(t)?4:6} ${t}`}function Joe(t){let e=`${t.foundation} ${t.component} ${t.protocol} ${t.priority} ${t.ip} ${t.port} typ ${t.type}`;return t.relatedAddress!=null&&(e+=` raddr ${t.relatedAddress}`),t.relatedPort!=null&&(e+=` rport ${t.relatedPort}`),t.tcpType!=null&&(e+=` tcptype ${t.tcpType}`),t.generation!=null&&(e+=` generation ${t.generation}`),t.ufrag!=null&&(e+=` ufrag ${t.ufrag}`),e}function P8t(t){let e=[],r=[],n=t.split(`\r
1116
+ `),qD.prototype[t]=e.toFunction({assertSize:ise})});BRe.exports=qD;function ise(t,e){if(t>e)throw new Ykt(t,e)}});var Hs=L((Yir,HRe)=>{"use strict";var sse=MD(),Jkt=mRe(),Qkt=vRe(),e4t=_Re(),t4t=SRe(),r4t=TRe(),MRe=kRe(),n4t=IRe(),i4t=RRe(),{encode:jRe}=$D(),{decode:qRe}=dS(),{encodingLength:s4t}=jD(),a4t=URe(),zRe=fS(),WRe={array:Jkt,bool:e4t,buffer:Qkt,reserved:t4t,string:r4t,when:n4t,select:i4t};for(let t of Object.keys(MRe))WRe[t]=MRe[t];var hU=Symbol("schema");function LRe(t){let e=new sse({readableObjectMode:!1,writableObjectMode:!0,transform:o4t});return e[hU]=t,e}function $Re(t){let e=null,r=Buffer.isBuffer(t);r||(e=t);let n=new sse({transform:c4t,readableObjectMode:!0,writableObjectMode:!1});return n[hU]=e,r&&n.append(t),n}function o4t(t,e,r){try{jRe(t,this[hU],this);let n=this.slice();this.consume(n.length),r(null,n)}catch(n){r(n)}}function c4t(t,e,r){this.append(t);try{for(;this.length>0;){let n=new a4t(this),i=qRe(n,this[hU]);n.commit(),this.push(i)}r()}catch(n){n instanceof zRe?r():r(n)}}HRe.exports={createEncodeStream:LRe,createDecodeStream:$Re,encode:jRe,decode:qRe,encodingLength:s4t,createEncode:LRe,createDecode:$Re,types:WRe,BinaryStream:sse,NotEnoughDataError:zRe}});import*as rp from"node:crypto";var cv,VRe=ce(()=>{cv=rp&&typeof rp=="object"&&"webcrypto"in rp?rp.webcrypto:rp&&typeof rp=="object"&&"randomBytes"in rp?rp:void 0});function uv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zD(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Jf(t,...e){if(!uv(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function pU(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");zD(t.outputLen),zD(t.blockLen)}function pS(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function KRe(t,e){Jf(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ip(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function mU(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Qf(t,e){return t<<32-e|t>>>e}function sp(t){if(Jf(t),ZRe)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=u4t[t[r]];return e}function GRe(t){if(t>=np._0&&t<=np._9)return t-np._0;if(t>=np.A&&t<=np.F)return t-(np.A-10);if(t>=np.a&&t<=np.f)return t-(np.a-10)}function lv(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ZRe)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let a=GRe(t.charCodeAt(s)),c=GRe(t.charCodeAt(s+1));if(a===void 0||c===void 0){let d=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+s)}n[i]=a*16+c}return n}function XRe(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function WD(t){return typeof t=="string"&&(t=XRe(t)),Jf(t),t}function ed(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Jf(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function gU(t){let e=n=>t().update(WD(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function xU(t=32){if(cv&&typeof cv.getRandomValues=="function")return cv.getRandomValues(new Uint8Array(t));if(cv&&typeof cv.randomBytes=="function")return Uint8Array.from(cv.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}var ZRe,u4t,np,hS,fv=ce(()=>{VRe();ZRe=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",u4t=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));np={_0:48,_9:57,A:65,F:70,a:97,f:102};hS=class{}});function HD(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ag(t,e,r=""){let n=uv(t),i=t?.length,s=e!==void 0;if(!n||s&&i!==e){let a=r&&`"${r}" `,c=s?` of length ${e}`:"",d=n?`length=${i}`:`type=${typeof t}`;throw new Error(a+"expected Uint8Array"+c+", got "+d)}return t}function VD(t){let e=t.toString(16);return e.length&1?"0"+e:e}function YRe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?cse:BigInt("0x"+t)}function mS(t){return YRe(sp(t))}function use(t){return Jf(t),YRe(sp(Uint8Array.from(t).reverse()))}function yU(t,e){return lv(t.toString(16).padStart(e*2,"0"))}function lse(t,e){return yU(t,e).reverse()}function yc(t,e,r){let n;if(typeof e=="string")try{n=lv(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(uv(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function JRe(t,e,r){return ase(t)&&ase(e)&&ase(r)&&e<=t&&t<r}function QRe(t,e,r,n){if(!JRe(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function vU(t){let e;for(e=0;t>cse;t>>=ose,e+=1);return e}function e9e(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),i=v=>Uint8Array.of(v),s=n(t),a=n(t),c=0,d=()=>{s.fill(1),a.fill(0),c=0},h=(...v)=>r(a,s,...v),p=(v=n(0))=>{a=h(i(0),v),s=h(),v.length!==0&&(a=h(i(1),v),s=h())},x=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let v=0,w=[];for(;v<e;){s=h();let S=s.slice();w.push(S),v+=s.length}return ed(...w)};return(v,w)=>{d(),p(v);let S;for(;!(S=w(x()));)p();return d(),S}}function GD(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,a){let c=t[i];if(a&&c===void 0)return;let d=typeof c;if(d!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${d}`)}Object.entries(e).forEach(([i,s])=>n(i,s,!1)),Object.entries(r).forEach(([i,s])=>n(i,s,!0))}function fse(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}var cse,ose,ase,Eg,bU=ce(()=>{fv();fv();cse=BigInt(0),ose=BigInt(1);ase=t=>typeof t=="bigint"&&cse<=t;Eg=t=>(ose<<BigInt(t))-ose});function td(t,e){let r=t%e;return r>=Ru?r:e+r}function t9e(t,e){if(t===Ru)throw new Error("invert: expected non-zero number");if(e<=Ru)throw new Error("invert: expected positive modulus, got "+e);let r=td(t,e),n=e,i=Ru,s=vc,a=vc,c=Ru;for(;r!==Ru;){let h=n/r,p=n%r,x=i-a*h,y=s-c*h;n=r,r=p,i=a,s=c,a=x,c=y}if(n!==vc)throw new Error("invert: does not exist");return td(i,e)}function dse(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function c9e(t,e){let r=(t.ORDER+vc)/i9e,n=t.pow(e,r);return dse(t,n,e),n}function d4t(t,e){let r=(t.ORDER-s9e)/a9e,n=t.mul(e,dv),i=t.pow(n,r),s=t.mul(e,i),a=t.mul(t.mul(s,dv),i),c=t.mul(s,t.sub(a,t.ONE));return dse(t,c,e),c}function h4t(t){let e=Sh(t),r=u9e(t),n=r(e,e.neg(e.ONE)),i=r(e,n),s=r(e,e.neg(n)),a=(t+l4t)/o9e;return(c,d)=>{let h=c.pow(d,a),p=c.mul(h,n),x=c.mul(h,i),y=c.mul(h,s),v=c.eql(c.sqr(p),d),w=c.eql(c.sqr(x),d);h=c.cmov(h,p,v),p=c.cmov(y,x,w);let S=c.eql(c.sqr(p),d),C=c.cmov(h,p,S);return dse(c,C,d),C}}function u9e(t){if(t<n9e)throw new Error("sqrt is not defined for small field");let e=t-vc,r=0;for(;e%dv===Ru;)e/=dv,r++;let n=dv,i=Sh(t);for(;r9e(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return c9e;let s=i.pow(n,e),a=(e+vc)/dv;return function(d,h){if(d.is0(h))return h;if(r9e(d,h)!==1)throw new Error("Cannot find square root");let p=r,x=d.mul(d.ONE,s),y=d.pow(h,e),v=d.pow(h,a);for(;!d.eql(y,d.ONE);){if(d.is0(y))return d.ZERO;let w=1,S=d.sqr(y);for(;!d.eql(S,d.ONE);)if(w++,S=d.sqr(S),w===p)throw new Error("Cannot find square root");let C=vc<<BigInt(p-w-1),k=d.pow(x,C);p=w,x=d.sqr(k),y=d.mul(y,x),v=d.mul(v,k)}return v}}function p4t(t){return t%i9e===n9e?c9e:t%a9e===s9e?d4t:t%o9e===f4t?h4t(t):u9e(t)}function hse(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=m4t.reduce((n,i)=>(n[i]="function",n),e);return GD(t,r),t}function g4t(t,e,r){if(r<Ru)throw new Error("invalid exponent, negatives unsupported");if(r===Ru)return t.ONE;if(r===vc)return e;let n=t.ONE,i=e;for(;r>Ru;)r&vc&&(n=t.mul(n,i)),i=t.sqr(i),r>>=vc;return n}function _U(t,e,r=!1){let n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((a,c,d)=>t.is0(c)?a:(n[d]=a,t.mul(a,c)),t.ONE),s=t.inv(i);return e.reduceRight((a,c,d)=>t.is0(c)?a:(n[d]=t.mul(a,n[d]),t.mul(a,c)),s),n}function r9e(t,e){let r=(t.ORDER-vc)/dv,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),a=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function wU(t,e){e!==void 0&&zD(e);let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Sh(t,e,r=!1,n={}){if(t<=Ru)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,s,a=!1,c;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let y=e;y.BITS&&(i=y.BITS),y.sqrt&&(s=y.sqrt),typeof y.isLE=="boolean"&&(r=y.isLE),typeof y.modFromBytes=="boolean"&&(a=y.modFromBytes),c=y.allowedLengths}else typeof e=="number"&&(i=e),n.sqrt&&(s=n.sqrt);let{nBitLength:d,nByteLength:h}=wU(t,i);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let p,x=Object.freeze({ORDER:t,isLE:r,BITS:d,BYTES:h,MASK:Eg(d),ZERO:Ru,ONE:vc,allowedLengths:c,create:y=>td(y,t),isValid:y=>{if(typeof y!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof y);return Ru<=y&&y<t},is0:y=>y===Ru,isValidNot0:y=>!x.is0(y)&&x.isValid(y),isOdd:y=>(y&vc)===vc,neg:y=>td(-y,t),eql:(y,v)=>y===v,sqr:y=>td(y*y,t),add:(y,v)=>td(y+v,t),sub:(y,v)=>td(y-v,t),mul:(y,v)=>td(y*v,t),pow:(y,v)=>g4t(x,y,v),div:(y,v)=>td(y*t9e(v,t),t),sqrN:y=>y*y,addN:(y,v)=>y+v,subN:(y,v)=>y-v,mulN:(y,v)=>y*v,inv:y=>t9e(y,t),sqrt:s||(y=>(p||(p=p4t(t)),p(x,y))),toBytes:y=>r?lse(y,h):yU(y,h),fromBytes:(y,v=!0)=>{if(c){if(!c.includes(y.length)||y.length>h)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+y.length);let S=new Uint8Array(h);S.set(y,r?0:S.length-y.length),y=S}if(y.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+y.length);let w=r?use(y):mS(y);if(a&&(w=td(w,t)),!v&&!x.isValid(w))throw new Error("invalid field element: outside of range 0..ORDER");return w},invertBatch:y=>_U(x,y),cmov:(y,v,w)=>w?v:y});return Object.freeze(x)}function l9e(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function pse(t){let e=l9e(t);return e+Math.ceil(e/2)}function f9e(t,e,r=!1){let n=t.length,i=l9e(e),s=pse(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let a=r?use(t):mS(t),c=td(a,e-vc)+vc;return r?lse(c,i):yU(c,i)}var Ru,vc,dv,n9e,i9e,s9e,l4t,a9e,f4t,o9e,m4t,SU=ce(()=>{bU();Ru=BigInt(0),vc=BigInt(1),dv=BigInt(2),n9e=BigInt(3),i9e=BigInt(4),s9e=BigInt(5),l4t=BigInt(7),a9e=BigInt(8),f4t=BigInt(9),o9e=BigInt(16);m4t=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function x4t(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),c=Number(r&s),d=n?4:0,h=n?0:4;t.setUint32(e+d,a,n),t.setUint32(e+h,c,n)}function d9e(t,e,r){return t&e^~t&r}function h9e(t,e,r){return t&e^t&r^e&r}var KD,ap,Uo,Mo,p9e=ce(()=>{fv();KD=class extends hS{constructor(e,r,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=mU(this.buffer)}update(e){pS(this),e=WD(e),Jf(e);let{view:r,buffer:n,blockLen:i}=this,s=e.length;for(let a=0;a<s;){let c=Math.min(i-this.pos,s-a);if(c===i){let d=mU(e);for(;i<=s-a;a+=i)this.process(d,a);continue}n.set(e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pS(this),KRe(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:a}=this;r[a++]=128,ip(this.buffer.subarray(a)),this.padOffset>i-a&&(this.process(n,0),a=0);for(let x=a;x<i;x++)r[x]=0;x4t(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=mU(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=d/4,p=this.get();if(h>p.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x<h;x++)c.setUint32(4*x,p[x],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:a,pos:c}=this;return e.destroyed=a,e.finished=s,e.length=i,e.pos=c,i%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ap=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Uo=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Mo=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function y4t(t,e=!1){return e?{h:Number(t&AU),l:Number(t>>m9e&AU)}:{h:Number(t>>m9e&AU)|0,l:Number(t&AU)|0}}function g9e(t,e=!1){let r=t.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;s<r;s++){let{h:a,l:c}=y4t(t[s],e);[n[s],i[s]]=[a,c]}return[n,i]}function Ah(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var AU,m9e,mse,gse,hv,pv,ZD,XD,x9e,y9e,v9e,b9e,_9e,w9e,S9e=ce(()=>{AU=BigInt(4294967295),m9e=BigInt(32);mse=(t,e,r)=>t>>>r,gse=(t,e,r)=>t<<32-r|e>>>r,hv=(t,e,r)=>t>>>r|e<<32-r,pv=(t,e,r)=>t<<32-r|e>>>r,ZD=(t,e,r)=>t<<64-r|e>>>r-32,XD=(t,e,r)=>t>>>r-32|e<<64-r;x9e=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),y9e=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,v9e=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),b9e=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,_9e=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),w9e=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0});var b4t,Tg,xse,A9e,_4t,w4t,Cg,kg,EU,yse,E9e,T9e,C9e,k9e=ce(()=>{p9e();S9e();fv();b4t=Uint32Array.from([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]),Tg=new Uint32Array(64),xse=class extends KD{constructor(e=32){super(64,e,8,!1),this.A=ap[0]|0,this.B=ap[1]|0,this.C=ap[2]|0,this.D=ap[3]|0,this.E=ap[4]|0,this.F=ap[5]|0,this.G=ap[6]|0,this.H=ap[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:a,G:c,H:d}=this;return[e,r,n,i,s,a,c,d]}set(e,r,n,i,s,a,c,d){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=a|0,this.G=c|0,this.H=d|0}process(e,r){for(let x=0;x<16;x++,r+=4)Tg[x]=e.getUint32(r,!1);for(let x=16;x<64;x++){let y=Tg[x-15],v=Tg[x-2],w=Qf(y,7)^Qf(y,18)^y>>>3,S=Qf(v,17)^Qf(v,19)^v>>>10;Tg[x]=S+Tg[x-7]+w+Tg[x-16]|0}let{A:n,B:i,C:s,D:a,E:c,F:d,G:h,H:p}=this;for(let x=0;x<64;x++){let y=Qf(c,6)^Qf(c,11)^Qf(c,25),v=p+y+d9e(c,d,h)+b4t[x]+Tg[x]|0,S=(Qf(n,2)^Qf(n,13)^Qf(n,22))+h9e(n,i,s)|0;p=h,h=d,d=c,c=a+v|0,a=s,s=i,i=n,n=v+S|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,d=d+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(n,i,s,a,c,d,h,p)}roundClean(){ip(Tg)}destroy(){this.set(0,0,0,0,0,0,0,0),ip(this.buffer)}},A9e=g9e(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),_4t=A9e[0],w4t=A9e[1],Cg=new Uint32Array(80),kg=new Uint32Array(80),EU=class extends KD{constructor(e=64){super(128,e,16,!1),this.Ah=Mo[0]|0,this.Al=Mo[1]|0,this.Bh=Mo[2]|0,this.Bl=Mo[3]|0,this.Ch=Mo[4]|0,this.Cl=Mo[5]|0,this.Dh=Mo[6]|0,this.Dl=Mo[7]|0,this.Eh=Mo[8]|0,this.El=Mo[9]|0,this.Fh=Mo[10]|0,this.Fl=Mo[11]|0,this.Gh=Mo[12]|0,this.Gl=Mo[13]|0,this.Hh=Mo[14]|0,this.Hl=Mo[15]|0}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:d,Eh:h,El:p,Fh:x,Fl:y,Gh:v,Gl:w,Hh:S,Hl:C}=this;return[e,r,n,i,s,a,c,d,h,p,x,y,v,w,S,C]}set(e,r,n,i,s,a,c,d,h,p,x,y,v,w,S,C){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=a|0,this.Dh=c|0,this.Dl=d|0,this.Eh=h|0,this.El=p|0,this.Fh=x|0,this.Fl=y|0,this.Gh=v|0,this.Gl=w|0,this.Hh=S|0,this.Hl=C|0}process(e,r){for(let E=0;E<16;E++,r+=4)Cg[E]=e.getUint32(r),kg[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let I=Cg[E-15]|0,R=kg[E-15]|0,U=hv(I,R,1)^hv(I,R,8)^mse(I,R,7),B=pv(I,R,1)^pv(I,R,8)^gse(I,R,7),z=Cg[E-2]|0,K=kg[E-2]|0,Ae=hv(z,K,19)^ZD(z,K,61)^mse(z,K,6),de=pv(z,K,19)^XD(z,K,61)^gse(z,K,6),te=v9e(B,de,kg[E-7],kg[E-16]),Q=b9e(te,U,Ae,Cg[E-7],Cg[E-16]);Cg[E]=Q|0,kg[E]=te|0}let{Ah:n,Al:i,Bh:s,Bl:a,Ch:c,Cl:d,Dh:h,Dl:p,Eh:x,El:y,Fh:v,Fl:w,Gh:S,Gl:C,Hh:k,Hl:T}=this;for(let E=0;E<80;E++){let I=hv(x,y,14)^hv(x,y,18)^ZD(x,y,41),R=pv(x,y,14)^pv(x,y,18)^XD(x,y,41),U=x&v^~x&S,B=y&w^~y&C,z=_9e(T,R,B,w4t[E],kg[E]),K=w9e(z,k,I,U,_4t[E],Cg[E]),Ae=z|0,de=hv(n,i,28)^ZD(n,i,34)^ZD(n,i,39),te=pv(n,i,28)^XD(n,i,34)^XD(n,i,39),Q=n&s^n&c^s&c,ee=i&a^i&d^a&d;k=S|0,T=C|0,S=v|0,C=w|0,v=x|0,w=y|0,{h:x,l:y}=Ah(h|0,p|0,K|0,Ae|0),h=c|0,p=d|0,c=s|0,d=a|0,s=n|0,a=i|0;let pe=x9e(Ae,te,ee);n=y9e(pe,K,de,Q),i=pe|0}({h:n,l:i}=Ah(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:a}=Ah(this.Bh|0,this.Bl|0,s|0,a|0),{h:c,l:d}=Ah(this.Ch|0,this.Cl|0,c|0,d|0),{h,l:p}=Ah(this.Dh|0,this.Dl|0,h|0,p|0),{h:x,l:y}=Ah(this.Eh|0,this.El|0,x|0,y|0),{h:v,l:w}=Ah(this.Fh|0,this.Fl|0,v|0,w|0),{h:S,l:C}=Ah(this.Gh|0,this.Gl|0,S|0,C|0),{h:k,l:T}=Ah(this.Hh|0,this.Hl|0,k|0,T|0),this.set(n,i,s,a,c,d,h,p,x,y,v,w,S,C,k,T)}roundClean(){ip(Cg,kg)}destroy(){ip(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},yse=class extends EU{constructor(){super(48),this.Ah=Uo[0]|0,this.Al=Uo[1]|0,this.Bh=Uo[2]|0,this.Bl=Uo[3]|0,this.Ch=Uo[4]|0,this.Cl=Uo[5]|0,this.Dh=Uo[6]|0,this.Dl=Uo[7]|0,this.Eh=Uo[8]|0,this.El=Uo[9]|0,this.Fh=Uo[10]|0,this.Fl=Uo[11]|0,this.Gh=Uo[12]|0,this.Gl=Uo[13]|0,this.Hh=Uo[14]|0,this.Hl=Uo[15]|0}},E9e=gU(()=>new xse),T9e=gU(()=>new EU),C9e=gU(()=>new yse)});var TU,vse,D9e=ce(()=>{fv();TU=class extends hS{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,pU(e);let n=WD(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let a=0;a<s.length;a++)s[a]^=54;this.iHash.update(s),this.oHash=e.create();for(let a=0;a<s.length;a++)s[a]^=106;this.oHash.update(s),ip(s)}update(e){return pS(this),this.iHash.update(e),this}digestInto(e){pS(this),Jf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:s,blockLen:a,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=a,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vse=(t,e,r)=>new TU(t,e).update(r).digest();vse.create=(t,e)=>new TU(t,e)});function YD(t,e){let r=e.negate();return t?r:e}function kU(t,e){let r=_U(t.Fp,e.map(n=>n.Z));return e.map((n,i)=>t.fromAffine(n.toAffine(r[i])))}function R9e(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function bse(t,e){R9e(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),i=2**t,s=Eg(t),a=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:i,shiftBy:a}}function I9e(t,e,r){let{windowSize:n,mask:i,maxNumber:s,shiftBy:a}=r,c=Number(t&i),d=t>>a;c>n&&(c-=s,d+=mv);let h=e*n,p=h+Math.abs(c)-1,x=c===0,y=c<0,v=e%2!==0;return{nextN:d,offset:p,isZero:x,isNeg:y,isNegF:v,offsetF:h}}function S4t(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function A4t(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}function wse(t){return O9e.get(t)||1}function F9e(t){if(t!==gS)throw new Error("invalid wNAF")}function N9e(t,e,r,n){let i=e,s=t.ZERO,a=t.ZERO;for(;r>gS||n>gS;)r&mv&&(s=s.add(i)),n&mv&&(a=a.add(i)),i=i.double(),r>>=mv,n>>=mv;return{p1:s,p2:a}}function B9e(t,e,r,n){S4t(r,t),A4t(n,e);let i=r.length,s=n.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");let a=t.ZERO,c=vU(BigInt(i)),d=1;c>12?d=c-3:c>4?d=c-2:c>0&&(d=2);let h=Eg(d),p=new Array(Number(h)+1).fill(a),x=Math.floor((e.BITS-1)/d)*d,y=a;for(let v=x;v>=0;v-=d){p.fill(a);for(let S=0;S<s;S++){let C=n[S],k=Number(C>>BigInt(v)&h);p[k]=p[k].add(r[S])}let w=a;for(let S=p.length-1,C=a;S>0;S--)C=C.add(p[S]),w=w.add(C);if(y=y.add(w),v!==0)for(let S=0;S<d;S++)y=y.double()}return y}function P9e(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return hse(e),e}else return Sh(t,{isLE:r})}function U9e(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let d of["p","n","h"]){let h=e[d];if(!(typeof h=="bigint"&&h>gS))throw new Error(`CURVE.${d} must be positive bigint`)}let i=P9e(e.p,r.Fp,n),s=P9e(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let d of c)if(!i.isValid(e[d]))throw new Error(`CURVE.${d} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:s}}var gS,mv,_se,O9e,CU,M9e=ce(()=>{bU();SU();gS=BigInt(0),mv=BigInt(1);_se=new WeakMap,O9e=new WeakMap;CU=class{constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let i=e;for(;r>gS;)r&mv&&(n=n.add(i)),i=i.double(),r>>=mv;return n}precomputeWindow(e,r){let{windows:n,windowSize:i}=bse(r,this.bits),s=[],a=e,c=a;for(let d=0;d<n;d++){c=a,s.push(c);for(let h=1;h<i;h++)c=c.add(a),s.push(c);a=c.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,s=this.BASE,a=bse(e,this.bits);for(let c=0;c<a.windows;c++){let{nextN:d,offset:h,isZero:p,isNeg:x,isNegF:y,offsetF:v}=I9e(n,c,a);n=d,p?s=s.add(YD(y,r[v])):i=i.add(YD(x,r[h]))}return F9e(n),{p:i,f:s}}wNAFUnsafe(e,r,n,i=this.ZERO){let s=bse(e,this.bits);for(let a=0;a<s.windows&&n!==gS;a++){let{nextN:c,offset:d,isZero:h,isNeg:p}=I9e(n,a,s);if(n=c,!h){let x=r[d];i=i.add(p?x.negate():x)}}return F9e(n),i}getPrecomputes(e,r,n){let i=_se.get(r);return i||(i=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(i=n(i)),_se.set(r,i))),i}cached(e,r,n){let i=wse(e);return this.wNAF(i,this.getPrecomputes(i,e,n),r)}unsafe(e,r,n,i){let s=wse(e);return s===1?this._unsafeLadder(e,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,i)}createCache(e,r){R9e(r,this.bits),O9e.set(e,r),_se.delete(e)}hasCache(e){return wse(e)!==1}}});function E4t(t,e,r){let[[n,i],[s,a]]=e,c=L9e(a*t,r),d=L9e(-i*t,r),h=t-c*n-d*s,p=-c*i-d*a,x=h<cp,y=p<cp;x&&(h=-h),y&&(p=-p);let v=Eg(Math.ceil(vU(r)/2))+yS;if(h<cp||h>=v||p<cp||p>=v)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:x,k1:h,k2neg:y,k2:p}}function Ase(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Sse(t,e){let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return HD(r.lowS,"lowS"),HD(r.prehash,"prehash"),r.format!==void 0&&Ase(r.format),r}function xS(t,e){let{BYTES:r}=t,n;if(typeof e=="bigint")n=e;else{let i=yc("private key",e);try{n=t.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function C4t(t,e={}){let r=U9e("weierstrass",t,e),{Fp:n,Fn:i}=r,s=r.CURVE,{h:a,n:c}=s;GD(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:d}=e;if(d&&(!n.is0(s.a)||typeof d.beta!="bigint"||!Array.isArray(d.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let h=q9e(n,i);function p(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function x(te,Q,ee){let{x:pe,y:H}=Q.toAffine(),oe=n.toBytes(pe);if(HD(ee,"isCompressed"),ee){p();let X=!n.isOdd(H);return ed(j9e(X),oe)}else return ed(Uint8Array.of(4),oe,n.toBytes(H))}function y(te){Ag(te,void 0,"Point");let{publicKey:Q,publicKeyUncompressed:ee}=h,pe=te.length,H=te[0],oe=te.subarray(1);if(pe===Q&&(H===2||H===3)){let X=n.fromBytes(oe);if(!n.isValid(X))throw new Error("bad point: is not on curve, wrong x");let N=S(X),Z;try{Z=n.sqrt(N)}catch(se){let Se=se instanceof Error?": "+se.message:"";throw new Error("bad point: is not on curve, sqrt error"+Se)}p();let ae=n.isOdd(Z);return(H&1)===1!==ae&&(Z=n.neg(Z)),{x:X,y:Z}}else if(pe===ee&&H===4){let X=n.BYTES,N=n.fromBytes(oe.subarray(0,X)),Z=n.fromBytes(oe.subarray(X,X*2));if(!C(N,Z))throw new Error("bad point: is not on curve");return{x:N,y:Z}}else throw new Error(`bad point: got length ${pe}, expected compressed=${Q} or uncompressed=${ee}`)}let v=e.toBytes||x,w=e.fromBytes||y;function S(te){let Q=n.sqr(te),ee=n.mul(Q,te);return n.add(n.add(ee,n.mul(te,s.a)),s.b)}function C(te,Q){let ee=n.sqr(Q),pe=S(te);return n.eql(ee,pe)}if(!C(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let k=n.mul(n.pow(s.a,DU),T4t),T=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(k,T)))throw new Error("bad curve params: a or b");function E(te,Q,ee=!1){if(!n.isValid(Q)||ee&&n.is0(Q))throw new Error(`bad point coordinate ${te}`);return Q}function I(te){if(!(te instanceof K))throw new Error("ProjectivePoint expected")}function R(te){if(!d||!d.basises)throw new Error("no endo");return E4t(te,d.basises,i.ORDER)}let U=fse((te,Q)=>{let{X:ee,Y:pe,Z:H}=te;if(n.eql(H,n.ONE))return{x:ee,y:pe};let oe=te.is0();Q==null&&(Q=oe?n.ONE:n.inv(H));let X=n.mul(ee,Q),N=n.mul(pe,Q),Z=n.mul(H,Q);if(oe)return{x:n.ZERO,y:n.ZERO};if(!n.eql(Z,n.ONE))throw new Error("invZ was invalid");return{x:X,y:N}}),B=fse(te=>{if(te.is0()){if(e.allowInfinityPoint&&!n.is0(te.Y))return;throw new Error("bad point: ZERO")}let{x:Q,y:ee}=te.toAffine();if(!n.isValid(Q)||!n.isValid(ee))throw new Error("bad point: x or y not field elements");if(!C(Q,ee))throw new Error("bad point: equation left != right");if(!te.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function z(te,Q,ee,pe,H){return ee=new K(n.mul(ee.X,te),ee.Y,ee.Z),Q=YD(pe,Q),ee=YD(H,ee),Q.add(ee)}class K{constructor(Q,ee,pe){this.X=E("x",Q),this.Y=E("y",ee,!0),this.Z=E("z",pe),Object.freeze(this)}static CURVE(){return s}static fromAffine(Q){let{x:ee,y:pe}=Q||{};if(!Q||!n.isValid(ee)||!n.isValid(pe))throw new Error("invalid affine point");if(Q instanceof K)throw new Error("projective point not allowed");return n.is0(ee)&&n.is0(pe)?K.ZERO:new K(ee,pe,n.ONE)}static fromBytes(Q){let ee=K.fromAffine(w(Ag(Q,void 0,"point")));return ee.assertValidity(),ee}static fromHex(Q){return K.fromBytes(yc("pointHex",Q))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Q=8,ee=!0){return de.createCache(this,Q),ee||this.multiply(DU),this}assertValidity(){B(this)}hasEvenY(){let{y:Q}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(Q)}equals(Q){I(Q);let{X:ee,Y:pe,Z:H}=this,{X:oe,Y:X,Z:N}=Q,Z=n.eql(n.mul(ee,N),n.mul(oe,H)),ae=n.eql(n.mul(pe,N),n.mul(X,H));return Z&&ae}negate(){return new K(this.X,n.neg(this.Y),this.Z)}double(){let{a:Q,b:ee}=s,pe=n.mul(ee,DU),{X:H,Y:oe,Z:X}=this,N=n.ZERO,Z=n.ZERO,ae=n.ZERO,J=n.mul(H,H),se=n.mul(oe,oe),Se=n.mul(X,X),fe=n.mul(H,oe);return fe=n.add(fe,fe),ae=n.mul(H,X),ae=n.add(ae,ae),N=n.mul(Q,ae),Z=n.mul(pe,Se),Z=n.add(N,Z),N=n.sub(se,Z),Z=n.add(se,Z),Z=n.mul(N,Z),N=n.mul(fe,N),ae=n.mul(pe,ae),Se=n.mul(Q,Se),fe=n.sub(J,Se),fe=n.mul(Q,fe),fe=n.add(fe,ae),ae=n.add(J,J),J=n.add(ae,J),J=n.add(J,Se),J=n.mul(J,fe),Z=n.add(Z,J),Se=n.mul(oe,X),Se=n.add(Se,Se),J=n.mul(Se,fe),N=n.sub(N,J),ae=n.mul(Se,se),ae=n.add(ae,ae),ae=n.add(ae,ae),new K(N,Z,ae)}add(Q){I(Q);let{X:ee,Y:pe,Z:H}=this,{X:oe,Y:X,Z:N}=Q,Z=n.ZERO,ae=n.ZERO,J=n.ZERO,se=s.a,Se=n.mul(s.b,DU),fe=n.mul(ee,oe),ze=n.mul(pe,X),Ue=n.mul(H,N),Ft=n.add(ee,pe),Ht=n.add(oe,X);Ft=n.mul(Ft,Ht),Ht=n.add(fe,ze),Ft=n.sub(Ft,Ht),Ht=n.add(ee,H);let Xe=n.add(oe,N);return Ht=n.mul(Ht,Xe),Xe=n.add(fe,Ue),Ht=n.sub(Ht,Xe),Xe=n.add(pe,H),Z=n.add(X,N),Xe=n.mul(Xe,Z),Z=n.add(ze,Ue),Xe=n.sub(Xe,Z),J=n.mul(se,Ht),Z=n.mul(Se,Ue),J=n.add(Z,J),Z=n.sub(ze,J),J=n.add(ze,J),ae=n.mul(Z,J),ze=n.add(fe,fe),ze=n.add(ze,fe),Ue=n.mul(se,Ue),Ht=n.mul(Se,Ht),ze=n.add(ze,Ue),Ue=n.sub(fe,Ue),Ue=n.mul(se,Ue),Ht=n.add(Ht,Ue),fe=n.mul(ze,Ht),ae=n.add(ae,fe),fe=n.mul(Xe,Ht),Z=n.mul(Ft,Z),Z=n.sub(Z,fe),fe=n.mul(Ft,ze),J=n.mul(Xe,J),J=n.add(J,fe),new K(Z,ae,J)}subtract(Q){return this.add(Q.negate())}is0(){return this.equals(K.ZERO)}multiply(Q){let{endo:ee}=e;if(!i.isValidNot0(Q))throw new Error("invalid scalar: out of range");let pe,H,oe=X=>de.cached(this,X,N=>kU(K,N));if(ee){let{k1neg:X,k1:N,k2neg:Z,k2:ae}=R(Q),{p:J,f:se}=oe(N),{p:Se,f:fe}=oe(ae);H=se.add(fe),pe=z(ee.beta,J,Se,X,Z)}else{let{p:X,f:N}=oe(Q);pe=X,H=N}return kU(K,[pe,H])[0]}multiplyUnsafe(Q){let{endo:ee}=e,pe=this;if(!i.isValid(Q))throw new Error("invalid scalar: out of range");if(Q===cp||pe.is0())return K.ZERO;if(Q===yS)return pe;if(de.hasCache(this))return this.multiply(Q);if(ee){let{k1neg:H,k1:oe,k2neg:X,k2:N}=R(Q),{p1:Z,p2:ae}=N9e(K,pe,oe,N);return z(ee.beta,Z,ae,H,X)}else return de.unsafe(pe,Q)}multiplyAndAddUnsafe(Q,ee,pe){let H=this.multiplyUnsafe(ee).add(Q.multiplyUnsafe(pe));return H.is0()?void 0:H}toAffine(Q){return U(this,Q)}isTorsionFree(){let{isTorsionFree:Q}=e;return a===yS?!0:Q?Q(K,this):de.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:Q}=e;return a===yS?this:Q?Q(K,this):this.multiplyUnsafe(a)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}toBytes(Q=!0){return HD(Q,"isCompressed"),this.assertValidity(),v(K,this,Q)}toHex(Q=!0){return sp(this.toBytes(Q))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Q=!0){return this.toBytes(Q)}_setWindowSize(Q){this.precompute(Q)}static normalizeZ(Q){return kU(K,Q)}static msm(Q,ee){return B9e(K,i,Q,ee)}static fromPrivateKey(Q){return K.BASE.multiply(xS(i,Q))}}K.BASE=new K(s.Gx,s.Gy,n.ONE),K.ZERO=new K(n.ZERO,n.ONE,n.ZERO),K.Fp=n,K.Fn=i;let Ae=i.BITS,de=new CU(K,e.endo?Math.ceil(Ae/2):Ae);return K.BASE.precompute(8),K}function j9e(t){return Uint8Array.of(t?2:3)}function q9e(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function k4t(t,e={}){let{Fn:r}=t,n=e.randomBytes||xU,i=Object.assign(q9e(t.Fp,r),{seed:pse(r.ORDER)});function s(v){try{return!!xS(r,v)}catch{return!1}}function a(v,w){let{publicKey:S,publicKeyUncompressed:C}=i;try{let k=v.length;return w===!0&&k!==S||w===!1&&k!==C?!1:!!t.fromBytes(v)}catch{return!1}}function c(v=n(i.seed)){return f9e(Ag(v,i.seed,"seed"),r.ORDER)}function d(v,w=!0){return t.BASE.multiply(xS(r,v)).toBytes(w)}function h(v){let w=c(v);return{secretKey:w,publicKey:d(w)}}function p(v){if(typeof v=="bigint")return!1;if(v instanceof t)return!0;let{secretKey:w,publicKey:S,publicKeyUncompressed:C}=i;if(r.allowedLengths||w===S)return;let k=yc("key",v).length;return k===S||k===C}function x(v,w,S=!0){if(p(v)===!0)throw new Error("first arg must be private key");if(p(w)===!1)throw new Error("second arg must be public key");let C=xS(r,v);return t.fromHex(w).multiply(C).toBytes(S)}return Object.freeze({getPublicKey:d,getSharedSecret:x,keygen:h,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:a,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:v=>xS(r,v),precompute(v=8,w=t.BASE){return w.precompute(v,!1)}},lengths:i})}function D4t(t,e,r={}){pU(e),GD(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||xU,i=r.hmac||((ee,...pe)=>vse(e,ee,ed(...pe))),{Fp:s,Fn:a}=t,{ORDER:c,BITS:d}=a,{keygen:h,getPublicKey:p,getSharedSecret:x,utils:y,lengths:v}=k4t(t,r),w={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},S="compact";function C(ee){let pe=c>>yS;return ee>pe}function k(ee,pe){if(!a.isValidNot0(pe))throw new Error(`invalid signature ${ee}: out of range 1..Point.Fn.ORDER`);return pe}function T(ee,pe){Ase(pe);let H=v.signature,oe=pe==="compact"?H:pe==="recovered"?H+1:void 0;return Ag(ee,oe,`${pe} signature`)}class E{constructor(pe,H,oe){this.r=k("r",pe),this.s=k("s",H),oe!=null&&(this.recovery=oe),Object.freeze(this)}static fromBytes(pe,H=S){T(pe,H);let oe;if(H==="der"){let{r:ae,s:J}=op.toSig(Ag(pe));return new E(ae,J)}H==="recovered"&&(oe=pe[0],H="compact",pe=pe.subarray(1));let X=a.BYTES,N=pe.subarray(0,X),Z=pe.subarray(X,X*2);return new E(a.fromBytes(N),a.fromBytes(Z),oe)}static fromHex(pe,H){return this.fromBytes(lv(pe),H)}addRecoveryBit(pe){return new E(this.r,this.s,pe)}recoverPublicKey(pe){let H=s.ORDER,{r:oe,s:X,recovery:N}=this;if(N==null||![0,1,2,3].includes(N))throw new Error("recovery id invalid");if(c*$9e<H&&N>1)throw new Error("recovery id is ambiguous for h>1 curve");let ae=N===2||N===3?oe+c:oe;if(!s.isValid(ae))throw new Error("recovery id 2 or 3 invalid");let J=s.toBytes(ae),se=t.fromBytes(ed(j9e((N&1)===0),J)),Se=a.inv(ae),fe=R(yc("msgHash",pe)),ze=a.create(-fe*Se),Ue=a.create(X*Se),Ft=t.BASE.multiplyUnsafe(ze).add(se.multiplyUnsafe(Ue));if(Ft.is0())throw new Error("point at infinify");return Ft.assertValidity(),Ft}hasHighS(){return C(this.s)}toBytes(pe=S){if(Ase(pe),pe==="der")return lv(op.hexFromSig(this));let H=a.toBytes(this.r),oe=a.toBytes(this.s);if(pe==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return ed(Uint8Array.of(this.recovery),H,oe)}return ed(H,oe)}toHex(pe){return sp(this.toBytes(pe))}assertValidity(){}static fromCompact(pe){return E.fromBytes(yc("sig",pe),"compact")}static fromDER(pe){return E.fromBytes(yc("sig",pe),"der")}normalizeS(){return this.hasHighS()?new E(this.r,a.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return sp(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return sp(this.toBytes("compact"))}}let I=r.bits2int||function(pe){if(pe.length>8192)throw new Error("input is too large");let H=mS(pe),oe=pe.length*8-d;return oe>0?H>>BigInt(oe):H},R=r.bits2int_modN||function(pe){return a.create(I(pe))},U=Eg(d);function B(ee){return QRe("num < 2^"+d,ee,cp,U),a.toBytes(ee)}function z(ee,pe){return Ag(ee,void 0,"message"),pe?Ag(e(ee),void 0,"prehashed message"):ee}function K(ee,pe,H){if(["recovered","canonical"].some(ze=>ze in H))throw new Error("sign() legacy options not supported");let{lowS:oe,prehash:X,extraEntropy:N}=Sse(H,w);ee=z(ee,X);let Z=R(ee),ae=xS(a,pe),J=[B(ae),B(Z)];if(N!=null&&N!==!1){let ze=N===!0?n(v.secretKey):N;J.push(yc("extraEntropy",ze))}let se=ed(...J),Se=Z;function fe(ze){let Ue=I(ze);if(!a.isValidNot0(Ue))return;let Ft=a.inv(Ue),Ht=t.BASE.multiply(Ue).toAffine(),Xe=a.create(Ht.x);if(Xe===cp)return;let lr=a.create(Ft*a.create(Se+Xe*ae));if(lr===cp)return;let Ce=(Ht.x===Xe?0:2)|Number(Ht.y&yS),pt=lr;return oe&&C(lr)&&(pt=a.neg(lr),Ce^=1),new E(Xe,pt,Ce)}return{seed:se,k2sig:fe}}function Ae(ee,pe,H={}){ee=yc("message",ee);let{seed:oe,k2sig:X}=K(ee,pe,H);return e9e(e.outputLen,a.BYTES,i)(oe,X)}function de(ee){let pe,H=typeof ee=="string"||uv(ee),oe=!H&&ee!==null&&typeof ee=="object"&&typeof ee.r=="bigint"&&typeof ee.s=="bigint";if(!H&&!oe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(oe)pe=new E(ee.r,ee.s);else if(H){try{pe=E.fromBytes(yc("sig",ee),"der")}catch(X){if(!(X instanceof op.Err))throw X}if(!pe)try{pe=E.fromBytes(yc("sig",ee),"compact")}catch{return!1}}return pe||!1}function te(ee,pe,H,oe={}){let{lowS:X,prehash:N,format:Z}=Sse(oe,w);if(H=yc("publicKey",H),pe=z(yc("message",pe),N),"strict"in oe)throw new Error("options.strict was renamed to lowS");let ae=Z===void 0?de(ee):E.fromBytes(yc("sig",ee),Z);if(ae===!1)return!1;try{let J=t.fromBytes(H);if(X&&ae.hasHighS())return!1;let{r:se,s:Se}=ae,fe=R(pe),ze=a.inv(Se),Ue=a.create(fe*ze),Ft=a.create(se*ze),Ht=t.BASE.multiplyUnsafe(Ue).add(J.multiplyUnsafe(Ft));return Ht.is0()?!1:a.create(Ht.x)===se}catch{return!1}}function Q(ee,pe,H={}){let{prehash:oe}=Sse(H,w);return pe=z(pe,oe),E.fromBytes(ee,"recovered").recoverPublicKey(pe).toBytes()}return Object.freeze({keygen:h,getPublicKey:p,getSharedSecret:x,utils:y,lengths:v,Point:t,sign:Ae,verify:te,recoverPublicKey:Q,Signature:E,hash:e})}function I4t(t){let e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp,n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(a=>Math.ceil(a/2)))):void 0,i=Sh(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),s={Fp:r,Fn:i,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:s}}function F4t(t){let{CURVE:e,curveOpts:r}=I4t(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}function P4t(t,e){let r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,wU(r.Fn.ORDER,r.Fn.BITS))})}function z9e(t){let{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:i}=F4t(t),s=C4t(e,r),a=D4t(s,n,i);return P4t(t,a)}var L9e,Ese,op,cp,yS,$9e,DU,T4t,W9e=ce(()=>{D9e();fv();bU();M9e();SU();L9e=(t,e)=>(t+(t>=0?e:-e)/$9e)/e;Ese=class extends Error{constructor(e=""){super(e)}},op={Err:Ese,_tlv:{encode:(t,e)=>{let{Err:r}=op;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=VD(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?VD(i.length/2|128):"";return VD(t)+s+i+e},decode(t,e){let{Err:r}=op,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),a=0;if(!s)a=i;else{let d=i&127;if(!d)throw new r("tlv.decode(long): indefinite length not supported");if(d>4)throw new r("tlv.decode(long): byte length is too big");let h=e.subarray(n,n+d);if(h.length!==d)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of h)a=a<<8|p;if(n+=d,a<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+a);if(c.length!==a)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+a)}}},_int:{encode(t){let{Err:e}=op;if(t<cp)throw new e("integer: negative integers are not allowed");let r=VD(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=op;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return mS(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=op,i=yc("signature",t),{v:s,l:a}=n.decode(48,i);if(a.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:d}=n.decode(2,s),{v:h,l:p}=n.decode(2,d);if(p.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(h)}},hexFromSig(t){let{_tlv:e,_int:r}=op,n=e.encode(2,r.encode(t.r)),i=e.encode(2,r.encode(t.s)),s=n+i;return e.encode(48,s)}},cp=BigInt(0),yS=BigInt(1),$9e=BigInt(2),DU=BigInt(3),T4t=BigInt(4)});function IU(t,e){let r=n=>z9e({...t,hash:n});return{...r(e),create:r}}var H9e=ce(()=>{W9e();});var V9e,G9e,K9e,R4t,O4t,N4t,Z9e,Isr,Fsr,X9e=ce(()=>{k9e();H9e();SU();V9e={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},G9e={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},K9e={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},R4t=Sh(V9e.p),O4t=Sh(G9e.p),N4t=Sh(K9e.p),Z9e=IU({...V9e,Fp:R4t,lowS:!1},E9e),Isr=IU({...G9e,Fp:O4t,lowS:!1},C9e),Fsr=IU({...K9e,Fp:N4t,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},T9e)});var FU,Y9e=ce(()=>{X9e();FU=Z9e});var Q9e=L(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0});Dg.LEB128=Dg.SignedLEB128=Dg.UnsignedLEB128=void 0;var vS;(function(t){t[t.LOWER_7=127]="LOWER_7",t[t.UPPER_1=128]="UPPER_1"})(vS||(vS={}));var J9e=t=>Number.isSafeInteger(t),gv=class{static decode(e,r=0){let n=this.$scanForNullBytes(e,r),i=0,s=0;for(let a=0;a<=n-r;a++){let c=e[r+a]&vS.LOWER_7;i|=c<<s,s+=7}return i}static encode(e){if(this.check(e),e<0)throw new Error(`An unsigned number must NOT be negative, ${e} is!`);let r=[],n=e;do{let i=n&vS.LOWER_7;n>>=7,n&&(i=i|vS.UPPER_1),r.push(i)}while(n);return Uint8Array.from(r)}static check(e){if(!J9e(e))throw new Error(`${e} is not a safe integer!`)}static $scanForNullBytes(e,r=0){let n=r,i=0;do{if(n>=e.byteLength)throw new Error("This is not a LEB128-encoded Uint8Array, no ending found!");i=e.slice(n,n+1)[0],n++}while(i&vS.UPPER_1);return n-1}static getLength(e,r=0){return this.$scanForNullBytes(e,r)-r}};Dg.UnsignedLEB128=gv;var JD=class{static $ceil7mul(e){let r=e;for(;r%7;)r++;return r}static check(e){if(!J9e(e))throw new Error(`${e} is not a safe integer!`)}static encode(e){if(this.check(e),e>=0)throw new Error(`A signed number must be negative, ${e} isn't!`);let r=Math.ceil(Math.log2(-e));return gv.encode((1<<this.$ceil7mul(r))+e)}static decode(e,r=0){let n=gv.decode(e,r);return-((1<<Math.ceil(Math.log2(n)))-n)}};Dg.SignedLEB128=JD;var QD=class{};Dg.LEB128=QD;QD.encode=t=>(t>=0?gv:JD).encode(t);QD.decode=(t,e=0,r=!1)=>(r?JD:gv).decode(t,e)});var tOe=L((Tse,eOe)=>{(function(t){"use strict";function e(N){return parseInt(N)===N}function r(N){if(!e(N.length))return!1;for(var Z=0;Z<N.length;Z++)if(!e(N[Z])||N[Z]<0||N[Z]>255)return!1;return!0}function n(N,Z){if(N.buffer&&N.name==="Uint8Array")return Z&&(N.slice?N=N.slice():N=Array.prototype.slice.call(N)),N;if(Array.isArray(N)){if(!r(N))throw new Error("Array contains invalid value: "+N);return new Uint8Array(N)}if(e(N.length)&&r(N))return new Uint8Array(N);throw new Error("unsupported array-like object")}function i(N){return new Uint8Array(N)}function s(N,Z,ae,J,se){(J!=null||se!=null)&&(N.slice?N=N.slice(J,se):N=Array.prototype.slice.call(N,J,se)),Z.set(N,ae)}var a=(function(){function N(ae){var J=[],se=0;for(ae=encodeURI(ae);se<ae.length;){var Se=ae.charCodeAt(se++);Se===37?(J.push(parseInt(ae.substr(se,2),16)),se+=2):J.push(Se)}return n(J)}function Z(ae){for(var J=[],se=0;se<ae.length;){var Se=ae[se];Se<128?(J.push(String.fromCharCode(Se)),se++):Se>191&&Se<224?(J.push(String.fromCharCode((Se&31)<<6|ae[se+1]&63)),se+=2):(J.push(String.fromCharCode((Se&15)<<12|(ae[se+1]&63)<<6|ae[se+2]&63)),se+=3)}return J.join("")}return{toBytes:N,fromBytes:Z}})(),c=(function(){function N(J){for(var se=[],Se=0;Se<J.length;Se+=2)se.push(parseInt(J.substr(Se,2),16));return se}var Z="0123456789abcdef";function ae(J){for(var se=[],Se=0;Se<J.length;Se++){var fe=J[Se];se.push(Z[(fe&240)>>4]+Z[fe&15])}return se.join("")}return{toBytes:N,fromBytes:ae}})(),d={16:10,24:12,32:14},h=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],p=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],x=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],y=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],v=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],w=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],S=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],C=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],k=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],T=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],I=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],R=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],U=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],B=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function z(N){for(var Z=[],ae=0;ae<N.length;ae+=4)Z.push(N[ae]<<24|N[ae+1]<<16|N[ae+2]<<8|N[ae+3]);return Z}var K=function(N){if(!(this instanceof K))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:n(N,!0)}),this._prepare()};K.prototype._prepare=function(){var N=d[this.key.length];if(N==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var Z=0;Z<=N;Z++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var ae=(N+1)*4,J=this.key.length/4,se=z(this.key),Se,Z=0;Z<J;Z++)Se=Z>>2,this._Ke[Se][Z%4]=se[Z],this._Kd[N-Se][Z%4]=se[Z];for(var fe=0,ze=J,Ue;ze<ae;){if(Ue=se[J-1],se[0]^=p[Ue>>16&255]<<24^p[Ue>>8&255]<<16^p[Ue&255]<<8^p[Ue>>24&255]^h[fe]<<24,fe+=1,J!=8)for(var Z=1;Z<J;Z++)se[Z]^=se[Z-1];else{for(var Z=1;Z<J/2;Z++)se[Z]^=se[Z-1];Ue=se[J/2-1],se[J/2]^=p[Ue&255]^p[Ue>>8&255]<<8^p[Ue>>16&255]<<16^p[Ue>>24&255]<<24;for(var Z=J/2+1;Z<J;Z++)se[Z]^=se[Z-1]}for(var Z=0,Ft,Ht;Z<J&&ze<ae;)Ft=ze>>2,Ht=ze%4,this._Ke[Ft][Ht]=se[Z],this._Kd[N-Ft][Ht]=se[Z++],ze++}for(var Ft=1;Ft<N;Ft++)for(var Ht=0;Ht<4;Ht++)Ue=this._Kd[Ft][Ht],this._Kd[Ft][Ht]=I[Ue>>24&255]^R[Ue>>16&255]^U[Ue>>8&255]^B[Ue&255]},K.prototype.encrypt=function(N){if(N.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var Z=this._Ke.length-1,ae=[0,0,0,0],J=z(N),se=0;se<4;se++)J[se]^=this._Ke[0][se];for(var Se=1;Se<Z;Se++){for(var se=0;se<4;se++)ae[se]=y[J[se]>>24&255]^v[J[(se+1)%4]>>16&255]^w[J[(se+2)%4]>>8&255]^S[J[(se+3)%4]&255]^this._Ke[Se][se];J=ae.slice()}for(var fe=i(16),ze,se=0;se<4;se++)ze=this._Ke[Z][se],fe[4*se]=(p[J[se]>>24&255]^ze>>24)&255,fe[4*se+1]=(p[J[(se+1)%4]>>16&255]^ze>>16)&255,fe[4*se+2]=(p[J[(se+2)%4]>>8&255]^ze>>8)&255,fe[4*se+3]=(p[J[(se+3)%4]&255]^ze)&255;return fe},K.prototype.decrypt=function(N){if(N.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var Z=this._Kd.length-1,ae=[0,0,0,0],J=z(N),se=0;se<4;se++)J[se]^=this._Kd[0][se];for(var Se=1;Se<Z;Se++){for(var se=0;se<4;se++)ae[se]=C[J[se]>>24&255]^k[J[(se+3)%4]>>16&255]^T[J[(se+2)%4]>>8&255]^E[J[(se+1)%4]&255]^this._Kd[Se][se];J=ae.slice()}for(var fe=i(16),ze,se=0;se<4;se++)ze=this._Kd[Z][se],fe[4*se]=(x[J[se]>>24&255]^ze>>24)&255,fe[4*se+1]=(x[J[(se+3)%4]>>16&255]^ze>>16)&255,fe[4*se+2]=(x[J[(se+2)%4]>>8&255]^ze>>8)&255,fe[4*se+3]=(x[J[(se+1)%4]&255]^ze)&255;return fe};var Ae=function(N){if(!(this instanceof Ae))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new K(N)};Ae.prototype.encrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16)s(N,ae,0,J,J+16),ae=this._aes.encrypt(ae),s(ae,Z,J);return Z},Ae.prototype.decrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16)s(N,ae,0,J,J+16),ae=this._aes.decrypt(ae),s(ae,Z,J);return Z};var de=function(N,Z){if(!(this instanceof de))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=n(Z,!0),this._aes=new K(N)};de.prototype.encrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16){s(N,ae,0,J,J+16);for(var se=0;se<16;se++)ae[se]^=this._lastCipherblock[se];this._lastCipherblock=this._aes.encrypt(ae),s(this._lastCipherblock,Z,J)}return Z},de.prototype.decrypt=function(N){if(N=n(N),N.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Z=i(N.length),ae=i(16),J=0;J<N.length;J+=16){s(N,ae,0,J,J+16),ae=this._aes.decrypt(ae);for(var se=0;se<16;se++)Z[J+se]=ae[se]^this._lastCipherblock[se];s(N,this._lastCipherblock,0,J,J+16)}return Z};var te=function(N,Z,ae){if(!(this instanceof te))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");ae||(ae=1),this.segmentSize=ae,this._shiftRegister=n(Z,!0),this._aes=new K(N)};te.prototype.encrypt=function(N){if(N.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var Z=n(N,!0),ae,J=0;J<Z.length;J+=this.segmentSize){ae=this._aes.encrypt(this._shiftRegister);for(var se=0;se<this.segmentSize;se++)Z[J+se]^=ae[se];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(Z,this._shiftRegister,16-this.segmentSize,J,J+this.segmentSize)}return Z},te.prototype.decrypt=function(N){if(N.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var Z=n(N,!0),ae,J=0;J<Z.length;J+=this.segmentSize){ae=this._aes.encrypt(this._shiftRegister);for(var se=0;se<this.segmentSize;se++)Z[J+se]^=ae[se];s(this._shiftRegister,this._shiftRegister,0,this.segmentSize),s(N,this._shiftRegister,16-this.segmentSize,J,J+this.segmentSize)}return Z};var Q=function(N,Z){if(!(this instanceof Q))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!Z)Z=i(16);else if(Z.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=n(Z,!0),this._lastPrecipherIndex=16,this._aes=new K(N)};Q.prototype.encrypt=function(N){for(var Z=n(N,!0),ae=0;ae<Z.length;ae++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),Z[ae]^=this._lastPrecipher[this._lastPrecipherIndex++];return Z},Q.prototype.decrypt=Q.prototype.encrypt;var ee=function(N){if(!(this instanceof ee))throw Error("Counter must be instanitated with `new`");N!==0&&!N&&(N=1),typeof N=="number"?(this._counter=i(16),this.setValue(N)):this.setBytes(N)};ee.prototype.setValue=function(N){if(typeof N!="number"||parseInt(N)!=N)throw new Error("invalid counter value (must be an integer)");if(N>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var Z=15;Z>=0;--Z)this._counter[Z]=N%256,N=parseInt(N/256)},ee.prototype.setBytes=function(N){if(N=n(N,!0),N.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=N},ee.prototype.increment=function(){for(var N=15;N>=0;N--)if(this._counter[N]===255)this._counter[N]=0;else{this._counter[N]++;break}};var pe=function(N,Z){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",Z instanceof ee||(Z=new ee(Z)),this._counter=Z,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new K(N)};pe.prototype.encrypt=function(N){for(var Z=n(N,!0),ae=0;ae<Z.length;ae++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),Z[ae]^=this._remainingCounter[this._remainingCounterIndex++];return Z},pe.prototype.decrypt=pe.prototype.encrypt;function H(N){N=n(N,!0);var Z=16-N.length%16,ae=i(N.length+Z);s(N,ae);for(var J=N.length;J<ae.length;J++)ae[J]=Z;return ae}function oe(N){if(N=n(N,!0),N.length<16)throw new Error("PKCS#7 invalid length");var Z=N[N.length-1];if(Z>16)throw new Error("PKCS#7 padding byte out of range");for(var ae=N.length-Z,J=0;J<Z;J++)if(N[ae+J]!==Z)throw new Error("PKCS#7 invalid padding byte");var se=i(ae);return s(N,se,0,0,ae),se}var X={AES:K,Counter:ee,ModeOfOperation:{ecb:Ae,cbc:de,cfb:te,ofb:Q,ctr:pe},utils:{hex:c,utf8:a},padding:{pkcs7:{pad:H,strip:oe}},_arrayTest:{coerceArray:n,createArray:i,copyArray:s}};typeof Tse<"u"?eOe.exports=X:typeof define=="function"&&define.amd?define([],function(){return X}):(t.aesjs&&(X._aesjs=t.aesjs),t.aesjs=X)})(Tse)});function iOe(t,e,r){var n=e?0:4,i=e?4:0,s=e?0:3,a=e?1:2,c=e?2:1,d=e?3:0,h=e?$4t:q4t,p=e?j4t:z4t,x=w.prototype,y="is"+t,v="_"+y;return x.buffer=void 0,x.offset=0,x[v]=!0,x.toNumber=T,x.toString=E,x.toJSON=T,x.toArray=M4t,wS&&(x.toBuffer=L4t),_S&&(x.toArrayBuffer=sOe),w[y]=S,w;function w(U,B,z,K){return this instanceof w?C(this,U,B,z,K):new w(U,B,z,K)}function S(U){return!!(U&&U[v])}function C(U,B,z,K,Ae){if(_S&&PU&&(B instanceof PU&&(B=new _S(B)),K instanceof PU&&(K=new _S(K))),!B&&!z&&!K&&!SS){U.buffer=aOe(rOe,0);return}if(!nOe(B,z)){var de=SS||Array;Ae=z,K=B,z=0,B=SS===wS?wS.alloc(8):new de(8)}U.buffer=B,U.offset=z|=0,RU!==typeof K&&(typeof K=="string"?k(B,z,K,Ae||10):nOe(K,Ae)?Cse(B,z,K,Ae):typeof Ae=="number"?(I(B,z+n,K),I(B,z+i,Ae)):K>0?h(B,z,K):K<0?p(B,z,K):Cse(B,z,rOe,0))}function k(U,B,z,K){var Ae=0,de=z.length,te=0,Q=0;z[0]==="-"&&Ae++;for(var ee=Ae;Ae<de;){var pe=parseInt(z[Ae++],K);if(!(pe>=0))break;Q=Q*K+pe,te=te*K+Math.floor(Q/bS),Q%=bS}ee&&(te=~te,Q?Q=bS-Q:te++),I(U,B+n,te),I(U,B+i,Q)}function T(){var U=this.buffer,B=this.offset,z=R(U,B+n),K=R(U,B+i);return r||(z|=0),z?z*bS+K:K}function E(U){var B=this.buffer,z=this.offset,K=R(B,z+n),Ae=R(B,z+i),de="",te=!r&&K&2147483648;for(te&&(K=~K,Ae=bS-Ae),U=U||10;;){var Q=K%U*bS+Ae;if(K=Math.floor(K/U),Ae=Math.floor(Q/U),de=(Q%U).toString(U)+de,!K&&!Ae)break}return te&&(de="-"+de),de}function I(U,B,z){U[B+d]=z&255,z=z>>8,U[B+c]=z&255,z=z>>8,U[B+a]=z&255,z=z>>8,U[B+s]=z&255}function R(U,B){return U[B+s]*U4t+(U[B+a]<<16)+(U[B+c]<<8)+U[B+d]}}function M4t(t){var e=this.buffer,r=this.offset;return SS=null,t!==!1&&B4t(e)?e.length===8?e:e.slice(r,r+8):aOe(e,r)}function L4t(t){var e=this.buffer,r=this.offset;return SS=wS,t!==!1&&wS.isBuffer(e)?e.length===8?e:e.slice(r,r+8):wS.from(sOe.call(this,t))}function sOe(t){var e=this.buffer,r=this.offset,n=e.buffer;if(SS=_S,t!==!1&&!e.offset&&n instanceof PU)return n.byteLength===8?n:n.slice(r,r+8);var i=new _S(8);return Cse(i,0,e,r),i.buffer}function nOe(t,e){var r=t&&t.length;return e|=0,r&&e+8<=r&&typeof t[e]!="string"}function Cse(t,e,r,n){e|=0,n|=0;for(var i=0;i<8;i++)t[e++]=r[n++]&255}function aOe(t,e){return Array.prototype.slice.call(t,e,e+8)}function $4t(t,e,r){for(var n=e+8;n>e;)t[--n]=r&255,r/=256}function j4t(t,e,r){var n=e+8;for(r++;n>e;)t[--n]=-r&255^255,r/=256}function q4t(t,e,r){for(var n=e+8;e<n;)t[e++]=r&255,r/=256}function z4t(t,e,r){var n=e+8;for(r++;e<n;)t[e++]=-r&255^255,r/=256}function W4t(t){return!!t&&Object.prototype.toString.call(t)=="[object Array]"}var RU,wS,_S,PU,rOe,B4t,bS,U4t,SS,OU,kse,NU=ce(()=>{RU="undefined",wS=RU!==typeof Buffer&&Buffer,_S=RU!==typeof Uint8Array&&Uint8Array,PU=RU!==typeof ArrayBuffer&&ArrayBuffer,rOe=[0,0,0,0,0,0,0,0],B4t=Array.isArray||W4t,bS=4294967296,U4t=16777216,OU=iOe("Uint64BE",!0,!0),kse=iOe("Int64BE",!0,!1)});var Ise=L(oOe=>{var Wr=oOe,{Buffer:BU}=Kr("buffer"),H4t=Kr("os");Wr.toBuffer=function(t,e,r){r=~~r;let n;if(this.isV4Format(t))n=e||BU.alloc(r+4),t.split(/\./g).map(i=>{n[r++]=parseInt(i,10)&255});else if(this.isV6Format(t)){let i=t.split(":",8),s;for(s=0;s<i.length;s++){let a=this.isV4Format(i[s]),c;a&&(c=this.toBuffer(i[s]),i[s]=c.slice(0,2).toString("hex")),c&&++s<8&&i.splice(s,0,c.slice(2,4).toString("hex"))}if(i[0]==="")for(;i.length<8;)i.unshift("0");else if(i[i.length-1]==="")for(;i.length<8;)i.push("0");else if(i.length<8){for(s=0;s<i.length&&i[s]!=="";s++);let a=[s,1];for(s=9-i.length;s>0;s--)a.push("0");i.splice(...a)}for(n=e||BU.alloc(r+16),s=0;s<i.length;s++){let a=parseInt(i[s],16);n[r++]=a>>8&255,n[r++]=a&255}}if(!n)throw Error(`Invalid ip address: ${t}`);return n};Wr.toString=function(t,e,r){e=~~e,r=r||t.length-e;let n=[];if(r===4){for(let i=0;i<r;i++)n.push(t[e+i]);n=n.join(".")}else if(r===16){for(let i=0;i<r;i+=2)n.push(t.readUInt16BE(e+i).toString(16));n=n.join(":"),n=n.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),n=n.replace(/:{3,4}/,"::")}return n};var V4t=/^(\d{1,3}\.){3,3}\d{1,3}$/,G4t=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;Wr.isV4Format=function(t){return V4t.test(t)};Wr.isV6Format=function(t){return G4t.test(t)};function e6(t){return t===4?"ipv4":t===6?"ipv6":t?t.toLowerCase():"ipv4"}Wr.fromPrefixLen=function(t,e){t>32?e="ipv6":e=e6(e);let r=4;e==="ipv6"&&(r=16);let n=BU.alloc(r);for(let i=0,s=n.length;i<s;++i){let a=8;t<8&&(a=t),t-=a,n[i]=~(255>>a)&255}return Wr.toString(n)};Wr.mask=function(t,e){t=Wr.toBuffer(t),e=Wr.toBuffer(e);let r=BU.alloc(Math.max(t.length,e.length)),n;if(t.length===e.length)for(n=0;n<t.length;n++)r[n]=t[n]&e[n];else if(e.length===4)for(n=0;n<e.length;n++)r[n]=t[t.length-4+n]&e[n];else{for(n=0;n<r.length-6;n++)r[n]=0;for(r[10]=255,r[11]=255,n=0;n<t.length;n++)r[n+12]=t[n]&e[n+12];n+=12}for(;n<r.length;n++)r[n]=0;return Wr.toString(r)};Wr.cidr=function(t){let e=t.split("/"),r=e[0];if(e.length!==2)throw new Error(`invalid CIDR subnet: ${r}`);let n=Wr.fromPrefixLen(parseInt(e[1],10));return Wr.mask(r,n)};Wr.subnet=function(t,e){let r=Wr.toLong(Wr.mask(t,e)),n=Wr.toBuffer(e),i=0;for(let a=0;a<n.length;a++)if(n[a]===255)i+=8;else{let c=n[a]&255;for(;c;)c=c<<1&255,i++}let s=2**(32-i);return{networkAddress:Wr.fromLong(r),firstAddress:s<=2?Wr.fromLong(r):Wr.fromLong(r+1),lastAddress:s<=2?Wr.fromLong(r+s-1):Wr.fromLong(r+s-2),broadcastAddress:Wr.fromLong(r+s-1),subnetMask:e,subnetMaskLength:i,numHosts:s<=2?s:s-2,length:s,contains(a){return r===Wr.toLong(Wr.mask(a,e))}}};Wr.cidrSubnet=function(t){let e=t.split("/"),r=e[0];if(e.length!==2)throw new Error(`invalid CIDR subnet: ${r}`);let n=Wr.fromPrefixLen(parseInt(e[1],10));return Wr.subnet(r,n)};Wr.not=function(t){let e=Wr.toBuffer(t);for(let r=0;r<e.length;r++)e[r]=255^e[r];return Wr.toString(e)};Wr.or=function(t,e){if(t=Wr.toBuffer(t),e=Wr.toBuffer(e),t.length===e.length){for(let s=0;s<t.length;++s)t[s]|=e[s];return Wr.toString(t)}let r=t,n=e;e.length>t.length&&(r=e,n=t);let i=r.length-n.length;for(let s=i;s<r.length;++s)r[s]|=n[s-i];return Wr.toString(r)};Wr.isEqual=function(t,e){if(t=Wr.toBuffer(t),e=Wr.toBuffer(e),t.length===e.length){for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}if(e.length===4){let n=e;e=t,t=n}for(let n=0;n<10;n++)if(e[n]!==0)return!1;let r=e.readUInt16BE(10);if(r!==0&&r!==65535)return!1;for(let n=0;n<4;n++)if(t[n]!==e[n+12])return!1;return!0};Wr.isPrivate=function(t){if(Wr.isLoopback(t))return!0;if(!Wr.isV6Format(t)){let e=Wr.normalizeToLong(t);if(e<0)throw new Error("invalid ipv4 address");t=Wr.fromLong(e)}return/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^f[cd][0-9a-f]{2}:/i.test(t)||/^fe80:/i.test(t)||/^::1$/.test(t)||/^::$/.test(t)};Wr.isPublic=function(t){return!Wr.isPrivate(t)};Wr.isLoopback=function(t){return!/\./.test(t)&&!/:/.test(t)&&(t=Wr.fromLong(Number(t))),/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(t)||/^0177\./.test(t)||/^0x7f\./i.test(t)||/^fe80::1$/i.test(t)||/^::1$/.test(t)||/^::$/.test(t)};Wr.loopback=function(t){if(t=e6(t),t!=="ipv4"&&t!=="ipv6")throw new Error("family must be ipv4 or ipv6");return t==="ipv4"?"127.0.0.1":"fe80::1"};Wr.address=function(t,e){let r=H4t.networkInterfaces();if(e=e6(e),t&&t!=="private"&&t!=="public"){let i=r[t].filter(s=>e6(s.family)===e);return i.length===0?void 0:i[0].address}let n=Object.keys(r).map(i=>{let s=r[i].filter(a=>(a.family=e6(a.family),a.family!==e||Wr.isLoopback(a.address)?!1:t?t==="public"?Wr.isPrivate(a.address):Wr.isPublic(a.address):!0));return s.length?s[0].address:void 0}).filter(Boolean);return n.length?n[0]:Wr.loopback(e)};Wr.toLong=function(t){let e=0;return t.split(".").forEach(r=>{e<<=8,e+=parseInt(r)}),e>>>0};Wr.fromLong=function(t){return`${t>>>24}.${t>>16&255}.${t>>8&255}.${t&255}`};Wr.normalizeToLong=function(t){let e=t.split(".").map(i=>i.startsWith("0x")||i.startsWith("0X")?parseInt(i,16):i.startsWith("0")&&i!=="0"&&/^[0-7]+$/.test(i)?parseInt(i,8):/^[1-9]\d*$/.test(i)||i==="0"?parseInt(i,10):NaN);if(e.some(isNaN))return-1;let r=0;switch(e.length){case 1:r=e[0];break;case 2:if(e[0]>255||e[1]>16777215)return-1;r=e[0]<<24|e[1]&16777215;break;case 3:if(e[0]>255||e[1]>255||e[2]>65535)return-1;r=e[0]<<24|e[1]<<16|e[2]&65535;break;case 4:if(e.some(i=>i>255))return-1;r=e[0]<<24|e[1]<<16|e[2]<<8|e[3];break;default:return-1}return r>>>0}});var cOe=L(Fse=>{"use strict";Fse.toString=function(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t};Fse.toType=function(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var uOe=L(Pse=>{"use strict";Pse.toString=function(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t};Pse.toRcode=function(t){switch(t.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var lOe=L(Rse=>{"use strict";Rse.toString=function(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t};Rse.toOpcode=function(t){switch(t.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var fOe=L(Ose=>{"use strict";Ose.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Ose.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var dOe=L(Nse=>{"use strict";Nse.toString=function(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`};Nse.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var mOe=L((pOe,Bse)=>{var hOe=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=x,t.encode=p,t.familyOf=h,t.name=void 0,t.sizeOf=d,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,s={name:"v4",size:r,isFormat:y=>e.test(y),encode(y,v,w){w=~~w,v=v||new Uint8Array(w+r);let S=y.length,C=0;for(let k=0;k<S;){let T=y.charCodeAt(k++);T===46?(v[w++]=C,C=0):C=C*10+(T-48)}return v[w]=C,v},decode(y,v){return v=~~v,`${y[v++]}.${y[v++]}.${y[v++]}.${y[v]}`}};t.v4=s;let a={name:"v6",size:i,isFormat:y=>y.length>0&&n.test(y),encode(y,v,w){w=~~w;let S=w+i,C=-1,k=0,T=0,E=!0,I=!1;v=v||new Uint8Array(w+i);for(let R=0;R<y.length;R++){let U=y.charCodeAt(R);U===58?(E?C!==-1?(w<S&&(v[w]=0),w<S-1&&(v[w+1]=0),w+=2):w<S&&(C=w):(I===!0?(w<S&&(v[w]=T),w++):(w<S&&(v[w]=k>>8),w<S-1&&(v[w+1]=k&255),w+=2),k=0,T=0),E=!0,I=!1):U===46?(w<S&&(v[w]=T),w++,T=0,k=0,E=!1,I=!0):(E=!1,U>=97?U-=87:U>=65?U-=55:(U-=48,T=T*10+U),k=(k<<4)+U)}if(E===!1)I===!0?(w<S&&(v[w]=T),w++):(w<S&&(v[w]=k>>8),w<S-1&&(v[w+1]=k&255),w+=2);else if(C===0)w<S&&(v[w]=0),w<S-1&&(v[w+1]=0),w+=2;else if(C!==-1){w+=2;for(let R=Math.min(w-1,S-1);R>=C+2;R--)v[R]=v[R-2];v[C]=0,v[C+1]=0,C=w}if(C!==w&&C!==-1)for(w>S-2&&(w=S-2);S>C;)v[--S]=w<S&&w>C?v[--w]:0;else for(;w<S;)v[w++]=0;return v},decode(y,v){v=~~v;let w="";for(let S=0;S<i;S+=2)S!==0&&(w+=":"),w+=(y[v+S]<<8|y[v+S+1]).toString(16);return w.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=a;let c="ip";t.name=c;function d(y){if(s.isFormat(y))return s.size;if(a.isFormat(y))return a.size;throw Error(`Invalid ip address: ${y}`)}function h(y){return d(y)===s.size?1:2}function p(y,v,w){w=~~w;let S=d(y);return typeof v=="function"&&(v=v(w+S)),S===s.size?s.encode(y,v,w):a.encode(y,v,w)}function x(y,v,w){if(v=~~v,w=w||y.length-v,w===s.size)return s.decode(y,v,w);if(w===a.size)return a.decode(y,v,w);throw Error(`Invalid buffer size needs to be ${s.size} for v4 or ${a.size} for v6.`)}return"default"in t?t.default:t})({});typeof define=="function"&&define.amd?define([],function(){return hOe}):typeof Bse=="object"&&typeof pOe=="object"&&(Bse.exports=hOe)});var yOe=L(Hr=>{"use strict";var Vr=Kr("buffer").Buffer,yp=cOe(),K4t=uOe(),Z4t=lOe(),MU=fOe(),Use=dOe(),xv=mOe(),X4t=0,gOe=32768,Mse=32768,Y4t=~Mse,xOe=32768,J4t=~xOe,or=Hr.name={};or.encode=function(t,e,r,{mail:n=!1}={}){e||(e=Vr.alloc(or.encodingLength(t))),r||(r=0);let i=r,s=t.replace(/^\.|\.$/gm,"");if(s.length){let a=[];if(n){let c="";s.split(".").forEach(d=>{d.endsWith("\\")?c+=(c.length?".":"")+d.slice(0,-1):a.length===0&&c.length?a.push(c+"."+d):a.push(d)})}else a=s.split(".");for(let c=0;c<a.length;c++){let d=e.write(a[c],r+1);e[r]=d,r+=d+1}}return e[r++]=0,or.encode.bytes=r-i,e};or.encode.bytes=0;or.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],i=e,s=0,a=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let d=t[e++];if(a+=c?0:1,d===0)break;if((d&192)===0){if(e+d>t.length)throw new Error("Cannot decode name (buffer overflow)");if(s+=d+1,s>254)throw new Error("Cannot decode name (name too long)");let h=t.toString("utf-8",e,e+d);r&&(h=h.replace(/\./g,"\\.")),n.push(h),e+=d,a+=c?0:d}else if((d&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let h=t.readUInt16BE(e-1)-49152;if(h>=i)throw new Error("Cannot decode name (bad pointer)");e=h,i=h,a+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return or.decode.bytes=a,n.length===0?".":n.join(".")};or.decode.bytes=0;or.encodingLength=function(t){return t==="."||t===".."?1:Vr.byteLength(t.replace(/^\.|\.$/gm,""))+2};var Nn={};Nn.encode=function(t,e,r){e||(e=Vr.alloc(Nn.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,Nn.encode.bytes=n+1,e};Nn.encode.bytes=0;Nn.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return Nn.decode.bytes=r+1,n};Nn.decode.bytes=0;Nn.encodingLength=function(t){return Vr.byteLength(t)+1};var id={};id.encode=function(t,e,r){e||(e=id.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?gOe:X4t;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|i,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};id.encode.bytes=12;id.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&gOe?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Z4t.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:K4t.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};id.decode.bytes=12;id.encodingLength=function(){return 12};var up=Hr.unknown={};up.encode=function(t,e,r){return e||(e=Vr.alloc(up.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),up.encode.bytes=t.length+2,e};up.encode.bytes=0;up.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return up.decode.bytes=r+2,n};up.decode.bytes=0;up.encodingLength=function(t){return t.length+2};var lp=Hr.ns={};lp.encode=function(t,e,r){return e||(e=Vr.alloc(lp.encodingLength(t))),r||(r=0),or.encode(t,e,r+2),e.writeUInt16BE(or.encode.bytes,r),lp.encode.bytes=or.encode.bytes+2,e};lp.encode.bytes=0;lp.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=or.decode(t,e+2);return lp.decode.bytes=r+2,n};lp.decode.bytes=0;lp.encodingLength=function(t){return or.encodingLength(t)+2};var fp=Hr.soa={};fp.encode=function(t,e,r){e||(e=Vr.alloc(fp.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.mname,e,r),r+=or.encode.bytes,or.encode(t.rname,e,r,{mail:!0}),r+=or.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),fp.encode.bytes=r-n,e};fp.encode.bytes=0;fp.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=or.decode(t,e),e+=or.decode.bytes,n.rname=or.decode(t,e,{mail:!0}),e+=or.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,fp.decode.bytes=e-r,n};fp.decode.bytes=0;fp.encodingLength=function(t){return 22+or.encodingLength(t.mname)+or.encodingLength(t.rname)};var dp=Hr.txt={};dp.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i<t.length;i++)if(typeof t[i]=="string"&&(t[i]=Vr.from(t[i])),!Vr.isBuffer(t[i]))throw new Error("Must be a Buffer");e||(e=Vr.alloc(dp.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(i){e[r++]=i.length,i.copy(e,r,0,i.length),r+=i.length}),e.writeUInt16BE(r-n-2,n),dp.encode.bytes=r-n,e};dp.encode.bytes=0;dp.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let s=t[e++];if(--n,n<s)throw new Error("Buffer overflow");i.push(t.slice(e,e+s)),e+=s,n-=s}return dp.decode.bytes=e-r,i};dp.decode.bytes=0;dp.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=Vr.byteLength(r)+1:e+=r.length+1}),e};var hp=Hr.null={};hp.encode=function(t,e,r){e||(e=Vr.alloc(hp.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=Vr.from(t)),t||(t=Vr.alloc(0));let n=r;r+=2;let i=t.length;return t.copy(e,r,0,i),r+=i,e.writeUInt16BE(r-n-2,n),hp.encode.bytes=r-n,e};hp.encode.bytes=0;hp.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let i=t.slice(e,e+n);return e+=n,hp.decode.bytes=e-r,i};hp.decode.bytes=0;hp.encodingLength=function(t){return t?(Vr.isBuffer(t)?t.length:Vr.byteLength(t))+2:2};var pp=Hr.hinfo={};pp.encode=function(t,e,r){e||(e=Vr.alloc(pp.encodingLength(t))),r||(r=0);let n=r;return r+=2,Nn.encode(t.cpu,e,r),r+=Nn.encode.bytes,Nn.encode(t.os,e,r),r+=Nn.encode.bytes,e.writeUInt16BE(r-n-2,n),pp.encode.bytes=r-n,e};pp.encode.bytes=0;pp.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=Nn.decode(t,e),e+=Nn.decode.bytes,n.os=Nn.decode(t,e),e+=Nn.decode.bytes,pp.decode.bytes=e-r,n};pp.decode.bytes=0;pp.encodingLength=function(t){return Nn.encodingLength(t.cpu)+Nn.encodingLength(t.os)+2};var rd=Hr.ptr={},Q4t=Hr.cname=rd,e3t=Hr.dname=rd;rd.encode=function(t,e,r){return e||(e=Vr.alloc(rd.encodingLength(t))),r||(r=0),or.encode(t,e,r+2),e.writeUInt16BE(or.encode.bytes,r),rd.encode.bytes=or.encode.bytes+2,e};rd.encode.bytes=0;rd.decode=function(t,e){e||(e=0);let r=or.decode(t,e+2);return rd.decode.bytes=or.decode.bytes+2,r};rd.decode.bytes=0;rd.encodingLength=function(t){return or.encodingLength(t)+2};var mp=Hr.srv={};mp.encode=function(t,e,r){e||(e=Vr.alloc(mp.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),or.encode(t.target,e,r+8);let n=or.encode.bytes+6;return e.writeUInt16BE(n,r),mp.encode.bytes=n+2,e};mp.encode.bytes=0;mp.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=or.decode(t,e+8),mp.decode.bytes=r+2,n};mp.decode.bytes=0;mp.encodingLength=function(t){return 8+or.encodingLength(t.target)};var ll=Hr.caa={};ll.ISSUER_CRITICAL=128;ll.encode=function(t,e,r){let n=ll.encodingLength(t);return e||(e=Vr.alloc(ll.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=ll.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,Nn.encode(t.tag,e,r),r+=Nn.encode.bytes,e.write(t.value,r),r+=Vr.byteLength(t.value),ll.encode.bytes=n,e};ll.encode.bytes=0;ll.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=t.readUInt8(e),e+=1,i.tag=Nn.decode(t,e),e+=Nn.decode.bytes,i.value=t.toString("utf-8",e,n+r),i.issuerCritical=!!(i.flags&ll.ISSUER_CRITICAL),ll.decode.bytes=r+2,i};ll.decode.bytes=0;ll.encodingLength=function(t){return Nn.encodingLength(t.tag)+Nn.encodingLength(t.value)+2};var Ig=Hr.mx={};Ig.encode=function(t,e,r){e||(e=Vr.alloc(Ig.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,or.encode(t.exchange,e,r),r+=or.encode.bytes,e.writeUInt16BE(r-n-2,n),Ig.encode.bytes=r-n,e};Ig.encode.bytes=0;Ig.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=or.decode(t,e),e+=or.decode.bytes,Ig.decode.bytes=e-r,n};Ig.encodingLength=function(t){return 4+or.encodingLength(t.exchange)};var gp=Hr.a={};gp.encode=function(t,e,r){return e||(e=Vr.alloc(gp.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xv.v4.encode(t,e,r),gp.encode.bytes=6,e};gp.encode.bytes=0;gp.decode=function(t,e){e||(e=0),e+=2;let r=xv.v4.decode(t,e);return gp.decode.bytes=6,r};gp.decode.bytes=0;gp.encodingLength=function(){return 6};var xp=Hr.aaaa={};xp.encode=function(t,e,r){return e||(e=Vr.alloc(xp.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xv.v6.encode(t,e,r),xp.encode.bytes=18,e};xp.encode.bytes=0;xp.decode=function(t,e){e||(e=0),e+=2;let r=xv.v6.decode(t,e);return xp.decode.bytes=18,r};xp.decode.bytes=0;xp.encodingLength=function(){return 18};var Ou=Hr.option={};Ou.encode=function(t,e,r){e||(e=Vr.alloc(Ou.encodingLength(t))),r||(r=0);let n=r,i=Use.toCode(t.code);if(e.writeUInt16BE(i,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(i){case 8:let s=t.sourcePrefixLength||0,a=t.family||xv.familyOf(t.ip),c=xv.encode(t.ip,Vr.alloc),d=Math.ceil(s/8);e.writeUInt16BE(d+4,r),r+=2,e.writeUInt16BE(a,r),r+=2,e.writeUInt8(s,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,d),r+=d;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let h=t.length||0;e.writeUInt16BE(h,r),r+=2,e.fill(0,r,r+h),r+=h;break;case 14:let p=t.tags.length*2;e.writeUInt16BE(p,r),r+=2;for(let x of t.tags)e.writeUInt16BE(x,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return Ou.encode.bytes=r-n,e};Ou.encode.bytes=0;Ou.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Use.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let i=Vr.alloc(r.family===1?4:16);t.copy(i,0,e,e+n-4),r.ip=xv.decode(i);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let s=0;s<n;s+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return Ou.decode.bytes=n+4,r};Ou.decode.bytes=0;Ou.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Use.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var dl=Hr.opt={};dl.encode=function(t,e,r){e||(e=Vr.alloc(dl.encodingLength(t))),r||(r=0);let n=r,i=AS(t,Ou);return e.writeUInt16BE(i,r),r=t6(t,Ou,e,r+2),dl.encode.bytes=r-n,e};dl.encode.bytes=0;dl.decode=function(t,e){e||(e=0);let r=e,n=[],i=t.readUInt16BE(e);e+=2;let s=0;for(;i>0;)n[s++]=Ou.decode(t,e),e+=Ou.decode.bytes,i-=Ou.decode.bytes;return dl.decode.bytes=e-r,n};dl.decode.bytes=0;dl.encodingLength=function(t){return 2+AS(t||[],Ou)};var jc=Hr.dnskey={};jc.PROTOCOL_DNSSEC=3;jc.ZONE_KEY=128;jc.SECURE_ENTRYPOINT=32768;jc.encode=function(t,e,r){e||(e=Vr.alloc(jc.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Vr.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(jc.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,jc.encode.bytes=r-n,e.writeUInt16BE(jc.encode.bytes-2,n),e};jc.encode.bytes=0;jc.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==jc.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,jc.decode.bytes=e-r,n};jc.decode.bytes=0;jc.encodingLength=function(t){return 6+Vr.byteLength(t.key)};var Eh=Hr.rrsig={};Eh.encode=function(t,e,r){e||(e=Vr.alloc(Eh.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Vr.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(yp.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,or.encode(t.signersName,e,r),r+=or.encode.bytes,i.copy(e,r,0,i.length),r+=i.length,Eh.encode.bytes=r-n,e.writeUInt16BE(Eh.encode.bytes-2,n),e};Eh.encode.bytes=0;Eh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.typeCovered=yp.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=or.decode(t,e),e+=or.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,Eh.decode.bytes=e-r,n};Eh.decode.bytes=0;Eh.encodingLength=function(t){return 20+or.encodingLength(t.signersName)+Vr.byteLength(t.signature)};var Th=Hr.rp={};Th.encode=function(t,e,r){e||(e=Vr.alloc(Th.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.mbox||".",e,r,{mail:!0}),r+=or.encode.bytes,or.encode(t.txt||".",e,r),r+=or.encode.bytes,Th.encode.bytes=r-n,e.writeUInt16BE(Th.encode.bytes-2,n),e};Th.encode.bytes=0;Th.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=or.decode(t,e,{mail:!0})||".",e+=or.decode.bytes,n.txt=or.decode(t,e)||".",e+=or.decode.bytes,Th.decode.bytes=e-r,n};Th.decode.bytes=0;Th.encodingLength=function(t){return 2+or.encodingLength(t.mbox||".")+or.encodingLength(t.txt||".")};var go={};go.encode=function(t,e,r){e||(e=Vr.alloc(go.encodingLength(t))),r||(r=0);let n=r;for(var i=[],s=0;s<t.length;s++){var a=yp.toType(t[s]);i[a>>8]===void 0&&(i[a>>8]=[]),i[a>>8][a>>3&31]|=1<<7-(a&7)}for(s=0;s<i.length;s++)if(i[s]!==void 0){var c=Vr.from(i[s]);e.writeUInt8(s,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return go.encode.bytes=r-n,e};go.encode.bytes=0;go.decode=function(t,e,r){e||(e=0);let n=e;for(var i=[];e-n<r;){var s=t.readUInt8(e);e+=1;var a=t.readUInt8(e);e+=1;for(var c=0;c<a;c++)for(var d=t.readUInt8(e+c),h=0;h<8;h++)if(d&1<<7-h){var p=yp.toString(s<<8|c<<3|h);i.push(p)}e+=a}return go.decode.bytes=e-n,i};go.decode.bytes=0;go.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=yp.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(i+=2+Math.ceil((e[r]+1)/8));return i};var Ch=Hr.nsec={};Ch.encode=function(t,e,r){e||(e=Vr.alloc(Ch.encodingLength(t))),r||(r=0);let n=r;return r+=2,or.encode(t.nextDomain,e,r),r+=or.encode.bytes,go.encode(t.rrtypes,e,r),r+=go.encode.bytes,Ch.encode.bytes=r-n,e.writeUInt16BE(Ch.encode.bytes-2,n),e};Ch.encode.bytes=0;Ch.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.nextDomain=or.decode(t,e),e+=or.decode.bytes,n.rrtypes=go.decode(t,e,i-(e-r)),e+=go.decode.bytes,Ch.decode.bytes=e-r,n};Ch.decode.bytes=0;Ch.encodingLength=function(t){return 2+or.encodingLength(t.nextDomain)+go.encodingLength(t.rrtypes)};var kh=Hr.nsec3={};kh.encode=function(t,e,r){e||(e=Vr.alloc(kh.encodingLength(t))),r||(r=0);let n=r,i=t.salt;if(!Vr.isBuffer(i))throw new Error("salt must be a Buffer");let s=t.nextDomain;if(!Vr.isBuffer(s))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,e.writeUInt8(s.length,r),r+=1,s.copy(e,r,0,s.length),r+=s.length,go.encode(t.rrtypes,e,r),r+=go.encode.bytes,kh.encode.bytes=r-n,e.writeUInt16BE(kh.encode.bytes-2,n),e};kh.encode.bytes=0;kh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let s=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+s),e+=s;let a=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+a),e+=a,n.rrtypes=go.decode(t,e,i-(e-r)),e+=go.decode.bytes,kh.decode.bytes=e-r,n};kh.decode.bytes=0;kh.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+go.encodingLength(t.rrtypes)};var Dh=Hr.ds={};Dh.encode=function(t,e,r){e||(e=Vr.alloc(Dh.encodingLength(t))),r||(r=0);let n=r,i=t.digest;if(!Vr.isBuffer(i))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,Dh.encode.bytes=r-n,e.writeUInt16BE(Dh.encode.bytes-2,n),e};Dh.encode.bytes=0;Dh.decode=function(t,e){e||(e=0);let r=e;var n={},i=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+i+2),e+=n.digest.length,Dh.decode.bytes=e-r,n};Dh.decode.bytes=0;Dh.encodingLength=function(t){return 6+Vr.byteLength(t.digest)};var fl=Hr.sshfp={};fl.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};fl.encode=function(e,r,n){r||(r=Vr.alloc(fl.encodingLength(e))),n||(n=0);let i=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let s=Vr.from(e.fingerprint.toUpperCase(),"hex");if(s.length!==fl.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return s.copy(r,n),n+=s.byteLength,fl.encode.bytes=n-i,r.writeUInt16BE(fl.encode.bytes-2,i),r};fl.encode.bytes=0;fl.decode=function(e,r){r||(r=0);let n=r,i={};r+=2,i.algorithm=e[r],r+=1,i.hash=e[r],r+=1;let s=fl.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(r,r+s).toString("hex").toUpperCase(),r+=s,fl.decode.bytes=r-n,i};fl.decode.bytes=0;fl.encodingLength=function(t){return 4+Vr.from(t.fingerprint,"hex").byteLength};var Ih=Hr.naptr={};Ih.encode=function(t,e,r){e||(e=Vr.alloc(Ih.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,Nn.encode(t.flags,e,r),r+=Nn.encode.bytes,Nn.encode(t.services,e,r),r+=Nn.encode.bytes,Nn.encode(t.regexp,e,r),r+=Nn.encode.bytes,or.encode(t.replacement,e,r),r+=or.encode.bytes,Ih.encode.bytes=r-n,e.writeUInt16BE(Ih.encode.bytes-2,n),e};Ih.encode.bytes=0;Ih.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=Nn.decode(t,e),e+=Nn.decode.bytes,n.services=Nn.decode(t,e),e+=Nn.decode.bytes,n.regexp=Nn.decode(t,e),e+=Nn.decode.bytes,n.replacement=or.decode(t,e),e+=or.decode.bytes,Ih.decode.bytes=e-r,n};Ih.decode.bytes=0;Ih.encodingLength=function(t){return Nn.encodingLength(t.flags)+Nn.encodingLength(t.services)+Nn.encodingLength(t.regexp)+or.encodingLength(t.replacement)+6};var Fh=Hr.tlsa={};Fh.encode=function(t,e,r){e||(e=Vr.alloc(Fh.encodingLength(t))),r||(r=0);let n=r,i=t.certificate;if(!Vr.isBuffer(i))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,Fh.encode.bytes=r-n,e.writeUInt16BE(Fh.encode.bytes-2,n),e};Fh.encode.bytes=0;Fh.decode=function(t,e){e||(e=0);let r=e,n={},i=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+i+2),e+=n.certificate.length,Fh.decode.bytes=e-r,n};Fh.decode.bytes=0;Fh.encodingLength=function(t){return 5+Vr.byteLength(t.certificate)};var Lse=Hr.record=function(t){switch(t.toUpperCase()){case"A":return gp;case"PTR":return rd;case"CNAME":return Q4t;case"DNAME":return e3t;case"TXT":return dp;case"NULL":return hp;case"AAAA":return xp;case"SRV":return mp;case"HINFO":return pp;case"CAA":return ll;case"NS":return lp;case"SOA":return fp;case"MX":return Ig;case"OPT":return dl;case"DNSKEY":return jc;case"RRSIG":return Eh;case"RP":return Th;case"NSEC":return Ch;case"NSEC3":return kh;case"SSHFP":return fl;case"DS":return Dh;case"NAPTR":return Ih;case"TLSA":return Fh}return up},Lo=Hr.answer={};Lo.encode=function(t,e,r){e||(e=Vr.alloc(Lo.encodingLength(t))),r||(r=0);let n=r;if(or.encode(t.name,e,r),r+=or.encode.bytes,e.writeUInt16BE(yp.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,dl.encode(t.options||[],e,r),r+=dl.encode.bytes}else{let i=MU.toClass(t.class===void 0?"IN":t.class);t.flush&&(i|=Mse),e.writeUInt16BE(i,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let s=Lse(t.type);s.encode(t.data,e,r),r+=s.encode.bytes}return Lo.encode.bytes=r-n,e};Lo.encode.bytes=0;Lo.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=or.decode(t,e),e+=or.decode.bytes,r.type=yp.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=dl.decode(t,e+8),e+=8+dl.decode.bytes;else{let i=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=MU.toString(i&Y4t),r.flush=!!(i&Mse);let s=Lse(r.type);r.data=s.decode(t,e+8),e+=8+s.decode.bytes}return Lo.decode.bytes=e-n,r};Lo.decode.bytes=0;Lo.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return or.encodingLength(t.name)+8+Lse(t.type).encodingLength(e)};var nd=Hr.question={};nd.encode=function(t,e,r){e||(e=Vr.alloc(nd.encodingLength(t))),r||(r=0);let n=r;return or.encode(t.name,e,r),r+=or.encode.bytes,e.writeUInt16BE(yp.toType(t.type),r),r+=2,e.writeUInt16BE(MU.toClass(t.class===void 0?"IN":t.class),r),r+=2,nd.encode.bytes=r-n,t};nd.encode.bytes=0;nd.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=or.decode(t,e),e+=or.decode.bytes,n.type=yp.toString(t.readUInt16BE(e)),e+=2,n.class=MU.toString(t.readUInt16BE(e)),e+=2,n.class&xOe&&(n.class&=J4t),nd.decode.bytes=e-r,n};nd.decode.bytes=0;nd.encodingLength=function(t){return or.encodingLength(t.name)+4};Hr.AUTHORITATIVE_ANSWER=1024;Hr.TRUNCATED_RESPONSE=512;Hr.RECURSION_DESIRED=256;Hr.RECURSION_AVAILABLE=128;Hr.AUTHENTIC_DATA=32;Hr.CHECKING_DISABLED=16;Hr.DNSSEC_OK=32768;Hr.encode=function(t,e,r){let n=!e;n&&(e=Vr.alloc(Hr.encodingLength(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),id.encode(t,e,r),r+=id.encode.bytes,r=t6(t.questions,nd,e,r),r=t6(t.answers,Lo,e,r),r=t6(t.authorities,Lo,e,r),r=t6(t.additionals,Lo,e,r),Hr.encode.bytes=r-i,n&&Hr.encode.bytes!==e.length?e.slice(0,Hr.encode.bytes):e};Hr.encode.bytes=0;Hr.decode=function(t,e){e||(e=0);let r=e,n=id.decode(t,e);return e+=id.decode.bytes,e=UU(n.questions,nd,t,e),e=UU(n.answers,Lo,t,e),e=UU(n.authorities,Lo,t,e),e=UU(n.additionals,Lo,t,e),Hr.decode.bytes=e-r,n};Hr.decode.bytes=0;Hr.encodingLength=function(t){return id.encodingLength(t)+AS(t.questions||[],nd)+AS(t.answers||[],Lo)+AS(t.authorities||[],Lo)+AS(t.additionals||[],Lo)};Hr.streamEncode=function(t){let e=Hr.encode(t),r=Vr.alloc(2);r.writeUInt16BE(e.byteLength);let n=Vr.concat([r,e]);return Hr.streamEncode.bytes=n.byteLength,n};Hr.streamEncode.bytes=0;Hr.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=Hr.decode(t.slice(2));return Hr.streamDecode.bytes=Hr.decode.bytes,r};Hr.streamDecode.bytes=0;function AS(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function t6(t,e,r,n){for(let i=0;i<t.length;i++)e.encode(t[i],r,n),n+=e.encode.bytes;return n}function UU(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e.decode(r,n),n+=e.decode.bytes;return n}});var _Oe=L((Wsr,bOe)=>{"use strict";var vOe=a3t;process.nextTick(s3t,42);bOe.exports=t3t;function t3t(t){var e=n;return r;function r(i){e(i||n3t)}function n(i){var s=[i];e=a,t(c);function a(d){s.push(d)}function c(d){var h=arguments;for(e=r3t(d)?n:p;s.length;)p(s.shift());function p(x){vOe(i3t,x,h)}}}}function r3t(t){return Object.prototype.toString.call(t)==="[object Error]"}function n3t(){}function i3t(t,e){t.apply(null,e)}function s3t(t){t===42&&(vOe=process.nextTick)}function a3t(t,e,r){process.nextTick(function(){t(e,r)})}});var AOe=L((Hsr,SOe)=>{var $se=yOe(),o3t=Kr("dgram"),c3t=_Oe(),u3t=Kr("events"),qse=Kr("os"),jse=function(){};SOe.exports=function(t){t||(t={});var e=new u3t.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",i=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),s={address:i,port:r},a={},c=!1,d=null;if(n==="udp6"&&(!i||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var h=t.socket||o3t.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});h.on("error",function(x){x.code==="EACCES"||x.code==="EADDRINUSE"?e.emit("error",x):e.emit("warning",x)}),h.on("message",function(x,y){try{x=$se.decode(x)}catch(v){e.emit("warning",v);return}e.emit("packet",x,y),x.type==="query"&&e.emit("query",x,y),x.type==="response"&&e.emit("response",x,y)}),h.on("listening",function(){r||(r=s.port=h.address().port),t.multicast!==!1&&(e.update(),d=setInterval(e.update,5e3),h.setMulticastTTL(t.ttl||255),h.setMulticastLoopback(t.loopback!==!1))});var p=c3t(function(x){if(!r||t.bind===!1)return x(null);h.once("error",x),h.bind(r,t.bind||t.interface,function(){h.removeListener("error",x),x(null)})});return p(function(x){if(x)return e.emit("error",x);e.emit("ready")}),e.send=function(x,y,v){if(typeof y=="function")return e.send(x,null,y);v||(v=jse),y?!y.host&&!y.address&&(y.address=s.address):y=s,p(w);function w(S){if(c)return v();if(S)return v(S);var C=$se.encode(x);h.send(C,0,C.length,y.port,y.address||y.host,v)}},e.response=e.respond=function(x,y,v){Array.isArray(x)&&(x={answers:x}),x.type="response",x.flags=(x.flags||0)|$se.AUTHORITATIVE_ANSWER,e.send(x,y,v)},e.query=function(x,y,v,w){if(typeof y=="function")return e.query(x,null,null,y);if(typeof y=="object"&&y&&y.port)return e.query(x,null,y,v);if(typeof v=="function")return e.query(x,y,null,v);w||(w=jse),typeof x=="string"&&(x=[{name:x,type:y||"ANY"}]),Array.isArray(x)&&(x={type:"query",questions:x}),x.type="query",e.send(x,v,w)},e.destroy=function(x){if(x||(x=jse),c)return process.nextTick(x);c=!0,clearInterval(d);for(var y in a)try{h.dropMembership(i,y)}catch{}a={},h.close(x)},e.update=function(){for(var x=t.interface?[].concat(t.interface):f3t(),y=!1,v=0;v<x.length;v++){var w=x[v];if(!a[w])try{h.addMembership(i,w),a[w]=!0,y=!0}catch(S){e.emit("warning",S)}}if(y){if(h.setMulticastInterface)try{h.setMulticastInterface(t.interface||l3t())}catch(S){e.emit("warning",S)}e.emit("networkInterface")}},e};function l3t(){for(var t=qse.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],i=0;i<n.length;i++){var s=n[i];if(wOe(s.family)&&!s.internal)return qse.platform()==="darwin"&&e[r]==="en0"?s.address:"0.0.0.0"}return"127.0.0.1"}function f3t(){for(var t=qse.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var i=t[e[n]],s=0;s<i.length;s++){var a=i[s];if(wOe(a.family)){r.push(a.address);break}}return r}function wOe(t){return t===4||t==="IPv4"}});var gMe={};yi(gMe,{AV1Obu:()=>R7e,AV1RtpPayload:()=>hae,AttributeKeys:()=>GDt,BitStream:()=>Ug,BitWriter:()=>C6,BitWriter2:()=>bM,BufferChain:()=>m3t,CONSENT_FAILURES:()=>Uae,CONSENT_INTERVAL:()=>rUe,COOKIE:()=>DM,Candidate:()=>$g,CandidatePair:()=>Nae,CandidatePairState:()=>nUe,CipherContext:()=>F6,CipherSuite:()=>oM,CipherSuiteList:()=>n7e,Connection:()=>fUe,ConnectionStates:()=>V8t,CurveType:()=>doe,DEFAULT_MAX_MESSAGE_SIZE:()=>RS,DePacketizerBase:()=>xDt,Directions:()=>XU,DtlsClient:()=>Dae,DtlsServer:()=>RBe,DtlsSocket:()=>woe,DtlsStates:()=>n8t,Event:()=>yr,EventDisposer:()=>JNe,ExtensionProfiles:()=>Ng,FINGERPRINT_LENGTH:()=>OBe,FINGERPRINT_XOR:()=>NBe,GenericNack:()=>U6,GroupDescription:()=>US,H264RtpPayload:()=>U7e,HEADER_LENGTH:()=>_p,HashAlgorithm:()=>I6,ICE_COMPLETED:()=>Bae,ICE_FAILED:()=>_6,INTEGRITY_LENGTH:()=>Soe,IPV4_PROTOCOL:()=>Aoe,IPV6_PROTOCOL:()=>Eoe,IceCandidate:()=>Koe,IceGathererStates:()=>l8t,IceTransportStates:()=>u8t,Inactive:()=>SUe,Int:()=>O6,MediaDescription:()=>yM,MediaStream:()=>EUe,MediaStreamTrack:()=>q6,MediaStreamTrackFactory:()=>V6t,Message:()=>sf,NalUnitType:()=>Og,NamedCurveAlgorithm:()=>Ep,NamedCurveAlgorithmList:()=>foe,OpusRtpPayload:()=>L7e,PacketChunk:()=>Y7e,PacketResult:()=>Q7e,PacketStatus:()=>J7e,PictureLossIndication:()=>N6,Profiles:()=>fDt,PromiseQueue:()=>S3t,ProtectionProfileAeadAes128Gcm:()=>Fv,ProtectionProfileAes128CmHmacSha1_80:()=>HS,RETRY_MAX:()=>BBe,RETRY_RTO:()=>UBe,RTCCertificate:()=>Goe,RTCDataChannel:()=>Poe,RTCDataChannelParameters:()=>Roe,RTCDtlsFingerprint:()=>mM,RTCDtlsParameters:()=>gM,RTCDtlsTransport:()=>qae,RTCIceCandidate:()=>BUe,RTCIceGatherer:()=>OUe,RTCIceParameters:()=>Zoe,RTCIceTransport:()=>RUe,RTCP_HEADER_SIZE:()=>lM,RTCPeerConnection:()=>q8t,RTCRtcpFeedback:()=>pUe,RTCRtcpParameters:()=>b6t,RTCRtpCodecParameters:()=>jg,RTCRtpCodingParameters:()=>gUe,RTCRtpHeaderExtensionParameters:()=>Mh,RTCRtpReceiver:()=>ece,RTCRtpRtxParameters:()=>mUe,RTCRtpSender:()=>dMe,RTCRtpSimulcastParameters:()=>Ooe,RTCRtpTransceiver:()=>wUe,RTCSctpCapabilities:()=>Yoe,RTCSctpTransport:()=>oMe,RTCSessionDescription:()=>lMe,RTCStatsReport:()=>_Ue,RTP_EXTENSION_URI:()=>Os,ReceiverEstimatedMaxBitrate:()=>B6,RecvDelta:()=>A6,Recvonly:()=>$oe,Red:()=>voe,RedEncoder:()=>vBe,RedHandler:()=>bBe,RedHeader:()=>Eae,RtcpHeader:()=>kp,RtcpPacketConverter:()=>iBe,RtcpPayloadSpecificFeedback:()=>LS,RtcpReceiverInfo:()=>kM,RtcpRrPacket:()=>$S,RtcpSenderInfo:()=>yoe,RtcpSourceDescriptionPacket:()=>L6,RtcpSrPacket:()=>Cv,RtcpTransportLayerFeedback:()=>Tv,RtpBuilder:()=>BDt,RtpHeader:()=>Tp,RtpPacket:()=>Cp,RtpRouter:()=>fMe,RunLengthChunk:()=>BS,SDPManager:()=>hMe,Sendonly:()=>Loe,Sendrecv:()=>joe,SessionDescription:()=>T6,SignalingStates:()=>H8t,SignatureAlgorithm:()=>Uh,SignatureScheme:()=>sae,SourceDescriptionChunk:()=>goe,SourceDescriptionItem:()=>xoe,SrtcpSession:()=>IBe,SrtpAuthenticationError:()=>kv,SrtpContext:()=>P6,SrtpSession:()=>FBe,SsrcDescription:()=>vM,StatusVectorChunk:()=>Z7e,StunOverTurnProtocol:()=>KBe,StunProtocol:()=>fM,TcpTransport:()=>t7e,TransceiverManager:()=>mMe,TransportWideCC:()=>M6,TurnProtocol:()=>XBe,UdpTransport:()=>aM,Vp8RtpPayload:()=>j7e,Vp9RtpPayload:()=>z7e,WeriftError:()=>E3t,addSDPHeader:()=>ioe,andDirection:()=>Woe,buffer2ArrayBuffer:()=>x3t,bufferArrayXor:()=>h3t,bufferReader:()=>zc,bufferWriter:()=>Vs,bufferWriterLE:()=>$Ne,bufferXor:()=>d3t,candidateFoundation:()=>dM,candidateFromIce:()=>qS,candidateFromSdp:()=>Qoe,candidatePairPriority:()=>hM,candidatePriority:()=>E6,candidateToIce:()=>NUe,candidateToSdp:()=>Joe,certificateTypes:()=>i7e,classes:()=>Toe,codecParametersFromString:()=>H6,codecParametersToString:()=>R8t,compactNtp:()=>Voe,crc32:()=>VNe,crc32c:()=>uoe,createBufferWriter:()=>S6,createSelfSignedCertificate:()=>H6t,createStunOverTurnClient:()=>Rae,createTurnClient:()=>JBe,dePacketizeRtpPackets:()=>yDt,debug:()=>_n,deepMerge:()=>FUe,defaultOptions:()=>iUe,defaultPeerConfig:()=>z8t,depacketizerCodecs:()=>vDt,deserializeAbsSendTime:()=>pBe,deserializeAudioLevelIndication:()=>mBe,deserializeString:()=>dBe,deserializeUint16BE:()=>hBe,deserializeVideoOrientation:()=>gBe,dumpBuffer:()=>g3t,enumerate:()=>bDt,findCodecByMimeType:()=>aoe,findPort:()=>XNe,fingerprint:()=>qoe,generateStatsId:()=>rs,getBit:()=>ir,getDataChannelMessageSize:()=>dUe,getGlobalIp:()=>p6t,getHostAddresses:()=>lUe,getStatsTimestamp:()=>qg,growBufferSize:()=>pae,int:()=>OS,interfaceAddress:()=>wM,isDtls:()=>TUe,isLinkLocalAddress:()=>uUe,isMedia:()=>H7e,isRtcp:()=>sBe,keyLength:()=>D7e,leb128decode:()=>N7e,makeIntegrityKey:()=>QBe,methods:()=>Coe,microTime:()=>kUe,milliTime:()=>Hoe,nodeIpAddress:()=>$ae,normalizeFamilyNodeV18:()=>D6,normalizeFingerprintAlgorithm:()=>zoe,normalizeFingerprintValue:()=>pM,ntpTime:()=>DUe,ntpTime2Sec:()=>nBe,paddingBits:()=>p3t,paddingByte:()=>k6,paddingLength:()=>Fae,parseGroup:()=>iM,parseIceServers:()=>IUe,parseMessage:()=>IM,random16:()=>coe,random32:()=>sM,randomPort:()=>loe,randomPorts:()=>A3t,reverseDirection:()=>CUe,reverseSimulcastDirection:()=>z6t,rtpHeaderExtensionsParser:()=>aBe,saltLength:()=>I7e,serializeAbsSendTime:()=>fBe,serializeAudioLevelIndication:()=>TDt,serializeRepairedRtpStreamId:()=>uBe,serializeSdesMid:()=>oBe,serializeSdesRTPStreamID:()=>cBe,serializeTransportWideCC:()=>lBe,serverReflexiveCandidate:()=>aUe,signatures:()=>hoe,sortCandidatePairs:()=>sUe,supportedAudioCodecs:()=>w6t,supportedCodecs:()=>Moe,supportedVideoCodecs:()=>_6t,timer:()=>_Dt,timestampSeconds:()=>z6,uint16Add:()=>jo,uint16Gt:()=>_M,uint16Gte:()=>w3t,uint24:()=>KNe,uint32Add:()=>bv,uint32Gt:()=>Oh,uint32Gte:()=>PS,uint8Add:()=>GNe,unwrapRtx:()=>wBe,url2Address:()=>m6t,useAV1X:()=>vUe,useAbsSendTime:()=>C6t,useAudioLevelIndication:()=>D6t,useDependencyDescriptor:()=>k6t,useFIR:()=>v6t,useH264:()=>xUe,useNACK:()=>Q6,useOPUS:()=>Boe,usePCMU:()=>Uoe,usePLI:()=>GS,useREMB:()=>e8,useRepairedRtpStreamId:()=>E6t,useSdesMid:()=>S6t,useSdesRTPStreamId:()=>A6t,useTWCC:()=>hUe,useTransportWideCC:()=>T6t,useVP8:()=>Noe,useVP9:()=>yUe,useVideoOrientation:()=>I6t,validateAddress:()=>Lae,validateRemoteCandidate:()=>Mae,wrapRtx:()=>SBe});import{randomBytes as LNe}from"crypto";import{createSocket as ZNe}from"dgram";import{createSocket as T3t}from"dgram";import*as QNe from"node:net";import{connect as C3t}from"node:net";import{createSign as k3t,randomBytes as D3t,webcrypto as I3t}from"crypto";import{createHash as F3t,createHmac as P3t}from"crypto";import{randomBytes as K3t}from"crypto";import{setTimeout as Z3t}from"timers/promises";import{createCipheriv as aDt,createDecipheriv as oDt}from"crypto";import{createHmac as Wse}from"crypto";import{createCipheriv as LOe,createDecipheriv as $Oe,createHmac as jOe,timingSafeEqual as DDt}from"crypto";import{createCipheriv as HOe,createDecipheriv as VOe}from"crypto";import{setTimeout as MDt}from"timers/promises";import{randomBytes as zDt}from"crypto";import{createHmac as MBe}from"crypto";import{randomBytes as LBe}from"crypto";import{createHash as n6t}from"crypto";import{setTimeout as i6t}from"timers/promises";import{createHash as c6t}from"crypto";import{isIPv4 as cNe}from"net";import{randomBytes as u6t}from"crypto";import{isIPv4 as uNe}from"net";import*as Oae from"node:timers/promises";import{randomUUID as f6t}from"crypto";import*as oUe from"node:os";import{EventEmitter as x6t}from"node:events";import{randomUUID as F6t}from"crypto";import{setTimeout as Qse}from"timers/promises";import{createHash as P6t}from"crypto";import{createSocket as R6t}from"dgram";import{performance as dNe}from"perf_hooks";import{randomUUID as O6t}from"crypto";import{randomUUID as AUe}from"crypto";import{setTimeout as Z6t}from"timers/promises";import{randomBytes as Q6t}from"crypto";import{isIPv4 as e8t}from"net";import{randomUUID as t8t}from"crypto";import{setTimeout as r8t}from"timers/promises";import{randomUUID as c8t}from"crypto";import{randomUUID as f8t}from"crypto";import{createHmac as SNe,randomBytes as d8t}from"crypto";import{randomBytes as ONe}from"crypto";import{randomUUID as NNe}from"crypto";import{setTimeout as BNe}from"timers/promises";import{randomUUID as U8t}from"crypto";function coe(){return ooe.jspack.Unpack("!H",LNe(2))[0]}function sM(){return ooe.jspack.Unpack("!L",LNe(4))[0]}function d3t(t,e){if(t.length!==e.length)throw new TypeError("[webrtc-stun] You can not XOR buffers which length are different");let r=t.length,n=Buffer.allocUnsafe(r);for(let i=0;i<r;i++)n[i]=t[i]^e[i];return n}function h3t(t){let e=[...t].sort((n,i)=>n.length-i.length).reverse()[0].length,r=Buffer.allocUnsafe(e);for(let n=0;n<e;n++)r[n]=0,t.forEach(i=>{r[n]^=i[n]??0});return r}function ir(t,e,r=1){let n=t.toString(2).split("");n=[...Array(8-n.length).fill("0"),...n];let i=n.slice(e,e+r).join("");return Number.parseInt(i,2)}function k6(t){let e=t.toString(2).split("");return[...[...Array(8-e.length)].map(()=>"0"),...e].join("")}function p3t(t,e){let r=t.toString(2);return[...[...Array(e-r.length)].map(()=>"0"),...r].join("")}function Vs(t,e){return S6(t)(e)}function S6(t,e){let r=t.reduce((i,s)=>i+s,0),n=e?Buffer.alloc(r):void 0;return i=>{let s=n||Buffer.alloc(r),a=0;return i.forEach((c,d)=>{let h=t[d];h===8?s.writeBigUInt64BE(c,a):s.writeUIntBE(c,a,h),a+=h}),s}}function $Ne(t,e){let r=t.reduce((s,a)=>s+a,0),n=Buffer.alloc(r),i=0;return e.forEach((s,a)=>{let c=t[a];c===8?n.writeBigUInt64LE(s,i):n.writeUIntLE(s,i,c),i+=c}),n}function zc(t,e){let r=0;return e.map(n=>{let i;return n===8?i=t.readBigUInt64BE(r):i=t.readUIntBE(r,n),r+=n,i})}function x3t(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function jNe(t){return typeof t!="string"}function qNe(t){let e=new Array(256),r=0;for(let n=0;n<256;++n)r=n,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,r=r&1?t^r>>>1:r>>>1,e[n]=r;return new Int32Array(e)}function zNe(t){let e=new Int32Array(4096),r=0,n=0,i=0;for(i=0;i<256;++i)e[i]=t[i];for(i=0;i<256;++i)for(n=t[i],r=256+i;r<4096;r+=256)n=e[r]=n>>>8^t[n&255];let s=[];for(i=1;i<16;++i)s[i-1]=e.subarray(i*256,i*256+256);return s}function WNe(t,e,r){let n=e^-1,i=0,s=t.length,a=0,c=0;for(;i<s;)a=t.charCodeAt(i++),a<128?n=n>>>8^r[(n^a)&255]:a<2048?(n=n>>>8^r[(n^(192|a>>6&31))&255],n=n>>>8^r[(n^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,c=t.charCodeAt(i++)&1023,n=n>>>8^r[(n^(240|a>>8&7))&255],n=n>>>8^r[(n^(128|a>>2&63))&255],n=n>>>8^r[(n^(128|c>>6&15|(a&3)<<4))&255],n=n>>>8^r[(n^(128|c&63))&255]):(n=n>>>8^r[(n^(224|a>>12&15))&255],n=n>>>8^r[(n^(128|a>>6&63))&255],n=n>>>8^r[(n^(128|a&63))&255]);return~n>>>0}function HNe(t,e,r,n){let[i,s,a,c,d,h,p,x,y,v,w,S,C,k,T]=n,E=e^-1,I=0,R=t.length-15;for(;I<R;)E=T[t[I++]^E&255]^k[t[I++]^E>>>8&255]^C[t[I++]^E>>>16&255]^S[t[I++]^E>>>24]^w[t[I++]]^v[t[I++]]^y[t[I++]]^x[t[I++]]^p[t[I++]]^h[t[I++]]^d[t[I++]]^c[t[I++]]^a[t[I++]]^s[t[I++]]^i[t[I++]]^r[t[I++]];for(R+=15;I<R;)E=E>>>8^r[(E^t[I++])&255];return~E>>>0}function VNe(t,e=0){return jNe(t)?HNe(t,e,nae,b3t):WNe(t,e,nae)}function uoe(t,e=0){return jNe(t)?HNe(t,e,iae,_3t):WNe(t,e,iae)}function GNe(t,e){return t+e&255}function jo(t,e){return t+e&65535}function bv(t,e){return Number(BigInt(t)+BigInt(e)&0xffffffffn)}function KNe(t){return t&16777215}function _M(t,e){return t<e&&e-t>32768||t>e&&t-e<32768}function w3t(t,e){return t===e||_M(t,e)}function Oh(t,e){return t<e&&e-t>2147483648||t>e&&t-e<2147483648}function PS(t,e){return t===e||Oh(t,e)}async function loe(t="udp4",e){let r=ZNe(t);setImmediate(()=>r.bind({port:0,address:wM(t,e)})),await new Promise(i=>{r.once("error",i),r.once("listening",i)});let n=r.address()?.port;return await new Promise(i=>r.close(()=>i())),n}async function A3t(t,e="udp4",r){return Promise.all([...Array(t)].map(()=>loe(e,r)))}async function XNe(t,e,r="udp4",n){let i;for(let s=t;s<=e;s++){let a=ZNe(r);if(setImmediate(()=>a.bind({port:s,address:wM(r,n)})),await new Promise(d=>{a.once("error",h=>d(h)),a.once("listening",()=>d())})){await new Promise(d=>a.close(()=>d()));continue}if(i=a.address()?.port,await new Promise(d=>a.close(()=>d())),t<=i&&i<=e)break}if(!i)throw new Error("port not found");return i}function D6(t){return t==="IPv4"?4:t==="IPv6"?6:t}function o7e(t,e,r){switch(r){case Ep.secp256r1_23:return O3t({publicKey:t,privateKey:e});case Ep.x25519_29:return Buffer.from(a7e.default.scalarMult(e,t));default:throw new Error}}function TOe(t,e,r){let n=P3t(t,e);return n.update(r),n.digest()}function V6(t,e,r,n="sha256"){let i=r,s=[],a=e;do{a=TOe(n,t,a);let c=TOe(n,t,Buffer.concat([a,e]));s.push(c),r-=c.length}while(r>0);return Buffer.concat(s,i)}function c7e(t,e,r){let n=Buffer.concat([Buffer.from("master secret"),e,r]);return V6(t,n,48)}function u7e(t,e){let r=l7e("sha256",e);return V6(t,Buffer.concat([Buffer.from("extended master secret"),r]),48)}function N3t(t,e,r,n,i,s){let a=s?n:i,c=s?i:n,d=Buffer.concat([Buffer.from(t),a,c]);return V6(r,d,e)}function l7e(t,e){return F3t(t).update(e).digest()}function f7e(t,e,r,n=12){let i=l7e("sha256",e);return V6(t,Buffer.concat([Buffer.from(r),i]),n)}function B3t(t,e){return f7e(t,e,"client finished")}function U3t(t,e){return f7e(t,e,"server finished")}function M3t(t,e,r,n,i,s,a="sha256"){let c=n*2+i*2,d=t,h=Buffer.concat([r,e]),p=V6(d,Buffer.concat([Buffer.from("key expansion"),h]),c,a),x=(0,s7e.createDecode)(p),y=x.readBuffer(n),v=x.readBuffer(n),w=x.readBuffer(i),S=x.readBuffer(i),C=Buffer.alloc(s,0),k=Buffer.alloc(s,0);return w.copy(C,0),S.copy(k,0),{clientWriteKey:y,serverWriteKey:v,clientNonce:C,serverNonce:k}}function tDt(){let t=new Y6;return t.id=X6.RSA,t.name="RSA",t.keyType=Z6.RSA,t}function rDt(){let t=new Y6;return t.id=X6.ECDHE_RSA,t.name="ECDHE_RSA",t.signType=AM.ECDHE,t.keyType=Z6.RSA,t}function nDt(){let t=new Y6;return t.id=X6.ECDHE_ECDSA,t.name="ECDHE_ECDSA",t.signType=AM.ECDHE,t.keyType=Z6.ECDSA,t}function iDt(){let t=new Y6;return t.id=X6.PSK,t.name="PSK",t.signType=AM.NULL,t.keyType=Z6.PSK,t}function sDt(){let t=new Y6;return t.id=X6.ECDHE_PSK,t.name="ECDHE_PSK",t.signType=AM.ECDHE,t.keyType=Z6.PSK,t}function y7e(t){switch(t){case Oa.TLS_RSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_RSA_WITH_AES_128_GCM_SHA256,"TLS_RSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",COe,r6);case Oa.TLS_RSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_RSA_WITH_AES_256_GCM_SHA384,"TLS_RSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",COe,n6,"sha384");case Oa.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",kOe,r6);case Oa.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",kOe,n6,"sha384");case Oa.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","aes-128-gcm",DOe,r6);case Oa.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","aes-256-gcm",DOe,n6,"sha384");case Oa.TLS_PSK_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_PSK_WITH_AES_128_GCM_SHA256,"TLS_PSK_WITH_AES_128_GCM_SHA256","aes-128-gcm",IOe,r6,"sha256");case Oa.TLS_PSK_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_PSK_WITH_AES_256_GCM_SHA384,"TLS_PSK_WITH_AES_256_GCM_SHA384","aes-256-gcm",IOe,n6,"sha384");case Oa.TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256:return Ph(Oa.TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256,"TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256","aes-128-gcm",FOe,r6,"sha256");case Oa.TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384:return Ph(Oa.TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384,"TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384","aes-256-gcm",FOe,n6,"sha384");default:break}return null}function Ph(t,e,r,n,i,s="sha256"){let a=new uDt;return a.id=t,a.name=e,a.blockAlgorithm=r,a.kx=n,a.hashAlgorithm=s,a.keyLength=i.K_LEN,a.nonceLength=i.N_MAX,a.nonceImplicitLength=4,a.nonceExplicitLength=8,a.ivLength=a.nonceImplicitLength,a.authTagLength=16,a}function b7e(t){switch(t){case Ep.secp256r1_23:{let{privateKey:e,publicKey:r}=R3t();return{curve:t,privateKey:e,publicKey:r}}case Ep.x25519_29:{let e=v7e.default.box.keyPair();return{curve:t,privateKey:Buffer.from(e.secretKey.buffer),publicKey:Buffer.from(e.publicKey.buffer)}}default:throw new Error}}function lDt(t,e){return Buffer.from((0,C7e.encode)(t,e).slice())}function N7e(t){let e=0,r=0;for(let n=0;n<8;n++){let i=t.readUInt8(n);if(e|=(i&127)<<n*7,r++,!(i&128))break}return[e,r]}function yDt(t,e,r){let n=i=>{let s=[];for(let d of e){let h=i.deSerialize(d.payload,r);h.fragment?(r??=Buffer.alloc(0),r=h.fragment):h.payload&&(r=void 0),s.push(h)}let a=!!s.find(d=>d.isKeyframe),c=Buffer.concat(s.map(d=>d.payload).filter(d=>d));return{isKeyframe:a,data:c,sequence:e.at(-1)?.header.sequenceNumber??0,timestamp:e.at(-1)?.header.timestamp??0,frameFragmentBuffer:r}};switch(t.toUpperCase()){case"AV1":{let i=e.map(c=>hae.deSerialize(c.payload)),s=!!i.find(c=>c.isKeyframe),a=hae.getFrame(i);return{isKeyframe:s,data:a,sequence:e.at(-1)?.header.sequenceNumber??0,timestamp:e.at(-1)?.header.timestamp??0}}case"MPEG4/ISO/AVC":return n(U7e);case"VP8":return n(j7e);case"VP9":return n(z7e);case"OPUS":return n(L7e);default:throw new Error}}function bDt(t){return t.map((e,r)=>[r,e])}function pae(t,e){let r=Buffer.alloc(e);return t.copy(r),r}function O6(t){return Number.parseInt(t.toString(),10)}function H7e(t){let e=t[0];return e>127&&e<192}function ROe(t){return t%4==0?0:4-t%4}function sBe(t){return t.length>=2&&t[1]>=192&&t[1]<=208}function aBe(t,e){return t.map(r=>{let n=e[r.id];if(!n)return{uri:"unknown",value:r.payload};switch(n){case Os.sdesMid:case Os.sdesRTPStreamID:case Os.repairedRtpStreamId:return{uri:n,value:dBe(r.payload)};case Os.transportWideCC:return{uri:n,value:hBe(r.payload)};case Os.absSendTime:return{uri:n,value:pBe(r.payload)};case Os.audioLevelIndication:return{uri:n,value:mBe(r.payload)};case Os.videoOrientation:return{uri:n,value:gBe(r.payload)};default:return{uri:n,value:r.payload}}}).reduce((r,n)=>(n&&(r[n.uri]=n.value),r),{})}function oBe(t){return Buffer.from(t)}function cBe(t){return Buffer.from(t)}function uBe(t){return Buffer.from(t)}function lBe(t){return Vs([2],[t])}function fBe(t){let e=Buffer.alloc(3),r=t>>14n&0x00ffffffn;return e.writeUIntBE(Number(r),0,3),e}function TDt(t){let e=new Ug(Buffer.alloc(1));return e.writeBits(1,1),e.writeBits(7,t),e.uint8Array}function dBe(t){return t.toString()}function hBe(t){return t.readUInt16BE()}function pBe(t){return zc(t,[3])[0]}function mBe(t){let e=new Ug(t);return{v:e.readBits(1)===1,level:e.readBits(7)}}function gBe(t){let e=new Ug(t);return e.readBits(4),{c:e.readBits(1),f:e.readBits(1),r1:e.readBits(1),r0:e.readBits(1)}}function wBe(t,e,r){return new Cp(new Tp({payloadType:e,marker:t.header.marker,sequenceNumber:boe.jspack.Unpack("!H",t.payload.subarray(0,2))[0],timestamp:t.header.timestamp,ssrc:r}),t.payload.subarray(2))}function SBe(t,e,r,n){return new Cp(new Tp({payloadType:e,marker:t.header.marker,sequenceNumber:r,timestamp:t.header.timestamp,ssrc:n,csrc:t.header.csrc,extensions:t.header.extensions}),Buffer.concat([Buffer.from(boe.jspack.Pack("!H",[t.header.sequenceNumber])),t.payload]))}function _oe(t,e,r="Failed to authenticate SRTP packet"){let n=t.length-e;$6(t.length>=qOe+e,r);let i=TBe(()=>Tp.deSerialize(t.subarray(0,n)),r);return i.paddingSize=0,$6(i.payloadOffset>=qOe&&i.payloadOffset<=n,r),i}function EBe(t,e,r,n="Failed to authenticate SRTCP packet"){return $6(t.length>=IDt+e+r,n),TBe(()=>kp.deSerialize(t.subarray(0,lM)),n)}function $6(t,e){if(!t)throw new kv(e)}function TBe(t,e){try{return t()}catch{throw new kv(e)}}function CBe(t,e,r="Failed to authenticate SRTP packet"){if(!t.padding)return t.paddingSize=0,t;$6(e.length>t.payloadOffset,r);let n=e[e.length-1];return $6(n>0&&n<=e.length-t.payloadOffset,r),t.paddingSize=n,t}function WOe(t,e,r){if(t.length!==e.length||!DDt(t,e))throw new kv(r)}function KOe(t,e){try{t.final()}catch{throw new kv(`Failed to authenticate ${e} packet`)}}function s6(t){return LBe(t).toString("hex").substring(0,t)}function $Be(){return LBe(12)}function DS(t){let[e]=t,r=j6.default.isV4Format(e)?Aoe:Eoe,n=Buffer.alloc(4);return n.writeUInt8(0,0),n.writeUInt8(r,1),n.writeUInt16BE(t[1],2),Buffer.concat([n,j6.default.toBuffer(e)])}function KDt(t){if(t.length<4)throw new Error("STUN error code is less than 4 bytes");let e=t.readUInt8(2),r=t.readUInt8(3),n=t.slice(4).toString("utf8");return[e*100+r,n]}function IS(t){if(t.length<4)throw new Error("STUN address length is less than 4 bytes");let e=t.readUInt8(1),r=t.readUInt16BE(2),n=t.slice(4);switch(e){case Aoe:if(n.length!=4)throw new Error("STUN address has invalid length for IPv4");return[j6.default.toString(n),r];case Eoe:if(n.length!=16)throw new Error("STUN address has invalid length for IPv6");return[j6.default.toString(n),r];default:throw new Error("STUN address has unknown protocol")}}function jBe(t,e){let r=[...koe,...e],n=t.slice(0,2);for(let i=2;i<t.length;i++){let s=t[i]^r[i-2],a=Buffer.alloc(1);a.writeUIntBE(s,0,1),n=Buffer.concat([n,a])}return n}function VU(t,e){return IS(jBe(t,e))}function ZDt(t){let e=Buffer.alloc(4);e.writeUInt16BE(0,0),e.writeUInt8(Math.floor(t[0]/100),2),e.writeUInt8(t[0]%100,3);let r=Buffer.from(t[1],"utf8");return Buffer.concat([e,r])}function GU(t,e){return jBe(DS(t),e)}function IM(t,e){if(t.length<_p)return;let r=t.readUint16BE(2);if(t.length!==_p+r)return;let n=t.readUint16BE(0),i=Buffer.from(t.slice(_p-12,_p)),s=new zBe;for(let c=_p;c<=t.length-4;){let d=t.readUInt16BE(c),h=t.readUInt16BE(c+2),p=t.slice(c+4,c+4+h),x=4*Math.floor((h+3)/4)-h;if(Object.keys(sNe).includes(d.toString())){let[,v,,w]=sNe[d];if(w.name===VU.name?s.setAttribute(v,w(p,i)):s.setAttribute(v,w(p)),v==="FINGERPRINT"){let S=WBe(t.slice(0,c));if(s.getAttributeValue("FINGERPRINT")!==S)return}else if(v==="MESSAGE-INTEGRITY"&&e){let S=t6t(t.slice(0,c),e),C=s.getAttributeValue("MESSAGE-INTEGRITY");if(!S.equals(C))return}}c+=4+h+x}let a=s.getAttributes();return s.clear(),new sf(n&16111,n&272,i,a)}function WBe(t){let e=Doe(t,t.length-_p+OBe);return(VNe(e)^NBe)>>>0}function t6t(t,e){let r=Doe(t,t.length-_p+Soe);return Buffer.from(MBe("sha1",e).update(r).digest("hex"),"hex")}function Fae(t){let e=t%4;return e===0?0:4-e}async function JBe({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a}={}){n??=a6t,a??="udp";let c=a==="udp"?await aM.init("udp4",{portRange:i,interfaceAddresses:s}):await t7e.init(t),d=new XBe(t,e,r,n,c);return await d.connectionMade(),d}async function Rae({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a}={}){let c=await JBe({address:t,username:e,password:r},{lifetime:n,portRange:i,interfaceAddresses:s,transport:a});return new KBe(c)}function QBe(t,e,r){return n6t("md5").update(Buffer.from([t,e,r].join(":"))).digest()}function oNe(t){return(t[0]&192)==64}function dM(t,e,r){let n=`${t}|${e}|${r}`;return c6t("md5").update(n,"ascii").digest("hex").slice(7)}function E6(t,e=65535){let n=0;return t==="host"?n=126:t==="prflx"?n=110:t==="srflx"?n=100:n=0,(1<<24)*n+256*e+255}function Mae(t){if(!["host","relay","srflx"].includes(t.type))throw new Error(`Unexpected candidate type "${t.type}"`);return t}function sUe(t,e){return t.sort((r,n)=>hM(r.localCandidate,r.remoteCandidate,e)-hM(n.localCandidate,n.remoteCandidate,e)).reverse()}function hM(t,e,r){let n=r&&t.priority||e.priority,i=r&&e.priority||t.priority;return 1*Math.min(n,i)+2*Math.max(n,i)+(n>i?1:0)}async function aUe(t,e){let r=new sf(1,0);try{let[n]=await t.request(r,e),i=t.localCandidate;if(!i)throw new Error("not exist");return new $g(dM("srflx","udp",i.host),i.component,i.transport,E6("srflx"),n.getAttributeValue("XOR-MAPPED-ADDRESS")[0],n.getAttributeValue("XOR-MAPPED-ADDRESS")[1],"srflx",i.host,i.port)}catch(n){d6t("error serverReflexiveCandidate",n)}}function Lae(t){return t&&Number.isNaN(t[1])?[t[0],443]:t}async function p6t(t,e){let r=new fM;await r.connectionMade(!0,void 0,e);let n=new sf(1,0),[i]=await r.request(n,t??["stun.l.google.com",19302]);return await r.close(),i.getAttributeValue("XOR-MAPPED-ADDRESS")[0]}function uUe(t){return D6(t.family)===4&&t.address?.startsWith("169.254.")||D6(t.family)===6&&t.address?.startsWith("fe80::")}function $ae(t,{useLinkLocalAddress:e}={}){let r=["ipsec","tun","utun","tap"],n=["vmnet","veth"],i=oUe.networkInterfaces();h6t(i);let s=Object.keys(i).map(a=>{for(let d of[...r,...n])if(a.startsWith(d))return{nic:a,addresses:[]};let c=i[a].filter(d=>D6(d.family)===t&&!cUe.default.isLoopback(d.address)&&(e?!0:!uUe(d)));return{nic:a,addresses:c.map(d=>d.address)}}).filter(a=>!!a);return s.sort((a,c)=>a.nic.localeCompare(c.nic)),Object.values(s).flatMap(a=>a.addresses)}function lUe(t,e,r={}){let n=[];return t&&n.push(...$ae(4,r)),e&&n.push(...$ae(6,r)),n}function fNe(t){return t.map((e,r)=>[r,e])}function bp(t,e){let r=t.split(e);return[r[0],r.slice(1).join(e)]}function dUe(t){return Buffer.isBuffer(t)?t.length:Buffer.byteLength(t)}function S6t(){return new Mh({uri:Os.sdesMid})}function A6t(){return new Mh({uri:Os.sdesRTPStreamID})}function E6t(){return new Mh({uri:Os.repairedRtpStreamId})}function T6t(){return new Mh({uri:Os.transportWideCC})}function C6t(){return new Mh({uri:Os.absSendTime})}function k6t(){return new Mh({uri:Os.dependencyDescriptor})}function D6t(){return new Mh({uri:Os.audioLevelIndication})}function I6t(){return new Mh({uri:Os.videoOrientation})}function rs(t,...e){let r=e.filter(n=>n!==void 0);return`${t}_${r.join("_")}`}function qg(){return performance.now()}function qoe(t,e){let r=s=>s.toUpperCase(),n=s=>s.match(/(.{2})/g).join(":"),i=P6t(e).update(t).digest("hex");return n(r(i))}function zoe(t){return q6t[t.trim().toLowerCase()]}function pM(t){return t.replace(/[^0-9a-f]/gi,"").toLowerCase()}function TUe(t){let e=t[0];return e>19&&e<64}function z6t(t){return t==="recv"?"send":"recv"}function CUe(t){return t==="sendonly"?"recvonly":t==="recvonly"?"sendonly":t}function IUe(t){let e=c=>{if(!c)return;let[d,h]=c.split(":");return[d,Number.parseInt(h)]},r=e(t.find(({urls:c})=>c.includes("stun:"))?.urls.slice(5)),n=e(t.find(({urls:c})=>c.includes("turn:"))?.urls.slice(5)),{credential:i,username:s}=t.find(({urls:c})=>c.includes("turn:"))||{},a={stunServer:r,turnServer:n,turnUsername:s,turnPassword:i};return j6t("iceOptions",a),a}function qS(t){let e=new Koe(t.component,t.foundation,t.host,t.port,t.priority,t.transport,t.type,t.generation,t.ufrag);return e.relatedAddress=t.relatedAddress,e.relatedPort=t.relatedPort,e.tcpType=t.tcptype,e}function NUe(t){return new $g(t.foundation,t.component,t.protocol,t.priority,t.ip,t.port,t.type,t.relatedAddress,t.relatedPort,t.tcpType,t.generation,t.ufrag)}function r8(t){let e=t%4;return e?4-e:0}function nMe(t){let e=Buffer.from(""),r=Buffer.from("");return t.forEach(([n,i])=>{let s=i.length+4,a=Buffer.alloc(4);a.writeUInt16BE(n,0),a.writeUInt16BE(s,2),e=Buffer.concat([e,r,a,i]),r=Buffer.concat([...Array(r8(s))].map(()=>Buffer.from("\0")))}),e}function iMe(t){let e=[],r=0;for(;r<=t.length-4;){let n=t.readUInt16BE(r),i=t.readUInt16BE(r+2);e.push([n,t.slice(r+4,r+i)]),r+=i+r8(i)}return e}function g8t(t){if(t.length<12)throw new Error("SCTP packet length is less than 12 bytes");let e=t.readUInt16BE(0),r=t.readUInt16BE(2),n=t.readUInt32BE(4),i=t.readUInt32LE(8),s=uoe(Buffer.concat([t.slice(0,8),Buffer.from("\0\0\0\0"),t.slice(12)]));if(i!==s)throw new Error("SCTP packet has invalid checksum");let a=[],c=12;for(;c+4<=t.length;){let d=t.readUInt8(c),h=t.readUInt8(c+1),p=t.readUInt16BE(c+2),x=t.slice(c+4,c+p),y=m8t[d.toString()];if(y)a.push(new y(h,x));else throw new Error("unknown");c+=p+r8(p)}return[e,r,n,a]}function x8t(t,e,r,n){let i=Buffer.alloc(8);i.writeUInt16BE(t,0),i.writeUInt16BE(e,2),i.writeUInt32BE(r,4);let s=n.bytes,a=uoe(Buffer.concat([i,Buffer.from("\0\0\0\0"),s])),c=Buffer.alloc(4);return c.writeUInt32LE(a,0),Buffer.concat([i,c,s])}function y8t(t){return t.map((e,r)=>[r,e])}function v8t(t){return t.reduce((e,r)=>(e[r]=new yr,e),{})}function yv(t){return(t-1)%xM}function FS(t){return(t+1)%xM}function eae(t){let e=t.match(/^IN (IP4|IP6) ([^ ]+)$/);if(!e)throw new Error("exception");return e[2]}function noe(t){return`IN IP${e8t(t)?4:6} ${t}`}function Joe(t){let e=`${t.foundation} ${t.component} ${t.protocol} ${t.priority} ${t.ip} ${t.port} typ ${t.type}`;return t.relatedAddress!=null&&(e+=` raddr ${t.relatedAddress}`),t.relatedPort!=null&&(e+=` rport ${t.relatedPort}`),t.tcpType!=null&&(e+=` tcptype ${t.tcpType}`),t.generation!=null&&(e+=` generation ${t.generation}`),t.ufrag!=null&&(e+=` ufrag ${t.ufrag}`),e}function P8t(t){let e=[],r=[],n=t.split(`\r
1108
1117
  `);return n.length===1&&(n=t.split(`
1109
- `)),n.forEach(i=>{i.startsWith("m=")?r.push([i]):r.length>0?r[r.length-1].push(i):e.push(i)}),[e,r]}function tae(t){if(t.includes(":")){let e=bp(t.slice(2),":");return[e[0],e[1]]}else return[t.slice(2),void 0]}function iM(t,e,r=n=>n.toString()){let n=e.split(" ");n.length>0&&t.push(new US(n[0],n.slice(1).map(r)))}function Qoe(t){let e=$g.fromSdp(t);return qS(e)}function ioe(t,e){let n=new OU(QDt(64)).toString().slice(0,8),i=0;e.origin=`- ${n} ${i} IN IP4 0.0.0.0`,e.msidSemantic.push(new US("WMS",["*"])),e.type=t}function HD(t){let e={};return t.split(";").forEach(r=>{if(r.includes("=")){let[n,i]=bp(r,"=");LDt.includes(n)?e[n]=Number(i):e[n]=i}else if(r.includes(":")){let[n,i]=r.split(":");e[n]=Number.isNaN(Number(i))?i:Number(i)}else e[r]=void 0}),e}function R8t(t,e="="){let r=Object.entries(t).map(([n,i])=>i?`${n}${e}${i}`:n);if(r.length>0)return r.join(";")}function pMe(){return{codecs:{audio:[Boe(),Uoe()],video:[Noe()]},headerExtensions:{audio:[],video:[]},iceTransportPolicy:"all",iceServers:[{urls:"stun:stun.l.google.com:19302"}],icePortRange:void 0,iceInterfaceAddresses:void 0,iceAdditionalHostAddresses:void 0,iceUseIpv4:!0,iceUseIpv6:!0,iceFilterStunResponse:void 0,iceFilterCandidatePair:void 0,icePasswordPrefix:void 0,iceUseLinkLocalAddress:void 0,dtls:{},bundlePolicy:"max-compat",debug:{},midSuffix:!1,forceTurnTCP:!1,maxMessageSize:RS}}var ooe,YNe,SM,zS,NS,s7e,a7e,$o,ud,h7e,_v,wp,v7e,Sv,Mg,Av,WS,Lg,Ev,ld,fd,CM,cd,C7e,F7e,boe,WU,Dv,vv,Bh,Nh,Iv,jD,Pae,KU,tUe,cUe,WD,YU,JU,Sp,soe,CD,bM,m3t,g3t,Ug,y3t,v3t,nae,b3t,iae,_3t,OS,S3t,wM,E3t,_n,yr,JNe,EOe,aM,t7e,Uh,ID,oM,n7e,Ep,foe,doe,sae,i7e,hoe,R3t,O3t,Ap,L3t,aae,FD,PD,poe,d7e,af,cM,$3t,p7e,j3t,RD,q3t,z3t,oae,W3t,H3t,V3t,G3t,moe,wv,m7e,X3t,g7e,x7e,GD,uae,Y3t,zse,KD,J3t,Q3t,e6t,AM,ZD,XD,YD,c6t,u6t,Oa,rD,nD,COe,kOe,DOe,IOe,FOe,EM,TM,MS,uM,_7e,w7e,S7e,fae,A7e,E7e,T7e,k7e,HS,Fv,f6t,D7e,I7e,d6t,hae,R7e,B7e,h6t,U7e,Og,p6t,m6t,g6t,L7e,j7e,z7e,x6t,v6t,_6t,lM,kp,POe,ND,BD,w6t,LS,$S,kM,G7e,UD,S6t,MD,BS,Z7e,AD,Y7e,J7e,Q7e,A6t,Tv,LD,goe,xoe,Cv,yoe,nBe,E6t,iBe,Os,C6t,voe,Eae,vBe,k6t,bBe,Ng,OOe,NOe,BOe,UOe,MOe,Tp,Cp,ABe,kv,qOe,I6t,F6t,zOe,P6t,Hse,GOe,kBe,iD,ZOe,R6t,O6t,DBe,IBe,N6t,FBe,B6t,qc,U6t,VS,PBe,L6t,XOe,$6t,Cae,kae,YOe,JOe,Vse,j6t,q6t,QOe,eNe,woe,Gse,Dae,Rh,W6t,tNe,H6t,jS,V6t,JD,ES,RBe,DM,OBe,NBe,_p,Soe,Aoe,Eoe,BBe,UBe,G6t,Toe,Coe,rNe,Iae,koe,aD,oD,X6t,Y6t,nNe,iNe,Kse,Zse,Xse,Yse,J6t,Q6t,qBe,zBe,sNe,eDt,sf,Doe,HBe,VBe,rDt,Jse,Ioe,aNe,fM,Nu,sDt,aDt,oDt,KBe,XBe,$g,lDt,dDt,Nae,Bae,_D,rUe,Uae,nUe,iUe,hDt,mDt,Gi,fUe,gDt,lNe,Foe,yDt,Poe,Roe,vDt,QD,GS,e8,hUe,jg,Mh,bDt,pUe,mUe,gUe,Ooe,xUe,Noe,yUe,vUe,Boe,Uoe,Moe,_Dt,wDt,hNe,pNe,NDt,LU,mNe,gNe,BDt,UDt,MDt,xNe,jae,yNe,LDt,bUe,vNe,ZU,$Dt,_Ue,wUe,SUe,Loe,$oe,joe,XU,qD,EUe,jDt,qDt,Woe,Hoe,WDt,kUe,zD,DUe,Voe,HDt,VDt,FUe,GDt,bNe,KDt,XDt,YDt,JDt,sd,qae,n8t,Goe,mM,gM,i8t,s8t,a8t,o8t,_Ne,wNe,RUe,u8t,l8t,OUe,BUe,Koe,Zoe,Lh,Xoe,QU,zae,h8t,eM,tM,Wae,Hae,t8,Vae,rM,Kae,GUe,Zae,Xae,YUe,QUe,tMe,p8t,m8t,Yae,sMe,$U,nM,ANe,Di,b8t,_8t,ENe,ad,wD,aMe,toe,TNe,w8t,CNe,kNe,DNe,S8t,A8t,xM,E8t,T8t,INe,FNe,PNe,RNe,C8t,k8t,D8t,I8t,TS,RS,oMe,Yoe,F8t,TD,yM,US,lMe,vM,jU,ece,cD,fMe,O8t,CS,N8t,B8t,rae,UNe,MNe,dMe,M8t,L8t,hMe,uD,$8t,j8t,od,q8t,aoe,z8t,W8t,mMe,H8t,V8t,xMe=ce(()=>{ooe=an($m(),1),YNe=an(k3e(),1),SM=an(XQ(),1),zS=an(pPe(),1),NS=an(Hs(),1),s7e=an(Hs(),1),a7e=an(vO(),1);Y9e();$o=an(Hs(),1),ud=an(Hs(),1),h7e=an(Hs(),1),_v=an(Hs(),1),wp=an(Hs(),1),v7e=an(vO(),1),Sv=an(Hs(),1),Mg=an(Hs(),1),Av=an(Hs(),1),WS=an(Hs(),1),Lg=an(Hs(),1),Ev=an(Hs(),1),ld=an(Hs(),1),fd=an(Hs(),1),CM=an(Hs(),1),cd=an(Hs(),1),C7e=an(Hs(),1),F7e=an(Q9e(),1),boe=an($m(),1),WU=an(tOe(),1),Dv=an(Hs(),1),vv=an(Hs(),1),Bh=an(Hs(),1),Nh=an(Hs(),1),Iv=an(Hs(),1);NU();jD=an(Ise(),1),Pae=an($m(),1);NU();KU=an(k9(),1),tUe=an(AOe(),1),cUe=an(Ise(),1);NU();WD=an(XQ(),1),YU=an($m(),1),JU=an($m(),1),Sp=an($m(),1),soe=an($m(),1);CD=class{constructor(t){this.bitLength=t}value=0;set(t,e,r){return r&=(1<<t)-1,this.value|=r<<this.bitLength-t-e,this}get buffer(){let t=Math.ceil(this.bitLength/8),e=Buffer.alloc(t);return e.writeUIntBE(this.value,0,t),e}},bM=class{constructor(t){if(this.bitLength=t,t>32)throw new Error}_value=0n;offset=0n;set(t,e=1){let r=BigInt(t),n=BigInt(e);return r&=(1n<<n)-1n,this._value|=r<<BigInt(this.bitLength)-n-this.offset,this.offset+=n,this}get value(){return Number(this._value)}get buffer(){let t=Math.ceil(this.bitLength/8),e=Buffer.alloc(t);return e.writeUIntBE(this.value,0,t),e}};m3t=class{buffer;constructor(t){this.buffer=Buffer.alloc(t)}writeInt16BE(t,e){return this.buffer.writeInt16BE(t,e),this}writeUInt8(t,e){return this.buffer.writeUInt8(t,e),this}},g3t=t=>"0x"+t.toString("hex").replace(/(.)(.)/g,"$1$2 ").split(" ").filter(e=>e!=null&&e.length>0).join(",0x");Ug=class{constructor(t){this.uint8Array=t}position=0;bitsPending=0;writeBits(t,e){if(t==0)return this;e&=4294967295>>>32-t;let r;return this.bitsPending>0?this.bitsPending>t?(this.uint8Array[this.position-1]|=e<<this.bitsPending-t,r=t,this.bitsPending-=t):this.bitsPending==t?(this.uint8Array[this.position-1]|=e,r=t,this.bitsPending=0):(this.uint8Array[this.position-1]|=e>>t-this.bitsPending,r=this.bitsPending,this.bitsPending=0):(r=Math.min(8,t),this.bitsPending=8-r,this.uint8Array[this.position++]=e>>t-r<<this.bitsPending),t-=r,t>0&&this.writeBits(t,e),this}readBits(t){return this._readBits(t)}_readBits(t,e){if(typeof e>"u"&&(e=0),t==0)return e;let r,n;if(this.bitsPending>0){let i=this.uint8Array[this.position-1]&255>>8-this.bitsPending;n=Math.min(this.bitsPending,t),this.bitsPending-=n,r=i>>this.bitsPending}else n=Math.min(8,t),this.bitsPending=8-n,r=this.uint8Array[this.position++]>>this.bitsPending;return t-=n,e=e<<n|r,t>0?this._readBits(t,e):e}seekTo(t){this.position=t/8|0,this.bitsPending=t%8,this.bitsPending>0&&(this.bitsPending=8-this.bitsPending,this.position++)}},y3t=3988292384,v3t=2197175160;nae=qNe(y3t),b3t=zNe(nae),iae=qNe(v3t),_3t=zNe(iae);OS=t=>Number.parseInt(t,10),S3t=class{queue=[];running=!1;push=t=>new Promise((e,r)=>{this.queue.push({promise:t,done:e,failed:r}),this.running||this.run()});async run(){let t=this.queue.shift();if(t){this.running=!0;try{let e=await t.promise();t.done(e)}catch(e){t.failed(e)}this.run()}else this.running=!1}cancel(){this.queue=[]}},wM=(t,e)=>e?e[t]:void 0;E3t=class extends Error{message;payload;path;constructor(t){super(t.message)}toJSON(){return{message:this.message,payload:JSON.parse(JSON.stringify(this.payload)),path:this.path}}},_n=YNe.default.debug,yr=class{event={stack:[],promiseStack:[],eventId:0};ended=!1;onended;onerror=t=>{};execute=(...t)=>{if(!this.ended){for(let e of this.event.stack)e.execute(...t);(async()=>{for(let e of this.event.promiseStack)await e.execute(...t)})().catch(e=>{this.onerror(e)})}};complete=()=>{if(!this.ended){for(let t of this.event.stack)t.complete&&t.complete();this.allUnsubscribe(),this.ended=!0,this.onended&&(this.onended(),this.onended=void 0)}};error=t=>{if(!this.ended){for(let e of this.event.stack)e.error&&e.error(t);this.allUnsubscribe()}};allUnsubscribe=()=>{if(this.ended)throw new Error("event completed");this.event={stack:[],promiseStack:[],eventId:0}};subscribe=(t,e,r)=>{let n=this.event.eventId;this.event.stack.push({execute:t,id:n,complete:e,error:r}),this.event.eventId++;let i=()=>{this.event.stack=this.event.stack.filter(a=>a.id!==n&&a)};return{unSubscribe:i,disposer:a=>{a.push(i)}}};pipe(t){this.subscribe((...e)=>{t.execute(...e)})}queuingSubscribe=(t,e,r)=>{if(this.ended)throw new Error("event completed");let n=this.event.eventId;this.event.promiseStack.push({execute:t,id:n,complete:e,error:r}),this.event.eventId++;let i=()=>{this.event.stack=this.event.stack.filter(a=>a.id!==n&&a)};return{unSubscribe:i,disposer:a=>{a.push(i)}}};once=(t,e,r)=>{let n=this.subscribe((...i)=>{n.unSubscribe(),t(...i)},e,r)};watch=(t,e)=>new Promise((r,n)=>{let i=e&&setTimeout(()=>{n("Event watch timeout")},e),{unSubscribe:s}=this.subscribe((...a)=>{t(...a)&&(i&&clearTimeout(i),s(),r(a))})});asPromise=t=>new Promise((e,r)=>{let n=t&&setTimeout(()=>{r("Event asPromise timeout")},t);this.once((...i)=>{n&&clearTimeout(n),e(i)},()=>{n&&clearTimeout(n),e([])},i=>{n&&clearTimeout(n),r(i)})});get returnTrigger(){let{execute:t,error:e,complete:r}=this;return{execute:t,error:e,complete:r}}get returnListener(){let{subscribe:t,once:e,asPromise:r}=this;return{subscribe:t,once:e,asPromise:r}}get length(){return this.event.stack.length}},JNe=class{_disposer=[];push(t){this._disposer.push(t)}dispose(){this._disposer.forEach(t=>t()),this._disposer=[]}},EOe=_n("werift-ice:packages/ice/src/transport.ts"),aM=class e7e{constructor(e,r={}){this.socketType=e,this.options=r,this.socket=T3t(e),this.socket.on("message",(n,i)=>{DD(i.family)===6&&([i.address]=i.address.split("%")),this.rinfo=i;try{this.onData(n,[i.address,i.port])}catch(s){EOe("onData error",s)}})}type="udp";socket;rinfo;onData=()=>{};closed=!1;static async init(e,r={}){let n=new e7e(e,r);return await n.init(),n}async init(){let e=wM(this.socketType,this.options.interfaceAddresses);if(this.options.port)this.socket.bind({port:this.options.port,address:e});else if(this.options.portRange){let r=await XNe(this.options.portRange[0],this.options.portRange[1],this.socketType,this.options.interfaceAddresses);this.socket.bind({port:r,address:e})}else this.socket.bind({address:e});await new Promise(r=>this.socket.once("listening",r))}send=async(e,r)=>{if(r&&!QNe.isIP(r[0]))return new Promise((n,i)=>{this.socket.send(e,r[1],r[0],s=>{s?(EOe("send error",r,e),i(s)):n()})});r=r??[this.rinfo?.address,this.rinfo?.port],this.socket.send(e,r[1],r[0])};get address(){return this.socket.address()}get host(){return this.socket.address().address}get port(){return this.socket.address().port}close=()=>new Promise(e=>{this.closed=!0,this.socket.once("close",e);try{this.socket.close()}catch{e()}})},t7e=class r7e{constructor(e){this.addr=e,this.connect()}type="tcp";connecting;client;onData=()=>{};closed=!1;connect(){this.closed||(this.client&&this.client.destroy(),this.connecting=new Promise((e,r)=>{try{this.client=C3t({port:this.addr[1],host:this.addr[0]},e)}catch(n){r(n)}}),this.client.on("data",e=>{let r=[this.client.remoteAddress,this.client.remotePort];this.onData(e,r)}),this.client.on("end",()=>{this.connect()}),this.client.on("error",e=>{console.log("error",e)}))}async init(){await this.connecting}static async init(e){let r=new r7e(e);return await r.init(),r}get address(){return{}}send=async(e,r)=>{await this.connecting,this.client.write(e,n=>{n&&console.log("err",n)})};close=async()=>{this.closed=!0,this.client.destroy()}},Uh={rsa_1:1,ecdsa_3:3},ID={sha256_4:4},oM={TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_49195:49195,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256_49199:49199},n7e=Object.values(oM),Ep={x25519_29:29,secp256r1_23:23},foe=Object.values(Ep),doe={named_curve_3:3},sae={rsa_pkcs1_sha256:1025,ecdsa_secp256r1_sha256:1027},i7e=[1,64],hoe=[{hash:ID.sha256_4,signature:Uh.rsa_1},{hash:ID.sha256_4,signature:Uh.ecdsa_3}],R3t=()=>{let t=FU.utils.randomPrivateKey(),e=FU.getPublicKey(t,!1),r=Buffer.from(t),n=Buffer.from(e);return{privateKey:r,publicKey:n}},O3t=({publicKey:t,privateKey:e})=>{let r=FU.getSharedSecret(e,t);return Buffer.from(r).subarray(1)};Ap={CLIENT:1,SERVER:2},L3t=class{id=0;name;hashAlgorithm;verifyDataLength=12;blockAlgorithm;kx;init(...t){throw new Error("not implemented")}encrypt(...t){throw new Error("not implemented")}decrypt(...t){throw new Error("not implemented")}toString(){return this.name}},aae=I3t;zS.cryptoProvider.set(aae);FD=class{constructor(t,e,r,n){this.sessionType=t,this.certPem=e,this.keyPem=r,e&&r&&n&&this.parseX509(e,r,n)}localRandom;remoteRandom;cipherSuite;remoteCertificate;remoteKeyPair;localKeyPair;masterSecret;cipher;namedCurve;signatureHashAlgorithm;localCert;localPrivateKey;static createSelfSignedCertificateWithKey=async(t,e)=>{let r=(()=>{switch(t.signature){case Uh.rsa_1:return"RSASSA-PKCS1-v1_5";case Uh.ecdsa_3:return"ECDSA"}})(),n=(()=>{if(t.hash===ID.sha256_4)return"SHA-256"})(),i=(()=>{switch(e){case Ep.secp256r1_23:return"P-256";case Ep.x25519_29:return r==="ECDSA"?"P-256":"X25519";default:{if(r==="ECDSA")return"P-256";if(r==="RSASSA-PKCS1-v1_5")return"X25519"}}})(),s=(()=>{switch(r){case"ECDSA":return{name:r,hash:n,namedCurve:i};case"RSASSA-PKCS1-v1_5":return{name:r,hash:n,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048}}})(),a=await aae.subtle.generateKey(s,!0,["sign","verify"]),d=(await zS.X509CertificateGenerator.createSelfSigned({serialNumber:D3t(8).toString("hex"),name:"C=AU, ST=Some-State, O=Internet Widgits Pty Ltd",notBefore:new Date,notAfter:new Date(Date.now()+10*365*24*60*60*1e3),signingAlgorithm:s,keys:a})).toString("pem"),h=zS.PemConverter.encode(await aae.subtle.exportKey("pkcs8",a.privateKey),"private key");return{certPem:d,keyPem:h,signatureHash:t}};encryptPacket(t){let e=t.recordLayerHeader,r=e.protocolVersion.major<<8|e.protocolVersion.minor,n=this.cipher.encrypt(this.sessionType,t.fragment,{type:e.contentType,version:r,epoch:e.epoch,sequenceNumber:e.sequenceNumber});return t.fragment=n,t.recordLayerHeader.contentLen=n.length,t}decryptPacket(t){let e=t.recordLayerHeader,r=e.protocolVersion.major<<8|e.protocolVersion.minor;return this.cipher.decrypt(this.sessionType,t.fragment,{type:e.contentType,version:r,epoch:e.epoch,sequenceNumber:e.sequenceNumber})}verifyData(t){return this.sessionType===Ap.CLIENT?B3t(this.masterSecret,t):U3t(this.masterSecret,t)}signatureData(t,e){let r=k3t(e).update(t),n=this.localPrivateKey.toPEM().toString();return r.sign(n)}generateKeySignature(t){let e=this.sessionType===Ap.CLIENT?this.localRandom:this.remoteRandom,r=this.sessionType===Ap.SERVER?this.localRandom:this.remoteRandom,n=this.valueKeySignature(e.serialize(),r.serialize(),this.localKeyPair.publicKey,this.namedCurve);return this.localPrivateKey.sign(n,t)}parseX509(t,e,r){let n=SM.Certificate.fromPEM(Buffer.from(t)),i=SM.PrivateKey.fromPEM(Buffer.from(e));this.localCert=n.raw,this.localPrivateKey=i,this.signatureHashAlgorithm=r}valueKeySignature(t,e,r,n){let i=Buffer.from((0,NS.encode)({type:doe.named_curve_3,curve:n,len:r.length},{type:NS.types.uint8,curve:NS.types.uint16be,len:NS.types.uint8}).slice());return Buffer.concat([t,e,i,r])}},PD=class{srtpProfile;static findMatchingSRTPProfile(t,e){for(let r of e)if(t.includes(r))return r}},poe=t=>"0x"+t.toString("hex").replace(/(.)(.)/g,"$1$2 ").split(" ").filter(e=>e!=null&&e.length>0).join(",0x"),d7e=t=>Object.entries({...t}).reduce((e,[r,n])=>((typeof n=="number"||typeof n=="string")&&(e[r]=n),Buffer.isBuffer(n)&&(e[r]=poe(n)),e),{}),af=class Fg{constructor(e,r,n,i,s,a){this.msg_type=e,this.length=r,this.message_seq=n,this.fragment_offset=i,this.fragment_length=s,this.fragment=a}static spec={msg_type:ud.types.uint8,length:ud.types.uint24be,message_seq:ud.types.uint16be,fragment_offset:ud.types.uint24be,fragment_length:ud.types.uint24be,fragment:ud.types.buffer(e=>e.current.fragment_length)};get summary(){return d7e(this)}static createEmpty(){return new Fg(void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new Fg(...Object.values((0,ud.decode)(e,Fg.spec)))}serialize(){let e=(0,ud.encode)(this,Fg.spec).slice();return Buffer.from(e)}chunk(e){let r=0,n=this.fragment.length;if(n===0)return[new Fg(this.msg_type,n,this.message_seq,r,0,this.fragment)];let i=[];for(e||(e=1240);r<n;){let s=Math.min(e,n-r),a=Buffer.from(this.fragment.slice(r,r+s));if(a.length<=0)throw new Error("Zero or less bytes processed while fragmenting handshake message.");i.push(new Fg(this.msg_type,n,this.message_seq,r,a.length,a)),r+=a.length}return i}static assemble(e){if(!e?.length)throw new Error("cannot reassemble handshake from empty array");e=e.sort((n,i)=>n.fragment_offset-i.fragment_offset);let r=Buffer.alloc(e[0].length);for(let n of e)n.fragment.copy(r,n.fragment_offset);return new Fg(e[0].msg_type,e[0].length,e[0].message_seq,0,r.length,r)}static findAllFragments(e,r){let n=e.find(i=>i.msg_type===r);return n?e?.length?e.filter(i=>i.msg_type===n.msg_type&&i.message_seq===n.message_seq&&i.length===n.length):[]:[]}},{uint16be:cM,uint24be:$3t,buffer:p7e,array:j3t,uint8:RD,string:q3t}=h7e.types,z3t={type:cM,data:p7e(cM)},oae=j3t(z3t,cM,"bytes"),W3t=p7e($3t),H3t=RD,V3t=q3t(cM),G3t={hash:RD,signature:RD},moe={major:RD,minor:RD},wv=class lD{constructor(e=Math.floor(Date.now()/1e3),r=K3t(28)){this.gmt_unix_time=e,this.random_bytes=r}static spec={gmt_unix_time:_v.types.uint32be,random_bytes:_v.types.buffer(28)};static deSerialize(e){return new lD(...Object.values((0,_v.decode)(e,lD.spec)))}static from(e){return new lD(...Object.values(e))}serialize(){let e=(0,_v.encode)(this,lD.spec).slice();return Buffer.from(e)}},m7e=class fD{constructor(e,r,n,i,s,a,c){this.clientVersion=e,this.random=r,this.sessionId=n,this.cookie=i,this.cipherSuites=s,this.compressionMethods=a,this.extensions=c}msgType=1;messageSeq=0;static spec={clientVersion:{major:$o.types.uint8,minor:$o.types.uint8},random:wv.spec,sessionId:$o.types.buffer($o.types.uint8),cookie:$o.types.buffer($o.types.uint8),cipherSuites:$o.types.array($o.types.uint16be,$o.types.uint16be,"bytes"),compressionMethods:$o.types.array($o.types.uint8,$o.types.uint8,"bytes"),extensions:oae};static createEmpty(){return new fD(void 0,void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new fD(...Object.values((0,$o.decode)(e,fD.spec)))}serialize(){let e=(0,$o.encode)(this,fD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},X3t=class dD{constructor(e,r,n,i,s){this.epoch=e,this.sequenceNumber=r,this.contentType=n,this.protocolVersion=i,this.contentLen=s}static spec={epoch:wp.types.uint16be,sequenceNumber:wp.types.uint48be,contentType:wp.types.uint8,protocolVersion:moe,contentLen:wp.types.uint16be};static createEmpty(){return new dD(void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new dD(...Object.values((0,wp.decode)(e,dD.spec)))}serialize(){let e=(0,wp.encode)(this,dD.spec).slice();return Buffer.from(e)}},g7e=class cae{constructor(e,r){this.recordLayerHeader=e,this.fragment=r}get summary(){return{header:this.recordLayerHeader,fragment:poe(this.fragment)}}static createEmpty(){return new cae(void 0,void 0)}static deSerialize(e){if(e.length<13)throw new Error("Invalid DTLS record: buffer is too short");let r=e.readUInt8(0),n=e.readUInt8(1),i=e.readUInt8(2),s=e.readUInt16BE(3),a=e.slice(5,11).readUIntBE(0,6),c=e.readUInt16BE(11);if(e.length<13+c)throw new Error("Invalid DTLS record: fragment length exceeds buffer");let d=e.slice(13,13+c);return new cae({contentType:r,protocolVersion:{major:n,minor:i},epoch:s,sequenceNumber:a,contentLen:c},d)}serialize(){let e=this.fragment.length,r=13+e,n=Buffer.alloc(r);return n.writeUInt8(this.recordLayerHeader.contentType,0),n.writeUInt8(this.recordLayerHeader.protocolVersion.major,1),n.writeUInt8(this.recordLayerHeader.protocolVersion.minor,2),n.writeUInt16BE(this.recordLayerHeader.epoch,3),n.writeUIntBE(this.recordLayerHeader.sequenceNumber,5,6),n.writeUInt16BE(e,11),this.fragment.copy(n,13),n}computeMACHeader(){return new X3t(this.recordLayerHeader.epoch,this.recordLayerHeader.sequenceNumber,this.recordLayerHeader.contentType,this.recordLayerHeader.protocolVersion,this.recordLayerHeader.contentLen).serialize()}},x7e=t=>e=>(t.lastFlight=e,e.flatMap(r=>(r.messageSeq=t.sequenceNumber++,r.toFragment().chunk()))),GD=t=>(e,r)=>e.map(n=>new g7e({contentType:n.type,protocolVersion:t.version,epoch:t.epoch,sequenceNumber:r,contentLen:n.fragment.length},n.fragment)),uae=(t=>(t[t.CloseNotify=0]="CloseNotify",t[t.UnexpectedMessage=10]="UnexpectedMessage",t[t.BadRecordMac=20]="BadRecordMac",t[t.DecryptionFailed=21]="DecryptionFailed",t[t.RecordOverflow=22]="RecordOverflow",t[t.DecompressionFailure=30]="DecompressionFailure",t[t.HandshakeFailure=40]="HandshakeFailure",t[t.NoCertificate=41]="NoCertificate",t[t.BadCertificate=42]="BadCertificate",t[t.UnsupportedCertificate=43]="UnsupportedCertificate",t[t.CertificateRevoked=44]="CertificateRevoked",t[t.CertificateExpired=45]="CertificateExpired",t[t.CertificateUnknown=46]="CertificateUnknown",t[t.IllegalParameter=47]="IllegalParameter",t[t.UnknownCa=48]="UnknownCa",t[t.AccessDenied=49]="AccessDenied",t[t.DecodeError=50]="DecodeError",t[t.DecryptError=51]="DecryptError",t[t.ExportRestriction=60]="ExportRestriction",t[t.ProtocolVersion=70]="ProtocolVersion",t[t.InsufficientSecurity=71]="InsufficientSecurity",t[t.InternalError=80]="InternalError",t[t.UserCanceled=90]="UserCanceled",t[t.NoRenegotiation=100]="NoRenegotiation",t[t.UnsupportedExtension=110]="UnsupportedExtension",t))(uae||{}),Y3t=_n("werift-dtls : packages/dtls/src/flight/flight.ts : warn"),zse=_n("werift-dtls : packages/dtls/src/flight/flight.ts : err"),KD=class lae{constructor(e,r,n,i){this.transport=e,this.dtls=r,this.flight=n,this.nextFlight=i}state="PREPARING";static RetransmitCount=10;createPacket(e){let r=x7e(this.dtls)(e);return this.dtls.bufferHandshakeCache(r,!0,this.flight),GD(this.dtls)(r.map(i=>({type:22,fragment:i.serialize()})),++this.dtls.recordSequenceNumber)}async transmit(e){let r=0;for(;r<=lae.RetransmitCount;r++){if(this.setState("SENDING"),this.send(e).catch(n=>{zse("fail to send",zse)}),this.setState("WAITING"),this.nextFlight===void 0){this.setState("FINISHED");break}if(await Z3t(1e3*((r+1)/2)),this.dtls.flight>=this.nextFlight){this.setState("FINISHED");break}else Y3t(this.dtls.sessionId,"retransmit",r,this.dtls.flight)}if(r>lae.RetransmitCount)throw zse(this.dtls.sessionId,"retransmit failed",r),new Error(`over retransmitCount : ${this.flight} ${this.nextFlight}`)}send=e=>Promise.all(e.map(r=>this.transport.send(r)));setState(e){this.state=e}},J3t=class extends KD{constructor(t,e,r){super(t,e,1,3),this.cipher=r}async exec(t){if(this.dtls.flight===1)throw new Error;this.dtls.flight=1;let e=new m7e({major:254,minor:253},new wv,Buffer.from([]),Buffer.from([]),n7e,[0],t);this.dtls.version=e.clientVersion,this.cipher.localRandom=wv.from(e.random);let r=this.createPacket([e]),n=Buffer.concat(r.map(i=>i.serialize()));await this.transmit([n])}},Q3t=_n("werift-dtls : packages/dtls/src/flight/client/flight3.ts : log"),e6t=class extends KD{constructor(t,e){super(t,e,3,5)}async exec(t){if(this.dtls.flight===3)throw new Error;this.dtls.flight=3,this.dtls.handshakeCache=[];let[e]=this.dtls.lastFlight;Q3t("dtls version",e.clientVersion),e.cookie=t.cookie,this.dtls.cookie=t.cookie;let r=this.createPacket([e]),n=Buffer.concat(r.map(i=>i.serialize()));await this.transmit([n])}},AM={NULL:0,ECDHE:1},ZD={NULL:0,RSA:1,ECDSA:2,PSK:3},XD={NULL:0,RSA:1,ECDHE_RSA:2,ECDHE_ECDSA:3,PSK:4,ECDHE_PSK:5},YD=class{id=0;name;signType;keyType;toString(){return this.name}};c6t=_n("werift-dtls : packages/dtls/src/cipher/suites/aead.ts : err"),u6t=class extends L3t{keyLength=0;nonceLength=0;ivLength=0;authTagLength=0;nonceImplicitLength=0;nonceExplicitLength=0;clientWriteKey;serverWriteKey;clientNonce;serverNonce;constructor(){super()}get summary(){return d7e(this)}init(t,e,r){let n=M3t(t,r,e,this.keyLength,this.ivLength,this.nonceLength,this.hashAlgorithm);this.clientWriteKey=n.clientWriteKey,this.serverWriteKey=n.serverWriteKey,this.clientNonce=n.clientNonce,this.serverNonce=n.serverNonce}encrypt(t,e,r){let n=t===Ap.CLIENT,i=n?this.clientNonce:this.serverNonce,s=n?this.clientWriteKey:this.serverWriteKey;if(!i||!s)throw new Error;i.writeUInt16BE(r.epoch,this.nonceImplicitLength),i.writeUIntBE(r.sequenceNumber,this.nonceImplicitLength+2,6);let a=i.slice(this.nonceImplicitLength),c=this.encodeAdditionalBuffer(r,e.length),d=a6t(this.blockAlgorithm,s,i,{authTagLength:this.authTagLength});d.setAAD(c,{plaintextLength:e.length});let h=d.update(e),p=d.final(),x=d.getAuthTag();return Buffer.concat([a,h,p,x])}encodeAdditionalBuffer(t,e){let r=Buffer.alloc(13);return r.writeUInt16BE(t.epoch,0),r.writeUintBE(t.sequenceNumber,2,6),r.writeUInt8(t.type,8),r.writeUInt16BE(t.version,9),r.writeUInt16BE(e,11),r}decrypt(t,e,r){let n=t===Ap.CLIENT,i=n?this.serverNonce:this.clientNonce,s=n?this.serverWriteKey:this.clientWriteKey;if(!i||!s)throw new Error;e.subarray(0,this.nonceExplicitLength).copy(i,this.nonceImplicitLength);let c=e.subarray(this.nonceExplicitLength,e.length-this.authTagLength),d=e.subarray(e.length-this.authTagLength),h=this.encodeAdditionalBuffer(r,c.length),p=o6t(this.blockAlgorithm,s,i,{authTagLength:this.authTagLength});p.setAuthTag(d),p.setAAD(h,{plaintextLength:c.length});let x=p.update(c);try{let y=p.final();return y.length>0?Buffer.concat([x,y]):x}catch(y){throw c6t("decrypt failed",y,t,poe(e),r,this.summary),y}}},Oa={TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:49195,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:49196,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:49199,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:49200,TLS_RSA_WITH_AES_128_GCM_SHA256:156,TLS_RSA_WITH_AES_256_GCM_SHA384:157,TLS_PSK_WITH_AES_128_GCM_SHA256:168,TLS_PSK_WITH_AES_256_GCM_SHA384:169,TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256:53249,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384:53250,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:52396,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:52393,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:52392,TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:52395},rD={K_LEN:16,N_MIN:12,N_MAX:12,P_MAX:2**36-31,A_MAX:2**53-1,C_MAX:2**36-15},nD={K_LEN:32,N_MIN:12,N_MAX:12,P_MAX:2**36-31,A_MAX:2**53-1,C_MAX:2**36-15},COe=t6t(),kOe=r6t(),DOe=n6t(),IOe=i6t(),FOe=s6t();EM=class{static type=23},TM=class kS{static type=65281;static spec={type:Sv.types.uint16be,data:Sv.types.uint8};type=kS.type;data=0;constructor(e={}){Object.assign(this,e)}static createEmpty(){return new kS}static deSerialize(e){return new kS((0,Sv.decode)(e,kS.spec))}serialize(){let e=(0,Sv.encode)(this,kS.spec).slice();return Buffer.from(e)}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},MS=class Pg{static type=14;static spec={type:Mg.types.uint16be,data:Mg.types.buffer(Mg.types.uint16be)};type=Pg.type;data=Buffer.from([]);profiles=[];mki=Buffer.from([0]);constructor(e={}){Object.assign(this,e)}static create(e,r){return new Pg({profiles:e,mki:r})}static deSerialize(e){let r=new Pg((0,Mg.decode)(e,Pg.spec)),n=r.data.readUInt16BE(),i=new Array(n/2);for(let s=0;s<i.length;s++)i[s]=r.data.readUInt16BE(s*2+2);return r.profiles=i,r.mki=r.data.slice(n+2),r}serialize(){let e=Buffer.alloc(2);e.writeUInt16BE(this.profiles.length*2);let r=Buffer.concat([e,...this.profiles.map(i=>{let s=Buffer.alloc(2);return s.writeUInt16BE(i),s}),this.mki]);this.data=r;let n=(0,Mg.encode)(this,Pg.spec).slice();return Buffer.from(n)}static fromData(e){let r=Buffer.alloc(4);return r.writeUInt16BE(Pg.type),r.writeUInt16BE(e.length,2),Pg.deSerialize(Buffer.concat([r,e]))}get extension(){return{type:this.type,data:this.serialize().slice(4)}}},uM=class hD{constructor(e){this.certificateList=e}msgType=11;messageSeq;static spec={certificateList:Av.types.array(W3t,Av.types.uint24be,"bytes")};static createEmpty(){return new hD(void 0)}static deSerialize(e){return new hD(...Object.values((0,Av.decode)(e,hD.spec)))}serialize(){let e=(0,Av.encode)(this,hD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},_7e=class pD{constructor(e=1){this.type=e}static spec={type:WS.types.uint8};static createEmpty(){return new pD}static deSerialize(e){return new pD(...Object.values((0,WS.decode)(e,pD.spec)))}serialize(){let e=(0,WS.encode)(this,pD.spec).slice();return Buffer.from(e)}},w7e=class mD{constructor(e,r){this.algorithm=e,this.signature=r}msgType=15;messageSeq;static spec={algorithm:Lg.types.uint16be,signature:Lg.types.buffer(Lg.types.uint16be)};static createEmpty(){return new mD(void 0,void 0)}static deSerialize(e){let r=(0,Lg.decode)(e,mD.spec);return new mD(...Object.values(r))}serialize(){let e=(0,Lg.encode)(this,mD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},S7e=class gD{constructor(e){this.publicKey=e}msgType=16;messageSeq;static spec={publicKey:Ev.types.buffer(Ev.types.uint8)};static createEmpty(){return new gD(void 0)}static deSerialize(e){let r=(0,Ev.decode)(e,gD.spec);return new gD(...Object.values(r))}serialize(){let e=(0,Ev.encode)(this,gD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},fae=class dae{constructor(e){this.verifyData=e}msgType=20;messageSeq;static createEmpty(){return new dae(void 0)}static deSerialize(e){return new dae(e)}serialize(){return this.verifyData}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},A7e=class xD{constructor(e,r,n){this.certificateTypes=e,this.signatures=r,this.authorities=n}msgType=13;messageSeq;static spec={certificateTypes:ld.types.array(H3t,ld.types.uint8,"bytes"),signatures:ld.types.array(G3t,ld.types.uint16be,"bytes"),authorities:ld.types.array(V3t,ld.types.uint16be,"bytes")};static createEmpty(){return new xD(void 0,void 0,void 0)}static deSerialize(e){return new xD(...Object.values((0,ld.decode)(e,xD.spec)))}serialize(){let e=(0,ld.encode)(this,xD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},E7e=class Rg{constructor(e,r,n,i,s,a){this.serverVersion=e,this.random=r,this.sessionId=n,this.cipherSuite=i,this.compressionMethod=s,this.extensions=a}msgType=2;messageSeq;static spec={serverVersion:moe,random:wv.spec,sessionId:fd.types.buffer(fd.types.uint8),cipherSuite:fd.types.uint16be,compressionMethod:fd.types.uint8};static createEmpty(){return new Rg(void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){let r=(0,fd.decode)(e,Rg.spec),n=new Rg(...Object.values(r));return n.serialize().length<e.length?new Rg(...Object.values((0,fd.decode)(e,{...Rg.spec,extensions:oae}))):n}serialize(){let e=this.extensions===void 0?(0,fd.encode)(this,Rg.spec).slice():(0,fd.encode)(this,{...Rg.spec,extensions:oae}).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},T7e=class yD{msgType=14;messageSeq;static spec={};static createEmpty(){return new yD}static deSerialize(e){return new yD(...Object.values((0,CM.decode)(e,yD.spec)))}serialize(){let e=(0,CM.encode)(this,yD.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}};k7e=class vD{constructor(e,r,n,i,s,a,c,d){this.ellipticCurveType=e,this.namedCurve=r,this.publicKeyLength=n,this.publicKey=i,this.hashAlgorithm=s,this.signatureAlgorithm=a,this.signatureLength=c,this.signature=d}msgType=12;messageSeq;static spec={ellipticCurveType:cd.types.uint8,namedCurve:cd.types.uint16be,publicKeyLength:cd.types.uint8,publicKey:cd.types.buffer(e=>e.current.publicKeyLength),hashAlgorithm:cd.types.uint8,signatureAlgorithm:cd.types.uint8,signatureLength:cd.types.uint16be,signature:cd.types.buffer(e=>e.current.signatureLength)};static createEmpty(){return new vD(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){let r=(0,cd.decode)(e,vD.spec);return new vD(...Object.values(r))}serialize(){return l6t(this,vD.spec)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},HS=1,Fv=7,f6t=[HS,Fv],D7e=t=>{switch(t){case HS:case Fv:return 16}},I7e=t=>{switch(t){case HS:return 14;case Fv:return 12}},d6t=_n("werift-rtp : packages/rtp/src/codec/av1.ts"),hae=class P7e{zBit_RtpStartsWithFragment;yBit_RtpEndsWithFragment;w_RtpNumObus;nBit_RtpStartsNewCodedVideoSequence;obu_or_fragment=[];static deSerialize=e=>{let r=new P7e,n=0;if(r.zBit_RtpStartsWithFragment=ir(e[n],0),r.yBit_RtpEndsWithFragment=ir(e[n],1),r.w_RtpNumObus=ir(e[n],2,2),r.nBit_RtpStartsNewCodedVideoSequence=ir(e[n],4),n++,r.nBit_RtpStartsNewCodedVideoSequence&&r.zBit_RtpStartsWithFragment)throw new Error;[...Array(r.w_RtpNumObus-1).keys()].forEach(s=>{let[a,c]=N7e(e.subarray(n)),d=n+c,h=d+a,p=!1;r.zBit_RtpStartsWithFragment&&s===0&&(p=!0),r.obu_or_fragment.push({data:e.subarray(d,h),isFragment:p}),n+=c+a});let i=!1;return(r.yBit_RtpEndsWithFragment||r.w_RtpNumObus===1&&r.zBit_RtpStartsWithFragment)&&(i=!0),r.obu_or_fragment.push({data:e.subarray(n),isFragment:i}),r};static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.nBit_RtpStartsNewCodedVideoSequence===1}static getFrame(e){let r=[],n=e.flatMap(c=>c.obu_or_fragment).reduce((c,d,h)=>(c[h]=d,c),{}),i=Object.keys(n).length;for(let c of Object.keys(n).map(Number)){let d=n[c];if(!d)continue;let{data:h,isFragment:p}=d;if(p){let x=[];for(let y=c;y<i;y++){let v=n[y];if(v.isFragment)x.push(v.data),delete n[y];else break}x.length<=1&&(d6t("fragment lost, maybe packet lost"),x=[]),r.push(Buffer.concat(x))}else r.push(h)}let s=r.map(c=>R7e.deSerialize(c)),a=s.pop();return Buffer.concat([...s.map(c=>(c.obu_has_size_field=1,c.serialize())),a.serialize()])}},R7e=class O7e{obu_forbidden_bit;obu_type;obu_extension_flag;obu_has_size_field;obu_reserved_1bit;payload;static deSerialize(e){let r=new O7e,n=0;return r.obu_forbidden_bit=ir(e[n],0),r.obu_type=B7e[ir(e[n],1,4)],r.obu_extension_flag=ir(e[n],5),r.obu_has_size_field=ir(e[n],6),r.obu_reserved_1bit=ir(e[n],7),n++,r.payload=e.subarray(n),r}serialize(){let e=new bM(8).set(this.obu_forbidden_bit).set(h6t[this.obu_type],4).set(this.obu_extension_flag).set(this.obu_has_size_field).set(this.obu_reserved_1bit).buffer,r=Buffer.alloc(0);return this.obu_has_size_field&&(r=F7e.LEB128.encode(this.payload.length)),Buffer.concat([e,r,this.payload])}};B7e={0:"Reserved",1:"OBU_SEQUENCE_HEADER",2:"OBU_TEMPORAL_DELIMITER",3:"OBU_FRAME_HEADER",4:"OBU_TILE_GROUP",5:"OBU_METADATA",6:"OBU_FRAME",7:"OBU_REDUNDANT_FRAME_HEADER",8:"OBU_TILE_LIST",15:"OBU_PADDING"},h6t=Object.entries(B7e).reduce((t,[e,r])=>(t[r]=Number(e),t),{}),U7e=class M7e{f;nri;nalUnitType;s;e;r;nalUnitPayloadType;payload;fragment;static deSerialize(e,r){let n=new M7e,i=0,s=e[i];if(n.f=ir(s,0),n.nri=ir(s,1,2),n.nalUnitType=ir(s,3,5),i++,n.s=ir(e[i],0),n.e=ir(e[i],1),n.r=ir(e[i],2),n.nalUnitPayloadType=ir(e[i],3,5),i++,0<n.nalUnitType&&n.nalUnitType<Og.stap_a)n.payload=this.packaging(e);else if(n.nalUnitType===Og.stap_a){let a=m6t,c=Buffer.alloc(0);for(;a<e.length;){let d=e.readUInt16BE(a);a+=g6t,c=Buffer.concat([c,this.packaging(e.subarray(a,a+d))]),a+=d}n.payload=c}else if(n.nalUnitType===Og.fu_a){r||(r=Buffer.alloc(0));let a=e.subarray(i);if(n.fragment=Buffer.concat([r,a]),n.e){let c=new Ug(Buffer.alloc(1)).writeBits(1,0).writeBits(2,n.nri).writeBits(5,n.nalUnitPayloadType),d=Buffer.concat([c.uint8Array,n.fragment]);n.fragment=void 0,n.payload=this.packaging(d)}}return n}static packaging(e){return Buffer.concat([p6t,e])}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.nalUnitType===Og.idrSlice||this.nalUnitPayloadType===Og.idrSlice}get isPartitionHead(){return this.nalUnitType===Og.fu_a||this.nalUnitType===Og.fu_b?this.s!==0:!0}},Og={idrSlice:5,stap_a:24,stap_b:25,mtap16:26,mtap24:27,fu_a:28,fu_b:29},p6t=Buffer.from([0,0,0,1]),m6t=1,g6t=2,L7e=class $7e{payload;static deSerialize(e){let r=new $7e;return r.payload=e,r}static isDetectedFinalPacketInSequence(e){return!0}get isKeyframe(){return!0}static createCodecPrivate(e=48e3){return Buffer.concat([Buffer.from("OpusHead"),Vs([1,1],[1,2]),$Ne([2,4,2,1],[312,e,0,0])])}},j7e=class q7e{xBit;nBit;sBit;pid;iBit;lBit;tBit;kBit;mBit;pictureId;payload;size0=0;hBit;ver;pBit;size1=0;size2=0;static deSerialize(e){let r=new q7e,n=0;if(r.xBit=ir(e[n],0),r.nBit=ir(e[n],2),r.sBit=ir(e[n],3),r.pid=ir(e[n],5,3),n++,r.xBit&&(r.iBit=ir(e[n],0),r.lBit=ir(e[n],1),r.tBit=ir(e[n],2),r.kBit=ir(e[n],3),n++),r.iBit)if(r.mBit=ir(e[n],0),r.mBit){let i=kD(ir(e[n],1,7)),s=kD(e[n+1]);r.pictureId=Number.parseInt(i+s,2),n+=2}else r.pictureId=ir(e[n],1,7),n++;return r.lBit&&n++,(r.lBit||r.kBit)&&(r.tBit,r.kBit,n++),r.payload=e.subarray(n),r.payloadHeaderExist&&(r.size0=ir(e[n],0,3),r.hBit=ir(e[n],3),r.ver=ir(e[n],4,3),r.pBit=ir(e[n],7),n++,r.size1=e[n],n++,r.size2=e[n]),r}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.pBit===0}get isPartitionHead(){return this.sBit===1}get payloadHeaderExist(){return this.sBit===1&&this.pid===0}get size(){return this.payloadHeaderExist?this.size0+8*this.size1+2048*this.size2:0}},z7e=class W7e{iBit;pBit;lBit;fBit;bBit;eBit;vBit;zBit;m;pictureId;tid;u;sid;d;tl0PicIdx;pDiff=[];n_s;y;g;width=[];height=[];n_g=0;pgT=[];pgU=[];pgP_Diff=[];payload;static deSerialize(e){let{p:r,offset:n}=this.parseRtpPayload(e);return r.payload=e.subarray(n),r}static parseRtpPayload(e){let r=new W7e,n=0;if(r.iBit=ir(e[n],0),r.pBit=ir(e[n],1),r.lBit=ir(e[n],2),r.fBit=ir(e[n],3),r.bBit=ir(e[n],4),r.eBit=ir(e[n],5),r.vBit=ir(e[n],6),r.zBit=ir(e[n],7),n++,r.iBit)if(r.m=ir(e[n],0),r.m){let i=kD(ir(e[n],1,7)),s=kD(e[n+1]);r.pictureId=Number.parseInt(i+s,2),n+=2}else r.pictureId=ir(e[n],1,7),n++;if(r.lBit&&(r.tid=ir(e[n],0,3),r.u=ir(e[n],3),r.sid=ir(e[n],4,3),r.d=ir(e[n],7),n++,r.fBit===0&&(r.tl0PicIdx=e[n],n++)),r.fBit&&r.pBit)for(;;){r.pDiff=[...r.pDiff,ir(e[n],0,7)];let i=ir(e[n],7);if(n++,i===0)break}return r.vBit&&(r.n_s=ir(e[n],0,3),r.y=ir(e[n],3),r.g=ir(e[n],4),n++,r.y&&[...Array(r.n_s+1)].forEach(()=>{r.width.push(e.readUInt16BE(n)),n+=2,r.height.push(e.readUInt16BE(n)),n+=2}),r.g&&(r.n_g=e[n],n++),r.n_g>0&&[...Array(r.n_g).keys()].forEach(i=>{r.pgT.push(ir(e[n],0,3)),r.pgU.push(ir(e[n],3));let s=ir(e[n],4,2);n++,r.pgP_Diff[i]=[],s>0&&[...Array(s)].forEach(()=>{r.pgP_Diff[i].push(e[n]),n++})})),{offset:n,p:r}}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return!!(!this.pBit&&this.bBit&&(!this.sid||!this.lBit))}get isPartitionHead(){return this.bBit&&(!this.lBit||!this.d)}},x6t=class{payload;fragment;static deSerialize(t,e){return{}}static isDetectedFinalPacketInSequence(t){return!0}get isKeyframe(){return!0}};v6t=["MPEG4/ISO/AVC","VP8","VP9","OPUS","AV1"];_6t={setTimeout:(...t)=>{let e=setTimeout(...t);return()=>clearTimeout(e)},setInterval:(...t)=>{let e=setInterval(()=>{t[0]()},...t.slice(1));return()=>clearInterval(e)}};lM=4,kp=class mae{version=2;padding=!1;count=0;type=0;length=0;constructor(e={}){Object.assign(this,e)}static serialize(e,r,n,i){let a=new mae({type:e,count:r,version:2,length:i}).serialize();return Buffer.concat([a,n])}serialize(){let e=new CD(8);return e.set(2,0,this.version),this.padding&&e.set(1,2,1),e.set(5,3,this.count),Vs([1,1,2],[e.value,this.type,this.length])}static deSerialize(e){let[r,n,i]=zc(e,[1,1,2]),s=ir(r,0,2),a=ir(r,2,1)>0,c=ir(r,3,5);return new mae({version:s,padding:a,count:c,type:n,length:i})}},POe=class gae{static count=4;count=gae.count;senderSsrc;mediaSsrc;fir=[];constructor(e={}){Object.assign(this,e)}get length(){return Math.floor(this.serialize().length/4-1)}static deSerialize(e){let[r,n]=zc(e,[4,4]),i=[];for(let s=8;s<e.length;s+=8)i.push({ssrc:e.readUInt32BE(s),sequenceNumber:e[s+4]});return new gae({senderSsrc:r,mediaSsrc:n,fir:i})}serialize(){let e=Vs([4,4],[this.senderSsrc,this.mediaSsrc]),r=Buffer.alloc(this.fir.length*8);return this.fir.forEach(({ssrc:n,sequenceNumber:i},s)=>{r.writeUInt32BE(n,s*8),r[s*8+4]=i}),Buffer.concat([e,r])}},ND=class xae{static count=1;count=xae.count;length=2;senderSsrc;mediaSsrc;constructor(e={}){Object.assign(this,e)}static deSerialize(e){let[r,n]=zc(e,[4,4]);return new xae({senderSsrc:r,mediaSsrc:n})}serialize(){return Vs([4,4],[this.senderSsrc,this.mediaSsrc])}},BD=class yae{static count=15;length;count=yae.count;senderSsrc;mediaSsrc;uniqueID="REMB";ssrcNum=0;brExp;brMantissa;bitrate;ssrcFeedbacks=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let[r,n,i,s,a]=zc(e,[4,4,4,1,1]),c=ir(a,0,6),d=(ir(a,6,2)<<16)+(e[14]<<8)+e[15],h=c>46?18446744073709551615n:BigInt(d)<<BigInt(c),p=[];for(let x=16;x<e.length;x+=4){let y=e.slice(x).readUIntBE(0,4);p.push(y)}return new yae({senderSsrc:r,mediaSsrc:n,uniqueID:Vs([4],[i]).toString(),ssrcNum:s,brExp:c,brMantissa:d,ssrcFeedbacks:p,bitrate:h})}serialize(){let e=Buffer.concat([Vs([4,4],[this.senderSsrc,this.mediaSsrc]),Buffer.from(this.uniqueID),Vs([1],[this.ssrcNum])]),r=new CD(24);r.set(6,0,this.brExp).set(18,6,this.brMantissa);let n=Buffer.concat(this.ssrcFeedbacks.map(s=>Vs([4],[s]))),i=Buffer.concat([e,Vs([3],[r.value]),n]);return this.length=i.length/4,i}},w6t=_n("werift-rtp: /rtcp/psfb/index"),LS=class vae{static type=206;type=vae.type;feedback;constructor(e={}){Object.assign(this,e)}serialize(){let e=this.feedback.serialize();return kp.serialize(this.type,this.feedback.count,e,this.feedback.length)}static deSerialize(e,r){let n;switch(r.count){case POe.count:n=POe.deSerialize(e);break;case ND.count:n=ND.deSerialize(e);break;case BD.count:n=BD.deSerialize(e);break;default:w6t("unknown psfb packet",r.count);break}return new vae({feedback:n})}},$S=class qU{ssrc=0;reports=[];static type=201;type=qU.type;constructor(e={}){Object.assign(this,e)}serialize(){let e=Vs([4],[this.ssrc]);return e=Buffer.concat([e,...this.reports.map(r=>r.serialize())]),kp.serialize(qU.type,this.reports.length,e,Math.floor(e.length/4))}static deSerialize(e,r){let[n]=zc(e,[4]),i=4,s=[];for(let a=0;a<r;a++)s.push(kM.deSerialize(e.slice(i,i+24))),i+=24;return new qU({ssrc:n,reports:s})}},kM=class V7e{ssrc;fractionLost;packetsLost;highestSequence;jitter;lsr;dlsr;constructor(e={}){Object.assign(this,e)}toJSON(){return{ssrc:this.ssrc,fractionLost:this.fractionLost,packetsLost:this.packetsLost,highestSequence:this.highestSequence,jitter:this.jitter,lsr:this.lsr,dlsr:this.dlsr}}serialize(){return Vs([4,1,3,4,4,4,4],[this.ssrc,this.fractionLost,this.packetsLost,this.highestSequence,this.jitter,this.lsr,this.dlsr])}static deSerialize(e){let[r,n,i,s,a,c,d]=zc(e,[4,1,3,4,4,4,4]);return new V7e({ssrc:r,fractionLost:n,packetsLost:i,highestSequence:s,jitter:a,lsr:c,dlsr:d})}},G7e=205,UD=class bae{static count=1;count=bae.count;header;senderSsrc;mediaSourceSsrc;lost=[];toJSON(){return{lost:this.lost,senderSsrc:this.senderSsrc,mediaSourceSsrc:this.mediaSourceSsrc}}constructor(e={}){Object.assign(this,e),this.header||(this.header=new kp({type:G7e,count:this.count,version:2}))}static deSerialize(e,r){let[n,i]=zc(e,[4,4]),s=[];for(let a=8;a<e.length;a+=4){let[c,d]=zc(e.subarray(a),[2,2]);s.push(c);for(let h=0;h<16;h++)d>>h&1&&s.push(c+h+1)}return new bae({header:r,senderSsrc:n,mediaSourceSsrc:i,lost:s})}serialize(){let e=Vs([4,4],[this.senderSsrc,this.mediaSourceSsrc]),r=[];if(this.lost.length>0){let i=this.lost[0],s=0;this.lost.slice(1).forEach(a=>{let c=a-i-1;c>=0&&c<16?s|=1<<c:(r.push(Vs([2,2],[i,s])),i=a,s=0)}),r.push(Vs([2,2],[i,s]))}let n=Buffer.concat([e,Buffer.concat(r)]);return this.header.length=n.length/4,Buffer.concat([this.header.serialize(),n])}},S6t=_n("werift/rtp/rtcp/rtpfb/twcc"),MD=class _ae{static count=15;count=_ae.count;length=2;senderSsrc;mediaSourceSsrc;baseSequenceNumber;packetStatusCount;referenceTime;fbPktCount;packetChunks=[];recvDeltas=[];header;constructor(e={}){Object.assign(this,e),this.header||(this.header=new kp({type:205,count:this.count,version:2}))}static deSerialize(e,r){let[n,i,s,a,c,d]=zc(e,[4,4,2,2,3,1]),h=[],p=[],x=16;for(let v=0;v<a;){let w=ir(e.slice(x,x+1)[0],0,1),S;switch(w){case 0:{let C=BS.deSerialize(e.slice(x,x+2));S=C;let k=Math.min(a-v,C.runLength);if(C.packetStatus===1||C.packetStatus===2)for(let T=0;T<k;T++)p.push(new AD({type:C.packetStatus}));v+=k}break;case 1:{let C=Z7e.deSerialize(e.slice(x,x+2));S=C,C.symbolSize===0&&C.symbolList.forEach(k=>{k===1&&p.push(new AD({type:1}))}),C.symbolSize===1&&C.symbolList.forEach(k=>{(k===1||k===2)&&p.push(new AD({type:k}))}),v+=C.symbolList.length}break}if(!S)throw new Error;x+=2,h.push(S)}let y=x;return p.forEach(v=>{v.type===1&&(v.deSerialize(e.slice(y,y+1)),y++),v.type===2&&(v.deSerialize(e.slice(y,y+2)),y+=2)}),new _ae({senderSsrc:n,mediaSourceSsrc:i,baseSequenceNumber:s,packetStatusCount:a,referenceTime:c,fbPktCount:d,recvDeltas:p,packetChunks:h,header:r})}serialize(){let e=Vs([4,4,2,2,3,1],[this.senderSsrc,this.mediaSourceSsrc,this.baseSequenceNumber,this.packetStatusCount,this.referenceTime,this.fbPktCount]),r=Buffer.concat(this.packetChunks.map(s=>s.serialize())),n=Buffer.concat(this.recvDeltas.map(s=>{try{return s.serialize()}catch(a){S6t(a?.message);return}}).filter(s=>s)),i=Buffer.concat([e,r,n]);if(this.header.padding&&i.length%4!==0){let s=4-i.length%4,a=Buffer.alloc(s);return a[a.length-1]=a.length,this.header.length=Math.floor((i.length+a.length)/4),Buffer.concat([this.header.serialize(),i,a])}return this.header.length=Math.floor(i.length/4),Buffer.concat([this.header.serialize(),i])}get packetResults(){let e=this.baseSequenceNumber-1,r=this.packetChunks.filter(a=>a instanceof BS).flatMap(a=>a.results(e)),n=0,s=BigInt(this.referenceTime)*64n;for(let a of r){let c=this.recvDeltas[n];!a.received||!c||(s+=BigInt(c.delta)/1000n,a.delta=c.delta,a.receivedAtMs=Number(s),n++)}return r}},BS=class K7e{type;packetStatus;runLength;constructor(e={}){Object.assign(this,e),this.type=0}static deSerialize(e){let r=ir(e[0],1,2),n=(ir(e[0],3,5)<<8)+e[1];return new K7e({type:0,packetStatus:r,runLength:n})}serialize(){return new bM(16).set(0).set(this.packetStatus,2).set(this.runLength,13).buffer}results(e){let r=this.packetStatus===1||this.packetStatus===2,n=[];for(let i=0;i<=this.runLength;++i)n.push(new Q7e({sequenceNumber:++e,received:r}));return n}},Z7e=class X7e{type;symbolSize;symbolList=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let n=ir(e[0],1,1),i=[];function s(a,c){for(let d=0;d<a;d++)c(d)}switch(n){case 0:s(6,a=>i.push(ir(e[0],2+a,1))),s(8,a=>i.push(ir(e[1],a,1)));break;case 1:s(3,a=>i.push(ir(e[0],2+a*2,2))),s(4,a=>i.push(ir(e[1],a*2,2)));break;default:n=(ir(e[0],2,6)<<8)+e[1]}return new X7e({type:1,symbolSize:n,symbolList:i})}serialize(){let e=Buffer.alloc(2),r=new bM(16).set(1).set(this.symbolSize),n=this.symbolSize===0?1:2;return this.symbolList.forEach(i=>{r.set(i,n)}),e.writeUInt16BE(r.value),e}},AD=class wae{type;delta;constructor(e={}){Object.assign(this,e)}static deSerialize(e){let r,n;if(e.length===1?(r=1,n=250*e[0]):e.length===2&&(r=2,n=250*e.readInt16BE()),r===void 0||n===void 0)throw new Error;return new wae({type:r,delta:n})}deSerialize(e){let r=wae.deSerialize(e);this.delta=r.delta}parsed=!1;parseDelta(){this.delta=Math.floor(this.delta/250),this.delta<0||this.delta>255?(this.delta>32767&&(this.delta=32767),this.delta<-32768&&(this.delta=-32768),this.type||(this.type=2)):this.type||(this.type=1),this.parsed=!0}serialize(){if(this.parsed||this.parseDelta(),this.type===1){let e=Buffer.alloc(1);return e.writeUInt8(this.delta),e}else if(this.type===2){let e=Buffer.alloc(2);return e.writeInt16BE(this.delta),e}throw new Error("errDeltaExceedLimit "+this.delta+" "+this.type)}},Y7e=(t=>(t[t.TypeTCCRunLengthChunk=0]="TypeTCCRunLengthChunk",t[t.TypeTCCStatusVectorChunk=1]="TypeTCCStatusVectorChunk",t[t.packetStatusChunkLength=2]="packetStatusChunkLength",t))(Y7e||{}),J7e=(t=>(t[t.TypeTCCPacketNotReceived=0]="TypeTCCPacketNotReceived",t[t.TypeTCCPacketReceivedSmallDelta=1]="TypeTCCPacketReceivedSmallDelta",t[t.TypeTCCPacketReceivedLargeDelta=2]="TypeTCCPacketReceivedLargeDelta",t[t.TypeTCCPacketReceivedWithoutDelta=3]="TypeTCCPacketReceivedWithoutDelta",t))(J7e||{}),Q7e=class{sequenceNumber=0;delta=0;received=!1;receivedAtMs=0;constructor(t){Object.assign(this,t)}},A6t=_n("werift-rtp:packages/rtp/rtcp/rtpfb/index"),Tv=class Sae{static type=G7e;type=Sae.type;feedback;header;constructor(e={}){Object.assign(this,e)}serialize(){return this.feedback.serialize()}static deSerialize(e,r){let n;switch(r.count){case UD.count:n=UD.deSerialize(e,r);break;case MD.count:n=MD.deSerialize(e,r);break;default:A6t("unknown rtpfb packet",r.count);break}return new Sae({feedback:n,header:r})}},LD=class Aae{static type=202;type=Aae.type;chunks=[];constructor(e){Object.assign(this,e)}get length(){let e=0;return this.chunks.forEach(r=>e+=r.length),e}serialize(){let e=Buffer.concat(this.chunks.map(r=>r.serialize()));for(;e.length%4;)e=Buffer.concat([e,Buffer.from([0])]);return kp.serialize(this.type,this.chunks.length,e,e.length/4)}static deSerialize(e,r){let n=[];for(let i=0;i<e.length;){let s=goe.deSerialize(e.slice(i));n.push(s),i+=s.length}return new Aae({chunks:n})}},goe=class eBe{source;items=[];constructor(e={}){Object.assign(this,e)}get length(){let e=4;return this.items.forEach(r=>e+=r.length),e+=1,e+=ROe(e),e}serialize(){let e=Buffer.concat([Vs([4],[this.source]),Buffer.concat(this.items.map(n=>n.serialize()))]);return Buffer.concat([e,Buffer.alloc(ROe(e.length))])}static deSerialize(e){let r=e.readUInt32BE(),n=[];for(let i=4;i<e.length&&e[i]!==0;){let a=xoe.deSerialize(e.slice(i));n.push(a),i+=a.length}return new eBe({source:r,items:n})}},xoe=class tBe{type;text;constructor(e){Object.assign(this,e)}get length(){return 2+Buffer.from(this.text).length}serialize(){let e=Buffer.from(this.text);return Buffer.concat([Vs([1,1],[this.type,e.length]),e])}static deSerialize(e){let r=e[0],n=e[1],i=e.slice(2,2+n).toString();return new tBe({type:r,text:i})}};Cv=class zU{ssrc=0;senderInfo;reports=[];static type=200;type=zU.type;constructor(e){Object.assign(this,e)}toJSON(){return{ssrc:this.ssrc,senderInfo:this.senderInfo.toJSON(),reports:this.reports.map(e=>e.toJSON())}}serialize(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.ssrc),e=Buffer.concat([e,this.senderInfo.serialize()]),e=Buffer.concat([e,...this.reports.map(r=>r.serialize())]),kp.serialize(zU.type,this.reports.length,e,Math.floor(e.length/4))}static deSerialize(e,r){let n=e.readUInt32BE(),i=yoe.deSerialize(e.subarray(4,24)),s=24,a=[];for(let d=0;d<r;d++)a.push(kM.deSerialize(e.subarray(s,s+24))),s+=24;return new zU({ssrc:n,senderInfo:i,reports:a})}},yoe=class rBe{ntpTimestamp;rtpTimestamp;packetCount;octetCount;constructor(e={}){Object.assign(this,e)}toJSON(){return{ntpTimestamp:nBe(this.ntpTimestamp),rtpTimestamp:this.rtpTimestamp}}serialize(){return Vs([8,4,4,4],[this.ntpTimestamp,this.rtpTimestamp,this.packetCount,this.octetCount])}static deSerialize(e){let[r,n,i,s]=zc(e,[8,4,4,4]);return new rBe({ntpTimestamp:r,rtpTimestamp:n,packetCount:i,octetCount:s})}},nBe=t=>{let[e,r]=zc(Vs([8],[t]),[4,4]);return+`${e}.${r}`},E6t=_n("werift-rtp:packages/rtp/src/rtcp/rtcp.ts"),iBe=class{static deSerialize(t){let e=0,r=[];for(;e<t.length;){let n=kp.deSerialize(t.subarray(e,e+lM));e+=lM;let i=t.subarray(e);e+=n.length*4,n.padding&&(i=i.subarray(0,i.length-i.subarray(-1)[0]));try{switch(n.type){case Cv.type:r.push(Cv.deSerialize(i,n.count));break;case $S.type:r.push($S.deSerialize(i,n.count));break;case LD.type:r.push(LD.deSerialize(i,n));break;case Tv.type:r.push(Tv.deSerialize(i,n));break;case LS.type:r.push(LS.deSerialize(i,n));break;default:break}}catch(s){E6t("deSerialize RTCP",s)}}return r}};Os={sdesMid:"urn:ietf:params:rtp-hdrext:sdes:mid",sdesRTPStreamID:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",repairedRtpStreamId:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",transportWideCC:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",absSendTime:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",dependencyDescriptor:"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension",audioLevelIndication:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",videoOrientation:"urn:3gpp:video-orientation"};C6t=_n("packages/rtp/src/rtp/red/packet.ts"),voe=class xBe{header;blocks=[];static deSerialize(e){let r=e instanceof ArrayBuffer?Buffer.from(e):e,n=new xBe,i=0;return[n.header,i]=Eae.deSerialize(r),n.header.fields.forEach(({blockLength:s,timestampOffset:a,blockPT:c})=>{if(s&&a){let d=r.subarray(i,i+s);n.blocks.push({block:d,blockPT:c,timestampOffset:a}),i+=s}else{let d=r.subarray(i);n.blocks.push({block:d,blockPT:c})}}),n}serialize(){this.header=new Eae;for(let{timestampOffset:r,blockPT:n,block:i}of this.blocks)r?this.header.fields.push({fBit:1,blockPT:n,blockLength:i.length,timestampOffset:r}):this.header.fields.push({fBit:0,blockPT:n});let e=this.header.serialize();for(let{block:r}of this.blocks)e=Buffer.concat([e,r]);return e}},Eae=class yBe{fields=[];static deSerialize(e){let r=0,n=new yBe;for(;;){let i={};n.fields.push(i);let s=new Ug(e.subarray(r));if(i.fBit=s.readBits(1),i.blockPT=s.readBits(7),r++,i.fBit===0)break;i.timestampOffset=s.readBits(14),i.blockLength=s.readBits(10),r+=3}return[n,r]}serialize(){let e=Buffer.alloc(0);for(let r of this.fields)try{if(r.timestampOffset&&r.blockLength){let n=new Ug(Buffer.alloc(4)).writeBits(1,r.fBit).writeBits(7,r.blockPT).writeBits(14,r.timestampOffset).writeBits(10,r.blockLength);e=Buffer.concat([e,n.uint8Array])}else{let n=new Ug(Buffer.alloc(1)).writeBits(1,0).writeBits(7,r.blockPT);e=Buffer.concat([e,n.uint8Array])}}catch(n){C6t(n?.message)}return e}},vBe=class{constructor(t=1){this.distance=t}cache=[];cacheSize=10;push(t){this.cache.push(t),this.cache.length>this.cacheSize&&this.cache.shift()}build(){let t=new voe,e=this.cache.slice(-(this.distance+1)),r=e.pop();return r&&(e.forEach(n=>{let i=bv(r.timestamp,-n.timestamp);i>k6t||t.blocks.push({block:n.block,blockPT:n.blockPT,timestampOffset:i})}),t.blocks.push({block:r.block,blockPT:r.blockPT})),t}},k6t=16383,bBe=class{size=150;sequenceNumbers=[];push(t,e){let r=[];return t.blocks.forEach(({blockPT:i,timestampOffset:s,block:a},c)=>{let d=jo(e.header.sequenceNumber,-(t.blocks.length-(c+1)));s?r.push(new Cp(new Tp({timestamp:bv(e.header.timestamp,-s),payloadType:i,ssrc:e.header.ssrc,sequenceNumber:d,marker:!0}),a)):r.push(new Cp(new Tp({timestamp:e.header.timestamp,payloadType:i,ssrc:e.header.ssrc,sequenceNumber:d,marker:!0}),a))}),r.filter(i=>this.sequenceNumbers.includes(i.header.sequenceNumber)?!1:(this.sequenceNumbers.length>this.size&&this.sequenceNumbers.shift(),this.sequenceNumbers.push(i.header.sequenceNumber),!0))}},Ng={OneByte:48862,TwoByte:4096},OOe=2,NOe=4,BOe=8,UOe=12,MOe=4,Tp=class _Be{version=2;padding=!1;paddingSize=0;extension=!1;marker=!1;payloadOffset=0;payloadType=0;sequenceNumber=0;timestamp=0;ssrc=0;csrcLength=0;csrc=[];extensionProfile=Ng.OneByte;extensionLength;extensions=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let r=new _Be,n=0,i=e[n++];r.version=ir(i,0,2),r.padding=ir(i,2)>0,r.extension=ir(i,3)>0,r.csrcLength=ir(i,4,4),r.csrc=[...Array(r.csrcLength)].map(()=>{let a=e.readUInt32BE(n);return n+=4,a}),n+=UOe-1;let s=e[1];r.marker=ir(s,0)>0,r.payloadType=ir(s,1,7),r.sequenceNumber=e.readUInt16BE(OOe),r.timestamp=e.readUInt32BE(NOe),r.ssrc=e.readUInt32BE(BOe);for(let a=0;a<r.csrc.length;a++){let c=UOe+a*MOe;r.csrc[a]=e.subarray(c).readUInt32BE()}if(r.extension){r.extensionProfile=e.subarray(n).readUInt16BE(),n+=2;let a=e.subarray(n).readUInt16BE()*4;switch(r.extensionLength=a,n+=2,r.extensionProfile){case Ng.OneByte:{let c=n+a;for(;n<c;){if(e[n]===0){n++;continue}let d=e[n]>>4,h=(e[n]&(e[n]^240))+1;if(n++,d===15)break;let p={id:d,payload:e.subarray(n,n+h)};r.extensions=[...r.extensions,p],n+=h}}break;case Ng.TwoByte:{let c=n+a;for(;n<c;){if(e[n]===0){n++;continue}let d=e[n];n++;let h=e[n];n++;let p={id:d,payload:e.subarray(n,n+h)};r.extensions=[...r.extensions,p],n+=h}}break;default:{let c={id:0,payload:e.subarray(n,n+a)};r.extensions=[...r.extensions,c],n+=r.extensions[0].payload.length}break}}return r.payloadOffset=n,r.padding&&(r.paddingSize=e[e.length-1]),r}get serializeSize(){let{csrc:e,extensionProfile:r,extensions:n}=this,i=12+e.length*MOe;if(n.length>0||this.extension===!0){let s=4;switch(r){case Ng.OneByte:for(let a of n)s+=1+a.payload.length;break;case Ng.TwoByte:for(let a of n)s+=2+a.payload.length;break;default:s+=n[0].payload.length}i+=Math.floor((s+3)/4)*4}return i}serialize(e){let r=Buffer.alloc(e),n=0,i=new CD(8);i.set(2,0,this.version),this.padding&&i.set(1,2,1),this.extensions.length>0&&(this.extension=!0),this.extension&&i.set(1,3,1),i.set(4,4,this.csrc.length),r.writeUInt8(i.value,n++);let s=new CD(8);this.marker&&s.set(1,0,1),s.set(7,1,this.payloadType),r.writeUInt8(s.value,n++),r.writeUInt16BE(this.sequenceNumber,OOe),n+=2,r.writeUInt32BE(this.timestamp,NOe),n+=4,r.writeUInt32BE(this.ssrc,BOe),n+=4;for(let a of this.csrc)r.writeUInt32BE(a,n),n+=4;if(this.extension){let a=n;r.writeUInt16BE(this.extensionProfile,n),n+=4;let c=n;switch(this.extensionProfile){case Ng.OneByte:for(let p of this.extensions)r.writeUInt8(p.id<<4|p.payload.length-1,n++),p.payload.copy(r,n),n+=p.payload.length;break;case Ng.TwoByte:for(let p of this.extensions)r.writeUInt8(p.id,n++),r.writeUInt8(p.payload.length,n++),p.payload.copy(r,n),n+=p.payload.length;break;default:{let p=this.extensions[0].payload.length;if(p%4!=0)throw new Error;this.extensions[0].payload.copy(r,n),n+=p}}let d=n-c,h=Math.trunc((d+3)/4)*4;r.writeUInt16BE(Math.trunc(h/4),a+2);for(let p=0;p<h-d;p++)r.writeUInt8(0,n),n++}return this.payloadOffset=n,r}},Cp=class Tae{constructor(e,r){this.header=e,this.payload=r}get serializeSize(){return this.header.serializeSize+this.payload.length}clone(){return new Tae(new Tp({...this.header}),this.payload)}serialize(){let e=this.header.serialize(this.header.serializeSize+this.payload.length),{payloadOffset:r}=this.header;if(this.payload.copy(e,r),this.header.padding){let n=Buffer.alloc(this.header.paddingSize);n.writeUInt8(this.header.paddingSize,this.header.paddingSize-1),e=Buffer.concat([e,n])}return e}static deSerialize(e){let r=Tp.deSerialize(e);return new Tae(r,e.subarray(r.payloadOffset,e.length-r.paddingSize))}clear(){this.payload=null}};ABe=class{constructor(t,e,r,n){this.srtpSessionKey=t,this.srtpSessionSalt=e,this.srtcpSessionKey=r,this.srtcpSessionSalt=n}encryptRtp(t,e,r){return Buffer.from([])}decryptRtp(t,e,r){return[]}encryptRTCP(t,e){return Buffer.from([])}decryptRTCP(t){return[]}},kv=class extends Error{constructor(t){super(t),this.name="SrtpAuthenticationError"}},qOe=12,I6t=8;F6t=class extends ABe{constructor(t,e,r,n,i,s){super(t,e,r,n),this.srtpSessionAuthTag=i,this.srtcpSessionAuthTag=s}authTagLength=10;encryptRtp(t,e,r){let n=t.serialize(t.serializeSize),i=this.generateCounter(t.sequenceNumber,r,t.ssrc,this.srtpSessionSalt),a=LOe("aes-128-ctr",this.srtpSessionKey,i).update(e),c=this.generateSrtpAuthTag(r,n,a);return Buffer.concat([n,a,c])}decryptRtp(t,e,r=_oe(t,this.authTagLength)){let n=t.length-this.authTagLength,i=t.subarray(0,n),s=t.subarray(n),a=this.generateSrtpAuthTag(e,i.subarray(0,r.payloadOffset),i.subarray(r.payloadOffset));WOe(s,a,"Failed to authenticate SRTP packet");let c=this.generateCounter(r.sequenceNumber,e,r.ssrc,this.srtpSessionSalt),d=$Oe("aes-128-ctr",this.srtpSessionKey,c),h=i.subarray(r.payloadOffset),p=d.update(h),x=Buffer.concat([i.subarray(0,r.payloadOffset),p]);return[x,CBe(r,x,"Failed to authenticate SRTP packet")]}encryptRTCP(t,e){let r=Buffer.from(t),n=r.readUInt32BE(4),i=this.generateCounter(e&65535,e>>16,n,this.srtcpSessionSalt);LOe("aes-128-ctr",this.srtcpSessionKey,i).update(r.slice(8)).copy(r,8),r=Buffer.concat([r,Buffer.alloc(4)]),r.writeUInt32BE(e,r.length-4),r[r.length-4]|=128;let c=this.generateSrtcpAuthTag(r);return r=Buffer.concat([r,c]),r}decryptRTCP(t){let e=EBe(t,this.authTagLength,zOe),r=t.length-(this.authTagLength+zOe),n=t.subarray(0,t.length-this.authTagLength),i=t.subarray(t.length-this.authTagLength),s=this.generateSrtcpAuthTag(n);WOe(i,s,"Failed to authenticate SRTCP packet");let a=Buffer.from(t).slice(0,r);if(t[r]>>>7===0)return[a,e];let d=t.readUInt32BE(r);d&=~(1<<31);let h=t.readUInt32BE(4),p=this.generateCounter(d&65535,d>>16,h,this.srtcpSessionSalt);return $Oe("aes-128-ctr",this.srtcpSessionKey,p).update(a.subarray(8)).copy(a,8),[a,e]}generateSrtcpAuthTag(t){return jOe("sha1",this.srtcpSessionAuthTag).update(t).digest().slice(0,10)}generateCounter(t,e,r,n){let i=Buffer.alloc(16);i.writeUInt32BE(r,4),i.writeUInt32BE(e,8),i.writeUInt32BE(Number(BigInt(t)<<16n),12);for(let s=0;s<n.length;s++)i[s]^=n[s];return i}generateSrtpAuthTag(t,...e){let r=jOe("sha1",this.srtpSessionAuthTag),n=Buffer.alloc(4);n.writeUInt32BE(t);for(let i of e)r.update(i);return r.update(n).digest().subarray(0,10)}},zOe=4;P6t=class extends ABe{aeadAuthTagLen=16;rtpIvWriter=SD([2,4,4,2],!0);rtcpIvWriter=SD([2,4,2,4],!0);aadWriter=SD([4],!0);constructor(t,e,r,n){super(t,e,r,n)}encryptRtp(t,e,r){let n=t.serialize(t.serializeSize),i=this.rtpInitializationVector(t,r),s=HOe("aes-128-gcm",this.srtpSessionKey,i);s.setAAD(n);let a=s.update(e);s.final();let c=s.getAuthTag();return Buffer.concat([n,a,c])}decryptRtp(t,e,r=_oe(t,this.aeadAuthTagLen)){let n=t.subarray(0,r.payloadOffset),i=t.length-this.aeadAuthTagLen,s=t.subarray(i),a=Buffer.from([]);a=pae(a,t.length-this.aeadAuthTagLen),n.copy(a);let c=this.rtpInitializationVector(r,e),d=t.slice(r.payloadOffset,i),h=VOe("aes-128-gcm",this.srtpSessionKey,c);h.setAAD(n),h.setAuthTag(s);let p=h.update(d);return KOe(h,"SRTP"),p.copy(a,r.payloadOffset),[a,CBe(r,a,"Failed to authenticate SRTP packet")]}encryptRTCP(t,e){let r=t.readUInt32BE(4),n=t.length+this.aeadAuthTagLen,i=Buffer.from([]);i=pae(i,n+Hse),t.slice(0,8).copy(i);let s=this.rtcpInitializationVector(r,e),a=this.rtcpAdditionalAuthenticatedData(t,e),c=HOe("aes-128-gcm",this.srtcpSessionKey,s);c.setAAD(a);let d=c.update(t.slice(8));return c.final(),d.copy(i,8),c.getAuthTag().copy(i,8+d.length),a.slice(8,12).copy(i,n),i}decryptRTCP(t){let e=EBe(t,this.aeadAuthTagLen,Hse),r=t.length-Hse,n=r-this.aeadAuthTagLen,i=t.readUInt32BE(4),s=t.readUInt32BE(r),a=s>>>31===1,c=s&~(GOe<<24),d=this.rtcpInitializationVector(i,c),h=a?Buffer.concat([t.subarray(0,8),t.subarray(r)]):Buffer.concat([t.subarray(0,n),t.subarray(r)]),p=a?t.slice(8,n):Buffer.alloc(0),x=a?Buffer.alloc(n):Buffer.from(t.subarray(0,n));a&&t.slice(0,8).copy(x);let y=VOe("aes-128-gcm",this.srtcpSessionKey,d);y.setAAD(h),y.setAuthTag(t.subarray(n,r));let v=y.update(p);return KOe(y,"SRTCP"),a&&v.copy(x,8),[x,e]}rtpInitializationVector(t,e){let r=this.rtpIvWriter([0,t.ssrc,e,t.sequenceNumber]);for(let n=0;n<r.length;n++)r[n]^=this.srtpSessionSalt[n];return r}rtcpInitializationVector(t,e){let r=this.rtcpIvWriter([0,t,0,e]);for(let n=0;n<r.length;n++)r[n]^=this.srtcpSessionSalt[n];return r}rtcpAdditionalAuthenticatedData(t,e){let r=Buffer.concat([t.subarray(0,8),this.aadWriter([e])]);return r[8]|=GOe,r}},Hse=4,GOe=128;kBe=class{constructor(t,e,r){this.masterKey=t,this.masterSalt=e,this.profile=r;{let n=14-e.length;n>0&&(this.masterSalt=Buffer.concat([e,Buffer.alloc(n)]))}switch(this.srtpSessionKey=this.generateSessionKey(0),this.srtpSessionSalt=this.generateSessionSalt(2),this.srtpSessionAuthTag=this.generateSessionAuthTag(1),this.srtpSessionAuth=Wse("sha1",this.srtpSessionAuthTag),this.srtcpSessionKey=this.generateSessionKey(3),this.srtcpSessionSalt=this.generateSessionSalt(5),this.srtcpSessionAuthTag=this.generateSessionAuthTag(4),this.srtcpSessionAuth=Wse("sha1",this.srtcpSessionAuthTag),r){case HS:this.cipher=new F6t(this.srtpSessionKey,this.srtpSessionSalt,this.srtcpSessionKey,this.srtcpSessionSalt,this.srtpSessionAuthTag,this.srtcpSessionAuthTag);break;case Fv:this.cipher=new P6t(this.srtpSessionKey,this.srtpSessionSalt,this.srtcpSessionKey,this.srtcpSessionSalt);break}}srtpSSRCStates={};srtpSessionKey;srtpSessionSalt;srtpSessionAuthTag;srtpSessionAuth;srtcpSSRCStates={};srtcpSessionKey;srtcpSessionSalt;srtcpSessionAuthTag;srtcpSessionAuth;cipher;generateSessionKey(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let i=r.length-1,s=e.length-1;i>=0;i--,s--)e[s]=e[s]^r[i];e=Buffer.concat([e,Buffer.from([0,0])]);let n=new WU.default.AES(this.masterKey);return Buffer.from(n.encrypt(e))}generateSessionSalt(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let i=r.length-1,s=e.length-1;i>=0;i--,s--)e[s]=e[s]^r[i];e=Buffer.concat([e,Buffer.from([0,0])]);let n=new WU.default.AES(this.masterKey);return e=Buffer.from(n.encrypt(e)),e.subarray(0,14)}generateSessionAuthTag(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let a=r.length-1,c=e.length-1;a>=0;a--,c--)e[c]=e[c]^r[a];let n=Buffer.concat([e,Buffer.from([0,0])]),i=Buffer.concat([e,Buffer.from([0,1])]),s=new WU.default.AES(this.masterKey);return n=Buffer.from(s.encrypt(n)),i=Buffer.from(s.encrypt(i)),Buffer.concat([n,i.subarray(0,4)])}getSrtpSsrcState(t){let e=this.srtpSSRCStates[t];return e||(e={ssrc:t,rolloverCounter:0,lastSequenceNumber:0},this.srtpSSRCStates[t]=e,e)}getSrtcpSsrcState(t){let e=this.srtcpSSRCStates[t];return e||(e={srtcpIndex:0,ssrc:t},this.srtcpSSRCStates[t]=e,e)}updateRolloverCount(t,e){e.rolloverHasProcessed?t===0?e.lastSequenceNumber>iD&&e.rolloverCounter++:e.lastSequenceNumber<iD&&t>ZOe-iD?e.rolloverCounter>0&&e.rolloverCounter--:t<iD&&e.lastSequenceNumber>ZOe-iD&&e.rolloverCounter++:e.rolloverHasProcessed=!0,e.lastSequenceNumber=t}generateSrtpAuthTag(t,e){this.srtpSessionAuth=Wse("sha1",this.srtpSessionAuthTag);let r=Buffer.alloc(4);return r.writeUInt32BE(e),this.srtpSessionAuth.update(t).update(r).digest().slice(0,10)}index(t){let e=this.srtcpSSRCStates[t];return e?e.srtcpIndex:0}setIndex(t,e){let r=this.getSrtcpSsrcState(t);r.srtcpIndex=e%2147483647}},iD=100,ZOe=65535,R6t=class extends kBe{constructor(t,e,r){super(t,e,r)}encryptRTCP(t){let e=t.readUInt32BE(4),r=this.getSrtcpSsrcState(e);return r.srtcpIndex++,r.srtcpIndex>>O6t&&(r.srtcpIndex=0),this.cipher.encryptRTCP(t,r.srtcpIndex)}decryptRTCP(t){return this.cipher.decryptRTCP(t)}},O6t=2147483647,DBe=class{constructor(t){this.ContextCls=t}localContext;remoteContext;onData;start(t,e,r,n,i){this.localContext=new this.ContextCls(t,e,i),this.remoteContext=new this.ContextCls(r,n,i)}},IBe=class extends DBe{constructor(t){super(R6t),this.config=t,this.start(t.keys.localMasterKey,t.keys.localMasterSalt,t.keys.remoteMasterKey,t.keys.remoteMasterSalt,t.profile)}decrypt=t=>{let[e]=this.remoteContext.decryptRTCP(t);return e};encrypt(t){return this.localContext.encryptRTCP(t)}},N6t=class extends kBe{constructor(t,e,r){super(t,e,r)}encryptRtp(t,e){let r=this.getSrtpSsrcState(e.ssrc);return this.updateRolloverCount(e.sequenceNumber,r),this.cipher.encryptRtp(e,t,r.rolloverCounter)}decryptRtp(t){let e=_oe(t,this.rtpAuthTagLength),r=this.srtpSSRCStates[e.ssrc],n=r?{...r}:{ssrc:e.ssrc,rolloverCounter:0,lastSequenceNumber:0};this.updateRolloverCount(e.sequenceNumber,n);let i=this.cipher.decryptRtp(t,n.rolloverCounter,e);return r?Object.assign(r,n):this.srtpSSRCStates[e.ssrc]=n,i}get rtpAuthTagLength(){return this.profile===Fv?16:10}},FBe=class extends DBe{constructor(t){super(N6t),this.config=t,this.start(t.keys.localMasterKey,t.keys.localMasterSalt,t.keys.remoteMasterKey,t.keys.remoteMasterSalt,t.profile)}decrypt=t=>{let[e]=this.remoteContext.decryptRtp(t);return e};encrypt(t,e){return this.localContext.encryptRtp(t,e)}},B6t=class{constructor(t){this.props=t}sequenceNumber=coe();timestamp=sM();create(t){this.sequenceNumber=jo(this.sequenceNumber,1);let e=this.props.between*this.props.clockRate/1e3;this.timestamp=bv(this.timestamp,e);let r=new Tp({sequenceNumber:this.sequenceNumber,timestamp:Number(this.timestamp),payloadType:96,extension:!0,marker:!1,padding:!1});return new Cp(r,t)}},qc=_n("werift-dtls : packages/dtls/src/flight/client/flight5.ts : log"),U6t=class extends KD{constructor(t,e,r,n){super(t,e,5,7),this.cipher=r,this.srtp=n}handleHandshake(t){this.dtls.bufferHandshakeCache([t],!1,4);let e=(()=>{switch(t.msg_type){case 2:return E7e.deSerialize(t.fragment);case 11:return uM.deSerialize(t.fragment);case 12:return k7e.deSerialize(t.fragment);case 13:return A7e.deSerialize(t.fragment);case 14:return T7e.deSerialize(t.fragment)}})();e&&VS[e.msgType]({dtls:this.dtls,cipher:this.cipher,srtp:this.srtp})(e)}async exec(){if(this.dtls.flight===5){qc(this.dtls.sessionId,"flight5 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=5;let t=this.dtls.requestedCertificateTypes.length>0;qc(this.dtls.sessionId,"send flight5",t);let e=[t&&this.sendCertificate(),this.sendClientKeyExchange(),t&&this.sendCertificateVerify(),this.sendChangeCipherSpec(),this.sendFinished()].filter(r=>r);this.dtls.lastMessage=e,await this.transmit(e)}sendCertificate(){let t=new uM([Buffer.from(this.cipher.localCert)]),e=this.createPacket([t]);return Buffer.concat(e.map(n=>n.serialize()))}sendClientKeyExchange(){if(!this.cipher.localKeyPair)throw new Error;let t=new S7e(this.cipher.localKeyPair.publicKey),e=this.createPacket([t]),r=Buffer.concat(e.map(c=>c.serialize())),n=this.cipher.localKeyPair,i=this.cipher.remoteKeyPair;if(!i.publicKey)throw new Error("not exist");let s=o7e(i.publicKey,n.privateKey,n.curve);qc(this.dtls.sessionId,"extendedMasterSecret",this.dtls.options.extendedMasterSecret,this.dtls.remoteExtendedMasterSecret);let a=Buffer.concat(this.dtls.sortedHandshakeCache.map(c=>c.serialize()));return this.cipher.masterSecret=this.dtls.options.extendedMasterSecret&&this.dtls.remoteExtendedMasterSecret?u7e(s,a):c7e(s,this.cipher.localRandom.serialize(),this.cipher.remoteRandom.serialize()),this.cipher.cipher=y7e(this.cipher.cipherSuite),this.cipher.cipher.init(this.cipher.masterSecret,this.cipher.remoteRandom.serialize(),this.cipher.localRandom.serialize()),qc(this.dtls.sessionId,"cipher",this.cipher.cipher.summary),r}sendCertificateVerify(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(a=>a.serialize())),e=this.cipher.signatureData(t,"sha256"),r=(()=>{switch(this.cipher.signatureHashAlgorithm?.signature){case Uh.ecdsa_3:return sae.ecdsa_secp256r1_sha256;case Uh.rsa_1:return sae.rsa_pkcs1_sha256}})();if(!r)throw new Error;qc(this.dtls.sessionId,"signatureScheme",this.cipher.signatureHashAlgorithm?.signature,r);let n=new w7e(r,e),i=this.createPacket([n]);return Buffer.concat(i.map(a=>a.serialize()))}sendChangeCipherSpec(){let t=_7e.createEmpty().serialize(),e=GD(this.dtls)([{type:20,fragment:t}],++this.dtls.recordSequenceNumber);return Buffer.concat(e.map(n=>n.serialize()))}sendFinished(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(s=>s.serialize())),e=this.cipher.verifyData(t),r=new fae(e);this.dtls.epoch=1;let[n]=this.createPacket([r]);this.dtls.recordSequenceNumber=0;let i=this.cipher.encryptPacket(n).serialize();return qc(this.dtls.sessionId,"finished",this.cipher.cipher.summary),i}},VS={};VS[2]=({cipher:t,srtp:e,dtls:r})=>n=>{qc(r.sessionId,"serverHello",n.cipherSuite),t.remoteRandom=wv.from(n.random),t.cipherSuite=n.cipherSuite,qc(r.sessionId,"selected cipherSuite",t.cipherSuite),n.extensions&&n.extensions.forEach(i=>{switch(i.type){case MS.type:{let s=MS.fromData(i.data),a=PD.findMatchingSRTPProfile(s.profiles,r.options.srtpProfiles||[]);if(qc(r.sessionId,"selected srtp profile",a),a==null)return;e.srtpProfile=a}break;case EM.type:r.remoteExtendedMasterSecret=!0;break;case TM.type:qc(r.sessionId,"RenegotiationIndication");break}})};VS[11]=({cipher:t,dtls:e})=>r=>{qc(e.sessionId,"handshake certificate",r),t.remoteCertificate=r.certificateList[0]};VS[12]=({cipher:t,dtls:e})=>r=>{if(!t.localRandom||!t.remoteRandom)throw new Error;qc(e.sessionId,"ServerKeyExchange",r),qc(e.sessionId,"selected curve",r.namedCurve),t.remoteKeyPair={curve:r.namedCurve,publicKey:r.publicKey},t.localKeyPair=b7e(r.namedCurve)};VS[13]=({dtls:t})=>e=>{qc(t.sessionId,"certificate_request",e),t.requestedCertificateTypes=e.certificateTypes,t.requestedSignatureAlgorithms=e.signatures};VS[14]=({dtls:t})=>e=>{qc(t.sessionId,"server_hello_done",e)};PBe=class bD{constructor(e,r){this.serverVersion=e,this.cookie=r}msgType=3;messageSeq;static spec={serverVersion:moe,cookie:Dv.types.buffer(Dv.types.uint8)};static createEmpty(){return new bD(void 0,void 0)}static deSerialize(e){return new bD(...Object.values((0,Dv.decode)(e,bD.spec)))}serialize(){let e=(0,Dv.encode)(this,bD.spec).slice();return Buffer.from(e)}get version(){return{major:255-this.serverVersion.major,minor:255-this.serverVersion.minor}}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},L6t=_n("werift-dtls : packages/dtls/src/context/dtls.ts : log"),XOe=class{constructor(t,e){this.options=t,this.sessionType=e}version={major:254,minor:253};lastFlight=[];lastMessage=[];recordSequenceNumber=0;sequenceNumber=0;epoch=0;flight=0;handshakeCache={};cookie;requestedCertificateTypes=[];requestedSignatureAlgorithms=[];remoteExtendedMasterSecret=!1;get sessionId(){return this.cookie?this.cookie.toString("hex").slice(0,10):""}get sortedHandshakeCache(){return Object.entries(this.handshakeCache).sort(([t],[e])=>Number(t)-Number(e)).flatMap(([,{data:t}])=>t.sort((e,r)=>e.message_seq-r.message_seq))}checkHandshakesExist=t=>!t.find(e=>this.sortedHandshakeCache.find(r=>r.msg_type===e)==null);bufferHandshakeCache(t,e,r){this.handshakeCache[r]||(this.handshakeCache[r]={data:[],isLocal:e,flight:r});let n=t.filter(i=>{let s=this.handshakeCache[r].data.find(a=>a.msg_type===i.msg_type);return s?(L6t(this.sessionId,"exist",s.summary,e,r),!1):!0});this.handshakeCache[r].data=[...this.handshakeCache[r].data,...n]}},$6t=class{constructor(t){this.socket=t}send=t=>this.socket.send(t)},Cae=class vp{static type=10;static spec={type:Bh.types.uint16be,data:Bh.types.array(Bh.types.uint16be,Bh.types.uint16be,"bytes")};type=vp.type;data=[];constructor(e={}){Object.assign(this,e)}static createEmpty(){return new vp}static fromData(e){return new vp({type:vp.type,data:(0,Bh.decode)(e,vp.spec.data)})}static deSerialize(e){return new vp((0,Bh.decode)(e,vp.spec))}serialize(){return Buffer.from((0,Bh.encode)(this,vp.spec).slice())}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},kae=class Bg{static type=13;static spec={type:Nh.types.uint16be,data:Nh.types.array({hash:Nh.types.uint8,signature:Nh.types.uint8},Nh.types.uint16be,"bytes")};type=Bg.type;data=[];constructor(e={}){Object.assign(this,e)}static createEmpty(){return new Bg}static deSerialize(e){return new Bg((0,Nh.decode)(e,Bg.spec))}serialize(){let e=(0,Nh.encode)(this,Bg.spec).slice();return Buffer.from(e)}static fromData(e){let r=Buffer.alloc(2);return r.writeUInt16BE(Bg.type),Bg.deSerialize(Buffer.concat([r,e]))}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},YOe=class HU{constructor(e,r){this.level=e,this.description=r}static spec={level:Iv.types.uint8,description:Iv.types.uint8};static deSerialize(e){return new HU(...Object.values((0,Iv.decode)(e,HU.spec)))}serialize(){let e=(0,Iv.encode)(this,HU.spec).slice();return Buffer.from(e)}},JOe=_n("werift-dtls : packages/dtls/record/receive.ts : log"),Vse=_n("werift-dtls : packages/dtls/record/receive.ts : err"),j6t=t=>{let e=0,r=[];for(;t.length>e;){let n=t.readUInt16BE(e+11);if(t.length<e+(12+n))break;let i=g7e.deSerialize(t.subarray(e));r.push(i),e+=13+n}return r},q6t=(t,e)=>r=>{switch(r.recordLayerHeader.contentType){case 20:return JOe(t.sessionId,"change cipher spec"),[{type:20,data:void 0}];case 22:{let i=r.fragment;try{r.recordLayerHeader.epoch>0&&(JOe(t.sessionId,"decrypt handshake"),i=e.decryptPacket(r))}catch(s){throw Vse(t.sessionId,"decrypt failed",s),s}try{let s=0,a=[];for(;i.length>s;){let c=af.deSerialize(i.subarray(s));a.push({type:22,data:c}),s+=c.fragment_length+12}return a}catch(s){throw Vse(t.sessionId,"decSerialize failed",s,i),s}}case 23:return[{type:23,data:e.decryptPacket(r)}];case 21:{let i=YOe.deSerialize(r.fragment);if(uae[i.description]==null){let s=e.decryptPacket(r);i=YOe.deSerialize(s)}if(Vse(t.sessionId,"ContentType.alert",i,uae[i.description],"flight",t.flight,"lastFlight",t.lastFlight),i.level>1)throw new Error("alert fatal error");return[{type:21,data:void 0}]}default:return[{type:21,data:void 0}]}},QOe=_n("werift-dtls : packages/dtls/src/socket.ts : log"),eNe=_n("werift-dtls : packages/dtls/src/socket.ts : err"),woe=class{constructor(t,e){this.options=t,this.sessionType=e,this.dtls=new XOe(this.options,this.sessionType),this.cipher=new FD(this.sessionType,this.options.cert,this.options.key,this.options.signatureHash),this.transport=new $6t(this.options.transport),this.setupExtensions(),this.transport.socket.onData=this.udpOnMessage}onConnect=new yr;onData=new yr;onError=new yr;onClose=new yr;transport;cipher;dtls;srtp=new PD;connected=!1;extensions=[];onHandleHandshakes;bufferFragmentedHandshakes=[];renegotiation(){QOe("renegotiation",this.sessionType),this.connected=!1,this.cipher=new FD(this.sessionType,this.options.cert,this.options.key,this.options.signatureHash),this.dtls=new XOe(this.options,this.sessionType),this.srtp=new PD,this.extensions=[],this.bufferFragmentedHandshakes=[]}udpOnMessage=t=>{let e=j6t(t);for(let r of e)try{let n=q6t(this.dtls,this.cipher)(r);for(let i of n)switch(i.type){case 22:{let s=i.data,a=this.handleFragmentHandshake([s]),c=Object.values(a.reduce((d,h)=>(d[h.msg_type]||(d[h.msg_type]=[]),d[h.msg_type].push(h),d),{})).map(d=>af.assemble(d)).sort((d,h)=>d.msg_type-h.msg_type);this.onHandleHandshakes(c).catch(d=>{eNe(this.dtls.sessionId,"onHandleHandshakes error",d),this.onError.execute(d)})}break;case 23:this.onData.execute(i.data);break;case 21:this.onClose.execute();break}}catch(n){eNe(this.dtls.sessionId,"catch udpOnMessage error",n)}};setupExtensions(){if(QOe(this.dtls.sessionId,"support srtpProfiles",this.options.srtpProfiles),this.options.srtpProfiles&&this.options.srtpProfiles.length>0){let t=MS.create(this.options.srtpProfiles,Buffer.from([0]));this.extensions.push(t.extension)}{let t=Cae.createEmpty();t.data=foe,this.extensions.push(t.extension)}{let t=kae.createEmpty();t.data=hoe,this.extensions.push(t.extension)}this.options.extendedMasterSecret&&this.extensions.push({type:EM.type,data:Buffer.alloc(0)});{let t=TM.createEmpty();this.extensions.push(t.extension)}}waitForReady=t=>new Promise(async(e,r)=>{for(let n=0;n<10;n++)if(t()){e();break}else await M6t(100*n);r("waitForReady timeout")});handleFragmentHandshake(t){let e=t.filter(r=>r.fragment_length!==r.length?(this.bufferFragmentedHandshakes.push(r),!1):!0);if(this.bufferFragmentedHandshakes.length>1){let[r]=this.bufferFragmentedHandshakes.slice(-1);r.fragment_offset+r.fragment_length===r.length&&(e=[...this.bufferFragmentedHandshakes,...e],this.bufferFragmentedHandshakes=[])}return e}send=async t=>{let e=GD(this.dtls)([{type:23,fragment:t}],++this.dtls.recordSequenceNumber)[0];await this.transport.send(this.cipher.encryptPacket(e).serialize())};close(){this.transport.socket.close()}extractSessionKeys(t,e){let r=this.exportKeyingMaterial("EXTRACTOR-dtls_srtp",t*2+e*2),{clientKey:n,serverKey:i,clientSalt:s,serverSalt:a}=(0,vv.decode)(r,{clientKey:vv.types.buffer(t),serverKey:vv.types.buffer(t),clientSalt:vv.types.buffer(e),serverSalt:vv.types.buffer(e)});return this.sessionType===Ap.CLIENT?{localKey:n,localSalt:s,remoteKey:i,remoteSalt:a}:{localKey:i,localSalt:a,remoteKey:n,remoteSalt:s}}exportKeyingMaterial(t,e){return N3t(t,e,this.cipher.masterSecret,this.cipher.localRandom.serialize(),this.cipher.remoteRandom.serialize(),this.sessionType===Ap.CLIENT)}get remoteCertificate(){return this.cipher.remoteCertificate}},Gse=_n("werift-dtls : packages/dtls/src/client.ts : log"),Dae=class extends woe{constructor(t){super(t,Ap.CLIENT),this.onHandleHandshakes=this.handleHandshakes,Gse(this.dtls.sessionId,"start client")}async connect(){await new J3t(this.transport,this.dtls,this.cipher).exec(this.extensions)}flight5;handleHandshakes=async t=>{Gse(this.dtls.sessionId,"handleHandshakes",t.map(e=>e.msg_type));for(let e of t)switch(e.msg_type){case 3:{let r=PBe.deSerialize(e.fragment);await new e6t(this.transport,this.dtls).exec(r)}break;case 2:{if(this.connected)return;this.flight5=new U6t(this.transport,this.dtls,this.cipher,this.srtp),this.flight5.handleHandshake(e)}break;case 11:case 12:case 13:await this.waitForReady(()=>!!this.flight5),this.flight5?.handleHandshake(e);break;case 14:{await this.waitForReady(()=>!!this.flight5),this.flight5?.handleHandshake(e);let r=[11,12,this.options.certificateRequest&&13].filter(n=>typeof n=="number");await this.waitForReady(()=>this.dtls.checkHandshakesExist(r)),await this.flight5?.exec()}break;case 20:this.dtls.flight=7,this.connected=!0,this.onConnect.execute(),Gse(this.dtls.sessionId,"dtls connected");break}}},Rh=_n("werift-dtls : packages/dtls/flight/server/flight2.ts : log"),W6t=(t,e,r,n)=>i=>{Rh("dtls version",i.clientVersion),e.flight=2,e.recordSequenceNumber=0,e.sequenceNumber=0,i.extensions.forEach(x=>{switch(x.type){case Cae.type:{let y=Cae.fromData(x.data).data;Rh(e.sessionId,"curves",y);let v=y.filter(w=>foe.includes(w))[0];r.namedCurve=v,Rh(e.sessionId,"curve selected",r.namedCurve)}break;case kae.type:{if(!r.signatureHashAlgorithm)throw new Error("need to set certificate");let y=kae.fromData(x.data).data;Rh(e.sessionId,"hash,signature",y);let v=y.find(S=>S.signature===r.signatureHashAlgorithm?.signature)?.signature,w=y.find(S=>S.hash===r.signatureHashAlgorithm?.hash)?.hash;if(v==null||w==null)throw new Error("invalid signatureHash")}break;case MS.type:{if(!e.options?.srtpProfiles||e.options.srtpProfiles.length===0)return;let y=MS.fromData(x.data);Rh(e.sessionId,"srtp profiles",y.profiles);let v=PD.findMatchingSRTPProfile(y.profiles,e.options?.srtpProfiles);if(!v)throw new Error;n.srtpProfile=v,Rh(e.sessionId,"srtp profile selected",n.srtpProfile)}break;case EM.type:e.remoteExtendedMasterSecret=!0;break;case TM.type:Rh(e.sessionId,"RenegotiationIndication",x.data);break;case 43:{let v=[...x.data.subarray(1)].map(w=>w.toString(10));Rh("dtls supported version",v)}break}}),r.localRandom=new wv,r.remoteRandom=wv.from(i.random);let s=i.cipherSuites;Rh(e.sessionId,"cipher suites",s);let a=(()=>{switch(r.signatureHashAlgorithm?.signature){case Uh.ecdsa_3:return oM.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_49195;case Uh.rsa_1:return oM.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256_49199}})();if(a===void 0||!s.includes(a))throw new Error("dtls cipher suite negotiation failed");r.cipherSuite=a,Rh(e.sessionId,"selected cipherSuite",r.cipherSuite),r.localKeyPair=b7e(r.namedCurve),e.cookie||=z6t(20);let c=new PBe({major:254,minor:253},e.cookie),d=x7e(e)([c]),p=GD(e)(d.map(x=>({type:22,fragment:x.serialize()})),++e.recordSequenceNumber).map(x=>x.serialize());for(let x of p)t.send(x)},tNe=_n("werift-dtls : packages/dtls/flight/server/flight4.ts : log"),H6t=class extends KD{constructor(t,e,r,n){super(t,e,4,6),this.cipher=r,this.srtp=n}async exec(t,e=!1){if(this.dtls.flight===4){tNe(this.dtls.sessionId,"flight4 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=4,this.dtls.sequenceNumber=1,this.dtls.bufferHandshakeCache([t],!1,4);let r=[this.sendServerHello(),this.sendCertificate(),this.sendServerKeyExchange(),e&&this.sendCertificateRequest(),this.sendServerHelloDone()].filter(n=>n);this.dtls.lastMessage=r,await this.transmit(r)}sendServerHello(){let t=[];this.srtp.srtpProfile&&t.push(MS.create([this.srtp.srtpProfile],Buffer.from([0])).extension),this.dtls.options.extendedMasterSecret&&t.push({type:EM.type,data:Buffer.alloc(0)});let e=TM.createEmpty();t.push(e.extension);let r=new E7e(this.dtls.version,this.cipher.localRandom,Buffer.from([0]),this.cipher.cipherSuite,0,t),n=this.createPacket([r]);return Buffer.concat(n.map(i=>i.serialize()))}sendCertificate(){let t=new uM([Buffer.from(this.cipher.localCert)]),e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}sendServerKeyExchange(){let t=this.cipher.generateKeySignature("sha256");if(!this.cipher.signatureHashAlgorithm)throw new Error("not exist");let e=new k7e(doe.named_curve_3,this.cipher.namedCurve,this.cipher.localKeyPair.publicKey.length,this.cipher.localKeyPair.publicKey,this.cipher.signatureHashAlgorithm.hash,this.cipher.signatureHashAlgorithm.signature,t.length,t),r=this.createPacket([e]);return Buffer.concat(r.map(n=>n.serialize()))}sendCertificateRequest(){let t=new A7e(i7e,hoe,[]);tNe(this.dtls.sessionId,"sendCertificateRequest",t);let e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}sendServerHelloDone(){let t=new T7e,e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}},jS=_n("werift-dtls : packages/dtls/flight/server/flight6.ts"),V6t=class extends KD{constructor(t,e,r){super(t,e,6),this.cipher=r}handleHandshake(t){this.dtls.bufferHandshakeCache([t],!1,5);let e=(()=>{switch(t.msg_type){case 11:return uM.deSerialize(t.fragment);case 15:return w7e.deSerialize(t.fragment);case 16:return S7e.deSerialize(t.fragment);case 20:return fae.deSerialize(t.fragment)}})();if(e){let r=JD[e.msgType];if(!r)return;r({dtls:this.dtls,cipher:this.cipher})(e)}}async exec(){if(this.dtls.flight===6){jS(this.dtls.sessionId,"flight6 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=6;let t=[this.sendChangeCipherSpec(),this.sendFinished()];this.dtls.lastMessage=t,await this.transmit(t)}sendChangeCipherSpec(){let t=_7e.createEmpty().serialize(),e=GD(this.dtls)([{type:20,fragment:t}],++this.dtls.recordSequenceNumber);return Buffer.concat(e.map(n=>n.serialize()))}sendFinished(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(s=>s.serialize())),e=this.cipher.verifyData(t),r=new fae(e);this.dtls.epoch=1;let[n]=this.createPacket([r]);return this.dtls.recordSequenceNumber=0,this.cipher.encryptPacket(n).serialize()}},JD={};JD[16]=({cipher:t,dtls:e})=>r=>{if(t.remoteKeyPair={curve:t.namedCurve,publicKey:r.publicKey},!t.remoteKeyPair.publicKey||!t.localKeyPair||!t.remoteRandom||!t.localRandom)throw new Error("not exist");let n=o7e(t.remoteKeyPair.publicKey,t.localKeyPair.privateKey,t.localKeyPair.curve);jS(e.sessionId,"extendedMasterSecret",e.options.extendedMasterSecret,e.remoteExtendedMasterSecret);let i=Buffer.concat(e.sortedHandshakeCache.map(s=>s.serialize()));t.masterSecret=e.options.extendedMasterSecret&&e.remoteExtendedMasterSecret?u7e(n,i):c7e(n,t.remoteRandom.serialize(),t.localRandom.serialize()),t.cipher=y7e(t.cipherSuite),t.cipher.init(t.masterSecret,t.localRandom.serialize(),t.remoteRandom.serialize()),jS(e.sessionId,"setup cipher",t.cipher.summary)};JD[11]=({cipher:t,dtls:e})=>r=>{jS(e.sessionId,"handshake certificate",r),t.remoteCertificate=r.certificateList[0]};JD[15]=({cipher:t,dtls:e})=>r=>{if(!t.remoteCertificate)throw new Error("client certificate missing before certificate verify");jS(e.sessionId,"certificate_verify",r.algorithm)};JD[20]=({dtls:t})=>e=>{jS(t.sessionId,"finished",e)};ES=_n("werift-dtls : packages/dtls/src/server.ts : log"),RBe=class extends woe{constructor(t){super(t,Ap.SERVER),this.onHandleHandshakes=this.handleHandshakes,ES(this.dtls.sessionId,"start server")}flight6;handleHandshakes=async t=>{ES(this.dtls.sessionId,"handleHandshakes",t.map(e=>e.msg_type));for(let e of t)switch(e.msg_type){case 1:{this.connected&&this.renegotiation();let r=m7e.deSerialize(e.fragment);r.cookie.length===0?(ES(this.dtls.sessionId,"send flight2"),W6t(this.transport,this.dtls,this.cipher,this.srtp)(r)):this.dtls.cookie&&r.cookie.equals(this.dtls.cookie)?(ES(this.dtls.sessionId,"send flight4"),await new H6t(this.transport,this.dtls,this.cipher,this.srtp).exec(e,this.options.certificateRequest)):ES("wrong state",{dtlsCookie:this.dtls.cookie?.toString("hex").slice(10),helloCookie:r.cookie.toString("hex").slice(10)})}break;case 11:case 15:case 16:{if(this.connected)return;this.flight6=new V6t(this.transport,this.dtls,this.cipher),this.flight6.handleHandshake(e)}break;case 20:{await this.waitForReady(()=>!!this.flight6),this.flight6?.handleHandshake(e);let r=[16,this.options.certificateRequest&&11,this.options.certificateRequest&&15].filter(n=>typeof n=="number");await this.waitForReady(()=>this.dtls.checkHandshakesExist(r)),await this.flight6?.exec(),this.connected=!0,this.onConnect.execute(),ES(this.dtls.sessionId,"dtls connected")}break}}},DM=554869826,OBe=8,NBe=1398035790,_p=20,Soe=24,Aoe=1,Eoe=2,BBe=6,UBe=50,G6t=["FINGERPRINT","MESSAGE-INTEGRITY","CHANGE-REQUEST","PRIORITY","USERNAME","ICE-CONTROLLING","SOURCE-ADDRESS","USE-CANDIDATE","ICE-CONTROLLED","ERROR-CODE","XOR-MAPPED-ADDRESS","CHANGED-ADDRESS","LIFETIME","REQUESTED-TRANSPORT","NONCE","REALM","XOR-RELAYED-ADDRESS","CHANNEL-NUMBER","XOR-PEER-ADDRESS","DATA","SOFTWARE","MAPPED-ADDRESS","RESPONSE-ORIGIN","OTHER-ADDRESS"],Toe=(t=>(t[t.REQUEST=0]="REQUEST",t[t.INDICATION=16]="INDICATION",t[t.RESPONSE=256]="RESPONSE",t[t.ERROR=272]="ERROR",t))(Toe||{}),Coe=(t=>(t[t.BINDING=1]="BINDING",t[t.SHARED_SECRET=2]="SHARED_SECRET",t[t.ALLOCATE=3]="ALLOCATE",t[t.REFRESH=4]="REFRESH",t[t.SEND=6]="SEND",t[t.DATA=7]="DATA",t[t.CREATE_PERMISSION=8]="CREATE_PERMISSION",t[t.CHANNEL_BIND=9]="CHANNEL_BIND",t))(Coe||{});rNe=class{queue=[];wait=new yr;put(t){this.queue.push(t),this.queue.length===1&&this.wait.execute(t)}get(){let t=this.queue.shift();return t||new Promise(e=>{this.wait.subscribe(r=>{this.queue.shift(),e(r)})})}},Iae=t=>{let e,r,n=new Promise((s,a)=>{e=s,r=a});n.then(()=>{i.execute(void 0),i.complete()}).catch(s=>{i.execute(s??new Error),i.complete()});let i=new yr;return t(e,r,i).catch(()=>{}),{awaitable:n,resolve:e,reject:r}};koe=Buffer.alloc(6);koe.writeUInt16BE(DM>>16,0);koe.writeUInt32BE(DM,2);aD=t=>{let e=Buffer.alloc(4);return e.writeUInt32BE(t,0),e},oD=t=>t.readUInt32BE(0),X6t=t=>{let e=Buffer.alloc(4);return e.writeUInt16BE(t,0),e},Y6t=t=>t.readUInt16BE(0),nNe=t=>new kse(t.toString()).toBuffer(),iNe=t=>{let e=new kse(t);return BigInt(e.toString())},Kse=t=>Buffer.from(t,"utf8"),Zse=t=>t.toString("utf8"),Xse=t=>t,Yse=t=>t,J6t=t=>Buffer.from([]),Q6t=t=>null,qBe=[[1,"MAPPED-ADDRESS",DS,IS],[3,"CHANGE-REQUEST",aD,oD],[4,"SOURCE-ADDRESS",DS,IS],[5,"CHANGED-ADDRESS",DS,IS],[6,"USERNAME",Kse,Zse],[8,"MESSAGE-INTEGRITY",Xse,Yse],[9,"ERROR-CODE",Z6t,K6t],[12,"CHANNEL-NUMBER",X6t,Y6t],[13,"LIFETIME",aD,oD],[18,"XOR-PEER-ADDRESS",GU,VU],[19,"DATA",Xse,Yse],[20,"REALM",Kse,Zse],[21,"NONCE",Xse,Yse],[22,"XOR-RELAYED-ADDRESS",GU,VU],[25,"REQUESTED-TRANSPORT",aD,oD],[32,"XOR-MAPPED-ADDRESS",GU,VU],[36,"PRIORITY",aD,oD],[37,"USE-CANDIDATE",J6t,Q6t],[32802,"SOFTWARE",Kse,Zse],[32808,"FINGERPRINT",aD,oD],[32809,"ICE-CONTROLLED",nNe,iNe],[32810,"ICE-CONTROLLING",nNe,iNe],[32811,"RESPONSE-ORIGIN",DS,IS],[32812,"OTHER-ADDRESS",DS,IS]],zBe=class{constructor(t=[]){this.attributes=t}getAttributes(){return this.attributes}setAttribute(t,e){let r=this.attributes.find(n=>n[0]===t);return r?r[1]=e:this.attributes.push([t,e]),this}getAttributeValue(t){let e=this.attributes.find(r=>r[0]===t);if(e)return e[1]}get attributesKeys(){return this.attributes.map(t=>t[0])}clear(){this.attributes=[]}},sNe=qBe.reduce((t,e)=>(t[e[0]]=e,t),{}),eDt=qBe.reduce((t,e)=>(t[e[1]]=e,t),{});sf=class extends zBe{constructor(t,e,r=$Be(),n=[]){super(n),this.messageMethod=t,this.messageClass=e,this.transactionId=r}toJSON(){return this.json}get json(){return{messageMethod:Coe[this.messageMethod],messageClass:Toe[this.messageClass],attributes:this.attributes}}get transactionIdHex(){return this.transactionId.toString("hex")}get bytes(){let t=Buffer.from([]);for(let r of this.attributesKeys){let n=this.getAttributeValue(r),[i,,s]=eDt[r],a=s.name===GU.name?s(n,this.transactionId):s(n),c=a.length,d=4*Math.floor((c+3)/4)-c,h=Buffer.alloc(4);h.writeUInt16BE(i,0),h.writeUInt16BE(c,2),t=Buffer.concat([t,h,a,Buffer.alloc(d,0)])}let e=Buffer.alloc(8);return e.writeUInt16BE(this.messageMethod|this.messageClass,0),e.writeUInt16BE(t.length,2),e.writeUInt32BE(DM,4),Buffer.concat([e,this.transactionId,t])}addMessageIntegrity(t){return this.setAttribute("MESSAGE-INTEGRITY",this.messageIntegrity(t)),this}messageIntegrity(t){let e=Doe(this.bytes,this.bytes.length-_p+Soe);return Buffer.from(MBe("sha1",t).update(e).digest("hex"),"hex")}addFingerprint(){this.setAttribute("FINGERPRINT",WBe(this.bytes))}},Doe=(t,e)=>{let r=Buffer.alloc(t.length);return t.copy(r,0,0,2),r.writeUInt16BE(e,2),t.copy(r,4,4),r};HBe=class extends Error{response;addr},VBe=class extends HBe{constructor(t,e){super(),this.response=t,this.addr=e}get str(){let t="STUN transaction failed",e=this.response.getAttributeValue("ERROR-CODE");if(e){let[r,n]=e;t+=` (${r} - ${n})`}return t}},rDt=class extends HBe{get str(){return"STUN transaction timed out"}},Jse=_n("werift-ice:packages/ice/src/stun/transaction.ts"),Ioe=class{constructor(t,e,r,n){this.request=t,this.addr=e,this.protocol=r,this.retransmissions=n,this.triesMax=1+(this.retransmissions?this.retransmissions:BBe)}timeoutDelay=UBe;ended=!1;tries=0;triesMax;onResponse=new yr;responseReceived=(t,e)=>{this.onResponse.length>0&&(t.messageClass===256?(this.onResponse.execute(t,e),this.onResponse.complete()):this.onResponse.error(new VBe(t,e)))};run=async()=>{try{return this.retry().catch(e=>{Jse("retry failed",e)}),await this.onResponse.asPromise()}catch(t){throw t}finally{this.cancel()}};retry=async()=>{for(;this.tries<this.triesMax&&!this.ended&&(this.protocol.sendStun(this.request,this.addr).catch(t=>{Jse("send stun failed",t)}),await new Promise(t=>setTimeout(t,this.timeoutDelay)),!this.ended);)this.timeoutDelay*=2,this.tries++;this.tries>=this.triesMax&&(Jse(`retry failed times:${this.tries} maxLimit:${this.triesMax}`),this.onResponse.error(new rDt))};cancel(){this.ended=!0}},aNe=_n("werift-ice : packages/ice/src/stun/protocol.ts"),fM=class GBe{static type="stun";type=GBe.type;transport;transactions={};get transactionsKeys(){return Object.keys(this.transactions)}localCandidate;sentMessage;localIp;onRequestReceived=new yr;onDataReceived=new yr;constructor(){}connectionMade=async(e,r,n)=>{e?this.transport=await aM.init("udp4",{portRange:r,interfaceAddresses:n}):this.transport=await aM.init("udp6",{portRange:r,interfaceAddresses:n}),this.transport.onData=(i,s)=>{this.datagramReceived(i,s)}};datagramReceived(e,r){try{let n=IM(e);if(!n){this.localCandidate&&this.onDataReceived.execute(e);return}(n.messageClass===256||n.messageClass===272)&&this.transactionsKeys.includes(n.transactionIdHex)?this.transactions[n.transactionIdHex].responseReceived(n,r):n.messageClass===0&&this.onRequestReceived.execute(n,r,e)}catch(n){aNe("datagramReceived error",n)}}getExtraInfo(){let{address:e,port:r}=this.transport.address;return[e,r]}async sendStun(e,r){if(this.transport.closed)return;let n=e.bytes;await this.transport.send(n,r).catch(()=>{aNe("sendStun failed",r,e)})}async sendData(e,r){this.transport.closed||await this.transport.send(e,r)}async request(e,r,n,i){if(this.transactionsKeys.includes(e.transactionIdHex))throw new Error("already request ed");n&&(e.addMessageIntegrity(n),e.addFingerprint());let s=new Ioe(e,r,this,i);this.transactions[e.transactionIdHex]=s;try{return await s.run()}catch(a){throw a}finally{delete this.transactions[e.transactionIdHex]}}async close(){Object.values(this.transactions).forEach(e=>{e.cancel()}),await this.transport.close(),this.onRequestReceived.complete(),this.onDataReceived.complete()}},Nu=_n("werift-ice:packages/ice/src/turn/protocol.ts"),sDt=500,aDt=600,oDt=285212672,KBe=class ZBe{constructor(e){this.turn=e,e.onData.subscribe((r,n)=>{this.handleStunMessage(r,n)}).disposer(this.disposer)}static type="turn";type=ZBe.type;localCandidate;disposer=new JNe;onRequestReceived=new yr;onDataReceived=new yr;handleStunMessage=(e,r)=>{try{let n=IM(e);if(!n){this.onDataReceived.execute(e);return}if(n.messageClass===256||n.messageClass===272){let i=this.turn.transactions[n.transactionIdHex];i&&i.responseReceived(n,r)}else n.messageClass===0&&this.onRequestReceived.execute(n,r,e)}catch(n){Nu("datagramReceived error",n)}};async request(e,r,n){if(this.turn.transactions[e.transactionIdHex])throw new Error("exist");n&&(e.addMessageIntegrity(n),e.addFingerprint());let i=new Ioe(e,r,this);this.turn.transactions[e.transactionIdHex]=i;try{return await i.run()}catch(s){throw s}finally{delete this.turn.transactions[e.transactionIdHex]}}async connectionMade(){}async sendData(e,r){await this.turn.sendData(e,r)}async sendStun(e,r){await this.turn.sendData(e.bytes,r)}async close(){return this.disposer.dispose(),this.turn.close()}},XBe=class YBe{constructor(e,r,n,i,s,a={}){this.server=e,this.username=r,this.password=n,this.lifetime=i,this.transport=s,this.options=a,this.channelRefreshTime=this.options.channelRefreshTime??sDt}static type="turn";type=YBe.type;onData=new yr;onRequestReceived=new yr;onDataReceived=new yr;integrityKey;nonce;realm;relayedAddress;mappedAddress;localCandidate;transactions={};refreshHandle;channelNumber=16384;channelByAddr={};addrByChannel={};channelRefreshTime;channelBinding;channelRefreshAt=0;tcpBuffer=Buffer.alloc(0);permissionByAddr={};creatingPermission=Promise.resolve();async connectionMade(){this.transport.onData=(i,s)=>{this.dataReceived(i,s)};let e=new sf(3,0);e.setAttribute("LIFETIME",this.lifetime).setAttribute("REQUESTED-TRANSPORT",oDt);let[r]=await this.requestWithRetry(e,this.server).catch(i=>{throw Nu("connect error",i),i});this.relayedAddress=r.getAttributeValue("XOR-RELAYED-ADDRESS"),this.mappedAddress=r.getAttributeValue("XOR-MAPPED-ADDRESS");let n=r.getAttributeValue("LIFETIME");Nu("connect",this.relayedAddress,this.mappedAddress,{exp:n}),this.refresh(n)}handleChannelData(e){let[r,n]=Pae.jspack.Unpack("!HH",e.slice(0,4)),i=this.addrByChannel[r];if(i){let s=e.subarray(4,4+n);this.onData.execute(s,i)}}handleSTUNMessage(e,r){try{let n=IM(e);if(!n)throw new Error("not stun message");if(n.messageClass===256||n.messageClass===272){let i=this.transactions[n.transactionIdHex];i&&i.responseReceived(n,r)}else n.messageClass===0&&this.onData.execute(e,r);if(n.getAttributeValue("DATA")){let i=n.getAttributeValue("DATA");this.onData.execute(i,r)}}catch{Nu("parse error",e.toString())}}dataReceived(e,r){let n=(i,s)=>{i.length>=4&&oNe(i)?this.handleChannelData(i):this.handleSTUNMessage(i,s)};if(this.transport.type==="tcp")for(this.tcpBuffer=Buffer.concat([this.tcpBuffer,e]);this.tcpBuffer.length>=4;){let[,i]=zc(this.tcpBuffer.subarray(0,4),[2,2]);i+=Fae(i);let s=oNe(this.tcpBuffer)?4+i:20+i;if(this.tcpBuffer.length<s)break;n(this.tcpBuffer.subarray(0,s),r),this.tcpBuffer=this.tcpBuffer.subarray(s)}else n(e,r)}async send(e,r){if(!this.transport.closed)if(this.transport.type==="tcp"){let n=Fae(e.length);await this.transport.send(n>0?Buffer.concat([e,Buffer.alloc(n)]):e,r)}else await this.transport.send(e,r)}async createPermission(e){let r=new sf(8,0);r.setAttribute("XOR-PEER-ADDRESS",e).setAttribute("USERNAME",this.username).setAttribute("REALM",this.realm).setAttribute("NONCE",this.nonce),await this.request(r,this.server).catch(n=>{throw n})}refresh=e=>{this.refreshHandle=Iae(async(r,n,i)=>{let s=!0;for(i.once(()=>{s=!1});s;){let a=.8333333333333334*e*1e3;Nu("refresh delay",a,{exp:e}),await iDt(a);let c=new sf(4,0);c.setAttribute("LIFETIME",e);try{let[d]=await this.requestWithRetry(c,this.server);e=d.getAttributeValue("LIFETIME"),Nu("refresh",{exp:e})}catch(d){Nu("refresh error",d)}}})};async request(e,r){if(this.transactions[e.transactionIdHex])throw new Error("exist");this.integrityKey&&e.setAttribute("USERNAME",this.username).setAttribute("REALM",this.realm).setAttribute("NONCE",this.nonce).addMessageIntegrity(this.integrityKey).addFingerprint();let n=new Ioe(e,r,this);this.transactions[e.transactionIdHex]=n;try{return await n.run()}catch(i){throw i}finally{delete this.transactions[e.transactionIdHex]}}async requestWithRetry(e,r){let n,i;try{[n,i]=await this.request(e,r)}catch(s){if(!(s instanceof VBe))throw Nu("requestWithRetry error",s),s;this.server=s.addr;let[a]=s.response.getAttributeValue("ERROR-CODE"),c=s.response.getAttributeValue("NONCE"),d=s.response.getAttributeValue("REALM");if((a===401&&d||a===438&&this.realm)&&c)Nu("retry with nonce",a),this.nonce=c,a===401&&(this.realm=d),this.integrityKey=QBe(this.username,this.realm,this.password),e.transactionId=$Be(),[n,i]=await this.request(e,this.server);else throw s}return[n,i]}async sendData(e,r){let n=await this.getChannel(r).catch(s=>new Error("channelBind error"));if(n instanceof Error){await this.getPermission(r);let s=new sf(6,16).setAttribute("DATA",e).setAttribute("XOR-PEER-ADDRESS",r);await this.sendStun(s,this.server);return}let i=Pae.jspack.Pack("!HH",[n.number,e.length]);await this.send(Buffer.concat([Buffer.from(i),e]),this.server)}async getPermission(e){await this.creatingPermission,this.permissionByAddr[e.join(":")]||(this.creatingPermission=this.createPermission(e),this.permissionByAddr[e.join(":")]=!0,await this.creatingPermission.catch(n=>{throw Nu("createPermission error",n),n}))}async getChannel(e){this.channelBinding&&await this.channelBinding;let r=this.channelByAddr[e.join(":")];return r?this.channelRefreshAt<OS(Date.now()/1e3)&&(this.channelBinding=this.channelBind(r.number,e),this.channelRefreshAt=OS(Date.now()/1e3)+this.channelRefreshTime,await this.channelBinding.catch(n=>{throw Nu("channelBind error",n),n}),this.channelBinding=void 0,Nu("channelBind refresh",r)):(this.channelByAddr[e.join(":")]={number:this.channelNumber++,address:e},r=this.channelByAddr[e.join(":")],this.addrByChannel[r.number]=e,this.channelBinding=this.channelBind(r.number,e),await this.channelBinding.catch(n=>{throw Nu("channelBind error",n),n}),this.channelRefreshAt=OS(Date.now()/1e3)+this.channelRefreshTime,this.channelBinding=void 0,Nu("channelBind",r)),r}async channelBind(e,r){let n=new sf(9,0);n.setAttribute("CHANNEL-NUMBER",e).setAttribute("XOR-PEER-ADDRESS",r);let[i]=await this.requestWithRetry(n,this.server);if(i.messageMethod!==9)throw new Error("should be CHANNEL_BIND")}async sendStun(e,r){await this.send(e.bytes,r)}async close(){this.refreshHandle?.resolve?.(),await this.transport.close()}};$g=class eUe{constructor(e,r,n,i,s,a,c,d,h,p,x,y){this.foundation=e,this.component=r,this.transport=n,this.priority=i,this.host=s,this.port=a,this.type=c,this.relatedAddress=d,this.relatedPort=h,this.tcptype=p,this.generation=x,this.ufrag=y}static fromSdp(e){let r=e.split(" ");if(r.length<8)throw new Error("SDP does not have enough properties");let n={foundation:r[0],component:Number(r[1]),transport:r[2],priority:Number(r[3]),host:r[4],port:Number(r[5]),type:r[7]};for(let x=8,y=r.length-1;x<y;x+=2)r[x]==="raddr"?n.related_address=r[x+1]:r[x]==="rport"?n.related_port=Number(r[x+1]):r[x]==="tcptype"?n.tcptype=r[x+1]:r[x]==="generation"?n.generation=Number(r[x+1]):r[x]==="ufrag"&&(n.ufrag=r[x+1]);let{foundation:i,component:s,transport:a,priority:c,host:d,port:h,type:p}=n;return new eUe(i,s,a,c,d,h,p,n.related_address,n.related_port,n.tcptype,n.generation,n.ufrag)}canPairWith(e){let r=cNe(this.host),n=cNe(e.host);return this.component===e.component&&this.transport.toLowerCase()===e.transport.toLowerCase()&&r===n}toSdp(){let e=`${this.foundation} ${this.component} ${this.transport} ${this.priority} ${this.host} ${this.port} typ ${this.type}`;return this.relatedAddress&&(e+=` raddr ${this.relatedAddress}`),this.relatedPort!=null&&(e+=` rport ${this.relatedPort}`),this.tcptype&&(e+=` tcptype ${this.tcptype}`),this.generation!=null&&(e+=` generation ${this.generation}`),this.ufrag!=null&&(e+=` ufrag ${this.ufrag}`),e}};lDt=class{cache=new Map;mdnsInstance=(0,tUe.default)();constructor(){this.mdnsInstance.setMaxListeners(50)}lookup(t){return new Promise((e,r)=>{let n=()=>{this.mdnsInstance.removeListener("response",s),clearTimeout(i)},i=setTimeout(()=>{n(),r(new Error("No mDNS response"))},1e4),s=a=>{let c=a.answers?.[0];c?.type==="A"&&c.name===t&&(n(),e(c.data))};this.mdnsInstance.on("response",s),this.mdnsInstance.query(t,"A")})}close(){this.mdnsInstance.destroy()}},dDt=_n("werift-ice : packages/ice/src/ice.ts : log"),Nae=class{constructor(t,e,r){this.protocol=t,this.remoteCandidate=e,this.iceControlling=r}id=fDt().toString();handle;nominated=!1;remoteNominated=!1;_state=0;get state(){return this._state}packetsSent=0;packetsReceived=0;bytesSent=0;bytesReceived=0;rtt;totalRoundTripTime=0;roundTripTimeMeasurements=0;toJSON(){return this.json}get json(){return{protocol:this.protocol.type,localCandidate:this.localCandidate.toSdp(),remoteCandidate:this.remoteCandidate.toSdp()}}updateState(t){this._state=t}get localCandidate(){if(!this.protocol.localCandidate)throw new Error("localCandidate not exist");return this.protocol.localCandidate}get remoteAddr(){return[this.remoteCandidate.host,this.remoteCandidate.port]}get component(){return this.localCandidate.component}get priority(){return hM(this.localCandidate,this.remoteCandidate,this.iceControlling)}get foundation(){return this.localCandidate.foundation}},Bae=1,_D=2,rUe=5,Uae=6,nUe=(t=>(t[t.FROZEN=0]="FROZEN",t[t.WAITING=1]="WAITING",t[t.IN_PROGRESS=2]="IN_PROGRESS",t[t.SUCCEEDED=3]="SUCCEEDED",t[t.FAILED=4]="FAILED",t))(nUe||{}),iUe={useIpv4:!0,useIpv6:!0};hDt=_n("werift-ice : packages/ice/src/utils.ts");mDt=t=>{if(!t)return;let[e,r]=t.split(":");return[e,Number.parseInt(r)]},Gi=_n("werift-ice : packages/ice/src/ice.ts : log"),fUe=class{constructor(t,e){this._iceControlling=t,this.options={...iUe,...e};let{stunServer:r,turnServer:n}=this.options;this.stunServer=Lae(r)??["stun.l.google.com",19302],this.turnServer=Lae(n),this.restart(),Gi("new Connection",this.options)}localUsername=sD(4);localPassword=sD(22);remoteIsLite=!1;remotePassword="";remoteUsername="";checkList=[];localCandidates=[];stunServer;turnServer;options;remoteCandidatesEnd=!1;localCandidatesEnd=!1;generation=-1;userHistory={};tieBreaker=BigInt(new OU(uDt(64)).toString());state="new";lookup;_remoteCandidates=[];nominated;nominating=!1;checkListDone=!1;checkListState=new rNe;earlyChecks=[];earlyChecksDone=!1;localCandidatesStart=!1;protocols=[];queryConsentHandle;onData=new yr;stateChanged=new yr;onIceCandidate=new yr;get iceControlling(){return this._iceControlling}set iceControlling(t){if(!(this.generation>0||this.nominated)){this._iceControlling=t;for(let e of this.checkList)e.iceControlling=t}}async restart(){this.generation++,this.localUsername=sD(4),this.localPassword=sD(22),this.options.localPasswordPrefix&&(this.localPassword=this.options.localPasswordPrefix+this.localPassword.slice(this.options.localPasswordPrefix.length)),this.userHistory[this.localUsername]=this.localPassword,this.remoteUsername="",this.remotePassword="",this.localCandidates=[],this._remoteCandidates=[],this.remoteCandidatesEnd=!1,this.localCandidatesEnd=!1,this.state="new",this.lookup?.close?.(),this.lookup=void 0,this.nominated=void 0,this.nominating=!1,this.checkList=[],this.checkListDone=!1,this.checkListState=new rNe,this.earlyChecks=[],this.earlyChecksDone=!1,this.localCandidatesStart=!1;for(let t of this.protocols)t.localCandidate&&(t.localCandidate.generation=this.generation,t.localCandidate.ufrag=this.localUsername);this.queryConsentHandle?.resolve?.(),this.queryConsentHandle=void 0}resetNominatedPair(){Gi("resetNominatedPair"),this.nominated=void 0,this.nominating=!1}setRemoteParams({iceLite:t,usernameFragment:e,password:r}){Gi("setRemoteParams",{iceLite:t,usernameFragment:e,password:r}),this.remoteIsLite=t,this.remoteUsername=e,this.remotePassword=r}async gatherCandidates(){if(!this.localCandidatesStart){this.localCandidatesStart=!0;let t=lUe(this.options.useIpv4,this.options.useIpv6,{useLinkLocalAddress:this.options.useLinkLocalAddress}),{interfaceAddresses:e}=this.options;if(e){let n=t.filter(i=>Object.values(e).includes(i));n.length&&(t=n)}this.options.additionalHostAddresses&&(t=Array.from(new Set([...this.options.additionalHostAddresses,...t])));let r=this.getCandidatePromises(t,5);await Promise.allSettled(r),this.localCandidatesEnd=!0}this.setState("completed")}appendLocalCandidate(t){this.localCandidates.push(t),this.onIceCandidate.execute(t)}ensureProtocol(t){t.onRequestReceived.subscribe((e,r,n)=>{if(e.messageMethod!==1){this.respondError(e,r,t,[400,"Bad Request"]);return}let i=e.getAttributeValue("USERNAME"),{remoteUsername:s}=lNe(i),a=this.userHistory[s]??this.localPassword,{iceControlling:c}=this;if(c&&e.attributesKeys.includes("ICE-CONTROLLING"))if(this.tieBreaker>=e.getAttributeValue("ICE-CONTROLLING")){this.respondError(e,r,t,[487,"Role Conflict"]);return}else this.switchRole(!1);else if(!c&&e.attributesKeys.includes("ICE-CONTROLLED"))if(this.tieBreaker<e.getAttributeValue("ICE-CONTROLLED"))this.respondError(e,r,t,[487,"Role Conflict"]);else{this.switchRole(!0);return}if(this.options.filterStunResponse&&!this.options.filterStunResponse(e,r,t))return;let d=new sf(1,256,e.transactionId);d.setAttribute("XOR-MAPPED-ADDRESS",r).addMessageIntegrity(Buffer.from(a,"utf8")).addFingerprint(),t.sendStun(d,r).catch(h=>{Gi("sendStun error",h)}),this.checkList.length===0&&!this.earlyChecksDone?this.earlyChecks.push([e,r,t]):this.checkIncoming(e,r,t)}),t.onDataReceived.subscribe(e=>{try{let r=this.nominated;r&&r.protocol===t&&(r.packetsReceived++,r.bytesReceived+=e.length),this.onData.execute(e)}catch(r){Gi("dataReceived",r)}})}getCandidatePromises(t,e=5){let r=[];t=t.filter(d=>!this.protocols.find(h=>h.localIp===d));let n=t.map(async d=>{let h=new fM;this.ensureProtocol(h);try{await h.connectionMade(uNe(d),this.options.portRange,this.options.interfaceAddresses),h.localIp=d,this.protocols.push(h),Gi("protocol",h.localIp);let p=[d,h.getExtraInfo()[1]];return h.localCandidate=new $g(dM("host","udp",p[0]),1,"udp",ED("host"),p[0],p[1],"host",void 0,void 0,void 0,this.generation,this.localUsername),this.pairLocalProtocol(h),this.appendLocalCandidate(h.localCandidate),h}catch(p){Gi("error protocol STUN",p)}});r.push(...n.map(d=>d.then(h=>h?.localCandidate)));let{stunServer:i,turnServer:s}=this;if(i){let d=n.map(async h=>{let p=await h;return p?new Promise(async(y,v)=>{let w=setTimeout(v,e*1e3);if(p.localCandidate?.host&&uNe(p.localCandidate?.host)){let S=await aUe(p,i).catch(C=>{Gi("error",C)});S&&this.appendLocalCandidate(S),clearTimeout(w),y(S)}else clearTimeout(w),y()}).catch(y=>{Gi("query STUN server",y)}):void 0});r.push(...d)}let{turnUsername:a,turnPassword:c}=this.options;if(s&&a&&c){let d=(async()=>{let h=await Rae({address:s,username:a,password:c},{portRange:this.options.portRange,interfaceAddresses:this.options.interfaceAddresses,transport:this.options.turnTransport==="tcp"?"tcp":"udp"}).catch(async y=>{if(this.options.turnTransport!=="tcp")return await Rae({address:s,username:a,password:c},{portRange:this.options.portRange,interfaceAddresses:this.options.interfaceAddresses,transport:"tcp"});throw y});this.ensureProtocol(h),this.protocols.push(h);let p=h.turn.relayedAddress,x=h.turn.mappedAddress;return Gi("turn candidateAddress",p),h.localCandidate=new $g(dM("relay","udp",p[0]),1,"udp",ED("relay"),p[0],p[1],"relay",x[0],x[1],void 0,this.generation,this.localUsername),this.appendLocalCandidate(h.localCandidate),h.localCandidate})().catch(h=>{Gi("query TURN server",h)});this.options.forceTurn&&(r=[]),r.push(d)}return r}async connect(){if(Gi("start connect ice"),!this.localCandidatesEnd&&!this.localCandidatesStart)throw new Error("Local candidates gathering was not performed");if(!this.remoteUsername||!this.remotePassword)throw new Error("Remote username or password is missing");for(let e of this.remoteCandidates)this.pairRemoteCandidate(e);this.sortCheckList(),this.unfreezeInitial(),Gi("earlyChecks",this.localPassword,this.earlyChecks.length);for(let e of this.earlyChecks)this.checkIncoming(...e);for(this.earlyChecks=[],this.earlyChecksDone=!0;!(this.state==="closed"||!this.schedulingChecks());)await Oae.setTimeout(20);let t=_D;for(;this.checkList.length>0&&t===_D;)t=await this.checkListState.get(),Gi("checkListState",t);for(let e of this.checkList)e.handle?.resolve?.();if(t!==Bae)throw new Error("ICE negotiation failed");this.queryConsent(),this.setState("connected")}unfreezeInitial(){let[t]=this.checkList;if(!t)return;t.state===0&&t.updateState(1);let e=new Set(t.localCandidate.foundation);for(let r of this.checkList)r.component===t.component&&!e.has(r.localCandidate.foundation)&&r.state===0&&(r.updateState(1),e.add(r.localCandidate.foundation))}schedulingChecks(){{let t=this.checkList.filter(e=>!(this.options.forceTurn&&e.protocol.type===fM.type)).find(e=>e.state===1);if(t)return t.handle=this.checkStart(t),!0}{let t=this.checkList.find(e=>e.state===0);if(t)return t.handle=this.checkStart(t),!0}return this.remoteCandidatesEnd?!1:!this.checkListDone}queryConsent=()=>{this.queryConsentHandle&&this.queryConsentHandle.resolve(),this.queryConsentHandle=Iae(async(t,e,r)=>{let n=0,i=!1,s=new AbortController;r.once(()=>{i=!0,n+=Uae,s.abort(),this.queryConsentHandle=void 0});let{localUsername:a,remoteUsername:c,iceControlling:d}=this;try{for(;this.state!=="closed"&&!i;){await Oae.setTimeout(rUe*(.8+.4*Math.random())*1e3,void 0,{signal:s.signal});let h=this.nominated;if(!h||i)break;let p=this.buildRequest({nominate:!1,localUsername:a,remoteUsername:c,iceControlling:d});try{await h.protocol.request(p,h.remoteAddr,Buffer.from(this.remotePassword,"utf8"),0),n=0,this.state==="disconnected"&&this.setState("connected")}catch{if(h.id===this.nominated?.id){Gi("no stun response"),n++,this.setState("disconnected");break}}if(n>=Uae){Gi("Consent to send expired"),this.queryConsentHandle=void 0,this.setState("closed");break}}}catch{}})};async close(){this.setState("closed"),this.queryConsentHandle?.resolve?.(),this.checkList&&!this.checkListDone&&this.checkListState.put(new Promise(t=>{t(_D)})),this.nominated=void 0;for(let t of this.protocols)t.close&&await t.close();this.protocols=[],this.localCandidates=[],this.lookup?.close?.(),this.lookup=void 0}setState(t){this.state=t,this.stateChanged.execute(t)}async addRemoteCandidate(t){if(!t){this.remoteCandidatesEnd=!0;return}if(t.host.includes(".local"))try{this.lookup||(this.lookup=new lDt);let e=await this.lookup.lookup(t.host);t.host=e}catch{return}try{Mae(t)}catch{return}Gi("addRemoteCandidate",t),this._remoteCandidates.push(t),this.pairRemoteCandidate(t),this.sortCheckList()}send=async t=>{let e=this.nominated;if(e)await e.protocol.sendData(t,e.remoteAddr),e.packetsSent++,e.bytesSent+=t.length;else return};getDefaultCandidate(){let t=this.localCandidates.sort((r,n)=>r.priority-n.priority),[e]=t;return e}set remoteCandidates(t){if(this.remoteCandidatesEnd)throw new Error("Cannot set remote candidates after end-of-candidates.");this._remoteCandidates=[];for(let e of t){try{Mae(e)}catch{continue}this._remoteCandidates.push(e)}this.remoteCandidatesEnd=!0}get remoteCandidates(){return this._remoteCandidates}get candidatePairs(){return this.checkList}sortCheckList(){sUe(this.checkList,this.iceControlling)}findPair(t,e){return this.checkList.find(n=>(0,KU.default)(n.protocol,t)&&(0,KU.default)(n.remoteCandidate,e))}switchRole(t){Gi("switch role",t),this.iceControlling=t,this.sortCheckList()}checkComplete(t){if(t.handle=void 0,t.state===3){if(t.nominated&&(t.remoteCandidate.generation==null||t.remoteCandidate.generation===this.generation)&&this.nominated==null){Gi("nominated",t.toJSON()),this.nominated=t,this.nominating=!1;for(let e of this.checkList)e.component===t.component&&[1,0].includes(e.state)&&e.updateState(4)}if(this.nominated){this.checkListDone||(Gi("ICE completed"),this.checkListState.put(new Promise(e=>e(Bae))),this.checkListDone=!0);return}Gi("not completed",t.toJSON());for(let e of this.checkList)e.localCandidate.foundation===t.localCandidate.foundation&&e.state===0&&e.updateState(1)}{let e=[3,4];if(this.checkList.find(({state:r})=>!e.includes(r)))return}!this.iceControlling&&this.checkList.find(({state:r})=>r===3)||this.checkListDone||(Gi("ICE failed"),this.checkListState.put(new Promise(e=>{e(_D)})))}checkStart=t=>Iae(async e=>{Gi("check start",t.toJSON()),t.updateState(2);let r={},{remotePassword:n,remoteUsername:i,generation:s}=this,a=t.localCandidate.ufrag??this.localUsername,c=this.iceControlling&&!this.remoteIsLite,d=this.buildRequest({nominate:c,localUsername:a,remoteUsername:i,iceControlling:this.iceControlling}),h=performance.now();try{let[p,x]=await t.protocol.request(d,t.remoteAddr,Buffer.from(n,"utf8"),4),v=(performance.now()-h)/1e3;t.rtt=v,t.totalRoundTripTime+=v,t.roundTripTimeMeasurements++,Gi("response received",d.toJSON(),p.toJSON(),x,{localUsername:a,remoteUsername:i,remotePassword:n,generation:s,rtt:v}),r.response=p,r.addr=x}catch(p){let x=p;if(Gi("failure case",d.toJSON(),x.response?JSON.stringify(x.response.toJSON(),null,2):p,{localUsername:a,remoteUsername:i,remotePassword:n,generation:s},t.remoteAddr),x.response?.getAttributeValue("ERROR-CODE")[0]===487){d.attributesKeys.includes("ICE-CONTROLLED")?this.switchRole(!0):d.attributesKeys.includes("ICE-CONTROLLING")&&this.switchRole(!1),await this.checkStart(t).awaitable,e();return}if(x.response?.getAttributeValue("ERROR-CODE")[0]===401){Gi("retry 401",t.toJSON()),await this.checkStart(t).awaitable,e();return}else{Gi("checkStart CandidatePairState.FAILED",t.toJSON()),t.updateState(4),this.checkComplete(t),e();return}}if(!(0,KU.default)(r.addr,t.remoteAddr)){t.updateState(4),this.checkComplete(t),e();return}if(c||t.remoteNominated)t.nominated=!0;else if(this.iceControlling&&!this.nominating){this.nominating=!0;let p=this.buildRequest({nominate:!0,localUsername:a,remoteUsername:i,iceControlling:this.iceControlling});try{await t.protocol.request(p,t.remoteAddr,Buffer.from(this.remotePassword,"utf8"))}catch{t.updateState(4),this.checkComplete(t);return}t.nominated=!0}t.updateState(3),this.checkComplete(t),e()});addPair(t){this.checkList.push(t),this.sortCheckList()}checkIncoming(t,e,r){let n=t.getAttributeValue("USERNAME"),{remoteUsername:i}=lNe(n),s,[a,c]=e;for(let h of this.remoteCandidates)if(h.host===a&&h.port===c){s=h;break}s||(s=new $g(sD(10),1,"udp",t.getAttributeValue("PRIORITY"),a,c,"prflx",void 0,void 0,void 0,void 0,void 0),this._remoteCandidates.push(s));let d=this.findPair(r,s);d||(d=new Nae(r,s,this.iceControlling),d.updateState(1),this.addPair(d)),d.localCandidate.ufrag=i,Gi("Triggered Checks",t.toJSON(),d.toJSON(),{localUsername:this.localUsername,remoteUsername:this.remoteUsername,localPassword:this.localPassword,remotePassword:this.remotePassword,generation:this.generation}),[1,4].includes(d.state)&&(d.handle=this.checkStart(d)),t.attributesKeys.includes("USE-CANDIDATE")&&!this.iceControlling&&(d.remoteNominated=!0,d.state===3&&(d.nominated=!0,this.checkComplete(d)))}tryPair(t,e){if(t.localCandidate?.canPairWith(e)&&!this.findPair(t,e)){let r=new Nae(t,e,this.iceControlling);if(this.options.filterCandidatePair&&!this.options.filterCandidatePair(r))return;r.updateState(1),this.addPair(r)}}pairLocalProtocol(t){for(let e of this.remoteCandidates)this.tryPair(t,e)}pairRemoteCandidate=t=>{for(let e of this.protocols)this.tryPair(e,t)};buildRequest({nominate:t,remoteUsername:e,localUsername:r,iceControlling:n}){let i=gDt({remoteUsername:e,localUsername:r}),s=new sf(1,0);return s.setAttribute("USERNAME",i).setAttribute("PRIORITY",ED("prflx")),n?(s.setAttribute("ICE-CONTROLLING",this.tieBreaker),t&&s.setAttribute("USE-CANDIDATE",null)):s.setAttribute("ICE-CONTROLLED",this.tieBreaker),s}respondError(t,e,r,n){let i=new sf(t.messageMethod,272,t.transactionId);i.setAttribute("ERROR-CODE",n).addMessageIntegrity(Buffer.from(this.localPassword,"utf8")).addFingerprint(),r.sendStun(i,e).catch(s=>{Gi("sendStun error",s)})}},gDt=({remoteUsername:t,localUsername:e})=>`${t}:${e}`,lNe=t=>{let[e,r]=t.split(":");return{remoteUsername:e,localUsername:r}};Foe=class extends xDt{addEventListener=(t,e)=>{this.addListener(t,e)};removeEventListener=(t,e)=>{this.removeListener(t,e)}},yDt=_n("werift:packages/webrtc/src/dataChannel.ts");Poe=class extends Foe{constructor(t,e,r=!0){if(super(),this.sctp=t,this.parameters=e,this.sendOpen=r,this.id=this.parameters.id,e.negotiated){if(this.id==null||this.id<0||this.id>65534)throw new Error("ID must be in range 0-65534 if data channel is negotiated out-of-band");this.sctp.dataChannelAddNegotiated(this)}else r&&(this.sendOpen=!1,this.sctp.dataChannelOpen(this))}stateChange=new yr;stateChanged=new yr;onMessage=new yr;error=new yr;bufferedAmountLow=new yr;onopen;onclose;onclosing;onmessage;onerror;isCreatedByRemote=!1;id;readyState="connecting";bufferedAmount=0;_bufferedAmountLowThreshold=0;messagesSent=0;bytesSent=0;messagesReceived=0;bytesReceived=0;get ordered(){return this.parameters.ordered}get maxRetransmits(){return this.parameters.maxRetransmits}get maxPacketLifeTime(){return this.parameters.maxPacketLifeTime}get label(){return this.parameters.label}get protocol(){return this.parameters.protocol}get negotiated(){return this.parameters.negotiated}get bufferedAmountLowThreshold(){return this._bufferedAmountLowThreshold}set bufferedAmountLowThreshold(t){if(t<0||t>4294967295)throw new Error("bufferedAmountLowThreshold must be in range 0 - 4294967295");this._bufferedAmountLowThreshold=t}setId(t){this.id=t}setReadyState(t){if(t!==this.readyState){switch(this.readyState=t,this.stateChange.execute(t),this.stateChanged.execute(t),t){case"open":this.onopen&&this.onopen(),this.emit("open");break;case"closed":this.onclose&&this.onclose(),this.emit("close");break;case"closing":this.onclosing&&this.onclosing();break}yDt("change state",t)}}addBufferedAmount(t){let e=this.bufferedAmount>this.bufferedAmountLowThreshold&&this.bufferedAmount+t<=this.bufferedAmountLowThreshold;this.bufferedAmount+=t,e&&(this.bufferedAmountLow.execute(),this.emit("bufferedamountlow"))}send(t){let e=this.sctp.datachannelSend(this,t);this.messagesSent++,this.bytesSent+=e}close(){this.sctp.dataChannelClose(this)}},Roe=class{label="";maxPacketLifeTime;maxRetransmits;ordered=!0;protocol="";negotiated=!1;id;constructor(t={}){Object.assign(this,t)}},vDt=()=>({type:"ccm",parameter:"fir"}),QD=()=>({type:"nack"}),GS=()=>({type:"nack",parameter:"pli"}),e8=()=>({type:"goog-remb"}),hUe=()=>({type:"transport-cc"}),jg=class{payloadType;mimeType;clockRate;channels;rtcpFeedback=[];parameters;direction="all";constructor(t){Object.assign(this,t)}get name(){return this.mimeType.split("/")[1]}get contentType(){return this.mimeType.split("/")[0]}get str(){let t=`${this.name}/${this.clockRate}`;return this.channels===2&&(t+="/2"),t}},Mh=class{id;uri;constructor(t){Object.assign(this,t)}},bDt=class{cname;mux=!1;ssrc;constructor(t={}){Object.assign(this,t)}},pUe=class{type;parameter;constructor(t={}){Object.assign(this,t)}},mUe=class{ssrc;constructor(t={}){Object.assign(this,t)}},gUe=class{ssrc;payloadType;rtx;constructor(t){Object.assign(this,t)}},Ooe=class{rid;direction;constructor(t){Object.assign(this,t)}},xUe=(t={})=>new jg({mimeType:"video/h264",clockRate:9e4,rtcpFeedback:[QD(),GS(),e8()],parameters:"profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1",...t}),Noe=(t={})=>new jg({mimeType:"video/VP8",clockRate:9e4,rtcpFeedback:[QD(),GS(),e8()],...t}),yUe=(t={})=>new jg({mimeType:"video/VP9",clockRate:9e4,rtcpFeedback:[QD(),GS(),e8()],...t}),vUe=(t={})=>new jg({mimeType:"video/AV1X",clockRate:9e4,rtcpFeedback:[QD(),GS(),e8()],...t}),Boe=(t={})=>new jg({mimeType:"audio/OPUS",clockRate:48e3,channels:2,...t}),Uoe=(t={})=>new jg({mimeType:"audio/PCMU",clockRate:8e3,channels:1,payloadType:0,...t}),Moe=[vUe(),yUe(),Noe(),xUe(),Boe(),Uoe()].map(t=>t.mimeType),_Dt=Moe.filter(t=>t.toLowerCase().startsWith("video/")),wDt=Moe.filter(t=>t.toLowerCase().startsWith("audio/"));hNe=2,pNe=3,NDt=0,LU=50,mNe=51,gNe=53,BDt=56,UDt=57,MDt="0.0.0.0",xNe=9,jae={auto:"actpass",client:"active",server:"passive"},yNe=Object.keys(jae).reduce((t,e)=>{let r=jae[e];return t[r]=e,t},{}),LDt=["apt","max-fr","max-fs","maxplaybackrate","minptime","stereo","useinbandfec"],bUe=["cname","msid","mslabel","label"],vNe={SRTP_AES128_CM_HMAC_SHA1_80:HS,SRTP_AEAD_AES_128_GCM:Fv},ZU=["sendonly","sendrecv"],$Dt=["sendrecv","recvonly"],_Ue=class extends Map{constructor(t){if(super(),t)for(let e of t)this.set(e.id,e)}};wUe=class{constructor(t,e,r,n,i){this.kind=t,this.receiver=r,this.sender=n,this._direction=i,e&&this.setDtlsTransport(e)}id=ODt().toString();onTrack=new yr;mid;mLineIndex;usedForSender=!1;_currentDirection;offerDirection;_codecs=[];set codecs(t){this._codecs=t}get codecs(){return this._codecs}headerExtensions=[];options={};stopping=!1;stopped=!1;get dtlsTransport(){return this.receiver.dtlsTransport}get direction(){return this._direction}setDirection(t){this._direction=t,ZU.includes(this._currentDirection??"")&&(this.usedForSender=!0)}get currentDirection(){return this._currentDirection}setCurrentDirection(t){this._currentDirection=t}setDtlsTransport(t){this.receiver.setDtlsTransport(t),this.sender.setDtlsTransport(t)}get msid(){return`${this.sender.streamId} ${this.sender.trackId}`}addTrack(t){this.receiver.addTrack(t)&&this.onTrack.execute(t,this)}stop(){this.stopping||(this.stopping=!0)}getPayloadType(t){return this.codecs.find(e=>e.mimeType.toLowerCase().includes(t.toLowerCase()))?.payloadType}getCodecStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id);for(let n of this.codecs){let i={type:"codec",id:rs("codec",n.payloadType,r),timestamp:t,payloadType:n.payloadType,transportId:r,mimeType:n.mimeType,clockRate:n.clockRate,channels:n.channels,sdpFmtpLine:n.parameters};e.push(i)}return e}},SUe="inactive",Loe="sendonly",$oe="recvonly",joe="sendrecv",XU=[SUe,Loe,$oe,joe],qD=class extends Foe{uuid=AUe().toString();streamId;remote=!1;label;kind;id;ssrc;rid;header;codec;enabled=!0;onReceiveRtp=new yr;onReceiveRtcp=new yr;onSourceChanged=new yr;stopped=!1;muted=!0;constructor(t){super(),Object.assign(this,t),this.onReceiveRtp.subscribe(e=>{this.muted=!1,this.header=e.header}),this.label=`${this.remote?"remote":"local"} ${this.kind}`}stop=()=>{this.stopped=!0,this.muted=!0,this.onReceiveRtp.complete(),this.emit("ended")};writeRtp=t=>{if(this.remote)throw new Error("this is remoteTrack");if(this.stopped)return;let e=Buffer.isBuffer(t)?Cp.deSerialize(t):t;e.header.payloadType=this.codec?.payloadType??e.header.payloadType,this.onReceiveRtp.execute(e)}},EUe=class{id;tracks=[];constructor(t){Array.isArray(t)?this.tracks=t:Object.assign(this,t),this.id??=AUe().toString()}addTrack(t){t.streamId=this.id,this.tracks.push(t)}getTracks(){return this.tracks}getAudioTracks(){return this.tracks.filter(t=>t.kind==="audio")}getVideoTracks(){return this.tracks.filter(t=>t.kind==="video")}},jDt=_n("werift:packages/webrtc/src/utils.ts");qDt={sha1:"sha1","sha-1":"sha1",sha224:"sha224","sha-224":"sha224",sha256:"sha256","sha-256":"sha256",sha384:"sha384","sha-384":"sha384",sha512:"sha512","sha-512":"sha512"};Woe=(t,e)=>XU[XU.indexOf(t)&XU.indexOf(e)];Hoe=Date.now,WDt=BigInt(Date.now())*1000n-process.hrtime.bigint()/1000n,kUe=()=>WDt+process.hrtime.bigint()/1000n,zD=()=>Date.now()/1e3,DUe=()=>{let e=(dNe.timeOrigin+dNe.now()-Date.UTC(1900,0,1))/1e3,[r,n]=e.toString().split(".").map(Number);return Vs([4,4],[r,n]).readBigUInt64BE()},Voe=t=>{let e=Vs([8],[t]),[,r,n]=zc(e,[2,2,2,2]);return Vs([2,2],[r,n]).readUInt32BE()};HDt=FD.createSelfSignedCertificateWithKey,VDt=class{static async rtpSource({port:t,kind:e,cb:r}){t??=await loe();let n=new qD({kind:e}),i=RDt("udp4");i.bind(t);let s=c=>{r&&(c=r(c)),n.writeRtp(c)};return i.addListener("message",s),[n,t,()=>{i.removeListener("message",s);try{i.close()}catch{}}]}},FUe=(t,e)=>{if(!t||typeof t!="object")return e!==null&&typeof e=="object"?e:t;if(!e||typeof e!="object")return e??t;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];n!=null&&(t[r]=n)}return t},GDt=_n("werift:packages/webrtc/src/media/receiver/nack.ts"),bNe=150,KDt=class{constructor(t){this.receiver=t}newEstSeqNum=0;_lost={};nackLoop;onPacketLost=new yr;mediaSourceSsrc;retryCount=10;closed=!1;get lostSeqNumbers(){return Object.keys(this._lost).map(Number).sort()}getLost(t){return this._lost[t]}setLost(t,e){this._lost[t]=e,!(this.nackLoop||this.closed)&&(this.nackLoop=setInterval(async()=>{try{await this.sendNack(),Object.keys(this._lost).length||(clearInterval(this.nackLoop),this.nackLoop=void 0)}catch(r){GDt("failed to send nack",r)}},5))}removeLost(t){delete this._lost[t]}addPacket(t){let{sequenceNumber:e,ssrc:r}=t.header;if(this.mediaSourceSsrc=r,this.newEstSeqNum===0){this.newEstSeqNum=e;return}if(this.getLost(e)){this.removeLost(e);return}if(e===jo(this.newEstSeqNum,1))this.newEstSeqNum=e;else if(e>jo(this.newEstSeqNum,1)){for(let n=jo(this.newEstSeqNum,1);n<e;n=jo(n,1))this.setLost(n,1);this.newEstSeqNum=e,this.pruneLost()}}pruneLost(){this.lostSeqNumbers.length>bNe&&(this._lost=Object.entries(this._lost).slice(-bNe).reduce((t,[e,r])=>(t[e]=r,t),{}))}close(){this.closed=!0,clearInterval(this.nackLoop),this._lost={}}updateRetryCount(){this.lostSeqNumbers.forEach(t=>{if(this._lost[t]++>this.retryCount)return this.removeLost(t),t})}sendNack=()=>new Promise((t,e)=>{if(this.lostSeqNumbers.length>0&&this.mediaSourceSsrc){let r=new UD({senderSsrc:this.receiver.rtcpSsrc,mediaSourceSsrc:this.mediaSourceSsrc,lost:this.lostSeqNumbers}),n=new Tv({feedback:r});this.receiver.dtlsTransport.sendRtcp([n]).then(t).catch(e),this.updateRetryCount(),this.onPacketLost.execute(r)}})},XDt=_n("werift:packages/webrtc/media/receiver/receiverTwcc"),YDt=class{constructor(t,e,r){this.dtlsTransport=t,this.rtcpSsrc=e,this.mediaSourceSsrc=r,this.runTWCC()}extensionInfo={};twccRunning=!1;fbPktCount=0;lastTimestamp;handleTWCC(t){this.extensionInfo[t]={tsn:t,timestamp:kUe()},Object.keys(this.extensionInfo).length>10&&this.sendTWCC()}async runTWCC(){for(;this.twccRunning;)this.sendTWCC(),await ZDt(100)}sendTWCC(){if(Object.keys(this.extensionInfo).length===0)return;let t=Object.values(this.extensionInfo).sort((p,x)=>p.tsn-x.tsn),e=t[0].tsn,r=t.slice(-1)[0].tsn,n=[],i=t[0].tsn,s=jo(r-e,1),a,c,d=[];for(let p=e;p<=r;p++){let x=this.extensionInfo[p]?.timestamp;if(x){this.lastTimestamp||(this.lastTimestamp=x),a||(a=this.lastTimestamp);let y=x-this.lastTimestamp;this.lastTimestamp=x;let v=new AD({delta:Number(y)});v.parseDelta(),d.push(v),c!=null&&c.status!==v.type&&(n.push(new BS({packetStatus:c.status,runLength:p-c.minTSN})),c={minTSN:p,status:v.type}),p===r&&(c!=null?n.push(new BS({packetStatus:c.status,runLength:p-c.minTSN+1})):n.push(new BS({packetStatus:v.type,runLength:1}))),c==null&&(c={minTSN:p,status:v.type})}}if(!a)return;let h=new Tv({feedback:new MD({senderSsrc:this.rtcpSsrc,mediaSourceSsrc:this.mediaSourceSsrc,baseSequenceNumber:i,packetStatusCount:s,referenceTime:KNe(Math.floor(Number(a/1000n/64n))),fbPktCount:this.fbPktCount,recvDeltas:d,packetChunks:n})});this.dtlsTransport.sendRtcp([h]).catch(p=>{XDt(p)}),this.extensionInfo={},this.fbPktCount=GNe(this.fbPktCount,1)}},JDt=class{base_seq;max_seq;cycles=0;packets_received=0;clockRate;jitter_q4=0;last_arrival;last_timestamp;expected_prior=0;received_prior=0;constructor(t){this.clockRate=t}add(t,e=Date.now()/1e3){let r=this.max_seq==null||_M(t.header.sequenceNumber,this.max_seq);if(this.packets_received++,this.base_seq==null&&(this.base_seq=t.header.sequenceNumber),r){let n=OS(e*this.clockRate);if(this.max_seq!=null&&t.header.sequenceNumber<this.max_seq&&(this.cycles+=65536),this.max_seq=t.header.sequenceNumber,t.header.timestamp!==this.last_timestamp&&this.packets_received>1){let i=Math.abs(n-(this.last_arrival??0)-(t.header.timestamp-(this.last_timestamp??0)));this.jitter_q4+=i-(this.jitter_q4+8>>4)}this.last_arrival=n,this.last_timestamp=t.header.timestamp}}get fraction_lost(){let t=this.packets_expected-this.expected_prior;this.expected_prior=this.packets_expected;let e=this.packets_received-this.received_prior;this.received_prior=this.packets_received;let r=t-e;return t==0||r<=0?0:Math.floor((r<<8)/t)}get jitter(){return this.jitter_q4>>4}get packets_expected(){return this.cycles+(this.max_seq??0)-(this.base_seq??0)+1}get packets_lost(){let t=this.packets_expected-this.packets_received;return t<0?0:t}},sd=_n("werift:packages/webrtc/src/transport/dtls.ts"),qae=class PUe{constructor(e,r,n,i=[]){this.config=e,this.iceTransport=r,this.localCertificate=n,this.srtpProfiles=i,this.localCertificate??=PUe.localCertificate}id=t8t().toString();state="new";role="auto";srtpStarted=!1;transportSequenceNumber=0;bytesSent=0;bytesReceived=0;packetsSent=0;packetsReceived=0;dataReceiver=()=>{};dtls;srtp;srtcp;onStateChange=new yr;onRtcp=new yr;onRtp=new yr;static localCertificate;static localCertificatePromise;remoteParameters;get localParameters(){return new gM(this.localCertificate?this.localCertificate.getFingerprints():[],this.role)}static async SetupCertificate(){return this.localCertificate?this.localCertificate:this.localCertificatePromise?this.localCertificatePromise:(this.localCertificatePromise=(async()=>{let{certPem:e,keyPem:r,signatureHash:n}=await FD.createSelfSignedCertificateWithKey({signature:Uh.ecdsa_3,hash:ID.sha256_4},Ep.secp256r1_23);return this.localCertificate=new Goe(r,e,n),this.localCertificate})(),this.localCertificatePromise)}setRemoteParams(e){let r=i8t([...this.remoteParameters?.fingerprints??[],...e.fingerprints]),n=e.role==="auto"&&this.remoteParameters?.role?this.remoteParameters.role:e.role;this.remoteParameters=new gM(r,n)}async start(){if(this.state!=="new")throw new Error("state must be new");if(!this.remoteParameters||this.remoteParameters.fingerprints.length===0)throw new Error("remote fingerprint not exist");this.role==="auto"&&(this.iceTransport.role==="controlling"?this.role="server":this.role="client"),this.setState("connecting"),await new Promise(async(e,r)=>{this.role==="server"?this.dtls=new RBe({cert:this.localCertificate?.certPem,key:this.localCertificate?.privateKey,signatureHash:this.localCertificate?.signatureHash,transport:_Ne(this.iceTransport.connection),srtpProfiles:this.srtpProfiles,extendedMasterSecret:!0,certificateRequest:!0}):this.dtls=new Dae({cert:this.localCertificate?.certPem,key:this.localCertificate?.privateKey,signatureHash:this.localCertificate?.signatureHash,transport:_Ne(this.iceTransport.connection),srtpProfiles:this.srtpProfiles,extendedMasterSecret:!0}),this.dtls.onData.subscribe(n=>{this.config.debug.inboundPacketLoss&&this.config.debug.inboundPacketLoss/100<Math.random()||this.dataReceiver(n)}),this.dtls.onClose.subscribe(()=>{this.state!=="failed"&&this.setState("closed")}),this.dtls.onConnect.once(e),this.dtls.onError.once(n=>{this.setState("failed"),sd("dtls failed",n),r(n)}),this.dtls instanceof Dae&&(await r8t(100),this.dtls.connect().catch(n=>{this.setState("failed"),sd("dtls connect failed",n),r(n)}))});try{this.verifyRemoteCertificateFingerprint()}catch(e){throw this.setState("failed"),this.dtls?.close(),e}this.srtpProfiles.length>0&&this.startSrtp(),this.setState("connected"),sd("dtls connected")}verifyRemoteCertificateFingerprint(){if(!this.remoteParameters||this.remoteParameters.fingerprints.length===0)throw new Error("remote fingerprint not exist");let e=this.dtls?.remoteCertificate;if(!e)throw new Error("remote certificate not available");let r=this.remoteParameters.fingerprints.flatMap(({algorithm:c,value:d})=>{let h=zoe(c);if(!h)return[];let p=pM(d);if(!p)throw new Error("remote fingerprint value is empty");return[{normalizedAlgorithm:h,normalizedValue:p}]});if(r.length===0)throw new Error("no supported remote fingerprint algorithms");let n=a8t(r),i=r.filter(({normalizedAlgorithm:c})=>c===n),s=i.reduce((c,{normalizedAlgorithm:d})=>(c.has(d)||c.set(d,pM(qoe(e,d))),c),new Map);if(!i.some(({normalizedAlgorithm:c,normalizedValue:d})=>s.get(c)===d))throw new Error("remote certificate fingerprint mismatch")}updateSrtpSession(){if(!this.dtls)throw new Error;let e=this.dtls.srtp.srtpProfile;if(!e)throw new Error("need srtpProfile");sd("selected SRTP Profile",e);let{localKey:r,localSalt:n,remoteKey:i,remoteSalt:s}=this.dtls.extractSessionKeys(D7e(e),I7e(e)),a={keys:{localMasterKey:r,localMasterSalt:n,remoteMasterKey:i,remoteMasterSalt:s},profile:e};this.srtp=new FBe(a),this.srtcp=new IBe(a)}startSrtp(){this.srtpStarted||(this.srtpStarted=!0,this.updateSrtpSession(),this.iceTransport.connection.onData.subscribe(e=>{if(!(this.config.debug.inboundPacketLoss&&this.config.debug.inboundPacketLoss/100<Math.random())&&H7e(e))if(this.bytesReceived+=e.length,this.packetsReceived++,sBe(e)){let r;try{r=this.srtcp.decrypt(e)}catch(i){if(i instanceof kv){sd("dropping invalid SRTCP packet",i);return}throw i}let n;try{n=iBe.deSerialize(r)}catch(i){sd("dropping malformed SRTCP packet",i);return}for(let i of n)try{this.onRtcp.execute(i)}catch(s){sd("RTCP error",s)}}else{let r;try{r=this.srtp.decrypt(e)}catch(i){if(i instanceof kv){sd("dropping invalid SRTP packet",i);return}throw i}let n;try{n=Cp.deSerialize(r)}catch(i){sd("dropping malformed SRTP packet",i);return}try{this.onRtp.execute(n)}catch(i){sd("RTP error",i)}}}))}sendData=async e=>{if(!(this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random())){if(!this.dtls)throw new Error("dtls not established");await this.dtls.send(e)}};async sendRtp(e,r){try{let n=this.srtp.encrypt(e,r);return this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random()||(this.bytesSent+=n.length,this.packetsSent++,await this.iceTransport.connection.send(n).catch(()=>{})),n.length}catch(n){return sd("failed to send",n),0}}async sendRtcp(e){let r=Buffer.concat(e.map(i=>i.serialize())),n=this.srtcp.encrypt(r);if(this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random())return n.length;this.bytesSent+=n.length,this.packetsSent++,await this.iceTransport.connection.send(n).catch(()=>{})}setState(e){e!=this.state&&(this.state=e,this.onStateChange.execute(e))}async stop(){this.setState("closed"),await this.iceTransport.stop()}async getStats(){let e=qg(),r=[],i={type:"transport",id:rs("transport",this.id),timestamp:e,bytesSent:this.bytesSent,bytesReceived:this.bytesReceived,packetsSent:this.packetsSent,packetsReceived:this.packetsReceived,dtlsState:this.state,iceState:this.iceTransport.state,selectedCandidatePairId:this.iceTransport.connection.nominated?rs("candidate-pair",this.iceTransport.connection.nominated.localCandidate.foundation,this.iceTransport.connection.nominated.remoteCandidate.foundation):void 0,localCertificateId:this.localCertificate?rs("certificate","local"):void 0,remoteCertificateId:this.remoteParameters?rs("certificate","remote"):void 0,dtlsRole:this.role==="auto"?void 0:this.role};if(r.push(i),this.localCertificate){let a=this.localCertificate.getFingerprints();if(a.length>0){let c={type:"certificate",id:rs("certificate","local"),timestamp:e,fingerprint:a[0].value,fingerprintAlgorithm:a[0].algorithm,base64Certificate:Buffer.from(this.localCertificate.certPem).toString("base64")};r.push(c)}}if(this.remoteParameters&&this.remoteParameters.fingerprints.length>0){let a={type:"certificate",id:rs("certificate","remote"),timestamp:e,fingerprint:this.remoteParameters.fingerprints[0].value,fingerprintAlgorithm:this.remoteParameters.fingerprints[0].algorithm,base64Certificate:""};r.push(a)}let s=await this.iceTransport.getStats();return r.push(...s),r}},n8t=["new","connecting","connected","closed","failed"],Goe=class{constructor(t,e,r){this.certPem=e,this.signatureHash=r;let n=WD.Certificate.fromPEM(Buffer.from(e));this.publicKey=n.publicKey.toPEM(),this.privateKey=WD.PrivateKey.fromPEM(Buffer.from(t)).toPEM()}publicKey;privateKey;getFingerprints(){return[new mM("sha-256",qoe(WD.Certificate.fromPEM(Buffer.from(this.certPem)).raw,"sha256"))]}},mM=class{constructor(t,e){this.algorithm=t,this.value=e}},gM=class{constructor(t=[],e){this.fingerprints=t,this.role=e}},i8t=t=>{let e=new Set;return t.filter(({algorithm:r,value:n})=>{let i=`${zoe(r)??r.trim().toLowerCase()}:${pM(n)}`;return e.has(i)?!1:(e.add(i),!0)})},s8t=["sha512","sha384","sha256","sha224","sha1"],a8t=t=>s8t.find(e=>t.some(({normalizedAlgorithm:r})=>r===e))??t[0].normalizedAlgorithm,o8t=class{constructor(t){this.ice=t,t.onData.subscribe(e=>{TUe(e)&&this.onData&&this.onData(e)})}closed=!1;onData=()=>{};get address(){return{}}type="ice";send=t=>this.ice.send(t);async close(){this.closed=!0,this.ice.close()}},_Ne=t=>new o8t(t),wNe=_n("werift:packages/webrtc/src/transport/ice.ts"),RUe=class{constructor(t){this.iceGather=t,this.connection=this.iceGather.connection,this.connection.stateChanged.subscribe(e=>{this.setState(e)}),this.iceGather.onIceCandidate=e=>{this.onIceCandidate.execute(e)}}id=c8t().toString();connection;state="new";waitStart;renominating=!1;onStateChange=new yr;onIceCandidate=new yr;onNegotiationNeeded=new yr;get role(){return this.connection.iceControlling?"controlling":"controlled"}get gatheringState(){return this.iceGather.gatheringState}get localCandidates(){return this.iceGather.localCandidates}get localParameters(){return this.iceGather.localParameters}setState(t){t!==this.state&&(this.state=t,this.onStateChange.execute(t))}gather(){return this.iceGather.gather()}addRemoteCandidate=t=>{if(!this.connection.remoteCandidatesEnd)return t?this.connection.addRemoteCandidate(NUe(t)):this.connection.addRemoteCandidate(void 0)};setRemoteParams(t,e=!1){e&&(this.renominating=!0),this.connection.remoteUsername&&this.connection.remotePassword&&(this.connection.remoteUsername!==t.usernameFragment||this.connection.remotePassword!==t.password)&&(this.renominating?(wNe("renomination",t),this.connection.resetNominatedPair(),this.renominating=!1):(wNe("restart",t),this.restart())),this.connection.setRemoteParams(t)}restart(){this.connection.restart(),this.setState("new"),this.iceGather.gatheringState="new",this.waitStart=void 0,this.onNegotiationNeeded.execute()}async start(){if(this.state==="closed")throw new Error("RTCIceTransport is closed");if(!this.connection.remotePassword||!this.connection.remoteUsername)throw new Error("remoteParams missing");this.waitStart&&await this.waitStart.asPromise(),this.waitStart=new yr,this.setState("checking");try{await this.connection.connect()}catch(t){throw this.setState("failed"),t}this.waitStart.execute(),this.waitStart.complete(),this.waitStart=void 0}async stop(){this.state!=="closed"&&(this.setState("closed"),await this.connection.close()),this.onStateChange.complete(),this.onIceCandidate.complete(),this.onNegotiationNeeded.complete()}async getStats(){let t=qg(),e=[];for(let n of this.localCandidates){let i={type:"local-candidate",id:rs("local-candidate",n.foundation),timestamp:t,transportId:rs("transport",this.id),address:n.ip,port:n.port,protocol:n.protocol,candidateType:n.type,priority:n.priority,foundation:n.foundation};e.push(i)}for(let n of this.connection.remoteCandidates){let i=qS(n),s={type:"remote-candidate",id:rs("remote-candidate",i.foundation),timestamp:t,transportId:rs("transport",this.id),address:i.ip,port:i.port,protocol:i.protocol,candidateType:i.type,priority:i.priority,foundation:i.foundation};e.push(s)}let r=this.connection?.candidatePairs?[...this.connection.candidatePairs.filter(n=>n.nominated),...this.connection.candidatePairs.filter(n=>!n.nominated)]:[];for(let n of r){let i={type:"candidate-pair",id:rs("candidate-pair",n.foundation),timestamp:t,transportId:rs("transport",this.id),localCandidateId:rs("local-candidate",n.localCandidate.foundation),remoteCandidateId:rs("remote-candidate",n.remoteCandidate.foundation),state:n.state,nominated:n.nominated,packetsSent:n.packetsSent,packetsReceived:n.packetsReceived,bytesSent:n.bytesSent,bytesReceived:n.bytesReceived,currentRoundTripTime:n.rtt};e.push(i)}return e}},u8t=["new","checking","connected","completed","disconnected","failed","closed"],l8t=["new","gathering","complete"],OUe=class{constructor(t={}){this.options=t,this.connection=new fUe(!1,this.options),this.connection.onIceCandidate.subscribe(e=>{this.onIceCandidate(qS(e))})}onIceCandidate=()=>{};gatheringState="new";connection;onGatheringStateChange=new yr;async gather(){this.gatheringState==="new"&&(this.setState("gathering"),await this.connection.gatherCandidates(),this.onIceCandidate(void 0),this.setState("complete"))}get localCandidates(){return this.connection.localCandidates.map(qS)}get localParameters(){return new Zoe({usernameFragment:this.connection.localUsername,password:this.connection.localPassword})}setState(t){t!==this.gatheringState&&(this.gatheringState=t,this.onGatheringStateChange.execute(t))}};BUe=class{candidate;sdpMid;sdpMLineIndex;usernameFragment;constructor(t){Object.assign(this,t)}static fromSdp(t){let e=$g.fromSdp(t);return qS(e).toJSON()}static isThis(t){if(typeof t?.candidate=="string")return!0}toJSON(){return{candidate:this.candidate,sdpMid:this.sdpMid,sdpMLineIndex:this.sdpMLineIndex,usernameFragment:this.usernameFragment}}},Koe=class{constructor(t,e,r,n,i,s,a,c,d){this.component=t,this.foundation=e,this.ip=r,this.port=n,this.priority=i,this.protocol=s,this.type=a,this.generation=c,this.ufrag=d}relatedAddress;relatedPort;sdpMid;sdpMLineIndex;tcpType;toJSON(){return new BUe({candidate:Joe(this),sdpMLineIndex:this.sdpMLineIndex,sdpMid:this.sdpMid,usernameFragment:this.ufrag})}static fromJSON(t){try{if(!t.candidate)throw new Error("candidate is required");let e=Qoe(t.candidate);return e.sdpMLineIndex=t.sdpMLineIndex??void 0,e.sdpMid=t.sdpMid??void 0,e}catch{}}},Zoe=class{iceLite=!1;usernameFragment;password;constructor(t={}){Object.assign(this,t)}},Lh=class UUe{constructor(e=0,r=Buffer.from("")){this.flags=e,this._body=r}get body(){return this._body}set body(e){this._body=e}static type=-1;get type(){return UUe.type}get bytes(){if(!this.body)throw new Error;let e=Buffer.alloc(4);return e.writeUInt8(this.type,0),e.writeUInt8(this.flags,1),e.writeUInt16BE(this.body.length+4,2),Buffer.concat([e,this.body,...[...Array(r8(this.body.length))].map(()=>Buffer.from("\0"))])}},Xoe=class extends Lh{constructor(t=0,e){super(t,e),this.flags=t,e?(this.initiateTag=e.readUInt32BE(0),this.advertisedRwnd=e.readUInt32BE(4),this.outboundStreams=e.readUInt16BE(8),this.inboundStreams=e.readUInt16BE(10),this.initialTsn=e.readUInt32BE(12),this.params=iMe(e.slice(16))):(this.initiateTag=0,this.advertisedRwnd=0,this.outboundStreams=0,this.inboundStreams=0,this.initialTsn=0,this.params=[])}initiateTag;advertisedRwnd;outboundStreams;inboundStreams;initialTsn;params;get body(){let t=Buffer.alloc(16);return t.writeUInt32BE(this.initiateTag,0),t.writeUInt32BE(this.advertisedRwnd,4),t.writeUInt16BE(this.outboundStreams,8),t.writeUInt16BE(this.inboundStreams,10),t.writeUInt32BE(this.initialTsn,12),Buffer.concat([t,nMe(this.params)])}},QU=class MUe extends Xoe{static type=1;get type(){return MUe.type}},zae=class LUe extends Xoe{static type=2;get type(){return LUe.type}},h8t=class $Ue extends Xoe{static type=130;get type(){return $Ue.type}},eM=class jUe extends Lh{constructor(e=0,r){if(super(e,r),this.flags=e,r){this.cumulativeTsn=r.readUInt32BE(0);let n=4;for(;n<r.length;)this.streams.push([r.readUInt16BE(n),r.readUInt16BE(n+2)]),n+=4}else this.cumulativeTsn=0}static type=192;streams=[];cumulativeTsn;get type(){return jUe.type}set body(e){}get body(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.cumulativeTsn,0),Buffer.concat([e,...this.streams.map(([r,n])=>{let i=Buffer.alloc(4);return i.writeUInt16BE(r,0),i.writeUInt16BE(n,2),i})])}},tM=class qUe extends Lh{constructor(e=0,r){super(e,r),this.flags=e,r&&(this.tsn=r.readUInt32BE(0),this.streamId=r.readUInt16BE(4),this.streamSeqNum=r.readUInt16BE(6),this.protocol=r.readUInt32BE(8),this.userData=r.slice(12))}static type=0;get type(){return qUe.type}tsn=0;streamId=0;streamSeqNum=0;protocol=0;userData=Buffer.from("");abandoned=!1;acked=!1;misses=0;retransmit=!1;sentCount=0;bookSize=0;expiry;maxRetransmits;sentTime;get bytes(){let e=16+this.userData.length,r=Buffer.alloc(16);r.writeUInt8(this.type,0),r.writeUInt8(this.flags,1),r.writeUInt16BE(e,2),r.writeUInt32BE(this.tsn,4),r.writeUInt16BE(this.streamId,8),r.writeUInt16BE(this.streamSeqNum,10),r.writeUInt32BE(this.protocol,12);let n=Buffer.concat([r,this.userData]);return e%4&&(n=Buffer.concat([n,...[...Array(r8(e))].map(()=>Buffer.from("\0"))])),n}},Wae=class zUe extends Lh{static type=10;get type(){return zUe.type}},Hae=class WUe extends Lh{static type=11;get type(){return WUe.type}},t8=class extends Lh{constructor(t=0,e=void 0){super(t,e),this.flags=t,e&&(this.params=iMe(e))}params=[];get body(){return nMe(this.params)}},Vae=class HUe extends t8{static type=6;get type(){return HUe.type}},rM=class Gae extends t8{static type=9;static CODE={InvalidStreamIdentifier:1,MissingMandatoryParameter:2,StaleCookieError:3,OutofResource:4,UnresolvableAddress:5,UnrecognizedChunkType:6,InvalidMandatoryParameter:7,UnrecognizedParameters:8,NoUserData:9,CookieReceivedWhileShuttingDown:10,RestartofanAssociationwithNewAddresses:11,UserInitiatedAbort:12,ProtocolViolation:13};get type(){return Gae.type}get descriptions(){return this.params.map(([e,r])=>({name:(Object.entries(Gae.CODE).find(([,i])=>i===e)||[])[0],body:r}))}},Kae=class VUe extends t8{static type=4;get type(){return VUe.type}},GUe=class KUe extends t8{static type=5;get type(){return KUe.type}},Zae=class ZUe extends t8{static type=130;get type(){return ZUe.type}},Xae=class XUe extends Lh{constructor(e=0,r){if(super(e,r),this.flags=e,r){this.cumulativeTsn=r.readUInt32BE(0),this.advertisedRwnd=r.readUInt32BE(4);let n=r.readUInt16BE(8),i=r.readUInt16BE(10),s=12;[...Array(n)].forEach(()=>{this.gaps.push([r.readUInt16BE(s),r.readUInt16BE(s+2)]),s+=4}),[...Array(i)].forEach(()=>{this.duplicates.push(r.readUInt32BE(s)),s+=4})}}static type=3;get type(){return XUe.type}gaps=[];duplicates=[];cumulativeTsn=0;advertisedRwnd=0;get bytes(){let e=16+4*(this.gaps.length+this.duplicates.length),r=Buffer.alloc(16);r.writeUInt8(this.type,0),r.writeUInt8(this.flags,1),r.writeUInt16BE(e,2),r.writeUInt32BE(this.cumulativeTsn,4),r.writeUInt32BE(this.advertisedRwnd,8),r.writeUInt16BE(this.gaps.length,12),r.writeUInt16BE(this.duplicates.length,14);let n=Buffer.concat([r,...this.gaps.map(i=>{let s=Buffer.alloc(4);return s.writeUInt16BE(i[0],0),s.writeUInt16BE(i[1],2),s})]);return n=Buffer.concat([n,...this.duplicates.map(i=>{let s=Buffer.alloc(4);return s.writeUInt32BE(i,0),s})]),n}},YUe=class JUe extends Lh{constructor(e=0,r){super(e,r),this.flags=e,r&&(this.cumulativeTsn=r.readUInt32BE(0))}static type=7;get type(){return JUe.type}cumulativeTsn=0;get body(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.cumulativeTsn,0),e}},QUe=class eMe extends Lh{static type=8;get type(){return eMe.type}},tMe=class rMe extends Lh{static type=14;get type(){return rMe.type}},p8t=[tM,QU,zae,Xae,Kae,GUe,Vae,YUe,QUe,rM,Wae,Hae,tMe,Zae,eM],m8t=p8t.reduce((t,e)=>(t[e.type]=e,t),{});Yae=class Jae{constructor(e,r,n,i){this.requestSequence=e,this.responseSequence=r,this.lastTsn=n,this.streams=i}static type=13;get type(){return Jae.type}get bytes(){let e=Buffer.from(Sp.jspack.Pack("!LLL",[this.requestSequence,this.responseSequence,this.lastTsn]));return Buffer.concat([e,...this.streams.map(r=>Buffer.from(Sp.jspack.Pack("!H",[r])))])}static parse(e){let[r,n,i]=Sp.jspack.Unpack("!LLL",e),s=[];for(let a=12;a<e.length;a+=2)s.push(Sp.jspack.Unpack("!H",e.slice(a))[0]);return new Jae(r,n,i,s)}},sMe=class Qae{constructor(e,r){this.requestSequence=e,this.newStreams=r}static type=17;get type(){return Qae.type}get bytes(){return Buffer.from(Sp.jspack.Pack("!LHH",[this.requestSequence,this.newStreams,0]))}static parse(e){let[r,n]=Sp.jspack.Unpack("!LHH",e);return new Qae(r,n)}},$U={ReconfigResultSuccessPerformed:1,BadSequenceNumber:5},nM=class eoe{constructor(e,r){this.responseSequence=e,this.result=r}static type=16;get type(){return eoe.type}get bytes(){return Buffer.from(Sp.jspack.Pack("!LL",[this.responseSequence,this.result]))}static parse(e){let[r,n]=Sp.jspack.Unpack("!LL",e);return new eoe(r,n)}},ANe={13:Yae,16:nM,17:sMe},Di=_n("werift/sctp/sctp"),b8t=24,_8t=60,ENe=65535,ad=1200,wD=1,aMe=2,toe=4,TNe=10,w8t=8,CNe=1/8,kNe=1/4,DNe=3,S8t=1,A8t=60,xM=2**32,E8t=200,T8t=30,INe=135,FNe=7,PNe=32776,RNe=49152,C8t=["new","closed","connected","connecting"],k8t=class roe{constructor(e,r=5e3){this.transport=e,this.port=r,this.localPort=this.port,this.transport.onData=n=>{this.handleData(n)}}flush=new yr;stateChanged=v8t(C8t);onReconfigStreams=new yr;onReceive=new yr;onSackReceived=async()=>{};associationState=1;started=!1;state="new";isServer=!0;isStopping=!1;isClosed=!1;hmacKey=d8t(16);localPartialReliability=!0;localPort;localVerificationTag=sM();remoteExtensions=[];remotePartialReliability=!0;remotePort;remoteVerificationTag=0;advertisedRwnd=1024*1024;peerAdvertisedRwnd=this.advertisedRwnd;get peerRwnd(){return Math.max(0,this.peerAdvertisedRwnd-this.flightSize)}inboundStreams={};_inboundStreamsCount=0;_inboundStreamsMax=ENe;lastReceivedTsn;sackDuplicates=[];sackMisOrdered=new Set;sackNeeded=!1;sackPacketCount=0;sackHasNewDataInPacket=!1;sackImmediate=!1;sackTimeout;cwnd=3*ad;fastRecoveryExit;fastRecoveryTransmit=!1;forwardTsnChunk;flightSize=0;outboundQueue=[];outboundStreamSeq={};_outboundStreamsCount=ENe;localTsn=Number(sM());lastSackedTsn=yv(this.localTsn);advancedPeerAckTsn=yv(this.localTsn);partialBytesAcked=0;sentQueue=[];transmitting=!1;transmitRequested=!1;reconfigRequestSeq=this.localTsn;reconfigResponseSeq=0;reconfigRequest;reconfigQueue=[];srtt;rttvar;rto=DNe;timer1Handle;timer1Chunk;timer1Failures=0;timer2Handle;timer2Chunk;timer2Failures=0;timer3Handle;timerReconfigHandle;timerReconfigFailures=0;timerHeartbeatHandle;heartbeatInterval=T8t;ssthresh;get isStopped(){return this.isStopping||this.isClosed}get maxChannels(){if(this._inboundStreamsCount>0)return Math.min(this._inboundStreamsCount,this._outboundStreamsCount)}static client(e,r=5e3){let n=new roe(e,r);return n.isServer=!1,n}static server(e,r=5e3){let n=new roe(e,r);return n.isServer=!0,n}async handleData(e){if(this.isStopped)return;let r,[,,n,i]=g8t(e);if(i.filter(a=>a.type===QU.type).length>0){if(i.length!=1)throw new Error;r=0}else r=this.localVerificationTag;if(n===r){this.sackHasNewDataInPacket=!1;for(let a of i)await this.receiveChunk(a);this.sackNeeded&&(this.sackHasNewDataInPacket&&this.sackPacketCount++,this.sackPacketCount>=2&&(this.sackImmediate=!0),await this.scheduleSack())}}async scheduleSack(){if(!this.isStopped&&this.sackNeeded){if(this.sackImmediate){this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),await this.sendSack();return}this.sackTimeout||(this.sackTimeout=setTimeout(()=>{this.sackTimeout=void 0,this.sendSack().catch(e=>{Di("send delayed sack failed",e.message)})},E8t))}}async sendSack(){if(this.isStopped||!this.sackNeeded)return;let e=[],r;[...this.sackMisOrdered].sort().forEach(i=>{let s=(i-this.lastReceivedTsn)%xM;i===r?e[e.length-1][1]=s:e.push([s,s]),r=FS(i)});let n=new Xae(0,void 0);n.cumulativeTsn=this.lastReceivedTsn,n.advertisedRwnd=Math.max(0,this.advertisedRwnd),n.duplicates=[...this.sackDuplicates],n.gaps=e,await this.sendChunk(n).catch(i=>{Di("send sack failed",i.message)}),this.sackDuplicates=[],this.sackNeeded=!1,this.sackPacketCount=0,this.sackImmediate=!1}async receiveChunk(e){switch(e.type){case tM.type:this.receiveDataChunk(e);break;case QU.type:{if(!this.isServer)return;let r=e;Di("receive init",r),this.lastReceivedTsn=yv(r.initialTsn),this.reconfigResponseSeq=yv(r.initialTsn),this.remoteVerificationTag=r.initiateTag,this.ssthresh=r.advertisedRwnd,this.peerAdvertisedRwnd=r.advertisedRwnd,this.getExtensions(r.params),this._inboundStreamsCount=Math.min(r.outboundStreams,this._inboundStreamsMax),this._outboundStreamsCount=Math.min(this._outboundStreamsCount,r.inboundStreams);let n=new zae;n.initiateTag=this.localVerificationTag,n.advertisedRwnd=this.advertisedRwnd,n.outboundStreams=this._outboundStreamsCount,n.inboundStreams=this._inboundStreamsCount,n.initialTsn=this.localTsn,this.setExtensions(n.params);let i=Date.now()/1e3,s=Buffer.from(JU.jspack.Pack("!L",[i]));s=Buffer.concat([s,SNe("sha1",this.hmacKey).update(s).digest()]),n.params.push([FNe,s]),Di("send initAck",n),await this.sendChunk(n).catch(a=>{Di("send initAck failed",a.message)})}break;case zae.type:{if(this.associationState!=2)return;let r=e;this.timer1Cancel(),this.lastReceivedTsn=yv(r.initialTsn),this.reconfigResponseSeq=yv(r.initialTsn),this.remoteVerificationTag=r.initiateTag,this.ssthresh=r.advertisedRwnd,this.peerAdvertisedRwnd=r.advertisedRwnd,this.getExtensions(r.params),this._inboundStreamsCount=Math.min(r.outboundStreams,this._inboundStreamsMax),this._outboundStreamsCount=Math.min(this._outboundStreamsCount,r.inboundStreams);let n=new Wae;for(let[i,s]of r.params)if(i===FNe){n.body=s;break}await this.sendChunk(n).catch(i=>{Di("send echo failed",i.message)}),this.timer1Start(n),this.setState(3)}break;case Xae.type:await this.receiveSackChunk(e);break;case Kae.type:{let r=new GUe;r.params=e.params,await this.sendChunk(r).catch(n=>{Di("send heartbeat ack failed",n.message)})}break;case Vae.type:this.setState(1);break;case YUe.type:{this.timer2Cancel(),this.setState(7);let r=new QUe;await this.sendChunk(r).catch(n=>{Di("send shutdown ack failed",n.message)}),this.t2Start(r),this.setState(6)}break;case rM.type:Di("ErrorChunk",e.descriptions);break;case Wae.type:{if(!this.isServer)return;let n=e.body,i=SNe("sha1",this.hmacKey).update(n.slice(0,4)).digest();if(n?.length!=b8t||!n.slice(4).equals(i)){Di("x State cookie is invalid");return}let s=Date.now()/1e3,a=JU.jspack.Unpack("!L",n)[0];if(a<s-_8t||a>s){let d=new rM(0,void 0);d.params.push([rM.CODE.StaleCookieError,Buffer.concat([...Array(8)].map(()=>Buffer.from("\0")))]),await this.sendChunk(d).catch(h=>{Di("send errorChunk failed",h.message)});return}let c=new Hae;await this.sendChunk(c).catch(d=>{Di("send cookieAck failed",d.message)}),this.setState(4)}break;case Hae.type:{if(this.associationState!=3)return;this.timer1Cancel(),this.setState(4)}break;case tMe.type:{if(this.associationState!=8)return;this.timer2Cancel(),this.setState(1)}break;case Zae.type:{if(this.associationState!=4)return;let r=e;for(let[n,i]of r.params){let s=ANe[n];s&&await this.receiveReconfigParam(s.parse(i))}}break;case eM.type:this.receiveForwardTsnChunk(e);break}}getExtensions(e){for(let[r,n]of e)r===RNe?this.remotePartialReliability=!0:r===PNe&&(this.remoteExtensions=[...n])}async receiveReconfigParam(e){switch(Di("receiveReconfigParam",ANe[e.type]),e.type){case Yae.type:{let r=e,n=new nM(r.requestSequence,$U.ReconfigResultSuccessPerformed);this.reconfigResponseSeq=r.requestSequence,await this.sendReconfigParam(n),await Promise.all(r.streams.map(async i=>{delete this.inboundStreams[i],this.outboundStreamSeq[i]&&(this.reconfigQueue.includes(i)||this.reconfigQueue.push(i))})),await this.transmitReconfigRequest(),this.onReconfigStreams.execute(r.streams)}break;case nM.type:{let r=e;if(r.result!==$U.ReconfigResultSuccessPerformed)Di("OutgoingSSNResetRequestParam failed",Object.keys($U).find(n=>$U[n]===r.result));else if(r.responseSequence===this.reconfigRequest?.requestSequence){let n=this.reconfigRequest.streams.map(i=>(delete this.outboundStreamSeq[i],i));this.onReconfigStreams.execute(n),this.reconfigRequest=void 0,this.timerReconfigCancel(),this.rto=DNe,this.timerReconfigFailures=0,this.reconfigQueue.length>0&&await this.transmitReconfigRequest()}}break;case sMe.type:{let r=e;this._inboundStreamsCount+=r.newStreams;let n=new nM(r.requestSequence,1);this.reconfigResponseSeq=r.requestSequence,await this.sendReconfigParam(n)}break}}receiveDataChunk(e){if(this.sackNeeded=!0,this.markReceived(e.tsn)){this.sackImmediate=!0;return}this.sackHasNewDataInPacket=!0,this.sackImmediate=!0,(e.flags&wD)===0&&(this.sackImmediate=!0),this.sackMisOrdered.size>0&&(this.sackImmediate=!0);let r=this.getInboundStream(e.streamId);r.addChunk(e),this.advertisedRwnd-=e.userData.length;for(let n of r.popMessages())this.advertisedRwnd+=n[2].length,this.receive(...n)}async receiveSackChunk(e){if(Oh(this.lastSackedTsn,e.cumulativeTsn))return;let r=Date.now()/1e3;this.lastSackedTsn=e.cumulativeTsn;let n=this.flightSize>=this.cwnd,i=0,s=0;for(;this.sentQueue.length>0&&PS(this.lastSackedTsn,this.sentQueue[0].tsn);){let c=this.sentQueue.shift();i++,c?.acked||(s+=c.bookSize,this.flightSizeDecrease(c)),i===1&&c.sentCount===1&&this.updateRto(r-c.sentTime)}this.sentQueue.length||(this.sentQueue=[]);let a=!1;if(e.gaps.length>0){let c=new Set,d;e.gaps.forEach(p=>{for(let x=p[0];x<p[1]+1;x++)d=(e.cumulativeTsn+x)%xM,c.add(d)});let h=e.cumulativeTsn;for(let p of this.sentQueue){if(Oh(p.tsn,d))break;c.has(p.tsn)&&!p.acked&&(s+=p.bookSize,p.acked=!0,this.flightSizeDecrease(p),h=p.tsn)}for(let p of this.sentQueue){if(Oh(p.tsn,h))break;c.has(p.tsn)||(p.misses++,p.misses===3&&(p.misses=0,this.maybeAbandon(p)||(p.retransmit=!0),p.acked=!1,this.flightSizeDecrease(p),a=!0))}}this.fastRecoveryExit===void 0?(i&&n&&(this.cwnd<=this.ssthresh?this.cwnd+=Math.min(s,ad):(this.partialBytesAcked+=s,this.partialBytesAcked>=this.cwnd&&(this.partialBytesAcked-=this.cwnd,this.cwnd+=ad))),a&&(this.ssthresh=Math.max(Math.floor(this.cwnd/2),4*ad),this.cwnd=this.ssthresh,this.partialBytesAcked=0,this.fastRecoveryExit=this.sentQueue[this.sentQueue.length-1].tsn,this.fastRecoveryTransmit=!0)):PS(e.cumulativeTsn,this.fastRecoveryExit)&&(this.fastRecoveryExit=void 0),this.sentQueue.length===0?this.timer3Cancel():i>0&&this.timer3Restart(),this.peerAdvertisedRwnd=e.advertisedRwnd,this.updateAdvancedPeerAckPoint(),await this.onSackReceived(),await this.transmit()}receiveForwardTsnChunk(e){if(this.sackNeeded=!0,this.sackImmediate=!0,PS(this.lastReceivedTsn,e.cumulativeTsn))return;let r=n=>Oh(n,this.lastReceivedTsn);this.lastReceivedTsn=e.cumulativeTsn,this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r));for(let n of[...this.sackMisOrdered].sort())if(n===FS(this.lastReceivedTsn))this.lastReceivedTsn=n;else break;this.sackDuplicates=this.sackDuplicates.filter(r),this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r));for(let[n,i]of e.streams){let s=this.getInboundStream(n);s.streamSequenceNumber=jo(i,1);for(let a of s.popMessages())this.advertisedRwnd+=a[2].length,this.receive(...a)}Object.values(this.inboundStreams).forEach(n=>{this.advertisedRwnd+=n.pruneChunks(this.lastReceivedTsn)})}updateRto(e){this.srtt?(this.rttvar=(1-kNe)*this.rttvar+kNe*Math.abs(this.srtt-e),this.srtt=(1-CNe)*this.srtt+CNe*e):(this.rttvar=e/2,this.srtt=e),this.rto=Math.max(S8t,Math.min(this.srtt+4*this.rttvar,A8t))}receive(e,r,n){this.onReceive.execute(e,r,n)}getInboundStream(e){return this.inboundStreams[e]||(this.inboundStreams[e]=new D8t),this.inboundStreams[e]}markReceived(e){if(PS(this.lastReceivedTsn,e)||this.sackMisOrdered.has(e))return this.sackDuplicates.push(e),!0;this.sackMisOrdered.add(e);for(let n of[...this.sackMisOrdered].sort())if(n===FS(this.lastReceivedTsn))this.lastReceivedTsn=n;else break;let r=n=>Oh(n,this.lastReceivedTsn);return this.sackDuplicates=this.sackDuplicates.filter(r),this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r)),!1}send=async(e,r,n,{expiry:i,maxRetransmits:s,ordered:a}={expiry:void 0,maxRetransmits:void 0,ordered:!0})=>{let c=a&&this.outboundStreamSeq[e]||0,d=Math.ceil(n.length/ad),h=0,p=[];for(let x=0;x<d;x++){let y=new tM(0,void 0);y.flags=0,a||(y.flags=toe),x===0&&(y.flags|=aMe),x===d-1&&(y.flags|=wD),y.tsn=this.localTsn,y.streamId=e,y.streamSeqNum=c,y.protocol=r,y.userData=n.slice(h,h+ad),y.bookSize=y.userData.length,y.expiry=i,y.maxRetransmits=s,h+=ad,this.localTsn=FS(this.localTsn),p.push(y)}for(p.forEach(x=>{this.outboundQueue.push(x)}),a&&(this.outboundStreamSeq[e]=jo(c,1)),await this.transmit();this.outboundQueue.length;)await this.flush.asPromise()};async transmit(){if(!this.isStopped){if(this.transmitting){this.transmitRequested=!0;return}this.transmitting=!0;try{do this.transmitRequested=!1,await this.transmitOnce();while(this.transmitRequested)}finally{this.transmitting=!1}}}async transmitOnce(){if(this.isStopped)return;this.forwardTsnChunk&&(await this.sendChunk(this.forwardTsnChunk).catch(i=>{Di("send forwardTsn failed",i.message)}),this.forwardTsnChunk=void 0,this.timer3Handle||this.timer3Start());let e=this.fastRecoveryExit!=null?2*ad:4*ad,r=Math.min(this.flightSize+e,this.cwnd),n=!0;for(let i of this.sentQueue){if(i.retransmit){if(this.fastRecoveryTransmit)this.fastRecoveryTransmit=!1;else if(this.flightSize>=r)break;this.flightSizeIncrease(i),i.misses=0,i.retransmit=!1,i.sentCount++,await this.sendChunk(i).catch(s=>{Di("send data failed",s.message)}),n&&this.timer3Restart()}n=!1}for(;this.outboundQueue.length>0&&this.flightSize<r&&this.peerRwnd>0;){let i=this.outboundQueue.shift();if(!i)break;if(i.bookSize>this.peerRwnd&&this.flightSize>0){this.outboundQueue.unshift(i);break}this.sentQueue.push(i),this.flightSizeIncrease(i),i.sentCount++,i.sentTime=Date.now()/1e3,await this.sendChunk(i).catch(s=>{Di("send data outboundQueue failed",s.message)}),this.timer3Handle||this.timer3Start()}this.outboundQueue.length||(this.outboundQueue=[]),this.flush.execute()}async transmitReconfigRequest(){if(this.reconfigQueue.length>0&&this.associationState===4&&!this.reconfigRequest){let e=[...new Set(this.reconfigQueue)],r=e.slice(0,INe);this.reconfigQueue=e.slice(INe);let n=new Yae(this.reconfigRequestSeq,this.reconfigResponseSeq,yv(this.localTsn),r);this.reconfigRequestSeq=FS(this.reconfigRequestSeq),this.reconfigRequest=n,await this.sendReconfigParam(n),this.timerReconfigHandleStart()}}async sendReconfigParam(e){Di("sendReconfigParam",e);let r=new Zae;r.params.push([e.type,e.bytes]),await this.sendChunk(r).catch(n=>{Di("send reconfig failed",n.message)})}async sendResetRequest(e){Di("sendResetRequest",e);let r=new tM(0,void 0);r.streamId=e,this.outboundQueue.push(r),this.timer3Handle||await this.transmit()}flightSizeIncrease(e){this.flightSize+=e.bookSize}flightSizeDecrease(e){this.flightSize=Math.max(0,this.flightSize-e.bookSize)}timer1Start(e){if(this.timer1Handle)throw new Error;this.timer1Chunk=e,this.timer1Failures=0,this.timer1Handle=setTimeout(this.timer1Expired,this.rto*1e3)}timer1Expired=()=>{if(!this.isStopped)if(this.timer1Failures++,this.timer1Handle=void 0,this.timer1Failures>w8t)this.setState(1);else{if(setImmediate(()=>{this.isStopped||this.sendChunk(this.timer1Chunk).catch(e=>{Di("send timer1 chunk failed",e.message)})}),this.isStopped)return;this.timer1Handle=setTimeout(this.timer1Expired,this.rto*1e3)}};timer1Cancel(){this.timer1Handle&&(clearTimeout(this.timer1Handle),this.timer1Handle=void 0,this.timer1Chunk=void 0)}t2Start(e){if(this.timer2Handle)throw new Error;this.timer2Chunk=e,this.timer2Failures=0,this.timer2Handle=setTimeout(this.timer2Expired,this.rto*1e3)}timer2Expired=()=>{if(!this.isStopped)if(this.timer2Failures++,this.timer2Handle=void 0,this.timer2Failures>TNe)this.setState(1);else{if(setImmediate(()=>{this.isStopped||this.sendChunk(this.timer2Chunk).catch(e=>{Di("send timer2Chunk failed",e.message)})}),this.isStopped)return;this.timer2Handle=setTimeout(this.timer2Expired,this.rto*1e3)}};timer2Cancel(){this.timer2Handle&&(clearTimeout(this.timer2Handle),this.timer2Handle=void 0,this.timer2Chunk=void 0)}timer3Start(){if(!this.isStopped){if(this.timer3Handle)throw new Error;this.timer3Handle=setTimeout(this.timer3Expired,this.rto*1e3)}}timer3Restart(){this.isStopped||(this.timer3Cancel(),this.timer3Handle=setTimeout(this.timer3Expired,this.rto*1e3))}timer3Expired=()=>{this.isStopped||(this.timer3Handle=void 0,this.sentQueue.forEach(e=>{this.maybeAbandon(e)||(e.retransmit=!0)}),this.updateAdvancedPeerAckPoint(),this.fastRecoveryExit=void 0,this.flightSize=0,this.partialBytesAcked=0,this.ssthresh=Math.max(Math.floor(this.cwnd/2),4*ad),this.cwnd=ad,this.transmit())};timer3Cancel(){this.timer3Handle&&(clearTimeout(this.timer3Handle),this.timer3Handle=void 0)}timerReconfigHandleStart(){this.isStopped||this.timerReconfigHandle||(Di("timerReconfigHandleStart",{rto:this.rto}),this.timerReconfigFailures=0,this.timerReconfigHandle=setTimeout(this.timerReconfigHandleExpired,this.rto*1e3))}timerReconfigHandleExpired=async()=>{if(!this.isStopped){if(this.timerReconfigFailures++,this.rto=Math.ceil(this.rto*1.5),this.timerReconfigFailures>TNe)Di("timerReconfigFailures",this.timerReconfigFailures),this.setState(1),this.timerReconfigHandle=void 0;else if(this.reconfigRequest){if(Di("timerReconfigHandleExpired",this.timerReconfigFailures,this.rto),await this.sendReconfigParam(this.reconfigRequest),this.isStopped)return;this.timerReconfigHandle=setTimeout(this.timerReconfigHandleExpired,this.rto*1e3)}}};timerReconfigCancel(){this.timerReconfigHandle&&(Di("timerReconfigCancel"),clearTimeout(this.timerReconfigHandle),this.timerReconfigHandle=void 0,this.timerReconfigFailures=0)}heartbeatStart(){this.timerHeartbeatHandle||this.associationState!==4||(this.timerHeartbeatHandle=setTimeout(this.timerHeartbeatExpired,(this.rto+this.heartbeatInterval)*1e3))}heartbeatRestart(){this.heartbeatCancel(),this.heartbeatStart()}heartbeatCancel(){this.timerHeartbeatHandle&&(clearTimeout(this.timerHeartbeatHandle),this.timerHeartbeatHandle=void 0)}timerHeartbeatExpired=async()=>{if(this.timerHeartbeatHandle=void 0,this.associationState===4){if(this.flightSize===0&&this.outboundQueue.length===0){let e=new Kae;e.params.push([1,Buffer.from(JU.jspack.Pack("!L",[Math.floor(Date.now()/1e3)]))]),await this.sendChunk(e).catch(r=>{Di("send heartbeat failed",r.message)})}this.heartbeatStart()}};setHeartbeatInterval(e){if(e<=0)throw new Error("heartbeat interval must be > 0");this.heartbeatInterval=e,this.heartbeatRestart()}updateAdvancedPeerAckPoint(){Oh(this.lastSackedTsn,this.advancedPeerAckTsn)&&(this.advancedPeerAckTsn=this.lastSackedTsn);let e=0,r={};for(;this.sentQueue.length>0&&this.sentQueue[0].abandoned;){let n=this.sentQueue.shift();this.advancedPeerAckTsn=n.tsn,e++,n.flags&toe||(r[n.streamId]=n.streamSeqNum)}this.sentQueue.length||(this.sentQueue=[]),e&&(this.forwardTsnChunk=new eM(0,void 0),this.forwardTsnChunk.cumulativeTsn=this.advancedPeerAckTsn,this.forwardTsnChunk.streams=Object.entries(r).map(([n,i])=>[Number(n),i]))}maybeAbandon(e){if(e.abandoned)return!0;if(!(!!e.maxRetransmits&&e.maxRetransmits<e.sentCount||!!e.expiry&&e.expiry<Date.now()/1e3))return!1;let n=this.sentQueue.findIndex(i=>i.type===e.type);for(let i=n;i>=0;i--){let s=this.sentQueue[i];if(s.abandoned=!0,s.retransmit=!1,s.flags&wD)break}for(let i=n;i<this.sentQueue.length;i++){let s=this.sentQueue[i];if(s.abandoned=!0,s.retransmit=!1,s.flags&wD)break}return!0}static getCapabilities(){return new I8t(65536)}setRemotePort(e){this.remotePort=e}async start(e){this.started||(this.started=!0,this.setConnectionState("connecting"),e&&this.setRemotePort(e),this.isServer||await this.init())}async init(){let e=new QU;e.initiateTag=this.localVerificationTag,e.advertisedRwnd=this.advertisedRwnd,e.outboundStreams=this._outboundStreamsCount,e.inboundStreams=this._inboundStreamsMax,e.initialTsn=this.localTsn,this.setExtensions(e.params),Di("send init",e);try{await this.sendChunk(e),this.timer1Start(e),this.setState(2)}catch(r){Di("send init failed",r.message)}}setExtensions(e){let r=[];this.localPartialReliability&&(e.push([RNe,Buffer.from("")]),r.push(eM.type)),r.push(h8t.type),e.push([PNe,Buffer.from(r)])}async sendChunk(e){if(this.state==="closed")return;if(this.remotePort===void 0)throw new Error("invalid remote port");let r=x8t(this.localPort,this.remotePort,this.remoteVerificationTag,e);await this.transport.send(r)}setState(e){e!=this.associationState&&(this.associationState=e),e===4?(this.isStopping=!1,this.isClosed=!1,this.setConnectionState("connected"),this.heartbeatStart()):e===1&&(this.isClosed=!0,this.timer1Cancel(),this.timer2Cancel(),this.timer3Cancel(),this.timerReconfigCancel(),this.heartbeatCancel(),this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),this.setConnectionState("closed"),this.removeAllListeners())}setConnectionState(e){this.state=e,Di("setConnectionState",e),this.stateChanged[e].execute()}async stop(){if(this.isStopped){this.setState(1);return}this.isStopping=!0,this.transport.onData=void 0,this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),this.associationState!==1&&await this.abort(),this.setState(1),clearTimeout(this.timer1Handle),clearTimeout(this.timer2Handle),clearTimeout(this.timer3Handle),clearTimeout(this.timerReconfigHandle),clearTimeout(this.timerHeartbeatHandle),clearTimeout(this.sackTimeout)}async abort(){let e=new Vae;await this.sendChunk(e).catch(r=>{Di("send abort failed",r.message)})}removeAllListeners(){Object.values(this.stateChanged).forEach(e=>e.allUnsubscribe())}},D8t=class{reassembly=[];streamSequenceNumber=0;constructor(){}addChunk(t){if(this.reassembly.length===0||Oh(t.tsn,this.reassembly[this.reassembly.length-1].tsn)){this.reassembly.push(t);return}for(let[e,r]of y8t(this.reassembly)){if(r.tsn===t.tsn)throw new Error("duplicate chunk in reassembly");if(Oh(r.tsn,t.tsn)){this.reassembly.splice(e,0,t);break}}}*popMessages(){let t=0,e,r,n;for(;t<this.reassembly.length;){let i=this.reassembly[t];if(e===void 0){if(n=!(i.flags&toe),!(i.flags&aMe)){if(n)break;t++;continue}if(n&&_M(i.streamSeqNum,this.streamSequenceNumber))break;r=i.tsn,e=t}else if(i.tsn!==r){if(n)break;e=void 0,t++;continue}if(i.flags&wD){let s=this.reassembly.slice(e,t+1).map(c=>c.userData).reduce((c,d)=>(c.push(d),c.push(Buffer.from("")),c),[]);s.pop();let a=Buffer.concat(s);this.reassembly=[...this.reassembly.slice(0,e),...this.reassembly.slice(t+1)],n&&i.streamSeqNum===this.streamSequenceNumber&&(this.streamSequenceNumber=jo(this.streamSequenceNumber,1)),t=e,yield[i.streamId,i.protocol,a]}else t++;r=FS(r)}}pruneChunks(t){let e=-1,r=0;for(let[n,i]of this.reassembly.entries())if(PS(t,i.tsn))e=n,r+=i.userData.length;else break;return this.reassembly=this.reassembly.slice(e+1),r}},I8t=class{constructor(t){this.maxMessageSize=t}};TS=_n("werift:packages/webrtc/src/transport/sctp.ts"),RS=65536,oMe=class cMe{constructor(e=5e3,r=RS){this.port=e,this.maxMessageSize=r}dtlsTransport;sctp;onDataChannel=new yr;id=f8t().toString();mid;mLineIndex;bundled=!1;dataChannels={};remoteMaxMessageSize=RS;dataChannelQueue=[];dataChannelId;eventDisposer=[];setDtlsTransport(e){this.dtlsTransport&&this.dtlsTransport.id===e.id||(this.eventDisposer.forEach(r=>r()),this.dtlsTransport=e,this.sctp=new k8t(new F8t(this.dtlsTransport),this.port),this.eventDisposer=[...[this.sctp.onReceive.subscribe(this.datachannelReceive),this.sctp.onReconfigStreams.subscribe(r=>{r.forEach(n=>{let i=this.dataChannels[n];i&&(i.setReadyState("closing"),i.setReadyState("closed"),delete this.dataChannels[n])})}),this.sctp.stateChanged.connected.subscribe(()=>{Object.values(this.dataChannels).forEach(r=>{r.negotiated&&r.readyState!=="open"&&r.setReadyState("open")}),this.dataChannelFlush()}),this.sctp.stateChanged.closed.subscribe(()=>{Object.values(this.dataChannels).forEach(r=>{r.setReadyState("closed")}),this.dataChannels={}}),this.dtlsTransport.onStateChange.subscribe(r=>{r==="closed"&&this.sctp.setState(1)})].map(r=>r.unSubscribe),()=>this.sctp.onSackReceived=async()=>{}],this.sctp.onSackReceived=async()=>{await this.dataChannelFlush()})}get isServer(){return this.dtlsTransport.iceTransport.role!=="controlling"}channelByLabel(e){return Object.values(this.dataChannels).find(r=>r.label===e)}datachannelReceive=async(e,r,n)=>{if(r===LU&&n.length>0)switch(TS("DCEP",e,r,n),n[0]){case pNe:{if(n.length<12){TS("DATA_CHANNEL_OPEN data.length not enough");return}if(Object.keys(this.dataChannels).includes(e.toString()))TS("datachannel already opened","retransmit ack");else{let[,s,,a,c,d]=YU.jspack.Unpack("!BBHLHH",n),h=12,p=n.slice(h,h+c).toString("utf8");h+=c;let x=n.slice(h,h+d).toString("utf8");TS("DATA_CHANNEL_OPEN",{channelType:s,reliability:a,streamId:e,label:p,protocol:x});let y=(s&3)===1?a:void 0,v=(s&3)===2?a:void 0,w=new Roe({label:p,ordered:(s&128)===0,maxPacketLifeTime:v,maxRetransmits:y,protocol:x,id:e}),S=new Poe(this,w,!1);S.isCreatedByRemote=!0,this.dataChannels[e]=S,this.onDataChannel.execute(S),S.setReadyState("open")}let i=this.dataChannels[e];this.dataChannelQueue.push([i,LU,Buffer.from(YU.jspack.Pack("!B",[hNe]))]),await this.dataChannelFlush()}break;case hNe:{TS("DATA_CHANNEL_ACK",e,r);let i=this.dataChannels[e];if(!i)throw new Error("channel not found");i.setReadyState("open")}break}else{let i=this.dataChannels[e];if(i){let s=(()=>{switch(r){case mNe:return n.toString("utf8");case BDt:return"";case gNe:return n;case UDt:return Buffer.from([]);default:throw new Error}})();i.messagesReceived++,i.bytesReceived+=n.length,i.onMessage.execute(s),i.emit("message",{data:s}),i.onmessage&&i.onmessage({data:s})}}};dataChannelAddNegotiated(e){if(e.id==null)throw new Error;if(this.dataChannels[e.id])throw new Error;this.dataChannels[e.id]=e,this.sctp.associationState===4&&e.setReadyState("open")}dataChannelOpen(e){if(e.id){if(this.dataChannels[e.id])throw new Error(`Data channel with ID ${e.id} already registered`);this.dataChannels[e.id]=e}let r=NDt,n=0,i=0;e.ordered||(r=128),e.maxRetransmits?(r=1,i=e.maxRetransmits):e.maxPacketLifeTime&&(r=2,i=e.maxPacketLifeTime);let s=YU.jspack.Pack("!BBHLHH",[pNe,r,n,i,e.label.length,e.protocol.length]),a=Buffer.concat([Buffer.from(s),Buffer.from(e.label,"utf8"),Buffer.from(e.protocol,"utf8")]);this.dataChannelQueue.push([e,LU,a]),this.dataChannelFlush()}async dataChannelFlush(){if(this.sctp.associationState==4){for(;this.dataChannelQueue.length>0;){let[e,r,n]=this.dataChannelQueue.shift(),i=e.id;if(i===void 0){for(i=this.dataChannelId;Object.keys(this.dataChannels).includes(i.toString());)i+=2;this.dataChannels[i]=e,e.setId(i)}if(r===LU)await this.sctp.send(i,r,n,{ordered:!0});else{let s=e.maxPacketLifeTime?Date.now()+e.maxPacketLifeTime/1e3:void 0;await this.sctp.send(i,r,n,{expiry:s,maxRetransmits:e.maxRetransmits,ordered:e.ordered}),e.addBufferedAmount(-n.length)}}this.dataChannelQueue=[]}}assertSendableMessageSize(e){if(this.remoteMaxMessageSize!==0&&e>this.remoteMaxMessageSize)throw new Error(`max-message-size exceeded: ${e} > ${this.remoteMaxMessageSize}`)}datachannelSend=(e,r)=>{let n=Buffer.isBuffer(r)?r:Buffer.from(r),i=dUe(r);return this.assertSendableMessageSize(i),e.addBufferedAmount(i),this.dataChannelQueue.push(typeof r=="string"?[e,mNe,n]:[e,gNe,n]),this.sctp.associationState!==4&&TS("sctp not established",this.sctp.associationState),this.dataChannelFlush(),i};getCapabilities(){return cMe.getCapabilities(this.maxMessageSize)}static getCapabilities(e=RS){return new Yoe(e)}setRemoteMaxMessageSize(e){this.remoteMaxMessageSize=e??RS}setRemotePort(e){this.sctp.setRemotePort(e)}async start(e){this.isServer?this.dataChannelId=0:this.dataChannelId=1,this.sctp.isServer=this.isServer,await this.sctp.start(e)}async stop(){this.dtlsTransport.dataReceiver=()=>{},await this.sctp.stop()}dataChannelClose(e){["closing","closed"].includes(e.readyState)||(e.setReadyState("closing"),this.sctp.associationState===4?(this.sctp.reconfigQueue.includes(e.id)||this.sctp.reconfigQueue.push(e.id),this.sctp.reconfigQueue.length===1&&this.sctp.transmitReconfigRequest()):(this.dataChannelQueue=this.dataChannelQueue.filter(r=>r[0].id!==e.id),this.sctp.reconfigQueue=this.sctp.reconfigQueue.filter(r=>r!==e.id),e.id&&delete this.dataChannels[e.id],e.setReadyState("closed")))}},Yoe=class{constructor(t){this.maxMessageSize=t}},F8t=class{constructor(t){this.dtls=t}set onData(t){this.dtls.dataReceiver=t}send=t=>this.dtls.sendData(t);close(){}},TD=class uMe{version=0;origin;name="-";time="0 0";host;group=[];extMapAllowMixed=!0;msidSemantic=[];media=[];type;dtlsRole;iceOptions;iceLite;icePassword;iceUsernameFragment;dtlsFingerprints=[];static parse(e){let[r,n]=P8t(e),i=new uMe;r.forEach(a=>{if(a.startsWith("v="))i.version=Number.parseInt(a.slice(2),10);else if(a.startsWith("o="))i.origin=a.slice(2);else if(a.startsWith("s="))i.name=a.slice(2);else if(a.startsWith("c="))i.host=eae(a.slice(2));else if(a.startsWith("t="))i.time=a.slice(2);else if(a.startsWith("a=")){let[c,d]=tae(a);switch(c){case"fingerprint":{let[h,p]=d?.split(" ")||[];i.dtlsFingerprints.push(new mM(h,p))}break;case"ice-lite":i.iceLite=!0;break;case"ice-options":i.iceOptions=d;break;case"ice-pwd":i.icePassword=d;break;case"ice-ufrag":i.iceUsernameFragment=d;break;case"group":iM(i.group,d);break;case"msid-semantic":iM(i.msidSemantic,d);break;case"setup":i.dtlsRole=yNe[d];break;case"extmap-allow-mixed":i.extMapAllowMixed=!0;break}}});let s=i.group.find(a=>a.semantic==="BUNDLE");return n.forEach(a=>{let d=a[0].match(/^m=([^ ]+) ([0-9]+) ([A-Z/]+) (.+)/);if(!d)throw new Error("m line not found");let h=d[1],p=d[4].split(" "),x=["audio","video"].includes(h)?p.map(w=>Number(w)):void 0,y=new yM(h,Number.parseInt(d[2]),d[3],x||p);if(y.dtlsParams=new gM([...i.dtlsFingerprints],i.dtlsRole),y.iceParams=new Zoe({iceLite:i.iceLite,usernameFragment:i.iceUsernameFragment,password:i.icePassword}),y.iceOptions=i.iceOptions,i.media.push(y),a.slice(1).forEach(w=>{if(w.startsWith("c="))y.host=eae(w.slice(2));else if(w.startsWith("a=")){let[S,C]=tae(w);switch(S){case"candidate":if(!C)throw new Error;y.iceCandidates.push(Qoe(C));break;case"end-of-candidates":y.iceCandidatesComplete=!0;break;case"extmap":{let[k,T]=C.split(" ");k.includes("/")&&([k]=k.split("/")),y.rtp.headerExtensions.push(new Mh({id:Number.parseInt(k),uri:T}))}break;case"fingerprint":{if(!C)throw new Error;let[k,T]=C.split(" ");y.dtlsParams?.fingerprints.push(new mM(k,T))}break;case"ice-options":y.iceOptions=C;break;case"ice-pwd":y.iceParams.password=C;break;case"ice-ufrag":y.iceParams.usernameFragment=C;break;case"ice-lite":y.iceParams.iceLite=!0;break;case"max-message-size":y.sctpCapabilities=new Yoe(Number.parseInt(C,10));break;case"mid":y.rtp.muxId=C;break;case"msid":y.msid=C;break;case"rtcp":{let[k,T]=bp(C," ");y.rtcpPort=Number.parseInt(k),y.rtcpHost=eae(T)}break;case"rtcp-mux":y.rtcpMux=!0;break;case"setup":y.dtlsParams.role=yNe[C];break;case"recvonly":case"sendonly":case"sendrecv":case"inactive":y.direction=S;break;case"rtpmap":{let[k,T]=bp(C," "),[E,I,R]=T.split("/"),U;y.kind==="audio"&&(U=R?Number.parseInt(R):1);let B=new jg({mimeType:y.kind+"/"+E,channels:U,clockRate:Number.parseInt(I),payloadType:Number.parseInt(k)});y.rtp.codecs.push(B)}break;case"sctpmap":{if(!C)throw new Error;let[k,T]=bp(C," ");y.sctpMap[Number.parseInt(k)]=T,y.sctpPort=Number.parseInt(k)}break;case"sctp-port":if(!C)throw new Error;y.sctpPort=Number.parseInt(C);break;case"ssrc":{let[k,T]=bp(C," "),E=Number.parseInt(k),[I,R]=bp(T,":"),U=y.ssrc.find(B=>B.ssrc===E);U||(U=new vM({ssrc:E}),y.ssrc.push(U)),bUe.includes(I)&&(U[I]=R)}break;case"ssrc-group":iM(y.ssrcGroup,C);break;case"rid":{let[k,T]=bp(C," ");y.simulcastParameters.push(new Ooe({rid:k,direction:T}))}break}}}),(!y.iceParams.usernameFragment||!y.iceParams.password)&&y.rtp.muxId&&s&&s.items.includes(y.rtp.muxId))for(let w=0;w<s.items.length;w++){if(!s.items.includes(w.toString()))continue;let S=i.media[w];if(S.iceParams?.usernameFragment&&S.iceParams.password){y.iceParams={...S.iceParams};break}}y.dtlsParams.role||(y.dtlsParams=void 0);let v=w=>y.rtp.codecs.find(S=>S.payloadType===w);a.slice(1).forEach(w=>{if(w.startsWith("a=")){let[S,C]=tae(w);if(S==="fmtp"){let[k,T]=bp(C," "),E=v(Number(k));E.parameters=T}else if(S==="rtcp-fb"){let[k,T,E]=C.split(" ");y.rtp.codecs.forEach(I=>{["*",I.payloadType.toString()].includes(k)&&I.rtcpFeedback.push(new pUe({type:T,parameter:E}))})}}})}),i}webrtcTrackId(e){if(e.msid?.includes(" ")){let r=e.msid.split(" ");for(let n of this.msidSemantic)if(n.semantic==="WMS"&&(n.items.includes(r[0])||n.items.includes("*")))return r[1]}}get string(){let e=[`v=${this.version}`,`o=${this.origin}`,`s=${this.name}`];this.host&&e.push(`c=${noe(this.host)}`),e.push(`t=${this.time}`),this.group.forEach(i=>e.push(`a=group:${i.str}`)),this.extMapAllowMixed&&e.push("a=extmap-allow-mixed"),this.msidSemantic.forEach(i=>e.push(`a=msid-semantic:${i.str}`));let r=this.media.map(i=>i.toString()).join("");return e.join(`\r
1118
+ `)),n.forEach(i=>{i.startsWith("m=")?r.push([i]):r.length>0?r[r.length-1].push(i):e.push(i)}),[e,r]}function tae(t){if(t.includes(":")){let e=bp(t.slice(2),":");return[e[0],e[1]]}else return[t.slice(2),void 0]}function iM(t,e,r=n=>n.toString()){let n=e.split(" ");n.length>0&&t.push(new US(n[0],n.slice(1).map(r)))}function Qoe(t){let e=$g.fromSdp(t);return qS(e)}function ioe(t,e){let n=new OU(Q6t(64)).toString().slice(0,8),i=0;e.origin=`- ${n} ${i} IN IP4 0.0.0.0`,e.msidSemantic.push(new US("WMS",["*"])),e.type=t}function H6(t){let e={};return t.split(";").forEach(r=>{if(r.includes("=")){let[n,i]=bp(r,"=");L6t.includes(n)?e[n]=Number(i):e[n]=i}else if(r.includes(":")){let[n,i]=r.split(":");e[n]=Number.isNaN(Number(i))?i:Number(i)}else e[r]=void 0}),e}function R8t(t,e="="){let r=Object.entries(t).map(([n,i])=>i?`${n}${e}${i}`:n);if(r.length>0)return r.join(";")}function pMe(){return{codecs:{audio:[Boe(),Uoe()],video:[Noe()]},headerExtensions:{audio:[],video:[]},iceTransportPolicy:"all",iceServers:[{urls:"stun:stun.l.google.com:19302"}],icePortRange:void 0,iceInterfaceAddresses:void 0,iceAdditionalHostAddresses:void 0,iceUseIpv4:!0,iceUseIpv6:!0,iceFilterStunResponse:void 0,iceFilterCandidatePair:void 0,icePasswordPrefix:void 0,iceUseLinkLocalAddress:void 0,dtls:{},bundlePolicy:"max-compat",debug:{},midSuffix:!1,forceTurnTCP:!1,maxMessageSize:RS}}var ooe,YNe,SM,zS,NS,s7e,a7e,$o,ud,h7e,_v,wp,v7e,Sv,Mg,Av,WS,Lg,Ev,ld,fd,CM,cd,C7e,F7e,boe,WU,Dv,vv,Bh,Nh,Iv,j6,Pae,KU,tUe,cUe,W6,YU,JU,Sp,soe,C6,bM,m3t,g3t,Ug,y3t,v3t,nae,b3t,iae,_3t,OS,S3t,wM,E3t,_n,yr,JNe,EOe,aM,t7e,Uh,I6,oM,n7e,Ep,foe,doe,sae,i7e,hoe,R3t,O3t,Ap,L3t,aae,F6,P6,poe,d7e,af,cM,$3t,p7e,j3t,R6,q3t,z3t,oae,W3t,H3t,V3t,G3t,moe,wv,m7e,X3t,g7e,x7e,G6,uae,Y3t,zse,K6,J3t,Q3t,eDt,AM,Z6,X6,Y6,cDt,uDt,Oa,r6,n6,COe,kOe,DOe,IOe,FOe,EM,TM,MS,uM,_7e,w7e,S7e,fae,A7e,E7e,T7e,k7e,HS,Fv,fDt,D7e,I7e,dDt,hae,R7e,B7e,hDt,U7e,Og,pDt,mDt,gDt,L7e,j7e,z7e,xDt,vDt,_Dt,lM,kp,POe,N6,B6,wDt,LS,$S,kM,G7e,U6,SDt,M6,BS,Z7e,A6,Y7e,J7e,Q7e,ADt,Tv,L6,goe,xoe,Cv,yoe,nBe,EDt,iBe,Os,CDt,voe,Eae,vBe,kDt,bBe,Ng,OOe,NOe,BOe,UOe,MOe,Tp,Cp,ABe,kv,qOe,IDt,FDt,zOe,PDt,Hse,GOe,kBe,i6,ZOe,RDt,ODt,DBe,IBe,NDt,FBe,BDt,qc,UDt,VS,PBe,LDt,XOe,$Dt,Cae,kae,YOe,JOe,Vse,jDt,qDt,QOe,eNe,woe,Gse,Dae,Rh,WDt,tNe,HDt,jS,VDt,J6,ES,RBe,DM,OBe,NBe,_p,Soe,Aoe,Eoe,BBe,UBe,GDt,Toe,Coe,rNe,Iae,koe,a6,o6,XDt,YDt,nNe,iNe,Kse,Zse,Xse,Yse,JDt,QDt,qBe,zBe,sNe,e6t,sf,Doe,HBe,VBe,r6t,Jse,Ioe,aNe,fM,Nu,s6t,a6t,o6t,KBe,XBe,$g,l6t,d6t,Nae,Bae,_6,rUe,Uae,nUe,iUe,h6t,m6t,Gi,fUe,g6t,lNe,Foe,y6t,Poe,Roe,v6t,Q6,GS,e8,hUe,jg,Mh,b6t,pUe,mUe,gUe,Ooe,xUe,Noe,yUe,vUe,Boe,Uoe,Moe,_6t,w6t,hNe,pNe,N6t,LU,mNe,gNe,B6t,U6t,M6t,xNe,jae,yNe,L6t,bUe,vNe,ZU,$6t,_Ue,wUe,SUe,Loe,$oe,joe,XU,q6,EUe,j6t,q6t,Woe,Hoe,W6t,kUe,z6,DUe,Voe,H6t,V6t,FUe,G6t,bNe,K6t,X6t,Y6t,J6t,sd,qae,n8t,Goe,mM,gM,i8t,s8t,a8t,o8t,_Ne,wNe,RUe,u8t,l8t,OUe,BUe,Koe,Zoe,Lh,Xoe,QU,zae,h8t,eM,tM,Wae,Hae,t8,Vae,rM,Kae,GUe,Zae,Xae,YUe,QUe,tMe,p8t,m8t,Yae,sMe,$U,nM,ANe,Di,b8t,_8t,ENe,ad,w6,aMe,toe,TNe,w8t,CNe,kNe,DNe,S8t,A8t,xM,E8t,T8t,INe,FNe,PNe,RNe,C8t,k8t,D8t,I8t,TS,RS,oMe,Yoe,F8t,T6,yM,US,lMe,vM,jU,ece,c6,fMe,O8t,CS,N8t,B8t,rae,UNe,MNe,dMe,M8t,L8t,hMe,u6,$8t,j8t,od,q8t,aoe,z8t,W8t,mMe,H8t,V8t,xMe=ce(()=>{ooe=an($m(),1),YNe=an(k3e(),1),SM=an(XQ(),1),zS=an(pPe(),1),NS=an(Hs(),1),s7e=an(Hs(),1),a7e=an(vO(),1);Y9e();$o=an(Hs(),1),ud=an(Hs(),1),h7e=an(Hs(),1),_v=an(Hs(),1),wp=an(Hs(),1),v7e=an(vO(),1),Sv=an(Hs(),1),Mg=an(Hs(),1),Av=an(Hs(),1),WS=an(Hs(),1),Lg=an(Hs(),1),Ev=an(Hs(),1),ld=an(Hs(),1),fd=an(Hs(),1),CM=an(Hs(),1),cd=an(Hs(),1),C7e=an(Hs(),1),F7e=an(Q9e(),1),boe=an($m(),1),WU=an(tOe(),1),Dv=an(Hs(),1),vv=an(Hs(),1),Bh=an(Hs(),1),Nh=an(Hs(),1),Iv=an(Hs(),1);NU();j6=an(Ise(),1),Pae=an($m(),1);NU();KU=an(k9(),1),tUe=an(AOe(),1),cUe=an(Ise(),1);NU();W6=an(XQ(),1),YU=an($m(),1),JU=an($m(),1),Sp=an($m(),1),soe=an($m(),1);C6=class{constructor(t){this.bitLength=t}value=0;set(t,e,r){return r&=(1<<t)-1,this.value|=r<<this.bitLength-t-e,this}get buffer(){let t=Math.ceil(this.bitLength/8),e=Buffer.alloc(t);return e.writeUIntBE(this.value,0,t),e}},bM=class{constructor(t){if(this.bitLength=t,t>32)throw new Error}_value=0n;offset=0n;set(t,e=1){let r=BigInt(t),n=BigInt(e);return r&=(1n<<n)-1n,this._value|=r<<BigInt(this.bitLength)-n-this.offset,this.offset+=n,this}get value(){return Number(this._value)}get buffer(){let t=Math.ceil(this.bitLength/8),e=Buffer.alloc(t);return e.writeUIntBE(this.value,0,t),e}};m3t=class{buffer;constructor(t){this.buffer=Buffer.alloc(t)}writeInt16BE(t,e){return this.buffer.writeInt16BE(t,e),this}writeUInt8(t,e){return this.buffer.writeUInt8(t,e),this}},g3t=t=>"0x"+t.toString("hex").replace(/(.)(.)/g,"$1$2 ").split(" ").filter(e=>e!=null&&e.length>0).join(",0x");Ug=class{constructor(t){this.uint8Array=t}position=0;bitsPending=0;writeBits(t,e){if(t==0)return this;e&=4294967295>>>32-t;let r;return this.bitsPending>0?this.bitsPending>t?(this.uint8Array[this.position-1]|=e<<this.bitsPending-t,r=t,this.bitsPending-=t):this.bitsPending==t?(this.uint8Array[this.position-1]|=e,r=t,this.bitsPending=0):(this.uint8Array[this.position-1]|=e>>t-this.bitsPending,r=this.bitsPending,this.bitsPending=0):(r=Math.min(8,t),this.bitsPending=8-r,this.uint8Array[this.position++]=e>>t-r<<this.bitsPending),t-=r,t>0&&this.writeBits(t,e),this}readBits(t){return this._readBits(t)}_readBits(t,e){if(typeof e>"u"&&(e=0),t==0)return e;let r,n;if(this.bitsPending>0){let i=this.uint8Array[this.position-1]&255>>8-this.bitsPending;n=Math.min(this.bitsPending,t),this.bitsPending-=n,r=i>>this.bitsPending}else n=Math.min(8,t),this.bitsPending=8-n,r=this.uint8Array[this.position++]>>this.bitsPending;return t-=n,e=e<<n|r,t>0?this._readBits(t,e):e}seekTo(t){this.position=t/8|0,this.bitsPending=t%8,this.bitsPending>0&&(this.bitsPending=8-this.bitsPending,this.position++)}},y3t=3988292384,v3t=2197175160;nae=qNe(y3t),b3t=zNe(nae),iae=qNe(v3t),_3t=zNe(iae);OS=t=>Number.parseInt(t,10),S3t=class{queue=[];running=!1;push=t=>new Promise((e,r)=>{this.queue.push({promise:t,done:e,failed:r}),this.running||this.run()});async run(){let t=this.queue.shift();if(t){this.running=!0;try{let e=await t.promise();t.done(e)}catch(e){t.failed(e)}this.run()}else this.running=!1}cancel(){this.queue=[]}},wM=(t,e)=>e?e[t]:void 0;E3t=class extends Error{message;payload;path;constructor(t){super(t.message)}toJSON(){return{message:this.message,payload:JSON.parse(JSON.stringify(this.payload)),path:this.path}}},_n=YNe.default.debug,yr=class{event={stack:[],promiseStack:[],eventId:0};ended=!1;onended;onerror=t=>{};execute=(...t)=>{if(!this.ended){for(let e of this.event.stack)e.execute(...t);(async()=>{for(let e of this.event.promiseStack)await e.execute(...t)})().catch(e=>{this.onerror(e)})}};complete=()=>{if(!this.ended){for(let t of this.event.stack)t.complete&&t.complete();this.allUnsubscribe(),this.ended=!0,this.onended&&(this.onended(),this.onended=void 0)}};error=t=>{if(!this.ended){for(let e of this.event.stack)e.error&&e.error(t);this.allUnsubscribe()}};allUnsubscribe=()=>{if(this.ended)throw new Error("event completed");this.event={stack:[],promiseStack:[],eventId:0}};subscribe=(t,e,r)=>{let n=this.event.eventId;this.event.stack.push({execute:t,id:n,complete:e,error:r}),this.event.eventId++;let i=()=>{this.event.stack=this.event.stack.filter(a=>a.id!==n&&a)};return{unSubscribe:i,disposer:a=>{a.push(i)}}};pipe(t){this.subscribe((...e)=>{t.execute(...e)})}queuingSubscribe=(t,e,r)=>{if(this.ended)throw new Error("event completed");let n=this.event.eventId;this.event.promiseStack.push({execute:t,id:n,complete:e,error:r}),this.event.eventId++;let i=()=>{this.event.stack=this.event.stack.filter(a=>a.id!==n&&a)};return{unSubscribe:i,disposer:a=>{a.push(i)}}};once=(t,e,r)=>{let n=this.subscribe((...i)=>{n.unSubscribe(),t(...i)},e,r)};watch=(t,e)=>new Promise((r,n)=>{let i=e&&setTimeout(()=>{n("Event watch timeout")},e),{unSubscribe:s}=this.subscribe((...a)=>{t(...a)&&(i&&clearTimeout(i),s(),r(a))})});asPromise=t=>new Promise((e,r)=>{let n=t&&setTimeout(()=>{r("Event asPromise timeout")},t);this.once((...i)=>{n&&clearTimeout(n),e(i)},()=>{n&&clearTimeout(n),e([])},i=>{n&&clearTimeout(n),r(i)})});get returnTrigger(){let{execute:t,error:e,complete:r}=this;return{execute:t,error:e,complete:r}}get returnListener(){let{subscribe:t,once:e,asPromise:r}=this;return{subscribe:t,once:e,asPromise:r}}get length(){return this.event.stack.length}},JNe=class{_disposer=[];push(t){this._disposer.push(t)}dispose(){this._disposer.forEach(t=>t()),this._disposer=[]}},EOe=_n("werift-ice:packages/ice/src/transport.ts"),aM=class e7e{constructor(e,r={}){this.socketType=e,this.options=r,this.socket=T3t(e),this.socket.on("message",(n,i)=>{D6(i.family)===6&&([i.address]=i.address.split("%")),this.rinfo=i;try{this.onData(n,[i.address,i.port])}catch(s){EOe("onData error",s)}})}type="udp";socket;rinfo;onData=()=>{};closed=!1;static async init(e,r={}){let n=new e7e(e,r);return await n.init(),n}async init(){let e=wM(this.socketType,this.options.interfaceAddresses);if(this.options.port)this.socket.bind({port:this.options.port,address:e});else if(this.options.portRange){let r=await XNe(this.options.portRange[0],this.options.portRange[1],this.socketType,this.options.interfaceAddresses);this.socket.bind({port:r,address:e})}else this.socket.bind({address:e});await new Promise(r=>this.socket.once("listening",r))}send=async(e,r)=>{if(r&&!QNe.isIP(r[0]))return new Promise((n,i)=>{this.socket.send(e,r[1],r[0],s=>{s?(EOe("send error",r,e),i(s)):n()})});r=r??[this.rinfo?.address,this.rinfo?.port],this.socket.send(e,r[1],r[0])};get address(){return this.socket.address()}get host(){return this.socket.address().address}get port(){return this.socket.address().port}close=()=>new Promise(e=>{this.closed=!0,this.socket.once("close",e);try{this.socket.close()}catch{e()}})},t7e=class r7e{constructor(e){this.addr=e,this.connect()}type="tcp";connecting;client;onData=()=>{};closed=!1;connect(){this.closed||(this.client&&this.client.destroy(),this.connecting=new Promise((e,r)=>{try{this.client=C3t({port:this.addr[1],host:this.addr[0]},e)}catch(n){r(n)}}),this.client.on("data",e=>{let r=[this.client.remoteAddress,this.client.remotePort];this.onData(e,r)}),this.client.on("end",()=>{this.connect()}),this.client.on("error",e=>{console.log("error",e)}))}async init(){await this.connecting}static async init(e){let r=new r7e(e);return await r.init(),r}get address(){return{}}send=async(e,r)=>{await this.connecting,this.client.write(e,n=>{n&&console.log("err",n)})};close=async()=>{this.closed=!0,this.client.destroy()}},Uh={rsa_1:1,ecdsa_3:3},I6={sha256_4:4},oM={TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_49195:49195,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256_49199:49199},n7e=Object.values(oM),Ep={x25519_29:29,secp256r1_23:23},foe=Object.values(Ep),doe={named_curve_3:3},sae={rsa_pkcs1_sha256:1025,ecdsa_secp256r1_sha256:1027},i7e=[1,64],hoe=[{hash:I6.sha256_4,signature:Uh.rsa_1},{hash:I6.sha256_4,signature:Uh.ecdsa_3}],R3t=()=>{let t=FU.utils.randomPrivateKey(),e=FU.getPublicKey(t,!1),r=Buffer.from(t),n=Buffer.from(e);return{privateKey:r,publicKey:n}},O3t=({publicKey:t,privateKey:e})=>{let r=FU.getSharedSecret(e,t);return Buffer.from(r).subarray(1)};Ap={CLIENT:1,SERVER:2},L3t=class{id=0;name;hashAlgorithm;verifyDataLength=12;blockAlgorithm;kx;init(...t){throw new Error("not implemented")}encrypt(...t){throw new Error("not implemented")}decrypt(...t){throw new Error("not implemented")}toString(){return this.name}},aae=I3t;zS.cryptoProvider.set(aae);F6=class{constructor(t,e,r,n){this.sessionType=t,this.certPem=e,this.keyPem=r,e&&r&&n&&this.parseX509(e,r,n)}localRandom;remoteRandom;cipherSuite;remoteCertificate;remoteKeyPair;localKeyPair;masterSecret;cipher;namedCurve;signatureHashAlgorithm;localCert;localPrivateKey;static createSelfSignedCertificateWithKey=async(t,e)=>{let r=(()=>{switch(t.signature){case Uh.rsa_1:return"RSASSA-PKCS1-v1_5";case Uh.ecdsa_3:return"ECDSA"}})(),n=(()=>{if(t.hash===I6.sha256_4)return"SHA-256"})(),i=(()=>{switch(e){case Ep.secp256r1_23:return"P-256";case Ep.x25519_29:return r==="ECDSA"?"P-256":"X25519";default:{if(r==="ECDSA")return"P-256";if(r==="RSASSA-PKCS1-v1_5")return"X25519"}}})(),s=(()=>{switch(r){case"ECDSA":return{name:r,hash:n,namedCurve:i};case"RSASSA-PKCS1-v1_5":return{name:r,hash:n,publicExponent:new Uint8Array([1,0,1]),modulusLength:2048}}})(),a=await aae.subtle.generateKey(s,!0,["sign","verify"]),d=(await zS.X509CertificateGenerator.createSelfSigned({serialNumber:D3t(8).toString("hex"),name:"C=AU, ST=Some-State, O=Internet Widgits Pty Ltd",notBefore:new Date,notAfter:new Date(Date.now()+10*365*24*60*60*1e3),signingAlgorithm:s,keys:a})).toString("pem"),h=zS.PemConverter.encode(await aae.subtle.exportKey("pkcs8",a.privateKey),"private key");return{certPem:d,keyPem:h,signatureHash:t}};encryptPacket(t){let e=t.recordLayerHeader,r=e.protocolVersion.major<<8|e.protocolVersion.minor,n=this.cipher.encrypt(this.sessionType,t.fragment,{type:e.contentType,version:r,epoch:e.epoch,sequenceNumber:e.sequenceNumber});return t.fragment=n,t.recordLayerHeader.contentLen=n.length,t}decryptPacket(t){let e=t.recordLayerHeader,r=e.protocolVersion.major<<8|e.protocolVersion.minor;return this.cipher.decrypt(this.sessionType,t.fragment,{type:e.contentType,version:r,epoch:e.epoch,sequenceNumber:e.sequenceNumber})}verifyData(t){return this.sessionType===Ap.CLIENT?B3t(this.masterSecret,t):U3t(this.masterSecret,t)}signatureData(t,e){let r=k3t(e).update(t),n=this.localPrivateKey.toPEM().toString();return r.sign(n)}generateKeySignature(t){let e=this.sessionType===Ap.CLIENT?this.localRandom:this.remoteRandom,r=this.sessionType===Ap.SERVER?this.localRandom:this.remoteRandom,n=this.valueKeySignature(e.serialize(),r.serialize(),this.localKeyPair.publicKey,this.namedCurve);return this.localPrivateKey.sign(n,t)}parseX509(t,e,r){let n=SM.Certificate.fromPEM(Buffer.from(t)),i=SM.PrivateKey.fromPEM(Buffer.from(e));this.localCert=n.raw,this.localPrivateKey=i,this.signatureHashAlgorithm=r}valueKeySignature(t,e,r,n){let i=Buffer.from((0,NS.encode)({type:doe.named_curve_3,curve:n,len:r.length},{type:NS.types.uint8,curve:NS.types.uint16be,len:NS.types.uint8}).slice());return Buffer.concat([t,e,i,r])}},P6=class{srtpProfile;static findMatchingSRTPProfile(t,e){for(let r of e)if(t.includes(r))return r}},poe=t=>"0x"+t.toString("hex").replace(/(.)(.)/g,"$1$2 ").split(" ").filter(e=>e!=null&&e.length>0).join(",0x"),d7e=t=>Object.entries({...t}).reduce((e,[r,n])=>((typeof n=="number"||typeof n=="string")&&(e[r]=n),Buffer.isBuffer(n)&&(e[r]=poe(n)),e),{}),af=class Fg{constructor(e,r,n,i,s,a){this.msg_type=e,this.length=r,this.message_seq=n,this.fragment_offset=i,this.fragment_length=s,this.fragment=a}static spec={msg_type:ud.types.uint8,length:ud.types.uint24be,message_seq:ud.types.uint16be,fragment_offset:ud.types.uint24be,fragment_length:ud.types.uint24be,fragment:ud.types.buffer(e=>e.current.fragment_length)};get summary(){return d7e(this)}static createEmpty(){return new Fg(void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new Fg(...Object.values((0,ud.decode)(e,Fg.spec)))}serialize(){let e=(0,ud.encode)(this,Fg.spec).slice();return Buffer.from(e)}chunk(e){let r=0,n=this.fragment.length;if(n===0)return[new Fg(this.msg_type,n,this.message_seq,r,0,this.fragment)];let i=[];for(e||(e=1240);r<n;){let s=Math.min(e,n-r),a=Buffer.from(this.fragment.slice(r,r+s));if(a.length<=0)throw new Error("Zero or less bytes processed while fragmenting handshake message.");i.push(new Fg(this.msg_type,n,this.message_seq,r,a.length,a)),r+=a.length}return i}static assemble(e){if(!e?.length)throw new Error("cannot reassemble handshake from empty array");e=e.sort((n,i)=>n.fragment_offset-i.fragment_offset);let r=Buffer.alloc(e[0].length);for(let n of e)n.fragment.copy(r,n.fragment_offset);return new Fg(e[0].msg_type,e[0].length,e[0].message_seq,0,r.length,r)}static findAllFragments(e,r){let n=e.find(i=>i.msg_type===r);return n?e?.length?e.filter(i=>i.msg_type===n.msg_type&&i.message_seq===n.message_seq&&i.length===n.length):[]:[]}},{uint16be:cM,uint24be:$3t,buffer:p7e,array:j3t,uint8:R6,string:q3t}=h7e.types,z3t={type:cM,data:p7e(cM)},oae=j3t(z3t,cM,"bytes"),W3t=p7e($3t),H3t=R6,V3t=q3t(cM),G3t={hash:R6,signature:R6},moe={major:R6,minor:R6},wv=class l6{constructor(e=Math.floor(Date.now()/1e3),r=K3t(28)){this.gmt_unix_time=e,this.random_bytes=r}static spec={gmt_unix_time:_v.types.uint32be,random_bytes:_v.types.buffer(28)};static deSerialize(e){return new l6(...Object.values((0,_v.decode)(e,l6.spec)))}static from(e){return new l6(...Object.values(e))}serialize(){let e=(0,_v.encode)(this,l6.spec).slice();return Buffer.from(e)}},m7e=class f6{constructor(e,r,n,i,s,a,c){this.clientVersion=e,this.random=r,this.sessionId=n,this.cookie=i,this.cipherSuites=s,this.compressionMethods=a,this.extensions=c}msgType=1;messageSeq=0;static spec={clientVersion:{major:$o.types.uint8,minor:$o.types.uint8},random:wv.spec,sessionId:$o.types.buffer($o.types.uint8),cookie:$o.types.buffer($o.types.uint8),cipherSuites:$o.types.array($o.types.uint16be,$o.types.uint16be,"bytes"),compressionMethods:$o.types.array($o.types.uint8,$o.types.uint8,"bytes"),extensions:oae};static createEmpty(){return new f6(void 0,void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new f6(...Object.values((0,$o.decode)(e,f6.spec)))}serialize(){let e=(0,$o.encode)(this,f6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},X3t=class d6{constructor(e,r,n,i,s){this.epoch=e,this.sequenceNumber=r,this.contentType=n,this.protocolVersion=i,this.contentLen=s}static spec={epoch:wp.types.uint16be,sequenceNumber:wp.types.uint48be,contentType:wp.types.uint8,protocolVersion:moe,contentLen:wp.types.uint16be};static createEmpty(){return new d6(void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){return new d6(...Object.values((0,wp.decode)(e,d6.spec)))}serialize(){let e=(0,wp.encode)(this,d6.spec).slice();return Buffer.from(e)}},g7e=class cae{constructor(e,r){this.recordLayerHeader=e,this.fragment=r}get summary(){return{header:this.recordLayerHeader,fragment:poe(this.fragment)}}static createEmpty(){return new cae(void 0,void 0)}static deSerialize(e){if(e.length<13)throw new Error("Invalid DTLS record: buffer is too short");let r=e.readUInt8(0),n=e.readUInt8(1),i=e.readUInt8(2),s=e.readUInt16BE(3),a=e.slice(5,11).readUIntBE(0,6),c=e.readUInt16BE(11);if(e.length<13+c)throw new Error("Invalid DTLS record: fragment length exceeds buffer");let d=e.slice(13,13+c);return new cae({contentType:r,protocolVersion:{major:n,minor:i},epoch:s,sequenceNumber:a,contentLen:c},d)}serialize(){let e=this.fragment.length,r=13+e,n=Buffer.alloc(r);return n.writeUInt8(this.recordLayerHeader.contentType,0),n.writeUInt8(this.recordLayerHeader.protocolVersion.major,1),n.writeUInt8(this.recordLayerHeader.protocolVersion.minor,2),n.writeUInt16BE(this.recordLayerHeader.epoch,3),n.writeUIntBE(this.recordLayerHeader.sequenceNumber,5,6),n.writeUInt16BE(e,11),this.fragment.copy(n,13),n}computeMACHeader(){return new X3t(this.recordLayerHeader.epoch,this.recordLayerHeader.sequenceNumber,this.recordLayerHeader.contentType,this.recordLayerHeader.protocolVersion,this.recordLayerHeader.contentLen).serialize()}},x7e=t=>e=>(t.lastFlight=e,e.flatMap(r=>(r.messageSeq=t.sequenceNumber++,r.toFragment().chunk()))),G6=t=>(e,r)=>e.map(n=>new g7e({contentType:n.type,protocolVersion:t.version,epoch:t.epoch,sequenceNumber:r,contentLen:n.fragment.length},n.fragment)),uae=(t=>(t[t.CloseNotify=0]="CloseNotify",t[t.UnexpectedMessage=10]="UnexpectedMessage",t[t.BadRecordMac=20]="BadRecordMac",t[t.DecryptionFailed=21]="DecryptionFailed",t[t.RecordOverflow=22]="RecordOverflow",t[t.DecompressionFailure=30]="DecompressionFailure",t[t.HandshakeFailure=40]="HandshakeFailure",t[t.NoCertificate=41]="NoCertificate",t[t.BadCertificate=42]="BadCertificate",t[t.UnsupportedCertificate=43]="UnsupportedCertificate",t[t.CertificateRevoked=44]="CertificateRevoked",t[t.CertificateExpired=45]="CertificateExpired",t[t.CertificateUnknown=46]="CertificateUnknown",t[t.IllegalParameter=47]="IllegalParameter",t[t.UnknownCa=48]="UnknownCa",t[t.AccessDenied=49]="AccessDenied",t[t.DecodeError=50]="DecodeError",t[t.DecryptError=51]="DecryptError",t[t.ExportRestriction=60]="ExportRestriction",t[t.ProtocolVersion=70]="ProtocolVersion",t[t.InsufficientSecurity=71]="InsufficientSecurity",t[t.InternalError=80]="InternalError",t[t.UserCanceled=90]="UserCanceled",t[t.NoRenegotiation=100]="NoRenegotiation",t[t.UnsupportedExtension=110]="UnsupportedExtension",t))(uae||{}),Y3t=_n("werift-dtls : packages/dtls/src/flight/flight.ts : warn"),zse=_n("werift-dtls : packages/dtls/src/flight/flight.ts : err"),K6=class lae{constructor(e,r,n,i){this.transport=e,this.dtls=r,this.flight=n,this.nextFlight=i}state="PREPARING";static RetransmitCount=10;createPacket(e){let r=x7e(this.dtls)(e);return this.dtls.bufferHandshakeCache(r,!0,this.flight),G6(this.dtls)(r.map(i=>({type:22,fragment:i.serialize()})),++this.dtls.recordSequenceNumber)}async transmit(e){let r=0;for(;r<=lae.RetransmitCount;r++){if(this.setState("SENDING"),this.send(e).catch(n=>{zse("fail to send",zse)}),this.setState("WAITING"),this.nextFlight===void 0){this.setState("FINISHED");break}if(await Z3t(1e3*((r+1)/2)),this.dtls.flight>=this.nextFlight){this.setState("FINISHED");break}else Y3t(this.dtls.sessionId,"retransmit",r,this.dtls.flight)}if(r>lae.RetransmitCount)throw zse(this.dtls.sessionId,"retransmit failed",r),new Error(`over retransmitCount : ${this.flight} ${this.nextFlight}`)}send=e=>Promise.all(e.map(r=>this.transport.send(r)));setState(e){this.state=e}},J3t=class extends K6{constructor(t,e,r){super(t,e,1,3),this.cipher=r}async exec(t){if(this.dtls.flight===1)throw new Error;this.dtls.flight=1;let e=new m7e({major:254,minor:253},new wv,Buffer.from([]),Buffer.from([]),n7e,[0],t);this.dtls.version=e.clientVersion,this.cipher.localRandom=wv.from(e.random);let r=this.createPacket([e]),n=Buffer.concat(r.map(i=>i.serialize()));await this.transmit([n])}},Q3t=_n("werift-dtls : packages/dtls/src/flight/client/flight3.ts : log"),eDt=class extends K6{constructor(t,e){super(t,e,3,5)}async exec(t){if(this.dtls.flight===3)throw new Error;this.dtls.flight=3,this.dtls.handshakeCache=[];let[e]=this.dtls.lastFlight;Q3t("dtls version",e.clientVersion),e.cookie=t.cookie,this.dtls.cookie=t.cookie;let r=this.createPacket([e]),n=Buffer.concat(r.map(i=>i.serialize()));await this.transmit([n])}},AM={NULL:0,ECDHE:1},Z6={NULL:0,RSA:1,ECDSA:2,PSK:3},X6={NULL:0,RSA:1,ECDHE_RSA:2,ECDHE_ECDSA:3,PSK:4,ECDHE_PSK:5},Y6=class{id=0;name;signType;keyType;toString(){return this.name}};cDt=_n("werift-dtls : packages/dtls/src/cipher/suites/aead.ts : err"),uDt=class extends L3t{keyLength=0;nonceLength=0;ivLength=0;authTagLength=0;nonceImplicitLength=0;nonceExplicitLength=0;clientWriteKey;serverWriteKey;clientNonce;serverNonce;constructor(){super()}get summary(){return d7e(this)}init(t,e,r){let n=M3t(t,r,e,this.keyLength,this.ivLength,this.nonceLength,this.hashAlgorithm);this.clientWriteKey=n.clientWriteKey,this.serverWriteKey=n.serverWriteKey,this.clientNonce=n.clientNonce,this.serverNonce=n.serverNonce}encrypt(t,e,r){let n=t===Ap.CLIENT,i=n?this.clientNonce:this.serverNonce,s=n?this.clientWriteKey:this.serverWriteKey;if(!i||!s)throw new Error;i.writeUInt16BE(r.epoch,this.nonceImplicitLength),i.writeUIntBE(r.sequenceNumber,this.nonceImplicitLength+2,6);let a=i.slice(this.nonceImplicitLength),c=this.encodeAdditionalBuffer(r,e.length),d=aDt(this.blockAlgorithm,s,i,{authTagLength:this.authTagLength});d.setAAD(c,{plaintextLength:e.length});let h=d.update(e),p=d.final(),x=d.getAuthTag();return Buffer.concat([a,h,p,x])}encodeAdditionalBuffer(t,e){let r=Buffer.alloc(13);return r.writeUInt16BE(t.epoch,0),r.writeUintBE(t.sequenceNumber,2,6),r.writeUInt8(t.type,8),r.writeUInt16BE(t.version,9),r.writeUInt16BE(e,11),r}decrypt(t,e,r){let n=t===Ap.CLIENT,i=n?this.serverNonce:this.clientNonce,s=n?this.serverWriteKey:this.clientWriteKey;if(!i||!s)throw new Error;e.subarray(0,this.nonceExplicitLength).copy(i,this.nonceImplicitLength);let c=e.subarray(this.nonceExplicitLength,e.length-this.authTagLength),d=e.subarray(e.length-this.authTagLength),h=this.encodeAdditionalBuffer(r,c.length),p=oDt(this.blockAlgorithm,s,i,{authTagLength:this.authTagLength});p.setAuthTag(d),p.setAAD(h,{plaintextLength:c.length});let x=p.update(c);try{let y=p.final();return y.length>0?Buffer.concat([x,y]):x}catch(y){throw cDt("decrypt failed",y,t,poe(e),r,this.summary),y}}},Oa={TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:49195,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:49196,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:49199,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:49200,TLS_RSA_WITH_AES_128_GCM_SHA256:156,TLS_RSA_WITH_AES_256_GCM_SHA384:157,TLS_PSK_WITH_AES_128_GCM_SHA256:168,TLS_PSK_WITH_AES_256_GCM_SHA384:169,TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256:53249,TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384:53250,TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:52396,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:52393,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:52392,TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:52395},r6={K_LEN:16,N_MIN:12,N_MAX:12,P_MAX:2**36-31,A_MAX:2**53-1,C_MAX:2**36-15},n6={K_LEN:32,N_MIN:12,N_MAX:12,P_MAX:2**36-31,A_MAX:2**53-1,C_MAX:2**36-15},COe=tDt(),kOe=rDt(),DOe=nDt(),IOe=iDt(),FOe=sDt();EM=class{static type=23},TM=class kS{static type=65281;static spec={type:Sv.types.uint16be,data:Sv.types.uint8};type=kS.type;data=0;constructor(e={}){Object.assign(this,e)}static createEmpty(){return new kS}static deSerialize(e){return new kS((0,Sv.decode)(e,kS.spec))}serialize(){let e=(0,Sv.encode)(this,kS.spec).slice();return Buffer.from(e)}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},MS=class Pg{static type=14;static spec={type:Mg.types.uint16be,data:Mg.types.buffer(Mg.types.uint16be)};type=Pg.type;data=Buffer.from([]);profiles=[];mki=Buffer.from([0]);constructor(e={}){Object.assign(this,e)}static create(e,r){return new Pg({profiles:e,mki:r})}static deSerialize(e){let r=new Pg((0,Mg.decode)(e,Pg.spec)),n=r.data.readUInt16BE(),i=new Array(n/2);for(let s=0;s<i.length;s++)i[s]=r.data.readUInt16BE(s*2+2);return r.profiles=i,r.mki=r.data.slice(n+2),r}serialize(){let e=Buffer.alloc(2);e.writeUInt16BE(this.profiles.length*2);let r=Buffer.concat([e,...this.profiles.map(i=>{let s=Buffer.alloc(2);return s.writeUInt16BE(i),s}),this.mki]);this.data=r;let n=(0,Mg.encode)(this,Pg.spec).slice();return Buffer.from(n)}static fromData(e){let r=Buffer.alloc(4);return r.writeUInt16BE(Pg.type),r.writeUInt16BE(e.length,2),Pg.deSerialize(Buffer.concat([r,e]))}get extension(){return{type:this.type,data:this.serialize().slice(4)}}},uM=class h6{constructor(e){this.certificateList=e}msgType=11;messageSeq;static spec={certificateList:Av.types.array(W3t,Av.types.uint24be,"bytes")};static createEmpty(){return new h6(void 0)}static deSerialize(e){return new h6(...Object.values((0,Av.decode)(e,h6.spec)))}serialize(){let e=(0,Av.encode)(this,h6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},_7e=class p6{constructor(e=1){this.type=e}static spec={type:WS.types.uint8};static createEmpty(){return new p6}static deSerialize(e){return new p6(...Object.values((0,WS.decode)(e,p6.spec)))}serialize(){let e=(0,WS.encode)(this,p6.spec).slice();return Buffer.from(e)}},w7e=class m6{constructor(e,r){this.algorithm=e,this.signature=r}msgType=15;messageSeq;static spec={algorithm:Lg.types.uint16be,signature:Lg.types.buffer(Lg.types.uint16be)};static createEmpty(){return new m6(void 0,void 0)}static deSerialize(e){let r=(0,Lg.decode)(e,m6.spec);return new m6(...Object.values(r))}serialize(){let e=(0,Lg.encode)(this,m6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},S7e=class g6{constructor(e){this.publicKey=e}msgType=16;messageSeq;static spec={publicKey:Ev.types.buffer(Ev.types.uint8)};static createEmpty(){return new g6(void 0)}static deSerialize(e){let r=(0,Ev.decode)(e,g6.spec);return new g6(...Object.values(r))}serialize(){let e=(0,Ev.encode)(this,g6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},fae=class dae{constructor(e){this.verifyData=e}msgType=20;messageSeq;static createEmpty(){return new dae(void 0)}static deSerialize(e){return new dae(e)}serialize(){return this.verifyData}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},A7e=class x6{constructor(e,r,n){this.certificateTypes=e,this.signatures=r,this.authorities=n}msgType=13;messageSeq;static spec={certificateTypes:ld.types.array(H3t,ld.types.uint8,"bytes"),signatures:ld.types.array(G3t,ld.types.uint16be,"bytes"),authorities:ld.types.array(V3t,ld.types.uint16be,"bytes")};static createEmpty(){return new x6(void 0,void 0,void 0)}static deSerialize(e){return new x6(...Object.values((0,ld.decode)(e,x6.spec)))}serialize(){let e=(0,ld.encode)(this,x6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},E7e=class Rg{constructor(e,r,n,i,s,a){this.serverVersion=e,this.random=r,this.sessionId=n,this.cipherSuite=i,this.compressionMethod=s,this.extensions=a}msgType=2;messageSeq;static spec={serverVersion:moe,random:wv.spec,sessionId:fd.types.buffer(fd.types.uint8),cipherSuite:fd.types.uint16be,compressionMethod:fd.types.uint8};static createEmpty(){return new Rg(void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){let r=(0,fd.decode)(e,Rg.spec),n=new Rg(...Object.values(r));return n.serialize().length<e.length?new Rg(...Object.values((0,fd.decode)(e,{...Rg.spec,extensions:oae}))):n}serialize(){let e=this.extensions===void 0?(0,fd.encode)(this,Rg.spec).slice():(0,fd.encode)(this,{...Rg.spec,extensions:oae}).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},T7e=class y6{msgType=14;messageSeq;static spec={};static createEmpty(){return new y6}static deSerialize(e){return new y6(...Object.values((0,CM.decode)(e,y6.spec)))}serialize(){let e=(0,CM.encode)(this,y6.spec).slice();return Buffer.from(e)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}};k7e=class v6{constructor(e,r,n,i,s,a,c,d){this.ellipticCurveType=e,this.namedCurve=r,this.publicKeyLength=n,this.publicKey=i,this.hashAlgorithm=s,this.signatureAlgorithm=a,this.signatureLength=c,this.signature=d}msgType=12;messageSeq;static spec={ellipticCurveType:cd.types.uint8,namedCurve:cd.types.uint16be,publicKeyLength:cd.types.uint8,publicKey:cd.types.buffer(e=>e.current.publicKeyLength),hashAlgorithm:cd.types.uint8,signatureAlgorithm:cd.types.uint8,signatureLength:cd.types.uint16be,signature:cd.types.buffer(e=>e.current.signatureLength)};static createEmpty(){return new v6(void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0)}static deSerialize(e){let r=(0,cd.decode)(e,v6.spec);return new v6(...Object.values(r))}serialize(){return lDt(this,v6.spec)}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},HS=1,Fv=7,fDt=[HS,Fv],D7e=t=>{switch(t){case HS:case Fv:return 16}},I7e=t=>{switch(t){case HS:return 14;case Fv:return 12}},dDt=_n("werift-rtp : packages/rtp/src/codec/av1.ts"),hae=class P7e{zBit_RtpStartsWithFragment;yBit_RtpEndsWithFragment;w_RtpNumObus;nBit_RtpStartsNewCodedVideoSequence;obu_or_fragment=[];static deSerialize=e=>{let r=new P7e,n=0;if(r.zBit_RtpStartsWithFragment=ir(e[n],0),r.yBit_RtpEndsWithFragment=ir(e[n],1),r.w_RtpNumObus=ir(e[n],2,2),r.nBit_RtpStartsNewCodedVideoSequence=ir(e[n],4),n++,r.nBit_RtpStartsNewCodedVideoSequence&&r.zBit_RtpStartsWithFragment)throw new Error;[...Array(r.w_RtpNumObus-1).keys()].forEach(s=>{let[a,c]=N7e(e.subarray(n)),d=n+c,h=d+a,p=!1;r.zBit_RtpStartsWithFragment&&s===0&&(p=!0),r.obu_or_fragment.push({data:e.subarray(d,h),isFragment:p}),n+=c+a});let i=!1;return(r.yBit_RtpEndsWithFragment||r.w_RtpNumObus===1&&r.zBit_RtpStartsWithFragment)&&(i=!0),r.obu_or_fragment.push({data:e.subarray(n),isFragment:i}),r};static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.nBit_RtpStartsNewCodedVideoSequence===1}static getFrame(e){let r=[],n=e.flatMap(c=>c.obu_or_fragment).reduce((c,d,h)=>(c[h]=d,c),{}),i=Object.keys(n).length;for(let c of Object.keys(n).map(Number)){let d=n[c];if(!d)continue;let{data:h,isFragment:p}=d;if(p){let x=[];for(let y=c;y<i;y++){let v=n[y];if(v.isFragment)x.push(v.data),delete n[y];else break}x.length<=1&&(dDt("fragment lost, maybe packet lost"),x=[]),r.push(Buffer.concat(x))}else r.push(h)}let s=r.map(c=>R7e.deSerialize(c)),a=s.pop();return Buffer.concat([...s.map(c=>(c.obu_has_size_field=1,c.serialize())),a.serialize()])}},R7e=class O7e{obu_forbidden_bit;obu_type;obu_extension_flag;obu_has_size_field;obu_reserved_1bit;payload;static deSerialize(e){let r=new O7e,n=0;return r.obu_forbidden_bit=ir(e[n],0),r.obu_type=B7e[ir(e[n],1,4)],r.obu_extension_flag=ir(e[n],5),r.obu_has_size_field=ir(e[n],6),r.obu_reserved_1bit=ir(e[n],7),n++,r.payload=e.subarray(n),r}serialize(){let e=new bM(8).set(this.obu_forbidden_bit).set(hDt[this.obu_type],4).set(this.obu_extension_flag).set(this.obu_has_size_field).set(this.obu_reserved_1bit).buffer,r=Buffer.alloc(0);return this.obu_has_size_field&&(r=F7e.LEB128.encode(this.payload.length)),Buffer.concat([e,r,this.payload])}};B7e={0:"Reserved",1:"OBU_SEQUENCE_HEADER",2:"OBU_TEMPORAL_DELIMITER",3:"OBU_FRAME_HEADER",4:"OBU_TILE_GROUP",5:"OBU_METADATA",6:"OBU_FRAME",7:"OBU_REDUNDANT_FRAME_HEADER",8:"OBU_TILE_LIST",15:"OBU_PADDING"},hDt=Object.entries(B7e).reduce((t,[e,r])=>(t[r]=Number(e),t),{}),U7e=class M7e{f;nri;nalUnitType;s;e;r;nalUnitPayloadType;payload;fragment;static deSerialize(e,r){let n=new M7e,i=0,s=e[i];if(n.f=ir(s,0),n.nri=ir(s,1,2),n.nalUnitType=ir(s,3,5),i++,n.s=ir(e[i],0),n.e=ir(e[i],1),n.r=ir(e[i],2),n.nalUnitPayloadType=ir(e[i],3,5),i++,0<n.nalUnitType&&n.nalUnitType<Og.stap_a)n.payload=this.packaging(e);else if(n.nalUnitType===Og.stap_a){let a=mDt,c=Buffer.alloc(0);for(;a<e.length;){let d=e.readUInt16BE(a);a+=gDt,c=Buffer.concat([c,this.packaging(e.subarray(a,a+d))]),a+=d}n.payload=c}else if(n.nalUnitType===Og.fu_a){r||(r=Buffer.alloc(0));let a=e.subarray(i);if(n.fragment=Buffer.concat([r,a]),n.e){let c=new Ug(Buffer.alloc(1)).writeBits(1,0).writeBits(2,n.nri).writeBits(5,n.nalUnitPayloadType),d=Buffer.concat([c.uint8Array,n.fragment]);n.fragment=void 0,n.payload=this.packaging(d)}}return n}static packaging(e){return Buffer.concat([pDt,e])}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.nalUnitType===Og.idrSlice||this.nalUnitPayloadType===Og.idrSlice}get isPartitionHead(){return this.nalUnitType===Og.fu_a||this.nalUnitType===Og.fu_b?this.s!==0:!0}},Og={idrSlice:5,stap_a:24,stap_b:25,mtap16:26,mtap24:27,fu_a:28,fu_b:29},pDt=Buffer.from([0,0,0,1]),mDt=1,gDt=2,L7e=class $7e{payload;static deSerialize(e){let r=new $7e;return r.payload=e,r}static isDetectedFinalPacketInSequence(e){return!0}get isKeyframe(){return!0}static createCodecPrivate(e=48e3){return Buffer.concat([Buffer.from("OpusHead"),Vs([1,1],[1,2]),$Ne([2,4,2,1],[312,e,0,0])])}},j7e=class q7e{xBit;nBit;sBit;pid;iBit;lBit;tBit;kBit;mBit;pictureId;payload;size0=0;hBit;ver;pBit;size1=0;size2=0;static deSerialize(e){let r=new q7e,n=0;if(r.xBit=ir(e[n],0),r.nBit=ir(e[n],2),r.sBit=ir(e[n],3),r.pid=ir(e[n],5,3),n++,r.xBit&&(r.iBit=ir(e[n],0),r.lBit=ir(e[n],1),r.tBit=ir(e[n],2),r.kBit=ir(e[n],3),n++),r.iBit)if(r.mBit=ir(e[n],0),r.mBit){let i=k6(ir(e[n],1,7)),s=k6(e[n+1]);r.pictureId=Number.parseInt(i+s,2),n+=2}else r.pictureId=ir(e[n],1,7),n++;return r.lBit&&n++,(r.lBit||r.kBit)&&(r.tBit,r.kBit,n++),r.payload=e.subarray(n),r.payloadHeaderExist&&(r.size0=ir(e[n],0,3),r.hBit=ir(e[n],3),r.ver=ir(e[n],4,3),r.pBit=ir(e[n],7),n++,r.size1=e[n],n++,r.size2=e[n]),r}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return this.pBit===0}get isPartitionHead(){return this.sBit===1}get payloadHeaderExist(){return this.sBit===1&&this.pid===0}get size(){return this.payloadHeaderExist?this.size0+8*this.size1+2048*this.size2:0}},z7e=class W7e{iBit;pBit;lBit;fBit;bBit;eBit;vBit;zBit;m;pictureId;tid;u;sid;d;tl0PicIdx;pDiff=[];n_s;y;g;width=[];height=[];n_g=0;pgT=[];pgU=[];pgP_Diff=[];payload;static deSerialize(e){let{p:r,offset:n}=this.parseRtpPayload(e);return r.payload=e.subarray(n),r}static parseRtpPayload(e){let r=new W7e,n=0;if(r.iBit=ir(e[n],0),r.pBit=ir(e[n],1),r.lBit=ir(e[n],2),r.fBit=ir(e[n],3),r.bBit=ir(e[n],4),r.eBit=ir(e[n],5),r.vBit=ir(e[n],6),r.zBit=ir(e[n],7),n++,r.iBit)if(r.m=ir(e[n],0),r.m){let i=k6(ir(e[n],1,7)),s=k6(e[n+1]);r.pictureId=Number.parseInt(i+s,2),n+=2}else r.pictureId=ir(e[n],1,7),n++;if(r.lBit&&(r.tid=ir(e[n],0,3),r.u=ir(e[n],3),r.sid=ir(e[n],4,3),r.d=ir(e[n],7),n++,r.fBit===0&&(r.tl0PicIdx=e[n],n++)),r.fBit&&r.pBit)for(;;){r.pDiff=[...r.pDiff,ir(e[n],0,7)];let i=ir(e[n],7);if(n++,i===0)break}return r.vBit&&(r.n_s=ir(e[n],0,3),r.y=ir(e[n],3),r.g=ir(e[n],4),n++,r.y&&[...Array(r.n_s+1)].forEach(()=>{r.width.push(e.readUInt16BE(n)),n+=2,r.height.push(e.readUInt16BE(n)),n+=2}),r.g&&(r.n_g=e[n],n++),r.n_g>0&&[...Array(r.n_g).keys()].forEach(i=>{r.pgT.push(ir(e[n],0,3)),r.pgU.push(ir(e[n],3));let s=ir(e[n],4,2);n++,r.pgP_Diff[i]=[],s>0&&[...Array(s)].forEach(()=>{r.pgP_Diff[i].push(e[n]),n++})})),{offset:n,p:r}}static isDetectedFinalPacketInSequence(e){return e.marker}get isKeyframe(){return!!(!this.pBit&&this.bBit&&(!this.sid||!this.lBit))}get isPartitionHead(){return this.bBit&&(!this.lBit||!this.d)}},xDt=class{payload;fragment;static deSerialize(t,e){return{}}static isDetectedFinalPacketInSequence(t){return!0}get isKeyframe(){return!0}};vDt=["MPEG4/ISO/AVC","VP8","VP9","OPUS","AV1"];_Dt={setTimeout:(...t)=>{let e=setTimeout(...t);return()=>clearTimeout(e)},setInterval:(...t)=>{let e=setInterval(()=>{t[0]()},...t.slice(1));return()=>clearInterval(e)}};lM=4,kp=class mae{version=2;padding=!1;count=0;type=0;length=0;constructor(e={}){Object.assign(this,e)}static serialize(e,r,n,i){let a=new mae({type:e,count:r,version:2,length:i}).serialize();return Buffer.concat([a,n])}serialize(){let e=new C6(8);return e.set(2,0,this.version),this.padding&&e.set(1,2,1),e.set(5,3,this.count),Vs([1,1,2],[e.value,this.type,this.length])}static deSerialize(e){let[r,n,i]=zc(e,[1,1,2]),s=ir(r,0,2),a=ir(r,2,1)>0,c=ir(r,3,5);return new mae({version:s,padding:a,count:c,type:n,length:i})}},POe=class gae{static count=4;count=gae.count;senderSsrc;mediaSsrc;fir=[];constructor(e={}){Object.assign(this,e)}get length(){return Math.floor(this.serialize().length/4-1)}static deSerialize(e){let[r,n]=zc(e,[4,4]),i=[];for(let s=8;s<e.length;s+=8)i.push({ssrc:e.readUInt32BE(s),sequenceNumber:e[s+4]});return new gae({senderSsrc:r,mediaSsrc:n,fir:i})}serialize(){let e=Vs([4,4],[this.senderSsrc,this.mediaSsrc]),r=Buffer.alloc(this.fir.length*8);return this.fir.forEach(({ssrc:n,sequenceNumber:i},s)=>{r.writeUInt32BE(n,s*8),r[s*8+4]=i}),Buffer.concat([e,r])}},N6=class xae{static count=1;count=xae.count;length=2;senderSsrc;mediaSsrc;constructor(e={}){Object.assign(this,e)}static deSerialize(e){let[r,n]=zc(e,[4,4]);return new xae({senderSsrc:r,mediaSsrc:n})}serialize(){return Vs([4,4],[this.senderSsrc,this.mediaSsrc])}},B6=class yae{static count=15;length;count=yae.count;senderSsrc;mediaSsrc;uniqueID="REMB";ssrcNum=0;brExp;brMantissa;bitrate;ssrcFeedbacks=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let[r,n,i,s,a]=zc(e,[4,4,4,1,1]),c=ir(a,0,6),d=(ir(a,6,2)<<16)+(e[14]<<8)+e[15],h=c>46?18446744073709551615n:BigInt(d)<<BigInt(c),p=[];for(let x=16;x<e.length;x+=4){let y=e.slice(x).readUIntBE(0,4);p.push(y)}return new yae({senderSsrc:r,mediaSsrc:n,uniqueID:Vs([4],[i]).toString(),ssrcNum:s,brExp:c,brMantissa:d,ssrcFeedbacks:p,bitrate:h})}serialize(){let e=Buffer.concat([Vs([4,4],[this.senderSsrc,this.mediaSsrc]),Buffer.from(this.uniqueID),Vs([1],[this.ssrcNum])]),r=new C6(24);r.set(6,0,this.brExp).set(18,6,this.brMantissa);let n=Buffer.concat(this.ssrcFeedbacks.map(s=>Vs([4],[s]))),i=Buffer.concat([e,Vs([3],[r.value]),n]);return this.length=i.length/4,i}},wDt=_n("werift-rtp: /rtcp/psfb/index"),LS=class vae{static type=206;type=vae.type;feedback;constructor(e={}){Object.assign(this,e)}serialize(){let e=this.feedback.serialize();return kp.serialize(this.type,this.feedback.count,e,this.feedback.length)}static deSerialize(e,r){let n;switch(r.count){case POe.count:n=POe.deSerialize(e);break;case N6.count:n=N6.deSerialize(e);break;case B6.count:n=B6.deSerialize(e);break;default:wDt("unknown psfb packet",r.count);break}return new vae({feedback:n})}},$S=class qU{ssrc=0;reports=[];static type=201;type=qU.type;constructor(e={}){Object.assign(this,e)}serialize(){let e=Vs([4],[this.ssrc]);return e=Buffer.concat([e,...this.reports.map(r=>r.serialize())]),kp.serialize(qU.type,this.reports.length,e,Math.floor(e.length/4))}static deSerialize(e,r){let[n]=zc(e,[4]),i=4,s=[];for(let a=0;a<r;a++)s.push(kM.deSerialize(e.slice(i,i+24))),i+=24;return new qU({ssrc:n,reports:s})}},kM=class V7e{ssrc;fractionLost;packetsLost;highestSequence;jitter;lsr;dlsr;constructor(e={}){Object.assign(this,e)}toJSON(){return{ssrc:this.ssrc,fractionLost:this.fractionLost,packetsLost:this.packetsLost,highestSequence:this.highestSequence,jitter:this.jitter,lsr:this.lsr,dlsr:this.dlsr}}serialize(){return Vs([4,1,3,4,4,4,4],[this.ssrc,this.fractionLost,this.packetsLost,this.highestSequence,this.jitter,this.lsr,this.dlsr])}static deSerialize(e){let[r,n,i,s,a,c,d]=zc(e,[4,1,3,4,4,4,4]);return new V7e({ssrc:r,fractionLost:n,packetsLost:i,highestSequence:s,jitter:a,lsr:c,dlsr:d})}},G7e=205,U6=class bae{static count=1;count=bae.count;header;senderSsrc;mediaSourceSsrc;lost=[];toJSON(){return{lost:this.lost,senderSsrc:this.senderSsrc,mediaSourceSsrc:this.mediaSourceSsrc}}constructor(e={}){Object.assign(this,e),this.header||(this.header=new kp({type:G7e,count:this.count,version:2}))}static deSerialize(e,r){let[n,i]=zc(e,[4,4]),s=[];for(let a=8;a<e.length;a+=4){let[c,d]=zc(e.subarray(a),[2,2]);s.push(c);for(let h=0;h<16;h++)d>>h&1&&s.push(c+h+1)}return new bae({header:r,senderSsrc:n,mediaSourceSsrc:i,lost:s})}serialize(){let e=Vs([4,4],[this.senderSsrc,this.mediaSourceSsrc]),r=[];if(this.lost.length>0){let i=this.lost[0],s=0;this.lost.slice(1).forEach(a=>{let c=a-i-1;c>=0&&c<16?s|=1<<c:(r.push(Vs([2,2],[i,s])),i=a,s=0)}),r.push(Vs([2,2],[i,s]))}let n=Buffer.concat([e,Buffer.concat(r)]);return this.header.length=n.length/4,Buffer.concat([this.header.serialize(),n])}},SDt=_n("werift/rtp/rtcp/rtpfb/twcc"),M6=class _ae{static count=15;count=_ae.count;length=2;senderSsrc;mediaSourceSsrc;baseSequenceNumber;packetStatusCount;referenceTime;fbPktCount;packetChunks=[];recvDeltas=[];header;constructor(e={}){Object.assign(this,e),this.header||(this.header=new kp({type:205,count:this.count,version:2}))}static deSerialize(e,r){let[n,i,s,a,c,d]=zc(e,[4,4,2,2,3,1]),h=[],p=[],x=16;for(let v=0;v<a;){let w=ir(e.slice(x,x+1)[0],0,1),S;switch(w){case 0:{let C=BS.deSerialize(e.slice(x,x+2));S=C;let k=Math.min(a-v,C.runLength);if(C.packetStatus===1||C.packetStatus===2)for(let T=0;T<k;T++)p.push(new A6({type:C.packetStatus}));v+=k}break;case 1:{let C=Z7e.deSerialize(e.slice(x,x+2));S=C,C.symbolSize===0&&C.symbolList.forEach(k=>{k===1&&p.push(new A6({type:1}))}),C.symbolSize===1&&C.symbolList.forEach(k=>{(k===1||k===2)&&p.push(new A6({type:k}))}),v+=C.symbolList.length}break}if(!S)throw new Error;x+=2,h.push(S)}let y=x;return p.forEach(v=>{v.type===1&&(v.deSerialize(e.slice(y,y+1)),y++),v.type===2&&(v.deSerialize(e.slice(y,y+2)),y+=2)}),new _ae({senderSsrc:n,mediaSourceSsrc:i,baseSequenceNumber:s,packetStatusCount:a,referenceTime:c,fbPktCount:d,recvDeltas:p,packetChunks:h,header:r})}serialize(){let e=Vs([4,4,2,2,3,1],[this.senderSsrc,this.mediaSourceSsrc,this.baseSequenceNumber,this.packetStatusCount,this.referenceTime,this.fbPktCount]),r=Buffer.concat(this.packetChunks.map(s=>s.serialize())),n=Buffer.concat(this.recvDeltas.map(s=>{try{return s.serialize()}catch(a){SDt(a?.message);return}}).filter(s=>s)),i=Buffer.concat([e,r,n]);if(this.header.padding&&i.length%4!==0){let s=4-i.length%4,a=Buffer.alloc(s);return a[a.length-1]=a.length,this.header.length=Math.floor((i.length+a.length)/4),Buffer.concat([this.header.serialize(),i,a])}return this.header.length=Math.floor(i.length/4),Buffer.concat([this.header.serialize(),i])}get packetResults(){let e=this.baseSequenceNumber-1,r=this.packetChunks.filter(a=>a instanceof BS).flatMap(a=>a.results(e)),n=0,s=BigInt(this.referenceTime)*64n;for(let a of r){let c=this.recvDeltas[n];!a.received||!c||(s+=BigInt(c.delta)/1000n,a.delta=c.delta,a.receivedAtMs=Number(s),n++)}return r}},BS=class K7e{type;packetStatus;runLength;constructor(e={}){Object.assign(this,e),this.type=0}static deSerialize(e){let r=ir(e[0],1,2),n=(ir(e[0],3,5)<<8)+e[1];return new K7e({type:0,packetStatus:r,runLength:n})}serialize(){return new bM(16).set(0).set(this.packetStatus,2).set(this.runLength,13).buffer}results(e){let r=this.packetStatus===1||this.packetStatus===2,n=[];for(let i=0;i<=this.runLength;++i)n.push(new Q7e({sequenceNumber:++e,received:r}));return n}},Z7e=class X7e{type;symbolSize;symbolList=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let n=ir(e[0],1,1),i=[];function s(a,c){for(let d=0;d<a;d++)c(d)}switch(n){case 0:s(6,a=>i.push(ir(e[0],2+a,1))),s(8,a=>i.push(ir(e[1],a,1)));break;case 1:s(3,a=>i.push(ir(e[0],2+a*2,2))),s(4,a=>i.push(ir(e[1],a*2,2)));break;default:n=(ir(e[0],2,6)<<8)+e[1]}return new X7e({type:1,symbolSize:n,symbolList:i})}serialize(){let e=Buffer.alloc(2),r=new bM(16).set(1).set(this.symbolSize),n=this.symbolSize===0?1:2;return this.symbolList.forEach(i=>{r.set(i,n)}),e.writeUInt16BE(r.value),e}},A6=class wae{type;delta;constructor(e={}){Object.assign(this,e)}static deSerialize(e){let r,n;if(e.length===1?(r=1,n=250*e[0]):e.length===2&&(r=2,n=250*e.readInt16BE()),r===void 0||n===void 0)throw new Error;return new wae({type:r,delta:n})}deSerialize(e){let r=wae.deSerialize(e);this.delta=r.delta}parsed=!1;parseDelta(){this.delta=Math.floor(this.delta/250),this.delta<0||this.delta>255?(this.delta>32767&&(this.delta=32767),this.delta<-32768&&(this.delta=-32768),this.type||(this.type=2)):this.type||(this.type=1),this.parsed=!0}serialize(){if(this.parsed||this.parseDelta(),this.type===1){let e=Buffer.alloc(1);return e.writeUInt8(this.delta),e}else if(this.type===2){let e=Buffer.alloc(2);return e.writeInt16BE(this.delta),e}throw new Error("errDeltaExceedLimit "+this.delta+" "+this.type)}},Y7e=(t=>(t[t.TypeTCCRunLengthChunk=0]="TypeTCCRunLengthChunk",t[t.TypeTCCStatusVectorChunk=1]="TypeTCCStatusVectorChunk",t[t.packetStatusChunkLength=2]="packetStatusChunkLength",t))(Y7e||{}),J7e=(t=>(t[t.TypeTCCPacketNotReceived=0]="TypeTCCPacketNotReceived",t[t.TypeTCCPacketReceivedSmallDelta=1]="TypeTCCPacketReceivedSmallDelta",t[t.TypeTCCPacketReceivedLargeDelta=2]="TypeTCCPacketReceivedLargeDelta",t[t.TypeTCCPacketReceivedWithoutDelta=3]="TypeTCCPacketReceivedWithoutDelta",t))(J7e||{}),Q7e=class{sequenceNumber=0;delta=0;received=!1;receivedAtMs=0;constructor(t){Object.assign(this,t)}},ADt=_n("werift-rtp:packages/rtp/rtcp/rtpfb/index"),Tv=class Sae{static type=G7e;type=Sae.type;feedback;header;constructor(e={}){Object.assign(this,e)}serialize(){return this.feedback.serialize()}static deSerialize(e,r){let n;switch(r.count){case U6.count:n=U6.deSerialize(e,r);break;case M6.count:n=M6.deSerialize(e,r);break;default:ADt("unknown rtpfb packet",r.count);break}return new Sae({feedback:n,header:r})}},L6=class Aae{static type=202;type=Aae.type;chunks=[];constructor(e){Object.assign(this,e)}get length(){let e=0;return this.chunks.forEach(r=>e+=r.length),e}serialize(){let e=Buffer.concat(this.chunks.map(r=>r.serialize()));for(;e.length%4;)e=Buffer.concat([e,Buffer.from([0])]);return kp.serialize(this.type,this.chunks.length,e,e.length/4)}static deSerialize(e,r){let n=[];for(let i=0;i<e.length;){let s=goe.deSerialize(e.slice(i));n.push(s),i+=s.length}return new Aae({chunks:n})}},goe=class eBe{source;items=[];constructor(e={}){Object.assign(this,e)}get length(){let e=4;return this.items.forEach(r=>e+=r.length),e+=1,e+=ROe(e),e}serialize(){let e=Buffer.concat([Vs([4],[this.source]),Buffer.concat(this.items.map(n=>n.serialize()))]);return Buffer.concat([e,Buffer.alloc(ROe(e.length))])}static deSerialize(e){let r=e.readUInt32BE(),n=[];for(let i=4;i<e.length&&e[i]!==0;){let a=xoe.deSerialize(e.slice(i));n.push(a),i+=a.length}return new eBe({source:r,items:n})}},xoe=class tBe{type;text;constructor(e){Object.assign(this,e)}get length(){return 2+Buffer.from(this.text).length}serialize(){let e=Buffer.from(this.text);return Buffer.concat([Vs([1,1],[this.type,e.length]),e])}static deSerialize(e){let r=e[0],n=e[1],i=e.slice(2,2+n).toString();return new tBe({type:r,text:i})}};Cv=class zU{ssrc=0;senderInfo;reports=[];static type=200;type=zU.type;constructor(e){Object.assign(this,e)}toJSON(){return{ssrc:this.ssrc,senderInfo:this.senderInfo.toJSON(),reports:this.reports.map(e=>e.toJSON())}}serialize(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.ssrc),e=Buffer.concat([e,this.senderInfo.serialize()]),e=Buffer.concat([e,...this.reports.map(r=>r.serialize())]),kp.serialize(zU.type,this.reports.length,e,Math.floor(e.length/4))}static deSerialize(e,r){let n=e.readUInt32BE(),i=yoe.deSerialize(e.subarray(4,24)),s=24,a=[];for(let d=0;d<r;d++)a.push(kM.deSerialize(e.subarray(s,s+24))),s+=24;return new zU({ssrc:n,senderInfo:i,reports:a})}},yoe=class rBe{ntpTimestamp;rtpTimestamp;packetCount;octetCount;constructor(e={}){Object.assign(this,e)}toJSON(){return{ntpTimestamp:nBe(this.ntpTimestamp),rtpTimestamp:this.rtpTimestamp}}serialize(){return Vs([8,4,4,4],[this.ntpTimestamp,this.rtpTimestamp,this.packetCount,this.octetCount])}static deSerialize(e){let[r,n,i,s]=zc(e,[8,4,4,4]);return new rBe({ntpTimestamp:r,rtpTimestamp:n,packetCount:i,octetCount:s})}},nBe=t=>{let[e,r]=zc(Vs([8],[t]),[4,4]);return+`${e}.${r}`},EDt=_n("werift-rtp:packages/rtp/src/rtcp/rtcp.ts"),iBe=class{static deSerialize(t){let e=0,r=[];for(;e<t.length;){let n=kp.deSerialize(t.subarray(e,e+lM));e+=lM;let i=t.subarray(e);e+=n.length*4,n.padding&&(i=i.subarray(0,i.length-i.subarray(-1)[0]));try{switch(n.type){case Cv.type:r.push(Cv.deSerialize(i,n.count));break;case $S.type:r.push($S.deSerialize(i,n.count));break;case L6.type:r.push(L6.deSerialize(i,n));break;case Tv.type:r.push(Tv.deSerialize(i,n));break;case LS.type:r.push(LS.deSerialize(i,n));break;default:break}}catch(s){EDt("deSerialize RTCP",s)}}return r}};Os={sdesMid:"urn:ietf:params:rtp-hdrext:sdes:mid",sdesRTPStreamID:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",repairedRtpStreamId:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",transportWideCC:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",absSendTime:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",dependencyDescriptor:"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension",audioLevelIndication:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",videoOrientation:"urn:3gpp:video-orientation"};CDt=_n("packages/rtp/src/rtp/red/packet.ts"),voe=class xBe{header;blocks=[];static deSerialize(e){let r=e instanceof ArrayBuffer?Buffer.from(e):e,n=new xBe,i=0;return[n.header,i]=Eae.deSerialize(r),n.header.fields.forEach(({blockLength:s,timestampOffset:a,blockPT:c})=>{if(s&&a){let d=r.subarray(i,i+s);n.blocks.push({block:d,blockPT:c,timestampOffset:a}),i+=s}else{let d=r.subarray(i);n.blocks.push({block:d,blockPT:c})}}),n}serialize(){this.header=new Eae;for(let{timestampOffset:r,blockPT:n,block:i}of this.blocks)r?this.header.fields.push({fBit:1,blockPT:n,blockLength:i.length,timestampOffset:r}):this.header.fields.push({fBit:0,blockPT:n});let e=this.header.serialize();for(let{block:r}of this.blocks)e=Buffer.concat([e,r]);return e}},Eae=class yBe{fields=[];static deSerialize(e){let r=0,n=new yBe;for(;;){let i={};n.fields.push(i);let s=new Ug(e.subarray(r));if(i.fBit=s.readBits(1),i.blockPT=s.readBits(7),r++,i.fBit===0)break;i.timestampOffset=s.readBits(14),i.blockLength=s.readBits(10),r+=3}return[n,r]}serialize(){let e=Buffer.alloc(0);for(let r of this.fields)try{if(r.timestampOffset&&r.blockLength){let n=new Ug(Buffer.alloc(4)).writeBits(1,r.fBit).writeBits(7,r.blockPT).writeBits(14,r.timestampOffset).writeBits(10,r.blockLength);e=Buffer.concat([e,n.uint8Array])}else{let n=new Ug(Buffer.alloc(1)).writeBits(1,0).writeBits(7,r.blockPT);e=Buffer.concat([e,n.uint8Array])}}catch(n){CDt(n?.message)}return e}},vBe=class{constructor(t=1){this.distance=t}cache=[];cacheSize=10;push(t){this.cache.push(t),this.cache.length>this.cacheSize&&this.cache.shift()}build(){let t=new voe,e=this.cache.slice(-(this.distance+1)),r=e.pop();return r&&(e.forEach(n=>{let i=bv(r.timestamp,-n.timestamp);i>kDt||t.blocks.push({block:n.block,blockPT:n.blockPT,timestampOffset:i})}),t.blocks.push({block:r.block,blockPT:r.blockPT})),t}},kDt=16383,bBe=class{size=150;sequenceNumbers=[];push(t,e){let r=[];return t.blocks.forEach(({blockPT:i,timestampOffset:s,block:a},c)=>{let d=jo(e.header.sequenceNumber,-(t.blocks.length-(c+1)));s?r.push(new Cp(new Tp({timestamp:bv(e.header.timestamp,-s),payloadType:i,ssrc:e.header.ssrc,sequenceNumber:d,marker:!0}),a)):r.push(new Cp(new Tp({timestamp:e.header.timestamp,payloadType:i,ssrc:e.header.ssrc,sequenceNumber:d,marker:!0}),a))}),r.filter(i=>this.sequenceNumbers.includes(i.header.sequenceNumber)?!1:(this.sequenceNumbers.length>this.size&&this.sequenceNumbers.shift(),this.sequenceNumbers.push(i.header.sequenceNumber),!0))}},Ng={OneByte:48862,TwoByte:4096},OOe=2,NOe=4,BOe=8,UOe=12,MOe=4,Tp=class _Be{version=2;padding=!1;paddingSize=0;extension=!1;marker=!1;payloadOffset=0;payloadType=0;sequenceNumber=0;timestamp=0;ssrc=0;csrcLength=0;csrc=[];extensionProfile=Ng.OneByte;extensionLength;extensions=[];constructor(e={}){Object.assign(this,e)}static deSerialize(e){let r=new _Be,n=0,i=e[n++];r.version=ir(i,0,2),r.padding=ir(i,2)>0,r.extension=ir(i,3)>0,r.csrcLength=ir(i,4,4),r.csrc=[...Array(r.csrcLength)].map(()=>{let a=e.readUInt32BE(n);return n+=4,a}),n+=UOe-1;let s=e[1];r.marker=ir(s,0)>0,r.payloadType=ir(s,1,7),r.sequenceNumber=e.readUInt16BE(OOe),r.timestamp=e.readUInt32BE(NOe),r.ssrc=e.readUInt32BE(BOe);for(let a=0;a<r.csrc.length;a++){let c=UOe+a*MOe;r.csrc[a]=e.subarray(c).readUInt32BE()}if(r.extension){r.extensionProfile=e.subarray(n).readUInt16BE(),n+=2;let a=e.subarray(n).readUInt16BE()*4;switch(r.extensionLength=a,n+=2,r.extensionProfile){case Ng.OneByte:{let c=n+a;for(;n<c;){if(e[n]===0){n++;continue}let d=e[n]>>4,h=(e[n]&(e[n]^240))+1;if(n++,d===15)break;let p={id:d,payload:e.subarray(n,n+h)};r.extensions=[...r.extensions,p],n+=h}}break;case Ng.TwoByte:{let c=n+a;for(;n<c;){if(e[n]===0){n++;continue}let d=e[n];n++;let h=e[n];n++;let p={id:d,payload:e.subarray(n,n+h)};r.extensions=[...r.extensions,p],n+=h}}break;default:{let c={id:0,payload:e.subarray(n,n+a)};r.extensions=[...r.extensions,c],n+=r.extensions[0].payload.length}break}}return r.payloadOffset=n,r.padding&&(r.paddingSize=e[e.length-1]),r}get serializeSize(){let{csrc:e,extensionProfile:r,extensions:n}=this,i=12+e.length*MOe;if(n.length>0||this.extension===!0){let s=4;switch(r){case Ng.OneByte:for(let a of n)s+=1+a.payload.length;break;case Ng.TwoByte:for(let a of n)s+=2+a.payload.length;break;default:s+=n[0].payload.length}i+=Math.floor((s+3)/4)*4}return i}serialize(e){let r=Buffer.alloc(e),n=0,i=new C6(8);i.set(2,0,this.version),this.padding&&i.set(1,2,1),this.extensions.length>0&&(this.extension=!0),this.extension&&i.set(1,3,1),i.set(4,4,this.csrc.length),r.writeUInt8(i.value,n++);let s=new C6(8);this.marker&&s.set(1,0,1),s.set(7,1,this.payloadType),r.writeUInt8(s.value,n++),r.writeUInt16BE(this.sequenceNumber,OOe),n+=2,r.writeUInt32BE(this.timestamp,NOe),n+=4,r.writeUInt32BE(this.ssrc,BOe),n+=4;for(let a of this.csrc)r.writeUInt32BE(a,n),n+=4;if(this.extension){let a=n;r.writeUInt16BE(this.extensionProfile,n),n+=4;let c=n;switch(this.extensionProfile){case Ng.OneByte:for(let p of this.extensions)r.writeUInt8(p.id<<4|p.payload.length-1,n++),p.payload.copy(r,n),n+=p.payload.length;break;case Ng.TwoByte:for(let p of this.extensions)r.writeUInt8(p.id,n++),r.writeUInt8(p.payload.length,n++),p.payload.copy(r,n),n+=p.payload.length;break;default:{let p=this.extensions[0].payload.length;if(p%4!=0)throw new Error;this.extensions[0].payload.copy(r,n),n+=p}}let d=n-c,h=Math.trunc((d+3)/4)*4;r.writeUInt16BE(Math.trunc(h/4),a+2);for(let p=0;p<h-d;p++)r.writeUInt8(0,n),n++}return this.payloadOffset=n,r}},Cp=class Tae{constructor(e,r){this.header=e,this.payload=r}get serializeSize(){return this.header.serializeSize+this.payload.length}clone(){return new Tae(new Tp({...this.header}),this.payload)}serialize(){let e=this.header.serialize(this.header.serializeSize+this.payload.length),{payloadOffset:r}=this.header;if(this.payload.copy(e,r),this.header.padding){let n=Buffer.alloc(this.header.paddingSize);n.writeUInt8(this.header.paddingSize,this.header.paddingSize-1),e=Buffer.concat([e,n])}return e}static deSerialize(e){let r=Tp.deSerialize(e);return new Tae(r,e.subarray(r.payloadOffset,e.length-r.paddingSize))}clear(){this.payload=null}};ABe=class{constructor(t,e,r,n){this.srtpSessionKey=t,this.srtpSessionSalt=e,this.srtcpSessionKey=r,this.srtcpSessionSalt=n}encryptRtp(t,e,r){return Buffer.from([])}decryptRtp(t,e,r){return[]}encryptRTCP(t,e){return Buffer.from([])}decryptRTCP(t){return[]}},kv=class extends Error{constructor(t){super(t),this.name="SrtpAuthenticationError"}},qOe=12,IDt=8;FDt=class extends ABe{constructor(t,e,r,n,i,s){super(t,e,r,n),this.srtpSessionAuthTag=i,this.srtcpSessionAuthTag=s}authTagLength=10;encryptRtp(t,e,r){let n=t.serialize(t.serializeSize),i=this.generateCounter(t.sequenceNumber,r,t.ssrc,this.srtpSessionSalt),a=LOe("aes-128-ctr",this.srtpSessionKey,i).update(e),c=this.generateSrtpAuthTag(r,n,a);return Buffer.concat([n,a,c])}decryptRtp(t,e,r=_oe(t,this.authTagLength)){let n=t.length-this.authTagLength,i=t.subarray(0,n),s=t.subarray(n),a=this.generateSrtpAuthTag(e,i.subarray(0,r.payloadOffset),i.subarray(r.payloadOffset));WOe(s,a,"Failed to authenticate SRTP packet");let c=this.generateCounter(r.sequenceNumber,e,r.ssrc,this.srtpSessionSalt),d=$Oe("aes-128-ctr",this.srtpSessionKey,c),h=i.subarray(r.payloadOffset),p=d.update(h),x=Buffer.concat([i.subarray(0,r.payloadOffset),p]);return[x,CBe(r,x,"Failed to authenticate SRTP packet")]}encryptRTCP(t,e){let r=Buffer.from(t),n=r.readUInt32BE(4),i=this.generateCounter(e&65535,e>>16,n,this.srtcpSessionSalt);LOe("aes-128-ctr",this.srtcpSessionKey,i).update(r.slice(8)).copy(r,8),r=Buffer.concat([r,Buffer.alloc(4)]),r.writeUInt32BE(e,r.length-4),r[r.length-4]|=128;let c=this.generateSrtcpAuthTag(r);return r=Buffer.concat([r,c]),r}decryptRTCP(t){let e=EBe(t,this.authTagLength,zOe),r=t.length-(this.authTagLength+zOe),n=t.subarray(0,t.length-this.authTagLength),i=t.subarray(t.length-this.authTagLength),s=this.generateSrtcpAuthTag(n);WOe(i,s,"Failed to authenticate SRTCP packet");let a=Buffer.from(t).slice(0,r);if(t[r]>>>7===0)return[a,e];let d=t.readUInt32BE(r);d&=~(1<<31);let h=t.readUInt32BE(4),p=this.generateCounter(d&65535,d>>16,h,this.srtcpSessionSalt);return $Oe("aes-128-ctr",this.srtcpSessionKey,p).update(a.subarray(8)).copy(a,8),[a,e]}generateSrtcpAuthTag(t){return jOe("sha1",this.srtcpSessionAuthTag).update(t).digest().slice(0,10)}generateCounter(t,e,r,n){let i=Buffer.alloc(16);i.writeUInt32BE(r,4),i.writeUInt32BE(e,8),i.writeUInt32BE(Number(BigInt(t)<<16n),12);for(let s=0;s<n.length;s++)i[s]^=n[s];return i}generateSrtpAuthTag(t,...e){let r=jOe("sha1",this.srtpSessionAuthTag),n=Buffer.alloc(4);n.writeUInt32BE(t);for(let i of e)r.update(i);return r.update(n).digest().subarray(0,10)}},zOe=4;PDt=class extends ABe{aeadAuthTagLen=16;rtpIvWriter=S6([2,4,4,2],!0);rtcpIvWriter=S6([2,4,2,4],!0);aadWriter=S6([4],!0);constructor(t,e,r,n){super(t,e,r,n)}encryptRtp(t,e,r){let n=t.serialize(t.serializeSize),i=this.rtpInitializationVector(t,r),s=HOe("aes-128-gcm",this.srtpSessionKey,i);s.setAAD(n);let a=s.update(e);s.final();let c=s.getAuthTag();return Buffer.concat([n,a,c])}decryptRtp(t,e,r=_oe(t,this.aeadAuthTagLen)){let n=t.subarray(0,r.payloadOffset),i=t.length-this.aeadAuthTagLen,s=t.subarray(i),a=Buffer.from([]);a=pae(a,t.length-this.aeadAuthTagLen),n.copy(a);let c=this.rtpInitializationVector(r,e),d=t.slice(r.payloadOffset,i),h=VOe("aes-128-gcm",this.srtpSessionKey,c);h.setAAD(n),h.setAuthTag(s);let p=h.update(d);return KOe(h,"SRTP"),p.copy(a,r.payloadOffset),[a,CBe(r,a,"Failed to authenticate SRTP packet")]}encryptRTCP(t,e){let r=t.readUInt32BE(4),n=t.length+this.aeadAuthTagLen,i=Buffer.from([]);i=pae(i,n+Hse),t.slice(0,8).copy(i);let s=this.rtcpInitializationVector(r,e),a=this.rtcpAdditionalAuthenticatedData(t,e),c=HOe("aes-128-gcm",this.srtcpSessionKey,s);c.setAAD(a);let d=c.update(t.slice(8));return c.final(),d.copy(i,8),c.getAuthTag().copy(i,8+d.length),a.slice(8,12).copy(i,n),i}decryptRTCP(t){let e=EBe(t,this.aeadAuthTagLen,Hse),r=t.length-Hse,n=r-this.aeadAuthTagLen,i=t.readUInt32BE(4),s=t.readUInt32BE(r),a=s>>>31===1,c=s&~(GOe<<24),d=this.rtcpInitializationVector(i,c),h=a?Buffer.concat([t.subarray(0,8),t.subarray(r)]):Buffer.concat([t.subarray(0,n),t.subarray(r)]),p=a?t.slice(8,n):Buffer.alloc(0),x=a?Buffer.alloc(n):Buffer.from(t.subarray(0,n));a&&t.slice(0,8).copy(x);let y=VOe("aes-128-gcm",this.srtcpSessionKey,d);y.setAAD(h),y.setAuthTag(t.subarray(n,r));let v=y.update(p);return KOe(y,"SRTCP"),a&&v.copy(x,8),[x,e]}rtpInitializationVector(t,e){let r=this.rtpIvWriter([0,t.ssrc,e,t.sequenceNumber]);for(let n=0;n<r.length;n++)r[n]^=this.srtpSessionSalt[n];return r}rtcpInitializationVector(t,e){let r=this.rtcpIvWriter([0,t,0,e]);for(let n=0;n<r.length;n++)r[n]^=this.srtcpSessionSalt[n];return r}rtcpAdditionalAuthenticatedData(t,e){let r=Buffer.concat([t.subarray(0,8),this.aadWriter([e])]);return r[8]|=GOe,r}},Hse=4,GOe=128;kBe=class{constructor(t,e,r){this.masterKey=t,this.masterSalt=e,this.profile=r;{let n=14-e.length;n>0&&(this.masterSalt=Buffer.concat([e,Buffer.alloc(n)]))}switch(this.srtpSessionKey=this.generateSessionKey(0),this.srtpSessionSalt=this.generateSessionSalt(2),this.srtpSessionAuthTag=this.generateSessionAuthTag(1),this.srtpSessionAuth=Wse("sha1",this.srtpSessionAuthTag),this.srtcpSessionKey=this.generateSessionKey(3),this.srtcpSessionSalt=this.generateSessionSalt(5),this.srtcpSessionAuthTag=this.generateSessionAuthTag(4),this.srtcpSessionAuth=Wse("sha1",this.srtcpSessionAuthTag),r){case HS:this.cipher=new FDt(this.srtpSessionKey,this.srtpSessionSalt,this.srtcpSessionKey,this.srtcpSessionSalt,this.srtpSessionAuthTag,this.srtcpSessionAuthTag);break;case Fv:this.cipher=new PDt(this.srtpSessionKey,this.srtpSessionSalt,this.srtcpSessionKey,this.srtcpSessionSalt);break}}srtpSSRCStates={};srtpSessionKey;srtpSessionSalt;srtpSessionAuthTag;srtpSessionAuth;srtcpSSRCStates={};srtcpSessionKey;srtcpSessionSalt;srtcpSessionAuthTag;srtcpSessionAuth;cipher;generateSessionKey(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let i=r.length-1,s=e.length-1;i>=0;i--,s--)e[s]=e[s]^r[i];e=Buffer.concat([e,Buffer.from([0,0])]);let n=new WU.default.AES(this.masterKey);return Buffer.from(n.encrypt(e))}generateSessionSalt(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let i=r.length-1,s=e.length-1;i>=0;i--,s--)e[s]=e[s]^r[i];e=Buffer.concat([e,Buffer.from([0,0])]);let n=new WU.default.AES(this.masterKey);return e=Buffer.from(n.encrypt(e)),e.subarray(0,14)}generateSessionAuthTag(t){let e=Buffer.from(this.masterSalt),r=Buffer.from([t,0,0,0,0,0,0]);for(let a=r.length-1,c=e.length-1;a>=0;a--,c--)e[c]=e[c]^r[a];let n=Buffer.concat([e,Buffer.from([0,0])]),i=Buffer.concat([e,Buffer.from([0,1])]),s=new WU.default.AES(this.masterKey);return n=Buffer.from(s.encrypt(n)),i=Buffer.from(s.encrypt(i)),Buffer.concat([n,i.subarray(0,4)])}getSrtpSsrcState(t){let e=this.srtpSSRCStates[t];return e||(e={ssrc:t,rolloverCounter:0,lastSequenceNumber:0},this.srtpSSRCStates[t]=e,e)}getSrtcpSsrcState(t){let e=this.srtcpSSRCStates[t];return e||(e={srtcpIndex:0,ssrc:t},this.srtcpSSRCStates[t]=e,e)}updateRolloverCount(t,e){e.rolloverHasProcessed?t===0?e.lastSequenceNumber>i6&&e.rolloverCounter++:e.lastSequenceNumber<i6&&t>ZOe-i6?e.rolloverCounter>0&&e.rolloverCounter--:t<i6&&e.lastSequenceNumber>ZOe-i6&&e.rolloverCounter++:e.rolloverHasProcessed=!0,e.lastSequenceNumber=t}generateSrtpAuthTag(t,e){this.srtpSessionAuth=Wse("sha1",this.srtpSessionAuthTag);let r=Buffer.alloc(4);return r.writeUInt32BE(e),this.srtpSessionAuth.update(t).update(r).digest().slice(0,10)}index(t){let e=this.srtcpSSRCStates[t];return e?e.srtcpIndex:0}setIndex(t,e){let r=this.getSrtcpSsrcState(t);r.srtcpIndex=e%2147483647}},i6=100,ZOe=65535,RDt=class extends kBe{constructor(t,e,r){super(t,e,r)}encryptRTCP(t){let e=t.readUInt32BE(4),r=this.getSrtcpSsrcState(e);return r.srtcpIndex++,r.srtcpIndex>>ODt&&(r.srtcpIndex=0),this.cipher.encryptRTCP(t,r.srtcpIndex)}decryptRTCP(t){return this.cipher.decryptRTCP(t)}},ODt=2147483647,DBe=class{constructor(t){this.ContextCls=t}localContext;remoteContext;onData;start(t,e,r,n,i){this.localContext=new this.ContextCls(t,e,i),this.remoteContext=new this.ContextCls(r,n,i)}},IBe=class extends DBe{constructor(t){super(RDt),this.config=t,this.start(t.keys.localMasterKey,t.keys.localMasterSalt,t.keys.remoteMasterKey,t.keys.remoteMasterSalt,t.profile)}decrypt=t=>{let[e]=this.remoteContext.decryptRTCP(t);return e};encrypt(t){return this.localContext.encryptRTCP(t)}},NDt=class extends kBe{constructor(t,e,r){super(t,e,r)}encryptRtp(t,e){let r=this.getSrtpSsrcState(e.ssrc);return this.updateRolloverCount(e.sequenceNumber,r),this.cipher.encryptRtp(e,t,r.rolloverCounter)}decryptRtp(t){let e=_oe(t,this.rtpAuthTagLength),r=this.srtpSSRCStates[e.ssrc],n=r?{...r}:{ssrc:e.ssrc,rolloverCounter:0,lastSequenceNumber:0};this.updateRolloverCount(e.sequenceNumber,n);let i=this.cipher.decryptRtp(t,n.rolloverCounter,e);return r?Object.assign(r,n):this.srtpSSRCStates[e.ssrc]=n,i}get rtpAuthTagLength(){return this.profile===Fv?16:10}},FBe=class extends DBe{constructor(t){super(NDt),this.config=t,this.start(t.keys.localMasterKey,t.keys.localMasterSalt,t.keys.remoteMasterKey,t.keys.remoteMasterSalt,t.profile)}decrypt=t=>{let[e]=this.remoteContext.decryptRtp(t);return e};encrypt(t,e){return this.localContext.encryptRtp(t,e)}},BDt=class{constructor(t){this.props=t}sequenceNumber=coe();timestamp=sM();create(t){this.sequenceNumber=jo(this.sequenceNumber,1);let e=this.props.between*this.props.clockRate/1e3;this.timestamp=bv(this.timestamp,e);let r=new Tp({sequenceNumber:this.sequenceNumber,timestamp:Number(this.timestamp),payloadType:96,extension:!0,marker:!1,padding:!1});return new Cp(r,t)}},qc=_n("werift-dtls : packages/dtls/src/flight/client/flight5.ts : log"),UDt=class extends K6{constructor(t,e,r,n){super(t,e,5,7),this.cipher=r,this.srtp=n}handleHandshake(t){this.dtls.bufferHandshakeCache([t],!1,4);let e=(()=>{switch(t.msg_type){case 2:return E7e.deSerialize(t.fragment);case 11:return uM.deSerialize(t.fragment);case 12:return k7e.deSerialize(t.fragment);case 13:return A7e.deSerialize(t.fragment);case 14:return T7e.deSerialize(t.fragment)}})();e&&VS[e.msgType]({dtls:this.dtls,cipher:this.cipher,srtp:this.srtp})(e)}async exec(){if(this.dtls.flight===5){qc(this.dtls.sessionId,"flight5 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=5;let t=this.dtls.requestedCertificateTypes.length>0;qc(this.dtls.sessionId,"send flight5",t);let e=[t&&this.sendCertificate(),this.sendClientKeyExchange(),t&&this.sendCertificateVerify(),this.sendChangeCipherSpec(),this.sendFinished()].filter(r=>r);this.dtls.lastMessage=e,await this.transmit(e)}sendCertificate(){let t=new uM([Buffer.from(this.cipher.localCert)]),e=this.createPacket([t]);return Buffer.concat(e.map(n=>n.serialize()))}sendClientKeyExchange(){if(!this.cipher.localKeyPair)throw new Error;let t=new S7e(this.cipher.localKeyPair.publicKey),e=this.createPacket([t]),r=Buffer.concat(e.map(c=>c.serialize())),n=this.cipher.localKeyPair,i=this.cipher.remoteKeyPair;if(!i.publicKey)throw new Error("not exist");let s=o7e(i.publicKey,n.privateKey,n.curve);qc(this.dtls.sessionId,"extendedMasterSecret",this.dtls.options.extendedMasterSecret,this.dtls.remoteExtendedMasterSecret);let a=Buffer.concat(this.dtls.sortedHandshakeCache.map(c=>c.serialize()));return this.cipher.masterSecret=this.dtls.options.extendedMasterSecret&&this.dtls.remoteExtendedMasterSecret?u7e(s,a):c7e(s,this.cipher.localRandom.serialize(),this.cipher.remoteRandom.serialize()),this.cipher.cipher=y7e(this.cipher.cipherSuite),this.cipher.cipher.init(this.cipher.masterSecret,this.cipher.remoteRandom.serialize(),this.cipher.localRandom.serialize()),qc(this.dtls.sessionId,"cipher",this.cipher.cipher.summary),r}sendCertificateVerify(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(a=>a.serialize())),e=this.cipher.signatureData(t,"sha256"),r=(()=>{switch(this.cipher.signatureHashAlgorithm?.signature){case Uh.ecdsa_3:return sae.ecdsa_secp256r1_sha256;case Uh.rsa_1:return sae.rsa_pkcs1_sha256}})();if(!r)throw new Error;qc(this.dtls.sessionId,"signatureScheme",this.cipher.signatureHashAlgorithm?.signature,r);let n=new w7e(r,e),i=this.createPacket([n]);return Buffer.concat(i.map(a=>a.serialize()))}sendChangeCipherSpec(){let t=_7e.createEmpty().serialize(),e=G6(this.dtls)([{type:20,fragment:t}],++this.dtls.recordSequenceNumber);return Buffer.concat(e.map(n=>n.serialize()))}sendFinished(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(s=>s.serialize())),e=this.cipher.verifyData(t),r=new fae(e);this.dtls.epoch=1;let[n]=this.createPacket([r]);this.dtls.recordSequenceNumber=0;let i=this.cipher.encryptPacket(n).serialize();return qc(this.dtls.sessionId,"finished",this.cipher.cipher.summary),i}},VS={};VS[2]=({cipher:t,srtp:e,dtls:r})=>n=>{qc(r.sessionId,"serverHello",n.cipherSuite),t.remoteRandom=wv.from(n.random),t.cipherSuite=n.cipherSuite,qc(r.sessionId,"selected cipherSuite",t.cipherSuite),n.extensions&&n.extensions.forEach(i=>{switch(i.type){case MS.type:{let s=MS.fromData(i.data),a=P6.findMatchingSRTPProfile(s.profiles,r.options.srtpProfiles||[]);if(qc(r.sessionId,"selected srtp profile",a),a==null)return;e.srtpProfile=a}break;case EM.type:r.remoteExtendedMasterSecret=!0;break;case TM.type:qc(r.sessionId,"RenegotiationIndication");break}})};VS[11]=({cipher:t,dtls:e})=>r=>{qc(e.sessionId,"handshake certificate",r),t.remoteCertificate=r.certificateList[0]};VS[12]=({cipher:t,dtls:e})=>r=>{if(!t.localRandom||!t.remoteRandom)throw new Error;qc(e.sessionId,"ServerKeyExchange",r),qc(e.sessionId,"selected curve",r.namedCurve),t.remoteKeyPair={curve:r.namedCurve,publicKey:r.publicKey},t.localKeyPair=b7e(r.namedCurve)};VS[13]=({dtls:t})=>e=>{qc(t.sessionId,"certificate_request",e),t.requestedCertificateTypes=e.certificateTypes,t.requestedSignatureAlgorithms=e.signatures};VS[14]=({dtls:t})=>e=>{qc(t.sessionId,"server_hello_done",e)};PBe=class b6{constructor(e,r){this.serverVersion=e,this.cookie=r}msgType=3;messageSeq;static spec={serverVersion:moe,cookie:Dv.types.buffer(Dv.types.uint8)};static createEmpty(){return new b6(void 0,void 0)}static deSerialize(e){return new b6(...Object.values((0,Dv.decode)(e,b6.spec)))}serialize(){let e=(0,Dv.encode)(this,b6.spec).slice();return Buffer.from(e)}get version(){return{major:255-this.serverVersion.major,minor:255-this.serverVersion.minor}}toFragment(){let e=this.serialize();return new af(this.msgType,e.length,this.messageSeq,0,e.length,e)}},LDt=_n("werift-dtls : packages/dtls/src/context/dtls.ts : log"),XOe=class{constructor(t,e){this.options=t,this.sessionType=e}version={major:254,minor:253};lastFlight=[];lastMessage=[];recordSequenceNumber=0;sequenceNumber=0;epoch=0;flight=0;handshakeCache={};cookie;requestedCertificateTypes=[];requestedSignatureAlgorithms=[];remoteExtendedMasterSecret=!1;get sessionId(){return this.cookie?this.cookie.toString("hex").slice(0,10):""}get sortedHandshakeCache(){return Object.entries(this.handshakeCache).sort(([t],[e])=>Number(t)-Number(e)).flatMap(([,{data:t}])=>t.sort((e,r)=>e.message_seq-r.message_seq))}checkHandshakesExist=t=>!t.find(e=>this.sortedHandshakeCache.find(r=>r.msg_type===e)==null);bufferHandshakeCache(t,e,r){this.handshakeCache[r]||(this.handshakeCache[r]={data:[],isLocal:e,flight:r});let n=t.filter(i=>{let s=this.handshakeCache[r].data.find(a=>a.msg_type===i.msg_type);return s?(LDt(this.sessionId,"exist",s.summary,e,r),!1):!0});this.handshakeCache[r].data=[...this.handshakeCache[r].data,...n]}},$Dt=class{constructor(t){this.socket=t}send=t=>this.socket.send(t)},Cae=class vp{static type=10;static spec={type:Bh.types.uint16be,data:Bh.types.array(Bh.types.uint16be,Bh.types.uint16be,"bytes")};type=vp.type;data=[];constructor(e={}){Object.assign(this,e)}static createEmpty(){return new vp}static fromData(e){return new vp({type:vp.type,data:(0,Bh.decode)(e,vp.spec.data)})}static deSerialize(e){return new vp((0,Bh.decode)(e,vp.spec))}serialize(){return Buffer.from((0,Bh.encode)(this,vp.spec).slice())}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},kae=class Bg{static type=13;static spec={type:Nh.types.uint16be,data:Nh.types.array({hash:Nh.types.uint8,signature:Nh.types.uint8},Nh.types.uint16be,"bytes")};type=Bg.type;data=[];constructor(e={}){Object.assign(this,e)}static createEmpty(){return new Bg}static deSerialize(e){return new Bg((0,Nh.decode)(e,Bg.spec))}serialize(){let e=(0,Nh.encode)(this,Bg.spec).slice();return Buffer.from(e)}static fromData(e){let r=Buffer.alloc(2);return r.writeUInt16BE(Bg.type),Bg.deSerialize(Buffer.concat([r,e]))}get extension(){return{type:this.type,data:this.serialize().slice(2)}}},YOe=class HU{constructor(e,r){this.level=e,this.description=r}static spec={level:Iv.types.uint8,description:Iv.types.uint8};static deSerialize(e){return new HU(...Object.values((0,Iv.decode)(e,HU.spec)))}serialize(){let e=(0,Iv.encode)(this,HU.spec).slice();return Buffer.from(e)}},JOe=_n("werift-dtls : packages/dtls/record/receive.ts : log"),Vse=_n("werift-dtls : packages/dtls/record/receive.ts : err"),jDt=t=>{let e=0,r=[];for(;t.length>e;){let n=t.readUInt16BE(e+11);if(t.length<e+(12+n))break;let i=g7e.deSerialize(t.subarray(e));r.push(i),e+=13+n}return r},qDt=(t,e)=>r=>{switch(r.recordLayerHeader.contentType){case 20:return JOe(t.sessionId,"change cipher spec"),[{type:20,data:void 0}];case 22:{let i=r.fragment;try{r.recordLayerHeader.epoch>0&&(JOe(t.sessionId,"decrypt handshake"),i=e.decryptPacket(r))}catch(s){throw Vse(t.sessionId,"decrypt failed",s),s}try{let s=0,a=[];for(;i.length>s;){let c=af.deSerialize(i.subarray(s));a.push({type:22,data:c}),s+=c.fragment_length+12}return a}catch(s){throw Vse(t.sessionId,"decSerialize failed",s,i),s}}case 23:return[{type:23,data:e.decryptPacket(r)}];case 21:{let i=YOe.deSerialize(r.fragment);if(uae[i.description]==null){let s=e.decryptPacket(r);i=YOe.deSerialize(s)}if(Vse(t.sessionId,"ContentType.alert",i,uae[i.description],"flight",t.flight,"lastFlight",t.lastFlight),i.level>1)throw new Error("alert fatal error");return[{type:21,data:void 0}]}default:return[{type:21,data:void 0}]}},QOe=_n("werift-dtls : packages/dtls/src/socket.ts : log"),eNe=_n("werift-dtls : packages/dtls/src/socket.ts : err"),woe=class{constructor(t,e){this.options=t,this.sessionType=e,this.dtls=new XOe(this.options,this.sessionType),this.cipher=new F6(this.sessionType,this.options.cert,this.options.key,this.options.signatureHash),this.transport=new $Dt(this.options.transport),this.setupExtensions(),this.transport.socket.onData=this.udpOnMessage}onConnect=new yr;onData=new yr;onError=new yr;onClose=new yr;transport;cipher;dtls;srtp=new P6;connected=!1;extensions=[];onHandleHandshakes;bufferFragmentedHandshakes=[];renegotiation(){QOe("renegotiation",this.sessionType),this.connected=!1,this.cipher=new F6(this.sessionType,this.options.cert,this.options.key,this.options.signatureHash),this.dtls=new XOe(this.options,this.sessionType),this.srtp=new P6,this.extensions=[],this.bufferFragmentedHandshakes=[]}udpOnMessage=t=>{let e=jDt(t);for(let r of e)try{let n=qDt(this.dtls,this.cipher)(r);for(let i of n)switch(i.type){case 22:{let s=i.data,a=this.handleFragmentHandshake([s]),c=Object.values(a.reduce((d,h)=>(d[h.msg_type]||(d[h.msg_type]=[]),d[h.msg_type].push(h),d),{})).map(d=>af.assemble(d)).sort((d,h)=>d.msg_type-h.msg_type);this.onHandleHandshakes(c).catch(d=>{eNe(this.dtls.sessionId,"onHandleHandshakes error",d),this.onError.execute(d)})}break;case 23:this.onData.execute(i.data);break;case 21:this.onClose.execute();break}}catch(n){eNe(this.dtls.sessionId,"catch udpOnMessage error",n)}};setupExtensions(){if(QOe(this.dtls.sessionId,"support srtpProfiles",this.options.srtpProfiles),this.options.srtpProfiles&&this.options.srtpProfiles.length>0){let t=MS.create(this.options.srtpProfiles,Buffer.from([0]));this.extensions.push(t.extension)}{let t=Cae.createEmpty();t.data=foe,this.extensions.push(t.extension)}{let t=kae.createEmpty();t.data=hoe,this.extensions.push(t.extension)}this.options.extendedMasterSecret&&this.extensions.push({type:EM.type,data:Buffer.alloc(0)});{let t=TM.createEmpty();this.extensions.push(t.extension)}}waitForReady=t=>new Promise(async(e,r)=>{for(let n=0;n<10;n++)if(t()){e();break}else await MDt(100*n);r("waitForReady timeout")});handleFragmentHandshake(t){let e=t.filter(r=>r.fragment_length!==r.length?(this.bufferFragmentedHandshakes.push(r),!1):!0);if(this.bufferFragmentedHandshakes.length>1){let[r]=this.bufferFragmentedHandshakes.slice(-1);r.fragment_offset+r.fragment_length===r.length&&(e=[...this.bufferFragmentedHandshakes,...e],this.bufferFragmentedHandshakes=[])}return e}send=async t=>{let e=G6(this.dtls)([{type:23,fragment:t}],++this.dtls.recordSequenceNumber)[0];await this.transport.send(this.cipher.encryptPacket(e).serialize())};close(){this.transport.socket.close()}extractSessionKeys(t,e){let r=this.exportKeyingMaterial("EXTRACTOR-dtls_srtp",t*2+e*2),{clientKey:n,serverKey:i,clientSalt:s,serverSalt:a}=(0,vv.decode)(r,{clientKey:vv.types.buffer(t),serverKey:vv.types.buffer(t),clientSalt:vv.types.buffer(e),serverSalt:vv.types.buffer(e)});return this.sessionType===Ap.CLIENT?{localKey:n,localSalt:s,remoteKey:i,remoteSalt:a}:{localKey:i,localSalt:a,remoteKey:n,remoteSalt:s}}exportKeyingMaterial(t,e){return N3t(t,e,this.cipher.masterSecret,this.cipher.localRandom.serialize(),this.cipher.remoteRandom.serialize(),this.sessionType===Ap.CLIENT)}get remoteCertificate(){return this.cipher.remoteCertificate}},Gse=_n("werift-dtls : packages/dtls/src/client.ts : log"),Dae=class extends woe{constructor(t){super(t,Ap.CLIENT),this.onHandleHandshakes=this.handleHandshakes,Gse(this.dtls.sessionId,"start client")}async connect(){await new J3t(this.transport,this.dtls,this.cipher).exec(this.extensions)}flight5;handleHandshakes=async t=>{Gse(this.dtls.sessionId,"handleHandshakes",t.map(e=>e.msg_type));for(let e of t)switch(e.msg_type){case 3:{let r=PBe.deSerialize(e.fragment);await new eDt(this.transport,this.dtls).exec(r)}break;case 2:{if(this.connected)return;this.flight5=new UDt(this.transport,this.dtls,this.cipher,this.srtp),this.flight5.handleHandshake(e)}break;case 11:case 12:case 13:await this.waitForReady(()=>!!this.flight5),this.flight5?.handleHandshake(e);break;case 14:{await this.waitForReady(()=>!!this.flight5),this.flight5?.handleHandshake(e);let r=[11,12,this.options.certificateRequest&&13].filter(n=>typeof n=="number");await this.waitForReady(()=>this.dtls.checkHandshakesExist(r)),await this.flight5?.exec()}break;case 20:this.dtls.flight=7,this.connected=!0,this.onConnect.execute(),Gse(this.dtls.sessionId,"dtls connected");break}}},Rh=_n("werift-dtls : packages/dtls/flight/server/flight2.ts : log"),WDt=(t,e,r,n)=>i=>{Rh("dtls version",i.clientVersion),e.flight=2,e.recordSequenceNumber=0,e.sequenceNumber=0,i.extensions.forEach(x=>{switch(x.type){case Cae.type:{let y=Cae.fromData(x.data).data;Rh(e.sessionId,"curves",y);let v=y.filter(w=>foe.includes(w))[0];r.namedCurve=v,Rh(e.sessionId,"curve selected",r.namedCurve)}break;case kae.type:{if(!r.signatureHashAlgorithm)throw new Error("need to set certificate");let y=kae.fromData(x.data).data;Rh(e.sessionId,"hash,signature",y);let v=y.find(S=>S.signature===r.signatureHashAlgorithm?.signature)?.signature,w=y.find(S=>S.hash===r.signatureHashAlgorithm?.hash)?.hash;if(v==null||w==null)throw new Error("invalid signatureHash")}break;case MS.type:{if(!e.options?.srtpProfiles||e.options.srtpProfiles.length===0)return;let y=MS.fromData(x.data);Rh(e.sessionId,"srtp profiles",y.profiles);let v=P6.findMatchingSRTPProfile(y.profiles,e.options?.srtpProfiles);if(!v)throw new Error;n.srtpProfile=v,Rh(e.sessionId,"srtp profile selected",n.srtpProfile)}break;case EM.type:e.remoteExtendedMasterSecret=!0;break;case TM.type:Rh(e.sessionId,"RenegotiationIndication",x.data);break;case 43:{let v=[...x.data.subarray(1)].map(w=>w.toString(10));Rh("dtls supported version",v)}break}}),r.localRandom=new wv,r.remoteRandom=wv.from(i.random);let s=i.cipherSuites;Rh(e.sessionId,"cipher suites",s);let a=(()=>{switch(r.signatureHashAlgorithm?.signature){case Uh.ecdsa_3:return oM.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_49195;case Uh.rsa_1:return oM.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256_49199}})();if(a===void 0||!s.includes(a))throw new Error("dtls cipher suite negotiation failed");r.cipherSuite=a,Rh(e.sessionId,"selected cipherSuite",r.cipherSuite),r.localKeyPair=b7e(r.namedCurve),e.cookie||=zDt(20);let c=new PBe({major:254,minor:253},e.cookie),d=x7e(e)([c]),p=G6(e)(d.map(x=>({type:22,fragment:x.serialize()})),++e.recordSequenceNumber).map(x=>x.serialize());for(let x of p)t.send(x)},tNe=_n("werift-dtls : packages/dtls/flight/server/flight4.ts : log"),HDt=class extends K6{constructor(t,e,r,n){super(t,e,4,6),this.cipher=r,this.srtp=n}async exec(t,e=!1){if(this.dtls.flight===4){tNe(this.dtls.sessionId,"flight4 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=4,this.dtls.sequenceNumber=1,this.dtls.bufferHandshakeCache([t],!1,4);let r=[this.sendServerHello(),this.sendCertificate(),this.sendServerKeyExchange(),e&&this.sendCertificateRequest(),this.sendServerHelloDone()].filter(n=>n);this.dtls.lastMessage=r,await this.transmit(r)}sendServerHello(){let t=[];this.srtp.srtpProfile&&t.push(MS.create([this.srtp.srtpProfile],Buffer.from([0])).extension),this.dtls.options.extendedMasterSecret&&t.push({type:EM.type,data:Buffer.alloc(0)});let e=TM.createEmpty();t.push(e.extension);let r=new E7e(this.dtls.version,this.cipher.localRandom,Buffer.from([0]),this.cipher.cipherSuite,0,t),n=this.createPacket([r]);return Buffer.concat(n.map(i=>i.serialize()))}sendCertificate(){let t=new uM([Buffer.from(this.cipher.localCert)]),e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}sendServerKeyExchange(){let t=this.cipher.generateKeySignature("sha256");if(!this.cipher.signatureHashAlgorithm)throw new Error("not exist");let e=new k7e(doe.named_curve_3,this.cipher.namedCurve,this.cipher.localKeyPair.publicKey.length,this.cipher.localKeyPair.publicKey,this.cipher.signatureHashAlgorithm.hash,this.cipher.signatureHashAlgorithm.signature,t.length,t),r=this.createPacket([e]);return Buffer.concat(r.map(n=>n.serialize()))}sendCertificateRequest(){let t=new A7e(i7e,hoe,[]);tNe(this.dtls.sessionId,"sendCertificateRequest",t);let e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}sendServerHelloDone(){let t=new T7e,e=this.createPacket([t]);return Buffer.concat(e.map(r=>r.serialize()))}},jS=_n("werift-dtls : packages/dtls/flight/server/flight6.ts"),VDt=class extends K6{constructor(t,e,r){super(t,e,6),this.cipher=r}handleHandshake(t){this.dtls.bufferHandshakeCache([t],!1,5);let e=(()=>{switch(t.msg_type){case 11:return uM.deSerialize(t.fragment);case 15:return w7e.deSerialize(t.fragment);case 16:return S7e.deSerialize(t.fragment);case 20:return fae.deSerialize(t.fragment)}})();if(e){let r=J6[e.msgType];if(!r)return;r({dtls:this.dtls,cipher:this.cipher})(e)}}async exec(){if(this.dtls.flight===6){jS(this.dtls.sessionId,"flight6 twice"),this.send(this.dtls.lastMessage);return}this.dtls.flight=6;let t=[this.sendChangeCipherSpec(),this.sendFinished()];this.dtls.lastMessage=t,await this.transmit(t)}sendChangeCipherSpec(){let t=_7e.createEmpty().serialize(),e=G6(this.dtls)([{type:20,fragment:t}],++this.dtls.recordSequenceNumber);return Buffer.concat(e.map(n=>n.serialize()))}sendFinished(){let t=Buffer.concat(this.dtls.sortedHandshakeCache.map(s=>s.serialize())),e=this.cipher.verifyData(t),r=new fae(e);this.dtls.epoch=1;let[n]=this.createPacket([r]);return this.dtls.recordSequenceNumber=0,this.cipher.encryptPacket(n).serialize()}},J6={};J6[16]=({cipher:t,dtls:e})=>r=>{if(t.remoteKeyPair={curve:t.namedCurve,publicKey:r.publicKey},!t.remoteKeyPair.publicKey||!t.localKeyPair||!t.remoteRandom||!t.localRandom)throw new Error("not exist");let n=o7e(t.remoteKeyPair.publicKey,t.localKeyPair.privateKey,t.localKeyPair.curve);jS(e.sessionId,"extendedMasterSecret",e.options.extendedMasterSecret,e.remoteExtendedMasterSecret);let i=Buffer.concat(e.sortedHandshakeCache.map(s=>s.serialize()));t.masterSecret=e.options.extendedMasterSecret&&e.remoteExtendedMasterSecret?u7e(n,i):c7e(n,t.remoteRandom.serialize(),t.localRandom.serialize()),t.cipher=y7e(t.cipherSuite),t.cipher.init(t.masterSecret,t.localRandom.serialize(),t.remoteRandom.serialize()),jS(e.sessionId,"setup cipher",t.cipher.summary)};J6[11]=({cipher:t,dtls:e})=>r=>{jS(e.sessionId,"handshake certificate",r),t.remoteCertificate=r.certificateList[0]};J6[15]=({cipher:t,dtls:e})=>r=>{if(!t.remoteCertificate)throw new Error("client certificate missing before certificate verify");jS(e.sessionId,"certificate_verify",r.algorithm)};J6[20]=({dtls:t})=>e=>{jS(t.sessionId,"finished",e)};ES=_n("werift-dtls : packages/dtls/src/server.ts : log"),RBe=class extends woe{constructor(t){super(t,Ap.SERVER),this.onHandleHandshakes=this.handleHandshakes,ES(this.dtls.sessionId,"start server")}flight6;handleHandshakes=async t=>{ES(this.dtls.sessionId,"handleHandshakes",t.map(e=>e.msg_type));for(let e of t)switch(e.msg_type){case 1:{this.connected&&this.renegotiation();let r=m7e.deSerialize(e.fragment);r.cookie.length===0?(ES(this.dtls.sessionId,"send flight2"),WDt(this.transport,this.dtls,this.cipher,this.srtp)(r)):this.dtls.cookie&&r.cookie.equals(this.dtls.cookie)?(ES(this.dtls.sessionId,"send flight4"),await new HDt(this.transport,this.dtls,this.cipher,this.srtp).exec(e,this.options.certificateRequest)):ES("wrong state",{dtlsCookie:this.dtls.cookie?.toString("hex").slice(10),helloCookie:r.cookie.toString("hex").slice(10)})}break;case 11:case 15:case 16:{if(this.connected)return;this.flight6=new VDt(this.transport,this.dtls,this.cipher),this.flight6.handleHandshake(e)}break;case 20:{await this.waitForReady(()=>!!this.flight6),this.flight6?.handleHandshake(e);let r=[16,this.options.certificateRequest&&11,this.options.certificateRequest&&15].filter(n=>typeof n=="number");await this.waitForReady(()=>this.dtls.checkHandshakesExist(r)),await this.flight6?.exec(),this.connected=!0,this.onConnect.execute(),ES(this.dtls.sessionId,"dtls connected")}break}}},DM=554869826,OBe=8,NBe=1398035790,_p=20,Soe=24,Aoe=1,Eoe=2,BBe=6,UBe=50,GDt=["FINGERPRINT","MESSAGE-INTEGRITY","CHANGE-REQUEST","PRIORITY","USERNAME","ICE-CONTROLLING","SOURCE-ADDRESS","USE-CANDIDATE","ICE-CONTROLLED","ERROR-CODE","XOR-MAPPED-ADDRESS","CHANGED-ADDRESS","LIFETIME","REQUESTED-TRANSPORT","NONCE","REALM","XOR-RELAYED-ADDRESS","CHANNEL-NUMBER","XOR-PEER-ADDRESS","DATA","SOFTWARE","MAPPED-ADDRESS","RESPONSE-ORIGIN","OTHER-ADDRESS"],Toe=(t=>(t[t.REQUEST=0]="REQUEST",t[t.INDICATION=16]="INDICATION",t[t.RESPONSE=256]="RESPONSE",t[t.ERROR=272]="ERROR",t))(Toe||{}),Coe=(t=>(t[t.BINDING=1]="BINDING",t[t.SHARED_SECRET=2]="SHARED_SECRET",t[t.ALLOCATE=3]="ALLOCATE",t[t.REFRESH=4]="REFRESH",t[t.SEND=6]="SEND",t[t.DATA=7]="DATA",t[t.CREATE_PERMISSION=8]="CREATE_PERMISSION",t[t.CHANNEL_BIND=9]="CHANNEL_BIND",t))(Coe||{});rNe=class{queue=[];wait=new yr;put(t){this.queue.push(t),this.queue.length===1&&this.wait.execute(t)}get(){let t=this.queue.shift();return t||new Promise(e=>{this.wait.subscribe(r=>{this.queue.shift(),e(r)})})}},Iae=t=>{let e,r,n=new Promise((s,a)=>{e=s,r=a});n.then(()=>{i.execute(void 0),i.complete()}).catch(s=>{i.execute(s??new Error),i.complete()});let i=new yr;return t(e,r,i).catch(()=>{}),{awaitable:n,resolve:e,reject:r}};koe=Buffer.alloc(6);koe.writeUInt16BE(DM>>16,0);koe.writeUInt32BE(DM,2);a6=t=>{let e=Buffer.alloc(4);return e.writeUInt32BE(t,0),e},o6=t=>t.readUInt32BE(0),XDt=t=>{let e=Buffer.alloc(4);return e.writeUInt16BE(t,0),e},YDt=t=>t.readUInt16BE(0),nNe=t=>new kse(t.toString()).toBuffer(),iNe=t=>{let e=new kse(t);return BigInt(e.toString())},Kse=t=>Buffer.from(t,"utf8"),Zse=t=>t.toString("utf8"),Xse=t=>t,Yse=t=>t,JDt=t=>Buffer.from([]),QDt=t=>null,qBe=[[1,"MAPPED-ADDRESS",DS,IS],[3,"CHANGE-REQUEST",a6,o6],[4,"SOURCE-ADDRESS",DS,IS],[5,"CHANGED-ADDRESS",DS,IS],[6,"USERNAME",Kse,Zse],[8,"MESSAGE-INTEGRITY",Xse,Yse],[9,"ERROR-CODE",ZDt,KDt],[12,"CHANNEL-NUMBER",XDt,YDt],[13,"LIFETIME",a6,o6],[18,"XOR-PEER-ADDRESS",GU,VU],[19,"DATA",Xse,Yse],[20,"REALM",Kse,Zse],[21,"NONCE",Xse,Yse],[22,"XOR-RELAYED-ADDRESS",GU,VU],[25,"REQUESTED-TRANSPORT",a6,o6],[32,"XOR-MAPPED-ADDRESS",GU,VU],[36,"PRIORITY",a6,o6],[37,"USE-CANDIDATE",JDt,QDt],[32802,"SOFTWARE",Kse,Zse],[32808,"FINGERPRINT",a6,o6],[32809,"ICE-CONTROLLED",nNe,iNe],[32810,"ICE-CONTROLLING",nNe,iNe],[32811,"RESPONSE-ORIGIN",DS,IS],[32812,"OTHER-ADDRESS",DS,IS]],zBe=class{constructor(t=[]){this.attributes=t}getAttributes(){return this.attributes}setAttribute(t,e){let r=this.attributes.find(n=>n[0]===t);return r?r[1]=e:this.attributes.push([t,e]),this}getAttributeValue(t){let e=this.attributes.find(r=>r[0]===t);if(e)return e[1]}get attributesKeys(){return this.attributes.map(t=>t[0])}clear(){this.attributes=[]}},sNe=qBe.reduce((t,e)=>(t[e[0]]=e,t),{}),e6t=qBe.reduce((t,e)=>(t[e[1]]=e,t),{});sf=class extends zBe{constructor(t,e,r=$Be(),n=[]){super(n),this.messageMethod=t,this.messageClass=e,this.transactionId=r}toJSON(){return this.json}get json(){return{messageMethod:Coe[this.messageMethod],messageClass:Toe[this.messageClass],attributes:this.attributes}}get transactionIdHex(){return this.transactionId.toString("hex")}get bytes(){let t=Buffer.from([]);for(let r of this.attributesKeys){let n=this.getAttributeValue(r),[i,,s]=e6t[r],a=s.name===GU.name?s(n,this.transactionId):s(n),c=a.length,d=4*Math.floor((c+3)/4)-c,h=Buffer.alloc(4);h.writeUInt16BE(i,0),h.writeUInt16BE(c,2),t=Buffer.concat([t,h,a,Buffer.alloc(d,0)])}let e=Buffer.alloc(8);return e.writeUInt16BE(this.messageMethod|this.messageClass,0),e.writeUInt16BE(t.length,2),e.writeUInt32BE(DM,4),Buffer.concat([e,this.transactionId,t])}addMessageIntegrity(t){return this.setAttribute("MESSAGE-INTEGRITY",this.messageIntegrity(t)),this}messageIntegrity(t){let e=Doe(this.bytes,this.bytes.length-_p+Soe);return Buffer.from(MBe("sha1",t).update(e).digest("hex"),"hex")}addFingerprint(){this.setAttribute("FINGERPRINT",WBe(this.bytes))}},Doe=(t,e)=>{let r=Buffer.alloc(t.length);return t.copy(r,0,0,2),r.writeUInt16BE(e,2),t.copy(r,4,4),r};HBe=class extends Error{response;addr},VBe=class extends HBe{constructor(t,e){super(),this.response=t,this.addr=e}get str(){let t="STUN transaction failed",e=this.response.getAttributeValue("ERROR-CODE");if(e){let[r,n]=e;t+=` (${r} - ${n})`}return t}},r6t=class extends HBe{get str(){return"STUN transaction timed out"}},Jse=_n("werift-ice:packages/ice/src/stun/transaction.ts"),Ioe=class{constructor(t,e,r,n){this.request=t,this.addr=e,this.protocol=r,this.retransmissions=n,this.triesMax=1+(this.retransmissions?this.retransmissions:BBe)}timeoutDelay=UBe;ended=!1;tries=0;triesMax;onResponse=new yr;responseReceived=(t,e)=>{this.onResponse.length>0&&(t.messageClass===256?(this.onResponse.execute(t,e),this.onResponse.complete()):this.onResponse.error(new VBe(t,e)))};run=async()=>{try{return this.retry().catch(e=>{Jse("retry failed",e)}),await this.onResponse.asPromise()}catch(t){throw t}finally{this.cancel()}};retry=async()=>{for(;this.tries<this.triesMax&&!this.ended&&(this.protocol.sendStun(this.request,this.addr).catch(t=>{Jse("send stun failed",t)}),await new Promise(t=>setTimeout(t,this.timeoutDelay)),!this.ended);)this.timeoutDelay*=2,this.tries++;this.tries>=this.triesMax&&(Jse(`retry failed times:${this.tries} maxLimit:${this.triesMax}`),this.onResponse.error(new r6t))};cancel(){this.ended=!0}},aNe=_n("werift-ice : packages/ice/src/stun/protocol.ts"),fM=class GBe{static type="stun";type=GBe.type;transport;transactions={};get transactionsKeys(){return Object.keys(this.transactions)}localCandidate;sentMessage;localIp;onRequestReceived=new yr;onDataReceived=new yr;constructor(){}connectionMade=async(e,r,n)=>{e?this.transport=await aM.init("udp4",{portRange:r,interfaceAddresses:n}):this.transport=await aM.init("udp6",{portRange:r,interfaceAddresses:n}),this.transport.onData=(i,s)=>{this.datagramReceived(i,s)}};datagramReceived(e,r){try{let n=IM(e);if(!n){this.localCandidate&&this.onDataReceived.execute(e);return}(n.messageClass===256||n.messageClass===272)&&this.transactionsKeys.includes(n.transactionIdHex)?this.transactions[n.transactionIdHex].responseReceived(n,r):n.messageClass===0&&this.onRequestReceived.execute(n,r,e)}catch(n){aNe("datagramReceived error",n)}}getExtraInfo(){let{address:e,port:r}=this.transport.address;return[e,r]}async sendStun(e,r){if(this.transport.closed)return;let n=e.bytes;await this.transport.send(n,r).catch(()=>{aNe("sendStun failed",r,e)})}async sendData(e,r){this.transport.closed||await this.transport.send(e,r)}async request(e,r,n,i){if(this.transactionsKeys.includes(e.transactionIdHex))throw new Error("already request ed");n&&(e.addMessageIntegrity(n),e.addFingerprint());let s=new Ioe(e,r,this,i);this.transactions[e.transactionIdHex]=s;try{return await s.run()}catch(a){throw a}finally{delete this.transactions[e.transactionIdHex]}}async close(){Object.values(this.transactions).forEach(e=>{e.cancel()}),await this.transport.close(),this.onRequestReceived.complete(),this.onDataReceived.complete()}},Nu=_n("werift-ice:packages/ice/src/turn/protocol.ts"),s6t=500,a6t=600,o6t=285212672,KBe=class ZBe{constructor(e){this.turn=e,e.onData.subscribe((r,n)=>{this.handleStunMessage(r,n)}).disposer(this.disposer)}static type="turn";type=ZBe.type;localCandidate;disposer=new JNe;onRequestReceived=new yr;onDataReceived=new yr;handleStunMessage=(e,r)=>{try{let n=IM(e);if(!n){this.onDataReceived.execute(e);return}if(n.messageClass===256||n.messageClass===272){let i=this.turn.transactions[n.transactionIdHex];i&&i.responseReceived(n,r)}else n.messageClass===0&&this.onRequestReceived.execute(n,r,e)}catch(n){Nu("datagramReceived error",n)}};async request(e,r,n){if(this.turn.transactions[e.transactionIdHex])throw new Error("exist");n&&(e.addMessageIntegrity(n),e.addFingerprint());let i=new Ioe(e,r,this);this.turn.transactions[e.transactionIdHex]=i;try{return await i.run()}catch(s){throw s}finally{delete this.turn.transactions[e.transactionIdHex]}}async connectionMade(){}async sendData(e,r){await this.turn.sendData(e,r)}async sendStun(e,r){await this.turn.sendData(e.bytes,r)}async close(){return this.disposer.dispose(),this.turn.close()}},XBe=class YBe{constructor(e,r,n,i,s,a={}){this.server=e,this.username=r,this.password=n,this.lifetime=i,this.transport=s,this.options=a,this.channelRefreshTime=this.options.channelRefreshTime??s6t}static type="turn";type=YBe.type;onData=new yr;onRequestReceived=new yr;onDataReceived=new yr;integrityKey;nonce;realm;relayedAddress;mappedAddress;localCandidate;transactions={};refreshHandle;channelNumber=16384;channelByAddr={};addrByChannel={};channelRefreshTime;channelBinding;channelRefreshAt=0;tcpBuffer=Buffer.alloc(0);permissionByAddr={};creatingPermission=Promise.resolve();async connectionMade(){this.transport.onData=(i,s)=>{this.dataReceived(i,s)};let e=new sf(3,0);e.setAttribute("LIFETIME",this.lifetime).setAttribute("REQUESTED-TRANSPORT",o6t);let[r]=await this.requestWithRetry(e,this.server).catch(i=>{throw Nu("connect error",i),i});this.relayedAddress=r.getAttributeValue("XOR-RELAYED-ADDRESS"),this.mappedAddress=r.getAttributeValue("XOR-MAPPED-ADDRESS");let n=r.getAttributeValue("LIFETIME");Nu("connect",this.relayedAddress,this.mappedAddress,{exp:n}),this.refresh(n)}handleChannelData(e){let[r,n]=Pae.jspack.Unpack("!HH",e.slice(0,4)),i=this.addrByChannel[r];if(i){let s=e.subarray(4,4+n);this.onData.execute(s,i)}}handleSTUNMessage(e,r){try{let n=IM(e);if(!n)throw new Error("not stun message");if(n.messageClass===256||n.messageClass===272){let i=this.transactions[n.transactionIdHex];i&&i.responseReceived(n,r)}else n.messageClass===0&&this.onData.execute(e,r);if(n.getAttributeValue("DATA")){let i=n.getAttributeValue("DATA");this.onData.execute(i,r)}}catch{Nu("parse error",e.toString())}}dataReceived(e,r){let n=(i,s)=>{i.length>=4&&oNe(i)?this.handleChannelData(i):this.handleSTUNMessage(i,s)};if(this.transport.type==="tcp")for(this.tcpBuffer=Buffer.concat([this.tcpBuffer,e]);this.tcpBuffer.length>=4;){let[,i]=zc(this.tcpBuffer.subarray(0,4),[2,2]);i+=Fae(i);let s=oNe(this.tcpBuffer)?4+i:20+i;if(this.tcpBuffer.length<s)break;n(this.tcpBuffer.subarray(0,s),r),this.tcpBuffer=this.tcpBuffer.subarray(s)}else n(e,r)}async send(e,r){if(!this.transport.closed)if(this.transport.type==="tcp"){let n=Fae(e.length);await this.transport.send(n>0?Buffer.concat([e,Buffer.alloc(n)]):e,r)}else await this.transport.send(e,r)}async createPermission(e){let r=new sf(8,0);r.setAttribute("XOR-PEER-ADDRESS",e).setAttribute("USERNAME",this.username).setAttribute("REALM",this.realm).setAttribute("NONCE",this.nonce),await this.request(r,this.server).catch(n=>{throw n})}refresh=e=>{this.refreshHandle=Iae(async(r,n,i)=>{let s=!0;for(i.once(()=>{s=!1});s;){let a=.8333333333333334*e*1e3;Nu("refresh delay",a,{exp:e}),await i6t(a);let c=new sf(4,0);c.setAttribute("LIFETIME",e);try{let[d]=await this.requestWithRetry(c,this.server);e=d.getAttributeValue("LIFETIME"),Nu("refresh",{exp:e})}catch(d){Nu("refresh error",d)}}})};async request(e,r){if(this.transactions[e.transactionIdHex])throw new Error("exist");this.integrityKey&&e.setAttribute("USERNAME",this.username).setAttribute("REALM",this.realm).setAttribute("NONCE",this.nonce).addMessageIntegrity(this.integrityKey).addFingerprint();let n=new Ioe(e,r,this);this.transactions[e.transactionIdHex]=n;try{return await n.run()}catch(i){throw i}finally{delete this.transactions[e.transactionIdHex]}}async requestWithRetry(e,r){let n,i;try{[n,i]=await this.request(e,r)}catch(s){if(!(s instanceof VBe))throw Nu("requestWithRetry error",s),s;this.server=s.addr;let[a]=s.response.getAttributeValue("ERROR-CODE"),c=s.response.getAttributeValue("NONCE"),d=s.response.getAttributeValue("REALM");if((a===401&&d||a===438&&this.realm)&&c)Nu("retry with nonce",a),this.nonce=c,a===401&&(this.realm=d),this.integrityKey=QBe(this.username,this.realm,this.password),e.transactionId=$Be(),[n,i]=await this.request(e,this.server);else throw s}return[n,i]}async sendData(e,r){let n=await this.getChannel(r).catch(s=>new Error("channelBind error"));if(n instanceof Error){await this.getPermission(r);let s=new sf(6,16).setAttribute("DATA",e).setAttribute("XOR-PEER-ADDRESS",r);await this.sendStun(s,this.server);return}let i=Pae.jspack.Pack("!HH",[n.number,e.length]);await this.send(Buffer.concat([Buffer.from(i),e]),this.server)}async getPermission(e){await this.creatingPermission,this.permissionByAddr[e.join(":")]||(this.creatingPermission=this.createPermission(e),this.permissionByAddr[e.join(":")]=!0,await this.creatingPermission.catch(n=>{throw Nu("createPermission error",n),n}))}async getChannel(e){this.channelBinding&&await this.channelBinding;let r=this.channelByAddr[e.join(":")];return r?this.channelRefreshAt<OS(Date.now()/1e3)&&(this.channelBinding=this.channelBind(r.number,e),this.channelRefreshAt=OS(Date.now()/1e3)+this.channelRefreshTime,await this.channelBinding.catch(n=>{throw Nu("channelBind error",n),n}),this.channelBinding=void 0,Nu("channelBind refresh",r)):(this.channelByAddr[e.join(":")]={number:this.channelNumber++,address:e},r=this.channelByAddr[e.join(":")],this.addrByChannel[r.number]=e,this.channelBinding=this.channelBind(r.number,e),await this.channelBinding.catch(n=>{throw Nu("channelBind error",n),n}),this.channelRefreshAt=OS(Date.now()/1e3)+this.channelRefreshTime,this.channelBinding=void 0,Nu("channelBind",r)),r}async channelBind(e,r){let n=new sf(9,0);n.setAttribute("CHANNEL-NUMBER",e).setAttribute("XOR-PEER-ADDRESS",r);let[i]=await this.requestWithRetry(n,this.server);if(i.messageMethod!==9)throw new Error("should be CHANNEL_BIND")}async sendStun(e,r){await this.send(e.bytes,r)}async close(){this.refreshHandle?.resolve?.(),await this.transport.close()}};$g=class eUe{constructor(e,r,n,i,s,a,c,d,h,p,x,y){this.foundation=e,this.component=r,this.transport=n,this.priority=i,this.host=s,this.port=a,this.type=c,this.relatedAddress=d,this.relatedPort=h,this.tcptype=p,this.generation=x,this.ufrag=y}static fromSdp(e){let r=e.split(" ");if(r.length<8)throw new Error("SDP does not have enough properties");let n={foundation:r[0],component:Number(r[1]),transport:r[2],priority:Number(r[3]),host:r[4],port:Number(r[5]),type:r[7]};for(let x=8,y=r.length-1;x<y;x+=2)r[x]==="raddr"?n.related_address=r[x+1]:r[x]==="rport"?n.related_port=Number(r[x+1]):r[x]==="tcptype"?n.tcptype=r[x+1]:r[x]==="generation"?n.generation=Number(r[x+1]):r[x]==="ufrag"&&(n.ufrag=r[x+1]);let{foundation:i,component:s,transport:a,priority:c,host:d,port:h,type:p}=n;return new eUe(i,s,a,c,d,h,p,n.related_address,n.related_port,n.tcptype,n.generation,n.ufrag)}canPairWith(e){let r=cNe(this.host),n=cNe(e.host);return this.component===e.component&&this.transport.toLowerCase()===e.transport.toLowerCase()&&r===n}toSdp(){let e=`${this.foundation} ${this.component} ${this.transport} ${this.priority} ${this.host} ${this.port} typ ${this.type}`;return this.relatedAddress&&(e+=` raddr ${this.relatedAddress}`),this.relatedPort!=null&&(e+=` rport ${this.relatedPort}`),this.tcptype&&(e+=` tcptype ${this.tcptype}`),this.generation!=null&&(e+=` generation ${this.generation}`),this.ufrag!=null&&(e+=` ufrag ${this.ufrag}`),e}};l6t=class{cache=new Map;mdnsInstance=(0,tUe.default)();constructor(){this.mdnsInstance.setMaxListeners(50)}lookup(t){return new Promise((e,r)=>{let n=()=>{this.mdnsInstance.removeListener("response",s),clearTimeout(i)},i=setTimeout(()=>{n(),r(new Error("No mDNS response"))},1e4),s=a=>{let c=a.answers?.[0];c?.type==="A"&&c.name===t&&(n(),e(c.data))};this.mdnsInstance.on("response",s),this.mdnsInstance.query(t,"A")})}close(){this.mdnsInstance.destroy()}},d6t=_n("werift-ice : packages/ice/src/ice.ts : log"),Nae=class{constructor(t,e,r){this.protocol=t,this.remoteCandidate=e,this.iceControlling=r}id=f6t().toString();handle;nominated=!1;remoteNominated=!1;_state=0;get state(){return this._state}packetsSent=0;packetsReceived=0;bytesSent=0;bytesReceived=0;rtt;totalRoundTripTime=0;roundTripTimeMeasurements=0;toJSON(){return this.json}get json(){return{protocol:this.protocol.type,localCandidate:this.localCandidate.toSdp(),remoteCandidate:this.remoteCandidate.toSdp()}}updateState(t){this._state=t}get localCandidate(){if(!this.protocol.localCandidate)throw new Error("localCandidate not exist");return this.protocol.localCandidate}get remoteAddr(){return[this.remoteCandidate.host,this.remoteCandidate.port]}get component(){return this.localCandidate.component}get priority(){return hM(this.localCandidate,this.remoteCandidate,this.iceControlling)}get foundation(){return this.localCandidate.foundation}},Bae=1,_6=2,rUe=5,Uae=6,nUe=(t=>(t[t.FROZEN=0]="FROZEN",t[t.WAITING=1]="WAITING",t[t.IN_PROGRESS=2]="IN_PROGRESS",t[t.SUCCEEDED=3]="SUCCEEDED",t[t.FAILED=4]="FAILED",t))(nUe||{}),iUe={useIpv4:!0,useIpv6:!0};h6t=_n("werift-ice : packages/ice/src/utils.ts");m6t=t=>{if(!t)return;let[e,r]=t.split(":");return[e,Number.parseInt(r)]},Gi=_n("werift-ice : packages/ice/src/ice.ts : log"),fUe=class{constructor(t,e){this._iceControlling=t,this.options={...iUe,...e};let{stunServer:r,turnServer:n}=this.options;this.stunServer=Lae(r)??["stun.l.google.com",19302],this.turnServer=Lae(n),this.restart(),Gi("new Connection",this.options)}localUsername=s6(4);localPassword=s6(22);remoteIsLite=!1;remotePassword="";remoteUsername="";checkList=[];localCandidates=[];stunServer;turnServer;options;remoteCandidatesEnd=!1;localCandidatesEnd=!1;generation=-1;userHistory={};tieBreaker=BigInt(new OU(u6t(64)).toString());state="new";lookup;_remoteCandidates=[];nominated;nominating=!1;checkListDone=!1;checkListState=new rNe;earlyChecks=[];earlyChecksDone=!1;localCandidatesStart=!1;protocols=[];queryConsentHandle;onData=new yr;stateChanged=new yr;onIceCandidate=new yr;get iceControlling(){return this._iceControlling}set iceControlling(t){if(!(this.generation>0||this.nominated)){this._iceControlling=t;for(let e of this.checkList)e.iceControlling=t}}async restart(){this.generation++,this.localUsername=s6(4),this.localPassword=s6(22),this.options.localPasswordPrefix&&(this.localPassword=this.options.localPasswordPrefix+this.localPassword.slice(this.options.localPasswordPrefix.length)),this.userHistory[this.localUsername]=this.localPassword,this.remoteUsername="",this.remotePassword="",this.localCandidates=[],this._remoteCandidates=[],this.remoteCandidatesEnd=!1,this.localCandidatesEnd=!1,this.state="new",this.lookup?.close?.(),this.lookup=void 0,this.nominated=void 0,this.nominating=!1,this.checkList=[],this.checkListDone=!1,this.checkListState=new rNe,this.earlyChecks=[],this.earlyChecksDone=!1,this.localCandidatesStart=!1;for(let t of this.protocols)t.localCandidate&&(t.localCandidate.generation=this.generation,t.localCandidate.ufrag=this.localUsername);this.queryConsentHandle?.resolve?.(),this.queryConsentHandle=void 0}resetNominatedPair(){Gi("resetNominatedPair"),this.nominated=void 0,this.nominating=!1}setRemoteParams({iceLite:t,usernameFragment:e,password:r}){Gi("setRemoteParams",{iceLite:t,usernameFragment:e,password:r}),this.remoteIsLite=t,this.remoteUsername=e,this.remotePassword=r}async gatherCandidates(){if(!this.localCandidatesStart){this.localCandidatesStart=!0;let t=lUe(this.options.useIpv4,this.options.useIpv6,{useLinkLocalAddress:this.options.useLinkLocalAddress}),{interfaceAddresses:e}=this.options;if(e){let n=t.filter(i=>Object.values(e).includes(i));n.length&&(t=n)}this.options.additionalHostAddresses&&(t=Array.from(new Set([...this.options.additionalHostAddresses,...t])));let r=this.getCandidatePromises(t,5);await Promise.allSettled(r),this.localCandidatesEnd=!0}this.setState("completed")}appendLocalCandidate(t){this.localCandidates.push(t),this.onIceCandidate.execute(t)}ensureProtocol(t){t.onRequestReceived.subscribe((e,r,n)=>{if(e.messageMethod!==1){this.respondError(e,r,t,[400,"Bad Request"]);return}let i=e.getAttributeValue("USERNAME"),{remoteUsername:s}=lNe(i),a=this.userHistory[s]??this.localPassword,{iceControlling:c}=this;if(c&&e.attributesKeys.includes("ICE-CONTROLLING"))if(this.tieBreaker>=e.getAttributeValue("ICE-CONTROLLING")){this.respondError(e,r,t,[487,"Role Conflict"]);return}else this.switchRole(!1);else if(!c&&e.attributesKeys.includes("ICE-CONTROLLED"))if(this.tieBreaker<e.getAttributeValue("ICE-CONTROLLED"))this.respondError(e,r,t,[487,"Role Conflict"]);else{this.switchRole(!0);return}if(this.options.filterStunResponse&&!this.options.filterStunResponse(e,r,t))return;let d=new sf(1,256,e.transactionId);d.setAttribute("XOR-MAPPED-ADDRESS",r).addMessageIntegrity(Buffer.from(a,"utf8")).addFingerprint(),t.sendStun(d,r).catch(h=>{Gi("sendStun error",h)}),this.checkList.length===0&&!this.earlyChecksDone?this.earlyChecks.push([e,r,t]):this.checkIncoming(e,r,t)}),t.onDataReceived.subscribe(e=>{try{let r=this.nominated;r&&r.protocol===t&&(r.packetsReceived++,r.bytesReceived+=e.length),this.onData.execute(e)}catch(r){Gi("dataReceived",r)}})}getCandidatePromises(t,e=5){let r=[];t=t.filter(d=>!this.protocols.find(h=>h.localIp===d));let n=t.map(async d=>{let h=new fM;this.ensureProtocol(h);try{await h.connectionMade(uNe(d),this.options.portRange,this.options.interfaceAddresses),h.localIp=d,this.protocols.push(h),Gi("protocol",h.localIp);let p=[d,h.getExtraInfo()[1]];return h.localCandidate=new $g(dM("host","udp",p[0]),1,"udp",E6("host"),p[0],p[1],"host",void 0,void 0,void 0,this.generation,this.localUsername),this.pairLocalProtocol(h),this.appendLocalCandidate(h.localCandidate),h}catch(p){Gi("error protocol STUN",p)}});r.push(...n.map(d=>d.then(h=>h?.localCandidate)));let{stunServer:i,turnServer:s}=this;if(i){let d=n.map(async h=>{let p=await h;return p?new Promise(async(y,v)=>{let w=setTimeout(v,e*1e3);if(p.localCandidate?.host&&uNe(p.localCandidate?.host)){let S=await aUe(p,i).catch(C=>{Gi("error",C)});S&&this.appendLocalCandidate(S),clearTimeout(w),y(S)}else clearTimeout(w),y()}).catch(y=>{Gi("query STUN server",y)}):void 0});r.push(...d)}let{turnUsername:a,turnPassword:c}=this.options;if(s&&a&&c){let d=(async()=>{let h=await Rae({address:s,username:a,password:c},{portRange:this.options.portRange,interfaceAddresses:this.options.interfaceAddresses,transport:this.options.turnTransport==="tcp"?"tcp":"udp"}).catch(async y=>{if(this.options.turnTransport!=="tcp")return await Rae({address:s,username:a,password:c},{portRange:this.options.portRange,interfaceAddresses:this.options.interfaceAddresses,transport:"tcp"});throw y});this.ensureProtocol(h),this.protocols.push(h);let p=h.turn.relayedAddress,x=h.turn.mappedAddress;return Gi("turn candidateAddress",p),h.localCandidate=new $g(dM("relay","udp",p[0]),1,"udp",E6("relay"),p[0],p[1],"relay",x[0],x[1],void 0,this.generation,this.localUsername),this.appendLocalCandidate(h.localCandidate),h.localCandidate})().catch(h=>{Gi("query TURN server",h)});this.options.forceTurn&&(r=[]),r.push(d)}return r}async connect(){if(Gi("start connect ice"),!this.localCandidatesEnd&&!this.localCandidatesStart)throw new Error("Local candidates gathering was not performed");if(!this.remoteUsername||!this.remotePassword)throw new Error("Remote username or password is missing");for(let e of this.remoteCandidates)this.pairRemoteCandidate(e);this.sortCheckList(),this.unfreezeInitial(),Gi("earlyChecks",this.localPassword,this.earlyChecks.length);for(let e of this.earlyChecks)this.checkIncoming(...e);for(this.earlyChecks=[],this.earlyChecksDone=!0;!(this.state==="closed"||!this.schedulingChecks());)await Oae.setTimeout(20);let t=_6;for(;this.checkList.length>0&&t===_6;)t=await this.checkListState.get(),Gi("checkListState",t);for(let e of this.checkList)e.handle?.resolve?.();if(t!==Bae)throw new Error("ICE negotiation failed");this.queryConsent(),this.setState("connected")}unfreezeInitial(){let[t]=this.checkList;if(!t)return;t.state===0&&t.updateState(1);let e=new Set(t.localCandidate.foundation);for(let r of this.checkList)r.component===t.component&&!e.has(r.localCandidate.foundation)&&r.state===0&&(r.updateState(1),e.add(r.localCandidate.foundation))}schedulingChecks(){{let t=this.checkList.filter(e=>!(this.options.forceTurn&&e.protocol.type===fM.type)).find(e=>e.state===1);if(t)return t.handle=this.checkStart(t),!0}{let t=this.checkList.find(e=>e.state===0);if(t)return t.handle=this.checkStart(t),!0}return this.remoteCandidatesEnd?!1:!this.checkListDone}queryConsent=()=>{this.queryConsentHandle&&this.queryConsentHandle.resolve(),this.queryConsentHandle=Iae(async(t,e,r)=>{let n=0,i=!1,s=new AbortController;r.once(()=>{i=!0,n+=Uae,s.abort(),this.queryConsentHandle=void 0});let{localUsername:a,remoteUsername:c,iceControlling:d}=this;try{for(;this.state!=="closed"&&!i;){await Oae.setTimeout(rUe*(.8+.4*Math.random())*1e3,void 0,{signal:s.signal});let h=this.nominated;if(!h||i)break;let p=this.buildRequest({nominate:!1,localUsername:a,remoteUsername:c,iceControlling:d});try{await h.protocol.request(p,h.remoteAddr,Buffer.from(this.remotePassword,"utf8"),0),n=0,this.state==="disconnected"&&this.setState("connected")}catch{if(h.id===this.nominated?.id){Gi("no stun response"),n++,this.setState("disconnected");break}}if(n>=Uae){Gi("Consent to send expired"),this.queryConsentHandle=void 0,this.setState("closed");break}}}catch{}})};async close(){this.setState("closed"),this.queryConsentHandle?.resolve?.(),this.checkList&&!this.checkListDone&&this.checkListState.put(new Promise(t=>{t(_6)})),this.nominated=void 0;for(let t of this.protocols)t.close&&await t.close();this.protocols=[],this.localCandidates=[],this.lookup?.close?.(),this.lookup=void 0}setState(t){this.state=t,this.stateChanged.execute(t)}async addRemoteCandidate(t){if(!t){this.remoteCandidatesEnd=!0;return}if(t.host.includes(".local"))try{this.lookup||(this.lookup=new l6t);let e=await this.lookup.lookup(t.host);t.host=e}catch{return}try{Mae(t)}catch{return}Gi("addRemoteCandidate",t),this._remoteCandidates.push(t),this.pairRemoteCandidate(t),this.sortCheckList()}send=async t=>{let e=this.nominated;if(e)await e.protocol.sendData(t,e.remoteAddr),e.packetsSent++,e.bytesSent+=t.length;else return};getDefaultCandidate(){let t=this.localCandidates.sort((r,n)=>r.priority-n.priority),[e]=t;return e}set remoteCandidates(t){if(this.remoteCandidatesEnd)throw new Error("Cannot set remote candidates after end-of-candidates.");this._remoteCandidates=[];for(let e of t){try{Mae(e)}catch{continue}this._remoteCandidates.push(e)}this.remoteCandidatesEnd=!0}get remoteCandidates(){return this._remoteCandidates}get candidatePairs(){return this.checkList}sortCheckList(){sUe(this.checkList,this.iceControlling)}findPair(t,e){return this.checkList.find(n=>(0,KU.default)(n.protocol,t)&&(0,KU.default)(n.remoteCandidate,e))}switchRole(t){Gi("switch role",t),this.iceControlling=t,this.sortCheckList()}checkComplete(t){if(t.handle=void 0,t.state===3){if(t.nominated&&(t.remoteCandidate.generation==null||t.remoteCandidate.generation===this.generation)&&this.nominated==null){Gi("nominated",t.toJSON()),this.nominated=t,this.nominating=!1;for(let e of this.checkList)e.component===t.component&&[1,0].includes(e.state)&&e.updateState(4)}if(this.nominated){this.checkListDone||(Gi("ICE completed"),this.checkListState.put(new Promise(e=>e(Bae))),this.checkListDone=!0);return}Gi("not completed",t.toJSON());for(let e of this.checkList)e.localCandidate.foundation===t.localCandidate.foundation&&e.state===0&&e.updateState(1)}{let e=[3,4];if(this.checkList.find(({state:r})=>!e.includes(r)))return}!this.iceControlling&&this.checkList.find(({state:r})=>r===3)||this.checkListDone||(Gi("ICE failed"),this.checkListState.put(new Promise(e=>{e(_6)})))}checkStart=t=>Iae(async e=>{Gi("check start",t.toJSON()),t.updateState(2);let r={},{remotePassword:n,remoteUsername:i,generation:s}=this,a=t.localCandidate.ufrag??this.localUsername,c=this.iceControlling&&!this.remoteIsLite,d=this.buildRequest({nominate:c,localUsername:a,remoteUsername:i,iceControlling:this.iceControlling}),h=performance.now();try{let[p,x]=await t.protocol.request(d,t.remoteAddr,Buffer.from(n,"utf8"),4),v=(performance.now()-h)/1e3;t.rtt=v,t.totalRoundTripTime+=v,t.roundTripTimeMeasurements++,Gi("response received",d.toJSON(),p.toJSON(),x,{localUsername:a,remoteUsername:i,remotePassword:n,generation:s,rtt:v}),r.response=p,r.addr=x}catch(p){let x=p;if(Gi("failure case",d.toJSON(),x.response?JSON.stringify(x.response.toJSON(),null,2):p,{localUsername:a,remoteUsername:i,remotePassword:n,generation:s},t.remoteAddr),x.response?.getAttributeValue("ERROR-CODE")[0]===487){d.attributesKeys.includes("ICE-CONTROLLED")?this.switchRole(!0):d.attributesKeys.includes("ICE-CONTROLLING")&&this.switchRole(!1),await this.checkStart(t).awaitable,e();return}if(x.response?.getAttributeValue("ERROR-CODE")[0]===401){Gi("retry 401",t.toJSON()),await this.checkStart(t).awaitable,e();return}else{Gi("checkStart CandidatePairState.FAILED",t.toJSON()),t.updateState(4),this.checkComplete(t),e();return}}if(!(0,KU.default)(r.addr,t.remoteAddr)){t.updateState(4),this.checkComplete(t),e();return}if(c||t.remoteNominated)t.nominated=!0;else if(this.iceControlling&&!this.nominating){this.nominating=!0;let p=this.buildRequest({nominate:!0,localUsername:a,remoteUsername:i,iceControlling:this.iceControlling});try{await t.protocol.request(p,t.remoteAddr,Buffer.from(this.remotePassword,"utf8"))}catch{t.updateState(4),this.checkComplete(t);return}t.nominated=!0}t.updateState(3),this.checkComplete(t),e()});addPair(t){this.checkList.push(t),this.sortCheckList()}checkIncoming(t,e,r){let n=t.getAttributeValue("USERNAME"),{remoteUsername:i}=lNe(n),s,[a,c]=e;for(let h of this.remoteCandidates)if(h.host===a&&h.port===c){s=h;break}s||(s=new $g(s6(10),1,"udp",t.getAttributeValue("PRIORITY"),a,c,"prflx",void 0,void 0,void 0,void 0,void 0),this._remoteCandidates.push(s));let d=this.findPair(r,s);d||(d=new Nae(r,s,this.iceControlling),d.updateState(1),this.addPair(d)),d.localCandidate.ufrag=i,Gi("Triggered Checks",t.toJSON(),d.toJSON(),{localUsername:this.localUsername,remoteUsername:this.remoteUsername,localPassword:this.localPassword,remotePassword:this.remotePassword,generation:this.generation}),[1,4].includes(d.state)&&(d.handle=this.checkStart(d)),t.attributesKeys.includes("USE-CANDIDATE")&&!this.iceControlling&&(d.remoteNominated=!0,d.state===3&&(d.nominated=!0,this.checkComplete(d)))}tryPair(t,e){if(t.localCandidate?.canPairWith(e)&&!this.findPair(t,e)){let r=new Nae(t,e,this.iceControlling);if(this.options.filterCandidatePair&&!this.options.filterCandidatePair(r))return;r.updateState(1),this.addPair(r)}}pairLocalProtocol(t){for(let e of this.remoteCandidates)this.tryPair(t,e)}pairRemoteCandidate=t=>{for(let e of this.protocols)this.tryPair(e,t)};buildRequest({nominate:t,remoteUsername:e,localUsername:r,iceControlling:n}){let i=g6t({remoteUsername:e,localUsername:r}),s=new sf(1,0);return s.setAttribute("USERNAME",i).setAttribute("PRIORITY",E6("prflx")),n?(s.setAttribute("ICE-CONTROLLING",this.tieBreaker),t&&s.setAttribute("USE-CANDIDATE",null)):s.setAttribute("ICE-CONTROLLED",this.tieBreaker),s}respondError(t,e,r,n){let i=new sf(t.messageMethod,272,t.transactionId);i.setAttribute("ERROR-CODE",n).addMessageIntegrity(Buffer.from(this.localPassword,"utf8")).addFingerprint(),r.sendStun(i,e).catch(s=>{Gi("sendStun error",s)})}},g6t=({remoteUsername:t,localUsername:e})=>`${t}:${e}`,lNe=t=>{let[e,r]=t.split(":");return{remoteUsername:e,localUsername:r}};Foe=class extends x6t{addEventListener=(t,e)=>{this.addListener(t,e)};removeEventListener=(t,e)=>{this.removeListener(t,e)}},y6t=_n("werift:packages/webrtc/src/dataChannel.ts");Poe=class extends Foe{constructor(t,e,r=!0){if(super(),this.sctp=t,this.parameters=e,this.sendOpen=r,this.id=this.parameters.id,e.negotiated){if(this.id==null||this.id<0||this.id>65534)throw new Error("ID must be in range 0-65534 if data channel is negotiated out-of-band");this.sctp.dataChannelAddNegotiated(this)}else r&&(this.sendOpen=!1,this.sctp.dataChannelOpen(this))}stateChange=new yr;stateChanged=new yr;onMessage=new yr;error=new yr;bufferedAmountLow=new yr;onopen;onclose;onclosing;onmessage;onerror;isCreatedByRemote=!1;id;readyState="connecting";bufferedAmount=0;_bufferedAmountLowThreshold=0;messagesSent=0;bytesSent=0;messagesReceived=0;bytesReceived=0;get ordered(){return this.parameters.ordered}get maxRetransmits(){return this.parameters.maxRetransmits}get maxPacketLifeTime(){return this.parameters.maxPacketLifeTime}get label(){return this.parameters.label}get protocol(){return this.parameters.protocol}get negotiated(){return this.parameters.negotiated}get bufferedAmountLowThreshold(){return this._bufferedAmountLowThreshold}set bufferedAmountLowThreshold(t){if(t<0||t>4294967295)throw new Error("bufferedAmountLowThreshold must be in range 0 - 4294967295");this._bufferedAmountLowThreshold=t}setId(t){this.id=t}setReadyState(t){if(t!==this.readyState){switch(this.readyState=t,this.stateChange.execute(t),this.stateChanged.execute(t),t){case"open":this.onopen&&this.onopen(),this.emit("open");break;case"closed":this.onclose&&this.onclose(),this.emit("close");break;case"closing":this.onclosing&&this.onclosing();break}y6t("change state",t)}}addBufferedAmount(t){let e=this.bufferedAmount>this.bufferedAmountLowThreshold&&this.bufferedAmount+t<=this.bufferedAmountLowThreshold;this.bufferedAmount+=t,e&&(this.bufferedAmountLow.execute(),this.emit("bufferedamountlow"))}send(t){let e=this.sctp.datachannelSend(this,t);this.messagesSent++,this.bytesSent+=e}close(){this.sctp.dataChannelClose(this)}},Roe=class{label="";maxPacketLifeTime;maxRetransmits;ordered=!0;protocol="";negotiated=!1;id;constructor(t={}){Object.assign(this,t)}},v6t=()=>({type:"ccm",parameter:"fir"}),Q6=()=>({type:"nack"}),GS=()=>({type:"nack",parameter:"pli"}),e8=()=>({type:"goog-remb"}),hUe=()=>({type:"transport-cc"}),jg=class{payloadType;mimeType;clockRate;channels;rtcpFeedback=[];parameters;direction="all";constructor(t){Object.assign(this,t)}get name(){return this.mimeType.split("/")[1]}get contentType(){return this.mimeType.split("/")[0]}get str(){let t=`${this.name}/${this.clockRate}`;return this.channels===2&&(t+="/2"),t}},Mh=class{id;uri;constructor(t){Object.assign(this,t)}},b6t=class{cname;mux=!1;ssrc;constructor(t={}){Object.assign(this,t)}},pUe=class{type;parameter;constructor(t={}){Object.assign(this,t)}},mUe=class{ssrc;constructor(t={}){Object.assign(this,t)}},gUe=class{ssrc;payloadType;rtx;constructor(t){Object.assign(this,t)}},Ooe=class{rid;direction;constructor(t){Object.assign(this,t)}},xUe=(t={})=>new jg({mimeType:"video/h264",clockRate:9e4,rtcpFeedback:[Q6(),GS(),e8()],parameters:"profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1",...t}),Noe=(t={})=>new jg({mimeType:"video/VP8",clockRate:9e4,rtcpFeedback:[Q6(),GS(),e8()],...t}),yUe=(t={})=>new jg({mimeType:"video/VP9",clockRate:9e4,rtcpFeedback:[Q6(),GS(),e8()],...t}),vUe=(t={})=>new jg({mimeType:"video/AV1X",clockRate:9e4,rtcpFeedback:[Q6(),GS(),e8()],...t}),Boe=(t={})=>new jg({mimeType:"audio/OPUS",clockRate:48e3,channels:2,...t}),Uoe=(t={})=>new jg({mimeType:"audio/PCMU",clockRate:8e3,channels:1,payloadType:0,...t}),Moe=[vUe(),yUe(),Noe(),xUe(),Boe(),Uoe()].map(t=>t.mimeType),_6t=Moe.filter(t=>t.toLowerCase().startsWith("video/")),w6t=Moe.filter(t=>t.toLowerCase().startsWith("audio/"));hNe=2,pNe=3,N6t=0,LU=50,mNe=51,gNe=53,B6t=56,U6t=57,M6t="0.0.0.0",xNe=9,jae={auto:"actpass",client:"active",server:"passive"},yNe=Object.keys(jae).reduce((t,e)=>{let r=jae[e];return t[r]=e,t},{}),L6t=["apt","max-fr","max-fs","maxplaybackrate","minptime","stereo","useinbandfec"],bUe=["cname","msid","mslabel","label"],vNe={SRTP_AES128_CM_HMAC_SHA1_80:HS,SRTP_AEAD_AES_128_GCM:Fv},ZU=["sendonly","sendrecv"],$6t=["sendrecv","recvonly"],_Ue=class extends Map{constructor(t){if(super(),t)for(let e of t)this.set(e.id,e)}};wUe=class{constructor(t,e,r,n,i){this.kind=t,this.receiver=r,this.sender=n,this._direction=i,e&&this.setDtlsTransport(e)}id=O6t().toString();onTrack=new yr;mid;mLineIndex;usedForSender=!1;_currentDirection;offerDirection;_codecs=[];set codecs(t){this._codecs=t}get codecs(){return this._codecs}headerExtensions=[];options={};stopping=!1;stopped=!1;get dtlsTransport(){return this.receiver.dtlsTransport}get direction(){return this._direction}setDirection(t){this._direction=t,ZU.includes(this._currentDirection??"")&&(this.usedForSender=!0)}get currentDirection(){return this._currentDirection}setCurrentDirection(t){this._currentDirection=t}setDtlsTransport(t){this.receiver.setDtlsTransport(t),this.sender.setDtlsTransport(t)}get msid(){return`${this.sender.streamId} ${this.sender.trackId}`}addTrack(t){this.receiver.addTrack(t)&&this.onTrack.execute(t,this)}stop(){this.stopping||(this.stopping=!0)}getPayloadType(t){return this.codecs.find(e=>e.mimeType.toLowerCase().includes(t.toLowerCase()))?.payloadType}getCodecStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id);for(let n of this.codecs){let i={type:"codec",id:rs("codec",n.payloadType,r),timestamp:t,payloadType:n.payloadType,transportId:r,mimeType:n.mimeType,clockRate:n.clockRate,channels:n.channels,sdpFmtpLine:n.parameters};e.push(i)}return e}},SUe="inactive",Loe="sendonly",$oe="recvonly",joe="sendrecv",XU=[SUe,Loe,$oe,joe],q6=class extends Foe{uuid=AUe().toString();streamId;remote=!1;label;kind;id;ssrc;rid;header;codec;enabled=!0;onReceiveRtp=new yr;onReceiveRtcp=new yr;onSourceChanged=new yr;stopped=!1;muted=!0;constructor(t){super(),Object.assign(this,t),this.onReceiveRtp.subscribe(e=>{this.muted=!1,this.header=e.header}),this.label=`${this.remote?"remote":"local"} ${this.kind}`}stop=()=>{this.stopped=!0,this.muted=!0,this.onReceiveRtp.complete(),this.emit("ended")};writeRtp=t=>{if(this.remote)throw new Error("this is remoteTrack");if(this.stopped)return;let e=Buffer.isBuffer(t)?Cp.deSerialize(t):t;e.header.payloadType=this.codec?.payloadType??e.header.payloadType,this.onReceiveRtp.execute(e)}},EUe=class{id;tracks=[];constructor(t){Array.isArray(t)?this.tracks=t:Object.assign(this,t),this.id??=AUe().toString()}addTrack(t){t.streamId=this.id,this.tracks.push(t)}getTracks(){return this.tracks}getAudioTracks(){return this.tracks.filter(t=>t.kind==="audio")}getVideoTracks(){return this.tracks.filter(t=>t.kind==="video")}},j6t=_n("werift:packages/webrtc/src/utils.ts");q6t={sha1:"sha1","sha-1":"sha1",sha224:"sha224","sha-224":"sha224",sha256:"sha256","sha-256":"sha256",sha384:"sha384","sha-384":"sha384",sha512:"sha512","sha-512":"sha512"};Woe=(t,e)=>XU[XU.indexOf(t)&XU.indexOf(e)];Hoe=Date.now,W6t=BigInt(Date.now())*1000n-process.hrtime.bigint()/1000n,kUe=()=>W6t+process.hrtime.bigint()/1000n,z6=()=>Date.now()/1e3,DUe=()=>{let e=(dNe.timeOrigin+dNe.now()-Date.UTC(1900,0,1))/1e3,[r,n]=e.toString().split(".").map(Number);return Vs([4,4],[r,n]).readBigUInt64BE()},Voe=t=>{let e=Vs([8],[t]),[,r,n]=zc(e,[2,2,2,2]);return Vs([2,2],[r,n]).readUInt32BE()};H6t=F6.createSelfSignedCertificateWithKey,V6t=class{static async rtpSource({port:t,kind:e,cb:r}){t??=await loe();let n=new q6({kind:e}),i=R6t("udp4");i.bind(t);let s=c=>{r&&(c=r(c)),n.writeRtp(c)};return i.addListener("message",s),[n,t,()=>{i.removeListener("message",s);try{i.close()}catch{}}]}},FUe=(t,e)=>{if(!t||typeof t!="object")return e!==null&&typeof e=="object"?e:t;if(!e||typeof e!="object")return e??t;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];n!=null&&(t[r]=n)}return t},G6t=_n("werift:packages/webrtc/src/media/receiver/nack.ts"),bNe=150,K6t=class{constructor(t){this.receiver=t}newEstSeqNum=0;_lost={};nackLoop;onPacketLost=new yr;mediaSourceSsrc;retryCount=10;closed=!1;get lostSeqNumbers(){return Object.keys(this._lost).map(Number).sort()}getLost(t){return this._lost[t]}setLost(t,e){this._lost[t]=e,!(this.nackLoop||this.closed)&&(this.nackLoop=setInterval(async()=>{try{await this.sendNack(),Object.keys(this._lost).length||(clearInterval(this.nackLoop),this.nackLoop=void 0)}catch(r){G6t("failed to send nack",r)}},5))}removeLost(t){delete this._lost[t]}addPacket(t){let{sequenceNumber:e,ssrc:r}=t.header;if(this.mediaSourceSsrc=r,this.newEstSeqNum===0){this.newEstSeqNum=e;return}if(this.getLost(e)){this.removeLost(e);return}if(e===jo(this.newEstSeqNum,1))this.newEstSeqNum=e;else if(e>jo(this.newEstSeqNum,1)){for(let n=jo(this.newEstSeqNum,1);n<e;n=jo(n,1))this.setLost(n,1);this.newEstSeqNum=e,this.pruneLost()}}pruneLost(){this.lostSeqNumbers.length>bNe&&(this._lost=Object.entries(this._lost).slice(-bNe).reduce((t,[e,r])=>(t[e]=r,t),{}))}close(){this.closed=!0,clearInterval(this.nackLoop),this._lost={}}updateRetryCount(){this.lostSeqNumbers.forEach(t=>{if(this._lost[t]++>this.retryCount)return this.removeLost(t),t})}sendNack=()=>new Promise((t,e)=>{if(this.lostSeqNumbers.length>0&&this.mediaSourceSsrc){let r=new U6({senderSsrc:this.receiver.rtcpSsrc,mediaSourceSsrc:this.mediaSourceSsrc,lost:this.lostSeqNumbers}),n=new Tv({feedback:r});this.receiver.dtlsTransport.sendRtcp([n]).then(t).catch(e),this.updateRetryCount(),this.onPacketLost.execute(r)}})},X6t=_n("werift:packages/webrtc/media/receiver/receiverTwcc"),Y6t=class{constructor(t,e,r){this.dtlsTransport=t,this.rtcpSsrc=e,this.mediaSourceSsrc=r,this.runTWCC()}extensionInfo={};twccRunning=!1;fbPktCount=0;lastTimestamp;handleTWCC(t){this.extensionInfo[t]={tsn:t,timestamp:kUe()},Object.keys(this.extensionInfo).length>10&&this.sendTWCC()}async runTWCC(){for(;this.twccRunning;)this.sendTWCC(),await Z6t(100)}sendTWCC(){if(Object.keys(this.extensionInfo).length===0)return;let t=Object.values(this.extensionInfo).sort((p,x)=>p.tsn-x.tsn),e=t[0].tsn,r=t.slice(-1)[0].tsn,n=[],i=t[0].tsn,s=jo(r-e,1),a,c,d=[];for(let p=e;p<=r;p++){let x=this.extensionInfo[p]?.timestamp;if(x){this.lastTimestamp||(this.lastTimestamp=x),a||(a=this.lastTimestamp);let y=x-this.lastTimestamp;this.lastTimestamp=x;let v=new A6({delta:Number(y)});v.parseDelta(),d.push(v),c!=null&&c.status!==v.type&&(n.push(new BS({packetStatus:c.status,runLength:p-c.minTSN})),c={minTSN:p,status:v.type}),p===r&&(c!=null?n.push(new BS({packetStatus:c.status,runLength:p-c.minTSN+1})):n.push(new BS({packetStatus:v.type,runLength:1}))),c==null&&(c={minTSN:p,status:v.type})}}if(!a)return;let h=new Tv({feedback:new M6({senderSsrc:this.rtcpSsrc,mediaSourceSsrc:this.mediaSourceSsrc,baseSequenceNumber:i,packetStatusCount:s,referenceTime:KNe(Math.floor(Number(a/1000n/64n))),fbPktCount:this.fbPktCount,recvDeltas:d,packetChunks:n})});this.dtlsTransport.sendRtcp([h]).catch(p=>{X6t(p)}),this.extensionInfo={},this.fbPktCount=GNe(this.fbPktCount,1)}},J6t=class{base_seq;max_seq;cycles=0;packets_received=0;clockRate;jitter_q4=0;last_arrival;last_timestamp;expected_prior=0;received_prior=0;constructor(t){this.clockRate=t}add(t,e=Date.now()/1e3){let r=this.max_seq==null||_M(t.header.sequenceNumber,this.max_seq);if(this.packets_received++,this.base_seq==null&&(this.base_seq=t.header.sequenceNumber),r){let n=OS(e*this.clockRate);if(this.max_seq!=null&&t.header.sequenceNumber<this.max_seq&&(this.cycles+=65536),this.max_seq=t.header.sequenceNumber,t.header.timestamp!==this.last_timestamp&&this.packets_received>1){let i=Math.abs(n-(this.last_arrival??0)-(t.header.timestamp-(this.last_timestamp??0)));this.jitter_q4+=i-(this.jitter_q4+8>>4)}this.last_arrival=n,this.last_timestamp=t.header.timestamp}}get fraction_lost(){let t=this.packets_expected-this.expected_prior;this.expected_prior=this.packets_expected;let e=this.packets_received-this.received_prior;this.received_prior=this.packets_received;let r=t-e;return t==0||r<=0?0:Math.floor((r<<8)/t)}get jitter(){return this.jitter_q4>>4}get packets_expected(){return this.cycles+(this.max_seq??0)-(this.base_seq??0)+1}get packets_lost(){let t=this.packets_expected-this.packets_received;return t<0?0:t}},sd=_n("werift:packages/webrtc/src/transport/dtls.ts"),qae=class PUe{constructor(e,r,n,i=[]){this.config=e,this.iceTransport=r,this.localCertificate=n,this.srtpProfiles=i,this.localCertificate??=PUe.localCertificate}id=t8t().toString();state="new";role="auto";srtpStarted=!1;transportSequenceNumber=0;bytesSent=0;bytesReceived=0;packetsSent=0;packetsReceived=0;dataReceiver=()=>{};dtls;srtp;srtcp;onStateChange=new yr;onRtcp=new yr;onRtp=new yr;static localCertificate;static localCertificatePromise;remoteParameters;get localParameters(){return new gM(this.localCertificate?this.localCertificate.getFingerprints():[],this.role)}static async SetupCertificate(){return this.localCertificate?this.localCertificate:this.localCertificatePromise?this.localCertificatePromise:(this.localCertificatePromise=(async()=>{let{certPem:e,keyPem:r,signatureHash:n}=await F6.createSelfSignedCertificateWithKey({signature:Uh.ecdsa_3,hash:I6.sha256_4},Ep.secp256r1_23);return this.localCertificate=new Goe(r,e,n),this.localCertificate})(),this.localCertificatePromise)}setRemoteParams(e){let r=i8t([...this.remoteParameters?.fingerprints??[],...e.fingerprints]),n=e.role==="auto"&&this.remoteParameters?.role?this.remoteParameters.role:e.role;this.remoteParameters=new gM(r,n)}async start(){if(this.state!=="new")throw new Error("state must be new");if(!this.remoteParameters||this.remoteParameters.fingerprints.length===0)throw new Error("remote fingerprint not exist");this.role==="auto"&&(this.iceTransport.role==="controlling"?this.role="server":this.role="client"),this.setState("connecting"),await new Promise(async(e,r)=>{this.role==="server"?this.dtls=new RBe({cert:this.localCertificate?.certPem,key:this.localCertificate?.privateKey,signatureHash:this.localCertificate?.signatureHash,transport:_Ne(this.iceTransport.connection),srtpProfiles:this.srtpProfiles,extendedMasterSecret:!0,certificateRequest:!0}):this.dtls=new Dae({cert:this.localCertificate?.certPem,key:this.localCertificate?.privateKey,signatureHash:this.localCertificate?.signatureHash,transport:_Ne(this.iceTransport.connection),srtpProfiles:this.srtpProfiles,extendedMasterSecret:!0}),this.dtls.onData.subscribe(n=>{this.config.debug.inboundPacketLoss&&this.config.debug.inboundPacketLoss/100<Math.random()||this.dataReceiver(n)}),this.dtls.onClose.subscribe(()=>{this.state!=="failed"&&this.setState("closed")}),this.dtls.onConnect.once(e),this.dtls.onError.once(n=>{this.setState("failed"),sd("dtls failed",n),r(n)}),this.dtls instanceof Dae&&(await r8t(100),this.dtls.connect().catch(n=>{this.setState("failed"),sd("dtls connect failed",n),r(n)}))});try{this.verifyRemoteCertificateFingerprint()}catch(e){throw this.setState("failed"),this.dtls?.close(),e}this.srtpProfiles.length>0&&this.startSrtp(),this.setState("connected"),sd("dtls connected")}verifyRemoteCertificateFingerprint(){if(!this.remoteParameters||this.remoteParameters.fingerprints.length===0)throw new Error("remote fingerprint not exist");let e=this.dtls?.remoteCertificate;if(!e)throw new Error("remote certificate not available");let r=this.remoteParameters.fingerprints.flatMap(({algorithm:c,value:d})=>{let h=zoe(c);if(!h)return[];let p=pM(d);if(!p)throw new Error("remote fingerprint value is empty");return[{normalizedAlgorithm:h,normalizedValue:p}]});if(r.length===0)throw new Error("no supported remote fingerprint algorithms");let n=a8t(r),i=r.filter(({normalizedAlgorithm:c})=>c===n),s=i.reduce((c,{normalizedAlgorithm:d})=>(c.has(d)||c.set(d,pM(qoe(e,d))),c),new Map);if(!i.some(({normalizedAlgorithm:c,normalizedValue:d})=>s.get(c)===d))throw new Error("remote certificate fingerprint mismatch")}updateSrtpSession(){if(!this.dtls)throw new Error;let e=this.dtls.srtp.srtpProfile;if(!e)throw new Error("need srtpProfile");sd("selected SRTP Profile",e);let{localKey:r,localSalt:n,remoteKey:i,remoteSalt:s}=this.dtls.extractSessionKeys(D7e(e),I7e(e)),a={keys:{localMasterKey:r,localMasterSalt:n,remoteMasterKey:i,remoteMasterSalt:s},profile:e};this.srtp=new FBe(a),this.srtcp=new IBe(a)}startSrtp(){this.srtpStarted||(this.srtpStarted=!0,this.updateSrtpSession(),this.iceTransport.connection.onData.subscribe(e=>{if(!(this.config.debug.inboundPacketLoss&&this.config.debug.inboundPacketLoss/100<Math.random())&&H7e(e))if(this.bytesReceived+=e.length,this.packetsReceived++,sBe(e)){let r;try{r=this.srtcp.decrypt(e)}catch(i){if(i instanceof kv){sd("dropping invalid SRTCP packet",i);return}throw i}let n;try{n=iBe.deSerialize(r)}catch(i){sd("dropping malformed SRTCP packet",i);return}for(let i of n)try{this.onRtcp.execute(i)}catch(s){sd("RTCP error",s)}}else{let r;try{r=this.srtp.decrypt(e)}catch(i){if(i instanceof kv){sd("dropping invalid SRTP packet",i);return}throw i}let n;try{n=Cp.deSerialize(r)}catch(i){sd("dropping malformed SRTP packet",i);return}try{this.onRtp.execute(n)}catch(i){sd("RTP error",i)}}}))}sendData=async e=>{if(!(this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random())){if(!this.dtls)throw new Error("dtls not established");await this.dtls.send(e)}};async sendRtp(e,r){try{let n=this.srtp.encrypt(e,r);return this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random()||(this.bytesSent+=n.length,this.packetsSent++,await this.iceTransport.connection.send(n).catch(()=>{})),n.length}catch(n){return sd("failed to send",n),0}}async sendRtcp(e){let r=Buffer.concat(e.map(i=>i.serialize())),n=this.srtcp.encrypt(r);if(this.config.debug.outboundPacketLoss&&this.config.debug.outboundPacketLoss/100<Math.random())return n.length;this.bytesSent+=n.length,this.packetsSent++,await this.iceTransport.connection.send(n).catch(()=>{})}setState(e){e!=this.state&&(this.state=e,this.onStateChange.execute(e))}async stop(){this.setState("closed"),await this.iceTransport.stop()}async getStats(){let e=qg(),r=[],i={type:"transport",id:rs("transport",this.id),timestamp:e,bytesSent:this.bytesSent,bytesReceived:this.bytesReceived,packetsSent:this.packetsSent,packetsReceived:this.packetsReceived,dtlsState:this.state,iceState:this.iceTransport.state,selectedCandidatePairId:this.iceTransport.connection.nominated?rs("candidate-pair",this.iceTransport.connection.nominated.localCandidate.foundation,this.iceTransport.connection.nominated.remoteCandidate.foundation):void 0,localCertificateId:this.localCertificate?rs("certificate","local"):void 0,remoteCertificateId:this.remoteParameters?rs("certificate","remote"):void 0,dtlsRole:this.role==="auto"?void 0:this.role};if(r.push(i),this.localCertificate){let a=this.localCertificate.getFingerprints();if(a.length>0){let c={type:"certificate",id:rs("certificate","local"),timestamp:e,fingerprint:a[0].value,fingerprintAlgorithm:a[0].algorithm,base64Certificate:Buffer.from(this.localCertificate.certPem).toString("base64")};r.push(c)}}if(this.remoteParameters&&this.remoteParameters.fingerprints.length>0){let a={type:"certificate",id:rs("certificate","remote"),timestamp:e,fingerprint:this.remoteParameters.fingerprints[0].value,fingerprintAlgorithm:this.remoteParameters.fingerprints[0].algorithm,base64Certificate:""};r.push(a)}let s=await this.iceTransport.getStats();return r.push(...s),r}},n8t=["new","connecting","connected","closed","failed"],Goe=class{constructor(t,e,r){this.certPem=e,this.signatureHash=r;let n=W6.Certificate.fromPEM(Buffer.from(e));this.publicKey=n.publicKey.toPEM(),this.privateKey=W6.PrivateKey.fromPEM(Buffer.from(t)).toPEM()}publicKey;privateKey;getFingerprints(){return[new mM("sha-256",qoe(W6.Certificate.fromPEM(Buffer.from(this.certPem)).raw,"sha256"))]}},mM=class{constructor(t,e){this.algorithm=t,this.value=e}},gM=class{constructor(t=[],e){this.fingerprints=t,this.role=e}},i8t=t=>{let e=new Set;return t.filter(({algorithm:r,value:n})=>{let i=`${zoe(r)??r.trim().toLowerCase()}:${pM(n)}`;return e.has(i)?!1:(e.add(i),!0)})},s8t=["sha512","sha384","sha256","sha224","sha1"],a8t=t=>s8t.find(e=>t.some(({normalizedAlgorithm:r})=>r===e))??t[0].normalizedAlgorithm,o8t=class{constructor(t){this.ice=t,t.onData.subscribe(e=>{TUe(e)&&this.onData&&this.onData(e)})}closed=!1;onData=()=>{};get address(){return{}}type="ice";send=t=>this.ice.send(t);async close(){this.closed=!0,this.ice.close()}},_Ne=t=>new o8t(t),wNe=_n("werift:packages/webrtc/src/transport/ice.ts"),RUe=class{constructor(t){this.iceGather=t,this.connection=this.iceGather.connection,this.connection.stateChanged.subscribe(e=>{this.setState(e)}),this.iceGather.onIceCandidate=e=>{this.onIceCandidate.execute(e)}}id=c8t().toString();connection;state="new";waitStart;renominating=!1;onStateChange=new yr;onIceCandidate=new yr;onNegotiationNeeded=new yr;get role(){return this.connection.iceControlling?"controlling":"controlled"}get gatheringState(){return this.iceGather.gatheringState}get localCandidates(){return this.iceGather.localCandidates}get localParameters(){return this.iceGather.localParameters}setState(t){t!==this.state&&(this.state=t,this.onStateChange.execute(t))}gather(){return this.iceGather.gather()}addRemoteCandidate=t=>{if(!this.connection.remoteCandidatesEnd)return t?this.connection.addRemoteCandidate(NUe(t)):this.connection.addRemoteCandidate(void 0)};setRemoteParams(t,e=!1){e&&(this.renominating=!0),this.connection.remoteUsername&&this.connection.remotePassword&&(this.connection.remoteUsername!==t.usernameFragment||this.connection.remotePassword!==t.password)&&(this.renominating?(wNe("renomination",t),this.connection.resetNominatedPair(),this.renominating=!1):(wNe("restart",t),this.restart())),this.connection.setRemoteParams(t)}restart(){this.connection.restart(),this.setState("new"),this.iceGather.gatheringState="new",this.waitStart=void 0,this.onNegotiationNeeded.execute()}async start(){if(this.state==="closed")throw new Error("RTCIceTransport is closed");if(!this.connection.remotePassword||!this.connection.remoteUsername)throw new Error("remoteParams missing");this.waitStart&&await this.waitStart.asPromise(),this.waitStart=new yr,this.setState("checking");try{await this.connection.connect()}catch(t){throw this.setState("failed"),t}this.waitStart.execute(),this.waitStart.complete(),this.waitStart=void 0}async stop(){this.state!=="closed"&&(this.setState("closed"),await this.connection.close()),this.onStateChange.complete(),this.onIceCandidate.complete(),this.onNegotiationNeeded.complete()}async getStats(){let t=qg(),e=[];for(let n of this.localCandidates){let i={type:"local-candidate",id:rs("local-candidate",n.foundation),timestamp:t,transportId:rs("transport",this.id),address:n.ip,port:n.port,protocol:n.protocol,candidateType:n.type,priority:n.priority,foundation:n.foundation};e.push(i)}for(let n of this.connection.remoteCandidates){let i=qS(n),s={type:"remote-candidate",id:rs("remote-candidate",i.foundation),timestamp:t,transportId:rs("transport",this.id),address:i.ip,port:i.port,protocol:i.protocol,candidateType:i.type,priority:i.priority,foundation:i.foundation};e.push(s)}let r=this.connection?.candidatePairs?[...this.connection.candidatePairs.filter(n=>n.nominated),...this.connection.candidatePairs.filter(n=>!n.nominated)]:[];for(let n of r){let i={type:"candidate-pair",id:rs("candidate-pair",n.foundation),timestamp:t,transportId:rs("transport",this.id),localCandidateId:rs("local-candidate",n.localCandidate.foundation),remoteCandidateId:rs("remote-candidate",n.remoteCandidate.foundation),state:n.state,nominated:n.nominated,packetsSent:n.packetsSent,packetsReceived:n.packetsReceived,bytesSent:n.bytesSent,bytesReceived:n.bytesReceived,currentRoundTripTime:n.rtt};e.push(i)}return e}},u8t=["new","checking","connected","completed","disconnected","failed","closed"],l8t=["new","gathering","complete"],OUe=class{constructor(t={}){this.options=t,this.connection=new fUe(!1,this.options),this.connection.onIceCandidate.subscribe(e=>{this.onIceCandidate(qS(e))})}onIceCandidate=()=>{};gatheringState="new";connection;onGatheringStateChange=new yr;async gather(){this.gatheringState==="new"&&(this.setState("gathering"),await this.connection.gatherCandidates(),this.onIceCandidate(void 0),this.setState("complete"))}get localCandidates(){return this.connection.localCandidates.map(qS)}get localParameters(){return new Zoe({usernameFragment:this.connection.localUsername,password:this.connection.localPassword})}setState(t){t!==this.gatheringState&&(this.gatheringState=t,this.onGatheringStateChange.execute(t))}};BUe=class{candidate;sdpMid;sdpMLineIndex;usernameFragment;constructor(t){Object.assign(this,t)}static fromSdp(t){let e=$g.fromSdp(t);return qS(e).toJSON()}static isThis(t){if(typeof t?.candidate=="string")return!0}toJSON(){return{candidate:this.candidate,sdpMid:this.sdpMid,sdpMLineIndex:this.sdpMLineIndex,usernameFragment:this.usernameFragment}}},Koe=class{constructor(t,e,r,n,i,s,a,c,d){this.component=t,this.foundation=e,this.ip=r,this.port=n,this.priority=i,this.protocol=s,this.type=a,this.generation=c,this.ufrag=d}relatedAddress;relatedPort;sdpMid;sdpMLineIndex;tcpType;toJSON(){return new BUe({candidate:Joe(this),sdpMLineIndex:this.sdpMLineIndex,sdpMid:this.sdpMid,usernameFragment:this.ufrag})}static fromJSON(t){try{if(!t.candidate)throw new Error("candidate is required");let e=Qoe(t.candidate);return e.sdpMLineIndex=t.sdpMLineIndex??void 0,e.sdpMid=t.sdpMid??void 0,e}catch{}}},Zoe=class{iceLite=!1;usernameFragment;password;constructor(t={}){Object.assign(this,t)}},Lh=class UUe{constructor(e=0,r=Buffer.from("")){this.flags=e,this._body=r}get body(){return this._body}set body(e){this._body=e}static type=-1;get type(){return UUe.type}get bytes(){if(!this.body)throw new Error;let e=Buffer.alloc(4);return e.writeUInt8(this.type,0),e.writeUInt8(this.flags,1),e.writeUInt16BE(this.body.length+4,2),Buffer.concat([e,this.body,...[...Array(r8(this.body.length))].map(()=>Buffer.from("\0"))])}},Xoe=class extends Lh{constructor(t=0,e){super(t,e),this.flags=t,e?(this.initiateTag=e.readUInt32BE(0),this.advertisedRwnd=e.readUInt32BE(4),this.outboundStreams=e.readUInt16BE(8),this.inboundStreams=e.readUInt16BE(10),this.initialTsn=e.readUInt32BE(12),this.params=iMe(e.slice(16))):(this.initiateTag=0,this.advertisedRwnd=0,this.outboundStreams=0,this.inboundStreams=0,this.initialTsn=0,this.params=[])}initiateTag;advertisedRwnd;outboundStreams;inboundStreams;initialTsn;params;get body(){let t=Buffer.alloc(16);return t.writeUInt32BE(this.initiateTag,0),t.writeUInt32BE(this.advertisedRwnd,4),t.writeUInt16BE(this.outboundStreams,8),t.writeUInt16BE(this.inboundStreams,10),t.writeUInt32BE(this.initialTsn,12),Buffer.concat([t,nMe(this.params)])}},QU=class MUe extends Xoe{static type=1;get type(){return MUe.type}},zae=class LUe extends Xoe{static type=2;get type(){return LUe.type}},h8t=class $Ue extends Xoe{static type=130;get type(){return $Ue.type}},eM=class jUe extends Lh{constructor(e=0,r){if(super(e,r),this.flags=e,r){this.cumulativeTsn=r.readUInt32BE(0);let n=4;for(;n<r.length;)this.streams.push([r.readUInt16BE(n),r.readUInt16BE(n+2)]),n+=4}else this.cumulativeTsn=0}static type=192;streams=[];cumulativeTsn;get type(){return jUe.type}set body(e){}get body(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.cumulativeTsn,0),Buffer.concat([e,...this.streams.map(([r,n])=>{let i=Buffer.alloc(4);return i.writeUInt16BE(r,0),i.writeUInt16BE(n,2),i})])}},tM=class qUe extends Lh{constructor(e=0,r){super(e,r),this.flags=e,r&&(this.tsn=r.readUInt32BE(0),this.streamId=r.readUInt16BE(4),this.streamSeqNum=r.readUInt16BE(6),this.protocol=r.readUInt32BE(8),this.userData=r.slice(12))}static type=0;get type(){return qUe.type}tsn=0;streamId=0;streamSeqNum=0;protocol=0;userData=Buffer.from("");abandoned=!1;acked=!1;misses=0;retransmit=!1;sentCount=0;bookSize=0;expiry;maxRetransmits;sentTime;get bytes(){let e=16+this.userData.length,r=Buffer.alloc(16);r.writeUInt8(this.type,0),r.writeUInt8(this.flags,1),r.writeUInt16BE(e,2),r.writeUInt32BE(this.tsn,4),r.writeUInt16BE(this.streamId,8),r.writeUInt16BE(this.streamSeqNum,10),r.writeUInt32BE(this.protocol,12);let n=Buffer.concat([r,this.userData]);return e%4&&(n=Buffer.concat([n,...[...Array(r8(e))].map(()=>Buffer.from("\0"))])),n}},Wae=class zUe extends Lh{static type=10;get type(){return zUe.type}},Hae=class WUe extends Lh{static type=11;get type(){return WUe.type}},t8=class extends Lh{constructor(t=0,e=void 0){super(t,e),this.flags=t,e&&(this.params=iMe(e))}params=[];get body(){return nMe(this.params)}},Vae=class HUe extends t8{static type=6;get type(){return HUe.type}},rM=class Gae extends t8{static type=9;static CODE={InvalidStreamIdentifier:1,MissingMandatoryParameter:2,StaleCookieError:3,OutofResource:4,UnresolvableAddress:5,UnrecognizedChunkType:6,InvalidMandatoryParameter:7,UnrecognizedParameters:8,NoUserData:9,CookieReceivedWhileShuttingDown:10,RestartofanAssociationwithNewAddresses:11,UserInitiatedAbort:12,ProtocolViolation:13};get type(){return Gae.type}get descriptions(){return this.params.map(([e,r])=>({name:(Object.entries(Gae.CODE).find(([,i])=>i===e)||[])[0],body:r}))}},Kae=class VUe extends t8{static type=4;get type(){return VUe.type}},GUe=class KUe extends t8{static type=5;get type(){return KUe.type}},Zae=class ZUe extends t8{static type=130;get type(){return ZUe.type}},Xae=class XUe extends Lh{constructor(e=0,r){if(super(e,r),this.flags=e,r){this.cumulativeTsn=r.readUInt32BE(0),this.advertisedRwnd=r.readUInt32BE(4);let n=r.readUInt16BE(8),i=r.readUInt16BE(10),s=12;[...Array(n)].forEach(()=>{this.gaps.push([r.readUInt16BE(s),r.readUInt16BE(s+2)]),s+=4}),[...Array(i)].forEach(()=>{this.duplicates.push(r.readUInt32BE(s)),s+=4})}}static type=3;get type(){return XUe.type}gaps=[];duplicates=[];cumulativeTsn=0;advertisedRwnd=0;get bytes(){let e=16+4*(this.gaps.length+this.duplicates.length),r=Buffer.alloc(16);r.writeUInt8(this.type,0),r.writeUInt8(this.flags,1),r.writeUInt16BE(e,2),r.writeUInt32BE(this.cumulativeTsn,4),r.writeUInt32BE(this.advertisedRwnd,8),r.writeUInt16BE(this.gaps.length,12),r.writeUInt16BE(this.duplicates.length,14);let n=Buffer.concat([r,...this.gaps.map(i=>{let s=Buffer.alloc(4);return s.writeUInt16BE(i[0],0),s.writeUInt16BE(i[1],2),s})]);return n=Buffer.concat([n,...this.duplicates.map(i=>{let s=Buffer.alloc(4);return s.writeUInt32BE(i,0),s})]),n}},YUe=class JUe extends Lh{constructor(e=0,r){super(e,r),this.flags=e,r&&(this.cumulativeTsn=r.readUInt32BE(0))}static type=7;get type(){return JUe.type}cumulativeTsn=0;get body(){let e=Buffer.alloc(4);return e.writeUInt32BE(this.cumulativeTsn,0),e}},QUe=class eMe extends Lh{static type=8;get type(){return eMe.type}},tMe=class rMe extends Lh{static type=14;get type(){return rMe.type}},p8t=[tM,QU,zae,Xae,Kae,GUe,Vae,YUe,QUe,rM,Wae,Hae,tMe,Zae,eM],m8t=p8t.reduce((t,e)=>(t[e.type]=e,t),{});Yae=class Jae{constructor(e,r,n,i){this.requestSequence=e,this.responseSequence=r,this.lastTsn=n,this.streams=i}static type=13;get type(){return Jae.type}get bytes(){let e=Buffer.from(Sp.jspack.Pack("!LLL",[this.requestSequence,this.responseSequence,this.lastTsn]));return Buffer.concat([e,...this.streams.map(r=>Buffer.from(Sp.jspack.Pack("!H",[r])))])}static parse(e){let[r,n,i]=Sp.jspack.Unpack("!LLL",e),s=[];for(let a=12;a<e.length;a+=2)s.push(Sp.jspack.Unpack("!H",e.slice(a))[0]);return new Jae(r,n,i,s)}},sMe=class Qae{constructor(e,r){this.requestSequence=e,this.newStreams=r}static type=17;get type(){return Qae.type}get bytes(){return Buffer.from(Sp.jspack.Pack("!LHH",[this.requestSequence,this.newStreams,0]))}static parse(e){let[r,n]=Sp.jspack.Unpack("!LHH",e);return new Qae(r,n)}},$U={ReconfigResultSuccessPerformed:1,BadSequenceNumber:5},nM=class eoe{constructor(e,r){this.responseSequence=e,this.result=r}static type=16;get type(){return eoe.type}get bytes(){return Buffer.from(Sp.jspack.Pack("!LL",[this.responseSequence,this.result]))}static parse(e){let[r,n]=Sp.jspack.Unpack("!LL",e);return new eoe(r,n)}},ANe={13:Yae,16:nM,17:sMe},Di=_n("werift/sctp/sctp"),b8t=24,_8t=60,ENe=65535,ad=1200,w6=1,aMe=2,toe=4,TNe=10,w8t=8,CNe=1/8,kNe=1/4,DNe=3,S8t=1,A8t=60,xM=2**32,E8t=200,T8t=30,INe=135,FNe=7,PNe=32776,RNe=49152,C8t=["new","closed","connected","connecting"],k8t=class roe{constructor(e,r=5e3){this.transport=e,this.port=r,this.localPort=this.port,this.transport.onData=n=>{this.handleData(n)}}flush=new yr;stateChanged=v8t(C8t);onReconfigStreams=new yr;onReceive=new yr;onSackReceived=async()=>{};associationState=1;started=!1;state="new";isServer=!0;isStopping=!1;isClosed=!1;hmacKey=d8t(16);localPartialReliability=!0;localPort;localVerificationTag=sM();remoteExtensions=[];remotePartialReliability=!0;remotePort;remoteVerificationTag=0;advertisedRwnd=1024*1024;peerAdvertisedRwnd=this.advertisedRwnd;get peerRwnd(){return Math.max(0,this.peerAdvertisedRwnd-this.flightSize)}inboundStreams={};_inboundStreamsCount=0;_inboundStreamsMax=ENe;lastReceivedTsn;sackDuplicates=[];sackMisOrdered=new Set;sackNeeded=!1;sackPacketCount=0;sackHasNewDataInPacket=!1;sackImmediate=!1;sackTimeout;cwnd=3*ad;fastRecoveryExit;fastRecoveryTransmit=!1;forwardTsnChunk;flightSize=0;outboundQueue=[];outboundStreamSeq={};_outboundStreamsCount=ENe;localTsn=Number(sM());lastSackedTsn=yv(this.localTsn);advancedPeerAckTsn=yv(this.localTsn);partialBytesAcked=0;sentQueue=[];transmitting=!1;transmitRequested=!1;reconfigRequestSeq=this.localTsn;reconfigResponseSeq=0;reconfigRequest;reconfigQueue=[];srtt;rttvar;rto=DNe;timer1Handle;timer1Chunk;timer1Failures=0;timer2Handle;timer2Chunk;timer2Failures=0;timer3Handle;timerReconfigHandle;timerReconfigFailures=0;timerHeartbeatHandle;heartbeatInterval=T8t;ssthresh;get isStopped(){return this.isStopping||this.isClosed}get maxChannels(){if(this._inboundStreamsCount>0)return Math.min(this._inboundStreamsCount,this._outboundStreamsCount)}static client(e,r=5e3){let n=new roe(e,r);return n.isServer=!1,n}static server(e,r=5e3){let n=new roe(e,r);return n.isServer=!0,n}async handleData(e){if(this.isStopped)return;let r,[,,n,i]=g8t(e);if(i.filter(a=>a.type===QU.type).length>0){if(i.length!=1)throw new Error;r=0}else r=this.localVerificationTag;if(n===r){this.sackHasNewDataInPacket=!1;for(let a of i)await this.receiveChunk(a);this.sackNeeded&&(this.sackHasNewDataInPacket&&this.sackPacketCount++,this.sackPacketCount>=2&&(this.sackImmediate=!0),await this.scheduleSack())}}async scheduleSack(){if(!this.isStopped&&this.sackNeeded){if(this.sackImmediate){this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),await this.sendSack();return}this.sackTimeout||(this.sackTimeout=setTimeout(()=>{this.sackTimeout=void 0,this.sendSack().catch(e=>{Di("send delayed sack failed",e.message)})},E8t))}}async sendSack(){if(this.isStopped||!this.sackNeeded)return;let e=[],r;[...this.sackMisOrdered].sort().forEach(i=>{let s=(i-this.lastReceivedTsn)%xM;i===r?e[e.length-1][1]=s:e.push([s,s]),r=FS(i)});let n=new Xae(0,void 0);n.cumulativeTsn=this.lastReceivedTsn,n.advertisedRwnd=Math.max(0,this.advertisedRwnd),n.duplicates=[...this.sackDuplicates],n.gaps=e,await this.sendChunk(n).catch(i=>{Di("send sack failed",i.message)}),this.sackDuplicates=[],this.sackNeeded=!1,this.sackPacketCount=0,this.sackImmediate=!1}async receiveChunk(e){switch(e.type){case tM.type:this.receiveDataChunk(e);break;case QU.type:{if(!this.isServer)return;let r=e;Di("receive init",r),this.lastReceivedTsn=yv(r.initialTsn),this.reconfigResponseSeq=yv(r.initialTsn),this.remoteVerificationTag=r.initiateTag,this.ssthresh=r.advertisedRwnd,this.peerAdvertisedRwnd=r.advertisedRwnd,this.getExtensions(r.params),this._inboundStreamsCount=Math.min(r.outboundStreams,this._inboundStreamsMax),this._outboundStreamsCount=Math.min(this._outboundStreamsCount,r.inboundStreams);let n=new zae;n.initiateTag=this.localVerificationTag,n.advertisedRwnd=this.advertisedRwnd,n.outboundStreams=this._outboundStreamsCount,n.inboundStreams=this._inboundStreamsCount,n.initialTsn=this.localTsn,this.setExtensions(n.params);let i=Date.now()/1e3,s=Buffer.from(JU.jspack.Pack("!L",[i]));s=Buffer.concat([s,SNe("sha1",this.hmacKey).update(s).digest()]),n.params.push([FNe,s]),Di("send initAck",n),await this.sendChunk(n).catch(a=>{Di("send initAck failed",a.message)})}break;case zae.type:{if(this.associationState!=2)return;let r=e;this.timer1Cancel(),this.lastReceivedTsn=yv(r.initialTsn),this.reconfigResponseSeq=yv(r.initialTsn),this.remoteVerificationTag=r.initiateTag,this.ssthresh=r.advertisedRwnd,this.peerAdvertisedRwnd=r.advertisedRwnd,this.getExtensions(r.params),this._inboundStreamsCount=Math.min(r.outboundStreams,this._inboundStreamsMax),this._outboundStreamsCount=Math.min(this._outboundStreamsCount,r.inboundStreams);let n=new Wae;for(let[i,s]of r.params)if(i===FNe){n.body=s;break}await this.sendChunk(n).catch(i=>{Di("send echo failed",i.message)}),this.timer1Start(n),this.setState(3)}break;case Xae.type:await this.receiveSackChunk(e);break;case Kae.type:{let r=new GUe;r.params=e.params,await this.sendChunk(r).catch(n=>{Di("send heartbeat ack failed",n.message)})}break;case Vae.type:this.setState(1);break;case YUe.type:{this.timer2Cancel(),this.setState(7);let r=new QUe;await this.sendChunk(r).catch(n=>{Di("send shutdown ack failed",n.message)}),this.t2Start(r),this.setState(6)}break;case rM.type:Di("ErrorChunk",e.descriptions);break;case Wae.type:{if(!this.isServer)return;let n=e.body,i=SNe("sha1",this.hmacKey).update(n.slice(0,4)).digest();if(n?.length!=b8t||!n.slice(4).equals(i)){Di("x State cookie is invalid");return}let s=Date.now()/1e3,a=JU.jspack.Unpack("!L",n)[0];if(a<s-_8t||a>s){let d=new rM(0,void 0);d.params.push([rM.CODE.StaleCookieError,Buffer.concat([...Array(8)].map(()=>Buffer.from("\0")))]),await this.sendChunk(d).catch(h=>{Di("send errorChunk failed",h.message)});return}let c=new Hae;await this.sendChunk(c).catch(d=>{Di("send cookieAck failed",d.message)}),this.setState(4)}break;case Hae.type:{if(this.associationState!=3)return;this.timer1Cancel(),this.setState(4)}break;case tMe.type:{if(this.associationState!=8)return;this.timer2Cancel(),this.setState(1)}break;case Zae.type:{if(this.associationState!=4)return;let r=e;for(let[n,i]of r.params){let s=ANe[n];s&&await this.receiveReconfigParam(s.parse(i))}}break;case eM.type:this.receiveForwardTsnChunk(e);break}}getExtensions(e){for(let[r,n]of e)r===RNe?this.remotePartialReliability=!0:r===PNe&&(this.remoteExtensions=[...n])}async receiveReconfigParam(e){switch(Di("receiveReconfigParam",ANe[e.type]),e.type){case Yae.type:{let r=e,n=new nM(r.requestSequence,$U.ReconfigResultSuccessPerformed);this.reconfigResponseSeq=r.requestSequence,await this.sendReconfigParam(n),await Promise.all(r.streams.map(async i=>{delete this.inboundStreams[i],this.outboundStreamSeq[i]&&(this.reconfigQueue.includes(i)||this.reconfigQueue.push(i))})),await this.transmitReconfigRequest(),this.onReconfigStreams.execute(r.streams)}break;case nM.type:{let r=e;if(r.result!==$U.ReconfigResultSuccessPerformed)Di("OutgoingSSNResetRequestParam failed",Object.keys($U).find(n=>$U[n]===r.result));else if(r.responseSequence===this.reconfigRequest?.requestSequence){let n=this.reconfigRequest.streams.map(i=>(delete this.outboundStreamSeq[i],i));this.onReconfigStreams.execute(n),this.reconfigRequest=void 0,this.timerReconfigCancel(),this.rto=DNe,this.timerReconfigFailures=0,this.reconfigQueue.length>0&&await this.transmitReconfigRequest()}}break;case sMe.type:{let r=e;this._inboundStreamsCount+=r.newStreams;let n=new nM(r.requestSequence,1);this.reconfigResponseSeq=r.requestSequence,await this.sendReconfigParam(n)}break}}receiveDataChunk(e){if(this.sackNeeded=!0,this.markReceived(e.tsn)){this.sackImmediate=!0;return}this.sackHasNewDataInPacket=!0,this.sackImmediate=!0,(e.flags&w6)===0&&(this.sackImmediate=!0),this.sackMisOrdered.size>0&&(this.sackImmediate=!0);let r=this.getInboundStream(e.streamId);r.addChunk(e),this.advertisedRwnd-=e.userData.length;for(let n of r.popMessages())this.advertisedRwnd+=n[2].length,this.receive(...n)}async receiveSackChunk(e){if(Oh(this.lastSackedTsn,e.cumulativeTsn))return;let r=Date.now()/1e3;this.lastSackedTsn=e.cumulativeTsn;let n=this.flightSize>=this.cwnd,i=0,s=0;for(;this.sentQueue.length>0&&PS(this.lastSackedTsn,this.sentQueue[0].tsn);){let c=this.sentQueue.shift();i++,c?.acked||(s+=c.bookSize,this.flightSizeDecrease(c)),i===1&&c.sentCount===1&&this.updateRto(r-c.sentTime)}this.sentQueue.length||(this.sentQueue=[]);let a=!1;if(e.gaps.length>0){let c=new Set,d;e.gaps.forEach(p=>{for(let x=p[0];x<p[1]+1;x++)d=(e.cumulativeTsn+x)%xM,c.add(d)});let h=e.cumulativeTsn;for(let p of this.sentQueue){if(Oh(p.tsn,d))break;c.has(p.tsn)&&!p.acked&&(s+=p.bookSize,p.acked=!0,this.flightSizeDecrease(p),h=p.tsn)}for(let p of this.sentQueue){if(Oh(p.tsn,h))break;c.has(p.tsn)||(p.misses++,p.misses===3&&(p.misses=0,this.maybeAbandon(p)||(p.retransmit=!0),p.acked=!1,this.flightSizeDecrease(p),a=!0))}}this.fastRecoveryExit===void 0?(i&&n&&(this.cwnd<=this.ssthresh?this.cwnd+=Math.min(s,ad):(this.partialBytesAcked+=s,this.partialBytesAcked>=this.cwnd&&(this.partialBytesAcked-=this.cwnd,this.cwnd+=ad))),a&&(this.ssthresh=Math.max(Math.floor(this.cwnd/2),4*ad),this.cwnd=this.ssthresh,this.partialBytesAcked=0,this.fastRecoveryExit=this.sentQueue[this.sentQueue.length-1].tsn,this.fastRecoveryTransmit=!0)):PS(e.cumulativeTsn,this.fastRecoveryExit)&&(this.fastRecoveryExit=void 0),this.sentQueue.length===0?this.timer3Cancel():i>0&&this.timer3Restart(),this.peerAdvertisedRwnd=e.advertisedRwnd,this.updateAdvancedPeerAckPoint(),await this.onSackReceived(),await this.transmit()}receiveForwardTsnChunk(e){if(this.sackNeeded=!0,this.sackImmediate=!0,PS(this.lastReceivedTsn,e.cumulativeTsn))return;let r=n=>Oh(n,this.lastReceivedTsn);this.lastReceivedTsn=e.cumulativeTsn,this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r));for(let n of[...this.sackMisOrdered].sort())if(n===FS(this.lastReceivedTsn))this.lastReceivedTsn=n;else break;this.sackDuplicates=this.sackDuplicates.filter(r),this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r));for(let[n,i]of e.streams){let s=this.getInboundStream(n);s.streamSequenceNumber=jo(i,1);for(let a of s.popMessages())this.advertisedRwnd+=a[2].length,this.receive(...a)}Object.values(this.inboundStreams).forEach(n=>{this.advertisedRwnd+=n.pruneChunks(this.lastReceivedTsn)})}updateRto(e){this.srtt?(this.rttvar=(1-kNe)*this.rttvar+kNe*Math.abs(this.srtt-e),this.srtt=(1-CNe)*this.srtt+CNe*e):(this.rttvar=e/2,this.srtt=e),this.rto=Math.max(S8t,Math.min(this.srtt+4*this.rttvar,A8t))}receive(e,r,n){this.onReceive.execute(e,r,n)}getInboundStream(e){return this.inboundStreams[e]||(this.inboundStreams[e]=new D8t),this.inboundStreams[e]}markReceived(e){if(PS(this.lastReceivedTsn,e)||this.sackMisOrdered.has(e))return this.sackDuplicates.push(e),!0;this.sackMisOrdered.add(e);for(let n of[...this.sackMisOrdered].sort())if(n===FS(this.lastReceivedTsn))this.lastReceivedTsn=n;else break;let r=n=>Oh(n,this.lastReceivedTsn);return this.sackDuplicates=this.sackDuplicates.filter(r),this.sackMisOrdered=new Set([...this.sackMisOrdered].filter(r)),!1}send=async(e,r,n,{expiry:i,maxRetransmits:s,ordered:a}={expiry:void 0,maxRetransmits:void 0,ordered:!0})=>{let c=a&&this.outboundStreamSeq[e]||0,d=Math.ceil(n.length/ad),h=0,p=[];for(let x=0;x<d;x++){let y=new tM(0,void 0);y.flags=0,a||(y.flags=toe),x===0&&(y.flags|=aMe),x===d-1&&(y.flags|=w6),y.tsn=this.localTsn,y.streamId=e,y.streamSeqNum=c,y.protocol=r,y.userData=n.slice(h,h+ad),y.bookSize=y.userData.length,y.expiry=i,y.maxRetransmits=s,h+=ad,this.localTsn=FS(this.localTsn),p.push(y)}for(p.forEach(x=>{this.outboundQueue.push(x)}),a&&(this.outboundStreamSeq[e]=jo(c,1)),await this.transmit();this.outboundQueue.length;)await this.flush.asPromise()};async transmit(){if(!this.isStopped){if(this.transmitting){this.transmitRequested=!0;return}this.transmitting=!0;try{do this.transmitRequested=!1,await this.transmitOnce();while(this.transmitRequested)}finally{this.transmitting=!1}}}async transmitOnce(){if(this.isStopped)return;this.forwardTsnChunk&&(await this.sendChunk(this.forwardTsnChunk).catch(i=>{Di("send forwardTsn failed",i.message)}),this.forwardTsnChunk=void 0,this.timer3Handle||this.timer3Start());let e=this.fastRecoveryExit!=null?2*ad:4*ad,r=Math.min(this.flightSize+e,this.cwnd),n=!0;for(let i of this.sentQueue){if(i.retransmit){if(this.fastRecoveryTransmit)this.fastRecoveryTransmit=!1;else if(this.flightSize>=r)break;this.flightSizeIncrease(i),i.misses=0,i.retransmit=!1,i.sentCount++,await this.sendChunk(i).catch(s=>{Di("send data failed",s.message)}),n&&this.timer3Restart()}n=!1}for(;this.outboundQueue.length>0&&this.flightSize<r&&this.peerRwnd>0;){let i=this.outboundQueue.shift();if(!i)break;if(i.bookSize>this.peerRwnd&&this.flightSize>0){this.outboundQueue.unshift(i);break}this.sentQueue.push(i),this.flightSizeIncrease(i),i.sentCount++,i.sentTime=Date.now()/1e3,await this.sendChunk(i).catch(s=>{Di("send data outboundQueue failed",s.message)}),this.timer3Handle||this.timer3Start()}this.outboundQueue.length||(this.outboundQueue=[]),this.flush.execute()}async transmitReconfigRequest(){if(this.reconfigQueue.length>0&&this.associationState===4&&!this.reconfigRequest){let e=[...new Set(this.reconfigQueue)],r=e.slice(0,INe);this.reconfigQueue=e.slice(INe);let n=new Yae(this.reconfigRequestSeq,this.reconfigResponseSeq,yv(this.localTsn),r);this.reconfigRequestSeq=FS(this.reconfigRequestSeq),this.reconfigRequest=n,await this.sendReconfigParam(n),this.timerReconfigHandleStart()}}async sendReconfigParam(e){Di("sendReconfigParam",e);let r=new Zae;r.params.push([e.type,e.bytes]),await this.sendChunk(r).catch(n=>{Di("send reconfig failed",n.message)})}async sendResetRequest(e){Di("sendResetRequest",e);let r=new tM(0,void 0);r.streamId=e,this.outboundQueue.push(r),this.timer3Handle||await this.transmit()}flightSizeIncrease(e){this.flightSize+=e.bookSize}flightSizeDecrease(e){this.flightSize=Math.max(0,this.flightSize-e.bookSize)}timer1Start(e){if(this.timer1Handle)throw new Error;this.timer1Chunk=e,this.timer1Failures=0,this.timer1Handle=setTimeout(this.timer1Expired,this.rto*1e3)}timer1Expired=()=>{if(!this.isStopped)if(this.timer1Failures++,this.timer1Handle=void 0,this.timer1Failures>w8t)this.setState(1);else{if(setImmediate(()=>{this.isStopped||this.sendChunk(this.timer1Chunk).catch(e=>{Di("send timer1 chunk failed",e.message)})}),this.isStopped)return;this.timer1Handle=setTimeout(this.timer1Expired,this.rto*1e3)}};timer1Cancel(){this.timer1Handle&&(clearTimeout(this.timer1Handle),this.timer1Handle=void 0,this.timer1Chunk=void 0)}t2Start(e){if(this.timer2Handle)throw new Error;this.timer2Chunk=e,this.timer2Failures=0,this.timer2Handle=setTimeout(this.timer2Expired,this.rto*1e3)}timer2Expired=()=>{if(!this.isStopped)if(this.timer2Failures++,this.timer2Handle=void 0,this.timer2Failures>TNe)this.setState(1);else{if(setImmediate(()=>{this.isStopped||this.sendChunk(this.timer2Chunk).catch(e=>{Di("send timer2Chunk failed",e.message)})}),this.isStopped)return;this.timer2Handle=setTimeout(this.timer2Expired,this.rto*1e3)}};timer2Cancel(){this.timer2Handle&&(clearTimeout(this.timer2Handle),this.timer2Handle=void 0,this.timer2Chunk=void 0)}timer3Start(){if(!this.isStopped){if(this.timer3Handle)throw new Error;this.timer3Handle=setTimeout(this.timer3Expired,this.rto*1e3)}}timer3Restart(){this.isStopped||(this.timer3Cancel(),this.timer3Handle=setTimeout(this.timer3Expired,this.rto*1e3))}timer3Expired=()=>{this.isStopped||(this.timer3Handle=void 0,this.sentQueue.forEach(e=>{this.maybeAbandon(e)||(e.retransmit=!0)}),this.updateAdvancedPeerAckPoint(),this.fastRecoveryExit=void 0,this.flightSize=0,this.partialBytesAcked=0,this.ssthresh=Math.max(Math.floor(this.cwnd/2),4*ad),this.cwnd=ad,this.transmit())};timer3Cancel(){this.timer3Handle&&(clearTimeout(this.timer3Handle),this.timer3Handle=void 0)}timerReconfigHandleStart(){this.isStopped||this.timerReconfigHandle||(Di("timerReconfigHandleStart",{rto:this.rto}),this.timerReconfigFailures=0,this.timerReconfigHandle=setTimeout(this.timerReconfigHandleExpired,this.rto*1e3))}timerReconfigHandleExpired=async()=>{if(!this.isStopped){if(this.timerReconfigFailures++,this.rto=Math.ceil(this.rto*1.5),this.timerReconfigFailures>TNe)Di("timerReconfigFailures",this.timerReconfigFailures),this.setState(1),this.timerReconfigHandle=void 0;else if(this.reconfigRequest){if(Di("timerReconfigHandleExpired",this.timerReconfigFailures,this.rto),await this.sendReconfigParam(this.reconfigRequest),this.isStopped)return;this.timerReconfigHandle=setTimeout(this.timerReconfigHandleExpired,this.rto*1e3)}}};timerReconfigCancel(){this.timerReconfigHandle&&(Di("timerReconfigCancel"),clearTimeout(this.timerReconfigHandle),this.timerReconfigHandle=void 0,this.timerReconfigFailures=0)}heartbeatStart(){this.timerHeartbeatHandle||this.associationState!==4||(this.timerHeartbeatHandle=setTimeout(this.timerHeartbeatExpired,(this.rto+this.heartbeatInterval)*1e3))}heartbeatRestart(){this.heartbeatCancel(),this.heartbeatStart()}heartbeatCancel(){this.timerHeartbeatHandle&&(clearTimeout(this.timerHeartbeatHandle),this.timerHeartbeatHandle=void 0)}timerHeartbeatExpired=async()=>{if(this.timerHeartbeatHandle=void 0,this.associationState===4){if(this.flightSize===0&&this.outboundQueue.length===0){let e=new Kae;e.params.push([1,Buffer.from(JU.jspack.Pack("!L",[Math.floor(Date.now()/1e3)]))]),await this.sendChunk(e).catch(r=>{Di("send heartbeat failed",r.message)})}this.heartbeatStart()}};setHeartbeatInterval(e){if(e<=0)throw new Error("heartbeat interval must be > 0");this.heartbeatInterval=e,this.heartbeatRestart()}updateAdvancedPeerAckPoint(){Oh(this.lastSackedTsn,this.advancedPeerAckTsn)&&(this.advancedPeerAckTsn=this.lastSackedTsn);let e=0,r={};for(;this.sentQueue.length>0&&this.sentQueue[0].abandoned;){let n=this.sentQueue.shift();this.advancedPeerAckTsn=n.tsn,e++,n.flags&toe||(r[n.streamId]=n.streamSeqNum)}this.sentQueue.length||(this.sentQueue=[]),e&&(this.forwardTsnChunk=new eM(0,void 0),this.forwardTsnChunk.cumulativeTsn=this.advancedPeerAckTsn,this.forwardTsnChunk.streams=Object.entries(r).map(([n,i])=>[Number(n),i]))}maybeAbandon(e){if(e.abandoned)return!0;if(!(!!e.maxRetransmits&&e.maxRetransmits<e.sentCount||!!e.expiry&&e.expiry<Date.now()/1e3))return!1;let n=this.sentQueue.findIndex(i=>i.type===e.type);for(let i=n;i>=0;i--){let s=this.sentQueue[i];if(s.abandoned=!0,s.retransmit=!1,s.flags&w6)break}for(let i=n;i<this.sentQueue.length;i++){let s=this.sentQueue[i];if(s.abandoned=!0,s.retransmit=!1,s.flags&w6)break}return!0}static getCapabilities(){return new I8t(65536)}setRemotePort(e){this.remotePort=e}async start(e){this.started||(this.started=!0,this.setConnectionState("connecting"),e&&this.setRemotePort(e),this.isServer||await this.init())}async init(){let e=new QU;e.initiateTag=this.localVerificationTag,e.advertisedRwnd=this.advertisedRwnd,e.outboundStreams=this._outboundStreamsCount,e.inboundStreams=this._inboundStreamsMax,e.initialTsn=this.localTsn,this.setExtensions(e.params),Di("send init",e);try{await this.sendChunk(e),this.timer1Start(e),this.setState(2)}catch(r){Di("send init failed",r.message)}}setExtensions(e){let r=[];this.localPartialReliability&&(e.push([RNe,Buffer.from("")]),r.push(eM.type)),r.push(h8t.type),e.push([PNe,Buffer.from(r)])}async sendChunk(e){if(this.state==="closed")return;if(this.remotePort===void 0)throw new Error("invalid remote port");let r=x8t(this.localPort,this.remotePort,this.remoteVerificationTag,e);await this.transport.send(r)}setState(e){e!=this.associationState&&(this.associationState=e),e===4?(this.isStopping=!1,this.isClosed=!1,this.setConnectionState("connected"),this.heartbeatStart()):e===1&&(this.isClosed=!0,this.timer1Cancel(),this.timer2Cancel(),this.timer3Cancel(),this.timerReconfigCancel(),this.heartbeatCancel(),this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),this.setConnectionState("closed"),this.removeAllListeners())}setConnectionState(e){this.state=e,Di("setConnectionState",e),this.stateChanged[e].execute()}async stop(){if(this.isStopped){this.setState(1);return}this.isStopping=!0,this.transport.onData=void 0,this.sackTimeout&&(clearTimeout(this.sackTimeout),this.sackTimeout=void 0),this.associationState!==1&&await this.abort(),this.setState(1),clearTimeout(this.timer1Handle),clearTimeout(this.timer2Handle),clearTimeout(this.timer3Handle),clearTimeout(this.timerReconfigHandle),clearTimeout(this.timerHeartbeatHandle),clearTimeout(this.sackTimeout)}async abort(){let e=new Vae;await this.sendChunk(e).catch(r=>{Di("send abort failed",r.message)})}removeAllListeners(){Object.values(this.stateChanged).forEach(e=>e.allUnsubscribe())}},D8t=class{reassembly=[];streamSequenceNumber=0;constructor(){}addChunk(t){if(this.reassembly.length===0||Oh(t.tsn,this.reassembly[this.reassembly.length-1].tsn)){this.reassembly.push(t);return}for(let[e,r]of y8t(this.reassembly)){if(r.tsn===t.tsn)throw new Error("duplicate chunk in reassembly");if(Oh(r.tsn,t.tsn)){this.reassembly.splice(e,0,t);break}}}*popMessages(){let t=0,e,r,n;for(;t<this.reassembly.length;){let i=this.reassembly[t];if(e===void 0){if(n=!(i.flags&toe),!(i.flags&aMe)){if(n)break;t++;continue}if(n&&_M(i.streamSeqNum,this.streamSequenceNumber))break;r=i.tsn,e=t}else if(i.tsn!==r){if(n)break;e=void 0,t++;continue}if(i.flags&w6){let s=this.reassembly.slice(e,t+1).map(c=>c.userData).reduce((c,d)=>(c.push(d),c.push(Buffer.from("")),c),[]);s.pop();let a=Buffer.concat(s);this.reassembly=[...this.reassembly.slice(0,e),...this.reassembly.slice(t+1)],n&&i.streamSeqNum===this.streamSequenceNumber&&(this.streamSequenceNumber=jo(this.streamSequenceNumber,1)),t=e,yield[i.streamId,i.protocol,a]}else t++;r=FS(r)}}pruneChunks(t){let e=-1,r=0;for(let[n,i]of this.reassembly.entries())if(PS(t,i.tsn))e=n,r+=i.userData.length;else break;return this.reassembly=this.reassembly.slice(e+1),r}},I8t=class{constructor(t){this.maxMessageSize=t}};TS=_n("werift:packages/webrtc/src/transport/sctp.ts"),RS=65536,oMe=class cMe{constructor(e=5e3,r=RS){this.port=e,this.maxMessageSize=r}dtlsTransport;sctp;onDataChannel=new yr;id=f8t().toString();mid;mLineIndex;bundled=!1;dataChannels={};remoteMaxMessageSize=RS;dataChannelQueue=[];dataChannelId;eventDisposer=[];setDtlsTransport(e){this.dtlsTransport&&this.dtlsTransport.id===e.id||(this.eventDisposer.forEach(r=>r()),this.dtlsTransport=e,this.sctp=new k8t(new F8t(this.dtlsTransport),this.port),this.eventDisposer=[...[this.sctp.onReceive.subscribe(this.datachannelReceive),this.sctp.onReconfigStreams.subscribe(r=>{r.forEach(n=>{let i=this.dataChannels[n];i&&(i.setReadyState("closing"),i.setReadyState("closed"),delete this.dataChannels[n])})}),this.sctp.stateChanged.connected.subscribe(()=>{Object.values(this.dataChannels).forEach(r=>{r.negotiated&&r.readyState!=="open"&&r.setReadyState("open")}),this.dataChannelFlush()}),this.sctp.stateChanged.closed.subscribe(()=>{Object.values(this.dataChannels).forEach(r=>{r.setReadyState("closed")}),this.dataChannels={}}),this.dtlsTransport.onStateChange.subscribe(r=>{r==="closed"&&this.sctp.setState(1)})].map(r=>r.unSubscribe),()=>this.sctp.onSackReceived=async()=>{}],this.sctp.onSackReceived=async()=>{await this.dataChannelFlush()})}get isServer(){return this.dtlsTransport.iceTransport.role!=="controlling"}channelByLabel(e){return Object.values(this.dataChannels).find(r=>r.label===e)}datachannelReceive=async(e,r,n)=>{if(r===LU&&n.length>0)switch(TS("DCEP",e,r,n),n[0]){case pNe:{if(n.length<12){TS("DATA_CHANNEL_OPEN data.length not enough");return}if(Object.keys(this.dataChannels).includes(e.toString()))TS("datachannel already opened","retransmit ack");else{let[,s,,a,c,d]=YU.jspack.Unpack("!BBHLHH",n),h=12,p=n.slice(h,h+c).toString("utf8");h+=c;let x=n.slice(h,h+d).toString("utf8");TS("DATA_CHANNEL_OPEN",{channelType:s,reliability:a,streamId:e,label:p,protocol:x});let y=(s&3)===1?a:void 0,v=(s&3)===2?a:void 0,w=new Roe({label:p,ordered:(s&128)===0,maxPacketLifeTime:v,maxRetransmits:y,protocol:x,id:e}),S=new Poe(this,w,!1);S.isCreatedByRemote=!0,this.dataChannels[e]=S,this.onDataChannel.execute(S),S.setReadyState("open")}let i=this.dataChannels[e];this.dataChannelQueue.push([i,LU,Buffer.from(YU.jspack.Pack("!B",[hNe]))]),await this.dataChannelFlush()}break;case hNe:{TS("DATA_CHANNEL_ACK",e,r);let i=this.dataChannels[e];if(!i)throw new Error("channel not found");i.setReadyState("open")}break}else{let i=this.dataChannels[e];if(i){let s=(()=>{switch(r){case mNe:return n.toString("utf8");case B6t:return"";case gNe:return n;case U6t:return Buffer.from([]);default:throw new Error}})();i.messagesReceived++,i.bytesReceived+=n.length,i.onMessage.execute(s),i.emit("message",{data:s}),i.onmessage&&i.onmessage({data:s})}}};dataChannelAddNegotiated(e){if(e.id==null)throw new Error;if(this.dataChannels[e.id])throw new Error;this.dataChannels[e.id]=e,this.sctp.associationState===4&&e.setReadyState("open")}dataChannelOpen(e){if(e.id){if(this.dataChannels[e.id])throw new Error(`Data channel with ID ${e.id} already registered`);this.dataChannels[e.id]=e}let r=N6t,n=0,i=0;e.ordered||(r=128),e.maxRetransmits?(r=1,i=e.maxRetransmits):e.maxPacketLifeTime&&(r=2,i=e.maxPacketLifeTime);let s=YU.jspack.Pack("!BBHLHH",[pNe,r,n,i,e.label.length,e.protocol.length]),a=Buffer.concat([Buffer.from(s),Buffer.from(e.label,"utf8"),Buffer.from(e.protocol,"utf8")]);this.dataChannelQueue.push([e,LU,a]),this.dataChannelFlush()}async dataChannelFlush(){if(this.sctp.associationState==4){for(;this.dataChannelQueue.length>0;){let[e,r,n]=this.dataChannelQueue.shift(),i=e.id;if(i===void 0){for(i=this.dataChannelId;Object.keys(this.dataChannels).includes(i.toString());)i+=2;this.dataChannels[i]=e,e.setId(i)}if(r===LU)await this.sctp.send(i,r,n,{ordered:!0});else{let s=e.maxPacketLifeTime?Date.now()+e.maxPacketLifeTime/1e3:void 0;await this.sctp.send(i,r,n,{expiry:s,maxRetransmits:e.maxRetransmits,ordered:e.ordered}),e.addBufferedAmount(-n.length)}}this.dataChannelQueue=[]}}assertSendableMessageSize(e){if(this.remoteMaxMessageSize!==0&&e>this.remoteMaxMessageSize)throw new Error(`max-message-size exceeded: ${e} > ${this.remoteMaxMessageSize}`)}datachannelSend=(e,r)=>{let n=Buffer.isBuffer(r)?r:Buffer.from(r),i=dUe(r);return this.assertSendableMessageSize(i),e.addBufferedAmount(i),this.dataChannelQueue.push(typeof r=="string"?[e,mNe,n]:[e,gNe,n]),this.sctp.associationState!==4&&TS("sctp not established",this.sctp.associationState),this.dataChannelFlush(),i};getCapabilities(){return cMe.getCapabilities(this.maxMessageSize)}static getCapabilities(e=RS){return new Yoe(e)}setRemoteMaxMessageSize(e){this.remoteMaxMessageSize=e??RS}setRemotePort(e){this.sctp.setRemotePort(e)}async start(e){this.isServer?this.dataChannelId=0:this.dataChannelId=1,this.sctp.isServer=this.isServer,await this.sctp.start(e)}async stop(){this.dtlsTransport.dataReceiver=()=>{},await this.sctp.stop()}dataChannelClose(e){["closing","closed"].includes(e.readyState)||(e.setReadyState("closing"),this.sctp.associationState===4?(this.sctp.reconfigQueue.includes(e.id)||this.sctp.reconfigQueue.push(e.id),this.sctp.reconfigQueue.length===1&&this.sctp.transmitReconfigRequest()):(this.dataChannelQueue=this.dataChannelQueue.filter(r=>r[0].id!==e.id),this.sctp.reconfigQueue=this.sctp.reconfigQueue.filter(r=>r!==e.id),e.id&&delete this.dataChannels[e.id],e.setReadyState("closed")))}},Yoe=class{constructor(t){this.maxMessageSize=t}},F8t=class{constructor(t){this.dtls=t}set onData(t){this.dtls.dataReceiver=t}send=t=>this.dtls.sendData(t);close(){}},T6=class uMe{version=0;origin;name="-";time="0 0";host;group=[];extMapAllowMixed=!0;msidSemantic=[];media=[];type;dtlsRole;iceOptions;iceLite;icePassword;iceUsernameFragment;dtlsFingerprints=[];static parse(e){let[r,n]=P8t(e),i=new uMe;r.forEach(a=>{if(a.startsWith("v="))i.version=Number.parseInt(a.slice(2),10);else if(a.startsWith("o="))i.origin=a.slice(2);else if(a.startsWith("s="))i.name=a.slice(2);else if(a.startsWith("c="))i.host=eae(a.slice(2));else if(a.startsWith("t="))i.time=a.slice(2);else if(a.startsWith("a=")){let[c,d]=tae(a);switch(c){case"fingerprint":{let[h,p]=d?.split(" ")||[];i.dtlsFingerprints.push(new mM(h,p))}break;case"ice-lite":i.iceLite=!0;break;case"ice-options":i.iceOptions=d;break;case"ice-pwd":i.icePassword=d;break;case"ice-ufrag":i.iceUsernameFragment=d;break;case"group":iM(i.group,d);break;case"msid-semantic":iM(i.msidSemantic,d);break;case"setup":i.dtlsRole=yNe[d];break;case"extmap-allow-mixed":i.extMapAllowMixed=!0;break}}});let s=i.group.find(a=>a.semantic==="BUNDLE");return n.forEach(a=>{let d=a[0].match(/^m=([^ ]+) ([0-9]+) ([A-Z/]+) (.+)/);if(!d)throw new Error("m line not found");let h=d[1],p=d[4].split(" "),x=["audio","video"].includes(h)?p.map(w=>Number(w)):void 0,y=new yM(h,Number.parseInt(d[2]),d[3],x||p);if(y.dtlsParams=new gM([...i.dtlsFingerprints],i.dtlsRole),y.iceParams=new Zoe({iceLite:i.iceLite,usernameFragment:i.iceUsernameFragment,password:i.icePassword}),y.iceOptions=i.iceOptions,i.media.push(y),a.slice(1).forEach(w=>{if(w.startsWith("c="))y.host=eae(w.slice(2));else if(w.startsWith("a=")){let[S,C]=tae(w);switch(S){case"candidate":if(!C)throw new Error;y.iceCandidates.push(Qoe(C));break;case"end-of-candidates":y.iceCandidatesComplete=!0;break;case"extmap":{let[k,T]=C.split(" ");k.includes("/")&&([k]=k.split("/")),y.rtp.headerExtensions.push(new Mh({id:Number.parseInt(k),uri:T}))}break;case"fingerprint":{if(!C)throw new Error;let[k,T]=C.split(" ");y.dtlsParams?.fingerprints.push(new mM(k,T))}break;case"ice-options":y.iceOptions=C;break;case"ice-pwd":y.iceParams.password=C;break;case"ice-ufrag":y.iceParams.usernameFragment=C;break;case"ice-lite":y.iceParams.iceLite=!0;break;case"max-message-size":y.sctpCapabilities=new Yoe(Number.parseInt(C,10));break;case"mid":y.rtp.muxId=C;break;case"msid":y.msid=C;break;case"rtcp":{let[k,T]=bp(C," ");y.rtcpPort=Number.parseInt(k),y.rtcpHost=eae(T)}break;case"rtcp-mux":y.rtcpMux=!0;break;case"setup":y.dtlsParams.role=yNe[C];break;case"recvonly":case"sendonly":case"sendrecv":case"inactive":y.direction=S;break;case"rtpmap":{let[k,T]=bp(C," "),[E,I,R]=T.split("/"),U;y.kind==="audio"&&(U=R?Number.parseInt(R):1);let B=new jg({mimeType:y.kind+"/"+E,channels:U,clockRate:Number.parseInt(I),payloadType:Number.parseInt(k)});y.rtp.codecs.push(B)}break;case"sctpmap":{if(!C)throw new Error;let[k,T]=bp(C," ");y.sctpMap[Number.parseInt(k)]=T,y.sctpPort=Number.parseInt(k)}break;case"sctp-port":if(!C)throw new Error;y.sctpPort=Number.parseInt(C);break;case"ssrc":{let[k,T]=bp(C," "),E=Number.parseInt(k),[I,R]=bp(T,":"),U=y.ssrc.find(B=>B.ssrc===E);U||(U=new vM({ssrc:E}),y.ssrc.push(U)),bUe.includes(I)&&(U[I]=R)}break;case"ssrc-group":iM(y.ssrcGroup,C);break;case"rid":{let[k,T]=bp(C," ");y.simulcastParameters.push(new Ooe({rid:k,direction:T}))}break}}}),(!y.iceParams.usernameFragment||!y.iceParams.password)&&y.rtp.muxId&&s&&s.items.includes(y.rtp.muxId))for(let w=0;w<s.items.length;w++){if(!s.items.includes(w.toString()))continue;let S=i.media[w];if(S.iceParams?.usernameFragment&&S.iceParams.password){y.iceParams={...S.iceParams};break}}y.dtlsParams.role||(y.dtlsParams=void 0);let v=w=>y.rtp.codecs.find(S=>S.payloadType===w);a.slice(1).forEach(w=>{if(w.startsWith("a=")){let[S,C]=tae(w);if(S==="fmtp"){let[k,T]=bp(C," "),E=v(Number(k));E.parameters=T}else if(S==="rtcp-fb"){let[k,T,E]=C.split(" ");y.rtp.codecs.forEach(I=>{["*",I.payloadType.toString()].includes(k)&&I.rtcpFeedback.push(new pUe({type:T,parameter:E}))})}}})}),i}webrtcTrackId(e){if(e.msid?.includes(" ")){let r=e.msid.split(" ");for(let n of this.msidSemantic)if(n.semantic==="WMS"&&(n.items.includes(r[0])||n.items.includes("*")))return r[1]}}get string(){let e=[`v=${this.version}`,`o=${this.origin}`,`s=${this.name}`];this.host&&e.push(`c=${noe(this.host)}`),e.push(`t=${this.time}`),this.group.forEach(i=>e.push(`a=group:${i.str}`)),this.extMapAllowMixed&&e.push("a=extmap-allow-mixed"),this.msidSemantic.forEach(i=>e.push(`a=msid-semantic:${i.str}`));let r=this.media.map(i=>i.toString()).join("");return e.join(`\r
1110
1119
  `)+`\r
1111
1120
  `+r}toJSON(){return new lMe(this.string,this.type)}toSdp(){return{type:this.type,sdp:this.string}}},yM=class{constructor(t,e,r,n){this.kind=t,this.port=e,this.profile=r,this.fmt=n}host;direction;msid;rtcpPort;rtcpHost;rtcpMux=!1;ssrc=[];ssrcGroup=[];rtp={codecs:[],headerExtensions:[]};sctpCapabilities;sctpMap={};sctpPort;dtlsParams;iceParams;iceCandidates=[];iceCandidatesComplete=!1;iceOptions;simulcastParameters=[];toString(){let t=[];if(t.push(`m=${this.kind} ${this.port} ${this.profile} ${this.fmt.map(e=>e.toString()).join(" ")}`),this.host&&t.push(`c=${noe(this.host)}`),this.iceCandidates.forEach(e=>{t.push(`a=candidate:${Joe(e)}`)}),this.iceCandidatesComplete&&t.push("a=end-of-candidates"),this.iceParams?.usernameFragment&&t.push(`a=ice-ufrag:${this.iceParams.usernameFragment}`),this.iceParams?.password&&t.push(`a=ice-pwd:${this.iceParams.password}`),this.iceParams?.iceLite&&t.push("a=ice-lite"),this.iceOptions&&t.push(`a=ice-options:${this.iceOptions}`),this.dtlsParams&&(this.dtlsParams.fingerprints.forEach(e=>{t.push(`a=fingerprint:${e.algorithm} ${e.value}`)}),t.push(`a=setup:${jae[this.dtlsParams.role]}`)),this.direction&&t.push(`a=${this.direction}`),this.rtp.muxId&&t.push(`a=mid:${this.rtp.muxId}`),this.msid&&t.push(`a=msid:${this.msid}`),this.rtcpPort&&this.rtcpHost&&(t.push(`a=rtcp:${this.rtcpPort} ${noe(this.rtcpHost)}`),this.rtcpMux&&t.push("a=rtcp-mux")),this.ssrcGroup.forEach(e=>{t.push(`a=ssrc-group:${e.str}`)}),this.ssrc.forEach(e=>{bUe.forEach(r=>{let n=e[r];n!==void 0&&t.push(`a=ssrc:${e.ssrc} ${r}:${n}`)})}),this.rtp.codecs.forEach(e=>{t.push(`a=rtpmap:${e.payloadType} ${e.str}`),e.rtcpFeedback.forEach(r=>{let n=r.type;r.parameter&&(n+=` ${r.parameter}`),t.push(`a=rtcp-fb:${e.payloadType} ${n}`)}),e.parameters&&t.push(`a=fmtp:${e.payloadType} ${e.parameters}`)}),Object.keys(this.sctpMap).forEach(e=>{let r=this.sctpMap[Number(e)];t.push(`a=sctpmap:${e} ${r}`)}),this.sctpPort&&t.push(`a=sctp-port:${this.sctpPort}`),this.sctpCapabilities&&t.push(`a=max-message-size:${this.sctpCapabilities.maxMessageSize}`),this.rtp.headerExtensions.forEach(e=>t.push(`a=extmap:${e.id} ${e.uri}`)),this.simulcastParameters.length){this.simulcastParameters.forEach(i=>{t.push(`a=rid:${i.rid} ${i.direction}`)});let e="a=simulcast:",r=this.simulcastParameters.filter(i=>i.direction==="recv");r.length&&(e+=`recv ${r.map(i=>i.rid).join(";")} `);let n=this.simulcastParameters.filter(i=>i.direction==="send");n.length&&(e+=`send ${n.map(i=>i.rid).join(";")}`),t.push(e)}return t.join(`\r
1112
1121
  `)+`\r
1113
- `}},US=class{constructor(t,e){this.semantic=t,this.items=e}get str(){return`${this.semantic} ${this.items.join(" ")}`}};lMe=class{constructor(t,e){this.sdp=t,this.type=e}static isThis(t){if(typeof t?.sdp=="string")return!0}toSdp(){return{sdp:this.sdp,type:this.type}}};vM=class{ssrc;cname;msid;msLabel;label;constructor(t){Object.assign(this,t)}},jU=_n("werift:packages/webrtc/src/media/rtpReceiver.ts"),ece=class{constructor(t,e,r){this.config=t,this.kind=e,this.rtcpSsrc=r}codecs={};get codecArray(){return Object.values(this.codecs).sort((t,e)=>t.payloadType-e.payloadType)}ssrcByRtx={};nack=new KDt(this);audioRedHandler=new bBe;type="receiver";uuid=FDt().toString();tracks=[];trackBySSRC={};trackByRID={};lastSRtimestamp={};receiveLastSRTimestamp={};onPacketLost=this.nack.onPacketLost;onRtcp=new yr;dtlsTransport;sdesMid;latestRid;latestRepairedRid;receiverTWCC;stopped=!1;remoteStreamId;remoteTrackId;rtcpRunning=!1;rtcpCancel=new AbortController;remoteStreams={};setDtlsTransport(t){this.dtlsTransport=t}get track(){return this.tracks[0]??new qD({kind:this.kind})}get nackEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type==="nack")}get twccEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type===hUe().type)}get pliEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type===GS().type)}prepareReceive(t){t.codecs.forEach(e=>{this.codecs[e.payloadType]=e}),t.encodings.forEach(e=>{e.rtx&&(this.ssrcByRtx[e.rtx.ssrc]=e.ssrc)})}setupTWCC(t){this.twccEnabled&&!this.receiverTWCC&&(this.receiverTWCC=new YDt(this.dtlsTransport,this.rtcpSsrc,t))}addTrack(t){return this.tracks.find(r=>{if(r.rid)return r.rid===t.rid;if(r.ssrc)return r.ssrc===t.ssrc})?!1:(this.tracks.push(t),t.ssrc&&(this.trackBySSRC[t.ssrc]=t),t.rid&&(this.trackByRID[t.rid]=t),!0)}stop(){this.stopped=!0,this.rtcpRunning=!1,this.rtcpCancel.abort(),this.receiverTWCC&&(this.receiverTWCC.twccRunning=!1),this.nack.close()}async runRtcp(){if(!(this.rtcpRunning||this.stopped)){this.rtcpRunning=!0;try{for(;this.rtcpRunning;){await Qse(500+Math.random()*1e3,void 0,{signal:this.rtcpCancel.signal});let t=Object.entries(this.remoteStreams).map(([r,n])=>{let i=0,s=0;if(this.lastSRtimestamp[r]){i=this.lastSRtimestamp[r];let a=zD()-this.receiveLastSRTimestamp[r];a>0&&a<65536&&(s=OS(a*65536))}return new kM({ssrc:Number(r),fractionLost:n.fraction_lost,packetsLost:n.packets_lost,highestSequence:n.max_seq,jitter:n.jitter,lsr:i,dlsr:s})}),e=new $S({ssrc:this.rtcpSsrc,reports:t});try{this.config.debug.receiverReportDelay&&await Qse(this.config.debug.receiverReportDelay),await this.dtlsTransport.sendRtcp([e])}catch(r){jU("sendRtcp failed",r),await Qse(500+Math.random()*1e3)}}}catch{}}}async getStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id);for(let n of this.tracks){if(!n.ssrc)continue;let i=this.remoteStreams[n.ssrc];if(!i)continue;let s={type:"inbound-rtp",id:rs("inbound-rtp",n.ssrc),timestamp:t,ssrc:n.ssrc,kind:this.kind,transportId:r,codecId:this.codecs[0]?rs("codec",this.codecs[0].payloadType,r):void 0,mid:this.sdesMid,trackIdentifier:n.id,packetsReceived:i.packets_received,packetsLost:i.packets_lost,jitter:i.jitter};if(e.push(s),this.lastSRtimestamp[n.ssrc]){let a={type:"remote-outbound-rtp",id:rs("remote-outbound-rtp",n.ssrc),timestamp:t,ssrc:n.ssrc,kind:this.kind,transportId:r,codecId:s.codecId,localId:s.id,remoteTimestamp:this.receiveLastSRTimestamp[n.ssrc]*1e3};e.push(a)}}return e}async sendRtcpPLI(t){if(!this.pliEnabled){jU("pli not supported",{mediaSsrc:t});return}if(this.stopped)return;jU("sendRtcpPLI",{mediaSsrc:t});let e=new LS({feedback:new ND({senderSsrc:this.rtcpSsrc,mediaSsrc:t})});try{await this.dtlsTransport.sendRtcp([e])}catch(r){jU(r)}}handleRtcpPacket(t){switch(t.type){case Cv.type:{let e=t;this.lastSRtimestamp[e.ssrc]=Voe(e.senderInfo.ntpTimestamp),this.receiveLastSRTimestamp[e.ssrc]=zD();let r=this.trackBySSRC[t.ssrc];r&&r.onReceiveRtcp.execute(t)}break}this.onRtcp.execute(t)}handleRtpBySsrc=(t,e)=>{let r=this.trackBySSRC[t.header.ssrc];this.handleRTP(t,e,r)};handleRtpByRid=(t,e,r)=>{let n=this.trackByRID[e];this.trackBySSRC[t.header.ssrc]||(this.trackBySSRC[t.header.ssrc]=n),this.handleRTP(t,r,n)};handleRTP(t,e,r){if(this.stopped)return;let n=this.codecs[t.header.payloadType];if(!n)return;if(this.remoteStreams[t.header.ssrc]=this.remoteStreams[t.header.ssrc]??new JDt(n.clockRate),this.remoteStreams[t.header.ssrc].add(t),this.receiverTWCC){let s=e[Os.transportWideCC];if(!s==null)throw new Error("undefined");this.receiverTWCC.handleTWCC(s)}else this.twccEnabled&&this.setupTWCC(t.header.ssrc);if(n.name.toLowerCase()==="rtx"){let s=this.ssrcByRtx[t.header.ssrc],a=HD(n.parameters??""),c=this.codecs[a.apt];if(t.payload.length<2)return;t=wBe(t,c.payloadType,s),r=this.trackBySSRC[s]}let i;if(!(n.name.toLowerCase()==="red"&&(i=voe.deSerialize(t.payload),!Object.keys(this.codecs).includes(i.header.fields[0].blockPT.toString())))){if(r?.kind==="video"&&this.nackEnabled&&this.nack.addPacket(t),r)if(i){if(r.kind==="audio"){let s=this.audioRedHandler.push(i,t);for(let a of s)r.onReceiveRtp.execute(a.clone(),e)}}else r.onReceiveRtp.execute(t.clone(),e);this.runRtcp()}}},cD=_n("werift:packages/webrtc/src/media/router.ts"),fMe=class{ssrcTable={};ridTable={};extIdUriMap={};constructor(){}registerRtpSender(t){this.ssrcTable[t.ssrc]=t}registerRtpReceiver(t,e){cD("registerRtpReceiver",e),this.ssrcTable[e]=t}registerRtpReceiverBySsrc(t,e){cD("registerRtpReceiverBySsrc",e),e.encodings.filter(r=>r.ssrc!=null).forEach((r,n)=>{this.registerRtpReceiver(t.receiver,r.ssrc),t.addTrack(new qD({ssrc:r.ssrc,kind:t.kind,id:t.sender.trackId,remote:!0,codec:e.codecs[n]})),r.rtx&&this.registerRtpReceiver(t.receiver,r.rtx.ssrc)}),e.headerExtensions.forEach(r=>{this.extIdUriMap[r.id]=r.uri})}registerRtpReceiverByRid(t,e,r){let[n]=r.codecs;cD("registerRtpReceiverByRid",e),t.addTrack(new qD({rid:e.rid,kind:t.kind,id:t.sender.trackId,remote:!0,codec:n})),this.ridTable[e.rid]=t.receiver}routeRtp=t=>{let e=aBe(t.header.extensions,this.extIdUriMap),r=this.ssrcTable[t.header.ssrc],n=e[Os.sdesRTPStreamID];if(typeof n=="string"?(r=this.ridTable[n],r.latestRid=n,r.handleRtpByRid(t,n,e)):r?r.handleRtpBySsrc(t,e):(r=Object.values(this.ridTable).filter(a=>a instanceof ece).find(a=>a.trackBySSRC[t.header.ssrc]),r&&(cD("simulcast register receiver by ssrc",t.header.ssrc),this.registerRtpReceiver(r,t.header.ssrc),r.handleRtpBySsrc(t,e))),!r){cD("ssrcReceiver not found");return}let i=e[Os.sdesMid];typeof i=="string"&&(r.sdesMid=i);let s=e[Os.repairedRtpStreamId];typeof s=="string"&&(r.latestRepairedRid=s)};routeRtcp=t=>{let e=[];switch(t.type){case Cv.type:t=t,e.push(this.ssrcTable[t.ssrc]);break;case $S.type:t=t,t.reports.forEach(r=>{e.push(this.ssrcTable[r.ssrc])});break;case LD.type:{let r=t}break;case Tv.type:{let r=t;r.feedback&&e.push(this.ssrcTable[r.feedback.mediaSourceSsrc])}break;case LS.type:{let r=t;switch(r.feedback.count){case BD.count:{let n=r.feedback;e.push(this.ssrcTable[n.ssrcFeedbacks[0]])}break;default:e.push(this.ssrcTable[r.feedback.senderSsrc]||this.ssrcTable[r.feedback.mediaSsrc])}}break}e.filter(r=>r).forEach(r=>r.handleRtcpPacket(t))}},O8t=class{numPackets=0;totalSize=0;firstPacketSentAtMs=0;lastPacketSentAtMs=0;firstPacketReceivedAtMs=0;lastPacketReceivedAtMs=0;addPacket(t,e,r){this.numPackets===0?(this.firstPacketSentAtMs=e,this.firstPacketReceivedAtMs=r,this.lastPacketSentAtMs=e,this.lastPacketReceivedAtMs=r):(e<this.firstPacketSentAtMs&&(this.firstPacketSentAtMs=e),r<this.firstPacketReceivedAtMs&&(this.firstPacketReceivedAtMs=r),e>this.lastPacketSentAtMs&&(this.lastPacketSentAtMs=e),r>this.lastPacketReceivedAtMs&&(this.lastPacketReceivedAtMs=r)),this.numPackets++,this.totalSize+=t}reset(){this.numPackets=0,this.totalSize=0,this.firstPacketSentAtMs=0,this.lastPacketSentAtMs=0,this.firstPacketReceivedAtMs=0,this.lastPacketReceivedAtMs=0}get receiveBitrate(){let t=this.lastPacketReceivedAtMs-this.firstPacketReceivedAtMs,e=this.totalSize/t*8*1e3;return OD(e)}get sendBitrate(){let t=this.lastPacketSentAtMs-this.firstPacketSentAtMs,e=this.totalSize/t*8*1e3;return OD(e)}},CS=20,N8t=10,B8t=class{congestion=!1;onAvailableBitrate=new yr;onCongestion=new yr;onCongestionScore=new yr;congestionCounter=0;cumulativeResult=new O8t;sentInfos={};_congestionScore=1;get congestionScore(){return this._congestionScore}set congestionScore(t){this._congestionScore=t,this.onCongestionScore.execute(t)}_availableBitrate=0;get availableBitrate(){return this._availableBitrate}set availableBitrate(t){this._availableBitrate=t,this.onAvailableBitrate.execute(t)}constructor(){}receiveTWCC(t){let r=Hoe()-this.cumulativeResult.firstPacketSentAtMs;r>1e3&&(this.cumulativeResult.reset(),this.congestionCounter<CS?this.congestionCounter++:this.congestionScore<N8t&&this.congestionScore++,this.congestionCounter>=CS&&!this.congestion&&(this.congestion=!0,this.onCongestion.execute(this.congestion)));for(let n of t.packetResults){if(!n.received)continue;let i=n.sequenceNumber,s=this.sentInfos[i];s&&n.receivedAtMs&&this.cumulativeResult.addPacket(s.size,s.sendingAtMs,n.receivedAtMs)}if(r>=100&&this.cumulativeResult.numPackets>=20){if(this.availableBitrate=Math.min(this.cumulativeResult.sendBitrate,this.cumulativeResult.receiveBitrate),this.cumulativeResult.reset(),this.congestionCounter>-CS){let n=OD(CS/2)+1,i=OD(CS/4)+1,s=n-(n-i)/10*this.congestionScore;this.congestionCounter=this.congestionCounter-s}this.congestionCounter<=-CS&&(this.congestionScore>1&&(this.congestionScore--,this.onCongestion.execute(!1)),this.congestionCounter=0),this.congestionCounter<=0&&this.congestion&&(this.congestion=!1,this.onCongestion.execute(this.congestion))}}rtpPacketSent(t){Object.keys(t).map(e=>Number(e)).sort().filter(e=>e<t.wideSeq).forEach(e=>{delete this.sentInfos[e]}),this.sentInfos[t.wideSeq]=t}},rae=_n("werift:packages/webrtc/src/media/rtpSender.ts"),UNe=128,MNe=.85,dMe=class{constructor(t){this.trackOrKind=t,this.kind=typeof this.trackOrKind=="string"?this.trackOrKind:this.trackOrKind.kind,typeof t!="string"&&(t.streamId&&(this.streamId=t.streamId),this.registerTrack(t))}type="sender";kind;ssrc=soe.jspack.Unpack("!L",ONe(4))[0];rtxSsrc=soe.jspack.Unpack("!L",ONe(4))[0];streamId=NNe().toString();trackId=NNe().toString();onReady=new yr;onRtcp=new yr;onPictureLossIndication=new yr;onGenericNack=new yr;senderBWE=new B8t;cname;mid;rtpStreamId;repairedRtpStreamId;rtxPayloadType;rtxSequenceNumber=coe();redRedundantPayloadType;_redDistance=2;redEncoder=new vBe(this._redDistance);headerExtensions=[];disposeTrack;lastSRtimestamp;lastSentSRTimestamp;ntpTimestamp=0n;rtpTimestamp=0;octetCount=0;packetCount=0;rtt;receiverEstimatedMaxBitrate=0n;sequenceNumber;timestamp;timestampOffset=0;seqOffset=0;rtpCache=[];codec;dtlsTransport;dtlsDisposer=[];track;stopped=!1;rtcpRunning=!1;rtcpCancel=new AbortController;setDtlsTransport(t){this.dtlsTransport&&this.dtlsDisposer.forEach(e=>e()),this.dtlsTransport=t,this.dtlsDisposer=[this.dtlsTransport.onStateChange.subscribe(e=>{e==="connected"&&this.onReady.execute()}).unSubscribe]}get redDistance(){return this._redDistance}set redDistance(t){this._redDistance=t,this.redEncoder.distance=t}prepareSend(t){this.cname=t.rtcp?.cname,this.mid=t.muxId,this.headerExtensions=t.headerExtensions,this.rtpStreamId=t.rtpStreamId,this.repairedRtpStreamId=t.repairedRtpStreamId,this.codec=t.codecs[0],this.track&&(this.track.codec=this.codec),t.codecs.forEach(e=>{let r=HD(e.parameters??"");e.name.toLowerCase()==="rtx"&&r.apt===this.codec?.payloadType&&(this.rtxPayloadType=e.payloadType),e.name.toLowerCase()==="red"&&(this.redRedundantPayloadType=Number((e.parameters??"").split("/")[0]))})}registerTrack(t){if(t.stopped)throw new Error("track is ended");this.disposeTrack&&this.disposeTrack(),t.id=this.trackId;let{unSubscribe:e}=t.onReceiveRtp.subscribe(async r=>{await this.sendRtp(r)});this.track=t,this.disposeTrack=e,this.codec&&(t.codec=this.codec),t.onSourceChanged.subscribe(r=>{this.replaceRTP(r)})}async replaceTrack(t){if(t!==null){if(t.stopped)throw new Error("track is ended");if(this.sequenceNumber!=null){let e=t.header||(await t.onReceiveRtp.asPromise())[0].header;this.replaceRTP(e)}this.registerTrack(t),rae("replaceTrack","ssrc",t.ssrc,"rid",t.rid)}}stop(){this.stopped=!0,this.rtcpRunning=!1,this.rtcpCancel.abort(),this.disposeTrack&&this.disposeTrack(),this.track=void 0}async runRtcp(){if(!(this.rtcpRunning||this.stopped)){this.rtcpRunning=!0;try{for(;this.rtcpRunning;){await BNe(500+Math.random()*1e3,void 0,{signal:this.rtcpCancel.signal});let t=[new Cv({ssrc:this.ssrc,senderInfo:new yoe({ntpTimestamp:this.ntpTimestamp,rtpTimestamp:this.rtpTimestamp,packetCount:this.packetCount,octetCount:this.octetCount})})];this.lastSRtimestamp=Voe(this.ntpTimestamp),this.lastSentSRTimestamp=zD(),this.cname&&t.push(new LD({chunks:[new goe({source:this.ssrc,items:[new xoe({type:1,text:this.cname})]})]}));try{await this.dtlsTransport.sendRtcp(t)}catch(e){rae("sendRtcp failed",e),await BNe(500+Math.random()*1e3)}}}catch{}}}replaceRTP({sequenceNumber:t,timestamp:e},r=!1){this.sequenceNumber!=null&&(this.seqOffset=jo(this.sequenceNumber,-t),r&&(this.seqOffset=jo(this.seqOffset,2))),this.timestamp!=null&&(this.timestampOffset=bv(this.timestamp,-e),r&&(this.timestampOffset=jo(this.timestampOffset,1))),this.rtpCache=[],rae("replaceRTP",this.sequenceNumber,t,this.seqOffset)}async sendRtp(t){if(this.dtlsTransport.state!=="connected"||!this.codec)return;t=Buffer.isBuffer(t)?Cp.deSerialize(t):t;let{header:e,payload:r}=t;e.ssrc=this.ssrc,e.payloadType=this.codec.payloadType,e.timestamp=bv(e.timestamp,this.timestampOffset),e.sequenceNumber=jo(e.sequenceNumber,this.seqOffset),this.timestamp=e.timestamp,this.sequenceNumber=e.sequenceNumber;let n=DUe(),i=[...e.extensions];e.extensions=this.headerExtensions.map(h=>{let p=(()=>{switch(h.uri){case Os.sdesMid:return this.mid?oBe(this.mid):void 0;case Os.sdesRTPStreamID:return this.rtpStreamId?cBe(this.rtpStreamId):void 0;case Os.repairedRtpStreamId:return this.repairedRtpStreamId?uBe(this.repairedRtpStreamId):void 0;case Os.transportWideCC:return this.dtlsTransport.transportSequenceNumber=jo(this.dtlsTransport.transportSequenceNumber,1),lBe(this.dtlsTransport.transportSequenceNumber);case Os.absSendTime:return fBe(n)}})();if(p)return{id:h.id,payload:p}}).filter(h=>h);for(let h of i){let p=e.extensions.find(x=>x.id===h.id);p?p.payload=h.payload:e.extensions.push(h)}e.extensions=e.extensions.sort((h,p)=>h.id-p.id),this.ntpTimestamp=n,this.rtpTimestamp=e.timestamp,this.octetCount+=r.length,this.packetCount=bv(this.packetCount,1),this.rtpCache[e.sequenceNumber%UNe]=t;let s=r;this.redRedundantPayloadType&&(this.redEncoder.push({block:s,timestamp:e.timestamp,blockPT:this.redRedundantPayloadType}),s=this.redEncoder.build().serialize());let a=await this.dtlsTransport.sendRtp(s,e);this.runRtcp();let c=Hoe(),d={wideSeq:this.dtlsTransport.transportSequenceNumber,size:a,sendingAtMs:c,sentAtMs:c};this.senderBWE.rtpPacketSent(d)}handleRtcpPacket(t){switch(t.type){case Cv.type:case $S.type:t.reports.filter(r=>r.ssrc===this.ssrc).forEach(r=>{if(this.lastSRtimestamp===r.lsr&&r.dlsr&&this.lastSentSRTimestamp){let n=zD()-this.lastSentSRTimestamp-r.dlsr/65536;this.rtt===void 0?this.rtt=n:this.rtt=MNe*this.rtt+(1-MNe)*n}});break;case Tv.type:{let e=t;switch(e.feedback.count){case MD.count:{let r=e.feedback;this.senderBWE.receiveTWCC(r)}break;case UD.count:{let r=e.feedback;r.lost.forEach(async n=>{let i=this.rtpCache[n%UNe];i&&i.header.sequenceNumber!==n&&(i=void 0),i&&(this.rtxPayloadType!=null&&(i=SBe(i,this.rtxPayloadType,this.rtxSequenceNumber,this.rtxSsrc),this.rtxSequenceNumber=jo(this.rtxSequenceNumber,1)),await this.dtlsTransport.sendRtp(i.payload,i.header))}),this.onGenericNack.execute(r)}break}}break;case LS.type:{let e=t;switch(e.feedback.count){case BD.count:{let r=e.feedback;this.receiverEstimatedMaxBitrate=r.bitrate}break;case ND.count:this.onPictureLossIndication.execute();break}}break}this.onRtcp.execute(t)}getParameters(){return{encodings:[]}}setParameters(t){}async getStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id),n={type:"outbound-rtp",id:rs("outbound-rtp",this.ssrc),timestamp:t,ssrc:this.ssrc,kind:this.kind,transportId:r,codecId:this.codec?rs("codec",this.codec.payloadType,r):void 0,mid:this.mid,packetsSent:this.packetCount,bytesSent:this.octetCount,rtxSsrc:this.rtxPayloadType?this.rtxSsrc:void 0};if(e.push(n),this.track){let i={type:"media-source",id:rs("media-source",this.trackId),timestamp:t,trackIdentifier:this.trackId,kind:this.kind};e.push(i)}if(this.rtt!==void 0){let i={type:"remote-inbound-rtp",id:rs("remote-inbound-rtp",this.ssrc),timestamp:t,ssrc:this.ssrc,kind:this.kind,transportId:r,codecId:n.codecId,localId:n.id,roundTripTime:this.rtt};e.push(i)}return e}},M8t=_n("werift:packages/webrtc/src/transport/sctpManager.ts"),L8t=class{sctpTransport;sctpRemotePort;dataChannelsOpened=0;dataChannelsClosed=0;dataChannels=[];onDataChannel=new yr;constructor(){}createSctpTransport(t){let e=new oMe(5e3,t);return e.mid=void 0,e.onDataChannel.subscribe(r=>{this.dataChannelsOpened++,this.dataChannels.push(r),this.onDataChannel.execute(r)}),this.sctpTransport=e,e}createDataChannel(t,e={}){let n={...{protocol:"",ordered:!0,negotiated:!1},...e};if(n.maxPacketLifeTime&&n.maxRetransmits)throw new Error("can not select both");this.sctpTransport||(this.sctpTransport=this.createSctpTransport());let i=new Roe({id:n.id,label:t,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits,negotiated:n.negotiated,ordered:n.ordered,protocol:n.protocol}),s=new Poe(this.sctpTransport,i);return this.dataChannelsOpened++,this.dataChannels.push(s),s.stateChange.subscribe(a=>{if(a==="closed"){this.dataChannelsClosed++;let c=this.dataChannels.indexOf(s);c!==-1&&this.dataChannels.splice(c,1)}}),s}async connectSctp(){!this.sctpTransport||!this.sctpRemotePort||(await this.sctpTransport.start(this.sctpRemotePort),await this.sctpTransport.sctp.stateChanged.connected.asPromise(),M8t("sctp connected"))}setRemoteSCTP(t,e){if(this.sctpTransport){if(this.sctpTransport.setRemoteMaxMessageSize(t.sctpCapabilities?.maxMessageSize),this.sctpRemotePort=t.sctpPort,!this.sctpRemotePort)throw new Error("sctpRemotePort not exist");this.sctpTransport.setRemotePort(this.sctpRemotePort),this.sctpTransport.mLineIndex=e,this.sctpTransport.mid||(this.sctpTransport.mid=t.rtp.muxId)}}async close(){this.sctpTransport&&await this.sctpTransport.stop(),this.onDataChannel.allUnsubscribe()}async getStats(){let t=qg(),e=[];for(let r of this.dataChannels){let n={type:"data-channel",id:rs("data-channel",r.id),timestamp:t,label:r.label,protocol:r.protocol,dataChannelIdentifier:r.id,state:r.readyState,messagesSent:r.messagesSent||0,bytesSent:r.bytesSent||0,messagesReceived:r.messagesReceived||0,bytesReceived:r.bytesReceived||0};e.push(n)}return e}},hMe=class{currentLocalDescription;currentRemoteDescription;pendingLocalDescription;pendingRemoteDescription;cname;midSuffix;bundlePolicy;seenMid=new Set;constructor({cname:t,midSuffix:e,bundlePolicy:r}){this.cname=t,this.midSuffix=e??!1,this.bundlePolicy=r}get localDescription(){if(this._localDescription)return this._localDescription.toJSON()}get remoteDescription(){if(this._remoteDescription)return this._remoteDescription.toJSON()}get _localDescription(){return this.pendingLocalDescription||this.currentLocalDescription}get _remoteDescription(){return this.pendingRemoteDescription||this.currentRemoteDescription}get inactiveRemoteMedia(){return this._remoteDescription?.media?.find?.(t=>t.direction==="inactive")}createMediaDescriptionForTransceiver(t,e){let r=new yM(t.kind,9,"UDP/TLS/RTP/SAVPF",t.codecs.map(n=>n.payloadType));return r.direction=e,r.msid=t.msid,r.rtp={codecs:t.codecs,headerExtensions:t.headerExtensions,muxId:t.mid},r.rtcpHost="0.0.0.0",r.rtcpPort=9,r.rtcpMux=!0,r.ssrc=[new vM({ssrc:t.sender.ssrc,cname:this.cname})],t.options.simulcast&&(r.simulcastParameters=t.options.simulcast.map(n=>new Ooe(n))),r.rtp.codecs.find(n=>n.name.toLowerCase()==="rtx")&&(r.ssrc.push(new vM({ssrc:t.sender.rtxSsrc,cname:this.cname})),r.ssrcGroup=[new US("FID",[t.sender.ssrc.toString(),t.sender.rtxSsrc.toString()])]),this.addTransportDescription(r,t.dtlsTransport),r}createMediaDescriptionForSctp(t){let e=new yM("application",xNe,"UDP/DTLS/SCTP",["webrtc-datachannel"]);return e.sctpPort=t.port,e.rtp.muxId=t.mid,e.sctpCapabilities=t.getCapabilities(),this.addTransportDescription(e,t.dtlsTransport),e}addTransportDescription(t,e){let r=e.iceTransport;t.iceCandidates=r.localCandidates,t.iceCandidatesComplete=r.gatheringState==="complete",t.iceParams=r.localParameters,t.iceOptions="trickle",t.host=MDt,t.port=xNe,t.direction==="inactive"&&(t.port=0,t.msid=void 0),t.dtlsParams||(t.dtlsParams=e.localParameters,t.dtlsParams.fingerprints||(t.dtlsParams.fingerprints=e.localParameters.fingerprints))}allocateMid(t=""){let e="";for(let r=0;e=(r++).toString()+t,!!this.seenMid.has(e););return this.seenMid.add(e),e}parseSdp({sdp:t,isLocal:e,signalingState:r,type:n}){let i=TD.parse(t);return this.validateDescription({description:i,isLocal:e,signalingState:r}),i.type=n,i}validateDescription({description:t,isLocal:e,signalingState:r}){if(e){if(t.type==="offer"){if(!["stable","have-local-offer"].includes(r))throw new Error("Cannot handle offer in signaling state")}else if(t.type==="answer"&&!["have-remote-offer","have-local-pranswer"].includes(r))throw new Error("Cannot handle answer in signaling state")}else if(t.type==="offer"){if(!["stable","have-remote-offer"].includes(r))throw new Error("Cannot handle offer in signaling state")}else if(t.type==="answer"&&!["have-local-offer","have-remote-pranswer"].includes(r))throw new Error("Cannot handle answer in signaling state")}buildOfferSdp(t,e){let r=new TD;ioe("offer",r),(this.currentLocalDescription?.media??[]).forEach((i,s)=>{let a=i.rtp.muxId;if(a)if(i.kind==="application"){if(!e)throw new Error("sctpTransport not found");e.mLineIndex=s,r.media.push(this.createMediaDescriptionForSctp(e))}else{let c=t.find(d=>d.mid===a);if(!c){if(i.direction==="inactive"){r.media.push(i);return}throw new Error("transceiver not found")}c.mLineIndex=s,r.media.push(this.createMediaDescriptionForTransceiver(c,c.direction))}});for(let i of t.filter(s=>!r.media.find(a=>a.rtp.muxId===s.mid))){i.mid==null&&(i.mid=this.allocateMid(this.midSuffix?"av":""));let s=this.createMediaDescriptionForTransceiver(i,i.direction);i.mLineIndex===void 0?(i.mLineIndex=r.media.length,r.media.push(s)):r.media[i.mLineIndex]=s}if(e&&!r.media.find(i=>i.kind==="application")&&(e.mLineIndex=r.media.length,e.mid==null&&(e.mid=this.allocateMid(this.midSuffix?"dc":"")),r.media.push(this.createMediaDescriptionForSctp(e))),this.bundlePolicy!=="disable"){let i=r.media.map(s=>s.rtp.muxId).filter(s=>s);if(i.length){let s=new US("BUNDLE",i);r.group.push(s)}}return r}buildAnswerSdp({transceivers:t,sctpTransport:e,signalingState:r}){if(!["have-remote-offer","have-local-pranswer"].includes(r))throw new Error("createAnswer failed");if(!this._remoteDescription)throw new Error("wrong state");let n=new TD;ioe("answer",n);for(let i of this._remoteDescription.media){let s,a;if(["audio","video"].includes(i.kind)){let c=t.find(d=>d.mid===i.rtp.muxId);if(!c)throw new Error(`Transceiver with mid=${i.rtp.muxId} not found`);a=this.createMediaDescriptionForTransceiver(c,Woe(c.direction,c.offerDirection)),s=c.dtlsTransport}else if(i.kind==="application"){if(!e||!e.mid)throw new Error("sctpTransport not found");a=this.createMediaDescriptionForSctp(e),s=e.dtlsTransport}else throw new Error("invalid kind");a.dtlsParams&&(s.role==="auto"?a.dtlsParams.role="client":a.dtlsParams.role=s.role),i.simulcastParameters&&i.simulcastParameters.length>0&&(a.simulcastParameters=i.simulcastParameters.map(c=>({...c,direction:c.direction==="send"?"recv":"send"}))),n.media.push(a)}if(this.bundlePolicy!=="disable"){let i=new US("BUNDLE",[]);for(let s of n.media)s.rtp.muxId&&i.items.push(s.rtp.muxId);n.group.push(i)}return n}setLocalDescription(t){this.currentLocalDescription=t,t.type==="answer"?this.pendingLocalDescription=void 0:this.pendingLocalDescription=t}setRemoteDescription(t,e){if(!t.sdp||!t.type||t.type==="rollback"||t.type==="pranswer")throw new Error("invalid sessionDescription");let r=this.parseSdp({sdp:t.sdp,isLocal:!1,signalingState:e,type:t.type});return r.type==="answer"?(this.currentRemoteDescription=r,this.pendingRemoteDescription=void 0):this.pendingRemoteDescription=r,r}registerMid(t){this.seenMid.add(t)}get remoteIsBundled(){let t=this._remoteDescription;return t?t.group.find(r=>r.semantic==="BUNDLE"&&this.bundlePolicy!=="disable"):void 0}setLocal(t,e,r){let n=new Map(e.map(a=>[a?.mLineIndex,a])),i=e.find(a=>a?.dtlsTransport)?.dtlsTransport??r?.dtlsTransport;t.media.filter(a=>["audio","video"].includes(a.kind)).forEach((a,c)=>{let h=(n.get(c)??e[c])?.dtlsTransport??i;if(!h)throw new Error(`dtls transport not found for media index ${c}`);this.addTransportDescription(a,h)});let s=t.media.find(a=>a.kind==="application");r&&s&&this.addTransportDescription(s,r.dtlsTransport),this.setLocalDescription(t)}},uD=_n("werift:packages/webrtc/src/transport/secureTransportManager.ts"),$8t=class{connectionState="new";iceConnectionState="new";iceGatheringState="new";certificate;iceGatheringStateChange=new yr;iceConnectionStateChange=new yr;onIceCandidate=new yr;connectionStateChange=new yr;config;transceiverManager;sctpManager;constructor({config:t,transceiverManager:e,sctpManager:r}){if(this.config=t,this.transceiverManager=e,this.sctpManager=r,this.config.dtls){let{keys:n}=this.config.dtls;n&&this.setupCertificate(n)}}get dtlsTransports(){return[...this.transceiverManager.getTransceivers().map(e=>e?.dtlsTransport),this.sctpManager.sctpTransport?.dtlsTransport].filter(e=>e!=null).reduce((e,r)=>(e.map(n=>n.id).includes(r.id)||e.push(r),e),[])}get iceTransports(){return this.dtlsTransports.map(t=>t.iceTransport)}setupCertificate(t){this.certificate=new Goe(t.keyPem,t.certPem,t.signatureHash)}createTransport(){let t=this.iceTransports.find(i=>i.state!=="closed"),e=new OUe({...IUe(this.config.iceServers),forceTurn:this.config.iceTransportPolicy==="relay",portRange:this.config.icePortRange,interfaceAddresses:this.config.iceInterfaceAddresses,additionalHostAddresses:this.config.iceAdditionalHostAddresses,filterStunResponse:this.config.iceFilterStunResponse,filterCandidatePair:this.config.iceFilterCandidatePair,localPasswordPrefix:this.config.icePasswordPrefix,useIpv4:this.config.iceUseIpv4,useIpv6:this.config.iceUseIpv6,turnTransport:this.config.forceTurnTCP===!0?"tcp":"udp",useLinkLocalAddress:this.config.iceUseLinkLocalAddress});t&&(e.connection.localUsername=t.connection.localUsername,e.connection.localPassword=t.connection.localPassword),e.onGatheringStateChange.subscribe(()=>{this.updateIceGatheringState()}),this.updateIceGatheringState();let r=new RUe(e);return r.onStateChange.subscribe(()=>{this.updateIceConnectionState()}),new qae(this.config,r,this.certificate,j8t)}handleNewIceCandidate({candidate:t,media:e,remoteIsBundled:r,transceiver:n,sctpTransport:i,bundlePolicy:s}){return s==="max-bundle"||r?(t.sdpMLineIndex=0,e&&(t.sdpMid=e.rtp.muxId)):(n&&(t.sdpMLineIndex=n.mLineIndex,t.sdpMid=n.mid),i&&(t.sdpMLineIndex=i.mLineIndex,t.sdpMid=i.mid)),t.foundation&&!t.foundation.startsWith("candidate:")&&(t.foundation="candidate:"+t.foundation),this.onIceCandidate.execute(t),t}async addIceCandidate(t,e){let r=Koe.fromJSON(e);if(!r)return;let n;typeof r.sdpMid=="number"&&(n=this.getTransportByMid(r.sdpMid)),!n&&typeof r.sdpMLineIndex=="number"&&(n=this.getTransportByMLineIndex(t,r.sdpMLineIndex)),n||(n=this.iceTransports[0]),n?await n.addRemoteCandidate(r):uD("iceTransport not found for candidate",r)}getTransportByMid(t){let e,r=this.transceiverManager.getTransceivers().find(n=>n.mid===t);return r?e=r.dtlsTransport.iceTransport:!e&&this.sctpManager.sctpTransport?.mid===t&&(e=this.sctpManager.sctpTransport.dtlsTransport.iceTransport),e}getTransportByMLineIndex(t,e){let r=t.media[e];return r?this.getTransportByMid(r.rtp.muxId):void 0}restartIce(){for(let t of this.iceTransports)t.restart()}setLocalRole({type:t,role:e}){for(let r of this.dtlsTransports){let n=r.iceTransport;t==="offer"?n.connection.iceControlling=!0:n.connection.iceControlling=!1,n.connection.remoteIsLite&&(n.connection.iceControlling=!0),t==="answer"&&e&&(r.role=e)}}updateIceGatheringState(){let t=this.iceTransports;function e(...n){return t.filter(i=>n.includes(i.gatheringState)).length===t.length}let r;t.length&&e("complete")?r="complete":!t.length||e("new","complete")?r="new":t.map(n=>n.gatheringState).includes("gathering")?r="gathering":r="new",this.iceGatheringState!==r&&(this.iceGatheringState=r,this.iceGatheringStateChange.execute(r))}updateIceConnectionState(){let t=this.iceTransports,e;function r(...i){return t.filter(s=>i.includes(s.state)).length===t.length}function n(...i){return t.some(s=>i.includes(s.state))}this.connectionState==="closed"?e="closed":n("failed")?e="failed":n("disconnected")?e="disconnected":r("new","closed")?e="new":n("new","checking")?e="checking":r("completed","closed")?e="completed":r("connected","completed","closed")?e="connected":e="new",this.iceConnectionState!==e&&(uD("iceConnectionStateChange",e),this.iceConnectionState=e,this.iceConnectionStateChange.execute(e))}async gatherCandidates(t){let e=this.iceTransports.find(r=>r.state==="connected"||r.state==="completed");t&&e?uD("skipping ICE gathering for bundled connection"):await Promise.allSettled(this.iceTransports.map(r=>r.gather())).catch(r=>{uD("gatherCandidates failed",r)})}setConnectionState(t){uD("connectionStateChange",t),this.connectionState=t,this.connectionStateChange.execute(t)}async getStats(){let t=[];for(let e of this.dtlsTransports){let r=await e.getStats();r&&t.push(...r)}return t}async ensureCerts(){this.certificate||(this.certificate=await qae.SetupCertificate());for(let t of this.dtlsTransports)t.localCertificate=this.certificate}async close(){this.setConnectionState("closed"),await Promise.allSettled([...this.dtlsTransports.map(t=>t.stop())]),this.iceGatheringStateChange.allUnsubscribe(),this.iceConnectionStateChange.allUnsubscribe(),this.onIceCandidate.allUnsubscribe(),this.connectionStateChange.allUnsubscribe()}},j8t=[vNe.SRTP_AEAD_AES_128_GCM,vNe.SRTP_AES128_CM_HMAC_SHA1_80],od=_n("werift:packages/webrtc/src/peerConnection.ts"),q8t=class extends Foe{cname=U8t().toString();config=pMe();signalingState="stable";negotiationneeded=!1;needRestart=!1;router=new fMe;sdpManager;transceiverManager;sctpManager;secureManager;isClosed=!1;shouldNegotiationneeded=!1;remoteBundleNegotiated=!1;iceGatheringStateChange=new yr;iceConnectionStateChange=new yr;signalingStateChange=new yr;connectionStateChange=new yr;onDataChannel=new yr;onRemoteTransceiverAdded=new yr;onTransceiverAdded=new yr;onIceCandidate=new yr;onNegotiationneeded=new yr;onTrack=new yr;ondatachannel;onicecandidate;onicecandidateerror;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;onconnectionstatechange;oniceconnectionstatechange;constructor(t={}){super(),this.setConfiguration(t),this.sdpManager=new hMe({cname:this.cname,bundlePolicy:this.config.bundlePolicy}),this.transceiverManager=new mMe(this.cname,this.config,this.router),this.transceiverManager.onTransceiverAdded.pipe(this.onTransceiverAdded),this.transceiverManager.onRemoteTransceiverAdded.pipe(this.onRemoteTransceiverAdded),this.transceiverManager.onTrack.subscribe(({track:e,stream:r,transceiver:n})=>{let i={track:e,streams:[r],transceiver:n,receiver:n.receiver};this.onTrack.execute(e),this.emit("track",i),this.ontrack&&this.ontrack(i)}),this.transceiverManager.onNegotiationNeeded.subscribe(()=>this.needNegotiation()),this.sctpManager=new L8t,this.sctpManager.onDataChannel.subscribe(e=>{this.onDataChannel.execute(e);let r={channel:e};this.ondatachannel?.(r),this.emit("datachannel",r)}),this.secureManager=new $8t({config:this.config,sctpManager:this.sctpManager,transceiverManager:this.transceiverManager}),this.secureManager.iceGatheringStateChange.pipe(this.iceGatheringStateChange),this.secureManager.iceConnectionStateChange.subscribe(e=>{e==="closed"&&this.close(),this.iceConnectionStateChange.execute(e)}),this.secureManager.connectionStateChange.subscribe(e=>{this.connectionStateChange.execute(e),this.onconnectionstatechange?.(),this.emit("connectionstatechange")}),this.secureManager.onIceCandidate.subscribe(e=>{let r=e?e.toJSON():void 0;this.onIceCandidate.execute(r),this.onicecandidate?.({candidate:r}),this.emit("icecandidate",{candidate:r})})}get connectionState(){return this.secureManager.connectionState}get iceConnectionState(){return this.secureManager.iceConnectionState}get iceGathererState(){return this.secureManager.iceGatheringState}get iceGatheringState(){return this.secureManager.iceGatheringState}get dtlsTransports(){return this.secureManager.dtlsTransports}get sctpTransport(){return this.sctpManager.sctpTransport}get sctpRemotePort(){return this.sctpManager.sctpRemotePort}get iceTransports(){return this.secureManager.iceTransports}get extIdUriMap(){return this.router.extIdUriMap}get iceGeneration(){return this.iceTransports[0].connection.generation}get localDescription(){return this.sdpManager.localDescription}get remoteDescription(){return this.sdpManager.remoteDescription}get remoteIsBundled(){return this.sdpManager.remoteIsBundled}get _localDescription(){return this.sdpManager._localDescription}get _remoteDescription(){return this.sdpManager._remoteDescription}getTransceivers(){return this.transceiverManager.getTransceivers()}getSenders(){return this.transceiverManager.getSenders()}getReceivers(){return this.transceiverManager.getReceivers()}setConfiguration(t){if(FUe(this.config,t),this.config.icePortRange){let[e,r]=this.config.icePortRange;if(e===r)throw new Error("should not be same value");if(e>=r)throw new Error("The min must be less than max")}if(!Number.isInteger(this.config.maxMessageSize)||this.config.maxMessageSize<0)throw new Error("maxMessageSize must be a non-negative integer");this.sctpManager?.sctpTransport&&(this.sctpManager.sctpTransport.maxMessageSize=this.config.maxMessageSize);for(let[e,r]of fNe([...this.config.codecs.audio||[],...this.config.codecs.video||[]]))if(r.payloadType==null)switch(r.payloadType=96+e,r.name.toLowerCase()){case"rtx":r.parameters=`apt=${r.payloadType-1}`;break;case"red":if(r.contentType==="audio"){let n=r.payloadType+1;r.parameters=`${n}/${n}`,r.payloadType=63}break}[...this.config.headerExtensions.audio||[],...this.config.headerExtensions.video||[]].forEach((e,r)=>{e.id=1+r})}getConfiguration(){return this.config}async createOffer({iceRestart:t}={}){(t||this.needRestart)&&(this.needRestart=!1,this.secureManager.restartIce()),await this.secureManager.ensureCerts();for(let r of this.transceiverManager.getTransceivers())r.codecs.length===0&&this.transceiverManager.assignTransceiverCodecs(r),r.headerExtensions.length===0&&(r.headerExtensions=this.config.headerExtensions[r.kind]??[]);return this.sdpManager.buildOfferSdp(this.transceiverManager.getTransceivers(),this.sctpTransport).toJSON()}createSctpTransport(){let t=this.sctpManager.createSctpTransport(this.config.maxMessageSize),e=this.findOrCreateTransport();return t.setDtlsTransport(e),t}createDataChannel(t,e={}){this.sctpTransport||(this.createSctpTransport(),this.needNegotiation());let r=this.sctpManager.createDataChannel(t,e);if(!r.sctp.dtlsTransport){let n=this.findOrCreateTransport();r.sctp.setDtlsTransport(n)}return r}removeTrack(t){if(this.isClosed)throw new Error("peer closed");this.transceiverManager.removeTrack(t),this.needNegotiation()}needNegotiation=async()=>{this.shouldNegotiationneeded=!0,!(this.negotiationneeded||this.signalingState!=="stable")&&(this.shouldNegotiationneeded=!1,setImmediate(()=>{this.negotiationneeded=!0,this.onNegotiationneeded.execute(),this.onnegotiationneeded&&this.onnegotiationneeded({})}))};findOrCreateTransport(){let t=this.dtlsTransports.find(i=>i.state!=="closed"),e=t?.iceTransport;if((this.sdpManager.bundlePolicy==="max-bundle"||this.sdpManager.bundlePolicy!=="disable"&&(this.remoteIsBundled||this.remoteBundleNegotiated))&&t)return t;let r=this.secureManager.createTransport();r.onRtp.subscribe(i=>{this.router.routeRtp(i)}),r.onRtcp.subscribe(i=>{this.router.routeRtcp(i)});let n=r.iceTransport;return n.onNegotiationNeeded.subscribe(()=>{this.needNegotiation()}),n.onIceCandidate.subscribe(i=>{if(!this.localDescription){od("localDescription not found when ice candidate was gathered");return}if(!i){this.sdpManager.setLocal(this._localDescription,this.transceiverManager.getTransceivers(),this.sctpTransport),this.onIceCandidate.execute(void 0),this.onicecandidate&&this.onicecandidate({candidate:void 0}),this.emit("icecandidate",{candidate:void 0});return}if(!this._localDescription){od("localDescription not found when ice candidate was gathered");return}this.secureManager.handleNewIceCandidate({candidate:i,bundlePolicy:this.sdpManager.bundlePolicy,remoteIsBundled:!!this.sdpManager.remoteIsBundled,media:this._localDescription.media[0],transceiver:this.transceiverManager.getTransceivers().find(s=>s?.dtlsTransport?.iceTransport.id===n.id),sctpTransport:this.sctpTransport?.dtlsTransport.iceTransport.id===n.id?this.sctpTransport:void 0})}),r}async setLocalDescription(t){t=t??(["stable","have-local-offer","have-remote-pranswer"].includes(this.signalingState)?await this.createOffer():await this.createAnswer());let r=this.sdpManager.parseSdp({sdp:t.sdp,isLocal:!0,signalingState:this.signalingState,type:t.type});r.type==="offer"?this.setSignalingState("have-local-offer"):r.type==="answer"&&this.setSignalingState("stable");for(let[i,s]of fNe(r.media)){let a=s.rtp.muxId;if(this.sdpManager.registerMid(a),["audio","video"].includes(s.kind)){let c=this.transceiverManager.getTransceiverByMLineIndex(i);c&&(c.mid=a)}s.kind==="application"&&this.sctpTransport&&(this.sctpTransport.mid=a)}let n=r.media.find(i=>i.dtlsParams)?.dtlsParams?.role;if(this.secureManager.setLocalRole({type:r.type,role:n}),["answer","pranswer"].includes(r.type))for(let i of this.transceiverManager.getTransceivers()){let s=Woe(i.direction,i.offerDirection);i.setCurrentDirection(s)}return this.sdpManager.setLocal(r,this.transceiverManager.getTransceivers(),this.sctpTransport),await this.gatherCandidates().catch(i=>{od("gatherCandidates failed",i)}),r.type==="answer"&&this.connect().catch(i=>{od("connect failed",i),this.secureManager.setConnectionState("failed")}),this.sdpManager.setLocal(r,this.transceiverManager.getTransceivers(),this.sctpTransport),this.shouldNegotiationneeded&&this.needNegotiation(),r}async gatherCandidates(){await this.secureManager.gatherCandidates(!!this.sdpManager.remoteIsBundled)}async addIceCandidate(t){let e=this.sdpManager.buildOfferSdp(this.transceiverManager.getTransceivers(),this.sctpTransport);await this.secureManager.addIceCandidate(e,t)}async connect(){od("start connect"),(await Promise.allSettled(this.dtlsTransports.map(async e=>{let{iceTransport:r}=e;if(r.state==="connected")return;let n=()=>e.state==="connected";n()||(this.secureManager.setConnectionState("connecting"),await r.start().catch(i=>{throw od("iceTransport.start failed",i),i}),!n()&&(await e.start().catch(i=>{throw od("dtlsTransport.start failed",i),i}),this.sctpTransport&&this.sctpTransport.dtlsTransport.id===e.id&&await this.sctpManager.connectSctp()))}))).find(e=>e.status==="rejected")?this.secureManager.setConnectionState("failed"):this.secureManager.setConnectionState("connected")}restartIce(){this.needRestart=!0,this.needNegotiation()}async setRemoteDescription(t){t instanceof TD&&(t=t.toSdp());let e=this.sdpManager.setRemoteDescription(t,this.signalingState);e.group.some(a=>a.semantic==="BUNDLE"&&a.items.length>0)&&(this.remoteBundleNegotiated=!0);let r,n=(a,c)=>a.kind===c.kind&&[void 0,c.rtp.muxId].includes(a.mid),i=e.media.map((a,c)=>{let d;if(["audio","video"].includes(a.kind)){let p=this.transceiverManager.getTransceivers().find(x=>n(x,a));if(!p)p=this.addTransceiver(a.kind,{direction:"recvonly"}),p.mid=a.rtp.muxId,this.onRemoteTransceiverAdded.execute(p);else if(p.direction==="inactive"&&p.stopping){p.stopped=!0,t.type==="answer"&&p.setCurrentDirection("inactive");return}this.sdpManager.remoteIsBundled&&(r?p.setDtlsTransport(r):r=p.dtlsTransport),d=p.dtlsTransport,this.transceiverManager.setRemoteRTP(p,a,e.type,c)}else if(a.kind==="application"){let p=this.sctpTransport;p||(p=this.createSctpTransport(),p.mid=a.rtp.muxId),this.sdpManager.remoteIsBundled&&(r?p.setDtlsTransport(r):r=p.dtlsTransport),d=p.dtlsTransport,this.sctpManager.setRemoteSCTP(a,c)}else throw new Error("invalid media kind");let h=d.iceTransport;if(a.iceParams){let p=!!this.sdpManager.inactiveRemoteMedia;h.setRemoteParams(a.iceParams,p),a.iceParams?.iceLite&&(h.connection.iceControlling=!0)}return a.dtlsParams&&d.setRemoteParams(a.dtlsParams),a.iceCandidates.forEach(h.addRemoteCandidate),a.iceCandidatesComplete&&h.addRemoteCandidate(void 0),e.type==="answer"&&a.dtlsParams?.role&&(d.role=a.dtlsParams.role==="client"?"server":"client"),h});i=i.filter(a=>!!a);let s=this.transceiverManager.getTransceivers().filter(a=>e.media.find(c=>n(a,c))==null);if(t.type==="answer")for(let a of s)a.stop(),a.stopped=!0;e.type==="offer"?this.setSignalingState("have-remote-offer"):e.type==="answer"&&this.setSignalingState("stable"),e.type==="answer"&&(od("caller start connect"),this.connect().catch(a=>{od("connect failed",a),this.secureManager.setConnectionState("failed")})),this.negotiationneeded=!1,this.shouldNegotiationneeded&&this.needNegotiation()}addTransceiver(t,e={}){let r=this.findOrCreateTransport(),n=this.transceiverManager.addTransceiver(t,r,e);return this.secureManager.updateIceConnectionState(),this.needNegotiation(),n}addTrack(t,e){if(this.isClosed)throw new Error("is closed");let r=this.transceiverManager.addTrack(t,e);if(!r.dtlsTransport){let n=this.findOrCreateTransport();r.setDtlsTransport(n)}return this.needNegotiation(),r.sender}async createAnswer(){return this.assertNotClosed(),await this.secureManager.ensureCerts(),this.sdpManager.buildAnswerSdp({transceivers:this.transceiverManager.getTransceivers(),sctpTransport:this.sctpTransport,signalingState:this.signalingState}).toJSON()}assertNotClosed(){if(this.isClosed)throw new Error("RTCPeerConnection is closed")}setSignalingState(t){od("signalingStateChange",t),this.signalingState=t,this.signalingStateChange.execute(t),this.onsignalingstatechange&&this.onsignalingstatechange({})}createPeerConnectionStats(){let t=qg();return{type:"peer-connection",id:rs("peer-connection"),timestamp:t,dataChannelsOpened:this.sctpManager.dataChannelsOpened,dataChannelsClosed:this.sctpManager.dataChannelsClosed}}async getStats(t){let e=[];e.push(this.createPeerConnectionStats());let r=await this.transceiverManager.getStats(t);e.push(...r);let n=await this.secureManager.getStats();if(e.push(...n),this.sctpTransport){let i=await this.sctpManager.getStats();i&&e.push(...i)}return new _Ue(e)}async close(){this.isClosed||(this.isClosed=!0,this.setSignalingState("closed"),this.transceiverManager.close(),await this.secureManager.close(),await this.sctpManager.close(),this.onDataChannel.allUnsubscribe(),this.iceGatheringStateChange.allUnsubscribe(),this.iceConnectionStateChange.allUnsubscribe(),this.signalingStateChange.allUnsubscribe(),this.onTransceiverAdded.allUnsubscribe(),this.onRemoteTransceiverAdded.allUnsubscribe(),this.onIceCandidate.allUnsubscribe(),od("peerConnection closed"))}},aoe=(t,e)=>t.find(r=>r.mimeType.toLowerCase()===e.mimeType.toLowerCase())?e:void 0;z8t=pMe(),W8t=_n("werift:packages/webrtc/src/media/rtpTransceiverManager.ts"),mMe=class{constructor(t,e,r){this.cname=t,this.config=e,this.router=r}transceivers=[];onTransceiverAdded=new yr;onRemoteTransceiverAdded=new yr;onTrack=new yr;onNegotiationNeeded=new yr;getTransceivers(){return this.transceivers}getSenders(){return this.getTransceivers().map(t=>t.sender)}getReceivers(){return this.getTransceivers().map(t=>t.receiver)}getTransceiverByMLineIndex(t){return this.transceivers.find(e=>e.mLineIndex===t)}pushTransceiver(t){this.transceivers.push(t)}replaceTransceiver(t,e){this.transceivers[e]=t}addTransceiver(t,e,r={}){let n=typeof t=="string"?t:t.kind,i=r.direction||"sendrecv",s=new dMe(t),a=new ece(this.config,n,s.ssrc),c=new wUe(n,e,a,s,i);c.options=r,this.router.registerRtpSender(c.sender);let d=this.transceivers.findIndex(p=>p.currentDirection==="inactive"&&!p.usedForSender),h=this.transceivers.find(p=>p.currentDirection==="inactive"&&!p.usedForSender);return d>-1&&h?(this.replaceTransceiver(c,d),c.mLineIndex=h.mLineIndex,c.mid=h.mid,h.setCurrentDirection(void 0)):this.pushTransceiver(c),this.onTransceiverAdded.execute(c),c}addTrack(t,e){if(this.getSenders().find(i=>i.track?.uuid===t.uuid))throw new Error("Track already added");let r=this.transceivers.find(i=>i.sender.track==null&&i.kind===t.kind&&ZU.includes(i.direction)===!0);if(r)return r.sender.registerTrack(t),r;let n=this.transceivers.find(i=>i.sender.track==null&&i.kind===t.kind&&ZU.includes(i.direction)===!1&&!i.usedForSender);if(n){switch(n.sender.registerTrack(t),n.direction){case"recvonly":n.setDirection("sendrecv");break;case"inactive":n.setDirection("sendonly");break}return n}else return this.addTransceiver(t,void 0,{direction:"sendrecv"})}removeTrack(t){if(!this.getSenders().find(({ssrc:r})=>t.ssrc===r))throw new Error("Sender does not exist");let e=this.transceivers.find(({sender:{ssrc:r}})=>t.ssrc===r);if(!e)throw new Error("No matching transceiver found");if(t.stop(),e.currentDirection==="recvonly"){this.onNegotiationNeeded.execute();return}e.stopping||e.stopped?e.setDirection("inactive"):e.direction==="sendrecv"?e.setDirection("recvonly"):(e.direction==="sendonly"||e.direction==="recvonly")&&e.setDirection("inactive")}assignTransceiverCodecs(t){let e=this.config.codecs[t.kind].filter(r=>{switch(r.direction){case"recvonly":return!!$Dt.includes(t.direction);case"sendonly":return!!ZU.includes(t.direction);case"sendrecv":return!![joe,$oe,Loe].includes(t.direction);case"all":return!0;default:return!1}});t.codecs=e}getLocalRtpParams(t){if(t.mid==null)throw new Error("mid not assigned");return{codecs:t.codecs,muxId:t.mid,headerExtensions:t.headerExtensions,rtcp:{cname:this.cname,ssrc:t.sender.ssrc,mux:!0}}}getRemoteRtpParams(t,e){return{muxId:t.rtp.muxId,rtcp:t.rtp.rtcp,codecs:e.codecs,headerExtensions:e.headerExtensions,encodings:Object.values(e.codecs.reduce((n,i)=>{if(i.name.toLowerCase()==="rtx"){let s=HD(i.parameters??""),a=n[s.apt];return a&&t.ssrc.length===2&&(a.rtx=new mUe({ssrc:t.ssrc[1].ssrc})),n}return n[i.payloadType]=new gUe({ssrc:t.ssrc[0]?.ssrc,payloadType:i.payloadType}),n},{}))}}setRemoteRTP(t,e,r,n){if(t.mid||(t.mid=e.rtp.muxId),t.mLineIndex=n,t.codecs=e.rtp.codecs.filter(c=>{let d=this.config.codecs[e.kind]||[],h=aoe(d,c);if(!h)return!1;if(h?.name.toLowerCase()==="rtx"){let x=HD(h.parameters??"").apt,y=e.rtp.codecs.find(v=>v.payloadType===x);return y?!!aoe(d,y):!1}return!0}),W8t("negotiated codecs",t.codecs),t.codecs.length===0)throw new Error("negotiate codecs failed.");t.headerExtensions=e.rtp.headerExtensions.filter(c=>(this.config.headerExtensions[e.kind]||[]).find(d=>d.uri===c.uri));let i=e.direction??"inactive",s=CUe(i);["answer","pranswer"].includes(r)?t.setCurrentDirection(s):t.offerDirection=s;let a=this.getLocalRtpParams(t);if(t.sender.prepareSend(a),["recvonly","sendrecv"].includes(t.direction)){let c=this.getRemoteRtpParams(e,t);for(let d of e.simulcastParameters)this.router.registerRtpReceiverByRid(t,d,c);t.receiver.prepareReceive(c),this.router.registerRtpReceiverBySsrc(t,c)}if(["sendonly","sendrecv"].includes(i)){if(e.msid){let[c,d]=e.msid.split(" ");t.receiver.remoteStreamId=c,t.receiver.remoteTrackId=d}this.onTrack.execute({track:t.receiver.track,transceiver:t,stream:new EUe({id:t.receiver.remoteStreamId,tracks:[t.receiver.track]})})}e.ssrc[0]?.ssrc&&t.receiver.setupTWCC(e.ssrc[0].ssrc)}async getStats(t){let e=[];for(let r of this.transceivers){let n=!t||r.sender.track===t||r.receiver.track===t;if(r.sender){let i=await r.sender.getStats();if(i)for(let s of i)s.type==="outbound-rtp"||s.type==="media-source"?n&&e.push(s):e.push(s)}if(r.receiver){let i=await r.receiver.getStats();if(i)for(let s of i)s.type==="inbound-rtp"||s.type==="remote-outbound-rtp"?n&&e.push(s):e.push(s)}if(n){let i=r.getCodecStats();i&&e.push(...i)}}return e}close(){for(let t of this.transceivers)t.receiver.stop(),t.sender.stop();this.onTransceiverAdded.allUnsubscribe(),this.onRemoteTransceiverAdded.allUnsubscribe(),this.onTrack.allUnsubscribe(),this.onNegotiationNeeded.allUnsubscribe()}},H8t=["stable","have-local-offer","have-remote-offer","have-local-pranswer","have-remote-pranswer","closed"],V8t=["closed","failed","disconnected","new","connecting","connected"]});var IMe={};yi(IMe,{SERVICE_TYPE:()=>nce,accountFingerprint:()=>ice,advertise:()=>r5t,browse:()=>DMe,osTag:()=>TMe,scan:()=>n5t});function TMe(){let t=process.platform;return t==="darwin"?"mac":t==="win32"?"win":t==="linux"?"linux":"other"}function CMe(t){return JSON.stringify(["oioxo-advert",t.v,t.acct,t.dev,t.os,t.name,t.nonce])}async function ice(t){let e=new TextEncoder().encode("oioxo-acct:"+t),r=await crypto.subtle.digest("SHA-256",e);return Buffer.from(new Uint8Array(r)).toString("base64url").slice(0,22)}async function kMe(){try{let e=await import("bonjour-service");return e.Bonjour??e.default??null}catch{return null}}async function r5t(t){let e=await kMe();if(!e)return{stop:()=>{}};let r=await ice(t.accountKey),n=Buffer.from(crypto.getRandomValues(new Uint8Array(8))).toString("base64url"),i={v:2,acct:r,dev:t.identity.deviceId,os:TMe(),name:t.label,nonce:n},s=await t.identity.sign(CMe(i)),a=new e,c=a.publish({name:"OIOXO "+t.identity.deviceId.slice(0,6),type:nce,protocol:"tcp",port:t.port,txt:{v:String(2),acct:r,dev:i.dev,os:i.os,name:t.label,nonce:n,sig:s}});return{stop:()=>{try{c.stop(()=>a.destroy())}catch{}}}}async function DMe(t){let e=await kMe();if(!e)return{stop:()=>{}};let r=await ice(t.accountKey),n=new e,i=new Set,s=n.find({type:nce,protocol:"tcp"},a=>{(async()=>{let c=a.txt;if(!c||c.acct!==r)return;let d=c.dev;if(!d||i.has(d)||!c.sig||!c.name||!c.nonce)return;let h=CMe({v:Number(c.v)||2,acct:c.acct,dev:d,os:c.os||"other",name:c.name,nonce:c.nonce}),p=await t.verify(d,c.sig,h).catch(()=>!1);i.add(d);let x=a.referer?.address||a.addresses&&a.addresses[0]||"",y=["mac","win","linux"].includes(c.os)?c.os:"other";t.onDevice({deviceId:d,label:c.name,os:y,host:x,port:a.port,trusted:p})})()});return{stop:()=>{try{s.stop(),n.destroy()}catch{}}}}async function n5t(t){let e=[],{stop:r}=await DMe({accountKey:t.accountKey,verify:t.verify,onDevice:n=>e.push(n)});return await new Promise(n=>setTimeout(n,t.ms??2500)),r(),e}var nce,FMe=ce(()=>{"use strict";nce="oioxo"});var iLe={};yi(iLe,{BROWSER_VERBS_DOC:()=>vce,BrowserController:()=>u8,isBlockedHost:()=>nLe,isLocalUrl:()=>LM,originOf:()=>gce,parseBrowserVerb:()=>yce,renderSnapshot:()=>xce});function w5t(t){let e=t.trim();if(/^(0x[0-9a-f]+|0[0-7]*|[1-9][0-9]*)$/i.test(e)){let n;if(/^0x/i.test(e)?n=parseInt(e,16):/^0[0-7]+$/.test(e)?n=parseInt(e,8):n=parseInt(e,10),Number.isFinite(n)&&n>=0&&n<=4294967295)return[n>>>24&255,n>>>16&255,n>>>8&255,n&255].join(".")}let r=e.split(".");if(r.length===4&&r.every(n=>/^(0x[0-9a-f]+|0[0-7]*|[0-9]+)$/i.test(n))){let n=r.map(i=>/^0x/i.test(i)?parseInt(i,16):/^0[0-7]+$/.test(i)?parseInt(i,8):parseInt(i,10));if(n.every(i=>Number.isFinite(i)&&i>=0&&i<=255))return n.join(".")}return t}function nLe(t){try{let e=new URL(t).hostname,r=w5t((e.startsWith("["),e));return rLe.test(e)||rLe.test(r)}catch{return!1}}function LM(t){try{let e=new URL(t);return e.protocol==="data:"||e.protocol==="about:"?!0:_5t.test(e.hostname)}catch{return!1}}function gce(t){try{return new URL(t).origin}catch{return""}}function xce(t,e){let r=e?`# ${e.title??""}
1122
+ `}},US=class{constructor(t,e){this.semantic=t,this.items=e}get str(){return`${this.semantic} ${this.items.join(" ")}`}};lMe=class{constructor(t,e){this.sdp=t,this.type=e}static isThis(t){if(typeof t?.sdp=="string")return!0}toSdp(){return{sdp:this.sdp,type:this.type}}};vM=class{ssrc;cname;msid;msLabel;label;constructor(t){Object.assign(this,t)}},jU=_n("werift:packages/webrtc/src/media/rtpReceiver.ts"),ece=class{constructor(t,e,r){this.config=t,this.kind=e,this.rtcpSsrc=r}codecs={};get codecArray(){return Object.values(this.codecs).sort((t,e)=>t.payloadType-e.payloadType)}ssrcByRtx={};nack=new K6t(this);audioRedHandler=new bBe;type="receiver";uuid=F6t().toString();tracks=[];trackBySSRC={};trackByRID={};lastSRtimestamp={};receiveLastSRTimestamp={};onPacketLost=this.nack.onPacketLost;onRtcp=new yr;dtlsTransport;sdesMid;latestRid;latestRepairedRid;receiverTWCC;stopped=!1;remoteStreamId;remoteTrackId;rtcpRunning=!1;rtcpCancel=new AbortController;remoteStreams={};setDtlsTransport(t){this.dtlsTransport=t}get track(){return this.tracks[0]??new q6({kind:this.kind})}get nackEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type==="nack")}get twccEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type===hUe().type)}get pliEnabled(){return this.codecArray[0]?.rtcpFeedback.find(t=>t.type===GS().type)}prepareReceive(t){t.codecs.forEach(e=>{this.codecs[e.payloadType]=e}),t.encodings.forEach(e=>{e.rtx&&(this.ssrcByRtx[e.rtx.ssrc]=e.ssrc)})}setupTWCC(t){this.twccEnabled&&!this.receiverTWCC&&(this.receiverTWCC=new Y6t(this.dtlsTransport,this.rtcpSsrc,t))}addTrack(t){return this.tracks.find(r=>{if(r.rid)return r.rid===t.rid;if(r.ssrc)return r.ssrc===t.ssrc})?!1:(this.tracks.push(t),t.ssrc&&(this.trackBySSRC[t.ssrc]=t),t.rid&&(this.trackByRID[t.rid]=t),!0)}stop(){this.stopped=!0,this.rtcpRunning=!1,this.rtcpCancel.abort(),this.receiverTWCC&&(this.receiverTWCC.twccRunning=!1),this.nack.close()}async runRtcp(){if(!(this.rtcpRunning||this.stopped)){this.rtcpRunning=!0;try{for(;this.rtcpRunning;){await Qse(500+Math.random()*1e3,void 0,{signal:this.rtcpCancel.signal});let t=Object.entries(this.remoteStreams).map(([r,n])=>{let i=0,s=0;if(this.lastSRtimestamp[r]){i=this.lastSRtimestamp[r];let a=z6()-this.receiveLastSRTimestamp[r];a>0&&a<65536&&(s=OS(a*65536))}return new kM({ssrc:Number(r),fractionLost:n.fraction_lost,packetsLost:n.packets_lost,highestSequence:n.max_seq,jitter:n.jitter,lsr:i,dlsr:s})}),e=new $S({ssrc:this.rtcpSsrc,reports:t});try{this.config.debug.receiverReportDelay&&await Qse(this.config.debug.receiverReportDelay),await this.dtlsTransport.sendRtcp([e])}catch(r){jU("sendRtcp failed",r),await Qse(500+Math.random()*1e3)}}}catch{}}}async getStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id);for(let n of this.tracks){if(!n.ssrc)continue;let i=this.remoteStreams[n.ssrc];if(!i)continue;let s={type:"inbound-rtp",id:rs("inbound-rtp",n.ssrc),timestamp:t,ssrc:n.ssrc,kind:this.kind,transportId:r,codecId:this.codecs[0]?rs("codec",this.codecs[0].payloadType,r):void 0,mid:this.sdesMid,trackIdentifier:n.id,packetsReceived:i.packets_received,packetsLost:i.packets_lost,jitter:i.jitter};if(e.push(s),this.lastSRtimestamp[n.ssrc]){let a={type:"remote-outbound-rtp",id:rs("remote-outbound-rtp",n.ssrc),timestamp:t,ssrc:n.ssrc,kind:this.kind,transportId:r,codecId:s.codecId,localId:s.id,remoteTimestamp:this.receiveLastSRTimestamp[n.ssrc]*1e3};e.push(a)}}return e}async sendRtcpPLI(t){if(!this.pliEnabled){jU("pli not supported",{mediaSsrc:t});return}if(this.stopped)return;jU("sendRtcpPLI",{mediaSsrc:t});let e=new LS({feedback:new N6({senderSsrc:this.rtcpSsrc,mediaSsrc:t})});try{await this.dtlsTransport.sendRtcp([e])}catch(r){jU(r)}}handleRtcpPacket(t){switch(t.type){case Cv.type:{let e=t;this.lastSRtimestamp[e.ssrc]=Voe(e.senderInfo.ntpTimestamp),this.receiveLastSRTimestamp[e.ssrc]=z6();let r=this.trackBySSRC[t.ssrc];r&&r.onReceiveRtcp.execute(t)}break}this.onRtcp.execute(t)}handleRtpBySsrc=(t,e)=>{let r=this.trackBySSRC[t.header.ssrc];this.handleRTP(t,e,r)};handleRtpByRid=(t,e,r)=>{let n=this.trackByRID[e];this.trackBySSRC[t.header.ssrc]||(this.trackBySSRC[t.header.ssrc]=n),this.handleRTP(t,r,n)};handleRTP(t,e,r){if(this.stopped)return;let n=this.codecs[t.header.payloadType];if(!n)return;if(this.remoteStreams[t.header.ssrc]=this.remoteStreams[t.header.ssrc]??new J6t(n.clockRate),this.remoteStreams[t.header.ssrc].add(t),this.receiverTWCC){let s=e[Os.transportWideCC];if(!s==null)throw new Error("undefined");this.receiverTWCC.handleTWCC(s)}else this.twccEnabled&&this.setupTWCC(t.header.ssrc);if(n.name.toLowerCase()==="rtx"){let s=this.ssrcByRtx[t.header.ssrc],a=H6(n.parameters??""),c=this.codecs[a.apt];if(t.payload.length<2)return;t=wBe(t,c.payloadType,s),r=this.trackBySSRC[s]}let i;if(!(n.name.toLowerCase()==="red"&&(i=voe.deSerialize(t.payload),!Object.keys(this.codecs).includes(i.header.fields[0].blockPT.toString())))){if(r?.kind==="video"&&this.nackEnabled&&this.nack.addPacket(t),r)if(i){if(r.kind==="audio"){let s=this.audioRedHandler.push(i,t);for(let a of s)r.onReceiveRtp.execute(a.clone(),e)}}else r.onReceiveRtp.execute(t.clone(),e);this.runRtcp()}}},c6=_n("werift:packages/webrtc/src/media/router.ts"),fMe=class{ssrcTable={};ridTable={};extIdUriMap={};constructor(){}registerRtpSender(t){this.ssrcTable[t.ssrc]=t}registerRtpReceiver(t,e){c6("registerRtpReceiver",e),this.ssrcTable[e]=t}registerRtpReceiverBySsrc(t,e){c6("registerRtpReceiverBySsrc",e),e.encodings.filter(r=>r.ssrc!=null).forEach((r,n)=>{this.registerRtpReceiver(t.receiver,r.ssrc),t.addTrack(new q6({ssrc:r.ssrc,kind:t.kind,id:t.sender.trackId,remote:!0,codec:e.codecs[n]})),r.rtx&&this.registerRtpReceiver(t.receiver,r.rtx.ssrc)}),e.headerExtensions.forEach(r=>{this.extIdUriMap[r.id]=r.uri})}registerRtpReceiverByRid(t,e,r){let[n]=r.codecs;c6("registerRtpReceiverByRid",e),t.addTrack(new q6({rid:e.rid,kind:t.kind,id:t.sender.trackId,remote:!0,codec:n})),this.ridTable[e.rid]=t.receiver}routeRtp=t=>{let e=aBe(t.header.extensions,this.extIdUriMap),r=this.ssrcTable[t.header.ssrc],n=e[Os.sdesRTPStreamID];if(typeof n=="string"?(r=this.ridTable[n],r.latestRid=n,r.handleRtpByRid(t,n,e)):r?r.handleRtpBySsrc(t,e):(r=Object.values(this.ridTable).filter(a=>a instanceof ece).find(a=>a.trackBySSRC[t.header.ssrc]),r&&(c6("simulcast register receiver by ssrc",t.header.ssrc),this.registerRtpReceiver(r,t.header.ssrc),r.handleRtpBySsrc(t,e))),!r){c6("ssrcReceiver not found");return}let i=e[Os.sdesMid];typeof i=="string"&&(r.sdesMid=i);let s=e[Os.repairedRtpStreamId];typeof s=="string"&&(r.latestRepairedRid=s)};routeRtcp=t=>{let e=[];switch(t.type){case Cv.type:t=t,e.push(this.ssrcTable[t.ssrc]);break;case $S.type:t=t,t.reports.forEach(r=>{e.push(this.ssrcTable[r.ssrc])});break;case L6.type:{let r=t}break;case Tv.type:{let r=t;r.feedback&&e.push(this.ssrcTable[r.feedback.mediaSourceSsrc])}break;case LS.type:{let r=t;switch(r.feedback.count){case B6.count:{let n=r.feedback;e.push(this.ssrcTable[n.ssrcFeedbacks[0]])}break;default:e.push(this.ssrcTable[r.feedback.senderSsrc]||this.ssrcTable[r.feedback.mediaSsrc])}}break}e.filter(r=>r).forEach(r=>r.handleRtcpPacket(t))}},O8t=class{numPackets=0;totalSize=0;firstPacketSentAtMs=0;lastPacketSentAtMs=0;firstPacketReceivedAtMs=0;lastPacketReceivedAtMs=0;addPacket(t,e,r){this.numPackets===0?(this.firstPacketSentAtMs=e,this.firstPacketReceivedAtMs=r,this.lastPacketSentAtMs=e,this.lastPacketReceivedAtMs=r):(e<this.firstPacketSentAtMs&&(this.firstPacketSentAtMs=e),r<this.firstPacketReceivedAtMs&&(this.firstPacketReceivedAtMs=r),e>this.lastPacketSentAtMs&&(this.lastPacketSentAtMs=e),r>this.lastPacketReceivedAtMs&&(this.lastPacketReceivedAtMs=r)),this.numPackets++,this.totalSize+=t}reset(){this.numPackets=0,this.totalSize=0,this.firstPacketSentAtMs=0,this.lastPacketSentAtMs=0,this.firstPacketReceivedAtMs=0,this.lastPacketReceivedAtMs=0}get receiveBitrate(){let t=this.lastPacketReceivedAtMs-this.firstPacketReceivedAtMs,e=this.totalSize/t*8*1e3;return O6(e)}get sendBitrate(){let t=this.lastPacketSentAtMs-this.firstPacketSentAtMs,e=this.totalSize/t*8*1e3;return O6(e)}},CS=20,N8t=10,B8t=class{congestion=!1;onAvailableBitrate=new yr;onCongestion=new yr;onCongestionScore=new yr;congestionCounter=0;cumulativeResult=new O8t;sentInfos={};_congestionScore=1;get congestionScore(){return this._congestionScore}set congestionScore(t){this._congestionScore=t,this.onCongestionScore.execute(t)}_availableBitrate=0;get availableBitrate(){return this._availableBitrate}set availableBitrate(t){this._availableBitrate=t,this.onAvailableBitrate.execute(t)}constructor(){}receiveTWCC(t){let r=Hoe()-this.cumulativeResult.firstPacketSentAtMs;r>1e3&&(this.cumulativeResult.reset(),this.congestionCounter<CS?this.congestionCounter++:this.congestionScore<N8t&&this.congestionScore++,this.congestionCounter>=CS&&!this.congestion&&(this.congestion=!0,this.onCongestion.execute(this.congestion)));for(let n of t.packetResults){if(!n.received)continue;let i=n.sequenceNumber,s=this.sentInfos[i];s&&n.receivedAtMs&&this.cumulativeResult.addPacket(s.size,s.sendingAtMs,n.receivedAtMs)}if(r>=100&&this.cumulativeResult.numPackets>=20){if(this.availableBitrate=Math.min(this.cumulativeResult.sendBitrate,this.cumulativeResult.receiveBitrate),this.cumulativeResult.reset(),this.congestionCounter>-CS){let n=O6(CS/2)+1,i=O6(CS/4)+1,s=n-(n-i)/10*this.congestionScore;this.congestionCounter=this.congestionCounter-s}this.congestionCounter<=-CS&&(this.congestionScore>1&&(this.congestionScore--,this.onCongestion.execute(!1)),this.congestionCounter=0),this.congestionCounter<=0&&this.congestion&&(this.congestion=!1,this.onCongestion.execute(this.congestion))}}rtpPacketSent(t){Object.keys(t).map(e=>Number(e)).sort().filter(e=>e<t.wideSeq).forEach(e=>{delete this.sentInfos[e]}),this.sentInfos[t.wideSeq]=t}},rae=_n("werift:packages/webrtc/src/media/rtpSender.ts"),UNe=128,MNe=.85,dMe=class{constructor(t){this.trackOrKind=t,this.kind=typeof this.trackOrKind=="string"?this.trackOrKind:this.trackOrKind.kind,typeof t!="string"&&(t.streamId&&(this.streamId=t.streamId),this.registerTrack(t))}type="sender";kind;ssrc=soe.jspack.Unpack("!L",ONe(4))[0];rtxSsrc=soe.jspack.Unpack("!L",ONe(4))[0];streamId=NNe().toString();trackId=NNe().toString();onReady=new yr;onRtcp=new yr;onPictureLossIndication=new yr;onGenericNack=new yr;senderBWE=new B8t;cname;mid;rtpStreamId;repairedRtpStreamId;rtxPayloadType;rtxSequenceNumber=coe();redRedundantPayloadType;_redDistance=2;redEncoder=new vBe(this._redDistance);headerExtensions=[];disposeTrack;lastSRtimestamp;lastSentSRTimestamp;ntpTimestamp=0n;rtpTimestamp=0;octetCount=0;packetCount=0;rtt;receiverEstimatedMaxBitrate=0n;sequenceNumber;timestamp;timestampOffset=0;seqOffset=0;rtpCache=[];codec;dtlsTransport;dtlsDisposer=[];track;stopped=!1;rtcpRunning=!1;rtcpCancel=new AbortController;setDtlsTransport(t){this.dtlsTransport&&this.dtlsDisposer.forEach(e=>e()),this.dtlsTransport=t,this.dtlsDisposer=[this.dtlsTransport.onStateChange.subscribe(e=>{e==="connected"&&this.onReady.execute()}).unSubscribe]}get redDistance(){return this._redDistance}set redDistance(t){this._redDistance=t,this.redEncoder.distance=t}prepareSend(t){this.cname=t.rtcp?.cname,this.mid=t.muxId,this.headerExtensions=t.headerExtensions,this.rtpStreamId=t.rtpStreamId,this.repairedRtpStreamId=t.repairedRtpStreamId,this.codec=t.codecs[0],this.track&&(this.track.codec=this.codec),t.codecs.forEach(e=>{let r=H6(e.parameters??"");e.name.toLowerCase()==="rtx"&&r.apt===this.codec?.payloadType&&(this.rtxPayloadType=e.payloadType),e.name.toLowerCase()==="red"&&(this.redRedundantPayloadType=Number((e.parameters??"").split("/")[0]))})}registerTrack(t){if(t.stopped)throw new Error("track is ended");this.disposeTrack&&this.disposeTrack(),t.id=this.trackId;let{unSubscribe:e}=t.onReceiveRtp.subscribe(async r=>{await this.sendRtp(r)});this.track=t,this.disposeTrack=e,this.codec&&(t.codec=this.codec),t.onSourceChanged.subscribe(r=>{this.replaceRTP(r)})}async replaceTrack(t){if(t!==null){if(t.stopped)throw new Error("track is ended");if(this.sequenceNumber!=null){let e=t.header||(await t.onReceiveRtp.asPromise())[0].header;this.replaceRTP(e)}this.registerTrack(t),rae("replaceTrack","ssrc",t.ssrc,"rid",t.rid)}}stop(){this.stopped=!0,this.rtcpRunning=!1,this.rtcpCancel.abort(),this.disposeTrack&&this.disposeTrack(),this.track=void 0}async runRtcp(){if(!(this.rtcpRunning||this.stopped)){this.rtcpRunning=!0;try{for(;this.rtcpRunning;){await BNe(500+Math.random()*1e3,void 0,{signal:this.rtcpCancel.signal});let t=[new Cv({ssrc:this.ssrc,senderInfo:new yoe({ntpTimestamp:this.ntpTimestamp,rtpTimestamp:this.rtpTimestamp,packetCount:this.packetCount,octetCount:this.octetCount})})];this.lastSRtimestamp=Voe(this.ntpTimestamp),this.lastSentSRTimestamp=z6(),this.cname&&t.push(new L6({chunks:[new goe({source:this.ssrc,items:[new xoe({type:1,text:this.cname})]})]}));try{await this.dtlsTransport.sendRtcp(t)}catch(e){rae("sendRtcp failed",e),await BNe(500+Math.random()*1e3)}}}catch{}}}replaceRTP({sequenceNumber:t,timestamp:e},r=!1){this.sequenceNumber!=null&&(this.seqOffset=jo(this.sequenceNumber,-t),r&&(this.seqOffset=jo(this.seqOffset,2))),this.timestamp!=null&&(this.timestampOffset=bv(this.timestamp,-e),r&&(this.timestampOffset=jo(this.timestampOffset,1))),this.rtpCache=[],rae("replaceRTP",this.sequenceNumber,t,this.seqOffset)}async sendRtp(t){if(this.dtlsTransport.state!=="connected"||!this.codec)return;t=Buffer.isBuffer(t)?Cp.deSerialize(t):t;let{header:e,payload:r}=t;e.ssrc=this.ssrc,e.payloadType=this.codec.payloadType,e.timestamp=bv(e.timestamp,this.timestampOffset),e.sequenceNumber=jo(e.sequenceNumber,this.seqOffset),this.timestamp=e.timestamp,this.sequenceNumber=e.sequenceNumber;let n=DUe(),i=[...e.extensions];e.extensions=this.headerExtensions.map(h=>{let p=(()=>{switch(h.uri){case Os.sdesMid:return this.mid?oBe(this.mid):void 0;case Os.sdesRTPStreamID:return this.rtpStreamId?cBe(this.rtpStreamId):void 0;case Os.repairedRtpStreamId:return this.repairedRtpStreamId?uBe(this.repairedRtpStreamId):void 0;case Os.transportWideCC:return this.dtlsTransport.transportSequenceNumber=jo(this.dtlsTransport.transportSequenceNumber,1),lBe(this.dtlsTransport.transportSequenceNumber);case Os.absSendTime:return fBe(n)}})();if(p)return{id:h.id,payload:p}}).filter(h=>h);for(let h of i){let p=e.extensions.find(x=>x.id===h.id);p?p.payload=h.payload:e.extensions.push(h)}e.extensions=e.extensions.sort((h,p)=>h.id-p.id),this.ntpTimestamp=n,this.rtpTimestamp=e.timestamp,this.octetCount+=r.length,this.packetCount=bv(this.packetCount,1),this.rtpCache[e.sequenceNumber%UNe]=t;let s=r;this.redRedundantPayloadType&&(this.redEncoder.push({block:s,timestamp:e.timestamp,blockPT:this.redRedundantPayloadType}),s=this.redEncoder.build().serialize());let a=await this.dtlsTransport.sendRtp(s,e);this.runRtcp();let c=Hoe(),d={wideSeq:this.dtlsTransport.transportSequenceNumber,size:a,sendingAtMs:c,sentAtMs:c};this.senderBWE.rtpPacketSent(d)}handleRtcpPacket(t){switch(t.type){case Cv.type:case $S.type:t.reports.filter(r=>r.ssrc===this.ssrc).forEach(r=>{if(this.lastSRtimestamp===r.lsr&&r.dlsr&&this.lastSentSRTimestamp){let n=z6()-this.lastSentSRTimestamp-r.dlsr/65536;this.rtt===void 0?this.rtt=n:this.rtt=MNe*this.rtt+(1-MNe)*n}});break;case Tv.type:{let e=t;switch(e.feedback.count){case M6.count:{let r=e.feedback;this.senderBWE.receiveTWCC(r)}break;case U6.count:{let r=e.feedback;r.lost.forEach(async n=>{let i=this.rtpCache[n%UNe];i&&i.header.sequenceNumber!==n&&(i=void 0),i&&(this.rtxPayloadType!=null&&(i=SBe(i,this.rtxPayloadType,this.rtxSequenceNumber,this.rtxSsrc),this.rtxSequenceNumber=jo(this.rtxSequenceNumber,1)),await this.dtlsTransport.sendRtp(i.payload,i.header))}),this.onGenericNack.execute(r)}break}}break;case LS.type:{let e=t;switch(e.feedback.count){case B6.count:{let r=e.feedback;this.receiverEstimatedMaxBitrate=r.bitrate}break;case N6.count:this.onPictureLossIndication.execute();break}}break}this.onRtcp.execute(t)}getParameters(){return{encodings:[]}}setParameters(t){}async getStats(){let t=qg(),e=[];if(!this.dtlsTransport)return e;let r=rs("transport",this.dtlsTransport.id),n={type:"outbound-rtp",id:rs("outbound-rtp",this.ssrc),timestamp:t,ssrc:this.ssrc,kind:this.kind,transportId:r,codecId:this.codec?rs("codec",this.codec.payloadType,r):void 0,mid:this.mid,packetsSent:this.packetCount,bytesSent:this.octetCount,rtxSsrc:this.rtxPayloadType?this.rtxSsrc:void 0};if(e.push(n),this.track){let i={type:"media-source",id:rs("media-source",this.trackId),timestamp:t,trackIdentifier:this.trackId,kind:this.kind};e.push(i)}if(this.rtt!==void 0){let i={type:"remote-inbound-rtp",id:rs("remote-inbound-rtp",this.ssrc),timestamp:t,ssrc:this.ssrc,kind:this.kind,transportId:r,codecId:n.codecId,localId:n.id,roundTripTime:this.rtt};e.push(i)}return e}},M8t=_n("werift:packages/webrtc/src/transport/sctpManager.ts"),L8t=class{sctpTransport;sctpRemotePort;dataChannelsOpened=0;dataChannelsClosed=0;dataChannels=[];onDataChannel=new yr;constructor(){}createSctpTransport(t){let e=new oMe(5e3,t);return e.mid=void 0,e.onDataChannel.subscribe(r=>{this.dataChannelsOpened++,this.dataChannels.push(r),this.onDataChannel.execute(r)}),this.sctpTransport=e,e}createDataChannel(t,e={}){let n={...{protocol:"",ordered:!0,negotiated:!1},...e};if(n.maxPacketLifeTime&&n.maxRetransmits)throw new Error("can not select both");this.sctpTransport||(this.sctpTransport=this.createSctpTransport());let i=new Roe({id:n.id,label:t,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits,negotiated:n.negotiated,ordered:n.ordered,protocol:n.protocol}),s=new Poe(this.sctpTransport,i);return this.dataChannelsOpened++,this.dataChannels.push(s),s.stateChange.subscribe(a=>{if(a==="closed"){this.dataChannelsClosed++;let c=this.dataChannels.indexOf(s);c!==-1&&this.dataChannels.splice(c,1)}}),s}async connectSctp(){!this.sctpTransport||!this.sctpRemotePort||(await this.sctpTransport.start(this.sctpRemotePort),await this.sctpTransport.sctp.stateChanged.connected.asPromise(),M8t("sctp connected"))}setRemoteSCTP(t,e){if(this.sctpTransport){if(this.sctpTransport.setRemoteMaxMessageSize(t.sctpCapabilities?.maxMessageSize),this.sctpRemotePort=t.sctpPort,!this.sctpRemotePort)throw new Error("sctpRemotePort not exist");this.sctpTransport.setRemotePort(this.sctpRemotePort),this.sctpTransport.mLineIndex=e,this.sctpTransport.mid||(this.sctpTransport.mid=t.rtp.muxId)}}async close(){this.sctpTransport&&await this.sctpTransport.stop(),this.onDataChannel.allUnsubscribe()}async getStats(){let t=qg(),e=[];for(let r of this.dataChannels){let n={type:"data-channel",id:rs("data-channel",r.id),timestamp:t,label:r.label,protocol:r.protocol,dataChannelIdentifier:r.id,state:r.readyState,messagesSent:r.messagesSent||0,bytesSent:r.bytesSent||0,messagesReceived:r.messagesReceived||0,bytesReceived:r.bytesReceived||0};e.push(n)}return e}},hMe=class{currentLocalDescription;currentRemoteDescription;pendingLocalDescription;pendingRemoteDescription;cname;midSuffix;bundlePolicy;seenMid=new Set;constructor({cname:t,midSuffix:e,bundlePolicy:r}){this.cname=t,this.midSuffix=e??!1,this.bundlePolicy=r}get localDescription(){if(this._localDescription)return this._localDescription.toJSON()}get remoteDescription(){if(this._remoteDescription)return this._remoteDescription.toJSON()}get _localDescription(){return this.pendingLocalDescription||this.currentLocalDescription}get _remoteDescription(){return this.pendingRemoteDescription||this.currentRemoteDescription}get inactiveRemoteMedia(){return this._remoteDescription?.media?.find?.(t=>t.direction==="inactive")}createMediaDescriptionForTransceiver(t,e){let r=new yM(t.kind,9,"UDP/TLS/RTP/SAVPF",t.codecs.map(n=>n.payloadType));return r.direction=e,r.msid=t.msid,r.rtp={codecs:t.codecs,headerExtensions:t.headerExtensions,muxId:t.mid},r.rtcpHost="0.0.0.0",r.rtcpPort=9,r.rtcpMux=!0,r.ssrc=[new vM({ssrc:t.sender.ssrc,cname:this.cname})],t.options.simulcast&&(r.simulcastParameters=t.options.simulcast.map(n=>new Ooe(n))),r.rtp.codecs.find(n=>n.name.toLowerCase()==="rtx")&&(r.ssrc.push(new vM({ssrc:t.sender.rtxSsrc,cname:this.cname})),r.ssrcGroup=[new US("FID",[t.sender.ssrc.toString(),t.sender.rtxSsrc.toString()])]),this.addTransportDescription(r,t.dtlsTransport),r}createMediaDescriptionForSctp(t){let e=new yM("application",xNe,"UDP/DTLS/SCTP",["webrtc-datachannel"]);return e.sctpPort=t.port,e.rtp.muxId=t.mid,e.sctpCapabilities=t.getCapabilities(),this.addTransportDescription(e,t.dtlsTransport),e}addTransportDescription(t,e){let r=e.iceTransport;t.iceCandidates=r.localCandidates,t.iceCandidatesComplete=r.gatheringState==="complete",t.iceParams=r.localParameters,t.iceOptions="trickle",t.host=M6t,t.port=xNe,t.direction==="inactive"&&(t.port=0,t.msid=void 0),t.dtlsParams||(t.dtlsParams=e.localParameters,t.dtlsParams.fingerprints||(t.dtlsParams.fingerprints=e.localParameters.fingerprints))}allocateMid(t=""){let e="";for(let r=0;e=(r++).toString()+t,!!this.seenMid.has(e););return this.seenMid.add(e),e}parseSdp({sdp:t,isLocal:e,signalingState:r,type:n}){let i=T6.parse(t);return this.validateDescription({description:i,isLocal:e,signalingState:r}),i.type=n,i}validateDescription({description:t,isLocal:e,signalingState:r}){if(e){if(t.type==="offer"){if(!["stable","have-local-offer"].includes(r))throw new Error("Cannot handle offer in signaling state")}else if(t.type==="answer"&&!["have-remote-offer","have-local-pranswer"].includes(r))throw new Error("Cannot handle answer in signaling state")}else if(t.type==="offer"){if(!["stable","have-remote-offer"].includes(r))throw new Error("Cannot handle offer in signaling state")}else if(t.type==="answer"&&!["have-local-offer","have-remote-pranswer"].includes(r))throw new Error("Cannot handle answer in signaling state")}buildOfferSdp(t,e){let r=new T6;ioe("offer",r),(this.currentLocalDescription?.media??[]).forEach((i,s)=>{let a=i.rtp.muxId;if(a)if(i.kind==="application"){if(!e)throw new Error("sctpTransport not found");e.mLineIndex=s,r.media.push(this.createMediaDescriptionForSctp(e))}else{let c=t.find(d=>d.mid===a);if(!c){if(i.direction==="inactive"){r.media.push(i);return}throw new Error("transceiver not found")}c.mLineIndex=s,r.media.push(this.createMediaDescriptionForTransceiver(c,c.direction))}});for(let i of t.filter(s=>!r.media.find(a=>a.rtp.muxId===s.mid))){i.mid==null&&(i.mid=this.allocateMid(this.midSuffix?"av":""));let s=this.createMediaDescriptionForTransceiver(i,i.direction);i.mLineIndex===void 0?(i.mLineIndex=r.media.length,r.media.push(s)):r.media[i.mLineIndex]=s}if(e&&!r.media.find(i=>i.kind==="application")&&(e.mLineIndex=r.media.length,e.mid==null&&(e.mid=this.allocateMid(this.midSuffix?"dc":"")),r.media.push(this.createMediaDescriptionForSctp(e))),this.bundlePolicy!=="disable"){let i=r.media.map(s=>s.rtp.muxId).filter(s=>s);if(i.length){let s=new US("BUNDLE",i);r.group.push(s)}}return r}buildAnswerSdp({transceivers:t,sctpTransport:e,signalingState:r}){if(!["have-remote-offer","have-local-pranswer"].includes(r))throw new Error("createAnswer failed");if(!this._remoteDescription)throw new Error("wrong state");let n=new T6;ioe("answer",n);for(let i of this._remoteDescription.media){let s,a;if(["audio","video"].includes(i.kind)){let c=t.find(d=>d.mid===i.rtp.muxId);if(!c)throw new Error(`Transceiver with mid=${i.rtp.muxId} not found`);a=this.createMediaDescriptionForTransceiver(c,Woe(c.direction,c.offerDirection)),s=c.dtlsTransport}else if(i.kind==="application"){if(!e||!e.mid)throw new Error("sctpTransport not found");a=this.createMediaDescriptionForSctp(e),s=e.dtlsTransport}else throw new Error("invalid kind");a.dtlsParams&&(s.role==="auto"?a.dtlsParams.role="client":a.dtlsParams.role=s.role),i.simulcastParameters&&i.simulcastParameters.length>0&&(a.simulcastParameters=i.simulcastParameters.map(c=>({...c,direction:c.direction==="send"?"recv":"send"}))),n.media.push(a)}if(this.bundlePolicy!=="disable"){let i=new US("BUNDLE",[]);for(let s of n.media)s.rtp.muxId&&i.items.push(s.rtp.muxId);n.group.push(i)}return n}setLocalDescription(t){this.currentLocalDescription=t,t.type==="answer"?this.pendingLocalDescription=void 0:this.pendingLocalDescription=t}setRemoteDescription(t,e){if(!t.sdp||!t.type||t.type==="rollback"||t.type==="pranswer")throw new Error("invalid sessionDescription");let r=this.parseSdp({sdp:t.sdp,isLocal:!1,signalingState:e,type:t.type});return r.type==="answer"?(this.currentRemoteDescription=r,this.pendingRemoteDescription=void 0):this.pendingRemoteDescription=r,r}registerMid(t){this.seenMid.add(t)}get remoteIsBundled(){let t=this._remoteDescription;return t?t.group.find(r=>r.semantic==="BUNDLE"&&this.bundlePolicy!=="disable"):void 0}setLocal(t,e,r){let n=new Map(e.map(a=>[a?.mLineIndex,a])),i=e.find(a=>a?.dtlsTransport)?.dtlsTransport??r?.dtlsTransport;t.media.filter(a=>["audio","video"].includes(a.kind)).forEach((a,c)=>{let h=(n.get(c)??e[c])?.dtlsTransport??i;if(!h)throw new Error(`dtls transport not found for media index ${c}`);this.addTransportDescription(a,h)});let s=t.media.find(a=>a.kind==="application");r&&s&&this.addTransportDescription(s,r.dtlsTransport),this.setLocalDescription(t)}},u6=_n("werift:packages/webrtc/src/transport/secureTransportManager.ts"),$8t=class{connectionState="new";iceConnectionState="new";iceGatheringState="new";certificate;iceGatheringStateChange=new yr;iceConnectionStateChange=new yr;onIceCandidate=new yr;connectionStateChange=new yr;config;transceiverManager;sctpManager;constructor({config:t,transceiverManager:e,sctpManager:r}){if(this.config=t,this.transceiverManager=e,this.sctpManager=r,this.config.dtls){let{keys:n}=this.config.dtls;n&&this.setupCertificate(n)}}get dtlsTransports(){return[...this.transceiverManager.getTransceivers().map(e=>e?.dtlsTransport),this.sctpManager.sctpTransport?.dtlsTransport].filter(e=>e!=null).reduce((e,r)=>(e.map(n=>n.id).includes(r.id)||e.push(r),e),[])}get iceTransports(){return this.dtlsTransports.map(t=>t.iceTransport)}setupCertificate(t){this.certificate=new Goe(t.keyPem,t.certPem,t.signatureHash)}createTransport(){let t=this.iceTransports.find(i=>i.state!=="closed"),e=new OUe({...IUe(this.config.iceServers),forceTurn:this.config.iceTransportPolicy==="relay",portRange:this.config.icePortRange,interfaceAddresses:this.config.iceInterfaceAddresses,additionalHostAddresses:this.config.iceAdditionalHostAddresses,filterStunResponse:this.config.iceFilterStunResponse,filterCandidatePair:this.config.iceFilterCandidatePair,localPasswordPrefix:this.config.icePasswordPrefix,useIpv4:this.config.iceUseIpv4,useIpv6:this.config.iceUseIpv6,turnTransport:this.config.forceTurnTCP===!0?"tcp":"udp",useLinkLocalAddress:this.config.iceUseLinkLocalAddress});t&&(e.connection.localUsername=t.connection.localUsername,e.connection.localPassword=t.connection.localPassword),e.onGatheringStateChange.subscribe(()=>{this.updateIceGatheringState()}),this.updateIceGatheringState();let r=new RUe(e);return r.onStateChange.subscribe(()=>{this.updateIceConnectionState()}),new qae(this.config,r,this.certificate,j8t)}handleNewIceCandidate({candidate:t,media:e,remoteIsBundled:r,transceiver:n,sctpTransport:i,bundlePolicy:s}){return s==="max-bundle"||r?(t.sdpMLineIndex=0,e&&(t.sdpMid=e.rtp.muxId)):(n&&(t.sdpMLineIndex=n.mLineIndex,t.sdpMid=n.mid),i&&(t.sdpMLineIndex=i.mLineIndex,t.sdpMid=i.mid)),t.foundation&&!t.foundation.startsWith("candidate:")&&(t.foundation="candidate:"+t.foundation),this.onIceCandidate.execute(t),t}async addIceCandidate(t,e){let r=Koe.fromJSON(e);if(!r)return;let n;typeof r.sdpMid=="number"&&(n=this.getTransportByMid(r.sdpMid)),!n&&typeof r.sdpMLineIndex=="number"&&(n=this.getTransportByMLineIndex(t,r.sdpMLineIndex)),n||(n=this.iceTransports[0]),n?await n.addRemoteCandidate(r):u6("iceTransport not found for candidate",r)}getTransportByMid(t){let e,r=this.transceiverManager.getTransceivers().find(n=>n.mid===t);return r?e=r.dtlsTransport.iceTransport:!e&&this.sctpManager.sctpTransport?.mid===t&&(e=this.sctpManager.sctpTransport.dtlsTransport.iceTransport),e}getTransportByMLineIndex(t,e){let r=t.media[e];return r?this.getTransportByMid(r.rtp.muxId):void 0}restartIce(){for(let t of this.iceTransports)t.restart()}setLocalRole({type:t,role:e}){for(let r of this.dtlsTransports){let n=r.iceTransport;t==="offer"?n.connection.iceControlling=!0:n.connection.iceControlling=!1,n.connection.remoteIsLite&&(n.connection.iceControlling=!0),t==="answer"&&e&&(r.role=e)}}updateIceGatheringState(){let t=this.iceTransports;function e(...n){return t.filter(i=>n.includes(i.gatheringState)).length===t.length}let r;t.length&&e("complete")?r="complete":!t.length||e("new","complete")?r="new":t.map(n=>n.gatheringState).includes("gathering")?r="gathering":r="new",this.iceGatheringState!==r&&(this.iceGatheringState=r,this.iceGatheringStateChange.execute(r))}updateIceConnectionState(){let t=this.iceTransports,e;function r(...i){return t.filter(s=>i.includes(s.state)).length===t.length}function n(...i){return t.some(s=>i.includes(s.state))}this.connectionState==="closed"?e="closed":n("failed")?e="failed":n("disconnected")?e="disconnected":r("new","closed")?e="new":n("new","checking")?e="checking":r("completed","closed")?e="completed":r("connected","completed","closed")?e="connected":e="new",this.iceConnectionState!==e&&(u6("iceConnectionStateChange",e),this.iceConnectionState=e,this.iceConnectionStateChange.execute(e))}async gatherCandidates(t){let e=this.iceTransports.find(r=>r.state==="connected"||r.state==="completed");t&&e?u6("skipping ICE gathering for bundled connection"):await Promise.allSettled(this.iceTransports.map(r=>r.gather())).catch(r=>{u6("gatherCandidates failed",r)})}setConnectionState(t){u6("connectionStateChange",t),this.connectionState=t,this.connectionStateChange.execute(t)}async getStats(){let t=[];for(let e of this.dtlsTransports){let r=await e.getStats();r&&t.push(...r)}return t}async ensureCerts(){this.certificate||(this.certificate=await qae.SetupCertificate());for(let t of this.dtlsTransports)t.localCertificate=this.certificate}async close(){this.setConnectionState("closed"),await Promise.allSettled([...this.dtlsTransports.map(t=>t.stop())]),this.iceGatheringStateChange.allUnsubscribe(),this.iceConnectionStateChange.allUnsubscribe(),this.onIceCandidate.allUnsubscribe(),this.connectionStateChange.allUnsubscribe()}},j8t=[vNe.SRTP_AEAD_AES_128_GCM,vNe.SRTP_AES128_CM_HMAC_SHA1_80],od=_n("werift:packages/webrtc/src/peerConnection.ts"),q8t=class extends Foe{cname=U8t().toString();config=pMe();signalingState="stable";negotiationneeded=!1;needRestart=!1;router=new fMe;sdpManager;transceiverManager;sctpManager;secureManager;isClosed=!1;shouldNegotiationneeded=!1;remoteBundleNegotiated=!1;iceGatheringStateChange=new yr;iceConnectionStateChange=new yr;signalingStateChange=new yr;connectionStateChange=new yr;onDataChannel=new yr;onRemoteTransceiverAdded=new yr;onTransceiverAdded=new yr;onIceCandidate=new yr;onNegotiationneeded=new yr;onTrack=new yr;ondatachannel;onicecandidate;onicecandidateerror;onicegatheringstatechange;onnegotiationneeded;onsignalingstatechange;ontrack;onconnectionstatechange;oniceconnectionstatechange;constructor(t={}){super(),this.setConfiguration(t),this.sdpManager=new hMe({cname:this.cname,bundlePolicy:this.config.bundlePolicy}),this.transceiverManager=new mMe(this.cname,this.config,this.router),this.transceiverManager.onTransceiverAdded.pipe(this.onTransceiverAdded),this.transceiverManager.onRemoteTransceiverAdded.pipe(this.onRemoteTransceiverAdded),this.transceiverManager.onTrack.subscribe(({track:e,stream:r,transceiver:n})=>{let i={track:e,streams:[r],transceiver:n,receiver:n.receiver};this.onTrack.execute(e),this.emit("track",i),this.ontrack&&this.ontrack(i)}),this.transceiverManager.onNegotiationNeeded.subscribe(()=>this.needNegotiation()),this.sctpManager=new L8t,this.sctpManager.onDataChannel.subscribe(e=>{this.onDataChannel.execute(e);let r={channel:e};this.ondatachannel?.(r),this.emit("datachannel",r)}),this.secureManager=new $8t({config:this.config,sctpManager:this.sctpManager,transceiverManager:this.transceiverManager}),this.secureManager.iceGatheringStateChange.pipe(this.iceGatheringStateChange),this.secureManager.iceConnectionStateChange.subscribe(e=>{e==="closed"&&this.close(),this.iceConnectionStateChange.execute(e)}),this.secureManager.connectionStateChange.subscribe(e=>{this.connectionStateChange.execute(e),this.onconnectionstatechange?.(),this.emit("connectionstatechange")}),this.secureManager.onIceCandidate.subscribe(e=>{let r=e?e.toJSON():void 0;this.onIceCandidate.execute(r),this.onicecandidate?.({candidate:r}),this.emit("icecandidate",{candidate:r})})}get connectionState(){return this.secureManager.connectionState}get iceConnectionState(){return this.secureManager.iceConnectionState}get iceGathererState(){return this.secureManager.iceGatheringState}get iceGatheringState(){return this.secureManager.iceGatheringState}get dtlsTransports(){return this.secureManager.dtlsTransports}get sctpTransport(){return this.sctpManager.sctpTransport}get sctpRemotePort(){return this.sctpManager.sctpRemotePort}get iceTransports(){return this.secureManager.iceTransports}get extIdUriMap(){return this.router.extIdUriMap}get iceGeneration(){return this.iceTransports[0].connection.generation}get localDescription(){return this.sdpManager.localDescription}get remoteDescription(){return this.sdpManager.remoteDescription}get remoteIsBundled(){return this.sdpManager.remoteIsBundled}get _localDescription(){return this.sdpManager._localDescription}get _remoteDescription(){return this.sdpManager._remoteDescription}getTransceivers(){return this.transceiverManager.getTransceivers()}getSenders(){return this.transceiverManager.getSenders()}getReceivers(){return this.transceiverManager.getReceivers()}setConfiguration(t){if(FUe(this.config,t),this.config.icePortRange){let[e,r]=this.config.icePortRange;if(e===r)throw new Error("should not be same value");if(e>=r)throw new Error("The min must be less than max")}if(!Number.isInteger(this.config.maxMessageSize)||this.config.maxMessageSize<0)throw new Error("maxMessageSize must be a non-negative integer");this.sctpManager?.sctpTransport&&(this.sctpManager.sctpTransport.maxMessageSize=this.config.maxMessageSize);for(let[e,r]of fNe([...this.config.codecs.audio||[],...this.config.codecs.video||[]]))if(r.payloadType==null)switch(r.payloadType=96+e,r.name.toLowerCase()){case"rtx":r.parameters=`apt=${r.payloadType-1}`;break;case"red":if(r.contentType==="audio"){let n=r.payloadType+1;r.parameters=`${n}/${n}`,r.payloadType=63}break}[...this.config.headerExtensions.audio||[],...this.config.headerExtensions.video||[]].forEach((e,r)=>{e.id=1+r})}getConfiguration(){return this.config}async createOffer({iceRestart:t}={}){(t||this.needRestart)&&(this.needRestart=!1,this.secureManager.restartIce()),await this.secureManager.ensureCerts();for(let r of this.transceiverManager.getTransceivers())r.codecs.length===0&&this.transceiverManager.assignTransceiverCodecs(r),r.headerExtensions.length===0&&(r.headerExtensions=this.config.headerExtensions[r.kind]??[]);return this.sdpManager.buildOfferSdp(this.transceiverManager.getTransceivers(),this.sctpTransport).toJSON()}createSctpTransport(){let t=this.sctpManager.createSctpTransport(this.config.maxMessageSize),e=this.findOrCreateTransport();return t.setDtlsTransport(e),t}createDataChannel(t,e={}){this.sctpTransport||(this.createSctpTransport(),this.needNegotiation());let r=this.sctpManager.createDataChannel(t,e);if(!r.sctp.dtlsTransport){let n=this.findOrCreateTransport();r.sctp.setDtlsTransport(n)}return r}removeTrack(t){if(this.isClosed)throw new Error("peer closed");this.transceiverManager.removeTrack(t),this.needNegotiation()}needNegotiation=async()=>{this.shouldNegotiationneeded=!0,!(this.negotiationneeded||this.signalingState!=="stable")&&(this.shouldNegotiationneeded=!1,setImmediate(()=>{this.negotiationneeded=!0,this.onNegotiationneeded.execute(),this.onnegotiationneeded&&this.onnegotiationneeded({})}))};findOrCreateTransport(){let t=this.dtlsTransports.find(i=>i.state!=="closed"),e=t?.iceTransport;if((this.sdpManager.bundlePolicy==="max-bundle"||this.sdpManager.bundlePolicy!=="disable"&&(this.remoteIsBundled||this.remoteBundleNegotiated))&&t)return t;let r=this.secureManager.createTransport();r.onRtp.subscribe(i=>{this.router.routeRtp(i)}),r.onRtcp.subscribe(i=>{this.router.routeRtcp(i)});let n=r.iceTransport;return n.onNegotiationNeeded.subscribe(()=>{this.needNegotiation()}),n.onIceCandidate.subscribe(i=>{if(!this.localDescription){od("localDescription not found when ice candidate was gathered");return}if(!i){this.sdpManager.setLocal(this._localDescription,this.transceiverManager.getTransceivers(),this.sctpTransport),this.onIceCandidate.execute(void 0),this.onicecandidate&&this.onicecandidate({candidate:void 0}),this.emit("icecandidate",{candidate:void 0});return}if(!this._localDescription){od("localDescription not found when ice candidate was gathered");return}this.secureManager.handleNewIceCandidate({candidate:i,bundlePolicy:this.sdpManager.bundlePolicy,remoteIsBundled:!!this.sdpManager.remoteIsBundled,media:this._localDescription.media[0],transceiver:this.transceiverManager.getTransceivers().find(s=>s?.dtlsTransport?.iceTransport.id===n.id),sctpTransport:this.sctpTransport?.dtlsTransport.iceTransport.id===n.id?this.sctpTransport:void 0})}),r}async setLocalDescription(t){t=t??(["stable","have-local-offer","have-remote-pranswer"].includes(this.signalingState)?await this.createOffer():await this.createAnswer());let r=this.sdpManager.parseSdp({sdp:t.sdp,isLocal:!0,signalingState:this.signalingState,type:t.type});r.type==="offer"?this.setSignalingState("have-local-offer"):r.type==="answer"&&this.setSignalingState("stable");for(let[i,s]of fNe(r.media)){let a=s.rtp.muxId;if(this.sdpManager.registerMid(a),["audio","video"].includes(s.kind)){let c=this.transceiverManager.getTransceiverByMLineIndex(i);c&&(c.mid=a)}s.kind==="application"&&this.sctpTransport&&(this.sctpTransport.mid=a)}let n=r.media.find(i=>i.dtlsParams)?.dtlsParams?.role;if(this.secureManager.setLocalRole({type:r.type,role:n}),["answer","pranswer"].includes(r.type))for(let i of this.transceiverManager.getTransceivers()){let s=Woe(i.direction,i.offerDirection);i.setCurrentDirection(s)}return this.sdpManager.setLocal(r,this.transceiverManager.getTransceivers(),this.sctpTransport),await this.gatherCandidates().catch(i=>{od("gatherCandidates failed",i)}),r.type==="answer"&&this.connect().catch(i=>{od("connect failed",i),this.secureManager.setConnectionState("failed")}),this.sdpManager.setLocal(r,this.transceiverManager.getTransceivers(),this.sctpTransport),this.shouldNegotiationneeded&&this.needNegotiation(),r}async gatherCandidates(){await this.secureManager.gatherCandidates(!!this.sdpManager.remoteIsBundled)}async addIceCandidate(t){let e=this.sdpManager.buildOfferSdp(this.transceiverManager.getTransceivers(),this.sctpTransport);await this.secureManager.addIceCandidate(e,t)}async connect(){od("start connect"),(await Promise.allSettled(this.dtlsTransports.map(async e=>{let{iceTransport:r}=e;if(r.state==="connected")return;let n=()=>e.state==="connected";n()||(this.secureManager.setConnectionState("connecting"),await r.start().catch(i=>{throw od("iceTransport.start failed",i),i}),!n()&&(await e.start().catch(i=>{throw od("dtlsTransport.start failed",i),i}),this.sctpTransport&&this.sctpTransport.dtlsTransport.id===e.id&&await this.sctpManager.connectSctp()))}))).find(e=>e.status==="rejected")?this.secureManager.setConnectionState("failed"):this.secureManager.setConnectionState("connected")}restartIce(){this.needRestart=!0,this.needNegotiation()}async setRemoteDescription(t){t instanceof T6&&(t=t.toSdp());let e=this.sdpManager.setRemoteDescription(t,this.signalingState);e.group.some(a=>a.semantic==="BUNDLE"&&a.items.length>0)&&(this.remoteBundleNegotiated=!0);let r,n=(a,c)=>a.kind===c.kind&&[void 0,c.rtp.muxId].includes(a.mid),i=e.media.map((a,c)=>{let d;if(["audio","video"].includes(a.kind)){let p=this.transceiverManager.getTransceivers().find(x=>n(x,a));if(!p)p=this.addTransceiver(a.kind,{direction:"recvonly"}),p.mid=a.rtp.muxId,this.onRemoteTransceiverAdded.execute(p);else if(p.direction==="inactive"&&p.stopping){p.stopped=!0,t.type==="answer"&&p.setCurrentDirection("inactive");return}this.sdpManager.remoteIsBundled&&(r?p.setDtlsTransport(r):r=p.dtlsTransport),d=p.dtlsTransport,this.transceiverManager.setRemoteRTP(p,a,e.type,c)}else if(a.kind==="application"){let p=this.sctpTransport;p||(p=this.createSctpTransport(),p.mid=a.rtp.muxId),this.sdpManager.remoteIsBundled&&(r?p.setDtlsTransport(r):r=p.dtlsTransport),d=p.dtlsTransport,this.sctpManager.setRemoteSCTP(a,c)}else throw new Error("invalid media kind");let h=d.iceTransport;if(a.iceParams){let p=!!this.sdpManager.inactiveRemoteMedia;h.setRemoteParams(a.iceParams,p),a.iceParams?.iceLite&&(h.connection.iceControlling=!0)}return a.dtlsParams&&d.setRemoteParams(a.dtlsParams),a.iceCandidates.forEach(h.addRemoteCandidate),a.iceCandidatesComplete&&h.addRemoteCandidate(void 0),e.type==="answer"&&a.dtlsParams?.role&&(d.role=a.dtlsParams.role==="client"?"server":"client"),h});i=i.filter(a=>!!a);let s=this.transceiverManager.getTransceivers().filter(a=>e.media.find(c=>n(a,c))==null);if(t.type==="answer")for(let a of s)a.stop(),a.stopped=!0;e.type==="offer"?this.setSignalingState("have-remote-offer"):e.type==="answer"&&this.setSignalingState("stable"),e.type==="answer"&&(od("caller start connect"),this.connect().catch(a=>{od("connect failed",a),this.secureManager.setConnectionState("failed")})),this.negotiationneeded=!1,this.shouldNegotiationneeded&&this.needNegotiation()}addTransceiver(t,e={}){let r=this.findOrCreateTransport(),n=this.transceiverManager.addTransceiver(t,r,e);return this.secureManager.updateIceConnectionState(),this.needNegotiation(),n}addTrack(t,e){if(this.isClosed)throw new Error("is closed");let r=this.transceiverManager.addTrack(t,e);if(!r.dtlsTransport){let n=this.findOrCreateTransport();r.setDtlsTransport(n)}return this.needNegotiation(),r.sender}async createAnswer(){return this.assertNotClosed(),await this.secureManager.ensureCerts(),this.sdpManager.buildAnswerSdp({transceivers:this.transceiverManager.getTransceivers(),sctpTransport:this.sctpTransport,signalingState:this.signalingState}).toJSON()}assertNotClosed(){if(this.isClosed)throw new Error("RTCPeerConnection is closed")}setSignalingState(t){od("signalingStateChange",t),this.signalingState=t,this.signalingStateChange.execute(t),this.onsignalingstatechange&&this.onsignalingstatechange({})}createPeerConnectionStats(){let t=qg();return{type:"peer-connection",id:rs("peer-connection"),timestamp:t,dataChannelsOpened:this.sctpManager.dataChannelsOpened,dataChannelsClosed:this.sctpManager.dataChannelsClosed}}async getStats(t){let e=[];e.push(this.createPeerConnectionStats());let r=await this.transceiverManager.getStats(t);e.push(...r);let n=await this.secureManager.getStats();if(e.push(...n),this.sctpTransport){let i=await this.sctpManager.getStats();i&&e.push(...i)}return new _Ue(e)}async close(){this.isClosed||(this.isClosed=!0,this.setSignalingState("closed"),this.transceiverManager.close(),await this.secureManager.close(),await this.sctpManager.close(),this.onDataChannel.allUnsubscribe(),this.iceGatheringStateChange.allUnsubscribe(),this.iceConnectionStateChange.allUnsubscribe(),this.signalingStateChange.allUnsubscribe(),this.onTransceiverAdded.allUnsubscribe(),this.onRemoteTransceiverAdded.allUnsubscribe(),this.onIceCandidate.allUnsubscribe(),od("peerConnection closed"))}},aoe=(t,e)=>t.find(r=>r.mimeType.toLowerCase()===e.mimeType.toLowerCase())?e:void 0;z8t=pMe(),W8t=_n("werift:packages/webrtc/src/media/rtpTransceiverManager.ts"),mMe=class{constructor(t,e,r){this.cname=t,this.config=e,this.router=r}transceivers=[];onTransceiverAdded=new yr;onRemoteTransceiverAdded=new yr;onTrack=new yr;onNegotiationNeeded=new yr;getTransceivers(){return this.transceivers}getSenders(){return this.getTransceivers().map(t=>t.sender)}getReceivers(){return this.getTransceivers().map(t=>t.receiver)}getTransceiverByMLineIndex(t){return this.transceivers.find(e=>e.mLineIndex===t)}pushTransceiver(t){this.transceivers.push(t)}replaceTransceiver(t,e){this.transceivers[e]=t}addTransceiver(t,e,r={}){let n=typeof t=="string"?t:t.kind,i=r.direction||"sendrecv",s=new dMe(t),a=new ece(this.config,n,s.ssrc),c=new wUe(n,e,a,s,i);c.options=r,this.router.registerRtpSender(c.sender);let d=this.transceivers.findIndex(p=>p.currentDirection==="inactive"&&!p.usedForSender),h=this.transceivers.find(p=>p.currentDirection==="inactive"&&!p.usedForSender);return d>-1&&h?(this.replaceTransceiver(c,d),c.mLineIndex=h.mLineIndex,c.mid=h.mid,h.setCurrentDirection(void 0)):this.pushTransceiver(c),this.onTransceiverAdded.execute(c),c}addTrack(t,e){if(this.getSenders().find(i=>i.track?.uuid===t.uuid))throw new Error("Track already added");let r=this.transceivers.find(i=>i.sender.track==null&&i.kind===t.kind&&ZU.includes(i.direction)===!0);if(r)return r.sender.registerTrack(t),r;let n=this.transceivers.find(i=>i.sender.track==null&&i.kind===t.kind&&ZU.includes(i.direction)===!1&&!i.usedForSender);if(n){switch(n.sender.registerTrack(t),n.direction){case"recvonly":n.setDirection("sendrecv");break;case"inactive":n.setDirection("sendonly");break}return n}else return this.addTransceiver(t,void 0,{direction:"sendrecv"})}removeTrack(t){if(!this.getSenders().find(({ssrc:r})=>t.ssrc===r))throw new Error("Sender does not exist");let e=this.transceivers.find(({sender:{ssrc:r}})=>t.ssrc===r);if(!e)throw new Error("No matching transceiver found");if(t.stop(),e.currentDirection==="recvonly"){this.onNegotiationNeeded.execute();return}e.stopping||e.stopped?e.setDirection("inactive"):e.direction==="sendrecv"?e.setDirection("recvonly"):(e.direction==="sendonly"||e.direction==="recvonly")&&e.setDirection("inactive")}assignTransceiverCodecs(t){let e=this.config.codecs[t.kind].filter(r=>{switch(r.direction){case"recvonly":return!!$6t.includes(t.direction);case"sendonly":return!!ZU.includes(t.direction);case"sendrecv":return!![joe,$oe,Loe].includes(t.direction);case"all":return!0;default:return!1}});t.codecs=e}getLocalRtpParams(t){if(t.mid==null)throw new Error("mid not assigned");return{codecs:t.codecs,muxId:t.mid,headerExtensions:t.headerExtensions,rtcp:{cname:this.cname,ssrc:t.sender.ssrc,mux:!0}}}getRemoteRtpParams(t,e){return{muxId:t.rtp.muxId,rtcp:t.rtp.rtcp,codecs:e.codecs,headerExtensions:e.headerExtensions,encodings:Object.values(e.codecs.reduce((n,i)=>{if(i.name.toLowerCase()==="rtx"){let s=H6(i.parameters??""),a=n[s.apt];return a&&t.ssrc.length===2&&(a.rtx=new mUe({ssrc:t.ssrc[1].ssrc})),n}return n[i.payloadType]=new gUe({ssrc:t.ssrc[0]?.ssrc,payloadType:i.payloadType}),n},{}))}}setRemoteRTP(t,e,r,n){if(t.mid||(t.mid=e.rtp.muxId),t.mLineIndex=n,t.codecs=e.rtp.codecs.filter(c=>{let d=this.config.codecs[e.kind]||[],h=aoe(d,c);if(!h)return!1;if(h?.name.toLowerCase()==="rtx"){let x=H6(h.parameters??"").apt,y=e.rtp.codecs.find(v=>v.payloadType===x);return y?!!aoe(d,y):!1}return!0}),W8t("negotiated codecs",t.codecs),t.codecs.length===0)throw new Error("negotiate codecs failed.");t.headerExtensions=e.rtp.headerExtensions.filter(c=>(this.config.headerExtensions[e.kind]||[]).find(d=>d.uri===c.uri));let i=e.direction??"inactive",s=CUe(i);["answer","pranswer"].includes(r)?t.setCurrentDirection(s):t.offerDirection=s;let a=this.getLocalRtpParams(t);if(t.sender.prepareSend(a),["recvonly","sendrecv"].includes(t.direction)){let c=this.getRemoteRtpParams(e,t);for(let d of e.simulcastParameters)this.router.registerRtpReceiverByRid(t,d,c);t.receiver.prepareReceive(c),this.router.registerRtpReceiverBySsrc(t,c)}if(["sendonly","sendrecv"].includes(i)){if(e.msid){let[c,d]=e.msid.split(" ");t.receiver.remoteStreamId=c,t.receiver.remoteTrackId=d}this.onTrack.execute({track:t.receiver.track,transceiver:t,stream:new EUe({id:t.receiver.remoteStreamId,tracks:[t.receiver.track]})})}e.ssrc[0]?.ssrc&&t.receiver.setupTWCC(e.ssrc[0].ssrc)}async getStats(t){let e=[];for(let r of this.transceivers){let n=!t||r.sender.track===t||r.receiver.track===t;if(r.sender){let i=await r.sender.getStats();if(i)for(let s of i)s.type==="outbound-rtp"||s.type==="media-source"?n&&e.push(s):e.push(s)}if(r.receiver){let i=await r.receiver.getStats();if(i)for(let s of i)s.type==="inbound-rtp"||s.type==="remote-outbound-rtp"?n&&e.push(s):e.push(s)}if(n){let i=r.getCodecStats();i&&e.push(...i)}}return e}close(){for(let t of this.transceivers)t.receiver.stop(),t.sender.stop();this.onTransceiverAdded.allUnsubscribe(),this.onRemoteTransceiverAdded.allUnsubscribe(),this.onTrack.allUnsubscribe(),this.onNegotiationNeeded.allUnsubscribe()}},H8t=["stable","have-local-offer","have-remote-offer","have-local-pranswer","have-remote-pranswer","closed"],V8t=["closed","failed","disconnected","new","connecting","connected"]});var IMe={};yi(IMe,{SERVICE_TYPE:()=>nce,accountFingerprint:()=>ice,advertise:()=>r5t,browse:()=>DMe,osTag:()=>TMe,scan:()=>n5t});function TMe(){let t=process.platform;return t==="darwin"?"mac":t==="win32"?"win":t==="linux"?"linux":"other"}function CMe(t){return JSON.stringify(["oioxo-advert",t.v,t.acct,t.dev,t.os,t.name,t.nonce])}async function ice(t){let e=new TextEncoder().encode("oioxo-acct:"+t),r=await crypto.subtle.digest("SHA-256",e);return Buffer.from(new Uint8Array(r)).toString("base64url").slice(0,22)}async function kMe(){try{let e=await import("bonjour-service");return e.Bonjour??e.default??null}catch{return null}}async function r5t(t){let e=await kMe();if(!e)return{stop:()=>{}};let r=await ice(t.accountKey),n=Buffer.from(crypto.getRandomValues(new Uint8Array(8))).toString("base64url"),i={v:2,acct:r,dev:t.identity.deviceId,os:TMe(),name:t.label,nonce:n},s=await t.identity.sign(CMe(i)),a=new e,c=a.publish({name:"OIOXO "+t.identity.deviceId.slice(0,6),type:nce,protocol:"tcp",port:t.port,txt:{v:String(2),acct:r,dev:i.dev,os:i.os,name:t.label,nonce:n,sig:s}});return{stop:()=>{try{c.stop(()=>a.destroy())}catch{}}}}async function DMe(t){let e=await kMe();if(!e)return{stop:()=>{}};let r=await ice(t.accountKey),n=new e,i=new Set,s=n.find({type:nce,protocol:"tcp"},a=>{(async()=>{let c=a.txt;if(!c||c.acct!==r)return;let d=c.dev;if(!d||i.has(d)||!c.sig||!c.name||!c.nonce)return;let h=CMe({v:Number(c.v)||2,acct:c.acct,dev:d,os:c.os||"other",name:c.name,nonce:c.nonce}),p=await t.verify(d,c.sig,h).catch(()=>!1);i.add(d);let x=a.referer?.address||a.addresses&&a.addresses[0]||"",y=["mac","win","linux"].includes(c.os)?c.os:"other";t.onDevice({deviceId:d,label:c.name,os:y,host:x,port:a.port,trusted:p})})()});return{stop:()=>{try{s.stop(),n.destroy()}catch{}}}}async function n5t(t){let e=[],{stop:r}=await DMe({accountKey:t.accountKey,verify:t.verify,onDevice:n=>e.push(n)});return await new Promise(n=>setTimeout(n,t.ms??2500)),r(),e}var nce,FMe=ce(()=>{"use strict";nce="oioxo"});var iLe={};yi(iLe,{BROWSER_VERBS_DOC:()=>vce,BrowserController:()=>u8,isBlockedHost:()=>nLe,isLocalUrl:()=>LM,originOf:()=>gce,parseBrowserVerb:()=>yce,renderSnapshot:()=>xce});function w5t(t){let e=t.trim();if(/^(0x[0-9a-f]+|0[0-7]*|[1-9][0-9]*)$/i.test(e)){let n;if(/^0x/i.test(e)?n=parseInt(e,16):/^0[0-7]+$/.test(e)?n=parseInt(e,8):n=parseInt(e,10),Number.isFinite(n)&&n>=0&&n<=4294967295)return[n>>>24&255,n>>>16&255,n>>>8&255,n&255].join(".")}let r=e.split(".");if(r.length===4&&r.every(n=>/^(0x[0-9a-f]+|0[0-7]*|[0-9]+)$/i.test(n))){let n=r.map(i=>/^0x/i.test(i)?parseInt(i,16):/^0[0-7]+$/.test(i)?parseInt(i,8):parseInt(i,10));if(n.every(i=>Number.isFinite(i)&&i>=0&&i<=255))return n.join(".")}return t}function nLe(t){try{let e=new URL(t).hostname,r=w5t((e.startsWith("["),e));return rLe.test(e)||rLe.test(r)}catch{return!1}}function LM(t){try{let e=new URL(t);return e.protocol==="data:"||e.protocol==="about:"?!0:_5t.test(e.hostname)}catch{return!1}}function gce(t){try{return new URL(t).origin}catch{return""}}function xce(t,e){let r=e?`# ${e.title??""}
1114
1123
  ${e.url??""}
1115
1124
  `:"",n=t.map(i=>`[${i.ref}] ${i.role} ${JSON.stringify(i.name)}`).join(`
1116
1125
  `);return`${r}${n}`.trim()}function yce(t){let e=s=>{if(!s||typeof s!="object")return null;let a=typeof s.verb=="string"?s.verb:typeof s.action=="string"?s.action:null;return!a||!["navigate","click","type","screenshot","snapshot","waitFor","scrollTo","evaluate","back","reload","close"].includes(a)?null:{...s,verb:a}},r=s=>{try{return e(JSON.parse(s))}catch{return null}},n=t.match(/```(?:browser|json)?\s*\n?([\s\S]*?)```/);if(n){let s=r(n[1].trim());if(s)return s}let i=t.indexOf("{");if(i>=0){let s=0;for(let a=i;a<t.length;a++)if(t[a]==="{")s++;else if(t[a]==="}"&&--s===0){let c=r(t.slice(i,a+1));if(c)return c;break}}return null}var _5t,rLe,u8,vce,$M=ce(()=>{"use strict";_5t=/^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\]|::1)$/i,rLe=/^(?:169\.254\.\d{1,3}\.\d{1,3}|\[(?:fe80|fd[0-9a-f]{2}):[0-9a-f:]*\]|metadata\.google\.internal|metadata)$/i;u8=class{backend;policy;approved;constructor(e,r={}){this.backend=e,this.policy=r,this.approved=r.approvedOrigins??new Set}approve(e){e&&this.approved.add(e)}async run(e){let r=n=>({ok:!1,url:"",title:"",error:n});if(e.verb==="evaluate"&&!this.policy.allowEvaluate)return r("evaluate (arbitrary JS) is disabled. Enable it explicitly to run page scripts.");if(e.verb==="navigate"){if(!e.url||!/^(https?:|about:|data:)/i.test(e.url))return r(`Refusing to navigate to a non-http(s) URL: ${e.url}`);if(nLe(e.url))return r(`Refusing to navigate to a cloud-metadata / link-local address: ${gce(e.url)||e.url}`);if(!LM(e.url)){let n=gce(e.url);if(!this.approved.has(n)){if(!(this.policy.confirmNavigate?await this.policy.confirmNavigate(n):!1))return r(`Navigation to ${n} was not approved. (Local URLs are always allowed.)`);this.approved.add(n)}}}if(e.verb==="click"&&e.ref==null&&!e.selector&&!e.text)return r("click needs a ref, selector, or text.");if(e.verb==="type"&&e.ref==null&&!e.selector)return r("type needs a ref or selector.");try{return await this.backend.run(e)}catch(n){return r(`Browser error: ${String(n?.message||n).slice(0,200)}`)}}dispose(){return this.backend.dispose()}};vce=`You can drive a real web browser to SEE and test pages. Reply with EXACTLY one fenced block tagged \`browser\` containing JSON: {"verb": "<name>", ...args}.
@@ -1282,7 +1291,7 @@ ${C.snippet}`:""}`).join(`
1282
1291
  `);return Gs(S||"No results.")}catch(v){return Gs(`web_search failed: ${v instanceof Error?v.message:"error"}`)}}),e.tool("fetch_url","Fetch a web page (http/https only) and return its readable text. Use to read a doc/article \u2014 typically a URL found via web_search.",{url:ao.string().describe("The full http(s) URL.")},async({url:x})=>{let y=await XS();if(!y.ok)return ZS(y.message);try{let w=await(await fetch(`${Us}/tools/fetch?url=${encodeURIComponent(x)}`,{signal:AbortSignal.timeout(12e3)})).json();return Gs(w.error?`fetch_url failed: ${w.error}`:w.text??"(empty)")}catch(v){return Gs(`fetch_url failed: ${v instanceof Error?v.message:"error"}`)}});let c=null,d=!1,h=async x=>{if(d=x,c)return c;let{makePlaywrightBackend:y}=await Promise.resolve().then(()=>(_ce(),bce)),{BrowserController:v}=await Promise.resolve().then(()=>($M(),iLe)),w=await y({headless:!1});return c=new v(w,{confirmNavigate:async()=>d,allowEvaluate:!1}),c};e.tool("browser",'Drive a REAL browser on this machine to see and test web pages \u2014 navigate, read a numbered snapshot of clickable elements, click/type by ref, screenshot. Runs LOCALLY (the page never leaves the device). Local URLs (localhost) are always allowed; set allow_external:true to permit other sites. Call one verb at a time; after navigate the result lists elements like [3] button "Sign in" \u2014 click by that ref.',{verb:ao.enum(["navigate","snapshot","screenshot","click","type","waitFor","scrollTo","back","reload","close"]).describe("The action."),url:ao.string().optional().describe("For navigate: the URL."),ref:ao.number().optional().describe("For click/type/scrollTo: element number from the latest snapshot."),text:ao.string().optional().describe("For type: text to enter. For click: visible text to match. For waitFor: text to wait for."),selector:ao.string().optional().describe("Optional CSS selector (prefer ref)."),submit:ao.boolean().optional().describe("For type: press Enter after typing."),allow_external:ao.boolean().optional().describe("Permit navigating to non-local sites (privacy gate; default false).")},async({verb:x,url:y,ref:v,text:w,selector:S,submit:C,allow_external:k})=>{let T=await XS();if(!T.ok)return ZS(T.message);try{let E=await h(!!k);if(x==="close")return await E.dispose(),c=null,Gs("Browser closed.");let I=await E.run({verb:x,url:y,ref:v,text:w,selector:S,submit:C});if(!I.ok)return Gs(`browser ${x} failed: ${I.error??"unknown error"}`);let R=`${I.title||""} \u2014 ${I.url}`.trim(),U=I.snapshot?`
1283
1292
  ${I.snapshot}`:"",B=I.consoleErrors?.length?`
1284
1293
  console errors: ${I.consoleErrors.slice(0,3).join(" | ")}`:"",z=I.screenshot?`
1285
- (screenshot captured: ${I.screenshot.length} bytes \u2014 not shown as text)`:"";return Gs(`${R}${U}${B}${z}`.trim()||"OK")}catch(E){return Gs(`browser failed: ${E instanceof Error?E.message:"error"}`)}});let p=new MM;await e.connect(p)}H8();BA();_l();var Oce=(()=>{try{return"0.5.66"}catch{}try{return TLe(import.meta.url)("../../package.json").version}catch{return"0.0.0"}})(),TIt=`OIOXO ${Oce} \u2014 context engine + terminal coding agent (https://oioxo.com)
1294
+ (screenshot captured: ${I.screenshot.length} bytes \u2014 not shown as text)`:"";return Gs(`${R}${U}${B}${z}`.trim()||"OK")}catch(E){return Gs(`browser failed: ${E instanceof Error?E.message:"error"}`)}});let p=new MM;await e.connect(p)}H8();BA();_l();var Oce=(()=>{try{return"0.5.67"}catch{}try{return TLe(import.meta.url)("../../package.json").version}catch{return"0.0.0"}})(),TIt=`OIOXO ${Oce} \u2014 context engine + terminal coding agent (https://oioxo.com)
1286
1295
 
1287
1296
  Private, on your device. Cut your AI bill by up to ~90% in Copilot, Cursor & Claude,
1288
1297
  and code from your terminal \u2014 nothing leaves your machine.