@zkpassport/ui 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/react.cjs +1 -1
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.js +1 -1
- package/dist/esm/react.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/react.js
CHANGED
|
@@ -1027,7 +1027,7 @@ ${e.join(`
|
|
|
1027
1027
|
`).map(o=>o.trim()).filter(Boolean),i={},n=0;for(;n<r.length;n++){let o=r[n],s=o.indexOf(":");if(s<=0)break;i[o.slice(0,s).trim()]=o.slice(s+1).trim();}return {headers:Object.keys(i).length?i:void 0,base64Lines:r.slice(n),base64Text:r.slice(n).join("")}}function Vw(t){return /\r\n/.test(t)?`\r
|
|
1028
1028
|
`:`
|
|
1029
1029
|
`}function P3(t,e={}){let r=[],i=e.label,n;for(T3.lastIndex=0;n=T3.exec(t);){let o=n[1].trim();if(i&&o!==i)continue;k3(o);let s=$w(n[2]);r.push({label:o,data:hn.decode(s.base64Text),headers:s.headers,lineLength:s.base64Lines[0]?.length??64,newline:Vw(n[0])});}if(e.strict&&r.length===0)throw new TypeError(i?`No PEM block with label '${i}' was found`:"No PEM blocks were found");return r}function dl(t,e,r={}){k3(t);let i=r.lineLength??64;if(!Number.isInteger(i)||i<1)throw new RangeError("PEM lineLength must be a positive integer");let n=r.newline??`
|
|
1030
|
-
`,o=[`-----BEGIN ${t}-----`];if(r.headers){for(let[s,a]of Object.entries(r.headers))o.push(`${s}: ${a}`);o.push("");}return o.push(...Gw(hn.encode(e),i)),o.push(`-----END ${t}-----`),`${o.join(n)}${n}`}function N3(t,e={}){return P3(t,e).map(({lineLength:r,newline:i,...n})=>n)}function R3(t,e){let[r]=N3(t,{label:e,strict:true});return r.data}function D3(t,e={}){let[r]=P3(t,{...e,strict:true}),i={label:r.label,headers:r.headers,lineLength:r.lineLength,newline:r.newline};return {bytes:r.data,format:i,normalized:dl(r.label,r.data,i)}}function O3(t,e){return dl(e.label,t,e)}var m0={name:"pem",encode:(t,e)=>{if(!e?.label)throw new TypeError("PEM label is required");return dl(e.label,t,e)},decode:(t,e)=>R3(t,e?.label),format:O3,is:t=>typeof t=="string"&&/-----BEGIN [^-]+-----/.test(t),parse:D3};function Xr(t){return t.trim().toLowerCase()}function jw(t){return t instanceof Error?t:new Error(String(t))}function M3(t,e,r){for(let i of [r.name,...r.aliases??[]])t.delete(Xr(i));e.delete(Xr(r.name));}function Pf(t,e,r){let i=t[r];if(typeof i!="function")throw new Error(`Converter '${e}' does not support ${r}()`);return i}function Xw(t,e,r){let i=Xr(r.name||t),n=e.trim();if(!n)return 0;let o=false;r.is&&(o=r.is(e));let s=false;try{r.decode(e),s=!0;}catch{s=false;}if(!o&&!s)return 0;switch(i){case "pem":return /-----BEGIN [^-]+-----/.test(e)?1:0;case "hex":{let a=n.replace(/^0x/i,"").replace(/[\s:.-]/g,"");return !a||/[^0-9a-f]/i.test(a)||a.length%2!==0?0:/^0x/i.test(n)||/[:\s.-]/.test(n)?.95:/[a-f]/.test(n)||/[A-F]/.test(n)?.8:.45}case "base64url":return /[-_]/.test(n)?.95:/=/.test(n)?.1:.6;case "base64":return /[+/=]/.test(n)?.9:.55;case "binary":case "utf8":case "utf16be":case "utf16le":return 0;default:return o&&s?.75:.5}}function Nf(t=[]){let e=new Map,r=new Set,i={register(n,o={}){if(!n.name||!Xr(n.name))throw new TypeError("Converter name is required");let s=[...new Set([n.name,...n.aliases??[]].map(Xr))],a=new Set;for(let c of s){let l=e.get(c);if(l){if(!o.override)throw new Error(`Converter '${c}' is already registered`);a.add(l);}}for(let c of a)M3(e,r,c);for(let c of s)e.set(c,n);return r.add(Xr(n.name)),this},unregister(n){let o=e.get(Xr(n));return o?(M3(e,r,o),true):false},has(n){return e.has(Xr(n))},get(n){let o=e.get(Xr(n));if(!o)throw new Error(`Converter '${n}' is not registered`);return o},list(){return [...r].map(n=>this.get(n))},encode(n,o,s){return this.get(n).encode(o,s)},decode(n,o,s){return this.get(n).decode(o,s)},tryDecode(n,o,s){try{return {ok:!0,bytes:this.decode(n,o,s)}}catch(a){return {ok:false,error:jw(a)}}},normalize(n,o,s){let a=this.get(n);return Pf(a,n,"normalize").call(a,o,s)},parse(n,o,s){let a=this.get(n);return Pf(a,n,"parse").call(a,o,s)},format(n,o,s){let a=this.get(n);return Pf(a,n,"format").call(a,o,s)},transcode(n,o){let s=this.decode(o.from,n,o.fromOptions);return this.encode(o.to,s,o.toOptions)},detect(n,o={}){let s=o.formats?.length?o.formats.map(c=>String(c)):this.list().map(c=>c.name).filter(c=>!["binary","utf8","utf16be","utf16le"].includes(Xr(c))),a=new Map;for(let c of s){let l=this.get(c),d=Xw(c,n,l);if(d<=0)continue;let u=l.name,h=a.get(u);(!h||d>h.confidence)&&a.set(u,{format:u,confidence:d});}return [...a.values()].sort((c,l)=>l.confidence-c.confidence)}};for(let n of t)i.register(n);return i}var U3={name:"binary",aliases:["latin1"],encode:vi.encode,decode:vi.decode,is:vi.is},F3={name:"hex",encode:tt.encode,decode:tt.decode,format:tt.format,is:tt.is,normalize:tt.normalize,parse:tt.parse},L3={name:"base64",aliases:["b64"],encode:er.encode,decode:er.decode,is:er.is,normalize:er.normalize},H3={name:"base64url",aliases:["base64-url","b64url"],encode:Er.encode,decode:Er.decode,is:Er.is,normalize:Er.normalize},K3={name:"utf8",aliases:["utf-8"],encode:t=>pn.decode(t),decode:t=>pn.encode(t),is:t=>typeof t=="string"},z3={name:"utf16be",aliases:["utf16","utf-16","utf-16be"],encode:t=>jr.decode(t),decode:t=>jr.encode(t),is:t=>typeof t=="string"},q3={name:"utf16le",aliases:["utf-16le","ucs2","usc2"],encode:t=>jr.decode(t,{littleEndian:true}),decode:t=>jr.encode(t,{littleEndian:true}),is:t=>typeof t=="string"},G3=[U3,F3,L3,H3,K3,z3,q3,m0];Nf(G3);({toBase64:er.encode,toBase64Url:Er.encode,toHex:tt.encode,toBinary:vi.encode,toUtf8String:pn.decode,isHex:tt.is,isBase64:er.is,isBase64Url:Er.is,formatString:er.normalize});var B;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice";})(B||(B={}));var S;(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",t[t.RelativeObjectIdentifier=28]="RelativeObjectIdentifier";})(S||(S={}));var Ei=class{constructor(e,r=0){f(this,"unusedBits",0);f(this,"value",new ArrayBuffer(0));if(e)if(typeof e=="number")this.fromNumber(e);else if(Vr(e))this.unusedBits=r,this.value=we(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof vr))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=we(e.valueBlock.valueHex),this}toASN(){return new vr({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new vr({name:e})}toNumber(){let e="",r=new Uint8Array(this.value);for(let i of r)e+=i.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),i=r.length+7>>3;this.unusedBits=(i<<3)-r.length;let n=new Uint8Array(i);r=r.padStart(i<<3,"0").split("").reverse().join("");let o=0;for(;o<i;)n[o]=parseInt(r.slice(o<<3,(o<<3)+8),2),o++;this.value=n.buffer;}};var ce=class{constructor(e){f(this,"buffer");typeof e=="number"?this.buffer=new ArrayBuffer(e):Vr(e)?this.buffer=we(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0);}get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}fromASN(e){if(!(e instanceof Ir))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=we(e.valueBlock.valueHex),this}toASN(){return new Ir({valueHex:this.buffer})}toSchema(e){return new Ir({name:e})}};var r_={fromASN:t=>t instanceof Cr?null:we(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new Cr;let e=Ii(t);if(e.result.error)throw new Error(e.result.error);return e.result}},i_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new _i({value:+t})},n_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new io({value:t})},he={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new _i({valueHex:t})};var o_={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new vr({valueHex:t})},s_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new no({value:t})},a_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new oo({value:t})},c_={fromASN:t=>t.valueBlock.value,toASN:t=>new ro({value:t})},_s={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new Ir({valueHex:t})},V3={fromASN:t=>new ce(t.getValue()),toASN:t=>t.toASN()};function tr(t){return {fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}var l_=tr(Jt),d_=tr(so),u_=tr(ao),f_=tr(co),p_=tr(lo),h_=tr(uo),m_=tr(fo),g_=tr(po),y_=tr(ho),b_=tr(un),S_=tr(mo),x_=tr(go),A_={fromASN:t=>t.toDate(),toASN:t=>new fn({valueDate:t})},w_={fromASN:t=>t.toDate(),toASN:t=>new yo({valueDate:t})},__={fromASN:()=>null,toASN:()=>new Cr};function mn(t){switch(t){case S.Any:return r_;case S.BitString:return o_;case S.BmpString:return d_;case S.Boolean:return c_;case S.CharacterString:return x_;case S.Enumerated:return n_;case S.GeneralString:return S_;case S.GeneralizedTime:return w_;case S.GraphicString:return y_;case S.IA5String:return g_;case S.Integer:return i_;case S.Null:return __;case S.NumericString:return f_;case S.ObjectIdentifier:return s_;case S.RelativeObjectIdentifier:return a_;case S.OctetString:return _s;case S.PrintableString:return p_;case S.TeletexString:return h_;case S.UTCTime:return A_;case S.UniversalString:return u_;case S.Utf8String:return l_;case S.VideotexString:return m_;case S.VisibleString:return b_;default:return null}}function rr(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?true:rr(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Mf(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?true:Mf(e)}return false}function j3(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return false;let r=new Uint8Array(t),i=new Uint8Array(e);for(let n=0;n<t.byteLength;n++)if(r[n]!==i[n])return false;return true}var ul=class{constructor(){f(this,"items",new WeakMap);}has(e){return this.items.has(e)}get(e,r=false){let i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(r&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){let r=this.get(e);r.schema||(r.schema=this.create(e,true));}createDefault(e){let r={type:B.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(r,i),r.items=Object.assign({},r.items,i.items)),r}create(e,r){let i=this.items.get(e)||this.createDefault(e),n=[];for(let o in i.items){let s=i.items[o],a=r?o:"",c;if(typeof s.type=="number"){let d=S[s.type],u=$r[d];if(!u)throw new Error(`Cannot get ASN1 class by name '${d}'`);c=new u({name:a});}else rr(s.type)?c=new s.type().toSchema(a):s.optional?this.get(s.type).type===B.Choice?c=new zr({name:a}):(c=this.create(s.type,false),c.name=a):c=new zr({name:a});let l=!!s.optional||s.defaultValue!==void 0;if(s.repeated){c.name="";let d=s.repeated==="set"?bt:ft;c=new d({name:"",value:[new bo({name:a,value:c})]});}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||rr(s.type)){let d=s.repeated?$e:wi;n.push(new d({name:a,optional:l,idBlock:{tagClass:3,tagNumber:s.context}}));}else {this.cache(s.type);let d=!!s.repeated,u=d?c:this.get(s.type,true).schema;u="valueBlock"in u?u.valueBlock.value:u.value,n.push(new $e({name:d?"":a,optional:l,idBlock:{tagClass:3,tagNumber:s.context},value:u}));}else n.push(new $e({optional:l,idBlock:{tagClass:3,tagNumber:s.context},value:[c]}));else c.optional=l,n.push(c);}switch(i.type){case B.Sequence:return new ft({value:n,name:""});case B.Set:return new bt({value:n,name:""});case B.Choice:return new ws({value:n,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}};var Ve=new ul;var N=t=>e=>{let r;Ve.has(e)?r=Ve.get(e):(r=Ve.createDefault(e),Ve.set(e,r)),Object.assign(r,t);};var g=t=>(e,r)=>{let i;Ve.has(e.constructor)?i=Ve.get(e.constructor):(i=Ve.createDefault(e.constructor),Ve.set(e.constructor,i));let n=Object.assign({},t);if(typeof n.type=="number"&&!n.converter){let o=mn(t.type);if(!o)throw new Error(`Cannot get default converter for property '${r}' of ${e.constructor.name}`);n.converter=o;}n.raw=t.raw,i.items[r]=n;};var gn=class extends Error{constructor(){super(...arguments);f(this,"schemas",[]);}};var Cs=class{static parse(e,r,i){let n=Ii(we(e),i?.berOptions);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,r,i)}static fromASN(e,r,i){try{if(rr(r))return new r().fromASN(e);let n=Ve.get(r);Ve.cache(r);let o=n.schema,s=this.handleChoiceTypes(e,n,r,o,i);if(s?.result)return s.result;s?.targetSchema&&(o=s.targetSchema);let a=this.handleSequenceTypes(e,n,r,o),c=new r;return Mf(r)?this.handleArrayTypes(e,n,r,i):(this.processSchemaItems(n,a,c,i),c)}catch(n){throw n instanceof gn&&n.schemas.push(r.name),n}}static handleChoiceTypes(e,r,i,n,o){if(e.constructor===$e&&r.type===B.Choice&&e.idBlock.tagClass===3)for(let s in r.items){let a=r.items[s];if(a.context===e.idBlock.tagNumber&&a.implicit&&typeof a.type=="function"&&Ve.has(a.type)){let c=Ve.get(a.type);if(c&&c.type===B.Sequence){let l=new ft;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in l.valueBlock){l.valueBlock.value=e.valueBlock.value;let d=this.fromASN(l,a.type,o),u=new i;return u[s]=d,{result:u}}}}}else if(e.constructor===$e&&r.type!==B.Choice){let s=new $e({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(let a in r.items)delete e[a];return {targetSchema:s}}return null}static handleSequenceTypes(e,r,i,n){if(r.type===B.Sequence){let o=xi({},e,n);if(!o.verified)throw new gn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else {let o=xi({},e,n);if(!o.verified)throw new gn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}}static processRepeatedField(e,r,i){let n=e.slice(r);if(n.length===1&&n[0].constructor.name==="Sequence"){let o=n[0];o.valueBlock&&o.valueBlock.value&&Array.isArray(o.valueBlock.value)&&(n=o.valueBlock.value);}if(typeof i.type=="number"){let o=mn(i.type);if(!o)throw new Error(`No converter for ASN.1 type ${i.type}`);return n.filter(s=>s&&s.valueBlock).map(s=>{try{return o.fromASN(s)}catch{return}}).filter(s=>s!==void 0)}else return n.filter(o=>o&&o.valueBlock).map(o=>{try{return this.fromASN(o,i.type)}catch{return}}).filter(o=>o!==void 0)}static processPrimitiveField(e,r){let i=mn(r.type);if(!i)throw new Error(`No converter for ASN.1 type ${r.type}`);return i.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Ve.has(e.type)&&Ve.get(e.type).type===B.Choice}static processOptionalChoiceField(e,r){try{return {processed:!0,value:this.fromASN(e,r.type)}}catch(i){if(i instanceof gn&&/Wrong values for Choice type/.test(i.message))return {processed:false};throw i}}static handleArrayTypes(e,r,i,n){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 o=r.itemType;if(typeof o=="number"){let s=mn(o);if(!s)throw new Error(`Cannot get default converter for array item of ${i.name} ASN1 schema`);return i.from(e.valueBlock.value,a=>s.fromASN(a))}else return i.from(e.valueBlock.value,s=>this.fromASN(s,o,n))}static processSchemaItems(e,r,i,n){for(let o in e.items){let s=r.result[o];if(!s)continue;let a=e.items[o],c=a.type,l;typeof c=="number"||rr(c)?l=this.processPrimitiveSchemaItem(s,a,c,n):l=this.processComplexSchemaItem(s,a,c,n),l&&typeof l=="object"&&"value"in l&&"raw"in l?(i[o]=l.value,i[`${o}Raw`]=l.raw):i[o]=l;}}static processPrimitiveSchemaItem(e,r,i,n){let o=r.converter??(rr(i)?new i:null);if(!o)throw new Error("Converter is empty");return r.repeated?this.processRepeatedPrimitiveItem(e,r,o,n):this.processSinglePrimitiveItem(e,r,i,o,n)}static processRepeatedPrimitiveItem(e,r,i,n){if(r.implicit){let o=r.repeated==="sequence"?ft:bt,s=new o;s.valueBlock=e.valueBlock;let a=Ii(s.toBER(false),n?.berOptions);if(a.offset===-1)throw new Error(`Cannot parse the child item. ${a.result.error}`);if(!("value"in a.result.valueBlock&&Array.isArray(a.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let c=a.result.valueBlock.value;return Array.from(c,l=>i.fromASN(l))}else return Array.from(e,o=>i.fromASN(o))}static processSinglePrimitiveItem(e,r,i,n,o){let s=e;if(r.implicit){let a;if(rr(i))a=new i().toSchema("");else {let c=S[i],l=$r[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);a=new l;}a.valueBlock=s.valueBlock,s=Ii(a.toBER(false),o?.berOptions).result;}return n.fromASN(s)}static processComplexSchemaItem(e,r,i,n){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,o=>this.fromASN(o,i,n))}else {let o=this.handleImplicitTagging(e,r,i);if(this.isOptionalChoiceField(r))try{return this.fromASN(o,i,n)}catch(s){if(s instanceof gn&&/Wrong values for Choice type/.test(s.message))return;throw s}else {let s=this.fromASN(o,i,n);return r.raw?{value:s,raw:e.valueBeforeDecodeView}:s}}}static handleImplicitTagging(e,r,i){if(r.implicit&&typeof r.context=="number"){let n=Ve.get(i);if(n.type===B.Sequence){let o=new ft;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}else if(n.type===B.Set){let o=new bt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}}return e}};var Is=class t{static serialize(e){return e instanceof Ke?e.toBER(false):this.toASN(e).toBER(false)}static toASN(e){if(e&&typeof e=="object"&&rr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let r=e.constructor,i=Ve.get(r);Ve.cache(r);let n=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){let s=mn(i.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);n=e.map(a=>s.toASN(a));}else n=e.map(s=>this.toAsnItem({type:i.itemType},"[]",r,s));}else for(let s in i.items){let a=i.items[s],c=e[s];if(c===void 0||a.defaultValue===c||typeof a.defaultValue=="object"&&typeof c=="object"&&j3(this.serialize(a.defaultValue),this.serialize(c)))continue;let l=t.toAsnItem(a,s,r,c);if(typeof a.context=="number")if(a.implicit)if(!a.repeated&&(typeof a.type=="number"||rr(a.type))){let d={};d.valueHex=l instanceof Cr?we(l.valueBeforeDecodeView):l.valueBlock.toBER(),n.push(new wi({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...d}));}else n.push(new $e({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:l.valueBlock.value}));else n.push(new $e({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else a.repeated?n=n.concat(l):n.push(l);}let o;switch(i.type){case B.Sequence:o=new ft({value:n});break;case B.Set:o=new bt({value:n});break;case B.Choice:if(!n[0])throw new Error(`Schema '${r.name}' has wrong data. Choice cannot be empty.`);o=n[0];break}return o}static toAsnItem(e,r,i,n){let o;if(typeof e.type=="number"){let s=e.converter;if(!s)throw new Error(`Property '${r}' doesn't have converter for type ${S[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(n,l=>s.toASN(l)),c=e.repeated==="sequence"?ft:bt;o=new c({value:a});}else o=s.toASN(n);}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");let s=Array.from(n,c=>this.toASN(c)),a=e.repeated==="sequence"?ft:bt;o=new a({value:s});}else o=this.toASN(n);return o}};var ie=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else {super();for(let r of e)this.push(r);}}};var ir=class t{static serialize(e){return Is.serialize(e)}static parse(e,r,i){return Cs.parse(e,r,i)}static toString(e,r){let i=Vr(e)?we(e):t.serialize(e),n=Ii(i,r?.berOptions);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function p(t,e,r,i){var n=arguments.length,o=n<3?e:i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,r,o):s(e,r))||o);return n>3&&o&&Object.defineProperty(e,r,o),o}var g0=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(i=>{let n=parseInt(i,10);if(isNaN(n)||n<0||n>255)throw new Error("Invalid IPv4 address part");return n})}static parseIPv6(e){let i=this.expandIPv6(e).split(":");if(i.length!==8)throw new Error("Invalid IPv6 address");return i.reduce((n,o)=>{let s=parseInt(o,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return n.push(s>>8&255),n.push(s&255),n},[])}static expandIPv6(e){if(!e.includes("::"))return e;let r=e.split("::");if(r.length>2)throw new Error("Invalid IPv6 address");let i=r[0]?r[0].split(":"):[],n=r[1]?r[1].split(":"):[],o=8-(i.length+n.length);if(o<0)throw new Error("Invalid IPv6 address");return [...i,...Array(o).fill("0"),...n].join(":")}static formatIPv6(e){let r=[];for(let i=0;i<16;i+=2)r.push((e[i]<<8|e[i+1]).toString(16));return this.compressIPv6(r.join(":"))}static compressIPv6(e){let r=e.split(":"),i=-1,n=0,o=-1,s=0;for(let a=0;a<r.length;a++)r[a]==="0"?(o===-1&&(o=a),s++):(s>n&&(i=o,n=s),o=-1,s=0);if(s>n&&(i=o,n=s),n>1){let a=r.slice(0,i).join(":"),c=r.slice(i+n).join(":");return `${a}::${c}`}return e}static parseCIDR(e){let[r,i]=e.split("/"),n=parseInt(i,10);if(this.isIPv4(r)){if(n<0||n>32)throw new Error("Invalid IPv4 prefix length");return [this.parseIPv4(r),n]}else {if(n<0||n>128)throw new Error("Invalid IPv6 prefix length");return [this.parseIPv6(r),n]}}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((n,o)=>n+ +o,0),i=e.slice(0,8).replace(/(.{2})/g,n=>`${parseInt(n,16)}.`);return i=i.slice(0,-1),`${i}/${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 i=r.length/2,n=r.slice(0,i),o=r.slice(i);if(r.every(c=>c===0))return r.length===8?"0.0.0.0/0":"::/0";let a=o.reduce((c,l)=>c+(l.toString(2).match(/1/g)||[]).length,0);return r.length===8?`${Array.from(n).join(".")}/${a}`:`${this.formatIPv6(n)}/${a}`}return this.decodeIP(tt.encode(e))}static fromString(e){if(e.includes("/")){let[i,n]=this.parseCIDR(e),o=new Uint8Array(i.length),s=n;for(let c=0;c<o.length;c++)s>=8?(o[c]=255,s-=8):s>0&&(o[c]=255<<8-s,s=0);let a=new Uint8Array(i.length*2);return a.set(i,0),a.set(o,i.length),a.buffer}let r=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(r).buffer}};var Uf,Ff,Lf,nr=class{constructor(e={}){f(this,"teletexString");f(this,"printableString");f(this,"universalString");f(this,"utf8String");f(this,"bmpString");Object.assign(this,e);}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};p([g({type:S.TeletexString})],nr.prototype,"teletexString",void 0);p([g({type:S.PrintableString})],nr.prototype,"printableString",void 0);p([g({type:S.UniversalString})],nr.prototype,"universalString",void 0);p([g({type:S.Utf8String})],nr.prototype,"utf8String",void 0);p([g({type:S.BmpString})],nr.prototype,"bmpString",void 0);nr=p([N({type:B.Choice})],nr);var vs=class extends nr{constructor(r={}){super(r);f(this,"ia5String");f(this,"anyValue");Object.assign(this,r);}toString(){return this.ia5String||(this.anyValue?tt.encode(this.anyValue):super.toString())}};p([g({type:S.IA5String})],vs.prototype,"ia5String",void 0);p([g({type:S.Any})],vs.prototype,"anyValue",void 0);vs=p([N({type:B.Choice})],vs);var y0=class{constructor(e={}){f(this,"type","");f(this,"value",new vs);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],y0.prototype,"type",void 0);p([g({type:vs})],y0.prototype,"value",void 0);var b0=Uf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Uf.prototype);}};b0=Uf=p([N({type:B.Set,itemType:y0})],b0);var Hf=Ff=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ff.prototype);}};Hf=Ff=p([N({type:B.Sequence,itemType:b0})],Hf);var xt=Lf=class extends Hf{constructor(e){super(e),Object.setPrototypeOf(this,Lf.prototype);}};xt=Lf=p([N({type:B.Sequence})],xt);var C_={fromASN:t=>g0.toString(_s.fromASN(t)),toASN:t=>_s.toASN(g0.fromString(t))},S0=class{constructor(e={}){f(this,"typeId","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],S0.prototype,"typeId",void 0);p([g({type:S.Any,context:0})],S0.prototype,"value",void 0);var x0=class{constructor(e={}){f(this,"nameAssigner");f(this,"partyName",new nr);Object.assign(this,e);}};p([g({type:nr,optional:true,context:0,implicit:true})],x0.prototype,"nameAssigner",void 0);p([g({type:nr,context:1,implicit:true})],x0.prototype,"partyName",void 0);var ue=class{constructor(e={}){f(this,"otherName");f(this,"rfc822Name");f(this,"dNSName");f(this,"x400Address");f(this,"directoryName");f(this,"ediPartyName");f(this,"uniformResourceIdentifier");f(this,"iPAddress");f(this,"registeredID");Object.assign(this,e);}};p([g({type:S0,context:0,implicit:true})],ue.prototype,"otherName",void 0);p([g({type:S.IA5String,context:1,implicit:true})],ue.prototype,"rfc822Name",void 0);p([g({type:S.IA5String,context:2,implicit:true})],ue.prototype,"dNSName",void 0);p([g({type:S.Any,context:3,implicit:true})],ue.prototype,"x400Address",void 0);p([g({type:xt,context:4,implicit:false})],ue.prototype,"directoryName",void 0);p([g({type:x0,context:5})],ue.prototype,"ediPartyName",void 0);p([g({type:S.IA5String,context:6,implicit:true})],ue.prototype,"uniformResourceIdentifier",void 0);p([g({type:S.OctetString,context:7,implicit:true,converter:C_})],ue.prototype,"iPAddress",void 0);p([g({type:S.ObjectIdentifier,context:8,implicit:true})],ue.prototype,"registeredID",void 0);ue=p([N({type:B.Choice})],ue);var Kf,xo=class{constructor(e={}){f(this,"accessMethod","");f(this,"accessLocation",new ue);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],xo.prototype,"accessMethod",void 0);p([g({type:ue})],xo.prototype,"accessLocation",void 0);var W3=Kf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Kf.prototype);}};W3=Kf=p([N({type:B.Sequence,itemType:xo})],W3);var A0=class extends ce{},Es=class{constructor(e={}){f(this,"keyIdentifier");f(this,"authorityCertIssuer");f(this,"authorityCertSerialNumber");e&&Object.assign(this,e);}};p([g({type:A0,context:0,optional:true,implicit:true})],Es.prototype,"keyIdentifier",void 0);p([g({type:ue,context:1,optional:true,implicit:true,repeated:"sequence"})],Es.prototype,"authorityCertIssuer",void 0);p([g({type:S.Integer,context:2,optional:true,implicit:true,converter:he})],Es.prototype,"authorityCertSerialNumber",void 0);var pl=class{constructor(e={}){f(this,"cA",false);f(this,"pathLenConstraint");Object.assign(this,e);}};p([g({type:S.Boolean,defaultValue:false})],pl.prototype,"cA",void 0);p([g({type:S.Integer,optional:true})],pl.prototype,"pathLenConstraint",void 0);var zf,Xe=zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,zf.prototype);}};Xe=zf=p([N({type:B.Sequence,itemType:ue})],Xe);var qf,Z3=qf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,qf.prototype);}};Z3=qf=p([N({type:B.Sequence})],Z3);var Gf,Bi=class{constructor(e={}){f(this,"ia5String");f(this,"visibleString");f(this,"bmpString");f(this,"utf8String");Object.assign(this,e);}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};p([g({type:S.IA5String})],Bi.prototype,"ia5String",void 0);p([g({type:S.VisibleString})],Bi.prototype,"visibleString",void 0);p([g({type:S.BmpString})],Bi.prototype,"bmpString",void 0);p([g({type:S.Utf8String})],Bi.prototype,"utf8String",void 0);Bi=p([N({type:B.Choice})],Bi);var w0=class{constructor(e={}){f(this,"organization",new Bi);f(this,"noticeNumbers",[]);Object.assign(this,e);}};p([g({type:Bi})],w0.prototype,"organization",void 0);p([g({type:S.Integer,repeated:"sequence"})],w0.prototype,"noticeNumbers",void 0);var _0=class{constructor(e={}){f(this,"noticeRef");f(this,"explicitText");Object.assign(this,e);}};p([g({type:w0,optional:true})],_0.prototype,"noticeRef",void 0);p([g({type:Bi,optional:true})],_0.prototype,"explicitText",void 0);var hl=class{constructor(e={}){f(this,"cPSuri");f(this,"userNotice");Object.assign(this,e);}};p([g({type:S.IA5String})],hl.prototype,"cPSuri",void 0);p([g({type:_0})],hl.prototype,"userNotice",void 0);hl=p([N({type:B.Choice})],hl);var C0=class{constructor(e={}){f(this,"policyQualifierId","");f(this,"qualifier",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],C0.prototype,"policyQualifierId",void 0);p([g({type:S.Any})],C0.prototype,"qualifier",void 0);var I0=class{constructor(e={}){f(this,"policyIdentifier","");f(this,"policyQualifiers");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],I0.prototype,"policyIdentifier",void 0);p([g({type:C0,repeated:"sequence",optional:true})],I0.prototype,"policyQualifiers",void 0);var Y3=Gf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Gf.prototype);}};Y3=Gf=p([N({type:B.Sequence,itemType:I0})],Y3);var v0=class{constructor(e=0){f(this,"value");this.value=e;}};p([g({type:S.Integer})],v0.prototype,"value",void 0);v0=p([N({type:B.Choice})],v0);var Q3=class extends v0{};Q3=p([N({type:B.Choice})],Q3);var $f,Br;(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";})(Br||(Br={}));var E0=class extends Ei{toJSON(){let e=[],r=this.toNumber();return r&Br.aACompromise&&e.push("aACompromise"),r&Br.affiliationChanged&&e.push("affiliationChanged"),r&Br.cACompromise&&e.push("cACompromise"),r&Br.certificateHold&&e.push("certificateHold"),r&Br.cessationOfOperation&&e.push("cessationOfOperation"),r&Br.keyCompromise&&e.push("keyCompromise"),r&Br.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Br.superseded&&e.push("superseded"),r&Br.unused&&e.push("unused"),e}toString(){return `[${this.toJSON().join(", ")}]`}},Ao=class{constructor(e={}){f(this,"fullName");f(this,"nameRelativeToCRLIssuer");Object.assign(this,e);}};p([g({type:ue,context:0,repeated:"sequence",implicit:true})],Ao.prototype,"fullName",void 0);p([g({type:b0,context:1,implicit:true})],Ao.prototype,"nameRelativeToCRLIssuer",void 0);Ao=p([N({type:B.Choice})],Ao);var Sn=class{constructor(e={}){f(this,"distributionPoint");f(this,"reasons");f(this,"cRLIssuer");Object.assign(this,e);}};p([g({type:Ao,context:0,optional:true})],Sn.prototype,"distributionPoint",void 0);p([g({type:E0,context:1,optional:true,implicit:true})],Sn.prototype,"reasons",void 0);p([g({type:ue,context:2,optional:true,repeated:"sequence",implicit:true})],Sn.prototype,"cRLIssuer",void 0);var ml=$f=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,$f.prototype);}};ml=$f=p([N({type:B.Sequence,itemType:Sn})],ml);var Vf,J3=Vf=class extends ml{constructor(e){super(e),Object.setPrototypeOf(this,Vf.prototype);}};J3=Vf=p([N({type:B.Sequence,itemType:Sn})],J3);var wo=class wo{constructor(e={}){f(this,"distributionPoint");f(this,"onlyContainsUserCerts",wo.ONLY);f(this,"onlyContainsCACerts",wo.ONLY);f(this,"onlySomeReasons");f(this,"indirectCRL",wo.ONLY);f(this,"onlyContainsAttributeCerts",wo.ONLY);Object.assign(this,e);}};f(wo,"ONLY",false);var or=wo;p([g({type:Ao,context:0,optional:true})],or.prototype,"distributionPoint",void 0);p([g({type:S.Boolean,context:1,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsUserCerts",void 0);p([g({type:S.Boolean,context:2,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsCACerts",void 0);p([g({type:E0,context:3,optional:true,implicit:true})],or.prototype,"onlySomeReasons",void 0);p([g({type:S.Boolean,context:4,defaultValue:or.ONLY,implicit:true})],or.prototype,"indirectCRL",void 0);p([g({type:S.Boolean,context:5,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsAttributeCerts",void 0);var B0;(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";})(B0||(B0={}));var jf=class{constructor(e=B0.unspecified){f(this,"reason",B0.unspecified);this.reason=e;}toJSON(){return B0[this.reason]}toString(){return this.toJSON()}};p([g({type:S.Enumerated})],jf.prototype,"reason",void 0);jf=p([N({type:B.Choice})],jf);var Xf,e4=Xf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Xf.prototype);}};e4=Xf=p([N({type:B.Sequence,itemType:S.ObjectIdentifier})],e4);var Wf=class{constructor(e=new ArrayBuffer(0)){f(this,"value");this.value=e;}};p([g({type:S.Integer,converter:he})],Wf.prototype,"value",void 0);Wf=p([N({type:B.Choice})],Wf);var Zf=class{constructor(e){f(this,"value",new Date);e&&(this.value=e);}};p([g({type:S.GeneralizedTime})],Zf.prototype,"value",void 0);Zf=p([N({type:B.Choice})],Zf);var Yf,t4=Yf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Yf.prototype);}};t4=Yf=p([N({type:B.Sequence})],t4);var r4;(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";})(r4||(r4={}));var Qf,Bs=class{constructor(e={}){f(this,"base",new ue);f(this,"minimum",0);f(this,"maximum");Object.assign(this,e);}};p([g({type:ue})],Bs.prototype,"base",void 0);p([g({type:S.Integer,context:0,defaultValue:0,implicit:true})],Bs.prototype,"minimum",void 0);p([g({type:S.Integer,context:1,optional:true,implicit:true})],Bs.prototype,"maximum",void 0);var gl=Qf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Qf.prototype);}};gl=Qf=p([N({type:B.Sequence,itemType:Bs})],gl);var yl=class{constructor(e={}){f(this,"permittedSubtrees");f(this,"excludedSubtrees");Object.assign(this,e);}};p([g({type:gl,context:0,optional:true,implicit:true})],yl.prototype,"permittedSubtrees",void 0);p([g({type:gl,context:1,optional:true,implicit:true})],yl.prototype,"excludedSubtrees",void 0);var bl=class{constructor(e={}){f(this,"requireExplicitPolicy");f(this,"inhibitPolicyMapping");Object.assign(this,e);}};p([g({type:S.Integer,context:0,implicit:true,optional:true,converter:he})],bl.prototype,"requireExplicitPolicy",void 0);p([g({type:S.Integer,context:1,implicit:true,optional:true,converter:he})],bl.prototype,"inhibitPolicyMapping",void 0);var Jf,T0=class{constructor(e={}){f(this,"issuerDomainPolicy","");f(this,"subjectDomainPolicy","");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],T0.prototype,"issuerDomainPolicy",void 0);p([g({type:S.ObjectIdentifier})],T0.prototype,"subjectDomainPolicy",void 0);var i4=Jf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Jf.prototype);}};i4=Jf=p([N({type:B.Sequence,itemType:T0})],i4);var ep,n4=ep=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,ep.prototype);}};n4=ep=p([N({type:B.Sequence})],n4);var Zr=class{constructor(e={}){f(this,"type","");f(this,"values",[]);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Zr.prototype,"type",void 0);p([g({type:S.Any,repeated:"set"})],Zr.prototype,"values",void 0);var tp,o4=tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,tp.prototype);}};o4=tp=p([N({type:B.Sequence,itemType:Zr})],o4);var Tr=class extends A0{};var k0=class{constructor(e={}){f(this,"notBefore");f(this,"notAfter");Object.assign(this,e);}};p([g({type:S.GeneralizedTime,context:0,implicit:true,optional:true})],k0.prototype,"notBefore",void 0);p([g({type:S.GeneralizedTime,context:1,implicit:true,optional:true})],k0.prototype,"notAfter",void 0);var P0;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate";})(P0||(P0={}));var Sl=class extends Ei{toJSON(){let e=[],r=this.toNumber();return r&P0.pKIXCertificate&&e.push("pKIXCertificate"),r&P0.newExtensions&&e.push("newExtensions"),r&P0.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return `[${this.toJSON().join(", ")}]`}},xl=class{constructor(e={}){f(this,"entrustVers","");f(this,"entrustInfoFlags",new Sl);Object.assign(this,e);}};p([g({type:S.GeneralString})],xl.prototype,"entrustVers",void 0);p([g({type:Sl})],xl.prototype,"entrustInfoFlags",void 0);var rp,s4=rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,rp.prototype);}};s4=rp=p([N({type:B.Sequence,itemType:xo})],s4);var J=class t{constructor(e={}){f(this,"algorithm","");f(this,"parameters");Object.assign(this,e);}isEqual(e){return e instanceof t&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&p0(e.parameters,this.parameters)||e.parameters===this.parameters)}};p([g({type:S.ObjectIdentifier})],J.prototype,"algorithm",void 0);p([g({type:S.Any,optional:true})],J.prototype,"parameters",void 0);var _o=class{constructor(e={}){f(this,"algorithm",new J);f(this,"subjectPublicKey",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:J})],_o.prototype,"algorithm",void 0);p([g({type:S.BitString})],_o.prototype,"subjectPublicKey",void 0);var je=class{constructor(e){f(this,"utcTime");f(this,"generalTime");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}};p([g({type:S.UTCTime})],je.prototype,"utcTime",void 0);p([g({type:S.GeneralizedTime})],je.prototype,"generalTime",void 0);je=p([N({type:B.Choice})],je);var Co=class{constructor(e){f(this,"notBefore",new je(new Date));f(this,"notAfter",new je(new Date));e&&(this.notBefore=new je(e.notBefore),this.notAfter=new je(e.notAfter));}};p([g({type:je})],Co.prototype,"notBefore",void 0);p([g({type:je})],Co.prototype,"notAfter",void 0);var ip,Al=class Al{constructor(e={}){f(this,"extnID","");f(this,"critical",Al.CRITICAL);f(this,"extnValue",new ce);Object.assign(this,e);}};f(Al,"CRITICAL",false);var Yr=Al;p([g({type:S.ObjectIdentifier})],Yr.prototype,"extnID",void 0);p([g({type:S.Boolean,defaultValue:Yr.CRITICAL})],Yr.prototype,"critical",void 0);p([g({type:ce})],Yr.prototype,"extnValue",void 0);var Ts=ip=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,ip.prototype);}};Ts=ip=p([N({type:B.Sequence,itemType:Yr})],Ts);var N0;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3";})(N0||(N0={}));var At=class{constructor(e={}){f(this,"version",N0.v1);f(this,"serialNumber",new ArrayBuffer(0));f(this,"signature",new J);f(this,"issuer",new xt);f(this,"validity",new Co);f(this,"subject",new xt);f(this,"subjectPublicKeyInfo",new _o);f(this,"issuerUniqueID");f(this,"subjectUniqueID");f(this,"extensions");Object.assign(this,e);}};p([g({type:S.Integer,context:0,defaultValue:N0.v1})],At.prototype,"version",void 0);p([g({type:S.Integer,converter:he})],At.prototype,"serialNumber",void 0);p([g({type:J})],At.prototype,"signature",void 0);p([g({type:xt})],At.prototype,"issuer",void 0);p([g({type:Co})],At.prototype,"validity",void 0);p([g({type:xt})],At.prototype,"subject",void 0);p([g({type:_o})],At.prototype,"subjectPublicKeyInfo",void 0);p([g({type:S.BitString,context:1,implicit:true,optional:true})],At.prototype,"issuerUniqueID",void 0);p([g({type:S.BitString,context:2,implicit:true,optional:true})],At.prototype,"subjectUniqueID",void 0);p([g({type:Ts,context:3,optional:true})],At.prototype,"extensions",void 0);var $t=class{constructor(e={}){f(this,"tbsCertificate",new At);f(this,"tbsCertificateRaw");f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:At,raw:true})],$t.prototype,"tbsCertificate",void 0);p([g({type:J})],$t.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],$t.prototype,"signatureValue",void 0);var ks=class{constructor(e={}){f(this,"userCertificate",new ArrayBuffer(0));f(this,"revocationDate",new je);f(this,"crlEntryExtensions");Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],ks.prototype,"userCertificate",void 0);p([g({type:je})],ks.prototype,"revocationDate",void 0);p([g({type:Yr,optional:true,repeated:"sequence"})],ks.prototype,"crlEntryExtensions",void 0);var sr=class{constructor(e={}){f(this,"version");f(this,"signature",new J);f(this,"issuer",new xt);f(this,"thisUpdate",new je);f(this,"nextUpdate");f(this,"revokedCertificates");f(this,"crlExtensions");Object.assign(this,e);}};p([g({type:S.Integer,optional:true})],sr.prototype,"version",void 0);p([g({type:J})],sr.prototype,"signature",void 0);p([g({type:xt})],sr.prototype,"issuer",void 0);p([g({type:je})],sr.prototype,"thisUpdate",void 0);p([g({type:je,optional:true})],sr.prototype,"nextUpdate",void 0);p([g({type:ks,repeated:"sequence",optional:true})],sr.prototype,"revokedCertificates",void 0);p([g({type:Yr,optional:true,context:0,repeated:"sequence"})],sr.prototype,"crlExtensions",void 0);var R0=class{constructor(e={}){f(this,"tbsCertList",new sr);f(this,"tbsCertListRaw");f(this,"signatureAlgorithm",new J);f(this,"signature",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:sr,raw:true})],R0.prototype,"tbsCertList",void 0);p([g({type:J})],R0.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],R0.prototype,"signature",void 0);var D0=class{constructor(e){this.zero=BigInt(0),this.one=BigInt(1),this.prime=e;}e(e){return typeof e=="bigint"?e%this.prime:BigInt(e)%this.prime}add(e,r){return (e+r)%this.prime}sub(e,r){return (this.prime+e-r)%this.prime}mul(e,r){return e*r%this.prime}square(e){return e*e%this.prime}div(e,r){return e/r%this.prime}};var O0=class{constructor(e,r){this.params=e,this.primeField=r;}getT(){return this.params.t}sbox(e){return e.map(r=>this.sboxP(r))}sboxP(e){let r=this.primeField.square(e);if(this.params.d==3)return this.primeField.mul(r,e);if(this.params.d==5)return this.primeField.mul(this.primeField.square(r),e);if(this.params.d==7)return this.primeField.mul(this.primeField.square(r),this.primeField.mul(r,e));throw new Error("Invalid d paramter, must be 3, 5 or 7")}matmulExternal(e){let r=this.params.t;if(r==2){let i=this.primeField.add(e[0],e[1]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i);}else if(r==3){let i=this.primeField.add(this.primeField.add(e[0],e[1]),e[2]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i),e[2]=this.primeField.add(e[2],i);}else if(r==4||r==8||r==12||r==16||r==20||r==24){let i=r/4;for(let n=0;n<i;n++){let o=n*4,s=e[o];s=this.primeField.add(s,e[o+1]);let a=e[o+2];a=this.primeField.add(a,e[o+3]);let c=e[o+1];c=this.primeField.add(c,c),c=this.primeField.add(c,a);let l=e[o+3];l=this.primeField.add(l,l),l=this.primeField.add(l,s);let d=a;d=this.primeField.add(d,d),d=this.primeField.add(d,d),d=this.primeField.add(d,l);let u=s;u=this.primeField.add(u,u),u=this.primeField.add(u,u),u=this.primeField.add(u,c);let h=l;h=this.primeField.add(h,u);let m=c;m=this.primeField.add(m,d),e[o]=h,e[o+1]=u,e[o+2]=m,e[o+3]=d;}if(r>4){let n=[this.primeField.zero,this.primeField.zero,this.primeField.zero,this.primeField.zero];for(let o=0;o<4;o++){n[o]=e[o];for(let s=1;s<i;s++)n[o]=this.primeField.add(n[o],e[4*s+o]);}for(let o=0;o<e.length;o++)e[o]=this.primeField.add(e[o],n[o%4]);}}else throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");return e}matmulInternal(e){let r=this.params.t;if(r==2){let i=this.primeField.add(e[0],e[1]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(this.primeField.add(e[1],e[1]),i);}else if(r==3){let i=this.primeField.add(this.primeField.add(e[0],e[1]),e[2]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i),e[2]=this.primeField.add(this.primeField.add(e[2],e[2]),i);}else if(r==4||r==8||r==12||r==16||r==20||r==24){let i=e[0];for(let n=1;n<r;n++)i=this.primeField.add(i,e[n]);for(let n=0;n<e.length;n++)e[n]=this.primeField.add(this.primeField.mul(this.params.mat_internal_diag_m_1[n],e[n]),i);}else throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");return e}permute(e){let r=this.params.t;if(e.length!=r)throw new Error("Invalid input length");let i=e;this.matmulExternal(i);for(let o=0;o<this.params.rounds_f_beginning;o++)i=this.addRc(i,this.params.round_constants[o]),i=this.sbox(i),this.matmulExternal(i);let n=this.params.rounds_f_beginning+this.params.rounds_p;for(let o=this.params.rounds_f_beginning;o<n;o++)i[0]=this.primeField.add(i[0],this.params.round_constants[o][0]),i[0]=this.sboxP(i[0]),this.matmulInternal(i);for(let o=n;o<this.params.rounds;o++)i=this.addRc(i,this.params.round_constants[o]),i=this.sbox(i),this.matmulExternal(i);return i}addRc(e,r){return e.map((i,n)=>this.primeField.add(i,r[n]))}};function np(t,e,r,i,n,o,s){let a=r/2,c=r+i;return {t,d:e,rounds_f_beginning:a,rounds_p:i,rounds_f_end:a,rounds:c,mat_internal_diag_m_1:n,_mat_internal:o,round_constants:s}}var a4=[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")],c4=[[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e8"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428c")]],l4=[[BigInt("0x19b849f69450b06848da1d39bd5e4a4302bb86744edc26238b0878e269ed23e5"),BigInt("0x265ddfe127dd51bd7239347b758f0a1320eb2cc7450acc1dad47f80c8dcf34d6"),BigInt("0x199750ec472f1809e0f66a545e1e51624108ac845015c2aa3dfc36bab497d8aa"),BigInt("0x157ff3fe65ac7208110f06a5f74302b14d743ea25067f0ffd032f787c7f1cdf8")],[BigInt("0x2e49c43c4569dd9c5fd35ac45fca33f10b15c590692f8beefe18f4896ac94902"),BigInt("0x0e35fb89981890520d4aef2b6d6506c3cb2f0b6973c24fa82731345ffa2d1f1e"),BigInt("0x251ad47cb15c4f1105f109ae5e944f1ba9d9e7806d667ffec6fe723002e0b996"),BigInt("0x13da07dc64d428369873e97160234641f8beb56fdd05e5f3563fa39d9c22df4e")],[BigInt("0x0c009b84e650e6d23dc00c7dccef7483a553939689d350cd46e7b89055fd4738"),BigInt("0x011f16b1c63a854f01992e3956f42d8b04eb650c6d535eb0203dec74befdca06"),BigInt("0x0ed69e5e383a688f209d9a561daa79612f3f78d0467ad45485df07093f367549"),BigInt("0x04dba94a7b0ce9e221acad41472b6bbe3aec507f5eb3d33f463672264c9f789b")],[BigInt("0x0a3f2637d840f3a16eb094271c9d237b6036757d4bb50bf7ce732ff1d4fa28e8"),BigInt("0x259a666f129eea198f8a1c502fdb38fa39b1f075569564b6e54a485d1182323f"),BigInt("0x28bf7459c9b2f4c6d8e7d06a4ee3a47f7745d4271038e5157a32fdf7ede0d6a1"),BigInt("0x0a1ca941f057037526ea200f489be8d4c37c85bbcce6a2aeec91bd6941432447")],[BigInt("0x0c6f8f958be0e93053d7fd4fc54512855535ed1539f051dcb43a26fd926361cf"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x123106a93cd17578d426e8128ac9d90aa9e8a00708e296e084dd57e69caaf811"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x26e1ba52ad9285d97dd3ab52f8e840085e8fa83ff1e8f1877b074867cd2dee75"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1cb55cad7bd133de18a64c5c47b9c97cbe4d8b7bf9e095864471537e6a4ae2c5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1dcd73e46acd8f8e0e2c7ce04bde7f6d2a53043d5060a41c7143f08e6e9055d0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x011003e32f6d9c66f5852f05474a4def0cda294a0eb4e9b9b12b9bb4512e5574"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2b1e809ac1d10ab29ad5f20d03a57dfebadfe5903f58bafed7c508dd2287ae8c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2539de1785b735999fb4dac35ee17ed0ef995d05ab2fc5faeaa69ae87bcec0a5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0c246c5a2ef8ee0126497f222b3e0a0ef4e1c3d41c86d46e43982cb11d77951d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x192089c4974f68e95408148f7c0632edbb09e6a6ad1a1c2f3f0305f5d03b527b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1eae0ad8ab68b2f06a0ee36eeb0d0c058529097d91096b756d8fdc2fb5a60d85"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x179190e5d0e22179e46f8282872abc88db6e2fdc0dee99e69768bd98c5d06bfb"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x29bb9e2c9076732576e9a81c7ac4b83214528f7db00f31bf6cafe794a9b3cd1c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x225d394e42207599403efd0c2464a90d52652645882aac35b10e590e6e691e08"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x064760623c25c8cf753d238055b444532be13557451c087de09efd454b23fd59"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x10ba3a0e01df92e87f301c4b716d8a394d67f4bf42a75c10922910a78f6b5b87"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0e070bf53f8451b24f9c6e96b0c2a801cb511bc0c242eb9d361b77693f21471c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1b94cd61b051b04dd39755ff93821a73ccd6cb11d2491d8aa7f921014de252fb"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1d7cb39bafb8c744e148787a2e70230f9d4e917d5713bb050487b5aa7d74070b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2ec93189bd1ab4f69117d0fe980c80ff8785c2961829f701bb74ac1f303b17db"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2db366bfdd36d277a692bb825b86275beac404a19ae07a9082ea46bd83517926"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x062100eb485db06269655cf186a68532985275428450359adc99cec6960711b8"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0761d33c66614aaa570e7f1e8244ca1120243f92fa59e4f900c567bf41f5a59b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x20fc411a114d13992c2705aa034e3f315d78608a0f7de4ccf7a72e494855ad0d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x25b5c004a4bdfcb5add9ec4e9ab219ba102c67e8b3effb5fc3a30f317250bc5a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x23b1822d278ed632a494e58f6df6f5ed038b186d8474155ad87e7dff62b37f4b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x22734b4c5c3f9493606c4ba9012499bf0f14d13bfcfcccaa16102a29cc2f69e0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x26c0c8fe09eb30b7e27a74dc33492347e5bdff409aa3610254413d3fad795ce5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x070dd0ccb6bd7bbae88eac03fa1fbb26196be3083a809829bbd626df348ccad9"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x12b6595bdb329b6fb043ba78bb28c3bec2c0a6de46d8c5ad6067c4ebfd4250da"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x248d97d7f76283d63bec30e7a5876c11c06fca9b275c671c5e33d95bb7e8d729"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1a306d439d463b0816fc6fd64cc939318b45eb759ddde4aa106d15d9bd9baaaa"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x28a8f8372e3c38daced7c00421cb4621f4f1b54ddc27821b0d62d3d6ec7c56cf"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0094975717f9a8a8bb35152f24d43294071ce320c829f388bc852183e1e2ce7e"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x04d5ee4c3aa78f7d80fde60d716480d3593f74d4f653ae83f4103246db2e8d65"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2a6cf5e9aa03d4336349ad6fb8ed2269c7bef54b8822cc76d08495c12efde187"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2304d31eaab960ba9274da43e19ddeb7f792180808fd6e43baae48d7efcba3f3"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x03fd9ac865a4b2a6d5e7009785817249bff08a7e0726fcb4e1c11d39d199f0b0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x00b7258ded52bbda2248404d55ee5044798afc3a209193073f7954d4d63b0b64"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x159f81ada0771799ec38fca2d4bf65ebb13d3a74f3298db36272c5ca65e92d9a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1ef90e67437fbc8550237a75bc28e3bb9000130ea25f0c5471e144cf4264431f"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1e65f838515e5ff0196b49aa41a2d2568df739bc176b08ec95a79ed82932e30d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2b1b045def3a166cec6ce768d079ba74b18c844e570e1f826575c1068c94c33f"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0832e5753ceb0ff6402543b1109229c165dc2d73bef715e3f1c6e07c168bb173"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x02f614e9cedfb3dc6b762ae0a37d41bab1b841c2e8b6451bc5a8e3c390b6ad16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0e2427d38bd46a60dd640b8e362cad967370ebb777bedff40f6a0be27e7ed705"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0493630b7c670b6deb7c84d414e7ce79049f0ec098c3c7c50768bbe29214a53a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x22ead100e8e482674decdab17066c5a26bb1515355d5461a3dc06cc85327cea9"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x25b3e56e655b42cdaae2626ed2554d48583f1ae35626d04de5084e0b6d2a6f16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1e32752ada8836ef5837a6cde8ff13dbb599c336349e4c584b4fdc0a0cf6f9d0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2fa2a871c15a387cc50f68f6f3c3455b23c00995f05078f672a9864074d412e5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2f569b8a9a4424c9278e1db7311e889f54ccbf10661bab7fcd18e7c7a7d83505"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x044cb455110a8fdd531ade530234c518a7df93f7332ffd2144165374b246b43d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x227808de93906d5d420246157f2e42b191fe8c90adfe118178ddc723a5319025"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x02fcca2934e046bc623adead873579865d03781ae090ad4a8579d2e7a6800355"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0ef915f0ac120b876abccceb344a1d36bad3f3c5ab91a8ddcbec2e060d8befac"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1797130f4b7a3e1777eb757bc6f287f6ab0fb85f6be63b09f3b16ef2b1405d38"),BigInt("0x0a76225dc04170ae3306c85abab59e608c7f497c20156d4d36c668555decc6e5"),BigInt("0x1fffb9ec1992d66ba1e77a7b93209af6f8fa76d48acb664796174b5326a31a5c"),BigInt("0x25721c4fc15a3f2853b57c338fa538d85f8fbba6c6b9c6090611889b797b9c5f")],[BigInt("0x0c817fd42d5f7a41215e3d07ba197216adb4c3790705da95eb63b982bfcaf75a"),BigInt("0x13abe3f5239915d39f7e13c2c24970b6df8cf86ce00a22002bc15866e52b5a96"),BigInt("0x2106feea546224ea12ef7f39987a46c85c1bc3dc29bdbd7a92cd60acb4d391ce"),BigInt("0x21ca859468a746b6aaa79474a37dab49f1ca5a28c748bc7157e1b3345bb0f959")],[BigInt("0x05ccd6255c1e6f0c5cf1f0df934194c62911d14d0321662a8f1a48999e34185b"),BigInt("0x0f0e34a64b70a626e464d846674c4c8816c4fb267fe44fe6ea28678cb09490a4"),BigInt("0x0558531a4e25470c6157794ca36d0e9647dbfcfe350d64838f5b1a8a2de0d4bf"),BigInt("0x09d3dca9173ed2faceea125157683d18924cadad3f655a60b72f5864961f1455")],[BigInt("0x0328cbd54e8c0913493f866ed03d218bf23f92d68aaec48617d4c722e5bd4335"),BigInt("0x2bf07216e2aff0a223a487b1a7094e07e79e7bcc9798c648ee3347dd5329d34b"),BigInt("0x1daf345a58006b736499c583cb76c316d6f78ed6a6dffc82111e11a63fe412df"),BigInt("0x176563472456aaa746b694c60e1823611ef39039b2edc7ff391e6f2293d2c404")]];var E_=new D0(BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")),op=null;function ar(){return op||(op=new O0(np(4,5,8,56,a4,c4,l4),E_)),op}ar().primeField;ar().permute.bind(ar());var d4;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(d4||(d4={}));var B_=ar().primeField,T_=ar().permute.bind(ar()),kr;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(kr||(kr={}));var sp=class t{constructor(e=0n){this.rate=ar().getT()-1,this.t=ar().getT(),this.state=new Array(this.t).fill(0n),this.state[this.rate]=e,this.cache=new Array(this.rate).fill(0n),this.cacheSize=0,this.mode=kr.ABSORB;}async performDuplex(){for(let e=this.cacheSize;e<this.rate;e++)this.cache[e]=0n;for(let e=0;e<this.rate;e++)this.state[e]=B_.add(this.state[e],this.cache[e]);return this.state=T_(this.state),await Promise.resolve(),this.state.slice(0,this.rate)}async absorb(e){this.mode===kr.ABSORB&&this.cacheSize===this.rate?(await this.performDuplex(),this.cache[0]=e,this.cacheSize=1):this.mode===kr.ABSORB&&this.cacheSize<this.rate?(this.cache[this.cacheSize]=e,this.cacheSize+=1):this.mode===kr.SQUEEZE&&(this.cache[0]=e,this.cacheSize=1,this.mode=kr.ABSORB);}async squeeze(){if(this.mode===kr.SQUEEZE&&this.cacheSize===0&&(this.mode=kr.ABSORB,this.cacheSize=0),this.mode===kr.ABSORB){let r=await this.performDuplex();this.mode=kr.SQUEEZE;for(let i=0;i<this.rate;i++)this.cache[i]=r[i];this.cacheSize=this.rate;}let e=this.cache[0];for(let r=1;r<this.cacheSize;r++)this.cache[r-1]=this.cache[r];return this.cacheSize-=1,this.cache[this.cacheSize]=0n,e}static async hashInternal(e,r,i){let n=(BigInt(e.length)<<64n)+BigInt(r-1),o=new t(n),s=100;for(let c=0;c<e.length;c+=s){let l=e.slice(c,Math.min(c+s,e.length));for(let d of l)await o.absorb(d);}i&&await o.absorb(1n);let a=[];for(let c=0;c<r;c++)a.push(await o.squeeze());return a}static async hashFixedLength(e,r=1){return this.hashInternal(e,r,false)}static async hashVariableLength(e,r=1){return this.hashInternal(e,r,true)}};async function Me(t){return (await sp.hashFixedLength(t))[0]}ar().primeField;It(Il(),1);It(Il(),1);var P4="1.2.840.10045.4.1",N4="1.2.840.10045.4.3.1",R4="1.2.840.10045.4.3.2",D4="1.2.840.10045.4.3.3",O4="1.2.840.10045.4.3.4";function U0(t){return new J({algorithm:t})}U0(P4);U0(N4);U0(R4);U0(D4);U0(O4);var F0=class{constructor(e={}){f(this,"fieldType");f(this,"parameters");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],F0.prototype,"fieldType",void 0);p([g({type:S.Any})],F0.prototype,"parameters",void 0);F0=p([N({type:B.Sequence})],F0);var yp=class extends ce{};var Os=class{constructor(e={}){f(this,"a");f(this,"b");f(this,"seed");Object.assign(this,e);}};p([g({type:S.OctetString})],Os.prototype,"a",void 0);p([g({type:S.OctetString})],Os.prototype,"b",void 0);p([g({type:S.BitString,optional:true})],Os.prototype,"seed",void 0);Os=p([N({type:B.Sequence})],Os);var bp;(function(t){t[t.ecpVer1=1]="ecpVer1";})(bp||(bp={}));var ei=class{constructor(e={}){f(this,"version",bp.ecpVer1);f(this,"fieldID");f(this,"curve");f(this,"base");f(this,"order");f(this,"cofactor");Object.assign(this,e);}};p([g({type:S.Integer})],ei.prototype,"version",void 0);p([g({type:F0})],ei.prototype,"fieldID",void 0);p([g({type:Os})],ei.prototype,"curve",void 0);p([g({type:yp})],ei.prototype,"base",void 0);p([g({type:S.Integer,converter:he})],ei.prototype,"order",void 0);p([g({type:S.Integer,optional:true})],ei.prototype,"cofactor",void 0);ei=p([N({type:B.Sequence})],ei);var An=class{constructor(e={}){f(this,"namedCurve");f(this,"implicitCurve");f(this,"specifiedCurve");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],An.prototype,"namedCurve",void 0);p([g({type:S.Null})],An.prototype,"implicitCurve",void 0);p([g({type:ei})],An.prototype,"specifiedCurve",void 0);An=p([N({type:B.Choice})],An);var Ms=class{constructor(e={}){f(this,"version",1);f(this,"privateKey",new ce);f(this,"parameters");f(this,"publicKey");Object.assign(this,e);}};p([g({type:S.Integer})],Ms.prototype,"version",void 0);p([g({type:ce})],Ms.prototype,"privateKey",void 0);p([g({type:An,context:0,optional:true})],Ms.prototype,"parameters",void 0);p([g({type:S.BitString,context:1,optional:true})],Ms.prototype,"publicKey",void 0);var vl=class{constructor(e={}){f(this,"r",new ArrayBuffer(0));f(this,"s",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],vl.prototype,"r",void 0);p([g({type:S.Integer,converter:he})],vl.prototype,"s",void 0);var Pt="1.2.840.113549.1.1",M4=`${Pt}.1`,U4=`${Pt}.7`,F4=`${Pt}.9`,L4=`${Pt}.10`,H4=`${Pt}.2`,K4=`${Pt}.4`,z4=`${Pt}.5`;var q4=`${Pt}.12`,G4=`${Pt}.13`,Sp=`${Pt}.15`,xp=`${Pt}.16`,$4="1.3.14.3.2.26",V4="2.16.840.1.101.3.4.2.4",j4="2.16.840.1.101.3.4.2.1",X4="2.16.840.1.101.3.4.2.2",W4="2.16.840.1.101.3.4.2.3",Z4="2.16.840.1.101.3.4.2.5",Y4="2.16.840.1.101.3.4.2.6",Q4="1.2.840.113549.2.2",J4="1.2.840.113549.2.5",Us=`${Pt}.8`;function We(t){return new J({algorithm:t,parameters:null})}We(Q4);We(J4);var ki=We($4);We(V4);We(j4);We(X4);We(W4);We(Z4);We(Y4);var El=new J({algorithm:Us,parameters:ir.serialize(ki)}),Ap=new J({algorithm:F4,parameters:ir.serialize(_s.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});We(M4);We(H4);We(K4);We(z4);We(Sp);We(xp);We(q4);We(G4);We(Sp);We(xp);var Fs=class{constructor(e={}){f(this,"hashAlgorithm",new J(ki));f(this,"maskGenAlgorithm",new J({algorithm:Us,parameters:ir.serialize(ki)}));f(this,"pSourceAlgorithm",new J(Ap));Object.assign(this,e);}};p([g({type:J,context:0,defaultValue:ki})],Fs.prototype,"hashAlgorithm",void 0);p([g({type:J,context:1,defaultValue:El})],Fs.prototype,"maskGenAlgorithm",void 0);p([g({type:J,context:2,defaultValue:Ap})],Fs.prototype,"pSourceAlgorithm",void 0);new J({algorithm:U4,parameters:ir.serialize(new Fs)});var wn=class{constructor(e={}){f(this,"hashAlgorithm",new J(ki));f(this,"maskGenAlgorithm",new J({algorithm:Us,parameters:ir.serialize(ki)}));f(this,"saltLength",20);f(this,"trailerField",1);Object.assign(this,e);}};p([g({type:J,context:0,defaultValue:ki})],wn.prototype,"hashAlgorithm",void 0);p([g({type:J,context:1,defaultValue:El})],wn.prototype,"maskGenAlgorithm",void 0);p([g({type:S.Integer,context:2,defaultValue:20})],wn.prototype,"saltLength",void 0);p([g({type:S.Integer,context:3,defaultValue:1})],wn.prototype,"trailerField",void 0);new J({algorithm:L4,parameters:ir.serialize(new wn)});var Bl=class{constructor(e={}){f(this,"digestAlgorithm",new J);f(this,"digest",new ce);Object.assign(this,e);}};p([g({type:J})],Bl.prototype,"digestAlgorithm",void 0);p([g({type:ce})],Bl.prototype,"digest",void 0);var wp,Ls=class{constructor(e={}){f(this,"prime",new ArrayBuffer(0));f(this,"exponent",new ArrayBuffer(0));f(this,"coefficient",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],Ls.prototype,"prime",void 0);p([g({type:S.Integer,converter:he})],Ls.prototype,"exponent",void 0);p([g({type:S.Integer,converter:he})],Ls.prototype,"coefficient",void 0);var Tl=wp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,wp.prototype);}};Tl=wp=p([N({type:B.Sequence,itemType:Ls})],Tl);var lr=class{constructor(e={}){f(this,"version",0);f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));f(this,"privateExponent",new ArrayBuffer(0));f(this,"prime1",new ArrayBuffer(0));f(this,"prime2",new ArrayBuffer(0));f(this,"exponent1",new ArrayBuffer(0));f(this,"exponent2",new ArrayBuffer(0));f(this,"coefficient",new ArrayBuffer(0));f(this,"otherPrimeInfos");Object.assign(this,e);}};p([g({type:S.Integer})],lr.prototype,"version",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"modulus",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"publicExponent",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"privateExponent",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"prime1",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"prime2",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"exponent1",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"exponent2",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"coefficient",void 0);p([g({type:Tl,optional:true})],lr.prototype,"otherPrimeInfos",void 0);var L0=class{constructor(e={}){f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],L0.prototype,"modulus",void 0);p([g({type:S.Integer,converter:he})],L0.prototype,"publicExponent",void 0);var Pr=class{constructor(e={}){f(this,"issuer",new xt);f(this,"serialNumber",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:xt})],Pr.prototype,"issuer",void 0);p([g({type:S.Integer,converter:he})],Pr.prototype,"serialNumber",void 0);var Eo=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true})],Eo.prototype,"subjectKeyIdentifier",void 0);p([g({type:Pr})],Eo.prototype,"issuerAndSerialNumber",void 0);Eo=p([N({type:B.Choice})],Eo);var ht;(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";})(ht||(ht={}));var mt=class extends J{};mt=p([N({type:B.Sequence})],mt);var H0=class extends J{};H0=p([N({type:B.Sequence})],H0);var Nt=class extends J{};Nt=p([N({type:B.Sequence})],Nt);var K0=class extends J{};K0=p([N({type:B.Sequence})],K0);var eb=class extends J{};eb=p([N({type:B.Sequence})],eb);var kl=class extends J{};kl=p([N({type:B.Sequence})],kl);var wt=class{constructor(e={}){f(this,"attrType","");f(this,"attrValues",[]);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],wt.prototype,"attrType",void 0);p([g({type:S.Any,repeated:"set"})],wt.prototype,"attrValues",void 0);var _p,dr=class{constructor(e={}){f(this,"version",ht.v0);f(this,"sid",new Eo);f(this,"digestAlgorithm",new mt);f(this,"signedAttrs");f(this,"signedAttrsRaw");f(this,"signatureAlgorithm",new H0);f(this,"signature",new ce);f(this,"unsignedAttrs");Object.assign(this,e);}};p([g({type:S.Integer})],dr.prototype,"version",void 0);p([g({type:Eo})],dr.prototype,"sid",void 0);p([g({type:mt})],dr.prototype,"digestAlgorithm",void 0);p([g({type:wt,repeated:"set",context:0,implicit:true,optional:true,raw:true})],dr.prototype,"signedAttrs",void 0);p([g({type:H0})],dr.prototype,"signatureAlgorithm",void 0);p([g({type:ce})],dr.prototype,"signature",void 0);p([g({type:wt,repeated:"set",context:1,implicit:true,optional:true})],dr.prototype,"unsignedAttrs",void 0);var z0=_p=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,_p.prototype);}};z0=_p=p([N({type:B.Set,itemType:dr})],z0);var tb=class extends dr{};tb=p([N({type:B.Sequence})],tb);var rb=class extends je{};rb=p([N({type:B.Choice})],rb);var q0=class{constructor(e={}){f(this,"acIssuer",new ue);f(this,"acSerial",0);f(this,"attrs",[]);Object.assign(this,e);}};p([g({type:ue})],q0.prototype,"acIssuer",void 0);p([g({type:S.Integer})],q0.prototype,"acSerial",void 0);p([g({type:Zr,repeated:"sequence"})],q0.prototype,"attrs",void 0);var Cp,G0=Cp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Cp.prototype);}};G0=Cp=p([N({type:B.Sequence,itemType:S.ObjectIdentifier})],G0);var Hs=class{constructor(e={}){f(this,"pathLenConstraint");f(this,"permittedAttrs");f(this,"excludedAttrs");f(this,"permitUnSpecified",true);Object.assign(this,e);}};p([g({type:S.Integer,optional:true})],Hs.prototype,"pathLenConstraint",void 0);p([g({type:G0,implicit:true,context:0,optional:true})],Hs.prototype,"permittedAttrs",void 0);p([g({type:G0,implicit:true,context:1,optional:true})],Hs.prototype,"excludedAttrs",void 0);p([g({type:S.Boolean,defaultValue:true})],Hs.prototype,"permitUnSpecified",void 0);var ur=class{constructor(e={}){f(this,"issuer",new Xe);f(this,"serial",new ArrayBuffer(0));f(this,"issuerUID",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:Xe})],ur.prototype,"issuer",void 0);p([g({type:S.Integer,converter:he})],ur.prototype,"serial",void 0);p([g({type:S.BitString,optional:true})],ur.prototype,"issuerUID",void 0);var Ip;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes";})(Ip||(Ip={}));var fr=class{constructor(e={}){f(this,"digestedObjectType",Ip.publicKey);f(this,"otherObjectTypeID");f(this,"digestAlgorithm",new J);f(this,"objectDigest",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Enumerated})],fr.prototype,"digestedObjectType",void 0);p([g({type:S.ObjectIdentifier,optional:true})],fr.prototype,"otherObjectTypeID",void 0);p([g({type:J})],fr.prototype,"digestAlgorithm",void 0);p([g({type:S.BitString})],fr.prototype,"objectDigest",void 0);var Bo=class{constructor(e={}){f(this,"issuerName");f(this,"baseCertificateID");f(this,"objectDigestInfo");Object.assign(this,e);}};p([g({type:Xe,optional:true})],Bo.prototype,"issuerName",void 0);p([g({type:ur,context:0,implicit:true,optional:true})],Bo.prototype,"baseCertificateID",void 0);p([g({type:fr,context:1,implicit:true,optional:true})],Bo.prototype,"objectDigestInfo",void 0);var To=class{constructor(e={}){f(this,"v1Form");f(this,"v2Form");Object.assign(this,e);}};p([g({type:ue,repeated:"sequence"})],To.prototype,"v1Form",void 0);p([g({type:Bo,context:0,implicit:true})],To.prototype,"v2Form",void 0);To=p([N({type:B.Choice})],To);var ko=class{constructor(e={}){f(this,"notBeforeTime",new Date);f(this,"notAfterTime",new Date);Object.assign(this,e);}};p([g({type:S.GeneralizedTime})],ko.prototype,"notBeforeTime",void 0);p([g({type:S.GeneralizedTime})],ko.prototype,"notAfterTime",void 0);var _n=class{constructor(e={}){f(this,"baseCertificateID");f(this,"entityName");f(this,"objectDigestInfo");Object.assign(this,e);}};p([g({type:ur,implicit:true,context:0,optional:true})],_n.prototype,"baseCertificateID",void 0);p([g({type:Xe,implicit:true,context:1,optional:true})],_n.prototype,"entityName",void 0);p([g({type:fr,implicit:true,context:2,optional:true})],_n.prototype,"objectDigestInfo",void 0);var vp;(function(t){t[t.v2=1]="v2";})(vp||(vp={}));var Rt=class{constructor(e={}){f(this,"version",vp.v2);f(this,"holder",new _n);f(this,"issuer",new To);f(this,"signature",new J);f(this,"serialNumber",new ArrayBuffer(0));f(this,"attrCertValidityPeriod",new ko);f(this,"attributes",[]);f(this,"issuerUniqueID");f(this,"extensions");Object.assign(this,e);}};p([g({type:S.Integer})],Rt.prototype,"version",void 0);p([g({type:_n})],Rt.prototype,"holder",void 0);p([g({type:To})],Rt.prototype,"issuer",void 0);p([g({type:J})],Rt.prototype,"signature",void 0);p([g({type:S.Integer,converter:he})],Rt.prototype,"serialNumber",void 0);p([g({type:ko})],Rt.prototype,"attrCertValidityPeriod",void 0);p([g({type:Zr,repeated:"sequence"})],Rt.prototype,"attributes",void 0);p([g({type:S.BitString,optional:true})],Rt.prototype,"issuerUniqueID",void 0);p([g({type:Ts,optional:true})],Rt.prototype,"extensions",void 0);var Po=class{constructor(e={}){f(this,"acinfo",new Rt);f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:Rt})],Po.prototype,"acinfo",void 0);p([g({type:J})],Po.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],Po.prototype,"signatureValue",void 0);var $0;(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";})($0||($0={}));var Ks=class extends Ei{};var zs=class{constructor(e={}){f(this,"type","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier,implicit:true,context:0})],zs.prototype,"type",void 0);p([g({type:S.Any,implicit:true,context:1})],zs.prototype,"value",void 0);var V0=class{constructor(e={}){f(this,"policyId","");f(this,"classList",new Ks($0.unclassified));f(this,"securityCategories");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],V0.prototype,"policyId",void 0);p([g({type:Ks,defaultValue:new Ks($0.unclassified)})],V0.prototype,"classList",void 0);p([g({type:zs,repeated:"set"})],V0.prototype,"securityCategories",void 0);var qs=class{constructor(e={}){f(this,"cotets");f(this,"oid");f(this,"string");Object.assign(this,e);}};p([g({type:ce})],qs.prototype,"cotets",void 0);p([g({type:S.ObjectIdentifier})],qs.prototype,"oid",void 0);p([g({type:S.Utf8String})],qs.prototype,"string",void 0);var Pl=class{constructor(e={}){f(this,"policyAuthority");f(this,"values",[]);Object.assign(this,e);}};p([g({type:Xe,implicit:true,context:0,optional:true})],Pl.prototype,"policyAuthority",void 0);p([g({type:qs,repeated:"sequence"})],Pl.prototype,"values",void 0);var Ep,Gs=class{constructor(e={}){f(this,"targetCertificate",new ur);f(this,"targetName");f(this,"certDigestInfo");Object.assign(this,e);}};p([g({type:ur})],Gs.prototype,"targetCertificate",void 0);p([g({type:ue,optional:true})],Gs.prototype,"targetName",void 0);p([g({type:fr,optional:true})],Gs.prototype,"certDigestInfo",void 0);var $s=class{constructor(e={}){f(this,"targetName");f(this,"targetGroup");f(this,"targetCert");Object.assign(this,e);}};p([g({type:ue,context:0,implicit:true})],$s.prototype,"targetName",void 0);p([g({type:ue,context:1,implicit:true})],$s.prototype,"targetGroup",void 0);p([g({type:Gs,context:2,implicit:true})],$s.prototype,"targetCert",void 0);$s=p([N({type:B.Choice})],$s);var Nl=Ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ep.prototype);}};Nl=Ep=p([N({type:B.Sequence,itemType:$s})],Nl);var Bp,ib=Bp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Bp.prototype);}};ib=Bp=p([N({type:B.Sequence,itemType:Nl})],ib);var Rl=class{constructor(e={}){f(this,"roleAuthority");f(this,"roleName");Object.assign(this,e);}};p([g({type:Xe,implicit:true,context:0,optional:true})],Rl.prototype,"roleAuthority",void 0);p([g({type:ue,implicit:true,context:1})],Rl.prototype,"roleName",void 0);var X0=class{constructor(e={}){f(this,"service",new ue);f(this,"ident",new ue);f(this,"authInfo");Object.assign(this,e);}};p([g({type:ue})],X0.prototype,"service",void 0);p([g({type:ue})],X0.prototype,"ident",void 0);p([g({type:ce,optional:true})],X0.prototype,"authInfo",void 0);var Tp,W0=class{constructor(e={}){f(this,"otherCertFormat","");f(this,"otherCert",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],W0.prototype,"otherCertFormat",void 0);p([g({type:S.Any})],W0.prototype,"otherCert",void 0);var Vs=class{constructor(e={}){f(this,"certificate");f(this,"v2AttrCert");f(this,"other");Object.assign(this,e);}};p([g({type:$t})],Vs.prototype,"certificate",void 0);p([g({type:Po,context:2,implicit:true})],Vs.prototype,"v2AttrCert",void 0);p([g({type:W0,context:3,implicit:true})],Vs.prototype,"other",void 0);Vs=p([N({type:B.Choice})],Vs);var js=Tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Tp.prototype);}};js=Tp=p([N({type:B.Set,itemType:Vs})],js);var Z0=class{constructor(e={}){f(this,"contentType","");f(this,"content",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Z0.prototype,"contentType",void 0);p([g({type:S.Any,context:0})],Z0.prototype,"content",void 0);var Y0=class{constructor(e={}){f(this,"single");f(this,"any");Object.assign(this,e);}};p([g({type:ce})],Y0.prototype,"single",void 0);p([g({type:S.Any})],Y0.prototype,"any",void 0);Y0=p([N({type:B.Choice})],Y0);var No=class{constructor(e={}){f(this,"eContentType","");f(this,"eContent");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],No.prototype,"eContentType",void 0);p([g({type:Y0,context:0,optional:true})],No.prototype,"eContent",void 0);var Q0=class{constructor(e={}){f(this,"value");f(this,"constructedValue");Object.assign(this,e);}};p([g({type:ce,context:0,implicit:true,optional:true})],Q0.prototype,"value",void 0);p([g({type:ce,converter:V3,context:0,implicit:true,optional:true,repeated:"sequence"})],Q0.prototype,"constructedValue",void 0);Q0=p([N({type:B.Choice})],Q0);var Cn=class{constructor(e={}){f(this,"contentType","");f(this,"contentEncryptionAlgorithm",new K0);f(this,"encryptedContent");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Cn.prototype,"contentType",void 0);p([g({type:K0})],Cn.prototype,"contentEncryptionAlgorithm",void 0);p([g({type:Q0,optional:true})],Cn.prototype,"encryptedContent",void 0);var In=class{constructor(e={}){f(this,"keyAttrId","");f(this,"keyAttr");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],In.prototype,"keyAttrId",void 0);p([g({type:S.Any,optional:true})],In.prototype,"keyAttr",void 0);var kp,Xs=class{constructor(e={}){f(this,"subjectKeyIdentifier",new Tr);f(this,"date");f(this,"other");Object.assign(this,e);}};p([g({type:Tr})],Xs.prototype,"subjectKeyIdentifier",void 0);p([g({type:S.GeneralizedTime,optional:true})],Xs.prototype,"date",void 0);p([g({type:In,optional:true})],Xs.prototype,"other",void 0);var Ws=class{constructor(e={}){f(this,"rKeyId");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Xs,context:0,implicit:true,optional:true})],Ws.prototype,"rKeyId",void 0);p([g({type:Pr,optional:true})],Ws.prototype,"issuerAndSerialNumber",void 0);Ws=p([N({type:B.Choice})],Ws);var J0=class{constructor(e={}){f(this,"rid",new Ws);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:Ws})],J0.prototype,"rid",void 0);p([g({type:ce})],J0.prototype,"encryptedKey",void 0);var Dl=kp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,kp.prototype);}};Dl=kp=p([N({type:B.Sequence,itemType:J0})],Dl);var ec=class{constructor(e={}){f(this,"algorithm",new J);f(this,"publicKey",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:J})],ec.prototype,"algorithm",void 0);p([g({type:S.BitString})],ec.prototype,"publicKey",void 0);var Ro=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"originatorKey");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true,optional:true})],Ro.prototype,"subjectKeyIdentifier",void 0);p([g({type:ec,context:1,implicit:true,optional:true})],Ro.prototype,"originatorKey",void 0);p([g({type:Pr,optional:true})],Ro.prototype,"issuerAndSerialNumber",void 0);Ro=p([N({type:B.Choice})],Ro);var Pi=class{constructor(e={}){f(this,"version",ht.v3);f(this,"originator",new Ro);f(this,"ukm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"recipientEncryptedKeys",new Dl);Object.assign(this,e);}};p([g({type:S.Integer})],Pi.prototype,"version",void 0);p([g({type:Ro,context:0})],Pi.prototype,"originator",void 0);p([g({type:ce,context:1,optional:true})],Pi.prototype,"ukm",void 0);p([g({type:Nt})],Pi.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:Dl})],Pi.prototype,"recipientEncryptedKeys",void 0);var Zs=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true})],Zs.prototype,"subjectKeyIdentifier",void 0);p([g({type:Pr})],Zs.prototype,"issuerAndSerialNumber",void 0);Zs=p([N({type:B.Choice})],Zs);var vn=class{constructor(e={}){f(this,"version",ht.v0);f(this,"rid",new Zs);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],vn.prototype,"version",void 0);p([g({type:Zs})],vn.prototype,"rid",void 0);p([g({type:Nt})],vn.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],vn.prototype,"encryptedKey",void 0);var Do=class{constructor(e={}){f(this,"keyIdentifier",new ce);f(this,"date");f(this,"other");Object.assign(this,e);}};p([g({type:ce})],Do.prototype,"keyIdentifier",void 0);p([g({type:S.GeneralizedTime,optional:true})],Do.prototype,"date",void 0);p([g({type:In,optional:true})],Do.prototype,"other",void 0);var En=class{constructor(e={}){f(this,"version",ht.v4);f(this,"kekid",new Do);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],En.prototype,"version",void 0);p([g({type:Do})],En.prototype,"kekid",void 0);p([g({type:Nt})],En.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],En.prototype,"encryptedKey",void 0);var Bn=class{constructor(e={}){f(this,"version",ht.v0);f(this,"keyDerivationAlgorithm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],Bn.prototype,"version",void 0);p([g({type:kl,context:0,optional:true})],Bn.prototype,"keyDerivationAlgorithm",void 0);p([g({type:Nt})],Bn.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],Bn.prototype,"encryptedKey",void 0);var tc=class{constructor(e={}){f(this,"oriType","");f(this,"oriValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],tc.prototype,"oriType",void 0);p([g({type:S.Any})],tc.prototype,"oriValue",void 0);var Ni=class{constructor(e={}){f(this,"ktri");f(this,"kari");f(this,"kekri");f(this,"pwri");f(this,"ori");Object.assign(this,e);}};p([g({type:vn,optional:true})],Ni.prototype,"ktri",void 0);p([g({type:Pi,context:1,implicit:true,optional:true})],Ni.prototype,"kari",void 0);p([g({type:En,context:2,implicit:true,optional:true})],Ni.prototype,"kekri",void 0);p([g({type:Bn,context:3,implicit:true,optional:true})],Ni.prototype,"pwri",void 0);p([g({type:tc,context:4,implicit:true,optional:true})],Ni.prototype,"ori",void 0);Ni=p([N({type:B.Choice})],Ni);var Pp,rc=Pp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Pp.prototype);}};rc=Pp=p([N({type:B.Set,itemType:Ni})],rc);var Np,Ys=class{constructor(e={}){f(this,"otherRevInfoFormat","");f(this,"otherRevInfo",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Ys.prototype,"otherRevInfoFormat",void 0);p([g({type:S.Any})],Ys.prototype,"otherRevInfo",void 0);var Ol=class{constructor(e={}){f(this,"other",new Ys);Object.assign(this,e);}};p([g({type:Ys,context:1,implicit:true})],Ol.prototype,"other",void 0);Ol=p([N({type:B.Choice})],Ol);var Qs=Np=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Np.prototype);}};Qs=Np=p([N({type:B.Set,itemType:Ol})],Qs);var Js=class{constructor(e={}){f(this,"certs");f(this,"crls");Object.assign(this,e);}};p([g({type:js,context:0,implicit:true,optional:true})],Js.prototype,"certs",void 0);p([g({type:Qs,context:1,implicit:true,optional:true})],Js.prototype,"crls",void 0);var Rp,Dp=Rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Rp.prototype);}};Dp=Rp=p([N({type:B.Set,itemType:wt})],Dp);var Oo=class{constructor(e={}){f(this,"version",ht.v0);f(this,"originatorInfo");f(this,"recipientInfos",new rc);f(this,"encryptedContentInfo",new Cn);f(this,"unprotectedAttrs");Object.assign(this,e);}};p([g({type:S.Integer})],Oo.prototype,"version",void 0);p([g({type:Js,context:0,implicit:true,optional:true})],Oo.prototype,"originatorInfo",void 0);p([g({type:rc})],Oo.prototype,"recipientInfos",void 0);p([g({type:Cn})],Oo.prototype,"encryptedContentInfo",void 0);p([g({type:Dp,context:1,implicit:true,optional:true})],Oo.prototype,"unprotectedAttrs",void 0);var Op,Ml=Op=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Op.prototype);}};Ml=Op=p([N({type:B.Set,itemType:mt})],Ml);var Ri=class{constructor(e={}){f(this,"version",ht.v0);f(this,"digestAlgorithms",new Ml);f(this,"encapContentInfo",new No);f(this,"certificates");f(this,"crls");f(this,"signerInfos",new z0);Object.assign(this,e);}};p([g({type:S.Integer})],Ri.prototype,"version",void 0);p([g({type:Ml})],Ri.prototype,"digestAlgorithms",void 0);p([g({type:No})],Ri.prototype,"encapContentInfo",void 0);p([g({type:js,context:0,implicit:true,optional:true})],Ri.prototype,"certificates",void 0);p([g({type:Qs,context:1,implicit:true,optional:true})],Ri.prototype,"crls",void 0);p([g({type:z0})],Ri.prototype,"signerInfos",void 0);var hC=Gt.Point.Fp;hC.ORDER;var mC=Gt.Point.CURVE().n,gC=8n,yC=mC/gC,ea=bs(yC,{BITS:249});Gt.Point.Fp;var Tn={x:5299619240641551281634865583518297030282874472190772894086521144482721001553n,y:16950150798460657717958625567821834550301663161624707787222815936182638968203n};Gt.Point.fromAffine(Tn);Gt.Point.fromAffine(Tn);new TextEncoder().encode("FROST_2_NONCE_COMBINER");var pb=Object.defineProperty,_C=Object.getOwnPropertyDescriptor,CC=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),hb=(t,e)=>()=>(t&&(e=t(t=0)),e),IC=(t,e)=>{for(var r in e)pb(t,r,{get:e[r],enumerable:true});},Dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?_C(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&pb(e,r,n),n},Di,ic,Gl=hb(()=>{Di={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},ic={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),UC={};IC(UC,{modPow:()=>yb,verifyDscSignature:()=>VC,verifyDscSignatureWithTbs:()=>jC,verifyECDSASignature:()=>zp,verifyRSASignature:()=>qp});function mb(t){return t<=192?["SHA-1","SHA-224","SHA-256","SHA-384","SHA-512"]:t<=256?["SHA-256","SHA-1","SHA-224","SHA-384","SHA-512"]:t<=384?["SHA-384","SHA-256","SHA-512","SHA-1","SHA-224"]:["SHA-512","SHA-384","SHA-256","SHA-1","SHA-224"]}function FC(t,e){if(t.length===e*2||t[0]!==48)return t;let r=t[1]===t.length-2?1:2,i=t[r];if(t[r+1]!==2||i!==t.length-r-1)return t;let n=t[r+2],o=t.slice(r+3,r+3+n);if(t[r+3+n]!==2)return t;let s=t[r+3+n+1],a=t.slice(r+3+n+2,r+3+n+2+s);for(;o.length>0&&o[0]===0;)o=o.slice(1);for(;a.length>0&&a[0]===0;)a=a.slice(1);let c=new Uint8Array(e),l=new Uint8Array(e);c.set(o,e-o.length),l.set(a,e-a.length);let d=new Uint8Array(e*2);return d.set(c,0),d.set(l,e),d}function zp(t,e,r){let i=bb[r.curve];if(!i)return false;try{let n=Math.ceil(r.key_size/8),o=FC(e,n),s=Buffer.from(r.public_key_x.replace("0x",""),"hex"),a=Buffer.from(r.public_key_y.replace("0x",""),"hex"),c=new Uint8Array(n),l=new Uint8Array(n);c.set(s,n-s.length),l.set(a,n-a.length);let d=new Uint8Array(1+n*2);return d[0]=4,d.set(c,1),d.set(l,1+n),i.verify(o,t,d,{prehash:!1,lowS:!1})}catch{return false}}async function qp(t,e,r,i,n,o){try{if(Sb.includes(n)){let s=HC();if(s)return await KC(t,r,i,n,o,s)}return zC(e,r,i,n,o)}catch{return false}}function LC(t){if(t===0)return new Uint8Array([0]);let e=[];for(;t>0;)e.unshift(t&255),t=t>>>8;return new Uint8Array(e)}function HC(){return typeof globalThis<"u"&&globalThis.crypto?.subtle?globalThis.crypto.subtle:typeof globalThis<"u"&&globalThis.crypto?.webcrypto?.subtle?globalThis.crypto.webcrypto.subtle:null}async function KC(t,e,r,i,n,o){let s=new Uint8Array(Buffer.from(r.modulus.replace("0x",""),"hex")),a=LC(r.exponent),c={kty:"RSA",n:ob(s),e:ob(a),alg:n?`PS${i.replace("SHA-","")}`:`RS${i.replace("SHA-","")}`,ext:true},l=n?{name:"RSA-PSS",hash:{name:i}}:{name:"RSASSA-PKCS1-v1_5",hash:{name:i}},d=n?{name:"RSA-PSS",saltLength:gb(i)}:{name:"RSASSA-PKCS1-v1_5"};try{let u=await o.importKey("jwk",c,l,!1,["verify"]),h=new Uint8Array(e).buffer,m=new Uint8Array(t).buffer;return await o.verify(d,u,h,m)}catch{return false}}function ob(t){return Buffer.from(t).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function gb(t){switch(t){case "SHA-1":return 20;case "SHA-224":return 28;case "SHA-256":return 32;case "SHA-384":return 48;case "SHA-512":return 64;default:return 32}}function zC(t,e,r,i,n){try{let o=BigInt(r.modulus),s=BigInt(r.exponent),a=Math.ceil(r.key_size/8);if(e.length!==a)if(e.length<a){let h=new Uint8Array(a);h.set(e,a-e.length),e=h;}else return !1;let c=BigInt(0);for(let h of e)c=c<<BigInt(8)|BigInt(h);if(c>=o)return !1;let l=yb(c,s,o),d=new Uint8Array(a),u=l;for(let h=a-1;h>=0;h--)d[h]=Number(u&BigInt(255)),u=u>>BigInt(8);return n?GC(d,t,i,r.key_size):qC(d,t,i)}catch{return false}}function yb(t,e,r){if(r===BigInt(1))return BigInt(0);let i=BigInt(1);for(t=t%r;e>BigInt(0);)e%BigInt(2)===BigInt(1)&&(i=i*t%r),e=e>>BigInt(1),t=t*t%r;return i}function qC(t,e,r){if(t[0]!==0||t[1]!==1)return false;let i=2;for(;i<t.length&&t[i]===255;)i++;if(i-2<Ab||i>=t.length||t[i]!==0)return false;i++;let n=t.slice(i),o=xb[r];if(sb(n,e,o))return true;let s=wb[r];return !!sb(n,e,s)}function sb(t,e,r){if(t.length!==r.length+e.length)return false;let i=0;for(let n=0;n<r.length;n++)i|=t[n]^r[n];for(let n=0;n<e.length;n++)i|=t[r.length+n]^e[n];return i===0}function GC(t,e,r,i){let n=$l[r],o=gb(r),s=i-1,a=Math.ceil(s/8);if(a<o+2)return false;let c=t.length>a?t.slice(t.length-a):t;if(c.length<a||c[a-1]!==188)return false;let l=a-o-1,d=c.slice(0,l),u=c.slice(l,l+o),h=255>>8*a-s;if((d[0]&~h)!==0)return false;let m=$C(u,l,n),b=new Uint8Array(l);for(let C=0;C<l;C++)b[C]=d[C]^m[C];b[0]&=h;let A=-1;for(let C=0;C<l;C++)if(b[C]===1){A=C;break}else if(b[C]!==0)return false;if(A===-1)return false;let x=l-A-1;if(x<0)return false;let y=b.slice(A+1),w=new Uint8Array(8+o+x);w.set(e,8),x>0&&w.set(y,8+o);let I=n(w);if(u.length!==I.length)return false;let _=0;for(let C=0;C<u.length;C++)_|=u[C]^I[C];return _===0}function $C(t,e,r){let i=r(new Uint8Array(0)).length,n=new Uint8Array(e),o=0;for(let s=0;o<e;s++){let a=new Uint8Array(4);a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255;let c=new Uint8Array(t.length+4);c.set(t),c.set(a,t.length);let l=r(c),d=Math.min(i,e-o);n.set(l.slice(0,d),o),o+=d;}return n}async function VC(t,e){let r=t.tbs.bytes.toUInt8Array(),i=t.signature.toUInt8Array(),n=e.public_key.type==="EC",o=e.signature_algorithm==="RSA-PSS",s=e.public_key.key_size,a=mb(s);for(let c of a){let l=$l[c];if(!l)continue;let d=l(r);if(n){let u=e.public_key;if(zp(d,i,u))return true}else {let u=e.public_key;if(await qp(r,d,i,u,c,o))return true}}return false}async function jC(t,e,r){let i=r.public_key.type==="EC",n=r.signature_algorithm==="RSA-PSS",o=r.public_key.key_size,s=mb(o);for(let a of s){let c=$l[a];if(!c)continue;let l=c(t);if(i){let d=r.public_key;if(zp(l,e,d))return true}else {let d=r.public_key;if(await qp(t,l,e,d,a,n))return true}}return false}var $l,ab,cb,lb,db,ub,fb,bb,Sb,xb,Ab,wb,XC=hb(()=>{Gl(),$l={"SHA-1":Jn,"SHA-224":Lr,"SHA-256":ot,"SHA-384":ps,"SHA-512":fs},ab={p:ic.brainpoolP224r1.p,a:ic.brainpoolP224r1.a,b:ic.brainpoolP224r1.b,n:ic.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},cb=Ge(qe(ab),Lr),lb={p:Di["P-192"].p,a:Di["P-192"].a,b:Di["P-192"].b,n:Di["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},db=Ge(qe(lb),Jn),ub={p:Di["P-224"].p,a:Di["P-224"].a,b:Di["P-224"].b,n:Di["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},fb=Ge(qe(ub),Lr),bb={"P-192":db,"P-224":fb,"P-256":lt,"P-384":dt,"P-521":ut,brainpoolP224r1:cb,brainpoolP256r1:gy,brainpoolP384r1:yy,brainpoolP512r1:by},Sb=["SHA-256","SHA-384","SHA-512"],xb={"SHA-1":new Uint8Array([48,33,48,9,6,5,43,14,3,2,26,5,0,4,20]),"SHA-224":new Uint8Array([48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28]),"SHA-256":new Uint8Array([48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]),"SHA-384":new Uint8Array([48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48]),"SHA-512":new Uint8Array([48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64])},Ab=8,wb={"SHA-1":new Uint8Array([48,31,48,7,6,5,43,14,3,2,26,4,20]),"SHA-224":new Uint8Array([48,43,48,11,6,9,96,134,72,1,101,3,4,2,4,4,28]),"SHA-256":new Uint8Array([48,47,48,11,6,9,96,134,72,1,101,3,4,2,1,4,32]),"SHA-384":new Uint8Array([48,63,48,11,6,9,96,134,72,1,101,3,4,2,2,4,48]),"SHA-512":new Uint8Array([48,79,48,11,6,9,96,134,72,1,101,3,4,2,3,4,64])};});var Hl=class Ze{constructor(e){this.bytes=Ze.convertToBytes(e);}static convertToBytes(e){if(typeof e=="bigint"||typeof e=="number"){let r=e.toString(16),i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}if(e instanceof Uint8Array)return new Uint8Array(e);if(Buffer.isBuffer(e))return new Uint8Array(e);if(Array.isArray(e)){if(!e.every(r=>typeof r=="number"&&r>=0&&r<=255))throw new Error("Invalid byte array: values must be between 0 and 255");return new Uint8Array(e)}if(e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e=="string"){if(Ze.isHexString(e)){let r=e.startsWith("0x")?e.slice(2):e,i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}try{let r=BigInt(e);return Ze.convertToBytes(r)}catch{return new Uint8Array(Buffer.from(e,"ascii"))}}throw new Error("Unsupported data type")}static isHexString(e){let r=e.startsWith("0x")?e.slice(2):e;return /^[0-9a-fA-F]*$/.test(r)}static from(e){return new Ze(e)}static fromHex(e){if(!Ze.isHexString(e))throw new Error("Invalid hex string");return new Ze(e.startsWith("0x")?e:"0x"+e)}static fromBuffer(e){return new Ze(e)}static fromBase64(e){let r=atob(e);return new Ze(Uint8Array.from(r,i=>i.charCodeAt(0)))}static empty(){return new Ze(new Uint8Array(0))}static zero(e){return new Ze(new Uint8Array(e))}toBigInt(){return BigInt("0x"+this.toHex().slice(2))}toUInt8Array(){return new Uint8Array(this.bytes)}toNumberArray(){return Array.from(this.bytes)}toHex(){return "0x"+Array.from(this.bytes).map(e=>e.toString(16).padStart(2,"0")).join("")}toBuffer(){return Buffer.from(this.bytes)}toString(e="hex"){return e==="hex"?this.toHex().slice(2):Buffer.from(this.bytes).toString(e)}toBase64(){return btoa(String.fromCharCode(...this.bytes))}toJSON(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return `Binary(${this.toHex()})`}[Symbol.toPrimitive](e){switch(e){case "number":return Number(this.toBigInt());case "string":return `Binary(${this.toHex()})`;default:return this.toBigInt()}}valueOf(){return this.toBigInt()}get length(){return this.bytes.length}*[Symbol.iterator](){yield*this.bytes;}equals(e){return this.length!==e.length?false:this.bytes.every((r,i)=>r===e.bytes[i])}slice(e,r){return new Ze(this.bytes.slice(e,r))}concat(e){return new Ze([...this.toNumberArray(),...e.toNumberArray()])}[Symbol.for("+")](e){return this.concat(e)}compare(e){let r=Math.min(this.length,e.length);for(let i=0;i<r;i++){let n=this.bytes[i]-e.bytes[i];if(n!==0)return n}return this.length-e.length}xor(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for XOR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]^e.bytes[i];return new Ze(r)}and(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for AND operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]&e.bytes[i];return new Ze(r)}or(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for OR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]|e.bytes[i];return new Ze(r)}not(){let e=new Uint8Array(this.length);for(let r=0;r<this.length;r++)e[r]=~this.bytes[r]&255;return new Ze(e)}padStart(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.fill(r,0,e-this.length),i.set(this.bytes,e-this.length),new Ze(i)}padEnd(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.set(this.bytes),i.fill(r,this.length),new Ze(i)}};BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");function _b(t){return t.startsWith("0x")?t.slice(2):t}function ZC(t){return BigInt("0x"+Buffer.from(t).toString("hex"))}function Mo(t,e){return t.concat(Array(e-t.length).fill(0))}function Cb(t,e){return Array(e-t.length).fill(0).concat(t)}function Uo(t,e){let r=BigInt(0);for(let i=0;i<e;i++)r*=BigInt(256),r+=BigInt(t[i]);return r}function YC(t,e){let r=BigInt(0);for(let i=0;i<Math.min(e,t.length);i++)r*=BigInt(2),r+=BigInt(t[i]);return r}function Ib(t,e){if(t.length===0)return [];let r=Math.ceil(t.length/e),i=new Array(r),n=t.length%e||e,o=0;for(let s=r-1;s>=0;s--){let a=s===r-1?n:e,c=0n;for(let d=0;d<a;d++)c=c<<8n|BigInt(t[o++]);let l=c.toString(16);i[s]="0x"+(l.length%2?"0":"")+l;}return i}var Kl={ethereum:1,base:8453,arbitrum:42161,optimism:10,polygon:137,celo:42220,gnosis:100,scroll:534352,linea:59144,world_chain:480,robinhood:4663,ethereum_sepolia:11155111,base_sepolia:84532,arbitrum_sepolia:421614,polygon_amoy:80002,celo_sepolia:11142220,gnosis_chiado:10200,scroll_sepolia:534351,linea_sepolia:59141,world_chain_sepolia:4801,local:31337};function Oi(t){if(!Kl[t])throw new Error(`Unsupported chain: ${t}`);return Kl[t]}function nc(t){for(let e in Kl)if(Kl[e]===t)return e;throw new Error(`Unsupported chain ID: ${t}`)}function Gp(t,e){return t.bind?.chain??(e?"ethereum_sepolia":"ethereum")}function me(t,e){return (typeof t=="string"||typeof t=="number")&&(t=new Date(t)),(typeof e=="string"||typeof e=="number")&&(e=new Date(e)),t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function kn(t){return typeof t=="string"||typeof t=="number"?new Date(t):t}function $p(t){for(let e in t){let r=t[e];if((e==="birthdate"||e==="expiry_date")&&r&&typeof r=="object"){if("eq"in r&&r.eq&&(r.eq.expected=kn(r.eq.expected)),"gte"in r&&r.gte&&(r.gte.expected=kn(r.gte.expected)),"gt"in r&&r.gt&&(r.gt.expected=kn(r.gt.expected)),"lte"in r&&r.lte&&(r.lte.expected=kn(r.lte.expected)),"lt"in r&&r.lt&&(r.lt.expected=kn(r.lt.expected)),"range"in r&&r.range&&Array.isArray(r.range.expected)){let[i,n]=r.range.expected;r.range.expected=[kn(i),kn(n)];}"disclose"in r&&r.disclose&&(r.disclose.result=kn(r.disclose.result));}}return t}function Te(t,e){return jn(t.toString(16).padStart(e*2,"0"))}async function Vp(t,e=3){let r;for(let i=0;i<=e;i++)try{return await t()}catch(n){if(r=n,i===e)throw n;let o=Math.min(100*Math.pow(2,i),5e3);await new Promise(s=>setTimeout(s,o));}throw r}var Pe=(t=>(t[t.NON_SALTED=0]="NON_SALTED",t[t.SALTED=1]="SALTED",t[t.NON_SALTED_MOCK=2]="NON_SALTED_MOCK",t[t.SALTED_MOCK=3]="SALTED_MOCK",t[t.NONE=4]="NONE",t))(Pe||{});function vb(t){return BigInt(t.publicInputs[0])}function Eb(t){return BigInt(t.publicInputs[1])}function QC(){return 2}function Bb(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function Tb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function JC(){return 2}function ta(t){return t==="D<<"?"DEU":t}function Mp(t){return t.replace(/^<+|<+$/g,"").replace(/</g," ")}function ve(t){return t.replace(/<+/g," ").replace(/</g," ").replace(/\s+/g," ").replace(/[áàâäãå]/g,"a").replace(/[éèêë]/g,"e").replace(/[íìîï]/g,"i").replace(/[óòôöõ]/g,"o").replace(/[úùûü]/g,"u").replace(/[ñ]/g,"n").replace(/[ç]/g,"c").replace(/[æ]/g,"ae").replace(/[œ]/g,"oe").replace(/[ø]/g,"o").replace(/[æ]/g,"ae").replace(/[œ]/g,"oe").replace(/[ø]/g,"o").replace(/[^a-zA-Z ]/g,"").trim()}function Up(t){return t.startsWith("P")?"passport":t==="IR"||t==="AR"?"residence_permit":t.startsWith("I")?"id_card":"other"}var jp=class Ll{constructor(e){this.issuingCountry=e.issuingCountry,this.nationality=e.nationality,this.documentType=e.documentType,this.documentNumber=e.documentNumber,this.dateOfExpiry=e.dateOfExpiry,this.dateOfBirth=e.dateOfBirth,this.name=e.name,this.gender=e.gender,this.firstName=e.firstName,this.lastName=e.lastName;}static fromDisclosedBytes(e,r){let i={issuingCountry:new Uint8Array(e.slice(2,5)),nationality:new Uint8Array(e.slice(r==="id_card"?45:54,r==="id_card"?48:57)),documentType:new Uint8Array(e.slice(0,2)),documentNumber:new Uint8Array(e.slice(r==="id_card"?5:44,r==="id_card"?14:53)),dateOfExpiry:new Uint8Array(e.slice(r==="id_card"?38:65,r==="id_card"?44:71)),dateOfBirth:new Uint8Array(e.slice(r==="id_card"?30:57,r==="id_card"?36:63)),name:new Uint8Array(e.slice(r==="id_card"?60:5,r==="id_card"?90:44)),gender:new Uint8Array(e.slice(r==="id_card"?37:64,r==="id_card"?38:65))},n=new TextDecoder,o=m=>n.decode(m).replace(/\0/g,""),s=i.name&&i.name.length>0?o(i.name):"",a=s.indexOf("<<"),c=a>=0?s.substring(0,a):"",l=a>=0?s.substring(a+2):"",d=l.indexOf("<"),u=d>=0?l.substring(0,d):l,h=l+" "+c;return new Ll({issuingCountry:ta(o(i.issuingCountry)),nationality:ta(o(i.nationality)),documentType:Up(o(i.documentType)),documentNumber:Mp(o(i.documentNumber)),dateOfExpiry:ra(i.dateOfExpiry),dateOfBirth:ra(i.dateOfBirth),name:ve(h),firstName:ve(u),lastName:ve(c),gender:o(i.gender)})}static fromFlagsProof(e){let r=e.publicInputs.slice(3,93).map(m=>parseInt(m,16)),i={issuingCountry:new Uint8Array(r.slice(0,3)),nationality:new Uint8Array(r.slice(3,6)),documentType:new Uint8Array(r.slice(6,8)),documentNumber:new Uint8Array(r.slice(8,17)),dateOfExpiry:new Uint8Array(r.slice(17,23)),dateOfBirth:new Uint8Array(r.slice(23,29)),name:new Uint8Array(r.slice(29,68)),gender:new Uint8Array(r.slice(68,69))},n=new TextDecoder,o=m=>n.decode(m).replace(/\0/g,""),s=i.name&&i.name.length>0?o(i.name):"",a=s.indexOf("<<"),c=a>0?s.substring(0,a):"",l=a>0?s.substring(a+2):"",d=l.indexOf("<"),u=d>=0?l.substring(0,d):l,h=l+" "+c;return new Ll({issuingCountry:ta(o(i.issuingCountry)),nationality:ta(o(i.nationality)),documentType:Up(o(i.documentType)),documentNumber:Mp(o(i.documentNumber)),dateOfExpiry:ra(i.dateOfExpiry),dateOfBirth:ra(i.dateOfBirth),name:ve(h),firstName:ve(u),lastName:ve(c),gender:o(i.gender)})}static fromBytesProof(e,r){let i=e.publicInputs.slice(93,182).map(b=>parseInt(b,16)),n={issuingCountry:new Uint8Array(i.slice(2,5)),nationality:new Uint8Array(i.slice(r==="id_card"?45:54,r==="id_card"?48:57)),documentType:new Uint8Array(i.slice(0,2)),documentNumber:new Uint8Array(i.slice(r==="id_card"?5:44,r==="id_card"?14:53)),dateOfExpiry:new Uint8Array(i.slice(r==="id_card"?38:65,r==="id_card"?44:71)),dateOfBirth:new Uint8Array(i.slice(r==="id_card"?30:57,r==="id_card"?36:63)),name:new Uint8Array(i.slice(r==="id_card"?60:5,r==="id_card"?90:44)),gender:new Uint8Array(i.slice(r==="id_card"?37:64,r==="id_card"?38:65))},o=new TextDecoder,s=b=>o.decode(b).replace(/\0/g,""),a=n.name&&n.name.length>0?s(n.name):"",c=a.indexOf("<<"),l=c>=0?a.substring(0,c):"",d=c>=0?a.substring(c+2):"",u=d.indexOf("<"),h=u>=0?d.substring(0,u):d,m=d+" "+l;return new Ll({issuingCountry:ta(s(n.issuingCountry)),nationality:ta(s(n.nationality)),documentType:Up(s(n.documentType)),documentNumber:Mp(s(n.documentNumber)),dateOfExpiry:ra(n.dateOfExpiry),dateOfBirth:ra(n.dateOfBirth),name:ve(m),firstName:ve(h),lastName:ve(l),gender:s(n.gender)})}};function ra(t){let e=new TextDecoder().decode(t).replace(/\0/g,""),r=parseInt(e.substring(0,2)),i=parseInt(e.substring(2,4))-1,n=parseInt(e.substring(4,6)),o=new Date().getFullYear(),s=Math.floor(o/100)*100,a=s-100,c=r+(r+s>o+10?a:s);return new Date(Date.UTC(c,i,n,0,0,0,0))}async function Xp(t,e){return await Me([BigInt(0),BigInt(se[0].standard),YC(t,253),...Ib(new Uint8Array(e),31).map(r=>BigInt(r))])}async function kb(t,e){let r=ot(new Uint8Array([0,...Te(se[0].evm,2),...t.map(i=>Number(i)),...e.map(i=>Number(i))]));return Uo(r,31)}function Pb(t){return t.minAge}function Nb(t){return t.maxAge}async function Wp(t,e){return await Me([BigInt(1),BigInt(se[1].standard),BigInt(t),BigInt(e)])}async function Rb(t,e){let r=ot(new Uint8Array([1,...Te(se[1].evm,2),t,e]));return Uo(r,31)}function eI(t){return t.charCodeAt(0)*65536+t.charCodeAt(1)*256+t.charCodeAt(2)}async function Mi(t,e,r=false){let i=e.map(o=>eI(o)),n=Mo(r?i.sort((o,s)=>o-s):i,200).map(o=>BigInt(o));return await Me([BigInt(t),BigInt(se[t].standard),...n])}async function oc(t,e,r=false){r&&e.sort((o,s)=>o.localeCompare(s));let i=e.map(o=>Array.from(new TextEncoder().encode(o))).flat(),n=ot(new Uint8Array([t,...Te(se[t].evm,2),...Mo(i,600)]));return Uo(n,31)}var Fo=Math.floor(Math.abs(Date.UTC(1900,0,1,0,0,0))/1e3);function zl(t){return new Date(t.minDateTimestamp*1e3)}function ql(t){return new Date(t.maxDateTimestamp*1e3)}function Db(t,e=Fo){return zl(t).getTime()===0?new Date(0):new Date(zl(t).getTime()+e*1e3)}function Ob(t,e=Fo){return ql(t).getTime()===0?new Date(0):new Date(ql(t).getTime()+e*1e3)}async function sc(t,e,r,i=Fo){return await Me([BigInt(t),BigInt(se[t].standard),t===2&&e!==0?BigInt(e)+BigInt(i):BigInt(e),t===2&&r!==0?BigInt(r)+BigInt(i):BigInt(r)])}async function Zp(t,e,r,i=Fo){let n=ot(new Uint8Array([t,...Te(se[t].evm,2),...Te(t===2&&e!==0?e+i:e,8),...Te(t===2&&r!==0?r+i:r,8)]));return Uo(n,31)}function Mb(t){return BigInt(t.publicInputs[0])}function Ub(t){return BigInt(t.publicInputs[1])}function tI(){return 2}var rI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(rI||{});function ac(t){let e=[];if(t.user_address&&t.user_address.length>0){let r=Hl.fromHex(t.user_address).toNumberArray();e=[...e,1,...Cb([r.length],2),...r];}if(t.chain){let r=Oi(t.chain),i=Hl.fromHex(r.toString(16)).toNumberArray();e=[...e,2,0,i.length,...i];}if(t.custom_data&&t.custom_data.length>0){let r=new TextEncoder().encode(t.custom_data);e=[...e,3,r.length>>8&255,r.length&255,...r];}if(e.length>509)throw new Error(`Data is too long: ${e.length} > 509`);return e}async function Yp(t,e=509){let r=Mo(t,e);return await Me([BigInt(8),BigInt(se[8].standard),...Ib(new Uint8Array(r),31).map(i=>BigInt(i))])}async function Fb(t,e=509){let r=Mo(t,e),i=ot(new Uint8Array([8,...Te(se[8].evm,2),...r]));return Uo(i,31)}var Lb=8544227306600425492560068004835614964118871262589609739238120993689090208159n,Hb=0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615dn;async function Qp(t,e,r,i){return await Me([BigInt(10),BigInt(se[10].standard),t,e,r,r===Hb?Lb:0n,i])}async function Kb(t,e,r,i){let n=ot(new Uint8Array([10,...Te(se[10].evm,2),...Te(t,32),...Te(e,1),...Te(r,32),...Te(r===Hb?Lb:0n,32),...Te(i,1)]));return Uo(n,31)}function Nr(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function zb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function Rr(t){let e=BigInt(t.publicInputs[t.publicInputs.length-3]);if(e===0n)return 0;if(e===1n)return 1;if(e===2n)return 2;if(e===3n)return 3;if(e===4n)return 4;throw new Error("Invalid nullifier type")}function pr(t){return BigInt(t.publicInputs[4])}function Jp(t){return BigInt(t.publicInputs[3])}function eh(t){return BigInt(t.publicInputs[2])}function hr(t){return BigInt(t.publicInputs[0])}function th(t){return new Date(Number(BigInt(t.publicInputs[1]))*1e3)}function ia(t){return t.startsWith("data_check_integrity")?JC():t.startsWith("sig_check_id_data")?tI():t.startsWith("sig_check_dsc")?QC():t.startsWith("oprf_auth")?3:t.startsWith("outer")?8+(Number(t.substring(t.lastIndexOf("_")+1))-3):8}function qb(t){let e=t.endsWith("evm")?3:2;switch(t){case "compare_age":return se[1].standard+e;case "compare_age_evm":return se[1].evm+e;case "compare_birthdate":return se[2].standard+e;case "compare_birthdate_evm":return se[2].evm+e;case "compare_expiry":return se[3].standard+e;case "compare_expiry_evm":return se[3].evm+e;case "disclose_bytes":return se[0].standard+e;case "disclose_bytes_evm":return se[0].evm+e;case "inclusion_check_issuing_country":return se[6].standard+e;case "inclusion_check_issuing_country_evm":return se[6].evm+e;case "inclusion_check_nationality":return se[4].standard+e;case "inclusion_check_nationality_evm":return se[4].evm+e;case "exclusion_check_issuing_country":return se[7].standard+e;case "exclusion_check_issuing_country_evm":return se[7].evm+e;case "exclusion_check_nationality":return se[5].standard+e;case "exclusion_check_nationality_evm":return se[5].evm+e;case "bind":return se[8].standard+e;case "bind_evm":return se[8].evm+e;case "exclusion_check_sanctions":return se[9].standard+e;case "exclusion_check_sanctions_evm":return se[9].evm+e;case "facematch":return se[10].standard+e;case "facematch_evm":return se[10].evm+e;default:throw new Error(`Unknown circuit name: ${t}`)}}var fe=(t=>(t[t.DISCLOSE=0]="DISCLOSE",t[t.AGE=1]="AGE",t[t.BIRTHDATE=2]="BIRTHDATE",t[t.EXPIRY_DATE=3]="EXPIRY_DATE",t[t.NATIONALITY_INCLUSION=4]="NATIONALITY_INCLUSION",t[t.NATIONALITY_EXCLUSION=5]="NATIONALITY_EXCLUSION",t[t.ISSUING_COUNTRY_INCLUSION=6]="ISSUING_COUNTRY_INCLUSION",t[t.ISSUING_COUNTRY_EXCLUSION=7]="ISSUING_COUNTRY_EXCLUSION",t[t.BIND=8]="BIND",t[t.SANCTIONS_EXCLUSION=9]="SANCTIONS_EXCLUSION",t[t.FACEMATCH=10]="FACEMATCH",t))(fe||{}),se={0:{evm:180,standard:4},1:{evm:2,standard:2},2:{evm:16,standard:2},3:{evm:16,standard:2},4:{evm:600,standard:200},5:{evm:600,standard:200},6:{evm:600,standard:200},7:{evm:600,standard:200},8:{evm:509,standard:17},9:{evm:33,standard:2},10:{evm:98,standard:5}};Gl();var Gb=["North Korea","Iran","Iraq","Libya","Somalia","Sudan","Syrian Arab Republic","Yemen"],Vl=["Austria","Belgium","Bulgaria","Croatia","Cyprus","Czech Republic","Denmark","Estonia","Finland","France","Germany","Greece","Hungary","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Netherlands","Poland","Portugal","Romania","Slovakia","Slovenia","Spain","Sweden"],$b=[...Vl,"Iceland","Liechtenstein","Norway"],Vb=[...Vl.filter(t=>t!=="Cyprus"&&t!=="Ireland"),"Switzerland","Iceland","Liechtenstein","Norway"],jb=["Brunei Darussalam","Cambodia","Indonesia","Lao People's Democratic Republic","Malaysia","Myanmar","Philippines","Singapore","Thailand","Vietnam"],Xb=["Argentina","Brazil","Chile","Colombia","Paraguay","Uruguay"];Gl();var Lp=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,Lp.prototype);}};Lp=Dt([N({type:B.Set,itemType:wt})],Lp);var Hp=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Dt([g({type:S.Integer})],Hp.prototype,"number",2),Dt([g({type:S.OctetString})],Hp.prototype,"hash",2);var Kp=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Dt([g({type:S.PrintableString})],Kp.prototype,"ldsVersion",2),Dt([g({type:S.PrintableString})],Kp.prototype,"unicodeVersion",2);var Fp=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Dt([g({type:S.ObjectIdentifier})],Fp.prototype,"value",2),Fp=Dt([N({type:B.Choice})],Fp);var Ul=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Dt([g({type:S.Integer})],Ul.prototype,"version",2),Dt([g({type:mt})],Ul.prototype,"hashAlgorithm",2),Dt([g({type:Hp,repeated:"sequence"})],Ul.prototype,"dataGroups",2),Dt([g({type:Kp,optional:true})],Ul.prototype,"versionInfo",2);var Fl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Dt([g({type:S.Integer})],Fl.prototype,"version",2),Dt([g({type:$t,repeated:"set"})],Fl.prototype,"certificates",2),Fl=Dt([N({type:B.Sequence})],Fl);Gl();var iI=["https://eu.node0.zkp.oprf.taceo.network","https://eu.node1.zkp.oprf.taceo.network","https://eu.node2.zkp.oprf.taceo.network"],Wb="1";Gt.Point.fromAffine(Tn);ea.ORDER;async function Zb(t,e){let r=iI,i;for(let n of r)try{let o=await fetch(`${n}/oprf_pub/${t}`);if(!o.ok)throw new Error(`OPRF node returned ${o.status}`);let{key:s}=await o.json();return {x:BigInt(s[0]),y:BigInt(s[1])}}catch(o){i=o instanceof Error?o:new Error(String(o));}throw new Error(`Failed to fetch OPRF public key for key ID ${t}: ${i?.message}`)}async function Yb(t){return Me([t.x,t.y])}async function Qb(t,e){let r=Array.from(Buffer.from(_b(t).padStart(64,"0"),"hex")),i=Cb(r,32),n=ot(new Uint8Array([9,...Te(se[9].evm,2),...i,e?1:0]));return Uo(n,31)}async function rh(t,e){return Me([BigInt(9),BigInt(se[9].standard),BigInt(`0x${_b(t)}`),e?1n:0n])}function na(t){if(!t)return 0n;let e=ot(new TextEncoder().encode(t)).slice(0,31);return ZC(Array.from(e))}function cc(t){return na(t)}function nI(t,e=0){let r=[];for(let i=e;i<t.length;i+=32){let n=new Uint8Array(32),o=Math.min(i+32,t.length);for(let s=0;s<o-i;s++)n[s]=t[i+s];r.push(Buffer.from(n));}return r.map(i=>i.toString("hex"))}function oI(t,e){return t.slice(0,e)}function sI(t,e){return t.slice(e)}function oa(t,e,r=0){let i=nI(Buffer.from(t,"hex"),r),n=sI(i,e),o=oI(i,e);return {proof:n,publicInputs:o.map(s=>s.startsWith("0x")?s:`0x${s}`)}}function Jb(t){return BigInt(t.publicInputs[0])}function e6(t){return BigInt(t.publicInputs[1])}function t6(t){return new Date(Number(BigInt(t.publicInputs[2]))*1e3)}function ih(t){return BigInt(t.publicInputs[3])}function nh(t){return BigInt(t.publicInputs[4])}function r6(t){let e=BigInt(t.publicInputs[t.publicInputs.length-3]);if(e===0n)return 0;if(e===1n)return 1;if(e===2n)return 2;if(e===3n)return 3;if(e===4n)return 4;throw new Error("Invalid nullifier type")}function i6(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function n6(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function oh(t){return t.publicInputs.slice(5,t.publicInputs.length-3).map(BigInt)}if(typeof window>"u")try{let t=CC("crypto");crypto=t;}catch{}XC();var es=It(Il(),1);var aI=Object.defineProperty,cI=Object.getOwnPropertyDescriptor,lI=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),c6=(t,e)=>()=>(t&&(e=t(t=0)),e),Ot=(t,e,r,i)=>{for(var n=i>1?void 0:i?cI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&aI(e,r,n),n},Ui,lc,Wl=c6(()=>{Ui={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},lc={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),o6,s6,a6,dI=c6(()=>{Wl(),o6={p:lc.brainpoolP224r1.p,a:lc.brainpoolP224r1.a,b:lc.brainpoolP224r1.b,n:lc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(o6),Lr),s6={p:Ui["P-192"].p,a:Ui["P-192"].a,b:Ui["P-192"].b,n:Ui["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(s6),Jn),a6={p:Ui["P-224"].p,a:Ui["P-224"].a,b:Ui["P-224"].b,n:Ui["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(a6),Lr);});BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Wl();Wl();var ah=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,ah.prototype);}};ah=Ot([N({type:B.Set,itemType:wt})],ah);var ch=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Ot([g({type:S.Integer})],ch.prototype,"number",2),Ot([g({type:S.OctetString})],ch.prototype,"hash",2);var lh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Ot([g({type:S.PrintableString})],lh.prototype,"ldsVersion",2),Ot([g({type:S.PrintableString})],lh.prototype,"unicodeVersion",2);var sh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Ot([g({type:S.ObjectIdentifier})],sh.prototype,"value",2),sh=Ot([N({type:B.Choice})],sh);var jl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Ot([g({type:S.Integer})],jl.prototype,"version",2),Ot([g({type:mt})],jl.prototype,"hashAlgorithm",2),Ot([g({type:ch,repeated:"sequence"})],jl.prototype,"dataGroups",2),Ot([g({type:lh,optional:true})],jl.prototype,"versionInfo",2);var Xl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Ot([g({type:S.Integer})],Xl.prototype,"version",2),Ot([g({type:$t,repeated:"set"})],Xl.prototype,"certificates",2),Xl=Ot([N({type:B.Sequence})],Xl);Wl();Gt.Point.fromAffine(Tn);ea.ORDER;if(typeof window>"u")try{let t=lI("crypto");crypto=t;}catch{}dI();function uI(t){return "0x"+Buffer.from(t).toString("hex").padStart(64,"0")}function l6(t){let e=[];for(let r=0;r<t.length;r+=32)e.push(uI(t.slice(r,r+32)));return e}var fI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(fI||{});var pI=(t=>(t[t.DISCLOSE=0]="DISCLOSE",t[t.AGE=1]="AGE",t[t.BIRTHDATE=2]="BIRTHDATE",t[t.EXPIRY_DATE=3]="EXPIRY_DATE",t[t.NATIONALITY_INCLUSION=4]="NATIONALITY_INCLUSION",t[t.NATIONALITY_EXCLUSION=5]="NATIONALITY_EXCLUSION",t[t.ISSUING_COUNTRY_INCLUSION=6]="ISSUING_COUNTRY_INCLUSION",t[t.ISSUING_COUNTRY_EXCLUSION=7]="ISSUING_COUNTRY_EXCLUSION",t[t.BIND=8]="BIND",t[t.SANCTIONS_EXCLUSION=9]="SANCTIONS_EXCLUSION",t[t.FACEMATCH=10]="FACEMATCH",t))(pI||{});var hI=Object.defineProperty,mI=Object.getOwnPropertyDescriptor,gI=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),m6=(t,e)=>()=>(t&&(e=t(t=0)),e),Mt=(t,e,r,i)=>{for(var n=i>1?void 0:i?mI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&hI(e,r,n),n},Fi,dc,Jl=m6(()=>{Fi={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},dc={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),d6,u6,f6,yI=m6(()=>{Jl(),d6={p:dc.brainpoolP224r1.p,a:dc.brainpoolP224r1.a,b:dc.brainpoolP224r1.b,n:dc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(d6),Lr),u6={p:Fi["P-192"].p,a:Fi["P-192"].a,b:Fi["P-192"].b,n:Fi["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(u6),Jn),f6={p:Fi["P-224"].p,a:Fi["P-224"].a,b:Fi["P-224"].b,n:Fi["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(f6),Lr);}),Ql=class Qe{constructor(e){this.bytes=Qe.convertToBytes(e);}static convertToBytes(e){if(typeof e=="bigint"||typeof e=="number"){let r=e.toString(16),i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}if(e instanceof Uint8Array)return new Uint8Array(e);if(Buffer.isBuffer(e))return new Uint8Array(e);if(Array.isArray(e)){if(!e.every(r=>typeof r=="number"&&r>=0&&r<=255))throw new Error("Invalid byte array: values must be between 0 and 255");return new Uint8Array(e)}if(e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e=="string"){if(Qe.isHexString(e)){let r=e.startsWith("0x")?e.slice(2):e,i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}try{let r=BigInt(e);return Qe.convertToBytes(r)}catch{return new Uint8Array(Buffer.from(e,"ascii"))}}throw new Error("Unsupported data type")}static isHexString(e){let r=e.startsWith("0x")?e.slice(2):e;return /^[0-9a-fA-F]*$/.test(r)}static from(e){return new Qe(e)}static fromHex(e){if(!Qe.isHexString(e))throw new Error("Invalid hex string");return new Qe(e.startsWith("0x")?e:"0x"+e)}static fromBuffer(e){return new Qe(e)}static fromBase64(e){let r=atob(e);return new Qe(Uint8Array.from(r,i=>i.charCodeAt(0)))}static empty(){return new Qe(new Uint8Array(0))}static zero(e){return new Qe(new Uint8Array(e))}toBigInt(){return BigInt("0x"+this.toHex().slice(2))}toUInt8Array(){return new Uint8Array(this.bytes)}toNumberArray(){return Array.from(this.bytes)}toHex(){return "0x"+Array.from(this.bytes).map(e=>e.toString(16).padStart(2,"0")).join("")}toBuffer(){return Buffer.from(this.bytes)}toString(e="hex"){return e==="hex"?this.toHex().slice(2):Buffer.from(this.bytes).toString(e)}toBase64(){return btoa(String.fromCharCode(...this.bytes))}toJSON(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return `Binary(${this.toHex()})`}[Symbol.toPrimitive](e){switch(e){case "number":return Number(this.toBigInt());case "string":return `Binary(${this.toHex()})`;default:return this.toBigInt()}}valueOf(){return this.toBigInt()}get length(){return this.bytes.length}*[Symbol.iterator](){yield*this.bytes;}equals(e){return this.length!==e.length?false:this.bytes.every((r,i)=>r===e.bytes[i])}slice(e,r){return new Qe(this.bytes.slice(e,r))}concat(e){return new Qe([...this.toNumberArray(),...e.toNumberArray()])}[Symbol.for("+")](e){return this.concat(e)}compare(e){let r=Math.min(this.length,e.length);for(let i=0;i<r;i++){let n=this.bytes[i]-e.bytes[i];if(n!==0)return n}return this.length-e.length}xor(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for XOR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]^e.bytes[i];return new Qe(r)}and(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for AND operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]&e.bytes[i];return new Qe(r)}or(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for OR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]|e.bytes[i];return new Qe(r)}not(){let e=new Uint8Array(this.length);for(let r=0;r<this.length;r++)e[r]=~this.bytes[r]&255;return new Qe(e)}padStart(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.fill(r,0,e-this.length),i.set(this.bytes,e-this.length),new Qe(i)}padEnd(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.set(this.bytes),i.fill(r,this.length),new Qe(i)}};function Dr(t,e){if(!t)throw new Error(e)}function sa(t,e){if(t.length===0)return [];let r=Math.ceil(t.length/e),i=new Array(r),n=t.length%e||e,o=0;for(let s=r-1;s>=0;s--){let a=s===r-1?n:e,c=0n;for(let d=0;d<a;d++)c=c<<8n|BigInt(t[o++]);let l=c.toString(16);i[s]="0x"+(l.length%2?"0":"")+l;}return i}var ed=class{constructor(t,e=2){this.depth=t,this.arity=e,this.zeroes=[],this.nodes=[];}get root(){return `0x${this.nodes[this.depth][0].toString(16).padStart(64,"0")}`}get leaves(){return this.nodes[0].slice()}async initialize(t,e=[]){if(e.length>this.arity**this.depth)throw new Error(`The tree cannot contain more than ${this.arity**this.depth} leaves`);if(new Set(e.map(r=>r.toString())).size!==e.length)throw new Error("Duplicate leaves");for(let r=0;r<this.depth;r+=1)this.zeroes.push(t),this.nodes[r]=[],t=await Me(Array(this.arity).fill(t).map(i=>BigInt(i)));if(this.nodes[this.depth]=[],e.length>0){this.nodes[0]=e;for(let r=0;r<this.depth;r+=1)for(let i=0;i<Math.ceil(this.nodes[r].length/this.arity);i+=1){let n=i*this.arity,o=[];for(let s=0;s<this.arity;s+=1)o.push(this.nodes[r][n+s]??this.zeroes[r]);this.nodes[r+1][i]=await Me(o.map(s=>BigInt(s)));}}else this.nodes[this.depth][0]=t;}serialize(){return this.nodes.map(t=>t.map(e=>`0x${e.toString(16).padStart(64,"0")}`))}};BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Jl();Jl();var fh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,fh.prototype);}};fh=Mt([N({type:B.Set,itemType:wt})],fh);var ph=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Mt([g({type:S.Integer})],ph.prototype,"number",2),Mt([g({type:S.OctetString})],ph.prototype,"hash",2);var hh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Mt([g({type:S.PrintableString})],hh.prototype,"ldsVersion",2),Mt([g({type:S.PrintableString})],hh.prototype,"unicodeVersion",2);var dh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Mt([g({type:S.ObjectIdentifier})],dh.prototype,"value",2),dh=Mt([N({type:B.Choice})],dh);var Zl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Mt([g({type:S.Integer})],Zl.prototype,"version",2),Mt([g({type:mt})],Zl.prototype,"hashAlgorithm",2),Mt([g({type:ph,repeated:"sequence"})],Zl.prototype,"dataGroups",2),Mt([g({type:hh,optional:true})],Zl.prototype,"versionInfo",2);var Yl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Mt([g({type:S.Integer})],Yl.prototype,"version",2),Mt([g({type:$t,repeated:"set"})],Yl.prototype,"certificates",2),Yl=Mt([N({type:B.Sequence})],Yl);Jl();Gt.Point.fromAffine(Tn);ea.ORDER;if(typeof window>"u")try{let t=gI("crypto");crypto=t;}catch{}yI();var bI="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",p6=[18,32];function SI(t){if(!(t instanceof Uint8Array))throw new Error("Input must be a Uint8Array");if(t.length===0)return "";let e=0;for(;e<t.length&&t[e]===0;)e++;let r=BigInt(0);for(let n=e;n<t.length;n++)r=r*BigInt(256)+BigInt(t[n]);let i="";for(;r>0n;){let n=Number(r%BigInt(58));i=bI[n]+i,r=r/BigInt(58);}return "1".repeat(e)+i}function mh(t){if(!t||typeof t!="string")throw new Error("Input must be a non-empty hex string");if(!t.match(/^(0x)?[0-9a-fA-F]+$/i))throw new Error("Invalid hex string format");t=t.startsWith("0x")?t.substring(2):t,t.length>64?t=t.substring(t.length-64):t.length<64&&(t=t.padStart(64,"0"));let e=new Uint8Array(34);e[0]=p6[0],e[1]=p6[1];for(let r=0;r<t.length;r+=2){let i=parseInt(t.substring(r,r+2),16);e[2+r/2]=i;}return SI(e)}var xI=16,AI=14,wI=8,_I=12,td=0n;var CI=1;var Lo=1,Ho=2,rd=3;function h6(t,e=253){let r=Math.pow(26,2),i=Math.ceil(r/e),n=Array(i).fill(0n),o=65;for(let s of t){let a=(s.charCodeAt(0)-o)*26+s.charCodeAt(1)-o,c=Math.floor(a/e);n[c]|=1n<<BigInt(a%e);}return n}function II(t){if(t.type==="RSA")return Ql.from(t.modulus).toUInt8Array();if(t.type==="EC")return Ql.from(t.public_key_x).concat(Ql.from(t.public_key_y)).toUInt8Array();throw new Error("Unsupported signature algorithm")}async function vI(t,e){let r=e?.version??0;Dr(r===0||r===1,`Unsupported Packaged Certificates version: ${r}`);let i=e?.tags?h6(e.tags):t?.tags?h6(t.tags):[0n,0n,0n];Dr(i.length===3,"Tags must be exactly 3 fields");let n=e?.type??CI;Dr(n>=0&&n<=255,`Certificate type must fit in a single byte: ${n}`),Dr(t?.country?.length===3,`Country code must be 3 characters: ${t?.country}`);let o=II(t.public_key);if(r===0)return Me([...i,BigInt(sa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2)]),31)[0]),...sa(o,31).map(s=>BigInt(s))]);if(r===1){Dr(t.fingerprint!==void 0,"Certificate fingerprint required");let s=BigInt(t.fingerprint),a=new Uint8Array(4);return a[0]=t.validity.not_after>>24&255,a[1]=t.validity.not_after>>16&255,a[2]=t.validity.not_after>>8&255,a[3]=t.validity.not_after&255,Me([...i,BigInt(sa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2),...a]),31)[0]),s,...sa(o,31).map(c=>BigInt(c))])}else throw new Error(`Unsupported Packaged Certificates version: ${r}`)}async function EI(t,e=0){let r=await Promise.all(t.map(i=>vI(i,{version:e})));return r.sort((i,n)=>i>n?1:i<n?-1:0),r}async function BI(t,e=0){let r=await EI(t,e),i=new ed(xI,2);return await i.initialize(td,r),i}async function TI(t){Dr(t.fingerprint!==void 0,"Revocation fingerprint required"),Dr(t.serial!==void 0,"Revocation serial required"),Dr(typeof t.fingerprint=="string"&&t.fingerprint.startsWith("0x"),`Revocation fingerprint must be a 0x-prefixed hex string: ${t.fingerprint}`),Dr(typeof t.serial=="string"&&t.serial.startsWith("0x"),`Revocation serial must be a 0x-prefixed hex string: ${t.serial}`);let e=Ql.from(t.serial).toUInt8Array(),r=await Me(sa(e,31).map(i=>BigInt(i)));return Me([BigInt(t.fingerprint),r])}async function kI(t){let e=await Promise.all(t.map(r=>TI(r)));return e.sort((r,i)=>r>i?1:r<i?-1:0),e}async function PI(t){let e=await kI(t),r=new ed(AI,2);return await r.initialize(td,e),r}async function NI(t){let e=t.map(i=>BigInt(i));e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(wI,2);return await r.initialize(td,e),r}var RI=21888242871839275222246405745257275088548364400416034343698204186575808495617n;function uh(t,e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{1,64}$/.test(e))throw new Error(`${t} must be a 0x-prefixed hex string of at most 64 hex chars: ${e}`);let r=BigInt(e);if(r>=RI)throw new Error(`${t} must be in [0, BN254_FIELD_MODULUS): ${r}`);return r}async function DI(t){let{schemaVersion:e,timestamp:r,certificateRoot:i,revocationRoot:n,masterlistRoot:o}=t;Dr(Number.isInteger(e)&&e>=0&&e<=65535,`Schema version must be an integer that fits in 2 bytes: ${e}`),Dr(Number.isInteger(r)&&r>=0&&r<=4294967295,`Timestamp must be an integer that fits in 4 bytes: ${r}`);let s=uh("certificateRoot",i),a=uh("revocationRoot",n),c=uh("masterlistRoot",o),l=await Me([s,a,c]),d=new Uint8Array([e>>>8&255,e&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255]),u=BigInt(sa(d,31)[0]);return {certificateRoot:`0x${(await Me([u,l])).toString(16).padStart(64,"0")}`,stateRoot:`0x${l.toString(16).padStart(64,"0")}`}}async function g6(t){let e=t.version??0,r=await BI(t.certificates,e);if(e===0)return r.root;if(e===1){let i=t,n=await PI(i.revocations??[]),o=await NI(i.masterlists??[]),{certificateRoot:s}=await DI({schemaVersion:e,timestamp:i.timestamp,certificateRoot:r.root,revocationRoot:n.root,masterlistRoot:o.root});return s}else throw new Error(`Unsupported Packaged Certificates schema version: ${e}`)}async function y6(t){let e;if(t.circuits!==void 0)e=t.circuits.map(i=>BigInt(i.vkey_hash));else if(t.hashes!==void 0)e=t.hashes.map(i=>BigInt(i));else throw new Error("Either circuits or hashes must be provided");e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(_I,2);return await r.initialize(td,e),r.root}var C6=It(uc(),1);function Sh(t){return YI.find(e=>e.chainId===t)}function ad(t){let e=Sh(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e}var gh="https://certificates.zkpassport.id/mainnet",jI="https://certificates.zkpassport.id/testnet",XI="http://localhost:8000/root",yh="https://circuits2.zkpassport.id/mainnet",WI="https://circuits2.zkpassport.id/testnet",ZI="http://localhost:8000",YI=[{chainId:Oi("ethereum"),chain:"ethereum",type:"mainnet",rpcUrl:"https://eth-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x8C93bB3a7ED88dA0647Ea53f8cd3f57832a513Cd",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("base"),chain:"base",type:"mainnet",rpcUrl:"https://base-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0xC404C605130F3345E1A2BFdf3BAFABED7234cCa7",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("robinhood"),chain:"robinhood",type:"mainnet",rpcUrl:"https://rpc.mainnet.chain.robinhood.com",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x0A55cA59e98e17666C1A9a099d546E676088bC1A",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("ethereum_sepolia"),chain:"ethereum_sepolia",type:"testnet",rpcUrl:"https://eth-sepolia.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x6Ee299B1E8049fadc3494f1110A3479f5BE8EC0e",packagedCertificatesUrl:jI,circuitUrl:WI},{chainId:Oi("local"),chain:"local",type:"dev",rpcUrl:"http://localhost:8545",rootRegistry:"0x5FbDB2315678afecb367f032d93F642f64180aa3",registryHelper:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",packagedCertificatesUrl:XI,circuitUrl:ZI}];function da(t){return t.startsWith("0x")?t.slice(2):t}function _t(t){return typeof t=="bigint"?`0x${t.toString(16).toLowerCase().padStart(64,"0")}`:`0x${da(t).toLowerCase().padStart(64,"0")}`}var QI=3,JI=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).packagedCertificatesUrl}/${e}.json`),ev="https://sanctions.zkpassport.id/mainnet",tv="https://sanctions.zkpassport.id/testnet",rv="http://localhost:8000/sanctions",iv=(t,e)=>(e=_t(e),t===1||t===8453?`${ev}/${e}.tree.json.gz`:t===11155111?`${tv}/${e}.tree.json.gz`:`${rv}/${e}.tree.json.gz`),nv=(t,{root:e,version:r,cid:i})=>{if(e)return e=_t(e),`${ad(t).circuitUrl}/by-root/${e}/manifest.json`;if(r)return `${ad(t).circuitUrl}/by-version/${r}/manifest.json`;if(i)return `https://ipfs.zkpassport.id/ipfs/${i}`;throw new Error("No root, version or cid provided")},ov=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).circuitUrl}/by-hash/${e}.json`),od=100,sv="0xc3bc16e8",w6="0x06ac4103",_6="0xcb0c82c7",av="0x76785af8",cv="0x5d8d57a6",lv="0xbb3dd539",dv="0x2aae4296",uv=[{country:"RUS",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"JPN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"GBR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"IDN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"NGA",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"DEU",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"EST",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LVA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SGP",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"VNM",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"TUR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"THA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"BRA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ARG",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"AUT",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"FRA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"PRT",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ESP",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"IRL",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ITA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CHE",id_card_support:0,residence_permit_support:.5,passport_support:1},{country:"BEL",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LUX",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NLD",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"POL",id_card_support:.25,residence_permit_support:.25,passport_support:1},{country:"DNK",id_card_support:0,residence_permit_support:.5,passport_support:1},{country:"SWE",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NOR",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SVN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CZE",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NOR",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LTU",id_card_support:.5,residence_permit_support:.5,passport_support:.5},{country:"FIN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"MEX",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"IND",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"PAK",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"IRN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"GRC",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ROU",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"KAZ",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"BLR",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"MAR",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"DZA",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"URY",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"PRY",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CHL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PER",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"ECU",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"PAN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"VEN",id_card_support:0,residence_permit_support:0,passport_support:0},{country:"COL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CRI",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"USA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CAN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"GHA",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"SEN",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"ETH",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"JOR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"OMN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CHN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"KOR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PRK",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"UAE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ARE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ISR",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"SAU",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"AUS",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"NZL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"MYS",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"TWN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PHL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"UZB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"UZB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"TKM",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"TJK",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"GEO",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ARM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"AZE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"CYP",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"RKS",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"MNE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ALB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"HRV",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SRB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"HUN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"MDA",id_card_support:0,residence_permit_support:0,passport_support:0},{country:"UKR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"BGR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"LIE",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"VAT",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"SMR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"JAM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"SLE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BEN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"CMR",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"KEN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"UGA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"RWA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"TZA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"ZWE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BWA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"YEM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"LBN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"QAT",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"KWT",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"IRQ",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"PSE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"ISL",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"MCO",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"MNG",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"AND",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ATG",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"BHR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BRB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"BLZ",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BIH",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"BMU",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"DMA",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"CIV",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"NPL",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"MKD",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"KNA",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"VCT",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"SYC",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"SYR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BHS",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"GMB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ZWE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"TLS",id_card_support:0,residence_permit_support:0,passport_support:.25}],Ft=(0, C6.default)("zkpassport:registry"),sd=t=>t.toString(16).padStart(64,"0");function xh(t,e={}){let r=typeof t=="number"?t:Oi(t);if(!Sh(r))throw new Error(`Unsupported chain: ${t}`);return new fv({...e,chainId:r})}var fv=class bh{constructor({rpcUrl:e,rootRegistry:r,chainId:i,registryHelper:n,packagedCertsUrlGenerator:o,circuitManifestUrlGenerator:s,packagedCircuitUrlGenerator:a,sanctionsTreeUrlGenerator:c,retryCount:l}={}){if(i===void 0)throw new Error("chainId is required");this.chainId=i;let d=Sh(i),u=e||d?.rpcUrl,h=r||d?.rootRegistry,m=n||d?.registryHelper;if(!u||!h||!m)throw new Error(`Unsupported chain ID: ${i}`);this.rpcUrl=u,this.rootRegistry=h,this.registryHelper=m,this.packagedCertsUrlGenerator=o||JI,this.circuitManifestUrlGenerator=s||nv,this.packagedCircuitUrlGenerator=a||ov,this.sanctionsTreeUrlGenerator=c||iv,this.retryCount=l||QI;}async getLatestCertificateRoot(){return this.getLatestRoot(Lo,"certificate")}async isCertificateRootValid(e,r){return this.isRootValid(Lo,"certificate",e,r)}async getCertificates(e,{validate:r=true,ipfs:i=false}={}){if(e?e=_t(e):e=await this.getLatestCertificateRoot(),i)throw new Error("IPFS flag not implemented");let n=await this.fetchJson(this.packagedCertsUrlGenerator(this.chainId,e),`certificates for root ${e}`);if(n.version||(n.version=0),Ft(`Got ${n.certificates?.length||0} packaged certificates (schema version ${n.version})`),!n.certificates||!Array.isArray(n.certificates))throw new Error("Invalid certificates returned");let o=n.version===0?n.serialised:n.certificates_serialised;if(!o||!Array.isArray(o))throw new Error("Invalid serialised certificates tree returned");for(let s of n.certificates)s.fingerprint&&(s.fingerprint=_t(s.fingerprint));if(r&&!await bh.validateCertificates(n,e))throw new Error(`Validation failed for packaged certificates: ${e}`);return n}static async validateCertificates(e,r){try{let i=await g6(e),n=_t(r),o=i.toLowerCase()===n.toLowerCase();return Ft(o?`Validated packaged certificates against root ${i}`:`Error validating packaged certificates. Expected: ${n} Got: ${i}`),o}catch(i){return console.error("Error validating circuit manifest:",i),false}}async getHistoricalCertificateRoots(e,r=od){let i=typeof e=="string"?da(e):e??1,n=typeof i=="number"?`${w6}${Lo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${_6}${Lo.toString(16).padStart(64,"0")}${i.padStart(64,"0")}${r.toString(16).padStart(64,"0")}`;try{let o=await this.rpcRequest(this.registryHelper,n);return this._handleHistoricalRootsResponse(o)}catch(o){throw o instanceof Error?o:new Error(String(o))}}async getAllHistoricalCertificateRoots(e=od,r){let i=0,n=false,o=1,s=[];for(;!n;){let{roots:a,isLastPage:c}=await this.getHistoricalCertificateRoots(o,e);if(s.push(...a),n=c,i++,a.length>0&&(o+=a.length),r&&r(i,a,s.length,n),a.length===0)break}return s}async getCertificateRootDetails(e){return this.getRootDetails(Lo,"certificate",e)}async getLatestCircuitRoot(){return this.getLatestRoot(Ho,"circuit")}async isCircuitRootValid(e,r){return this.isRootValid(Ho,"circuit",e,r)}async getCircuitManifest(e,{validate:r=true,ipfs:i=false,version:n=void 0}={}){if(!e&&!n?e=await this.getLatestCircuitRoot():e&&(e=_t(e)),i)throw new Error("IPFS flag not implemented");let o=await this.fetchJson(this.circuitManifestUrlGenerator(this.chainId,{root:e,version:n}),`circuit manifest for root ${e}`);if(!o.version||!o.root||!o.circuits)throw new Error("Invalid circuit manifest returned");if(Ft(`Got circuit manifest for root ${e}`),r&&!await this.validateCircuitManifest(o,e))throw new Error(`Validation failed for circuit manifest: ${e}`);return o}async validateCircuitManifest(e,r){try{let i=Object.values(e.circuits).map(a=>a.hash),n=_t(await y6({hashes:i})),o=_t(r||e.root),s=n.toLowerCase()===o.toLowerCase();return Ft(s?`Validated circuit manifest against root ${n}`:`Error validating circuit manifest. Expected: ${o} Got: ${n}`),s}catch(i){return console.error("Error validating circuit manifest:",i),false}}static async validatePackagedCircuit(e,r){let i=_t(r||e.vkey_hash),n=l6(Hl.fromBase64(e.vkey).toUInt8Array()),o=_t((await Me(n.map(BigInt))).toString(16)),s=o===i;return Ft(s?`Validated packaged circuit against hash ${i}`:`Error validating packaged circuit. Expected: ${i} Got: ${o}`),s}async getPackagedCircuit(e,r,{validate:i=true,ipfs:n=false}={}){if(n)throw new Error("IPFS flag not implemented");let o=r.circuits[e]?.hash||null;if(!o)throw new Error(`Circuit ${e} not found in manifest`);let s=await this.fetchJson(this.packagedCircuitUrlGenerator(this.chainId,o),`packaged circuit for ${e}`);if(!s.name||!s.hash||!s.noir_version||!s.bb_version)throw new Error(`Invalid packaged circuit returned for ${e}`);if(Ft(`Got packaged circuit for ${e}`),i&&!await bh.validatePackagedCircuit(s,o))throw new Error(`Validation failed for packaged circuit: ${e}`);return s}async getHistoricalCircuitRoots(e,r=od){let i=typeof e=="string"?da(e):e??1,n=typeof i=="number"?`${w6}${Ho.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${_6}${Ho.toString(16).padStart(64,"0")}${i.padStart(64,"0")}${r.toString(16).padStart(64,"0")}`;try{let o=await this.rpcRequest(this.registryHelper,n);return this._handleHistoricalRootsResponse(o)}catch(o){throw o instanceof Error?o:new Error(String(o))}}async getAllHistoricalCircuitRoots(e=od,r){let i=0,n=false,o=1,s=[];for(;!n;){let{roots:a,isLastPage:c}=await this.getHistoricalCircuitRoots(o,e);if(s.push(...a),n=c,i++,a.length>0&&(o+=a.length),r&&r(i,a,s.length,n),a.length===0)break}return s}async getCircuitRootDetails(e){return this.getRootDetails(Ho,"circuit",e)}async getLatestSanctionsRoot(){return this.getLatestRoot(rd,"sanctions")}async isSanctionsRootValid(e,r){return this.isRootValid(rd,"sanctions",e,r)}async getSanctionsTree(e,{validate:r=true}={}){e?e=_t(e):e=await this.getLatestSanctionsRoot();let i=await this.fetchJson(this.sanctionsTreeUrlGenerator(this.chainId,e),`sanctions tree for root ${e}`,{headers:{"Accept-Encoding":"gzip"}});if(!Array.isArray(i)||!i.every(n=>Array.isArray(n)))throw new Error("Invalid serialised sanctions tree returned");if(Ft(`Got sanctions tree with ${i.length} layers for root ${e}`),r){let n=i[i.length-1]?.[0];if(!(n!==void 0&&_t(n)===e.toLowerCase()))throw new Error(`Validation failed for sanctions tree: ${e}`)}return {root:e,serialised:i}}async getSanctionsRootDetails(e){return this.getRootDetails(rd,"sanctions",e)}async getRegistryAddress(e){Ft(`Getting registry address for ID ${e} from root registry ${this.rootRegistry}`);let r;if(typeof e=="string"&&e.startsWith("0x"))r=`0x${e.substring(2).padStart(64,"0")}`;else if(typeof e=="number")r=`0x${e.toString(16).padStart(64,"0")}`;else throw new Error(`Invalid registry ID: ${e}`);try{let i=await this.rpcRequest(this.rootRegistry,`${cv}${r.slice(2)}`);if(!i.ok)throw new Error(`Error getting address for registry ID ${e}: ${i.status} ${i.statusText}`);let n=await i.json();if(n.error)throw new Error(`Error getting address for registry ID ${e}: ${n.error.message}`);if(n.result==="0x0000000000000000000000000000000000000000000000000000000000000000")throw new Error(`Registry ID ${e} doesn't exist`);let o=`0x${n.result.slice(-40)}`;return Ft(`Got address for registry ID ${e}: ${o}`),o}catch(i){throw new Error(`Error getting address for registry ID ${e}: ${i}`)}}async isDocumentSupported(e,r,i="passport"){if(r&&!(await this.getCertificates()).certificates.filter(o=>o.country===e).some(o=>Math.floor(r.getTime()/1e3)>=o.validity.not_before))return 0;let n=uv.find(o=>o.country===e);return n?n[`${i}_support`]:0}getRpcUrl(){return this.rpcUrl}getRootRegistryAddress(){return this.rootRegistry}getRegistryHelperAddress(){return this.registryHelper}async getCertificateRegistryAddress(){return this.getRegistryAddress(Lo)}async getCircuitRegistryAddress(){return this.getRegistryAddress(Ho)}getUrlForPackagedCertificates(e,r){return this.packagedCertsUrlGenerator(this.chainId,e,r)}getUrlForCircuitManifestByRoot(e){return this.circuitManifestUrlGenerator(this.chainId,{root:e})}getUrlForCircuitManifestByVersion(e){return this.circuitManifestUrlGenerator(this.chainId,{version:e})}getUrlForCircuitManifestByCid(e){return this.circuitManifestUrlGenerator(this.chainId,{cid:e})}getUrlForPackagedCircuits(e,r){return this.packagedCircuitUrlGenerator(this.chainId,e,r)}async getLatestRoot(e,r){Ft(`Getting latest ${r} root`,{registry:this.rootRegistry});let i=await this.rpcRequest(this.rootRegistry,sv+sd(e));if(!i.ok)throw new Error(`Failed to get latest ${r} root: ${i.status} ${i.statusText}`);let n=await i.json();if(n.error)throw new Error(`Error from blockchain: ${n.error.message}`);return Ft(`Got latest ${r} root: ${n.result}`),n.result}async isRootValid(e,r,i,n){i=_t(i);let o=n??Math.floor(Date.now()/1e3),s=await this.rpcRequest(this.rootRegistry,dv+sd(e)+da(i)+o.toString(16).padStart(64,"0"));if(!s.ok)throw new Error(`Error checking if ${r} root is valid: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw new Error(`Error from blockchain: ${a.error.message}`);return parseInt(da(a.result))===1}async getRootDetails(e,r,i){if(i){Ft(`Getting ${r} root details`);let o=await this.rpcRequest(this.registryHelper,lv+sd(e)+da(i).padStart(64,"0"));if(!o.ok)throw new Error(`Failed to get ${r} root details: ${o.status} ${o.statusText}`);return this._handleRootDetailsResponse(o)}Ft(`Getting latest ${r} root details`);let n=await this.rpcRequest(this.registryHelper,av+sd(e));if(!n.ok)throw new Error(`Failed to get latest ${r} root details: ${n.status} ${n.statusText}`);return this._handleRootDetailsResponse(n)}async fetchJson(e,r,i){Ft(`Getting ${r} from:`,e);let n=await Vp(()=>fetch(e,i),this.retryCount);if(!n.ok)throw new Error(`Failed to get ${r}: ${n.status} ${n.statusText}, URL: ${e}`);return await n.json()}async rpcRequest(e,r){return Vp(()=>fetch(this.rpcUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:Math.floor(Math.random()*1e6),method:"eth_call",params:[{to:e,data:r},"latest"]})}),this.retryCount)}async _handleRootDetailsResponse(e){let r=await e.json();if(r.error)throw new Error(`Error from node: ${r.error.message}`);if(r.result){let i=r.result.slice(2),n=parseInt(i.slice(0,64),16),o=`0x${i.slice(64,128)}`,s=new Date(parseInt(i.slice(128,192),16)*1e3),a=parseInt(i.slice(192,256),16),c=a===0?void 0:new Date(a*1e3),l=parseInt(i.slice(256,320),16)===1,d=parseInt(i.slice(320,384),16),u=mh(`0x${i.slice(384,448)}`),h=i.slice(448,512),m=i.slice(512,576),b=i.slice(576,640),A=h===""?void 0:`0x${h}`,x=m===""?void 0:`0x${m}`,y=b===""?void 0:`0x${b}`;return {index:n,root:o,validFrom:s,validTo:c,revoked:l,leaves:d,cid:u,...A!==void 0&&{metadata1:A},...x!==void 0&&{metadata2:x},...y!==void 0&&{metadata3:y},isLatest:c===void 0}}else throw new Error("No result returned from node")}async _handleHistoricalRootsResponse(e){let r=await e.json();if(r.error)throw new Error(r?.error?.message||"Error getting roots");if(r.result){let i=r.result.slice(2),n=parseInt(i.slice(0,64),16),o=parseInt(i.slice(64,128),16)===1,s=i.slice(n*2),a=parseInt(s.slice(0,64),16),c=[],l=10;for(let d=0;d<a;d++){let u=64+d*l*64,h=parseInt(s.slice(u,u+64),16),m=`0x${s.slice(u+64,u+128)}`,b=new Date(parseInt(s.slice(u+128,u+192),16)*1e3),A=parseInt(s.slice(u+192,u+256),16),x=A===0?void 0:new Date(A*1e3),y=parseInt(s.slice(u+256,u+320),16)===1,w=parseInt(s.slice(u+320,u+384),16),I=mh(`0x${s.slice(u+384,u+448)}`),_=s.slice(u+448,u+512),C=s.slice(u+512,u+576),v=s.slice(u+576,u+640),T=_===""?void 0:`0x${_}`,G=C===""?void 0:`0x${C}`,F=v===""?void 0:`0x${v}`;c.push({root:m,validFrom:b,validTo:x,revoked:y,cid:I,leaves:w,...T!==void 0&&{metadata1:T},...G!==void 0&&{metadata2:G},...F!==void 0&&{metadata3:F},isLatest:d===a-1&&o,index:h});}return {roots:c,isLastPage:o}}return {roots:[],isLastPage:true}}};var I6=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function pv(){return typeof process<"u"&&process.versions!=null&&typeof window>"u"}async function cd(t,e){if(pv())try{let r=await Promise.resolve().then(()=>It(E6(),1)).catch(()=>{try{return {default:I6("ws")}}catch{throw new Error("WebSocket implementation 'ws' not found. Please install it with: npm install ws")}}),i=r.default||r.WebSocket||r;return new i(t,{headers:{Origin:e||"nodejs"}})}catch(r){throw console.error("Failed to create WebSocket client:",r),new Error("WebSocket implementation 'ws' not found. Please install it with: npm install ws")}return new WebSocket(t)}var B6=10,T6="wss://bridge.zkpassport.id",k6=3e4,ua="1";var hv=typeof window<"u"?{getRandomValues:t=>window.crypto.getRandomValues(t)}:globalThis.crypto,Ah=typeof window<"u"?window.crypto:typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:hv;function P6(t){let e=new Uint8Array(t);if(Ah&&typeof Ah.getRandomValues=="function")return Ah.getRandomValues(e),e;throw new Error("No secure random number generator available in this environment. Make sure you're in a secure context that provides crypto APIs.")}function wh(t){try{let e=new URL(t);return `${e.protocol}//${e.host.split(":")[0]}`}catch{return t}}function fa(t=16){let e=P6(t);return Buffer.from(e).toString("hex")}function N6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(t,...e){if(!N6(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 fc(t,e=true){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 _h(t,e){at(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function R6(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Or(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mr(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function pa(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}var gv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,yv=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pc(t){if(at(t),yv)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=bv[t[r]];return e}function Ch(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ha(t){if(typeof t=="string")t=Ch(t);else if(N6(t))t=zo(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function D6(t,e){if(t.length!==e.length)return false;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}var O6=(t,e)=>{function r(i,...n){if(at(i),!gv)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){let d=n[0];if(!d)throw new Error("nonce / iv required");t.varSizeNonce?at(d):at(d,t.nonceLength);}let o=t.tagLength;o&&n[1]!==void 0&&at(n[1]);let s=e(i,...n),a=(d,u)=>{if(u!==void 0){if(d!==2)throw new Error("cipher output not supported");at(u);}},c=false;return {encrypt(d,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=true,at(d),a(s.encrypt.length,u),s.encrypt(d,u)},decrypt(d,u){if(at(d),o&&d.length<o)throw new Error("invalid ciphertext length: smaller than tagLength="+o);return a(s.decrypt.length,u),s.decrypt(d,u)}}}return Object.assign(r,t),r};function M6(t,e,r=true){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!hc(e))throw new Error("invalid output, must be aligned");return e}function ld(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);let n=BigInt(32),o=BigInt(4294967295),s=Number(r>>n&o),a=Number(r&o),c=0,l=4;t.setUint32(e+c,s,i),t.setUint32(e+l,a,i);}function U6(t,e,r){let i=new Uint8Array(16),n=pa(i);return ld(n,0,BigInt(e),r),ld(n,8,BigInt(t),r),i}function hc(t){return t.byteOffset%4===0}function zo(t){return Uint8Array.from(t)}var Li=16,vh=new Uint8Array(16),ti=Or(vh),Sv=225,xv=(t,e,r,i)=>{let n=i&1;return {s3:r<<31|i>>>1,s2:e<<31|r>>>1,s1:t<<31|e>>>1,s0:t>>>1^Sv<<24&-(n&1)}},mr=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function Av(t){t.reverse();let e=t[15]&1,r=0;for(let i=0;i<t.length;i++){let n=t[i];t[i]=n>>>1|r,r=(n&1)<<7;}return t[0]^=-e&225,t}var wv=t=>t>64*1024?8:t>1024?4:2,dd=class{constructor(e,r){this.blockLen=Li,this.outputLen=Li,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=false,e=ha(e),at(e,16);let i=pa(e),n=i.getUint32(0,false),o=i.getUint32(4,false),s=i.getUint32(8,false),a=i.getUint32(12,false),c=[];for(let b=0;b<128;b++)c.push({s0:mr(n),s1:mr(o),s2:mr(s),s3:mr(a)}),{s0:n,s1:o,s2:s,s3:a}=xv(n,o,s,a);let l=wv(r||1024);if(![1,2,4,8].includes(l))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;let u=128/l,h=this.windowSize=2**l,m=[];for(let b=0;b<u;b++)for(let A=0;A<h;A++){let x=0,y=0,w=0,I=0;for(let _=0;_<l;_++){if(!(A>>>l-_-1&1))continue;let{s0:v,s1:T,s2:G,s3:F}=c[l*b+_];x^=v,y^=T,w^=G,I^=F;}m.push({s0:x,s1:y,s2:w,s3:I});}this.t=m;}_updateBlock(e,r,i,n){e^=this.s0,r^=this.s1,i^=this.s2,n^=this.s3;let{W:o,t:s,windowSize:a}=this,c=0,l=0,d=0,u=0,h=(1<<o)-1,m=0;for(let b of [e,r,i,n])for(let A=0;A<4;A++){let x=b>>>8*A&255;for(let y=8/o-1;y>=0;y--){let w=x>>>o*y&h,{s0:I,s1:_,s2:C,s3:v}=s[m*a+w];c^=I,l^=_,d^=C,u^=v,m+=1;}}this.s0=c,this.s1=l,this.s2=d,this.s3=u;}update(e){fc(this),e=ha(e),at(e);let r=Or(e),i=Math.floor(e.length/Li),n=e.length%Li;for(let o=0;o<i;o++)this._updateBlock(r[o*4+0],r[o*4+1],r[o*4+2],r[o*4+3]);return n&&(vh.set(e.subarray(i*Li)),this._updateBlock(ti[0],ti[1],ti[2],ti[3]),Mr(ti)),this}destroy(){let{t:e}=this;for(let r of e)r.s0=0,r.s1=0,r.s2=0,r.s3=0;}digestInto(e){fc(this),_h(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Or(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e}digest(){let e=new Uint8Array(Li);return this.digestInto(e),this.destroy(),e}},Ih=class extends dd{constructor(e,r){e=ha(e),at(e);let i=Av(zo(e));super(i,r),Mr(i);}update(e){e=ha(e),fc(this);let r=Or(e),i=e.length%Li,n=Math.floor(e.length/Li);for(let o=0;o<n;o++)this._updateBlock(mr(r[o*4+3]),mr(r[o*4+2]),mr(r[o*4+1]),mr(r[o*4+0]));return i&&(vh.set(e.subarray(n*Li)),this._updateBlock(mr(ti[3]),mr(ti[2]),mr(ti[1]),mr(ti[0])),Mr(ti)),this}digestInto(e){fc(this),_h(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Or(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e.reverse()}};function F6(t){let e=(i,n)=>t(n,i.length).update(ha(i)).digest(),r=t(new Uint8Array(16),0);return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=(i,n)=>t(i,n),e}var Eh=F6((t,e)=>new dd(t,e));F6((t,e)=>new Ih(t,e));var Th=16,Cv=4,ud=new Uint8Array(Th),Iv=283;function kh(t){return t<<1^Iv&-(t>>7)}function L6(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(e&1),t=kh(t);return r}var vv=(()=>{let t=new Uint8Array(256);for(let r=0,i=1;r<256;r++,i^=kh(i))t[r]=i;let e=new Uint8Array(256);e[0]=99;for(let r=0;r<255;r++){let i=t[255-r];i|=i<<8,e[t[r]]=(i^i>>4^i>>5^i>>6^i>>7^99)&255;}return Mr(t),e})();var Ev=t=>t<<24|t>>>8,Bh=t=>t<<8|t>>>24;function Bv(t,e){if(t.length!==256)throw new Error("Wrong sbox length");let r=new Uint32Array(256).map((l,d)=>e(t[d])),i=r.map(Bh),n=i.map(Bh),o=n.map(Bh),s=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let d=0;d<256;d++){let u=l*256+d;s[u]=r[l]^i[d],a[u]=n[l]^o[d],c[u]=t[l]<<8|t[d];}return {sbox:t,sbox2:c,T0:r,T1:i,T2:n,T3:o,T01:s,T23:a}}var K6=Bv(vv,t=>L6(t,3)<<24|t<<16|t<<8|L6(t,2));var Tv=(()=>{let t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=kh(r))t[e]=r;return t})();function kv(t){at(t);let e=t.length;if(![16,24,32].includes(e))throw new Error("aes: invalid key size, should be 16, 24 or 32, got "+e);let{sbox2:r}=K6,i=[];hc(t)||i.push(t=zo(t));let n=Or(t),o=n.length,s=c=>mc(r,c,c,c,c),a=new Uint32Array(e+28);a.set(n);for(let c=o;c<a.length;c++){let l=a[c-1];c%o===0?l=s(Ev(l))^Tv[c/o-1]:o>6&&c%o===4&&(l=s(l)),a[c]=a[c-o]^l;}return Mr(...i),a}function fd(t,e,r,i,n,o){return t[r<<8&65280|i>>>8&255]^e[n>>>8&65280|o>>>24&255]}function mc(t,e,r,i,n){return t[e&255|r&65280]|t[i>>>16&255|n>>>16&65280]<<16}function H6(t,e,r,i,n){let{sbox2:o,T01:s,T23:a}=K6,c=0;e^=t[c++],r^=t[c++],i^=t[c++],n^=t[c++];let l=t.length/4-2;for(let b=0;b<l;b++){let A=t[c++]^fd(s,a,e,r,i,n),x=t[c++]^fd(s,a,r,i,n,e),y=t[c++]^fd(s,a,i,n,e,r),w=t[c++]^fd(s,a,n,e,r,i);e=A,r=x,i=y,n=w;}let d=t[c++]^mc(o,e,r,i,n),u=t[c++]^mc(o,r,i,n,e),h=t[c++]^mc(o,i,n,e,r),m=t[c++]^mc(o,n,e,r,i);return {s0:d,s1:u,s2:h,s3:m}}function pd(t,e,r,i,n){at(r,Th),at(i),n=M6(i.length,n);let o=r,s=Or(o),a=pa(o),c=Or(i),l=Or(n),d=12,u=i.length,h=a.getUint32(d,e),{s0:m,s1:b,s2:A,s3:x}=H6(t,s[0],s[1],s[2],s[3]);for(let w=0;w+4<=c.length;w+=4)l[w+0]=c[w+0]^m,l[w+1]=c[w+1]^b,l[w+2]=c[w+2]^A,l[w+3]=c[w+3]^x,h=h+1>>>0,a.setUint32(d,h,e),{s0:m,s1:b,s2:A,s3:x}=H6(t,s[0],s[1],s[2],s[3]);let y=Th*Math.floor(c.length/Cv);if(y<u){let w=new Uint32Array([m,b,A,x]),I=R6(w);for(let _=y,C=0;_<u;_++,C++)n[_]=i[_]^I[C];Mr(w);}return n}function Pv(t,e,r,i,n){let o=n?n.length:0,s=t.create(r,i.length+o);n&&s.update(n);let a=U6(8*i.length,8*o,e);s.update(i),s.update(a);let c=s.digest();return Mr(a),c}var Ph=O6({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:true},function(e,r,i){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");let n=16;function o(a,c,l){let d=Pv(Eh,false,a,l,i);for(let u=0;u<c.length;u++)d[u]^=c[u];return d}function s(){let a=kv(e),c=ud.slice(),l=ud.slice();if(pd(a,false,l,l,c),r.length===12)l.set(r);else {let u=ud.slice(),h=pa(u);ld(h,8,BigInt(r.length*8),false);let m=Eh.create(c).update(r).update(u);m.digestInto(l),m.destroy();}let d=pd(a,false,l,ud);return {xk:a,authKey:c,counter:l,tagMask:d}}return {encrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),h=new Uint8Array(a.length+n),m=[c,l,d,u];hc(a)||m.push(a=zo(a)),pd(c,false,d,a,h.subarray(0,a.length));let b=o(l,u,h.subarray(0,h.length-n));return m.push(b),h.set(b,a.length),Mr(...m),h},decrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),h=[c,l,u,d];hc(a)||h.push(a=zo(a));let m=a.subarray(0,-n),b=a.subarray(-n),A=o(l,u,m);if(h.push(A),!D6(A,b))throw new Error("aes/gcm: invalid ghash tag");let x=pd(c,false,d,m);return Mr(...h),x}}});var Nv={p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n},{p:Go,n:Mh,Gx:Rv,Gy:Dv,b:W6}=Nv,$o=32,Nh=64,Vt=(t="")=>{throw new Error(t)},Z6=t=>typeof t=="bigint",Y6=t=>typeof t=="string",Ov=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",gc=(t,e)=>!Ov(t)||typeof e=="number"&&e>0&&t.length!==e?Vt("Uint8Array expected"):t,Uh=t=>new Uint8Array(t),Mv=t=>Uint8Array.from(t),Q6=(t,e)=>t.toString(16).padStart(e,"0"),J6=t=>Array.from(gc(t)).map(e=>Q6(e,2)).join(""),Hi={_0:48,_9:57,A:65,F:70,a:97,f:102},z6=t=>{if(t>=Hi._0&&t<=Hi._9)return t-Hi._0;if(t>=Hi.A&&t<=Hi.F)return t-(Hi.A-10);if(t>=Hi.a&&t<=Hi.f)return t-(Hi.a-10)},e5=t=>{let e="hex invalid";if(!Y6(t))return Vt(e);let r=t.length,i=r/2;if(r%2)return Vt(e);let n=Uh(i);for(let o=0,s=0;o<i;o++,s+=2){let a=z6(t.charCodeAt(s)),c=z6(t.charCodeAt(s+1));if(a===void 0||c===void 0)return Vt(e);n[o]=a*16+c;}return n},yd=(t,e)=>gc(Y6(t)?e5(t):Mv(gc(t)),e),Uv=()=>globalThis?.crypto;var q6=(...t)=>{let e=Uh(t.reduce((i,n)=>i+gc(n).length,0)),r=0;return t.forEach(i=>{e.set(i,r),r+=i.length;}),e},Fv=(t=$o)=>Uv().getRandomValues(Uh(t)),md=BigInt,bc=(t,e,r,i="bad number: out of range")=>Z6(t)&&e<=t&&t<r?t:Vt(i),ee=(t,e=Go)=>{let r=t%e;return r>=0n?r:e+r};var Lv=(t,e)=>{(t===0n||e<=0n)&&Vt("no inverse n="+t+" mod="+e);let r=ee(t,e),i=e,n=0n,s=1n;for(;r!==0n;){let c=i/r,l=i%r,d=n-s*c;i=r,r=l,n=s,s=d;}return i===1n?ee(n,e):Vt("no inverse")};var G6=t=>t instanceof Nn?t:Vt("Point expected"),t5=t=>ee(ee(t*t)*t+W6),$6=t=>bc(t,0n,Go),hd=t=>bc(t,1n,Go),Hv=t=>bc(t,1n,Mh),Rh=t=>(t&1n)===0n,r5=t=>Uint8Array.of(t),Kv=t=>r5(Rh(t)?2:3),zv=t=>{let e=t5(hd(t)),r=1n;for(let i=e,n=(Go+1n)/4n;n>0n;n>>=1n)n&1n&&(r=r*i%Go),i=i*i%Go;return ee(r*r)===e?r:Vt("sqrt invalid")},ri=class ri{constructor(e,r,i){f(this,"px");f(this,"py");f(this,"pz");this.px=$6(e),this.py=hd(r),this.pz=$6(i),Object.freeze(this);}static fromBytes(e){gc(e);let r,i=e[0],n=e.subarray(1),o=V6(n,0,$o),s=e.length;if(s===$o+1&&[2,3].includes(i)){let a=zv(o),c=Rh(a);Rh(md(i))!==c&&(a=ee(-a)),r=new ri(o,a,1n);}return s===Nh+1&&i===4&&(r=new ri(o,V6(n,$o,Nh),1n)),r?r.assertValidity():Vt("bad point: not on curve")}equals(e){let{px:r,py:i,pz:n}=this,{px:o,py:s,pz:a}=G6(e),c=ee(r*a),l=ee(o*n),d=ee(i*a),u=ee(s*n);return c===l&&d===u}is0(){return this.equals(qo)}negate(){return new ri(this.px,ee(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:i,pz:n}=this,{px:o,py:s,pz:a}=G6(e),c=0n,l=W6,d=0n,u=0n,h=0n,m=ee(l*3n),b=ee(r*o),A=ee(i*s),x=ee(n*a),y=ee(r+i),w=ee(o+s);y=ee(y*w),w=ee(b+A),y=ee(y-w),w=ee(r+n);let I=ee(o+a);return w=ee(w*I),I=ee(b+x),w=ee(w-I),I=ee(i+n),d=ee(s+a),I=ee(I*d),d=ee(A+x),I=ee(I-d),h=ee(c*w),d=ee(m*x),h=ee(d+h),d=ee(A-h),h=ee(A+h),u=ee(d*h),A=ee(b+b),A=ee(A+b),x=ee(c*x),w=ee(m*w),A=ee(A+x),x=ee(b-x),x=ee(c*x),w=ee(w+x),b=ee(A*w),u=ee(u+b),b=ee(I*w),d=ee(y*d),d=ee(d-b),b=ee(y*A),h=ee(I*h),h=ee(h+b),new ri(d,u,h)}multiply(e,r=true){if(!r&&e===0n)return qo;if(Hv(e),e===1n)return this;if(this.equals(Pn))return Xv(e).p;let i=qo,n=Pn;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?i=i.add(o):r&&(n=n.add(o));return i}toAffine(){let{px:e,py:r,pz:i}=this;if(this.equals(qo))return {x:0n,y:0n};if(i===1n)return {x:e,y:r};let n=Lv(i,Go);return ee(i*n)!==1n&&Vt("inverse invalid"),{x:ee(e*n),y:ee(r*n)}}assertValidity(){let{x:e,y:r}=this.toAffine();return hd(e),hd(r),ee(r*r)===t5(e)?this:Vt("bad point: not on curve")}toBytes(e=true){let{x:r,y:i}=this.assertValidity().toAffine(),n=Dh(r);return e?q6(Kv(i),n):q6(r5(4),n,Dh(i))}static fromAffine(e){let{x:r,y:i}=e;return r===0n&&i===0n?qo:new ri(r,i,1n)}toHex(e){return J6(this.toBytes(e))}static fromPrivateKey(e){return Pn.multiply(yc(e))}static fromHex(e){return ri.fromBytes(yd(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}};f(ri,"BASE"),f(ri,"ZERO");var Nn=ri,Pn=new Nn(Rv,Dv,1n),qo=new Nn(0n,1n,0n);Nn.BASE=Pn;Nn.ZERO=qo;var Fh=t=>md("0x"+(J6(t)||"0")),V6=(t,e,r)=>Fh(t.subarray(e,r)),qv=2n**256n,Dh=t=>e5(Q6(bc(t,0n,qv),Nh)),yc=t=>{let e=Z6(t)?t:Fh(yd(t,$o));return bc(e,1n,Mh,"private key invalid 3")};var i5=(t,e=true)=>Pn.multiply(yc(t)).toBytes(e);var n5=(t,e,r=true)=>Nn.fromBytes(yd(e)).multiply(yc(t)).toBytes(r),Gv=t=>{t=yd(t),(t.length<$o+8||t.length>1024)&&Vt("expected 40-1024b");let e=ee(Fh(t),Mh-1n);return Dh(e+1n)},$v=()=>Gv(Fv($o+16));var o5={normPrivateKeyToScalar:yc,isValidPrivateKey:t=>{try{return !!yc(t)}catch{return false}},randomPrivateKey:$v,precompute:(t=8,e=Pn)=>(e.multiply(3n),e)},gd=8,Vv=256,s5=Math.ceil(Vv/gd)+1,Oh=2**(gd-1),jv=()=>{let t=[],e=Pn,r=e;for(let i=0;i<s5;i++){r=e,t.push(r);for(let n=1;n<Oh;n++)r=r.add(e),t.push(r);e=r.double();}return t},j6,X6=(t,e)=>{let r=e.negate();return t?r:e},Xv=t=>{let e=j6||(j6=jv()),r=qo,i=Pn,n=2**gd,o=n,s=md(n-1),a=md(gd);for(let c=0;c<s5;c++){let l=Number(t&s);t>>=a,l>Oh&&(l-=o,t+=1n);let d=c*Oh,u=d,h=d+Math.abs(l)-1,m=c%2!==0,b=l<0;l===0?i=i.add(X6(m,e[u])):r=r.add(X6(b,e[h]));}return {p:r,f:i}};function Wv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sd(t,...e){if(!Wv(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 Lh(t,e=true){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 a5(t,e){Sd(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Sc(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function xd(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ur(t,e){return t<<32-e|t>>>e}function Zv(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Hh(t){return typeof t=="string"&&(t=Zv(t)),Sd(t),t}var bd=class{};function c5(t){let e=i=>t().update(Hh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Yv(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);let n=BigInt(32),o=BigInt(4294967295),s=Number(r>>n&o),a=Number(r&o),c=i?4:0,l=i?0:4;t.setUint32(e+c,s,i),t.setUint32(e+l,a,i);}function l5(t,e,r){return t&e^~t&r}function d5(t,e,r){return t&e^t&r^e&r}var Ad=class extends bd{constructor(e,r,i,n){super(),this.finished=false,this.length=0,this.pos=0,this.destroyed=false,this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(e),this.view=xd(this.buffer);}update(e){Lh(this),e=Hh(e),Sd(e);let{view:r,buffer:i,blockLen:n}=this,o=e.length;for(let s=0;s<o;){let a=Math.min(n-this.pos,o-s);if(a===n){let c=xd(e);for(;n<=o-s;s+=n)this.process(c,s);continue}i.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(r,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){Lh(this),a5(e,this),this.finished=true;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:s}=this;r[s++]=128,Sc(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(i,0),s=0);for(let u=s;u<n;u++)r[u]=0;Yv(i,n-8,BigInt(this.length*8),o),this.process(i,0);let a=xd(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],o);}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:i,length:n,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=a,n%r&&e.buffer.set(i),e}clone(){return this._cloneInto()}},Ki=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Qv=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]),Rn=new Uint32Array(64),Kh=class extends Ad{constructor(e=32){super(64,e,8,false),this.A=Ki[0]|0,this.B=Ki[1]|0,this.C=Ki[2]|0,this.D=Ki[3]|0,this.E=Ki[4]|0,this.F=Ki[5]|0,this.G=Ki[6]|0,this.H=Ki[7]|0;}get(){let{A:e,B:r,C:i,D:n,E:o,F:s,G:a,H:c}=this;return [e,r,i,n,o,s,a,c]}set(e,r,i,n,o,s,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0;}process(e,r){for(let u=0;u<16;u++,r+=4)Rn[u]=e.getUint32(r,false);for(let u=16;u<64;u++){let h=Rn[u-15],m=Rn[u-2],b=Ur(h,7)^Ur(h,18)^h>>>3,A=Ur(m,17)^Ur(m,19)^m>>>10;Rn[u]=A+Rn[u-7]+b+Rn[u-16]|0;}let{A:i,B:n,C:o,D:s,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){let h=Ur(a,6)^Ur(a,11)^Ur(a,25),m=d+h+l5(a,c,l)+Qv[u]+Rn[u]|0,A=(Ur(i,2)^Ur(i,13)^Ur(i,22))+d5(i,n,o)|0;d=l,l=c,c=a,a=s+m|0,s=o,o=n,n=i,i=m+A|0;}i=i+this.A|0,n=n+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(i,n,o,s,a,c,l,d);}roundClean(){Sc(Rn);}destroy(){this.set(0,0,0,0,0,0,0,0),Sc(this.buffer);}};var u5=c5(()=>new Kh);async function f5(t){let r=new TextEncoder().encode(t),i=await u5(r);return new Uint8Array(i).slice(0,12)}function wd(){let t=o5.randomPrivateKey(),e=i5(t);return {privateKey:t,publicKey:e}}function zh(t,e){return n5(t,e).slice(0,32)}async function xc(t,e,r){let i=await f5(r),n=Ph(e,i),o=Ch(t);return n.encrypt(o)}async function qh(t,e,r){let i=await f5(r),o=Ph(e,i).decrypt(t);return new TextDecoder().decode(o)}var U8=It(uc(),1);function Aa(t){let e=t.length;for(;--e>=0;)t[e]=0;}var Jv=0,J5=1,e9=2,t9=3,r9=258,p2=29,Dc=256,Ec=Dc+1+p2,ya=30,h2=19,e8=2*Ec+1,Vo=15,Gh=16,i9=7,m2=256,t8=16,r8=17,i8=18,n2=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Bd=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n9=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n8=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o9=512,qi=new Array((Ec+2)*2);Aa(qi);var Cc=new Array(ya*2);Aa(Cc);var Bc=new Array(o9);Aa(Bc);var Tc=new Array(r9-t9+1);Aa(Tc);var g2=new Array(p2);Aa(g2);var Td=new Array(ya);Aa(Td);function $h(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length;}var o8,s8,a8;function Vh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e;}var c8=t=>t<256?Bc[t]:Bc[256+(t>>>7)],kc=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255;},Lt=(t,e,r)=>{t.bi_valid>Gh-r?(t.bi_buf|=e<<t.bi_valid&65535,kc(t,t.bi_buf),t.bi_buf=e>>Gh-t.bi_valid,t.bi_valid+=r-Gh):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r);},oi=(t,e,r)=>{Lt(t,r[e*2],r[e*2+1]);},l8=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},s9=t=>{t.bi_valid===16?(kc(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8);},a9=(t,e)=>{let r=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length,l,d,u,h,m,b,A=0;for(h=0;h<=Vo;h++)t.bl_count[h]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<e8;l++)d=t.heap[l],h=r[r[d*2+1]*2+1]+1,h>c&&(h=c,A++),r[d*2+1]=h,!(d>i)&&(t.bl_count[h]++,m=0,d>=a&&(m=s[d-a]),b=r[d*2],t.opt_len+=b*(h+m),o&&(t.static_len+=b*(n[d*2+1]+m)));if(A!==0){do{for(h=c-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[c]--,A-=2;}while(A>0);for(h=c;h!==0;h--)for(d=t.bl_count[h];d!==0;)u=t.heap[--l],!(u>i)&&(r[u*2+1]!==h&&(t.opt_len+=(h-r[u*2+1])*r[u*2],r[u*2+1]=h),d--);}},d8=(t,e,r)=>{let i=new Array(Vo+1),n=0,o,s;for(o=1;o<=Vo;o++)n=n+r[o-1]<<1,i[o]=n;for(s=0;s<=e;s++){let a=t[s*2+1];a!==0&&(t[s*2]=l8(i[a]++,a));}},c9=()=>{let t,e,r,i,n,o=new Array(Vo+1);for(r=0,i=0;i<p2-1;i++)for(g2[i]=r,t=0;t<1<<n2[i];t++)Tc[r++]=i;for(Tc[r-1]=i,n=0,i=0;i<16;i++)for(Td[i]=n,t=0;t<1<<Bd[i];t++)Bc[n++]=i;for(n>>=7;i<ya;i++)for(Td[i]=n<<7,t=0;t<1<<Bd[i]-7;t++)Bc[256+n++]=i;for(e=0;e<=Vo;e++)o[e]=0;for(t=0;t<=143;)qi[t*2+1]=8,t++,o[8]++;for(;t<=255;)qi[t*2+1]=9,t++,o[9]++;for(;t<=279;)qi[t*2+1]=7,t++,o[7]++;for(;t<=287;)qi[t*2+1]=8,t++,o[8]++;for(d8(qi,Ec+1,o),t=0;t<ya;t++)Cc[t*2+1]=5,Cc[t*2]=l8(t,5);o8=new $h(qi,n2,Dc+1,Ec,Vo),s8=new $h(Cc,Bd,0,ya,Vo),a8=new $h(new Array(0),n9,0,h2,i9);},u8=t=>{let e;for(e=0;e<Ec;e++)t.dyn_ltree[e*2]=0;for(e=0;e<ya;e++)t.dyn_dtree[e*2]=0;for(e=0;e<h2;e++)t.bl_tree[e*2]=0;t.dyn_ltree[m2*2]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0;},f8=t=>{t.bi_valid>8?kc(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0;},p5=(t,e,r,i)=>{let n=e*2,o=r*2;return t[n]<t[o]||t[n]===t[o]&&i[e]<=i[r]},jh=(t,e,r)=>{let i=t.heap[r],n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&p5(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!p5(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i;},h5=(t,e,r)=>{let i,n,o=0,s,a;if(t.sym_next!==0)do i=t.pending_buf[t.sym_buf+o++]&255,i+=(t.pending_buf[t.sym_buf+o++]&255)<<8,n=t.pending_buf[t.sym_buf+o++],i===0?oi(t,n,e):(s=Tc[n],oi(t,s+Dc+1,e),a=n2[s],a!==0&&(n-=g2[s],Lt(t,n,a)),i--,s=c8(i),oi(t,s,r),a=Bd[s],a!==0&&(i-=Td[s],Lt(t,i,a)));while(o<t.sym_next);oi(t,m2,e);},o2=(t,e)=>{let r=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,o=e.stat_desc.elems,s,a,c=-1,l;for(t.heap_len=0,t.heap_max=e8,s=0;s<o;s++)r[s*2]!==0?(t.heap[++t.heap_len]=c=s,t.depth[s]=0):r[s*2+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,r[l*2]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[l*2+1]);for(e.max_code=c,s=t.heap_len>>1;s>=1;s--)jh(t,r,s);l=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],jh(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[l*2]=r[s*2]+r[a*2],t.depth[l]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[s*2+1]=r[a*2+1]=l,t.heap[1]=l++,jh(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],a9(t,e),d8(r,c,t.bl_count);},m5=(t,e,r)=>{let i,n=-1,o,s=e[1],a=0,c=7,l=4;for(s===0&&(c=138,l=3),e[(r+1)*2+1]=65535,i=0;i<=r;i++)o=s,s=e[(i+1)*2+1],!(++a<c&&o===s)&&(a<l?t.bl_tree[o*2]+=a:o!==0?(o!==n&&t.bl_tree[o*2]++,t.bl_tree[t8*2]++):a<=10?t.bl_tree[r8*2]++:t.bl_tree[i8*2]++,a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4));},g5=(t,e,r)=>{let i,n=-1,o,s=e[1],a=0,c=7,l=4;for(s===0&&(c=138,l=3),i=0;i<=r;i++)if(o=s,s=e[(i+1)*2+1],!(++a<c&&o===s)){if(a<l)do oi(t,o,t.bl_tree);while(--a!==0);else o!==0?(o!==n&&(oi(t,o,t.bl_tree),a--),oi(t,t8,t.bl_tree),Lt(t,a-3,2)):a<=10?(oi(t,r8,t.bl_tree),Lt(t,a-3,3)):(oi(t,i8,t.bl_tree),Lt(t,a-11,7));a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4);}},l9=t=>{let e;for(m5(t,t.dyn_ltree,t.l_desc.max_code),m5(t,t.dyn_dtree,t.d_desc.max_code),o2(t,t.bl_desc),e=h2-1;e>=3&&t.bl_tree[n8[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},d9=(t,e,r,i)=>{let n;for(Lt(t,e-257,5),Lt(t,r-1,5),Lt(t,i-4,4),n=0;n<i;n++)Lt(t,t.bl_tree[n8[n]*2+1],3);g5(t,t.dyn_ltree,e-1),g5(t,t.dyn_dtree,r-1);},u9=t=>{let e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return 0;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return 1;for(r=32;r<Dc;r++)if(t.dyn_ltree[r*2]!==0)return 1;return 0},y5=false,f9=t=>{y5||(c9(),y5=true),t.l_desc=new Vh(t.dyn_ltree,o8),t.d_desc=new Vh(t.dyn_dtree,s8),t.bl_desc=new Vh(t.bl_tree,a8),t.bi_buf=0,t.bi_valid=0,u8(t);},p8=(t,e,r,i)=>{Lt(t,(Jv<<1)+(i?1:0),3),f8(t),kc(t,r),kc(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r;},p9=t=>{Lt(t,J5<<1,3),oi(t,m2,qi),s9(t);},h9=(t,e,r,i)=>{let n,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=u9(t)),o2(t,t.l_desc),o2(t,t.d_desc),s=l9(t),n=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=n&&(n=o)):n=o=r+5,r+4<=n&&e!==-1?p8(t,e,r,i):t.strategy===4||o===n?(Lt(t,(J5<<1)+(i?1:0),3),h5(t,qi,Cc)):(Lt(t,(e9<<1)+(i?1:0),3),d9(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),h5(t,t.dyn_ltree,t.dyn_dtree)),u8(t),i&&f8(t);},m9=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(Tc[r]+Dc+1)*2]++,t.dyn_dtree[c8(e)*2]++),t.sym_next===t.sym_end),g9=f9,y9=p8,b9=h9,S9=m9,x9=p9,A9={_tr_init:g9,_tr_stored_block:y9,_tr_flush_block:b9,_tr_tally:S9,_tr_align:x9},w9=(t,e,r,i)=>{let n=t&65535|0,o=t>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do n=n+e[i++]|0,o=o+n|0;while(--s);n%=65521,o%=65521;}return n|o<<16|0},Pc=w9,_9=()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t;}return e},C9=new Uint32Array(_9()),I9=(t,e,r,i)=>{let n=C9,o=i+r;t^=-1;for(let s=i;s<o;s++)t=t>>>8^n[(t^e[s])&255];return t^-1},it=I9,Wo={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},wa={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:v9,_tr_stored_block:s2,_tr_flush_block:E9,_tr_tally:Mn,_tr_align:B9}=A9,{Z_NO_FLUSH:Un,Z_PARTIAL_FLUSH:T9,Z_FULL_FLUSH:k9,Z_FINISH:gr,Z_BLOCK:b5,Z_OK:ct,Z_STREAM_END:S5,Z_STREAM_ERROR:si,Z_DATA_ERROR:P9,Z_BUF_ERROR:Xh,Z_DEFAULT_COMPRESSION:N9,Z_FILTERED:R9,Z_HUFFMAN_ONLY:_d,Z_RLE:D9,Z_FIXED:O9,Z_DEFAULT_STRATEGY:M9,Z_UNKNOWN:U9,Z_DEFLATED:Nd}=wa,F9=9,L9=15,H9=8,K9=29,z9=256,a2=z9+1+K9,q9=30,G9=19,$9=2*a2+1,V9=15,be=3,On=258,ai=On+be+1,j9=32,Sa=42,y2=57,c2=69,l2=73,d2=91,u2=103,jo=113,wc=666,Ct=1,_a=2,Zo=3,Ca=4,X9=3,Xo=(t,e)=>(t.msg=Wo[e],e),x5=t=>t*2-(t>4?9:0),Dn=t=>{let e=t.length;for(;--e>=0;)t[e]=0;},W9=t=>{let e,r,i,n=t.w_size;e=t.hash_size,i=e;do r=t.head[--i],t.head[i]=r>=n?r-n:0;while(--e);e=n,i=e;do r=t.prev[--i],t.prev[i]=r>=n?r-n:0;while(--e)},b2=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask,Yo=(t,e)=>{let r;if(t.legacy_hash)r=t.ins_h=b2(t,t.ins_h,t.window[e+be-1]);else {let n=t.window,o=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24;r=t.ins_h=Math.imul(o,66521)+66521>>>16&t.hash_mask;}let i=t.prev[e&t.w_mask]=t.head[r];return t.head[r]=e,i},jt=t=>{let e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0));},Xt=(t,e)=>{E9(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,jt(t.strm);},Se=(t,e)=>{t.pending_buf[t.pending++]=e;},Ac=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255;},f2=(t,e,r,i)=>{let n=t.avail_in;return n>i&&(n=i),n===0?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),r),t.state.wrap===1?t.adler=Pc(t.adler,e,n,r):t.state.wrap===2&&(t.adler=it(t.adler,e,n,r)),t.next_in+=n,t.total_in+=n,n)},h8=(t,e)=>{let r=t.max_chain_length,i=t.strstart,n,o,s=t.prev_length,a=t.nice_match,c=t.strstart>t.w_size-ai?t.strstart-(t.w_size-ai):0,l=t.window,d=t.w_mask,u=t.prev,h=t.strstart+On,m=l[i+s-1],b=l[i+s];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do if(n=e,!(l[n+s]!==b||l[n+s-1]!==m||l[n]!==l[i]||l[++n]!==l[i+1])){i+=2,n++;do;while(l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&i<h);if(o=On-(h-i),i=h-On,o>s){if(t.match_start=e,s=o,o>=a)break;m=l[i+s-1],b=l[i+s];}}while((e=u[e&d])>c&&--r!==0);return s<=t.lookahead?s:t.lookahead},xa=t=>{let e=t.w_size,r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ai)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),W9(t),i+=e),t.strm.avail_in===0)break;if(r=f2(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,t.legacy_hash){if(t.lookahead+t.insert>=be)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=b2(t,t.ins_h,t.window[n+1]);t.insert&&(Yo(t,n),n++,t.insert--,!(t.lookahead+t.insert<be)););}else if(t.lookahead+t.insert>be)for(n=t.strstart-t.insert;t.insert&&(Yo(t,n),n++,t.insert--,!(t.lookahead+t.insert<=be)););}while(t.lookahead<ai&&t.strm.avail_in!==0)},m8=(t,e)=>{let r=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,i,n,o,s=0,a=t.strm.avail_in;do{if(i=65535,o=t.bi_valid+42>>3,t.strm.avail_out<o||(o=t.strm.avail_out-o,n=t.strstart-t.block_start,i>n+t.strm.avail_in&&(i=n+t.strm.avail_in),i>o&&(i=o),i<r&&(i===0&&e!==gr||e===Un||i!==n+t.strm.avail_in)))break;s=e===gr&&i===n+t.strm.avail_in?1:0,s2(t,0,0,s),t.pending_buf[t.pending-4]=i,t.pending_buf[t.pending-3]=i>>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,jt(t.strm),n&&(n>i&&(n=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,i-=n),i&&(f2(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i);}while(s===0);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?Ca:e!==Un&&e!==gr&&t.strm.avail_in===0&&t.strstart===t.block_start?_a:(o=t.window_size-t.strstart,t.strm.avail_in>o&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,o+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),o>t.strm.avail_in&&(o=t.strm.avail_in),o&&(f2(t.strm,t.window,t.strstart,o),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.high_water<t.strstart&&(t.high_water=t.strstart),o=t.bi_valid+42>>3,o=t.pending_buf_size-o>65535?65535:t.pending_buf_size-o,r=o>t.w_size?t.w_size:o,n=t.strstart-t.block_start,(n>=r||(n||e===gr)&&e!==Un&&t.strm.avail_in===0&&n<=o)&&(i=n>o?o:n,s=e===gr&&t.strm.avail_in===0&&i===n?1:0,s2(t,t.block_start,i,s),t.block_start+=i,jt(t.strm)),s?Zo:Ct)},Wh=(t,e)=>{let r,i;for(;;){if(t.lookahead<ai){if(xa(t),t.lookahead<ai&&e===Un)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Yo(t,t.strstart)),r!==0&&t.strstart-r<=t.w_size-ai&&(t.match_length=h8(t,r)),t.match_length>=be)if(i=Mn(t,t.strstart-t.match_start,t.match_length-be),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=be){t.match_length--;do t.strstart++,r=Yo(t,t.strstart);while(--t.match_length!==0);t.strstart++;}else t.strstart+=t.match_length,t.match_length=0,t.legacy_hash&&(t.ins_h=t.window[t.strstart],t.ins_h=b2(t,t.ins_h,t.window[t.strstart+1]));else i=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=t.strstart<be-1?t.strstart:be-1,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},ma=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<ai){if(xa(t),t.lookahead<ai&&e===Un)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Yo(t,t.strstart)),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=be-1,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-ai&&(t.match_length=h8(t,r),t.match_length<=5&&(t.strategy===R9||t.match_length===be&&t.strstart-t.match_start>4096)&&(t.match_length=be-1)),t.prev_length>=be&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-be,i=Mn(t,t.strstart-1-t.prev_match,t.prev_length-be),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=n&&(r=Yo(t,t.strstart));while(--t.prev_length!==0);if(t.match_available=0,t.match_length=be-1,t.strstart++,i&&(Xt(t,false),t.strm.avail_out===0))return Ct}else if(t.match_available){if(i=Mn(t,0,t.window[t.strstart-1]),i&&Xt(t,false),t.strstart++,t.lookahead--,t.strm.avail_out===0)return Ct}else t.match_available=1,t.strstart++,t.lookahead--;}return t.match_available&&(i=Mn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<be-1?t.strstart:be-1,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},Z9=(t,e)=>{let r,i,n,o,s=t.window;for(;;){if(t.lookahead<=On){if(xa(t),t.lookahead<=On&&e===Un)return Ct;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=be&&t.strstart>0&&(n=t.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){o=t.strstart+On;do;while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<o);t.match_length=On-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead);}if(t.match_length>=be?(r=Mn(t,1,t.match_length-be),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=0,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},Y9=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(xa(t),t.lookahead===0)){if(e===Un)return Ct;break}if(t.match_length=0,r=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=0,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a};function ii(t,e,r,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=i,this.func=n;}var _c=[new ii(0,0,0,0,m8),new ii(4,4,8,4,Wh),new ii(4,5,16,8,Wh),new ii(4,6,32,32,Wh),new ii(4,4,16,16,ma),new ii(8,16,32,32,ma),new ii(8,16,128,128,ma),new ii(8,32,128,256,ma),new ii(32,128,258,1024,ma),new ii(32,258,258,4096,ma)],Q9=t=>{t.window_size=2*t.w_size,Dn(t.head),t.max_lazy_match=_c[t.level].max_lazy,t.good_match=_c[t.level].good_length,t.nice_match=_c[t.level].nice_length,t.max_chain_length=_c[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=be-1,t.match_available=0,t.ins_h=0;};function J9(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Nd,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array($9*2),this.dyn_dtree=new Uint16Array((2*q9+1)*2),this.bl_tree=new Uint16Array((2*G9+1)*2),Dn(this.dyn_ltree),Dn(this.dyn_dtree),Dn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(V9+1),this.heap=new Uint16Array(2*a2+1),Dn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*a2+1),Dn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0;}var Oc=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.status!==Sa&&e.status!==y2&&e.status!==c2&&e.status!==l2&&e.status!==d2&&e.status!==u2&&e.status!==jo&&e.status!==wc?1:0},g8=t=>{if(Oc(t))return Xo(t,si);t.total_in=t.total_out=0,t.data_type=U9;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?y2:e.wrap?Sa:jo,t.adler=e.wrap===2?0:1,e.last_flush=-2,v9(e),ct},y8=t=>{let e=g8(t);return e===ct&&Q9(t.state),e},e7=(t,e)=>Oc(t)||t.state.wrap!==2?si:(t.state.gzhead=e,ct),b8=(t,e,r,i,n,o,s)=>{if(!t)return si;let a=1;if(e===N9&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>F9||r!==Nd||i<8||i>15||e<0||e>9||o<0||o>O9||i===8&&a!==1)return Xo(t,si);i===8&&(i=9);let c=new J9;return t.state=c,c.strm=t,c.status=Sa,c.wrap=a,c.gzhead=null,c.w_bits=i,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.legacy_hash=s?1:0,c.hash_bits=n+7,!c.legacy_hash&&c.hash_bits<15&&(c.hash_bits=15),c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+be-1)/be),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<n+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=e,c.strategy=o,c.method=r,y8(t)},t7=(t,e)=>b8(t,e,Nd,L9,H9,M9),r7=(t,e)=>{if(Oc(t)||e>b5||e<0)return t?Xo(t,si):si;let r=t.state;if(!t.output||t.avail_in!==0&&!t.input||r.status===wc&&e!==gr)return Xo(t,t.avail_out===0?Xh:si);let i=r.last_flush;if(r.last_flush=e,r.pending!==0){if(jt(t),t.avail_out===0)return r.last_flush=-1,ct}else if(t.avail_in===0&&x5(e)<=x5(i)&&e!==gr)return Xo(t,Xh);if(r.status===wc&&t.avail_in!==0)return Xo(t,Xh);if(r.status===Sa&&r.wrap===0&&(r.status=jo),r.status===Sa){let n=Nd+(r.w_bits-8<<4)<<8,o=-1;if(r.strategy>=_d||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,n|=o<<6,r.strstart!==0&&(n|=j9),n+=31-n%31,Ac(r,n),r.strstart!==0&&(Ac(r,t.adler>>>16),Ac(r,t.adler&65535)),t.adler=1,r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===y2){if(t.adler=0,Se(r,31),Se(r,139),Se(r,8),r.gzhead)Se(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Se(r,r.gzhead.time&255),Se(r,r.gzhead.time>>8&255),Se(r,r.gzhead.time>>16&255),Se(r,r.gzhead.time>>24&255),Se(r,r.level===9?2:r.strategy>=_d||r.level<2?4:0),Se(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Se(r,r.gzhead.extra.length&255),Se(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=it(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=c2;else if(Se(r,0),Se(r,0),Se(r,0),Se(r,0),Se(r,0),Se(r,r.level===9?2:r.strategy>=_d||r.level<2?4:0),Se(r,X9),r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===c2){if(r.gzhead.extra){let n=r.pending,o=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+o>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex+=a,jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0,o-=a;}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0;}r.status=l2;}if(r.status===l2){if(r.gzhead.name){let n=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0;}r.gzindex<r.gzhead.name.length?o=r.gzhead.name.charCodeAt(r.gzindex++)&255:o=0,Se(r,o);}while(o!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0;}r.status=d2;}if(r.status===d2){if(r.gzhead.comment){let n=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0;}r.gzindex<r.gzhead.comment.length?o=r.gzhead.comment.charCodeAt(r.gzindex++)&255:o=0,Se(r,o);}while(o!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n));}r.status=u2;}if(r.status===u2){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(jt(t),r.pending!==0))return r.last_flush=-1,ct;Se(r,t.adler&255),Se(r,t.adler>>8&255),t.adler=0;}if(r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(t.avail_in!==0||r.lookahead!==0||e!==Un&&r.status!==wc){let n=r.level===0?m8(r,e):r.strategy===_d?Y9(r,e):r.strategy===D9?Z9(r,e):_c[r.level].func(r,e);if((n===Zo||n===Ca)&&(r.status=wc),n===Ct||n===Zo)return t.avail_out===0&&(r.last_flush=-1),ct;if(n===_a&&(e===T9?B9(r):e!==b5&&(s2(r,0,0,false),e===k9&&(Dn(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),jt(t),t.avail_out===0))return r.last_flush=-1,ct}return e!==gr?ct:r.wrap<=0?S5:(r.wrap===2?(Se(r,t.adler&255),Se(r,t.adler>>8&255),Se(r,t.adler>>16&255),Se(r,t.adler>>24&255),Se(r,t.total_in&255),Se(r,t.total_in>>8&255),Se(r,t.total_in>>16&255),Se(r,t.total_in>>24&255)):(Ac(r,t.adler>>>16),Ac(r,t.adler&65535)),jt(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?ct:S5)},i7=t=>{if(Oc(t))return si;let e=t.state.status;return t.state=null,e===jo?Xo(t,P9):ct},n7=(t,e)=>{let r=e.length;if(Oc(t))return si;let i=t.state,n=i.wrap;if(n===2||n===1&&i.status!==Sa||i.lookahead)return si;if(n===1&&(t.adler=Pc(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){n===0&&(Dn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let c=new Uint8Array(i.w_size);c.set(e.subarray(r-i.w_size,r),0),e=c,r=i.w_size;}let o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,xa(i);i.lookahead>=be;){let c=i.strstart,l=i.lookahead-(be-1);do Yo(i,c),c++;while(--l);i.strstart=c,i.lookahead=be-1,xa(i);}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=be-1,i.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,i.wrap=n,ct},o7=t7,s7=b8,a7=y8,c7=g8,l7=e7,d7=r7,u7=i7,f7=n7,p7="pako deflate (from Nodeca project)",Ic={deflateInit:o7,deflateInit2:s7,deflateReset:a7,deflateResetKeep:c7,deflateSetHeader:l7,deflate:d7,deflateEnd:u7,deflateSetDictionary:f7,deflateInfo:p7},h7=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),m7=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let i in r)h7(r,i)&&(t[i]=r[i]);}}return t},g7=t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;let r=new Uint8Array(e);for(let i=0,n=0,o=t.length;i<o;i++){let s=t[i];r.set(s,n),n+=s.length;}return r},Rd={assign:m7,flattenChunks:g7},S8=true;try{String.fromCharCode.apply(null,new Uint8Array(1));}catch{S8=false;}var Nc=new Uint8Array(256);for(let t=0;t<256;t++)Nc[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Nc[254]=Nc[255]=1;var y7=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,r,i,n,o,s=t.length,a=0;for(n=0;n<s;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,n=0;o<a;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|r&63):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|r&63):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|r&63);return e},b7=(t,e)=>{if(e<65534&&t.subarray&&S8)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r},S7=(t,e)=>{let r=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let i,n,o=new Array(r*2);for(n=0,i=0;i<r;){let s=t[i++];if(s<128){o[n++]=s;continue}let a=Nc[s];if(a>4){o[n++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<r;)s=s<<6|t[i++]&63,a--;if(a>1){o[n++]=65533;continue}s<65536?o[n++]=s:(s-=65536,o[n++]=55296|s>>10&1023,o[n++]=56320|s&1023);}return b7(o,n)},x7=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let r=e-1;for(;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Nc[t[r]]>e?r:e},Rc={string2buf:y7,buf2string:S7,utf8border:x7};function A7(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0;}var x8=A7,A8=Object.prototype.toString,{Z_NO_FLUSH:w7,Z_SYNC_FLUSH:_7,Z_FULL_FLUSH:C7,Z_FINISH:I7,Z_OK:kd,Z_STREAM_END:v7,Z_DEFAULT_COMPRESSION:E7,Z_DEFAULT_STRATEGY:B7,Z_DEFLATED:T7}=wa,k7={level:E7,method:T7,chunkSize:16384,windowBits:15,memLevel:8,strategy:B7,legacyHash:true};function Mc(t){this.options=Rd.assign({},k7,t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=false,this.chunks=[],this.strm=new x8,this.strm.avail_out=0;let r=Ic.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(r!==kd)throw new Error(Wo[r]);if(e.header&&Ic.deflateSetHeader(this.strm,e.header),e.dictionary){let i;if(typeof e.dictionary=="string"?i=Rc.string2buf(e.dictionary):A8.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,r=Ic.deflateSetDictionary(this.strm,i),r!==kd)throw new Error(Wo[r]);this._dict_set=true;}}Mc.prototype.push=function(t,e){let r=this.strm,i=this.options.chunkSize,n,o;if(this.ended)return false;for(e===~~e?o=e:o=e===true?I7:w7,typeof t=="string"?r.input=Rc.string2buf(t):A8.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(o===_7||o===C7)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(n=Ic.deflate(r,o),n===v7)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=Ic.deflateEnd(this.strm),this.onEnd(n),this.ended=true,n===kd;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return true};Mc.prototype.onData=function(t){this.chunks.push(t);};Mc.prototype.onEnd=function(t){t===kd&&(this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function S2(t,e){let r=new Mc(e);if(r.push(t,true),r.err)throw r.msg||Wo[r.err];return r.result}var D7=S2,F7={deflate:D7},Cd=16209,L7=16191,H7=function(e,r){let i,n,o,s,a,c,l,d,u,h,m,b,A,x,y,w,I,_,C,v,T,G,F,H,k=e.state;i=e.next_in,F=e.input,n=i+(e.avail_in-5),o=e.next_out,H=e.output,s=o-(r-e.avail_out),a=o+(e.avail_out-257),c=k.dmax,l=k.wsize,d=k.whave,u=k.wnext,h=k.window,m=k.hold,b=k.bits,A=k.lencode,x=k.distcode,y=(1<<k.lenbits)-1,w=(1<<k.distbits)-1;e:do{b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=A[m&y];t:for(;;){if(_=I>>>24,m>>>=_,b-=_,_=I>>>16&255,_===0)H[o++]=I&65535;else if(_&16){C=I&65535,_&=15,_&&(b<_&&(m+=F[i++]<<b,b+=8),C+=m&(1<<_)-1,m>>>=_,b-=_),b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=x[m&w];r:for(;;){if(_=I>>>24,m>>>=_,b-=_,_=I>>>16&255,_&16){if(v=I&65535,_&=15,b<_&&(m+=F[i++]<<b,b+=8,b<_&&(m+=F[i++]<<b,b+=8)),v+=m&(1<<_)-1,v>c){e.msg="invalid distance too far back",k.mode=Cd;break e}if(m>>>=_,b-=_,_=o-s,v>_){if(_=v-_,_>d&&k.sane){e.msg="invalid distance too far back",k.mode=Cd;break e}if(T=0,G=h,u===0){if(T+=l-_,_<C){C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}}else if(u<_){if(T+=l+u-_,_-=u,_<C){C-=_;do H[o++]=h[T++];while(--_);if(T=0,u<C){_=u,C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}}}else if(T+=u-_,_<C){C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}for(;C>2;)H[o++]=G[T++],H[o++]=G[T++],H[o++]=G[T++],C-=3;C&&(H[o++]=G[T++],C>1&&(H[o++]=G[T++]));}else {T=o-v;do H[o++]=H[T++],H[o++]=H[T++],H[o++]=H[T++],C-=3;while(C>2);C&&(H[o++]=H[T++],C>1&&(H[o++]=H[T++]));}}else if((_&64)===0){I=x[(I&65535)+(m&(1<<_)-1)];continue r}else {e.msg="invalid distance code",k.mode=Cd;break e}break}}else if((_&64)===0){I=A[(I&65535)+(m&(1<<_)-1)];continue t}else if(_&32){k.mode=L7;break e}else {e.msg="invalid literal/length code",k.mode=Cd;break e}break}}while(i<n&&o<a);C=b>>3,i-=C,b-=C<<3,m&=(1<<b)-1,e.next_in=i,e.next_out=o,e.avail_in=i<n?5+(n-i):5-(i-n),e.avail_out=o<a?257+(a-o):257-(o-a),k.hold=m,k.bits=b;},ga=15,A5=852,w5=592,_5=0,Zh=1,C5=2,K7=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),z7=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),q7=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),G7=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),$7=(t,e,r,i,n,o,s,a)=>{let c=a.bits,l=0,d=0,u=0,h=0,m=0,b=0,A=0,x=0,y=0,w=0,I,_,C,v,T,G=null,F,H=new Uint16Array(ga+1),k=new Uint16Array(ga+1),E=null,q,O,z;for(l=0;l<=ga;l++)H[l]=0;for(d=0;d<i;d++)H[e[r+d]]++;for(m=c,h=ga;h>=1&&H[h]===0;h--);if(m>h&&(m=h),h===0)return n[o++]=1<<24|64<<16|0,n[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<h&&H[u]===0;u++);for(m<u&&(m=u),x=1,l=1;l<=ga;l++)if(x<<=1,x-=H[l],x<0)return -1;if(x>0&&(t===_5||h!==1))return -1;for(k[1]=0,l=1;l<ga;l++)k[l+1]=k[l]+H[l];for(d=0;d<i;d++)e[r+d]!==0&&(s[k[e[r+d]]++]=d);if(t===_5?(G=E=s,F=20):t===Zh?(G=K7,E=z7,F=257):(G=q7,E=G7,F=0),w=0,d=0,l=u,T=o,b=m,A=0,C=-1,y=1<<m,v=y-1,t===Zh&&y>A5||t===C5&&y>w5)return 1;for(;;){q=l-A,s[d]+1<F?(O=0,z=s[d]):s[d]>=F?(O=E[s[d]-F],z=G[s[d]-F]):(O=96,z=0),I=1<<l-A,_=1<<b,u=_;do _-=I,n[T+(w>>A)+_]=q<<24|O<<16|z|0;while(_!==0);for(I=1<<l-1;w&I;)I>>=1;if(I!==0?(w&=I-1,w+=I):w=0,d++,--H[l]===0){if(l===h)break;l=e[r+s[d]];}if(l>m&&(w&v)!==C){for(A===0&&(A=m),T+=u,b=l-A,x=1<<b;b+A<h&&(x-=H[b+A],!(x<=0));)b++,x<<=1;if(y+=1<<b,t===Zh&&y>A5||t===C5&&y>w5)return 1;C=w&v,n[C]=m<<24|b<<16|T-o|0;}}return w!==0&&(n[T+w]=l-A<<24|64<<16|0),a.bits=m,0},vc=$7,V7=0,w8=1,_8=2,{Z_FINISH:I5,Z_BLOCK:j7,Z_TREES:Id,Z_OK:Qo,Z_STREAM_END:X7,Z_NEED_DICT:W7,Z_STREAM_ERROR:yr,Z_DATA_ERROR:C8,Z_MEM_ERROR:I8,Z_BUF_ERROR:Z7,Z_DEFLATED:v5}=wa,Dd=16180,E5=16181,B5=16182,T5=16183,k5=16184,P5=16185,N5=16186,R5=16187,D5=16188,O5=16189,Pd=16190,zi=16191,Yh=16192,M5=16193,Qh=16194,U5=16195,F5=16196,L5=16197,H5=16198,vd=16199,Ed=16200,K5=16201,z5=16202,q5=16203,G5=16204,$5=16205,Jh=16206,V5=16207,j5=16208,De=16209,v8=16210,E8=16211,Y7=852,Q7=592,J7=15,eE=J7,X5=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function tE(){this.strm=null,this.mode=0,this.last=false,this.wrap=0,this.havedict=false,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0;}var Jo=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.mode<Dd||e.mode>E8?1:0},B8=t=>{if(Jo(t))return yr;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Dd,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Y7),e.distcode=e.distdyn=new Int32Array(Q7),e.sane=1,e.back=-1,Qo},T8=t=>{if(Jo(t))return yr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,B8(t)},k8=(t,e)=>{let r;if(Jo(t))return yr;let i=t.state;return e<0?(r=0,e=-e):(r=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?yr:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,T8(t))},P8=(t,e)=>{if(!t)return yr;let r=new tE;t.state=r,r.strm=t,r.window=null,r.mode=Dd;let i=k8(t,e);return i!==Qo&&(t.state=null),i},rE=t=>P8(t,eE),W5=true,e2,t2,iE=t=>{if(W5){e2=new Int32Array(512),t2=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(vc(w8,t.lens,0,288,e2,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;vc(_8,t.lens,0,32,t2,0,t.work,{bits:5}),W5=false;}t.lencode=e2,t.lenbits=9,t.distcode=t2,t.distbits=5;},N8=(t,e,r,i)=>{let n,o=t.state;return o.window===null&&(o.window=new Uint8Array(1<<o.wbits)),o.wsize===0&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0),i>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(e.subarray(r-i,r-i+n),o.wnext),i-=n,i?(o.window.set(e.subarray(r-i,r),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0},nE=(t,e)=>{let r,i,n,o,s,a,c,l,d,u,h,m,b,A,x=0,y,w,I,_,C,v,T,G,F=new Uint8Array(4),H,k,E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Jo(t)||!t.output||!t.input&&t.avail_in!==0)return yr;r=t.state,r.mode===zi&&(r.mode=Yh),s=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,l=r.hold,d=r.bits,u=a,h=c,G=Qo;e:for(;;)switch(r.mode){case Dd:if(r.wrap===0){r.mode=Yh;break}for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&2&&l===35615){r.wbits===0&&(r.wbits=15),r.check=0,F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0),l=0,d=0,r.mode=E5;break}if(r.head&&(r.head.done=false),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=De;break}if((l&15)!==v5){t.msg="unknown compression method",r.mode=De;break}if(l>>>=4,d-=4,T=(l&15)+8,r.wbits===0&&(r.wbits=T),T>15||T>r.wbits){t.msg="invalid window size",r.mode=De;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=l&512?O5:zi,l=0,d=0;break;case E5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.flags=l,(r.flags&255)!==v5){t.msg="unknown compression method",r.mode=De;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=De;break}r.head&&(r.head.text=l>>8&1),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0,r.mode=B5;case B5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.head&&(r.head.time=l),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,F[2]=l>>>16&255,F[3]=l>>>24&255,r.check=it(r.check,F,4,0)),l=0,d=0,r.mode=T5;case T5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.head&&(r.head.xflags=l&255,r.head.os=l>>8),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0,r.mode=k5;case k5:if(r.flags&1024){for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.length=l,r.head&&(r.head.extra_len=l),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0;}else r.head&&(r.head.extra=null);r.mode=P5;case P5:if(r.flags&1024&&(m=r.length,m>a&&(m=a),m&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(o,o+m),T)),r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,r.length-=m),r.length))break e;r.length=0,r.mode=N5;case N5:if(r.flags&2048){if(a===0)break e;m=0;do T=i[o+m++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T));while(T&&m<a);if(r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,T)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=R5;case R5:if(r.flags&4096){if(a===0)break e;m=0;do T=i[o+m++],r.head&&T&&r.length<65536&&(r.head.comment+=String.fromCharCode(T));while(T&&m<a);if(r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,T)break e}else r.head&&(r.head.comment=null);r.mode=D5;case D5:if(r.flags&512){for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&4&&l!==(r.check&65535)){t.msg="header crc mismatch",r.mode=De;break}l=0,d=0;}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=true),t.adler=r.check=0,r.mode=zi;break;case O5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}t.adler=r.check=X5(l),l=0,d=0,r.mode=Pd;case Pd:if(r.havedict===0)return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,W7;t.adler=r.check=1,r.mode=zi;case zi:if(e===j7||e===Id)break e;case Yh:if(r.last){l>>>=d&7,d-=d&7,r.mode=Jh;break}for(;d<3;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}switch(r.last=l&1,l>>>=1,d-=1,l&3){case 0:r.mode=M5;break;case 1:if(iE(r),r.mode=vd,e===Id){l>>>=2,d-=2;break e}break;case 2:r.mode=F5;break;case 3:t.msg="invalid block type",r.mode=De;}l>>>=2,d-=2;break;case M5:for(l>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",r.mode=De;break}if(r.length=l&65535,l=0,d=0,r.mode=Qh,e===Id)break e;case Qh:r.mode=U5;case U5:if(m=r.length,m){if(m>a&&(m=a),m>c&&(m=c),m===0)break e;n.set(i.subarray(o,o+m),s),a-=m,o+=m,c-=m,s+=m,r.length-=m;break}r.mode=zi;break;case F5:for(;d<14;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.nlen=(l&31)+257,l>>>=5,d-=5,r.ndist=(l&31)+1,l>>>=5,d-=5,r.ncode=(l&15)+4,l>>>=4,d-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=De;break}r.have=0,r.mode=L5;case L5:for(;r.have<r.ncode;){for(;d<3;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.lens[E[r.have++]]=l&7,l>>>=3,d-=3;}for(;r.have<19;)r.lens[E[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,H={bits:r.lenbits},G=vc(V7,r.lens,0,19,r.lencode,0,r.work,H),r.lenbits=H.bits,G){t.msg="invalid code lengths set",r.mode=De;break}r.have=0,r.mode=H5;case H5:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[l&(1<<r.lenbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(I<16)l>>>=y,d-=y,r.lens[r.have++]=I;else {if(I===16){for(k=y+2;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(l>>>=y,d-=y,r.have===0){t.msg="invalid bit length repeat",r.mode=De;break}T=r.lens[r.have-1],m=3+(l&3),l>>>=2,d-=2;}else if(I===17){for(k=y+3;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=y,d-=y,T=0,m=3+(l&7),l>>>=3,d-=3;}else {for(k=y+7;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=y,d-=y,T=0,m=11+(l&127),l>>>=7,d-=7;}if(r.have+m>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=De;break}for(;m--;)r.lens[r.have++]=T;}}if(r.mode===De)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=De;break}if(r.lenbits=9,H={bits:r.lenbits},G=vc(w8,r.lens,0,r.nlen,r.lencode,0,r.work,H),r.lenbits=H.bits,G){t.msg="invalid literal/lengths set",r.mode=De;break}if(r.distbits=6,r.distcode=r.distdyn,H={bits:r.distbits},G=vc(_8,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,H),r.distbits=H.bits,G){t.msg="invalid distances set",r.mode=De;break}if(r.mode=vd,e===Id)break e;case vd:r.mode=Ed;case Ed:if(a>=6&&c>=258){t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,H7(t,h),s=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,l=r.hold,d=r.bits,r.mode===zi&&(r.back=-1);break}for(r.back=0;x=r.lencode[l&(1<<r.lenbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(w&&(w&240)===0){for(_=y,C=w,v=I;x=r.lencode[v+((l&(1<<_+C)-1)>>_)],y=x>>>24,w=x>>>16&255,I=x&65535,!(_+y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=y,d-=y,r.back+=y,r.length=I,w===0){r.mode=$5;break}if(w&32){r.back=-1,r.mode=zi;break}if(w&64){t.msg="invalid literal/length code",r.mode=De;break}r.extra=w&15,r.mode=K5;case K5:if(r.extra){for(k=r.extra;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra;}r.was=r.length,r.mode=z5;case z5:for(;x=r.distcode[l&(1<<r.distbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((w&240)===0){for(_=y,C=w,v=I;x=r.distcode[v+((l&(1<<_+C)-1)>>_)],y=x>>>24,w=x>>>16&255,I=x&65535,!(_+y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=y,d-=y,r.back+=y,w&64){t.msg="invalid distance code",r.mode=De;break}r.offset=I,r.extra=w&15,r.mode=q5;case q5:if(r.extra){for(k=r.extra;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra;}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=De;break}r.mode=G5;case G5:if(c===0)break e;if(m=h-c,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=De;break}m>r.wnext?(m-=r.wnext,b=r.wsize-m):b=r.wnext-m,m>r.length&&(m=r.length),A=r.window;}else A=n,b=s-r.offset,m=r.length;m>c&&(m=c),c-=m,r.length-=m;do n[s++]=A[b++];while(--m);r.length===0&&(r.mode=Ed);break;case $5:if(c===0)break e;n[s++]=r.length,c--,r.mode=Ed;break;case Jh:if(r.wrap){for(;d<32;){if(a===0)break e;a--,l|=i[o++]<<d,d+=8;}if(h-=c,t.total_out+=h,r.total+=h,r.wrap&4&&h&&(t.adler=r.check=r.flags?it(r.check,n,h,s-h):Pc(r.check,n,h,s-h)),h=c,r.wrap&4&&(r.flags?l:X5(l))!==r.check){t.msg="incorrect data check",r.mode=De;break}l=0,d=0;}r.mode=V5;case V5:if(r.wrap&&r.flags){for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&4&&l!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=De;break}l=0,d=0;}r.mode=j5;case j5:G=X7;break e;case De:G=C8;break e;case v8:return I8;case E8:default:return yr}return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,(r.wsize||h!==t.avail_out&&r.mode<De&&(r.mode<Jh||e!==I5))&&N8(t,t.output,t.next_out,h-t.avail_out),u-=t.avail_in,h-=t.avail_out,t.total_in+=u,t.total_out+=h,r.total+=h,r.wrap&4&&h&&(t.adler=r.check=r.flags?it(r.check,n,h,t.next_out-h):Pc(r.check,n,h,t.next_out-h)),t.data_type=r.bits+(r.last?64:0)+(r.mode===zi?128:0)+(r.mode===vd||r.mode===Qh?256:0),(u===0&&h===0||e===I5)&&G===Qo&&(G=Z7),G},oE=t=>{if(Jo(t))return yr;let e=t.state;return e.window&&(e.window=null),t.state=null,Qo},sE=(t,e)=>{if(Jo(t))return yr;let r=t.state;return (r.wrap&2)===0?yr:(r.head=e,e.done=false,Qo)},aE=(t,e)=>{let r=e.length,i,n,o;return Jo(t)||(i=t.state,i.wrap!==0&&i.mode!==Pd)?yr:i.mode===Pd&&(n=1,n=Pc(n,e,r,0),n!==i.check)?C8:(o=N8(t,e,r,r),o?(i.mode=v8,I8):(i.havedict=1,Qo))},cE=T8,lE=k8,dE=B8,uE=rE,fE=P8,pE=nE,hE=oE,mE=sE,gE=aE,yE="pako inflate (from Nodeca project)",ni={inflateReset:cE,inflateReset2:lE,inflateResetKeep:dE,inflateInit:uE,inflateInit2:fE,inflate:pE,inflateEnd:hE,inflateGetHeader:mE,inflateSetDictionary:gE,inflateInfo:yE};function bE(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=false;}var SE=bE,R8=Object.prototype.toString,{Z_NO_FLUSH:xE,Z_FINISH:Z5,Z_OK:ba,Z_STREAM_END:r2,Z_NEED_DICT:i2,Z_STREAM_ERROR:AE,Z_DATA_ERROR:Y5,Z_MEM_ERROR:wE,Z_BUF_ERROR:Q5}=wa,_E={chunkSize:1024*64,windowBits:15,to:""};function Uc(t){this.options=Rd.assign({},_E,t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=false,this.chunks=[],this.strm=new x8,this.strm.avail_out=0;let r=ni.inflateInit2(this.strm,e.windowBits);if(r!==ba)throw new Error(Wo[r]);if(this.header=new SE,ni.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Rc.string2buf(e.dictionary):R8.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=ni.inflateSetDictionary(this.strm,e.dictionary),r!==ba)))throw new Error(Wo[r])}Uc.prototype.push=function(t,e){let r=this.strm,i=this.options.chunkSize,n=this.options.dictionary,o,s,a;if(this.ended)return false;for(e===~~e?s=e:s=e===true?Z5:xE,R8.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),o=ni.inflate(r,s),o===i2&&n&&(o=ni.inflateSetDictionary(r,n),o===ba?o=ni.inflate(r,s):o===Y5&&(o=i2));r.avail_in>0&&o===r2&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)ni.inflateReset(r),o=ni.inflate(r,s);switch(o){case AE:case Y5:case i2:case wE:return this.onEnd(o),this.ended=true,false}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===r2||s>0))if(this.options.to==="string"){let c=Rc.utf8border(r.output,r.next_out),l=r.next_out-c,d=Rc.buf2string(r.output,c);r.next_out=l,r.avail_out=i-l,l&&r.output.set(r.output.subarray(c,c+l),0),this.onData(d);}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((o===ba||o===Q5)&&a===0)){if(o===r2)return o=ni.inflateEnd(this.strm),this.onEnd(o),this.ended=true,true;if(r.avail_in===0){if(s===Z5)return o=ni.inflateEnd(this.strm),this.onEnd(o===ba?Q5:o),this.ended=true,false;break}}}return true};Uc.prototype.onData=function(t){this.chunks.push(t);};Uc.prototype.onEnd=function(t){t===ba&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function x2(t,e){let r=new Uc(e);if(r.push(t,true),r.err)throw r.msg||Wo[r.err];return r.result}var vE=x2,kE={inflate:vE},{deflate:PE}=F7,{inflate:NE}=kE;var D8=PE;var A2=NE;var RE=(0, U8.default)("bridge"),O8=32*1024,w2=1024*16,DE=1;function M8(t,e){return {jsonrpc:"2.0",id:fa(16),method:t,params:e}}async function OE(t,e,r,i){let n=[],o=[];if(e){let s=Buffer.from(D8(JSON.stringify(e))).toString("base64"),a=Math.ceil(s.length/w2),c=fa(16);for(let l=0;l<a;l++){let d=l*w2,u=Math.min(d+w2,s.length),h=s.slice(d,u),m=JSON.stringify({method:t,params:h,chunk:{id:c,index:l,length:a}}),b=await xc(m,r,i),A=M8("encryptedMessage",{payload:Buffer.from(b).toString("base64")});o.push(A.id),n.push(JSON.stringify(A));}}else {let s=JSON.stringify({method:t,params:e||{}}),a=await xc(s,r,i),c=M8("encryptedMessage",{payload:Buffer.from(a).toString("base64")});o.push(c.id),n.push(JSON.stringify(c));}return {chunks:n,messageIds:o}}async function _2(t,e,r,i,n){try{let{chunks:o,messageIds:s}=await OE(t,e,r,i);for(let a of o){if(a.length>O8)throw new Error(`Payload exceeds max size of ${O8} bytes`);n.send(a),o.length>1&&await new Promise(c=>setTimeout(c,DE));}return {success:!0,messageIds:s}}catch(o){return RE("Error sending encrypted message:",o),{success:false,messageIds:[]}}}var C2=class{constructor(t){f(this,"code");f(this,"reason");f(this,"event");this.code=t.code,this.reason=t.reason,this.event=t.event;}},Od=class{constructor(t){f(this,"code");f(this,"reason");f(this,"wasConnected");f(this,"wasIntentionalClose");f(this,"willReconnect");f(this,"event");this.code=t.code,this.reason=t.reason,this.wasConnected=t.wasConnected,this.wasIntentionalClose=t.wasIntentionalClose,this.willReconnect=t.willReconnect,this.event=t.event;}};var F8=It(uc(),1);var I2=class{constructor(t){f(this,"log");f(this,"role");f(this,"origin");f(this,"_bridgeOrigin");f(this,"bridgeId");f(this,"keyPair");f(this,"remotePublicKey");f(this,"sharedSecret");f(this,"websocket");f(this,"secureChannelEstablished",false);f(this,"intentionalClose",false);f(this,"keepalive");f(this,"reconnect");f(this,"reconnectAttempts",0);f(this,"maxReconnectAttempts");f(this,"reconnectTimer");f(this,"pingTimer");f(this,"pingInterval",3e4);f(this,"isReconnecting",false);f(this,"isConnected",false);f(this,"everConnected",false);f(this,"isCreatingSocket",false);f(this,"resumedSession",false);f(this,"bridgeUrl");f(this,"validMessagesReceived",0);f(this,"lastMessageTimestamp",0);f(this,"lastCloseEvent");f(this,"originOnConnect");f(this,"_originValidatedViaOoc",false);f(this,"eventListeners");f(this,"incompleteMessages",new Map);f(this,"seenMessageIds",new Set);f(this,"reconnectOnWake",()=>{document.visibilityState==="visible"&&this.reconnectIfDisconnected();});this.role=t.role,this.origin=t.origin;let e=t.pinOrigin??true;this._bridgeOrigin=e?t.domain:void 0,this.log=(0, F8.default)(`bridge:${this.role}`),this.bridgeId=t.bridgeId||fa(16),this.keyPair=t.keyPair,this.reconnect=t.reconnect??true,this.keepalive=t.keepalive??true,this.maxReconnectAttempts=t.reconnectAttempts??B6,this.pingInterval=t.pingInterval||k6,this.bridgeUrl=t.bridgeUrl??T6,this.originOnConnect=t.originOnConnect??true,this.eventListeners={connected:[],"secure-channel-established":[],"raw-message-received":[],"message-received":[],"chunk-received":[],error:[],"failed-to-connect":[],disconnected:[]},this.reconnect&&typeof document<"u"&&(document.addEventListener("visibilitychange",this.reconnectOnWake),window.addEventListener("online",this.reconnectOnWake));}resume(){this.log("Resuming bridge session"),this.secureChannelEstablished=true,this.resumedSession=true;}on(t,e){return this.eventListeners[t].push(e),()=>this.off(t,e)}off(t,e){let r=this.eventListeners[t].indexOf(e);r!==-1&&this.eventListeners[t].splice(r,1);}async emit(t,...e){await Promise.all(this.eventListeners[t].map(async r=>{try{await r(...e);}catch(i){this.log(`Error in ${t} listener:`,i);}}));}setupWebSocketHandlers(t){t.onopen=async()=>{if(this.isConnected=true,this.everConnected=true,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this.websocket&&this.websocket.send(JSON.stringify({method:"ping",params:{},nocache:true}));},this.pingInterval),this.isReconnecting){if(this.log("Reconnected to bridge"),this.resetReconnection(),this.lastMessageTimestamp>0&&this.websocket){let e=this.lastMessageTimestamp-1e3;this.log(`Requesting message replay starting from ${e}`),this.websocket.send(JSON.stringify({method:"replay",params:{timestamp:e}}));}await this.emit("connected",true);}else this.log("Connected to bridge"),this.lastMessageTimestamp===0&&(this.lastMessageTimestamp=Date.now()),await this.emit("connected",false),this.resumedSession&&(this.log("Resumed session, emitting secure channel established event"),await this.emit("secure-channel-established"));},t.onerror=e=>{this.log("[websocket.onerror]",e?.message??"socket error");},t.onmessage=async e=>{await this.emit("raw-message-received",e.data);try{let r=JSON.parse(e.data);await this.handleWebSocketMessage(r);}catch(r){this.log("Error parsing message:",r),await this.emit("error",`Error parsing message: ${r instanceof Error?r.message:String(r)}`);}},t.onclose=async e=>{let{code:r,reason:i,wasClean:n}=e;this.log("[websocket.onclose]",{code:r,reason:i,wasClean:n,readyState:t.readyState}),this.lastCloseEvent=e,this.pingTimer&&clearInterval(this.pingTimer);let o=this.isConnected;if(this.isConnected=false,o){let s=new Od({code:e.code,reason:e.reason,wasConnected:true,wasIntentionalClose:this.intentionalClose,willReconnect:!this.intentionalClose&&this.reconnect,event:e});if(await this.emit("disconnected",s),this.websocket!==t||this.isReconnecting)return}if(this.intentionalClose){this.log("Intentional close, not attempting reconnect"),this._handleCleanup();return}if(!o&&this.isReconnecting){this.log("Reconnection attempt failed"),await this.handleReconnect();return}if(!o){let s=new C2({code:e.code,reason:e.reason,event:e});await this.emit("failed-to-connect",s);return}this.log("WebSocket closed"),this.reconnect&&await this.handleReconnect();};}async handleWebSocketMessage(t){if(t.method==="ping"){this.log("Received ping message, responding with pong"),this.websocket?.send(JSON.stringify({method:"pong",params:{},nocache:true}));return}if(t.method!=="pong"){if(this.role==="joiner"&&t.method==="ooc"&&t.params?.origin){if(!this.originOnConnect){this.log("WARNING: Ignoring unsolicited ooc message");return}if(this.secureChannelEstablished){this.log("WARNING: Secure channel already established. Ignoring ooc message");return}let e=wh(t.params.origin);if(this.log("Received origin on connect:",e),this._bridgeOrigin&&this._bridgeOrigin!==e){this.log(`WARNING: Expected origin ${this._bridgeOrigin} but got ${e} (via ooc)`),await this.emit("error",`Origin on connect ${e} does not match expected origin ${this._bridgeOrigin}`);return}this._bridgeOrigin||(this._bridgeOrigin=e,this.log("Set bridge origin from ooc:",this._bridgeOrigin)),this._originValidatedViaOoc=true,this.secureChannelEstablished=true,await this.emit("secure-channel-established");return}if(!t.id){this.log("Ignoring message with missing id:",t);return}if(this.seenMessageIds.has(t.id)){this.log("Ignoring message with duplicate id:",t.id);return}if(this.seenMessageIds.add(t.id),this.validMessagesReceived+=1,this.lastMessageTimestamp=Date.now(),this.role==="creator"&&t.method==="handshake"&&(this.log("Processing handshake message"),await this.handleHandshake(t)),t.method==="encryptedMessage"){if(this.log("Processing encrypted message"),this.role==="joiner"&&this._bridgeOrigin){let e=t.origin?wh(t.origin):void 0;if(e!==this._bridgeOrigin){this.log(`WARNING: Origin differs from origin in connection string. Expected ${this._bridgeOrigin} but got ${e}`),this.log("Ignoring received message:",t),this.emit("error",`Origin ${e} does not match expected origin ${this._bridgeOrigin}`);return}}await this.handleEncryptedMessage(t);}}}async handleHandshake(t){this.log("Received handshake:",t);try{let e=new Uint8Array(Buffer.from(t.params.pubkey,"hex"));if(this.secureChannelEstablished&&this.remotePublicKey!==e){this.log("Secure channel already established, ignoring handshake"),this.emit("error","Secure channel already established, ignoring handshake"),this.websocket?.send(JSON.stringify({method:"error",params:{message:"Secure channel already established, ignoring handshake"}}));return}if(this.remotePublicKey=e,this.sharedSecret=zh(this.keyPair.privateKey,e),await qh(Buffer.from(t.params.greeting,"hex"),this.sharedSecret,this.bridgeId)!=="hello")throw new Error("Invalid greeting");this.websocket&&(await _2("hello",null,this.sharedSecret,this.bridgeId,this.websocket)).messageIds.forEach(n=>this.seenMessageIds.add(n)),this.secureChannelEstablished?this.log("Secure channel already established, sending handshake message again"):(this.secureChannelEstablished=!0,await this.emit("secure-channel-established"));}catch(e){this.log("Error handling handshake:",e),await this.emit("error",`Error handling handshake: ${e instanceof Error?e.message:String(e)}`);}}async handleEncryptedMessage(t){try{if(!this.sharedSecret)throw new Error("Shared secret not available");let e=new Uint8Array(Buffer.from(t.params.payload,"base64")),r=await qh(e,this.sharedSecret,this.bridgeId),i=JSON.parse(r);if(!i.chunk||i.chunk.length==1)if(i.method==="hello"&&!this.secureChannelEstablished)this.log(`Verified origin: ${t.origin}`),this.secureChannelEstablished=!0,await this.emit("secure-channel-established");else {try{if(i.params&&i.params.length>0){this.log("Received compressed single-part message");let n=Buffer.from(i.params,"base64"),o=A2(n),s=new TextDecoder().decode(o);i.params=JSON.parse(s),delete i.chunk;}}catch(n){if(n!=="incorrect header check")throw console.error("Some error happened data:",n),new Error("Failed to parse data: ");this.log("Received uncompressed single-part message");try{i.params=JSON.parse(i.params);}catch{}}await this.emit("message-received",i);}else {let{index:n,length:o,id:s}=i.chunk;this.log(`Received chunk (${n+1}/${o}) for chunk id ${s}`),this.incompleteMessages.has(s)||this.incompleteMessages.set(s,{chunks:new Array(o),expectedChunks:o,timestamp:Date.now()});let a=this.incompleteMessages.get(s);if(a.expectedChunks!==o)throw this.log(`Chunk count mismatch for id ${s}. Expected ${a.expectedChunks}, got ${o}`),new Error(`Chunk count mismatch for id ${s}. Expected ${a.expectedChunks}, got ${o}`);if(a.chunks[n]=i.params,await this.emit("chunk-received",i.chunk),(()=>{for(let l=0;l<a.chunks.length;l++)if(a.chunks[l]===void 0)return !1;return !0})()){let l=a.chunks.join(""),d=Buffer.from(l,"base64"),u=A2(d),h=new TextDecoder().decode(u),m=JSON.parse(h);this.log(`Received all chunks for chunk id ${s}, reconstructing message`);let b={method:i.method,params:m};this.incompleteMessages.delete(s),await this.emit("message-received",b);}}}catch(e){this.log("Error decrypting message:",e),await this.emit("error",`Error decrypting message: ${e instanceof Error?e.message:String(e)}`);}}async handleReconnect(){if(this.reconnectAttempts++,this.reconnectAttempts>this.maxReconnectAttempts){this.log(`WebSocket disconnected, max reconnection attempts (${this.maxReconnectAttempts}) reached`),this.resetReconnection();let e=this.lastCloseEvent;await this.emit("disconnected",new Od({code:e.code,reason:e.reason,wasConnected:true,wasIntentionalClose:false,willReconnect:false,event:e}));return}this.isReconnecting=true,this.log(`WebSocket disconnected, attempting reconnect ${this.reconnectAttempts}/${this.maxReconnectAttempts}`);let t=0;this.reconnectAttempts>1&&(t=1e3*Math.pow(2,this.reconnectAttempts-2),this.log(`Waiting ${t}ms before reconnecting...`)),this.reconnectTimer=setTimeout(async()=>{this.isCreatingSocket=true;try{let e=await this._getWsConnectionUrl();this.websocket=await cd(e,this.origin),this.setupWebSocketHandlers(this.websocket);}catch(e){this.log("Reconnection failed:",e),await this.handleReconnect();}finally{this.isCreatingSocket=false;}},t);}reconnectIfDisconnected(){return this.intentionalClose||!this.reconnect||!this.everConnected||this.isCreatingSocket||this.websocket?.readyState!==3?false:(this.log("Connection lost, reconnecting now"),this.resetReconnection(),this.handleReconnect(),true)}resetReconnection(){this.log("Resetting reconnection state"),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.reconnectAttempts=0,this.isReconnecting=false;}isBridgeConnected(){return this.websocket?this.websocket.readyState===1:false}isSecureChannelEstablished(){return this.secureChannelEstablished}async sendSecureMessage(t,e={}){if(!this.isConnected||!this.secureChannelEstablished)return await this.emit("error","Cannot send message: Secure channel not established"),false;let r=await _2(t,e,this.sharedSecret,this.bridgeId,this.websocket);return r.messageIds.forEach(i=>this.seenMessageIds.add(i)),r.success}onConnect(t){return this.on("connected",t)}onSecureChannelEstablished(t){return this.on("secure-channel-established",t)}onRawMessage(t){return this.on("raw-message-received",t)}onSecureMessage(t){return this.on("message-received",t)}onError(t){return this.on("error",t)}onFailedToConnect(t){return this.on("failed-to-connect",e=>t(e))}onDisconnect(t){return this.on("disconnected",e=>t(e))}setRemotePublicKey(t){this.remotePublicKey=t;}computeSharedSecret(){if(!this.remotePublicKey)throw new Error("Remote public key not set");this.sharedSecret=zh(this.keyPair.privateKey,this.remotePublicKey);}async createEncryptedGreeting(){if(!this.sharedSecret)throw new Error("Shared secret not available");let t=await xc("hello",this.sharedSecret,this.bridgeId);return Buffer.from(t).toString("hex")}async _getWsConnectionUrl(){if(this.role==="creator")return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}`;{let t=this.originOnConnect?"&ooc":"";if(this.isSecureChannelEstablished())return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}`;{let e=await this.createEncryptedGreeting(),r=JSON.stringify({jsonrpc:"2.0",id:fa(16),method:"handshake",params:{pubkey:this.getPublicKey(),greeting:e}}),i=Buffer.from(r).toString("base64");return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}&moc=${encodeURIComponent(i)}${t}`}}}getPublicKey(){return pc(this.keyPair.publicKey)}getRemotePublicKey(){if(!this.remotePublicKey)throw new Error("Remote public key not set");return pc(this.remotePublicKey)}getBridgeId(){return this.bridgeId}getWebSocket(){return this.websocket}get bridgeOrigin(){return this.role==="creator"?this.origin:this._bridgeOrigin}get connectionString(){let t=this.bridgeOrigin;if(!t)throw new Error("Bridge origin is not known yet, wait for the secure channel to be established");let e=this.originOnConnect?"&ooc":"";return this.role==="creator"?`obsidion:${this.getPublicKey()}?d=${t}&v=${ua}${e}`:`obsidion:${this.getBridgeId()}?d=${t}&v=${ua}${e}`}async connect(t){try{this.log("Connecting to bridge...",t);let e=await(this.origin?cd(t,this.origin):cd(t));this.websocket=e,this.setupWebSocketHandlers(e);}catch(e){throw this.log("Error connecting to bridge:",e),await this.emit("error",`Error connecting to bridge: ${e instanceof Error?e.message:String(e)}`),e}}_handleCleanup(){this.log("Cleaning up event listeners and associated state"),typeof document<"u"&&(document.removeEventListener("visibilitychange",this.reconnectOnWake),window.removeEventListener("online",this.reconnectOnWake)),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=void 0,this.websocket&&(this.websocket.onopen=null,this.websocket.onmessage=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket=void 0),this.secureChannelEstablished=false,this.sharedSecret=void 0,this.remotePublicKey=void 0,this.eventListeners={connected:[],"secure-channel-established":[],"raw-message-received":[],"message-received":[],"chunk-received":[],error:[],"failed-to-connect":[],disconnected:[]};}cleanup(){this.log("Closing connection to bridge"),this.intentionalClose=true;let t=this.websocket?.readyState;t===1||t===0?this.websocket.close(1e3,"Connection closed by user"):this._handleCleanup();}};var v2=It(uc(),1),E2=class L8{static async create(e={}){e.debug&&v2.default.enable("bridge*");let r=e.autoconnect??true;if(e.origin&&typeof window<"u")throw new Error("Origin can't be specified when running in browser");!e.origin&&typeof window>"u"&&(e.origin="nodejs");let i=e.origin||window?.location?.protocol+"//"+window?.location?.hostname;if(e.remotePublicKey&&!e.resume)throw new Error("Can only provide remotePublicKey when resuming a bridge session");if(e.resume&&(!e.keyPair||!e.remotePublicKey))throw new Error("Resuming a bridge session requires a keyPair and remotePublicKey");let n=e.keyPair||wd(),o=pc(n.publicKey),s=new I2({role:"creator",origin:i,bridgeId:o,keyPair:n,reconnect:e.reconnect,keepalive:e.keepalive,pingInterval:e.pingInterval,bridgeUrl:e.bridgeUrl,originOnConnect:e.originOnConnect??true});return e.resume&&(s.setRemotePublicKey(e.remotePublicKey),await s.computeSharedSecret(),s.resume()),(e.resume||r)&&await s.connect(await s._getWsConnectionUrl()),{websocket:s.getWebSocket(),connection:s,onConnect:a=>s.onConnect(a),onFailedToConnect:a=>s.onFailedToConnect(a),onSecureChannelEstablished:a=>s.onSecureChannelEstablished(a),onRawMessage:a=>s.onRawMessage(a),onSecureMessage:a=>s.onSecureMessage(a),onError:a=>s.onError(a),onDisconnect:a=>s.onDisconnect(a),isBridgeConnected:()=>s.isBridgeConnected(),isSecureChannelEstablished:()=>s.isSecureChannelEstablished(),sendMessage:(a,c)=>s.sendSecureMessage(a,c||{}),connectionString:s.connectionString,bridgeId:s.getBridgeId(),origin:s.bridgeOrigin,getKeyPair:()=>s.keyPair,getPublicKey:()=>s.getPublicKey(),getRemotePublicKey:()=>s.getRemotePublicKey(),close:()=>s.cleanup(),cleanup:()=>s.cleanup(),[Symbol.dispose]:()=>s.cleanup()}}static async join(e,r={}){if(r.debug&&v2.default.enable("bridge*"),r.resume&&!r.keyPair)throw new Error("Resuming a bridge session requires a keyPair");let i=r.keyPair||wd(),{domain:n,pubkey:o,ooc:s}=L8.parseConnectionString(e),a=r.originOnConnect!==void 0?r.originOnConnect:s;if(r.pinOrigin===false&&(!a||r.resume))throw new Error("pinOrigin: false requires originOnConnect and cannot be combined with resume");let c=new I2({role:"joiner",domain:n,bridgeId:o,keyPair:i,reconnect:r.reconnect,keepalive:r.keepalive,pingInterval:r.pingInterval,bridgeUrl:r.bridgeUrl,originOnConnect:a,pinOrigin:r.pinOrigin});return c.setRemotePublicKey(new Uint8Array(Buffer.from(o,"hex"))),await c.computeSharedSecret(),r.resume&&c.resume(),await c.connect(await c._getWsConnectionUrl()),{websocket:c.getWebSocket(),connection:c,onConnect:l=>c.onConnect(l),onFailedToConnect:l=>c.onFailedToConnect(l),onSecureChannelEstablished:l=>c.onSecureChannelEstablished(l),onRawMessage:l=>c.onRawMessage(l),onSecureMessage:l=>c.onSecureMessage(l),onError:l=>c.onError(l),onDisconnect:l=>c.onDisconnect(l),isBridgeConnected:()=>c.isBridgeConnected(),isSecureChannelEstablished:()=>c.isSecureChannelEstablished(),sendMessage:(l,d)=>c.sendSecureMessage(l,d||{}),get connectionString(){return c.connectionString},bridgeId:c.getBridgeId(),get origin(){return c.bridgeOrigin},getKeyPair:()=>c.keyPair,getPublicKey:()=>c.getPublicKey(),getRemotePublicKey:()=>c.getRemotePublicKey(),close:()=>c.cleanup(),cleanup:()=>c.cleanup(),[Symbol.dispose]:()=>c.cleanup()}}static parseConnectionString(e){let r=new URL(e),i=r.pathname,n=r.searchParams.get("d"),o=r.searchParams.has("ooc");if(!n||!i)throw new Error("Invalid connection string: missing required parameters");return n!=="nodejs"&&!n.startsWith("http")&&(n="https://"+n),{domain:n,pubkey:i,ooc:o}}static async generateKeyPair(){return wd()}};var Kd=It(V8(),1);var j8={locale:"en",countries:{AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:["People's Republic of China","China"],CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:["Republic of the Congo","Congo"],CD:["Democratic Republic of the Congo","Congo"],CK:"Cook Islands",CR:"Costa Rica",CI:["Cote d'Ivoire","C\xF4te d'Ivoire","Ivory Coast"],HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:["Czech Republic","Czechia"],DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:["Republic of The Gambia","The Gambia","Gambia"],GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:["Islamic Republic of Iran","Iran"],IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"North Korea",KR:["South Korea","Korea, Republic of","Republic of Korea"],KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:["Netherlands","The Netherlands","Netherlands (Kingdom of the)"],NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:["The Republic of North Macedonia","North Macedonia"],MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:["State of Palestine","Palestine"],PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:["Pitcairn","Pitcairn Islands"],PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Reunion",RO:"Romania",RU:["Russian Federation","Russia"],RW:"Rwanda",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Eswatini",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:["Taiwan, Province of China","Taiwan"],TJ:"Tajikistan",TZ:["United Republic of Tanzania","Tanzania"],TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:["T\xFCrkiye","Turkey"],TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:["United Arab Emirates","UAE"],GB:["United Kingdom","UK","Great Britain"],US:["United States of America","United States","USA","U.S.A.","US","U.S."],UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela",VN:"Vietnam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",AX:["\xC5land Islands","Aland Islands"],BQ:"Bonaire, Sint Eustatius and Saba",CW:"Cura\xE7ao",GG:"Guernsey",IM:"Isle of Man",JE:"Jersey",ME:"Montenegro",BL:"Saint Barth\xE9lemy",MF:"Saint Martin (French part)",RS:"Serbia",SX:"Sint Maarten (Dutch part)",SS:"South Sudan",XK:"Kosovo"}};var eS={debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}};(0, Kd.registerLocale)(j8);function Gi(t){if(t==="Zero Knowledge Republic")return "ZKR";let e;return e=(0, Kd.getAlpha3Code)(t,"en")||t||"ZKR",e}function Ln(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function pS(t,e,r,i){i[r][t]={...i[r][t],range:e};}function va(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function jE(){let t={query:{}},e="query",r=false,i=o=>{if(t[e].policy)throw new Error(`Cannot call .${o}() on a policy-driven query. The query for policy '${t[e].policy}' is immutable.`);r=true;},n={eq:(o,s)=>(i("eq"),(o==="issuing_country"||o==="nationality")&&(s=Gi(s)),va("eq",o,s,e,t),n),gte:(o,s)=>{if(i("gte"),Ln("gte",o,s,e,t),o==="age"&&(s<1||s>=100))throw new Error("Age must be between 1 and 99 (inclusive)");return n},gt:(o,s)=>(i("gt"),Ln("gt",o,s,e,t),n),lte:(o,s)=>(i("lte"),Ln("lte",o,s,e,t),n),lt:(o,s)=>(i("lt"),Ln("lt",o,s,e,t),n),range:(o,s,a)=>(i("range"),pS(o,[s,a],e,t),n),in:(o,s)=>(i("in"),s=s.map(a=>Gi(a)),va("in",o,s,e,t),n),out:(o,s)=>(i("out"),s=s.map(a=>Gi(a)),va("out",o,s,e,t),n),disclose:o=>(i("disclose"),t[e][o]={...t[e][o],disclose:true},n),bind:(o,s)=>(t[e].bind={...t[e].bind,[o]:s},n),sanctions:(o="all",s="all",a={strict:false})=>(i("sanctions"),t[e].sanctions={...t[e].sanctions,countries:o,lists:s,strict:a.strict??false},n),facematch:(o="strict")=>(i("facematch"),t[e].facematch={mode:o},n),raw:o=>(i("raw"),t[e]=o,n),policy:o=>{if(typeof o!="string"||o.length===0)throw new Error(".policy() requires a non-empty string id.");if(t[e].policy)throw new Error(`Cannot call .policy() more than once on a request (already set to '${t[e].policy}').`);if(r)throw new Error("Cannot combine .policy() with builder methods like .gte()/.disclose()/etc.");return t[e].policy=o,n},done:(()=>({query:t[e]}))};return n}var XE="0.19.0",O2=XE,gt=10080*60,Fn=new Date(0),hS="https://dashboard-api.zkpassport.id",WE="https://verifier.zkpassport.id",tS="0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b",rS="0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d",iS="0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b",nS="0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211",oS="0x0e1889bec6c1d686abcf08360ff404f803ab345881ea8cba6aad33b7f7f7ffe0",sS=1440*60*1e3,ZE=class{static checkDiscloseBytesPublicInputs(t,e,r){let i={},n=true,o=t.committedInputs?.disclose_bytes?.disclosedBytes??t.committedInputs?.disclose_bytes_evm?.disclosedBytes,s=jp.fromDisclosedBytes(o,"passport"),a=jp.fromDisclosedBytes(o,"id_card");if(r.document_type&&(r.document_type.eq&&r.document_type.eq.result&&r.document_type.eq.expected!==s.documentType&&(console.warn("Document type does not match the expected document type"),n=false,i.document_type={...i.document_type,eq:{expected:`${r.document_type.eq.expected}`,received:`${s.documentType??a.documentType}`,message:"Document type does not match the expected document type"}}),r.document_type.disclose&&r.document_type.disclose.result!==a.documentType&&(console.warn("Document type does not match the disclosed document type in query result"),n=false,i.document_type={...i.document_type,disclose:{expected:`${r.document_type.disclose?.result}`,received:`${a.documentType??s.documentType}`,message:"Document type does not match the disclosed document type in query result"}}),r.document_type.eq&&(e.document_type?.eq===void 0||r.document_type.eq.expected!==e.document_type.eq)&&(console.warn("Document type eq does not match the original query"),n=false,i.document_type={...i.document_type,eq:{expected:`${e.document_type?.eq}`,received:`${r.document_type.eq.expected}`,message:"Document type eq does not match the original query"}}),r.document_type.disclose&&!e.document_type?.disclose&&(console.warn("Document type disclose is not in the original query"),n=false,i.document_type={...i.document_type,disclose:{expected:"Not requested in original query",received:`${r.document_type.disclose.result}`,message:"Document type disclose is not in the original query"}})),r.birthdate){let c=s.dateOfBirth,l=a.dateOfBirth;r.birthdate.eq&&r.birthdate.eq.result&&!me(r.birthdate.eq.expected,c)&&!me(r.birthdate.eq.expected,l)&&(console.warn("Birthdate does not match the expected birthdate"),n=false,i.birthdate={...i.birthdate,eq:{expected:`${r.birthdate.eq.expected.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Birthdate does not match the expected birthdate"}}),r.birthdate.disclose&&!me(r.birthdate.disclose.result,c)&&!me(r.birthdate.disclose.result,l)&&(console.warn("Birthdate does not match the disclosed birthdate in query result"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${r.birthdate.disclose.result.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Birthdate does not match the disclosed birthdate in query result"}}),r.birthdate.eq&&(e.birthdate?.eq===void 0||!me(r.birthdate.eq.expected,e.birthdate.eq))&&(console.warn("Birthdate eq does not match the original query"),n=false,i.birthdate={...i.birthdate,eq:{expected:`${e.birthdate?.eq?.toISOString?.()??"undefined"}`,received:`${r.birthdate.eq.expected.toISOString()}`,message:"Birthdate eq does not match the original query"}}),r.birthdate.disclose&&!e.birthdate?.disclose&&(console.warn("Birthdate disclose is not in the original query"),n=false,i.birthdate={...i.birthdate,disclose:{expected:"Not requested in original query",received:`${r.birthdate.disclose.result}`,message:"Birthdate disclose is not in the original query"}});}if(r.expiry_date){let c=s.dateOfExpiry,l=a.dateOfExpiry;r.expiry_date.eq&&r.expiry_date.eq.result&&!me(r.expiry_date.eq.expected,c)&&!me(r.expiry_date.eq.expected,l)&&(console.warn("Expiry date does not match the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,eq:{expected:`${r.expiry_date.eq.expected.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Expiry date does not match the expected expiry date"}}),r.expiry_date.disclose&&!me(r.expiry_date.disclose.result,c)&&!me(r.expiry_date.disclose.result,l)&&(console.warn("Expiry date does not match the disclosed expiry date in query result"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${r.expiry_date.disclose.result.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Expiry date does not match the disclosed expiry date in query result"}}),r.expiry_date.eq&&(e.expiry_date?.eq===void 0||!me(r.expiry_date.eq.expected,e.expiry_date.eq))&&(console.warn("Expiry date eq does not match the original query"),n=false,i.expiry_date={...i.expiry_date,eq:{expected:`${e.expiry_date?.eq?.toISOString?.()??"undefined"}`,received:`${r.expiry_date.eq.expected.toISOString()}`,message:"Expiry date eq does not match the original query"}}),r.expiry_date.disclose&&!e.expiry_date?.disclose&&(console.warn("Expiry date disclose is not in the original query"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:"Not requested in original query",received:`${r.expiry_date.disclose.result}`,message:"Expiry date disclose is not in the original query"}});}if(r.nationality){let c=s.nationality,l=a.nationality;r.nationality.eq&&r.nationality.eq.result&&r.nationality.eq.expected!==c&&r.nationality.eq.expected!==l&&(console.warn("Nationality does not match the expected nationality"),n=false,i.nationality={...i.nationality,eq:{expected:`${r.nationality.eq.expected}`,received:`${c??l}`,message:"Nationality does not match the expected nationality"}}),r.nationality.disclose&&r.nationality.disclose.result!==c&&r.nationality.disclose.result!==l&&(console.warn("Nationality does not match the disclosed nationality in query result"),n=false,i.nationality={...i.nationality,disclose:{expected:`${r.nationality.disclose.result}`,received:`${c??l}`,message:"Nationality does not match the disclosed nationality in query result"}}),r.nationality.eq&&(e.nationality?.eq===void 0||r.nationality.eq.expected!==e.nationality.eq)&&(console.warn("Nationality eq does not match the original query"),n=false,i.nationality={...i.nationality,eq:{expected:`${e.nationality?.eq}`,received:`${r.nationality.eq.expected}`,message:"Nationality eq does not match the original query"}}),r.nationality.disclose&&!e.nationality?.disclose&&(console.warn("Nationality disclose is not in the original query"),n=false,i.nationality={...i.nationality,disclose:{expected:"Not requested in original query",received:`${r.nationality.disclose.result}`,message:"Nationality disclose is not in the original query"}});}if(r.document_number){let c=s.documentNumber,l=a.documentNumber;r.document_number.eq&&r.document_number.eq.result&&r.document_number.eq.expected!==c&&r.document_number.eq.expected!==l&&(console.warn("Document number does not match the expected document number"),n=false,i.document_number={...i.document_number,eq:{expected:`${r.document_number.eq.expected}`,received:`${c??l}`,message:"Document number does not match the expected document number"}}),r.document_number.disclose&&r.document_number.disclose.result!==c&&r.document_number.disclose.result!==l&&(console.warn("Document number does not match the disclosed document number in query result"),n=false,i.document_number={...i.document_number,disclose:{expected:`${r.document_number.disclose.result}`,received:`${c??l}`,message:"Document number does not match the disclosed document number in query result"}}),r.document_number.eq&&(e.document_number?.eq===void 0||r.document_number.eq.expected!==e.document_number.eq)&&(console.warn("Document number eq does not match the original query"),n=false,i.document_number={...i.document_number,eq:{expected:`${e.document_number?.eq}`,received:`${r.document_number.eq.expected}`,message:"Document number eq does not match the original query"}}),r.document_number.disclose&&!e.document_number?.disclose&&(console.warn("Document number disclose is not in the original query"),n=false,i.document_number={...i.document_number,disclose:{expected:"Not requested in original query",received:`${r.document_number.disclose.result}`,message:"Document number disclose is not in the original query"}});}if(r.gender){let c=s.gender,l=a.gender;r.gender.eq&&r.gender.eq.result&&r.gender.eq.expected!==c&&r.gender.eq.expected!==l&&(console.warn("Gender does not match the expected gender"),n=false,i.gender={...i.gender,eq:{expected:`${r.gender.eq.expected}`,received:`${c??l}`,message:"Gender does not match the expected gender"}}),r.gender.disclose&&r.gender.disclose.result!==c&&r.gender.disclose.result!==l&&(console.warn("Gender does not match the disclosed gender in query result"),n=false,i.gender={...i.gender,disclose:{expected:`${r.gender.disclose.result}`,received:`${c??l}`,message:"Gender does not match the disclosed gender in query result"}}),r.gender.eq&&(e.gender?.eq===void 0||r.gender.eq.expected!==e.gender.eq)&&(console.warn("Gender eq does not match the original query"),n=false,i.gender={...i.gender,eq:{expected:`${e.gender?.eq}`,received:`${r.gender.eq.expected}`,message:"Gender eq does not match the original query"}}),r.gender.disclose&&!e.gender?.disclose&&(console.warn("Gender disclose is not in the original query"),n=false,i.gender={...i.gender,disclose:{expected:"Not requested in original query",received:`${r.gender.disclose.result}`,message:"Gender disclose is not in the original query"}});}if(r.issuing_country){let c=s.issuingCountry,l=a.issuingCountry;r.issuing_country.eq&&r.issuing_country.eq.result&&r.issuing_country.eq.expected!==c&&r.issuing_country.eq.expected!==l&&(console.warn("Issuing country does not match the expected issuing country"),n=false,i.issuing_country={...i.issuing_country,eq:{expected:`${r.issuing_country.eq.expected}`,received:`${c??l}`,message:"Issuing country does not match the expected issuing country"}}),r.issuing_country.disclose&&r.issuing_country.disclose.result!==c&&r.issuing_country.disclose.result!==l&&(console.warn("Issuing country does not match the disclosed issuing country in query result"),n=false,i.issuing_country={...i.issuing_country,disclose:{expected:`${r.issuing_country.disclose.result}`,received:`${c??l}`,message:"Issuing country does not match the disclosed issuing country in query result"}}),r.issuing_country.eq&&(e.issuing_country?.eq===void 0||r.issuing_country.eq.expected!==e.issuing_country.eq)&&(console.warn("Issuing country eq does not match the original query"),n=false,i.issuing_country={...i.issuing_country,eq:{expected:`${e.issuing_country?.eq}`,received:`${r.issuing_country.eq.expected}`,message:"Issuing country eq does not match the original query"}}),r.issuing_country.disclose&&!e.issuing_country?.disclose&&(console.warn("Issuing country disclose is not in the original query"),n=false,i.issuing_country={...i.issuing_country,disclose:{expected:"Not requested in original query",received:`${r.issuing_country.disclose.result}`,message:"Issuing country disclose is not in the original query"}});}if(r.fullname){let c=s.name,l=a.name;r.fullname.eq&&r.fullname.eq.result&&ve(r.fullname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.fullname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Fullname does not match the expected fullname"),n=false,i.fullname={...i.fullname,eq:{expected:`${r.fullname.eq.expected}`,received:`${c??l}`,message:"Fullname does not match the expected fullname"}}),r.fullname.disclose&&ve(r.fullname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.fullname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Fullname does not match the disclosed fullname in query result"),n=false,i.fullname={...i.fullname,disclose:{expected:`${r.fullname.disclose.result}`,received:`${c??l}`,message:"Fullname does not match the disclosed fullname in query result"}}),r.fullname.eq&&(e.fullname?.eq===void 0||ve(r.fullname.eq.expected).toLowerCase()!==ve(e.fullname.eq).toLowerCase())&&(console.warn("Fullname eq does not match the original query"),n=false,i.fullname={...i.fullname,eq:{expected:`${e.fullname?.eq}`,received:`${r.fullname.eq.expected}`,message:"Fullname eq does not match the original query"}}),r.fullname.disclose&&!e.fullname?.disclose&&(console.warn("Fullname disclose is not in the original query"),n=false,i.fullname={...i.fullname,disclose:{expected:"Not requested in original query",received:`${r.fullname.disclose.result}`,message:"Fullname disclose is not in the original query"}});}if(r.firstname){let c=s.firstName&&s.firstName.length>0?s.firstName:s.name,l=a.firstName&&a.firstName.length>0?a.firstName:a.name;r.firstname.eq&&r.firstname.eq.result&&ve(r.firstname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.firstname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Firstname does not match the expected firstname"),n=false,i.firstname={...i.firstname,eq:{expected:`${r.firstname.eq.expected}`,received:`${c??l}`,message:"Firstname does not match the expected firstname"}}),r.firstname.disclose&&ve(r.firstname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.firstname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Firstname does not match the disclosed firstname in query result"),n=false,i.firstname={...i.firstname,disclose:{expected:`${r.firstname.disclose.result}`,received:`${c??l}`,message:"Firstname does not match the disclosed firstname in query result"}}),r.firstname.eq&&(e.firstname?.eq===void 0||ve(r.firstname.eq.expected).toLowerCase()!==ve(e.firstname.eq).toLowerCase())&&(console.warn("Firstname eq does not match the original query"),n=false,i.firstname={...i.firstname,eq:{expected:`${e.firstname?.eq}`,received:`${r.firstname.eq.expected}`,message:"Firstname eq does not match the original query"}}),r.firstname.disclose&&!e.firstname?.disclose&&(console.warn("Firstname disclose is not in the original query"),n=false,i.firstname={...i.firstname,disclose:{expected:"Not requested in original query",received:`${r.firstname.disclose.result}`,message:"Firstname disclose is not in the original query"}});}if(r.lastname){let c=s.lastName&&s.lastName.length>0?s.lastName:s.name,l=a.lastName&&a.lastName.length>0?a.lastName:a.name;r.lastname.eq&&r.lastname.eq.result&&ve(r.lastname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.lastname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Lastname does not match the expected lastname"),n=false,i.lastname={...i.lastname,eq:{expected:`${r.lastname.eq.expected}`,received:`${c??l}`,message:"Lastname does not match the expected lastname"}}),r.lastname.disclose&&ve(r.lastname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.lastname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Lastname does not match the disclosed lastname in query result"),n=false,i.lastname={...i.lastname,disclose:{expected:`${r.lastname.disclose.result}`,received:`${c??l}`,message:"Lastname does not match the disclosed lastname in query result"}}),r.lastname.eq&&(e.lastname?.eq===void 0||ve(r.lastname.eq.expected).toLowerCase()!==ve(e.lastname.eq).toLowerCase())&&(console.warn("Lastname eq does not match the original query"),n=false,i.lastname={...i.lastname,eq:{expected:`${e.lastname?.eq}`,received:`${r.lastname.eq.expected}`,message:"Lastname eq does not match the original query"}}),r.lastname.disclose&&!e.lastname?.disclose&&(console.warn("Lastname disclose is not in the original query"),n=false,i.lastname={...i.lastname,disclose:{expected:"Not requested in original query",received:`${r.lastname.disclose.result}`,message:"Lastname disclose is not in the original query"}});}return {isCorrect:n,queryResultErrors:i}}static checkAgePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0,0);let s=Pb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm),a=Nb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm);return r.age?(r.age.gte&&r.age.gte.result&&s!==r.age.gte.expected&&(console.warn("Age is not greater than or equal to the expected age"),n=false,i.age={...i.age,gte:{expected:r.age.gte.expected,received:s,message:"Age is not greater than or equal to the expected age"}}),r.age.gt&&r.age.gt.result&&s!==r.age.gt.expected+1&&(console.warn("Age is not greater than the expected age"),n=false,i.age={...i.age,gt:{expected:r.age.gt.expected,received:s,message:"Age is not greater than the expected age"}}),r.age.lt&&r.age.lt.result&&a!==r.age.lt.expected-1&&(console.warn("Age is not less than the expected age"),n=false,i.age={...i.age,lt:{expected:r.age.lt.expected,received:a,message:"Age is not less than the expected age"}}),r.age.lte&&r.age.lte.result&&a!==r.age.lte.expected&&(console.warn("Age is not less than or equal to the expected age"),n=false,i.age={...i.age,lte:{expected:r.age.lte.expected,received:a,message:"Age is not less than or equal to the expected age"}}),r.age.eq&&r.age.eq.result&&(s!==r.age.eq.expected||a!==r.age.eq.expected)&&(console.warn("Age does not match the expected age"),n=false,i.age={...i.age,eq:{expected:r.age.eq.expected,received:s!==r.age.eq.expected?s:a,message:"Age does not match the expected age"}}),r.age.range&&r.age.range.result&&(s!==r.age.range.expected[0]||a!==r.age.range.expected[1])&&(console.warn("Age is not in the expected range"),n=false,i.age={...i.age,range:{expected:r.age.range.expected,received:[s,a],message:"Age is not in the expected range"}}),!r.age.lt&&!r.age.lte&&!r.age.eq&&!r.age.range&&a!=0&&(console.warn("Maximum age should be equal to 0"),n=false,i.age={...i.age,disclose:{expected:0,received:a,message:"Maximum age should be equal to 0"}}),!r.age.gte&&!r.age.gt&&!r.age.eq&&!r.age.range&&s!=0&&(console.warn("Minimum age should be equal to 0"),n=false,i.age={...i.age,disclose:{expected:0,received:s,message:"Minimum age should be equal to 0"}}),r.age.disclose&&(r.age.disclose.result!==s||r.age.disclose.result!==a)&&(console.warn("Age does not match the disclosed age in query result"),n=false,i.age={...i.age,disclose:{expected:`${s}`,received:`${r.age.disclose.result}`,message:"Age does not match the disclosed age in query result"}})):(console.warn("Age is not set in the query result"),n=false,i.age={...i.age,disclose:{message:"Age is not set in the query result"}}),r.age?.gte&&(e.age?.gte===void 0||r.age.gte.expected!==e.age.gte)&&(console.warn("Age gte does not match the original query"),n=false,i.age={...i.age,gte:{expected:e.age?.gte,received:r.age.gte.expected,message:"Age gte does not match the original query"}}),r.age?.gt&&(e.age?.gt===void 0||r.age.gt.expected!==e.age.gt)&&(console.warn("Age gt does not match the original query"),n=false,i.age={...i.age,gt:{expected:e.age?.gt,received:r.age.gt.expected,message:"Age gt does not match the original query"}}),r.age?.lt&&(e.age?.lt===void 0||r.age.lt.expected!==e.age.lt)&&(console.warn("Age lt does not match the original query"),n=false,i.age={...i.age,lt:{expected:e.age?.lt,received:r.age.lt.expected,message:"Age lt does not match the original query"}}),r.age?.lte&&(e.age?.lte===void 0||r.age.lte.expected!==e.age.lte)&&(console.warn("Age lte does not match the original query"),n=false,i.age={...i.age,lte:{expected:e.age?.lte,received:r.age.lte.expected,message:"Age lte does not match the original query"}}),r.age?.eq&&(e.age?.eq===void 0||r.age.eq.expected!==e.age.eq)&&(console.warn("Age eq does not match the original query"),n=false,i.age={...i.age,eq:{expected:e.age?.eq,received:r.age.eq.expected,message:"Age eq does not match the original query"}}),r.age?.range&&(e.age?.range===void 0||r.age.range.expected[0]!==e.age.range[0]||r.age.range.expected[1]!==e.age.range[1])&&(console.warn("Age range does not match the original query"),n=false,i.age={...i.age,range:{expected:e.age?.range,received:r.age.range.expected,message:"Age range does not match the original query"}}),r.age?.disclose&&!e.age?.disclose&&(console.warn("Age disclose is not in the original query"),n=false,i.age={...i.age,disclose:{expected:"Not requested in original query",received:`${r.age.disclose.result}`,message:"Age disclose is not in the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkBirthdatePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0);let s=Db(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Fo),a=Ob(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Fo);if(r.birthdate){if(r.birthdate.gte&&r.birthdate.gte.result&&!me(s,r.birthdate.gte.expected)&&(console.warn("Birthdate is not greater than or equal to the expected birthdate"),n=false,i.birthdate={...i.birthdate,gte:{expected:r.birthdate.gte.expected,received:s,message:"Birthdate is not greater than or equal to the expected birthdate"}}),r.birthdate.gt&&r.birthdate.gt.result){let c=new Date(r.birthdate.gt.expected);c.setDate(c.getDate()+1),me(s,c)||(console.warn("Birthdate is not greater than the expected birthdate"),n=false,i.birthdate={...i.birthdate,gt:{expected:r.birthdate.gt.expected,received:s,message:"Birthdate is not greater than the expected birthdate"}});}if(r.birthdate.lte&&r.birthdate.lte.result&&!me(a,r.birthdate.lte.expected)&&(console.warn("Birthdate is not less than the expected birthdate"),n=false,i.birthdate={...i.birthdate,lte:{expected:r.birthdate.lte.expected,received:a,message:"Birthdate is not less than the expected birthdate"}}),r.birthdate.lt&&r.birthdate.lt.result){let c=new Date(r.birthdate.lt.expected);c.setDate(c.getDate()-1),me(a,c)||(console.warn("Birthdate is not less than the expected birthdate"),n=false,i.birthdate={...i.birthdate,lt:{expected:r.birthdate.lt.expected,received:a,message:"Birthdate is not less than the expected birthdate"}});}r.birthdate.range&&r.birthdate.range.result&&(!me(s,r.birthdate.range.expected[0])||!me(a,r.birthdate.range.expected[1]))&&(console.warn("Birthdate is not in the expected range"),n=false,i.birthdate={...i.birthdate,range:{expected:r.birthdate.range.expected,received:[s,a],message:"Birthdate is not in the expected range"}}),!r.birthdate.lte&&!r.birthdate.lt&&!r.birthdate.eq&&!r.birthdate.range&&!me(a,Fn)&&(console.warn("Maximum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Fn.toISOString()}`,received:`${a.toISOString()}`,message:"Maximum birthdate should be equal to default date value"}}),!r.birthdate.gte&&!r.birthdate.gt&&!r.birthdate.eq&&!r.birthdate.range&&!me(s,Fn)&&(console.warn("Minimum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Fn.toISOString()}`,received:`${s.toISOString()}`,message:"Minimum birthdate should be equal to default date value"}});}else console.warn("Birthdate is not set in the query result"),n=false,i.birthdate={...i.birthdate,disclose:{message:"Birthdate is not set in the query result"}};return r.birthdate?.gte&&(e.birthdate?.gte===void 0||!me(r.birthdate.gte.expected,e.birthdate.gte))&&(console.warn("Birthdate gte does not match the original query"),n=false,i.birthdate={...i.birthdate,gte:{expected:e.birthdate?.gte,received:r.birthdate.gte.expected,message:"Birthdate gte does not match the original query"}}),r.birthdate?.gt&&(e.birthdate?.gt===void 0||!me(r.birthdate.gt.expected,e.birthdate.gt))&&(console.warn("Birthdate gt does not match the original query"),n=false,i.birthdate={...i.birthdate,gt:{expected:e.birthdate?.gt,received:r.birthdate.gt.expected,message:"Birthdate gt does not match the original query"}}),r.birthdate?.lte&&(e.birthdate?.lte===void 0||!me(r.birthdate.lte.expected,e.birthdate.lte))&&(console.warn("Birthdate lte does not match the original query"),n=false,i.birthdate={...i.birthdate,lte:{expected:e.birthdate?.lte,received:r.birthdate.lte.expected,message:"Birthdate lte does not match the original query"}}),r.birthdate?.lt&&(e.birthdate?.lt===void 0||!me(r.birthdate.lt.expected,e.birthdate.lt))&&(console.warn("Birthdate lt does not match the original query"),n=false,i.birthdate={...i.birthdate,lt:{expected:e.birthdate?.lt,received:r.birthdate.lt.expected,message:"Birthdate lt does not match the original query"}}),r.birthdate?.range&&(e.birthdate?.range===void 0||!me(r.birthdate.range.expected[0],e.birthdate.range[0])||!me(r.birthdate.range.expected[1],e.birthdate.range[1]))&&(console.warn("Birthdate range does not match the original query"),n=false,i.birthdate={...i.birthdate,range:{expected:e.birthdate?.range,received:r.birthdate.range.expected,message:"Birthdate range does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkExpiryDatePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0);let s=zl(t.committedInputs?.compare_expiry??t.committedInputs?.compare_expiry_evm),a=ql(t.committedInputs?.compare_expiry??t.committedInputs?.compare_expiry_evm);return r.expiry_date?(r.expiry_date.gte&&r.expiry_date.gte.result&&!me(s,r.expiry_date.gte.expected)&&(console.warn("Expiry date is not greater than or equal to the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,gte:{expected:r.expiry_date.gte.expected,received:s,message:"Expiry date is not greater than or equal to the expected expiry date"}}),r.expiry_date.lte&&r.expiry_date.lte.result&&!me(a,r.expiry_date.lte.expected)&&(console.warn("Expiry date is not less than the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,lte:{expected:r.expiry_date.lte.expected,received:a,message:"Expiry date is not less than the expected expiry date"}}),r.expiry_date.range&&r.expiry_date.range.result&&(!me(s,r.expiry_date.range.expected[0])||!me(a,r.expiry_date.range.expected[1]))&&(console.warn("Expiry date is not in the expected range"),n=false,i.expiry_date={...i.expiry_date,range:{expected:r.expiry_date.range.expected,received:[s,a],message:"Expiry date is not in the expected range"}}),!r.expiry_date.lte&&!r.expiry_date.lt&&!r.expiry_date.eq&&!r.expiry_date.range&&!me(a,Fn)&&(console.warn("Maximum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Fn.toISOString()}`,received:`${a.toISOString()}`,message:"Maximum expiry date should be equal to default date value"}}),!r.expiry_date.gte&&!r.expiry_date.gt&&!r.expiry_date.eq&&!r.expiry_date.range&&!me(s,Fn)&&(console.warn("Minimum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Fn.toISOString()}`,received:`${s.toISOString()}`,message:"Minimum expiry date should be equal to default date value"}})):(console.warn("Expiry date is not set in the query result"),n=false,i.expiry_date={...i.expiry_date,disclose:{message:"Expiry date is not set in the query result"}}),r.expiry_date?.gte&&(e.expiry_date?.gte===void 0||!me(r.expiry_date.gte.expected,e.expiry_date.gte))&&(console.warn("Expiry date gte does not match the original query"),n=false,i.expiry_date={...i.expiry_date,gte:{expected:e.expiry_date?.gte,received:r.expiry_date.gte.expected,message:"Expiry date gte does not match the original query"}}),r.expiry_date?.gt&&(e.expiry_date?.gt===void 0||!me(r.expiry_date.gt.expected,e.expiry_date.gt))&&(console.warn("Expiry date gt does not match the original query"),n=false,i.expiry_date={...i.expiry_date,gt:{expected:e.expiry_date?.gt,received:r.expiry_date.gt.expected,message:"Expiry date gt does not match the original query"}}),r.expiry_date?.lte&&(e.expiry_date?.lte===void 0||!me(r.expiry_date.lte.expected,e.expiry_date.lte))&&(console.warn("Expiry date lte does not match the original query"),n=false,i.expiry_date={...i.expiry_date,lte:{expected:e.expiry_date?.lte,received:r.expiry_date.lte.expected,message:"Expiry date lte does not match the original query"}}),r.expiry_date?.lt&&(e.expiry_date?.lt===void 0||!me(r.expiry_date.lt.expected,e.expiry_date.lt))&&(console.warn("Expiry date lt does not match the original query"),n=false,i.expiry_date={...i.expiry_date,lt:{expected:e.expiry_date?.lt,received:r.expiry_date.lt.expected,message:"Expiry date lt does not match the original query"}}),r.expiry_date?.range&&(e.expiry_date?.range===void 0||!me(r.expiry_date.range.expected[0],e.expiry_date.range[0])||!me(r.expiry_date.range.expected[1],e.expiry_date.range[1]))&&(console.warn("Expiry date range does not match the original query"),n=false,i.expiry_date={...i.expiry_date,range:{expected:e.expiry_date?.range,received:r.expiry_date.range.expected,message:"Expiry date range does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkNationalityExclusionPublicInputs(t,e,r){let i={},n=true;e.nationality&&e.nationality.out&&e.nationality.out.result?e.nationality.out.expected?.every(o=>r.includes(o))||(console.warn("Nationality exclusion list does not match the one from the query results"),n=false,i.nationality={...i.nationality,out:{expected:e.nationality.out.expected,received:r,message:"Nationality exclusion list does not match the one from the query results"}}):(!e.nationality||!e.nationality.out)&&(console.warn("Nationality exclusion is not set in the query result"),n=false,i.nationality={...i.nationality,out:{message:"Nationality exclusion is not set in the query result"}});for(let o=1;o<r.length;o++)r[o]<r[o-1]&&(console.warn("The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"),n=false,i.nationality={...i.nationality,out:{message:"The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"}});return e.nationality?.out&&(t.nationality?.out===void 0||e.nationality.out.expected?.length!==t.nationality.out.length||!e.nationality.out.expected?.every(o=>t.nationality.out.includes(o)))&&(console.warn("Nationality exclusion list does not match the original query"),n=false,i.nationality={...i.nationality,out:{expected:t.nationality?.out,received:e.nationality.out.expected,message:"Nationality exclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkIssuingCountryExclusionPublicInputs(t,e,r){let i={},n=true;e.issuing_country&&e.issuing_country.out&&e.issuing_country.out.result?e.issuing_country.out.expected?.every(o=>r.includes(o))||(console.warn("Issuing country exclusion list does not match the one from the query results"),n=false,i.issuing_country={...i.issuing_country,out:{expected:e.issuing_country.out.expected,received:r,message:"Issuing country exclusion list does not match the one from the query results"}}):(!e.issuing_country||!e.issuing_country.out)&&(console.warn("Issuing country exclusion is not set in the query result"),n=false,i.issuing_country={...i.issuing_country,out:{message:"Issuing country exclusion is not set in the query result"}});for(let o=1;o<r.length;o++)r[o]<r[o-1]&&(console.warn("The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"),n=false,i.issuing_country={...i.issuing_country,out:{message:"The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"}});return e.issuing_country?.out&&(t.issuing_country?.out===void 0||e.issuing_country.out.expected?.length!==t.issuing_country.out.length||!e.issuing_country.out.expected?.every(o=>t.issuing_country.out.includes(o)))&&(console.warn("Issuing country exclusion list does not match the original query"),n=false,i.issuing_country={...i.issuing_country,out:{expected:t.issuing_country?.out,received:e.issuing_country.out.expected,message:"Issuing country exclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkNationalityInclusionPublicInputs(t,e,r){let i={},n=true;return e.nationality&&e.nationality.in&&e.nationality.in.result?e.nationality.in.expected?.every(o=>r.includes(o))||(console.warn("Nationality inclusion list does not match the one from the query results"),n=false,i.nationality={...i.nationality,in:{expected:e.nationality.in.expected,received:r,message:"Nationality inclusion list does not match the one from the query results"}}):(!e.nationality||!e.nationality.in)&&(console.warn("Nationality inclusion is not set in the query result"),n=false,i.nationality={...i.nationality,in:{message:"Nationality inclusion is not set in the query result"}}),e.nationality?.in&&(t.nationality?.in===void 0||e.nationality.in.expected?.length!==t.nationality.in.length||!e.nationality.in.expected?.every(o=>t.nationality.in.includes(o)))&&(console.warn("Nationality inclusion list does not match the original query"),n=false,i.nationality={...i.nationality,in:{expected:t.nationality?.in,received:e.nationality.in.expected,message:"Nationality inclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkIssuingCountryInclusionPublicInputs(t,e,r){let i={},n=true;return e.issuing_country&&e.issuing_country.in&&e.issuing_country.in.result?e.issuing_country.in.expected?.every(o=>r.includes(o))||(console.warn("Issuing country inclusion list does not match the one from the query results"),n=false,i.issuing_country={...i.issuing_country,in:{expected:e.issuing_country.in.expected,received:r,message:"Issuing country inclusion list does not match the one from the query results"}}):(!e.issuing_country||!e.issuing_country.in)&&(console.warn("Issuing country inclusion is not set in the query result"),n=false,i.issuing_country={...i.issuing_country,in:{message:"Issuing country inclusion is not set in the query result"}}),e.issuing_country?.in&&(t.issuing_country?.in===void 0||e.issuing_country.in.expected?.length!==t.issuing_country.in.length||!e.issuing_country.in.expected?.every(o=>t.issuing_country.in.includes(o)))&&(console.warn("Issuing country inclusion list does not match the original query"),n=false,i.issuing_country={...i.issuing_country,in:{expected:t.issuing_country?.in,received:e.issuing_country.in.expected,message:"Issuing country inclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkScopeFromDisclosureProof(t,e,r,i,n){if(t==="*")return {isCorrect:true,queryResultErrors:r};let o=true;if(cc(t)!==eh(e)&&(console.warn("The proof comes from a different domain than the one expected"),o=false,r[i]||(r[i]={}),r[i].scope={expected:`Scope: ${cc(t).toString()}`,received:`Scope: ${eh(e).toString()}`,message:"The proof comes from a different domain than the one expected"}),na(n)!==Jp(e)){let s=n?"The proof uses a different scope than the one expected":"The proof uses a scope but none was passed to verify()";console.warn(s),o=false,r[i]||(r[i]={}),r[i].scope={expected:`Scope: ${na(n).toString()}`,received:`Scope: ${Jp(e).toString()}`,message:s};}return {isCorrect:o,queryResultErrors:r}}static async checkRegistryRoot(t,e,r,i,n,o){let s;try{s=await t(o??xh(Gp(r,!!e)));}catch(a){console.warn(a),s=false;}if(!s){console.warn(n.message);let{section:a,field:c,...l}=n;i[a]={...i[a],[c]:l};}return {isCorrect:s,queryResultErrors:i}}static async checkCertificateRegistryRoot(t,e,r,i,n,o={},s){return this.checkRegistryRoot(a=>a.isCertificateRootValid(t,n),i,o,e,{section:r?"outer":"sig_check_dsc",field:"certificate",expected:"A valid root from ZKPassport Registry",received:`Got invalid certificate registry root: ${t}`,message:"The ID was signed by an unrecognized root certificate"},s)}static async checkCircuitRegistryRoot(t,e,r,i,n={},o){return this.checkRegistryRoot(s=>s.isCircuitRootValid(t,i),r,n,e,{section:"outer",field:"circuit",expected:"A valid circuit from ZKPassport Registry",received:`Got invalid circuit registry root: ${t}`,message:"The proof uses an unrecognized circuit"},o)}static async checkSanctionsRegistryRoot(t,e,r,i,n={},o){return this.checkRegistryRoot(s=>s.isSanctionsRootValid(t,i),r,n,e,{section:"sanctions",field:"eq",expected:"A valid root from ZKPassport Registry",received:`Got invalid sanctions registry root: ${t}`,message:"Invalid sanctions registry root"},o)}static checkBindPublicInputs(t,e,r){let i={},n=true;if(e.bind){let o=[];e.bind.user_address?.toLowerCase().replace("0x","")!==r.user_address?.toLowerCase().replace("0x","")&&(console.warn("Bound user address does not match the one from the query results"),n=false,o.push(`user_address: expected ${e.bind.user_address}, received ${r.user_address}`)),e.bind.chain!==r.chain&&(console.warn("Bound chain id does not match the one from the query results"),n=false,o.push(`chain: expected ${e.bind.chain}, received ${r.chain}`)),e.bind.custom_data?.trim().toLowerCase()!==r.custom_data?.trim().toLowerCase()&&(console.warn("Bound custom data does not match the one from the query results"),n=false,o.push(`custom_data: expected ${e.bind.custom_data}, received ${r.custom_data}`)),o.length>0&&(i.bind={...i.bind,eq:{expected:`${e.bind.user_address}, ${e.bind.chain}, ${e.bind.custom_data}`,received:`${r.user_address}, ${r.chain}, ${r.custom_data}`,message:`Bound data does not match: ${o.join("; ")}`}});}return (t.bind===void 0||r.user_address?.toLowerCase().replace("0x","")!==t.bind.user_address?.toLowerCase().replace("0x","")||r.chain!==t.bind.chain||r.custom_data?.trim().toLowerCase()!==t.bind.custom_data?.trim().toLowerCase())&&(console.warn("Bound data does not match the original query"),n=false,i.bind={...i.bind,eq:{expected:`${t.bind?.user_address}, ${t.bind?.chain}, ${t.bind?.custom_data}`,received:`${r.user_address}, ${r.chain}, ${r.custom_data}`,message:"Bound data does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static async checkSanctionsExclusionPublicInputs(t,e,r,i,n,o){let s={},a=true;if(r.isStrict!==(t.sanctions?.strict??false)&&(console.warn("Sanctions strict mode does not match the original query"),a=false,s.sanctions={...s.sanctions,eq:{expected:`strict: ${t.sanctions?.strict??false}`,received:`strict: ${r.isStrict}`,message:"Sanctions strict mode does not match the original query"}}),e.sanctions&&e.sanctions.passed){let{isCorrect:c}=await this.checkSanctionsRegistryRoot(r.rootHash,s,i,n,t,o);a=a&&c,e.sanctions.isStrict!==r.isStrict&&(console.warn("Invalid sanctions strict mode"),a=false,s.sanctions={...s.sanctions,eq:{expected:e.sanctions.isStrict.toString(),received:r.isStrict.toString(),message:"Invalid sanctions strict mode"}});}return e.sanctions&&(t.sanctions===void 0||e.sanctions.isStrict!==(t.sanctions.strict??false))&&(console.warn("Sanctions config does not match the original query"),a=false,s.sanctions={...s.sanctions,eq:{expected:`strict: ${t.sanctions?.strict??false}`,received:`strict: ${e.sanctions.isStrict}`,message:"Sanctions config does not match the original query"}}),{isCorrect:a,queryResultErrors:s}}static async checkFacematchPublicInputs(t,e,r){let i=true,n={};r.rootKeyLeaf!==iS&&r.rootKeyLeaf!==nS&&r.rootKeyLeaf!==oS&&(console.warn("Invalid facematch root key hash"),i=false,n.facematch={...n.facematch,eq:{expected:`${iS} (iOS) or ${nS} (Android) or ${oS} (Android)`,received:r.rootKeyLeaf,message:"Invalid facematch root key hash"}});let o="production";return r.environment!==o&&(console.warn("Invalid facematch environment, it should be production"),i=false,n.facematch={...n.facematch,eq:{expected:o,received:r.environment,message:"Invalid facematch environment, it should be production"}}),r.appIdHash!==tS&&r.appIdHash!==rS&&(console.warn("Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"),i=false,n.facematch={...n.facematch,eq:{expected:`${tS} (iOS) or ${rS} (Android)`,received:r.appIdHash,message:"Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"}}),(e.facematch&&r.mode!==e.facematch.mode||r.mode!==t.facematch?.mode)&&(console.warn("Invalid facematch mode"),i=false,n.facematch={...n.facematch,eq:{expected:t.facematch?.mode,received:r.mode,message:"Invalid facematch mode"}}),{isCorrect:i,queryResultErrors:n}}static async checkCurrentDate(t,e,r,i){let n=new Date,o=new Date(n.getFullYear(),n.getMonth(),n.getDate(),0,0,0,0),s=th(e),a=o.getTime()-s.getTime(),c=r?r*1e3:gt*1e3,l=true;return a>=c&&(console.warn("The date used to check the validity of the ID falls out of the validity period"),l=false,i[t]||(i[t]={}),i[t].date={expected:`Difference: ${r} seconds`,received:`Difference: ${Math.round(a/1e3)} seconds`,message:"The date used to check the validity of the ID falls out of the validity period"}),s.getTime()-o.getTime()>sS&&(console.warn("The date used to check the validity of the ID is in the future"),l=false,i[t]||(i[t]={}),i[t].date={expected:`Difference: ${r} seconds`,received:`Difference: ${Math.round(a/1e3)} seconds`,message:"The date used to check the validity of the ID is in the future"}),{isCorrect:l,queryResultErrors:i}}static checkQueryCompleteness(t,e){let r=true,i={},n=(...m)=>m.some(b=>e.has(b)),o=(m,b)=>{r=false,i[m]={...i[m],commitment:{expected:"A proof covering the requested condition",received:"No matching proof was provided",message:b}};},s=n("disclose_bytes","disclose_bytes_evm"),a=m=>!!m&&(m.gte!==void 0||m.gt!==void 0||m.lte!==void 0||m.lt!==void 0||m.range!==void 0),c=m=>!!m&&(m.eq!==void 0||m.disclose===true),l=t.age;(a(l)||l?.eq!==void 0)&&!n("compare_age","compare_age_evm")&&o("age","The proof does not verify the requested age condition"),a(t.birthdate)&&!n("compare_birthdate","compare_birthdate_evm")&&o("birthdate","The proof does not verify the requested birthdate condition"),c(t.birthdate)&&!s&&o("birthdate","The proof does not disclose the requested birthdate"),a(t.expiry_date)&&!n("compare_expiry","compare_expiry_evm")&&o("expiry_date","The proof does not verify the requested expiry date condition"),c(t.expiry_date)&&!s&&o("expiry_date","The proof does not disclose the requested expiry date");let d=t.nationality;d?.in!==void 0&&!n("inclusion_check_nationality","inclusion_check_nationality_evm")&&o("nationality","The proof does not verify the requested nationality inclusion"),d?.out!==void 0&&!n("exclusion_check_nationality","exclusion_check_nationality_evm")&&o("nationality","The proof does not verify the requested nationality exclusion"),c(d)&&!s&&o("nationality","The proof does not disclose the requested nationality");let u=t.issuing_country;u?.in!==void 0&&!n("inclusion_check_issuing_country","inclusion_check_issuing_country_evm")&&o("issuing_country","The proof does not verify the requested issuing country inclusion"),u?.out!==void 0&&!n("exclusion_check_issuing_country","exclusion_check_issuing_country_evm")&&o("issuing_country","The proof does not verify the requested issuing country exclusion"),c(u)&&!s&&o("issuing_country","The proof does not disclose the requested issuing country");let h=["firstname","lastname","fullname","document_number","document_type","gender"];for(let m of h)c(t[m])&&!s&&o(m,`The proof does not disclose the requested ${m}`);return t.bind&&!n("bind","bind_evm")&&o("bind","The proof does not verify the requested bound data"),t.sanctions&&!n("exclusion_check_sanctions","exclusion_check_sanctions_evm")&&o("sanctions","The proof does not verify the requested sanctions exclusion"),t.facematch&&!n("facematch","facematch_evm")&&o("facematch","The proof does not verify the requested FaceMatch"),r||console.warn("The proof does not verify all the requested conditions and information"),{isCorrect:r,queryResultErrors:i}}static async checkPublicInputs(t,e,r,i,n,o,s,a,c){let l,d,u=true,h,m,b,A=new Date,x=new Date(A.getFullYear(),A.getMonth(),A.getDate(),0,0,0,0),y={},w=["sig_check_dsc","sig_check_id_data","data_check_integrity","disclose_bytes","compare_age","compare_birthdate","compare_expiry","exclusion_check_nationality","inclusion_check_nationality","exclusion_check_issuing_country","inclusion_check_issuing_country","bind","exclusion_check_sanctions","facematch"],I=e.sort((k,E)=>{let q=O=>{let z=O.name||"";return w.findIndex(W=>z.startsWith(W))};return q(k)-q(E)}),_=w.slice(3),C=I.find(k=>_.some(E=>k.name?.startsWith(E))),v=C?th(oa(C.proof,ia(C.name))):void 0,T=v?Math.floor(v.getTime()/1e3):void 0;for(let k of I){let E=oa(k.proof,ia(k.name));if(k.name?.startsWith("outer")){let q=k.name?.startsWith("outer_evm"),O=t6(E),z=Math.floor(O.getTime()/1e3),W=Jb(E),{isCorrect:Y,queryResultErrors:oe}=await this.checkCertificateRegistryRoot(W.toString(16),y,true,a,z,r,c);u=u&&Y,y={...y,...oe};let te=e6(E),{isCorrect:$,queryResultErrors:R}=await this.checkCircuitRegistryRoot(te.toString(16),y,a,z,r,c);u=u&&$,y={...y,...R};let M=x.getTime()-O.getTime(),V=n?n*1e3:gt*1e3;M>=V&&(console.warn("The date used to check the validity of the ID is older than the validity period"),u=false,y.outer={...y.outer,date:{expected:`Difference: ${n} seconds`,received:`Difference: ${Math.round(M/1e3)} seconds`,message:"The date used to check the validity of the ID is older than the validity period"}}),O.getTime()-x.getTime()>sS&&(console.warn("The date used to check the validity of the ID is in the future"),u=false,y.outer={...y.outer,date:{expected:`Difference: ${n} seconds`,received:`Difference: ${Math.round(M/1e3)} seconds`,message:"The date used to check the validity of the ID is in the future"}});let K=oh(E),L=k.committedInputs,re=Object.keys(L||{});if(re.length!==K.length&&(console.warn("The proof does not verify all the requested conditions and information"),u=false,y.outer={...y.outer,commitment:{expected:`Number of parameter commitments: ${K.length}`,received:`Number of disclosure proofs provided: ${re.length}`,message:"The proof does not verify all the requested conditions and information"}}),cc(t)!==ih(E)&&(console.warn("The proof comes from a different domain than the one expected"),u=false,y.outer={...y.outer,scope:{expected:`Scope: ${cc(t).toString()}`,received:`Scope: ${ih(E).toString()}`,message:"The proof comes from a different domain than the one expected"}}),na(o)!==nh(E)){let D=o?"The proof uses a different scope than the one expected":"The proof uses a scope but none was passed to verify()";console.warn(D),u=false,y.outer={...y.outer,scope:{expected:`Scope: ${na(o).toString()}`,received:`Scope: ${nh(E).toString()}`,message:D}};}if(L?.compare_age||L?.compare_age_evm){let D=L?.compare_age??L?.compare_age_evm,X=q?await Rb(D.minAge,D.maxAge):await Wp(D.minAge,D.maxAge);K.includes(X)||(console.warn("This proof does not verify the age"),u=false,y.age={...y.age,commitment:{expected:`Age parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the age"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkAgePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.compare_birthdate||L?.compare_birthdate_evm){let D=L?.compare_birthdate??L?.compare_birthdate_evm,X=q?await Zp(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0):await sc(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0);K.includes(X)||(console.warn("This proof does not verify the birthdate"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Birthdate parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the birthdate"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkBirthdatePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.compare_expiry||L?.compare_expiry_evm){let D=L?.compare_expiry??L?.compare_expiry_evm,X=q?await Zp(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp):await sc(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp);K.includes(X)||(console.warn("This proof does not verify the expiry date"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Expiry date parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the expiry date"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.disclose_bytes||L?.disclose_bytes_evm){let D=L?.disclose_bytes??L?.disclose_bytes_evm,X=q?await kb(D.discloseMask,D.disclosedBytes):await Xp(D.discloseMask,D.disclosedBytes);K.includes(X)||(console.warn("This proof does not verify any of the data disclosed"),u=false,y.disclose={...y.disclose,commitment:{expected:`Disclosure parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify any of the data disclosed"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.inclusion_check_nationality||L?.inclusion_check_nationality_evm){let D=L?.inclusion_check_nationality??L?.inclusion_check_nationality_evm,X=q?await oc(fe.NATIONALITY_INCLUSION,D.countries):await Mi(fe.NATIONALITY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the nationality"),u=false,y.nationality={...y.nationality,commitment:{expected:`Nationality parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the inclusion of the nationality"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkNationalityInclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.inclusion_check_issuing_country||L?.inclusion_check_issuing_country_evm){let D=L?.inclusion_check_issuing_country??L?.inclusion_check_issuing_country_evm,X=q?await oc(fe.ISSUING_COUNTRY_INCLUSION,D.countries):await Mi(fe.ISSUING_COUNTRY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the issuing country"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Issuing country parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the inclusion of the issuing country"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkIssuingCountryInclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.exclusion_check_nationality||L?.exclusion_check_nationality_evm){let D=L?.exclusion_check_nationality??L?.exclusion_check_nationality_evm,X=q?await oc(fe.NATIONALITY_EXCLUSION,D.countries):await Mi(fe.NATIONALITY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the nationality"),u=false,y.nationality={...y.nationality,commitment:{expected:`Nationality parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion of the nationality"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkNationalityExclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.exclusion_check_issuing_country||L?.exclusion_check_issuing_country_evm){let D=L?.exclusion_check_issuing_country??L?.exclusion_check_issuing_country_evm,X=q?await oc(fe.ISSUING_COUNTRY_EXCLUSION,D.countries):await Mi(fe.ISSUING_COUNTRY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the issuing country"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Issuing country parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion of the issuing country"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkIssuingCountryExclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.bind||L?.bind_evm){let D=L?.bind??L?.bind_evm,X=q?await Fb(ac(D.data)):await Yp(ac(D.data));K.includes(X)||(console.warn("This proof does not verify the bound data"),u=false,y.bind={...y.bind,commitment:{expected:`Bind parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the bound data"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkBindPublicInputs(r,i,D.data);u=u&&Q,y={...y,...ne};}if(L?.exclusion_check_sanctions||L?.exclusion_check_sanctions_evm){let D=L?.exclusion_check_sanctions??L?.exclusion_check_sanctions_evm,X=q?await Qb(D.rootHash,D.isStrict):await rh(D.rootHash,D.isStrict);K.includes(X)||(console.warn("This proof does not verify the exclusion from the sanction lists"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Sanctions parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion from the sanction lists"}});let{isCorrect:Q,queryResultErrors:ne}=await this.checkSanctionsExclusionPublicInputs(r,i,D,a,z,c);u=u&&Q,y={...y,...ne};}if(L?.facematch||L?.facematch_evm){let D=L?.facematch??L?.facematch_evm,X=q?await Kb(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n):await Qp(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n);K.includes(X)||(console.warn("This proof does not verify FaceMatch"),u=false,y.facematch={...y.facematch,commitment:{expected:`Facematch parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify FaceMatch"}});let{isCorrect:Q,queryResultErrors:ne}=await this.checkFacematchPublicInputs(r,i,D);u=u&&Q,y={...y,...ne};}h=i6(E).toString(10),m=r6(E),b=n6(E);}else if(k.name?.startsWith("sig_check_dsc")){d=Eb(E);let q=vb(E),{isCorrect:O,queryResultErrors:z}=await this.checkCertificateRegistryRoot(q.toString(16),y,false,a,T,r,c);u=u&&O,y={...y,...z};}else if(k.name?.startsWith("sig_check_id_data"))l=Mb(E),l!==d&&(console.warn("Failed to check the link between the certificate signature and ID signature"),u=false,y.sig_check_id_data={...y.sig_check_id_data,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the certificate signature and ID signature"}}),d=Ub(E);else if(k.name?.startsWith("data_check_integrity"))l=Bb(E),l!==d&&(console.warn("Failed to check the link between the ID signature and the data signed"),u=false,y.data_check_integrity={...y.data_check_integrity,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the ID signature and the data signed"}}),d=Tb(E);else if(k.name==="disclose_bytes"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the data to disclose"),u=false,y.disclose={...y.disclose,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the validity of the ID and the data to disclose"}});let q=pr(E),O=await Xp((k.committedInputs?.disclose_bytes).discloseMask,(k.committedInputs?.disclose_bytes).disclosedBytes);q!==O&&(console.warn("The disclosed data does not match the data committed by the proof"),u=false,y.disclose={...y.disclose,commitment:{expected:`Commitment: ${O}`,received:`Commitment: ${q}`,message:"The disclosed data does not match the data committed by the proof"}});let{isCorrect:z,queryResultErrors:W}=this.checkScopeFromDisclosureProof(t,E,y,"disclose",o);u=u&&z,y={...y,...W};let{isCorrect:Y,queryResultErrors:oe}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Y&&z,y={...y,...oe,...W};let{isCorrect:te,queryResultErrors:$}=await this.checkCurrentDate("disclose",E,n??gt,y);u=u&&te,y={...y,...$},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_age"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the age derived from it"),u=false,y.age={...y.age,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the age derived from it"}});let q=pr(E),O=k.committedInputs?.compare_age,z=await Wp(O.minAge,O.maxAge);q!==z&&(console.warn("The conditions for the age check do not match the conditions checked by the proof"),u=false,y.age={...y.age,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the age check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"age",o),{isCorrect:oe,queryResultErrors:te}=this.checkAgePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("age",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_birthdate"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the birthdate derived from it"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the birthdate derived from it"}});let q=pr(E),O=k.committedInputs?.compare_birthdate,z=await sc(fe.BIRTHDATE,O.minDateTimestamp,O.maxDateTimestamp,0);q!==z&&(console.warn("The conditions for the birthdate check do not match the conditions checked by the proof"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the birthdate check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"birthdate",o),{isCorrect:oe,queryResultErrors:te}=this.checkBirthdatePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("birthdate",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_expiry"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and its expiry date"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and its expiry date"}});let q=pr(E),O=k.committedInputs?.compare_expiry,z=await sc(fe.EXPIRY_DATE,O.minDateTimestamp,O.maxDateTimestamp);q!==z&&(console.warn("The conditions for the expiry date check do not match the conditions checked by the proof"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the expiry date check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"expiry_date",o),{isCorrect:oe,queryResultErrors:te}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("expiry_date",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_nationality"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the nationality exclusion check"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the nationality exclusion check"}});let q=(k.committedInputs?.exclusion_check_nationality).countries,O=pr(E),z=await Mi(fe.NATIONALITY_EXCLUSION,q,true);O!==z&&(console.warn("The committed country list for the exclusion check does not match the one from the proof"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the exclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityExclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_issuing_country"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the issuing country exclusion check"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the issuing country exclusion check"}});let q=(k.committedInputs?.exclusion_check_issuing_country).countries,O=pr(E),z=await Mi(fe.ISSUING_COUNTRY_EXCLUSION,q,true);O!==z&&(console.warn("The committed country list for the issuing country exclusion check does not match the one from the proof"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the issuing country exclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryExclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="inclusion_check_nationality"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the nationality inclusion check"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the nationality inclusion check"}});let q=(k.committedInputs?.inclusion_check_nationality).countries,O=pr(E),z=await Mi(fe.NATIONALITY_INCLUSION,q,false);O!==z&&(console.warn("The committed country list for the nationality inclusion check does not match the one from the proof"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the nationality inclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityInclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="inclusion_check_issuing_country"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the issuing country inclusion check"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the issuing country inclusion check"}});let q=(k.committedInputs?.inclusion_check_issuing_country).countries,O=pr(E),z=await Mi(fe.ISSUING_COUNTRY_INCLUSION,q,false);O!==z&&(console.warn("The committed country list for the issuing country inclusion check does not match the one from the proof"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the issuing country inclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryInclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="bind"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the bound data"),u=false,y.bind={...y.bind,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the bound data"}});let q=k.committedInputs?.bind,O=pr(E),z=await Yp(ac(q.data));O!==z&&(console.warn("The bound data does not match the one from the proof"),u=false,y.bind={...y.bind,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The bound data does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"bind",o),{isCorrect:oe,queryResultErrors:te}=this.checkBindPublicInputs(r,i,q.data);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("bind",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_sanctions"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the sanctions exclusion check"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the sanctions exclusion check"}});let q=k.committedInputs?.exclusion_check_sanctions,O=await rh(q.rootHash,q.isStrict),z=pr(E);z!==O&&(console.warn("The sanction lists check against do not match the sanction lists from the proof"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Commitment: ${O.toString()}`,received:`Commitment: ${z.toString()}`,message:"The sanction lists check against do not match the sanction lists from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"sanctions",o),{isCorrect:oe,queryResultErrors:te}=await this.checkSanctionsExclusionPublicInputs(r,i,q,a,T,c);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("sanctions",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name?.startsWith("facematch")&&!k.name?.endsWith("_evm")){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the facematch check"),u=false,y.facematch={...y.facematch,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the facematch check"}});let q=k.committedInputs?.facematch,O=pr(E),z=await Qp(BigInt(q.rootKeyLeaf),q.environment==="development"?0n:1n,BigInt(q.appIdHash),q.mode==="regular"?1n:2n);O!==z&&(console.warn("The FaceMatch verification does not match the ones from the proof"),u=false,y.facematch={...y.facematch,commitment:{expected:`Commitment: ${z.toString()}`,received:`Commitment: ${O.toString()}`,message:"The FaceMatch verification does not match the ones from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"facematch",o),{isCorrect:oe,queryResultErrors:te}=await this.checkFacematchPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("facematch",E,n??gt,y);u=u&&$,y={...y,...R};}}let G=new Set;for(let k of I)for(let E of Object.keys(k.committedInputs??{}))G.add(E);let{isCorrect:F,queryResultErrors:H}=this.checkQueryCompleteness(r,G);if(u=u&&F,y={...y,...H},u&&m&&(m===Pe.SALTED||m===Pe.SALTED_MOCK))try{let k=await Zb(s??Wb),E=await Yb(k),q=b;if(q===void 0){let O=I.find(z=>z.name&&!z.name.startsWith("sig_check_")&&!z.name.startsWith("data_check_")&&!z.name.startsWith("outer")&&!z.name.startsWith("facematch"));if(O){let z=oa(O.proof,ia(O.name));q=zb(z);}}(q===void 0||q!==E)&&(console.warn("OPRF public key hash mismatch: proof uses an unknown OPRF key"),u=!1);}catch(k){console.warn("Failed to verify OPRF public key:",k),u=false;}return m===Pe.NONE?(h!==void 0&&BigInt(h)!==0n&&(console.warn("Proofs with the NONE nullifier type cannot carry a unique identifier"),u=false),h=void 0):h!==void 0&&BigInt(h)===0n&&(h=void 0),{isCorrect:u,uniqueIdentifier:h,uniqueIdentifierType:m,queryResultErrors:y}}},YE={abi:[{type:"constructor",inputs:[{name:"_admin",type:"address",internalType:"address"},{name:"_guardian",type:"address",internalType:"address"},{name:"_rootRegistry",type:"address",internalType:"contract RootRegistry"},{name:"_defaultOPRFPubKeyHash",type:"bytes32",internalType:"bytes32"}],stateMutability:"nonpayable"},{type:"function",name:"addHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newHelper",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"subVerifier",type:"address",internalType:"contract SubVerifier"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"admin",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"config",inputs:[{name:"key",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"value",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"defaultOPRFPubKeyHash",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"guardian",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"helperCount",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"helpers",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"contract VerifierHelper"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"removeHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"removeSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"rootRegistry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract RootRegistry"}],stateMutability:"view"},{type:"function",name:"setDefaultOPRFPubKeyHash",inputs:[{name:"newHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setGuardian",inputs:[{name:"newGuardian",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"subverifierCount",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"subverifiers",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"contract SubVerifier"}],stateMutability:"view"},{type:"function",name:"transferAdmin",inputs:[{name:"newAdmin",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateConfig",inputs:[{name:"key",type:"bytes32",internalType:"bytes32"},{name:"value",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newHelper",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newSubVerifier",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"verify",inputs:[{name:"params",type:"tuple",internalType:"struct ProofVerificationParams",components:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"proofVerificationData",type:"tuple",internalType:"struct ProofVerificationData",components:[{name:"vkeyHash",type:"bytes32",internalType:"bytes32"},{name:"proof",type:"bytes",internalType:"bytes"},{name:"publicInputs",type:"bytes32[]",internalType:"bytes32[]"}]},{name:"committedInputs",type:"bytes",internalType:"bytes"},{name:"serviceConfig",type:"tuple",internalType:"struct ServiceConfig",components:[{name:"validityPeriodInSeconds",type:"uint256",internalType:"uint256"},{name:"domain",type:"string",internalType:"string"},{name:"scope",type:"string",internalType:"string"},{name:"devMode",type:"bool",internalType:"bool"}]}]}],outputs:[{name:"valid",type:"bool",internalType:"bool"},{name:"uniqueIdentifier",type:"bytes32",internalType:"bytes32"},{name:"helper",type:"address",internalType:"contract VerifierHelper"}],stateMutability:"view"},{type:"event",name:"AdminUpdated",inputs:[{name:"oldAdmin",type:"address",indexed:true,internalType:"address"},{name:"newAdmin",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"ConfigUpdated",inputs:[{name:"key",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldValue",type:"bytes32",indexed:false,internalType:"bytes32"},{name:"newValue",type:"bytes32",indexed:false,internalType:"bytes32"}],anonymous:false},{type:"event",name:"DefaultOPRFPubKeyHashUpdated",inputs:[{name:"oldHash",type:"bytes32",indexed:false,internalType:"bytes32"},{name:"newHash",type:"bytes32",indexed:false,internalType:"bytes32"}],anonymous:false},{type:"event",name:"GuardianUpdated",inputs:[{name:"oldGuardian",type:"address",indexed:true,internalType:"address"},{name:"newGuardian",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperAdded",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"helper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperRemoved",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"helper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperUpdated",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldHelper",type:"address",indexed:true,internalType:"address"},{name:"newHelper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"PausedStatusChanged",inputs:[{name:"paused",type:"bool",indexed:false,internalType:"bool"}],anonymous:false},{type:"event",name:"RootRegistryUpdated",inputs:[{name:"oldRootRegistry",type:"address",indexed:true,internalType:"address"},{name:"newRootRegistry",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"RootVerifierDeployed",inputs:[{name:"admin",type:"address",indexed:false,internalType:"address"},{name:"guardian",type:"address",indexed:false,internalType:"address"},{name:"rootRegistry",type:"address",indexed:false,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierAdded",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"subVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierRemoved",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"subVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierUpdated",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldSubVerifier",type:"address",indexed:true,internalType:"address"},{name:"newSubVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false}]},aS=class{static getDetails(){return {functionName:"verify",abi:YE.abi,address:"0x1D000001000EFD9a6371f4d90bB8920D5431c0D8"}}static getParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){if(!t.name?.startsWith("outer_evm"))throw new Error("This proof cannot be verified on an EVM chain. Please make sure to use the `compressed-evm` mode.");let o=oa(t.proof,ia(t.name)),s=[],a=[];for(let h in t.committedInputs){let m=qb(h),b=h;s.push({circuitName:b,count:m});let A="";if(b==="inclusion_check_issuing_country_evm"||b==="inclusion_check_nationality_evm"||b==="exclusion_check_issuing_country_evm"||b==="exclusion_check_nationality_evm"){let x=t.committedInputs[b].countries;(b==="exclusion_check_issuing_country_evm"||b==="exclusion_check_nationality_evm")&&x.sort((w,I)=>w.localeCompare(I));let y=(()=>{switch(b){case "exclusion_check_issuing_country_evm":return fe.ISSUING_COUNTRY_EXCLUSION;case "exclusion_check_nationality_evm":return fe.NATIONALITY_EXCLUSION;case "inclusion_check_issuing_country_evm":return fe.ISSUING_COUNTRY_INCLUSION;case "inclusion_check_nationality_evm":return fe.NATIONALITY_INCLUSION}})();A=y.toString(16).padStart(2,"0")+se[y].evm.toString(16).padStart(4,"0")+Mo(x.map(w=>Array.from(new TextEncoder().encode(w))).flat(),600).map(w=>w.toString(16).padStart(2,"0")).join("");}else if(b==="compare_age_evm"){let x=t.committedInputs[b];A=fe.AGE.toString(16).padStart(2,"0")+se[fe.AGE].evm.toString(16).padStart(4,"0")+x.minAge.toString(16).padStart(2,"0")+x.maxAge.toString(16).padStart(2,"0");}else if(b==="compare_birthdate_evm"){let x=t.committedInputs[b],y=Array.from(Te(x.minDateTimestamp,8)),w=Array.from(Te(x.maxDateTimestamp,8));A=fe.BIRTHDATE.toString(16).padStart(2,"0")+se[fe.BIRTHDATE].evm.toString(16).padStart(4,"0")+y.map(I=>I.toString(16).padStart(2,"0")).join("")+w.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="compare_expiry_evm"){let x=t.committedInputs[b],y=Array.from(Te(x.minDateTimestamp,8)),w=Array.from(Te(x.maxDateTimestamp,8));A=fe.EXPIRY_DATE.toString(16).padStart(2,"0")+se[fe.EXPIRY_DATE].evm.toString(16).padStart(4,"0")+y.map(I=>I.toString(16).padStart(2,"0")).join("")+w.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="disclose_bytes_evm"){let x=t.committedInputs[b];A=fe.DISCLOSE.toString(16).padStart(2,"0")+se[fe.DISCLOSE].evm.toString(16).padStart(4,"0")+x.discloseMask.map(y=>y.toString(16).padStart(2,"0")).join("")+x.disclosedBytes.map(y=>y.toString(16).padStart(2,"0")).join("");}else if(b==="bind_evm"){let x=t.committedInputs[b];A=fe.BIND.toString(16).padStart(2,"0")+se[fe.BIND].evm.toString(16).padStart(4,"0")+Mo(ac(x.data),509).map(y=>y.toString(16).padStart(2,"0")).join("");}else if(b==="exclusion_check_sanctions_evm"){let x=t.committedInputs[b];A+=fe.SANCTIONS_EXCLUSION.toString(16).padStart(2,"0"),A+=se[fe.SANCTIONS_EXCLUSION].evm.toString(16).padStart(4,"0"),A+=Array.from(Te(BigInt(x.rootHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.isStrict?"01":"00";}else if(b.startsWith("facematch")&&b.endsWith("_evm")){let x=t.committedInputs[b];A+=fe.FACEMATCH.toString(16).padStart(2,"0"),A+=se[fe.FACEMATCH].evm.toString(16).padStart(4,"0"),A+=Array.from(Te(BigInt(x.rootKeyLeaf),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.environment==="development"?"00":"01",A+=Array.from(Te(BigInt(x.appIdHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=Array.from(Te(BigInt(x.integrityPubkeyHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.mode==="regular"?"01":"02";}else throw new Error(`Unsupported circuit for EVM verification: ${b}`);a.push({circuitName:b,inputs:A});}let c=oh(o).map(h=>h.toString(16).padStart(64,"0")),l="";for(let h of c){let m=a.find(b=>{let A=ot(jn(b.inputs)),x=new Uint8Array(A.length);for(let y=0;y<A.length-1;y++)x[y+1]=A[y];return x[0]=0,Vn(x)===h.replace("0x","")});if(m)if(s.find(A=>A.circuitName===m.circuitName)?.count)l+=m.inputs;else throw new Error(`Unknown circuit name: ${m.circuitName}`);else throw new Error(`Invalid commitment: ${h}`)}let d=t.version?.split(".").map(h=>Number(h));if(!d||d.length!==3)throw new Error("Invalid version format");let u=new Uint8Array([...Te(d[0],2),...Te(d[1],2),...Te(d[2],2)]);return {version:`0x${Vn(u).padEnd(64,"0")}`,proofVerificationData:{vkeyHash:`0x${t.vkeyHash.replace("0x","").padStart(64,"0")}`,proof:`0x${o.proof.join("")}`,publicInputs:o.publicInputs},committedInputs:`0x${l}`,serviceConfig:{validityPeriodInSeconds:e,domain:r,scope:i??"",devMode:n}}}};async function QE({domain:t,proofs:e,query:r,queryResult:i,scope:n,policyId:o,requestId:s}){let a=e.map(c=>({proof:c.proof,vkeyHash:c.vkeyHash,version:c.version,name:c.name,index:c.index,total:c.total,committedInputs:c.committedInputs}));try{let c=await fetch(`${hS}/public/proofs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:t,proofs:a,query:r,queryResult:i,scope:n,policyId:o,sdkVersion:O2,requestId:s}),signal:AbortSignal.timeout(3e4)});c.ok?eS.debug("API response status:",c.status):eS.warn("API request failed with status:",c.status);}catch{}}var JE=[0,20,0];function eB(t){if(!t)return "v5";let e=t.split(".").map(c=>Number(c));if(e.length!==3||e.some(c=>Number.isNaN(c)))return "v5";let[r,i,n]=e,[o,s,a]=JE;return r!==o?r>o?"v5":"v4":i!==s?i>s?"v5":"v4":n>=a?"v5":"v4"}async function tB(t,{writingDirectory:e}={}){await rB(t);let r=e?e+"/.bb-crs":void 0;if(t==="v4"){console.warn("Using deprecated v4 UltraHonk Verifier"),r=e?e+"/.bb-crs-v4":void 0;let{UltraHonkVerifierBackend:s,Barretenberg:a}=await Promise.resolve().then(()=>It(W8(),1)),c=await a.new({crsPath:r});return {verifier:new s(c),destroy:()=>c.destroy()}}let{UltraHonkVerifierBackend:i,Barretenberg:n}=await Promise.resolve().then(()=>It(Y8(),1)),o=await n.new({crsPath:r});return {verifier:new i(o),destroy:()=>o.destroy()}}var cS="__zkpassport_bb_version",lS="keyval-store";async function rB(t){if(!(typeof indexedDB>"u"))try{let e=typeof localStorage<"u"?localStorage:void 0;if((e?.getItem(cS)??"v4")===t)return;let r=!0;if(typeof indexedDB.databases=="function")try{r=(await indexedDB.databases()).some(i=>i.name===lS);}catch{r=!0;}r&&await new Promise(i=>{let n=indexedDB.deleteDatabase(lS);n.onsuccess=n.onerror=n.onblocked=()=>i();}),e?.setItem(cS,t);}catch{}}async function dS({proofs:t,originalQuery:e,queryResult:r,domain:i,validity:n,scope:o,devMode:s,oprfKeyId:a}){try{let c=await fetch(`${WE}/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proofs:t,originalQuery:e,queryResult:r,serviceConfig:{domain:i,scope:o,validityPeriodInSeconds:n,devMode:s},oprfKeyId:a}),signal:AbortSignal.timeout(6e4)});if(c.status>=500)return console.warn(`Verifier API error (status ${c.status})`),null;let l=await c.json().catch(()=>null);return !l||typeof l.verified!="boolean"?(console.warn(`Unexpected verifier API response (status ${c.status})`),null):l.verified?{uniqueIdentifier:l.uniqueIdentifier,uniqueIdentifierType:l.uniqueIdentifierType,verified:!0}:(console.warn("Verifier API did not verify the proofs:",l.error),{uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:!1,queryResultErrors:l.queryResultErrors})}catch(c){return console.warn("Verifier API call failed:",c),null}}typeof globalThis.Buffer>"u"&&(globalThis.Buffer=es.Buffer,typeof window<"u"&&(window.Buffer=es.Buffer));var uS="Verify identity privately";function iB({uniqueIdentifier:t,uniqueIdentifierType:e}){return e===Pe.SALTED_MOCK?Pe.SALTED:e===Pe.NON_SALTED_MOCK?t===void 0?Pe.NONE:Pe.NON_SALTED:e}function nB(t,e){if(e==null||!t.verified||iB(t)===e)return t;let r=t.uniqueIdentifierType,i=r===void 0?"missing":Pe[r];return console.warn(`Unique identifier type mismatch: requested ${Pe[e]}, got ${i}`),{...t,uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:false}}var fS=false;function oB(){fS||(fS=true,console.warn("[zkpassport] onResult is deprecated. Use onSuccess and verify the proofs on your backend with verify()."));}function sB(t){let e=t.connection.getWebSocket();if(e)try{e.send(JSON.stringify({method:"replay",params:{timestamp:1}}));}catch{}}var M2=class{constructor(t){if(this.topicToConfig={},this.topicToLocalConfig={},this.topicToPublicKey={},this.topicToBridge={},this.topicToRequestReceived={},this.topicToService={},this.topicToCallerPurpose={},this.topicToProofs={},this.topicToFailedProofCount={},this.topicToResults={},this.topicToPolicy={},this.dashboardConfig=null,this.dashboardConfigPromise=null,this.dashboardConfigError=null,this.onRequestReceivedCallbacks={},this.onGeneratingProofCallbacks={},this.onBridgeConnectCallbacks={},this.onBridgeConnectionLostCallbacks={},this.onProofGeneratedCallbacks={},this.onSuccessCallbacks={},this.onResultCallbacks={},this.onRejectCallbacks={},this.onErrorCallbacks={},!t&&typeof window>"u")throw new Error("Domain argument is required in Node.js environment");this.domainProvided=!!t,this.domain=this.normalizeDomain(t||window.location.hostname);}normalizeDomain(t){return t.trim().replace(/^https?:\/\//,"").replace(/\/[^/]*$/,"").replace(/:[0-9]+/,"").replace(/\?.*$/,"").replace(/#.*$/,"").toLowerCase()}async handleResult(t){let e=this.topicToResults[t];delete this.topicToResults[t];let r=this.topicToProofs[t],i=this.topicToFailedProofCount[t]>0,n=!i&&r.length>0;if(n)try{await Promise.all(this.onSuccessCallbacks[t].map(a=>a({proofs:r,result:e})));}catch{}let o=this.topicToLocalConfig[t]?.devMode===true,s=this.topicToPolicy[t]?.proofStorageEnabled===true;n&&s&&this.domainProvided&&!o&&QE({domain:this.domain,proofs:r,query:this.topicToConfig[t],queryResult:e,scope:this.topicToService[t]?.scope,policyId:this.topicToPolicy[t]?.id,requestId:this.topicToPublicKey[t]}),this.onResultCallbacks[t].length>0&&await this.verifyAndReportResult(t,r,e,i),delete this.topicToProofs[t],delete this.topicToFailedProofCount[t];}async verifyAndReportResult(t,e,r,i){let n;try{n=await this.verify({proofs:e,originalQuery:this.topicToConfig[t],queryResult:r,validity:this.topicToLocalConfig[t]?.validity,scope:this.topicToService[t]?.scope,devMode:this.topicToLocalConfig[t]?.devMode,oprfKeyId:this.topicToLocalConfig[t]?.oprfKeyId??void 0,uniqueIdentifierType:this.topicToLocalConfig[t]?.uniqueIdentifierType,verifierMode:this.topicToLocalConfig[t]?.verifierMode,config:this.topicToLocalConfig[t]?.config});}catch(l){let d=l instanceof Error?l.message:String(l);await Promise.all(this.onErrorCallbacks[t].map(u=>u(d)));return}let{uniqueIdentifier:o,uniqueIdentifierType:s,verified:a,queryResultErrors:c}=n;await Promise.all(this.onResultCallbacks[t].map(l=>l({uniqueIdentifier:i?void 0:o,uniqueIdentifierType:i?void 0:s,verified:i?false:a,result:r,queryResultErrors:c,proofs:e,sdkInstance:this})));}async handleEncryptedMessage(t,e){if(e.method==="accept")await Promise.all(this.onGeneratingProofCallbacks[t].map(r=>r(t)));else if(e.method==="reject")await Promise.all(this.onRejectCallbacks[t].map(r=>r()));else if(e.method==="proof")this.topicToProofs[t].push(e.params),await Promise.all(this.onProofGeneratedCallbacks[t].map(r=>r(e.params))),this.topicToResults[t]&&e.params.total===this.topicToProofs[t].length+this.topicToFailedProofCount[t]&&await this.handleResult(t);else if(e.method==="done")this.topicToResults[t]=$p(e.params),this.topicToProofs[t].length>0&&this.topicToProofs[t].length+this.topicToFailedProofCount[t]===this.topicToProofs[t][0].total&&await this.handleResult(t);else if(e.method==="error"){let r=e.params.error;r&&r==="This ID is not supported yet"?this.topicToResults[t]&&await this.handleResult(t):r&&r.startsWith("Cannot generate proof")&&(this.topicToFailedProofCount[t]+=1,this.topicToResults[t]&&this.topicToProofs[t].length>0&&this.topicToProofs[t].length+this.topicToFailedProofCount[t]===this.topicToProofs[t][0].total&&await this.handleResult(t)),await Promise.all(this.onErrorCallbacks[t].map(i=>i(r)));}}assertNotPolicyLocked(t,e){if(this.topicToPolicy[t])throw new Error(`Cannot call .${e}() on a policy-driven request. The query for policy '${this.topicToPolicy[t].id}' is immutable.`)}getZkPassportRequest(t){return {eq:(e,r)=>(this.assertNotPolicyLocked(t,"eq"),(e==="issuing_country"||e==="nationality")&&(r=Gi(r)),va("eq",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),gte:(e,r)=>{if(this.assertNotPolicyLocked(t,"gte"),Ln("gte",e,r,t,this.topicToConfig),e==="age"&&(r<1||r>=100))throw new Error("Age must be between 1 and 99 (inclusive)");return this.getZkPassportRequest(t)},gt:(e,r)=>(this.assertNotPolicyLocked(t,"gt"),Ln("gt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lte:(e,r)=>(this.assertNotPolicyLocked(t,"lte"),Ln("lte",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lt:(e,r)=>(this.assertNotPolicyLocked(t,"lt"),Ln("lt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),range:(e,r,i)=>(this.assertNotPolicyLocked(t,"range"),pS(e,[r,i],t,this.topicToConfig),this.getZkPassportRequest(t)),in:(e,r)=>(this.assertNotPolicyLocked(t,"in"),r=r.map(i=>Gi(i)),va("in",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),out:(e,r)=>(this.assertNotPolicyLocked(t,"out"),r=r.map(i=>Gi(i)),va("out",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),disclose:e=>(this.assertNotPolicyLocked(t,"disclose"),this.topicToConfig[t][e]={...this.topicToConfig[t][e],disclose:true},this.getZkPassportRequest(t)),bind:(e,r)=>(this.topicToConfig[t].bind={...this.topicToConfig[t].bind,[e]:r},this.getZkPassportRequest(t)),sanctions:(e="all",r="all",i={strict:false})=>(this.assertNotPolicyLocked(t,"sanctions"),this.topicToConfig[t].sanctions={...this.topicToConfig[t].sanctions,countries:e,lists:r,strict:i.strict??false},this.getZkPassportRequest(t)),facematch:(e="strict")=>(this.assertNotPolicyLocked(t,"facematch"),this.topicToConfig[t].facematch={mode:e},this.getZkPassportRequest(t)),raw:e=>{this.assertNotPolicyLocked(t,"raw");let{policy:r,bind:i,...n}=e;if(r){if(Object.keys(n).length>0)throw new Error("A query with `policy` cannot also carry conditions (bind is allowed).");this.getZkPassportRequest(t).policy(r),i&&(this.topicToConfig[t].bind=i);}else this.topicToConfig[t]=e;return this.getZkPassportRequest(t)},policy:e=>{if(this.assertCanApplyPolicy(t,e),!this.dashboardConfig)throw this.dashboardConfigError?this.dashboardConfigError:new Error(`${this.domain} is not set up for ZKPassport verification. If this is your site, register the domain at https://dashboard.zkpassport.id.`);let r=this.findPolicy(this.dashboardConfig,e),{bind:i,...n}=r.query;this.topicToConfig[t]=n;let o=this.topicToService[t];return o&&(this.topicToCallerPurpose[t]||(o.purpose=r.purpose||uS),o.scope||(o.scope=r.id),o.policyId=r.id),this.topicToPolicy[t]={id:r.id,proofStorageEnabled:r.proofStorageEnabled===true},this.getZkPassportRequest(t)},done:(()=>{if(this.topicToFailedProofCount[t]=0,t==="offline-query"){let o=this.topicToConfig[t];return delete this.topicToConfig[t],delete this.topicToPolicy[t],{query:o}}let e=this.topicToLocalConfig[t],r=this.topicToConfig[t],i=!!r.facematch,n=!!r.facematch&&r.facematch?.mode==="strict";if(e.uniqueIdentifierType===Pe.SALTED&&(e.devMode===false&&!n||!i))throw new Error("Salted nullifier requires strict facematch. Add .facematch('strict') to your query or remove the salted nullifier option.");return {url:this._getUrl(t),query:this.topicToConfig[t],requestId:t,policy:this.topicToPolicy[t]?.id,onRequestReceived:o=>this.onRequestReceivedCallbacks[t].push(o),onGeneratingProof:o=>this.onGeneratingProofCallbacks[t].push(o),onBridgeConnect:o=>this.onBridgeConnectCallbacks[t].push(o),onBridgeConnectionLost:o=>this.onBridgeConnectionLostCallbacks[t].push(o),onProofGenerated:o=>this.onProofGeneratedCallbacks[t].push(o),onSuccess:o=>this.onSuccessCallbacks[t].push(o),onResult:o=>{oB(),this.onResultCallbacks[t].push(o);},onReject:o=>this.onRejectCallbacks[t].push(o),onError:o=>this.onErrorCallbacks[t].push(o),isBridgeConnected:()=>this.topicToBridge[t].isBridgeConnected(),requestReceived:()=>this.topicToRequestReceived[t]===true}})}}async getDashboardConfig(){return this.dashboardConfig?this.dashboardConfig:(this.dashboardConfigPromise||(this.dashboardConfigPromise=this.fetchDashboardConfig().then(t=>(this.dashboardConfig=t,t)).catch(t=>{throw this.dashboardConfigPromise=null,t})),this.dashboardConfigPromise)}async fetchDashboardConfig(){let t=`${hS}/public/project?domain=${encodeURIComponent(this.domain)}`,e;try{e=await fetch(t,{signal:AbortSignal.timeout(1e4)});}catch(i){throw new Error(`Failed to fetch dashboard config for domain '${this.domain}': ${i.message}`)}if(!e.ok)throw new Error(`Failed to fetch dashboard config for domain '${this.domain}': ${e.status} ${e.statusText}`);let r=await e.json();if(r&&r.project===null)return null;if(!r||!r.project||!Array.isArray(r.policies))throw new Error(`Invalid dashboard config response for domain '${this.domain}'`);return r}findPolicy(t,e){let r=t.policies.find(i=>i.id===e);if(!r)throw new Error(`Policy '${e}' not found for domain '${this.domain}'. The dashboard returned ${t.policies.length} policies for this domain.`);if(!r.query||typeof r.query!="object")throw new Error(`Invalid policy '${e}' for domain '${this.domain}': missing query object.`);return r}assertCanApplyPolicy(t,e){if(typeof e!="string"||e.length===0)throw new Error(".policy() requires a non-empty string id.");if(this.topicToPolicy[t])throw new Error(`Cannot call .policy() more than once on a request (already set to '${this.topicToPolicy[t].id}').`);if(Object.keys(this.topicToConfig[t]).length>0)throw new Error("Cannot combine .policy() with builder methods like .gte()/.disclose()/etc. Call .policy() first; only .bind() may follow it.")}async request({name:t,logo:e,purpose:r,scope:i,projectID:n,mode:o,validity:s,devMode:a,uniqueIdentifierType:c,oprfKeyId:l,topicOverride:d,keyPairOverride:u,replayMissedMessages:h,cloudProverUrl:m,bridgeUrl:b,returnDeepLink:A,verifierMode:x,config:y,overrides:w}){if(d==="offline-query")throw new Error("You cannot override the topic with 'offline-query'");if(l&&c===Pe.NONE)throw new Error("An OPRF key cannot be used with the NONE unique identifier type. Remove the oprfKeyId option or use the SALTED type.");let I=null;try{I=await this.getDashboardConfig(),this.dashboardConfigError=null;}catch(v){this.dashboardConfigError=v;}let _=await E2.create({keyPair:u,bridgeId:d,bridgeUrl:b}),C=_.connection.getBridgeId();return this.topicToConfig[C]={},this.topicToCallerPurpose[C]=r,this.topicToService[C]={name:t||I?.project?.name||this.domain,logo:e||I?.project?.logoUrl||"",purpose:r||uS,scope:i,projectID:n,cloudProverUrl:m,bridgeUrl:b},this.topicToProofs[C]=[],this.topicToLocalConfig[C]={validity:s||gt,mode:o||"fast",devMode:a??false,uniqueIdentifierType:l?Pe.SALTED:c,oprfKeyId:l??null,returnDeepLink:A,verifierMode:x,config:y,appClip:w?.appClip??false},this.onRequestReceivedCallbacks[C]=[],this.onGeneratingProofCallbacks[C]=[],this.onBridgeConnectCallbacks[C]=[],this.onBridgeConnectionLostCallbacks[C]=[],this.onProofGeneratedCallbacks[C]=[],this.onSuccessCallbacks[C]=[],this.onResultCallbacks[C]=[],this.onRejectCallbacks[C]=[],this.onErrorCallbacks[C]=[],this.topicToPublicKey[C]=_.getPublicKey(),this.topicToBridge[C]=_,_.onConnect(async v=>{h&&!v&&sB(_),await Promise.all(this.onBridgeConnectCallbacks[C].map(T=>T()));}),_.onDisconnect(async v=>{v.wasIntentionalClose||v.willReconnect||await Promise.all(this.onBridgeConnectionLostCallbacks[C].map(T=>T()));}),_.onSecureChannelEstablished(async()=>{await Promise.all(this.onRequestReceivedCallbacks[C].map(v=>v()));}),_.onSecureMessage(async v=>{try{await this.handleEncryptedMessage(C,v);}catch{}}),this.getZkPassportRequest(C)}createQuery(){return jE()}async verify({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,uniqueIdentifierType:c,verifierMode:l="auto",config:d}){if(!e||!r)throw new Error("verify() requires `originalQuery` and `queryResult`");let u={uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:false};if(!t||t.length===0)return u;let h={proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o,oprfKeyId:a},m={...h,writingDirectory:s,config:d},b={...h,domain:this.domain},A=a?Pe.SALTED:c,x;if(l==="local")x=await this.verifyLocally(m);else if(l==="api")x=await dS(b)??u;else {let y;try{y=await this.verifyLocally(m);}catch(w){console.warn("Local proof verification failed:",w);}x=y?.verified?y:await dS(b)??y??u;}return nB(x,A)}async verifyLocally({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,config:c}){let l=$p(r);typeof window>"u"&&!s&&(s="/tmp");let d=eB(t[0]?.version),u,h=true,m,b,A;try{let x=xh(Gp(e,o),c),{isCorrect:y,uniqueIdentifier:w,uniqueIdentifierType:I,queryResultErrors:_}=await ZE.checkPublicInputs(this.domain,t,e,l,i,n,a,o,x);if(m=w,b=I,h=y,A=y?void 0:_,(b===Pe.SALTED_MOCK||b===Pe.NON_SALTED_MOCK)&&!o&&(h=!1,console.warn("You are trying to verify a mock proof. This is only allowed in dev mode. To enable dev mode, set the `devMode` parameter to `true` in the request function parameters.")),h){let C=await x.getCircuitManifest(void 0,{version:t[0].version});u=await tB(d,{writingDirectory:s});for(let v of t){let T=v.name?.startsWith("outer_evm_"),G=v.name,F=oa(v.proof,ia(G)),H=await x.getPackagedCircuit(G,C,{validate:!T});if(T)try{let{createPublicClient:k,http:E}=await Promise.resolve().then(()=>It(J8(),1)),{address:q,abi:O,functionName:z}=this.getSolidityVerifierDetails(),W=k({transport:E(x.getRpcUrl())}),Y=this.getSolidityVerifierParameters({proof:v,validityPeriodInSeconds:i,domain:this.domain,scope:n,devMode:o}),oe=await W.readContract({address:q,abi:O,functionName:z,args:[Y]});h=Array.isArray(oe)?!!oe[0]:!1;}catch(k){console.warn("Error verifying proof",k),h=!1;}else {let k=es.Buffer.from(H.vkey,"base64");try{h=await u.verifier.verifyProof({proof:es.Buffer.from(F.proof.join(""),"hex"),publicInputs:F.publicInputs,verificationKey:new Uint8Array(k)});}catch(E){console.warn(`Error verifying proof ${G}`,E),h=!1;}}if(!h)break}}}finally{await u?.destroy();}return m=h?m:void 0,b=h?b:void 0,{uniqueIdentifier:m,uniqueIdentifierType:b,verified:h,queryResultErrors:A}}getSolidityVerifierDetails(){return aS.getDetails()}getSolidityVerifierParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){return aS.getParameters({proof:t,validityPeriodInSeconds:e,domain:r??this.domain,scope:i,devMode:n})}_getUrl(t){let e=es.Buffer.from(JSON.stringify(this.topicToConfig[t])).toString("base64"),r=es.Buffer.from(JSON.stringify(this.topicToService[t])).toString("base64"),i=this.topicToPublicKey[t],n=Math.floor(Date.now()/1e3)-this.topicToLocalConfig[t].validity,o=this.topicToLocalConfig[t].uniqueIdentifierType,s=this.topicToLocalConfig[t].oprfKeyId,a=this.topicToLocalConfig[t].returnDeepLink,c=`https://zkpassport.id/${this.topicToLocalConfig[t].appClip?"c":"r"}?d=${this.domain}&t=${t}&c=${encodeURIComponent(e)}&s=${encodeURIComponent(r)}&p=${i}&m=${this.topicToLocalConfig[t].mode}&v=${O2}&dt=${n}&dev=${this.topicToLocalConfig[t].devMode?"1":"0"}`;return o!=null&&(c+=`&nt=${o}`),s&&(c+=`&oprf_k=${s}`),a&&(c+=`&r=${encodeURIComponent(a)}`),c}getUrl(t){return this._getUrl(t)}getServiceDetails(t){return this.topicToService[t]}getRequestKeyPair(t){return this.topicToBridge[t]?.getKeyPair()}cancelRequest(t){this.topicToBridge[t]&&(this.topicToBridge[t].close(),delete this.topicToBridge[t]),delete this.topicToPublicKey[t],delete this.topicToConfig[t],delete this.topicToLocalConfig[t],delete this.topicToProofs[t],delete this.topicToFailedProofCount[t],delete this.topicToResults[t],delete this.topicToPolicy[t],this.onRequestReceivedCallbacks[t]=[],this.onGeneratingProofCallbacks[t]=[],this.onBridgeConnectCallbacks[t]=[],this.onBridgeConnectionLostCallbacks[t]=[],this.onProofGeneratedCallbacks[t]=[],this.onSuccessCallbacks[t]=[],this.onResultCallbacks[t]=[],this.onRejectCallbacks[t]=[],this.onErrorCallbacks[t]=[];}clearAllRequests(){for(let t in this.topicToBridge)this.cancelRequest(t);}};var zd="[zkpassport]";function aB(){try{return typeof localStorage<"u"&&localStorage.getItem("zkpassport:debug")==="1"}catch{return false}}var ci={error(...t){console.error(zd,...t);},warn(...t){console.warn(zd,...t);},info(...t){console.info(zd,...t);},debug(...t){aB()&&console.debug(zd,...t);}};function gS(t){let e=t.showIntroScreen===true,[r,i]=Ht(e?"intro":"preparing"),[n,o]=Ht(null),[s,a]=Ht(null),[c,l]=Ht(null),[d,u]=Ht(null),[h,m]=Ht(null),[b,A]=Ht(0),[x,y]=Ht({received:0,total:null}),w=Fr(t);w.current=t;let I=Fr(null),_=Fr("preparing"),C=Fr(e),v=Fr(false),T=Fr(null),G=Fr(null);G.current===null&&(G.current=new M2(t.domain)),is(()=>{let k=G.current,E=false,q=false,O=null,z=w.current.showIntroScreen===true,W=z&&!v.current;C.current=W,_.current="preparing",i(W?"intro":"preparing"),o(null),a(null),l(null),u(null),m(null),y({received:0,total:null}),I.current=null;let{domain:Y,theme:oe,showIntroScreen:te,query:$,onReady:R,onRetryClicked:M,onBridgeConnect:V,onRequestReceived:K,onGeneratingProof:L,onProofGenerated:re,onSuccess:D,onResult:X,onReject:Q,onError:ne,...le}=w.current;X&&w.current.onSuccess&&ci.warn("onResult is deprecated and drives the card; onSuccess return values are ignored");let _e=()=>{q||(q=true,br(w.current.onReady));},Oe=false,Ne=yt=>{Oe=true,C.current=false,v.current=true,i(yt);},Fe=(yt,ye)=>{ci.error(ye),Ne("error");let $i=ye instanceof Error?ye.message:String(ye);br(w.current.onError,`${yt}: ${$i}`);},ge=yt=>(...ye)=>{if(!E)try{yt(...ye);}catch($i){Fe("Failed to handle a verification update",$i);}},Le=(yt,ye=false)=>{_.current=yt,ye&&(C.current=false,v.current=true),C.current||i(yt);};return k.request({...le,verifierMode:le.verifierMode??"api"}).then(yt=>{let ye;try{ye=$(yt);}catch(Re){E||Fe("Failed to build the verification query",Re);return}if(O=ye.requestId,E){k.cancelRequest(ye.requestId);return}ye.onBridgeConnect(ge(()=>{(_.current==="preparing"||_.current==="connecting")&&Le("waiting"),_e(),br(w.current.onBridgeConnect);})),ye.onBridgeConnectionLost(ge(()=>{Oe||(Ne("error"),br(w.current.onError,"The connection to your phone was lost."));})),ye.onRequestReceived(ge(()=>{Le("scanned",!0),br(w.current.onRequestReceived);})),ye.onGeneratingProof(ge(()=>{Le("generating",!0),br(w.current.onGeneratingProof);})),ye.onProofGenerated(ge(Re=>{y(Vi=>({received:Vi.received+1,total:Re.total??Vi.total})),br(w.current.onProofGenerated,Re);})),ye.onSuccess(ge(Re=>{if(X){br(w.current.onSuccess,Re);return}let Vi=Hn=>{E||Ne(Hn);},z2;try{z2=w.current.onSuccess?.(Re);}catch(Hn){ci.error(Hn),Vi("error");return}Promise.resolve(z2).then(Hn=>Vi(Hn===!1?"error":"success"),Hn=>{ci.error(Hn),Vi("error");});})),X&&ye.onResult(ge(Re=>{Ne(Re.verified?"success":"error"),br(w.current.onResult,Re);})),ye.onReject(ge(()=>{Ne("error"),br(w.current.onReject);})),ye.onError(ge(Re=>{Ne("error"),br(w.current.onError,Re);})),I.current=ye,l(ye.query);try{let Re=k.getServiceDetails(ye.requestId);Re&&(u(Re.name||null),m(Re.logo||null));}catch(Re){ci.error(Re);}let $i=JSON.stringify(ye.query);z&&v.current&&$i!==T.current&&(C.current=true,i("intro")),T.current=$i;try{ye.requestReceived()?Le("scanned",!0):ye.isBridgeConnected()?(Le("waiting"),_e()):Le("connecting");}catch(Re){Fe("Failed to check the verification state",Re);}o(ye.url);try{a(cB(ye.url));}catch(Re){Fe("Failed to render the QR code",Re);}}).catch(yt=>{E||Fe("Failed to start the verification request",yt);}),()=>{E=true,O&&k.cancelRequest(O);}},[b]);let F=cu(()=>{br(w.current.onRetryClicked),A(k=>k+1);},[]),H=cu(()=>{C.current=false,v.current=true,i(_.current);},[]);return {state:r,url:n,qrSvg:s,query:c,serviceName:d,serviceLogo:h,retry:F,continueWithPhone:H,proofProgress:x}}function cB(t){let e=mS.default.create(t,{errorCorrectionLevel:"Q"}),r=e.modules.size,i=e.modules.data,n=100/r,o=u=>u.toFixed(3),s=[[0,0],[0,r-7],[r-7,0]],a=(u,h)=>s.some(([m,b])=>u>=m&&u<m+7&&h>=b&&h<b+7),c="",l=n*.47;for(let u=0;u<r;u++)for(let h=0;h<r;h++){if(!i[u*r+h]||a(u,h))continue;let m=(h+.5)*n,b=(u+.5)*n;c+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(l)}"/>`;}let d="";for(let[u,h]of s){let m=(h+3.5)*n,b=(u+3.5)*n;d+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(n*3)}" fill="none" stroke="currentColor" stroke-width="${o(n)}"/><circle cx="${o(m)}" cy="${o(b)}" r="${o(n*1.5)}"/>`;}return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" shape-rendering="geometricPrecision" fill="currentColor">${d}${c}</svg>`}function br(t,...e){if(t)try{t(...e);}catch{}}function yS(t,{probe:e}){let[r,i]=Ht("idle"),n=Fr(null);return is(()=>(i("idle"),()=>n.current?.()),[t]),{openState:r,openApp:()=>{if(t){if(n.current?.(),!e){n.current=pu(t);return}i("opening"),n.current=pu(t,s=>i(s?"opened":"nothing-opened"));}}}}var lB={firstname:"first name",lastname:"last name",fullname:"full name",birthdate:"date of birth",age:"age",expiry_date:"ID expiry date",nationality:"nationality",issuing_country:"issuing country",document_number:"document number",document_type:"document type",gender:"gender"},dB=["birthdate","expiry_date"],bS=["nationality","issuing_country"],SS=["firstname","lastname","fullname","gender","birthdate","age","document_type","document_number","nationality","issuing_country","expiry_date"],li={disclose:0,age:1,date:2,country:3,field:4,sanctions:5,facematch:6,bind:7},uB=3,fB={year:"numeric",month:"long",day:"numeric"};function xS(t){return t.toLocaleDateString(void 0,fB)}var pB={passport:"passport",id_card:"ID card",residence_permit:"residence permit"},hB={passport:"a passport",id_card:"an ID card",residence_permit:"a residence permit",other:"another accepted document"};function Wt(t,e){if(e instanceof Date)return xS(e);if(dB.includes(t)&&(typeof e=="string"||typeof e=="number")){let r=new Date(e);if(!Number.isNaN(r.getTime()))return xS(r)}return t==="document_type"&&typeof e=="string"?pB[e]??e.replace(/_/g," "):String(e)}function mB(t,e){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} ${e} ${t[t.length-1]}`}function U2(t){return lB[t]??String(t).replace(/_/g," ")}function AS(t,e,r){let i=U2(t),n=e.map(c=>Wt(t,c)).sort((c,l)=>c.localeCompare(l)),o=bS.includes(t)?li.country:li.field;if(n.length<=uB){let c=r?n.length===1?`is not ${n[0]}`:`is not any of ${n.join(", ")}`:`is ${mB(n,"or")}`;return {title:`Your ${i} ${c}`,group:o}}let s=bS.includes(t)?"countries":"values";return {title:`Your ${i} ${r?"is not any of":"is one of"} these ${n.length} ${s}:`,detail:n.join(", "),group:o}}function gB(t,e,r){let i=U2(t);if(t==="age"){let n=li.age;e.gte!=null&&r.push({title:`You are ${e.gte} or older`,group:n}),e.gt!=null&&r.push({title:`You are over ${e.gt}`,group:n}),e.lte!=null&&r.push({title:`You are ${e.lte} or younger`,group:n}),e.lt!=null&&r.push({title:`You are under ${e.lt}`,group:n}),e.range!=null&&r.push({title:`Your age is between ${e.range[0]} and ${e.range[1]}`,group:n}),e.eq!=null&&r.push({title:`You are ${e.eq} years old`,group:n});return}if(t==="expiry_date"){let n=li.date;(e.gte!=null||e.gt!=null)&&r.push({title:`Your ID is valid until at least ${Wt(t,e.gte??e.gt)}`,group:n}),(e.lte!=null||e.lt!=null)&&r.push({title:`Your ID expires before ${Wt(t,e.lte??e.lt)}`,group:n}),e.range!=null&&r.push({title:`Your ID expires between ${Wt(t,e.range[0])} and ${Wt(t,e.range[1])}`,group:n}),e.eq!=null&&r.push({title:`Your ID expires on ${Wt(t,e.eq)}`,group:n});return}if(t==="birthdate"){let n=li.date;(e.gte!=null||e.gt!=null)&&r.push({title:`You were born after ${Wt(t,e.gte??e.gt)}`,group:n}),(e.lte!=null||e.lt!=null)&&r.push({title:`You were born before ${Wt(t,e.lte??e.lt)}`,group:n}),e.range!=null&&r.push({title:`You were born between ${Wt(t,e.range[0])} and ${Wt(t,e.range[1])}`,group:n}),e.eq!=null&&r.push({title:`Your date of birth is ${Wt(t,e.eq)}`,group:n});return}e.eq!=null&&r.push({title:t==="document_type"?`Your ID is ${hB[String(e.eq)]??Wt(t,e.eq)}`:`Your ${i} is ${Wt(t,e.eq)}`,group:li.field}),e.in!=null&&r.push(AS(t,e.in,false)),e.out!=null&&r.push(AS(t,e.out,true));}function yB(t){return t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function bB(t){let{user_address:e,chain:r,custom_data:i}=t,n="Bound to",o=[];if(r&&o.push({label:"Chain",value:yB(r)}),e&&o.push({label:"Wallet",value:e}),i!=null){let s=typeof i=="string"?i:JSON.stringify(i);if(o.length===0)return {note:n,title:s};o.push({label:"Data",value:s});}return o.length===0?{note:n,title:"This site"}:{note:n,title:"",rows:o}}function SB(t){let e=i=>{let n=SS.indexOf(i);return n===-1?SS.length:n};return (t.includes("fullname")?t.filter(i=>i!=="firstname"&&i!=="lastname"):t).map(i=>({title:`Share your ${U2(i)}`,group:li.disclose,order:e(i)}))}function wS(t){if(!t)return [];let e=[],r=[];for(let[i,n]of Object.entries(t)){if(n==null)continue;if(i==="sanctions"){e.push({title:"You are not on any sanctions list",group:li.sanctions});continue}if(i==="facematch"){e.push({title:"Your face matches your ID photo",group:li.facematch});continue}if(i==="bind"){e.push({...bB(n),group:li.bind});continue}if(i==="policy")continue;let o=i;n.disclose&&r.push(o),gB(o,n,e);}return e.push(...SB(r)),e.length===0?[{title:"You hold a valid, unexpired passport or ID card"}]:e.map((i,n)=>({entry:i,index:n})).sort((i,n)=>i.entry.group-n.entry.group||(i.entry.order??0)-(n.entry.order??0)||i.index-n.index).map(({entry:{group:i,order:n,...o}})=>o)}function qd(){if(typeof navigator>"u"||typeof window>"u")return false;if(navigator.userAgentData?.mobile)return true;let e=navigator.userAgent;return !!(/Android|iPhone|iPod|Mobile|IEMobile/i.test(e)||/iPad/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)}function Gd(){if(typeof navigator>"u")return false;let t=navigator.userAgent;return /FBAN|FBAV|FB_IAB|Instagram|Twitter|TwitterAndroid|Discord|Snapchat|TikTok|BytedanceWebview|musical_ly|Line\/|MicroMessenger|GSA\/|LinkedInApp|Pinterest/i.test(t)||/Android/.test(t)&&/; wv\)/.test(t)?true:xB()?false:!!(/iPhone|iPad|iPod/.test(t)&&/AppleWebKit/.test(t)&&!/Safari\//.test(t))}function xB(){return navigator.standalone===true}var AB=0;function U(t,e,r,i,n,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var l={type:t,props:c,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--AB,__i:-1,__u:0,__source:n,__self:o};if(typeof t=="function"&&(s=t.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return Ce.vnode&&Ce.vnode(l),l}function _S({options:t,controlRef:e}){fm(NB,[]);let{state:r,url:i,qrSvg:n,query:o,serviceName:s,serviceLogo:a,retry:c,continueWithPhone:l,proofProgress:d}=gS(t);is(()=>{if(e)return e.current={retry:c},()=>{e.current=null;}},[c,e]);let u=t.display?.header??true,h=t.display?.steps??true,m=t.display?.appLinks??true,b=t.display?.frame??true,A=t.name??s??t.domain??"",x=t.logo??a??"",y=r==="scanned"||r==="generating"||r==="success"||r==="error",w=!!o?.facematch,I=vB(r),_=r==="waiting"||r==="scanned",[C,v]=Ht(false),T=qd(),G=Gd(),F=r==="preparing"||r==="connecting"||r==="waiting",H=T&&F&&!C,k=EB(r,y,w,d,T&&!C);return U("div",{className:"zkp-card","data-state":r,"data-theme":t.theme??"auto","data-frame":b?void 0:"none",children:[_?U("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:c,dangerouslySetInnerHTML:{__html:Am}}):null,u?U(xr,{children:[U("div",{className:"zkp-header",children:[U("div",{className:"zkp-header-icons",children:[U("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:ka}}),x?U(xr,{children:[U("div",{className:"zkp-header-dots",children:[U("span",{}),U("span",{}),U("span",{})]}),U("div",{className:"zkp-app-icon-slot",children:U("img",{className:"zkp-app-icon",src:x,alt:A?`${A} icon`:""})})]}):null]}),U("p",{className:"zkp-title",children:[U("strong",{children:A||"This app"})," uses ",U("strong",{children:"ZKPassport"})," to verify identity without compromising your privacy."]})]}),U("div",{className:"zkp-divider zkp-divider-header"})]}):null,r==="intro"?U(IB,{appName:A||"This app",items:wS(o),purpose:t.purpose,loading:o===null,onContinue:l}):U("div",{className:"zkp-screen",children:[H?U(kB,{requestUrl:r==="waiting"?i:null,inAppBrowser:G,onRevealQr:()=>v(true)}):U(BB,{state:r,qrSvg:n,caption:I}),T&&C&&F?U("button",{type:"button",className:"zkp-qr-reveal zkp-qr-back",onClick:()=>v(false),children:"Open the ZKPassport app instead"}):null,h&&k.length>0?U(xr,{children:[U("div",{className:"zkp-divider zkp-divider-top"}),U("div",{className:"zkp-steps",children:k.map(E=>U(TB,{status:E.status,icon:E.icon,children:E.label},E.key))})]}):null,m&&!H?U("div",{className:`zkp-collapse${y?" zkp-collapse-out":""}`,children:U("div",{className:"zkp-collapse-inner",children:[U("div",{className:"zkp-divider zkp-divider-bottom"}),U("div",{className:"zkp-footer",children:[U("span",{className:"zkp-footer-label",children:"ZKPassport App"}),U("div",{className:"zkp-store-buttons",children:[U($d,{href:Jc,badge:uu}),U($d,{href:ns,badge:fu})]})]})]})}):null,r==="error"?U("div",{className:"zkp-result-actions",children:U("button",{type:"button",className:"zkp-retry",onClick:c,children:"Try again"})}):null]})]})}var wB=2;function _B({item:t}){return U("li",{className:"zkp-intro-note",children:[U("span",{className:"zkp-intro-note-label",children:t.note}),t.rows?U("dl",{className:"zkp-intro-note-rows",children:t.rows.map(e=>U("div",{children:[U("dt",{children:e.label}),U("dd",{children:e.value})]},e.label))}):U("span",{className:"zkp-intro-note-text",children:t.title}),t.detail?U("span",{className:"zkp-intro-item-detail",children:t.detail}):null]})}var CB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 32" fill="currentColor" aria-hidden="true"><circle cx="27.5033" cy="15.722" r="7.48372"/><path d="M55.1719 31.4604H0V17.3281H17.0845C17.857 22.3884 22.2278 26.265 27.504 26.265C32.7802 26.265 37.151 22.3884 37.9235 17.3281H55.1719V31.4604Z"/><path d="M55.1719 14.1192H37.9236C37.1511 9.05887 32.7803 5.18223 27.504 5.18223C22.2278 5.18223 17.857 9.05887 17.0845 14.1192H0V0H55.1719V14.1192Z"/></svg>';function IB({appName:t,items:e,purpose:r,loading:i,onContinue:n}){return U("div",{className:"zkp-intro",children:[U("div",{className:"zkp-intro-request",children:[U("p",{className:"zkp-eyebrow",children:[t," wants to verify"]}),i?U("ul",{className:"zkp-intro-list",role:"status","aria-label":"Loading request",children:Array.from({length:wB},(o,s)=>U("li",{children:[U("span",{className:"zkp-intro-check zkp-skel-check"}),U("span",{className:"zkp-intro-item",children:U("span",{className:"zkp-intro-item-title zkp-skel-text",children:U("span",{className:"zkp-skel-bar",style:{width:"80%"}})})})]},s))}):U("ul",{className:"zkp-intro-list",children:e.map((o,s)=>o.note?U(_B,{item:o},s):U("li",{children:[U("span",{className:"zkp-intro-check",dangerouslySetInnerHTML:{__html:os}}),U("span",{className:"zkp-intro-item",children:[U("span",{className:"zkp-intro-item-title",children:o.title}),o.detail?U("span",{className:"zkp-intro-item-detail",children:o.detail}):null]})]},s))}),r&&!i?U("p",{className:"zkp-intro-purpose",children:[U("span",{className:"zkp-intro-purpose-label",children:"Purpose"}),r]}):null]}),U("div",{className:"zkp-intro-question",children:[U("span",{className:"zkp-chip-symbol","aria-hidden":"true",dangerouslySetInnerHTML:{__html:CB}}),U("p",{className:"zkp-intro-question-text",children:"Do you have a passport or ID with a chip?"}),U("p",{className:"zkp-intro-question-hint",children:"Look for this symbol on your passport or ID card. Your phone reads the chip over NFC."}),U("button",{type:"button",className:"zkp-intro-continue",onClick:n,children:"Continue"})]}),U("div",{className:"zkp-intro-footer",children:[U("div",{className:"zkp-divider"}),U("p",{className:"zkp-intro-footer-note",children:"Your ID data never leaves your device."}),U("div",{className:"zkp-privacy-strip","aria-label":"Private, encrypted, on your device",children:[U("span",{children:"Private"}),U("span",{className:"zkp-privacy-dot","aria-hidden":"true",children:"\xB7"}),U("span",{children:"Encrypted"}),U("span",{className:"zkp-privacy-dot","aria-hidden":"true",children:"\xB7"}),U("span",{children:"On your device"})]})]})]})}function vB(t){switch(t){case "scanned":return "Approve the request on your phone";case "generating":return "Generating proof\u2026";case "success":return "Request complete";case "error":return "Something went wrong";default:return ""}}function EB(t,e,r,i,n){let o=t==="success",s=t==="generating",{received:a,total:c}=i,l=c!==null&&a>=c,d=e?"done":"pending",u=[{key:"download",label:U(xr,{children:[U("a",{href:mm,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),status:d,icon:e?null:bm},{key:"scan",label:n?"Tap \u201COpen ZKPassport App\u201D above.":"Scan this QR code with the ZKPassport app.",status:d,icon:e?null:gm},{key:"approve",label:"Approve the request on your phone.",status:t==="scanned"?"current":s||o?"done":"pending",icon:e?null:ym}];return r&&u.push({key:"selfie",label:"Take a selfie to match your ID photo.",status:s&&a===0?"current":s&&a>0||o?"done":"pending",icon:null}),u.push({key:"generate",label:s&&c!==null?`Generate proof on your device (${Math.min(a,c)}/${c}).`:"Generate proof on your device.",status:s&&!l&&(!r||a>0)?"current":s&&l||o?"done":"pending",icon:null},{key:"verify",label:"Verify the proof.",status:s&&l?"current":o?"done":"pending",icon:null}),e?u:u.slice(0,3)}function BB({state:t,qrSvg:e,caption:r}){return U("div",{className:"zkp-qr-slot","data-state":t,children:[U("div",{className:"zkp-skeleton"}),U("div",{className:"zkp-qr",dangerouslySetInnerHTML:e?{__html:e}:void 0}),e?U("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:ka}}):null,U("div",{className:"zkp-overlay",children:[U("div",{className:"zkp-overlay-body",children:[t==="connecting"||t==="generating"?U("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:du}}):null,t==="scanned"?U("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:xm}}):null,t==="success"?U("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:os}}):null,t==="error"?U("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:Sm}}):null]}),r?U("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function TB({status:t,icon:e,children:r}){return U("div",{className:"zkp-step","data-status":t,"data-mode":e?"icon":"progress",children:[U("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:e??os}}),U("div",{className:"zkp-step-text",children:r})]})}function kB({requestUrl:t,inAppBrowser:e,onRevealQr:r}){let{openState:i,openApp:n}=yS(t,{probe:!e}),o=i==="opening";return i==="opened"?U("div",{className:"zkp-open-app-hero","data-state":i,children:[U("p",{className:"zkp-inapp-hint",role:"status",children:"Check your phone \u2014 approve the request in the ZKPassport app."}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:n,children:"Open the app again"}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:r,children:"Scan a QR code with another device instead"})]}):U("div",{className:"zkp-open-app-hero","data-state":i,children:[t?U("button",{type:"button",className:"zkp-open-app zkp-open-app-block",disabled:o,onClick:n,children:[o?U("span",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:du}}):null,o?"Opening\u2026":"Open ZKPassport App"]}):U("div",{className:"zkp-open-app-loading",role:"status","aria-label":"Preparing request",children:U("span",{className:"zkp-skel-row",style:{width:"100%",height:"48px"}})}),e?U("p",{className:"zkp-inapp-hint",children:"If nothing opens, open this page in your browser and try again."}):null,U(PB,{requestUrl:t,appNotFound:i==="nothing-opened"}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:r,children:"Scan a QR code with another device instead"})]})}function PB({requestUrl:t,appNotFound:e}){let r=Cm();return U("div",{className:"zkp-install",children:[U("p",{className:"zkp-install-title",role:e?"status":void 0,children:e?"App not found":"Don\u2019t have the app yet?"}),U("p",{className:"zkp-install-note",children:e?"Install the ZKPassport app, then tap Open again. It reads the chip in your passport or ID card, and that data never leaves your phone.":"Verification happens in the ZKPassport app: it reads the chip in your passport or ID card, and that data never leaves your phone. Free on iOS and Android."}),U("div",{className:"zkp-store-buttons zkp-install-stores",children:[r!=="android"?U($d,{href:Jc,badge:uu}):null,r!=="ios"?U($d,{href:_m(t),badge:fu}):null]})]})}function $d({href:t,badge:e}){return U("a",{className:"zkp-store-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":e.ariaLabel,dangerouslySetInnerHTML:{__html:e.svg}})}function NB(){e1(Im,"card");}var CS=`@layer zkpassport {
|
|
1030
|
+
`,o=[`-----BEGIN ${t}-----`];if(r.headers){for(let[s,a]of Object.entries(r.headers))o.push(`${s}: ${a}`);o.push("");}return o.push(...Gw(hn.encode(e),i)),o.push(`-----END ${t}-----`),`${o.join(n)}${n}`}function N3(t,e={}){return P3(t,e).map(({lineLength:r,newline:i,...n})=>n)}function R3(t,e){let[r]=N3(t,{label:e,strict:true});return r.data}function D3(t,e={}){let[r]=P3(t,{...e,strict:true}),i={label:r.label,headers:r.headers,lineLength:r.lineLength,newline:r.newline};return {bytes:r.data,format:i,normalized:dl(r.label,r.data,i)}}function O3(t,e){return dl(e.label,t,e)}var m0={name:"pem",encode:(t,e)=>{if(!e?.label)throw new TypeError("PEM label is required");return dl(e.label,t,e)},decode:(t,e)=>R3(t,e?.label),format:O3,is:t=>typeof t=="string"&&/-----BEGIN [^-]+-----/.test(t),parse:D3};function Xr(t){return t.trim().toLowerCase()}function jw(t){return t instanceof Error?t:new Error(String(t))}function M3(t,e,r){for(let i of [r.name,...r.aliases??[]])t.delete(Xr(i));e.delete(Xr(r.name));}function Pf(t,e,r){let i=t[r];if(typeof i!="function")throw new Error(`Converter '${e}' does not support ${r}()`);return i}function Xw(t,e,r){let i=Xr(r.name||t),n=e.trim();if(!n)return 0;let o=false;r.is&&(o=r.is(e));let s=false;try{r.decode(e),s=!0;}catch{s=false;}if(!o&&!s)return 0;switch(i){case "pem":return /-----BEGIN [^-]+-----/.test(e)?1:0;case "hex":{let a=n.replace(/^0x/i,"").replace(/[\s:.-]/g,"");return !a||/[^0-9a-f]/i.test(a)||a.length%2!==0?0:/^0x/i.test(n)||/[:\s.-]/.test(n)?.95:/[a-f]/.test(n)||/[A-F]/.test(n)?.8:.45}case "base64url":return /[-_]/.test(n)?.95:/=/.test(n)?.1:.6;case "base64":return /[+/=]/.test(n)?.9:.55;case "binary":case "utf8":case "utf16be":case "utf16le":return 0;default:return o&&s?.75:.5}}function Nf(t=[]){let e=new Map,r=new Set,i={register(n,o={}){if(!n.name||!Xr(n.name))throw new TypeError("Converter name is required");let s=[...new Set([n.name,...n.aliases??[]].map(Xr))],a=new Set;for(let c of s){let l=e.get(c);if(l){if(!o.override)throw new Error(`Converter '${c}' is already registered`);a.add(l);}}for(let c of a)M3(e,r,c);for(let c of s)e.set(c,n);return r.add(Xr(n.name)),this},unregister(n){let o=e.get(Xr(n));return o?(M3(e,r,o),true):false},has(n){return e.has(Xr(n))},get(n){let o=e.get(Xr(n));if(!o)throw new Error(`Converter '${n}' is not registered`);return o},list(){return [...r].map(n=>this.get(n))},encode(n,o,s){return this.get(n).encode(o,s)},decode(n,o,s){return this.get(n).decode(o,s)},tryDecode(n,o,s){try{return {ok:!0,bytes:this.decode(n,o,s)}}catch(a){return {ok:false,error:jw(a)}}},normalize(n,o,s){let a=this.get(n);return Pf(a,n,"normalize").call(a,o,s)},parse(n,o,s){let a=this.get(n);return Pf(a,n,"parse").call(a,o,s)},format(n,o,s){let a=this.get(n);return Pf(a,n,"format").call(a,o,s)},transcode(n,o){let s=this.decode(o.from,n,o.fromOptions);return this.encode(o.to,s,o.toOptions)},detect(n,o={}){let s=o.formats?.length?o.formats.map(c=>String(c)):this.list().map(c=>c.name).filter(c=>!["binary","utf8","utf16be","utf16le"].includes(Xr(c))),a=new Map;for(let c of s){let l=this.get(c),d=Xw(c,n,l);if(d<=0)continue;let u=l.name,h=a.get(u);(!h||d>h.confidence)&&a.set(u,{format:u,confidence:d});}return [...a.values()].sort((c,l)=>l.confidence-c.confidence)}};for(let n of t)i.register(n);return i}var U3={name:"binary",aliases:["latin1"],encode:vi.encode,decode:vi.decode,is:vi.is},F3={name:"hex",encode:tt.encode,decode:tt.decode,format:tt.format,is:tt.is,normalize:tt.normalize,parse:tt.parse},L3={name:"base64",aliases:["b64"],encode:er.encode,decode:er.decode,is:er.is,normalize:er.normalize},H3={name:"base64url",aliases:["base64-url","b64url"],encode:Er.encode,decode:Er.decode,is:Er.is,normalize:Er.normalize},K3={name:"utf8",aliases:["utf-8"],encode:t=>pn.decode(t),decode:t=>pn.encode(t),is:t=>typeof t=="string"},z3={name:"utf16be",aliases:["utf16","utf-16","utf-16be"],encode:t=>jr.decode(t),decode:t=>jr.encode(t),is:t=>typeof t=="string"},q3={name:"utf16le",aliases:["utf-16le","ucs2","usc2"],encode:t=>jr.decode(t,{littleEndian:true}),decode:t=>jr.encode(t,{littleEndian:true}),is:t=>typeof t=="string"},G3=[U3,F3,L3,H3,K3,z3,q3,m0];Nf(G3);({toBase64:er.encode,toBase64Url:Er.encode,toHex:tt.encode,toBinary:vi.encode,toUtf8String:pn.decode,isHex:tt.is,isBase64:er.is,isBase64Url:Er.is,formatString:er.normalize});var B;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice";})(B||(B={}));var S;(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",t[t.RelativeObjectIdentifier=28]="RelativeObjectIdentifier";})(S||(S={}));var Ei=class{constructor(e,r=0){f(this,"unusedBits",0);f(this,"value",new ArrayBuffer(0));if(e)if(typeof e=="number")this.fromNumber(e);else if(Vr(e))this.unusedBits=r,this.value=we(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof vr))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=we(e.valueBlock.valueHex),this}toASN(){return new vr({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new vr({name:e})}toNumber(){let e="",r=new Uint8Array(this.value);for(let i of r)e+=i.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),i=r.length+7>>3;this.unusedBits=(i<<3)-r.length;let n=new Uint8Array(i);r=r.padStart(i<<3,"0").split("").reverse().join("");let o=0;for(;o<i;)n[o]=parseInt(r.slice(o<<3,(o<<3)+8),2),o++;this.value=n.buffer;}};var ce=class{constructor(e){f(this,"buffer");typeof e=="number"?this.buffer=new ArrayBuffer(e):Vr(e)?this.buffer=we(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0);}get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}fromASN(e){if(!(e instanceof Ir))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=we(e.valueBlock.valueHex),this}toASN(){return new Ir({valueHex:this.buffer})}toSchema(e){return new Ir({name:e})}};var r_={fromASN:t=>t instanceof Cr?null:we(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new Cr;let e=Ii(t);if(e.result.error)throw new Error(e.result.error);return e.result}},i_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new _i({value:+t})},n_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new io({value:t})},he={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new _i({valueHex:t})};var o_={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new vr({valueHex:t})},s_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new no({value:t})},a_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new oo({value:t})},c_={fromASN:t=>t.valueBlock.value,toASN:t=>new ro({value:t})},_s={fromASN:t=>we(t.valueBlock.valueHexView),toASN:t=>new Ir({valueHex:t})},V3={fromASN:t=>new ce(t.getValue()),toASN:t=>t.toASN()};function tr(t){return {fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}var l_=tr(Jt),d_=tr(so),u_=tr(ao),f_=tr(co),p_=tr(lo),h_=tr(uo),m_=tr(fo),g_=tr(po),y_=tr(ho),b_=tr(un),S_=tr(mo),x_=tr(go),A_={fromASN:t=>t.toDate(),toASN:t=>new fn({valueDate:t})},w_={fromASN:t=>t.toDate(),toASN:t=>new yo({valueDate:t})},__={fromASN:()=>null,toASN:()=>new Cr};function mn(t){switch(t){case S.Any:return r_;case S.BitString:return o_;case S.BmpString:return d_;case S.Boolean:return c_;case S.CharacterString:return x_;case S.Enumerated:return n_;case S.GeneralString:return S_;case S.GeneralizedTime:return w_;case S.GraphicString:return y_;case S.IA5String:return g_;case S.Integer:return i_;case S.Null:return __;case S.NumericString:return f_;case S.ObjectIdentifier:return s_;case S.RelativeObjectIdentifier:return a_;case S.OctetString:return _s;case S.PrintableString:return p_;case S.TeletexString:return h_;case S.UTCTime:return A_;case S.UniversalString:return u_;case S.Utf8String:return l_;case S.VideotexString:return m_;case S.VisibleString:return b_;default:return null}}function rr(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?true:rr(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Mf(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?true:Mf(e)}return false}function j3(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return false;let r=new Uint8Array(t),i=new Uint8Array(e);for(let n=0;n<t.byteLength;n++)if(r[n]!==i[n])return false;return true}var ul=class{constructor(){f(this,"items",new WeakMap);}has(e){return this.items.has(e)}get(e,r=false){let i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(r&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){let r=this.get(e);r.schema||(r.schema=this.create(e,true));}createDefault(e){let r={type:B.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(r,i),r.items=Object.assign({},r.items,i.items)),r}create(e,r){let i=this.items.get(e)||this.createDefault(e),n=[];for(let o in i.items){let s=i.items[o],a=r?o:"",c;if(typeof s.type=="number"){let d=S[s.type],u=$r[d];if(!u)throw new Error(`Cannot get ASN1 class by name '${d}'`);c=new u({name:a});}else rr(s.type)?c=new s.type().toSchema(a):s.optional?this.get(s.type).type===B.Choice?c=new zr({name:a}):(c=this.create(s.type,false),c.name=a):c=new zr({name:a});let l=!!s.optional||s.defaultValue!==void 0;if(s.repeated){c.name="";let d=s.repeated==="set"?bt:ft;c=new d({name:"",value:[new bo({name:a,value:c})]});}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||rr(s.type)){let d=s.repeated?$e:wi;n.push(new d({name:a,optional:l,idBlock:{tagClass:3,tagNumber:s.context}}));}else {this.cache(s.type);let d=!!s.repeated,u=d?c:this.get(s.type,true).schema;u="valueBlock"in u?u.valueBlock.value:u.value,n.push(new $e({name:d?"":a,optional:l,idBlock:{tagClass:3,tagNumber:s.context},value:u}));}else n.push(new $e({optional:l,idBlock:{tagClass:3,tagNumber:s.context},value:[c]}));else c.optional=l,n.push(c);}switch(i.type){case B.Sequence:return new ft({value:n,name:""});case B.Set:return new bt({value:n,name:""});case B.Choice:return new ws({value:n,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}};var Ve=new ul;var N=t=>e=>{let r;Ve.has(e)?r=Ve.get(e):(r=Ve.createDefault(e),Ve.set(e,r)),Object.assign(r,t);};var g=t=>(e,r)=>{let i;Ve.has(e.constructor)?i=Ve.get(e.constructor):(i=Ve.createDefault(e.constructor),Ve.set(e.constructor,i));let n=Object.assign({},t);if(typeof n.type=="number"&&!n.converter){let o=mn(t.type);if(!o)throw new Error(`Cannot get default converter for property '${r}' of ${e.constructor.name}`);n.converter=o;}n.raw=t.raw,i.items[r]=n;};var gn=class extends Error{constructor(){super(...arguments);f(this,"schemas",[]);}};var Cs=class{static parse(e,r,i){let n=Ii(we(e),i?.berOptions);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,r,i)}static fromASN(e,r,i){try{if(rr(r))return new r().fromASN(e);let n=Ve.get(r);Ve.cache(r);let o=n.schema,s=this.handleChoiceTypes(e,n,r,o,i);if(s?.result)return s.result;s?.targetSchema&&(o=s.targetSchema);let a=this.handleSequenceTypes(e,n,r,o),c=new r;return Mf(r)?this.handleArrayTypes(e,n,r,i):(this.processSchemaItems(n,a,c,i),c)}catch(n){throw n instanceof gn&&n.schemas.push(r.name),n}}static handleChoiceTypes(e,r,i,n,o){if(e.constructor===$e&&r.type===B.Choice&&e.idBlock.tagClass===3)for(let s in r.items){let a=r.items[s];if(a.context===e.idBlock.tagNumber&&a.implicit&&typeof a.type=="function"&&Ve.has(a.type)){let c=Ve.get(a.type);if(c&&c.type===B.Sequence){let l=new ft;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in l.valueBlock){l.valueBlock.value=e.valueBlock.value;let d=this.fromASN(l,a.type,o),u=new i;return u[s]=d,{result:u}}}}}else if(e.constructor===$e&&r.type!==B.Choice){let s=new $e({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(let a in r.items)delete e[a];return {targetSchema:s}}return null}static handleSequenceTypes(e,r,i,n){if(r.type===B.Sequence){let o=xi({},e,n);if(!o.verified)throw new gn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else {let o=xi({},e,n);if(!o.verified)throw new gn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}}static processRepeatedField(e,r,i){let n=e.slice(r);if(n.length===1&&n[0].constructor.name==="Sequence"){let o=n[0];o.valueBlock&&o.valueBlock.value&&Array.isArray(o.valueBlock.value)&&(n=o.valueBlock.value);}if(typeof i.type=="number"){let o=mn(i.type);if(!o)throw new Error(`No converter for ASN.1 type ${i.type}`);return n.filter(s=>s&&s.valueBlock).map(s=>{try{return o.fromASN(s)}catch{return}}).filter(s=>s!==void 0)}else return n.filter(o=>o&&o.valueBlock).map(o=>{try{return this.fromASN(o,i.type)}catch{return}}).filter(o=>o!==void 0)}static processPrimitiveField(e,r){let i=mn(r.type);if(!i)throw new Error(`No converter for ASN.1 type ${r.type}`);return i.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Ve.has(e.type)&&Ve.get(e.type).type===B.Choice}static processOptionalChoiceField(e,r){try{return {processed:!0,value:this.fromASN(e,r.type)}}catch(i){if(i instanceof gn&&/Wrong values for Choice type/.test(i.message))return {processed:false};throw i}}static handleArrayTypes(e,r,i,n){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 o=r.itemType;if(typeof o=="number"){let s=mn(o);if(!s)throw new Error(`Cannot get default converter for array item of ${i.name} ASN1 schema`);return i.from(e.valueBlock.value,a=>s.fromASN(a))}else return i.from(e.valueBlock.value,s=>this.fromASN(s,o,n))}static processSchemaItems(e,r,i,n){for(let o in e.items){let s=r.result[o];if(!s)continue;let a=e.items[o],c=a.type,l;typeof c=="number"||rr(c)?l=this.processPrimitiveSchemaItem(s,a,c,n):l=this.processComplexSchemaItem(s,a,c,n),l&&typeof l=="object"&&"value"in l&&"raw"in l?(i[o]=l.value,i[`${o}Raw`]=l.raw):i[o]=l;}}static processPrimitiveSchemaItem(e,r,i,n){let o=r.converter??(rr(i)?new i:null);if(!o)throw new Error("Converter is empty");return r.repeated?this.processRepeatedPrimitiveItem(e,r,o,n):this.processSinglePrimitiveItem(e,r,i,o,n)}static processRepeatedPrimitiveItem(e,r,i,n){if(r.implicit){let o=r.repeated==="sequence"?ft:bt,s=new o;s.valueBlock=e.valueBlock;let a=Ii(s.toBER(false),n?.berOptions);if(a.offset===-1)throw new Error(`Cannot parse the child item. ${a.result.error}`);if(!("value"in a.result.valueBlock&&Array.isArray(a.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let c=a.result.valueBlock.value;return Array.from(c,l=>i.fromASN(l))}else return Array.from(e,o=>i.fromASN(o))}static processSinglePrimitiveItem(e,r,i,n,o){let s=e;if(r.implicit){let a;if(rr(i))a=new i().toSchema("");else {let c=S[i],l=$r[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);a=new l;}a.valueBlock=s.valueBlock,s=Ii(a.toBER(false),o?.berOptions).result;}return n.fromASN(s)}static processComplexSchemaItem(e,r,i,n){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,o=>this.fromASN(o,i,n))}else {let o=this.handleImplicitTagging(e,r,i);if(this.isOptionalChoiceField(r))try{return this.fromASN(o,i,n)}catch(s){if(s instanceof gn&&/Wrong values for Choice type/.test(s.message))return;throw s}else {let s=this.fromASN(o,i,n);return r.raw?{value:s,raw:e.valueBeforeDecodeView}:s}}}static handleImplicitTagging(e,r,i){if(r.implicit&&typeof r.context=="number"){let n=Ve.get(i);if(n.type===B.Sequence){let o=new ft;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}else if(n.type===B.Set){let o=new bt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in o.valueBlock)return o.valueBlock.value=e.valueBlock.value,o}}return e}};var Is=class t{static serialize(e){return e instanceof Ke?e.toBER(false):this.toASN(e).toBER(false)}static toASN(e){if(e&&typeof e=="object"&&rr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let r=e.constructor,i=Ve.get(r);Ve.cache(r);let n=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){let s=mn(i.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);n=e.map(a=>s.toASN(a));}else n=e.map(s=>this.toAsnItem({type:i.itemType},"[]",r,s));}else for(let s in i.items){let a=i.items[s],c=e[s];if(c===void 0||a.defaultValue===c||typeof a.defaultValue=="object"&&typeof c=="object"&&j3(this.serialize(a.defaultValue),this.serialize(c)))continue;let l=t.toAsnItem(a,s,r,c);if(typeof a.context=="number")if(a.implicit)if(!a.repeated&&(typeof a.type=="number"||rr(a.type))){let d={};d.valueHex=l instanceof Cr?we(l.valueBeforeDecodeView):l.valueBlock.toBER(),n.push(new wi({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...d}));}else n.push(new $e({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:l.valueBlock.value}));else n.push(new $e({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else a.repeated?n=n.concat(l):n.push(l);}let o;switch(i.type){case B.Sequence:o=new ft({value:n});break;case B.Set:o=new bt({value:n});break;case B.Choice:if(!n[0])throw new Error(`Schema '${r.name}' has wrong data. Choice cannot be empty.`);o=n[0];break}return o}static toAsnItem(e,r,i,n){let o;if(typeof e.type=="number"){let s=e.converter;if(!s)throw new Error(`Property '${r}' doesn't have converter for type ${S[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(n,l=>s.toASN(l)),c=e.repeated==="sequence"?ft:bt;o=new c({value:a});}else o=s.toASN(n);}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");let s=Array.from(n,c=>this.toASN(c)),a=e.repeated==="sequence"?ft:bt;o=new a({value:s});}else o=this.toASN(n);return o}};var ie=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else {super();for(let r of e)this.push(r);}}};var ir=class t{static serialize(e){return Is.serialize(e)}static parse(e,r,i){return Cs.parse(e,r,i)}static toString(e,r){let i=Vr(e)?we(e):t.serialize(e),n=Ii(i,r?.berOptions);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function p(t,e,r,i){var n=arguments.length,o=n<3?e:i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,r,o):s(e,r))||o);return n>3&&o&&Object.defineProperty(e,r,o),o}var g0=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(i=>{let n=parseInt(i,10);if(isNaN(n)||n<0||n>255)throw new Error("Invalid IPv4 address part");return n})}static parseIPv6(e){let i=this.expandIPv6(e).split(":");if(i.length!==8)throw new Error("Invalid IPv6 address");return i.reduce((n,o)=>{let s=parseInt(o,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return n.push(s>>8&255),n.push(s&255),n},[])}static expandIPv6(e){if(!e.includes("::"))return e;let r=e.split("::");if(r.length>2)throw new Error("Invalid IPv6 address");let i=r[0]?r[0].split(":"):[],n=r[1]?r[1].split(":"):[],o=8-(i.length+n.length);if(o<0)throw new Error("Invalid IPv6 address");return [...i,...Array(o).fill("0"),...n].join(":")}static formatIPv6(e){let r=[];for(let i=0;i<16;i+=2)r.push((e[i]<<8|e[i+1]).toString(16));return this.compressIPv6(r.join(":"))}static compressIPv6(e){let r=e.split(":"),i=-1,n=0,o=-1,s=0;for(let a=0;a<r.length;a++)r[a]==="0"?(o===-1&&(o=a),s++):(s>n&&(i=o,n=s),o=-1,s=0);if(s>n&&(i=o,n=s),n>1){let a=r.slice(0,i).join(":"),c=r.slice(i+n).join(":");return `${a}::${c}`}return e}static parseCIDR(e){let[r,i]=e.split("/"),n=parseInt(i,10);if(this.isIPv4(r)){if(n<0||n>32)throw new Error("Invalid IPv4 prefix length");return [this.parseIPv4(r),n]}else {if(n<0||n>128)throw new Error("Invalid IPv6 prefix length");return [this.parseIPv6(r),n]}}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((n,o)=>n+ +o,0),i=e.slice(0,8).replace(/(.{2})/g,n=>`${parseInt(n,16)}.`);return i=i.slice(0,-1),`${i}/${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 i=r.length/2,n=r.slice(0,i),o=r.slice(i);if(r.every(c=>c===0))return r.length===8?"0.0.0.0/0":"::/0";let a=o.reduce((c,l)=>c+(l.toString(2).match(/1/g)||[]).length,0);return r.length===8?`${Array.from(n).join(".")}/${a}`:`${this.formatIPv6(n)}/${a}`}return this.decodeIP(tt.encode(e))}static fromString(e){if(e.includes("/")){let[i,n]=this.parseCIDR(e),o=new Uint8Array(i.length),s=n;for(let c=0;c<o.length;c++)s>=8?(o[c]=255,s-=8):s>0&&(o[c]=255<<8-s,s=0);let a=new Uint8Array(i.length*2);return a.set(i,0),a.set(o,i.length),a.buffer}let r=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(r).buffer}};var Uf,Ff,Lf,nr=class{constructor(e={}){f(this,"teletexString");f(this,"printableString");f(this,"universalString");f(this,"utf8String");f(this,"bmpString");Object.assign(this,e);}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};p([g({type:S.TeletexString})],nr.prototype,"teletexString",void 0);p([g({type:S.PrintableString})],nr.prototype,"printableString",void 0);p([g({type:S.UniversalString})],nr.prototype,"universalString",void 0);p([g({type:S.Utf8String})],nr.prototype,"utf8String",void 0);p([g({type:S.BmpString})],nr.prototype,"bmpString",void 0);nr=p([N({type:B.Choice})],nr);var vs=class extends nr{constructor(r={}){super(r);f(this,"ia5String");f(this,"anyValue");Object.assign(this,r);}toString(){return this.ia5String||(this.anyValue?tt.encode(this.anyValue):super.toString())}};p([g({type:S.IA5String})],vs.prototype,"ia5String",void 0);p([g({type:S.Any})],vs.prototype,"anyValue",void 0);vs=p([N({type:B.Choice})],vs);var y0=class{constructor(e={}){f(this,"type","");f(this,"value",new vs);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],y0.prototype,"type",void 0);p([g({type:vs})],y0.prototype,"value",void 0);var b0=Uf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Uf.prototype);}};b0=Uf=p([N({type:B.Set,itemType:y0})],b0);var Hf=Ff=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ff.prototype);}};Hf=Ff=p([N({type:B.Sequence,itemType:b0})],Hf);var xt=Lf=class extends Hf{constructor(e){super(e),Object.setPrototypeOf(this,Lf.prototype);}};xt=Lf=p([N({type:B.Sequence})],xt);var C_={fromASN:t=>g0.toString(_s.fromASN(t)),toASN:t=>_s.toASN(g0.fromString(t))},S0=class{constructor(e={}){f(this,"typeId","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],S0.prototype,"typeId",void 0);p([g({type:S.Any,context:0})],S0.prototype,"value",void 0);var x0=class{constructor(e={}){f(this,"nameAssigner");f(this,"partyName",new nr);Object.assign(this,e);}};p([g({type:nr,optional:true,context:0,implicit:true})],x0.prototype,"nameAssigner",void 0);p([g({type:nr,context:1,implicit:true})],x0.prototype,"partyName",void 0);var ue=class{constructor(e={}){f(this,"otherName");f(this,"rfc822Name");f(this,"dNSName");f(this,"x400Address");f(this,"directoryName");f(this,"ediPartyName");f(this,"uniformResourceIdentifier");f(this,"iPAddress");f(this,"registeredID");Object.assign(this,e);}};p([g({type:S0,context:0,implicit:true})],ue.prototype,"otherName",void 0);p([g({type:S.IA5String,context:1,implicit:true})],ue.prototype,"rfc822Name",void 0);p([g({type:S.IA5String,context:2,implicit:true})],ue.prototype,"dNSName",void 0);p([g({type:S.Any,context:3,implicit:true})],ue.prototype,"x400Address",void 0);p([g({type:xt,context:4,implicit:false})],ue.prototype,"directoryName",void 0);p([g({type:x0,context:5})],ue.prototype,"ediPartyName",void 0);p([g({type:S.IA5String,context:6,implicit:true})],ue.prototype,"uniformResourceIdentifier",void 0);p([g({type:S.OctetString,context:7,implicit:true,converter:C_})],ue.prototype,"iPAddress",void 0);p([g({type:S.ObjectIdentifier,context:8,implicit:true})],ue.prototype,"registeredID",void 0);ue=p([N({type:B.Choice})],ue);var Kf,xo=class{constructor(e={}){f(this,"accessMethod","");f(this,"accessLocation",new ue);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],xo.prototype,"accessMethod",void 0);p([g({type:ue})],xo.prototype,"accessLocation",void 0);var W3=Kf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Kf.prototype);}};W3=Kf=p([N({type:B.Sequence,itemType:xo})],W3);var A0=class extends ce{},Es=class{constructor(e={}){f(this,"keyIdentifier");f(this,"authorityCertIssuer");f(this,"authorityCertSerialNumber");e&&Object.assign(this,e);}};p([g({type:A0,context:0,optional:true,implicit:true})],Es.prototype,"keyIdentifier",void 0);p([g({type:ue,context:1,optional:true,implicit:true,repeated:"sequence"})],Es.prototype,"authorityCertIssuer",void 0);p([g({type:S.Integer,context:2,optional:true,implicit:true,converter:he})],Es.prototype,"authorityCertSerialNumber",void 0);var pl=class{constructor(e={}){f(this,"cA",false);f(this,"pathLenConstraint");Object.assign(this,e);}};p([g({type:S.Boolean,defaultValue:false})],pl.prototype,"cA",void 0);p([g({type:S.Integer,optional:true})],pl.prototype,"pathLenConstraint",void 0);var zf,Xe=zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,zf.prototype);}};Xe=zf=p([N({type:B.Sequence,itemType:ue})],Xe);var qf,Z3=qf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,qf.prototype);}};Z3=qf=p([N({type:B.Sequence})],Z3);var Gf,Bi=class{constructor(e={}){f(this,"ia5String");f(this,"visibleString");f(this,"bmpString");f(this,"utf8String");Object.assign(this,e);}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};p([g({type:S.IA5String})],Bi.prototype,"ia5String",void 0);p([g({type:S.VisibleString})],Bi.prototype,"visibleString",void 0);p([g({type:S.BmpString})],Bi.prototype,"bmpString",void 0);p([g({type:S.Utf8String})],Bi.prototype,"utf8String",void 0);Bi=p([N({type:B.Choice})],Bi);var w0=class{constructor(e={}){f(this,"organization",new Bi);f(this,"noticeNumbers",[]);Object.assign(this,e);}};p([g({type:Bi})],w0.prototype,"organization",void 0);p([g({type:S.Integer,repeated:"sequence"})],w0.prototype,"noticeNumbers",void 0);var _0=class{constructor(e={}){f(this,"noticeRef");f(this,"explicitText");Object.assign(this,e);}};p([g({type:w0,optional:true})],_0.prototype,"noticeRef",void 0);p([g({type:Bi,optional:true})],_0.prototype,"explicitText",void 0);var hl=class{constructor(e={}){f(this,"cPSuri");f(this,"userNotice");Object.assign(this,e);}};p([g({type:S.IA5String})],hl.prototype,"cPSuri",void 0);p([g({type:_0})],hl.prototype,"userNotice",void 0);hl=p([N({type:B.Choice})],hl);var C0=class{constructor(e={}){f(this,"policyQualifierId","");f(this,"qualifier",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],C0.prototype,"policyQualifierId",void 0);p([g({type:S.Any})],C0.prototype,"qualifier",void 0);var I0=class{constructor(e={}){f(this,"policyIdentifier","");f(this,"policyQualifiers");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],I0.prototype,"policyIdentifier",void 0);p([g({type:C0,repeated:"sequence",optional:true})],I0.prototype,"policyQualifiers",void 0);var Y3=Gf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Gf.prototype);}};Y3=Gf=p([N({type:B.Sequence,itemType:I0})],Y3);var v0=class{constructor(e=0){f(this,"value");this.value=e;}};p([g({type:S.Integer})],v0.prototype,"value",void 0);v0=p([N({type:B.Choice})],v0);var Q3=class extends v0{};Q3=p([N({type:B.Choice})],Q3);var $f,Br;(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";})(Br||(Br={}));var E0=class extends Ei{toJSON(){let e=[],r=this.toNumber();return r&Br.aACompromise&&e.push("aACompromise"),r&Br.affiliationChanged&&e.push("affiliationChanged"),r&Br.cACompromise&&e.push("cACompromise"),r&Br.certificateHold&&e.push("certificateHold"),r&Br.cessationOfOperation&&e.push("cessationOfOperation"),r&Br.keyCompromise&&e.push("keyCompromise"),r&Br.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Br.superseded&&e.push("superseded"),r&Br.unused&&e.push("unused"),e}toString(){return `[${this.toJSON().join(", ")}]`}},Ao=class{constructor(e={}){f(this,"fullName");f(this,"nameRelativeToCRLIssuer");Object.assign(this,e);}};p([g({type:ue,context:0,repeated:"sequence",implicit:true})],Ao.prototype,"fullName",void 0);p([g({type:b0,context:1,implicit:true})],Ao.prototype,"nameRelativeToCRLIssuer",void 0);Ao=p([N({type:B.Choice})],Ao);var Sn=class{constructor(e={}){f(this,"distributionPoint");f(this,"reasons");f(this,"cRLIssuer");Object.assign(this,e);}};p([g({type:Ao,context:0,optional:true})],Sn.prototype,"distributionPoint",void 0);p([g({type:E0,context:1,optional:true,implicit:true})],Sn.prototype,"reasons",void 0);p([g({type:ue,context:2,optional:true,repeated:"sequence",implicit:true})],Sn.prototype,"cRLIssuer",void 0);var ml=$f=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,$f.prototype);}};ml=$f=p([N({type:B.Sequence,itemType:Sn})],ml);var Vf,J3=Vf=class extends ml{constructor(e){super(e),Object.setPrototypeOf(this,Vf.prototype);}};J3=Vf=p([N({type:B.Sequence,itemType:Sn})],J3);var wo=class wo{constructor(e={}){f(this,"distributionPoint");f(this,"onlyContainsUserCerts",wo.ONLY);f(this,"onlyContainsCACerts",wo.ONLY);f(this,"onlySomeReasons");f(this,"indirectCRL",wo.ONLY);f(this,"onlyContainsAttributeCerts",wo.ONLY);Object.assign(this,e);}};f(wo,"ONLY",false);var or=wo;p([g({type:Ao,context:0,optional:true})],or.prototype,"distributionPoint",void 0);p([g({type:S.Boolean,context:1,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsUserCerts",void 0);p([g({type:S.Boolean,context:2,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsCACerts",void 0);p([g({type:E0,context:3,optional:true,implicit:true})],or.prototype,"onlySomeReasons",void 0);p([g({type:S.Boolean,context:4,defaultValue:or.ONLY,implicit:true})],or.prototype,"indirectCRL",void 0);p([g({type:S.Boolean,context:5,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsAttributeCerts",void 0);var B0;(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";})(B0||(B0={}));var jf=class{constructor(e=B0.unspecified){f(this,"reason",B0.unspecified);this.reason=e;}toJSON(){return B0[this.reason]}toString(){return this.toJSON()}};p([g({type:S.Enumerated})],jf.prototype,"reason",void 0);jf=p([N({type:B.Choice})],jf);var Xf,e4=Xf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Xf.prototype);}};e4=Xf=p([N({type:B.Sequence,itemType:S.ObjectIdentifier})],e4);var Wf=class{constructor(e=new ArrayBuffer(0)){f(this,"value");this.value=e;}};p([g({type:S.Integer,converter:he})],Wf.prototype,"value",void 0);Wf=p([N({type:B.Choice})],Wf);var Zf=class{constructor(e){f(this,"value",new Date);e&&(this.value=e);}};p([g({type:S.GeneralizedTime})],Zf.prototype,"value",void 0);Zf=p([N({type:B.Choice})],Zf);var Yf,t4=Yf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Yf.prototype);}};t4=Yf=p([N({type:B.Sequence})],t4);var r4;(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";})(r4||(r4={}));var Qf,Bs=class{constructor(e={}){f(this,"base",new ue);f(this,"minimum",0);f(this,"maximum");Object.assign(this,e);}};p([g({type:ue})],Bs.prototype,"base",void 0);p([g({type:S.Integer,context:0,defaultValue:0,implicit:true})],Bs.prototype,"minimum",void 0);p([g({type:S.Integer,context:1,optional:true,implicit:true})],Bs.prototype,"maximum",void 0);var gl=Qf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Qf.prototype);}};gl=Qf=p([N({type:B.Sequence,itemType:Bs})],gl);var yl=class{constructor(e={}){f(this,"permittedSubtrees");f(this,"excludedSubtrees");Object.assign(this,e);}};p([g({type:gl,context:0,optional:true,implicit:true})],yl.prototype,"permittedSubtrees",void 0);p([g({type:gl,context:1,optional:true,implicit:true})],yl.prototype,"excludedSubtrees",void 0);var bl=class{constructor(e={}){f(this,"requireExplicitPolicy");f(this,"inhibitPolicyMapping");Object.assign(this,e);}};p([g({type:S.Integer,context:0,implicit:true,optional:true,converter:he})],bl.prototype,"requireExplicitPolicy",void 0);p([g({type:S.Integer,context:1,implicit:true,optional:true,converter:he})],bl.prototype,"inhibitPolicyMapping",void 0);var Jf,T0=class{constructor(e={}){f(this,"issuerDomainPolicy","");f(this,"subjectDomainPolicy","");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],T0.prototype,"issuerDomainPolicy",void 0);p([g({type:S.ObjectIdentifier})],T0.prototype,"subjectDomainPolicy",void 0);var i4=Jf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Jf.prototype);}};i4=Jf=p([N({type:B.Sequence,itemType:T0})],i4);var ep,n4=ep=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,ep.prototype);}};n4=ep=p([N({type:B.Sequence})],n4);var Zr=class{constructor(e={}){f(this,"type","");f(this,"values",[]);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Zr.prototype,"type",void 0);p([g({type:S.Any,repeated:"set"})],Zr.prototype,"values",void 0);var tp,o4=tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,tp.prototype);}};o4=tp=p([N({type:B.Sequence,itemType:Zr})],o4);var Tr=class extends A0{};var k0=class{constructor(e={}){f(this,"notBefore");f(this,"notAfter");Object.assign(this,e);}};p([g({type:S.GeneralizedTime,context:0,implicit:true,optional:true})],k0.prototype,"notBefore",void 0);p([g({type:S.GeneralizedTime,context:1,implicit:true,optional:true})],k0.prototype,"notAfter",void 0);var P0;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate";})(P0||(P0={}));var Sl=class extends Ei{toJSON(){let e=[],r=this.toNumber();return r&P0.pKIXCertificate&&e.push("pKIXCertificate"),r&P0.newExtensions&&e.push("newExtensions"),r&P0.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return `[${this.toJSON().join(", ")}]`}},xl=class{constructor(e={}){f(this,"entrustVers","");f(this,"entrustInfoFlags",new Sl);Object.assign(this,e);}};p([g({type:S.GeneralString})],xl.prototype,"entrustVers",void 0);p([g({type:Sl})],xl.prototype,"entrustInfoFlags",void 0);var rp,s4=rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,rp.prototype);}};s4=rp=p([N({type:B.Sequence,itemType:xo})],s4);var J=class t{constructor(e={}){f(this,"algorithm","");f(this,"parameters");Object.assign(this,e);}isEqual(e){return e instanceof t&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&p0(e.parameters,this.parameters)||e.parameters===this.parameters)}};p([g({type:S.ObjectIdentifier})],J.prototype,"algorithm",void 0);p([g({type:S.Any,optional:true})],J.prototype,"parameters",void 0);var _o=class{constructor(e={}){f(this,"algorithm",new J);f(this,"subjectPublicKey",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:J})],_o.prototype,"algorithm",void 0);p([g({type:S.BitString})],_o.prototype,"subjectPublicKey",void 0);var je=class{constructor(e){f(this,"utcTime");f(this,"generalTime");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}};p([g({type:S.UTCTime})],je.prototype,"utcTime",void 0);p([g({type:S.GeneralizedTime})],je.prototype,"generalTime",void 0);je=p([N({type:B.Choice})],je);var Co=class{constructor(e){f(this,"notBefore",new je(new Date));f(this,"notAfter",new je(new Date));e&&(this.notBefore=new je(e.notBefore),this.notAfter=new je(e.notAfter));}};p([g({type:je})],Co.prototype,"notBefore",void 0);p([g({type:je})],Co.prototype,"notAfter",void 0);var ip,Al=class Al{constructor(e={}){f(this,"extnID","");f(this,"critical",Al.CRITICAL);f(this,"extnValue",new ce);Object.assign(this,e);}};f(Al,"CRITICAL",false);var Yr=Al;p([g({type:S.ObjectIdentifier})],Yr.prototype,"extnID",void 0);p([g({type:S.Boolean,defaultValue:Yr.CRITICAL})],Yr.prototype,"critical",void 0);p([g({type:ce})],Yr.prototype,"extnValue",void 0);var Ts=ip=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,ip.prototype);}};Ts=ip=p([N({type:B.Sequence,itemType:Yr})],Ts);var N0;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3";})(N0||(N0={}));var At=class{constructor(e={}){f(this,"version",N0.v1);f(this,"serialNumber",new ArrayBuffer(0));f(this,"signature",new J);f(this,"issuer",new xt);f(this,"validity",new Co);f(this,"subject",new xt);f(this,"subjectPublicKeyInfo",new _o);f(this,"issuerUniqueID");f(this,"subjectUniqueID");f(this,"extensions");Object.assign(this,e);}};p([g({type:S.Integer,context:0,defaultValue:N0.v1})],At.prototype,"version",void 0);p([g({type:S.Integer,converter:he})],At.prototype,"serialNumber",void 0);p([g({type:J})],At.prototype,"signature",void 0);p([g({type:xt})],At.prototype,"issuer",void 0);p([g({type:Co})],At.prototype,"validity",void 0);p([g({type:xt})],At.prototype,"subject",void 0);p([g({type:_o})],At.prototype,"subjectPublicKeyInfo",void 0);p([g({type:S.BitString,context:1,implicit:true,optional:true})],At.prototype,"issuerUniqueID",void 0);p([g({type:S.BitString,context:2,implicit:true,optional:true})],At.prototype,"subjectUniqueID",void 0);p([g({type:Ts,context:3,optional:true})],At.prototype,"extensions",void 0);var $t=class{constructor(e={}){f(this,"tbsCertificate",new At);f(this,"tbsCertificateRaw");f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:At,raw:true})],$t.prototype,"tbsCertificate",void 0);p([g({type:J})],$t.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],$t.prototype,"signatureValue",void 0);var ks=class{constructor(e={}){f(this,"userCertificate",new ArrayBuffer(0));f(this,"revocationDate",new je);f(this,"crlEntryExtensions");Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],ks.prototype,"userCertificate",void 0);p([g({type:je})],ks.prototype,"revocationDate",void 0);p([g({type:Yr,optional:true,repeated:"sequence"})],ks.prototype,"crlEntryExtensions",void 0);var sr=class{constructor(e={}){f(this,"version");f(this,"signature",new J);f(this,"issuer",new xt);f(this,"thisUpdate",new je);f(this,"nextUpdate");f(this,"revokedCertificates");f(this,"crlExtensions");Object.assign(this,e);}};p([g({type:S.Integer,optional:true})],sr.prototype,"version",void 0);p([g({type:J})],sr.prototype,"signature",void 0);p([g({type:xt})],sr.prototype,"issuer",void 0);p([g({type:je})],sr.prototype,"thisUpdate",void 0);p([g({type:je,optional:true})],sr.prototype,"nextUpdate",void 0);p([g({type:ks,repeated:"sequence",optional:true})],sr.prototype,"revokedCertificates",void 0);p([g({type:Yr,optional:true,context:0,repeated:"sequence"})],sr.prototype,"crlExtensions",void 0);var R0=class{constructor(e={}){f(this,"tbsCertList",new sr);f(this,"tbsCertListRaw");f(this,"signatureAlgorithm",new J);f(this,"signature",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:sr,raw:true})],R0.prototype,"tbsCertList",void 0);p([g({type:J})],R0.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],R0.prototype,"signature",void 0);var D0=class{constructor(e){this.zero=BigInt(0),this.one=BigInt(1),this.prime=e;}e(e){return typeof e=="bigint"?e%this.prime:BigInt(e)%this.prime}add(e,r){return (e+r)%this.prime}sub(e,r){return (this.prime+e-r)%this.prime}mul(e,r){return e*r%this.prime}square(e){return e*e%this.prime}div(e,r){return e/r%this.prime}};var O0=class{constructor(e,r){this.params=e,this.primeField=r;}getT(){return this.params.t}sbox(e){return e.map(r=>this.sboxP(r))}sboxP(e){let r=this.primeField.square(e);if(this.params.d==3)return this.primeField.mul(r,e);if(this.params.d==5)return this.primeField.mul(this.primeField.square(r),e);if(this.params.d==7)return this.primeField.mul(this.primeField.square(r),this.primeField.mul(r,e));throw new Error("Invalid d paramter, must be 3, 5 or 7")}matmulExternal(e){let r=this.params.t;if(r==2){let i=this.primeField.add(e[0],e[1]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i);}else if(r==3){let i=this.primeField.add(this.primeField.add(e[0],e[1]),e[2]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i),e[2]=this.primeField.add(e[2],i);}else if(r==4||r==8||r==12||r==16||r==20||r==24){let i=r/4;for(let n=0;n<i;n++){let o=n*4,s=e[o];s=this.primeField.add(s,e[o+1]);let a=e[o+2];a=this.primeField.add(a,e[o+3]);let c=e[o+1];c=this.primeField.add(c,c),c=this.primeField.add(c,a);let l=e[o+3];l=this.primeField.add(l,l),l=this.primeField.add(l,s);let d=a;d=this.primeField.add(d,d),d=this.primeField.add(d,d),d=this.primeField.add(d,l);let u=s;u=this.primeField.add(u,u),u=this.primeField.add(u,u),u=this.primeField.add(u,c);let h=l;h=this.primeField.add(h,u);let m=c;m=this.primeField.add(m,d),e[o]=h,e[o+1]=u,e[o+2]=m,e[o+3]=d;}if(r>4){let n=[this.primeField.zero,this.primeField.zero,this.primeField.zero,this.primeField.zero];for(let o=0;o<4;o++){n[o]=e[o];for(let s=1;s<i;s++)n[o]=this.primeField.add(n[o],e[4*s+o]);}for(let o=0;o<e.length;o++)e[o]=this.primeField.add(e[o],n[o%4]);}}else throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");return e}matmulInternal(e){let r=this.params.t;if(r==2){let i=this.primeField.add(e[0],e[1]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(this.primeField.add(e[1],e[1]),i);}else if(r==3){let i=this.primeField.add(this.primeField.add(e[0],e[1]),e[2]);e[0]=this.primeField.add(e[0],i),e[1]=this.primeField.add(e[1],i),e[2]=this.primeField.add(this.primeField.add(e[2],e[2]),i);}else if(r==4||r==8||r==12||r==16||r==20||r==24){let i=e[0];for(let n=1;n<r;n++)i=this.primeField.add(i,e[n]);for(let n=0;n<e.length;n++)e[n]=this.primeField.add(this.primeField.mul(this.params.mat_internal_diag_m_1[n],e[n]),i);}else throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");return e}permute(e){let r=this.params.t;if(e.length!=r)throw new Error("Invalid input length");let i=e;this.matmulExternal(i);for(let o=0;o<this.params.rounds_f_beginning;o++)i=this.addRc(i,this.params.round_constants[o]),i=this.sbox(i),this.matmulExternal(i);let n=this.params.rounds_f_beginning+this.params.rounds_p;for(let o=this.params.rounds_f_beginning;o<n;o++)i[0]=this.primeField.add(i[0],this.params.round_constants[o][0]),i[0]=this.sboxP(i[0]),this.matmulInternal(i);for(let o=n;o<this.params.rounds;o++)i=this.addRc(i,this.params.round_constants[o]),i=this.sbox(i),this.matmulExternal(i);return i}addRc(e,r){return e.map((i,n)=>this.primeField.add(i,r[n]))}};function np(t,e,r,i,n,o,s){let a=r/2,c=r+i;return {t,d:e,rounds_f_beginning:a,rounds_p:i,rounds_f_end:a,rounds:c,mat_internal_diag_m_1:n,_mat_internal:o,round_constants:s}}var a4=[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")],c4=[[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e8"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")],[BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428c")]],l4=[[BigInt("0x19b849f69450b06848da1d39bd5e4a4302bb86744edc26238b0878e269ed23e5"),BigInt("0x265ddfe127dd51bd7239347b758f0a1320eb2cc7450acc1dad47f80c8dcf34d6"),BigInt("0x199750ec472f1809e0f66a545e1e51624108ac845015c2aa3dfc36bab497d8aa"),BigInt("0x157ff3fe65ac7208110f06a5f74302b14d743ea25067f0ffd032f787c7f1cdf8")],[BigInt("0x2e49c43c4569dd9c5fd35ac45fca33f10b15c590692f8beefe18f4896ac94902"),BigInt("0x0e35fb89981890520d4aef2b6d6506c3cb2f0b6973c24fa82731345ffa2d1f1e"),BigInt("0x251ad47cb15c4f1105f109ae5e944f1ba9d9e7806d667ffec6fe723002e0b996"),BigInt("0x13da07dc64d428369873e97160234641f8beb56fdd05e5f3563fa39d9c22df4e")],[BigInt("0x0c009b84e650e6d23dc00c7dccef7483a553939689d350cd46e7b89055fd4738"),BigInt("0x011f16b1c63a854f01992e3956f42d8b04eb650c6d535eb0203dec74befdca06"),BigInt("0x0ed69e5e383a688f209d9a561daa79612f3f78d0467ad45485df07093f367549"),BigInt("0x04dba94a7b0ce9e221acad41472b6bbe3aec507f5eb3d33f463672264c9f789b")],[BigInt("0x0a3f2637d840f3a16eb094271c9d237b6036757d4bb50bf7ce732ff1d4fa28e8"),BigInt("0x259a666f129eea198f8a1c502fdb38fa39b1f075569564b6e54a485d1182323f"),BigInt("0x28bf7459c9b2f4c6d8e7d06a4ee3a47f7745d4271038e5157a32fdf7ede0d6a1"),BigInt("0x0a1ca941f057037526ea200f489be8d4c37c85bbcce6a2aeec91bd6941432447")],[BigInt("0x0c6f8f958be0e93053d7fd4fc54512855535ed1539f051dcb43a26fd926361cf"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x123106a93cd17578d426e8128ac9d90aa9e8a00708e296e084dd57e69caaf811"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x26e1ba52ad9285d97dd3ab52f8e840085e8fa83ff1e8f1877b074867cd2dee75"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1cb55cad7bd133de18a64c5c47b9c97cbe4d8b7bf9e095864471537e6a4ae2c5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1dcd73e46acd8f8e0e2c7ce04bde7f6d2a53043d5060a41c7143f08e6e9055d0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x011003e32f6d9c66f5852f05474a4def0cda294a0eb4e9b9b12b9bb4512e5574"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2b1e809ac1d10ab29ad5f20d03a57dfebadfe5903f58bafed7c508dd2287ae8c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2539de1785b735999fb4dac35ee17ed0ef995d05ab2fc5faeaa69ae87bcec0a5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0c246c5a2ef8ee0126497f222b3e0a0ef4e1c3d41c86d46e43982cb11d77951d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x192089c4974f68e95408148f7c0632edbb09e6a6ad1a1c2f3f0305f5d03b527b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1eae0ad8ab68b2f06a0ee36eeb0d0c058529097d91096b756d8fdc2fb5a60d85"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x179190e5d0e22179e46f8282872abc88db6e2fdc0dee99e69768bd98c5d06bfb"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x29bb9e2c9076732576e9a81c7ac4b83214528f7db00f31bf6cafe794a9b3cd1c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x225d394e42207599403efd0c2464a90d52652645882aac35b10e590e6e691e08"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x064760623c25c8cf753d238055b444532be13557451c087de09efd454b23fd59"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x10ba3a0e01df92e87f301c4b716d8a394d67f4bf42a75c10922910a78f6b5b87"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0e070bf53f8451b24f9c6e96b0c2a801cb511bc0c242eb9d361b77693f21471c"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1b94cd61b051b04dd39755ff93821a73ccd6cb11d2491d8aa7f921014de252fb"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1d7cb39bafb8c744e148787a2e70230f9d4e917d5713bb050487b5aa7d74070b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2ec93189bd1ab4f69117d0fe980c80ff8785c2961829f701bb74ac1f303b17db"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2db366bfdd36d277a692bb825b86275beac404a19ae07a9082ea46bd83517926"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x062100eb485db06269655cf186a68532985275428450359adc99cec6960711b8"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0761d33c66614aaa570e7f1e8244ca1120243f92fa59e4f900c567bf41f5a59b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x20fc411a114d13992c2705aa034e3f315d78608a0f7de4ccf7a72e494855ad0d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x25b5c004a4bdfcb5add9ec4e9ab219ba102c67e8b3effb5fc3a30f317250bc5a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x23b1822d278ed632a494e58f6df6f5ed038b186d8474155ad87e7dff62b37f4b"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x22734b4c5c3f9493606c4ba9012499bf0f14d13bfcfcccaa16102a29cc2f69e0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x26c0c8fe09eb30b7e27a74dc33492347e5bdff409aa3610254413d3fad795ce5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x070dd0ccb6bd7bbae88eac03fa1fbb26196be3083a809829bbd626df348ccad9"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x12b6595bdb329b6fb043ba78bb28c3bec2c0a6de46d8c5ad6067c4ebfd4250da"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x248d97d7f76283d63bec30e7a5876c11c06fca9b275c671c5e33d95bb7e8d729"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1a306d439d463b0816fc6fd64cc939318b45eb759ddde4aa106d15d9bd9baaaa"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x28a8f8372e3c38daced7c00421cb4621f4f1b54ddc27821b0d62d3d6ec7c56cf"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0094975717f9a8a8bb35152f24d43294071ce320c829f388bc852183e1e2ce7e"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x04d5ee4c3aa78f7d80fde60d716480d3593f74d4f653ae83f4103246db2e8d65"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2a6cf5e9aa03d4336349ad6fb8ed2269c7bef54b8822cc76d08495c12efde187"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2304d31eaab960ba9274da43e19ddeb7f792180808fd6e43baae48d7efcba3f3"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x03fd9ac865a4b2a6d5e7009785817249bff08a7e0726fcb4e1c11d39d199f0b0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x00b7258ded52bbda2248404d55ee5044798afc3a209193073f7954d4d63b0b64"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x159f81ada0771799ec38fca2d4bf65ebb13d3a74f3298db36272c5ca65e92d9a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1ef90e67437fbc8550237a75bc28e3bb9000130ea25f0c5471e144cf4264431f"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1e65f838515e5ff0196b49aa41a2d2568df739bc176b08ec95a79ed82932e30d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2b1b045def3a166cec6ce768d079ba74b18c844e570e1f826575c1068c94c33f"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0832e5753ceb0ff6402543b1109229c165dc2d73bef715e3f1c6e07c168bb173"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x02f614e9cedfb3dc6b762ae0a37d41bab1b841c2e8b6451bc5a8e3c390b6ad16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0e2427d38bd46a60dd640b8e362cad967370ebb777bedff40f6a0be27e7ed705"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0493630b7c670b6deb7c84d414e7ce79049f0ec098c3c7c50768bbe29214a53a"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x22ead100e8e482674decdab17066c5a26bb1515355d5461a3dc06cc85327cea9"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x25b3e56e655b42cdaae2626ed2554d48583f1ae35626d04de5084e0b6d2a6f16"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1e32752ada8836ef5837a6cde8ff13dbb599c336349e4c584b4fdc0a0cf6f9d0"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2fa2a871c15a387cc50f68f6f3c3455b23c00995f05078f672a9864074d412e5"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x2f569b8a9a4424c9278e1db7311e889f54ccbf10661bab7fcd18e7c7a7d83505"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x044cb455110a8fdd531ade530234c518a7df93f7332ffd2144165374b246b43d"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x227808de93906d5d420246157f2e42b191fe8c90adfe118178ddc723a5319025"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x02fcca2934e046bc623adead873579865d03781ae090ad4a8579d2e7a6800355"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x0ef915f0ac120b876abccceb344a1d36bad3f3c5ab91a8ddcbec2e060d8befac"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")],[BigInt("0x1797130f4b7a3e1777eb757bc6f287f6ab0fb85f6be63b09f3b16ef2b1405d38"),BigInt("0x0a76225dc04170ae3306c85abab59e608c7f497c20156d4d36c668555decc6e5"),BigInt("0x1fffb9ec1992d66ba1e77a7b93209af6f8fa76d48acb664796174b5326a31a5c"),BigInt("0x25721c4fc15a3f2853b57c338fa538d85f8fbba6c6b9c6090611889b797b9c5f")],[BigInt("0x0c817fd42d5f7a41215e3d07ba197216adb4c3790705da95eb63b982bfcaf75a"),BigInt("0x13abe3f5239915d39f7e13c2c24970b6df8cf86ce00a22002bc15866e52b5a96"),BigInt("0x2106feea546224ea12ef7f39987a46c85c1bc3dc29bdbd7a92cd60acb4d391ce"),BigInt("0x21ca859468a746b6aaa79474a37dab49f1ca5a28c748bc7157e1b3345bb0f959")],[BigInt("0x05ccd6255c1e6f0c5cf1f0df934194c62911d14d0321662a8f1a48999e34185b"),BigInt("0x0f0e34a64b70a626e464d846674c4c8816c4fb267fe44fe6ea28678cb09490a4"),BigInt("0x0558531a4e25470c6157794ca36d0e9647dbfcfe350d64838f5b1a8a2de0d4bf"),BigInt("0x09d3dca9173ed2faceea125157683d18924cadad3f655a60b72f5864961f1455")],[BigInt("0x0328cbd54e8c0913493f866ed03d218bf23f92d68aaec48617d4c722e5bd4335"),BigInt("0x2bf07216e2aff0a223a487b1a7094e07e79e7bcc9798c648ee3347dd5329d34b"),BigInt("0x1daf345a58006b736499c583cb76c316d6f78ed6a6dffc82111e11a63fe412df"),BigInt("0x176563472456aaa746b694c60e1823611ef39039b2edc7ff391e6f2293d2c404")]];var E_=new D0(BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")),op=null;function ar(){return op||(op=new O0(np(4,5,8,56,a4,c4,l4),E_)),op}ar().primeField;ar().permute.bind(ar());var d4;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(d4||(d4={}));var B_=ar().primeField,T_=ar().permute.bind(ar()),kr;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(kr||(kr={}));var sp=class t{constructor(e=0n){this.rate=ar().getT()-1,this.t=ar().getT(),this.state=new Array(this.t).fill(0n),this.state[this.rate]=e,this.cache=new Array(this.rate).fill(0n),this.cacheSize=0,this.mode=kr.ABSORB;}async performDuplex(){for(let e=this.cacheSize;e<this.rate;e++)this.cache[e]=0n;for(let e=0;e<this.rate;e++)this.state[e]=B_.add(this.state[e],this.cache[e]);return this.state=T_(this.state),await Promise.resolve(),this.state.slice(0,this.rate)}async absorb(e){this.mode===kr.ABSORB&&this.cacheSize===this.rate?(await this.performDuplex(),this.cache[0]=e,this.cacheSize=1):this.mode===kr.ABSORB&&this.cacheSize<this.rate?(this.cache[this.cacheSize]=e,this.cacheSize+=1):this.mode===kr.SQUEEZE&&(this.cache[0]=e,this.cacheSize=1,this.mode=kr.ABSORB);}async squeeze(){if(this.mode===kr.SQUEEZE&&this.cacheSize===0&&(this.mode=kr.ABSORB,this.cacheSize=0),this.mode===kr.ABSORB){let r=await this.performDuplex();this.mode=kr.SQUEEZE;for(let i=0;i<this.rate;i++)this.cache[i]=r[i];this.cacheSize=this.rate;}let e=this.cache[0];for(let r=1;r<this.cacheSize;r++)this.cache[r-1]=this.cache[r];return this.cacheSize-=1,this.cache[this.cacheSize]=0n,e}static async hashInternal(e,r,i){let n=(BigInt(e.length)<<64n)+BigInt(r-1),o=new t(n),s=100;for(let c=0;c<e.length;c+=s){let l=e.slice(c,Math.min(c+s,e.length));for(let d of l)await o.absorb(d);}i&&await o.absorb(1n);let a=[];for(let c=0;c<r;c++)a.push(await o.squeeze());return a}static async hashFixedLength(e,r=1){return this.hashInternal(e,r,false)}static async hashVariableLength(e,r=1){return this.hashInternal(e,r,true)}};async function Me(t){return (await sp.hashFixedLength(t))[0]}ar().primeField;It(Il(),1);It(Il(),1);var P4="1.2.840.10045.4.1",N4="1.2.840.10045.4.3.1",R4="1.2.840.10045.4.3.2",D4="1.2.840.10045.4.3.3",O4="1.2.840.10045.4.3.4";function U0(t){return new J({algorithm:t})}U0(P4);U0(N4);U0(R4);U0(D4);U0(O4);var F0=class{constructor(e={}){f(this,"fieldType");f(this,"parameters");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],F0.prototype,"fieldType",void 0);p([g({type:S.Any})],F0.prototype,"parameters",void 0);F0=p([N({type:B.Sequence})],F0);var yp=class extends ce{};var Os=class{constructor(e={}){f(this,"a");f(this,"b");f(this,"seed");Object.assign(this,e);}};p([g({type:S.OctetString})],Os.prototype,"a",void 0);p([g({type:S.OctetString})],Os.prototype,"b",void 0);p([g({type:S.BitString,optional:true})],Os.prototype,"seed",void 0);Os=p([N({type:B.Sequence})],Os);var bp;(function(t){t[t.ecpVer1=1]="ecpVer1";})(bp||(bp={}));var ei=class{constructor(e={}){f(this,"version",bp.ecpVer1);f(this,"fieldID");f(this,"curve");f(this,"base");f(this,"order");f(this,"cofactor");Object.assign(this,e);}};p([g({type:S.Integer})],ei.prototype,"version",void 0);p([g({type:F0})],ei.prototype,"fieldID",void 0);p([g({type:Os})],ei.prototype,"curve",void 0);p([g({type:yp})],ei.prototype,"base",void 0);p([g({type:S.Integer,converter:he})],ei.prototype,"order",void 0);p([g({type:S.Integer,optional:true})],ei.prototype,"cofactor",void 0);ei=p([N({type:B.Sequence})],ei);var An=class{constructor(e={}){f(this,"namedCurve");f(this,"implicitCurve");f(this,"specifiedCurve");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],An.prototype,"namedCurve",void 0);p([g({type:S.Null})],An.prototype,"implicitCurve",void 0);p([g({type:ei})],An.prototype,"specifiedCurve",void 0);An=p([N({type:B.Choice})],An);var Ms=class{constructor(e={}){f(this,"version",1);f(this,"privateKey",new ce);f(this,"parameters");f(this,"publicKey");Object.assign(this,e);}};p([g({type:S.Integer})],Ms.prototype,"version",void 0);p([g({type:ce})],Ms.prototype,"privateKey",void 0);p([g({type:An,context:0,optional:true})],Ms.prototype,"parameters",void 0);p([g({type:S.BitString,context:1,optional:true})],Ms.prototype,"publicKey",void 0);var vl=class{constructor(e={}){f(this,"r",new ArrayBuffer(0));f(this,"s",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],vl.prototype,"r",void 0);p([g({type:S.Integer,converter:he})],vl.prototype,"s",void 0);var Pt="1.2.840.113549.1.1",M4=`${Pt}.1`,U4=`${Pt}.7`,F4=`${Pt}.9`,L4=`${Pt}.10`,H4=`${Pt}.2`,K4=`${Pt}.4`,z4=`${Pt}.5`;var q4=`${Pt}.12`,G4=`${Pt}.13`,Sp=`${Pt}.15`,xp=`${Pt}.16`,$4="1.3.14.3.2.26",V4="2.16.840.1.101.3.4.2.4",j4="2.16.840.1.101.3.4.2.1",X4="2.16.840.1.101.3.4.2.2",W4="2.16.840.1.101.3.4.2.3",Z4="2.16.840.1.101.3.4.2.5",Y4="2.16.840.1.101.3.4.2.6",Q4="1.2.840.113549.2.2",J4="1.2.840.113549.2.5",Us=`${Pt}.8`;function We(t){return new J({algorithm:t,parameters:null})}We(Q4);We(J4);var ki=We($4);We(V4);We(j4);We(X4);We(W4);We(Z4);We(Y4);var El=new J({algorithm:Us,parameters:ir.serialize(ki)}),Ap=new J({algorithm:F4,parameters:ir.serialize(_s.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});We(M4);We(H4);We(K4);We(z4);We(Sp);We(xp);We(q4);We(G4);We(Sp);We(xp);var Fs=class{constructor(e={}){f(this,"hashAlgorithm",new J(ki));f(this,"maskGenAlgorithm",new J({algorithm:Us,parameters:ir.serialize(ki)}));f(this,"pSourceAlgorithm",new J(Ap));Object.assign(this,e);}};p([g({type:J,context:0,defaultValue:ki})],Fs.prototype,"hashAlgorithm",void 0);p([g({type:J,context:1,defaultValue:El})],Fs.prototype,"maskGenAlgorithm",void 0);p([g({type:J,context:2,defaultValue:Ap})],Fs.prototype,"pSourceAlgorithm",void 0);new J({algorithm:U4,parameters:ir.serialize(new Fs)});var wn=class{constructor(e={}){f(this,"hashAlgorithm",new J(ki));f(this,"maskGenAlgorithm",new J({algorithm:Us,parameters:ir.serialize(ki)}));f(this,"saltLength",20);f(this,"trailerField",1);Object.assign(this,e);}};p([g({type:J,context:0,defaultValue:ki})],wn.prototype,"hashAlgorithm",void 0);p([g({type:J,context:1,defaultValue:El})],wn.prototype,"maskGenAlgorithm",void 0);p([g({type:S.Integer,context:2,defaultValue:20})],wn.prototype,"saltLength",void 0);p([g({type:S.Integer,context:3,defaultValue:1})],wn.prototype,"trailerField",void 0);new J({algorithm:L4,parameters:ir.serialize(new wn)});var Bl=class{constructor(e={}){f(this,"digestAlgorithm",new J);f(this,"digest",new ce);Object.assign(this,e);}};p([g({type:J})],Bl.prototype,"digestAlgorithm",void 0);p([g({type:ce})],Bl.prototype,"digest",void 0);var wp,Ls=class{constructor(e={}){f(this,"prime",new ArrayBuffer(0));f(this,"exponent",new ArrayBuffer(0));f(this,"coefficient",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],Ls.prototype,"prime",void 0);p([g({type:S.Integer,converter:he})],Ls.prototype,"exponent",void 0);p([g({type:S.Integer,converter:he})],Ls.prototype,"coefficient",void 0);var Tl=wp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,wp.prototype);}};Tl=wp=p([N({type:B.Sequence,itemType:Ls})],Tl);var lr=class{constructor(e={}){f(this,"version",0);f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));f(this,"privateExponent",new ArrayBuffer(0));f(this,"prime1",new ArrayBuffer(0));f(this,"prime2",new ArrayBuffer(0));f(this,"exponent1",new ArrayBuffer(0));f(this,"exponent2",new ArrayBuffer(0));f(this,"coefficient",new ArrayBuffer(0));f(this,"otherPrimeInfos");Object.assign(this,e);}};p([g({type:S.Integer})],lr.prototype,"version",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"modulus",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"publicExponent",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"privateExponent",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"prime1",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"prime2",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"exponent1",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"exponent2",void 0);p([g({type:S.Integer,converter:he})],lr.prototype,"coefficient",void 0);p([g({type:Tl,optional:true})],lr.prototype,"otherPrimeInfos",void 0);var L0=class{constructor(e={}){f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Integer,converter:he})],L0.prototype,"modulus",void 0);p([g({type:S.Integer,converter:he})],L0.prototype,"publicExponent",void 0);var Pr=class{constructor(e={}){f(this,"issuer",new xt);f(this,"serialNumber",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:xt})],Pr.prototype,"issuer",void 0);p([g({type:S.Integer,converter:he})],Pr.prototype,"serialNumber",void 0);var Eo=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true})],Eo.prototype,"subjectKeyIdentifier",void 0);p([g({type:Pr})],Eo.prototype,"issuerAndSerialNumber",void 0);Eo=p([N({type:B.Choice})],Eo);var ht;(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";})(ht||(ht={}));var mt=class extends J{};mt=p([N({type:B.Sequence})],mt);var H0=class extends J{};H0=p([N({type:B.Sequence})],H0);var Nt=class extends J{};Nt=p([N({type:B.Sequence})],Nt);var K0=class extends J{};K0=p([N({type:B.Sequence})],K0);var eb=class extends J{};eb=p([N({type:B.Sequence})],eb);var kl=class extends J{};kl=p([N({type:B.Sequence})],kl);var wt=class{constructor(e={}){f(this,"attrType","");f(this,"attrValues",[]);Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],wt.prototype,"attrType",void 0);p([g({type:S.Any,repeated:"set"})],wt.prototype,"attrValues",void 0);var _p,dr=class{constructor(e={}){f(this,"version",ht.v0);f(this,"sid",new Eo);f(this,"digestAlgorithm",new mt);f(this,"signedAttrs");f(this,"signedAttrsRaw");f(this,"signatureAlgorithm",new H0);f(this,"signature",new ce);f(this,"unsignedAttrs");Object.assign(this,e);}};p([g({type:S.Integer})],dr.prototype,"version",void 0);p([g({type:Eo})],dr.prototype,"sid",void 0);p([g({type:mt})],dr.prototype,"digestAlgorithm",void 0);p([g({type:wt,repeated:"set",context:0,implicit:true,optional:true,raw:true})],dr.prototype,"signedAttrs",void 0);p([g({type:H0})],dr.prototype,"signatureAlgorithm",void 0);p([g({type:ce})],dr.prototype,"signature",void 0);p([g({type:wt,repeated:"set",context:1,implicit:true,optional:true})],dr.prototype,"unsignedAttrs",void 0);var z0=_p=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,_p.prototype);}};z0=_p=p([N({type:B.Set,itemType:dr})],z0);var tb=class extends dr{};tb=p([N({type:B.Sequence})],tb);var rb=class extends je{};rb=p([N({type:B.Choice})],rb);var q0=class{constructor(e={}){f(this,"acIssuer",new ue);f(this,"acSerial",0);f(this,"attrs",[]);Object.assign(this,e);}};p([g({type:ue})],q0.prototype,"acIssuer",void 0);p([g({type:S.Integer})],q0.prototype,"acSerial",void 0);p([g({type:Zr,repeated:"sequence"})],q0.prototype,"attrs",void 0);var Cp,G0=Cp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Cp.prototype);}};G0=Cp=p([N({type:B.Sequence,itemType:S.ObjectIdentifier})],G0);var Hs=class{constructor(e={}){f(this,"pathLenConstraint");f(this,"permittedAttrs");f(this,"excludedAttrs");f(this,"permitUnSpecified",true);Object.assign(this,e);}};p([g({type:S.Integer,optional:true})],Hs.prototype,"pathLenConstraint",void 0);p([g({type:G0,implicit:true,context:0,optional:true})],Hs.prototype,"permittedAttrs",void 0);p([g({type:G0,implicit:true,context:1,optional:true})],Hs.prototype,"excludedAttrs",void 0);p([g({type:S.Boolean,defaultValue:true})],Hs.prototype,"permitUnSpecified",void 0);var ur=class{constructor(e={}){f(this,"issuer",new Xe);f(this,"serial",new ArrayBuffer(0));f(this,"issuerUID",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:Xe})],ur.prototype,"issuer",void 0);p([g({type:S.Integer,converter:he})],ur.prototype,"serial",void 0);p([g({type:S.BitString,optional:true})],ur.prototype,"issuerUID",void 0);var Ip;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes";})(Ip||(Ip={}));var fr=class{constructor(e={}){f(this,"digestedObjectType",Ip.publicKey);f(this,"otherObjectTypeID");f(this,"digestAlgorithm",new J);f(this,"objectDigest",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.Enumerated})],fr.prototype,"digestedObjectType",void 0);p([g({type:S.ObjectIdentifier,optional:true})],fr.prototype,"otherObjectTypeID",void 0);p([g({type:J})],fr.prototype,"digestAlgorithm",void 0);p([g({type:S.BitString})],fr.prototype,"objectDigest",void 0);var Bo=class{constructor(e={}){f(this,"issuerName");f(this,"baseCertificateID");f(this,"objectDigestInfo");Object.assign(this,e);}};p([g({type:Xe,optional:true})],Bo.prototype,"issuerName",void 0);p([g({type:ur,context:0,implicit:true,optional:true})],Bo.prototype,"baseCertificateID",void 0);p([g({type:fr,context:1,implicit:true,optional:true})],Bo.prototype,"objectDigestInfo",void 0);var To=class{constructor(e={}){f(this,"v1Form");f(this,"v2Form");Object.assign(this,e);}};p([g({type:ue,repeated:"sequence"})],To.prototype,"v1Form",void 0);p([g({type:Bo,context:0,implicit:true})],To.prototype,"v2Form",void 0);To=p([N({type:B.Choice})],To);var ko=class{constructor(e={}){f(this,"notBeforeTime",new Date);f(this,"notAfterTime",new Date);Object.assign(this,e);}};p([g({type:S.GeneralizedTime})],ko.prototype,"notBeforeTime",void 0);p([g({type:S.GeneralizedTime})],ko.prototype,"notAfterTime",void 0);var _n=class{constructor(e={}){f(this,"baseCertificateID");f(this,"entityName");f(this,"objectDigestInfo");Object.assign(this,e);}};p([g({type:ur,implicit:true,context:0,optional:true})],_n.prototype,"baseCertificateID",void 0);p([g({type:Xe,implicit:true,context:1,optional:true})],_n.prototype,"entityName",void 0);p([g({type:fr,implicit:true,context:2,optional:true})],_n.prototype,"objectDigestInfo",void 0);var vp;(function(t){t[t.v2=1]="v2";})(vp||(vp={}));var Rt=class{constructor(e={}){f(this,"version",vp.v2);f(this,"holder",new _n);f(this,"issuer",new To);f(this,"signature",new J);f(this,"serialNumber",new ArrayBuffer(0));f(this,"attrCertValidityPeriod",new ko);f(this,"attributes",[]);f(this,"issuerUniqueID");f(this,"extensions");Object.assign(this,e);}};p([g({type:S.Integer})],Rt.prototype,"version",void 0);p([g({type:_n})],Rt.prototype,"holder",void 0);p([g({type:To})],Rt.prototype,"issuer",void 0);p([g({type:J})],Rt.prototype,"signature",void 0);p([g({type:S.Integer,converter:he})],Rt.prototype,"serialNumber",void 0);p([g({type:ko})],Rt.prototype,"attrCertValidityPeriod",void 0);p([g({type:Zr,repeated:"sequence"})],Rt.prototype,"attributes",void 0);p([g({type:S.BitString,optional:true})],Rt.prototype,"issuerUniqueID",void 0);p([g({type:Ts,optional:true})],Rt.prototype,"extensions",void 0);var Po=class{constructor(e={}){f(this,"acinfo",new Rt);f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:Rt})],Po.prototype,"acinfo",void 0);p([g({type:J})],Po.prototype,"signatureAlgorithm",void 0);p([g({type:S.BitString})],Po.prototype,"signatureValue",void 0);var $0;(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";})($0||($0={}));var Ks=class extends Ei{};var zs=class{constructor(e={}){f(this,"type","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier,implicit:true,context:0})],zs.prototype,"type",void 0);p([g({type:S.Any,implicit:true,context:1})],zs.prototype,"value",void 0);var V0=class{constructor(e={}){f(this,"policyId","");f(this,"classList",new Ks($0.unclassified));f(this,"securityCategories");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],V0.prototype,"policyId",void 0);p([g({type:Ks,defaultValue:new Ks($0.unclassified)})],V0.prototype,"classList",void 0);p([g({type:zs,repeated:"set"})],V0.prototype,"securityCategories",void 0);var qs=class{constructor(e={}){f(this,"cotets");f(this,"oid");f(this,"string");Object.assign(this,e);}};p([g({type:ce})],qs.prototype,"cotets",void 0);p([g({type:S.ObjectIdentifier})],qs.prototype,"oid",void 0);p([g({type:S.Utf8String})],qs.prototype,"string",void 0);var Pl=class{constructor(e={}){f(this,"policyAuthority");f(this,"values",[]);Object.assign(this,e);}};p([g({type:Xe,implicit:true,context:0,optional:true})],Pl.prototype,"policyAuthority",void 0);p([g({type:qs,repeated:"sequence"})],Pl.prototype,"values",void 0);var Ep,Gs=class{constructor(e={}){f(this,"targetCertificate",new ur);f(this,"targetName");f(this,"certDigestInfo");Object.assign(this,e);}};p([g({type:ur})],Gs.prototype,"targetCertificate",void 0);p([g({type:ue,optional:true})],Gs.prototype,"targetName",void 0);p([g({type:fr,optional:true})],Gs.prototype,"certDigestInfo",void 0);var $s=class{constructor(e={}){f(this,"targetName");f(this,"targetGroup");f(this,"targetCert");Object.assign(this,e);}};p([g({type:ue,context:0,implicit:true})],$s.prototype,"targetName",void 0);p([g({type:ue,context:1,implicit:true})],$s.prototype,"targetGroup",void 0);p([g({type:Gs,context:2,implicit:true})],$s.prototype,"targetCert",void 0);$s=p([N({type:B.Choice})],$s);var Nl=Ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ep.prototype);}};Nl=Ep=p([N({type:B.Sequence,itemType:$s})],Nl);var Bp,ib=Bp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Bp.prototype);}};ib=Bp=p([N({type:B.Sequence,itemType:Nl})],ib);var Rl=class{constructor(e={}){f(this,"roleAuthority");f(this,"roleName");Object.assign(this,e);}};p([g({type:Xe,implicit:true,context:0,optional:true})],Rl.prototype,"roleAuthority",void 0);p([g({type:ue,implicit:true,context:1})],Rl.prototype,"roleName",void 0);var X0=class{constructor(e={}){f(this,"service",new ue);f(this,"ident",new ue);f(this,"authInfo");Object.assign(this,e);}};p([g({type:ue})],X0.prototype,"service",void 0);p([g({type:ue})],X0.prototype,"ident",void 0);p([g({type:ce,optional:true})],X0.prototype,"authInfo",void 0);var Tp,W0=class{constructor(e={}){f(this,"otherCertFormat","");f(this,"otherCert",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],W0.prototype,"otherCertFormat",void 0);p([g({type:S.Any})],W0.prototype,"otherCert",void 0);var Vs=class{constructor(e={}){f(this,"certificate");f(this,"v2AttrCert");f(this,"other");Object.assign(this,e);}};p([g({type:$t})],Vs.prototype,"certificate",void 0);p([g({type:Po,context:2,implicit:true})],Vs.prototype,"v2AttrCert",void 0);p([g({type:W0,context:3,implicit:true})],Vs.prototype,"other",void 0);Vs=p([N({type:B.Choice})],Vs);var js=Tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Tp.prototype);}};js=Tp=p([N({type:B.Set,itemType:Vs})],js);var Z0=class{constructor(e={}){f(this,"contentType","");f(this,"content",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Z0.prototype,"contentType",void 0);p([g({type:S.Any,context:0})],Z0.prototype,"content",void 0);var Y0=class{constructor(e={}){f(this,"single");f(this,"any");Object.assign(this,e);}};p([g({type:ce})],Y0.prototype,"single",void 0);p([g({type:S.Any})],Y0.prototype,"any",void 0);Y0=p([N({type:B.Choice})],Y0);var No=class{constructor(e={}){f(this,"eContentType","");f(this,"eContent");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],No.prototype,"eContentType",void 0);p([g({type:Y0,context:0,optional:true})],No.prototype,"eContent",void 0);var Q0=class{constructor(e={}){f(this,"value");f(this,"constructedValue");Object.assign(this,e);}};p([g({type:ce,context:0,implicit:true,optional:true})],Q0.prototype,"value",void 0);p([g({type:ce,converter:V3,context:0,implicit:true,optional:true,repeated:"sequence"})],Q0.prototype,"constructedValue",void 0);Q0=p([N({type:B.Choice})],Q0);var Cn=class{constructor(e={}){f(this,"contentType","");f(this,"contentEncryptionAlgorithm",new K0);f(this,"encryptedContent");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Cn.prototype,"contentType",void 0);p([g({type:K0})],Cn.prototype,"contentEncryptionAlgorithm",void 0);p([g({type:Q0,optional:true})],Cn.prototype,"encryptedContent",void 0);var In=class{constructor(e={}){f(this,"keyAttrId","");f(this,"keyAttr");Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],In.prototype,"keyAttrId",void 0);p([g({type:S.Any,optional:true})],In.prototype,"keyAttr",void 0);var kp,Xs=class{constructor(e={}){f(this,"subjectKeyIdentifier",new Tr);f(this,"date");f(this,"other");Object.assign(this,e);}};p([g({type:Tr})],Xs.prototype,"subjectKeyIdentifier",void 0);p([g({type:S.GeneralizedTime,optional:true})],Xs.prototype,"date",void 0);p([g({type:In,optional:true})],Xs.prototype,"other",void 0);var Ws=class{constructor(e={}){f(this,"rKeyId");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Xs,context:0,implicit:true,optional:true})],Ws.prototype,"rKeyId",void 0);p([g({type:Pr,optional:true})],Ws.prototype,"issuerAndSerialNumber",void 0);Ws=p([N({type:B.Choice})],Ws);var J0=class{constructor(e={}){f(this,"rid",new Ws);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:Ws})],J0.prototype,"rid",void 0);p([g({type:ce})],J0.prototype,"encryptedKey",void 0);var Dl=kp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,kp.prototype);}};Dl=kp=p([N({type:B.Sequence,itemType:J0})],Dl);var ec=class{constructor(e={}){f(this,"algorithm",new J);f(this,"publicKey",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:J})],ec.prototype,"algorithm",void 0);p([g({type:S.BitString})],ec.prototype,"publicKey",void 0);var Ro=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"originatorKey");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true,optional:true})],Ro.prototype,"subjectKeyIdentifier",void 0);p([g({type:ec,context:1,implicit:true,optional:true})],Ro.prototype,"originatorKey",void 0);p([g({type:Pr,optional:true})],Ro.prototype,"issuerAndSerialNumber",void 0);Ro=p([N({type:B.Choice})],Ro);var Pi=class{constructor(e={}){f(this,"version",ht.v3);f(this,"originator",new Ro);f(this,"ukm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"recipientEncryptedKeys",new Dl);Object.assign(this,e);}};p([g({type:S.Integer})],Pi.prototype,"version",void 0);p([g({type:Ro,context:0})],Pi.prototype,"originator",void 0);p([g({type:ce,context:1,optional:true})],Pi.prototype,"ukm",void 0);p([g({type:Nt})],Pi.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:Dl})],Pi.prototype,"recipientEncryptedKeys",void 0);var Zs=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};p([g({type:Tr,context:0,implicit:true})],Zs.prototype,"subjectKeyIdentifier",void 0);p([g({type:Pr})],Zs.prototype,"issuerAndSerialNumber",void 0);Zs=p([N({type:B.Choice})],Zs);var vn=class{constructor(e={}){f(this,"version",ht.v0);f(this,"rid",new Zs);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],vn.prototype,"version",void 0);p([g({type:Zs})],vn.prototype,"rid",void 0);p([g({type:Nt})],vn.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],vn.prototype,"encryptedKey",void 0);var Do=class{constructor(e={}){f(this,"keyIdentifier",new ce);f(this,"date");f(this,"other");Object.assign(this,e);}};p([g({type:ce})],Do.prototype,"keyIdentifier",void 0);p([g({type:S.GeneralizedTime,optional:true})],Do.prototype,"date",void 0);p([g({type:In,optional:true})],Do.prototype,"other",void 0);var En=class{constructor(e={}){f(this,"version",ht.v4);f(this,"kekid",new Do);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],En.prototype,"version",void 0);p([g({type:Do})],En.prototype,"kekid",void 0);p([g({type:Nt})],En.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],En.prototype,"encryptedKey",void 0);var Bn=class{constructor(e={}){f(this,"version",ht.v0);f(this,"keyDerivationAlgorithm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};p([g({type:S.Integer})],Bn.prototype,"version",void 0);p([g({type:kl,context:0,optional:true})],Bn.prototype,"keyDerivationAlgorithm",void 0);p([g({type:Nt})],Bn.prototype,"keyEncryptionAlgorithm",void 0);p([g({type:ce})],Bn.prototype,"encryptedKey",void 0);var tc=class{constructor(e={}){f(this,"oriType","");f(this,"oriValue",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],tc.prototype,"oriType",void 0);p([g({type:S.Any})],tc.prototype,"oriValue",void 0);var Ni=class{constructor(e={}){f(this,"ktri");f(this,"kari");f(this,"kekri");f(this,"pwri");f(this,"ori");Object.assign(this,e);}};p([g({type:vn,optional:true})],Ni.prototype,"ktri",void 0);p([g({type:Pi,context:1,implicit:true,optional:true})],Ni.prototype,"kari",void 0);p([g({type:En,context:2,implicit:true,optional:true})],Ni.prototype,"kekri",void 0);p([g({type:Bn,context:3,implicit:true,optional:true})],Ni.prototype,"pwri",void 0);p([g({type:tc,context:4,implicit:true,optional:true})],Ni.prototype,"ori",void 0);Ni=p([N({type:B.Choice})],Ni);var Pp,rc=Pp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Pp.prototype);}};rc=Pp=p([N({type:B.Set,itemType:Ni})],rc);var Np,Ys=class{constructor(e={}){f(this,"otherRevInfoFormat","");f(this,"otherRevInfo",new ArrayBuffer(0));Object.assign(this,e);}};p([g({type:S.ObjectIdentifier})],Ys.prototype,"otherRevInfoFormat",void 0);p([g({type:S.Any})],Ys.prototype,"otherRevInfo",void 0);var Ol=class{constructor(e={}){f(this,"other",new Ys);Object.assign(this,e);}};p([g({type:Ys,context:1,implicit:true})],Ol.prototype,"other",void 0);Ol=p([N({type:B.Choice})],Ol);var Qs=Np=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Np.prototype);}};Qs=Np=p([N({type:B.Set,itemType:Ol})],Qs);var Js=class{constructor(e={}){f(this,"certs");f(this,"crls");Object.assign(this,e);}};p([g({type:js,context:0,implicit:true,optional:true})],Js.prototype,"certs",void 0);p([g({type:Qs,context:1,implicit:true,optional:true})],Js.prototype,"crls",void 0);var Rp,Dp=Rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Rp.prototype);}};Dp=Rp=p([N({type:B.Set,itemType:wt})],Dp);var Oo=class{constructor(e={}){f(this,"version",ht.v0);f(this,"originatorInfo");f(this,"recipientInfos",new rc);f(this,"encryptedContentInfo",new Cn);f(this,"unprotectedAttrs");Object.assign(this,e);}};p([g({type:S.Integer})],Oo.prototype,"version",void 0);p([g({type:Js,context:0,implicit:true,optional:true})],Oo.prototype,"originatorInfo",void 0);p([g({type:rc})],Oo.prototype,"recipientInfos",void 0);p([g({type:Cn})],Oo.prototype,"encryptedContentInfo",void 0);p([g({type:Dp,context:1,implicit:true,optional:true})],Oo.prototype,"unprotectedAttrs",void 0);var Op,Ml=Op=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Op.prototype);}};Ml=Op=p([N({type:B.Set,itemType:mt})],Ml);var Ri=class{constructor(e={}){f(this,"version",ht.v0);f(this,"digestAlgorithms",new Ml);f(this,"encapContentInfo",new No);f(this,"certificates");f(this,"crls");f(this,"signerInfos",new z0);Object.assign(this,e);}};p([g({type:S.Integer})],Ri.prototype,"version",void 0);p([g({type:Ml})],Ri.prototype,"digestAlgorithms",void 0);p([g({type:No})],Ri.prototype,"encapContentInfo",void 0);p([g({type:js,context:0,implicit:true,optional:true})],Ri.prototype,"certificates",void 0);p([g({type:Qs,context:1,implicit:true,optional:true})],Ri.prototype,"crls",void 0);p([g({type:z0})],Ri.prototype,"signerInfos",void 0);var hC=Gt.Point.Fp;hC.ORDER;var mC=Gt.Point.CURVE().n,gC=8n,yC=mC/gC,ea=bs(yC,{BITS:249});Gt.Point.Fp;var Tn={x:5299619240641551281634865583518297030282874472190772894086521144482721001553n,y:16950150798460657717958625567821834550301663161624707787222815936182638968203n};Gt.Point.fromAffine(Tn);Gt.Point.fromAffine(Tn);new TextEncoder().encode("FROST_2_NONCE_COMBINER");var pb=Object.defineProperty,_C=Object.getOwnPropertyDescriptor,CC=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),hb=(t,e)=>()=>(t&&(e=t(t=0)),e),IC=(t,e)=>{for(var r in e)pb(t,r,{get:e[r],enumerable:true});},Dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?_C(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&pb(e,r,n),n},Di,ic,Gl=hb(()=>{Di={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},ic={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),UC={};IC(UC,{modPow:()=>yb,verifyDscSignature:()=>VC,verifyDscSignatureWithTbs:()=>jC,verifyECDSASignature:()=>zp,verifyRSASignature:()=>qp});function mb(t){return t<=192?["SHA-1","SHA-224","SHA-256","SHA-384","SHA-512"]:t<=256?["SHA-256","SHA-1","SHA-224","SHA-384","SHA-512"]:t<=384?["SHA-384","SHA-256","SHA-512","SHA-1","SHA-224"]:["SHA-512","SHA-384","SHA-256","SHA-1","SHA-224"]}function FC(t,e){if(t.length===e*2||t[0]!==48)return t;let r=t[1]===t.length-2?1:2,i=t[r];if(t[r+1]!==2||i!==t.length-r-1)return t;let n=t[r+2],o=t.slice(r+3,r+3+n);if(t[r+3+n]!==2)return t;let s=t[r+3+n+1],a=t.slice(r+3+n+2,r+3+n+2+s);for(;o.length>0&&o[0]===0;)o=o.slice(1);for(;a.length>0&&a[0]===0;)a=a.slice(1);let c=new Uint8Array(e),l=new Uint8Array(e);c.set(o,e-o.length),l.set(a,e-a.length);let d=new Uint8Array(e*2);return d.set(c,0),d.set(l,e),d}function zp(t,e,r){let i=bb[r.curve];if(!i)return false;try{let n=Math.ceil(r.key_size/8),o=FC(e,n),s=Buffer.from(r.public_key_x.replace("0x",""),"hex"),a=Buffer.from(r.public_key_y.replace("0x",""),"hex"),c=new Uint8Array(n),l=new Uint8Array(n);c.set(s,n-s.length),l.set(a,n-a.length);let d=new Uint8Array(1+n*2);return d[0]=4,d.set(c,1),d.set(l,1+n),i.verify(o,t,d,{prehash:!1,lowS:!1})}catch{return false}}async function qp(t,e,r,i,n,o){try{if(Sb.includes(n)){let s=HC();if(s)return await KC(t,r,i,n,o,s)}return zC(e,r,i,n,o)}catch{return false}}function LC(t){if(t===0)return new Uint8Array([0]);let e=[];for(;t>0;)e.unshift(t&255),t=t>>>8;return new Uint8Array(e)}function HC(){return typeof globalThis<"u"&&globalThis.crypto?.subtle?globalThis.crypto.subtle:typeof globalThis<"u"&&globalThis.crypto?.webcrypto?.subtle?globalThis.crypto.webcrypto.subtle:null}async function KC(t,e,r,i,n,o){let s=new Uint8Array(Buffer.from(r.modulus.replace("0x",""),"hex")),a=LC(r.exponent),c={kty:"RSA",n:ob(s),e:ob(a),alg:n?`PS${i.replace("SHA-","")}`:`RS${i.replace("SHA-","")}`,ext:true},l=n?{name:"RSA-PSS",hash:{name:i}}:{name:"RSASSA-PKCS1-v1_5",hash:{name:i}},d=n?{name:"RSA-PSS",saltLength:gb(i)}:{name:"RSASSA-PKCS1-v1_5"};try{let u=await o.importKey("jwk",c,l,!1,["verify"]),h=new Uint8Array(e).buffer,m=new Uint8Array(t).buffer;return await o.verify(d,u,h,m)}catch{return false}}function ob(t){return Buffer.from(t).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function gb(t){switch(t){case "SHA-1":return 20;case "SHA-224":return 28;case "SHA-256":return 32;case "SHA-384":return 48;case "SHA-512":return 64;default:return 32}}function zC(t,e,r,i,n){try{let o=BigInt(r.modulus),s=BigInt(r.exponent),a=Math.ceil(r.key_size/8);if(e.length!==a)if(e.length<a){let h=new Uint8Array(a);h.set(e,a-e.length),e=h;}else return !1;let c=BigInt(0);for(let h of e)c=c<<BigInt(8)|BigInt(h);if(c>=o)return !1;let l=yb(c,s,o),d=new Uint8Array(a),u=l;for(let h=a-1;h>=0;h--)d[h]=Number(u&BigInt(255)),u=u>>BigInt(8);return n?GC(d,t,i,r.key_size):qC(d,t,i)}catch{return false}}function yb(t,e,r){if(r===BigInt(1))return BigInt(0);let i=BigInt(1);for(t=t%r;e>BigInt(0);)e%BigInt(2)===BigInt(1)&&(i=i*t%r),e=e>>BigInt(1),t=t*t%r;return i}function qC(t,e,r){if(t[0]!==0||t[1]!==1)return false;let i=2;for(;i<t.length&&t[i]===255;)i++;if(i-2<Ab||i>=t.length||t[i]!==0)return false;i++;let n=t.slice(i),o=xb[r];if(sb(n,e,o))return true;let s=wb[r];return !!sb(n,e,s)}function sb(t,e,r){if(t.length!==r.length+e.length)return false;let i=0;for(let n=0;n<r.length;n++)i|=t[n]^r[n];for(let n=0;n<e.length;n++)i|=t[r.length+n]^e[n];return i===0}function GC(t,e,r,i){let n=$l[r],o=gb(r),s=i-1,a=Math.ceil(s/8);if(a<o+2)return false;let c=t.length>a?t.slice(t.length-a):t;if(c.length<a||c[a-1]!==188)return false;let l=a-o-1,d=c.slice(0,l),u=c.slice(l,l+o),h=255>>8*a-s;if((d[0]&~h)!==0)return false;let m=$C(u,l,n),b=new Uint8Array(l);for(let C=0;C<l;C++)b[C]=d[C]^m[C];b[0]&=h;let A=-1;for(let C=0;C<l;C++)if(b[C]===1){A=C;break}else if(b[C]!==0)return false;if(A===-1)return false;let x=l-A-1;if(x<0)return false;let y=b.slice(A+1),w=new Uint8Array(8+o+x);w.set(e,8),x>0&&w.set(y,8+o);let I=n(w);if(u.length!==I.length)return false;let _=0;for(let C=0;C<u.length;C++)_|=u[C]^I[C];return _===0}function $C(t,e,r){let i=r(new Uint8Array(0)).length,n=new Uint8Array(e),o=0;for(let s=0;o<e;s++){let a=new Uint8Array(4);a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255;let c=new Uint8Array(t.length+4);c.set(t),c.set(a,t.length);let l=r(c),d=Math.min(i,e-o);n.set(l.slice(0,d),o),o+=d;}return n}async function VC(t,e){let r=t.tbs.bytes.toUInt8Array(),i=t.signature.toUInt8Array(),n=e.public_key.type==="EC",o=e.signature_algorithm==="RSA-PSS",s=e.public_key.key_size,a=mb(s);for(let c of a){let l=$l[c];if(!l)continue;let d=l(r);if(n){let u=e.public_key;if(zp(d,i,u))return true}else {let u=e.public_key;if(await qp(r,d,i,u,c,o))return true}}return false}async function jC(t,e,r){let i=r.public_key.type==="EC",n=r.signature_algorithm==="RSA-PSS",o=r.public_key.key_size,s=mb(o);for(let a of s){let c=$l[a];if(!c)continue;let l=c(t);if(i){let d=r.public_key;if(zp(l,e,d))return true}else {let d=r.public_key;if(await qp(t,l,e,d,a,n))return true}}return false}var $l,ab,cb,lb,db,ub,fb,bb,Sb,xb,Ab,wb,XC=hb(()=>{Gl(),$l={"SHA-1":Jn,"SHA-224":Lr,"SHA-256":ot,"SHA-384":ps,"SHA-512":fs},ab={p:ic.brainpoolP224r1.p,a:ic.brainpoolP224r1.a,b:ic.brainpoolP224r1.b,n:ic.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},cb=Ge(qe(ab),Lr),lb={p:Di["P-192"].p,a:Di["P-192"].a,b:Di["P-192"].b,n:Di["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},db=Ge(qe(lb),Jn),ub={p:Di["P-224"].p,a:Di["P-224"].a,b:Di["P-224"].b,n:Di["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},fb=Ge(qe(ub),Lr),bb={"P-192":db,"P-224":fb,"P-256":lt,"P-384":dt,"P-521":ut,brainpoolP224r1:cb,brainpoolP256r1:gy,brainpoolP384r1:yy,brainpoolP512r1:by},Sb=["SHA-256","SHA-384","SHA-512"],xb={"SHA-1":new Uint8Array([48,33,48,9,6,5,43,14,3,2,26,5,0,4,20]),"SHA-224":new Uint8Array([48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28]),"SHA-256":new Uint8Array([48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]),"SHA-384":new Uint8Array([48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48]),"SHA-512":new Uint8Array([48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64])},Ab=8,wb={"SHA-1":new Uint8Array([48,31,48,7,6,5,43,14,3,2,26,4,20]),"SHA-224":new Uint8Array([48,43,48,11,6,9,96,134,72,1,101,3,4,2,4,4,28]),"SHA-256":new Uint8Array([48,47,48,11,6,9,96,134,72,1,101,3,4,2,1,4,32]),"SHA-384":new Uint8Array([48,63,48,11,6,9,96,134,72,1,101,3,4,2,2,4,48]),"SHA-512":new Uint8Array([48,79,48,11,6,9,96,134,72,1,101,3,4,2,3,4,64])};});var Hl=class Ze{constructor(e){this.bytes=Ze.convertToBytes(e);}static convertToBytes(e){if(typeof e=="bigint"||typeof e=="number"){let r=e.toString(16),i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}if(e instanceof Uint8Array)return new Uint8Array(e);if(Buffer.isBuffer(e))return new Uint8Array(e);if(Array.isArray(e)){if(!e.every(r=>typeof r=="number"&&r>=0&&r<=255))throw new Error("Invalid byte array: values must be between 0 and 255");return new Uint8Array(e)}if(e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e=="string"){if(Ze.isHexString(e)){let r=e.startsWith("0x")?e.slice(2):e,i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}try{let r=BigInt(e);return Ze.convertToBytes(r)}catch{return new Uint8Array(Buffer.from(e,"ascii"))}}throw new Error("Unsupported data type")}static isHexString(e){let r=e.startsWith("0x")?e.slice(2):e;return /^[0-9a-fA-F]*$/.test(r)}static from(e){return new Ze(e)}static fromHex(e){if(!Ze.isHexString(e))throw new Error("Invalid hex string");return new Ze(e.startsWith("0x")?e:"0x"+e)}static fromBuffer(e){return new Ze(e)}static fromBase64(e){let r=atob(e);return new Ze(Uint8Array.from(r,i=>i.charCodeAt(0)))}static empty(){return new Ze(new Uint8Array(0))}static zero(e){return new Ze(new Uint8Array(e))}toBigInt(){return BigInt("0x"+this.toHex().slice(2))}toUInt8Array(){return new Uint8Array(this.bytes)}toNumberArray(){return Array.from(this.bytes)}toHex(){return "0x"+Array.from(this.bytes).map(e=>e.toString(16).padStart(2,"0")).join("")}toBuffer(){return Buffer.from(this.bytes)}toString(e="hex"){return e==="hex"?this.toHex().slice(2):Buffer.from(this.bytes).toString(e)}toBase64(){return btoa(String.fromCharCode(...this.bytes))}toJSON(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return `Binary(${this.toHex()})`}[Symbol.toPrimitive](e){switch(e){case "number":return Number(this.toBigInt());case "string":return `Binary(${this.toHex()})`;default:return this.toBigInt()}}valueOf(){return this.toBigInt()}get length(){return this.bytes.length}*[Symbol.iterator](){yield*this.bytes;}equals(e){return this.length!==e.length?false:this.bytes.every((r,i)=>r===e.bytes[i])}slice(e,r){return new Ze(this.bytes.slice(e,r))}concat(e){return new Ze([...this.toNumberArray(),...e.toNumberArray()])}[Symbol.for("+")](e){return this.concat(e)}compare(e){let r=Math.min(this.length,e.length);for(let i=0;i<r;i++){let n=this.bytes[i]-e.bytes[i];if(n!==0)return n}return this.length-e.length}xor(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for XOR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]^e.bytes[i];return new Ze(r)}and(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for AND operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]&e.bytes[i];return new Ze(r)}or(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for OR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]|e.bytes[i];return new Ze(r)}not(){let e=new Uint8Array(this.length);for(let r=0;r<this.length;r++)e[r]=~this.bytes[r]&255;return new Ze(e)}padStart(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.fill(r,0,e-this.length),i.set(this.bytes,e-this.length),new Ze(i)}padEnd(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.set(this.bytes),i.fill(r,this.length),new Ze(i)}};BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");function _b(t){return t.startsWith("0x")?t.slice(2):t}function ZC(t){return BigInt("0x"+Buffer.from(t).toString("hex"))}function Mo(t,e){return t.concat(Array(e-t.length).fill(0))}function Cb(t,e){return Array(e-t.length).fill(0).concat(t)}function Uo(t,e){let r=BigInt(0);for(let i=0;i<e;i++)r*=BigInt(256),r+=BigInt(t[i]);return r}function YC(t,e){let r=BigInt(0);for(let i=0;i<Math.min(e,t.length);i++)r*=BigInt(2),r+=BigInt(t[i]);return r}function Ib(t,e){if(t.length===0)return [];let r=Math.ceil(t.length/e),i=new Array(r),n=t.length%e||e,o=0;for(let s=r-1;s>=0;s--){let a=s===r-1?n:e,c=0n;for(let d=0;d<a;d++)c=c<<8n|BigInt(t[o++]);let l=c.toString(16);i[s]="0x"+(l.length%2?"0":"")+l;}return i}var Kl={ethereum:1,base:8453,arbitrum:42161,optimism:10,polygon:137,celo:42220,gnosis:100,scroll:534352,linea:59144,world_chain:480,robinhood:4663,ethereum_sepolia:11155111,base_sepolia:84532,arbitrum_sepolia:421614,polygon_amoy:80002,celo_sepolia:11142220,gnosis_chiado:10200,scroll_sepolia:534351,linea_sepolia:59141,world_chain_sepolia:4801,local:31337};function Oi(t){if(!Kl[t])throw new Error(`Unsupported chain: ${t}`);return Kl[t]}function nc(t){for(let e in Kl)if(Kl[e]===t)return e;throw new Error(`Unsupported chain ID: ${t}`)}function Gp(t,e){return t.bind?.chain??(e?"ethereum_sepolia":"ethereum")}function me(t,e){return (typeof t=="string"||typeof t=="number")&&(t=new Date(t)),(typeof e=="string"||typeof e=="number")&&(e=new Date(e)),t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function kn(t){return typeof t=="string"||typeof t=="number"?new Date(t):t}function $p(t){for(let e in t){let r=t[e];if((e==="birthdate"||e==="expiry_date")&&r&&typeof r=="object"){if("eq"in r&&r.eq&&(r.eq.expected=kn(r.eq.expected)),"gte"in r&&r.gte&&(r.gte.expected=kn(r.gte.expected)),"gt"in r&&r.gt&&(r.gt.expected=kn(r.gt.expected)),"lte"in r&&r.lte&&(r.lte.expected=kn(r.lte.expected)),"lt"in r&&r.lt&&(r.lt.expected=kn(r.lt.expected)),"range"in r&&r.range&&Array.isArray(r.range.expected)){let[i,n]=r.range.expected;r.range.expected=[kn(i),kn(n)];}"disclose"in r&&r.disclose&&(r.disclose.result=kn(r.disclose.result));}}return t}function Te(t,e){return jn(t.toString(16).padStart(e*2,"0"))}async function Vp(t,e=3){let r;for(let i=0;i<=e;i++)try{return await t()}catch(n){if(r=n,i===e)throw n;let o=Math.min(100*Math.pow(2,i),5e3);await new Promise(s=>setTimeout(s,o));}throw r}var Pe=(t=>(t[t.NON_SALTED=0]="NON_SALTED",t[t.SALTED=1]="SALTED",t[t.NON_SALTED_MOCK=2]="NON_SALTED_MOCK",t[t.SALTED_MOCK=3]="SALTED_MOCK",t[t.NONE=4]="NONE",t))(Pe||{});function vb(t){return BigInt(t.publicInputs[0])}function Eb(t){return BigInt(t.publicInputs[1])}function QC(){return 2}function Bb(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function Tb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function JC(){return 2}function ta(t){return t==="D<<"?"DEU":t}function Mp(t){return t.replace(/^<+|<+$/g,"").replace(/</g," ")}function ve(t){return t.replace(/<+/g," ").replace(/</g," ").replace(/\s+/g," ").replace(/[áàâäãå]/g,"a").replace(/[éèêë]/g,"e").replace(/[íìîï]/g,"i").replace(/[óòôöõ]/g,"o").replace(/[úùûü]/g,"u").replace(/[ñ]/g,"n").replace(/[ç]/g,"c").replace(/[æ]/g,"ae").replace(/[œ]/g,"oe").replace(/[ø]/g,"o").replace(/[æ]/g,"ae").replace(/[œ]/g,"oe").replace(/[ø]/g,"o").replace(/[^a-zA-Z ]/g,"").trim()}function Up(t){return t.startsWith("P")?"passport":t==="IR"||t==="AR"?"residence_permit":t.startsWith("I")?"id_card":"other"}var jp=class Ll{constructor(e){this.issuingCountry=e.issuingCountry,this.nationality=e.nationality,this.documentType=e.documentType,this.documentNumber=e.documentNumber,this.dateOfExpiry=e.dateOfExpiry,this.dateOfBirth=e.dateOfBirth,this.name=e.name,this.gender=e.gender,this.firstName=e.firstName,this.lastName=e.lastName;}static fromDisclosedBytes(e,r){let i={issuingCountry:new Uint8Array(e.slice(2,5)),nationality:new Uint8Array(e.slice(r==="id_card"?45:54,r==="id_card"?48:57)),documentType:new Uint8Array(e.slice(0,2)),documentNumber:new Uint8Array(e.slice(r==="id_card"?5:44,r==="id_card"?14:53)),dateOfExpiry:new Uint8Array(e.slice(r==="id_card"?38:65,r==="id_card"?44:71)),dateOfBirth:new Uint8Array(e.slice(r==="id_card"?30:57,r==="id_card"?36:63)),name:new Uint8Array(e.slice(r==="id_card"?60:5,r==="id_card"?90:44)),gender:new Uint8Array(e.slice(r==="id_card"?37:64,r==="id_card"?38:65))},n=new TextDecoder,o=m=>n.decode(m).replace(/\0/g,""),s=i.name&&i.name.length>0?o(i.name):"",a=s.indexOf("<<"),c=a>=0?s.substring(0,a):"",l=a>=0?s.substring(a+2):"",d=l.indexOf("<"),u=d>=0?l.substring(0,d):l,h=l+" "+c;return new Ll({issuingCountry:ta(o(i.issuingCountry)),nationality:ta(o(i.nationality)),documentType:Up(o(i.documentType)),documentNumber:Mp(o(i.documentNumber)),dateOfExpiry:ra(i.dateOfExpiry),dateOfBirth:ra(i.dateOfBirth),name:ve(h),firstName:ve(u),lastName:ve(c),gender:o(i.gender)})}static fromFlagsProof(e){let r=e.publicInputs.slice(3,93).map(m=>parseInt(m,16)),i={issuingCountry:new Uint8Array(r.slice(0,3)),nationality:new Uint8Array(r.slice(3,6)),documentType:new Uint8Array(r.slice(6,8)),documentNumber:new Uint8Array(r.slice(8,17)),dateOfExpiry:new Uint8Array(r.slice(17,23)),dateOfBirth:new Uint8Array(r.slice(23,29)),name:new Uint8Array(r.slice(29,68)),gender:new Uint8Array(r.slice(68,69))},n=new TextDecoder,o=m=>n.decode(m).replace(/\0/g,""),s=i.name&&i.name.length>0?o(i.name):"",a=s.indexOf("<<"),c=a>0?s.substring(0,a):"",l=a>0?s.substring(a+2):"",d=l.indexOf("<"),u=d>=0?l.substring(0,d):l,h=l+" "+c;return new Ll({issuingCountry:ta(o(i.issuingCountry)),nationality:ta(o(i.nationality)),documentType:Up(o(i.documentType)),documentNumber:Mp(o(i.documentNumber)),dateOfExpiry:ra(i.dateOfExpiry),dateOfBirth:ra(i.dateOfBirth),name:ve(h),firstName:ve(u),lastName:ve(c),gender:o(i.gender)})}static fromBytesProof(e,r){let i=e.publicInputs.slice(93,182).map(b=>parseInt(b,16)),n={issuingCountry:new Uint8Array(i.slice(2,5)),nationality:new Uint8Array(i.slice(r==="id_card"?45:54,r==="id_card"?48:57)),documentType:new Uint8Array(i.slice(0,2)),documentNumber:new Uint8Array(i.slice(r==="id_card"?5:44,r==="id_card"?14:53)),dateOfExpiry:new Uint8Array(i.slice(r==="id_card"?38:65,r==="id_card"?44:71)),dateOfBirth:new Uint8Array(i.slice(r==="id_card"?30:57,r==="id_card"?36:63)),name:new Uint8Array(i.slice(r==="id_card"?60:5,r==="id_card"?90:44)),gender:new Uint8Array(i.slice(r==="id_card"?37:64,r==="id_card"?38:65))},o=new TextDecoder,s=b=>o.decode(b).replace(/\0/g,""),a=n.name&&n.name.length>0?s(n.name):"",c=a.indexOf("<<"),l=c>=0?a.substring(0,c):"",d=c>=0?a.substring(c+2):"",u=d.indexOf("<"),h=u>=0?d.substring(0,u):d,m=d+" "+l;return new Ll({issuingCountry:ta(s(n.issuingCountry)),nationality:ta(s(n.nationality)),documentType:Up(s(n.documentType)),documentNumber:Mp(s(n.documentNumber)),dateOfExpiry:ra(n.dateOfExpiry),dateOfBirth:ra(n.dateOfBirth),name:ve(m),firstName:ve(h),lastName:ve(l),gender:s(n.gender)})}};function ra(t){let e=new TextDecoder().decode(t).replace(/\0/g,""),r=parseInt(e.substring(0,2)),i=parseInt(e.substring(2,4))-1,n=parseInt(e.substring(4,6)),o=new Date().getFullYear(),s=Math.floor(o/100)*100,a=s-100,c=r+(r+s>o+10?a:s);return new Date(Date.UTC(c,i,n,0,0,0,0))}async function Xp(t,e){return await Me([BigInt(0),BigInt(se[0].standard),YC(t,253),...Ib(new Uint8Array(e),31).map(r=>BigInt(r))])}async function kb(t,e){let r=ot(new Uint8Array([0,...Te(se[0].evm,2),...t.map(i=>Number(i)),...e.map(i=>Number(i))]));return Uo(r,31)}function Pb(t){return t.minAge}function Nb(t){return t.maxAge}async function Wp(t,e){return await Me([BigInt(1),BigInt(se[1].standard),BigInt(t),BigInt(e)])}async function Rb(t,e){let r=ot(new Uint8Array([1,...Te(se[1].evm,2),t,e]));return Uo(r,31)}function eI(t){return t.charCodeAt(0)*65536+t.charCodeAt(1)*256+t.charCodeAt(2)}async function Mi(t,e,r=false){let i=e.map(o=>eI(o)),n=Mo(r?i.sort((o,s)=>o-s):i,200).map(o=>BigInt(o));return await Me([BigInt(t),BigInt(se[t].standard),...n])}async function oc(t,e,r=false){r&&e.sort((o,s)=>o.localeCompare(s));let i=e.map(o=>Array.from(new TextEncoder().encode(o))).flat(),n=ot(new Uint8Array([t,...Te(se[t].evm,2),...Mo(i,600)]));return Uo(n,31)}var Fo=Math.floor(Math.abs(Date.UTC(1900,0,1,0,0,0))/1e3);function zl(t){return new Date(t.minDateTimestamp*1e3)}function ql(t){return new Date(t.maxDateTimestamp*1e3)}function Db(t,e=Fo){return zl(t).getTime()===0?new Date(0):new Date(zl(t).getTime()+e*1e3)}function Ob(t,e=Fo){return ql(t).getTime()===0?new Date(0):new Date(ql(t).getTime()+e*1e3)}async function sc(t,e,r,i=Fo){return await Me([BigInt(t),BigInt(se[t].standard),t===2&&e!==0?BigInt(e)+BigInt(i):BigInt(e),t===2&&r!==0?BigInt(r)+BigInt(i):BigInt(r)])}async function Zp(t,e,r,i=Fo){let n=ot(new Uint8Array([t,...Te(se[t].evm,2),...Te(t===2&&e!==0?e+i:e,8),...Te(t===2&&r!==0?r+i:r,8)]));return Uo(n,31)}function Mb(t){return BigInt(t.publicInputs[0])}function Ub(t){return BigInt(t.publicInputs[1])}function tI(){return 2}var rI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(rI||{});function ac(t){let e=[];if(t.user_address&&t.user_address.length>0){let r=Hl.fromHex(t.user_address).toNumberArray();e=[...e,1,...Cb([r.length],2),...r];}if(t.chain){let r=Oi(t.chain),i=Hl.fromHex(r.toString(16)).toNumberArray();e=[...e,2,0,i.length,...i];}if(t.custom_data&&t.custom_data.length>0){let r=new TextEncoder().encode(t.custom_data);e=[...e,3,r.length>>8&255,r.length&255,...r];}if(e.length>509)throw new Error(`Data is too long: ${e.length} > 509`);return e}async function Yp(t,e=509){let r=Mo(t,e);return await Me([BigInt(8),BigInt(se[8].standard),...Ib(new Uint8Array(r),31).map(i=>BigInt(i))])}async function Fb(t,e=509){let r=Mo(t,e),i=ot(new Uint8Array([8,...Te(se[8].evm,2),...r]));return Uo(i,31)}var Lb=8544227306600425492560068004835614964118871262589609739238120993689090208159n,Hb=0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615dn;async function Qp(t,e,r,i){return await Me([BigInt(10),BigInt(se[10].standard),t,e,r,r===Hb?Lb:0n,i])}async function Kb(t,e,r,i){let n=ot(new Uint8Array([10,...Te(se[10].evm,2),...Te(t,32),...Te(e,1),...Te(r,32),...Te(r===Hb?Lb:0n,32),...Te(i,1)]));return Uo(n,31)}function Nr(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function zb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function Rr(t){let e=BigInt(t.publicInputs[t.publicInputs.length-3]);if(e===0n)return 0;if(e===1n)return 1;if(e===2n)return 2;if(e===3n)return 3;if(e===4n)return 4;throw new Error("Invalid nullifier type")}function pr(t){return BigInt(t.publicInputs[4])}function Jp(t){return BigInt(t.publicInputs[3])}function eh(t){return BigInt(t.publicInputs[2])}function hr(t){return BigInt(t.publicInputs[0])}function th(t){return new Date(Number(BigInt(t.publicInputs[1]))*1e3)}function ia(t){return t.startsWith("data_check_integrity")?JC():t.startsWith("sig_check_id_data")?tI():t.startsWith("sig_check_dsc")?QC():t.startsWith("oprf_auth")?3:t.startsWith("outer")?8+(Number(t.substring(t.lastIndexOf("_")+1))-3):8}function qb(t){let e=t.endsWith("evm")?3:2;switch(t){case "compare_age":return se[1].standard+e;case "compare_age_evm":return se[1].evm+e;case "compare_birthdate":return se[2].standard+e;case "compare_birthdate_evm":return se[2].evm+e;case "compare_expiry":return se[3].standard+e;case "compare_expiry_evm":return se[3].evm+e;case "disclose_bytes":return se[0].standard+e;case "disclose_bytes_evm":return se[0].evm+e;case "inclusion_check_issuing_country":return se[6].standard+e;case "inclusion_check_issuing_country_evm":return se[6].evm+e;case "inclusion_check_nationality":return se[4].standard+e;case "inclusion_check_nationality_evm":return se[4].evm+e;case "exclusion_check_issuing_country":return se[7].standard+e;case "exclusion_check_issuing_country_evm":return se[7].evm+e;case "exclusion_check_nationality":return se[5].standard+e;case "exclusion_check_nationality_evm":return se[5].evm+e;case "bind":return se[8].standard+e;case "bind_evm":return se[8].evm+e;case "exclusion_check_sanctions":return se[9].standard+e;case "exclusion_check_sanctions_evm":return se[9].evm+e;case "facematch":return se[10].standard+e;case "facematch_evm":return se[10].evm+e;default:throw new Error(`Unknown circuit name: ${t}`)}}var fe=(t=>(t[t.DISCLOSE=0]="DISCLOSE",t[t.AGE=1]="AGE",t[t.BIRTHDATE=2]="BIRTHDATE",t[t.EXPIRY_DATE=3]="EXPIRY_DATE",t[t.NATIONALITY_INCLUSION=4]="NATIONALITY_INCLUSION",t[t.NATIONALITY_EXCLUSION=5]="NATIONALITY_EXCLUSION",t[t.ISSUING_COUNTRY_INCLUSION=6]="ISSUING_COUNTRY_INCLUSION",t[t.ISSUING_COUNTRY_EXCLUSION=7]="ISSUING_COUNTRY_EXCLUSION",t[t.BIND=8]="BIND",t[t.SANCTIONS_EXCLUSION=9]="SANCTIONS_EXCLUSION",t[t.FACEMATCH=10]="FACEMATCH",t))(fe||{}),se={0:{evm:180,standard:4},1:{evm:2,standard:2},2:{evm:16,standard:2},3:{evm:16,standard:2},4:{evm:600,standard:200},5:{evm:600,standard:200},6:{evm:600,standard:200},7:{evm:600,standard:200},8:{evm:509,standard:17},9:{evm:33,standard:2},10:{evm:98,standard:5}};Gl();var Gb=["North Korea","Iran","Iraq","Libya","Somalia","Sudan","Syrian Arab Republic","Yemen"],Vl=["Austria","Belgium","Bulgaria","Croatia","Cyprus","Czech Republic","Denmark","Estonia","Finland","France","Germany","Greece","Hungary","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Netherlands","Poland","Portugal","Romania","Slovakia","Slovenia","Spain","Sweden"],$b=[...Vl,"Iceland","Liechtenstein","Norway"],Vb=[...Vl.filter(t=>t!=="Cyprus"&&t!=="Ireland"),"Switzerland","Iceland","Liechtenstein","Norway"],jb=["Brunei Darussalam","Cambodia","Indonesia","Lao People's Democratic Republic","Malaysia","Myanmar","Philippines","Singapore","Thailand","Vietnam"],Xb=["Argentina","Brazil","Chile","Colombia","Paraguay","Uruguay"];Gl();var Lp=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,Lp.prototype);}};Lp=Dt([N({type:B.Set,itemType:wt})],Lp);var Hp=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Dt([g({type:S.Integer})],Hp.prototype,"number",2),Dt([g({type:S.OctetString})],Hp.prototype,"hash",2);var Kp=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Dt([g({type:S.PrintableString})],Kp.prototype,"ldsVersion",2),Dt([g({type:S.PrintableString})],Kp.prototype,"unicodeVersion",2);var Fp=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Dt([g({type:S.ObjectIdentifier})],Fp.prototype,"value",2),Fp=Dt([N({type:B.Choice})],Fp);var Ul=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Dt([g({type:S.Integer})],Ul.prototype,"version",2),Dt([g({type:mt})],Ul.prototype,"hashAlgorithm",2),Dt([g({type:Hp,repeated:"sequence"})],Ul.prototype,"dataGroups",2),Dt([g({type:Kp,optional:true})],Ul.prototype,"versionInfo",2);var Fl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Dt([g({type:S.Integer})],Fl.prototype,"version",2),Dt([g({type:$t,repeated:"set"})],Fl.prototype,"certificates",2),Fl=Dt([N({type:B.Sequence})],Fl);Gl();var iI=["https://eu.node0.zkp.oprf.taceo.network","https://eu.node1.zkp.oprf.taceo.network","https://eu.node2.zkp.oprf.taceo.network"],Wb="1";Gt.Point.fromAffine(Tn);ea.ORDER;async function Zb(t,e){let r=iI,i;for(let n of r)try{let o=await fetch(`${n}/oprf_pub/${t}`);if(!o.ok)throw new Error(`OPRF node returned ${o.status}`);let{key:s}=await o.json();return {x:BigInt(s[0]),y:BigInt(s[1])}}catch(o){i=o instanceof Error?o:new Error(String(o));}throw new Error(`Failed to fetch OPRF public key for key ID ${t}: ${i?.message}`)}async function Yb(t){return Me([t.x,t.y])}async function Qb(t,e){let r=Array.from(Buffer.from(_b(t).padStart(64,"0"),"hex")),i=Cb(r,32),n=ot(new Uint8Array([9,...Te(se[9].evm,2),...i,e?1:0]));return Uo(n,31)}async function rh(t,e){return Me([BigInt(9),BigInt(se[9].standard),BigInt(`0x${_b(t)}`),e?1n:0n])}function na(t){if(!t)return 0n;let e=ot(new TextEncoder().encode(t)).slice(0,31);return ZC(Array.from(e))}function cc(t){return na(t)}function nI(t,e=0){let r=[];for(let i=e;i<t.length;i+=32){let n=new Uint8Array(32),o=Math.min(i+32,t.length);for(let s=0;s<o-i;s++)n[s]=t[i+s];r.push(Buffer.from(n));}return r.map(i=>i.toString("hex"))}function oI(t,e){return t.slice(0,e)}function sI(t,e){return t.slice(e)}function oa(t,e,r=0){let i=nI(Buffer.from(t,"hex"),r),n=sI(i,e),o=oI(i,e);return {proof:n,publicInputs:o.map(s=>s.startsWith("0x")?s:`0x${s}`)}}function Jb(t){return BigInt(t.publicInputs[0])}function e6(t){return BigInt(t.publicInputs[1])}function t6(t){return new Date(Number(BigInt(t.publicInputs[2]))*1e3)}function ih(t){return BigInt(t.publicInputs[3])}function nh(t){return BigInt(t.publicInputs[4])}function r6(t){let e=BigInt(t.publicInputs[t.publicInputs.length-3]);if(e===0n)return 0;if(e===1n)return 1;if(e===2n)return 2;if(e===3n)return 3;if(e===4n)return 4;throw new Error("Invalid nullifier type")}function i6(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function n6(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function oh(t){return t.publicInputs.slice(5,t.publicInputs.length-3).map(BigInt)}if(typeof window>"u")try{let t=CC("crypto");crypto=t;}catch{}XC();var es=It(Il(),1);var aI=Object.defineProperty,cI=Object.getOwnPropertyDescriptor,lI=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),c6=(t,e)=>()=>(t&&(e=t(t=0)),e),Ot=(t,e,r,i)=>{for(var n=i>1?void 0:i?cI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&aI(e,r,n),n},Ui,lc,Wl=c6(()=>{Ui={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},lc={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),o6,s6,a6,dI=c6(()=>{Wl(),o6={p:lc.brainpoolP224r1.p,a:lc.brainpoolP224r1.a,b:lc.brainpoolP224r1.b,n:lc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(o6),Lr),s6={p:Ui["P-192"].p,a:Ui["P-192"].a,b:Ui["P-192"].b,n:Ui["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(s6),Jn),a6={p:Ui["P-224"].p,a:Ui["P-224"].a,b:Ui["P-224"].b,n:Ui["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(a6),Lr);});BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Wl();Wl();var ah=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,ah.prototype);}};ah=Ot([N({type:B.Set,itemType:wt})],ah);var ch=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Ot([g({type:S.Integer})],ch.prototype,"number",2),Ot([g({type:S.OctetString})],ch.prototype,"hash",2);var lh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Ot([g({type:S.PrintableString})],lh.prototype,"ldsVersion",2),Ot([g({type:S.PrintableString})],lh.prototype,"unicodeVersion",2);var sh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Ot([g({type:S.ObjectIdentifier})],sh.prototype,"value",2),sh=Ot([N({type:B.Choice})],sh);var jl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Ot([g({type:S.Integer})],jl.prototype,"version",2),Ot([g({type:mt})],jl.prototype,"hashAlgorithm",2),Ot([g({type:ch,repeated:"sequence"})],jl.prototype,"dataGroups",2),Ot([g({type:lh,optional:true})],jl.prototype,"versionInfo",2);var Xl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Ot([g({type:S.Integer})],Xl.prototype,"version",2),Ot([g({type:$t,repeated:"set"})],Xl.prototype,"certificates",2),Xl=Ot([N({type:B.Sequence})],Xl);Wl();Gt.Point.fromAffine(Tn);ea.ORDER;if(typeof window>"u")try{let t=lI("crypto");crypto=t;}catch{}dI();function uI(t){return "0x"+Buffer.from(t).toString("hex").padStart(64,"0")}function l6(t){let e=[];for(let r=0;r<t.length;r+=32)e.push(uI(t.slice(r,r+32)));return e}var fI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(fI||{});var pI=(t=>(t[t.DISCLOSE=0]="DISCLOSE",t[t.AGE=1]="AGE",t[t.BIRTHDATE=2]="BIRTHDATE",t[t.EXPIRY_DATE=3]="EXPIRY_DATE",t[t.NATIONALITY_INCLUSION=4]="NATIONALITY_INCLUSION",t[t.NATIONALITY_EXCLUSION=5]="NATIONALITY_EXCLUSION",t[t.ISSUING_COUNTRY_INCLUSION=6]="ISSUING_COUNTRY_INCLUSION",t[t.ISSUING_COUNTRY_EXCLUSION=7]="ISSUING_COUNTRY_EXCLUSION",t[t.BIND=8]="BIND",t[t.SANCTIONS_EXCLUSION=9]="SANCTIONS_EXCLUSION",t[t.FACEMATCH=10]="FACEMATCH",t))(pI||{});var hI=Object.defineProperty,mI=Object.getOwnPropertyDescriptor,gI=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),m6=(t,e)=>()=>(t&&(e=t(t=0)),e),Mt=(t,e,r,i)=>{for(var n=i>1?void 0:i?mI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&hI(e,r,n),n},Fi,dc,Jl=m6(()=>{Fi={"P-192":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffcn,b:0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1n,n:0xffffffffffffffffffffffff99def836146bc9b1b4d22831n,p:0xfffffffffffffffffffffffffffffffeffffffffffffffffn},"P-224":{a:0xfffffffffffffffffffffffffffffffefffffffffffffffffffffffen,b:0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4n,n:0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3dn,p:0xffffffffffffffffffffffffffffffff000000000000000000000001n},"P-256":{a:lt.Point.CURVE().a,b:lt.Point.CURVE().b,n:lt.Point.CURVE().n,p:lt.Point.CURVE().p},"P-384":{a:dt.Point.CURVE().a,b:dt.Point.CURVE().b,n:dt.Point.CURVE().n,p:dt.Point.CURVE().p},"P-521":{a:ut.Point.CURVE().a,b:ut.Point.CURVE().b,n:ut.Point.CURVE().n,p:ut.Point.CURVE().p}},dc={brainpoolP160r1:{a:0x340e7be2a280eb74e2be61bada745d97e8f7c300n,b:0x1e589a8595423412134faa2dbdec95c8d8675e58n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP160t1:{a:0xe95e4a5f737059dc60dfc7ad95b3d8139515620cn,b:0x7a556b6dae535b7b51ed2c4d7daa7a0b5c55f380n,n:0xe95e4a5f737059dc60df5991d45029409e60fc09n,p:0xe95e4a5f737059dc60dfc7ad95b3d8139515620fn},brainpoolP192r1:{a:0x6a91174076b1e0e19c39c031fe8685c1cae040e5c69a28efn,b:0x469a28ef7c28cca3dc721d044f4496bcca7ef4146fbf25c9n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP192t1:{a:0xc302f41d932a36cda7a3463093d18db78fce476de1a86294n,b:0x13d56ffaec78681e68f9deb43b35bec2fb68542e27897b79n,n:0xc302f41d932a36cda7a3462f9e9e916b5be8f1029ac4acc1n,p:0xc302f41d932a36cda7a3463093d18db78fce476de1a86297n},brainpoolP224r1:{a:0x68a5e62ca9ce6c1c299803a6c1530b514e182ad8b0042a59cad29f43n,b:0x2580f63ccfe44138870713b1a92369e33e2135d266dbb372386c400bn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP224t1:{a:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0fcn,b:0x4b337d934104cd7bef271bf60ced1ed20da14c08b3bb64f18a60888dn,n:0xd7c134aa264366862a18302575d0fb98d116bc4b6ddebca3a5a7939fn,p:0xd7c134aa264366862a18302575d1d787b09f075797da89f57ec8c0ffn},brainpoolP256r1:{a:0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9n,b:0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP256t1:{a:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5374n,b:0x662c61c430d84ea4fe66a7733d0b76b7bf93ebc4af2f49256ae58101fee92b04n,n:0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7n,p:0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377n},brainpoolP320r1:{a:0x3ee30b568fbab0f883ccebd46d3f3bb8a2a73513f5eb79da66190eb085ffa9f492f375a97d860eb4n,b:0x520883949dfdbc42d3ad198640688a6fe13f41349554b49acc31dccd884539816f5eb4ac8fb1f1a6n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP320t1:{a:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e24n,b:0xa7f561e038eb1ed560b3d147db782013064c19f27ed27c6780aaf77fb8a547ceb5b4fef422340353n,n:0xd35e472036bc4fb7e13c785ed201e065f98fcfa5b68f12a32d482ec7ee8658e98691555b44c59311n,p:0xd35e472036bc4fb7e13c785ed201e065f98fcfa6f6f40def4f92b9ec7893ec28fcd412b1f1b32e27n},brainpoolP384r1:{a:0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826n,b:0x4a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11n,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP384t1:{a:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50n,b:0x7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471een,n:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565n,p:0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53n},brainpoolP512r1:{a:0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94can,b:0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723n,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n},brainpoolP512t1:{a:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n,b:0x7cbbbcf9441cfab76e1890e46884eae321f70c0bcb4981527897504bec3e36a62bcdfa2304976540f6450085f2dae145c22553b465763689180ea2571867423en,n:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069n,p:0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3n}};}),d6,u6,f6,yI=m6(()=>{Jl(),d6={p:dc.brainpoolP224r1.p,a:dc.brainpoolP224r1.a,b:dc.brainpoolP224r1.b,n:dc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(d6),Lr),u6={p:Fi["P-192"].p,a:Fi["P-192"].a,b:Fi["P-192"].b,n:Fi["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(u6),Jn),f6={p:Fi["P-224"].p,a:Fi["P-224"].a,b:Fi["P-224"].b,n:Fi["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(f6),Lr);}),Ql=class Qe{constructor(e){this.bytes=Qe.convertToBytes(e);}static convertToBytes(e){if(typeof e=="bigint"||typeof e=="number"){let r=e.toString(16),i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}if(e instanceof Uint8Array)return new Uint8Array(e);if(Buffer.isBuffer(e))return new Uint8Array(e);if(Array.isArray(e)){if(!e.every(r=>typeof r=="number"&&r>=0&&r<=255))throw new Error("Invalid byte array: values must be between 0 and 255");return new Uint8Array(e)}if(e instanceof ArrayBuffer)return new Uint8Array(e);if(typeof e=="string"){if(Qe.isHexString(e)){let r=e.startsWith("0x")?e.slice(2):e,i=r.padStart(Math.ceil(r.length/2)*2,"0");return new Uint8Array(i.match(/.{1,2}/g)?.map(n=>parseInt(n,16))||[])}try{let r=BigInt(e);return Qe.convertToBytes(r)}catch{return new Uint8Array(Buffer.from(e,"ascii"))}}throw new Error("Unsupported data type")}static isHexString(e){let r=e.startsWith("0x")?e.slice(2):e;return /^[0-9a-fA-F]*$/.test(r)}static from(e){return new Qe(e)}static fromHex(e){if(!Qe.isHexString(e))throw new Error("Invalid hex string");return new Qe(e.startsWith("0x")?e:"0x"+e)}static fromBuffer(e){return new Qe(e)}static fromBase64(e){let r=atob(e);return new Qe(Uint8Array.from(r,i=>i.charCodeAt(0)))}static empty(){return new Qe(new Uint8Array(0))}static zero(e){return new Qe(new Uint8Array(e))}toBigInt(){return BigInt("0x"+this.toHex().slice(2))}toUInt8Array(){return new Uint8Array(this.bytes)}toNumberArray(){return Array.from(this.bytes)}toHex(){return "0x"+Array.from(this.bytes).map(e=>e.toString(16).padStart(2,"0")).join("")}toBuffer(){return Buffer.from(this.bytes)}toString(e="hex"){return e==="hex"?this.toHex().slice(2):Buffer.from(this.bytes).toString(e)}toBase64(){return btoa(String.fromCharCode(...this.bytes))}toJSON(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return `Binary(${this.toHex()})`}[Symbol.toPrimitive](e){switch(e){case "number":return Number(this.toBigInt());case "string":return `Binary(${this.toHex()})`;default:return this.toBigInt()}}valueOf(){return this.toBigInt()}get length(){return this.bytes.length}*[Symbol.iterator](){yield*this.bytes;}equals(e){return this.length!==e.length?false:this.bytes.every((r,i)=>r===e.bytes[i])}slice(e,r){return new Qe(this.bytes.slice(e,r))}concat(e){return new Qe([...this.toNumberArray(),...e.toNumberArray()])}[Symbol.for("+")](e){return this.concat(e)}compare(e){let r=Math.min(this.length,e.length);for(let i=0;i<r;i++){let n=this.bytes[i]-e.bytes[i];if(n!==0)return n}return this.length-e.length}xor(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for XOR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]^e.bytes[i];return new Qe(r)}and(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for AND operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]&e.bytes[i];return new Qe(r)}or(e){if(this.length!==e.length)throw new Error("Binary instances must be of equal length for OR operation");let r=new Uint8Array(this.length);for(let i=0;i<this.length;i++)r[i]=this.bytes[i]|e.bytes[i];return new Qe(r)}not(){let e=new Uint8Array(this.length);for(let r=0;r<this.length;r++)e[r]=~this.bytes[r]&255;return new Qe(e)}padStart(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.fill(r,0,e-this.length),i.set(this.bytes,e-this.length),new Qe(i)}padEnd(e,r=0){if(this.length>=e)return this;let i=new Uint8Array(e);return i.set(this.bytes),i.fill(r,this.length),new Qe(i)}};function Dr(t,e){if(!t)throw new Error(e)}function sa(t,e){if(t.length===0)return [];let r=Math.ceil(t.length/e),i=new Array(r),n=t.length%e||e,o=0;for(let s=r-1;s>=0;s--){let a=s===r-1?n:e,c=0n;for(let d=0;d<a;d++)c=c<<8n|BigInt(t[o++]);let l=c.toString(16);i[s]="0x"+(l.length%2?"0":"")+l;}return i}var ed=class{constructor(t,e=2){this.depth=t,this.arity=e,this.zeroes=[],this.nodes=[];}get root(){return `0x${this.nodes[this.depth][0].toString(16).padStart(64,"0")}`}get leaves(){return this.nodes[0].slice()}async initialize(t,e=[]){if(e.length>this.arity**this.depth)throw new Error(`The tree cannot contain more than ${this.arity**this.depth} leaves`);if(new Set(e.map(r=>r.toString())).size!==e.length)throw new Error("Duplicate leaves");for(let r=0;r<this.depth;r+=1)this.zeroes.push(t),this.nodes[r]=[],t=await Me(Array(this.arity).fill(t).map(i=>BigInt(i)));if(this.nodes[this.depth]=[],e.length>0){this.nodes[0]=e;for(let r=0;r<this.depth;r+=1)for(let i=0;i<Math.ceil(this.nodes[r].length/this.arity);i+=1){let n=i*this.arity,o=[];for(let s=0;s<this.arity;s+=1)o.push(this.nodes[r][n+s]??this.zeroes[r]);this.nodes[r+1][i]=await Me(o.map(s=>BigInt(s)));}}else this.nodes[this.depth][0]=t;}serialize(){return this.nodes.map(t=>t.map(e=>`0x${e.toString(16).padStart(64,"0")}`))}};BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Jl();Jl();var fh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,fh.prototype);}};fh=Mt([N({type:B.Set,itemType:wt})],fh);var ph=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Mt([g({type:S.Integer})],ph.prototype,"number",2),Mt([g({type:S.OctetString})],ph.prototype,"hash",2);var hh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Mt([g({type:S.PrintableString})],hh.prototype,"ldsVersion",2),Mt([g({type:S.PrintableString})],hh.prototype,"unicodeVersion",2);var dh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Mt([g({type:S.ObjectIdentifier})],dh.prototype,"value",2),dh=Mt([N({type:B.Choice})],dh);var Zl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Mt([g({type:S.Integer})],Zl.prototype,"version",2),Mt([g({type:mt})],Zl.prototype,"hashAlgorithm",2),Mt([g({type:ph,repeated:"sequence"})],Zl.prototype,"dataGroups",2),Mt([g({type:hh,optional:true})],Zl.prototype,"versionInfo",2);var Yl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Mt([g({type:S.Integer})],Yl.prototype,"version",2),Mt([g({type:$t,repeated:"set"})],Yl.prototype,"certificates",2),Yl=Mt([N({type:B.Sequence})],Yl);Jl();Gt.Point.fromAffine(Tn);ea.ORDER;if(typeof window>"u")try{let t=gI("crypto");crypto=t;}catch{}yI();var bI="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",p6=[18,32];function SI(t){if(!(t instanceof Uint8Array))throw new Error("Input must be a Uint8Array");if(t.length===0)return "";let e=0;for(;e<t.length&&t[e]===0;)e++;let r=BigInt(0);for(let n=e;n<t.length;n++)r=r*BigInt(256)+BigInt(t[n]);let i="";for(;r>0n;){let n=Number(r%BigInt(58));i=bI[n]+i,r=r/BigInt(58);}return "1".repeat(e)+i}function mh(t){if(!t||typeof t!="string")throw new Error("Input must be a non-empty hex string");if(!t.match(/^(0x)?[0-9a-fA-F]+$/i))throw new Error("Invalid hex string format");t=t.startsWith("0x")?t.substring(2):t,t.length>64?t=t.substring(t.length-64):t.length<64&&(t=t.padStart(64,"0"));let e=new Uint8Array(34);e[0]=p6[0],e[1]=p6[1];for(let r=0;r<t.length;r+=2){let i=parseInt(t.substring(r,r+2),16);e[2+r/2]=i;}return SI(e)}var xI=16,AI=14,wI=8,_I=12,td=0n;var CI=1;var Lo=1,Ho=2,rd=3;function h6(t,e=253){let r=Math.pow(26,2),i=Math.ceil(r/e),n=Array(i).fill(0n),o=65;for(let s of t){let a=(s.charCodeAt(0)-o)*26+s.charCodeAt(1)-o,c=Math.floor(a/e);n[c]|=1n<<BigInt(a%e);}return n}function II(t){if(t.type==="RSA")return Ql.from(t.modulus).toUInt8Array();if(t.type==="EC")return Ql.from(t.public_key_x).concat(Ql.from(t.public_key_y)).toUInt8Array();throw new Error("Unsupported signature algorithm")}async function vI(t,e){let r=e?.version??0;Dr(r===0||r===1,`Unsupported Packaged Certificates version: ${r}`);let i=e?.tags?h6(e.tags):t?.tags?h6(t.tags):[0n,0n,0n];Dr(i.length===3,"Tags must be exactly 3 fields");let n=e?.type??CI;Dr(n>=0&&n<=255,`Certificate type must fit in a single byte: ${n}`),Dr(t?.country?.length===3,`Country code must be 3 characters: ${t?.country}`);let o=II(t.public_key);if(r===0)return Me([...i,BigInt(sa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2)]),31)[0]),...sa(o,31).map(s=>BigInt(s))]);if(r===1){Dr(t.fingerprint!==void 0,"Certificate fingerprint required");let s=BigInt(t.fingerprint),a=new Uint8Array(4);return a[0]=t.validity.not_after>>24&255,a[1]=t.validity.not_after>>16&255,a[2]=t.validity.not_after>>8&255,a[3]=t.validity.not_after&255,Me([...i,BigInt(sa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2),...a]),31)[0]),s,...sa(o,31).map(c=>BigInt(c))])}else throw new Error(`Unsupported Packaged Certificates version: ${r}`)}async function EI(t,e=0){let r=await Promise.all(t.map(i=>vI(i,{version:e})));return r.sort((i,n)=>i>n?1:i<n?-1:0),r}async function BI(t,e=0){let r=await EI(t,e),i=new ed(xI,2);return await i.initialize(td,r),i}async function TI(t){Dr(t.fingerprint!==void 0,"Revocation fingerprint required"),Dr(t.serial!==void 0,"Revocation serial required"),Dr(typeof t.fingerprint=="string"&&t.fingerprint.startsWith("0x"),`Revocation fingerprint must be a 0x-prefixed hex string: ${t.fingerprint}`),Dr(typeof t.serial=="string"&&t.serial.startsWith("0x"),`Revocation serial must be a 0x-prefixed hex string: ${t.serial}`);let e=Ql.from(t.serial).toUInt8Array(),r=await Me(sa(e,31).map(i=>BigInt(i)));return Me([BigInt(t.fingerprint),r])}async function kI(t){let e=await Promise.all(t.map(r=>TI(r)));return e.sort((r,i)=>r>i?1:r<i?-1:0),e}async function PI(t){let e=await kI(t),r=new ed(AI,2);return await r.initialize(td,e),r}async function NI(t){let e=t.map(i=>BigInt(i));e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(wI,2);return await r.initialize(td,e),r}var RI=21888242871839275222246405745257275088548364400416034343698204186575808495617n;function uh(t,e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{1,64}$/.test(e))throw new Error(`${t} must be a 0x-prefixed hex string of at most 64 hex chars: ${e}`);let r=BigInt(e);if(r>=RI)throw new Error(`${t} must be in [0, BN254_FIELD_MODULUS): ${r}`);return r}async function DI(t){let{schemaVersion:e,timestamp:r,certificateRoot:i,revocationRoot:n,masterlistRoot:o}=t;Dr(Number.isInteger(e)&&e>=0&&e<=65535,`Schema version must be an integer that fits in 2 bytes: ${e}`),Dr(Number.isInteger(r)&&r>=0&&r<=4294967295,`Timestamp must be an integer that fits in 4 bytes: ${r}`);let s=uh("certificateRoot",i),a=uh("revocationRoot",n),c=uh("masterlistRoot",o),l=await Me([s,a,c]),d=new Uint8Array([e>>>8&255,e&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255]),u=BigInt(sa(d,31)[0]);return {certificateRoot:`0x${(await Me([u,l])).toString(16).padStart(64,"0")}`,stateRoot:`0x${l.toString(16).padStart(64,"0")}`}}async function g6(t){let e=t.version??0,r=await BI(t.certificates,e);if(e===0)return r.root;if(e===1){let i=t,n=await PI(i.revocations??[]),o=await NI(i.masterlists??[]),{certificateRoot:s}=await DI({schemaVersion:e,timestamp:i.timestamp,certificateRoot:r.root,revocationRoot:n.root,masterlistRoot:o.root});return s}else throw new Error(`Unsupported Packaged Certificates schema version: ${e}`)}async function y6(t){let e;if(t.circuits!==void 0)e=t.circuits.map(i=>BigInt(i.vkey_hash));else if(t.hashes!==void 0)e=t.hashes.map(i=>BigInt(i));else throw new Error("Either circuits or hashes must be provided");e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(_I,2);return await r.initialize(td,e),r.root}var C6=It(uc(),1);function Sh(t){return YI.find(e=>e.chainId===t)}function ad(t){let e=Sh(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e}var gh="https://certificates.zkpassport.id/mainnet",jI="https://certificates.zkpassport.id/testnet",XI="http://localhost:8000/root",yh="https://circuits2.zkpassport.id/mainnet",WI="https://circuits2.zkpassport.id/testnet",ZI="http://localhost:8000",YI=[{chainId:Oi("ethereum"),chain:"ethereum",type:"mainnet",rpcUrl:"https://eth-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x8C93bB3a7ED88dA0647Ea53f8cd3f57832a513Cd",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("base"),chain:"base",type:"mainnet",rpcUrl:"https://base-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0xC404C605130F3345E1A2BFdf3BAFABED7234cCa7",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("robinhood"),chain:"robinhood",type:"mainnet",rpcUrl:"https://rpc.mainnet.chain.robinhood.com",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x0A55cA59e98e17666C1A9a099d546E676088bC1A",packagedCertificatesUrl:gh,circuitUrl:yh},{chainId:Oi("ethereum_sepolia"),chain:"ethereum_sepolia",type:"testnet",rpcUrl:"https://eth-sepolia.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x6Ee299B1E8049fadc3494f1110A3479f5BE8EC0e",packagedCertificatesUrl:jI,circuitUrl:WI},{chainId:Oi("local"),chain:"local",type:"dev",rpcUrl:"http://localhost:8545",rootRegistry:"0x5FbDB2315678afecb367f032d93F642f64180aa3",registryHelper:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",packagedCertificatesUrl:XI,circuitUrl:ZI}];function da(t){return t.startsWith("0x")?t.slice(2):t}function _t(t){return typeof t=="bigint"?`0x${t.toString(16).toLowerCase().padStart(64,"0")}`:`0x${da(t).toLowerCase().padStart(64,"0")}`}var QI=3,JI=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).packagedCertificatesUrl}/${e}.json`),ev="https://sanctions.zkpassport.id/mainnet",tv="https://sanctions.zkpassport.id/testnet",rv="http://localhost:8000/sanctions",iv=(t,e)=>(e=_t(e),t===1||t===8453?`${ev}/${e}.tree.json.gz`:t===11155111?`${tv}/${e}.tree.json.gz`:`${rv}/${e}.tree.json.gz`),nv=(t,{root:e,version:r,cid:i})=>{if(e)return e=_t(e),`${ad(t).circuitUrl}/by-root/${e}/manifest.json`;if(r)return `${ad(t).circuitUrl}/by-version/${r}/manifest.json`;if(i)return `https://ipfs.zkpassport.id/ipfs/${i}`;throw new Error("No root, version or cid provided")},ov=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).circuitUrl}/by-hash/${e}.json`),od=100,sv="0xc3bc16e8",w6="0x06ac4103",_6="0xcb0c82c7",av="0x76785af8",cv="0x5d8d57a6",lv="0xbb3dd539",dv="0x2aae4296",uv=[{country:"RUS",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"JPN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"GBR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"IDN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"NGA",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"DEU",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"EST",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LVA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SGP",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"VNM",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"TUR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"THA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"BRA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ARG",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"AUT",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"FRA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"PRT",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ESP",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"IRL",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ITA",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CHE",id_card_support:0,residence_permit_support:.5,passport_support:1},{country:"BEL",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LUX",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NLD",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"POL",id_card_support:.25,residence_permit_support:.25,passport_support:1},{country:"DNK",id_card_support:0,residence_permit_support:.5,passport_support:1},{country:"SWE",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NOR",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SVN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CZE",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"NOR",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"LTU",id_card_support:.5,residence_permit_support:.5,passport_support:.5},{country:"FIN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"MEX",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"IND",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"PAK",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"IRN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"GRC",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"ROU",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"KAZ",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"BLR",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"MAR",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"DZA",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"URY",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"PRY",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"CHL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PER",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"ECU",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"PAN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"VEN",id_card_support:0,residence_permit_support:0,passport_support:0},{country:"COL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CRI",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"USA",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CAN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"GHA",id_card_support:.25,residence_permit_support:0,passport_support:.5},{country:"SEN",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"ETH",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"JOR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"OMN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"CHN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"KOR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PRK",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"UAE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ARE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ISR",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"SAU",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"AUS",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"NZL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"MYS",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"TWN",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"PHL",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"UZB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"UZB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"TKM",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"TJK",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"GEO",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ARM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"AZE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"CYP",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"RKS",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"MNE",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ALB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"HRV",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"SRB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"HUN",id_card_support:.5,residence_permit_support:.5,passport_support:1},{country:"MDA",id_card_support:0,residence_permit_support:0,passport_support:0},{country:"UKR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"BGR",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"LIE",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"VAT",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"SMR",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"JAM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"SLE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BEN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"CMR",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"KEN",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"UGA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"RWA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"TZA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"ZWE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BWA",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"YEM",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"LBN",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"QAT",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"KWT",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"IRQ",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"PSE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"ISL",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"MCO",id_card_support:.5,residence_permit_support:0,passport_support:1},{country:"MNG",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"AND",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"ATG",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"BHR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BRB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"BLZ",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BIH",id_card_support:0,residence_permit_support:0,passport_support:1},{country:"BMU",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"DMA",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"CIV",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"NPL",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"MKD",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"KNA",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"VCT",id_card_support:0,residence_permit_support:0,passport_support:.5},{country:"SYC",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"SYR",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"BHS",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"GMB",id_card_support:0,residence_permit_support:0,passport_support:.75},{country:"ZWE",id_card_support:0,residence_permit_support:0,passport_support:.25},{country:"TLS",id_card_support:0,residence_permit_support:0,passport_support:.25}],Ft=(0, C6.default)("zkpassport:registry"),sd=t=>t.toString(16).padStart(64,"0");function xh(t,e={}){let r=typeof t=="number"?t:Oi(t);if(!Sh(r))throw new Error(`Unsupported chain: ${t}`);return new fv({...e,chainId:r})}var fv=class bh{constructor({rpcUrl:e,rootRegistry:r,chainId:i,registryHelper:n,packagedCertsUrlGenerator:o,circuitManifestUrlGenerator:s,packagedCircuitUrlGenerator:a,sanctionsTreeUrlGenerator:c,retryCount:l}={}){if(i===void 0)throw new Error("chainId is required");this.chainId=i;let d=Sh(i),u=e||d?.rpcUrl,h=r||d?.rootRegistry,m=n||d?.registryHelper;if(!u||!h||!m)throw new Error(`Unsupported chain ID: ${i}`);this.rpcUrl=u,this.rootRegistry=h,this.registryHelper=m,this.packagedCertsUrlGenerator=o||JI,this.circuitManifestUrlGenerator=s||nv,this.packagedCircuitUrlGenerator=a||ov,this.sanctionsTreeUrlGenerator=c||iv,this.retryCount=l||QI;}async getLatestCertificateRoot(){return this.getLatestRoot(Lo,"certificate")}async isCertificateRootValid(e,r){return this.isRootValid(Lo,"certificate",e,r)}async getCertificates(e,{validate:r=true,ipfs:i=false}={}){if(e?e=_t(e):e=await this.getLatestCertificateRoot(),i)throw new Error("IPFS flag not implemented");let n=await this.fetchJson(this.packagedCertsUrlGenerator(this.chainId,e),`certificates for root ${e}`);if(n.version||(n.version=0),Ft(`Got ${n.certificates?.length||0} packaged certificates (schema version ${n.version})`),!n.certificates||!Array.isArray(n.certificates))throw new Error("Invalid certificates returned");let o=n.version===0?n.serialised:n.certificates_serialised;if(!o||!Array.isArray(o))throw new Error("Invalid serialised certificates tree returned");for(let s of n.certificates)s.fingerprint&&(s.fingerprint=_t(s.fingerprint));if(r&&!await bh.validateCertificates(n,e))throw new Error(`Validation failed for packaged certificates: ${e}`);return n}static async validateCertificates(e,r){try{let i=await g6(e),n=_t(r),o=i.toLowerCase()===n.toLowerCase();return Ft(o?`Validated packaged certificates against root ${i}`:`Error validating packaged certificates. Expected: ${n} Got: ${i}`),o}catch(i){return console.error("Error validating circuit manifest:",i),false}}async getHistoricalCertificateRoots(e,r=od){let i=typeof e=="string"?da(e):e??1,n=typeof i=="number"?`${w6}${Lo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${_6}${Lo.toString(16).padStart(64,"0")}${i.padStart(64,"0")}${r.toString(16).padStart(64,"0")}`;try{let o=await this.rpcRequest(this.registryHelper,n);return this._handleHistoricalRootsResponse(o)}catch(o){throw o instanceof Error?o:new Error(String(o))}}async getAllHistoricalCertificateRoots(e=od,r){let i=0,n=false,o=1,s=[];for(;!n;){let{roots:a,isLastPage:c}=await this.getHistoricalCertificateRoots(o,e);if(s.push(...a),n=c,i++,a.length>0&&(o+=a.length),r&&r(i,a,s.length,n),a.length===0)break}return s}async getCertificateRootDetails(e){return this.getRootDetails(Lo,"certificate",e)}async getLatestCircuitRoot(){return this.getLatestRoot(Ho,"circuit")}async isCircuitRootValid(e,r){return this.isRootValid(Ho,"circuit",e,r)}async getCircuitManifest(e,{validate:r=true,ipfs:i=false,version:n=void 0}={}){if(!e&&!n?e=await this.getLatestCircuitRoot():e&&(e=_t(e)),i)throw new Error("IPFS flag not implemented");let o=await this.fetchJson(this.circuitManifestUrlGenerator(this.chainId,{root:e,version:n}),`circuit manifest for root ${e}`);if(!o.version||!o.root||!o.circuits)throw new Error("Invalid circuit manifest returned");if(Ft(`Got circuit manifest for root ${e}`),r&&!await this.validateCircuitManifest(o,e))throw new Error(`Validation failed for circuit manifest: ${e}`);return o}async validateCircuitManifest(e,r){try{let i=Object.values(e.circuits).map(a=>a.hash),n=_t(await y6({hashes:i})),o=_t(r||e.root),s=n.toLowerCase()===o.toLowerCase();return Ft(s?`Validated circuit manifest against root ${n}`:`Error validating circuit manifest. Expected: ${o} Got: ${n}`),s}catch(i){return console.error("Error validating circuit manifest:",i),false}}static async validatePackagedCircuit(e,r){let i=_t(r||e.vkey_hash),n=l6(Hl.fromBase64(e.vkey).toUInt8Array()),o=_t((await Me(n.map(BigInt))).toString(16)),s=o===i;return Ft(s?`Validated packaged circuit against hash ${i}`:`Error validating packaged circuit. Expected: ${i} Got: ${o}`),s}async getPackagedCircuit(e,r,{validate:i=true,ipfs:n=false}={}){if(n)throw new Error("IPFS flag not implemented");let o=r.circuits[e]?.hash||null;if(!o)throw new Error(`Circuit ${e} not found in manifest`);let s=await this.fetchJson(this.packagedCircuitUrlGenerator(this.chainId,o),`packaged circuit for ${e}`);if(!s.name||!s.hash||!s.noir_version||!s.bb_version)throw new Error(`Invalid packaged circuit returned for ${e}`);if(Ft(`Got packaged circuit for ${e}`),i&&!await bh.validatePackagedCircuit(s,o))throw new Error(`Validation failed for packaged circuit: ${e}`);return s}async getHistoricalCircuitRoots(e,r=od){let i=typeof e=="string"?da(e):e??1,n=typeof i=="number"?`${w6}${Ho.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${_6}${Ho.toString(16).padStart(64,"0")}${i.padStart(64,"0")}${r.toString(16).padStart(64,"0")}`;try{let o=await this.rpcRequest(this.registryHelper,n);return this._handleHistoricalRootsResponse(o)}catch(o){throw o instanceof Error?o:new Error(String(o))}}async getAllHistoricalCircuitRoots(e=od,r){let i=0,n=false,o=1,s=[];for(;!n;){let{roots:a,isLastPage:c}=await this.getHistoricalCircuitRoots(o,e);if(s.push(...a),n=c,i++,a.length>0&&(o+=a.length),r&&r(i,a,s.length,n),a.length===0)break}return s}async getCircuitRootDetails(e){return this.getRootDetails(Ho,"circuit",e)}async getLatestSanctionsRoot(){return this.getLatestRoot(rd,"sanctions")}async isSanctionsRootValid(e,r){return this.isRootValid(rd,"sanctions",e,r)}async getSanctionsTree(e,{validate:r=true}={}){e?e=_t(e):e=await this.getLatestSanctionsRoot();let i=await this.fetchJson(this.sanctionsTreeUrlGenerator(this.chainId,e),`sanctions tree for root ${e}`,{headers:{"Accept-Encoding":"gzip"}});if(!Array.isArray(i)||!i.every(n=>Array.isArray(n)))throw new Error("Invalid serialised sanctions tree returned");if(Ft(`Got sanctions tree with ${i.length} layers for root ${e}`),r){let n=i[i.length-1]?.[0];if(!(n!==void 0&&_t(n)===e.toLowerCase()))throw new Error(`Validation failed for sanctions tree: ${e}`)}return {root:e,serialised:i}}async getSanctionsRootDetails(e){return this.getRootDetails(rd,"sanctions",e)}async getRegistryAddress(e){Ft(`Getting registry address for ID ${e} from root registry ${this.rootRegistry}`);let r;if(typeof e=="string"&&e.startsWith("0x"))r=`0x${e.substring(2).padStart(64,"0")}`;else if(typeof e=="number")r=`0x${e.toString(16).padStart(64,"0")}`;else throw new Error(`Invalid registry ID: ${e}`);try{let i=await this.rpcRequest(this.rootRegistry,`${cv}${r.slice(2)}`);if(!i.ok)throw new Error(`Error getting address for registry ID ${e}: ${i.status} ${i.statusText}`);let n=await i.json();if(n.error)throw new Error(`Error getting address for registry ID ${e}: ${n.error.message}`);if(n.result==="0x0000000000000000000000000000000000000000000000000000000000000000")throw new Error(`Registry ID ${e} doesn't exist`);let o=`0x${n.result.slice(-40)}`;return Ft(`Got address for registry ID ${e}: ${o}`),o}catch(i){throw new Error(`Error getting address for registry ID ${e}: ${i}`)}}async isDocumentSupported(e,r,i="passport"){if(r&&!(await this.getCertificates()).certificates.filter(o=>o.country===e).some(o=>Math.floor(r.getTime()/1e3)>=o.validity.not_before))return 0;let n=uv.find(o=>o.country===e);return n?n[`${i}_support`]:0}getRpcUrl(){return this.rpcUrl}getRootRegistryAddress(){return this.rootRegistry}getRegistryHelperAddress(){return this.registryHelper}async getCertificateRegistryAddress(){return this.getRegistryAddress(Lo)}async getCircuitRegistryAddress(){return this.getRegistryAddress(Ho)}getUrlForPackagedCertificates(e,r){return this.packagedCertsUrlGenerator(this.chainId,e,r)}getUrlForCircuitManifestByRoot(e){return this.circuitManifestUrlGenerator(this.chainId,{root:e})}getUrlForCircuitManifestByVersion(e){return this.circuitManifestUrlGenerator(this.chainId,{version:e})}getUrlForCircuitManifestByCid(e){return this.circuitManifestUrlGenerator(this.chainId,{cid:e})}getUrlForPackagedCircuits(e,r){return this.packagedCircuitUrlGenerator(this.chainId,e,r)}async getLatestRoot(e,r){Ft(`Getting latest ${r} root`,{registry:this.rootRegistry});let i=await this.rpcRequest(this.rootRegistry,sv+sd(e));if(!i.ok)throw new Error(`Failed to get latest ${r} root: ${i.status} ${i.statusText}`);let n=await i.json();if(n.error)throw new Error(`Error from blockchain: ${n.error.message}`);return Ft(`Got latest ${r} root: ${n.result}`),n.result}async isRootValid(e,r,i,n){i=_t(i);let o=n??Math.floor(Date.now()/1e3),s=await this.rpcRequest(this.rootRegistry,dv+sd(e)+da(i)+o.toString(16).padStart(64,"0"));if(!s.ok)throw new Error(`Error checking if ${r} root is valid: ${s.status} ${s.statusText}`);let a=await s.json();if(a.error)throw new Error(`Error from blockchain: ${a.error.message}`);return parseInt(da(a.result))===1}async getRootDetails(e,r,i){if(i){Ft(`Getting ${r} root details`);let o=await this.rpcRequest(this.registryHelper,lv+sd(e)+da(i).padStart(64,"0"));if(!o.ok)throw new Error(`Failed to get ${r} root details: ${o.status} ${o.statusText}`);return this._handleRootDetailsResponse(o)}Ft(`Getting latest ${r} root details`);let n=await this.rpcRequest(this.registryHelper,av+sd(e));if(!n.ok)throw new Error(`Failed to get latest ${r} root details: ${n.status} ${n.statusText}`);return this._handleRootDetailsResponse(n)}async fetchJson(e,r,i){Ft(`Getting ${r} from:`,e);let n=await Vp(()=>fetch(e,i),this.retryCount);if(!n.ok)throw new Error(`Failed to get ${r}: ${n.status} ${n.statusText}, URL: ${e}`);return await n.json()}async rpcRequest(e,r){return Vp(()=>fetch(this.rpcUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:Math.floor(Math.random()*1e6),method:"eth_call",params:[{to:e,data:r},"latest"]})}),this.retryCount)}async _handleRootDetailsResponse(e){let r=await e.json();if(r.error)throw new Error(`Error from node: ${r.error.message}`);if(r.result){let i=r.result.slice(2),n=parseInt(i.slice(0,64),16),o=`0x${i.slice(64,128)}`,s=new Date(parseInt(i.slice(128,192),16)*1e3),a=parseInt(i.slice(192,256),16),c=a===0?void 0:new Date(a*1e3),l=parseInt(i.slice(256,320),16)===1,d=parseInt(i.slice(320,384),16),u=mh(`0x${i.slice(384,448)}`),h=i.slice(448,512),m=i.slice(512,576),b=i.slice(576,640),A=h===""?void 0:`0x${h}`,x=m===""?void 0:`0x${m}`,y=b===""?void 0:`0x${b}`;return {index:n,root:o,validFrom:s,validTo:c,revoked:l,leaves:d,cid:u,...A!==void 0&&{metadata1:A},...x!==void 0&&{metadata2:x},...y!==void 0&&{metadata3:y},isLatest:c===void 0}}else throw new Error("No result returned from node")}async _handleHistoricalRootsResponse(e){let r=await e.json();if(r.error)throw new Error(r?.error?.message||"Error getting roots");if(r.result){let i=r.result.slice(2),n=parseInt(i.slice(0,64),16),o=parseInt(i.slice(64,128),16)===1,s=i.slice(n*2),a=parseInt(s.slice(0,64),16),c=[],l=10;for(let d=0;d<a;d++){let u=64+d*l*64,h=parseInt(s.slice(u,u+64),16),m=`0x${s.slice(u+64,u+128)}`,b=new Date(parseInt(s.slice(u+128,u+192),16)*1e3),A=parseInt(s.slice(u+192,u+256),16),x=A===0?void 0:new Date(A*1e3),y=parseInt(s.slice(u+256,u+320),16)===1,w=parseInt(s.slice(u+320,u+384),16),I=mh(`0x${s.slice(u+384,u+448)}`),_=s.slice(u+448,u+512),C=s.slice(u+512,u+576),v=s.slice(u+576,u+640),T=_===""?void 0:`0x${_}`,G=C===""?void 0:`0x${C}`,F=v===""?void 0:`0x${v}`;c.push({root:m,validFrom:b,validTo:x,revoked:y,cid:I,leaves:w,...T!==void 0&&{metadata1:T},...G!==void 0&&{metadata2:G},...F!==void 0&&{metadata3:F},isLatest:d===a-1&&o,index:h});}return {roots:c,isLastPage:o}}return {roots:[],isLastPage:true}}};var I6=(t=>typeof Ie<"u"?Ie:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof Ie<"u"?Ie:e)[r]}):t)(function(t){if(typeof Ie<"u")return Ie.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function pv(){return typeof process<"u"&&process.versions!=null&&typeof window>"u"}async function cd(t,e){if(pv())try{let r=await Promise.resolve().then(()=>It(E6(),1)).catch(()=>{try{return {default:I6("ws")}}catch{throw new Error("WebSocket implementation 'ws' not found. Please install it with: npm install ws")}}),i=r.default||r.WebSocket||r;return new i(t,{headers:{Origin:e||"nodejs"}})}catch(r){throw console.error("Failed to create WebSocket client:",r),new Error("WebSocket implementation 'ws' not found. Please install it with: npm install ws")}return new WebSocket(t)}var B6=10,T6="wss://bridge.zkpassport.id",k6=3e4,ua="1";var hv=typeof window<"u"?{getRandomValues:t=>window.crypto.getRandomValues(t)}:globalThis.crypto,Ah=typeof window<"u"?window.crypto:typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:hv;function P6(t){let e=new Uint8Array(t);if(Ah&&typeof Ah.getRandomValues=="function")return Ah.getRandomValues(e),e;throw new Error("No secure random number generator available in this environment. Make sure you're in a secure context that provides crypto APIs.")}function wh(t){try{let e=new URL(t);return `${e.protocol}//${e.host.split(":")[0]}`}catch{return t}}function fa(t=16){let e=P6(t);return Buffer.from(e).toString("hex")}function N6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(t,...e){if(!N6(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 fc(t,e=true){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 _h(t,e){at(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function R6(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Or(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mr(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function pa(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}var gv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,yv=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pc(t){if(at(t),yv)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=bv[t[r]];return e}function Ch(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ha(t){if(typeof t=="string")t=Ch(t);else if(N6(t))t=zo(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function D6(t,e){if(t.length!==e.length)return false;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}var O6=(t,e)=>{function r(i,...n){if(at(i),!gv)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){let d=n[0];if(!d)throw new Error("nonce / iv required");t.varSizeNonce?at(d):at(d,t.nonceLength);}let o=t.tagLength;o&&n[1]!==void 0&&at(n[1]);let s=e(i,...n),a=(d,u)=>{if(u!==void 0){if(d!==2)throw new Error("cipher output not supported");at(u);}},c=false;return {encrypt(d,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=true,at(d),a(s.encrypt.length,u),s.encrypt(d,u)},decrypt(d,u){if(at(d),o&&d.length<o)throw new Error("invalid ciphertext length: smaller than tagLength="+o);return a(s.decrypt.length,u),s.decrypt(d,u)}}}return Object.assign(r,t),r};function M6(t,e,r=true){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!hc(e))throw new Error("invalid output, must be aligned");return e}function ld(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);let n=BigInt(32),o=BigInt(4294967295),s=Number(r>>n&o),a=Number(r&o),c=0,l=4;t.setUint32(e+c,s,i),t.setUint32(e+l,a,i);}function U6(t,e,r){let i=new Uint8Array(16),n=pa(i);return ld(n,0,BigInt(e),r),ld(n,8,BigInt(t),r),i}function hc(t){return t.byteOffset%4===0}function zo(t){return Uint8Array.from(t)}var Li=16,vh=new Uint8Array(16),ti=Or(vh),Sv=225,xv=(t,e,r,i)=>{let n=i&1;return {s3:r<<31|i>>>1,s2:e<<31|r>>>1,s1:t<<31|e>>>1,s0:t>>>1^Sv<<24&-(n&1)}},mr=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function Av(t){t.reverse();let e=t[15]&1,r=0;for(let i=0;i<t.length;i++){let n=t[i];t[i]=n>>>1|r,r=(n&1)<<7;}return t[0]^=-e&225,t}var wv=t=>t>64*1024?8:t>1024?4:2,dd=class{constructor(e,r){this.blockLen=Li,this.outputLen=Li,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=false,e=ha(e),at(e,16);let i=pa(e),n=i.getUint32(0,false),o=i.getUint32(4,false),s=i.getUint32(8,false),a=i.getUint32(12,false),c=[];for(let b=0;b<128;b++)c.push({s0:mr(n),s1:mr(o),s2:mr(s),s3:mr(a)}),{s0:n,s1:o,s2:s,s3:a}=xv(n,o,s,a);let l=wv(r||1024);if(![1,2,4,8].includes(l))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;let u=128/l,h=this.windowSize=2**l,m=[];for(let b=0;b<u;b++)for(let A=0;A<h;A++){let x=0,y=0,w=0,I=0;for(let _=0;_<l;_++){if(!(A>>>l-_-1&1))continue;let{s0:v,s1:T,s2:G,s3:F}=c[l*b+_];x^=v,y^=T,w^=G,I^=F;}m.push({s0:x,s1:y,s2:w,s3:I});}this.t=m;}_updateBlock(e,r,i,n){e^=this.s0,r^=this.s1,i^=this.s2,n^=this.s3;let{W:o,t:s,windowSize:a}=this,c=0,l=0,d=0,u=0,h=(1<<o)-1,m=0;for(let b of [e,r,i,n])for(let A=0;A<4;A++){let x=b>>>8*A&255;for(let y=8/o-1;y>=0;y--){let w=x>>>o*y&h,{s0:I,s1:_,s2:C,s3:v}=s[m*a+w];c^=I,l^=_,d^=C,u^=v,m+=1;}}this.s0=c,this.s1=l,this.s2=d,this.s3=u;}update(e){fc(this),e=ha(e),at(e);let r=Or(e),i=Math.floor(e.length/Li),n=e.length%Li;for(let o=0;o<i;o++)this._updateBlock(r[o*4+0],r[o*4+1],r[o*4+2],r[o*4+3]);return n&&(vh.set(e.subarray(i*Li)),this._updateBlock(ti[0],ti[1],ti[2],ti[3]),Mr(ti)),this}destroy(){let{t:e}=this;for(let r of e)r.s0=0,r.s1=0,r.s2=0,r.s3=0;}digestInto(e){fc(this),_h(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Or(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e}digest(){let e=new Uint8Array(Li);return this.digestInto(e),this.destroy(),e}},Ih=class extends dd{constructor(e,r){e=ha(e),at(e);let i=Av(zo(e));super(i,r),Mr(i);}update(e){e=ha(e),fc(this);let r=Or(e),i=e.length%Li,n=Math.floor(e.length/Li);for(let o=0;o<n;o++)this._updateBlock(mr(r[o*4+3]),mr(r[o*4+2]),mr(r[o*4+1]),mr(r[o*4+0]));return i&&(vh.set(e.subarray(n*Li)),this._updateBlock(mr(ti[3]),mr(ti[2]),mr(ti[1]),mr(ti[0])),Mr(ti)),this}digestInto(e){fc(this),_h(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Or(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e.reverse()}};function F6(t){let e=(i,n)=>t(n,i.length).update(ha(i)).digest(),r=t(new Uint8Array(16),0);return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=(i,n)=>t(i,n),e}var Eh=F6((t,e)=>new dd(t,e));F6((t,e)=>new Ih(t,e));var Th=16,Cv=4,ud=new Uint8Array(Th),Iv=283;function kh(t){return t<<1^Iv&-(t>>7)}function L6(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(e&1),t=kh(t);return r}var vv=(()=>{let t=new Uint8Array(256);for(let r=0,i=1;r<256;r++,i^=kh(i))t[r]=i;let e=new Uint8Array(256);e[0]=99;for(let r=0;r<255;r++){let i=t[255-r];i|=i<<8,e[t[r]]=(i^i>>4^i>>5^i>>6^i>>7^99)&255;}return Mr(t),e})();var Ev=t=>t<<24|t>>>8,Bh=t=>t<<8|t>>>24;function Bv(t,e){if(t.length!==256)throw new Error("Wrong sbox length");let r=new Uint32Array(256).map((l,d)=>e(t[d])),i=r.map(Bh),n=i.map(Bh),o=n.map(Bh),s=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let d=0;d<256;d++){let u=l*256+d;s[u]=r[l]^i[d],a[u]=n[l]^o[d],c[u]=t[l]<<8|t[d];}return {sbox:t,sbox2:c,T0:r,T1:i,T2:n,T3:o,T01:s,T23:a}}var K6=Bv(vv,t=>L6(t,3)<<24|t<<16|t<<8|L6(t,2));var Tv=(()=>{let t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=kh(r))t[e]=r;return t})();function kv(t){at(t);let e=t.length;if(![16,24,32].includes(e))throw new Error("aes: invalid key size, should be 16, 24 or 32, got "+e);let{sbox2:r}=K6,i=[];hc(t)||i.push(t=zo(t));let n=Or(t),o=n.length,s=c=>mc(r,c,c,c,c),a=new Uint32Array(e+28);a.set(n);for(let c=o;c<a.length;c++){let l=a[c-1];c%o===0?l=s(Ev(l))^Tv[c/o-1]:o>6&&c%o===4&&(l=s(l)),a[c]=a[c-o]^l;}return Mr(...i),a}function fd(t,e,r,i,n,o){return t[r<<8&65280|i>>>8&255]^e[n>>>8&65280|o>>>24&255]}function mc(t,e,r,i,n){return t[e&255|r&65280]|t[i>>>16&255|n>>>16&65280]<<16}function H6(t,e,r,i,n){let{sbox2:o,T01:s,T23:a}=K6,c=0;e^=t[c++],r^=t[c++],i^=t[c++],n^=t[c++];let l=t.length/4-2;for(let b=0;b<l;b++){let A=t[c++]^fd(s,a,e,r,i,n),x=t[c++]^fd(s,a,r,i,n,e),y=t[c++]^fd(s,a,i,n,e,r),w=t[c++]^fd(s,a,n,e,r,i);e=A,r=x,i=y,n=w;}let d=t[c++]^mc(o,e,r,i,n),u=t[c++]^mc(o,r,i,n,e),h=t[c++]^mc(o,i,n,e,r),m=t[c++]^mc(o,n,e,r,i);return {s0:d,s1:u,s2:h,s3:m}}function pd(t,e,r,i,n){at(r,Th),at(i),n=M6(i.length,n);let o=r,s=Or(o),a=pa(o),c=Or(i),l=Or(n),d=12,u=i.length,h=a.getUint32(d,e),{s0:m,s1:b,s2:A,s3:x}=H6(t,s[0],s[1],s[2],s[3]);for(let w=0;w+4<=c.length;w+=4)l[w+0]=c[w+0]^m,l[w+1]=c[w+1]^b,l[w+2]=c[w+2]^A,l[w+3]=c[w+3]^x,h=h+1>>>0,a.setUint32(d,h,e),{s0:m,s1:b,s2:A,s3:x}=H6(t,s[0],s[1],s[2],s[3]);let y=Th*Math.floor(c.length/Cv);if(y<u){let w=new Uint32Array([m,b,A,x]),I=R6(w);for(let _=y,C=0;_<u;_++,C++)n[_]=i[_]^I[C];Mr(w);}return n}function Pv(t,e,r,i,n){let o=n?n.length:0,s=t.create(r,i.length+o);n&&s.update(n);let a=U6(8*i.length,8*o,e);s.update(i),s.update(a);let c=s.digest();return Mr(a),c}var Ph=O6({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:true},function(e,r,i){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");let n=16;function o(a,c,l){let d=Pv(Eh,false,a,l,i);for(let u=0;u<c.length;u++)d[u]^=c[u];return d}function s(){let a=kv(e),c=ud.slice(),l=ud.slice();if(pd(a,false,l,l,c),r.length===12)l.set(r);else {let u=ud.slice(),h=pa(u);ld(h,8,BigInt(r.length*8),false);let m=Eh.create(c).update(r).update(u);m.digestInto(l),m.destroy();}let d=pd(a,false,l,ud);return {xk:a,authKey:c,counter:l,tagMask:d}}return {encrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),h=new Uint8Array(a.length+n),m=[c,l,d,u];hc(a)||m.push(a=zo(a)),pd(c,false,d,a,h.subarray(0,a.length));let b=o(l,u,h.subarray(0,h.length-n));return m.push(b),h.set(b,a.length),Mr(...m),h},decrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),h=[c,l,u,d];hc(a)||h.push(a=zo(a));let m=a.subarray(0,-n),b=a.subarray(-n),A=o(l,u,m);if(h.push(A),!D6(A,b))throw new Error("aes/gcm: invalid ghash tag");let x=pd(c,false,d,m);return Mr(...h),x}}});var Nv={p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n},{p:Go,n:Mh,Gx:Rv,Gy:Dv,b:W6}=Nv,$o=32,Nh=64,Vt=(t="")=>{throw new Error(t)},Z6=t=>typeof t=="bigint",Y6=t=>typeof t=="string",Ov=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",gc=(t,e)=>!Ov(t)||typeof e=="number"&&e>0&&t.length!==e?Vt("Uint8Array expected"):t,Uh=t=>new Uint8Array(t),Mv=t=>Uint8Array.from(t),Q6=(t,e)=>t.toString(16).padStart(e,"0"),J6=t=>Array.from(gc(t)).map(e=>Q6(e,2)).join(""),Hi={_0:48,_9:57,A:65,F:70,a:97,f:102},z6=t=>{if(t>=Hi._0&&t<=Hi._9)return t-Hi._0;if(t>=Hi.A&&t<=Hi.F)return t-(Hi.A-10);if(t>=Hi.a&&t<=Hi.f)return t-(Hi.a-10)},e5=t=>{let e="hex invalid";if(!Y6(t))return Vt(e);let r=t.length,i=r/2;if(r%2)return Vt(e);let n=Uh(i);for(let o=0,s=0;o<i;o++,s+=2){let a=z6(t.charCodeAt(s)),c=z6(t.charCodeAt(s+1));if(a===void 0||c===void 0)return Vt(e);n[o]=a*16+c;}return n},yd=(t,e)=>gc(Y6(t)?e5(t):Mv(gc(t)),e),Uv=()=>globalThis?.crypto;var q6=(...t)=>{let e=Uh(t.reduce((i,n)=>i+gc(n).length,0)),r=0;return t.forEach(i=>{e.set(i,r),r+=i.length;}),e},Fv=(t=$o)=>Uv().getRandomValues(Uh(t)),md=BigInt,bc=(t,e,r,i="bad number: out of range")=>Z6(t)&&e<=t&&t<r?t:Vt(i),ee=(t,e=Go)=>{let r=t%e;return r>=0n?r:e+r};var Lv=(t,e)=>{(t===0n||e<=0n)&&Vt("no inverse n="+t+" mod="+e);let r=ee(t,e),i=e,n=0n,s=1n;for(;r!==0n;){let c=i/r,l=i%r,d=n-s*c;i=r,r=l,n=s,s=d;}return i===1n?ee(n,e):Vt("no inverse")};var G6=t=>t instanceof Nn?t:Vt("Point expected"),t5=t=>ee(ee(t*t)*t+W6),$6=t=>bc(t,0n,Go),hd=t=>bc(t,1n,Go),Hv=t=>bc(t,1n,Mh),Rh=t=>(t&1n)===0n,r5=t=>Uint8Array.of(t),Kv=t=>r5(Rh(t)?2:3),zv=t=>{let e=t5(hd(t)),r=1n;for(let i=e,n=(Go+1n)/4n;n>0n;n>>=1n)n&1n&&(r=r*i%Go),i=i*i%Go;return ee(r*r)===e?r:Vt("sqrt invalid")},ri=class ri{constructor(e,r,i){f(this,"px");f(this,"py");f(this,"pz");this.px=$6(e),this.py=hd(r),this.pz=$6(i),Object.freeze(this);}static fromBytes(e){gc(e);let r,i=e[0],n=e.subarray(1),o=V6(n,0,$o),s=e.length;if(s===$o+1&&[2,3].includes(i)){let a=zv(o),c=Rh(a);Rh(md(i))!==c&&(a=ee(-a)),r=new ri(o,a,1n);}return s===Nh+1&&i===4&&(r=new ri(o,V6(n,$o,Nh),1n)),r?r.assertValidity():Vt("bad point: not on curve")}equals(e){let{px:r,py:i,pz:n}=this,{px:o,py:s,pz:a}=G6(e),c=ee(r*a),l=ee(o*n),d=ee(i*a),u=ee(s*n);return c===l&&d===u}is0(){return this.equals(qo)}negate(){return new ri(this.px,ee(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:i,pz:n}=this,{px:o,py:s,pz:a}=G6(e),c=0n,l=W6,d=0n,u=0n,h=0n,m=ee(l*3n),b=ee(r*o),A=ee(i*s),x=ee(n*a),y=ee(r+i),w=ee(o+s);y=ee(y*w),w=ee(b+A),y=ee(y-w),w=ee(r+n);let I=ee(o+a);return w=ee(w*I),I=ee(b+x),w=ee(w-I),I=ee(i+n),d=ee(s+a),I=ee(I*d),d=ee(A+x),I=ee(I-d),h=ee(c*w),d=ee(m*x),h=ee(d+h),d=ee(A-h),h=ee(A+h),u=ee(d*h),A=ee(b+b),A=ee(A+b),x=ee(c*x),w=ee(m*w),A=ee(A+x),x=ee(b-x),x=ee(c*x),w=ee(w+x),b=ee(A*w),u=ee(u+b),b=ee(I*w),d=ee(y*d),d=ee(d-b),b=ee(y*A),h=ee(I*h),h=ee(h+b),new ri(d,u,h)}multiply(e,r=true){if(!r&&e===0n)return qo;if(Hv(e),e===1n)return this;if(this.equals(Pn))return Xv(e).p;let i=qo,n=Pn;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?i=i.add(o):r&&(n=n.add(o));return i}toAffine(){let{px:e,py:r,pz:i}=this;if(this.equals(qo))return {x:0n,y:0n};if(i===1n)return {x:e,y:r};let n=Lv(i,Go);return ee(i*n)!==1n&&Vt("inverse invalid"),{x:ee(e*n),y:ee(r*n)}}assertValidity(){let{x:e,y:r}=this.toAffine();return hd(e),hd(r),ee(r*r)===t5(e)?this:Vt("bad point: not on curve")}toBytes(e=true){let{x:r,y:i}=this.assertValidity().toAffine(),n=Dh(r);return e?q6(Kv(i),n):q6(r5(4),n,Dh(i))}static fromAffine(e){let{x:r,y:i}=e;return r===0n&&i===0n?qo:new ri(r,i,1n)}toHex(e){return J6(this.toBytes(e))}static fromPrivateKey(e){return Pn.multiply(yc(e))}static fromHex(e){return ri.fromBytes(yd(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}};f(ri,"BASE"),f(ri,"ZERO");var Nn=ri,Pn=new Nn(Rv,Dv,1n),qo=new Nn(0n,1n,0n);Nn.BASE=Pn;Nn.ZERO=qo;var Fh=t=>md("0x"+(J6(t)||"0")),V6=(t,e,r)=>Fh(t.subarray(e,r)),qv=2n**256n,Dh=t=>e5(Q6(bc(t,0n,qv),Nh)),yc=t=>{let e=Z6(t)?t:Fh(yd(t,$o));return bc(e,1n,Mh,"private key invalid 3")};var i5=(t,e=true)=>Pn.multiply(yc(t)).toBytes(e);var n5=(t,e,r=true)=>Nn.fromBytes(yd(e)).multiply(yc(t)).toBytes(r),Gv=t=>{t=yd(t),(t.length<$o+8||t.length>1024)&&Vt("expected 40-1024b");let e=ee(Fh(t),Mh-1n);return Dh(e+1n)},$v=()=>Gv(Fv($o+16));var o5={normPrivateKeyToScalar:yc,isValidPrivateKey:t=>{try{return !!yc(t)}catch{return false}},randomPrivateKey:$v,precompute:(t=8,e=Pn)=>(e.multiply(3n),e)},gd=8,Vv=256,s5=Math.ceil(Vv/gd)+1,Oh=2**(gd-1),jv=()=>{let t=[],e=Pn,r=e;for(let i=0;i<s5;i++){r=e,t.push(r);for(let n=1;n<Oh;n++)r=r.add(e),t.push(r);e=r.double();}return t},j6,X6=(t,e)=>{let r=e.negate();return t?r:e},Xv=t=>{let e=j6||(j6=jv()),r=qo,i=Pn,n=2**gd,o=n,s=md(n-1),a=md(gd);for(let c=0;c<s5;c++){let l=Number(t&s);t>>=a,l>Oh&&(l-=o,t+=1n);let d=c*Oh,u=d,h=d+Math.abs(l)-1,m=c%2!==0,b=l<0;l===0?i=i.add(X6(m,e[u])):r=r.add(X6(b,e[h]));}return {p:r,f:i}};function Wv(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sd(t,...e){if(!Wv(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 Lh(t,e=true){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 a5(t,e){Sd(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Sc(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function xd(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ur(t,e){return t<<32-e|t>>>e}function Zv(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Hh(t){return typeof t=="string"&&(t=Zv(t)),Sd(t),t}var bd=class{};function c5(t){let e=i=>t().update(Hh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Yv(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);let n=BigInt(32),o=BigInt(4294967295),s=Number(r>>n&o),a=Number(r&o),c=i?4:0,l=i?0:4;t.setUint32(e+c,s,i),t.setUint32(e+l,a,i);}function l5(t,e,r){return t&e^~t&r}function d5(t,e,r){return t&e^t&r^e&r}var Ad=class extends bd{constructor(e,r,i,n){super(),this.finished=false,this.length=0,this.pos=0,this.destroyed=false,this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(e),this.view=xd(this.buffer);}update(e){Lh(this),e=Hh(e),Sd(e);let{view:r,buffer:i,blockLen:n}=this,o=e.length;for(let s=0;s<o;){let a=Math.min(n-this.pos,o-s);if(a===n){let c=xd(e);for(;n<=o-s;s+=n)this.process(c,s);continue}i.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(r,0),this.pos=0);}return this.length+=e.length,this.roundClean(),this}digestInto(e){Lh(this),a5(e,this),this.finished=true;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:s}=this;r[s++]=128,Sc(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(i,0),s=0);for(let u=s;u<n;u++)r[u]=0;Yv(i,n-8,BigInt(this.length*8),o),this.process(i,0);let a=xd(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,d[u],o);}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:i,length:n,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=n,e.pos=a,n%r&&e.buffer.set(i),e}clone(){return this._cloneInto()}},Ki=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Qv=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]),Rn=new Uint32Array(64),Kh=class extends Ad{constructor(e=32){super(64,e,8,false),this.A=Ki[0]|0,this.B=Ki[1]|0,this.C=Ki[2]|0,this.D=Ki[3]|0,this.E=Ki[4]|0,this.F=Ki[5]|0,this.G=Ki[6]|0,this.H=Ki[7]|0;}get(){let{A:e,B:r,C:i,D:n,E:o,F:s,G:a,H:c}=this;return [e,r,i,n,o,s,a,c]}set(e,r,i,n,o,s,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0;}process(e,r){for(let u=0;u<16;u++,r+=4)Rn[u]=e.getUint32(r,false);for(let u=16;u<64;u++){let h=Rn[u-15],m=Rn[u-2],b=Ur(h,7)^Ur(h,18)^h>>>3,A=Ur(m,17)^Ur(m,19)^m>>>10;Rn[u]=A+Rn[u-7]+b+Rn[u-16]|0;}let{A:i,B:n,C:o,D:s,E:a,F:c,G:l,H:d}=this;for(let u=0;u<64;u++){let h=Ur(a,6)^Ur(a,11)^Ur(a,25),m=d+h+l5(a,c,l)+Qv[u]+Rn[u]|0,A=(Ur(i,2)^Ur(i,13)^Ur(i,22))+d5(i,n,o)|0;d=l,l=c,c=a,a=s+m|0,s=o,o=n,n=i,i=m+A|0;}i=i+this.A|0,n=n+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(i,n,o,s,a,c,l,d);}roundClean(){Sc(Rn);}destroy(){this.set(0,0,0,0,0,0,0,0),Sc(this.buffer);}};var u5=c5(()=>new Kh);async function f5(t){let r=new TextEncoder().encode(t),i=await u5(r);return new Uint8Array(i).slice(0,12)}function wd(){let t=o5.randomPrivateKey(),e=i5(t);return {privateKey:t,publicKey:e}}function zh(t,e){return n5(t,e).slice(0,32)}async function xc(t,e,r){let i=await f5(r),n=Ph(e,i),o=Ch(t);return n.encrypt(o)}async function qh(t,e,r){let i=await f5(r),o=Ph(e,i).decrypt(t);return new TextDecoder().decode(o)}var U8=It(uc(),1);function Aa(t){let e=t.length;for(;--e>=0;)t[e]=0;}var Jv=0,J5=1,e9=2,t9=3,r9=258,p2=29,Dc=256,Ec=Dc+1+p2,ya=30,h2=19,e8=2*Ec+1,Vo=15,Gh=16,i9=7,m2=256,t8=16,r8=17,i8=18,n2=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Bd=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),n9=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n8=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o9=512,qi=new Array((Ec+2)*2);Aa(qi);var Cc=new Array(ya*2);Aa(Cc);var Bc=new Array(o9);Aa(Bc);var Tc=new Array(r9-t9+1);Aa(Tc);var g2=new Array(p2);Aa(g2);var Td=new Array(ya);Aa(Td);function $h(t,e,r,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=t&&t.length;}var o8,s8,a8;function Vh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e;}var c8=t=>t<256?Bc[t]:Bc[256+(t>>>7)],kc=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255;},Lt=(t,e,r)=>{t.bi_valid>Gh-r?(t.bi_buf|=e<<t.bi_valid&65535,kc(t,t.bi_buf),t.bi_buf=e>>Gh-t.bi_valid,t.bi_valid+=r-Gh):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r);},oi=(t,e,r)=>{Lt(t,r[e*2],r[e*2+1]);},l8=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},s9=t=>{t.bi_valid===16?(kc(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8);},a9=(t,e)=>{let r=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length,l,d,u,h,m,b,A=0;for(h=0;h<=Vo;h++)t.bl_count[h]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<e8;l++)d=t.heap[l],h=r[r[d*2+1]*2+1]+1,h>c&&(h=c,A++),r[d*2+1]=h,!(d>i)&&(t.bl_count[h]++,m=0,d>=a&&(m=s[d-a]),b=r[d*2],t.opt_len+=b*(h+m),o&&(t.static_len+=b*(n[d*2+1]+m)));if(A!==0){do{for(h=c-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[c]--,A-=2;}while(A>0);for(h=c;h!==0;h--)for(d=t.bl_count[h];d!==0;)u=t.heap[--l],!(u>i)&&(r[u*2+1]!==h&&(t.opt_len+=(h-r[u*2+1])*r[u*2],r[u*2+1]=h),d--);}},d8=(t,e,r)=>{let i=new Array(Vo+1),n=0,o,s;for(o=1;o<=Vo;o++)n=n+r[o-1]<<1,i[o]=n;for(s=0;s<=e;s++){let a=t[s*2+1];a!==0&&(t[s*2]=l8(i[a]++,a));}},c9=()=>{let t,e,r,i,n,o=new Array(Vo+1);for(r=0,i=0;i<p2-1;i++)for(g2[i]=r,t=0;t<1<<n2[i];t++)Tc[r++]=i;for(Tc[r-1]=i,n=0,i=0;i<16;i++)for(Td[i]=n,t=0;t<1<<Bd[i];t++)Bc[n++]=i;for(n>>=7;i<ya;i++)for(Td[i]=n<<7,t=0;t<1<<Bd[i]-7;t++)Bc[256+n++]=i;for(e=0;e<=Vo;e++)o[e]=0;for(t=0;t<=143;)qi[t*2+1]=8,t++,o[8]++;for(;t<=255;)qi[t*2+1]=9,t++,o[9]++;for(;t<=279;)qi[t*2+1]=7,t++,o[7]++;for(;t<=287;)qi[t*2+1]=8,t++,o[8]++;for(d8(qi,Ec+1,o),t=0;t<ya;t++)Cc[t*2+1]=5,Cc[t*2]=l8(t,5);o8=new $h(qi,n2,Dc+1,Ec,Vo),s8=new $h(Cc,Bd,0,ya,Vo),a8=new $h(new Array(0),n9,0,h2,i9);},u8=t=>{let e;for(e=0;e<Ec;e++)t.dyn_ltree[e*2]=0;for(e=0;e<ya;e++)t.dyn_dtree[e*2]=0;for(e=0;e<h2;e++)t.bl_tree[e*2]=0;t.dyn_ltree[m2*2]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0;},f8=t=>{t.bi_valid>8?kc(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0;},p5=(t,e,r,i)=>{let n=e*2,o=r*2;return t[n]<t[o]||t[n]===t[o]&&i[e]<=i[r]},jh=(t,e,r)=>{let i=t.heap[r],n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&p5(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!p5(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i;},h5=(t,e,r)=>{let i,n,o=0,s,a;if(t.sym_next!==0)do i=t.pending_buf[t.sym_buf+o++]&255,i+=(t.pending_buf[t.sym_buf+o++]&255)<<8,n=t.pending_buf[t.sym_buf+o++],i===0?oi(t,n,e):(s=Tc[n],oi(t,s+Dc+1,e),a=n2[s],a!==0&&(n-=g2[s],Lt(t,n,a)),i--,s=c8(i),oi(t,s,r),a=Bd[s],a!==0&&(i-=Td[s],Lt(t,i,a)));while(o<t.sym_next);oi(t,m2,e);},o2=(t,e)=>{let r=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,o=e.stat_desc.elems,s,a,c=-1,l;for(t.heap_len=0,t.heap_max=e8,s=0;s<o;s++)r[s*2]!==0?(t.heap[++t.heap_len]=c=s,t.depth[s]=0):r[s*2+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,r[l*2]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[l*2+1]);for(e.max_code=c,s=t.heap_len>>1;s>=1;s--)jh(t,r,s);l=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],jh(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[l*2]=r[s*2]+r[a*2],t.depth[l]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[s*2+1]=r[a*2+1]=l,t.heap[1]=l++,jh(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],a9(t,e),d8(r,c,t.bl_count);},m5=(t,e,r)=>{let i,n=-1,o,s=e[1],a=0,c=7,l=4;for(s===0&&(c=138,l=3),e[(r+1)*2+1]=65535,i=0;i<=r;i++)o=s,s=e[(i+1)*2+1],!(++a<c&&o===s)&&(a<l?t.bl_tree[o*2]+=a:o!==0?(o!==n&&t.bl_tree[o*2]++,t.bl_tree[t8*2]++):a<=10?t.bl_tree[r8*2]++:t.bl_tree[i8*2]++,a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4));},g5=(t,e,r)=>{let i,n=-1,o,s=e[1],a=0,c=7,l=4;for(s===0&&(c=138,l=3),i=0;i<=r;i++)if(o=s,s=e[(i+1)*2+1],!(++a<c&&o===s)){if(a<l)do oi(t,o,t.bl_tree);while(--a!==0);else o!==0?(o!==n&&(oi(t,o,t.bl_tree),a--),oi(t,t8,t.bl_tree),Lt(t,a-3,2)):a<=10?(oi(t,r8,t.bl_tree),Lt(t,a-3,3)):(oi(t,i8,t.bl_tree),Lt(t,a-11,7));a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4);}},l9=t=>{let e;for(m5(t,t.dyn_ltree,t.l_desc.max_code),m5(t,t.dyn_dtree,t.d_desc.max_code),o2(t,t.bl_desc),e=h2-1;e>=3&&t.bl_tree[n8[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},d9=(t,e,r,i)=>{let n;for(Lt(t,e-257,5),Lt(t,r-1,5),Lt(t,i-4,4),n=0;n<i;n++)Lt(t,t.bl_tree[n8[n]*2+1],3);g5(t,t.dyn_ltree,e-1),g5(t,t.dyn_dtree,r-1);},u9=t=>{let e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return 0;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return 1;for(r=32;r<Dc;r++)if(t.dyn_ltree[r*2]!==0)return 1;return 0},y5=false,f9=t=>{y5||(c9(),y5=true),t.l_desc=new Vh(t.dyn_ltree,o8),t.d_desc=new Vh(t.dyn_dtree,s8),t.bl_desc=new Vh(t.bl_tree,a8),t.bi_buf=0,t.bi_valid=0,u8(t);},p8=(t,e,r,i)=>{Lt(t,(Jv<<1)+(i?1:0),3),f8(t),kc(t,r),kc(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r;},p9=t=>{Lt(t,J5<<1,3),oi(t,m2,qi),s9(t);},h9=(t,e,r,i)=>{let n,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=u9(t)),o2(t,t.l_desc),o2(t,t.d_desc),s=l9(t),n=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=n&&(n=o)):n=o=r+5,r+4<=n&&e!==-1?p8(t,e,r,i):t.strategy===4||o===n?(Lt(t,(J5<<1)+(i?1:0),3),h5(t,qi,Cc)):(Lt(t,(e9<<1)+(i?1:0),3),d9(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),h5(t,t.dyn_ltree,t.dyn_dtree)),u8(t),i&&f8(t);},m9=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(Tc[r]+Dc+1)*2]++,t.dyn_dtree[c8(e)*2]++),t.sym_next===t.sym_end),g9=f9,y9=p8,b9=h9,S9=m9,x9=p9,A9={_tr_init:g9,_tr_stored_block:y9,_tr_flush_block:b9,_tr_tally:S9,_tr_align:x9},w9=(t,e,r,i)=>{let n=t&65535|0,o=t>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do n=n+e[i++]|0,o=o+n|0;while(--s);n%=65521,o%=65521;}return n|o<<16|0},Pc=w9,_9=()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t;}return e},C9=new Uint32Array(_9()),I9=(t,e,r,i)=>{let n=C9,o=i+r;t^=-1;for(let s=i;s<o;s++)t=t>>>8^n[(t^e[s])&255];return t^-1},it=I9,Wo={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},wa={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:v9,_tr_stored_block:s2,_tr_flush_block:E9,_tr_tally:Mn,_tr_align:B9}=A9,{Z_NO_FLUSH:Un,Z_PARTIAL_FLUSH:T9,Z_FULL_FLUSH:k9,Z_FINISH:gr,Z_BLOCK:b5,Z_OK:ct,Z_STREAM_END:S5,Z_STREAM_ERROR:si,Z_DATA_ERROR:P9,Z_BUF_ERROR:Xh,Z_DEFAULT_COMPRESSION:N9,Z_FILTERED:R9,Z_HUFFMAN_ONLY:_d,Z_RLE:D9,Z_FIXED:O9,Z_DEFAULT_STRATEGY:M9,Z_UNKNOWN:U9,Z_DEFLATED:Nd}=wa,F9=9,L9=15,H9=8,K9=29,z9=256,a2=z9+1+K9,q9=30,G9=19,$9=2*a2+1,V9=15,be=3,On=258,ai=On+be+1,j9=32,Sa=42,y2=57,c2=69,l2=73,d2=91,u2=103,jo=113,wc=666,Ct=1,_a=2,Zo=3,Ca=4,X9=3,Xo=(t,e)=>(t.msg=Wo[e],e),x5=t=>t*2-(t>4?9:0),Dn=t=>{let e=t.length;for(;--e>=0;)t[e]=0;},W9=t=>{let e,r,i,n=t.w_size;e=t.hash_size,i=e;do r=t.head[--i],t.head[i]=r>=n?r-n:0;while(--e);e=n,i=e;do r=t.prev[--i],t.prev[i]=r>=n?r-n:0;while(--e)},b2=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask,Yo=(t,e)=>{let r;if(t.legacy_hash)r=t.ins_h=b2(t,t.ins_h,t.window[e+be-1]);else {let n=t.window,o=n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24;r=t.ins_h=Math.imul(o,66521)+66521>>>16&t.hash_mask;}let i=t.prev[e&t.w_mask]=t.head[r];return t.head[r]=e,i},jt=t=>{let e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0));},Xt=(t,e)=>{E9(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,jt(t.strm);},Se=(t,e)=>{t.pending_buf[t.pending++]=e;},Ac=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255;},f2=(t,e,r,i)=>{let n=t.avail_in;return n>i&&(n=i),n===0?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),r),t.state.wrap===1?t.adler=Pc(t.adler,e,n,r):t.state.wrap===2&&(t.adler=it(t.adler,e,n,r)),t.next_in+=n,t.total_in+=n,n)},h8=(t,e)=>{let r=t.max_chain_length,i=t.strstart,n,o,s=t.prev_length,a=t.nice_match,c=t.strstart>t.w_size-ai?t.strstart-(t.w_size-ai):0,l=t.window,d=t.w_mask,u=t.prev,h=t.strstart+On,m=l[i+s-1],b=l[i+s];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do if(n=e,!(l[n+s]!==b||l[n+s-1]!==m||l[n]!==l[i]||l[++n]!==l[i+1])){i+=2,n++;do;while(l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&i<h);if(o=On-(h-i),i=h-On,o>s){if(t.match_start=e,s=o,o>=a)break;m=l[i+s-1],b=l[i+s];}}while((e=u[e&d])>c&&--r!==0);return s<=t.lookahead?s:t.lookahead},xa=t=>{let e=t.w_size,r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ai)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),W9(t),i+=e),t.strm.avail_in===0)break;if(r=f2(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,t.legacy_hash){if(t.lookahead+t.insert>=be)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=b2(t,t.ins_h,t.window[n+1]);t.insert&&(Yo(t,n),n++,t.insert--,!(t.lookahead+t.insert<be)););}else if(t.lookahead+t.insert>be)for(n=t.strstart-t.insert;t.insert&&(Yo(t,n),n++,t.insert--,!(t.lookahead+t.insert<=be)););}while(t.lookahead<ai&&t.strm.avail_in!==0)},m8=(t,e)=>{let r=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,i,n,o,s=0,a=t.strm.avail_in;do{if(i=65535,o=t.bi_valid+42>>3,t.strm.avail_out<o||(o=t.strm.avail_out-o,n=t.strstart-t.block_start,i>n+t.strm.avail_in&&(i=n+t.strm.avail_in),i>o&&(i=o),i<r&&(i===0&&e!==gr||e===Un||i!==n+t.strm.avail_in)))break;s=e===gr&&i===n+t.strm.avail_in?1:0,s2(t,0,0,s),t.pending_buf[t.pending-4]=i,t.pending_buf[t.pending-3]=i>>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,jt(t.strm),n&&(n>i&&(n=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,i-=n),i&&(f2(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i);}while(s===0);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?Ca:e!==Un&&e!==gr&&t.strm.avail_in===0&&t.strstart===t.block_start?_a:(o=t.window_size-t.strstart,t.strm.avail_in>o&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,o+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),o>t.strm.avail_in&&(o=t.strm.avail_in),o&&(f2(t.strm,t.window,t.strstart,o),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.high_water<t.strstart&&(t.high_water=t.strstart),o=t.bi_valid+42>>3,o=t.pending_buf_size-o>65535?65535:t.pending_buf_size-o,r=o>t.w_size?t.w_size:o,n=t.strstart-t.block_start,(n>=r||(n||e===gr)&&e!==Un&&t.strm.avail_in===0&&n<=o)&&(i=n>o?o:n,s=e===gr&&t.strm.avail_in===0&&i===n?1:0,s2(t,t.block_start,i,s),t.block_start+=i,jt(t.strm)),s?Zo:Ct)},Wh=(t,e)=>{let r,i;for(;;){if(t.lookahead<ai){if(xa(t),t.lookahead<ai&&e===Un)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Yo(t,t.strstart)),r!==0&&t.strstart-r<=t.w_size-ai&&(t.match_length=h8(t,r)),t.match_length>=be)if(i=Mn(t,t.strstart-t.match_start,t.match_length-be),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=be){t.match_length--;do t.strstart++,r=Yo(t,t.strstart);while(--t.match_length!==0);t.strstart++;}else t.strstart+=t.match_length,t.match_length=0,t.legacy_hash&&(t.ins_h=t.window[t.strstart],t.ins_h=b2(t,t.ins_h,t.window[t.strstart+1]));else i=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=t.strstart<be-1?t.strstart:be-1,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},ma=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<ai){if(xa(t),t.lookahead<ai&&e===Un)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Yo(t,t.strstart)),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=be-1,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-ai&&(t.match_length=h8(t,r),t.match_length<=5&&(t.strategy===R9||t.match_length===be&&t.strstart-t.match_start>4096)&&(t.match_length=be-1)),t.prev_length>=be&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-be,i=Mn(t,t.strstart-1-t.prev_match,t.prev_length-be),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=n&&(r=Yo(t,t.strstart));while(--t.prev_length!==0);if(t.match_available=0,t.match_length=be-1,t.strstart++,i&&(Xt(t,false),t.strm.avail_out===0))return Ct}else if(t.match_available){if(i=Mn(t,0,t.window[t.strstart-1]),i&&Xt(t,false),t.strstart++,t.lookahead--,t.strm.avail_out===0)return Ct}else t.match_available=1,t.strstart++,t.lookahead--;}return t.match_available&&(i=Mn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<be-1?t.strstart:be-1,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},Z9=(t,e)=>{let r,i,n,o,s=t.window;for(;;){if(t.lookahead<=On){if(xa(t),t.lookahead<=On&&e===Un)return Ct;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=be&&t.strstart>0&&(n=t.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){o=t.strstart+On;do;while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<o);t.match_length=On-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead);}if(t.match_length>=be?(r=Mn(t,1,t.match_length-be),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=0,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a},Y9=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(xa(t),t.lookahead===0)){if(e===Un)return Ct;break}if(t.match_length=0,r=Mn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Xt(t,false),t.strm.avail_out===0))return Ct}return t.insert=0,e===gr?(Xt(t,true),t.strm.avail_out===0?Zo:Ca):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:_a};function ii(t,e,r,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=i,this.func=n;}var _c=[new ii(0,0,0,0,m8),new ii(4,4,8,4,Wh),new ii(4,5,16,8,Wh),new ii(4,6,32,32,Wh),new ii(4,4,16,16,ma),new ii(8,16,32,32,ma),new ii(8,16,128,128,ma),new ii(8,32,128,256,ma),new ii(32,128,258,1024,ma),new ii(32,258,258,4096,ma)],Q9=t=>{t.window_size=2*t.w_size,Dn(t.head),t.max_lazy_match=_c[t.level].max_lazy,t.good_match=_c[t.level].good_length,t.nice_match=_c[t.level].nice_length,t.max_chain_length=_c[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=be-1,t.match_available=0,t.ins_h=0;};function J9(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Nd,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array($9*2),this.dyn_dtree=new Uint16Array((2*q9+1)*2),this.bl_tree=new Uint16Array((2*G9+1)*2),Dn(this.dyn_ltree),Dn(this.dyn_dtree),Dn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(V9+1),this.heap=new Uint16Array(2*a2+1),Dn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*a2+1),Dn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0;}var Oc=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.status!==Sa&&e.status!==y2&&e.status!==c2&&e.status!==l2&&e.status!==d2&&e.status!==u2&&e.status!==jo&&e.status!==wc?1:0},g8=t=>{if(Oc(t))return Xo(t,si);t.total_in=t.total_out=0,t.data_type=U9;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?y2:e.wrap?Sa:jo,t.adler=e.wrap===2?0:1,e.last_flush=-2,v9(e),ct},y8=t=>{let e=g8(t);return e===ct&&Q9(t.state),e},e7=(t,e)=>Oc(t)||t.state.wrap!==2?si:(t.state.gzhead=e,ct),b8=(t,e,r,i,n,o,s)=>{if(!t)return si;let a=1;if(e===N9&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>F9||r!==Nd||i<8||i>15||e<0||e>9||o<0||o>O9||i===8&&a!==1)return Xo(t,si);i===8&&(i=9);let c=new J9;return t.state=c,c.strm=t,c.status=Sa,c.wrap=a,c.gzhead=null,c.w_bits=i,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.legacy_hash=s?1:0,c.hash_bits=n+7,!c.legacy_hash&&c.hash_bits<15&&(c.hash_bits=15),c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+be-1)/be),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<n+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=e,c.strategy=o,c.method=r,y8(t)},t7=(t,e)=>b8(t,e,Nd,L9,H9,M9),r7=(t,e)=>{if(Oc(t)||e>b5||e<0)return t?Xo(t,si):si;let r=t.state;if(!t.output||t.avail_in!==0&&!t.input||r.status===wc&&e!==gr)return Xo(t,t.avail_out===0?Xh:si);let i=r.last_flush;if(r.last_flush=e,r.pending!==0){if(jt(t),t.avail_out===0)return r.last_flush=-1,ct}else if(t.avail_in===0&&x5(e)<=x5(i)&&e!==gr)return Xo(t,Xh);if(r.status===wc&&t.avail_in!==0)return Xo(t,Xh);if(r.status===Sa&&r.wrap===0&&(r.status=jo),r.status===Sa){let n=Nd+(r.w_bits-8<<4)<<8,o=-1;if(r.strategy>=_d||r.level<2?o=0:r.level<6?o=1:r.level===6?o=2:o=3,n|=o<<6,r.strstart!==0&&(n|=j9),n+=31-n%31,Ac(r,n),r.strstart!==0&&(Ac(r,t.adler>>>16),Ac(r,t.adler&65535)),t.adler=1,r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===y2){if(t.adler=0,Se(r,31),Se(r,139),Se(r,8),r.gzhead)Se(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Se(r,r.gzhead.time&255),Se(r,r.gzhead.time>>8&255),Se(r,r.gzhead.time>>16&255),Se(r,r.gzhead.time>>24&255),Se(r,r.level===9?2:r.strategy>=_d||r.level<2?4:0),Se(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Se(r,r.gzhead.extra.length&255),Se(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=it(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=c2;else if(Se(r,0),Se(r,0),Se(r,0),Se(r,0),Se(r,0),Se(r,r.level===9?2:r.strategy>=_d||r.level<2?4:0),Se(r,X9),r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===c2){if(r.gzhead.extra){let n=r.pending,o=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+o>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex+=a,jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0,o-=a;}let s=new Uint8Array(r.gzhead.extra);r.pending_buf.set(s.subarray(r.gzindex,r.gzindex+o),r.pending),r.pending+=o,r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0;}r.status=l2;}if(r.status===l2){if(r.gzhead.name){let n=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0;}r.gzindex<r.gzhead.name.length?o=r.gzhead.name.charCodeAt(r.gzindex++)&255:o=0,Se(r,o);}while(o!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0;}r.status=d2;}if(r.status===d2){if(r.gzhead.comment){let n=r.pending,o;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n)),jt(t),r.pending!==0)return r.last_flush=-1,ct;n=0;}r.gzindex<r.gzhead.comment.length?o=r.gzhead.comment.charCodeAt(r.gzindex++)&255:o=0,Se(r,o);}while(o!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=it(t.adler,r.pending_buf,r.pending-n,n));}r.status=u2;}if(r.status===u2){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(jt(t),r.pending!==0))return r.last_flush=-1,ct;Se(r,t.adler&255),Se(r,t.adler>>8&255),t.adler=0;}if(r.status=jo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(t.avail_in!==0||r.lookahead!==0||e!==Un&&r.status!==wc){let n=r.level===0?m8(r,e):r.strategy===_d?Y9(r,e):r.strategy===D9?Z9(r,e):_c[r.level].func(r,e);if((n===Zo||n===Ca)&&(r.status=wc),n===Ct||n===Zo)return t.avail_out===0&&(r.last_flush=-1),ct;if(n===_a&&(e===T9?B9(r):e!==b5&&(s2(r,0,0,false),e===k9&&(Dn(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),jt(t),t.avail_out===0))return r.last_flush=-1,ct}return e!==gr?ct:r.wrap<=0?S5:(r.wrap===2?(Se(r,t.adler&255),Se(r,t.adler>>8&255),Se(r,t.adler>>16&255),Se(r,t.adler>>24&255),Se(r,t.total_in&255),Se(r,t.total_in>>8&255),Se(r,t.total_in>>16&255),Se(r,t.total_in>>24&255)):(Ac(r,t.adler>>>16),Ac(r,t.adler&65535)),jt(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?ct:S5)},i7=t=>{if(Oc(t))return si;let e=t.state.status;return t.state=null,e===jo?Xo(t,P9):ct},n7=(t,e)=>{let r=e.length;if(Oc(t))return si;let i=t.state,n=i.wrap;if(n===2||n===1&&i.status!==Sa||i.lookahead)return si;if(n===1&&(t.adler=Pc(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){n===0&&(Dn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let c=new Uint8Array(i.w_size);c.set(e.subarray(r-i.w_size,r),0),e=c,r=i.w_size;}let o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,xa(i);i.lookahead>=be;){let c=i.strstart,l=i.lookahead-(be-1);do Yo(i,c),c++;while(--l);i.strstart=c,i.lookahead=be-1,xa(i);}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=be-1,i.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,i.wrap=n,ct},o7=t7,s7=b8,a7=y8,c7=g8,l7=e7,d7=r7,u7=i7,f7=n7,p7="pako deflate (from Nodeca project)",Ic={deflateInit:o7,deflateInit2:s7,deflateReset:a7,deflateResetKeep:c7,deflateSetHeader:l7,deflate:d7,deflateEnd:u7,deflateSetDictionary:f7,deflateInfo:p7},h7=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),m7=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let i in r)h7(r,i)&&(t[i]=r[i]);}}return t},g7=t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;let r=new Uint8Array(e);for(let i=0,n=0,o=t.length;i<o;i++){let s=t[i];r.set(s,n),n+=s.length;}return r},Rd={assign:m7,flattenChunks:g7},S8=true;try{String.fromCharCode.apply(null,new Uint8Array(1));}catch{S8=false;}var Nc=new Uint8Array(256);for(let t=0;t<256;t++)Nc[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Nc[254]=Nc[255]=1;var y7=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,r,i,n,o,s=t.length,a=0;for(n=0;n<s;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,n=0;o<a;n++)r=t.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=t.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|r&63):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|r&63):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|r&63);return e},b7=(t,e)=>{if(e<65534&&t.subarray&&S8)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let i=0;i<e;i++)r+=String.fromCharCode(t[i]);return r},S7=(t,e)=>{let r=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let i,n,o=new Array(r*2);for(n=0,i=0;i<r;){let s=t[i++];if(s<128){o[n++]=s;continue}let a=Nc[s];if(a>4){o[n++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<r;)s=s<<6|t[i++]&63,a--;if(a>1){o[n++]=65533;continue}s<65536?o[n++]=s:(s-=65536,o[n++]=55296|s>>10&1023,o[n++]=56320|s&1023);}return b7(o,n)},x7=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let r=e-1;for(;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Nc[t[r]]>e?r:e},Rc={string2buf:y7,buf2string:S7,utf8border:x7};function A7(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0;}var x8=A7,A8=Object.prototype.toString,{Z_NO_FLUSH:w7,Z_SYNC_FLUSH:_7,Z_FULL_FLUSH:C7,Z_FINISH:I7,Z_OK:kd,Z_STREAM_END:v7,Z_DEFAULT_COMPRESSION:E7,Z_DEFAULT_STRATEGY:B7,Z_DEFLATED:T7}=wa,k7={level:E7,method:T7,chunkSize:16384,windowBits:15,memLevel:8,strategy:B7,legacyHash:true};function Mc(t){this.options=Rd.assign({},k7,t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=false,this.chunks=[],this.strm=new x8,this.strm.avail_out=0;let r=Ic.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(r!==kd)throw new Error(Wo[r]);if(e.header&&Ic.deflateSetHeader(this.strm,e.header),e.dictionary){let i;if(typeof e.dictionary=="string"?i=Rc.string2buf(e.dictionary):A8.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,r=Ic.deflateSetDictionary(this.strm,i),r!==kd)throw new Error(Wo[r]);this._dict_set=true;}}Mc.prototype.push=function(t,e){let r=this.strm,i=this.options.chunkSize,n,o;if(this.ended)return false;for(e===~~e?o=e:o=e===true?I7:w7,typeof t=="string"?r.input=Rc.string2buf(t):A8.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(o===_7||o===C7)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(n=Ic.deflate(r,o),n===v7)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=Ic.deflateEnd(this.strm),this.onEnd(n),this.ended=true,n===kd;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return true};Mc.prototype.onData=function(t){this.chunks.push(t);};Mc.prototype.onEnd=function(t){t===kd&&(this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function S2(t,e){let r=new Mc(e);if(r.push(t,true),r.err)throw r.msg||Wo[r.err];return r.result}var D7=S2,F7={deflate:D7},Cd=16209,L7=16191,H7=function(e,r){let i,n,o,s,a,c,l,d,u,h,m,b,A,x,y,w,I,_,C,v,T,G,F,H,k=e.state;i=e.next_in,F=e.input,n=i+(e.avail_in-5),o=e.next_out,H=e.output,s=o-(r-e.avail_out),a=o+(e.avail_out-257),c=k.dmax,l=k.wsize,d=k.whave,u=k.wnext,h=k.window,m=k.hold,b=k.bits,A=k.lencode,x=k.distcode,y=(1<<k.lenbits)-1,w=(1<<k.distbits)-1;e:do{b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=A[m&y];t:for(;;){if(_=I>>>24,m>>>=_,b-=_,_=I>>>16&255,_===0)H[o++]=I&65535;else if(_&16){C=I&65535,_&=15,_&&(b<_&&(m+=F[i++]<<b,b+=8),C+=m&(1<<_)-1,m>>>=_,b-=_),b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=x[m&w];r:for(;;){if(_=I>>>24,m>>>=_,b-=_,_=I>>>16&255,_&16){if(v=I&65535,_&=15,b<_&&(m+=F[i++]<<b,b+=8,b<_&&(m+=F[i++]<<b,b+=8)),v+=m&(1<<_)-1,v>c){e.msg="invalid distance too far back",k.mode=Cd;break e}if(m>>>=_,b-=_,_=o-s,v>_){if(_=v-_,_>d&&k.sane){e.msg="invalid distance too far back",k.mode=Cd;break e}if(T=0,G=h,u===0){if(T+=l-_,_<C){C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}}else if(u<_){if(T+=l+u-_,_-=u,_<C){C-=_;do H[o++]=h[T++];while(--_);if(T=0,u<C){_=u,C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}}}else if(T+=u-_,_<C){C-=_;do H[o++]=h[T++];while(--_);T=o-v,G=H;}for(;C>2;)H[o++]=G[T++],H[o++]=G[T++],H[o++]=G[T++],C-=3;C&&(H[o++]=G[T++],C>1&&(H[o++]=G[T++]));}else {T=o-v;do H[o++]=H[T++],H[o++]=H[T++],H[o++]=H[T++],C-=3;while(C>2);C&&(H[o++]=H[T++],C>1&&(H[o++]=H[T++]));}}else if((_&64)===0){I=x[(I&65535)+(m&(1<<_)-1)];continue r}else {e.msg="invalid distance code",k.mode=Cd;break e}break}}else if((_&64)===0){I=A[(I&65535)+(m&(1<<_)-1)];continue t}else if(_&32){k.mode=L7;break e}else {e.msg="invalid literal/length code",k.mode=Cd;break e}break}}while(i<n&&o<a);C=b>>3,i-=C,b-=C<<3,m&=(1<<b)-1,e.next_in=i,e.next_out=o,e.avail_in=i<n?5+(n-i):5-(i-n),e.avail_out=o<a?257+(a-o):257-(o-a),k.hold=m,k.bits=b;},ga=15,A5=852,w5=592,_5=0,Zh=1,C5=2,K7=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),z7=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),q7=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),G7=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),$7=(t,e,r,i,n,o,s,a)=>{let c=a.bits,l=0,d=0,u=0,h=0,m=0,b=0,A=0,x=0,y=0,w=0,I,_,C,v,T,G=null,F,H=new Uint16Array(ga+1),k=new Uint16Array(ga+1),E=null,q,O,z;for(l=0;l<=ga;l++)H[l]=0;for(d=0;d<i;d++)H[e[r+d]]++;for(m=c,h=ga;h>=1&&H[h]===0;h--);if(m>h&&(m=h),h===0)return n[o++]=1<<24|64<<16|0,n[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<h&&H[u]===0;u++);for(m<u&&(m=u),x=1,l=1;l<=ga;l++)if(x<<=1,x-=H[l],x<0)return -1;if(x>0&&(t===_5||h!==1))return -1;for(k[1]=0,l=1;l<ga;l++)k[l+1]=k[l]+H[l];for(d=0;d<i;d++)e[r+d]!==0&&(s[k[e[r+d]]++]=d);if(t===_5?(G=E=s,F=20):t===Zh?(G=K7,E=z7,F=257):(G=q7,E=G7,F=0),w=0,d=0,l=u,T=o,b=m,A=0,C=-1,y=1<<m,v=y-1,t===Zh&&y>A5||t===C5&&y>w5)return 1;for(;;){q=l-A,s[d]+1<F?(O=0,z=s[d]):s[d]>=F?(O=E[s[d]-F],z=G[s[d]-F]):(O=96,z=0),I=1<<l-A,_=1<<b,u=_;do _-=I,n[T+(w>>A)+_]=q<<24|O<<16|z|0;while(_!==0);for(I=1<<l-1;w&I;)I>>=1;if(I!==0?(w&=I-1,w+=I):w=0,d++,--H[l]===0){if(l===h)break;l=e[r+s[d]];}if(l>m&&(w&v)!==C){for(A===0&&(A=m),T+=u,b=l-A,x=1<<b;b+A<h&&(x-=H[b+A],!(x<=0));)b++,x<<=1;if(y+=1<<b,t===Zh&&y>A5||t===C5&&y>w5)return 1;C=w&v,n[C]=m<<24|b<<16|T-o|0;}}return w!==0&&(n[T+w]=l-A<<24|64<<16|0),a.bits=m,0},vc=$7,V7=0,w8=1,_8=2,{Z_FINISH:I5,Z_BLOCK:j7,Z_TREES:Id,Z_OK:Qo,Z_STREAM_END:X7,Z_NEED_DICT:W7,Z_STREAM_ERROR:yr,Z_DATA_ERROR:C8,Z_MEM_ERROR:I8,Z_BUF_ERROR:Z7,Z_DEFLATED:v5}=wa,Dd=16180,E5=16181,B5=16182,T5=16183,k5=16184,P5=16185,N5=16186,R5=16187,D5=16188,O5=16189,Pd=16190,zi=16191,Yh=16192,M5=16193,Qh=16194,U5=16195,F5=16196,L5=16197,H5=16198,vd=16199,Ed=16200,K5=16201,z5=16202,q5=16203,G5=16204,$5=16205,Jh=16206,V5=16207,j5=16208,De=16209,v8=16210,E8=16211,Y7=852,Q7=592,J7=15,eE=J7,X5=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function tE(){this.strm=null,this.mode=0,this.last=false,this.wrap=0,this.havedict=false,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0;}var Jo=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.mode<Dd||e.mode>E8?1:0},B8=t=>{if(Jo(t))return yr;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Dd,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Y7),e.distcode=e.distdyn=new Int32Array(Q7),e.sane=1,e.back=-1,Qo},T8=t=>{if(Jo(t))return yr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,B8(t)},k8=(t,e)=>{let r;if(Jo(t))return yr;let i=t.state;return e<0?(r=0,e=-e):(r=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?yr:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=r,i.wbits=e,T8(t))},P8=(t,e)=>{if(!t)return yr;let r=new tE;t.state=r,r.strm=t,r.window=null,r.mode=Dd;let i=k8(t,e);return i!==Qo&&(t.state=null),i},rE=t=>P8(t,eE),W5=true,e2,t2,iE=t=>{if(W5){e2=new Int32Array(512),t2=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(vc(w8,t.lens,0,288,e2,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;vc(_8,t.lens,0,32,t2,0,t.work,{bits:5}),W5=false;}t.lencode=e2,t.lenbits=9,t.distcode=t2,t.distbits=5;},N8=(t,e,r,i)=>{let n,o=t.state;return o.window===null&&(o.window=new Uint8Array(1<<o.wbits)),o.wsize===0&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0),i>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(e.subarray(r-i,r-i+n),o.wnext),i-=n,i?(o.window.set(e.subarray(r-i,r),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0},nE=(t,e)=>{let r,i,n,o,s,a,c,l,d,u,h,m,b,A,x=0,y,w,I,_,C,v,T,G,F=new Uint8Array(4),H,k,E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Jo(t)||!t.output||!t.input&&t.avail_in!==0)return yr;r=t.state,r.mode===zi&&(r.mode=Yh),s=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,l=r.hold,d=r.bits,u=a,h=c,G=Qo;e:for(;;)switch(r.mode){case Dd:if(r.wrap===0){r.mode=Yh;break}for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&2&&l===35615){r.wbits===0&&(r.wbits=15),r.check=0,F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0),l=0,d=0,r.mode=E5;break}if(r.head&&(r.head.done=false),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=De;break}if((l&15)!==v5){t.msg="unknown compression method",r.mode=De;break}if(l>>>=4,d-=4,T=(l&15)+8,r.wbits===0&&(r.wbits=T),T>15||T>r.wbits){t.msg="invalid window size",r.mode=De;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=l&512?O5:zi,l=0,d=0;break;case E5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.flags=l,(r.flags&255)!==v5){t.msg="unknown compression method",r.mode=De;break}if(r.flags&57344){t.msg="unknown header flags set",r.mode=De;break}r.head&&(r.head.text=l>>8&1),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0,r.mode=B5;case B5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.head&&(r.head.time=l),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,F[2]=l>>>16&255,F[3]=l>>>24&255,r.check=it(r.check,F,4,0)),l=0,d=0,r.mode=T5;case T5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.head&&(r.head.xflags=l&255,r.head.os=l>>8),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0,r.mode=k5;case k5:if(r.flags&1024){for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.length=l,r.head&&(r.head.extra_len=l),r.flags&512&&r.wrap&4&&(F[0]=l&255,F[1]=l>>>8&255,r.check=it(r.check,F,2,0)),l=0,d=0;}else r.head&&(r.head.extra=null);r.mode=P5;case P5:if(r.flags&1024&&(m=r.length,m>a&&(m=a),m&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(o,o+m),T)),r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,r.length-=m),r.length))break e;r.length=0,r.mode=N5;case N5:if(r.flags&2048){if(a===0)break e;m=0;do T=i[o+m++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T));while(T&&m<a);if(r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,T)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=R5;case R5:if(r.flags&4096){if(a===0)break e;m=0;do T=i[o+m++],r.head&&T&&r.length<65536&&(r.head.comment+=String.fromCharCode(T));while(T&&m<a);if(r.flags&512&&r.wrap&4&&(r.check=it(r.check,i,m,o)),a-=m,o+=m,T)break e}else r.head&&(r.head.comment=null);r.mode=D5;case D5:if(r.flags&512){for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&4&&l!==(r.check&65535)){t.msg="header crc mismatch",r.mode=De;break}l=0,d=0;}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=true),t.adler=r.check=0,r.mode=zi;break;case O5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}t.adler=r.check=X5(l),l=0,d=0,r.mode=Pd;case Pd:if(r.havedict===0)return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,W7;t.adler=r.check=1,r.mode=zi;case zi:if(e===j7||e===Id)break e;case Yh:if(r.last){l>>>=d&7,d-=d&7,r.mode=Jh;break}for(;d<3;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}switch(r.last=l&1,l>>>=1,d-=1,l&3){case 0:r.mode=M5;break;case 1:if(iE(r),r.mode=vd,e===Id){l>>>=2,d-=2;break e}break;case 2:r.mode=F5;break;case 3:t.msg="invalid block type",r.mode=De;}l>>>=2,d-=2;break;case M5:for(l>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",r.mode=De;break}if(r.length=l&65535,l=0,d=0,r.mode=Qh,e===Id)break e;case Qh:r.mode=U5;case U5:if(m=r.length,m){if(m>a&&(m=a),m>c&&(m=c),m===0)break e;n.set(i.subarray(o,o+m),s),a-=m,o+=m,c-=m,s+=m,r.length-=m;break}r.mode=zi;break;case F5:for(;d<14;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.nlen=(l&31)+257,l>>>=5,d-=5,r.ndist=(l&31)+1,l>>>=5,d-=5,r.ncode=(l&15)+4,l>>>=4,d-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=De;break}r.have=0,r.mode=L5;case L5:for(;r.have<r.ncode;){for(;d<3;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.lens[E[r.have++]]=l&7,l>>>=3,d-=3;}for(;r.have<19;)r.lens[E[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,H={bits:r.lenbits},G=vc(V7,r.lens,0,19,r.lencode,0,r.work,H),r.lenbits=H.bits,G){t.msg="invalid code lengths set",r.mode=De;break}r.have=0,r.mode=H5;case H5:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[l&(1<<r.lenbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(I<16)l>>>=y,d-=y,r.lens[r.have++]=I;else {if(I===16){for(k=y+2;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(l>>>=y,d-=y,r.have===0){t.msg="invalid bit length repeat",r.mode=De;break}T=r.lens[r.have-1],m=3+(l&3),l>>>=2,d-=2;}else if(I===17){for(k=y+3;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=y,d-=y,T=0,m=3+(l&7),l>>>=3,d-=3;}else {for(k=y+7;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=y,d-=y,T=0,m=11+(l&127),l>>>=7,d-=7;}if(r.have+m>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=De;break}for(;m--;)r.lens[r.have++]=T;}}if(r.mode===De)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=De;break}if(r.lenbits=9,H={bits:r.lenbits},G=vc(w8,r.lens,0,r.nlen,r.lencode,0,r.work,H),r.lenbits=H.bits,G){t.msg="invalid literal/lengths set",r.mode=De;break}if(r.distbits=6,r.distcode=r.distdyn,H={bits:r.distbits},G=vc(_8,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,H),r.distbits=H.bits,G){t.msg="invalid distances set",r.mode=De;break}if(r.mode=vd,e===Id)break e;case vd:r.mode=Ed;case Ed:if(a>=6&&c>=258){t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,H7(t,h),s=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,l=r.hold,d=r.bits,r.mode===zi&&(r.back=-1);break}for(r.back=0;x=r.lencode[l&(1<<r.lenbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(w&&(w&240)===0){for(_=y,C=w,v=I;x=r.lencode[v+((l&(1<<_+C)-1)>>_)],y=x>>>24,w=x>>>16&255,I=x&65535,!(_+y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=y,d-=y,r.back+=y,r.length=I,w===0){r.mode=$5;break}if(w&32){r.back=-1,r.mode=zi;break}if(w&64){t.msg="invalid literal/length code",r.mode=De;break}r.extra=w&15,r.mode=K5;case K5:if(r.extra){for(k=r.extra;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra;}r.was=r.length,r.mode=z5;case z5:for(;x=r.distcode[l&(1<<r.distbits)-1],y=x>>>24,w=x>>>16&255,I=x&65535,!(y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((w&240)===0){for(_=y,C=w,v=I;x=r.distcode[v+((l&(1<<_+C)-1)>>_)],y=x>>>24,w=x>>>16&255,I=x&65535,!(_+y<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=y,d-=y,r.back+=y,w&64){t.msg="invalid distance code",r.mode=De;break}r.offset=I,r.extra=w&15,r.mode=q5;case q5:if(r.extra){for(k=r.extra;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,d-=r.extra,r.back+=r.extra;}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=De;break}r.mode=G5;case G5:if(c===0)break e;if(m=h-c,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=De;break}m>r.wnext?(m-=r.wnext,b=r.wsize-m):b=r.wnext-m,m>r.length&&(m=r.length),A=r.window;}else A=n,b=s-r.offset,m=r.length;m>c&&(m=c),c-=m,r.length-=m;do n[s++]=A[b++];while(--m);r.length===0&&(r.mode=Ed);break;case $5:if(c===0)break e;n[s++]=r.length,c--,r.mode=Ed;break;case Jh:if(r.wrap){for(;d<32;){if(a===0)break e;a--,l|=i[o++]<<d,d+=8;}if(h-=c,t.total_out+=h,r.total+=h,r.wrap&4&&h&&(t.adler=r.check=r.flags?it(r.check,n,h,s-h):Pc(r.check,n,h,s-h)),h=c,r.wrap&4&&(r.flags?l:X5(l))!==r.check){t.msg="incorrect data check",r.mode=De;break}l=0,d=0;}r.mode=V5;case V5:if(r.wrap&&r.flags){for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.wrap&4&&l!==(r.total&4294967295)){t.msg="incorrect length check",r.mode=De;break}l=0,d=0;}r.mode=j5;case j5:G=X7;break e;case De:G=C8;break e;case v8:return I8;case E8:default:return yr}return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,r.hold=l,r.bits=d,(r.wsize||h!==t.avail_out&&r.mode<De&&(r.mode<Jh||e!==I5))&&N8(t,t.output,t.next_out,h-t.avail_out),u-=t.avail_in,h-=t.avail_out,t.total_in+=u,t.total_out+=h,r.total+=h,r.wrap&4&&h&&(t.adler=r.check=r.flags?it(r.check,n,h,t.next_out-h):Pc(r.check,n,h,t.next_out-h)),t.data_type=r.bits+(r.last?64:0)+(r.mode===zi?128:0)+(r.mode===vd||r.mode===Qh?256:0),(u===0&&h===0||e===I5)&&G===Qo&&(G=Z7),G},oE=t=>{if(Jo(t))return yr;let e=t.state;return e.window&&(e.window=null),t.state=null,Qo},sE=(t,e)=>{if(Jo(t))return yr;let r=t.state;return (r.wrap&2)===0?yr:(r.head=e,e.done=false,Qo)},aE=(t,e)=>{let r=e.length,i,n,o;return Jo(t)||(i=t.state,i.wrap!==0&&i.mode!==Pd)?yr:i.mode===Pd&&(n=1,n=Pc(n,e,r,0),n!==i.check)?C8:(o=N8(t,e,r,r),o?(i.mode=v8,I8):(i.havedict=1,Qo))},cE=T8,lE=k8,dE=B8,uE=rE,fE=P8,pE=nE,hE=oE,mE=sE,gE=aE,yE="pako inflate (from Nodeca project)",ni={inflateReset:cE,inflateReset2:lE,inflateResetKeep:dE,inflateInit:uE,inflateInit2:fE,inflate:pE,inflateEnd:hE,inflateGetHeader:mE,inflateSetDictionary:gE,inflateInfo:yE};function bE(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=false;}var SE=bE,R8=Object.prototype.toString,{Z_NO_FLUSH:xE,Z_FINISH:Z5,Z_OK:ba,Z_STREAM_END:r2,Z_NEED_DICT:i2,Z_STREAM_ERROR:AE,Z_DATA_ERROR:Y5,Z_MEM_ERROR:wE,Z_BUF_ERROR:Q5}=wa,_E={chunkSize:1024*64,windowBits:15,to:""};function Uc(t){this.options=Rd.assign({},_E,t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=false,this.chunks=[],this.strm=new x8,this.strm.avail_out=0;let r=ni.inflateInit2(this.strm,e.windowBits);if(r!==ba)throw new Error(Wo[r]);if(this.header=new SE,ni.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Rc.string2buf(e.dictionary):R8.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=ni.inflateSetDictionary(this.strm,e.dictionary),r!==ba)))throw new Error(Wo[r])}Uc.prototype.push=function(t,e){let r=this.strm,i=this.options.chunkSize,n=this.options.dictionary,o,s,a;if(this.ended)return false;for(e===~~e?s=e:s=e===true?Z5:xE,R8.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),o=ni.inflate(r,s),o===i2&&n&&(o=ni.inflateSetDictionary(r,n),o===ba?o=ni.inflate(r,s):o===Y5&&(o=i2));r.avail_in>0&&o===r2&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)ni.inflateReset(r),o=ni.inflate(r,s);switch(o){case AE:case Y5:case i2:case wE:return this.onEnd(o),this.ended=true,false}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===r2||s>0))if(this.options.to==="string"){let c=Rc.utf8border(r.output,r.next_out),l=r.next_out-c,d=Rc.buf2string(r.output,c);r.next_out=l,r.avail_out=i-l,l&&r.output.set(r.output.subarray(c,c+l),0),this.onData(d);}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0;if(!((o===ba||o===Q5)&&a===0)){if(o===r2)return o=ni.inflateEnd(this.strm),this.onEnd(o),this.ended=true,true;if(r.avail_in===0){if(s===Z5)return o=ni.inflateEnd(this.strm),this.onEnd(o===ba?Q5:o),this.ended=true,false;break}}}return true};Uc.prototype.onData=function(t){this.chunks.push(t);};Uc.prototype.onEnd=function(t){t===ba&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function x2(t,e){let r=new Uc(e);if(r.push(t,true),r.err)throw r.msg||Wo[r.err];return r.result}var vE=x2,kE={inflate:vE},{deflate:PE}=F7,{inflate:NE}=kE;var D8=PE;var A2=NE;var RE=(0, U8.default)("bridge"),O8=32*1024,w2=1024*16,DE=1;function M8(t,e){return {jsonrpc:"2.0",id:fa(16),method:t,params:e}}async function OE(t,e,r,i){let n=[],o=[];if(e){let s=Buffer.from(D8(JSON.stringify(e))).toString("base64"),a=Math.ceil(s.length/w2),c=fa(16);for(let l=0;l<a;l++){let d=l*w2,u=Math.min(d+w2,s.length),h=s.slice(d,u),m=JSON.stringify({method:t,params:h,chunk:{id:c,index:l,length:a}}),b=await xc(m,r,i),A=M8("encryptedMessage",{payload:Buffer.from(b).toString("base64")});o.push(A.id),n.push(JSON.stringify(A));}}else {let s=JSON.stringify({method:t,params:e||{}}),a=await xc(s,r,i),c=M8("encryptedMessage",{payload:Buffer.from(a).toString("base64")});o.push(c.id),n.push(JSON.stringify(c));}return {chunks:n,messageIds:o}}async function _2(t,e,r,i,n){try{let{chunks:o,messageIds:s}=await OE(t,e,r,i);for(let a of o){if(a.length>O8)throw new Error(`Payload exceeds max size of ${O8} bytes`);n.send(a),o.length>1&&await new Promise(c=>setTimeout(c,DE));}return {success:!0,messageIds:s}}catch(o){return RE("Error sending encrypted message:",o),{success:false,messageIds:[]}}}var C2=class{constructor(t){f(this,"code");f(this,"reason");f(this,"event");this.code=t.code,this.reason=t.reason,this.event=t.event;}},Od=class{constructor(t){f(this,"code");f(this,"reason");f(this,"wasConnected");f(this,"wasIntentionalClose");f(this,"willReconnect");f(this,"event");this.code=t.code,this.reason=t.reason,this.wasConnected=t.wasConnected,this.wasIntentionalClose=t.wasIntentionalClose,this.willReconnect=t.willReconnect,this.event=t.event;}};var F8=It(uc(),1);var I2=class{constructor(t){f(this,"log");f(this,"role");f(this,"origin");f(this,"_bridgeOrigin");f(this,"bridgeId");f(this,"keyPair");f(this,"remotePublicKey");f(this,"sharedSecret");f(this,"websocket");f(this,"secureChannelEstablished",false);f(this,"intentionalClose",false);f(this,"keepalive");f(this,"reconnect");f(this,"reconnectAttempts",0);f(this,"maxReconnectAttempts");f(this,"reconnectTimer");f(this,"pingTimer");f(this,"pingInterval",3e4);f(this,"isReconnecting",false);f(this,"isConnected",false);f(this,"everConnected",false);f(this,"isCreatingSocket",false);f(this,"resumedSession",false);f(this,"bridgeUrl");f(this,"validMessagesReceived",0);f(this,"lastMessageTimestamp",0);f(this,"lastCloseEvent");f(this,"originOnConnect");f(this,"_originValidatedViaOoc",false);f(this,"eventListeners");f(this,"incompleteMessages",new Map);f(this,"seenMessageIds",new Set);f(this,"reconnectOnWake",()=>{document.visibilityState==="visible"&&this.reconnectIfDisconnected();});this.role=t.role,this.origin=t.origin;let e=t.pinOrigin??true;this._bridgeOrigin=e?t.domain:void 0,this.log=(0, F8.default)(`bridge:${this.role}`),this.bridgeId=t.bridgeId||fa(16),this.keyPair=t.keyPair,this.reconnect=t.reconnect??true,this.keepalive=t.keepalive??true,this.maxReconnectAttempts=t.reconnectAttempts??B6,this.pingInterval=t.pingInterval||k6,this.bridgeUrl=t.bridgeUrl??T6,this.originOnConnect=t.originOnConnect??true,this.eventListeners={connected:[],"secure-channel-established":[],"raw-message-received":[],"message-received":[],"chunk-received":[],error:[],"failed-to-connect":[],disconnected:[]},this.reconnect&&typeof document<"u"&&(document.addEventListener("visibilitychange",this.reconnectOnWake),window.addEventListener("online",this.reconnectOnWake));}resume(){this.log("Resuming bridge session"),this.secureChannelEstablished=true,this.resumedSession=true;}on(t,e){return this.eventListeners[t].push(e),()=>this.off(t,e)}off(t,e){let r=this.eventListeners[t].indexOf(e);r!==-1&&this.eventListeners[t].splice(r,1);}async emit(t,...e){await Promise.all(this.eventListeners[t].map(async r=>{try{await r(...e);}catch(i){this.log(`Error in ${t} listener:`,i);}}));}setupWebSocketHandlers(t){t.onopen=async()=>{if(this.isConnected=true,this.everConnected=true,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this.websocket&&this.websocket.send(JSON.stringify({method:"ping",params:{},nocache:true}));},this.pingInterval),this.isReconnecting){if(this.log("Reconnected to bridge"),this.resetReconnection(),this.lastMessageTimestamp>0&&this.websocket){let e=this.lastMessageTimestamp-1e3;this.log(`Requesting message replay starting from ${e}`),this.websocket.send(JSON.stringify({method:"replay",params:{timestamp:e}}));}await this.emit("connected",true);}else this.log("Connected to bridge"),this.lastMessageTimestamp===0&&(this.lastMessageTimestamp=Date.now()),await this.emit("connected",false),this.resumedSession&&(this.log("Resumed session, emitting secure channel established event"),await this.emit("secure-channel-established"));},t.onerror=e=>{this.log("[websocket.onerror]",e?.message??"socket error");},t.onmessage=async e=>{await this.emit("raw-message-received",e.data);try{let r=JSON.parse(e.data);await this.handleWebSocketMessage(r);}catch(r){this.log("Error parsing message:",r),await this.emit("error",`Error parsing message: ${r instanceof Error?r.message:String(r)}`);}},t.onclose=async e=>{let{code:r,reason:i,wasClean:n}=e;this.log("[websocket.onclose]",{code:r,reason:i,wasClean:n,readyState:t.readyState}),this.lastCloseEvent=e,this.pingTimer&&clearInterval(this.pingTimer);let o=this.isConnected;if(this.isConnected=false,o){let s=new Od({code:e.code,reason:e.reason,wasConnected:true,wasIntentionalClose:this.intentionalClose,willReconnect:!this.intentionalClose&&this.reconnect,event:e});if(await this.emit("disconnected",s),this.websocket!==t||this.isReconnecting)return}if(this.intentionalClose){this.log("Intentional close, not attempting reconnect"),this._handleCleanup();return}if(!o&&this.isReconnecting){this.log("Reconnection attempt failed"),await this.handleReconnect();return}if(!o){let s=new C2({code:e.code,reason:e.reason,event:e});await this.emit("failed-to-connect",s);return}this.log("WebSocket closed"),this.reconnect&&await this.handleReconnect();};}async handleWebSocketMessage(t){if(t.method==="ping"){this.log("Received ping message, responding with pong"),this.websocket?.send(JSON.stringify({method:"pong",params:{},nocache:true}));return}if(t.method!=="pong"){if(this.role==="joiner"&&t.method==="ooc"&&t.params?.origin){if(!this.originOnConnect){this.log("WARNING: Ignoring unsolicited ooc message");return}if(this.secureChannelEstablished){this.log("WARNING: Secure channel already established. Ignoring ooc message");return}let e=wh(t.params.origin);if(this.log("Received origin on connect:",e),this._bridgeOrigin&&this._bridgeOrigin!==e){this.log(`WARNING: Expected origin ${this._bridgeOrigin} but got ${e} (via ooc)`),await this.emit("error",`Origin on connect ${e} does not match expected origin ${this._bridgeOrigin}`);return}this._bridgeOrigin||(this._bridgeOrigin=e,this.log("Set bridge origin from ooc:",this._bridgeOrigin)),this._originValidatedViaOoc=true,this.secureChannelEstablished=true,await this.emit("secure-channel-established");return}if(!t.id){this.log("Ignoring message with missing id:",t);return}if(this.seenMessageIds.has(t.id)){this.log("Ignoring message with duplicate id:",t.id);return}if(this.seenMessageIds.add(t.id),this.validMessagesReceived+=1,this.lastMessageTimestamp=Date.now(),this.role==="creator"&&t.method==="handshake"&&(this.log("Processing handshake message"),await this.handleHandshake(t)),t.method==="encryptedMessage"){if(this.log("Processing encrypted message"),this.role==="joiner"&&this._bridgeOrigin){let e=t.origin?wh(t.origin):void 0;if(e!==this._bridgeOrigin){this.log(`WARNING: Origin differs from origin in connection string. Expected ${this._bridgeOrigin} but got ${e}`),this.log("Ignoring received message:",t),this.emit("error",`Origin ${e} does not match expected origin ${this._bridgeOrigin}`);return}}await this.handleEncryptedMessage(t);}}}async handleHandshake(t){this.log("Received handshake:",t);try{let e=new Uint8Array(Buffer.from(t.params.pubkey,"hex"));if(this.secureChannelEstablished&&this.remotePublicKey!==e){this.log("Secure channel already established, ignoring handshake"),this.emit("error","Secure channel already established, ignoring handshake"),this.websocket?.send(JSON.stringify({method:"error",params:{message:"Secure channel already established, ignoring handshake"}}));return}if(this.remotePublicKey=e,this.sharedSecret=zh(this.keyPair.privateKey,e),await qh(Buffer.from(t.params.greeting,"hex"),this.sharedSecret,this.bridgeId)!=="hello")throw new Error("Invalid greeting");this.websocket&&(await _2("hello",null,this.sharedSecret,this.bridgeId,this.websocket)).messageIds.forEach(n=>this.seenMessageIds.add(n)),this.secureChannelEstablished?this.log("Secure channel already established, sending handshake message again"):(this.secureChannelEstablished=!0,await this.emit("secure-channel-established"));}catch(e){this.log("Error handling handshake:",e),await this.emit("error",`Error handling handshake: ${e instanceof Error?e.message:String(e)}`);}}async handleEncryptedMessage(t){try{if(!this.sharedSecret)throw new Error("Shared secret not available");let e=new Uint8Array(Buffer.from(t.params.payload,"base64")),r=await qh(e,this.sharedSecret,this.bridgeId),i=JSON.parse(r);if(!i.chunk||i.chunk.length==1)if(i.method==="hello"&&!this.secureChannelEstablished)this.log(`Verified origin: ${t.origin}`),this.secureChannelEstablished=!0,await this.emit("secure-channel-established");else {try{if(i.params&&i.params.length>0){this.log("Received compressed single-part message");let n=Buffer.from(i.params,"base64"),o=A2(n),s=new TextDecoder().decode(o);i.params=JSON.parse(s),delete i.chunk;}}catch(n){if(n!=="incorrect header check")throw console.error("Some error happened data:",n),new Error("Failed to parse data: ");this.log("Received uncompressed single-part message");try{i.params=JSON.parse(i.params);}catch{}}await this.emit("message-received",i);}else {let{index:n,length:o,id:s}=i.chunk;this.log(`Received chunk (${n+1}/${o}) for chunk id ${s}`),this.incompleteMessages.has(s)||this.incompleteMessages.set(s,{chunks:new Array(o),expectedChunks:o,timestamp:Date.now()});let a=this.incompleteMessages.get(s);if(a.expectedChunks!==o)throw this.log(`Chunk count mismatch for id ${s}. Expected ${a.expectedChunks}, got ${o}`),new Error(`Chunk count mismatch for id ${s}. Expected ${a.expectedChunks}, got ${o}`);if(a.chunks[n]=i.params,await this.emit("chunk-received",i.chunk),(()=>{for(let l=0;l<a.chunks.length;l++)if(a.chunks[l]===void 0)return !1;return !0})()){let l=a.chunks.join(""),d=Buffer.from(l,"base64"),u=A2(d),h=new TextDecoder().decode(u),m=JSON.parse(h);this.log(`Received all chunks for chunk id ${s}, reconstructing message`);let b={method:i.method,params:m};this.incompleteMessages.delete(s),await this.emit("message-received",b);}}}catch(e){this.log("Error decrypting message:",e),await this.emit("error",`Error decrypting message: ${e instanceof Error?e.message:String(e)}`);}}async handleReconnect(){if(this.reconnectAttempts++,this.reconnectAttempts>this.maxReconnectAttempts){this.log(`WebSocket disconnected, max reconnection attempts (${this.maxReconnectAttempts}) reached`),this.resetReconnection();let e=this.lastCloseEvent;await this.emit("disconnected",new Od({code:e.code,reason:e.reason,wasConnected:true,wasIntentionalClose:false,willReconnect:false,event:e}));return}this.isReconnecting=true,this.log(`WebSocket disconnected, attempting reconnect ${this.reconnectAttempts}/${this.maxReconnectAttempts}`);let t=0;this.reconnectAttempts>1&&(t=1e3*Math.pow(2,this.reconnectAttempts-2),this.log(`Waiting ${t}ms before reconnecting...`)),this.reconnectTimer=setTimeout(async()=>{this.isCreatingSocket=true;try{let e=await this._getWsConnectionUrl();this.websocket=await cd(e,this.origin),this.setupWebSocketHandlers(this.websocket);}catch(e){this.log("Reconnection failed:",e),await this.handleReconnect();}finally{this.isCreatingSocket=false;}},t);}reconnectIfDisconnected(){return this.intentionalClose||!this.reconnect||!this.everConnected||this.isCreatingSocket||this.websocket?.readyState!==3?false:(this.log("Connection lost, reconnecting now"),this.resetReconnection(),this.handleReconnect(),true)}resetReconnection(){this.log("Resetting reconnection state"),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.reconnectAttempts=0,this.isReconnecting=false;}isBridgeConnected(){return this.websocket?this.websocket.readyState===1:false}isSecureChannelEstablished(){return this.secureChannelEstablished}async sendSecureMessage(t,e={}){if(!this.isConnected||!this.secureChannelEstablished)return await this.emit("error","Cannot send message: Secure channel not established"),false;let r=await _2(t,e,this.sharedSecret,this.bridgeId,this.websocket);return r.messageIds.forEach(i=>this.seenMessageIds.add(i)),r.success}onConnect(t){return this.on("connected",t)}onSecureChannelEstablished(t){return this.on("secure-channel-established",t)}onRawMessage(t){return this.on("raw-message-received",t)}onSecureMessage(t){return this.on("message-received",t)}onError(t){return this.on("error",t)}onFailedToConnect(t){return this.on("failed-to-connect",e=>t(e))}onDisconnect(t){return this.on("disconnected",e=>t(e))}setRemotePublicKey(t){this.remotePublicKey=t;}computeSharedSecret(){if(!this.remotePublicKey)throw new Error("Remote public key not set");this.sharedSecret=zh(this.keyPair.privateKey,this.remotePublicKey);}async createEncryptedGreeting(){if(!this.sharedSecret)throw new Error("Shared secret not available");let t=await xc("hello",this.sharedSecret,this.bridgeId);return Buffer.from(t).toString("hex")}async _getWsConnectionUrl(){if(this.role==="creator")return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}`;{let t=this.originOnConnect?"&ooc":"";if(this.isSecureChannelEstablished())return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}`;{let e=await this.createEncryptedGreeting(),r=JSON.stringify({jsonrpc:"2.0",id:fa(16),method:"handshake",params:{pubkey:this.getPublicKey(),greeting:e}}),i=Buffer.from(r).toString("base64");return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${ua}&moc=${encodeURIComponent(i)}${t}`}}}getPublicKey(){return pc(this.keyPair.publicKey)}getRemotePublicKey(){if(!this.remotePublicKey)throw new Error("Remote public key not set");return pc(this.remotePublicKey)}getBridgeId(){return this.bridgeId}getWebSocket(){return this.websocket}get bridgeOrigin(){return this.role==="creator"?this.origin:this._bridgeOrigin}get connectionString(){let t=this.bridgeOrigin;if(!t)throw new Error("Bridge origin is not known yet, wait for the secure channel to be established");let e=this.originOnConnect?"&ooc":"";return this.role==="creator"?`obsidion:${this.getPublicKey()}?d=${t}&v=${ua}${e}`:`obsidion:${this.getBridgeId()}?d=${t}&v=${ua}${e}`}async connect(t){try{this.log("Connecting to bridge...",t);let e=await(this.origin?cd(t,this.origin):cd(t));this.websocket=e,this.setupWebSocketHandlers(e);}catch(e){throw this.log("Error connecting to bridge:",e),await this.emit("error",`Error connecting to bridge: ${e instanceof Error?e.message:String(e)}`),e}}_handleCleanup(){this.log("Cleaning up event listeners and associated state"),typeof document<"u"&&(document.removeEventListener("visibilitychange",this.reconnectOnWake),window.removeEventListener("online",this.reconnectOnWake)),this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=void 0,this.websocket&&(this.websocket.onopen=null,this.websocket.onmessage=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket=void 0),this.secureChannelEstablished=false,this.sharedSecret=void 0,this.remotePublicKey=void 0,this.eventListeners={connected:[],"secure-channel-established":[],"raw-message-received":[],"message-received":[],"chunk-received":[],error:[],"failed-to-connect":[],disconnected:[]};}cleanup(){this.log("Closing connection to bridge"),this.intentionalClose=true;let t=this.websocket?.readyState;t===1||t===0?this.websocket.close(1e3,"Connection closed by user"):this._handleCleanup();}};var v2=It(uc(),1),E2=class L8{static async create(e={}){e.debug&&v2.default.enable("bridge*");let r=e.autoconnect??true;if(e.origin&&typeof window<"u")throw new Error("Origin can't be specified when running in browser");!e.origin&&typeof window>"u"&&(e.origin="nodejs");let i=e.origin||window?.location?.protocol+"//"+window?.location?.hostname;if(e.remotePublicKey&&!e.resume)throw new Error("Can only provide remotePublicKey when resuming a bridge session");if(e.resume&&(!e.keyPair||!e.remotePublicKey))throw new Error("Resuming a bridge session requires a keyPair and remotePublicKey");let n=e.keyPair||wd(),o=pc(n.publicKey),s=new I2({role:"creator",origin:i,bridgeId:o,keyPair:n,reconnect:e.reconnect,keepalive:e.keepalive,pingInterval:e.pingInterval,bridgeUrl:e.bridgeUrl,originOnConnect:e.originOnConnect??true});return e.resume&&(s.setRemotePublicKey(e.remotePublicKey),await s.computeSharedSecret(),s.resume()),(e.resume||r)&&await s.connect(await s._getWsConnectionUrl()),{websocket:s.getWebSocket(),connection:s,onConnect:a=>s.onConnect(a),onFailedToConnect:a=>s.onFailedToConnect(a),onSecureChannelEstablished:a=>s.onSecureChannelEstablished(a),onRawMessage:a=>s.onRawMessage(a),onSecureMessage:a=>s.onSecureMessage(a),onError:a=>s.onError(a),onDisconnect:a=>s.onDisconnect(a),isBridgeConnected:()=>s.isBridgeConnected(),isSecureChannelEstablished:()=>s.isSecureChannelEstablished(),sendMessage:(a,c)=>s.sendSecureMessage(a,c||{}),connectionString:s.connectionString,bridgeId:s.getBridgeId(),origin:s.bridgeOrigin,getKeyPair:()=>s.keyPair,getPublicKey:()=>s.getPublicKey(),getRemotePublicKey:()=>s.getRemotePublicKey(),close:()=>s.cleanup(),cleanup:()=>s.cleanup(),[Symbol.dispose]:()=>s.cleanup()}}static async join(e,r={}){if(r.debug&&v2.default.enable("bridge*"),r.resume&&!r.keyPair)throw new Error("Resuming a bridge session requires a keyPair");let i=r.keyPair||wd(),{domain:n,pubkey:o,ooc:s}=L8.parseConnectionString(e),a=r.originOnConnect!==void 0?r.originOnConnect:s;if(r.pinOrigin===false&&(!a||r.resume))throw new Error("pinOrigin: false requires originOnConnect and cannot be combined with resume");let c=new I2({role:"joiner",domain:n,bridgeId:o,keyPair:i,reconnect:r.reconnect,keepalive:r.keepalive,pingInterval:r.pingInterval,bridgeUrl:r.bridgeUrl,originOnConnect:a,pinOrigin:r.pinOrigin});return c.setRemotePublicKey(new Uint8Array(Buffer.from(o,"hex"))),await c.computeSharedSecret(),r.resume&&c.resume(),await c.connect(await c._getWsConnectionUrl()),{websocket:c.getWebSocket(),connection:c,onConnect:l=>c.onConnect(l),onFailedToConnect:l=>c.onFailedToConnect(l),onSecureChannelEstablished:l=>c.onSecureChannelEstablished(l),onRawMessage:l=>c.onRawMessage(l),onSecureMessage:l=>c.onSecureMessage(l),onError:l=>c.onError(l),onDisconnect:l=>c.onDisconnect(l),isBridgeConnected:()=>c.isBridgeConnected(),isSecureChannelEstablished:()=>c.isSecureChannelEstablished(),sendMessage:(l,d)=>c.sendSecureMessage(l,d||{}),get connectionString(){return c.connectionString},bridgeId:c.getBridgeId(),get origin(){return c.bridgeOrigin},getKeyPair:()=>c.keyPair,getPublicKey:()=>c.getPublicKey(),getRemotePublicKey:()=>c.getRemotePublicKey(),close:()=>c.cleanup(),cleanup:()=>c.cleanup(),[Symbol.dispose]:()=>c.cleanup()}}static parseConnectionString(e){let r=new URL(e),i=r.pathname,n=r.searchParams.get("d"),o=r.searchParams.has("ooc");if(!n||!i)throw new Error("Invalid connection string: missing required parameters");return n!=="nodejs"&&!n.startsWith("http")&&(n="https://"+n),{domain:n,pubkey:i,ooc:o}}static async generateKeyPair(){return wd()}};var Kd=It(V8(),1);var j8={locale:"en",countries:{AF:"Afghanistan",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:["People's Republic of China","China"],CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:["Republic of the Congo","Congo"],CD:["Democratic Republic of the Congo","Congo"],CK:"Cook Islands",CR:"Costa Rica",CI:["Cote d'Ivoire","C\xF4te d'Ivoire","Ivory Coast"],HR:"Croatia",CU:"Cuba",CY:"Cyprus",CZ:["Czech Republic","Czechia"],DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:["Republic of The Gambia","The Gambia","Gambia"],GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:["Islamic Republic of Iran","Iran"],IQ:"Iraq",IE:"Ireland",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"North Korea",KR:["South Korea","Korea, Republic of","Republic of Korea"],KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:["Netherlands","The Netherlands","Netherlands (Kingdom of the)"],NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MK:["The Republic of North Macedonia","North Macedonia"],MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:["State of Palestine","Palestine"],PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:["Pitcairn","Pitcairn Islands"],PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Reunion",RO:"Romania",RU:["Russian Federation","Russia"],RW:"Rwanda",SH:"Saint Helena",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Eswatini",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:["Taiwan, Province of China","Taiwan"],TJ:"Tajikistan",TZ:["United Republic of Tanzania","Tanzania"],TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:["T\xFCrkiye","Turkey"],TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:["United Arab Emirates","UAE"],GB:["United Kingdom","UK","Great Britain"],US:["United States of America","United States","USA","U.S.A.","US","U.S."],UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela",VN:"Vietnam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe",AX:["\xC5land Islands","Aland Islands"],BQ:"Bonaire, Sint Eustatius and Saba",CW:"Cura\xE7ao",GG:"Guernsey",IM:"Isle of Man",JE:"Jersey",ME:"Montenegro",BL:"Saint Barth\xE9lemy",MF:"Saint Martin (French part)",RS:"Serbia",SX:"Sint Maarten (Dutch part)",SS:"South Sudan",XK:"Kosovo"}};var eS={debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}};(0, Kd.registerLocale)(j8);function Gi(t){if(t==="Zero Knowledge Republic")return "ZKR";let e;return e=(0, Kd.getAlpha3Code)(t,"en")||t||"ZKR",e}function Ln(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function pS(t,e,r,i){i[r][t]={...i[r][t],range:e};}function va(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function jE(){let t={query:{}},e="query",r=false,i=o=>{if(t[e].policy)throw new Error(`Cannot call .${o}() on a policy-driven query. The query for policy '${t[e].policy}' is immutable.`);r=true;},n={eq:(o,s)=>(i("eq"),(o==="issuing_country"||o==="nationality")&&(s=Gi(s)),va("eq",o,s,e,t),n),gte:(o,s)=>{if(i("gte"),Ln("gte",o,s,e,t),o==="age"&&(s<1||s>=100))throw new Error("Age must be between 1 and 99 (inclusive)");return n},gt:(o,s)=>(i("gt"),Ln("gt",o,s,e,t),n),lte:(o,s)=>(i("lte"),Ln("lte",o,s,e,t),n),lt:(o,s)=>(i("lt"),Ln("lt",o,s,e,t),n),range:(o,s,a)=>(i("range"),pS(o,[s,a],e,t),n),in:(o,s)=>(i("in"),s=s.map(a=>Gi(a)),va("in",o,s,e,t),n),out:(o,s)=>(i("out"),s=s.map(a=>Gi(a)),va("out",o,s,e,t),n),disclose:o=>(i("disclose"),t[e][o]={...t[e][o],disclose:true},n),bind:(o,s)=>(t[e].bind={...t[e].bind,[o]:s},n),sanctions:(o="all",s="all",a={strict:false})=>(i("sanctions"),t[e].sanctions={...t[e].sanctions,countries:o,lists:s,strict:a.strict??false},n),facematch:(o="strict")=>(i("facematch"),t[e].facematch={mode:o},n),raw:o=>(i("raw"),t[e]=o,n),policy:o=>{if(typeof o!="string"||o.length===0)throw new Error(".policy() requires a non-empty string id.");if(t[e].policy)throw new Error(`Cannot call .policy() more than once on a request (already set to '${t[e].policy}').`);if(r)throw new Error("Cannot combine .policy() with builder methods like .gte()/.disclose()/etc.");return t[e].policy=o,n},done:(()=>({query:t[e]}))};return n}var XE="0.19.1",O2=XE,gt=10080*60,Fn=new Date(0),hS="https://dashboard-api.zkpassport.id",WE="https://verifier.zkpassport.id",tS="0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b",rS="0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d",iS="0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b",nS="0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211",oS="0x0e1889bec6c1d686abcf08360ff404f803ab345881ea8cba6aad33b7f7f7ffe0",sS=1440*60*1e3,ZE=class{static checkDiscloseBytesPublicInputs(t,e,r){let i={},n=true,o=t.committedInputs?.disclose_bytes?.disclosedBytes??t.committedInputs?.disclose_bytes_evm?.disclosedBytes,s=jp.fromDisclosedBytes(o,"passport"),a=jp.fromDisclosedBytes(o,"id_card");if(r.document_type&&(r.document_type.eq&&r.document_type.eq.result&&r.document_type.eq.expected!==s.documentType&&(console.warn("Document type does not match the expected document type"),n=false,i.document_type={...i.document_type,eq:{expected:`${r.document_type.eq.expected}`,received:`${s.documentType??a.documentType}`,message:"Document type does not match the expected document type"}}),r.document_type.disclose&&r.document_type.disclose.result!==a.documentType&&(console.warn("Document type does not match the disclosed document type in query result"),n=false,i.document_type={...i.document_type,disclose:{expected:`${r.document_type.disclose?.result}`,received:`${a.documentType??s.documentType}`,message:"Document type does not match the disclosed document type in query result"}}),r.document_type.eq&&(e.document_type?.eq===void 0||r.document_type.eq.expected!==e.document_type.eq)&&(console.warn("Document type eq does not match the original query"),n=false,i.document_type={...i.document_type,eq:{expected:`${e.document_type?.eq}`,received:`${r.document_type.eq.expected}`,message:"Document type eq does not match the original query"}}),r.document_type.disclose&&!e.document_type?.disclose&&(console.warn("Document type disclose is not in the original query"),n=false,i.document_type={...i.document_type,disclose:{expected:"Not requested in original query",received:`${r.document_type.disclose.result}`,message:"Document type disclose is not in the original query"}})),r.birthdate){let c=s.dateOfBirth,l=a.dateOfBirth;r.birthdate.eq&&r.birthdate.eq.result&&!me(r.birthdate.eq.expected,c)&&!me(r.birthdate.eq.expected,l)&&(console.warn("Birthdate does not match the expected birthdate"),n=false,i.birthdate={...i.birthdate,eq:{expected:`${r.birthdate.eq.expected.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Birthdate does not match the expected birthdate"}}),r.birthdate.disclose&&!me(r.birthdate.disclose.result,c)&&!me(r.birthdate.disclose.result,l)&&(console.warn("Birthdate does not match the disclosed birthdate in query result"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${r.birthdate.disclose.result.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Birthdate does not match the disclosed birthdate in query result"}}),r.birthdate.eq&&(e.birthdate?.eq===void 0||!me(r.birthdate.eq.expected,e.birthdate.eq))&&(console.warn("Birthdate eq does not match the original query"),n=false,i.birthdate={...i.birthdate,eq:{expected:`${e.birthdate?.eq?.toISOString?.()??"undefined"}`,received:`${r.birthdate.eq.expected.toISOString()}`,message:"Birthdate eq does not match the original query"}}),r.birthdate.disclose&&!e.birthdate?.disclose&&(console.warn("Birthdate disclose is not in the original query"),n=false,i.birthdate={...i.birthdate,disclose:{expected:"Not requested in original query",received:`${r.birthdate.disclose.result}`,message:"Birthdate disclose is not in the original query"}});}if(r.expiry_date){let c=s.dateOfExpiry,l=a.dateOfExpiry;r.expiry_date.eq&&r.expiry_date.eq.result&&!me(r.expiry_date.eq.expected,c)&&!me(r.expiry_date.eq.expected,l)&&(console.warn("Expiry date does not match the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,eq:{expected:`${r.expiry_date.eq.expected.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Expiry date does not match the expected expiry date"}}),r.expiry_date.disclose&&!me(r.expiry_date.disclose.result,c)&&!me(r.expiry_date.disclose.result,l)&&(console.warn("Expiry date does not match the disclosed expiry date in query result"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${r.expiry_date.disclose.result.toISOString()}`,received:`${c?.toISOString()??l?.toISOString()}`,message:"Expiry date does not match the disclosed expiry date in query result"}}),r.expiry_date.eq&&(e.expiry_date?.eq===void 0||!me(r.expiry_date.eq.expected,e.expiry_date.eq))&&(console.warn("Expiry date eq does not match the original query"),n=false,i.expiry_date={...i.expiry_date,eq:{expected:`${e.expiry_date?.eq?.toISOString?.()??"undefined"}`,received:`${r.expiry_date.eq.expected.toISOString()}`,message:"Expiry date eq does not match the original query"}}),r.expiry_date.disclose&&!e.expiry_date?.disclose&&(console.warn("Expiry date disclose is not in the original query"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:"Not requested in original query",received:`${r.expiry_date.disclose.result}`,message:"Expiry date disclose is not in the original query"}});}if(r.nationality){let c=s.nationality,l=a.nationality;r.nationality.eq&&r.nationality.eq.result&&r.nationality.eq.expected!==c&&r.nationality.eq.expected!==l&&(console.warn("Nationality does not match the expected nationality"),n=false,i.nationality={...i.nationality,eq:{expected:`${r.nationality.eq.expected}`,received:`${c??l}`,message:"Nationality does not match the expected nationality"}}),r.nationality.disclose&&r.nationality.disclose.result!==c&&r.nationality.disclose.result!==l&&(console.warn("Nationality does not match the disclosed nationality in query result"),n=false,i.nationality={...i.nationality,disclose:{expected:`${r.nationality.disclose.result}`,received:`${c??l}`,message:"Nationality does not match the disclosed nationality in query result"}}),r.nationality.eq&&(e.nationality?.eq===void 0||r.nationality.eq.expected!==e.nationality.eq)&&(console.warn("Nationality eq does not match the original query"),n=false,i.nationality={...i.nationality,eq:{expected:`${e.nationality?.eq}`,received:`${r.nationality.eq.expected}`,message:"Nationality eq does not match the original query"}}),r.nationality.disclose&&!e.nationality?.disclose&&(console.warn("Nationality disclose is not in the original query"),n=false,i.nationality={...i.nationality,disclose:{expected:"Not requested in original query",received:`${r.nationality.disclose.result}`,message:"Nationality disclose is not in the original query"}});}if(r.document_number){let c=s.documentNumber,l=a.documentNumber;r.document_number.eq&&r.document_number.eq.result&&r.document_number.eq.expected!==c&&r.document_number.eq.expected!==l&&(console.warn("Document number does not match the expected document number"),n=false,i.document_number={...i.document_number,eq:{expected:`${r.document_number.eq.expected}`,received:`${c??l}`,message:"Document number does not match the expected document number"}}),r.document_number.disclose&&r.document_number.disclose.result!==c&&r.document_number.disclose.result!==l&&(console.warn("Document number does not match the disclosed document number in query result"),n=false,i.document_number={...i.document_number,disclose:{expected:`${r.document_number.disclose.result}`,received:`${c??l}`,message:"Document number does not match the disclosed document number in query result"}}),r.document_number.eq&&(e.document_number?.eq===void 0||r.document_number.eq.expected!==e.document_number.eq)&&(console.warn("Document number eq does not match the original query"),n=false,i.document_number={...i.document_number,eq:{expected:`${e.document_number?.eq}`,received:`${r.document_number.eq.expected}`,message:"Document number eq does not match the original query"}}),r.document_number.disclose&&!e.document_number?.disclose&&(console.warn("Document number disclose is not in the original query"),n=false,i.document_number={...i.document_number,disclose:{expected:"Not requested in original query",received:`${r.document_number.disclose.result}`,message:"Document number disclose is not in the original query"}});}if(r.gender){let c=s.gender,l=a.gender;r.gender.eq&&r.gender.eq.result&&r.gender.eq.expected!==c&&r.gender.eq.expected!==l&&(console.warn("Gender does not match the expected gender"),n=false,i.gender={...i.gender,eq:{expected:`${r.gender.eq.expected}`,received:`${c??l}`,message:"Gender does not match the expected gender"}}),r.gender.disclose&&r.gender.disclose.result!==c&&r.gender.disclose.result!==l&&(console.warn("Gender does not match the disclosed gender in query result"),n=false,i.gender={...i.gender,disclose:{expected:`${r.gender.disclose.result}`,received:`${c??l}`,message:"Gender does not match the disclosed gender in query result"}}),r.gender.eq&&(e.gender?.eq===void 0||r.gender.eq.expected!==e.gender.eq)&&(console.warn("Gender eq does not match the original query"),n=false,i.gender={...i.gender,eq:{expected:`${e.gender?.eq}`,received:`${r.gender.eq.expected}`,message:"Gender eq does not match the original query"}}),r.gender.disclose&&!e.gender?.disclose&&(console.warn("Gender disclose is not in the original query"),n=false,i.gender={...i.gender,disclose:{expected:"Not requested in original query",received:`${r.gender.disclose.result}`,message:"Gender disclose is not in the original query"}});}if(r.issuing_country){let c=s.issuingCountry,l=a.issuingCountry;r.issuing_country.eq&&r.issuing_country.eq.result&&r.issuing_country.eq.expected!==c&&r.issuing_country.eq.expected!==l&&(console.warn("Issuing country does not match the expected issuing country"),n=false,i.issuing_country={...i.issuing_country,eq:{expected:`${r.issuing_country.eq.expected}`,received:`${c??l}`,message:"Issuing country does not match the expected issuing country"}}),r.issuing_country.disclose&&r.issuing_country.disclose.result!==c&&r.issuing_country.disclose.result!==l&&(console.warn("Issuing country does not match the disclosed issuing country in query result"),n=false,i.issuing_country={...i.issuing_country,disclose:{expected:`${r.issuing_country.disclose.result}`,received:`${c??l}`,message:"Issuing country does not match the disclosed issuing country in query result"}}),r.issuing_country.eq&&(e.issuing_country?.eq===void 0||r.issuing_country.eq.expected!==e.issuing_country.eq)&&(console.warn("Issuing country eq does not match the original query"),n=false,i.issuing_country={...i.issuing_country,eq:{expected:`${e.issuing_country?.eq}`,received:`${r.issuing_country.eq.expected}`,message:"Issuing country eq does not match the original query"}}),r.issuing_country.disclose&&!e.issuing_country?.disclose&&(console.warn("Issuing country disclose is not in the original query"),n=false,i.issuing_country={...i.issuing_country,disclose:{expected:"Not requested in original query",received:`${r.issuing_country.disclose.result}`,message:"Issuing country disclose is not in the original query"}});}if(r.fullname){let c=s.name,l=a.name;r.fullname.eq&&r.fullname.eq.result&&ve(r.fullname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.fullname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Fullname does not match the expected fullname"),n=false,i.fullname={...i.fullname,eq:{expected:`${r.fullname.eq.expected}`,received:`${c??l}`,message:"Fullname does not match the expected fullname"}}),r.fullname.disclose&&ve(r.fullname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.fullname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Fullname does not match the disclosed fullname in query result"),n=false,i.fullname={...i.fullname,disclose:{expected:`${r.fullname.disclose.result}`,received:`${c??l}`,message:"Fullname does not match the disclosed fullname in query result"}}),r.fullname.eq&&(e.fullname?.eq===void 0||ve(r.fullname.eq.expected).toLowerCase()!==ve(e.fullname.eq).toLowerCase())&&(console.warn("Fullname eq does not match the original query"),n=false,i.fullname={...i.fullname,eq:{expected:`${e.fullname?.eq}`,received:`${r.fullname.eq.expected}`,message:"Fullname eq does not match the original query"}}),r.fullname.disclose&&!e.fullname?.disclose&&(console.warn("Fullname disclose is not in the original query"),n=false,i.fullname={...i.fullname,disclose:{expected:"Not requested in original query",received:`${r.fullname.disclose.result}`,message:"Fullname disclose is not in the original query"}});}if(r.firstname){let c=s.firstName&&s.firstName.length>0?s.firstName:s.name,l=a.firstName&&a.firstName.length>0?a.firstName:a.name;r.firstname.eq&&r.firstname.eq.result&&ve(r.firstname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.firstname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Firstname does not match the expected firstname"),n=false,i.firstname={...i.firstname,eq:{expected:`${r.firstname.eq.expected}`,received:`${c??l}`,message:"Firstname does not match the expected firstname"}}),r.firstname.disclose&&ve(r.firstname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.firstname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Firstname does not match the disclosed firstname in query result"),n=false,i.firstname={...i.firstname,disclose:{expected:`${r.firstname.disclose.result}`,received:`${c??l}`,message:"Firstname does not match the disclosed firstname in query result"}}),r.firstname.eq&&(e.firstname?.eq===void 0||ve(r.firstname.eq.expected).toLowerCase()!==ve(e.firstname.eq).toLowerCase())&&(console.warn("Firstname eq does not match the original query"),n=false,i.firstname={...i.firstname,eq:{expected:`${e.firstname?.eq}`,received:`${r.firstname.eq.expected}`,message:"Firstname eq does not match the original query"}}),r.firstname.disclose&&!e.firstname?.disclose&&(console.warn("Firstname disclose is not in the original query"),n=false,i.firstname={...i.firstname,disclose:{expected:"Not requested in original query",received:`${r.firstname.disclose.result}`,message:"Firstname disclose is not in the original query"}});}if(r.lastname){let c=s.lastName&&s.lastName.length>0?s.lastName:s.name,l=a.lastName&&a.lastName.length>0?a.lastName:a.name;r.lastname.eq&&r.lastname.eq.result&&ve(r.lastname.eq.expected).toLowerCase()!==c.toLowerCase()&&ve(r.lastname.eq.expected).toLowerCase()!==l.toLowerCase()&&(console.warn("Lastname does not match the expected lastname"),n=false,i.lastname={...i.lastname,eq:{expected:`${r.lastname.eq.expected}`,received:`${c??l}`,message:"Lastname does not match the expected lastname"}}),r.lastname.disclose&&ve(r.lastname.disclose.result).toLowerCase()!==c.toLowerCase()&&ve(r.lastname.disclose.result).toLowerCase()!==l.toLowerCase()&&(console.warn("Lastname does not match the disclosed lastname in query result"),n=false,i.lastname={...i.lastname,disclose:{expected:`${r.lastname.disclose.result}`,received:`${c??l}`,message:"Lastname does not match the disclosed lastname in query result"}}),r.lastname.eq&&(e.lastname?.eq===void 0||ve(r.lastname.eq.expected).toLowerCase()!==ve(e.lastname.eq).toLowerCase())&&(console.warn("Lastname eq does not match the original query"),n=false,i.lastname={...i.lastname,eq:{expected:`${e.lastname?.eq}`,received:`${r.lastname.eq.expected}`,message:"Lastname eq does not match the original query"}}),r.lastname.disclose&&!e.lastname?.disclose&&(console.warn("Lastname disclose is not in the original query"),n=false,i.lastname={...i.lastname,disclose:{expected:"Not requested in original query",received:`${r.lastname.disclose.result}`,message:"Lastname disclose is not in the original query"}});}return {isCorrect:n,queryResultErrors:i}}static checkAgePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0,0);let s=Pb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm),a=Nb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm);return r.age?(r.age.gte&&r.age.gte.result&&s!==r.age.gte.expected&&(console.warn("Age is not greater than or equal to the expected age"),n=false,i.age={...i.age,gte:{expected:r.age.gte.expected,received:s,message:"Age is not greater than or equal to the expected age"}}),r.age.gt&&r.age.gt.result&&s!==r.age.gt.expected+1&&(console.warn("Age is not greater than the expected age"),n=false,i.age={...i.age,gt:{expected:r.age.gt.expected,received:s,message:"Age is not greater than the expected age"}}),r.age.lt&&r.age.lt.result&&a!==r.age.lt.expected-1&&(console.warn("Age is not less than the expected age"),n=false,i.age={...i.age,lt:{expected:r.age.lt.expected,received:a,message:"Age is not less than the expected age"}}),r.age.lte&&r.age.lte.result&&a!==r.age.lte.expected&&(console.warn("Age is not less than or equal to the expected age"),n=false,i.age={...i.age,lte:{expected:r.age.lte.expected,received:a,message:"Age is not less than or equal to the expected age"}}),r.age.eq&&r.age.eq.result&&(s!==r.age.eq.expected||a!==r.age.eq.expected)&&(console.warn("Age does not match the expected age"),n=false,i.age={...i.age,eq:{expected:r.age.eq.expected,received:s!==r.age.eq.expected?s:a,message:"Age does not match the expected age"}}),r.age.range&&r.age.range.result&&(s!==r.age.range.expected[0]||a!==r.age.range.expected[1])&&(console.warn("Age is not in the expected range"),n=false,i.age={...i.age,range:{expected:r.age.range.expected,received:[s,a],message:"Age is not in the expected range"}}),!r.age.lt&&!r.age.lte&&!r.age.eq&&!r.age.range&&a!=0&&(console.warn("Maximum age should be equal to 0"),n=false,i.age={...i.age,disclose:{expected:0,received:a,message:"Maximum age should be equal to 0"}}),!r.age.gte&&!r.age.gt&&!r.age.eq&&!r.age.range&&s!=0&&(console.warn("Minimum age should be equal to 0"),n=false,i.age={...i.age,disclose:{expected:0,received:s,message:"Minimum age should be equal to 0"}}),r.age.disclose&&(r.age.disclose.result!==s||r.age.disclose.result!==a)&&(console.warn("Age does not match the disclosed age in query result"),n=false,i.age={...i.age,disclose:{expected:`${s}`,received:`${r.age.disclose.result}`,message:"Age does not match the disclosed age in query result"}})):(console.warn("Age is not set in the query result"),n=false,i.age={...i.age,disclose:{message:"Age is not set in the query result"}}),r.age?.gte&&(e.age?.gte===void 0||r.age.gte.expected!==e.age.gte)&&(console.warn("Age gte does not match the original query"),n=false,i.age={...i.age,gte:{expected:e.age?.gte,received:r.age.gte.expected,message:"Age gte does not match the original query"}}),r.age?.gt&&(e.age?.gt===void 0||r.age.gt.expected!==e.age.gt)&&(console.warn("Age gt does not match the original query"),n=false,i.age={...i.age,gt:{expected:e.age?.gt,received:r.age.gt.expected,message:"Age gt does not match the original query"}}),r.age?.lt&&(e.age?.lt===void 0||r.age.lt.expected!==e.age.lt)&&(console.warn("Age lt does not match the original query"),n=false,i.age={...i.age,lt:{expected:e.age?.lt,received:r.age.lt.expected,message:"Age lt does not match the original query"}}),r.age?.lte&&(e.age?.lte===void 0||r.age.lte.expected!==e.age.lte)&&(console.warn("Age lte does not match the original query"),n=false,i.age={...i.age,lte:{expected:e.age?.lte,received:r.age.lte.expected,message:"Age lte does not match the original query"}}),r.age?.eq&&(e.age?.eq===void 0||r.age.eq.expected!==e.age.eq)&&(console.warn("Age eq does not match the original query"),n=false,i.age={...i.age,eq:{expected:e.age?.eq,received:r.age.eq.expected,message:"Age eq does not match the original query"}}),r.age?.range&&(e.age?.range===void 0||r.age.range.expected[0]!==e.age.range[0]||r.age.range.expected[1]!==e.age.range[1])&&(console.warn("Age range does not match the original query"),n=false,i.age={...i.age,range:{expected:e.age?.range,received:r.age.range.expected,message:"Age range does not match the original query"}}),r.age?.disclose&&!e.age?.disclose&&(console.warn("Age disclose is not in the original query"),n=false,i.age={...i.age,disclose:{expected:"Not requested in original query",received:`${r.age.disclose.result}`,message:"Age disclose is not in the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkBirthdatePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0);let s=Db(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Fo),a=Ob(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Fo);if(r.birthdate){if(r.birthdate.gte&&r.birthdate.gte.result&&!me(s,r.birthdate.gte.expected)&&(console.warn("Birthdate is not greater than or equal to the expected birthdate"),n=false,i.birthdate={...i.birthdate,gte:{expected:r.birthdate.gte.expected,received:s,message:"Birthdate is not greater than or equal to the expected birthdate"}}),r.birthdate.gt&&r.birthdate.gt.result){let c=new Date(r.birthdate.gt.expected);c.setDate(c.getDate()+1),me(s,c)||(console.warn("Birthdate is not greater than the expected birthdate"),n=false,i.birthdate={...i.birthdate,gt:{expected:r.birthdate.gt.expected,received:s,message:"Birthdate is not greater than the expected birthdate"}});}if(r.birthdate.lte&&r.birthdate.lte.result&&!me(a,r.birthdate.lte.expected)&&(console.warn("Birthdate is not less than the expected birthdate"),n=false,i.birthdate={...i.birthdate,lte:{expected:r.birthdate.lte.expected,received:a,message:"Birthdate is not less than the expected birthdate"}}),r.birthdate.lt&&r.birthdate.lt.result){let c=new Date(r.birthdate.lt.expected);c.setDate(c.getDate()-1),me(a,c)||(console.warn("Birthdate is not less than the expected birthdate"),n=false,i.birthdate={...i.birthdate,lt:{expected:r.birthdate.lt.expected,received:a,message:"Birthdate is not less than the expected birthdate"}});}r.birthdate.range&&r.birthdate.range.result&&(!me(s,r.birthdate.range.expected[0])||!me(a,r.birthdate.range.expected[1]))&&(console.warn("Birthdate is not in the expected range"),n=false,i.birthdate={...i.birthdate,range:{expected:r.birthdate.range.expected,received:[s,a],message:"Birthdate is not in the expected range"}}),!r.birthdate.lte&&!r.birthdate.lt&&!r.birthdate.eq&&!r.birthdate.range&&!me(a,Fn)&&(console.warn("Maximum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Fn.toISOString()}`,received:`${a.toISOString()}`,message:"Maximum birthdate should be equal to default date value"}}),!r.birthdate.gte&&!r.birthdate.gt&&!r.birthdate.eq&&!r.birthdate.range&&!me(s,Fn)&&(console.warn("Minimum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Fn.toISOString()}`,received:`${s.toISOString()}`,message:"Minimum birthdate should be equal to default date value"}});}else console.warn("Birthdate is not set in the query result"),n=false,i.birthdate={...i.birthdate,disclose:{message:"Birthdate is not set in the query result"}};return r.birthdate?.gte&&(e.birthdate?.gte===void 0||!me(r.birthdate.gte.expected,e.birthdate.gte))&&(console.warn("Birthdate gte does not match the original query"),n=false,i.birthdate={...i.birthdate,gte:{expected:e.birthdate?.gte,received:r.birthdate.gte.expected,message:"Birthdate gte does not match the original query"}}),r.birthdate?.gt&&(e.birthdate?.gt===void 0||!me(r.birthdate.gt.expected,e.birthdate.gt))&&(console.warn("Birthdate gt does not match the original query"),n=false,i.birthdate={...i.birthdate,gt:{expected:e.birthdate?.gt,received:r.birthdate.gt.expected,message:"Birthdate gt does not match the original query"}}),r.birthdate?.lte&&(e.birthdate?.lte===void 0||!me(r.birthdate.lte.expected,e.birthdate.lte))&&(console.warn("Birthdate lte does not match the original query"),n=false,i.birthdate={...i.birthdate,lte:{expected:e.birthdate?.lte,received:r.birthdate.lte.expected,message:"Birthdate lte does not match the original query"}}),r.birthdate?.lt&&(e.birthdate?.lt===void 0||!me(r.birthdate.lt.expected,e.birthdate.lt))&&(console.warn("Birthdate lt does not match the original query"),n=false,i.birthdate={...i.birthdate,lt:{expected:e.birthdate?.lt,received:r.birthdate.lt.expected,message:"Birthdate lt does not match the original query"}}),r.birthdate?.range&&(e.birthdate?.range===void 0||!me(r.birthdate.range.expected[0],e.birthdate.range[0])||!me(r.birthdate.range.expected[1],e.birthdate.range[1]))&&(console.warn("Birthdate range does not match the original query"),n=false,i.birthdate={...i.birthdate,range:{expected:e.birthdate?.range,received:r.birthdate.range.expected,message:"Birthdate range does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkExpiryDatePublicInputs(t,e,r){let i={},n=true,o=new Date;new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0);let s=zl(t.committedInputs?.compare_expiry??t.committedInputs?.compare_expiry_evm),a=ql(t.committedInputs?.compare_expiry??t.committedInputs?.compare_expiry_evm);return r.expiry_date?(r.expiry_date.gte&&r.expiry_date.gte.result&&!me(s,r.expiry_date.gte.expected)&&(console.warn("Expiry date is not greater than or equal to the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,gte:{expected:r.expiry_date.gte.expected,received:s,message:"Expiry date is not greater than or equal to the expected expiry date"}}),r.expiry_date.lte&&r.expiry_date.lte.result&&!me(a,r.expiry_date.lte.expected)&&(console.warn("Expiry date is not less than the expected expiry date"),n=false,i.expiry_date={...i.expiry_date,lte:{expected:r.expiry_date.lte.expected,received:a,message:"Expiry date is not less than the expected expiry date"}}),r.expiry_date.range&&r.expiry_date.range.result&&(!me(s,r.expiry_date.range.expected[0])||!me(a,r.expiry_date.range.expected[1]))&&(console.warn("Expiry date is not in the expected range"),n=false,i.expiry_date={...i.expiry_date,range:{expected:r.expiry_date.range.expected,received:[s,a],message:"Expiry date is not in the expected range"}}),!r.expiry_date.lte&&!r.expiry_date.lt&&!r.expiry_date.eq&&!r.expiry_date.range&&!me(a,Fn)&&(console.warn("Maximum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Fn.toISOString()}`,received:`${a.toISOString()}`,message:"Maximum expiry date should be equal to default date value"}}),!r.expiry_date.gte&&!r.expiry_date.gt&&!r.expiry_date.eq&&!r.expiry_date.range&&!me(s,Fn)&&(console.warn("Minimum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Fn.toISOString()}`,received:`${s.toISOString()}`,message:"Minimum expiry date should be equal to default date value"}})):(console.warn("Expiry date is not set in the query result"),n=false,i.expiry_date={...i.expiry_date,disclose:{message:"Expiry date is not set in the query result"}}),r.expiry_date?.gte&&(e.expiry_date?.gte===void 0||!me(r.expiry_date.gte.expected,e.expiry_date.gte))&&(console.warn("Expiry date gte does not match the original query"),n=false,i.expiry_date={...i.expiry_date,gte:{expected:e.expiry_date?.gte,received:r.expiry_date.gte.expected,message:"Expiry date gte does not match the original query"}}),r.expiry_date?.gt&&(e.expiry_date?.gt===void 0||!me(r.expiry_date.gt.expected,e.expiry_date.gt))&&(console.warn("Expiry date gt does not match the original query"),n=false,i.expiry_date={...i.expiry_date,gt:{expected:e.expiry_date?.gt,received:r.expiry_date.gt.expected,message:"Expiry date gt does not match the original query"}}),r.expiry_date?.lte&&(e.expiry_date?.lte===void 0||!me(r.expiry_date.lte.expected,e.expiry_date.lte))&&(console.warn("Expiry date lte does not match the original query"),n=false,i.expiry_date={...i.expiry_date,lte:{expected:e.expiry_date?.lte,received:r.expiry_date.lte.expected,message:"Expiry date lte does not match the original query"}}),r.expiry_date?.lt&&(e.expiry_date?.lt===void 0||!me(r.expiry_date.lt.expected,e.expiry_date.lt))&&(console.warn("Expiry date lt does not match the original query"),n=false,i.expiry_date={...i.expiry_date,lt:{expected:e.expiry_date?.lt,received:r.expiry_date.lt.expected,message:"Expiry date lt does not match the original query"}}),r.expiry_date?.range&&(e.expiry_date?.range===void 0||!me(r.expiry_date.range.expected[0],e.expiry_date.range[0])||!me(r.expiry_date.range.expected[1],e.expiry_date.range[1]))&&(console.warn("Expiry date range does not match the original query"),n=false,i.expiry_date={...i.expiry_date,range:{expected:e.expiry_date?.range,received:r.expiry_date.range.expected,message:"Expiry date range does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkNationalityExclusionPublicInputs(t,e,r){let i={},n=true;e.nationality&&e.nationality.out&&e.nationality.out.result?e.nationality.out.expected?.every(o=>r.includes(o))||(console.warn("Nationality exclusion list does not match the one from the query results"),n=false,i.nationality={...i.nationality,out:{expected:e.nationality.out.expected,received:r,message:"Nationality exclusion list does not match the one from the query results"}}):(!e.nationality||!e.nationality.out)&&(console.warn("Nationality exclusion is not set in the query result"),n=false,i.nationality={...i.nationality,out:{message:"Nationality exclusion is not set in the query result"}});for(let o=1;o<r.length;o++)r[o]<r[o-1]&&(console.warn("The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"),n=false,i.nationality={...i.nationality,out:{message:"The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"}});return e.nationality?.out&&(t.nationality?.out===void 0||e.nationality.out.expected?.length!==t.nationality.out.length||!e.nationality.out.expected?.every(o=>t.nationality.out.includes(o)))&&(console.warn("Nationality exclusion list does not match the original query"),n=false,i.nationality={...i.nationality,out:{expected:t.nationality?.out,received:e.nationality.out.expected,message:"Nationality exclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkIssuingCountryExclusionPublicInputs(t,e,r){let i={},n=true;e.issuing_country&&e.issuing_country.out&&e.issuing_country.out.result?e.issuing_country.out.expected?.every(o=>r.includes(o))||(console.warn("Issuing country exclusion list does not match the one from the query results"),n=false,i.issuing_country={...i.issuing_country,out:{expected:e.issuing_country.out.expected,received:r,message:"Issuing country exclusion list does not match the one from the query results"}}):(!e.issuing_country||!e.issuing_country.out)&&(console.warn("Issuing country exclusion is not set in the query result"),n=false,i.issuing_country={...i.issuing_country,out:{message:"Issuing country exclusion is not set in the query result"}});for(let o=1;o<r.length;o++)r[o]<r[o-1]&&(console.warn("The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"),n=false,i.issuing_country={...i.issuing_country,out:{message:"The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"}});return e.issuing_country?.out&&(t.issuing_country?.out===void 0||e.issuing_country.out.expected?.length!==t.issuing_country.out.length||!e.issuing_country.out.expected?.every(o=>t.issuing_country.out.includes(o)))&&(console.warn("Issuing country exclusion list does not match the original query"),n=false,i.issuing_country={...i.issuing_country,out:{expected:t.issuing_country?.out,received:e.issuing_country.out.expected,message:"Issuing country exclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkNationalityInclusionPublicInputs(t,e,r){let i={},n=true;return e.nationality&&e.nationality.in&&e.nationality.in.result?e.nationality.in.expected?.every(o=>r.includes(o))||(console.warn("Nationality inclusion list does not match the one from the query results"),n=false,i.nationality={...i.nationality,in:{expected:e.nationality.in.expected,received:r,message:"Nationality inclusion list does not match the one from the query results"}}):(!e.nationality||!e.nationality.in)&&(console.warn("Nationality inclusion is not set in the query result"),n=false,i.nationality={...i.nationality,in:{message:"Nationality inclusion is not set in the query result"}}),e.nationality?.in&&(t.nationality?.in===void 0||e.nationality.in.expected?.length!==t.nationality.in.length||!e.nationality.in.expected?.every(o=>t.nationality.in.includes(o)))&&(console.warn("Nationality inclusion list does not match the original query"),n=false,i.nationality={...i.nationality,in:{expected:t.nationality?.in,received:e.nationality.in.expected,message:"Nationality inclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkIssuingCountryInclusionPublicInputs(t,e,r){let i={},n=true;return e.issuing_country&&e.issuing_country.in&&e.issuing_country.in.result?e.issuing_country.in.expected?.every(o=>r.includes(o))||(console.warn("Issuing country inclusion list does not match the one from the query results"),n=false,i.issuing_country={...i.issuing_country,in:{expected:e.issuing_country.in.expected,received:r,message:"Issuing country inclusion list does not match the one from the query results"}}):(!e.issuing_country||!e.issuing_country.in)&&(console.warn("Issuing country inclusion is not set in the query result"),n=false,i.issuing_country={...i.issuing_country,in:{message:"Issuing country inclusion is not set in the query result"}}),e.issuing_country?.in&&(t.issuing_country?.in===void 0||e.issuing_country.in.expected?.length!==t.issuing_country.in.length||!e.issuing_country.in.expected?.every(o=>t.issuing_country.in.includes(o)))&&(console.warn("Issuing country inclusion list does not match the original query"),n=false,i.issuing_country={...i.issuing_country,in:{expected:t.issuing_country?.in,received:e.issuing_country.in.expected,message:"Issuing country inclusion list does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static checkScopeFromDisclosureProof(t,e,r,i,n){if(t==="*")return {isCorrect:true,queryResultErrors:r};let o=true;if(cc(t)!==eh(e)&&(console.warn("The proof comes from a different domain than the one expected"),o=false,r[i]||(r[i]={}),r[i].scope={expected:`Scope: ${cc(t).toString()}`,received:`Scope: ${eh(e).toString()}`,message:"The proof comes from a different domain than the one expected"}),na(n)!==Jp(e)){let s=n?"The proof uses a different scope than the one expected":"The proof uses a scope but none was passed to verify()";console.warn(s),o=false,r[i]||(r[i]={}),r[i].scope={expected:`Scope: ${na(n).toString()}`,received:`Scope: ${Jp(e).toString()}`,message:s};}return {isCorrect:o,queryResultErrors:r}}static async checkRegistryRoot(t,e,r,i,n,o){let s;try{s=await t(o??xh(Gp(r,!!e)));}catch(a){console.warn(a),s=false;}if(!s){console.warn(n.message);let{section:a,field:c,...l}=n;i[a]={...i[a],[c]:l};}return {isCorrect:s,queryResultErrors:i}}static async checkCertificateRegistryRoot(t,e,r,i,n,o={},s){return this.checkRegistryRoot(a=>a.isCertificateRootValid(t,n),i,o,e,{section:r?"outer":"sig_check_dsc",field:"certificate",expected:"A valid root from ZKPassport Registry",received:`Got invalid certificate registry root: ${t}`,message:"The ID was signed by an unrecognized root certificate"},s)}static async checkCircuitRegistryRoot(t,e,r,i,n={},o){return this.checkRegistryRoot(s=>s.isCircuitRootValid(t,i),r,n,e,{section:"outer",field:"circuit",expected:"A valid circuit from ZKPassport Registry",received:`Got invalid circuit registry root: ${t}`,message:"The proof uses an unrecognized circuit"},o)}static async checkSanctionsRegistryRoot(t,e,r,i,n={},o){return this.checkRegistryRoot(s=>s.isSanctionsRootValid(t,i),r,n,e,{section:"sanctions",field:"eq",expected:"A valid root from ZKPassport Registry",received:`Got invalid sanctions registry root: ${t}`,message:"Invalid sanctions registry root"},o)}static checkBindPublicInputs(t,e,r){let i={},n=true;if(e.bind){let o=[];e.bind.user_address?.toLowerCase().replace("0x","")!==r.user_address?.toLowerCase().replace("0x","")&&(console.warn("Bound user address does not match the one from the query results"),n=false,o.push(`user_address: expected ${e.bind.user_address}, received ${r.user_address}`)),e.bind.chain!==r.chain&&(console.warn("Bound chain id does not match the one from the query results"),n=false,o.push(`chain: expected ${e.bind.chain}, received ${r.chain}`)),e.bind.custom_data?.trim().toLowerCase()!==r.custom_data?.trim().toLowerCase()&&(console.warn("Bound custom data does not match the one from the query results"),n=false,o.push(`custom_data: expected ${e.bind.custom_data}, received ${r.custom_data}`)),o.length>0&&(i.bind={...i.bind,eq:{expected:`${e.bind.user_address}, ${e.bind.chain}, ${e.bind.custom_data}`,received:`${r.user_address}, ${r.chain}, ${r.custom_data}`,message:`Bound data does not match: ${o.join("; ")}`}});}return (t.bind===void 0||r.user_address?.toLowerCase().replace("0x","")!==t.bind.user_address?.toLowerCase().replace("0x","")||r.chain!==t.bind.chain||r.custom_data?.trim().toLowerCase()!==t.bind.custom_data?.trim().toLowerCase())&&(console.warn("Bound data does not match the original query"),n=false,i.bind={...i.bind,eq:{expected:`${t.bind?.user_address}, ${t.bind?.chain}, ${t.bind?.custom_data}`,received:`${r.user_address}, ${r.chain}, ${r.custom_data}`,message:"Bound data does not match the original query"}}),{isCorrect:n,queryResultErrors:i}}static async checkSanctionsExclusionPublicInputs(t,e,r,i,n,o){let s={},a=true;if(r.isStrict!==(t.sanctions?.strict??false)&&(console.warn("Sanctions strict mode does not match the original query"),a=false,s.sanctions={...s.sanctions,eq:{expected:`strict: ${t.sanctions?.strict??false}`,received:`strict: ${r.isStrict}`,message:"Sanctions strict mode does not match the original query"}}),e.sanctions&&e.sanctions.passed){let{isCorrect:c}=await this.checkSanctionsRegistryRoot(r.rootHash,s,i,n,t,o);a=a&&c,e.sanctions.isStrict!==r.isStrict&&(console.warn("Invalid sanctions strict mode"),a=false,s.sanctions={...s.sanctions,eq:{expected:e.sanctions.isStrict.toString(),received:r.isStrict.toString(),message:"Invalid sanctions strict mode"}});}return e.sanctions&&(t.sanctions===void 0||e.sanctions.isStrict!==(t.sanctions.strict??false))&&(console.warn("Sanctions config does not match the original query"),a=false,s.sanctions={...s.sanctions,eq:{expected:`strict: ${t.sanctions?.strict??false}`,received:`strict: ${e.sanctions.isStrict}`,message:"Sanctions config does not match the original query"}}),{isCorrect:a,queryResultErrors:s}}static async checkFacematchPublicInputs(t,e,r){let i=true,n={};r.rootKeyLeaf!==iS&&r.rootKeyLeaf!==nS&&r.rootKeyLeaf!==oS&&(console.warn("Invalid facematch root key hash"),i=false,n.facematch={...n.facematch,eq:{expected:`${iS} (iOS) or ${nS} (Android) or ${oS} (Android)`,received:r.rootKeyLeaf,message:"Invalid facematch root key hash"}});let o="production";return r.environment!==o&&(console.warn("Invalid facematch environment, it should be production"),i=false,n.facematch={...n.facematch,eq:{expected:o,received:r.environment,message:"Invalid facematch environment, it should be production"}}),r.appIdHash!==tS&&r.appIdHash!==rS&&(console.warn("Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"),i=false,n.facematch={...n.facematch,eq:{expected:`${tS} (iOS) or ${rS} (Android)`,received:r.appIdHash,message:"Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"}}),(e.facematch&&r.mode!==e.facematch.mode||r.mode!==t.facematch?.mode)&&(console.warn("Invalid facematch mode"),i=false,n.facematch={...n.facematch,eq:{expected:t.facematch?.mode,received:r.mode,message:"Invalid facematch mode"}}),{isCorrect:i,queryResultErrors:n}}static async checkCurrentDate(t,e,r,i){let n=new Date,o=new Date(n.getFullYear(),n.getMonth(),n.getDate(),0,0,0,0),s=th(e),a=o.getTime()-s.getTime(),c=r?r*1e3:gt*1e3,l=true;return a>=c&&(console.warn("The date used to check the validity of the ID falls out of the validity period"),l=false,i[t]||(i[t]={}),i[t].date={expected:`Difference: ${r} seconds`,received:`Difference: ${Math.round(a/1e3)} seconds`,message:"The date used to check the validity of the ID falls out of the validity period"}),s.getTime()-o.getTime()>sS&&(console.warn("The date used to check the validity of the ID is in the future"),l=false,i[t]||(i[t]={}),i[t].date={expected:`Difference: ${r} seconds`,received:`Difference: ${Math.round(a/1e3)} seconds`,message:"The date used to check the validity of the ID is in the future"}),{isCorrect:l,queryResultErrors:i}}static checkQueryCompleteness(t,e){let r=true,i={},n=(...m)=>m.some(b=>e.has(b)),o=(m,b)=>{r=false,i[m]={...i[m],commitment:{expected:"A proof covering the requested condition",received:"No matching proof was provided",message:b}};},s=n("disclose_bytes","disclose_bytes_evm"),a=m=>!!m&&(m.gte!==void 0||m.gt!==void 0||m.lte!==void 0||m.lt!==void 0||m.range!==void 0),c=m=>!!m&&(m.eq!==void 0||m.disclose===true),l=t.age;(a(l)||l?.eq!==void 0)&&!n("compare_age","compare_age_evm")&&o("age","The proof does not verify the requested age condition"),a(t.birthdate)&&!n("compare_birthdate","compare_birthdate_evm")&&o("birthdate","The proof does not verify the requested birthdate condition"),c(t.birthdate)&&!s&&o("birthdate","The proof does not disclose the requested birthdate"),a(t.expiry_date)&&!n("compare_expiry","compare_expiry_evm")&&o("expiry_date","The proof does not verify the requested expiry date condition"),c(t.expiry_date)&&!s&&o("expiry_date","The proof does not disclose the requested expiry date");let d=t.nationality;d?.in!==void 0&&!n("inclusion_check_nationality","inclusion_check_nationality_evm")&&o("nationality","The proof does not verify the requested nationality inclusion"),d?.out!==void 0&&!n("exclusion_check_nationality","exclusion_check_nationality_evm")&&o("nationality","The proof does not verify the requested nationality exclusion"),c(d)&&!s&&o("nationality","The proof does not disclose the requested nationality");let u=t.issuing_country;u?.in!==void 0&&!n("inclusion_check_issuing_country","inclusion_check_issuing_country_evm")&&o("issuing_country","The proof does not verify the requested issuing country inclusion"),u?.out!==void 0&&!n("exclusion_check_issuing_country","exclusion_check_issuing_country_evm")&&o("issuing_country","The proof does not verify the requested issuing country exclusion"),c(u)&&!s&&o("issuing_country","The proof does not disclose the requested issuing country");let h=["firstname","lastname","fullname","document_number","document_type","gender"];for(let m of h)c(t[m])&&!s&&o(m,`The proof does not disclose the requested ${m}`);return t.bind&&!n("bind","bind_evm")&&o("bind","The proof does not verify the requested bound data"),t.sanctions&&!n("exclusion_check_sanctions","exclusion_check_sanctions_evm")&&o("sanctions","The proof does not verify the requested sanctions exclusion"),t.facematch&&!n("facematch","facematch_evm")&&o("facematch","The proof does not verify the requested FaceMatch"),r||console.warn("The proof does not verify all the requested conditions and information"),{isCorrect:r,queryResultErrors:i}}static async checkPublicInputs(t,e,r,i,n,o,s,a,c){let l,d,u=true,h,m,b,A=new Date,x=new Date(A.getFullYear(),A.getMonth(),A.getDate(),0,0,0,0),y={},w=["sig_check_dsc","sig_check_id_data","data_check_integrity","disclose_bytes","compare_age","compare_birthdate","compare_expiry","exclusion_check_nationality","inclusion_check_nationality","exclusion_check_issuing_country","inclusion_check_issuing_country","bind","exclusion_check_sanctions","facematch"],I=e.sort((k,E)=>{let q=O=>{let z=O.name||"";return w.findIndex(W=>z.startsWith(W))};return q(k)-q(E)}),_=w.slice(3),C=I.find(k=>_.some(E=>k.name?.startsWith(E))),v=C?th(oa(C.proof,ia(C.name))):void 0,T=v?Math.floor(v.getTime()/1e3):void 0;for(let k of I){let E=oa(k.proof,ia(k.name));if(k.name?.startsWith("outer")){let q=k.name?.startsWith("outer_evm"),O=t6(E),z=Math.floor(O.getTime()/1e3),W=Jb(E),{isCorrect:Y,queryResultErrors:oe}=await this.checkCertificateRegistryRoot(W.toString(16),y,true,a,z,r,c);u=u&&Y,y={...y,...oe};let te=e6(E),{isCorrect:$,queryResultErrors:R}=await this.checkCircuitRegistryRoot(te.toString(16),y,a,z,r,c);u=u&&$,y={...y,...R};let M=x.getTime()-O.getTime(),V=n?n*1e3:gt*1e3;M>=V&&(console.warn("The date used to check the validity of the ID is older than the validity period"),u=false,y.outer={...y.outer,date:{expected:`Difference: ${n} seconds`,received:`Difference: ${Math.round(M/1e3)} seconds`,message:"The date used to check the validity of the ID is older than the validity period"}}),O.getTime()-x.getTime()>sS&&(console.warn("The date used to check the validity of the ID is in the future"),u=false,y.outer={...y.outer,date:{expected:`Difference: ${n} seconds`,received:`Difference: ${Math.round(M/1e3)} seconds`,message:"The date used to check the validity of the ID is in the future"}});let K=oh(E),L=k.committedInputs,re=Object.keys(L||{});if(re.length!==K.length&&(console.warn("The proof does not verify all the requested conditions and information"),u=false,y.outer={...y.outer,commitment:{expected:`Number of parameter commitments: ${K.length}`,received:`Number of disclosure proofs provided: ${re.length}`,message:"The proof does not verify all the requested conditions and information"}}),cc(t)!==ih(E)&&(console.warn("The proof comes from a different domain than the one expected"),u=false,y.outer={...y.outer,scope:{expected:`Scope: ${cc(t).toString()}`,received:`Scope: ${ih(E).toString()}`,message:"The proof comes from a different domain than the one expected"}}),na(o)!==nh(E)){let D=o?"The proof uses a different scope than the one expected":"The proof uses a scope but none was passed to verify()";console.warn(D),u=false,y.outer={...y.outer,scope:{expected:`Scope: ${na(o).toString()}`,received:`Scope: ${nh(E).toString()}`,message:D}};}if(L?.compare_age||L?.compare_age_evm){let D=L?.compare_age??L?.compare_age_evm,X=q?await Rb(D.minAge,D.maxAge):await Wp(D.minAge,D.maxAge);K.includes(X)||(console.warn("This proof does not verify the age"),u=false,y.age={...y.age,commitment:{expected:`Age parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the age"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkAgePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.compare_birthdate||L?.compare_birthdate_evm){let D=L?.compare_birthdate??L?.compare_birthdate_evm,X=q?await Zp(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0):await sc(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0);K.includes(X)||(console.warn("This proof does not verify the birthdate"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Birthdate parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the birthdate"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkBirthdatePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.compare_expiry||L?.compare_expiry_evm){let D=L?.compare_expiry??L?.compare_expiry_evm,X=q?await Zp(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp):await sc(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp);K.includes(X)||(console.warn("This proof does not verify the expiry date"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Expiry date parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the expiry date"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.disclose_bytes||L?.disclose_bytes_evm){let D=L?.disclose_bytes??L?.disclose_bytes_evm,X=q?await kb(D.discloseMask,D.disclosedBytes):await Xp(D.discloseMask,D.disclosedBytes);K.includes(X)||(console.warn("This proof does not verify any of the data disclosed"),u=false,y.disclose={...y.disclose,commitment:{expected:`Disclosure parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify any of the data disclosed"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Q,y={...y,...ne};}if(L?.inclusion_check_nationality||L?.inclusion_check_nationality_evm){let D=L?.inclusion_check_nationality??L?.inclusion_check_nationality_evm,X=q?await oc(fe.NATIONALITY_INCLUSION,D.countries):await Mi(fe.NATIONALITY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the nationality"),u=false,y.nationality={...y.nationality,commitment:{expected:`Nationality parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the inclusion of the nationality"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkNationalityInclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.inclusion_check_issuing_country||L?.inclusion_check_issuing_country_evm){let D=L?.inclusion_check_issuing_country??L?.inclusion_check_issuing_country_evm,X=q?await oc(fe.ISSUING_COUNTRY_INCLUSION,D.countries):await Mi(fe.ISSUING_COUNTRY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the issuing country"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Issuing country parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the inclusion of the issuing country"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkIssuingCountryInclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.exclusion_check_nationality||L?.exclusion_check_nationality_evm){let D=L?.exclusion_check_nationality??L?.exclusion_check_nationality_evm,X=q?await oc(fe.NATIONALITY_EXCLUSION,D.countries):await Mi(fe.NATIONALITY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the nationality"),u=false,y.nationality={...y.nationality,commitment:{expected:`Nationality parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion of the nationality"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkNationalityExclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.exclusion_check_issuing_country||L?.exclusion_check_issuing_country_evm){let D=L?.exclusion_check_issuing_country??L?.exclusion_check_issuing_country_evm,X=q?await oc(fe.ISSUING_COUNTRY_EXCLUSION,D.countries):await Mi(fe.ISSUING_COUNTRY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the issuing country"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Issuing country parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion of the issuing country"}});let Q=D.countries,{isCorrect:ne,queryResultErrors:le}=this.checkIssuingCountryExclusionPublicInputs(r,i,Q);u=u&&ne,y={...y,...le};}if(L?.bind||L?.bind_evm){let D=L?.bind??L?.bind_evm,X=q?await Fb(ac(D.data)):await Yp(ac(D.data));K.includes(X)||(console.warn("This proof does not verify the bound data"),u=false,y.bind={...y.bind,commitment:{expected:`Bind parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the bound data"}});let{isCorrect:Q,queryResultErrors:ne}=this.checkBindPublicInputs(r,i,D.data);u=u&&Q,y={...y,...ne};}if(L?.exclusion_check_sanctions||L?.exclusion_check_sanctions_evm){let D=L?.exclusion_check_sanctions??L?.exclusion_check_sanctions_evm,X=q?await Qb(D.rootHash,D.isStrict):await rh(D.rootHash,D.isStrict);K.includes(X)||(console.warn("This proof does not verify the exclusion from the sanction lists"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Sanctions parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify the exclusion from the sanction lists"}});let{isCorrect:Q,queryResultErrors:ne}=await this.checkSanctionsExclusionPublicInputs(r,i,D,a,z,c);u=u&&Q,y={...y,...ne};}if(L?.facematch||L?.facematch_evm){let D=L?.facematch??L?.facematch_evm,X=q?await Kb(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n):await Qp(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n);K.includes(X)||(console.warn("This proof does not verify FaceMatch"),u=false,y.facematch={...y.facematch,commitment:{expected:`Facematch parameter commitment: ${X.toString()}`,received:`Parameter commitments included: ${K.join(", ")}`,message:"This proof does not verify FaceMatch"}});let{isCorrect:Q,queryResultErrors:ne}=await this.checkFacematchPublicInputs(r,i,D);u=u&&Q,y={...y,...ne};}h=i6(E).toString(10),m=r6(E),b=n6(E);}else if(k.name?.startsWith("sig_check_dsc")){d=Eb(E);let q=vb(E),{isCorrect:O,queryResultErrors:z}=await this.checkCertificateRegistryRoot(q.toString(16),y,false,a,T,r,c);u=u&&O,y={...y,...z};}else if(k.name?.startsWith("sig_check_id_data"))l=Mb(E),l!==d&&(console.warn("Failed to check the link between the certificate signature and ID signature"),u=false,y.sig_check_id_data={...y.sig_check_id_data,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the certificate signature and ID signature"}}),d=Ub(E);else if(k.name?.startsWith("data_check_integrity"))l=Bb(E),l!==d&&(console.warn("Failed to check the link between the ID signature and the data signed"),u=false,y.data_check_integrity={...y.data_check_integrity,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the ID signature and the data signed"}}),d=Tb(E);else if(k.name==="disclose_bytes"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the data to disclose"),u=false,y.disclose={...y.disclose,commitment:{expected:`Commitment: ${d?.toString()||"undefined"}`,received:`Commitment: ${l?.toString()||"undefined"}`,message:"Failed to check the link between the validity of the ID and the data to disclose"}});let q=pr(E),O=await Xp((k.committedInputs?.disclose_bytes).discloseMask,(k.committedInputs?.disclose_bytes).disclosedBytes);q!==O&&(console.warn("The disclosed data does not match the data committed by the proof"),u=false,y.disclose={...y.disclose,commitment:{expected:`Commitment: ${O}`,received:`Commitment: ${q}`,message:"The disclosed data does not match the data committed by the proof"}});let{isCorrect:z,queryResultErrors:W}=this.checkScopeFromDisclosureProof(t,E,y,"disclose",o);u=u&&z,y={...y,...W};let{isCorrect:Y,queryResultErrors:oe}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Y&&z,y={...y,...oe,...W};let{isCorrect:te,queryResultErrors:$}=await this.checkCurrentDate("disclose",E,n??gt,y);u=u&&te,y={...y,...$},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_age"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the age derived from it"),u=false,y.age={...y.age,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the age derived from it"}});let q=pr(E),O=k.committedInputs?.compare_age,z=await Wp(O.minAge,O.maxAge);q!==z&&(console.warn("The conditions for the age check do not match the conditions checked by the proof"),u=false,y.age={...y.age,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the age check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"age",o),{isCorrect:oe,queryResultErrors:te}=this.checkAgePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("age",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_birthdate"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the birthdate derived from it"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the birthdate derived from it"}});let q=pr(E),O=k.committedInputs?.compare_birthdate,z=await sc(fe.BIRTHDATE,O.minDateTimestamp,O.maxDateTimestamp,0);q!==z&&(console.warn("The conditions for the birthdate check do not match the conditions checked by the proof"),u=false,y.birthdate={...y.birthdate,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the birthdate check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"birthdate",o),{isCorrect:oe,queryResultErrors:te}=this.checkBirthdatePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("birthdate",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="compare_expiry"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and its expiry date"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and its expiry date"}});let q=pr(E),O=k.committedInputs?.compare_expiry,z=await sc(fe.EXPIRY_DATE,O.minDateTimestamp,O.maxDateTimestamp);q!==z&&(console.warn("The conditions for the expiry date check do not match the conditions checked by the proof"),u=false,y.expiry_date={...y.expiry_date,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${q}`,message:"The conditions for the expiry date check do not match the conditions checked by the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"expiry_date",o),{isCorrect:oe,queryResultErrors:te}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("expiry_date",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_nationality"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the nationality exclusion check"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the nationality exclusion check"}});let q=(k.committedInputs?.exclusion_check_nationality).countries,O=pr(E),z=await Mi(fe.NATIONALITY_EXCLUSION,q,true);O!==z&&(console.warn("The committed country list for the exclusion check does not match the one from the proof"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the exclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityExclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_issuing_country"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the issuing country exclusion check"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the issuing country exclusion check"}});let q=(k.committedInputs?.exclusion_check_issuing_country).countries,O=pr(E),z=await Mi(fe.ISSUING_COUNTRY_EXCLUSION,q,true);O!==z&&(console.warn("The committed country list for the issuing country exclusion check does not match the one from the proof"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the issuing country exclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryExclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="inclusion_check_nationality"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the nationality inclusion check"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the nationality inclusion check"}});let q=(k.committedInputs?.inclusion_check_nationality).countries,O=pr(E),z=await Mi(fe.NATIONALITY_INCLUSION,q,false);O!==z&&(console.warn("The committed country list for the nationality inclusion check does not match the one from the proof"),u=false,y.nationality={...y.nationality,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the nationality inclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityInclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="inclusion_check_issuing_country"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the issuing country inclusion check"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the issuing country inclusion check"}});let q=(k.committedInputs?.inclusion_check_issuing_country).countries,O=pr(E),z=await Mi(fe.ISSUING_COUNTRY_INCLUSION,q,false);O!==z&&(console.warn("The committed country list for the issuing country inclusion check does not match the one from the proof"),u=false,y.issuing_country={...y.issuing_country,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The committed country list for the issuing country inclusion check does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryInclusionPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="bind"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the bound data"),u=false,y.bind={...y.bind,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the bound data"}});let q=k.committedInputs?.bind,O=pr(E),z=await Yp(ac(q.data));O!==z&&(console.warn("The bound data does not match the one from the proof"),u=false,y.bind={...y.bind,commitment:{expected:`Commitment: ${z}`,received:`Commitment: ${O}`,message:"The bound data does not match the one from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"bind",o),{isCorrect:oe,queryResultErrors:te}=this.checkBindPublicInputs(r,i,q.data);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("bind",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name==="exclusion_check_sanctions"){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the sanctions exclusion check"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the sanctions exclusion check"}});let q=k.committedInputs?.exclusion_check_sanctions,O=await rh(q.rootHash,q.isStrict),z=pr(E);z!==O&&(console.warn("The sanction lists check against do not match the sanction lists from the proof"),u=false,y.sanctions={...y.sanctions,commitment:{expected:`Commitment: ${O.toString()}`,received:`Commitment: ${z.toString()}`,message:"The sanction lists check against do not match the sanction lists from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"sanctions",o),{isCorrect:oe,queryResultErrors:te}=await this.checkSanctionsExclusionPublicInputs(r,i,q,a,T,c);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("sanctions",E,n??gt,y);u=u&&$,y={...y,...R},h=Nr(E).toString(10),m=Rr(E);}else if(k.name?.startsWith("facematch")&&!k.name?.endsWith("_evm")){l=hr(E),l!==d&&(console.warn("Failed to check the link between the validity of the ID and the facematch check"),u=false,y.facematch={...y.facematch,commitment:{expected:`Commitment: ${d}`,received:`Commitment: ${l}`,message:"Failed to check the link between the validity of the ID and the facematch check"}});let q=k.committedInputs?.facematch,O=pr(E),z=await Qp(BigInt(q.rootKeyLeaf),q.environment==="development"?0n:1n,BigInt(q.appIdHash),q.mode==="regular"?1n:2n);O!==z&&(console.warn("The FaceMatch verification does not match the ones from the proof"),u=false,y.facematch={...y.facematch,commitment:{expected:`Commitment: ${z.toString()}`,received:`Commitment: ${O.toString()}`,message:"The FaceMatch verification does not match the ones from the proof"}});let{isCorrect:W,queryResultErrors:Y}=this.checkScopeFromDisclosureProof(t,E,y,"facematch",o),{isCorrect:oe,queryResultErrors:te}=await this.checkFacematchPublicInputs(r,i,q);u=u&&oe&&W,y={...y,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("facematch",E,n??gt,y);u=u&&$,y={...y,...R};}}let G=new Set;for(let k of I)for(let E of Object.keys(k.committedInputs??{}))G.add(E);let{isCorrect:F,queryResultErrors:H}=this.checkQueryCompleteness(r,G);if(u=u&&F,y={...y,...H},u&&m&&(m===Pe.SALTED||m===Pe.SALTED_MOCK))try{let k=await Zb(s??Wb),E=await Yb(k),q=b;if(q===void 0){let O=I.find(z=>z.name&&!z.name.startsWith("sig_check_")&&!z.name.startsWith("data_check_")&&!z.name.startsWith("outer")&&!z.name.startsWith("facematch"));if(O){let z=oa(O.proof,ia(O.name));q=zb(z);}}(q===void 0||q!==E)&&(console.warn("OPRF public key hash mismatch: proof uses an unknown OPRF key"),u=!1);}catch(k){console.warn("Failed to verify OPRF public key:",k),u=false;}return m===Pe.NONE?(h!==void 0&&BigInt(h)!==0n&&(console.warn("Proofs with the NONE nullifier type cannot carry a unique identifier"),u=false),h=void 0):h!==void 0&&BigInt(h)===0n&&(h=void 0),{isCorrect:u,uniqueIdentifier:h,uniqueIdentifierType:m,queryResultErrors:y}}},YE={abi:[{type:"constructor",inputs:[{name:"_admin",type:"address",internalType:"address"},{name:"_guardian",type:"address",internalType:"address"},{name:"_rootRegistry",type:"address",internalType:"contract RootRegistry"},{name:"_defaultOPRFPubKeyHash",type:"bytes32",internalType:"bytes32"}],stateMutability:"nonpayable"},{type:"function",name:"addHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newHelper",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"subVerifier",type:"address",internalType:"contract SubVerifier"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"admin",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"config",inputs:[{name:"key",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"value",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"defaultOPRFPubKeyHash",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"guardian",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"helperCount",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"helpers",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"contract VerifierHelper"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"removeHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"removeSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"rootRegistry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract RootRegistry"}],stateMutability:"view"},{type:"function",name:"setDefaultOPRFPubKeyHash",inputs:[{name:"newHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setGuardian",inputs:[{name:"newGuardian",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"subverifierCount",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"subverifiers",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"address",internalType:"contract SubVerifier"}],stateMutability:"view"},{type:"function",name:"transferAdmin",inputs:[{name:"newAdmin",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateConfig",inputs:[{name:"key",type:"bytes32",internalType:"bytes32"},{name:"value",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateHelper",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newHelper",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateSubVerifier",inputs:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"newSubVerifier",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"verify",inputs:[{name:"params",type:"tuple",internalType:"struct ProofVerificationParams",components:[{name:"version",type:"bytes32",internalType:"bytes32"},{name:"proofVerificationData",type:"tuple",internalType:"struct ProofVerificationData",components:[{name:"vkeyHash",type:"bytes32",internalType:"bytes32"},{name:"proof",type:"bytes",internalType:"bytes"},{name:"publicInputs",type:"bytes32[]",internalType:"bytes32[]"}]},{name:"committedInputs",type:"bytes",internalType:"bytes"},{name:"serviceConfig",type:"tuple",internalType:"struct ServiceConfig",components:[{name:"validityPeriodInSeconds",type:"uint256",internalType:"uint256"},{name:"domain",type:"string",internalType:"string"},{name:"scope",type:"string",internalType:"string"},{name:"devMode",type:"bool",internalType:"bool"}]}]}],outputs:[{name:"valid",type:"bool",internalType:"bool"},{name:"uniqueIdentifier",type:"bytes32",internalType:"bytes32"},{name:"helper",type:"address",internalType:"contract VerifierHelper"}],stateMutability:"view"},{type:"event",name:"AdminUpdated",inputs:[{name:"oldAdmin",type:"address",indexed:true,internalType:"address"},{name:"newAdmin",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"ConfigUpdated",inputs:[{name:"key",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldValue",type:"bytes32",indexed:false,internalType:"bytes32"},{name:"newValue",type:"bytes32",indexed:false,internalType:"bytes32"}],anonymous:false},{type:"event",name:"DefaultOPRFPubKeyHashUpdated",inputs:[{name:"oldHash",type:"bytes32",indexed:false,internalType:"bytes32"},{name:"newHash",type:"bytes32",indexed:false,internalType:"bytes32"}],anonymous:false},{type:"event",name:"GuardianUpdated",inputs:[{name:"oldGuardian",type:"address",indexed:true,internalType:"address"},{name:"newGuardian",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperAdded",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"helper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperRemoved",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"helper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"HelperUpdated",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldHelper",type:"address",indexed:true,internalType:"address"},{name:"newHelper",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"PausedStatusChanged",inputs:[{name:"paused",type:"bool",indexed:false,internalType:"bool"}],anonymous:false},{type:"event",name:"RootRegistryUpdated",inputs:[{name:"oldRootRegistry",type:"address",indexed:true,internalType:"address"},{name:"newRootRegistry",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"RootVerifierDeployed",inputs:[{name:"admin",type:"address",indexed:false,internalType:"address"},{name:"guardian",type:"address",indexed:false,internalType:"address"},{name:"rootRegistry",type:"address",indexed:false,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierAdded",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"subVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierRemoved",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"subVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false},{type:"event",name:"SubVerifierUpdated",inputs:[{name:"version",type:"bytes32",indexed:true,internalType:"bytes32"},{name:"oldSubVerifier",type:"address",indexed:true,internalType:"address"},{name:"newSubVerifier",type:"address",indexed:true,internalType:"address"}],anonymous:false}]},aS=class{static getDetails(){return {functionName:"verify",abi:YE.abi,address:"0x1D000001000EFD9a6371f4d90bB8920D5431c0D8"}}static getParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){if(!t.name?.startsWith("outer_evm"))throw new Error("This proof cannot be verified on an EVM chain. Please make sure to use the `compressed-evm` mode.");let o=oa(t.proof,ia(t.name)),s=[],a=[];for(let h in t.committedInputs){let m=qb(h),b=h;s.push({circuitName:b,count:m});let A="";if(b==="inclusion_check_issuing_country_evm"||b==="inclusion_check_nationality_evm"||b==="exclusion_check_issuing_country_evm"||b==="exclusion_check_nationality_evm"){let x=t.committedInputs[b].countries;(b==="exclusion_check_issuing_country_evm"||b==="exclusion_check_nationality_evm")&&x.sort((w,I)=>w.localeCompare(I));let y=(()=>{switch(b){case "exclusion_check_issuing_country_evm":return fe.ISSUING_COUNTRY_EXCLUSION;case "exclusion_check_nationality_evm":return fe.NATIONALITY_EXCLUSION;case "inclusion_check_issuing_country_evm":return fe.ISSUING_COUNTRY_INCLUSION;case "inclusion_check_nationality_evm":return fe.NATIONALITY_INCLUSION}})();A=y.toString(16).padStart(2,"0")+se[y].evm.toString(16).padStart(4,"0")+Mo(x.map(w=>Array.from(new TextEncoder().encode(w))).flat(),600).map(w=>w.toString(16).padStart(2,"0")).join("");}else if(b==="compare_age_evm"){let x=t.committedInputs[b];A=fe.AGE.toString(16).padStart(2,"0")+se[fe.AGE].evm.toString(16).padStart(4,"0")+x.minAge.toString(16).padStart(2,"0")+x.maxAge.toString(16).padStart(2,"0");}else if(b==="compare_birthdate_evm"){let x=t.committedInputs[b],y=Array.from(Te(x.minDateTimestamp,8)),w=Array.from(Te(x.maxDateTimestamp,8));A=fe.BIRTHDATE.toString(16).padStart(2,"0")+se[fe.BIRTHDATE].evm.toString(16).padStart(4,"0")+y.map(I=>I.toString(16).padStart(2,"0")).join("")+w.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="compare_expiry_evm"){let x=t.committedInputs[b],y=Array.from(Te(x.minDateTimestamp,8)),w=Array.from(Te(x.maxDateTimestamp,8));A=fe.EXPIRY_DATE.toString(16).padStart(2,"0")+se[fe.EXPIRY_DATE].evm.toString(16).padStart(4,"0")+y.map(I=>I.toString(16).padStart(2,"0")).join("")+w.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="disclose_bytes_evm"){let x=t.committedInputs[b];A=fe.DISCLOSE.toString(16).padStart(2,"0")+se[fe.DISCLOSE].evm.toString(16).padStart(4,"0")+x.discloseMask.map(y=>y.toString(16).padStart(2,"0")).join("")+x.disclosedBytes.map(y=>y.toString(16).padStart(2,"0")).join("");}else if(b==="bind_evm"){let x=t.committedInputs[b];A=fe.BIND.toString(16).padStart(2,"0")+se[fe.BIND].evm.toString(16).padStart(4,"0")+Mo(ac(x.data),509).map(y=>y.toString(16).padStart(2,"0")).join("");}else if(b==="exclusion_check_sanctions_evm"){let x=t.committedInputs[b];A+=fe.SANCTIONS_EXCLUSION.toString(16).padStart(2,"0"),A+=se[fe.SANCTIONS_EXCLUSION].evm.toString(16).padStart(4,"0"),A+=Array.from(Te(BigInt(x.rootHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.isStrict?"01":"00";}else if(b.startsWith("facematch")&&b.endsWith("_evm")){let x=t.committedInputs[b];A+=fe.FACEMATCH.toString(16).padStart(2,"0"),A+=se[fe.FACEMATCH].evm.toString(16).padStart(4,"0"),A+=Array.from(Te(BigInt(x.rootKeyLeaf),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.environment==="development"?"00":"01",A+=Array.from(Te(BigInt(x.appIdHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=Array.from(Te(BigInt(x.integrityPubkeyHash),32)).map(y=>y.toString(16).padStart(2,"0")).join(""),A+=x.mode==="regular"?"01":"02";}else throw new Error(`Unsupported circuit for EVM verification: ${b}`);a.push({circuitName:b,inputs:A});}let c=oh(o).map(h=>h.toString(16).padStart(64,"0")),l="";for(let h of c){let m=a.find(b=>{let A=ot(jn(b.inputs)),x=new Uint8Array(A.length);for(let y=0;y<A.length-1;y++)x[y+1]=A[y];return x[0]=0,Vn(x)===h.replace("0x","")});if(m)if(s.find(A=>A.circuitName===m.circuitName)?.count)l+=m.inputs;else throw new Error(`Unknown circuit name: ${m.circuitName}`);else throw new Error(`Invalid commitment: ${h}`)}let d=t.version?.split(".").map(h=>Number(h));if(!d||d.length!==3)throw new Error("Invalid version format");let u=new Uint8Array([...Te(d[0],2),...Te(d[1],2),...Te(d[2],2)]);return {version:`0x${Vn(u).padEnd(64,"0")}`,proofVerificationData:{vkeyHash:`0x${t.vkeyHash.replace("0x","").padStart(64,"0")}`,proof:`0x${o.proof.join("")}`,publicInputs:o.publicInputs},committedInputs:`0x${l}`,serviceConfig:{validityPeriodInSeconds:e,domain:r,scope:i??"",devMode:n}}}};async function QE({domain:t,proofs:e,query:r,queryResult:i,scope:n,policyId:o,requestId:s}){let a=e.map(c=>({proof:c.proof,vkeyHash:c.vkeyHash,version:c.version,name:c.name,index:c.index,total:c.total,committedInputs:c.committedInputs}));try{let c=await fetch(`${hS}/public/proofs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:t,proofs:a,query:r,queryResult:i,scope:n,policyId:o,sdkVersion:O2,requestId:s}),signal:AbortSignal.timeout(3e4)});c.ok?eS.debug("API response status:",c.status):eS.warn("API request failed with status:",c.status);}catch{}}var JE=[0,20,0];function eB(t){if(!t)return "v5";let e=t.split(".").map(c=>Number(c));if(e.length!==3||e.some(c=>Number.isNaN(c)))return "v5";let[r,i,n]=e,[o,s,a]=JE;return r!==o?r>o?"v5":"v4":i!==s?i>s?"v5":"v4":n>=a?"v5":"v4"}async function tB(t,{writingDirectory:e}={}){await rB(t);let r=e?e+"/.bb-crs":void 0;if(t==="v4"){console.warn("Using deprecated v4 UltraHonk Verifier"),r=e?e+"/.bb-crs-v4":void 0;let{UltraHonkVerifierBackend:s,Barretenberg:a}=await Promise.resolve().then(()=>It(W8(),1)),c=await a.new({crsPath:r});return {verifier:new s(c),destroy:()=>c.destroy()}}let{UltraHonkVerifierBackend:i,Barretenberg:n}=await Promise.resolve().then(()=>It(Y8(),1)),o=await n.new({crsPath:r});return {verifier:new i(o),destroy:()=>o.destroy()}}var cS="__zkpassport_bb_version",lS="keyval-store";async function rB(t){if(!(typeof indexedDB>"u"))try{let e=typeof localStorage<"u"?localStorage:void 0;if((e?.getItem(cS)??"v4")===t)return;let r=!0;if(typeof indexedDB.databases=="function")try{r=(await indexedDB.databases()).some(i=>i.name===lS);}catch{r=!0;}r&&await new Promise(i=>{let n=indexedDB.deleteDatabase(lS);n.onsuccess=n.onerror=n.onblocked=()=>i();}),e?.setItem(cS,t);}catch{}}async function dS({proofs:t,originalQuery:e,queryResult:r,domain:i,validity:n,scope:o,devMode:s,oprfKeyId:a}){try{let c=await fetch(`${WE}/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proofs:t,originalQuery:e,queryResult:r,serviceConfig:{domain:i,scope:o,validityPeriodInSeconds:n,devMode:s},oprfKeyId:a}),signal:AbortSignal.timeout(6e4)});if(c.status>=500)return console.warn(`Verifier API error (status ${c.status})`),null;let l=await c.json().catch(()=>null);return !l||typeof l.verified!="boolean"?(console.warn(`Unexpected verifier API response (status ${c.status})`),null):l.verified?{uniqueIdentifier:l.uniqueIdentifier,uniqueIdentifierType:l.uniqueIdentifierType,verified:!0}:(console.warn("Verifier API did not verify the proofs:",l.error),{uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:!1,queryResultErrors:l.queryResultErrors})}catch(c){return console.warn("Verifier API call failed:",c),null}}typeof globalThis.Buffer>"u"&&(globalThis.Buffer=es.Buffer,typeof window<"u"&&(window.Buffer=es.Buffer));var uS="Verify identity privately";function iB({uniqueIdentifier:t,uniqueIdentifierType:e}){return e===Pe.SALTED_MOCK?Pe.SALTED:e===Pe.NON_SALTED_MOCK?t===void 0?Pe.NONE:Pe.NON_SALTED:e}function nB(t,e){if(e==null||!t.verified||iB(t)===e)return t;let r=t.uniqueIdentifierType,i=r===void 0?"missing":Pe[r];return console.warn(`Unique identifier type mismatch: requested ${Pe[e]}, got ${i}`),{...t,uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:false}}var fS=false;function oB(){fS||(fS=true,console.warn("[zkpassport] onResult is deprecated. Use onSuccess and verify the proofs on your backend with verify()."));}function sB(t){let e=t.connection.getWebSocket();if(e)try{e.send(JSON.stringify({method:"replay",params:{timestamp:1}}));}catch{}}var M2=class{constructor(t){if(this.topicToConfig={},this.topicToLocalConfig={},this.topicToPublicKey={},this.topicToBridge={},this.topicToRequestReceived={},this.topicToService={},this.topicToCallerPurpose={},this.topicToProofs={},this.topicToFailedProofCount={},this.topicToResults={},this.topicToPolicy={},this.dashboardConfig=null,this.dashboardConfigPromise=null,this.dashboardConfigError=null,this.onRequestReceivedCallbacks={},this.onGeneratingProofCallbacks={},this.onBridgeConnectCallbacks={},this.onBridgeConnectionLostCallbacks={},this.onProofGeneratedCallbacks={},this.onSuccessCallbacks={},this.onResultCallbacks={},this.onRejectCallbacks={},this.onErrorCallbacks={},!t&&typeof window>"u")throw new Error("Domain argument is required in Node.js environment");this.domainProvided=!!t,this.domain=this.normalizeDomain(t||window.location.hostname);}normalizeDomain(t){return t.trim().replace(/^https?:\/\//,"").replace(/\/[^/]*$/,"").replace(/:[0-9]+/,"").replace(/\?.*$/,"").replace(/#.*$/,"").toLowerCase()}async handleResult(t){let e=this.topicToResults[t];delete this.topicToResults[t];let r=this.topicToProofs[t],i=this.topicToFailedProofCount[t]>0,n=!i&&r.length>0;if(n)try{await Promise.all(this.onSuccessCallbacks[t].map(a=>a({proofs:r,result:e})));}catch{}let o=this.topicToLocalConfig[t]?.devMode===true,s=this.topicToPolicy[t]?.proofStorageEnabled===true;n&&s&&this.domainProvided&&!o&&QE({domain:this.domain,proofs:r,query:this.topicToConfig[t],queryResult:e,scope:this.topicToService[t]?.scope,policyId:this.topicToPolicy[t]?.id,requestId:this.topicToPublicKey[t]}),this.onResultCallbacks[t].length>0&&await this.verifyAndReportResult(t,r,e,i),delete this.topicToProofs[t],delete this.topicToFailedProofCount[t];}async verifyAndReportResult(t,e,r,i){let n;try{n=await this.verify({proofs:e,originalQuery:this.topicToConfig[t],queryResult:r,validity:this.topicToLocalConfig[t]?.validity,scope:this.topicToService[t]?.scope,devMode:this.topicToLocalConfig[t]?.devMode,oprfKeyId:this.topicToLocalConfig[t]?.oprfKeyId??void 0,uniqueIdentifierType:this.topicToLocalConfig[t]?.uniqueIdentifierType,verifierMode:this.topicToLocalConfig[t]?.verifierMode,config:this.topicToLocalConfig[t]?.config});}catch(l){let d=l instanceof Error?l.message:String(l);await Promise.all(this.onErrorCallbacks[t].map(u=>u(d)));return}let{uniqueIdentifier:o,uniqueIdentifierType:s,verified:a,queryResultErrors:c}=n;await Promise.all(this.onResultCallbacks[t].map(l=>l({uniqueIdentifier:i?void 0:o,uniqueIdentifierType:i?void 0:s,verified:i?false:a,result:r,queryResultErrors:c,proofs:e,sdkInstance:this})));}async handleEncryptedMessage(t,e){if(e.method==="accept")await Promise.all(this.onGeneratingProofCallbacks[t].map(r=>r(t)));else if(e.method==="reject")await Promise.all(this.onRejectCallbacks[t].map(r=>r()));else if(e.method==="proof")this.topicToProofs[t].push(e.params),await Promise.all(this.onProofGeneratedCallbacks[t].map(r=>r(e.params))),this.topicToResults[t]&&e.params.total===this.topicToProofs[t].length+this.topicToFailedProofCount[t]&&await this.handleResult(t);else if(e.method==="done")this.topicToResults[t]=$p(e.params),this.topicToProofs[t].length>0&&this.topicToProofs[t].length+this.topicToFailedProofCount[t]===this.topicToProofs[t][0].total&&await this.handleResult(t);else if(e.method==="error"){let r=e.params.error;r&&r==="This ID is not supported yet"?this.topicToResults[t]&&await this.handleResult(t):r&&r.startsWith("Cannot generate proof")&&(this.topicToFailedProofCount[t]+=1,this.topicToResults[t]&&this.topicToProofs[t].length>0&&this.topicToProofs[t].length+this.topicToFailedProofCount[t]===this.topicToProofs[t][0].total&&await this.handleResult(t)),await Promise.all(this.onErrorCallbacks[t].map(i=>i(r)));}}assertNotPolicyLocked(t,e){if(this.topicToPolicy[t])throw new Error(`Cannot call .${e}() on a policy-driven request. The query for policy '${this.topicToPolicy[t].id}' is immutable.`)}getZkPassportRequest(t){return {eq:(e,r)=>(this.assertNotPolicyLocked(t,"eq"),(e==="issuing_country"||e==="nationality")&&(r=Gi(r)),va("eq",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),gte:(e,r)=>{if(this.assertNotPolicyLocked(t,"gte"),Ln("gte",e,r,t,this.topicToConfig),e==="age"&&(r<1||r>=100))throw new Error("Age must be between 1 and 99 (inclusive)");return this.getZkPassportRequest(t)},gt:(e,r)=>(this.assertNotPolicyLocked(t,"gt"),Ln("gt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lte:(e,r)=>(this.assertNotPolicyLocked(t,"lte"),Ln("lte",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lt:(e,r)=>(this.assertNotPolicyLocked(t,"lt"),Ln("lt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),range:(e,r,i)=>(this.assertNotPolicyLocked(t,"range"),pS(e,[r,i],t,this.topicToConfig),this.getZkPassportRequest(t)),in:(e,r)=>(this.assertNotPolicyLocked(t,"in"),r=r.map(i=>Gi(i)),va("in",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),out:(e,r)=>(this.assertNotPolicyLocked(t,"out"),r=r.map(i=>Gi(i)),va("out",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),disclose:e=>(this.assertNotPolicyLocked(t,"disclose"),this.topicToConfig[t][e]={...this.topicToConfig[t][e],disclose:true},this.getZkPassportRequest(t)),bind:(e,r)=>(this.topicToConfig[t].bind={...this.topicToConfig[t].bind,[e]:r},this.getZkPassportRequest(t)),sanctions:(e="all",r="all",i={strict:false})=>(this.assertNotPolicyLocked(t,"sanctions"),this.topicToConfig[t].sanctions={...this.topicToConfig[t].sanctions,countries:e,lists:r,strict:i.strict??false},this.getZkPassportRequest(t)),facematch:(e="strict")=>(this.assertNotPolicyLocked(t,"facematch"),this.topicToConfig[t].facematch={mode:e},this.getZkPassportRequest(t)),raw:e=>{this.assertNotPolicyLocked(t,"raw");let{policy:r,bind:i,...n}=e;if(r){if(Object.keys(n).length>0)throw new Error("A query with `policy` cannot also carry conditions (bind is allowed).");this.getZkPassportRequest(t).policy(r),i&&(this.topicToConfig[t].bind=i);}else this.topicToConfig[t]=e;return this.getZkPassportRequest(t)},policy:e=>{if(this.assertCanApplyPolicy(t,e),!this.dashboardConfig)throw this.dashboardConfigError?this.dashboardConfigError:new Error(`${this.domain} is not set up for ZKPassport verification. If this is your site, register the domain at https://dashboard.zkpassport.id.`);let r=this.findPolicy(this.dashboardConfig,e),{bind:i,...n}=r.query;this.topicToConfig[t]=n;let o=this.topicToService[t];return o&&(this.topicToCallerPurpose[t]||(o.purpose=r.purpose||uS),o.scope||(o.scope=r.id),o.policyId=r.id),this.topicToPolicy[t]={id:r.id,proofStorageEnabled:r.proofStorageEnabled===true},this.getZkPassportRequest(t)},done:(()=>{if(this.topicToFailedProofCount[t]=0,t==="offline-query"){let o=this.topicToConfig[t];return delete this.topicToConfig[t],delete this.topicToPolicy[t],{query:o}}let e=this.topicToLocalConfig[t],r=this.topicToConfig[t],i=!!r.facematch,n=!!r.facematch&&r.facematch?.mode==="strict";if(e.uniqueIdentifierType===Pe.SALTED&&(e.devMode===false&&!n||!i))throw new Error("Salted nullifier requires strict facematch. Add .facematch('strict') to your query or remove the salted nullifier option.");return {url:this._getUrl(t),query:this.topicToConfig[t],requestId:t,policy:this.topicToPolicy[t]?.id,onRequestReceived:o=>this.onRequestReceivedCallbacks[t].push(o),onGeneratingProof:o=>this.onGeneratingProofCallbacks[t].push(o),onBridgeConnect:o=>this.onBridgeConnectCallbacks[t].push(o),onBridgeConnectionLost:o=>this.onBridgeConnectionLostCallbacks[t].push(o),onProofGenerated:o=>this.onProofGeneratedCallbacks[t].push(o),onSuccess:o=>this.onSuccessCallbacks[t].push(o),onResult:o=>{oB(),this.onResultCallbacks[t].push(o);},onReject:o=>this.onRejectCallbacks[t].push(o),onError:o=>this.onErrorCallbacks[t].push(o),isBridgeConnected:()=>this.topicToBridge[t].isBridgeConnected(),requestReceived:()=>this.topicToRequestReceived[t]===true}})}}async getDashboardConfig(){return this.dashboardConfig?this.dashboardConfig:(this.dashboardConfigPromise||(this.dashboardConfigPromise=this.fetchDashboardConfig().then(t=>(this.dashboardConfig=t,t)).catch(t=>{throw this.dashboardConfigPromise=null,t})),this.dashboardConfigPromise)}async fetchDashboardConfig(){let t=`${hS}/public/project?domain=${encodeURIComponent(this.domain)}`,e;try{e=await fetch(t,{signal:AbortSignal.timeout(1e4)});}catch(i){throw new Error(`Failed to fetch dashboard config for domain '${this.domain}': ${i.message}`)}if(!e.ok)throw new Error(`Failed to fetch dashboard config for domain '${this.domain}': ${e.status} ${e.statusText}`);let r=await e.json();if(r&&r.project===null)return null;if(!r||!r.project||!Array.isArray(r.policies))throw new Error(`Invalid dashboard config response for domain '${this.domain}'`);return r}findPolicy(t,e){let r=t.policies.find(i=>i.id===e);if(!r)throw new Error(`Policy '${e}' not found for domain '${this.domain}'. The dashboard returned ${t.policies.length} policies for this domain.`);if(!r.query||typeof r.query!="object")throw new Error(`Invalid policy '${e}' for domain '${this.domain}': missing query object.`);return r}assertCanApplyPolicy(t,e){if(typeof e!="string"||e.length===0)throw new Error(".policy() requires a non-empty string id.");if(this.topicToPolicy[t])throw new Error(`Cannot call .policy() more than once on a request (already set to '${this.topicToPolicy[t].id}').`);if(Object.keys(this.topicToConfig[t]).length>0)throw new Error("Cannot combine .policy() with builder methods like .gte()/.disclose()/etc. Call .policy() first; only .bind() may follow it.")}async request({name:t,logo:e,purpose:r,scope:i,projectID:n,mode:o,validity:s,devMode:a,uniqueIdentifierType:c,oprfKeyId:l,topicOverride:d,keyPairOverride:u,replayMissedMessages:h,cloudProverUrl:m,bridgeUrl:b,returnDeepLink:A,verifierMode:x,config:y,overrides:w}){if(d==="offline-query")throw new Error("You cannot override the topic with 'offline-query'");if(l&&c===Pe.NONE)throw new Error("An OPRF key cannot be used with the NONE unique identifier type. Remove the oprfKeyId option or use the SALTED type.");let I=null;try{I=await this.getDashboardConfig(),this.dashboardConfigError=null;}catch(v){this.dashboardConfigError=v;}let _=await E2.create({keyPair:u,bridgeId:d,bridgeUrl:b}),C=_.connection.getBridgeId();return this.topicToConfig[C]={},this.topicToCallerPurpose[C]=r,this.topicToService[C]={name:t||I?.project?.name||this.domain,logo:e||I?.project?.logoUrl||"",purpose:r||uS,scope:i,projectID:n,cloudProverUrl:m,bridgeUrl:b},this.topicToProofs[C]=[],this.topicToLocalConfig[C]={validity:s||gt,mode:o||"fast",devMode:a??false,uniqueIdentifierType:l?Pe.SALTED:c,oprfKeyId:l??null,returnDeepLink:A,verifierMode:x,config:y,appClip:w?.appClip??false},this.onRequestReceivedCallbacks[C]=[],this.onGeneratingProofCallbacks[C]=[],this.onBridgeConnectCallbacks[C]=[],this.onBridgeConnectionLostCallbacks[C]=[],this.onProofGeneratedCallbacks[C]=[],this.onSuccessCallbacks[C]=[],this.onResultCallbacks[C]=[],this.onRejectCallbacks[C]=[],this.onErrorCallbacks[C]=[],this.topicToPublicKey[C]=_.getPublicKey(),this.topicToBridge[C]=_,_.onConnect(async v=>{h&&!v&&sB(_),await Promise.all(this.onBridgeConnectCallbacks[C].map(T=>T()));}),_.onDisconnect(async v=>{v.wasIntentionalClose||v.willReconnect||await Promise.all(this.onBridgeConnectionLostCallbacks[C].map(T=>T()));}),_.onSecureChannelEstablished(async()=>{await Promise.all(this.onRequestReceivedCallbacks[C].map(v=>v()));}),_.onSecureMessage(async v=>{try{await this.handleEncryptedMessage(C,v);}catch{}}),this.getZkPassportRequest(C)}createQuery(){return jE()}async verify({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,uniqueIdentifierType:c,verifierMode:l="auto",config:d}){if(!e||!r)throw new Error("verify() requires `originalQuery` and `queryResult`");let u={uniqueIdentifier:void 0,uniqueIdentifierType:void 0,verified:false};if(!t||t.length===0)return u;let h={proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o,oprfKeyId:a},m={...h,writingDirectory:s,config:d},b={...h,domain:this.domain},A=a?Pe.SALTED:c,x;if(l==="local")x=await this.verifyLocally(m);else if(l==="api")x=await dS(b)??u;else {let y;try{y=await this.verifyLocally(m);}catch(w){console.warn("Local proof verification failed:",w);}x=y?.verified?y:await dS(b)??y??u;}return nB(x,A)}async verifyLocally({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,config:c}){let l=$p(r);typeof window>"u"&&!s&&(s="/tmp");let d=eB(t[0]?.version),u,h=true,m,b,A;try{let x=xh(Gp(e,o),c),{isCorrect:y,uniqueIdentifier:w,uniqueIdentifierType:I,queryResultErrors:_}=await ZE.checkPublicInputs(this.domain,t,e,l,i,n,a,o,x);if(m=w,b=I,h=y,A=y?void 0:_,(b===Pe.SALTED_MOCK||b===Pe.NON_SALTED_MOCK)&&!o&&(h=!1,console.warn("You are trying to verify a mock proof. This is only allowed in dev mode. To enable dev mode, set the `devMode` parameter to `true` in the request function parameters.")),h){let C=await x.getCircuitManifest(void 0,{version:t[0].version});u=await tB(d,{writingDirectory:s});for(let v of t){let T=v.name?.startsWith("outer_evm_"),G=v.name,F=oa(v.proof,ia(G)),H=await x.getPackagedCircuit(G,C,{validate:!T});if(T)try{let{createPublicClient:k,http:E}=await Promise.resolve().then(()=>It(J8(),1)),{address:q,abi:O,functionName:z}=this.getSolidityVerifierDetails(),W=k({transport:E(x.getRpcUrl())}),Y=this.getSolidityVerifierParameters({proof:v,validityPeriodInSeconds:i,domain:this.domain,scope:n,devMode:o}),oe=await W.readContract({address:q,abi:O,functionName:z,args:[Y]});h=Array.isArray(oe)?!!oe[0]:!1;}catch(k){console.warn("Error verifying proof",k),h=!1;}else {let k=es.Buffer.from(H.vkey,"base64");try{h=await u.verifier.verifyProof({proof:es.Buffer.from(F.proof.join(""),"hex"),publicInputs:F.publicInputs,verificationKey:new Uint8Array(k)});}catch(E){console.warn(`Error verifying proof ${G}`,E),h=!1;}}if(!h)break}}}finally{await u?.destroy();}return m=h?m:void 0,b=h?b:void 0,{uniqueIdentifier:m,uniqueIdentifierType:b,verified:h,queryResultErrors:A}}getSolidityVerifierDetails(){return aS.getDetails()}getSolidityVerifierParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){return aS.getParameters({proof:t,validityPeriodInSeconds:e,domain:r??this.domain,scope:i,devMode:n})}_getUrl(t){let e=es.Buffer.from(JSON.stringify(this.topicToConfig[t])).toString("base64"),r=es.Buffer.from(JSON.stringify(this.topicToService[t])).toString("base64"),i=this.topicToPublicKey[t],n=Math.floor(Date.now()/1e3)-this.topicToLocalConfig[t].validity,o=this.topicToLocalConfig[t].uniqueIdentifierType,s=this.topicToLocalConfig[t].oprfKeyId,a=this.topicToLocalConfig[t].returnDeepLink,c=`https://zkpassport.id/${this.topicToLocalConfig[t].appClip?"c":"r"}?d=${this.domain}&t=${t}&c=${encodeURIComponent(e)}&s=${encodeURIComponent(r)}&p=${i}&m=${this.topicToLocalConfig[t].mode}&v=${O2}&dt=${n}&dev=${this.topicToLocalConfig[t].devMode?"1":"0"}`;return o!=null&&(c+=`&nt=${o}`),s&&(c+=`&oprf_k=${s}`),a&&(c+=`&r=${encodeURIComponent(a)}`),c}getUrl(t){return this._getUrl(t)}getServiceDetails(t){return this.topicToService[t]}getRequestKeyPair(t){return this.topicToBridge[t]?.getKeyPair()}cancelRequest(t){this.topicToBridge[t]&&(this.topicToBridge[t].close(),delete this.topicToBridge[t]),delete this.topicToPublicKey[t],delete this.topicToConfig[t],delete this.topicToLocalConfig[t],delete this.topicToProofs[t],delete this.topicToFailedProofCount[t],delete this.topicToResults[t],delete this.topicToPolicy[t],this.onRequestReceivedCallbacks[t]=[],this.onGeneratingProofCallbacks[t]=[],this.onBridgeConnectCallbacks[t]=[],this.onBridgeConnectionLostCallbacks[t]=[],this.onProofGeneratedCallbacks[t]=[],this.onSuccessCallbacks[t]=[],this.onResultCallbacks[t]=[],this.onRejectCallbacks[t]=[],this.onErrorCallbacks[t]=[];}clearAllRequests(){for(let t in this.topicToBridge)this.cancelRequest(t);}};var zd="[zkpassport]";function aB(){try{return typeof localStorage<"u"&&localStorage.getItem("zkpassport:debug")==="1"}catch{return false}}var ci={error(...t){console.error(zd,...t);},warn(...t){console.warn(zd,...t);},info(...t){console.info(zd,...t);},debug(...t){aB()&&console.debug(zd,...t);}};function gS(t){let e=t.showIntroScreen===true,[r,i]=Ht(e?"intro":"preparing"),[n,o]=Ht(null),[s,a]=Ht(null),[c,l]=Ht(null),[d,u]=Ht(null),[h,m]=Ht(null),[b,A]=Ht(0),[x,y]=Ht({received:0,total:null}),w=Fr(t);w.current=t;let I=Fr(null),_=Fr("preparing"),C=Fr(e),v=Fr(false),T=Fr(null),G=Fr(null);G.current===null&&(G.current=new M2(t.domain)),is(()=>{let k=G.current,E=false,q=false,O=null,z=w.current.showIntroScreen===true,W=z&&!v.current;C.current=W,_.current="preparing",i(W?"intro":"preparing"),o(null),a(null),l(null),u(null),m(null),y({received:0,total:null}),I.current=null;let{domain:Y,theme:oe,showIntroScreen:te,query:$,onReady:R,onRetryClicked:M,onBridgeConnect:V,onRequestReceived:K,onGeneratingProof:L,onProofGenerated:re,onSuccess:D,onResult:X,onReject:Q,onError:ne,...le}=w.current;X&&w.current.onSuccess&&ci.warn("onResult is deprecated and drives the card; onSuccess return values are ignored");let _e=()=>{q||(q=true,br(w.current.onReady));},Oe=false,Ne=yt=>{Oe=true,C.current=false,v.current=true,i(yt);},Fe=(yt,ye)=>{ci.error(ye),Ne("error");let $i=ye instanceof Error?ye.message:String(ye);br(w.current.onError,`${yt}: ${$i}`);},ge=yt=>(...ye)=>{if(!E)try{yt(...ye);}catch($i){Fe("Failed to handle a verification update",$i);}},Le=(yt,ye=false)=>{_.current=yt,ye&&(C.current=false,v.current=true),C.current||i(yt);};return k.request({...le,verifierMode:le.verifierMode??"api"}).then(yt=>{let ye;try{ye=$(yt);}catch(Re){E||Fe("Failed to build the verification query",Re);return}if(O=ye.requestId,E){k.cancelRequest(ye.requestId);return}ye.onBridgeConnect(ge(()=>{(_.current==="preparing"||_.current==="connecting")&&Le("waiting"),_e(),br(w.current.onBridgeConnect);})),ye.onBridgeConnectionLost(ge(()=>{Oe||(Ne("error"),br(w.current.onError,"The connection to your phone was lost."));})),ye.onRequestReceived(ge(()=>{Le("scanned",!0),br(w.current.onRequestReceived);})),ye.onGeneratingProof(ge(()=>{Le("generating",!0),br(w.current.onGeneratingProof);})),ye.onProofGenerated(ge(Re=>{y(Vi=>({received:Vi.received+1,total:Re.total??Vi.total})),br(w.current.onProofGenerated,Re);})),ye.onSuccess(ge(Re=>{if(X){br(w.current.onSuccess,Re);return}let Vi=Hn=>{E||Ne(Hn);},z2;try{z2=w.current.onSuccess?.(Re);}catch(Hn){ci.error(Hn),Vi("error");return}Promise.resolve(z2).then(Hn=>Vi(Hn===!1?"error":"success"),Hn=>{ci.error(Hn),Vi("error");});})),X&&ye.onResult(ge(Re=>{Ne(Re.verified?"success":"error"),br(w.current.onResult,Re);})),ye.onReject(ge(()=>{Ne("error"),br(w.current.onReject);})),ye.onError(ge(Re=>{Ne("error"),br(w.current.onError,Re);})),I.current=ye,l(ye.query);try{let Re=k.getServiceDetails(ye.requestId);Re&&(u(Re.name||null),m(Re.logo||null));}catch(Re){ci.error(Re);}let $i=JSON.stringify(ye.query);z&&v.current&&$i!==T.current&&(C.current=true,i("intro")),T.current=$i;try{ye.requestReceived()?Le("scanned",!0):ye.isBridgeConnected()?(Le("waiting"),_e()):Le("connecting");}catch(Re){Fe("Failed to check the verification state",Re);}o(ye.url);try{a(cB(ye.url));}catch(Re){Fe("Failed to render the QR code",Re);}}).catch(yt=>{E||Fe("Failed to start the verification request",yt);}),()=>{E=true,O&&k.cancelRequest(O);}},[b]);let F=cu(()=>{br(w.current.onRetryClicked),A(k=>k+1);},[]),H=cu(()=>{C.current=false,v.current=true,i(_.current);},[]);return {state:r,url:n,qrSvg:s,query:c,serviceName:d,serviceLogo:h,retry:F,continueWithPhone:H,proofProgress:x}}function cB(t){let e=mS.default.create(t,{errorCorrectionLevel:"Q"}),r=e.modules.size,i=e.modules.data,n=100/r,o=u=>u.toFixed(3),s=[[0,0],[0,r-7],[r-7,0]],a=(u,h)=>s.some(([m,b])=>u>=m&&u<m+7&&h>=b&&h<b+7),c="",l=n*.47;for(let u=0;u<r;u++)for(let h=0;h<r;h++){if(!i[u*r+h]||a(u,h))continue;let m=(h+.5)*n,b=(u+.5)*n;c+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(l)}"/>`;}let d="";for(let[u,h]of s){let m=(h+3.5)*n,b=(u+3.5)*n;d+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(n*3)}" fill="none" stroke="currentColor" stroke-width="${o(n)}"/><circle cx="${o(m)}" cy="${o(b)}" r="${o(n*1.5)}"/>`;}return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" shape-rendering="geometricPrecision" fill="currentColor">${d}${c}</svg>`}function br(t,...e){if(t)try{t(...e);}catch{}}function yS(t,{probe:e}){let[r,i]=Ht("idle"),n=Fr(null);return is(()=>(i("idle"),()=>n.current?.()),[t]),{openState:r,openApp:()=>{if(t){if(n.current?.(),!e){n.current=pu(t);return}i("opening"),n.current=pu(t,s=>i(s?"opened":"nothing-opened"));}}}}var lB={firstname:"first name",lastname:"last name",fullname:"full name",birthdate:"date of birth",age:"age",expiry_date:"ID expiry date",nationality:"nationality",issuing_country:"issuing country",document_number:"document number",document_type:"document type",gender:"gender"},dB=["birthdate","expiry_date"],bS=["nationality","issuing_country"],SS=["firstname","lastname","fullname","gender","birthdate","age","document_type","document_number","nationality","issuing_country","expiry_date"],li={disclose:0,age:1,date:2,country:3,field:4,sanctions:5,facematch:6,bind:7},uB=3,fB={year:"numeric",month:"long",day:"numeric"};function xS(t){return t.toLocaleDateString(void 0,fB)}var pB={passport:"passport",id_card:"ID card",residence_permit:"residence permit"},hB={passport:"a passport",id_card:"an ID card",residence_permit:"a residence permit",other:"another accepted document"};function Wt(t,e){if(e instanceof Date)return xS(e);if(dB.includes(t)&&(typeof e=="string"||typeof e=="number")){let r=new Date(e);if(!Number.isNaN(r.getTime()))return xS(r)}return t==="document_type"&&typeof e=="string"?pB[e]??e.replace(/_/g," "):String(e)}function mB(t,e){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} ${e} ${t[t.length-1]}`}function U2(t){return lB[t]??String(t).replace(/_/g," ")}function AS(t,e,r){let i=U2(t),n=e.map(c=>Wt(t,c)).sort((c,l)=>c.localeCompare(l)),o=bS.includes(t)?li.country:li.field;if(n.length<=uB){let c=r?n.length===1?`is not ${n[0]}`:`is not any of ${n.join(", ")}`:`is ${mB(n,"or")}`;return {title:`Your ${i} ${c}`,group:o}}let s=bS.includes(t)?"countries":"values";return {title:`Your ${i} ${r?"is not any of":"is one of"} these ${n.length} ${s}:`,detail:n.join(", "),group:o}}function gB(t,e,r){let i=U2(t);if(t==="age"){let n=li.age;e.gte!=null&&r.push({title:`You are ${e.gte} or older`,group:n}),e.gt!=null&&r.push({title:`You are over ${e.gt}`,group:n}),e.lte!=null&&r.push({title:`You are ${e.lte} or younger`,group:n}),e.lt!=null&&r.push({title:`You are under ${e.lt}`,group:n}),e.range!=null&&r.push({title:`Your age is between ${e.range[0]} and ${e.range[1]}`,group:n}),e.eq!=null&&r.push({title:`You are ${e.eq} years old`,group:n});return}if(t==="expiry_date"){let n=li.date;(e.gte!=null||e.gt!=null)&&r.push({title:`Your ID is valid until at least ${Wt(t,e.gte??e.gt)}`,group:n}),(e.lte!=null||e.lt!=null)&&r.push({title:`Your ID expires before ${Wt(t,e.lte??e.lt)}`,group:n}),e.range!=null&&r.push({title:`Your ID expires between ${Wt(t,e.range[0])} and ${Wt(t,e.range[1])}`,group:n}),e.eq!=null&&r.push({title:`Your ID expires on ${Wt(t,e.eq)}`,group:n});return}if(t==="birthdate"){let n=li.date;(e.gte!=null||e.gt!=null)&&r.push({title:`You were born after ${Wt(t,e.gte??e.gt)}`,group:n}),(e.lte!=null||e.lt!=null)&&r.push({title:`You were born before ${Wt(t,e.lte??e.lt)}`,group:n}),e.range!=null&&r.push({title:`You were born between ${Wt(t,e.range[0])} and ${Wt(t,e.range[1])}`,group:n}),e.eq!=null&&r.push({title:`Your date of birth is ${Wt(t,e.eq)}`,group:n});return}e.eq!=null&&r.push({title:t==="document_type"?`Your ID is ${hB[String(e.eq)]??Wt(t,e.eq)}`:`Your ${i} is ${Wt(t,e.eq)}`,group:li.field}),e.in!=null&&r.push(AS(t,e.in,false)),e.out!=null&&r.push(AS(t,e.out,true));}function yB(t){return t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function bB(t){let{user_address:e,chain:r,custom_data:i}=t,n="Bound to",o=[];if(r&&o.push({label:"Chain",value:yB(r)}),e&&o.push({label:"Wallet",value:e}),i!=null){let s=typeof i=="string"?i:JSON.stringify(i);if(o.length===0)return {note:n,title:s};o.push({label:"Data",value:s});}return o.length===0?{note:n,title:"This site"}:{note:n,title:"",rows:o}}function SB(t){let e=i=>{let n=SS.indexOf(i);return n===-1?SS.length:n};return (t.includes("fullname")?t.filter(i=>i!=="firstname"&&i!=="lastname"):t).map(i=>({title:`Share your ${U2(i)}`,group:li.disclose,order:e(i)}))}function wS(t){if(!t)return [];let e=[],r=[];for(let[i,n]of Object.entries(t)){if(n==null)continue;if(i==="sanctions"){e.push({title:"You are not on any sanctions list",group:li.sanctions});continue}if(i==="facematch"){e.push({title:"Your face matches your ID photo",group:li.facematch});continue}if(i==="bind"){e.push({...bB(n),group:li.bind});continue}if(i==="policy")continue;let o=i;n.disclose&&r.push(o),gB(o,n,e);}return e.push(...SB(r)),e.length===0?[{title:"You hold a valid, unexpired passport or ID card"}]:e.map((i,n)=>({entry:i,index:n})).sort((i,n)=>i.entry.group-n.entry.group||(i.entry.order??0)-(n.entry.order??0)||i.index-n.index).map(({entry:{group:i,order:n,...o}})=>o)}function qd(){if(typeof navigator>"u"||typeof window>"u")return false;if(navigator.userAgentData?.mobile)return true;let e=navigator.userAgent;return !!(/Android|iPhone|iPod|Mobile|IEMobile/i.test(e)||/iPad/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)}function Gd(){if(typeof navigator>"u")return false;let t=navigator.userAgent;return /FBAN|FBAV|FB_IAB|Instagram|Twitter|TwitterAndroid|Discord|Snapchat|TikTok|BytedanceWebview|musical_ly|Line\/|MicroMessenger|GSA\/|LinkedInApp|Pinterest/i.test(t)||/Android/.test(t)&&/; wv\)/.test(t)?true:xB()?false:!!(/iPhone|iPad|iPod/.test(t)&&/AppleWebKit/.test(t)&&!/Safari\//.test(t))}function xB(){return navigator.standalone===true}var AB=0;function U(t,e,r,i,n,o){e||(e={});var s,a,c=e;if("ref"in c)for(a in c={},e)a=="ref"?s=e[a]:c[a]=e[a];var l={type:t,props:c,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--AB,__i:-1,__u:0,__source:n,__self:o};if(typeof t=="function"&&(s=t.defaultProps))for(a in s)c[a]===void 0&&(c[a]=s[a]);return Ce.vnode&&Ce.vnode(l),l}function _S({options:t,controlRef:e}){fm(NB,[]);let{state:r,url:i,qrSvg:n,query:o,serviceName:s,serviceLogo:a,retry:c,continueWithPhone:l,proofProgress:d}=gS(t);is(()=>{if(e)return e.current={retry:c},()=>{e.current=null;}},[c,e]);let u=t.display?.header??true,h=t.display?.steps??true,m=t.display?.appLinks??true,b=t.display?.frame??true,A=t.name??s??t.domain??"",x=t.logo??a??"",y=r==="scanned"||r==="generating"||r==="success"||r==="error",w=!!o?.facematch,I=vB(r),_=r==="waiting"||r==="scanned",[C,v]=Ht(false),T=qd(),G=Gd(),F=r==="preparing"||r==="connecting"||r==="waiting",H=T&&F&&!C,k=EB(r,y,w,d,T&&!C);return U("div",{className:"zkp-card","data-state":r,"data-theme":t.theme??"auto","data-frame":b?void 0:"none",children:[_?U("button",{type:"button",className:"zkp-restart","aria-label":"Restart verification",title:"Restart verification",onClick:c,dangerouslySetInnerHTML:{__html:Am}}):null,u?U(xr,{children:[U("div",{className:"zkp-header",children:[U("div",{className:"zkp-header-icons",children:[U("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:ka}}),x?U(xr,{children:[U("div",{className:"zkp-header-dots",children:[U("span",{}),U("span",{}),U("span",{})]}),U("div",{className:"zkp-app-icon-slot",children:U("img",{className:"zkp-app-icon",src:x,alt:A?`${A} icon`:""})})]}):null]}),U("p",{className:"zkp-title",children:[U("strong",{children:A||"This app"})," uses ",U("strong",{children:"ZKPassport"})," to verify identity without compromising your privacy."]})]}),U("div",{className:"zkp-divider zkp-divider-header"})]}):null,r==="intro"?U(IB,{appName:A||"This app",items:wS(o),purpose:t.purpose,loading:o===null,onContinue:l}):U("div",{className:"zkp-screen",children:[H?U(kB,{requestUrl:r==="waiting"?i:null,inAppBrowser:G,onRevealQr:()=>v(true)}):U(BB,{state:r,qrSvg:n,caption:I}),T&&C&&F?U("button",{type:"button",className:"zkp-qr-reveal zkp-qr-back",onClick:()=>v(false),children:"Open the ZKPassport app instead"}):null,h&&k.length>0?U(xr,{children:[U("div",{className:"zkp-divider zkp-divider-top"}),U("div",{className:"zkp-steps",children:k.map(E=>U(TB,{status:E.status,icon:E.icon,children:E.label},E.key))})]}):null,m&&!H?U("div",{className:`zkp-collapse${y?" zkp-collapse-out":""}`,children:U("div",{className:"zkp-collapse-inner",children:[U("div",{className:"zkp-divider zkp-divider-bottom"}),U("div",{className:"zkp-footer",children:[U("span",{className:"zkp-footer-label",children:"ZKPassport App"}),U("div",{className:"zkp-store-buttons",children:[U($d,{href:Jc,badge:uu}),U($d,{href:ns,badge:fu})]})]})]})}):null,r==="error"?U("div",{className:"zkp-result-actions",children:U("button",{type:"button",className:"zkp-retry",onClick:c,children:"Try again"})}):null]})]})}var wB=2;function _B({item:t}){return U("li",{className:"zkp-intro-note",children:[U("span",{className:"zkp-intro-note-label",children:t.note}),t.rows?U("dl",{className:"zkp-intro-note-rows",children:t.rows.map(e=>U("div",{children:[U("dt",{children:e.label}),U("dd",{children:e.value})]},e.label))}):U("span",{className:"zkp-intro-note-text",children:t.title}),t.detail?U("span",{className:"zkp-intro-item-detail",children:t.detail}):null]})}var CB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 32" fill="currentColor" aria-hidden="true"><circle cx="27.5033" cy="15.722" r="7.48372"/><path d="M55.1719 31.4604H0V17.3281H17.0845C17.857 22.3884 22.2278 26.265 27.504 26.265C32.7802 26.265 37.151 22.3884 37.9235 17.3281H55.1719V31.4604Z"/><path d="M55.1719 14.1192H37.9236C37.1511 9.05887 32.7803 5.18223 27.504 5.18223C22.2278 5.18223 17.857 9.05887 17.0845 14.1192H0V0H55.1719V14.1192Z"/></svg>';function IB({appName:t,items:e,purpose:r,loading:i,onContinue:n}){return U("div",{className:"zkp-intro",children:[U("div",{className:"zkp-intro-request",children:[U("p",{className:"zkp-eyebrow",children:[t," wants to verify"]}),i?U("ul",{className:"zkp-intro-list",role:"status","aria-label":"Loading request",children:Array.from({length:wB},(o,s)=>U("li",{children:[U("span",{className:"zkp-intro-check zkp-skel-check"}),U("span",{className:"zkp-intro-item",children:U("span",{className:"zkp-intro-item-title zkp-skel-text",children:U("span",{className:"zkp-skel-bar",style:{width:"80%"}})})})]},s))}):U("ul",{className:"zkp-intro-list",children:e.map((o,s)=>o.note?U(_B,{item:o},s):U("li",{children:[U("span",{className:"zkp-intro-check",dangerouslySetInnerHTML:{__html:os}}),U("span",{className:"zkp-intro-item",children:[U("span",{className:"zkp-intro-item-title",children:o.title}),o.detail?U("span",{className:"zkp-intro-item-detail",children:o.detail}):null]})]},s))}),r&&!i?U("p",{className:"zkp-intro-purpose",children:[U("span",{className:"zkp-intro-purpose-label",children:"Purpose"}),r]}):null]}),U("div",{className:"zkp-intro-question",children:[U("span",{className:"zkp-chip-symbol","aria-hidden":"true",dangerouslySetInnerHTML:{__html:CB}}),U("p",{className:"zkp-intro-question-text",children:"Do you have a passport or ID with a chip?"}),U("p",{className:"zkp-intro-question-hint",children:"Look for this symbol on your passport or ID card. Your phone reads the chip over NFC."}),U("button",{type:"button",className:"zkp-intro-continue",onClick:n,children:"Continue"})]}),U("div",{className:"zkp-intro-footer",children:[U("div",{className:"zkp-divider"}),U("p",{className:"zkp-intro-footer-note",children:"Your ID data never leaves your device."}),U("div",{className:"zkp-privacy-strip","aria-label":"Private, encrypted, on your device",children:[U("span",{children:"Private"}),U("span",{className:"zkp-privacy-dot","aria-hidden":"true",children:"\xB7"}),U("span",{children:"Encrypted"}),U("span",{className:"zkp-privacy-dot","aria-hidden":"true",children:"\xB7"}),U("span",{children:"On your device"})]})]})]})}function vB(t){switch(t){case "scanned":return "Approve the request on your phone";case "generating":return "Generating proof\u2026";case "success":return "Request complete";case "error":return "Something went wrong";default:return ""}}function EB(t,e,r,i,n){let o=t==="success",s=t==="generating",{received:a,total:c}=i,l=c!==null&&a>=c,d=e?"done":"pending",u=[{key:"download",label:U(xr,{children:[U("a",{href:mm,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),status:d,icon:e?null:bm},{key:"scan",label:n?"Tap \u201COpen ZKPassport App\u201D above.":"Scan this QR code with the ZKPassport app.",status:d,icon:e?null:gm},{key:"approve",label:"Approve the request on your phone.",status:t==="scanned"?"current":s||o?"done":"pending",icon:e?null:ym}];return r&&u.push({key:"selfie",label:"Take a selfie to match your ID photo.",status:s&&a===0?"current":s&&a>0||o?"done":"pending",icon:null}),u.push({key:"generate",label:s&&c!==null?`Generate proof on your device (${Math.min(a,c)}/${c}).`:"Generate proof on your device.",status:s&&!l&&(!r||a>0)?"current":s&&l||o?"done":"pending",icon:null},{key:"verify",label:"Verify the proof.",status:s&&l?"current":o?"done":"pending",icon:null}),e?u:u.slice(0,3)}function BB({state:t,qrSvg:e,caption:r}){return U("div",{className:"zkp-qr-slot","data-state":t,children:[U("div",{className:"zkp-skeleton"}),U("div",{className:"zkp-qr",dangerouslySetInnerHTML:e?{__html:e}:void 0}),e?U("div",{className:"zkp-qr-logo",dangerouslySetInnerHTML:{__html:ka}}):null,U("div",{className:"zkp-overlay",children:[U("div",{className:"zkp-overlay-body",children:[t==="connecting"||t==="generating"?U("div",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:du}}):null,t==="scanned"?U("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:xm}}):null,t==="success"?U("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:os}}):null,t==="error"?U("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:Sm}}):null]}),r?U("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function TB({status:t,icon:e,children:r}){return U("div",{className:"zkp-step","data-status":t,"data-mode":e?"icon":"progress",children:[U("div",{className:"zkp-step-marker",dangerouslySetInnerHTML:{__html:e??os}}),U("div",{className:"zkp-step-text",children:r})]})}function kB({requestUrl:t,inAppBrowser:e,onRevealQr:r}){let{openState:i,openApp:n}=yS(t,{probe:!e}),o=i==="opening";return i==="opened"?U("div",{className:"zkp-open-app-hero","data-state":i,children:[U("p",{className:"zkp-inapp-hint",role:"status",children:"Check your phone \u2014 approve the request in the ZKPassport app."}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:n,children:"Open the app again"}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:r,children:"Scan a QR code with another device instead"})]}):U("div",{className:"zkp-open-app-hero","data-state":i,children:[t?U("button",{type:"button",className:"zkp-open-app zkp-open-app-block",disabled:o,onClick:n,children:[o?U("span",{className:"zkp-spinner",dangerouslySetInnerHTML:{__html:du}}):null,o?"Opening\u2026":"Open ZKPassport App"]}):U("div",{className:"zkp-open-app-loading",role:"status","aria-label":"Preparing request",children:U("span",{className:"zkp-skel-row",style:{width:"100%",height:"48px"}})}),e?U("p",{className:"zkp-inapp-hint",children:"If nothing opens, open this page in your browser and try again."}):null,U(PB,{requestUrl:t,appNotFound:i==="nothing-opened"}),U("button",{type:"button",className:"zkp-qr-reveal",onClick:r,children:"Scan a QR code with another device instead"})]})}function PB({requestUrl:t,appNotFound:e}){let r=Cm();return U("div",{className:"zkp-install",children:[U("p",{className:"zkp-install-title",role:e?"status":void 0,children:e?"App not found":"Don\u2019t have the app yet?"}),U("p",{className:"zkp-install-note",children:e?"Install the ZKPassport app, then tap Open again. It reads the chip in your passport or ID card, and that data never leaves your phone.":"Verification happens in the ZKPassport app: it reads the chip in your passport or ID card, and that data never leaves your phone. Free on iOS and Android."}),U("div",{className:"zkp-store-buttons zkp-install-stores",children:[r!=="android"?U($d,{href:Jc,badge:uu}):null,r!=="ios"?U($d,{href:_m(t),badge:fu}):null]})]})}function $d({href:t,badge:e}){return U("a",{className:"zkp-store-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":e.ariaLabel,dangerouslySetInnerHTML:{__html:e.svg}})}function NB(){e1(Im,"card");}var CS=`@layer zkpassport {
|
|
1031
1031
|
/* "Verify with ZKPassport" button (opens the hosted popup).
|
|
1032
1032
|
Customize via CSS custom properties on the mount element or any ancestor:
|
|
1033
1033
|
--zkp-btn-bg/-fg/-border-color/-radius/-padding/-font/-font-size/-letter-spacing/
|