@zkpassport/ui 0.19.1 → 0.19.2

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.
@@ -1026,7 +1026,7 @@ ${e.join(`
1026
1026
  `).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 zA(t){return /\r\n/.test(t)?`\r
1027
1027
  `:`
1028
1028
  `}function B3(t,e={}){let r=[],i=e.label,n;for(v3.lastIndex=0;n=v3.exec(t);){let o=n[1].trim();if(i&&o!==i)continue;E3(o);let s=KA(n[2]);r.push({label:o,data:pn.decode(s.base64Text),headers:s.headers,lineLength:s.base64Lines[0]?.length??64,newline:zA(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={}){E3(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??`
1029
- `,o=[`-----BEGIN ${t}-----`];if(r.headers){for(let[s,a]of Object.entries(r.headers))o.push(`${s}: ${a}`);o.push("");}return o.push(...HA(pn.encode(e),i)),o.push(`-----END ${t}-----`),`${o.join(n)}${n}`}function T3(t,e={}){return B3(t,e).map(({lineLength:r,newline:i,...n})=>n)}function k3(t,e){let[r]=T3(t,{label:e,strict:true});return r.data}function P3(t,e={}){let[r]=B3(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 N3(t,e){return dl(e.label,t,e)}var p0={name:"pem",encode:(t,e)=>{if(!e?.label)throw new TypeError("PEM label is required");return dl(e.label,t,e)},decode:(t,e)=>k3(t,e?.label),format:N3,is:t=>typeof t=="string"&&/-----BEGIN [^-]+-----/.test(t),parse:P3};function jr(t){return t.trim().toLowerCase()}function qA(t){return t instanceof Error?t:new Error(String(t))}function R3(t,e,r){for(let i of [r.name,...r.aliases??[]])t.delete(jr(i));e.delete(jr(r.name));}function Tf(t,e,r){let i=t[r];if(typeof i!="function")throw new Error(`Converter '${e}' does not support ${r}()`);return i}function GA(t,e,r){let i=jr(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 kf(t=[]){let e=new Map,r=new Set,i={register(n,o={}){if(!n.name||!jr(n.name))throw new TypeError("Converter name is required");let s=[...new Set([n.name,...n.aliases??[]].map(jr))],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)R3(e,r,c);for(let c of s)e.set(c,n);return r.add(jr(n.name)),this},unregister(n){let o=e.get(jr(n));return o?(R3(e,r,o),true):false},has(n){return e.has(jr(n))},get(n){let o=e.get(jr(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:qA(a)}}},normalize(n,o,s){let a=this.get(n);return Tf(a,n,"normalize").call(a,o,s)},parse(n,o,s){let a=this.get(n);return Tf(a,n,"parse").call(a,o,s)},format(n,o,s){let a=this.get(n);return Tf(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(jr(c))),a=new Map;for(let c of s){let l=this.get(c),d=GA(c,n,l);if(d<=0)continue;let u=l.name,p=a.get(u);(!p||d>p.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 D3={name:"binary",aliases:["latin1"],encode:Ii.encode,decode:Ii.decode,is:Ii.is},O3={name:"hex",encode:tt.encode,decode:tt.decode,format:tt.format,is:tt.is,normalize:tt.normalize,parse:tt.parse},M3={name:"base64",aliases:["b64"],encode:er.encode,decode:er.decode,is:er.is,normalize:er.normalize},U3={name:"base64url",aliases:["base64-url","b64url"],encode:vr.encode,decode:vr.decode,is:vr.is,normalize:vr.normalize},F3={name:"utf8",aliases:["utf-8"],encode:t=>fn.decode(t),decode:t=>fn.encode(t),is:t=>typeof t=="string"},L3={name:"utf16be",aliases:["utf16","utf-16","utf-16be"],encode:t=>Vr.decode(t),decode:t=>Vr.encode(t),is:t=>typeof t=="string"},H3={name:"utf16le",aliases:["utf-16le","ucs2","usc2"],encode:t=>Vr.decode(t,{littleEndian:true}),decode:t=>Vr.encode(t,{littleEndian:true}),is:t=>typeof t=="string"},K3=[D3,O3,M3,U3,F3,L3,H3,p0];kf(K3);({toBase64:er.encode,toBase64Url:vr.encode,toHex:tt.encode,toBinary:Ii.encode,toUtf8String:fn.decode,isHex:tt.is,isBase64:er.is,isBase64Url:vr.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 vi=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($r(e))this.unusedBits=r,this.value=Ae(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Ir))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=Ae(e.valueBlock.valueHex),this}toASN(){return new Ir({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Ir({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):$r(e)?this.buffer=Ae(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 Cr))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=Ae(e.valueBlock.valueHex),this}toASN(){return new Cr({valueHex:this.buffer})}toSchema(e){return new Cr({name:e})}};var QA={fromASN:t=>t instanceof _r?null:Ae(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new _r;let e=Ci(t);if(e.result.error)throw new Error(e.result.error);return e.result}},JA={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Ai({value:+t})},e_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ro({value:t})},he={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Ai({valueHex:t})};var t_={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Ir({valueHex:t})},r_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new io({value:t})},i_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new no({value:t})},n_={fromASN:t=>t.valueBlock.value,toASN:t=>new to({value:t})},As={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Cr({valueHex:t})},q3={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 o_=tr(Jt),s_=tr(oo),a_=tr(so),c_=tr(ao),l_=tr(co),d_=tr(lo),u_=tr(uo),f_=tr(fo),p_=tr(po),h_=tr(dn),m_=tr(ho),g_=tr(mo),y_={fromASN:t=>t.toDate(),toASN:t=>new un({valueDate:t})},b_={fromASN:t=>t.toDate(),toASN:t=>new go({valueDate:t})},S_={fromASN:()=>null,toASN:()=>new _r};function hn(t){switch(t){case S.Any:return QA;case S.BitString:return t_;case S.BmpString:return s_;case S.Boolean:return n_;case S.CharacterString:return g_;case S.Enumerated:return e_;case S.GeneralString:return m_;case S.GeneralizedTime:return b_;case S.GraphicString:return p_;case S.IA5String:return f_;case S.Integer:return JA;case S.Null:return S_;case S.NumericString:return c_;case S.ObjectIdentifier:return r_;case S.RelativeObjectIdentifier:return i_;case S.OctetString:return As;case S.PrintableString:return l_;case S.TeletexString:return d_;case S.UTCTime:return y_;case S.UniversalString:return a_;case S.Utf8String:return o_;case S.VideotexString:return u_;case S.VisibleString:return h_;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 Df(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?true:Df(e)}return false}function G3(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=Gr[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 Kr({name:a}):(c=this.create(s.type,false),c.name=a):c=new Kr({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 yo({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 y=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=hn(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 mn=class extends Error{constructor(){super(...arguments);f(this,"schemas",[]);}};var _s=class{static parse(e,r,i){let n=Ci(Ae(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 Df(r)?this.handleArrayTypes(e,n,r,i):(this.processSchemaItems(n,a,c,i),c)}catch(n){throw n instanceof mn&&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=Si({},e,n);if(!o.verified)throw new mn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else {let o=Si({},e,n);if(!o.verified)throw new mn(`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=hn(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=hn(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 mn&&/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=hn(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=Ci(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=Gr[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);a=new l;}a.valueBlock=s.valueBlock,s=Ci(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 mn&&/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 Cs=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=hn(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"&&G3(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 _r?Ae(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 Cs.serialize(e)}static parse(e,r,i){return _s.parse(e,r,i)}static toString(e,r){let i=$r(e)?Ae(e):t.serialize(e),n=Ci(i,r?.berOptions);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function h(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 h0=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 Of,Mf,Uf,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||""}};h([y({type:S.TeletexString})],nr.prototype,"teletexString",void 0);h([y({type:S.PrintableString})],nr.prototype,"printableString",void 0);h([y({type:S.UniversalString})],nr.prototype,"universalString",void 0);h([y({type:S.Utf8String})],nr.prototype,"utf8String",void 0);h([y({type:S.BmpString})],nr.prototype,"bmpString",void 0);nr=h([N({type:B.Choice})],nr);var Is=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())}};h([y({type:S.IA5String})],Is.prototype,"ia5String",void 0);h([y({type:S.Any})],Is.prototype,"anyValue",void 0);Is=h([N({type:B.Choice})],Is);var m0=class{constructor(e={}){f(this,"type","");f(this,"value",new Is);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],m0.prototype,"type",void 0);h([y({type:Is})],m0.prototype,"value",void 0);var g0=Of=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Of.prototype);}};g0=Of=h([N({type:B.Set,itemType:m0})],g0);var Ff=Mf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Mf.prototype);}};Ff=Mf=h([N({type:B.Sequence,itemType:g0})],Ff);var xt=Uf=class extends Ff{constructor(e){super(e),Object.setPrototypeOf(this,Uf.prototype);}};xt=Uf=h([N({type:B.Sequence})],xt);var x_={fromASN:t=>h0.toString(As.fromASN(t)),toASN:t=>As.toASN(h0.fromString(t))},y0=class{constructor(e={}){f(this,"typeId","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],y0.prototype,"typeId",void 0);h([y({type:S.Any,context:0})],y0.prototype,"value",void 0);var b0=class{constructor(e={}){f(this,"nameAssigner");f(this,"partyName",new nr);Object.assign(this,e);}};h([y({type:nr,optional:true,context:0,implicit:true})],b0.prototype,"nameAssigner",void 0);h([y({type:nr,context:1,implicit:true})],b0.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);}};h([y({type:y0,context:0,implicit:true})],ue.prototype,"otherName",void 0);h([y({type:S.IA5String,context:1,implicit:true})],ue.prototype,"rfc822Name",void 0);h([y({type:S.IA5String,context:2,implicit:true})],ue.prototype,"dNSName",void 0);h([y({type:S.Any,context:3,implicit:true})],ue.prototype,"x400Address",void 0);h([y({type:xt,context:4,implicit:false})],ue.prototype,"directoryName",void 0);h([y({type:b0,context:5})],ue.prototype,"ediPartyName",void 0);h([y({type:S.IA5String,context:6,implicit:true})],ue.prototype,"uniformResourceIdentifier",void 0);h([y({type:S.OctetString,context:7,implicit:true,converter:x_})],ue.prototype,"iPAddress",void 0);h([y({type:S.ObjectIdentifier,context:8,implicit:true})],ue.prototype,"registeredID",void 0);ue=h([N({type:B.Choice})],ue);var Lf,So=class{constructor(e={}){f(this,"accessMethod","");f(this,"accessLocation",new ue);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],So.prototype,"accessMethod",void 0);h([y({type:ue})],So.prototype,"accessLocation",void 0);var V3=Lf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Lf.prototype);}};V3=Lf=h([N({type:B.Sequence,itemType:So})],V3);var S0=class extends ce{},vs=class{constructor(e={}){f(this,"keyIdentifier");f(this,"authorityCertIssuer");f(this,"authorityCertSerialNumber");e&&Object.assign(this,e);}};h([y({type:S0,context:0,optional:true,implicit:true})],vs.prototype,"keyIdentifier",void 0);h([y({type:ue,context:1,optional:true,implicit:true,repeated:"sequence"})],vs.prototype,"authorityCertIssuer",void 0);h([y({type:S.Integer,context:2,optional:true,implicit:true,converter:he})],vs.prototype,"authorityCertSerialNumber",void 0);var pl=class{constructor(e={}){f(this,"cA",false);f(this,"pathLenConstraint");Object.assign(this,e);}};h([y({type:S.Boolean,defaultValue:false})],pl.prototype,"cA",void 0);h([y({type:S.Integer,optional:true})],pl.prototype,"pathLenConstraint",void 0);var Hf,Xe=Hf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Hf.prototype);}};Xe=Hf=h([N({type:B.Sequence,itemType:ue})],Xe);var Kf,j3=Kf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Kf.prototype);}};j3=Kf=h([N({type:B.Sequence})],j3);var zf,Ei=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||""}};h([y({type:S.IA5String})],Ei.prototype,"ia5String",void 0);h([y({type:S.VisibleString})],Ei.prototype,"visibleString",void 0);h([y({type:S.BmpString})],Ei.prototype,"bmpString",void 0);h([y({type:S.Utf8String})],Ei.prototype,"utf8String",void 0);Ei=h([N({type:B.Choice})],Ei);var x0=class{constructor(e={}){f(this,"organization",new Ei);f(this,"noticeNumbers",[]);Object.assign(this,e);}};h([y({type:Ei})],x0.prototype,"organization",void 0);h([y({type:S.Integer,repeated:"sequence"})],x0.prototype,"noticeNumbers",void 0);var w0=class{constructor(e={}){f(this,"noticeRef");f(this,"explicitText");Object.assign(this,e);}};h([y({type:x0,optional:true})],w0.prototype,"noticeRef",void 0);h([y({type:Ei,optional:true})],w0.prototype,"explicitText",void 0);var hl=class{constructor(e={}){f(this,"cPSuri");f(this,"userNotice");Object.assign(this,e);}};h([y({type:S.IA5String})],hl.prototype,"cPSuri",void 0);h([y({type:w0})],hl.prototype,"userNotice",void 0);hl=h([N({type:B.Choice})],hl);var A0=class{constructor(e={}){f(this,"policyQualifierId","");f(this,"qualifier",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],A0.prototype,"policyQualifierId",void 0);h([y({type:S.Any})],A0.prototype,"qualifier",void 0);var _0=class{constructor(e={}){f(this,"policyIdentifier","");f(this,"policyQualifiers");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],_0.prototype,"policyIdentifier",void 0);h([y({type:A0,repeated:"sequence",optional:true})],_0.prototype,"policyQualifiers",void 0);var X3=zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,zf.prototype);}};X3=zf=h([N({type:B.Sequence,itemType:_0})],X3);var C0=class{constructor(e=0){f(this,"value");this.value=e;}};h([y({type:S.Integer})],C0.prototype,"value",void 0);C0=h([N({type:B.Choice})],C0);var W3=class extends C0{};W3=h([N({type:B.Choice})],W3);var qf,Er;(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";})(Er||(Er={}));var I0=class extends vi{toJSON(){let e=[],r=this.toNumber();return r&Er.aACompromise&&e.push("aACompromise"),r&Er.affiliationChanged&&e.push("affiliationChanged"),r&Er.cACompromise&&e.push("cACompromise"),r&Er.certificateHold&&e.push("certificateHold"),r&Er.cessationOfOperation&&e.push("cessationOfOperation"),r&Er.keyCompromise&&e.push("keyCompromise"),r&Er.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Er.superseded&&e.push("superseded"),r&Er.unused&&e.push("unused"),e}toString(){return `[${this.toJSON().join(", ")}]`}},xo=class{constructor(e={}){f(this,"fullName");f(this,"nameRelativeToCRLIssuer");Object.assign(this,e);}};h([y({type:ue,context:0,repeated:"sequence",implicit:true})],xo.prototype,"fullName",void 0);h([y({type:g0,context:1,implicit:true})],xo.prototype,"nameRelativeToCRLIssuer",void 0);xo=h([N({type:B.Choice})],xo);var bn=class{constructor(e={}){f(this,"distributionPoint");f(this,"reasons");f(this,"cRLIssuer");Object.assign(this,e);}};h([y({type:xo,context:0,optional:true})],bn.prototype,"distributionPoint",void 0);h([y({type:I0,context:1,optional:true,implicit:true})],bn.prototype,"reasons",void 0);h([y({type:ue,context:2,optional:true,repeated:"sequence",implicit:true})],bn.prototype,"cRLIssuer",void 0);var ml=qf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,qf.prototype);}};ml=qf=h([N({type:B.Sequence,itemType:bn})],ml);var Gf,Z3=Gf=class extends ml{constructor(e){super(e),Object.setPrototypeOf(this,Gf.prototype);}};Z3=Gf=h([N({type:B.Sequence,itemType:bn})],Z3);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;h([y({type:xo,context:0,optional:true})],or.prototype,"distributionPoint",void 0);h([y({type:S.Boolean,context:1,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsUserCerts",void 0);h([y({type:S.Boolean,context:2,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsCACerts",void 0);h([y({type:I0,context:3,optional:true,implicit:true})],or.prototype,"onlySomeReasons",void 0);h([y({type:S.Boolean,context:4,defaultValue:or.ONLY,implicit:true})],or.prototype,"indirectCRL",void 0);h([y({type:S.Boolean,context:5,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsAttributeCerts",void 0);var v0;(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";})(v0||(v0={}));var $f=class{constructor(e=v0.unspecified){f(this,"reason",v0.unspecified);this.reason=e;}toJSON(){return v0[this.reason]}toString(){return this.toJSON()}};h([y({type:S.Enumerated})],$f.prototype,"reason",void 0);$f=h([N({type:B.Choice})],$f);var Vf,Y3=Vf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Vf.prototype);}};Y3=Vf=h([N({type:B.Sequence,itemType:S.ObjectIdentifier})],Y3);var jf=class{constructor(e=new ArrayBuffer(0)){f(this,"value");this.value=e;}};h([y({type:S.Integer,converter:he})],jf.prototype,"value",void 0);jf=h([N({type:B.Choice})],jf);var Xf=class{constructor(e){f(this,"value",new Date);e&&(this.value=e);}};h([y({type:S.GeneralizedTime})],Xf.prototype,"value",void 0);Xf=h([N({type:B.Choice})],Xf);var Wf,Q3=Wf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Wf.prototype);}};Q3=Wf=h([N({type:B.Sequence})],Q3);var J3;(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";})(J3||(J3={}));var Zf,Es=class{constructor(e={}){f(this,"base",new ue);f(this,"minimum",0);f(this,"maximum");Object.assign(this,e);}};h([y({type:ue})],Es.prototype,"base",void 0);h([y({type:S.Integer,context:0,defaultValue:0,implicit:true})],Es.prototype,"minimum",void 0);h([y({type:S.Integer,context:1,optional:true,implicit:true})],Es.prototype,"maximum",void 0);var gl=Zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Zf.prototype);}};gl=Zf=h([N({type:B.Sequence,itemType:Es})],gl);var yl=class{constructor(e={}){f(this,"permittedSubtrees");f(this,"excludedSubtrees");Object.assign(this,e);}};h([y({type:gl,context:0,optional:true,implicit:true})],yl.prototype,"permittedSubtrees",void 0);h([y({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);}};h([y({type:S.Integer,context:0,implicit:true,optional:true,converter:he})],bl.prototype,"requireExplicitPolicy",void 0);h([y({type:S.Integer,context:1,implicit:true,optional:true,converter:he})],bl.prototype,"inhibitPolicyMapping",void 0);var Yf,E0=class{constructor(e={}){f(this,"issuerDomainPolicy","");f(this,"subjectDomainPolicy","");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],E0.prototype,"issuerDomainPolicy",void 0);h([y({type:S.ObjectIdentifier})],E0.prototype,"subjectDomainPolicy",void 0);var e4=Yf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Yf.prototype);}};e4=Yf=h([N({type:B.Sequence,itemType:E0})],e4);var Qf,t4=Qf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Qf.prototype);}};t4=Qf=h([N({type:B.Sequence})],t4);var Wr=class{constructor(e={}){f(this,"type","");f(this,"values",[]);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Wr.prototype,"type",void 0);h([y({type:S.Any,repeated:"set"})],Wr.prototype,"values",void 0);var Jf,r4=Jf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Jf.prototype);}};r4=Jf=h([N({type:B.Sequence,itemType:Wr})],r4);var Br=class extends S0{};var B0=class{constructor(e={}){f(this,"notBefore");f(this,"notAfter");Object.assign(this,e);}};h([y({type:S.GeneralizedTime,context:0,implicit:true,optional:true})],B0.prototype,"notBefore",void 0);h([y({type:S.GeneralizedTime,context:1,implicit:true,optional:true})],B0.prototype,"notAfter",void 0);var T0;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate";})(T0||(T0={}));var Sl=class extends vi{toJSON(){let e=[],r=this.toNumber();return r&T0.pKIXCertificate&&e.push("pKIXCertificate"),r&T0.newExtensions&&e.push("newExtensions"),r&T0.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);}};h([y({type:S.GeneralString})],xl.prototype,"entrustVers",void 0);h([y({type:Sl})],xl.prototype,"entrustInfoFlags",void 0);var ep,i4=ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,ep.prototype);}};i4=ep=h([N({type:B.Sequence,itemType:So})],i4);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&&u0(e.parameters,this.parameters)||e.parameters===this.parameters)}};h([y({type:S.ObjectIdentifier})],J.prototype,"algorithm",void 0);h([y({type:S.Any,optional:true})],J.prototype,"parameters",void 0);var Ao=class{constructor(e={}){f(this,"algorithm",new J);f(this,"subjectPublicKey",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:J})],Ao.prototype,"algorithm",void 0);h([y({type:S.BitString})],Ao.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}};h([y({type:S.UTCTime})],je.prototype,"utcTime",void 0);h([y({type:S.GeneralizedTime})],je.prototype,"generalTime",void 0);je=h([N({type:B.Choice})],je);var _o=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));}};h([y({type:je})],_o.prototype,"notBefore",void 0);h([y({type:je})],_o.prototype,"notAfter",void 0);var tp,wl=class wl{constructor(e={}){f(this,"extnID","");f(this,"critical",wl.CRITICAL);f(this,"extnValue",new ce);Object.assign(this,e);}};f(wl,"CRITICAL",false);var Zr=wl;h([y({type:S.ObjectIdentifier})],Zr.prototype,"extnID",void 0);h([y({type:S.Boolean,defaultValue:Zr.CRITICAL})],Zr.prototype,"critical",void 0);h([y({type:ce})],Zr.prototype,"extnValue",void 0);var Bs=tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,tp.prototype);}};Bs=tp=h([N({type:B.Sequence,itemType:Zr})],Bs);var k0;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3";})(k0||(k0={}));var wt=class{constructor(e={}){f(this,"version",k0.v1);f(this,"serialNumber",new ArrayBuffer(0));f(this,"signature",new J);f(this,"issuer",new xt);f(this,"validity",new _o);f(this,"subject",new xt);f(this,"subjectPublicKeyInfo",new Ao);f(this,"issuerUniqueID");f(this,"subjectUniqueID");f(this,"extensions");Object.assign(this,e);}};h([y({type:S.Integer,context:0,defaultValue:k0.v1})],wt.prototype,"version",void 0);h([y({type:S.Integer,converter:he})],wt.prototype,"serialNumber",void 0);h([y({type:J})],wt.prototype,"signature",void 0);h([y({type:xt})],wt.prototype,"issuer",void 0);h([y({type:_o})],wt.prototype,"validity",void 0);h([y({type:xt})],wt.prototype,"subject",void 0);h([y({type:Ao})],wt.prototype,"subjectPublicKeyInfo",void 0);h([y({type:S.BitString,context:1,implicit:true,optional:true})],wt.prototype,"issuerUniqueID",void 0);h([y({type:S.BitString,context:2,implicit:true,optional:true})],wt.prototype,"subjectUniqueID",void 0);h([y({type:Bs,context:3,optional:true})],wt.prototype,"extensions",void 0);var $t=class{constructor(e={}){f(this,"tbsCertificate",new wt);f(this,"tbsCertificateRaw");f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:wt,raw:true})],$t.prototype,"tbsCertificate",void 0);h([y({type:J})],$t.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],$t.prototype,"signatureValue",void 0);var Ts=class{constructor(e={}){f(this,"userCertificate",new ArrayBuffer(0));f(this,"revocationDate",new je);f(this,"crlEntryExtensions");Object.assign(this,e);}};h([y({type:S.Integer,converter:he})],Ts.prototype,"userCertificate",void 0);h([y({type:je})],Ts.prototype,"revocationDate",void 0);h([y({type:Zr,optional:true,repeated:"sequence"})],Ts.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);}};h([y({type:S.Integer,optional:true})],sr.prototype,"version",void 0);h([y({type:J})],sr.prototype,"signature",void 0);h([y({type:xt})],sr.prototype,"issuer",void 0);h([y({type:je})],sr.prototype,"thisUpdate",void 0);h([y({type:je,optional:true})],sr.prototype,"nextUpdate",void 0);h([y({type:Ts,repeated:"sequence",optional:true})],sr.prototype,"revokedCertificates",void 0);h([y({type:Zr,optional:true,context:0,repeated:"sequence"})],sr.prototype,"crlExtensions",void 0);var P0=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);}};h([y({type:sr,raw:true})],P0.prototype,"tbsCertList",void 0);h([y({type:J})],P0.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],P0.prototype,"signature",void 0);var N0=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 R0=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 p=l;p=this.primeField.add(p,u);let m=c;m=this.primeField.add(m,d),e[o]=p,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 rp(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 n4=[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")],o4=[[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")]],s4=[[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 __=new N0(BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")),ip=null;function ar(){return ip||(ip=new R0(rp(4,5,8,56,n4,o4,s4),__)),ip}ar().primeField;ar().permute.bind(ar());var a4;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(a4||(a4={}));var C_=ar().primeField,I_=ar().permute.bind(ar()),Tr;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(Tr||(Tr={}));var np=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=Tr.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]=C_.add(this.state[e],this.cache[e]);return this.state=I_(this.state),await Promise.resolve(),this.state.slice(0,this.rate)}async absorb(e){this.mode===Tr.ABSORB&&this.cacheSize===this.rate?(await this.performDuplex(),this.cache[0]=e,this.cacheSize=1):this.mode===Tr.ABSORB&&this.cacheSize<this.rate?(this.cache[this.cacheSize]=e,this.cacheSize+=1):this.mode===Tr.SQUEEZE&&(this.cache[0]=e,this.cacheSize=1,this.mode=Tr.ABSORB);}async squeeze(){if(this.mode===Tr.SQUEEZE&&this.cacheSize===0&&(this.mode=Tr.ABSORB,this.cacheSize=0),this.mode===Tr.ABSORB){let r=await this.performDuplex();this.mode=Tr.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 np.hashFixedLength(t))[0]}ar().primeField;It(Il(),1);It(Il(),1);var B4="1.2.840.10045.4.1",T4="1.2.840.10045.4.3.1",k4="1.2.840.10045.4.3.2",P4="1.2.840.10045.4.3.3",N4="1.2.840.10045.4.3.4";function O0(t){return new J({algorithm:t})}O0(B4);O0(T4);O0(k4);O0(P4);O0(N4);var M0=class{constructor(e={}){f(this,"fieldType");f(this,"parameters");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],M0.prototype,"fieldType",void 0);h([y({type:S.Any})],M0.prototype,"parameters",void 0);M0=h([N({type:B.Sequence})],M0);var mp=class extends ce{};var Ds=class{constructor(e={}){f(this,"a");f(this,"b");f(this,"seed");Object.assign(this,e);}};h([y({type:S.OctetString})],Ds.prototype,"a",void 0);h([y({type:S.OctetString})],Ds.prototype,"b",void 0);h([y({type:S.BitString,optional:true})],Ds.prototype,"seed",void 0);Ds=h([N({type:B.Sequence})],Ds);var gp;(function(t){t[t.ecpVer1=1]="ecpVer1";})(gp||(gp={}));var Jr=class{constructor(e={}){f(this,"version",gp.ecpVer1);f(this,"fieldID");f(this,"curve");f(this,"base");f(this,"order");f(this,"cofactor");Object.assign(this,e);}};h([y({type:S.Integer})],Jr.prototype,"version",void 0);h([y({type:M0})],Jr.prototype,"fieldID",void 0);h([y({type:Ds})],Jr.prototype,"curve",void 0);h([y({type:mp})],Jr.prototype,"base",void 0);h([y({type:S.Integer,converter:he})],Jr.prototype,"order",void 0);h([y({type:S.Integer,optional:true})],Jr.prototype,"cofactor",void 0);Jr=h([N({type:B.Sequence})],Jr);var xn=class{constructor(e={}){f(this,"namedCurve");f(this,"implicitCurve");f(this,"specifiedCurve");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],xn.prototype,"namedCurve",void 0);h([y({type:S.Null})],xn.prototype,"implicitCurve",void 0);h([y({type:Jr})],xn.prototype,"specifiedCurve",void 0);xn=h([N({type:B.Choice})],xn);var Os=class{constructor(e={}){f(this,"version",1);f(this,"privateKey",new ce);f(this,"parameters");f(this,"publicKey");Object.assign(this,e);}};h([y({type:S.Integer})],Os.prototype,"version",void 0);h([y({type:ce})],Os.prototype,"privateKey",void 0);h([y({type:xn,context:0,optional:true})],Os.prototype,"parameters",void 0);h([y({type:S.BitString,context:1,optional:true})],Os.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);}};h([y({type:S.Integer,converter:he})],vl.prototype,"r",void 0);h([y({type:S.Integer,converter:he})],vl.prototype,"s",void 0);var Pt="1.2.840.113549.1.1",R4=`${Pt}.1`,D4=`${Pt}.7`,O4=`${Pt}.9`,M4=`${Pt}.10`,U4=`${Pt}.2`,F4=`${Pt}.4`,L4=`${Pt}.5`;var H4=`${Pt}.12`,K4=`${Pt}.13`,yp=`${Pt}.15`,bp=`${Pt}.16`,z4="1.3.14.3.2.26",q4="2.16.840.1.101.3.4.2.4",G4="2.16.840.1.101.3.4.2.1",$4="2.16.840.1.101.3.4.2.2",V4="2.16.840.1.101.3.4.2.3",j4="2.16.840.1.101.3.4.2.5",X4="2.16.840.1.101.3.4.2.6",W4="1.2.840.113549.2.2",Z4="1.2.840.113549.2.5",Ms=`${Pt}.8`;function We(t){return new J({algorithm:t,parameters:null})}We(W4);We(Z4);var Ti=We(z4);We(q4);We(G4);We($4);We(V4);We(j4);We(X4);var El=new J({algorithm:Ms,parameters:ir.serialize(Ti)}),Sp=new J({algorithm:O4,parameters:ir.serialize(As.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(R4);We(U4);We(F4);We(L4);We(yp);We(bp);We(H4);We(K4);We(yp);We(bp);var Us=class{constructor(e={}){f(this,"hashAlgorithm",new J(Ti));f(this,"maskGenAlgorithm",new J({algorithm:Ms,parameters:ir.serialize(Ti)}));f(this,"pSourceAlgorithm",new J(Sp));Object.assign(this,e);}};h([y({type:J,context:0,defaultValue:Ti})],Us.prototype,"hashAlgorithm",void 0);h([y({type:J,context:1,defaultValue:El})],Us.prototype,"maskGenAlgorithm",void 0);h([y({type:J,context:2,defaultValue:Sp})],Us.prototype,"pSourceAlgorithm",void 0);new J({algorithm:D4,parameters:ir.serialize(new Us)});var wn=class{constructor(e={}){f(this,"hashAlgorithm",new J(Ti));f(this,"maskGenAlgorithm",new J({algorithm:Ms,parameters:ir.serialize(Ti)}));f(this,"saltLength",20);f(this,"trailerField",1);Object.assign(this,e);}};h([y({type:J,context:0,defaultValue:Ti})],wn.prototype,"hashAlgorithm",void 0);h([y({type:J,context:1,defaultValue:El})],wn.prototype,"maskGenAlgorithm",void 0);h([y({type:S.Integer,context:2,defaultValue:20})],wn.prototype,"saltLength",void 0);h([y({type:S.Integer,context:3,defaultValue:1})],wn.prototype,"trailerField",void 0);new J({algorithm:M4,parameters:ir.serialize(new wn)});var Bl=class{constructor(e={}){f(this,"digestAlgorithm",new J);f(this,"digest",new ce);Object.assign(this,e);}};h([y({type:J})],Bl.prototype,"digestAlgorithm",void 0);h([y({type:ce})],Bl.prototype,"digest",void 0);var xp,Fs=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);}};h([y({type:S.Integer,converter:he})],Fs.prototype,"prime",void 0);h([y({type:S.Integer,converter:he})],Fs.prototype,"exponent",void 0);h([y({type:S.Integer,converter:he})],Fs.prototype,"coefficient",void 0);var Tl=xp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,xp.prototype);}};Tl=xp=h([N({type:B.Sequence,itemType:Fs})],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);}};h([y({type:S.Integer})],lr.prototype,"version",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"modulus",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"publicExponent",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"privateExponent",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"prime1",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"prime2",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"exponent1",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"exponent2",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"coefficient",void 0);h([y({type:Tl,optional:true})],lr.prototype,"otherPrimeInfos",void 0);var U0=class{constructor(e={}){f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.Integer,converter:he})],U0.prototype,"modulus",void 0);h([y({type:S.Integer,converter:he})],U0.prototype,"publicExponent",void 0);var kr=class{constructor(e={}){f(this,"issuer",new xt);f(this,"serialNumber",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:xt})],kr.prototype,"issuer",void 0);h([y({type:S.Integer,converter:he})],kr.prototype,"serialNumber",void 0);var vo=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true})],vo.prototype,"subjectKeyIdentifier",void 0);h([y({type:kr})],vo.prototype,"issuerAndSerialNumber",void 0);vo=h([N({type:B.Choice})],vo);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=h([N({type:B.Sequence})],mt);var F0=class extends J{};F0=h([N({type:B.Sequence})],F0);var Nt=class extends J{};Nt=h([N({type:B.Sequence})],Nt);var L0=class extends J{};L0=h([N({type:B.Sequence})],L0);var Y4=class extends J{};Y4=h([N({type:B.Sequence})],Y4);var kl=class extends J{};kl=h([N({type:B.Sequence})],kl);var At=class{constructor(e={}){f(this,"attrType","");f(this,"attrValues",[]);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],At.prototype,"attrType",void 0);h([y({type:S.Any,repeated:"set"})],At.prototype,"attrValues",void 0);var wp,dr=class{constructor(e={}){f(this,"version",ht.v0);f(this,"sid",new vo);f(this,"digestAlgorithm",new mt);f(this,"signedAttrs");f(this,"signedAttrsRaw");f(this,"signatureAlgorithm",new F0);f(this,"signature",new ce);f(this,"unsignedAttrs");Object.assign(this,e);}};h([y({type:S.Integer})],dr.prototype,"version",void 0);h([y({type:vo})],dr.prototype,"sid",void 0);h([y({type:mt})],dr.prototype,"digestAlgorithm",void 0);h([y({type:At,repeated:"set",context:0,implicit:true,optional:true,raw:true})],dr.prototype,"signedAttrs",void 0);h([y({type:F0})],dr.prototype,"signatureAlgorithm",void 0);h([y({type:ce})],dr.prototype,"signature",void 0);h([y({type:At,repeated:"set",context:1,implicit:true,optional:true})],dr.prototype,"unsignedAttrs",void 0);var H0=wp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,wp.prototype);}};H0=wp=h([N({type:B.Set,itemType:dr})],H0);var Q4=class extends dr{};Q4=h([N({type:B.Sequence})],Q4);var J4=class extends je{};J4=h([N({type:B.Choice})],J4);var K0=class{constructor(e={}){f(this,"acIssuer",new ue);f(this,"acSerial",0);f(this,"attrs",[]);Object.assign(this,e);}};h([y({type:ue})],K0.prototype,"acIssuer",void 0);h([y({type:S.Integer})],K0.prototype,"acSerial",void 0);h([y({type:Wr,repeated:"sequence"})],K0.prototype,"attrs",void 0);var Ap,z0=Ap=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ap.prototype);}};z0=Ap=h([N({type:B.Sequence,itemType:S.ObjectIdentifier})],z0);var Ls=class{constructor(e={}){f(this,"pathLenConstraint");f(this,"permittedAttrs");f(this,"excludedAttrs");f(this,"permitUnSpecified",true);Object.assign(this,e);}};h([y({type:S.Integer,optional:true})],Ls.prototype,"pathLenConstraint",void 0);h([y({type:z0,implicit:true,context:0,optional:true})],Ls.prototype,"permittedAttrs",void 0);h([y({type:z0,implicit:true,context:1,optional:true})],Ls.prototype,"excludedAttrs",void 0);h([y({type:S.Boolean,defaultValue:true})],Ls.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);}};h([y({type:Xe})],ur.prototype,"issuer",void 0);h([y({type:S.Integer,converter:he})],ur.prototype,"serial",void 0);h([y({type:S.BitString,optional:true})],ur.prototype,"issuerUID",void 0);var _p;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes";})(_p||(_p={}));var fr=class{constructor(e={}){f(this,"digestedObjectType",_p.publicKey);f(this,"otherObjectTypeID");f(this,"digestAlgorithm",new J);f(this,"objectDigest",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.Enumerated})],fr.prototype,"digestedObjectType",void 0);h([y({type:S.ObjectIdentifier,optional:true})],fr.prototype,"otherObjectTypeID",void 0);h([y({type:J})],fr.prototype,"digestAlgorithm",void 0);h([y({type:S.BitString})],fr.prototype,"objectDigest",void 0);var Eo=class{constructor(e={}){f(this,"issuerName");f(this,"baseCertificateID");f(this,"objectDigestInfo");Object.assign(this,e);}};h([y({type:Xe,optional:true})],Eo.prototype,"issuerName",void 0);h([y({type:ur,context:0,implicit:true,optional:true})],Eo.prototype,"baseCertificateID",void 0);h([y({type:fr,context:1,implicit:true,optional:true})],Eo.prototype,"objectDigestInfo",void 0);var Bo=class{constructor(e={}){f(this,"v1Form");f(this,"v2Form");Object.assign(this,e);}};h([y({type:ue,repeated:"sequence"})],Bo.prototype,"v1Form",void 0);h([y({type:Eo,context:0,implicit:true})],Bo.prototype,"v2Form",void 0);Bo=h([N({type:B.Choice})],Bo);var To=class{constructor(e={}){f(this,"notBeforeTime",new Date);f(this,"notAfterTime",new Date);Object.assign(this,e);}};h([y({type:S.GeneralizedTime})],To.prototype,"notBeforeTime",void 0);h([y({type:S.GeneralizedTime})],To.prototype,"notAfterTime",void 0);var An=class{constructor(e={}){f(this,"baseCertificateID");f(this,"entityName");f(this,"objectDigestInfo");Object.assign(this,e);}};h([y({type:ur,implicit:true,context:0,optional:true})],An.prototype,"baseCertificateID",void 0);h([y({type:Xe,implicit:true,context:1,optional:true})],An.prototype,"entityName",void 0);h([y({type:fr,implicit:true,context:2,optional:true})],An.prototype,"objectDigestInfo",void 0);var Cp;(function(t){t[t.v2=1]="v2";})(Cp||(Cp={}));var Rt=class{constructor(e={}){f(this,"version",Cp.v2);f(this,"holder",new An);f(this,"issuer",new Bo);f(this,"signature",new J);f(this,"serialNumber",new ArrayBuffer(0));f(this,"attrCertValidityPeriod",new To);f(this,"attributes",[]);f(this,"issuerUniqueID");f(this,"extensions");Object.assign(this,e);}};h([y({type:S.Integer})],Rt.prototype,"version",void 0);h([y({type:An})],Rt.prototype,"holder",void 0);h([y({type:Bo})],Rt.prototype,"issuer",void 0);h([y({type:J})],Rt.prototype,"signature",void 0);h([y({type:S.Integer,converter:he})],Rt.prototype,"serialNumber",void 0);h([y({type:To})],Rt.prototype,"attrCertValidityPeriod",void 0);h([y({type:Wr,repeated:"sequence"})],Rt.prototype,"attributes",void 0);h([y({type:S.BitString,optional:true})],Rt.prototype,"issuerUniqueID",void 0);h([y({type:Bs,optional:true})],Rt.prototype,"extensions",void 0);var ko=class{constructor(e={}){f(this,"acinfo",new Rt);f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:Rt})],ko.prototype,"acinfo",void 0);h([y({type:J})],ko.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],ko.prototype,"signatureValue",void 0);var q0;(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";})(q0||(q0={}));var Hs=class extends vi{};var Ks=class{constructor(e={}){f(this,"type","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier,implicit:true,context:0})],Ks.prototype,"type",void 0);h([y({type:S.Any,implicit:true,context:1})],Ks.prototype,"value",void 0);var G0=class{constructor(e={}){f(this,"policyId","");f(this,"classList",new Hs(q0.unclassified));f(this,"securityCategories");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],G0.prototype,"policyId",void 0);h([y({type:Hs,defaultValue:new Hs(q0.unclassified)})],G0.prototype,"classList",void 0);h([y({type:Ks,repeated:"set"})],G0.prototype,"securityCategories",void 0);var zs=class{constructor(e={}){f(this,"cotets");f(this,"oid");f(this,"string");Object.assign(this,e);}};h([y({type:ce})],zs.prototype,"cotets",void 0);h([y({type:S.ObjectIdentifier})],zs.prototype,"oid",void 0);h([y({type:S.Utf8String})],zs.prototype,"string",void 0);var Pl=class{constructor(e={}){f(this,"policyAuthority");f(this,"values",[]);Object.assign(this,e);}};h([y({type:Xe,implicit:true,context:0,optional:true})],Pl.prototype,"policyAuthority",void 0);h([y({type:zs,repeated:"sequence"})],Pl.prototype,"values",void 0);var Ip,qs=class{constructor(e={}){f(this,"targetCertificate",new ur);f(this,"targetName");f(this,"certDigestInfo");Object.assign(this,e);}};h([y({type:ur})],qs.prototype,"targetCertificate",void 0);h([y({type:ue,optional:true})],qs.prototype,"targetName",void 0);h([y({type:fr,optional:true})],qs.prototype,"certDigestInfo",void 0);var Gs=class{constructor(e={}){f(this,"targetName");f(this,"targetGroup");f(this,"targetCert");Object.assign(this,e);}};h([y({type:ue,context:0,implicit:true})],Gs.prototype,"targetName",void 0);h([y({type:ue,context:1,implicit:true})],Gs.prototype,"targetGroup",void 0);h([y({type:qs,context:2,implicit:true})],Gs.prototype,"targetCert",void 0);Gs=h([N({type:B.Choice})],Gs);var Nl=Ip=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ip.prototype);}};Nl=Ip=h([N({type:B.Sequence,itemType:Gs})],Nl);var vp,eb=vp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,vp.prototype);}};eb=vp=h([N({type:B.Sequence,itemType:Nl})],eb);var Rl=class{constructor(e={}){f(this,"roleAuthority");f(this,"roleName");Object.assign(this,e);}};h([y({type:Xe,implicit:true,context:0,optional:true})],Rl.prototype,"roleAuthority",void 0);h([y({type:ue,implicit:true,context:1})],Rl.prototype,"roleName",void 0);var V0=class{constructor(e={}){f(this,"service",new ue);f(this,"ident",new ue);f(this,"authInfo");Object.assign(this,e);}};h([y({type:ue})],V0.prototype,"service",void 0);h([y({type:ue})],V0.prototype,"ident",void 0);h([y({type:ce,optional:true})],V0.prototype,"authInfo",void 0);var Ep,j0=class{constructor(e={}){f(this,"otherCertFormat","");f(this,"otherCert",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],j0.prototype,"otherCertFormat",void 0);h([y({type:S.Any})],j0.prototype,"otherCert",void 0);var $s=class{constructor(e={}){f(this,"certificate");f(this,"v2AttrCert");f(this,"other");Object.assign(this,e);}};h([y({type:$t})],$s.prototype,"certificate",void 0);h([y({type:ko,context:2,implicit:true})],$s.prototype,"v2AttrCert",void 0);h([y({type:j0,context:3,implicit:true})],$s.prototype,"other",void 0);$s=h([N({type:B.Choice})],$s);var Vs=Ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ep.prototype);}};Vs=Ep=h([N({type:B.Set,itemType:$s})],Vs);var X0=class{constructor(e={}){f(this,"contentType","");f(this,"content",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],X0.prototype,"contentType",void 0);h([y({type:S.Any,context:0})],X0.prototype,"content",void 0);var W0=class{constructor(e={}){f(this,"single");f(this,"any");Object.assign(this,e);}};h([y({type:ce})],W0.prototype,"single",void 0);h([y({type:S.Any})],W0.prototype,"any",void 0);W0=h([N({type:B.Choice})],W0);var Po=class{constructor(e={}){f(this,"eContentType","");f(this,"eContent");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Po.prototype,"eContentType",void 0);h([y({type:W0,context:0,optional:true})],Po.prototype,"eContent",void 0);var Z0=class{constructor(e={}){f(this,"value");f(this,"constructedValue");Object.assign(this,e);}};h([y({type:ce,context:0,implicit:true,optional:true})],Z0.prototype,"value",void 0);h([y({type:ce,converter:q3,context:0,implicit:true,optional:true,repeated:"sequence"})],Z0.prototype,"constructedValue",void 0);Z0=h([N({type:B.Choice})],Z0);var _n=class{constructor(e={}){f(this,"contentType","");f(this,"contentEncryptionAlgorithm",new L0);f(this,"encryptedContent");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],_n.prototype,"contentType",void 0);h([y({type:L0})],_n.prototype,"contentEncryptionAlgorithm",void 0);h([y({type:Z0,optional:true})],_n.prototype,"encryptedContent",void 0);var Cn=class{constructor(e={}){f(this,"keyAttrId","");f(this,"keyAttr");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Cn.prototype,"keyAttrId",void 0);h([y({type:S.Any,optional:true})],Cn.prototype,"keyAttr",void 0);var Bp,js=class{constructor(e={}){f(this,"subjectKeyIdentifier",new Br);f(this,"date");f(this,"other");Object.assign(this,e);}};h([y({type:Br})],js.prototype,"subjectKeyIdentifier",void 0);h([y({type:S.GeneralizedTime,optional:true})],js.prototype,"date",void 0);h([y({type:Cn,optional:true})],js.prototype,"other",void 0);var Xs=class{constructor(e={}){f(this,"rKeyId");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:js,context:0,implicit:true,optional:true})],Xs.prototype,"rKeyId",void 0);h([y({type:kr,optional:true})],Xs.prototype,"issuerAndSerialNumber",void 0);Xs=h([N({type:B.Choice})],Xs);var Y0=class{constructor(e={}){f(this,"rid",new Xs);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:Xs})],Y0.prototype,"rid",void 0);h([y({type:ce})],Y0.prototype,"encryptedKey",void 0);var Dl=Bp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Bp.prototype);}};Dl=Bp=h([N({type:B.Sequence,itemType:Y0})],Dl);var Q0=class{constructor(e={}){f(this,"algorithm",new J);f(this,"publicKey",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:J})],Q0.prototype,"algorithm",void 0);h([y({type:S.BitString})],Q0.prototype,"publicKey",void 0);var No=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"originatorKey");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true,optional:true})],No.prototype,"subjectKeyIdentifier",void 0);h([y({type:Q0,context:1,implicit:true,optional:true})],No.prototype,"originatorKey",void 0);h([y({type:kr,optional:true})],No.prototype,"issuerAndSerialNumber",void 0);No=h([N({type:B.Choice})],No);var ki=class{constructor(e={}){f(this,"version",ht.v3);f(this,"originator",new No);f(this,"ukm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"recipientEncryptedKeys",new Dl);Object.assign(this,e);}};h([y({type:S.Integer})],ki.prototype,"version",void 0);h([y({type:No,context:0})],ki.prototype,"originator",void 0);h([y({type:ce,context:1,optional:true})],ki.prototype,"ukm",void 0);h([y({type:Nt})],ki.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:Dl})],ki.prototype,"recipientEncryptedKeys",void 0);var Ws=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true})],Ws.prototype,"subjectKeyIdentifier",void 0);h([y({type:kr})],Ws.prototype,"issuerAndSerialNumber",void 0);Ws=h([N({type:B.Choice})],Ws);var In=class{constructor(e={}){f(this,"version",ht.v0);f(this,"rid",new Ws);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:S.Integer})],In.prototype,"version",void 0);h([y({type:Ws})],In.prototype,"rid",void 0);h([y({type:Nt})],In.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],In.prototype,"encryptedKey",void 0);var Ro=class{constructor(e={}){f(this,"keyIdentifier",new ce);f(this,"date");f(this,"other");Object.assign(this,e);}};h([y({type:ce})],Ro.prototype,"keyIdentifier",void 0);h([y({type:S.GeneralizedTime,optional:true})],Ro.prototype,"date",void 0);h([y({type:Cn,optional:true})],Ro.prototype,"other",void 0);var vn=class{constructor(e={}){f(this,"version",ht.v4);f(this,"kekid",new Ro);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:S.Integer})],vn.prototype,"version",void 0);h([y({type:Ro})],vn.prototype,"kekid",void 0);h([y({type:Nt})],vn.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],vn.prototype,"encryptedKey",void 0);var En=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);}};h([y({type:S.Integer})],En.prototype,"version",void 0);h([y({type:kl,context:0,optional:true})],En.prototype,"keyDerivationAlgorithm",void 0);h([y({type:Nt})],En.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],En.prototype,"encryptedKey",void 0);var J0=class{constructor(e={}){f(this,"oriType","");f(this,"oriValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],J0.prototype,"oriType",void 0);h([y({type:S.Any})],J0.prototype,"oriValue",void 0);var Pi=class{constructor(e={}){f(this,"ktri");f(this,"kari");f(this,"kekri");f(this,"pwri");f(this,"ori");Object.assign(this,e);}};h([y({type:In,optional:true})],Pi.prototype,"ktri",void 0);h([y({type:ki,context:1,implicit:true,optional:true})],Pi.prototype,"kari",void 0);h([y({type:vn,context:2,implicit:true,optional:true})],Pi.prototype,"kekri",void 0);h([y({type:En,context:3,implicit:true,optional:true})],Pi.prototype,"pwri",void 0);h([y({type:J0,context:4,implicit:true,optional:true})],Pi.prototype,"ori",void 0);Pi=h([N({type:B.Choice})],Pi);var Tp,ec=Tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Tp.prototype);}};ec=Tp=h([N({type:B.Set,itemType:Pi})],ec);var kp,Zs=class{constructor(e={}){f(this,"otherRevInfoFormat","");f(this,"otherRevInfo",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Zs.prototype,"otherRevInfoFormat",void 0);h([y({type:S.Any})],Zs.prototype,"otherRevInfo",void 0);var Ol=class{constructor(e={}){f(this,"other",new Zs);Object.assign(this,e);}};h([y({type:Zs,context:1,implicit:true})],Ol.prototype,"other",void 0);Ol=h([N({type:B.Choice})],Ol);var Ys=kp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,kp.prototype);}};Ys=kp=h([N({type:B.Set,itemType:Ol})],Ys);var Qs=class{constructor(e={}){f(this,"certs");f(this,"crls");Object.assign(this,e);}};h([y({type:Vs,context:0,implicit:true,optional:true})],Qs.prototype,"certs",void 0);h([y({type:Ys,context:1,implicit:true,optional:true})],Qs.prototype,"crls",void 0);var Pp,Np=Pp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Pp.prototype);}};Np=Pp=h([N({type:B.Set,itemType:At})],Np);var Do=class{constructor(e={}){f(this,"version",ht.v0);f(this,"originatorInfo");f(this,"recipientInfos",new ec);f(this,"encryptedContentInfo",new _n);f(this,"unprotectedAttrs");Object.assign(this,e);}};h([y({type:S.Integer})],Do.prototype,"version",void 0);h([y({type:Qs,context:0,implicit:true,optional:true})],Do.prototype,"originatorInfo",void 0);h([y({type:ec})],Do.prototype,"recipientInfos",void 0);h([y({type:_n})],Do.prototype,"encryptedContentInfo",void 0);h([y({type:Np,context:1,implicit:true,optional:true})],Do.prototype,"unprotectedAttrs",void 0);var Rp,Ml=Rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Rp.prototype);}};Ml=Rp=h([N({type:B.Set,itemType:mt})],Ml);var Ni=class{constructor(e={}){f(this,"version",ht.v0);f(this,"digestAlgorithms",new Ml);f(this,"encapContentInfo",new Po);f(this,"certificates");f(this,"crls");f(this,"signerInfos",new H0);Object.assign(this,e);}};h([y({type:S.Integer})],Ni.prototype,"version",void 0);h([y({type:Ml})],Ni.prototype,"digestAlgorithms",void 0);h([y({type:Po})],Ni.prototype,"encapContentInfo",void 0);h([y({type:Vs,context:0,implicit:true,optional:true})],Ni.prototype,"certificates",void 0);h([y({type:Ys,context:1,implicit:true,optional:true})],Ni.prototype,"crls",void 0);h([y({type:H0})],Ni.prototype,"signerInfos",void 0);var dC=Gt.Point.Fp;dC.ORDER;var uC=Gt.Point.CURVE().n,fC=8n,pC=uC/fC,Js=ys(pC,{BITS:249});Gt.Point.Fp;var Bn={x:5299619240641551281634865583518297030282874472190772894086521144482721001553n,y:16950150798460657717958625567821834550301663161624707787222815936182638968203n};Gt.Point.fromAffine(Bn);Gt.Point.fromAffine(Bn);new TextEncoder().encode("FROST_2_NONCE_COMBINER");var db=Object.defineProperty,SC=Object.getOwnPropertyDescriptor,xC=(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')}),ub=(t,e)=>()=>(t&&(e=t(t=0)),e),wC=(t,e)=>{for(var r in e)db(t,r,{get:e[r],enumerable:true});},Dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?SC(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&&db(e,r,n),n},Ri,tc,Gl=ub(()=>{Ri={"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}},tc={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}};}),RC={};wC(RC,{modPow:()=>hb,verifyDscSignature:()=>zC,verifyDscSignatureWithTbs:()=>qC,verifyECDSASignature:()=>Hp,verifyRSASignature:()=>Kp});function fb(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 DC(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 Hp(t,e,r){let i=mb[r.curve];if(!i)return false;try{let n=Math.ceil(r.key_size/8),o=DC(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 Kp(t,e,r,i,n,o){try{if(gb.includes(n)){let s=MC();if(s)return await UC(t,r,i,n,o,s)}return FC(e,r,i,n,o)}catch{return false}}function OC(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 MC(){return typeof globalThis<"u"&&globalThis.crypto?.subtle?globalThis.crypto.subtle:typeof globalThis<"u"&&globalThis.crypto?.webcrypto?.subtle?globalThis.crypto.webcrypto.subtle:null}async function UC(t,e,r,i,n,o){let s=new Uint8Array(Buffer.from(r.modulus.replace("0x",""),"hex")),a=OC(r.exponent),c={kty:"RSA",n:rb(s),e:rb(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:pb(i)}:{name:"RSASSA-PKCS1-v1_5"};try{let u=await o.importKey("jwk",c,l,!1,["verify"]),p=new Uint8Array(e).buffer,m=new Uint8Array(t).buffer;return await o.verify(d,u,p,m)}catch{return false}}function rb(t){return Buffer.from(t).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function pb(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 FC(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 p=new Uint8Array(a);p.set(e,a-e.length),e=p;}else return !1;let c=BigInt(0);for(let p of e)c=c<<BigInt(8)|BigInt(p);if(c>=o)return !1;let l=hb(c,s,o),d=new Uint8Array(a),u=l;for(let p=a-1;p>=0;p--)d[p]=Number(u&BigInt(255)),u=u>>BigInt(8);return n?HC(d,t,i,r.key_size):LC(d,t,i)}catch{return false}}function hb(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 LC(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<bb||i>=t.length||t[i]!==0)return false;i++;let n=t.slice(i),o=yb[r];if(ib(n,e,o))return true;let s=Sb[r];return !!ib(n,e,s)}function ib(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 HC(t,e,r,i){let n=$l[r],o=pb(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),p=255>>8*a-s;if((d[0]&~p)!==0)return false;let m=KC(u,l,n),b=new Uint8Array(l);for(let C=0;C<l;C++)b[C]=d[C]^m[C];b[0]&=p;let w=-1;for(let C=0;C<l;C++)if(b[C]===1){w=C;break}else if(b[C]!==0)return false;if(w===-1)return false;let x=l-w-1;if(x<0)return false;let g=b.slice(w+1),A=new Uint8Array(8+o+x);A.set(e,8),x>0&&A.set(g,8+o);let I=n(A);if(u.length!==I.length)return false;let _=0;for(let C=0;C<u.length;C++)_|=u[C]^I[C];return _===0}function KC(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 zC(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=fb(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(Hp(d,i,u))return true}else {let u=e.public_key;if(await Kp(r,d,i,u,c,o))return true}}return false}async function qC(t,e,r){let i=r.public_key.type==="EC",n=r.signature_algorithm==="RSA-PSS",o=r.public_key.key_size,s=fb(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(Hp(l,e,d))return true}else {let d=r.public_key;if(await Kp(t,l,e,d,a,n))return true}}return false}var $l,nb,ob,sb,ab,cb,lb,mb,gb,yb,bb,Sb,GC=ub(()=>{Gl(),$l={"SHA-1":Qn,"SHA-224":Fr,"SHA-256":ot,"SHA-384":fs,"SHA-512":us},nb={p:tc.brainpoolP224r1.p,a:tc.brainpoolP224r1.a,b:tc.brainpoolP224r1.b,n:tc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},ob=Ge(qe(nb),Fr),sb={p:Ri["P-192"].p,a:Ri["P-192"].a,b:Ri["P-192"].b,n:Ri["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},ab=Ge(qe(sb),Qn),cb={p:Ri["P-224"].p,a:Ri["P-224"].a,b:Ri["P-224"].b,n:Ri["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},lb=Ge(qe(cb),Fr),mb={"P-192":ab,"P-224":lb,"P-256":lt,"P-384":dt,"P-521":ut,brainpoolP224r1:ob,brainpoolP256r1:py,brainpoolP384r1:hy,brainpoolP512r1:my},gb=["SHA-256","SHA-384","SHA-512"],yb={"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])},bb=8,Sb={"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 xb(t){return t.startsWith("0x")?t.slice(2):t}function VC(t){return BigInt("0x"+Buffer.from(t).toString("hex"))}function Oo(t,e){return t.concat(Array(e-t.length).fill(0))}function wb(t,e){return Array(e-t.length).fill(0).concat(t)}function Mo(t,e){let r=BigInt(0);for(let i=0;i<e;i++)r*=BigInt(256),r+=BigInt(t[i]);return r}function jC(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 Ab(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 Di(t){if(!Kl[t])throw new Error(`Unsupported chain: ${t}`);return Kl[t]}function rc(t){for(let e in Kl)if(Kl[e]===t)return e;throw new Error(`Unsupported chain ID: ${t}`)}function zp(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 Tn(t){return typeof t=="string"||typeof t=="number"?new Date(t):t}function qp(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=Tn(r.eq.expected)),"gte"in r&&r.gte&&(r.gte.expected=Tn(r.gte.expected)),"gt"in r&&r.gt&&(r.gt.expected=Tn(r.gt.expected)),"lte"in r&&r.lte&&(r.lte.expected=Tn(r.lte.expected)),"lt"in r&&r.lt&&(r.lt.expected=Tn(r.lt.expected)),"range"in r&&r.range&&Array.isArray(r.range.expected)){let[i,n]=r.range.expected;r.range.expected=[Tn(i),Tn(n)];}"disclose"in r&&r.disclose&&(r.disclose.result=Tn(r.disclose.result));}}return t}function Te(t,e){return Vn(t.toString(16).padStart(e*2,"0"))}async function Gp(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 _b(t){return BigInt(t.publicInputs[0])}function Cb(t){return BigInt(t.publicInputs[1])}function XC(){return 2}function Ib(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function vb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function WC(){return 2}function ea(t){return t==="D<<"?"DEU":t}function Dp(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 Op(t){return t.startsWith("P")?"passport":t==="IR"||t==="AR"?"residence_permit":t.startsWith("I")?"id_card":"other"}var $p=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,p=l+" "+c;return new Ll({issuingCountry:ea(o(i.issuingCountry)),nationality:ea(o(i.nationality)),documentType:Op(o(i.documentType)),documentNumber:Dp(o(i.documentNumber)),dateOfExpiry:ta(i.dateOfExpiry),dateOfBirth:ta(i.dateOfBirth),name:ve(p),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,p=l+" "+c;return new Ll({issuingCountry:ea(o(i.issuingCountry)),nationality:ea(o(i.nationality)),documentType:Op(o(i.documentType)),documentNumber:Dp(o(i.documentNumber)),dateOfExpiry:ta(i.dateOfExpiry),dateOfBirth:ta(i.dateOfBirth),name:ve(p),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("<"),p=u>=0?d.substring(0,u):d,m=d+" "+l;return new Ll({issuingCountry:ea(s(n.issuingCountry)),nationality:ea(s(n.nationality)),documentType:Op(s(n.documentType)),documentNumber:Dp(s(n.documentNumber)),dateOfExpiry:ta(n.dateOfExpiry),dateOfBirth:ta(n.dateOfBirth),name:ve(m),firstName:ve(p),lastName:ve(l),gender:s(n.gender)})}};function ta(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 Vp(t,e){return await Me([BigInt(0),BigInt(se[0].standard),jC(t,253),...Ab(new Uint8Array(e),31).map(r=>BigInt(r))])}async function Eb(t,e){let r=ot(new Uint8Array([0,...Te(se[0].evm,2),...t.map(i=>Number(i)),...e.map(i=>Number(i))]));return Mo(r,31)}function Bb(t){return t.minAge}function Tb(t){return t.maxAge}async function jp(t,e){return await Me([BigInt(1),BigInt(se[1].standard),BigInt(t),BigInt(e)])}async function kb(t,e){let r=ot(new Uint8Array([1,...Te(se[1].evm,2),t,e]));return Mo(r,31)}function ZC(t){return t.charCodeAt(0)*65536+t.charCodeAt(1)*256+t.charCodeAt(2)}async function Oi(t,e,r=false){let i=e.map(o=>ZC(o)),n=Oo(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 ic(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),...Oo(i,600)]));return Mo(n,31)}var Uo=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 Pb(t,e=Uo){return zl(t).getTime()===0?new Date(0):new Date(zl(t).getTime()+e*1e3)}function Nb(t,e=Uo){return ql(t).getTime()===0?new Date(0):new Date(ql(t).getTime()+e*1e3)}async function nc(t,e,r,i=Uo){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 Xp(t,e,r,i=Uo){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 Mo(n,31)}function Rb(t){return BigInt(t.publicInputs[0])}function Db(t){return BigInt(t.publicInputs[1])}function YC(){return 2}var QC=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(QC||{});function oc(t){let e=[];if(t.user_address&&t.user_address.length>0){let r=Hl.fromHex(t.user_address).toNumberArray();e=[...e,1,...wb([r.length],2),...r];}if(t.chain){let r=Di(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 Wp(t,e=509){let r=Oo(t,e);return await Me([BigInt(8),BigInt(se[8].standard),...Ab(new Uint8Array(r),31).map(i=>BigInt(i))])}async function Ob(t,e=509){let r=Oo(t,e),i=ot(new Uint8Array([8,...Te(se[8].evm,2),...r]));return Mo(i,31)}var Mb=8544227306600425492560068004835614964118871262589609739238120993689090208159n,Ub=0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615dn;async function Zp(t,e,r,i){return await Me([BigInt(10),BigInt(se[10].standard),t,e,r,r===Ub?Mb:0n,i])}async function Fb(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===Ub?Mb:0n,32),...Te(i,1)]));return Mo(n,31)}function Pr(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function Lb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function Nr(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 Yp(t){return BigInt(t.publicInputs[3])}function Qp(t){return BigInt(t.publicInputs[2])}function hr(t){return BigInt(t.publicInputs[0])}function Jp(t){return new Date(Number(BigInt(t.publicInputs[1]))*1e3)}function ra(t){return t.startsWith("data_check_integrity")?WC():t.startsWith("sig_check_id_data")?YC():t.startsWith("sig_check_dsc")?XC():t.startsWith("oprf_auth")?3:t.startsWith("outer")?8+(Number(t.substring(t.lastIndexOf("_")+1))-3):8}function Hb(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 Kb=["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"],zb=[...Vl,"Iceland","Liechtenstein","Norway"],qb=[...Vl.filter(t=>t!=="Cyprus"&&t!=="Ireland"),"Switzerland","Iceland","Liechtenstein","Norway"],Gb=["Brunei Darussalam","Cambodia","Indonesia","Lao People's Democratic Republic","Malaysia","Myanmar","Philippines","Singapore","Thailand","Vietnam"],$b=["Argentina","Brazil","Chile","Colombia","Paraguay","Uruguay"];Gl();var Up=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,Up.prototype);}};Up=Dt([N({type:B.Set,itemType:At})],Up);var Fp=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Dt([y({type:S.Integer})],Fp.prototype,"number",2),Dt([y({type:S.OctetString})],Fp.prototype,"hash",2);var Lp=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Dt([y({type:S.PrintableString})],Lp.prototype,"ldsVersion",2),Dt([y({type:S.PrintableString})],Lp.prototype,"unicodeVersion",2);var Mp=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Dt([y({type:S.ObjectIdentifier})],Mp.prototype,"value",2),Mp=Dt([N({type:B.Choice})],Mp);var Ul=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Dt([y({type:S.Integer})],Ul.prototype,"version",2),Dt([y({type:mt})],Ul.prototype,"hashAlgorithm",2),Dt([y({type:Fp,repeated:"sequence"})],Ul.prototype,"dataGroups",2),Dt([y({type:Lp,optional:true})],Ul.prototype,"versionInfo",2);var Fl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Dt([y({type:S.Integer})],Fl.prototype,"version",2),Dt([y({type:$t,repeated:"set"})],Fl.prototype,"certificates",2),Fl=Dt([N({type:B.Sequence})],Fl);Gl();var JC=["https://eu.node0.zkp.oprf.taceo.network","https://eu.node1.zkp.oprf.taceo.network","https://eu.node2.zkp.oprf.taceo.network"],Vb="1";Gt.Point.fromAffine(Bn);Js.ORDER;async function jb(t,e){let r=JC,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 Xb(t){return Me([t.x,t.y])}async function Wb(t,e){let r=Array.from(Buffer.from(xb(t).padStart(64,"0"),"hex")),i=wb(r,32),n=ot(new Uint8Array([9,...Te(se[9].evm,2),...i,e?1:0]));return Mo(n,31)}async function eh(t,e){return Me([BigInt(9),BigInt(se[9].standard),BigInt(`0x${xb(t)}`),e?1n:0n])}function ia(t){if(!t)return 0n;let e=ot(new TextEncoder().encode(t)).slice(0,31);return VC(Array.from(e))}function sc(t){return ia(t)}function eI(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 tI(t,e){return t.slice(0,e)}function rI(t,e){return t.slice(e)}function na(t,e,r=0){let i=eI(Buffer.from(t,"hex"),r),n=rI(i,e),o=tI(i,e);return {proof:n,publicInputs:o.map(s=>s.startsWith("0x")?s:`0x${s}`)}}function Zb(t){return BigInt(t.publicInputs[0])}function Yb(t){return BigInt(t.publicInputs[1])}function Qb(t){return new Date(Number(BigInt(t.publicInputs[2]))*1e3)}function th(t){return BigInt(t.publicInputs[3])}function rh(t){return BigInt(t.publicInputs[4])}function Jb(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 e6(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function t6(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function ih(t){return t.publicInputs.slice(5,t.publicInputs.length-3).map(BigInt)}if(typeof window>"u")try{let t=xC("crypto");crypto=t;}catch{}GC();var Jo=It(Il(),1);var iI=Object.defineProperty,nI=Object.getOwnPropertyDescriptor,oI=(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')}),o6=(t,e)=>()=>(t&&(e=t(t=0)),e),Ot=(t,e,r,i)=>{for(var n=i>1?void 0:i?nI(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&&iI(e,r,n),n},Mi,ac,Wl=o6(()=>{Mi={"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}},ac={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}};}),r6,i6,n6,sI=o6(()=>{Wl(),r6={p:ac.brainpoolP224r1.p,a:ac.brainpoolP224r1.a,b:ac.brainpoolP224r1.b,n:ac.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(r6),Fr),i6={p:Mi["P-192"].p,a:Mi["P-192"].a,b:Mi["P-192"].b,n:Mi["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(i6),Qn),n6={p:Mi["P-224"].p,a:Mi["P-224"].a,b:Mi["P-224"].b,n:Mi["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(n6),Fr);});BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Wl();Wl();var oh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,oh.prototype);}};oh=Ot([N({type:B.Set,itemType:At})],oh);var sh=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Ot([y({type:S.Integer})],sh.prototype,"number",2),Ot([y({type:S.OctetString})],sh.prototype,"hash",2);var ah=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Ot([y({type:S.PrintableString})],ah.prototype,"ldsVersion",2),Ot([y({type:S.PrintableString})],ah.prototype,"unicodeVersion",2);var nh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Ot([y({type:S.ObjectIdentifier})],nh.prototype,"value",2),nh=Ot([N({type:B.Choice})],nh);var jl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Ot([y({type:S.Integer})],jl.prototype,"version",2),Ot([y({type:mt})],jl.prototype,"hashAlgorithm",2),Ot([y({type:sh,repeated:"sequence"})],jl.prototype,"dataGroups",2),Ot([y({type:ah,optional:true})],jl.prototype,"versionInfo",2);var Xl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Ot([y({type:S.Integer})],Xl.prototype,"version",2),Ot([y({type:$t,repeated:"set"})],Xl.prototype,"certificates",2),Xl=Ot([N({type:B.Sequence})],Xl);Wl();Gt.Point.fromAffine(Bn);Js.ORDER;if(typeof window>"u")try{let t=oI("crypto");crypto=t;}catch{}sI();function aI(t){return "0x"+Buffer.from(t).toString("hex").padStart(64,"0")}function s6(t){let e=[];for(let r=0;r<t.length;r+=32)e.push(aI(t.slice(r,r+32)));return e}var cI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(cI||{});var lI=(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))(lI||{});var dI=Object.defineProperty,uI=Object.getOwnPropertyDescriptor,fI=(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')}),f6=(t,e)=>()=>(t&&(e=t(t=0)),e),Mt=(t,e,r,i)=>{for(var n=i>1?void 0:i?uI(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&&dI(e,r,n),n},Ui,cc,Jl=f6(()=>{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}},cc={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}};}),a6,c6,l6,pI=f6(()=>{Jl(),a6={p:cc.brainpoolP224r1.p,a:cc.brainpoolP224r1.a,b:cc.brainpoolP224r1.b,n:cc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(a6),Fr),c6={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(c6),Qn),l6={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(l6),Fr);}),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 Rr(t,e){if(!t)throw new Error(e)}function oa(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 dh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,dh.prototype);}};dh=Mt([N({type:B.Set,itemType:At})],dh);var uh=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Mt([y({type:S.Integer})],uh.prototype,"number",2),Mt([y({type:S.OctetString})],uh.prototype,"hash",2);var fh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Mt([y({type:S.PrintableString})],fh.prototype,"ldsVersion",2),Mt([y({type:S.PrintableString})],fh.prototype,"unicodeVersion",2);var ch=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Mt([y({type:S.ObjectIdentifier})],ch.prototype,"value",2),ch=Mt([N({type:B.Choice})],ch);var Zl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Mt([y({type:S.Integer})],Zl.prototype,"version",2),Mt([y({type:mt})],Zl.prototype,"hashAlgorithm",2),Mt([y({type:uh,repeated:"sequence"})],Zl.prototype,"dataGroups",2),Mt([y({type:fh,optional:true})],Zl.prototype,"versionInfo",2);var Yl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Mt([y({type:S.Integer})],Yl.prototype,"version",2),Mt([y({type:$t,repeated:"set"})],Yl.prototype,"certificates",2),Yl=Mt([N({type:B.Sequence})],Yl);Jl();Gt.Point.fromAffine(Bn);Js.ORDER;if(typeof window>"u")try{let t=fI("crypto");crypto=t;}catch{}pI();var hI="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",d6=[18,32];function mI(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=hI[n]+i,r=r/BigInt(58);}return "1".repeat(e)+i}function ph(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]=d6[0],e[1]=d6[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 mI(e)}var gI=16,yI=14,bI=8,SI=12,td=0n;var xI=1;var Fo=1,Lo=2,rd=3;function u6(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 wI(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 AI(t,e){let r=e?.version??0;Rr(r===0||r===1,`Unsupported Packaged Certificates version: ${r}`);let i=e?.tags?u6(e.tags):t?.tags?u6(t.tags):[0n,0n,0n];Rr(i.length===3,"Tags must be exactly 3 fields");let n=e?.type??xI;Rr(n>=0&&n<=255,`Certificate type must fit in a single byte: ${n}`),Rr(t?.country?.length===3,`Country code must be 3 characters: ${t?.country}`);let o=wI(t.public_key);if(r===0)return Me([...i,BigInt(oa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2)]),31)[0]),...oa(o,31).map(s=>BigInt(s))]);if(r===1){Rr(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(oa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2),...a]),31)[0]),s,...oa(o,31).map(c=>BigInt(c))])}else throw new Error(`Unsupported Packaged Certificates version: ${r}`)}async function _I(t,e=0){let r=await Promise.all(t.map(i=>AI(i,{version:e})));return r.sort((i,n)=>i>n?1:i<n?-1:0),r}async function CI(t,e=0){let r=await _I(t,e),i=new ed(gI,2);return await i.initialize(td,r),i}async function II(t){Rr(t.fingerprint!==void 0,"Revocation fingerprint required"),Rr(t.serial!==void 0,"Revocation serial required"),Rr(typeof t.fingerprint=="string"&&t.fingerprint.startsWith("0x"),`Revocation fingerprint must be a 0x-prefixed hex string: ${t.fingerprint}`),Rr(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(oa(e,31).map(i=>BigInt(i)));return Me([BigInt(t.fingerprint),r])}async function vI(t){let e=await Promise.all(t.map(r=>II(r)));return e.sort((r,i)=>r>i?1:r<i?-1:0),e}async function EI(t){let e=await vI(t),r=new ed(yI,2);return await r.initialize(td,e),r}async function BI(t){let e=t.map(i=>BigInt(i));e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(bI,2);return await r.initialize(td,e),r}var TI=21888242871839275222246405745257275088548364400416034343698204186575808495617n;function lh(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>=TI)throw new Error(`${t} must be in [0, BN254_FIELD_MODULUS): ${r}`);return r}async function kI(t){let{schemaVersion:e,timestamp:r,certificateRoot:i,revocationRoot:n,masterlistRoot:o}=t;Rr(Number.isInteger(e)&&e>=0&&e<=65535,`Schema version must be an integer that fits in 2 bytes: ${e}`),Rr(Number.isInteger(r)&&r>=0&&r<=4294967295,`Timestamp must be an integer that fits in 4 bytes: ${r}`);let s=lh("certificateRoot",i),a=lh("revocationRoot",n),c=lh("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(oa(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 p6(t){let e=t.version??0,r=await CI(t.certificates,e);if(e===0)return r.root;if(e===1){let i=t,n=await EI(i.revocations??[]),o=await BI(i.masterlists??[]),{certificateRoot:s}=await kI({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 h6(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(SI,2);return await r.initialize(td,e),r.root}var w6=It(lc(),1);function yh(t){return jI.find(e=>e.chainId===t)}function ad(t){let e=yh(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e}var hh="https://certificates.zkpassport.id/mainnet",qI="https://certificates.zkpassport.id/testnet",GI="http://localhost:8000/root",mh="https://circuits2.zkpassport.id/mainnet",$I="https://circuits2.zkpassport.id/testnet",VI="http://localhost:8000",jI=[{chainId:Di("ethereum"),chain:"ethereum",type:"mainnet",rpcUrl:"https://eth-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x8C93bB3a7ED88dA0647Ea53f8cd3f57832a513Cd",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("base"),chain:"base",type:"mainnet",rpcUrl:"https://base-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0xC404C605130F3345E1A2BFdf3BAFABED7234cCa7",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("robinhood"),chain:"robinhood",type:"mainnet",rpcUrl:"https://rpc.mainnet.chain.robinhood.com",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x0A55cA59e98e17666C1A9a099d546E676088bC1A",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("ethereum_sepolia"),chain:"ethereum_sepolia",type:"testnet",rpcUrl:"https://eth-sepolia.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x6Ee299B1E8049fadc3494f1110A3479f5BE8EC0e",packagedCertificatesUrl:qI,circuitUrl:$I},{chainId:Di("local"),chain:"local",type:"dev",rpcUrl:"http://localhost:8545",rootRegistry:"0x5FbDB2315678afecb367f032d93F642f64180aa3",registryHelper:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",packagedCertificatesUrl:GI,circuitUrl:VI}];function la(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${la(t).toLowerCase().padStart(64,"0")}`}var XI=3,WI=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).packagedCertificatesUrl}/${e}.json`),ZI="https://sanctions.zkpassport.id/mainnet",YI="https://sanctions.zkpassport.id/testnet",QI="http://localhost:8000/sanctions",JI=(t,e)=>(e=_t(e),t===1||t===8453?`${ZI}/${e}.tree.json.gz`:t===11155111?`${YI}/${e}.tree.json.gz`:`${QI}/${e}.tree.json.gz`),ev=(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")},tv=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).circuitUrl}/by-hash/${e}.json`),od=100,rv="0xc3bc16e8",S6="0x06ac4103",x6="0xcb0c82c7",iv="0x76785af8",nv="0x5d8d57a6",ov="0xbb3dd539",sv="0x2aae4296",av=[{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, w6.default)("zkpassport:registry"),sd=t=>t.toString(16).padStart(64,"0");function bh(t,e={}){let r=typeof t=="number"?t:Di(t);if(!yh(r))throw new Error(`Unsupported chain: ${t}`);return new cv({...e,chainId:r})}var cv=class gh{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=yh(i),u=e||d?.rpcUrl,p=r||d?.rootRegistry,m=n||d?.registryHelper;if(!u||!p||!m)throw new Error(`Unsupported chain ID: ${i}`);this.rpcUrl=u,this.rootRegistry=p,this.registryHelper=m,this.packagedCertsUrlGenerator=o||WI,this.circuitManifestUrlGenerator=s||ev,this.packagedCircuitUrlGenerator=a||tv,this.sanctionsTreeUrlGenerator=c||JI,this.retryCount=l||XI;}async getLatestCertificateRoot(){return this.getLatestRoot(Fo,"certificate")}async isCertificateRootValid(e,r){return this.isRootValid(Fo,"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 gh.validateCertificates(n,e))throw new Error(`Validation failed for packaged certificates: ${e}`);return n}static async validateCertificates(e,r){try{let i=await p6(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"?la(e):e??1,n=typeof i=="number"?`${S6}${Fo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${x6}${Fo.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(Fo,"certificate",e)}async getLatestCircuitRoot(){return this.getLatestRoot(Lo,"circuit")}async isCircuitRootValid(e,r){return this.isRootValid(Lo,"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 h6({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=s6(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 gh.validatePackagedCircuit(s,o))throw new Error(`Validation failed for packaged circuit: ${e}`);return s}async getHistoricalCircuitRoots(e,r=od){let i=typeof e=="string"?la(e):e??1,n=typeof i=="number"?`${S6}${Lo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${x6}${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 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(Lo,"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,`${nv}${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=av.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(Fo)}async getCircuitRegistryAddress(){return this.getRegistryAddress(Lo)}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,rv+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,sv+sd(e)+la(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(la(a.result))===1}async getRootDetails(e,r,i){if(i){Ft(`Getting ${r} root details`);let o=await this.rpcRequest(this.registryHelper,ov+sd(e)+la(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,iv+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 Gp(()=>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 Gp(()=>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=ph(`0x${i.slice(384,448)}`),p=i.slice(448,512),m=i.slice(512,576),b=i.slice(576,640),w=p===""?void 0:`0x${p}`,x=m===""?void 0:`0x${m}`,g=b===""?void 0:`0x${b}`;return {index:n,root:o,validFrom:s,validTo:c,revoked:l,leaves:d,cid:u,...w!==void 0&&{metadata1:w},...x!==void 0&&{metadata2:x},...g!==void 0&&{metadata3:g},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,p=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),w=parseInt(s.slice(u+192,u+256),16),x=w===0?void 0:new Date(w*1e3),g=parseInt(s.slice(u+256,u+320),16)===1,A=parseInt(s.slice(u+320,u+384),16),I=ph(`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:g,cid:I,leaves:A,...T!==void 0&&{metadata1:T},...G!==void 0&&{metadata2:G},...F!==void 0&&{metadata3:F},isLatest:d===a-1&&o,index:p});}return {roots:c,isLastPage:o}}return {roots:[],isLastPage:true}}};var A6=(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 lv(){return typeof process<"u"&&process.versions!=null&&typeof window>"u"}async function cd(t,e){if(lv())try{let r=await Promise.resolve().then(()=>It(C6(),1)).catch(()=>{try{return {default:A6("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 I6=10,v6="wss://bridge.zkpassport.id",E6=3e4,da="1";var dv=typeof window<"u"?{getRandomValues:t=>window.crypto.getRandomValues(t)}:globalThis.crypto,Sh=typeof window<"u"?window.crypto:typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:dv;function B6(t){let e=new Uint8Array(t);if(Sh&&typeof Sh.getRandomValues=="function")return Sh.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 xh(t){try{let e=new URL(t);return `${e.protocol}//${e.host.split(":")[0]}`}catch{return t}}function ua(t=16){let e=B6(t);return Buffer.from(e).toString("hex")}function T6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(t,...e){if(!T6(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 dc(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 wh(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 k6(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Dr(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Or(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function fa(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}var fv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,pv=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function uc(t){if(at(t),pv)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=hv[t[r]];return e}function Ah(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function pa(t){if(typeof t=="string")t=Ah(t);else if(T6(t))t=Ko(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function P6(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 N6=(t,e)=>{function r(i,...n){if(at(i),!fv)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 R6(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&&!fc(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 D6(t,e,r){let i=new Uint8Array(16),n=fa(i);return ld(n,0,BigInt(e),r),ld(n,8,BigInt(t),r),i}function fc(t){return t.byteOffset%4===0}function Ko(t){return Uint8Array.from(t)}var Fi=16,Ch=new Uint8Array(16),ei=Dr(Ch),mv=225,gv=(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^mv<<24&-(n&1)}},mr=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function yv(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 bv=t=>t>64*1024?8:t>1024?4:2,dd=class{constructor(e,r){this.blockLen=Fi,this.outputLen=Fi,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=false,e=pa(e),at(e,16);let i=fa(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}=gv(n,o,s,a);let l=bv(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,p=this.windowSize=2**l,m=[];for(let b=0;b<u;b++)for(let w=0;w<p;w++){let x=0,g=0,A=0,I=0;for(let _=0;_<l;_++){if(!(w>>>l-_-1&1))continue;let{s0:v,s1:T,s2:G,s3:F}=c[l*b+_];x^=v,g^=T,A^=G,I^=F;}m.push({s0:x,s1:g,s2:A,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,p=(1<<o)-1,m=0;for(let b of [e,r,i,n])for(let w=0;w<4;w++){let x=b>>>8*w&255;for(let g=8/o-1;g>=0;g--){let A=x>>>o*g&p,{s0:I,s1:_,s2:C,s3:v}=s[m*a+A];c^=I,l^=_,d^=C,u^=v,m+=1;}}this.s0=c,this.s1=l,this.s2=d,this.s3=u;}update(e){dc(this),e=pa(e),at(e);let r=Dr(e),i=Math.floor(e.length/Fi),n=e.length%Fi;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&&(Ch.set(e.subarray(i*Fi)),this._updateBlock(ei[0],ei[1],ei[2],ei[3]),Or(ei)),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){dc(this),wh(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Dr(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e}digest(){let e=new Uint8Array(Fi);return this.digestInto(e),this.destroy(),e}},_h=class extends dd{constructor(e,r){e=pa(e),at(e);let i=yv(Ko(e));super(i,r),Or(i);}update(e){e=pa(e),dc(this);let r=Dr(e),i=e.length%Fi,n=Math.floor(e.length/Fi);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&&(Ch.set(e.subarray(n*Fi)),this._updateBlock(mr(ei[3]),mr(ei[2]),mr(ei[1]),mr(ei[0])),Or(ei)),this}digestInto(e){dc(this),wh(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Dr(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e.reverse()}};function O6(t){let e=(i,n)=>t(n,i.length).update(pa(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 Ih=O6((t,e)=>new dd(t,e));O6((t,e)=>new _h(t,e));var Eh=16,xv=4,ud=new Uint8Array(Eh),wv=283;function Bh(t){return t<<1^wv&-(t>>7)}function M6(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(e&1),t=Bh(t);return r}var Av=(()=>{let t=new Uint8Array(256);for(let r=0,i=1;r<256;r++,i^=Bh(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 Or(t),e})();var _v=t=>t<<24|t>>>8,vh=t=>t<<8|t>>>24;function Cv(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(vh),n=i.map(vh),o=n.map(vh),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 F6=Cv(Av,t=>M6(t,3)<<24|t<<16|t<<8|M6(t,2));var Iv=(()=>{let t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=Bh(r))t[e]=r;return t})();function vv(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}=F6,i=[];fc(t)||i.push(t=Ko(t));let n=Dr(t),o=n.length,s=c=>pc(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(_v(l))^Iv[c/o-1]:o>6&&c%o===4&&(l=s(l)),a[c]=a[c-o]^l;}return Or(...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 pc(t,e,r,i,n){return t[e&255|r&65280]|t[i>>>16&255|n>>>16&65280]<<16}function U6(t,e,r,i,n){let{sbox2:o,T01:s,T23:a}=F6,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 w=t[c++]^fd(s,a,e,r,i,n),x=t[c++]^fd(s,a,r,i,n,e),g=t[c++]^fd(s,a,i,n,e,r),A=t[c++]^fd(s,a,n,e,r,i);e=w,r=x,i=g,n=A;}let d=t[c++]^pc(o,e,r,i,n),u=t[c++]^pc(o,r,i,n,e),p=t[c++]^pc(o,i,n,e,r),m=t[c++]^pc(o,n,e,r,i);return {s0:d,s1:u,s2:p,s3:m}}function pd(t,e,r,i,n){at(r,Eh),at(i),n=R6(i.length,n);let o=r,s=Dr(o),a=fa(o),c=Dr(i),l=Dr(n),d=12,u=i.length,p=a.getUint32(d,e),{s0:m,s1:b,s2:w,s3:x}=U6(t,s[0],s[1],s[2],s[3]);for(let A=0;A+4<=c.length;A+=4)l[A+0]=c[A+0]^m,l[A+1]=c[A+1]^b,l[A+2]=c[A+2]^w,l[A+3]=c[A+3]^x,p=p+1>>>0,a.setUint32(d,p,e),{s0:m,s1:b,s2:w,s3:x}=U6(t,s[0],s[1],s[2],s[3]);let g=Eh*Math.floor(c.length/xv);if(g<u){let A=new Uint32Array([m,b,w,x]),I=k6(A);for(let _=g,C=0;_<u;_++,C++)n[_]=i[_]^I[C];Or(A);}return n}function Ev(t,e,r,i,n){let o=n?n.length:0,s=t.create(r,i.length+o);n&&s.update(n);let a=D6(8*i.length,8*o,e);s.update(i),s.update(a);let c=s.digest();return Or(a),c}var Th=N6({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=Ev(Ih,false,a,l,i);for(let u=0;u<c.length;u++)d[u]^=c[u];return d}function s(){let a=vv(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(),p=fa(u);ld(p,8,BigInt(r.length*8),false);let m=Ih.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(),p=new Uint8Array(a.length+n),m=[c,l,d,u];fc(a)||m.push(a=Ko(a)),pd(c,false,d,a,p.subarray(0,a.length));let b=o(l,u,p.subarray(0,p.length-n));return m.push(b),p.set(b,a.length),Or(...m),p},decrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),p=[c,l,u,d];fc(a)||p.push(a=Ko(a));let m=a.subarray(0,-n),b=a.subarray(-n),w=o(l,u,m);if(p.push(w),!P6(w,b))throw new Error("aes/gcm: invalid ghash tag");let x=pd(c,false,d,m);return Or(...p),x}}});var Bv={p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n},{p:qo,n:Dh,Gx:Tv,Gy:kv,b:V6}=Bv,Go=32,kh=64,Vt=(t="")=>{throw new Error(t)},j6=t=>typeof t=="bigint",X6=t=>typeof t=="string",Pv=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",hc=(t,e)=>!Pv(t)||typeof e=="number"&&e>0&&t.length!==e?Vt("Uint8Array expected"):t,Oh=t=>new Uint8Array(t),Nv=t=>Uint8Array.from(t),W6=(t,e)=>t.toString(16).padStart(e,"0"),Z6=t=>Array.from(hc(t)).map(e=>W6(e,2)).join(""),Li={_0:48,_9:57,A:65,F:70,a:97,f:102},L6=t=>{if(t>=Li._0&&t<=Li._9)return t-Li._0;if(t>=Li.A&&t<=Li.F)return t-(Li.A-10);if(t>=Li.a&&t<=Li.f)return t-(Li.a-10)},Y6=t=>{let e="hex invalid";if(!X6(t))return Vt(e);let r=t.length,i=r/2;if(r%2)return Vt(e);let n=Oh(i);for(let o=0,s=0;o<i;o++,s+=2){let a=L6(t.charCodeAt(s)),c=L6(t.charCodeAt(s+1));if(a===void 0||c===void 0)return Vt(e);n[o]=a*16+c;}return n},yd=(t,e)=>hc(X6(t)?Y6(t):Nv(hc(t)),e),Rv=()=>globalThis?.crypto;var H6=(...t)=>{let e=Oh(t.reduce((i,n)=>i+hc(n).length,0)),r=0;return t.forEach(i=>{e.set(i,r),r+=i.length;}),e},Dv=(t=Go)=>Rv().getRandomValues(Oh(t)),md=BigInt,gc=(t,e,r,i="bad number: out of range")=>j6(t)&&e<=t&&t<r?t:Vt(i),ee=(t,e=qo)=>{let r=t%e;return r>=0n?r:e+r};var Ov=(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 K6=t=>t instanceof Pn?t:Vt("Point expected"),Q6=t=>ee(ee(t*t)*t+V6),z6=t=>gc(t,0n,qo),hd=t=>gc(t,1n,qo),Mv=t=>gc(t,1n,Dh),Ph=t=>(t&1n)===0n,J6=t=>Uint8Array.of(t),Uv=t=>J6(Ph(t)?2:3),Fv=t=>{let e=Q6(hd(t)),r=1n;for(let i=e,n=(qo+1n)/4n;n>0n;n>>=1n)n&1n&&(r=r*i%qo),i=i*i%qo;return ee(r*r)===e?r:Vt("sqrt invalid")},ti=class ti{constructor(e,r,i){f(this,"px");f(this,"py");f(this,"pz");this.px=z6(e),this.py=hd(r),this.pz=z6(i),Object.freeze(this);}static fromBytes(e){hc(e);let r,i=e[0],n=e.subarray(1),o=q6(n,0,Go),s=e.length;if(s===Go+1&&[2,3].includes(i)){let a=Fv(o),c=Ph(a);Ph(md(i))!==c&&(a=ee(-a)),r=new ti(o,a,1n);}return s===kh+1&&i===4&&(r=new ti(o,q6(n,Go,kh),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}=K6(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(zo)}negate(){return new ti(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}=K6(e),c=0n,l=V6,d=0n,u=0n,p=0n,m=ee(l*3n),b=ee(r*o),w=ee(i*s),x=ee(n*a),g=ee(r+i),A=ee(o+s);g=ee(g*A),A=ee(b+w),g=ee(g-A),A=ee(r+n);let I=ee(o+a);return A=ee(A*I),I=ee(b+x),A=ee(A-I),I=ee(i+n),d=ee(s+a),I=ee(I*d),d=ee(w+x),I=ee(I-d),p=ee(c*A),d=ee(m*x),p=ee(d+p),d=ee(w-p),p=ee(w+p),u=ee(d*p),w=ee(b+b),w=ee(w+b),x=ee(c*x),A=ee(m*A),w=ee(w+x),x=ee(b-x),x=ee(c*x),A=ee(A+x),b=ee(w*A),u=ee(u+b),b=ee(I*A),d=ee(g*d),d=ee(d-b),b=ee(g*w),p=ee(I*p),p=ee(p+b),new ti(d,u,p)}multiply(e,r=true){if(!r&&e===0n)return zo;if(Mv(e),e===1n)return this;if(this.equals(kn))return Gv(e).p;let i=zo,n=kn;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(zo))return {x:0n,y:0n};if(i===1n)return {x:e,y:r};let n=Ov(i,qo);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)===Q6(e)?this:Vt("bad point: not on curve")}toBytes(e=true){let{x:r,y:i}=this.assertValidity().toAffine(),n=Nh(r);return e?H6(Uv(i),n):H6(J6(4),n,Nh(i))}static fromAffine(e){let{x:r,y:i}=e;return r===0n&&i===0n?zo:new ti(r,i,1n)}toHex(e){return Z6(this.toBytes(e))}static fromPrivateKey(e){return kn.multiply(mc(e))}static fromHex(e){return ti.fromBytes(yd(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}};f(ti,"BASE"),f(ti,"ZERO");var Pn=ti,kn=new Pn(Tv,kv,1n),zo=new Pn(0n,1n,0n);Pn.BASE=kn;Pn.ZERO=zo;var Mh=t=>md("0x"+(Z6(t)||"0")),q6=(t,e,r)=>Mh(t.subarray(e,r)),Lv=2n**256n,Nh=t=>Y6(W6(gc(t,0n,Lv),kh)),mc=t=>{let e=j6(t)?t:Mh(yd(t,Go));return gc(e,1n,Dh,"private key invalid 3")};var e5=(t,e=true)=>kn.multiply(mc(t)).toBytes(e);var t5=(t,e,r=true)=>Pn.fromBytes(yd(e)).multiply(mc(t)).toBytes(r),Hv=t=>{t=yd(t),(t.length<Go+8||t.length>1024)&&Vt("expected 40-1024b");let e=ee(Mh(t),Dh-1n);return Nh(e+1n)},Kv=()=>Hv(Dv(Go+16));var r5={normPrivateKeyToScalar:mc,isValidPrivateKey:t=>{try{return !!mc(t)}catch{return false}},randomPrivateKey:Kv,precompute:(t=8,e=kn)=>(e.multiply(3n),e)},gd=8,zv=256,i5=Math.ceil(zv/gd)+1,Rh=2**(gd-1),qv=()=>{let t=[],e=kn,r=e;for(let i=0;i<i5;i++){r=e,t.push(r);for(let n=1;n<Rh;n++)r=r.add(e),t.push(r);e=r.double();}return t},G6,$6=(t,e)=>{let r=e.negate();return t?r:e},Gv=t=>{let e=G6||(G6=qv()),r=zo,i=kn,n=2**gd,o=n,s=md(n-1),a=md(gd);for(let c=0;c<i5;c++){let l=Number(t&s);t>>=a,l>Rh&&(l-=o,t+=1n);let d=c*Rh,u=d,p=d+Math.abs(l)-1,m=c%2!==0,b=l<0;l===0?i=i.add($6(m,e[u])):r=r.add($6(b,e[p]));}return {p:r,f:i}};function $v(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sd(t,...e){if(!$v(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 Uh(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 n5(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 yc(...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 Mr(t,e){return t<<32-e|t>>>e}function Vv(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Fh(t){return typeof t=="string"&&(t=Vv(t)),Sd(t),t}var bd=class{};function o5(t){let e=i=>t().update(Fh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function jv(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 s5(t,e,r){return t&e^~t&r}function a5(t,e,r){return t&e^t&r^e&r}var wd=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){Uh(this),e=Fh(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){Uh(this),n5(e,this),this.finished=true;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:s}=this;r[s++]=128,yc(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(i,0),s=0);for(let u=s;u<n;u++)r[u]=0;jv(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()}},Hi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Xv=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]),Nn=new Uint32Array(64),Lh=class extends wd{constructor(e=32){super(64,e,8,false),this.A=Hi[0]|0,this.B=Hi[1]|0,this.C=Hi[2]|0,this.D=Hi[3]|0,this.E=Hi[4]|0,this.F=Hi[5]|0,this.G=Hi[6]|0,this.H=Hi[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)Nn[u]=e.getUint32(r,false);for(let u=16;u<64;u++){let p=Nn[u-15],m=Nn[u-2],b=Mr(p,7)^Mr(p,18)^p>>>3,w=Mr(m,17)^Mr(m,19)^m>>>10;Nn[u]=w+Nn[u-7]+b+Nn[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 p=Mr(a,6)^Mr(a,11)^Mr(a,25),m=d+p+s5(a,c,l)+Xv[u]+Nn[u]|0,w=(Mr(i,2)^Mr(i,13)^Mr(i,22))+a5(i,n,o)|0;d=l,l=c,c=a,a=s+m|0,s=o,o=n,n=i,i=m+w|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(){yc(Nn);}destroy(){this.set(0,0,0,0,0,0,0,0),yc(this.buffer);}};var c5=o5(()=>new Lh);async function l5(t){let r=new TextEncoder().encode(t),i=await c5(r);return new Uint8Array(i).slice(0,12)}function Ad(){let t=r5.randomPrivateKey(),e=e5(t);return {privateKey:t,publicKey:e}}function Hh(t,e){return t5(t,e).slice(0,32)}async function bc(t,e,r){let i=await l5(r),n=Th(e,i),o=Ah(t);return n.encrypt(o)}async function Kh(t,e,r){let i=await l5(r),o=Th(e,i).decrypt(t);return new TextDecoder().decode(o)}var D8=It(lc(),1);function xa(t){let e=t.length;for(;--e>=0;)t[e]=0;}var Wv=0,Z5=1,Zv=2,Yv=3,Qv=258,u2=29,Nc=256,Ic=Nc+1+u2,ga=30,f2=19,Y5=2*Ic+1,$o=15,zh=16,Jv=7,p2=256,Q5=16,J5=17,e8=18,r2=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]),e9=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),t8=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t9=512,zi=new Array((Ic+2)*2);xa(zi);var Ac=new Array(ga*2);xa(Ac);var vc=new Array(t9);xa(vc);var Ec=new Array(Qv-Yv+1);xa(Ec);var h2=new Array(u2);xa(h2);var Td=new Array(ga);xa(Td);function qh(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 r8,i8,n8;function Gh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e;}var o8=t=>t<256?vc[t]:vc[256+(t>>>7)],Bc=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255;},Lt=(t,e,r)=>{t.bi_valid>zh-r?(t.bi_buf|=e<<t.bi_valid&65535,Bc(t,t.bi_buf),t.bi_buf=e>>zh-t.bi_valid,t.bi_valid+=r-zh):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r);},ni=(t,e,r)=>{Lt(t,r[e*2],r[e*2+1]);},s8=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},r9=t=>{t.bi_valid===16?(Bc(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);},i9=(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,p,m,b,w=0;for(p=0;p<=$o;p++)t.bl_count[p]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<Y5;l++)d=t.heap[l],p=r[r[d*2+1]*2+1]+1,p>c&&(p=c,w++),r[d*2+1]=p,!(d>i)&&(t.bl_count[p]++,m=0,d>=a&&(m=s[d-a]),b=r[d*2],t.opt_len+=b*(p+m),o&&(t.static_len+=b*(n[d*2+1]+m)));if(w!==0){do{for(p=c-1;t.bl_count[p]===0;)p--;t.bl_count[p]--,t.bl_count[p+1]+=2,t.bl_count[c]--,w-=2;}while(w>0);for(p=c;p!==0;p--)for(d=t.bl_count[p];d!==0;)u=t.heap[--l],!(u>i)&&(r[u*2+1]!==p&&(t.opt_len+=(p-r[u*2+1])*r[u*2],r[u*2+1]=p),d--);}},a8=(t,e,r)=>{let i=new Array($o+1),n=0,o,s;for(o=1;o<=$o;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]=s8(i[a]++,a));}},n9=()=>{let t,e,r,i,n,o=new Array($o+1);for(r=0,i=0;i<u2-1;i++)for(h2[i]=r,t=0;t<1<<r2[i];t++)Ec[r++]=i;for(Ec[r-1]=i,n=0,i=0;i<16;i++)for(Td[i]=n,t=0;t<1<<Bd[i];t++)vc[n++]=i;for(n>>=7;i<ga;i++)for(Td[i]=n<<7,t=0;t<1<<Bd[i]-7;t++)vc[256+n++]=i;for(e=0;e<=$o;e++)o[e]=0;for(t=0;t<=143;)zi[t*2+1]=8,t++,o[8]++;for(;t<=255;)zi[t*2+1]=9,t++,o[9]++;for(;t<=279;)zi[t*2+1]=7,t++,o[7]++;for(;t<=287;)zi[t*2+1]=8,t++,o[8]++;for(a8(zi,Ic+1,o),t=0;t<ga;t++)Ac[t*2+1]=5,Ac[t*2]=s8(t,5);r8=new qh(zi,r2,Nc+1,Ic,$o),i8=new qh(Ac,Bd,0,ga,$o),n8=new qh(new Array(0),e9,0,f2,Jv);},c8=t=>{let e;for(e=0;e<Ic;e++)t.dyn_ltree[e*2]=0;for(e=0;e<ga;e++)t.dyn_dtree[e*2]=0;for(e=0;e<f2;e++)t.bl_tree[e*2]=0;t.dyn_ltree[p2*2]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0;},l8=t=>{t.bi_valid>8?Bc(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0;},d5=(t,e,r,i)=>{let n=e*2,o=r*2;return t[n]<t[o]||t[n]===t[o]&&i[e]<=i[r]},$h=(t,e,r)=>{let i=t.heap[r],n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&d5(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!d5(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i;},u5=(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?ni(t,n,e):(s=Ec[n],ni(t,s+Nc+1,e),a=r2[s],a!==0&&(n-=h2[s],Lt(t,n,a)),i--,s=o8(i),ni(t,s,r),a=Bd[s],a!==0&&(i-=Td[s],Lt(t,i,a)));while(o<t.sym_next);ni(t,p2,e);},i2=(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=Y5,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--)$h(t,r,s);l=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$h(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++,$h(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],i9(t,e),a8(r,c,t.bl_count);},f5=(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[Q5*2]++):a<=10?t.bl_tree[J5*2]++:t.bl_tree[e8*2]++,a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4));},p5=(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 ni(t,o,t.bl_tree);while(--a!==0);else o!==0?(o!==n&&(ni(t,o,t.bl_tree),a--),ni(t,Q5,t.bl_tree),Lt(t,a-3,2)):a<=10?(ni(t,J5,t.bl_tree),Lt(t,a-3,3)):(ni(t,e8,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);}},o9=t=>{let e;for(f5(t,t.dyn_ltree,t.l_desc.max_code),f5(t,t.dyn_dtree,t.d_desc.max_code),i2(t,t.bl_desc),e=f2-1;e>=3&&t.bl_tree[t8[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},s9=(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[t8[n]*2+1],3);p5(t,t.dyn_ltree,e-1),p5(t,t.dyn_dtree,r-1);},a9=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<Nc;r++)if(t.dyn_ltree[r*2]!==0)return 1;return 0},h5=false,c9=t=>{h5||(n9(),h5=true),t.l_desc=new Gh(t.dyn_ltree,r8),t.d_desc=new Gh(t.dyn_dtree,i8),t.bl_desc=new Gh(t.bl_tree,n8),t.bi_buf=0,t.bi_valid=0,c8(t);},d8=(t,e,r,i)=>{Lt(t,(Wv<<1)+(i?1:0),3),l8(t),Bc(t,r),Bc(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r;},l9=t=>{Lt(t,Z5<<1,3),ni(t,p2,zi),r9(t);},d9=(t,e,r,i)=>{let n,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=a9(t)),i2(t,t.l_desc),i2(t,t.d_desc),s=o9(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?d8(t,e,r,i):t.strategy===4||o===n?(Lt(t,(Z5<<1)+(i?1:0),3),u5(t,zi,Ac)):(Lt(t,(Zv<<1)+(i?1:0),3),s9(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),u5(t,t.dyn_ltree,t.dyn_dtree)),c8(t),i&&l8(t);},u9=(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[(Ec[r]+Nc+1)*2]++,t.dyn_dtree[o8(e)*2]++),t.sym_next===t.sym_end),f9=c9,p9=d8,h9=d9,m9=u9,g9=l9,y9={_tr_init:f9,_tr_stored_block:p9,_tr_flush_block:h9,_tr_tally:m9,_tr_align:g9},b9=(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},Tc=b9,S9=()=>{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},x9=new Uint32Array(S9()),w9=(t,e,r,i)=>{let n=x9,o=i+r;t^=-1;for(let s=i;s<o;s++)t=t>>>8^n[(t^e[s])&255];return t^-1},it=w9,Xo={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:A9,_tr_stored_block:n2,_tr_flush_block:_9,_tr_tally:On,_tr_align:C9}=y9,{Z_NO_FLUSH:Mn,Z_PARTIAL_FLUSH:I9,Z_FULL_FLUSH:v9,Z_FINISH:gr,Z_BLOCK:m5,Z_OK:ct,Z_STREAM_END:g5,Z_STREAM_ERROR:oi,Z_DATA_ERROR:E9,Z_BUF_ERROR:Vh,Z_DEFAULT_COMPRESSION:B9,Z_FILTERED:T9,Z_HUFFMAN_ONLY:_d,Z_RLE:k9,Z_FIXED:P9,Z_DEFAULT_STRATEGY:N9,Z_UNKNOWN:R9,Z_DEFLATED:Nd}=wa,D9=9,O9=15,M9=8,U9=29,F9=256,o2=F9+1+U9,L9=30,H9=19,K9=2*o2+1,z9=15,be=3,Dn=258,si=Dn+be+1,q9=32,ba=42,m2=57,s2=69,a2=73,c2=91,l2=103,Vo=113,xc=666,Ct=1,Aa=2,Wo=3,_a=4,G9=3,jo=(t,e)=>(t.msg=Xo[e],e),y5=t=>t*2-(t>4?9:0),Rn=t=>{let e=t.length;for(;--e>=0;)t[e]=0;},$9=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)},g2=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask,Zo=(t,e)=>{let r;if(t.legacy_hash)r=t.ins_h=g2(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)=>{_9(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;},Sc=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255;},d2=(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=Tc(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)},u8=(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-si?t.strstart-(t.w_size-si):0,l=t.window,d=t.w_mask,u=t.prev,p=t.strstart+Dn,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<p);if(o=Dn-(p-i),i=p-Dn,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},Sa=t=>{let e=t.w_size,r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-si)&&(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),$9(t),i+=e),t.strm.avail_in===0)break;if(r=d2(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=g2(t,t.ins_h,t.window[n+1]);t.insert&&(Zo(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&&(Zo(t,n),n++,t.insert--,!(t.lookahead+t.insert<=be)););}while(t.lookahead<si&&t.strm.avail_in!==0)},f8=(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===Mn||i!==n+t.strm.avail_in)))break;s=e===gr&&i===n+t.strm.avail_in?1:0,n2(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&&(d2(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?_a:e!==Mn&&e!==gr&&t.strm.avail_in===0&&t.strstart===t.block_start?Aa:(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&&(d2(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!==Mn&&t.strm.avail_in===0&&n<=o)&&(i=n>o?o:n,s=e===gr&&t.strm.avail_in===0&&i===n?1:0,n2(t,t.block_start,i,s),t.block_start+=i,jt(t.strm)),s?Wo:Ct)},jh=(t,e)=>{let r,i;for(;;){if(t.lookahead<si){if(Sa(t),t.lookahead<si&&e===Mn)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Zo(t,t.strstart)),r!==0&&t.strstart-r<=t.w_size-si&&(t.match_length=u8(t,r)),t.match_length>=be)if(i=On(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=Zo(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=g2(t,t.ins_h,t.window[t.strstart+1]));else i=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},ha=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<si){if(Sa(t),t.lookahead<si&&e===Mn)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Zo(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-si&&(t.match_length=u8(t,r),t.match_length<=5&&(t.strategy===T9||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=On(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=Zo(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=On(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=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},V9=(t,e)=>{let r,i,n,o,s=t.window;for(;;){if(t.lookahead<=Dn){if(Sa(t),t.lookahead<=Dn&&e===Mn)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+Dn;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=Dn-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead);}if(t.match_length>=be?(r=On(t,1,t.match_length-be),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},j9=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(Sa(t),t.lookahead===0)){if(e===Mn)return Ct;break}if(t.match_length=0,r=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa};function ri(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 wc=[new ri(0,0,0,0,f8),new ri(4,4,8,4,jh),new ri(4,5,16,8,jh),new ri(4,6,32,32,jh),new ri(4,4,16,16,ha),new ri(8,16,32,32,ha),new ri(8,16,128,128,ha),new ri(8,32,128,256,ha),new ri(32,128,258,1024,ha),new ri(32,258,258,4096,ha)],X9=t=>{t.window_size=2*t.w_size,Rn(t.head),t.max_lazy_match=wc[t.level].max_lazy,t.good_match=wc[t.level].good_length,t.nice_match=wc[t.level].nice_length,t.max_chain_length=wc[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 W9(){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(K9*2),this.dyn_dtree=new Uint16Array((2*L9+1)*2),this.bl_tree=new Uint16Array((2*H9+1)*2),Rn(this.dyn_ltree),Rn(this.dyn_dtree),Rn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(z9+1),this.heap=new Uint16Array(2*o2+1),Rn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*o2+1),Rn(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 Rc=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.status!==ba&&e.status!==m2&&e.status!==s2&&e.status!==a2&&e.status!==c2&&e.status!==l2&&e.status!==Vo&&e.status!==xc?1:0},p8=t=>{if(Rc(t))return jo(t,oi);t.total_in=t.total_out=0,t.data_type=R9;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?m2:e.wrap?ba:Vo,t.adler=e.wrap===2?0:1,e.last_flush=-2,A9(e),ct},h8=t=>{let e=p8(t);return e===ct&&X9(t.state),e},Z9=(t,e)=>Rc(t)||t.state.wrap!==2?oi:(t.state.gzhead=e,ct),m8=(t,e,r,i,n,o,s)=>{if(!t)return oi;let a=1;if(e===B9&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>D9||r!==Nd||i<8||i>15||e<0||e>9||o<0||o>P9||i===8&&a!==1)return jo(t,oi);i===8&&(i=9);let c=new W9;return t.state=c,c.strm=t,c.status=ba,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,h8(t)},Y9=(t,e)=>m8(t,e,Nd,O9,M9,N9),Q9=(t,e)=>{if(Rc(t)||e>m5||e<0)return t?jo(t,oi):oi;let r=t.state;if(!t.output||t.avail_in!==0&&!t.input||r.status===xc&&e!==gr)return jo(t,t.avail_out===0?Vh:oi);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&&y5(e)<=y5(i)&&e!==gr)return jo(t,Vh);if(r.status===xc&&t.avail_in!==0)return jo(t,Vh);if(r.status===ba&&r.wrap===0&&(r.status=Vo),r.status===ba){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|=q9),n+=31-n%31,Sc(r,n),r.strstart!==0&&(Sc(r,t.adler>>>16),Sc(r,t.adler&65535)),t.adler=1,r.status=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===m2){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=s2;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,G9),r.status=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===s2){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=a2;}if(r.status===a2){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=c2;}if(r.status===c2){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=l2;}if(r.status===l2){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=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(t.avail_in!==0||r.lookahead!==0||e!==Mn&&r.status!==xc){let n=r.level===0?f8(r,e):r.strategy===_d?j9(r,e):r.strategy===k9?V9(r,e):wc[r.level].func(r,e);if((n===Wo||n===_a)&&(r.status=xc),n===Ct||n===Wo)return t.avail_out===0&&(r.last_flush=-1),ct;if(n===Aa&&(e===I9?C9(r):e!==m5&&(n2(r,0,0,false),e===v9&&(Rn(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?g5:(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)):(Sc(r,t.adler>>>16),Sc(r,t.adler&65535)),jt(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?ct:g5)},J9=t=>{if(Rc(t))return oi;let e=t.state.status;return t.state=null,e===Vo?jo(t,E9):ct},e7=(t,e)=>{let r=e.length;if(Rc(t))return oi;let i=t.state,n=i.wrap;if(n===2||n===1&&i.status!==ba||i.lookahead)return oi;if(n===1&&(t.adler=Tc(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){n===0&&(Rn(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,Sa(i);i.lookahead>=be;){let c=i.strstart,l=i.lookahead-(be-1);do Zo(i,c),c++;while(--l);i.strstart=c,i.lookahead=be-1,Sa(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},t7=Y9,r7=m8,i7=h8,n7=p8,o7=Z9,s7=Q9,a7=J9,c7=e7,l7="pako deflate (from Nodeca project)",_c={deflateInit:t7,deflateInit2:r7,deflateReset:i7,deflateResetKeep:n7,deflateSetHeader:o7,deflate:s7,deflateEnd:a7,deflateSetDictionary:c7,deflateInfo:l7},d7=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),u7=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)d7(r,i)&&(t[i]=r[i]);}}return t},f7=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:u7,flattenChunks:f7},g8=true;try{String.fromCharCode.apply(null,new Uint8Array(1));}catch{g8=false;}var kc=new Uint8Array(256);for(let t=0;t<256;t++)kc[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;kc[254]=kc[255]=1;var p7=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},h7=(t,e)=>{if(e<65534&&t.subarray&&g8)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},m7=(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=kc[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 h7(o,n)},g7=(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+kc[t[r]]>e?r:e},Pc={string2buf:p7,buf2string:m7,utf8border:g7};function y7(){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 y8=y7,b8=Object.prototype.toString,{Z_NO_FLUSH:b7,Z_SYNC_FLUSH:S7,Z_FULL_FLUSH:x7,Z_FINISH:w7,Z_OK:kd,Z_STREAM_END:A7,Z_DEFAULT_COMPRESSION:_7,Z_DEFAULT_STRATEGY:C7,Z_DEFLATED:I7}=wa,v7={level:_7,method:I7,chunkSize:16384,windowBits:15,memLevel:8,strategy:C7,legacyHash:true};function Dc(t){this.options=Rd.assign({},v7,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 y8,this.strm.avail_out=0;let r=_c.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(r!==kd)throw new Error(Xo[r]);if(e.header&&_c.deflateSetHeader(this.strm,e.header),e.dictionary){let i;if(typeof e.dictionary=="string"?i=Pc.string2buf(e.dictionary):b8.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,r=_c.deflateSetDictionary(this.strm,i),r!==kd)throw new Error(Xo[r]);this._dict_set=true;}}Dc.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?w7:b7,typeof t=="string"?r.input=Pc.string2buf(t):b8.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===S7||o===x7)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(n=_c.deflate(r,o),n===A7)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=_c.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};Dc.prototype.onData=function(t){this.chunks.push(t);};Dc.prototype.onEnd=function(t){t===kd&&(this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function y2(t,e){let r=new Dc(e);if(r.push(t,true),r.err)throw r.msg||Xo[r.err];return r.result}var k7=y2,D7={deflate:k7},Cd=16209,O7=16191,M7=function(e,r){let i,n,o,s,a,c,l,d,u,p,m,b,w,x,g,A,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,p=k.window,m=k.hold,b=k.bits,w=k.lencode,x=k.distcode,g=(1<<k.lenbits)-1,A=(1<<k.distbits)-1;e:do{b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=w[m&g];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&A];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=p,u===0){if(T+=l-_,_<C){C-=_;do H[o++]=p[T++];while(--_);T=o-v,G=H;}}else if(u<_){if(T+=l+u-_,_-=u,_<C){C-=_;do H[o++]=p[T++];while(--_);if(T=0,u<C){_=u,C-=_;do H[o++]=p[T++];while(--_);T=o-v,G=H;}}}else if(T+=u-_,_<C){C-=_;do H[o++]=p[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=w[(I&65535)+(m&(1<<_)-1)];continue t}else if(_&32){k.mode=O7;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;},ma=15,b5=852,S5=592,x5=0,Xh=1,w5=2,U7=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]),F7=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]),L7=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]),H7=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]),K7=(t,e,r,i,n,o,s,a)=>{let c=a.bits,l=0,d=0,u=0,p=0,m=0,b=0,w=0,x=0,g=0,A=0,I,_,C,v,T,G=null,F,H=new Uint16Array(ma+1),k=new Uint16Array(ma+1),E=null,q,O,z;for(l=0;l<=ma;l++)H[l]=0;for(d=0;d<i;d++)H[e[r+d]]++;for(m=c,p=ma;p>=1&&H[p]===0;p--);if(m>p&&(m=p),p===0)return n[o++]=1<<24|64<<16|0,n[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<p&&H[u]===0;u++);for(m<u&&(m=u),x=1,l=1;l<=ma;l++)if(x<<=1,x-=H[l],x<0)return -1;if(x>0&&(t===x5||p!==1))return -1;for(k[1]=0,l=1;l<ma;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===x5?(G=E=s,F=20):t===Xh?(G=U7,E=F7,F=257):(G=L7,E=H7,F=0),A=0,d=0,l=u,T=o,b=m,w=0,C=-1,g=1<<m,v=g-1,t===Xh&&g>b5||t===w5&&g>S5)return 1;for(;;){q=l-w,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-w,_=1<<b,u=_;do _-=I,n[T+(A>>w)+_]=q<<24|O<<16|z|0;while(_!==0);for(I=1<<l-1;A&I;)I>>=1;if(I!==0?(A&=I-1,A+=I):A=0,d++,--H[l]===0){if(l===p)break;l=e[r+s[d]];}if(l>m&&(A&v)!==C){for(w===0&&(w=m),T+=u,b=l-w,x=1<<b;b+w<p&&(x-=H[b+w],!(x<=0));)b++,x<<=1;if(g+=1<<b,t===Xh&&g>b5||t===w5&&g>S5)return 1;C=A&v,n[C]=m<<24|b<<16|T-o|0;}}return A!==0&&(n[T+A]=l-w<<24|64<<16|0),a.bits=m,0},Cc=K7,z7=0,S8=1,x8=2,{Z_FINISH:A5,Z_BLOCK:q7,Z_TREES:Id,Z_OK:Yo,Z_STREAM_END:G7,Z_NEED_DICT:$7,Z_STREAM_ERROR:yr,Z_DATA_ERROR:w8,Z_MEM_ERROR:A8,Z_BUF_ERROR:V7,Z_DEFLATED:_5}=wa,Dd=16180,C5=16181,I5=16182,v5=16183,E5=16184,B5=16185,T5=16186,k5=16187,P5=16188,N5=16189,Pd=16190,Ki=16191,Wh=16192,R5=16193,Zh=16194,D5=16195,O5=16196,M5=16197,U5=16198,vd=16199,Ed=16200,F5=16201,L5=16202,H5=16203,K5=16204,z5=16205,Yh=16206,q5=16207,G5=16208,De=16209,_8=16210,C8=16211,j7=852,X7=592,W7=15,Z7=W7,$5=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function Y7(){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 Qo=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.mode<Dd||e.mode>C8?1:0},I8=t=>{if(Qo(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(j7),e.distcode=e.distdyn=new Int32Array(X7),e.sane=1,e.back=-1,Yo},v8=t=>{if(Qo(t))return yr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,I8(t)},E8=(t,e)=>{let r;if(Qo(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,v8(t))},B8=(t,e)=>{if(!t)return yr;let r=new Y7;t.state=r,r.strm=t,r.window=null,r.mode=Dd;let i=E8(t,e);return i!==Yo&&(t.state=null),i},Q7=t=>B8(t,Z7),V5=true,Qh,Jh,J7=t=>{if(V5){Qh=new Int32Array(512),Jh=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(Cc(S8,t.lens,0,288,Qh,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Cc(x8,t.lens,0,32,Jh,0,t.work,{bits:5}),V5=false;}t.lencode=Qh,t.lenbits=9,t.distcode=Jh,t.distbits=5;},T8=(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},eE=(t,e)=>{let r,i,n,o,s,a,c,l,d,u,p,m,b,w,x=0,g,A,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(Qo(t)||!t.output||!t.input&&t.avail_in!==0)return yr;r=t.state,r.mode===Ki&&(r.mode=Wh),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,p=c,G=Yo;e:for(;;)switch(r.mode){case Dd:if(r.wrap===0){r.mode=Wh;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=C5;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)!==_5){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?N5:Ki,l=0,d=0;break;case C5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.flags=l,(r.flags&255)!==_5){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=I5;case I5: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=v5;case v5: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=E5;case E5: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=B5;case B5: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=T5;case T5: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=k5;case k5: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=P5;case P5: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=Ki;break;case N5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}t.adler=r.check=$5(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,$7;t.adler=r.check=1,r.mode=Ki;case Ki:if(e===q7||e===Id)break e;case Wh:if(r.last){l>>>=d&7,d-=d&7,r.mode=Yh;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=R5;break;case 1:if(J7(r),r.mode=vd,e===Id){l>>>=2,d-=2;break e}break;case 2:r.mode=O5;break;case 3:t.msg="invalid block type",r.mode=De;}l>>>=2,d-=2;break;case R5: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=Zh,e===Id)break e;case Zh:r.mode=D5;case D5: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=Ki;break;case O5: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=M5;case M5: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=Cc(z7,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=U5;case U5:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[l&(1<<r.lenbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(I<16)l>>>=g,d-=g,r.lens[r.have++]=I;else {if(I===16){for(k=g+2;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(l>>>=g,d-=g,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=g+3;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=g,d-=g,T=0,m=3+(l&7),l>>>=3,d-=3;}else {for(k=g+7;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=g,d-=g,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=Cc(S8,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=Cc(x8,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,M7(t,p),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===Ki&&(r.back=-1);break}for(r.back=0;x=r.lencode[l&(1<<r.lenbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(A&&(A&240)===0){for(_=g,C=A,v=I;x=r.lencode[v+((l&(1<<_+C)-1)>>_)],g=x>>>24,A=x>>>16&255,I=x&65535,!(_+g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=g,d-=g,r.back+=g,r.length=I,A===0){r.mode=z5;break}if(A&32){r.back=-1,r.mode=Ki;break}if(A&64){t.msg="invalid literal/length code",r.mode=De;break}r.extra=A&15,r.mode=F5;case F5: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=L5;case L5:for(;x=r.distcode[l&(1<<r.distbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((A&240)===0){for(_=g,C=A,v=I;x=r.distcode[v+((l&(1<<_+C)-1)>>_)],g=x>>>24,A=x>>>16&255,I=x&65535,!(_+g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=g,d-=g,r.back+=g,A&64){t.msg="invalid distance code",r.mode=De;break}r.offset=I,r.extra=A&15,r.mode=H5;case H5: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=K5;case K5:if(c===0)break e;if(m=p-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),w=r.window;}else w=n,b=s-r.offset,m=r.length;m>c&&(m=c),c-=m,r.length-=m;do n[s++]=w[b++];while(--m);r.length===0&&(r.mode=Ed);break;case z5:if(c===0)break e;n[s++]=r.length,c--,r.mode=Ed;break;case Yh:if(r.wrap){for(;d<32;){if(a===0)break e;a--,l|=i[o++]<<d,d+=8;}if(p-=c,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?it(r.check,n,p,s-p):Tc(r.check,n,p,s-p)),p=c,r.wrap&4&&(r.flags?l:$5(l))!==r.check){t.msg="incorrect data check",r.mode=De;break}l=0,d=0;}r.mode=q5;case q5: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=G5;case G5:G=G7;break e;case De:G=w8;break e;case _8:return A8;case C8: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||p!==t.avail_out&&r.mode<De&&(r.mode<Yh||e!==A5))&&T8(t,t.output,t.next_out,p-t.avail_out),u-=t.avail_in,p-=t.avail_out,t.total_in+=u,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?it(r.check,n,p,t.next_out-p):Tc(r.check,n,p,t.next_out-p)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ki?128:0)+(r.mode===vd||r.mode===Zh?256:0),(u===0&&p===0||e===A5)&&G===Yo&&(G=V7),G},tE=t=>{if(Qo(t))return yr;let e=t.state;return e.window&&(e.window=null),t.state=null,Yo},rE=(t,e)=>{if(Qo(t))return yr;let r=t.state;return (r.wrap&2)===0?yr:(r.head=e,e.done=false,Yo)},iE=(t,e)=>{let r=e.length,i,n,o;return Qo(t)||(i=t.state,i.wrap!==0&&i.mode!==Pd)?yr:i.mode===Pd&&(n=1,n=Tc(n,e,r,0),n!==i.check)?w8:(o=T8(t,e,r,r),o?(i.mode=_8,A8):(i.havedict=1,Yo))},nE=v8,oE=E8,sE=I8,aE=Q7,cE=B8,lE=eE,dE=tE,uE=rE,fE=iE,pE="pako inflate (from Nodeca project)",ii={inflateReset:nE,inflateReset2:oE,inflateResetKeep:sE,inflateInit:aE,inflateInit2:cE,inflate:lE,inflateEnd:dE,inflateGetHeader:uE,inflateSetDictionary:fE,inflateInfo:pE};function hE(){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 mE=hE,k8=Object.prototype.toString,{Z_NO_FLUSH:gE,Z_FINISH:j5,Z_OK:ya,Z_STREAM_END:e2,Z_NEED_DICT:t2,Z_STREAM_ERROR:yE,Z_DATA_ERROR:X5,Z_MEM_ERROR:bE,Z_BUF_ERROR:W5}=wa,SE={chunkSize:1024*64,windowBits:15,to:""};function Oc(t){this.options=Rd.assign({},SE,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 y8,this.strm.avail_out=0;let r=ii.inflateInit2(this.strm,e.windowBits);if(r!==ya)throw new Error(Xo[r]);if(this.header=new mE,ii.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Pc.string2buf(e.dictionary):k8.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=ii.inflateSetDictionary(this.strm,e.dictionary),r!==ya)))throw new Error(Xo[r])}Oc.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?j5:gE,k8.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=ii.inflate(r,s),o===t2&&n&&(o=ii.inflateSetDictionary(r,n),o===ya?o=ii.inflate(r,s):o===X5&&(o=t2));r.avail_in>0&&o===e2&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)ii.inflateReset(r),o=ii.inflate(r,s);switch(o){case yE:case X5:case t2:case bE:return this.onEnd(o),this.ended=true,false}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===e2||s>0))if(this.options.to==="string"){let c=Pc.utf8border(r.output,r.next_out),l=r.next_out-c,d=Pc.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===ya||o===W5)&&a===0)){if(o===e2)return o=ii.inflateEnd(this.strm),this.onEnd(o),this.ended=true,true;if(r.avail_in===0){if(s===j5)return o=ii.inflateEnd(this.strm),this.onEnd(o===ya?W5:o),this.ended=true,false;break}}}return true};Oc.prototype.onData=function(t){this.chunks.push(t);};Oc.prototype.onEnd=function(t){t===ya&&(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 b2(t,e){let r=new Oc(e);if(r.push(t,true),r.err)throw r.msg||Xo[r.err];return r.result}var AE=b2,vE={inflate:AE},{deflate:EE}=D7,{inflate:BE}=vE;var P8=EE;var S2=BE;var TE=(0, D8.default)("bridge"),N8=32*1024,x2=1024*16,kE=1;function R8(t,e){return {jsonrpc:"2.0",id:ua(16),method:t,params:e}}async function PE(t,e,r,i){let n=[],o=[];if(e){let s=Buffer.from(P8(JSON.stringify(e))).toString("base64"),a=Math.ceil(s.length/x2),c=ua(16);for(let l=0;l<a;l++){let d=l*x2,u=Math.min(d+x2,s.length),p=s.slice(d,u),m=JSON.stringify({method:t,params:p,chunk:{id:c,index:l,length:a}}),b=await bc(m,r,i),w=R8("encryptedMessage",{payload:Buffer.from(b).toString("base64")});o.push(w.id),n.push(JSON.stringify(w));}}else {let s=JSON.stringify({method:t,params:e||{}}),a=await bc(s,r,i),c=R8("encryptedMessage",{payload:Buffer.from(a).toString("base64")});o.push(c.id),n.push(JSON.stringify(c));}return {chunks:n,messageIds:o}}async function w2(t,e,r,i,n){try{let{chunks:o,messageIds:s}=await PE(t,e,r,i);for(let a of o){if(a.length>N8)throw new Error(`Payload exceeds max size of ${N8} bytes`);n.send(a),o.length>1&&await new Promise(c=>setTimeout(c,kE));}return {success:!0,messageIds:s}}catch(o){return TE("Error sending encrypted message:",o),{success:false,messageIds:[]}}}var A2=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 O8=It(lc(),1);var _2=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, O8.default)(`bridge:${this.role}`),this.bridgeId=t.bridgeId||ua(16),this.keyPair=t.keyPair,this.reconnect=t.reconnect??true,this.keepalive=t.keepalive??true,this.maxReconnectAttempts=t.reconnectAttempts??I6,this.pingInterval=t.pingInterval||E6,this.bridgeUrl=t.bridgeUrl??v6,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 A2({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=xh(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?xh(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=Hh(this.keyPair.privateKey,e),await Kh(Buffer.from(t.params.greeting,"hex"),this.sharedSecret,this.bridgeId)!=="hello")throw new Error("Invalid greeting");this.websocket&&(await w2("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 Kh(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=S2(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=S2(d),p=new TextDecoder().decode(u),m=JSON.parse(p);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 w2(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=Hh(this.keyPair.privateKey,this.remotePublicKey);}async createEncryptedGreeting(){if(!this.sharedSecret)throw new Error("Shared secret not available");let t=await bc("hello",this.sharedSecret,this.bridgeId);return Buffer.from(t).toString("hex")}async _getWsConnectionUrl(){if(this.role==="creator")return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}`;{let t=this.originOnConnect?"&ooc":"";if(this.isSecureChannelEstablished())return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}`;{let e=await this.createEncryptedGreeting(),r=JSON.stringify({jsonrpc:"2.0",id:ua(16),method:"handshake",params:{pubkey:this.getPublicKey(),greeting:e}}),i=Buffer.from(r).toString("base64");return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}&moc=${encodeURIComponent(i)}${t}`}}}getPublicKey(){return uc(this.keyPair.publicKey)}getRemotePublicKey(){if(!this.remotePublicKey)throw new Error("Remote public key not set");return uc(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=${da}${e}`:`obsidion:${this.getBridgeId()}?d=${t}&v=${da}${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 C2=It(lc(),1),I2=class M8{static async create(e={}){e.debug&&C2.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||Ad(),o=uc(n.publicKey),s=new _2({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&&C2.default.enable("bridge*"),r.resume&&!r.keyPair)throw new Error("Resuming a bridge session requires a keyPair");let i=r.keyPair||Ad(),{domain:n,pubkey:o,ooc:s}=M8.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 _2({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 Ad()}};var Kd=It(q8(),1);var G8={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 Y8={debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}};(0, Kd.registerLocale)(G8);function qi(t){if(t==="Zero Knowledge Republic")return "ZKR";let e;return e=(0, Kd.getAlpha3Code)(t,"en")||t||"ZKR",e}function Fn(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function dS(t,e,r,i){i[r][t]={...i[r][t],range:e};}function Ia(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function qE(){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=qi(s)),Ia("eq",o,s,e,t),n),gte:(o,s)=>{if(i("gte"),Fn("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"),Fn("gt",o,s,e,t),n),lte:(o,s)=>(i("lte"),Fn("lte",o,s,e,t),n),lt:(o,s)=>(i("lt"),Fn("lt",o,s,e,t),n),range:(o,s,a)=>(i("range"),dS(o,[s,a],e,t),n),in:(o,s)=>(i("in"),s=s.map(a=>qi(a)),Ia("in",o,s,e,t),n),out:(o,s)=>(i("out"),s=s.map(a=>qi(a)),Ia("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 GE="0.19.1",R2=GE,gt=10080*60,Un=new Date(0),uS="https://dashboard-api.zkpassport.id",$E="https://verifier.zkpassport.id",Q8="0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b",J8="0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d",eS="0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b",tS="0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211",rS="0x0e1889bec6c1d686abcf08360ff404f803ab345881ea8cba6aad33b7f7f7ffe0",iS=1440*60*1e3,VE=class{static checkDiscloseBytesPublicInputs(t,e,r){let i={},n=true,o=t.committedInputs?.disclose_bytes?.disclosedBytes??t.committedInputs?.disclose_bytes_evm?.disclosedBytes,s=$p.fromDisclosedBytes(o,"passport"),a=$p.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=Bb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm),a=Tb(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=Pb(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Uo),a=Nb(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Uo);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,Un)&&(console.warn("Maximum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Un.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,Un)&&(console.warn("Minimum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Un.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,Un)&&(console.warn("Maximum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Un.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,Un)&&(console.warn("Minimum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Un.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(sc(t)!==Qp(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: ${sc(t).toString()}`,received:`Scope: ${Qp(e).toString()}`,message:"The proof comes from a different domain than the one expected"}),ia(n)!==Yp(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: ${ia(n).toString()}`,received:`Scope: ${Yp(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??bh(zp(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!==eS&&r.rootKeyLeaf!==tS&&r.rootKeyLeaf!==rS&&(console.warn("Invalid facematch root key hash"),i=false,n.facematch={...n.facematch,eq:{expected:`${eS} (iOS) or ${tS} (Android) or ${rS} (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!==Q8&&r.appIdHash!==J8&&(console.warn("Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"),i=false,n.facematch={...n.facematch,eq:{expected:`${Q8} (iOS) or ${J8} (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=Jp(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()>iS&&(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 p=["firstname","lastname","fullname","document_number","document_type","gender"];for(let m of p)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,p,m,b,w=new Date,x=new Date(w.getFullYear(),w.getMonth(),w.getDate(),0,0,0,0),g={},A=["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 A.findIndex(W=>z.startsWith(W))};return q(k)-q(E)}),_=A.slice(3),C=I.find(k=>_.some(E=>k.name?.startsWith(E))),v=C?Jp(na(C.proof,ra(C.name))):void 0,T=v?Math.floor(v.getTime()/1e3):void 0;for(let k of I){let E=na(k.proof,ra(k.name));if(k.name?.startsWith("outer")){let q=k.name?.startsWith("outer_evm"),O=Qb(E),z=Math.floor(O.getTime()/1e3),W=Zb(E),{isCorrect:Y,queryResultErrors:oe}=await this.checkCertificateRegistryRoot(W.toString(16),g,true,a,z,r,c);u=u&&Y,g={...g,...oe};let te=Yb(E),{isCorrect:$,queryResultErrors:R}=await this.checkCircuitRegistryRoot(te.toString(16),g,a,z,r,c);u=u&&$,g={...g,...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,g.outer={...g.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()>iS&&(console.warn("The date used to check the validity of the ID is in the future"),u=false,g.outer={...g.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=ih(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,g.outer={...g.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"}}),sc(t)!==th(E)&&(console.warn("The proof comes from a different domain than the one expected"),u=false,g.outer={...g.outer,scope:{expected:`Scope: ${sc(t).toString()}`,received:`Scope: ${th(E).toString()}`,message:"The proof comes from a different domain than the one expected"}}),ia(o)!==rh(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,g.outer={...g.outer,scope:{expected:`Scope: ${ia(o).toString()}`,received:`Scope: ${rh(E).toString()}`,message:D}};}if(L?.compare_age||L?.compare_age_evm){let D=L?.compare_age??L?.compare_age_evm,X=q?await kb(D.minAge,D.maxAge):await jp(D.minAge,D.maxAge);K.includes(X)||(console.warn("This proof does not verify the age"),u=false,g.age={...g.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,g={...g,...ne};}if(L?.compare_birthdate||L?.compare_birthdate_evm){let D=L?.compare_birthdate??L?.compare_birthdate_evm,X=q?await Xp(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0):await nc(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0);K.includes(X)||(console.warn("This proof does not verify the birthdate"),u=false,g.birthdate={...g.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,g={...g,...ne};}if(L?.compare_expiry||L?.compare_expiry_evm){let D=L?.compare_expiry??L?.compare_expiry_evm,X=q?await Xp(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp):await nc(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp);K.includes(X)||(console.warn("This proof does not verify the expiry date"),u=false,g.expiry_date={...g.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,g={...g,...ne};}if(L?.disclose_bytes||L?.disclose_bytes_evm){let D=L?.disclose_bytes??L?.disclose_bytes_evm,X=q?await Eb(D.discloseMask,D.disclosedBytes):await Vp(D.discloseMask,D.disclosedBytes);K.includes(X)||(console.warn("This proof does not verify any of the data disclosed"),u=false,g.disclose={...g.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,g={...g,...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 ic(fe.NATIONALITY_INCLUSION,D.countries):await Oi(fe.NATIONALITY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the nationality"),u=false,g.nationality={...g.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,g={...g,...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 ic(fe.ISSUING_COUNTRY_INCLUSION,D.countries):await Oi(fe.ISSUING_COUNTRY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the issuing country"),u=false,g.issuing_country={...g.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,g={...g,...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 ic(fe.NATIONALITY_EXCLUSION,D.countries):await Oi(fe.NATIONALITY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the nationality"),u=false,g.nationality={...g.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,g={...g,...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 ic(fe.ISSUING_COUNTRY_EXCLUSION,D.countries):await Oi(fe.ISSUING_COUNTRY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the issuing country"),u=false,g.issuing_country={...g.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,g={...g,...le};}if(L?.bind||L?.bind_evm){let D=L?.bind??L?.bind_evm,X=q?await Ob(oc(D.data)):await Wp(oc(D.data));K.includes(X)||(console.warn("This proof does not verify the bound data"),u=false,g.bind={...g.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,g={...g,...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 Wb(D.rootHash,D.isStrict):await eh(D.rootHash,D.isStrict);K.includes(X)||(console.warn("This proof does not verify the exclusion from the sanction lists"),u=false,g.sanctions={...g.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,g={...g,...ne};}if(L?.facematch||L?.facematch_evm){let D=L?.facematch??L?.facematch_evm,X=q?await Fb(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n):await Zp(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,g.facematch={...g.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,g={...g,...ne};}p=e6(E).toString(10),m=Jb(E),b=t6(E);}else if(k.name?.startsWith("sig_check_dsc")){d=Cb(E);let q=_b(E),{isCorrect:O,queryResultErrors:z}=await this.checkCertificateRegistryRoot(q.toString(16),g,false,a,T,r,c);u=u&&O,g={...g,...z};}else if(k.name?.startsWith("sig_check_id_data"))l=Rb(E),l!==d&&(console.warn("Failed to check the link between the certificate signature and ID signature"),u=false,g.sig_check_id_data={...g.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=Db(E);else if(k.name?.startsWith("data_check_integrity"))l=Ib(E),l!==d&&(console.warn("Failed to check the link between the ID signature and the data signed"),u=false,g.data_check_integrity={...g.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=vb(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,g.disclose={...g.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 Vp((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,g.disclose={...g.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,g,"disclose",o);u=u&&z,g={...g,...W};let{isCorrect:Y,queryResultErrors:oe}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Y&&z,g={...g,...oe,...W};let{isCorrect:te,queryResultErrors:$}=await this.checkCurrentDate("disclose",E,n??gt,g);u=u&&te,g={...g,...$},p=Pr(E).toString(10),m=Nr(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,g.age={...g.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 jp(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,g.age={...g.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,g,"age",o),{isCorrect:oe,queryResultErrors:te}=this.checkAgePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("age",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.birthdate={...g.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 nc(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,g.birthdate={...g.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,g,"birthdate",o),{isCorrect:oe,queryResultErrors:te}=this.checkBirthdatePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("birthdate",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.expiry_date={...g.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 nc(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,g.expiry_date={...g.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,g,"expiry_date",o),{isCorrect:oe,queryResultErrors:te}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("expiry_date",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.nationality={...g.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 Oi(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,g.nationality={...g.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,g,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityExclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.issuing_country={...g.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 Oi(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,g.issuing_country={...g.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,g,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryExclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.nationality={...g.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 Oi(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,g.nationality={...g.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,g,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityInclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.issuing_country={...g.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 Oi(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,g.issuing_country={...g.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,g,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryInclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.bind={...g.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 Wp(oc(q.data));O!==z&&(console.warn("The bound data does not match the one from the proof"),u=false,g.bind={...g.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,g,"bind",o),{isCorrect:oe,queryResultErrors:te}=this.checkBindPublicInputs(r,i,q.data);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("bind",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.sanctions={...g.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 eh(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,g.sanctions={...g.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,g,"sanctions",o),{isCorrect:oe,queryResultErrors:te}=await this.checkSanctionsExclusionPublicInputs(r,i,q,a,T,c);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("sanctions",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.facematch={...g.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 Zp(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,g.facematch={...g.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,g,"facematch",o),{isCorrect:oe,queryResultErrors:te}=await this.checkFacematchPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("facematch",E,n??gt,g);u=u&&$,g={...g,...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,g={...g,...H},u&&m&&(m===Pe.SALTED||m===Pe.SALTED_MOCK))try{let k=await jb(s??Vb),E=await Xb(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=na(O.proof,ra(O.name));q=Lb(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?(p!==void 0&&BigInt(p)!==0n&&(console.warn("Proofs with the NONE nullifier type cannot carry a unique identifier"),u=false),p=void 0):p!==void 0&&BigInt(p)===0n&&(p=void 0),{isCorrect:u,uniqueIdentifier:p,uniqueIdentifierType:m,queryResultErrors:g}}},jE={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}]},nS=class{static getDetails(){return {functionName:"verify",abi:jE.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=na(t.proof,ra(t.name)),s=[],a=[];for(let p in t.committedInputs){let m=Hb(p),b=p;s.push({circuitName:b,count:m});let w="";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((A,I)=>A.localeCompare(I));let g=(()=>{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}})();w=g.toString(16).padStart(2,"0")+se[g].evm.toString(16).padStart(4,"0")+Oo(x.map(A=>Array.from(new TextEncoder().encode(A))).flat(),600).map(A=>A.toString(16).padStart(2,"0")).join("");}else if(b==="compare_age_evm"){let x=t.committedInputs[b];w=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],g=Array.from(Te(x.minDateTimestamp,8)),A=Array.from(Te(x.maxDateTimestamp,8));w=fe.BIRTHDATE.toString(16).padStart(2,"0")+se[fe.BIRTHDATE].evm.toString(16).padStart(4,"0")+g.map(I=>I.toString(16).padStart(2,"0")).join("")+A.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="compare_expiry_evm"){let x=t.committedInputs[b],g=Array.from(Te(x.minDateTimestamp,8)),A=Array.from(Te(x.maxDateTimestamp,8));w=fe.EXPIRY_DATE.toString(16).padStart(2,"0")+se[fe.EXPIRY_DATE].evm.toString(16).padStart(4,"0")+g.map(I=>I.toString(16).padStart(2,"0")).join("")+A.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="disclose_bytes_evm"){let x=t.committedInputs[b];w=fe.DISCLOSE.toString(16).padStart(2,"0")+se[fe.DISCLOSE].evm.toString(16).padStart(4,"0")+x.discloseMask.map(g=>g.toString(16).padStart(2,"0")).join("")+x.disclosedBytes.map(g=>g.toString(16).padStart(2,"0")).join("");}else if(b==="bind_evm"){let x=t.committedInputs[b];w=fe.BIND.toString(16).padStart(2,"0")+se[fe.BIND].evm.toString(16).padStart(4,"0")+Oo(oc(x.data),509).map(g=>g.toString(16).padStart(2,"0")).join("");}else if(b==="exclusion_check_sanctions_evm"){let x=t.committedInputs[b];w+=fe.SANCTIONS_EXCLUSION.toString(16).padStart(2,"0"),w+=se[fe.SANCTIONS_EXCLUSION].evm.toString(16).padStart(4,"0"),w+=Array.from(Te(BigInt(x.rootHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.isStrict?"01":"00";}else if(b.startsWith("facematch")&&b.endsWith("_evm")){let x=t.committedInputs[b];w+=fe.FACEMATCH.toString(16).padStart(2,"0"),w+=se[fe.FACEMATCH].evm.toString(16).padStart(4,"0"),w+=Array.from(Te(BigInt(x.rootKeyLeaf),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.environment==="development"?"00":"01",w+=Array.from(Te(BigInt(x.appIdHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=Array.from(Te(BigInt(x.integrityPubkeyHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.mode==="regular"?"01":"02";}else throw new Error(`Unsupported circuit for EVM verification: ${b}`);a.push({circuitName:b,inputs:w});}let c=ih(o).map(p=>p.toString(16).padStart(64,"0")),l="";for(let p of c){let m=a.find(b=>{let w=ot(Vn(b.inputs)),x=new Uint8Array(w.length);for(let g=0;g<w.length-1;g++)x[g+1]=w[g];return x[0]=0,$n(x)===p.replace("0x","")});if(m)if(s.find(w=>w.circuitName===m.circuitName)?.count)l+=m.inputs;else throw new Error(`Unknown circuit name: ${m.circuitName}`);else throw new Error(`Invalid commitment: ${p}`)}let d=t.version?.split(".").map(p=>Number(p));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${$n(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 XE({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(`${uS}/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:R2,requestId:s}),signal:AbortSignal.timeout(3e4)});c.ok?Y8.debug("API response status:",c.status):Y8.warn("API request failed with status:",c.status);}catch{}}var WE=[0,20,0];function ZE(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]=WE;return r!==o?r>o?"v5":"v4":i!==s?i>s?"v5":"v4":n>=a?"v5":"v4"}async function YE(t,{writingDirectory:e}={}){await QE(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(V8(),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(X8(),1)),o=await n.new({crsPath:r});return {verifier:new i(o),destroy:()=>o.destroy()}}var oS="__zkpassport_bb_version",sS="keyval-store";async function QE(t){if(!(typeof indexedDB>"u"))try{let e=typeof localStorage<"u"?localStorage:void 0;if((e?.getItem(oS)??"v4")===t)return;let r=!0;if(typeof indexedDB.databases=="function")try{r=(await indexedDB.databases()).some(i=>i.name===sS);}catch{r=!0;}r&&await new Promise(i=>{let n=indexedDB.deleteDatabase(sS);n.onsuccess=n.onerror=n.onblocked=()=>i();}),e?.setItem(oS,t);}catch{}}async function aS({proofs:t,originalQuery:e,queryResult:r,domain:i,validity:n,scope:o,devMode:s,oprfKeyId:a}){try{let c=await fetch(`${$E}/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=Jo.Buffer,typeof window<"u"&&(window.Buffer=Jo.Buffer));var cS="Verify identity privately";function JE({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 eB(t,e){if(e==null||!t.verified||JE(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 lS=false;function tB(){lS||(lS=true,console.warn("[zkpassport] onResult is deprecated. Use onSuccess and verify the proofs on your backend with verify()."));}function rB(t){let e=t.connection.getWebSocket();if(e)try{e.send(JSON.stringify({method:"replay",params:{timestamp:1}}));}catch{}}var D2=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&&XE({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]=qp(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=qi(r)),Ia("eq",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),gte:(e,r)=>{if(this.assertNotPolicyLocked(t,"gte"),Fn("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"),Fn("gt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lte:(e,r)=>(this.assertNotPolicyLocked(t,"lte"),Fn("lte",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lt:(e,r)=>(this.assertNotPolicyLocked(t,"lt"),Fn("lt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),range:(e,r,i)=>(this.assertNotPolicyLocked(t,"range"),dS(e,[r,i],t,this.topicToConfig),this.getZkPassportRequest(t)),in:(e,r)=>(this.assertNotPolicyLocked(t,"in"),r=r.map(i=>qi(i)),Ia("in",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),out:(e,r)=>(this.assertNotPolicyLocked(t,"out"),r=r.map(i=>qi(i)),Ia("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||cS),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=>{tB(),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=`${uS}/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:p,cloudProverUrl:m,bridgeUrl:b,returnDeepLink:w,verifierMode:x,config:g,overrides:A}){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 I2.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||cS,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:w,verifierMode:x,config:g,appClip:A?.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=>{p&&!v&&rB(_),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 qE()}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 p={proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o,oprfKeyId:a},m={...p,writingDirectory:s,config:d},b={...p,domain:this.domain},w=a?Pe.SALTED:c,x;if(l==="local")x=await this.verifyLocally(m);else if(l==="api")x=await aS(b)??u;else {let g;try{g=await this.verifyLocally(m);}catch(A){console.warn("Local proof verification failed:",A);}x=g?.verified?g:await aS(b)??g??u;}return eB(x,w)}async verifyLocally({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,config:c}){let l=qp(r);typeof window>"u"&&!s&&(s="/tmp");let d=ZE(t[0]?.version),u,p=true,m,b,w;try{let x=bh(zp(e,o),c),{isCorrect:g,uniqueIdentifier:A,uniqueIdentifierType:I,queryResultErrors:_}=await VE.checkPublicInputs(this.domain,t,e,l,i,n,a,o,x);if(m=A,b=I,p=g,w=g?void 0:_,(b===Pe.SALTED_MOCK||b===Pe.NON_SALTED_MOCK)&&!o&&(p=!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.")),p){let C=await x.getCircuitManifest(void 0,{version:t[0].version});u=await YE(d,{writingDirectory:s});for(let v of t){let T=v.name?.startsWith("outer_evm_"),G=v.name,F=na(v.proof,ra(G)),H=await x.getPackagedCircuit(G,C,{validate:!T});if(T)try{let{createPublicClient:k,http:E}=await Promise.resolve().then(()=>It(Z8(),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]});p=Array.isArray(oe)?!!oe[0]:!1;}catch(k){console.warn("Error verifying proof",k),p=!1;}else {let k=Jo.Buffer.from(H.vkey,"base64");try{p=await u.verifier.verifyProof({proof:Jo.Buffer.from(F.proof.join(""),"hex"),publicInputs:F.publicInputs,verificationKey:new Uint8Array(k)});}catch(E){console.warn(`Error verifying proof ${G}`,E),p=!1;}}if(!p)break}}}finally{await u?.destroy();}return m=p?m:void 0,b=p?b:void 0,{uniqueIdentifier:m,uniqueIdentifierType:b,verified:p,queryResultErrors:w}}getSolidityVerifierDetails(){return nS.getDetails()}getSolidityVerifierParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){return nS.getParameters({proof:t,validityPeriodInSeconds:e,domain:r??this.domain,scope:i,devMode:n})}_getUrl(t){let e=Jo.Buffer.from(JSON.stringify(this.topicToConfig[t])).toString("base64"),r=Jo.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=${R2}&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 iB(){try{return typeof localStorage<"u"&&localStorage.getItem("zkpassport:debug")==="1"}catch{return false}}var ai={error(...t){console.error(zd,...t);},warn(...t){console.warn(zd,...t);},info(...t){console.info(zd,...t);},debug(...t){iB()&&console.debug(zd,...t);}};function pS(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),[p,m]=Ht(null),[b,w]=Ht(0),[x,g]=Ht({received:0,total:null}),A=Ur(t);A.current=t;let I=Ur(null),_=Ur("preparing"),C=Ur(e),v=Ur(false),T=Ur(null),G=Ur(null);G.current===null&&(G.current=new D2(t.domain)),rs(()=>{let k=G.current,E=false,q=false,O=null,z=A.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),g({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}=A.current;X&&A.current.onSuccess&&ai.warn("onResult is deprecated and drives the card; onSuccess return values are ignored");let _e=()=>{q||(q=true,br(A.current.onReady));},Oe=false,Ne=yt=>{Oe=true,C.current=false,v.current=true,i(yt);},Fe=(yt,ye)=>{ai.error(ye),Ne("error");let Gi=ye instanceof Error?ye.message:String(ye);br(A.current.onError,`${yt}: ${Gi}`);},ge=yt=>(...ye)=>{if(!E)try{yt(...ye);}catch(Gi){Fe("Failed to handle a verification update",Gi);}},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(A.current.onBridgeConnect);})),ye.onBridgeConnectionLost(ge(()=>{Oe||(Ne("error"),br(A.current.onError,"The connection to your phone was lost."));})),ye.onRequestReceived(ge(()=>{Le("scanned",!0),br(A.current.onRequestReceived);})),ye.onGeneratingProof(ge(()=>{Le("generating",!0),br(A.current.onGeneratingProof);})),ye.onProofGenerated(ge(Re=>{g($i=>({received:$i.received+1,total:Re.total??$i.total})),br(A.current.onProofGenerated,Re);})),ye.onSuccess(ge(Re=>{if(X){br(A.current.onSuccess,Re);return}let $i=Ln=>{E||Ne(Ln);},L2;try{L2=A.current.onSuccess?.(Re);}catch(Ln){ai.error(Ln),$i("error");return}Promise.resolve(L2).then(Ln=>$i(Ln===!1?"error":"success"),Ln=>{ai.error(Ln),$i("error");});})),X&&ye.onResult(ge(Re=>{Ne(Re.verified?"success":"error"),br(A.current.onResult,Re);})),ye.onReject(ge(()=>{Ne("error"),br(A.current.onReject);})),ye.onError(ge(Re=>{Ne("error"),br(A.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){ai.error(Re);}let Gi=JSON.stringify(ye.query);z&&v.current&&Gi!==T.current&&(C.current=true,i("intro")),T.current=Gi;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(nB(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=su(()=>{br(A.current.onRetryClicked),w(k=>k+1);},[]),H=su(()=>{C.current=false,v.current=true,i(_.current);},[]);return {state:r,url:n,qrSvg:s,query:c,serviceName:d,serviceLogo:p,retry:F,continueWithPhone:H,proofProgress:x}}function nB(t){let e=fS.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,p)=>s.some(([m,b])=>u>=m&&u<m+7&&p>=b&&p<b+7),c="",l=n*.47;for(let u=0;u<r;u++)for(let p=0;p<r;p++){if(!i[u*r+p]||a(u,p))continue;let m=(p+.5)*n,b=(u+.5)*n;c+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(l)}"/>`;}let d="";for(let[u,p]of s){let m=(p+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 hS(t,{probe:e}){let[r,i]=Ht("idle"),n=Ur(null);return rs(()=>(i("idle"),()=>n.current?.()),[t]),{openState:r,openApp:()=>{if(t){if(n.current?.(),!e){n.current=uu(t);return}i("opening"),n.current=uu(t,s=>i(s?"opened":"nothing-opened"));}}}}var oB={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"},sB=["birthdate","expiry_date"],mS=["nationality","issuing_country"],gS=["firstname","lastname","fullname","gender","birthdate","age","document_type","document_number","nationality","issuing_country","expiry_date"],ci={disclose:0,age:1,date:2,country:3,field:4,sanctions:5,facematch:6,bind:7},aB=3,cB={year:"numeric",month:"long",day:"numeric"};function yS(t){return t.toLocaleDateString(void 0,cB)}var lB={passport:"passport",id_card:"ID card",residence_permit:"residence permit"},dB={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 yS(e);if(sB.includes(t)&&(typeof e=="string"||typeof e=="number")){let r=new Date(e);if(!Number.isNaN(r.getTime()))return yS(r)}return t==="document_type"&&typeof e=="string"?lB[e]??e.replace(/_/g," "):String(e)}function uB(t,e){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} ${e} ${t[t.length-1]}`}function O2(t){return oB[t]??String(t).replace(/_/g," ")}function bS(t,e,r){let i=O2(t),n=e.map(c=>Wt(t,c)).sort((c,l)=>c.localeCompare(l)),o=mS.includes(t)?ci.country:ci.field;if(n.length<=aB){let c=r?n.length===1?`is not ${n[0]}`:`is not any of ${n.join(", ")}`:`is ${uB(n,"or")}`;return {title:`Your ${i} ${c}`,group:o}}let s=mS.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 fB(t,e,r){let i=O2(t);if(t==="age"){let n=ci.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=ci.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=ci.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 ${dB[String(e.eq)]??Wt(t,e.eq)}`:`Your ${i} is ${Wt(t,e.eq)}`,group:ci.field}),e.in!=null&&r.push(bS(t,e.in,false)),e.out!=null&&r.push(bS(t,e.out,true));}function pB(t){return t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function hB(t){let{user_address:e,chain:r,custom_data:i}=t,n="Bound to",o=[];if(r&&o.push({label:"Chain",value:pB(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 mB(t){let e=i=>{let n=gS.indexOf(i);return n===-1?gS.length:n};return (t.includes("fullname")?t.filter(i=>i!=="firstname"&&i!=="lastname"):t).map(i=>({title:`Share your ${O2(i)}`,group:ci.disclose,order:e(i)}))}function SS(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:ci.sanctions});continue}if(i==="facematch"){e.push({title:"Your face matches your ID photo",group:ci.facematch});continue}if(i==="bind"){e.push({...hB(n),group:ci.bind});continue}if(i==="policy")continue;let o=i;n.disclose&&r.push(o),fB(o,n,e);}return e.push(...mB(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:gB()?false:!!(/iPhone|iPad|iPod/.test(t)&&/AppleWebKit/.test(t)&&!/Safari\//.test(t))}function gB(){return navigator.standalone===true}var yB=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:--yB,__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 M2({options:t,controlRef:e}){lm(BB,[]);let{state:r,url:i,qrSvg:n,query:o,serviceName:s,serviceLogo:a,retry:c,continueWithPhone:l,proofProgress:d}=pS(t);rs(()=>{if(e)return e.current={retry:c},()=>{e.current=null;}},[c,e]);let u=t.display?.header??true,p=t.display?.steps??true,m=t.display?.appLinks??true,b=t.display?.frame??true,w=t.name??s??t.domain??"",x=t.logo??a??"",g=r==="scanned"||r==="generating"||r==="success"||r==="error",A=!!o?.facematch,I=AB(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=_B(r,g,A,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:bm}}):null,u?U(Sr,{children:[U("div",{className:"zkp-header",children:[U("div",{className:"zkp-header-icons",children:[U("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:Ba}}),x?U(Sr,{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:w?`${w} icon`:""})})]}):null]}),U("p",{className:"zkp-title",children:[U("strong",{children:w||"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(wB,{appName:w||"This app",items:SS(o),purpose:t.purpose,loading:o===null,onContinue:l}):U("div",{className:"zkp-screen",children:[H?U(vB,{requestUrl:r==="waiting"?i:null,inAppBrowser:G,onRevealQr:()=>v(true)}):U(CB,{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,p&&k.length>0?U(Sr,{children:[U("div",{className:"zkp-divider zkp-divider-top"}),U("div",{className:"zkp-steps",children:k.map(E=>U(IB,{status:E.status,icon:E.icon,children:E.label},E.key))})]}):null,m&&!H?U("div",{className:`zkp-collapse${g?" 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:lu}),U($d,{href:is,badge:du})]})]})]})}):null,r==="error"?U("div",{className:"zkp-result-actions",children:U("button",{type:"button",className:"zkp-retry",onClick:c,children:"Try again"})}):null]})]})}var bB=2;function SB({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 xB='<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 wB({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:bB},(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(SB,{item:o},s):U("li",{children:[U("span",{className:"zkp-intro-check",dangerouslySetInnerHTML:{__html:ns}}),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:xB}}),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 AB(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 _B(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(Sr,{children:[U("a",{href:fm,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),status:d,icon:e?null:mm},{key:"scan",label:n?"Tap \u201COpen ZKPassport App\u201D above.":"Scan this QR code with the ZKPassport app.",status:d,icon:e?null:pm},{key:"approve",label:"Approve the request on your phone.",status:t==="scanned"?"current":s||o?"done":"pending",icon:e?null:hm}];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 CB({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:Ba}}):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:cu}}):null,t==="scanned"?U("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:ym}}):null,t==="success"?U("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:ns}}):null,t==="error"?U("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:gm}}):null]}),r?U("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function IB({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??ns}}),U("div",{className:"zkp-step-text",children:r})]})}function vB({requestUrl:t,inAppBrowser:e,onRevealQr:r}){let{openState:i,openApp:n}=hS(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:cu}}):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(EB,{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 EB({requestUrl:t,appNotFound:e}){let r=wm();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:lu}):null,r!=="ios"?U($d,{href:xm(t),badge:du}):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 BB(){e1(Am,"card");}var xS=`@layer zkpassport {
1029
+ `,o=[`-----BEGIN ${t}-----`];if(r.headers){for(let[s,a]of Object.entries(r.headers))o.push(`${s}: ${a}`);o.push("");}return o.push(...HA(pn.encode(e),i)),o.push(`-----END ${t}-----`),`${o.join(n)}${n}`}function T3(t,e={}){return B3(t,e).map(({lineLength:r,newline:i,...n})=>n)}function k3(t,e){let[r]=T3(t,{label:e,strict:true});return r.data}function P3(t,e={}){let[r]=B3(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 N3(t,e){return dl(e.label,t,e)}var p0={name:"pem",encode:(t,e)=>{if(!e?.label)throw new TypeError("PEM label is required");return dl(e.label,t,e)},decode:(t,e)=>k3(t,e?.label),format:N3,is:t=>typeof t=="string"&&/-----BEGIN [^-]+-----/.test(t),parse:P3};function jr(t){return t.trim().toLowerCase()}function qA(t){return t instanceof Error?t:new Error(String(t))}function R3(t,e,r){for(let i of [r.name,...r.aliases??[]])t.delete(jr(i));e.delete(jr(r.name));}function Tf(t,e,r){let i=t[r];if(typeof i!="function")throw new Error(`Converter '${e}' does not support ${r}()`);return i}function GA(t,e,r){let i=jr(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 kf(t=[]){let e=new Map,r=new Set,i={register(n,o={}){if(!n.name||!jr(n.name))throw new TypeError("Converter name is required");let s=[...new Set([n.name,...n.aliases??[]].map(jr))],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)R3(e,r,c);for(let c of s)e.set(c,n);return r.add(jr(n.name)),this},unregister(n){let o=e.get(jr(n));return o?(R3(e,r,o),true):false},has(n){return e.has(jr(n))},get(n){let o=e.get(jr(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:qA(a)}}},normalize(n,o,s){let a=this.get(n);return Tf(a,n,"normalize").call(a,o,s)},parse(n,o,s){let a=this.get(n);return Tf(a,n,"parse").call(a,o,s)},format(n,o,s){let a=this.get(n);return Tf(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(jr(c))),a=new Map;for(let c of s){let l=this.get(c),d=GA(c,n,l);if(d<=0)continue;let u=l.name,p=a.get(u);(!p||d>p.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 D3={name:"binary",aliases:["latin1"],encode:Ii.encode,decode:Ii.decode,is:Ii.is},O3={name:"hex",encode:tt.encode,decode:tt.decode,format:tt.format,is:tt.is,normalize:tt.normalize,parse:tt.parse},M3={name:"base64",aliases:["b64"],encode:er.encode,decode:er.decode,is:er.is,normalize:er.normalize},U3={name:"base64url",aliases:["base64-url","b64url"],encode:vr.encode,decode:vr.decode,is:vr.is,normalize:vr.normalize},F3={name:"utf8",aliases:["utf-8"],encode:t=>fn.decode(t),decode:t=>fn.encode(t),is:t=>typeof t=="string"},L3={name:"utf16be",aliases:["utf16","utf-16","utf-16be"],encode:t=>Vr.decode(t),decode:t=>Vr.encode(t),is:t=>typeof t=="string"},H3={name:"utf16le",aliases:["utf-16le","ucs2","usc2"],encode:t=>Vr.decode(t,{littleEndian:true}),decode:t=>Vr.encode(t,{littleEndian:true}),is:t=>typeof t=="string"},K3=[D3,O3,M3,U3,F3,L3,H3,p0];kf(K3);({toBase64:er.encode,toBase64Url:vr.encode,toHex:tt.encode,toBinary:Ii.encode,toUtf8String:fn.decode,isHex:tt.is,isBase64:er.is,isBase64Url:vr.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 vi=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($r(e))this.unusedBits=r,this.value=Ae(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Ir))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=Ae(e.valueBlock.valueHex),this}toASN(){return new Ir({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Ir({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):$r(e)?this.buffer=Ae(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 Cr))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=Ae(e.valueBlock.valueHex),this}toASN(){return new Cr({valueHex:this.buffer})}toSchema(e){return new Cr({name:e})}};var QA={fromASN:t=>t instanceof _r?null:Ae(t.valueBeforeDecodeView),toASN:t=>{if(t===null)return new _r;let e=Ci(t);if(e.result.error)throw new Error(e.result.error);return e.result}},JA={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Ai({value:+t})},e_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ro({value:t})},he={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Ai({valueHex:t})};var t_={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Ir({valueHex:t})},r_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new io({value:t})},i_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new no({value:t})},n_={fromASN:t=>t.valueBlock.value,toASN:t=>new to({value:t})},As={fromASN:t=>Ae(t.valueBlock.valueHexView),toASN:t=>new Cr({valueHex:t})},q3={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 o_=tr(Jt),s_=tr(oo),a_=tr(so),c_=tr(ao),l_=tr(co),d_=tr(lo),u_=tr(uo),f_=tr(fo),p_=tr(po),h_=tr(dn),m_=tr(ho),g_=tr(mo),y_={fromASN:t=>t.toDate(),toASN:t=>new un({valueDate:t})},b_={fromASN:t=>t.toDate(),toASN:t=>new go({valueDate:t})},S_={fromASN:()=>null,toASN:()=>new _r};function hn(t){switch(t){case S.Any:return QA;case S.BitString:return t_;case S.BmpString:return s_;case S.Boolean:return n_;case S.CharacterString:return g_;case S.Enumerated:return e_;case S.GeneralString:return m_;case S.GeneralizedTime:return b_;case S.GraphicString:return p_;case S.IA5String:return f_;case S.Integer:return JA;case S.Null:return S_;case S.NumericString:return c_;case S.ObjectIdentifier:return r_;case S.RelativeObjectIdentifier:return i_;case S.OctetString:return As;case S.PrintableString:return l_;case S.TeletexString:return d_;case S.UTCTime:return y_;case S.UniversalString:return a_;case S.Utf8String:return o_;case S.VideotexString:return u_;case S.VisibleString:return h_;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 Df(t){if(t){let e=Object.getPrototypeOf(t);return e?.prototype?.constructor===Array?true:Df(e)}return false}function G3(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=Gr[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 Kr({name:a}):(c=this.create(s.type,false),c.name=a):c=new Kr({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 yo({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 y=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=hn(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 mn=class extends Error{constructor(){super(...arguments);f(this,"schemas",[]);}};var _s=class{static parse(e,r,i){let n=Ci(Ae(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 Df(r)?this.handleArrayTypes(e,n,r,i):(this.processSchemaItems(n,a,c,i),c)}catch(n){throw n instanceof mn&&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=Si({},e,n);if(!o.verified)throw new mn(`Data does not match to ${i.name} ASN1 schema.${o.result.error?` ${o.result.error}`:""}`);return o}else {let o=Si({},e,n);if(!o.verified)throw new mn(`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=hn(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=hn(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 mn&&/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=hn(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=Ci(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=Gr[c];if(!l)throw new Error(`Cannot get '${c}' class from asn1js module`);a=new l;}a.valueBlock=s.valueBlock,s=Ci(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 mn&&/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 Cs=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=hn(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"&&G3(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 _r?Ae(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 Cs.serialize(e)}static parse(e,r,i){return _s.parse(e,r,i)}static toString(e,r){let i=$r(e)?Ae(e):t.serialize(e),n=Ci(i,r?.berOptions);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function h(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 h0=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 Of,Mf,Uf,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||""}};h([y({type:S.TeletexString})],nr.prototype,"teletexString",void 0);h([y({type:S.PrintableString})],nr.prototype,"printableString",void 0);h([y({type:S.UniversalString})],nr.prototype,"universalString",void 0);h([y({type:S.Utf8String})],nr.prototype,"utf8String",void 0);h([y({type:S.BmpString})],nr.prototype,"bmpString",void 0);nr=h([N({type:B.Choice})],nr);var Is=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())}};h([y({type:S.IA5String})],Is.prototype,"ia5String",void 0);h([y({type:S.Any})],Is.prototype,"anyValue",void 0);Is=h([N({type:B.Choice})],Is);var m0=class{constructor(e={}){f(this,"type","");f(this,"value",new Is);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],m0.prototype,"type",void 0);h([y({type:Is})],m0.prototype,"value",void 0);var g0=Of=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Of.prototype);}};g0=Of=h([N({type:B.Set,itemType:m0})],g0);var Ff=Mf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Mf.prototype);}};Ff=Mf=h([N({type:B.Sequence,itemType:g0})],Ff);var xt=Uf=class extends Ff{constructor(e){super(e),Object.setPrototypeOf(this,Uf.prototype);}};xt=Uf=h([N({type:B.Sequence})],xt);var x_={fromASN:t=>h0.toString(As.fromASN(t)),toASN:t=>As.toASN(h0.fromString(t))},y0=class{constructor(e={}){f(this,"typeId","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],y0.prototype,"typeId",void 0);h([y({type:S.Any,context:0})],y0.prototype,"value",void 0);var b0=class{constructor(e={}){f(this,"nameAssigner");f(this,"partyName",new nr);Object.assign(this,e);}};h([y({type:nr,optional:true,context:0,implicit:true})],b0.prototype,"nameAssigner",void 0);h([y({type:nr,context:1,implicit:true})],b0.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);}};h([y({type:y0,context:0,implicit:true})],ue.prototype,"otherName",void 0);h([y({type:S.IA5String,context:1,implicit:true})],ue.prototype,"rfc822Name",void 0);h([y({type:S.IA5String,context:2,implicit:true})],ue.prototype,"dNSName",void 0);h([y({type:S.Any,context:3,implicit:true})],ue.prototype,"x400Address",void 0);h([y({type:xt,context:4,implicit:false})],ue.prototype,"directoryName",void 0);h([y({type:b0,context:5})],ue.prototype,"ediPartyName",void 0);h([y({type:S.IA5String,context:6,implicit:true})],ue.prototype,"uniformResourceIdentifier",void 0);h([y({type:S.OctetString,context:7,implicit:true,converter:x_})],ue.prototype,"iPAddress",void 0);h([y({type:S.ObjectIdentifier,context:8,implicit:true})],ue.prototype,"registeredID",void 0);ue=h([N({type:B.Choice})],ue);var Lf,So=class{constructor(e={}){f(this,"accessMethod","");f(this,"accessLocation",new ue);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],So.prototype,"accessMethod",void 0);h([y({type:ue})],So.prototype,"accessLocation",void 0);var V3=Lf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Lf.prototype);}};V3=Lf=h([N({type:B.Sequence,itemType:So})],V3);var S0=class extends ce{},vs=class{constructor(e={}){f(this,"keyIdentifier");f(this,"authorityCertIssuer");f(this,"authorityCertSerialNumber");e&&Object.assign(this,e);}};h([y({type:S0,context:0,optional:true,implicit:true})],vs.prototype,"keyIdentifier",void 0);h([y({type:ue,context:1,optional:true,implicit:true,repeated:"sequence"})],vs.prototype,"authorityCertIssuer",void 0);h([y({type:S.Integer,context:2,optional:true,implicit:true,converter:he})],vs.prototype,"authorityCertSerialNumber",void 0);var pl=class{constructor(e={}){f(this,"cA",false);f(this,"pathLenConstraint");Object.assign(this,e);}};h([y({type:S.Boolean,defaultValue:false})],pl.prototype,"cA",void 0);h([y({type:S.Integer,optional:true})],pl.prototype,"pathLenConstraint",void 0);var Hf,Xe=Hf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Hf.prototype);}};Xe=Hf=h([N({type:B.Sequence,itemType:ue})],Xe);var Kf,j3=Kf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Kf.prototype);}};j3=Kf=h([N({type:B.Sequence})],j3);var zf,Ei=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||""}};h([y({type:S.IA5String})],Ei.prototype,"ia5String",void 0);h([y({type:S.VisibleString})],Ei.prototype,"visibleString",void 0);h([y({type:S.BmpString})],Ei.prototype,"bmpString",void 0);h([y({type:S.Utf8String})],Ei.prototype,"utf8String",void 0);Ei=h([N({type:B.Choice})],Ei);var x0=class{constructor(e={}){f(this,"organization",new Ei);f(this,"noticeNumbers",[]);Object.assign(this,e);}};h([y({type:Ei})],x0.prototype,"organization",void 0);h([y({type:S.Integer,repeated:"sequence"})],x0.prototype,"noticeNumbers",void 0);var w0=class{constructor(e={}){f(this,"noticeRef");f(this,"explicitText");Object.assign(this,e);}};h([y({type:x0,optional:true})],w0.prototype,"noticeRef",void 0);h([y({type:Ei,optional:true})],w0.prototype,"explicitText",void 0);var hl=class{constructor(e={}){f(this,"cPSuri");f(this,"userNotice");Object.assign(this,e);}};h([y({type:S.IA5String})],hl.prototype,"cPSuri",void 0);h([y({type:w0})],hl.prototype,"userNotice",void 0);hl=h([N({type:B.Choice})],hl);var A0=class{constructor(e={}){f(this,"policyQualifierId","");f(this,"qualifier",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],A0.prototype,"policyQualifierId",void 0);h([y({type:S.Any})],A0.prototype,"qualifier",void 0);var _0=class{constructor(e={}){f(this,"policyIdentifier","");f(this,"policyQualifiers");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],_0.prototype,"policyIdentifier",void 0);h([y({type:A0,repeated:"sequence",optional:true})],_0.prototype,"policyQualifiers",void 0);var X3=zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,zf.prototype);}};X3=zf=h([N({type:B.Sequence,itemType:_0})],X3);var C0=class{constructor(e=0){f(this,"value");this.value=e;}};h([y({type:S.Integer})],C0.prototype,"value",void 0);C0=h([N({type:B.Choice})],C0);var W3=class extends C0{};W3=h([N({type:B.Choice})],W3);var qf,Er;(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";})(Er||(Er={}));var I0=class extends vi{toJSON(){let e=[],r=this.toNumber();return r&Er.aACompromise&&e.push("aACompromise"),r&Er.affiliationChanged&&e.push("affiliationChanged"),r&Er.cACompromise&&e.push("cACompromise"),r&Er.certificateHold&&e.push("certificateHold"),r&Er.cessationOfOperation&&e.push("cessationOfOperation"),r&Er.keyCompromise&&e.push("keyCompromise"),r&Er.privilegeWithdrawn&&e.push("privilegeWithdrawn"),r&Er.superseded&&e.push("superseded"),r&Er.unused&&e.push("unused"),e}toString(){return `[${this.toJSON().join(", ")}]`}},xo=class{constructor(e={}){f(this,"fullName");f(this,"nameRelativeToCRLIssuer");Object.assign(this,e);}};h([y({type:ue,context:0,repeated:"sequence",implicit:true})],xo.prototype,"fullName",void 0);h([y({type:g0,context:1,implicit:true})],xo.prototype,"nameRelativeToCRLIssuer",void 0);xo=h([N({type:B.Choice})],xo);var bn=class{constructor(e={}){f(this,"distributionPoint");f(this,"reasons");f(this,"cRLIssuer");Object.assign(this,e);}};h([y({type:xo,context:0,optional:true})],bn.prototype,"distributionPoint",void 0);h([y({type:I0,context:1,optional:true,implicit:true})],bn.prototype,"reasons",void 0);h([y({type:ue,context:2,optional:true,repeated:"sequence",implicit:true})],bn.prototype,"cRLIssuer",void 0);var ml=qf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,qf.prototype);}};ml=qf=h([N({type:B.Sequence,itemType:bn})],ml);var Gf,Z3=Gf=class extends ml{constructor(e){super(e),Object.setPrototypeOf(this,Gf.prototype);}};Z3=Gf=h([N({type:B.Sequence,itemType:bn})],Z3);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;h([y({type:xo,context:0,optional:true})],or.prototype,"distributionPoint",void 0);h([y({type:S.Boolean,context:1,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsUserCerts",void 0);h([y({type:S.Boolean,context:2,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsCACerts",void 0);h([y({type:I0,context:3,optional:true,implicit:true})],or.prototype,"onlySomeReasons",void 0);h([y({type:S.Boolean,context:4,defaultValue:or.ONLY,implicit:true})],or.prototype,"indirectCRL",void 0);h([y({type:S.Boolean,context:5,defaultValue:or.ONLY,implicit:true})],or.prototype,"onlyContainsAttributeCerts",void 0);var v0;(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";})(v0||(v0={}));var $f=class{constructor(e=v0.unspecified){f(this,"reason",v0.unspecified);this.reason=e;}toJSON(){return v0[this.reason]}toString(){return this.toJSON()}};h([y({type:S.Enumerated})],$f.prototype,"reason",void 0);$f=h([N({type:B.Choice})],$f);var Vf,Y3=Vf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Vf.prototype);}};Y3=Vf=h([N({type:B.Sequence,itemType:S.ObjectIdentifier})],Y3);var jf=class{constructor(e=new ArrayBuffer(0)){f(this,"value");this.value=e;}};h([y({type:S.Integer,converter:he})],jf.prototype,"value",void 0);jf=h([N({type:B.Choice})],jf);var Xf=class{constructor(e){f(this,"value",new Date);e&&(this.value=e);}};h([y({type:S.GeneralizedTime})],Xf.prototype,"value",void 0);Xf=h([N({type:B.Choice})],Xf);var Wf,Q3=Wf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Wf.prototype);}};Q3=Wf=h([N({type:B.Sequence})],Q3);var J3;(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";})(J3||(J3={}));var Zf,Es=class{constructor(e={}){f(this,"base",new ue);f(this,"minimum",0);f(this,"maximum");Object.assign(this,e);}};h([y({type:ue})],Es.prototype,"base",void 0);h([y({type:S.Integer,context:0,defaultValue:0,implicit:true})],Es.prototype,"minimum",void 0);h([y({type:S.Integer,context:1,optional:true,implicit:true})],Es.prototype,"maximum",void 0);var gl=Zf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Zf.prototype);}};gl=Zf=h([N({type:B.Sequence,itemType:Es})],gl);var yl=class{constructor(e={}){f(this,"permittedSubtrees");f(this,"excludedSubtrees");Object.assign(this,e);}};h([y({type:gl,context:0,optional:true,implicit:true})],yl.prototype,"permittedSubtrees",void 0);h([y({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);}};h([y({type:S.Integer,context:0,implicit:true,optional:true,converter:he})],bl.prototype,"requireExplicitPolicy",void 0);h([y({type:S.Integer,context:1,implicit:true,optional:true,converter:he})],bl.prototype,"inhibitPolicyMapping",void 0);var Yf,E0=class{constructor(e={}){f(this,"issuerDomainPolicy","");f(this,"subjectDomainPolicy","");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],E0.prototype,"issuerDomainPolicy",void 0);h([y({type:S.ObjectIdentifier})],E0.prototype,"subjectDomainPolicy",void 0);var e4=Yf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Yf.prototype);}};e4=Yf=h([N({type:B.Sequence,itemType:E0})],e4);var Qf,t4=Qf=class extends Xe{constructor(e){super(e),Object.setPrototypeOf(this,Qf.prototype);}};t4=Qf=h([N({type:B.Sequence})],t4);var Wr=class{constructor(e={}){f(this,"type","");f(this,"values",[]);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Wr.prototype,"type",void 0);h([y({type:S.Any,repeated:"set"})],Wr.prototype,"values",void 0);var Jf,r4=Jf=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Jf.prototype);}};r4=Jf=h([N({type:B.Sequence,itemType:Wr})],r4);var Br=class extends S0{};var B0=class{constructor(e={}){f(this,"notBefore");f(this,"notAfter");Object.assign(this,e);}};h([y({type:S.GeneralizedTime,context:0,implicit:true,optional:true})],B0.prototype,"notBefore",void 0);h([y({type:S.GeneralizedTime,context:1,implicit:true,optional:true})],B0.prototype,"notAfter",void 0);var T0;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate";})(T0||(T0={}));var Sl=class extends vi{toJSON(){let e=[],r=this.toNumber();return r&T0.pKIXCertificate&&e.push("pKIXCertificate"),r&T0.newExtensions&&e.push("newExtensions"),r&T0.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);}};h([y({type:S.GeneralString})],xl.prototype,"entrustVers",void 0);h([y({type:Sl})],xl.prototype,"entrustInfoFlags",void 0);var ep,i4=ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,ep.prototype);}};i4=ep=h([N({type:B.Sequence,itemType:So})],i4);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&&u0(e.parameters,this.parameters)||e.parameters===this.parameters)}};h([y({type:S.ObjectIdentifier})],J.prototype,"algorithm",void 0);h([y({type:S.Any,optional:true})],J.prototype,"parameters",void 0);var Ao=class{constructor(e={}){f(this,"algorithm",new J);f(this,"subjectPublicKey",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:J})],Ao.prototype,"algorithm",void 0);h([y({type:S.BitString})],Ao.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}};h([y({type:S.UTCTime})],je.prototype,"utcTime",void 0);h([y({type:S.GeneralizedTime})],je.prototype,"generalTime",void 0);je=h([N({type:B.Choice})],je);var _o=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));}};h([y({type:je})],_o.prototype,"notBefore",void 0);h([y({type:je})],_o.prototype,"notAfter",void 0);var tp,wl=class wl{constructor(e={}){f(this,"extnID","");f(this,"critical",wl.CRITICAL);f(this,"extnValue",new ce);Object.assign(this,e);}};f(wl,"CRITICAL",false);var Zr=wl;h([y({type:S.ObjectIdentifier})],Zr.prototype,"extnID",void 0);h([y({type:S.Boolean,defaultValue:Zr.CRITICAL})],Zr.prototype,"critical",void 0);h([y({type:ce})],Zr.prototype,"extnValue",void 0);var Bs=tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,tp.prototype);}};Bs=tp=h([N({type:B.Sequence,itemType:Zr})],Bs);var k0;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3";})(k0||(k0={}));var wt=class{constructor(e={}){f(this,"version",k0.v1);f(this,"serialNumber",new ArrayBuffer(0));f(this,"signature",new J);f(this,"issuer",new xt);f(this,"validity",new _o);f(this,"subject",new xt);f(this,"subjectPublicKeyInfo",new Ao);f(this,"issuerUniqueID");f(this,"subjectUniqueID");f(this,"extensions");Object.assign(this,e);}};h([y({type:S.Integer,context:0,defaultValue:k0.v1})],wt.prototype,"version",void 0);h([y({type:S.Integer,converter:he})],wt.prototype,"serialNumber",void 0);h([y({type:J})],wt.prototype,"signature",void 0);h([y({type:xt})],wt.prototype,"issuer",void 0);h([y({type:_o})],wt.prototype,"validity",void 0);h([y({type:xt})],wt.prototype,"subject",void 0);h([y({type:Ao})],wt.prototype,"subjectPublicKeyInfo",void 0);h([y({type:S.BitString,context:1,implicit:true,optional:true})],wt.prototype,"issuerUniqueID",void 0);h([y({type:S.BitString,context:2,implicit:true,optional:true})],wt.prototype,"subjectUniqueID",void 0);h([y({type:Bs,context:3,optional:true})],wt.prototype,"extensions",void 0);var $t=class{constructor(e={}){f(this,"tbsCertificate",new wt);f(this,"tbsCertificateRaw");f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:wt,raw:true})],$t.prototype,"tbsCertificate",void 0);h([y({type:J})],$t.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],$t.prototype,"signatureValue",void 0);var Ts=class{constructor(e={}){f(this,"userCertificate",new ArrayBuffer(0));f(this,"revocationDate",new je);f(this,"crlEntryExtensions");Object.assign(this,e);}};h([y({type:S.Integer,converter:he})],Ts.prototype,"userCertificate",void 0);h([y({type:je})],Ts.prototype,"revocationDate",void 0);h([y({type:Zr,optional:true,repeated:"sequence"})],Ts.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);}};h([y({type:S.Integer,optional:true})],sr.prototype,"version",void 0);h([y({type:J})],sr.prototype,"signature",void 0);h([y({type:xt})],sr.prototype,"issuer",void 0);h([y({type:je})],sr.prototype,"thisUpdate",void 0);h([y({type:je,optional:true})],sr.prototype,"nextUpdate",void 0);h([y({type:Ts,repeated:"sequence",optional:true})],sr.prototype,"revokedCertificates",void 0);h([y({type:Zr,optional:true,context:0,repeated:"sequence"})],sr.prototype,"crlExtensions",void 0);var P0=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);}};h([y({type:sr,raw:true})],P0.prototype,"tbsCertList",void 0);h([y({type:J})],P0.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],P0.prototype,"signature",void 0);var N0=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 R0=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 p=l;p=this.primeField.add(p,u);let m=c;m=this.primeField.add(m,d),e[o]=p,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 rp(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 n4=[BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7"),BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b"),BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15"),BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")],o4=[[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")]],s4=[[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 __=new N0(BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")),ip=null;function ar(){return ip||(ip=new R0(rp(4,5,8,56,n4,o4,s4),__)),ip}ar().primeField;ar().permute.bind(ar());var a4;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(a4||(a4={}));var C_=ar().primeField,I_=ar().permute.bind(ar()),Tr;(function(t){t[t.ABSORB=0]="ABSORB",t[t.SQUEEZE=1]="SQUEEZE";})(Tr||(Tr={}));var np=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=Tr.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]=C_.add(this.state[e],this.cache[e]);return this.state=I_(this.state),await Promise.resolve(),this.state.slice(0,this.rate)}async absorb(e){this.mode===Tr.ABSORB&&this.cacheSize===this.rate?(await this.performDuplex(),this.cache[0]=e,this.cacheSize=1):this.mode===Tr.ABSORB&&this.cacheSize<this.rate?(this.cache[this.cacheSize]=e,this.cacheSize+=1):this.mode===Tr.SQUEEZE&&(this.cache[0]=e,this.cacheSize=1,this.mode=Tr.ABSORB);}async squeeze(){if(this.mode===Tr.SQUEEZE&&this.cacheSize===0&&(this.mode=Tr.ABSORB,this.cacheSize=0),this.mode===Tr.ABSORB){let r=await this.performDuplex();this.mode=Tr.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 np.hashFixedLength(t))[0]}ar().primeField;It(Il(),1);It(Il(),1);var B4="1.2.840.10045.4.1",T4="1.2.840.10045.4.3.1",k4="1.2.840.10045.4.3.2",P4="1.2.840.10045.4.3.3",N4="1.2.840.10045.4.3.4";function O0(t){return new J({algorithm:t})}O0(B4);O0(T4);O0(k4);O0(P4);O0(N4);var M0=class{constructor(e={}){f(this,"fieldType");f(this,"parameters");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],M0.prototype,"fieldType",void 0);h([y({type:S.Any})],M0.prototype,"parameters",void 0);M0=h([N({type:B.Sequence})],M0);var mp=class extends ce{};var Ds=class{constructor(e={}){f(this,"a");f(this,"b");f(this,"seed");Object.assign(this,e);}};h([y({type:S.OctetString})],Ds.prototype,"a",void 0);h([y({type:S.OctetString})],Ds.prototype,"b",void 0);h([y({type:S.BitString,optional:true})],Ds.prototype,"seed",void 0);Ds=h([N({type:B.Sequence})],Ds);var gp;(function(t){t[t.ecpVer1=1]="ecpVer1";})(gp||(gp={}));var Jr=class{constructor(e={}){f(this,"version",gp.ecpVer1);f(this,"fieldID");f(this,"curve");f(this,"base");f(this,"order");f(this,"cofactor");Object.assign(this,e);}};h([y({type:S.Integer})],Jr.prototype,"version",void 0);h([y({type:M0})],Jr.prototype,"fieldID",void 0);h([y({type:Ds})],Jr.prototype,"curve",void 0);h([y({type:mp})],Jr.prototype,"base",void 0);h([y({type:S.Integer,converter:he})],Jr.prototype,"order",void 0);h([y({type:S.Integer,optional:true})],Jr.prototype,"cofactor",void 0);Jr=h([N({type:B.Sequence})],Jr);var xn=class{constructor(e={}){f(this,"namedCurve");f(this,"implicitCurve");f(this,"specifiedCurve");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],xn.prototype,"namedCurve",void 0);h([y({type:S.Null})],xn.prototype,"implicitCurve",void 0);h([y({type:Jr})],xn.prototype,"specifiedCurve",void 0);xn=h([N({type:B.Choice})],xn);var Os=class{constructor(e={}){f(this,"version",1);f(this,"privateKey",new ce);f(this,"parameters");f(this,"publicKey");Object.assign(this,e);}};h([y({type:S.Integer})],Os.prototype,"version",void 0);h([y({type:ce})],Os.prototype,"privateKey",void 0);h([y({type:xn,context:0,optional:true})],Os.prototype,"parameters",void 0);h([y({type:S.BitString,context:1,optional:true})],Os.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);}};h([y({type:S.Integer,converter:he})],vl.prototype,"r",void 0);h([y({type:S.Integer,converter:he})],vl.prototype,"s",void 0);var Pt="1.2.840.113549.1.1",R4=`${Pt}.1`,D4=`${Pt}.7`,O4=`${Pt}.9`,M4=`${Pt}.10`,U4=`${Pt}.2`,F4=`${Pt}.4`,L4=`${Pt}.5`;var H4=`${Pt}.12`,K4=`${Pt}.13`,yp=`${Pt}.15`,bp=`${Pt}.16`,z4="1.3.14.3.2.26",q4="2.16.840.1.101.3.4.2.4",G4="2.16.840.1.101.3.4.2.1",$4="2.16.840.1.101.3.4.2.2",V4="2.16.840.1.101.3.4.2.3",j4="2.16.840.1.101.3.4.2.5",X4="2.16.840.1.101.3.4.2.6",W4="1.2.840.113549.2.2",Z4="1.2.840.113549.2.5",Ms=`${Pt}.8`;function We(t){return new J({algorithm:t,parameters:null})}We(W4);We(Z4);var Ti=We(z4);We(q4);We(G4);We($4);We(V4);We(j4);We(X4);var El=new J({algorithm:Ms,parameters:ir.serialize(Ti)}),Sp=new J({algorithm:O4,parameters:ir.serialize(As.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(R4);We(U4);We(F4);We(L4);We(yp);We(bp);We(H4);We(K4);We(yp);We(bp);var Us=class{constructor(e={}){f(this,"hashAlgorithm",new J(Ti));f(this,"maskGenAlgorithm",new J({algorithm:Ms,parameters:ir.serialize(Ti)}));f(this,"pSourceAlgorithm",new J(Sp));Object.assign(this,e);}};h([y({type:J,context:0,defaultValue:Ti})],Us.prototype,"hashAlgorithm",void 0);h([y({type:J,context:1,defaultValue:El})],Us.prototype,"maskGenAlgorithm",void 0);h([y({type:J,context:2,defaultValue:Sp})],Us.prototype,"pSourceAlgorithm",void 0);new J({algorithm:D4,parameters:ir.serialize(new Us)});var wn=class{constructor(e={}){f(this,"hashAlgorithm",new J(Ti));f(this,"maskGenAlgorithm",new J({algorithm:Ms,parameters:ir.serialize(Ti)}));f(this,"saltLength",20);f(this,"trailerField",1);Object.assign(this,e);}};h([y({type:J,context:0,defaultValue:Ti})],wn.prototype,"hashAlgorithm",void 0);h([y({type:J,context:1,defaultValue:El})],wn.prototype,"maskGenAlgorithm",void 0);h([y({type:S.Integer,context:2,defaultValue:20})],wn.prototype,"saltLength",void 0);h([y({type:S.Integer,context:3,defaultValue:1})],wn.prototype,"trailerField",void 0);new J({algorithm:M4,parameters:ir.serialize(new wn)});var Bl=class{constructor(e={}){f(this,"digestAlgorithm",new J);f(this,"digest",new ce);Object.assign(this,e);}};h([y({type:J})],Bl.prototype,"digestAlgorithm",void 0);h([y({type:ce})],Bl.prototype,"digest",void 0);var xp,Fs=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);}};h([y({type:S.Integer,converter:he})],Fs.prototype,"prime",void 0);h([y({type:S.Integer,converter:he})],Fs.prototype,"exponent",void 0);h([y({type:S.Integer,converter:he})],Fs.prototype,"coefficient",void 0);var Tl=xp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,xp.prototype);}};Tl=xp=h([N({type:B.Sequence,itemType:Fs})],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);}};h([y({type:S.Integer})],lr.prototype,"version",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"modulus",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"publicExponent",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"privateExponent",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"prime1",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"prime2",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"exponent1",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"exponent2",void 0);h([y({type:S.Integer,converter:he})],lr.prototype,"coefficient",void 0);h([y({type:Tl,optional:true})],lr.prototype,"otherPrimeInfos",void 0);var U0=class{constructor(e={}){f(this,"modulus",new ArrayBuffer(0));f(this,"publicExponent",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.Integer,converter:he})],U0.prototype,"modulus",void 0);h([y({type:S.Integer,converter:he})],U0.prototype,"publicExponent",void 0);var kr=class{constructor(e={}){f(this,"issuer",new xt);f(this,"serialNumber",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:xt})],kr.prototype,"issuer",void 0);h([y({type:S.Integer,converter:he})],kr.prototype,"serialNumber",void 0);var vo=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true})],vo.prototype,"subjectKeyIdentifier",void 0);h([y({type:kr})],vo.prototype,"issuerAndSerialNumber",void 0);vo=h([N({type:B.Choice})],vo);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=h([N({type:B.Sequence})],mt);var F0=class extends J{};F0=h([N({type:B.Sequence})],F0);var Nt=class extends J{};Nt=h([N({type:B.Sequence})],Nt);var L0=class extends J{};L0=h([N({type:B.Sequence})],L0);var Y4=class extends J{};Y4=h([N({type:B.Sequence})],Y4);var kl=class extends J{};kl=h([N({type:B.Sequence})],kl);var At=class{constructor(e={}){f(this,"attrType","");f(this,"attrValues",[]);Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],At.prototype,"attrType",void 0);h([y({type:S.Any,repeated:"set"})],At.prototype,"attrValues",void 0);var wp,dr=class{constructor(e={}){f(this,"version",ht.v0);f(this,"sid",new vo);f(this,"digestAlgorithm",new mt);f(this,"signedAttrs");f(this,"signedAttrsRaw");f(this,"signatureAlgorithm",new F0);f(this,"signature",new ce);f(this,"unsignedAttrs");Object.assign(this,e);}};h([y({type:S.Integer})],dr.prototype,"version",void 0);h([y({type:vo})],dr.prototype,"sid",void 0);h([y({type:mt})],dr.prototype,"digestAlgorithm",void 0);h([y({type:At,repeated:"set",context:0,implicit:true,optional:true,raw:true})],dr.prototype,"signedAttrs",void 0);h([y({type:F0})],dr.prototype,"signatureAlgorithm",void 0);h([y({type:ce})],dr.prototype,"signature",void 0);h([y({type:At,repeated:"set",context:1,implicit:true,optional:true})],dr.prototype,"unsignedAttrs",void 0);var H0=wp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,wp.prototype);}};H0=wp=h([N({type:B.Set,itemType:dr})],H0);var Q4=class extends dr{};Q4=h([N({type:B.Sequence})],Q4);var J4=class extends je{};J4=h([N({type:B.Choice})],J4);var K0=class{constructor(e={}){f(this,"acIssuer",new ue);f(this,"acSerial",0);f(this,"attrs",[]);Object.assign(this,e);}};h([y({type:ue})],K0.prototype,"acIssuer",void 0);h([y({type:S.Integer})],K0.prototype,"acSerial",void 0);h([y({type:Wr,repeated:"sequence"})],K0.prototype,"attrs",void 0);var Ap,z0=Ap=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ap.prototype);}};z0=Ap=h([N({type:B.Sequence,itemType:S.ObjectIdentifier})],z0);var Ls=class{constructor(e={}){f(this,"pathLenConstraint");f(this,"permittedAttrs");f(this,"excludedAttrs");f(this,"permitUnSpecified",true);Object.assign(this,e);}};h([y({type:S.Integer,optional:true})],Ls.prototype,"pathLenConstraint",void 0);h([y({type:z0,implicit:true,context:0,optional:true})],Ls.prototype,"permittedAttrs",void 0);h([y({type:z0,implicit:true,context:1,optional:true})],Ls.prototype,"excludedAttrs",void 0);h([y({type:S.Boolean,defaultValue:true})],Ls.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);}};h([y({type:Xe})],ur.prototype,"issuer",void 0);h([y({type:S.Integer,converter:he})],ur.prototype,"serial",void 0);h([y({type:S.BitString,optional:true})],ur.prototype,"issuerUID",void 0);var _p;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes";})(_p||(_p={}));var fr=class{constructor(e={}){f(this,"digestedObjectType",_p.publicKey);f(this,"otherObjectTypeID");f(this,"digestAlgorithm",new J);f(this,"objectDigest",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.Enumerated})],fr.prototype,"digestedObjectType",void 0);h([y({type:S.ObjectIdentifier,optional:true})],fr.prototype,"otherObjectTypeID",void 0);h([y({type:J})],fr.prototype,"digestAlgorithm",void 0);h([y({type:S.BitString})],fr.prototype,"objectDigest",void 0);var Eo=class{constructor(e={}){f(this,"issuerName");f(this,"baseCertificateID");f(this,"objectDigestInfo");Object.assign(this,e);}};h([y({type:Xe,optional:true})],Eo.prototype,"issuerName",void 0);h([y({type:ur,context:0,implicit:true,optional:true})],Eo.prototype,"baseCertificateID",void 0);h([y({type:fr,context:1,implicit:true,optional:true})],Eo.prototype,"objectDigestInfo",void 0);var Bo=class{constructor(e={}){f(this,"v1Form");f(this,"v2Form");Object.assign(this,e);}};h([y({type:ue,repeated:"sequence"})],Bo.prototype,"v1Form",void 0);h([y({type:Eo,context:0,implicit:true})],Bo.prototype,"v2Form",void 0);Bo=h([N({type:B.Choice})],Bo);var To=class{constructor(e={}){f(this,"notBeforeTime",new Date);f(this,"notAfterTime",new Date);Object.assign(this,e);}};h([y({type:S.GeneralizedTime})],To.prototype,"notBeforeTime",void 0);h([y({type:S.GeneralizedTime})],To.prototype,"notAfterTime",void 0);var An=class{constructor(e={}){f(this,"baseCertificateID");f(this,"entityName");f(this,"objectDigestInfo");Object.assign(this,e);}};h([y({type:ur,implicit:true,context:0,optional:true})],An.prototype,"baseCertificateID",void 0);h([y({type:Xe,implicit:true,context:1,optional:true})],An.prototype,"entityName",void 0);h([y({type:fr,implicit:true,context:2,optional:true})],An.prototype,"objectDigestInfo",void 0);var Cp;(function(t){t[t.v2=1]="v2";})(Cp||(Cp={}));var Rt=class{constructor(e={}){f(this,"version",Cp.v2);f(this,"holder",new An);f(this,"issuer",new Bo);f(this,"signature",new J);f(this,"serialNumber",new ArrayBuffer(0));f(this,"attrCertValidityPeriod",new To);f(this,"attributes",[]);f(this,"issuerUniqueID");f(this,"extensions");Object.assign(this,e);}};h([y({type:S.Integer})],Rt.prototype,"version",void 0);h([y({type:An})],Rt.prototype,"holder",void 0);h([y({type:Bo})],Rt.prototype,"issuer",void 0);h([y({type:J})],Rt.prototype,"signature",void 0);h([y({type:S.Integer,converter:he})],Rt.prototype,"serialNumber",void 0);h([y({type:To})],Rt.prototype,"attrCertValidityPeriod",void 0);h([y({type:Wr,repeated:"sequence"})],Rt.prototype,"attributes",void 0);h([y({type:S.BitString,optional:true})],Rt.prototype,"issuerUniqueID",void 0);h([y({type:Bs,optional:true})],Rt.prototype,"extensions",void 0);var ko=class{constructor(e={}){f(this,"acinfo",new Rt);f(this,"signatureAlgorithm",new J);f(this,"signatureValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:Rt})],ko.prototype,"acinfo",void 0);h([y({type:J})],ko.prototype,"signatureAlgorithm",void 0);h([y({type:S.BitString})],ko.prototype,"signatureValue",void 0);var q0;(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";})(q0||(q0={}));var Hs=class extends vi{};var Ks=class{constructor(e={}){f(this,"type","");f(this,"value",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier,implicit:true,context:0})],Ks.prototype,"type",void 0);h([y({type:S.Any,implicit:true,context:1})],Ks.prototype,"value",void 0);var G0=class{constructor(e={}){f(this,"policyId","");f(this,"classList",new Hs(q0.unclassified));f(this,"securityCategories");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],G0.prototype,"policyId",void 0);h([y({type:Hs,defaultValue:new Hs(q0.unclassified)})],G0.prototype,"classList",void 0);h([y({type:Ks,repeated:"set"})],G0.prototype,"securityCategories",void 0);var zs=class{constructor(e={}){f(this,"cotets");f(this,"oid");f(this,"string");Object.assign(this,e);}};h([y({type:ce})],zs.prototype,"cotets",void 0);h([y({type:S.ObjectIdentifier})],zs.prototype,"oid",void 0);h([y({type:S.Utf8String})],zs.prototype,"string",void 0);var Pl=class{constructor(e={}){f(this,"policyAuthority");f(this,"values",[]);Object.assign(this,e);}};h([y({type:Xe,implicit:true,context:0,optional:true})],Pl.prototype,"policyAuthority",void 0);h([y({type:zs,repeated:"sequence"})],Pl.prototype,"values",void 0);var Ip,qs=class{constructor(e={}){f(this,"targetCertificate",new ur);f(this,"targetName");f(this,"certDigestInfo");Object.assign(this,e);}};h([y({type:ur})],qs.prototype,"targetCertificate",void 0);h([y({type:ue,optional:true})],qs.prototype,"targetName",void 0);h([y({type:fr,optional:true})],qs.prototype,"certDigestInfo",void 0);var Gs=class{constructor(e={}){f(this,"targetName");f(this,"targetGroup");f(this,"targetCert");Object.assign(this,e);}};h([y({type:ue,context:0,implicit:true})],Gs.prototype,"targetName",void 0);h([y({type:ue,context:1,implicit:true})],Gs.prototype,"targetGroup",void 0);h([y({type:qs,context:2,implicit:true})],Gs.prototype,"targetCert",void 0);Gs=h([N({type:B.Choice})],Gs);var Nl=Ip=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ip.prototype);}};Nl=Ip=h([N({type:B.Sequence,itemType:Gs})],Nl);var vp,eb=vp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,vp.prototype);}};eb=vp=h([N({type:B.Sequence,itemType:Nl})],eb);var Rl=class{constructor(e={}){f(this,"roleAuthority");f(this,"roleName");Object.assign(this,e);}};h([y({type:Xe,implicit:true,context:0,optional:true})],Rl.prototype,"roleAuthority",void 0);h([y({type:ue,implicit:true,context:1})],Rl.prototype,"roleName",void 0);var V0=class{constructor(e={}){f(this,"service",new ue);f(this,"ident",new ue);f(this,"authInfo");Object.assign(this,e);}};h([y({type:ue})],V0.prototype,"service",void 0);h([y({type:ue})],V0.prototype,"ident",void 0);h([y({type:ce,optional:true})],V0.prototype,"authInfo",void 0);var Ep,j0=class{constructor(e={}){f(this,"otherCertFormat","");f(this,"otherCert",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],j0.prototype,"otherCertFormat",void 0);h([y({type:S.Any})],j0.prototype,"otherCert",void 0);var $s=class{constructor(e={}){f(this,"certificate");f(this,"v2AttrCert");f(this,"other");Object.assign(this,e);}};h([y({type:$t})],$s.prototype,"certificate",void 0);h([y({type:ko,context:2,implicit:true})],$s.prototype,"v2AttrCert",void 0);h([y({type:j0,context:3,implicit:true})],$s.prototype,"other",void 0);$s=h([N({type:B.Choice})],$s);var Vs=Ep=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Ep.prototype);}};Vs=Ep=h([N({type:B.Set,itemType:$s})],Vs);var X0=class{constructor(e={}){f(this,"contentType","");f(this,"content",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],X0.prototype,"contentType",void 0);h([y({type:S.Any,context:0})],X0.prototype,"content",void 0);var W0=class{constructor(e={}){f(this,"single");f(this,"any");Object.assign(this,e);}};h([y({type:ce})],W0.prototype,"single",void 0);h([y({type:S.Any})],W0.prototype,"any",void 0);W0=h([N({type:B.Choice})],W0);var Po=class{constructor(e={}){f(this,"eContentType","");f(this,"eContent");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Po.prototype,"eContentType",void 0);h([y({type:W0,context:0,optional:true})],Po.prototype,"eContent",void 0);var Z0=class{constructor(e={}){f(this,"value");f(this,"constructedValue");Object.assign(this,e);}};h([y({type:ce,context:0,implicit:true,optional:true})],Z0.prototype,"value",void 0);h([y({type:ce,converter:q3,context:0,implicit:true,optional:true,repeated:"sequence"})],Z0.prototype,"constructedValue",void 0);Z0=h([N({type:B.Choice})],Z0);var _n=class{constructor(e={}){f(this,"contentType","");f(this,"contentEncryptionAlgorithm",new L0);f(this,"encryptedContent");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],_n.prototype,"contentType",void 0);h([y({type:L0})],_n.prototype,"contentEncryptionAlgorithm",void 0);h([y({type:Z0,optional:true})],_n.prototype,"encryptedContent",void 0);var Cn=class{constructor(e={}){f(this,"keyAttrId","");f(this,"keyAttr");Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Cn.prototype,"keyAttrId",void 0);h([y({type:S.Any,optional:true})],Cn.prototype,"keyAttr",void 0);var Bp,js=class{constructor(e={}){f(this,"subjectKeyIdentifier",new Br);f(this,"date");f(this,"other");Object.assign(this,e);}};h([y({type:Br})],js.prototype,"subjectKeyIdentifier",void 0);h([y({type:S.GeneralizedTime,optional:true})],js.prototype,"date",void 0);h([y({type:Cn,optional:true})],js.prototype,"other",void 0);var Xs=class{constructor(e={}){f(this,"rKeyId");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:js,context:0,implicit:true,optional:true})],Xs.prototype,"rKeyId",void 0);h([y({type:kr,optional:true})],Xs.prototype,"issuerAndSerialNumber",void 0);Xs=h([N({type:B.Choice})],Xs);var Y0=class{constructor(e={}){f(this,"rid",new Xs);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:Xs})],Y0.prototype,"rid",void 0);h([y({type:ce})],Y0.prototype,"encryptedKey",void 0);var Dl=Bp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Bp.prototype);}};Dl=Bp=h([N({type:B.Sequence,itemType:Y0})],Dl);var Q0=class{constructor(e={}){f(this,"algorithm",new J);f(this,"publicKey",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:J})],Q0.prototype,"algorithm",void 0);h([y({type:S.BitString})],Q0.prototype,"publicKey",void 0);var No=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"originatorKey");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true,optional:true})],No.prototype,"subjectKeyIdentifier",void 0);h([y({type:Q0,context:1,implicit:true,optional:true})],No.prototype,"originatorKey",void 0);h([y({type:kr,optional:true})],No.prototype,"issuerAndSerialNumber",void 0);No=h([N({type:B.Choice})],No);var ki=class{constructor(e={}){f(this,"version",ht.v3);f(this,"originator",new No);f(this,"ukm");f(this,"keyEncryptionAlgorithm",new Nt);f(this,"recipientEncryptedKeys",new Dl);Object.assign(this,e);}};h([y({type:S.Integer})],ki.prototype,"version",void 0);h([y({type:No,context:0})],ki.prototype,"originator",void 0);h([y({type:ce,context:1,optional:true})],ki.prototype,"ukm",void 0);h([y({type:Nt})],ki.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:Dl})],ki.prototype,"recipientEncryptedKeys",void 0);var Ws=class{constructor(e={}){f(this,"subjectKeyIdentifier");f(this,"issuerAndSerialNumber");Object.assign(this,e);}};h([y({type:Br,context:0,implicit:true})],Ws.prototype,"subjectKeyIdentifier",void 0);h([y({type:kr})],Ws.prototype,"issuerAndSerialNumber",void 0);Ws=h([N({type:B.Choice})],Ws);var In=class{constructor(e={}){f(this,"version",ht.v0);f(this,"rid",new Ws);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:S.Integer})],In.prototype,"version",void 0);h([y({type:Ws})],In.prototype,"rid",void 0);h([y({type:Nt})],In.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],In.prototype,"encryptedKey",void 0);var Ro=class{constructor(e={}){f(this,"keyIdentifier",new ce);f(this,"date");f(this,"other");Object.assign(this,e);}};h([y({type:ce})],Ro.prototype,"keyIdentifier",void 0);h([y({type:S.GeneralizedTime,optional:true})],Ro.prototype,"date",void 0);h([y({type:Cn,optional:true})],Ro.prototype,"other",void 0);var vn=class{constructor(e={}){f(this,"version",ht.v4);f(this,"kekid",new Ro);f(this,"keyEncryptionAlgorithm",new Nt);f(this,"encryptedKey",new ce);Object.assign(this,e);}};h([y({type:S.Integer})],vn.prototype,"version",void 0);h([y({type:Ro})],vn.prototype,"kekid",void 0);h([y({type:Nt})],vn.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],vn.prototype,"encryptedKey",void 0);var En=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);}};h([y({type:S.Integer})],En.prototype,"version",void 0);h([y({type:kl,context:0,optional:true})],En.prototype,"keyDerivationAlgorithm",void 0);h([y({type:Nt})],En.prototype,"keyEncryptionAlgorithm",void 0);h([y({type:ce})],En.prototype,"encryptedKey",void 0);var J0=class{constructor(e={}){f(this,"oriType","");f(this,"oriValue",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],J0.prototype,"oriType",void 0);h([y({type:S.Any})],J0.prototype,"oriValue",void 0);var Pi=class{constructor(e={}){f(this,"ktri");f(this,"kari");f(this,"kekri");f(this,"pwri");f(this,"ori");Object.assign(this,e);}};h([y({type:In,optional:true})],Pi.prototype,"ktri",void 0);h([y({type:ki,context:1,implicit:true,optional:true})],Pi.prototype,"kari",void 0);h([y({type:vn,context:2,implicit:true,optional:true})],Pi.prototype,"kekri",void 0);h([y({type:En,context:3,implicit:true,optional:true})],Pi.prototype,"pwri",void 0);h([y({type:J0,context:4,implicit:true,optional:true})],Pi.prototype,"ori",void 0);Pi=h([N({type:B.Choice})],Pi);var Tp,ec=Tp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Tp.prototype);}};ec=Tp=h([N({type:B.Set,itemType:Pi})],ec);var kp,Zs=class{constructor(e={}){f(this,"otherRevInfoFormat","");f(this,"otherRevInfo",new ArrayBuffer(0));Object.assign(this,e);}};h([y({type:S.ObjectIdentifier})],Zs.prototype,"otherRevInfoFormat",void 0);h([y({type:S.Any})],Zs.prototype,"otherRevInfo",void 0);var Ol=class{constructor(e={}){f(this,"other",new Zs);Object.assign(this,e);}};h([y({type:Zs,context:1,implicit:true})],Ol.prototype,"other",void 0);Ol=h([N({type:B.Choice})],Ol);var Ys=kp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,kp.prototype);}};Ys=kp=h([N({type:B.Set,itemType:Ol})],Ys);var Qs=class{constructor(e={}){f(this,"certs");f(this,"crls");Object.assign(this,e);}};h([y({type:Vs,context:0,implicit:true,optional:true})],Qs.prototype,"certs",void 0);h([y({type:Ys,context:1,implicit:true,optional:true})],Qs.prototype,"crls",void 0);var Pp,Np=Pp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Pp.prototype);}};Np=Pp=h([N({type:B.Set,itemType:At})],Np);var Do=class{constructor(e={}){f(this,"version",ht.v0);f(this,"originatorInfo");f(this,"recipientInfos",new ec);f(this,"encryptedContentInfo",new _n);f(this,"unprotectedAttrs");Object.assign(this,e);}};h([y({type:S.Integer})],Do.prototype,"version",void 0);h([y({type:Qs,context:0,implicit:true,optional:true})],Do.prototype,"originatorInfo",void 0);h([y({type:ec})],Do.prototype,"recipientInfos",void 0);h([y({type:_n})],Do.prototype,"encryptedContentInfo",void 0);h([y({type:Np,context:1,implicit:true,optional:true})],Do.prototype,"unprotectedAttrs",void 0);var Rp,Ml=Rp=class extends ie{constructor(e){super(e),Object.setPrototypeOf(this,Rp.prototype);}};Ml=Rp=h([N({type:B.Set,itemType:mt})],Ml);var Ni=class{constructor(e={}){f(this,"version",ht.v0);f(this,"digestAlgorithms",new Ml);f(this,"encapContentInfo",new Po);f(this,"certificates");f(this,"crls");f(this,"signerInfos",new H0);Object.assign(this,e);}};h([y({type:S.Integer})],Ni.prototype,"version",void 0);h([y({type:Ml})],Ni.prototype,"digestAlgorithms",void 0);h([y({type:Po})],Ni.prototype,"encapContentInfo",void 0);h([y({type:Vs,context:0,implicit:true,optional:true})],Ni.prototype,"certificates",void 0);h([y({type:Ys,context:1,implicit:true,optional:true})],Ni.prototype,"crls",void 0);h([y({type:H0})],Ni.prototype,"signerInfos",void 0);var dC=Gt.Point.Fp;dC.ORDER;var uC=Gt.Point.CURVE().n,fC=8n,pC=uC/fC,Js=ys(pC,{BITS:249});Gt.Point.Fp;var Bn={x:5299619240641551281634865583518297030282874472190772894086521144482721001553n,y:16950150798460657717958625567821834550301663161624707787222815936182638968203n};Gt.Point.fromAffine(Bn);Gt.Point.fromAffine(Bn);new TextEncoder().encode("FROST_2_NONCE_COMBINER");var db=Object.defineProperty,SC=Object.getOwnPropertyDescriptor,xC=(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')}),ub=(t,e)=>()=>(t&&(e=t(t=0)),e),wC=(t,e)=>{for(var r in e)db(t,r,{get:e[r],enumerable:true});},Dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?SC(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&&db(e,r,n),n},Ri,tc,Gl=ub(()=>{Ri={"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}},tc={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}};}),RC={};wC(RC,{modPow:()=>hb,verifyDscSignature:()=>zC,verifyDscSignatureWithTbs:()=>qC,verifyECDSASignature:()=>Hp,verifyRSASignature:()=>Kp});function fb(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 DC(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 Hp(t,e,r){let i=mb[r.curve];if(!i)return false;try{let n=Math.ceil(r.key_size/8),o=DC(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 Kp(t,e,r,i,n,o){try{if(gb.includes(n)){let s=MC();if(s)return await UC(t,r,i,n,o,s)}return FC(e,r,i,n,o)}catch{return false}}function OC(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 MC(){return typeof globalThis<"u"&&globalThis.crypto?.subtle?globalThis.crypto.subtle:typeof globalThis<"u"&&globalThis.crypto?.webcrypto?.subtle?globalThis.crypto.webcrypto.subtle:null}async function UC(t,e,r,i,n,o){let s=new Uint8Array(Buffer.from(r.modulus.replace("0x",""),"hex")),a=OC(r.exponent),c={kty:"RSA",n:rb(s),e:rb(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:pb(i)}:{name:"RSASSA-PKCS1-v1_5"};try{let u=await o.importKey("jwk",c,l,!1,["verify"]),p=new Uint8Array(e).buffer,m=new Uint8Array(t).buffer;return await o.verify(d,u,p,m)}catch{return false}}function rb(t){return Buffer.from(t).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function pb(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 FC(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 p=new Uint8Array(a);p.set(e,a-e.length),e=p;}else return !1;let c=BigInt(0);for(let p of e)c=c<<BigInt(8)|BigInt(p);if(c>=o)return !1;let l=hb(c,s,o),d=new Uint8Array(a),u=l;for(let p=a-1;p>=0;p--)d[p]=Number(u&BigInt(255)),u=u>>BigInt(8);return n?HC(d,t,i,r.key_size):LC(d,t,i)}catch{return false}}function hb(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 LC(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<bb||i>=t.length||t[i]!==0)return false;i++;let n=t.slice(i),o=yb[r];if(ib(n,e,o))return true;let s=Sb[r];return !!ib(n,e,s)}function ib(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 HC(t,e,r,i){let n=$l[r],o=pb(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),p=255>>8*a-s;if((d[0]&~p)!==0)return false;let m=KC(u,l,n),b=new Uint8Array(l);for(let C=0;C<l;C++)b[C]=d[C]^m[C];b[0]&=p;let w=-1;for(let C=0;C<l;C++)if(b[C]===1){w=C;break}else if(b[C]!==0)return false;if(w===-1)return false;let x=l-w-1;if(x<0)return false;let g=b.slice(w+1),A=new Uint8Array(8+o+x);A.set(e,8),x>0&&A.set(g,8+o);let I=n(A);if(u.length!==I.length)return false;let _=0;for(let C=0;C<u.length;C++)_|=u[C]^I[C];return _===0}function KC(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 zC(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=fb(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(Hp(d,i,u))return true}else {let u=e.public_key;if(await Kp(r,d,i,u,c,o))return true}}return false}async function qC(t,e,r){let i=r.public_key.type==="EC",n=r.signature_algorithm==="RSA-PSS",o=r.public_key.key_size,s=fb(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(Hp(l,e,d))return true}else {let d=r.public_key;if(await Kp(t,l,e,d,a,n))return true}}return false}var $l,nb,ob,sb,ab,cb,lb,mb,gb,yb,bb,Sb,GC=ub(()=>{Gl(),$l={"SHA-1":Qn,"SHA-224":Fr,"SHA-256":ot,"SHA-384":fs,"SHA-512":us},nb={p:tc.brainpoolP224r1.p,a:tc.brainpoolP224r1.a,b:tc.brainpoolP224r1.b,n:tc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},ob=Ge(qe(nb),Fr),sb={p:Ri["P-192"].p,a:Ri["P-192"].a,b:Ri["P-192"].b,n:Ri["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},ab=Ge(qe(sb),Qn),cb={p:Ri["P-224"].p,a:Ri["P-224"].a,b:Ri["P-224"].b,n:Ri["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},lb=Ge(qe(cb),Fr),mb={"P-192":ab,"P-224":lb,"P-256":lt,"P-384":dt,"P-521":ut,brainpoolP224r1:ob,brainpoolP256r1:py,brainpoolP384r1:hy,brainpoolP512r1:my},gb=["SHA-256","SHA-384","SHA-512"],yb={"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])},bb=8,Sb={"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 xb(t){return t.startsWith("0x")?t.slice(2):t}function VC(t){return BigInt("0x"+Buffer.from(t).toString("hex"))}function Oo(t,e){return t.concat(Array(e-t.length).fill(0))}function wb(t,e){return Array(e-t.length).fill(0).concat(t)}function Mo(t,e){let r=BigInt(0);for(let i=0;i<e;i++)r*=BigInt(256),r+=BigInt(t[i]);return r}function jC(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 Ab(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 Di(t){if(!Kl[t])throw new Error(`Unsupported chain: ${t}`);return Kl[t]}function rc(t){for(let e in Kl)if(Kl[e]===t)return e;throw new Error(`Unsupported chain ID: ${t}`)}function zp(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 Tn(t){return typeof t=="string"||typeof t=="number"?new Date(t):t}function qp(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=Tn(r.eq.expected)),"gte"in r&&r.gte&&(r.gte.expected=Tn(r.gte.expected)),"gt"in r&&r.gt&&(r.gt.expected=Tn(r.gt.expected)),"lte"in r&&r.lte&&(r.lte.expected=Tn(r.lte.expected)),"lt"in r&&r.lt&&(r.lt.expected=Tn(r.lt.expected)),"range"in r&&r.range&&Array.isArray(r.range.expected)){let[i,n]=r.range.expected;r.range.expected=[Tn(i),Tn(n)];}"disclose"in r&&r.disclose&&(r.disclose.result=Tn(r.disclose.result));}}return t}function Te(t,e){return Vn(t.toString(16).padStart(e*2,"0"))}async function Gp(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 _b(t){return BigInt(t.publicInputs[0])}function Cb(t){return BigInt(t.publicInputs[1])}function XC(){return 2}function Ib(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function vb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function WC(){return 2}function ea(t){return t==="D<<"?"DEU":t}function Dp(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 Op(t){return t.startsWith("P")?"passport":t==="IR"||t==="AR"?"residence_permit":t.startsWith("I")?"id_card":"other"}var $p=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,p=l+" "+c;return new Ll({issuingCountry:ea(o(i.issuingCountry)),nationality:ea(o(i.nationality)),documentType:Op(o(i.documentType)),documentNumber:Dp(o(i.documentNumber)),dateOfExpiry:ta(i.dateOfExpiry),dateOfBirth:ta(i.dateOfBirth),name:ve(p),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,p=l+" "+c;return new Ll({issuingCountry:ea(o(i.issuingCountry)),nationality:ea(o(i.nationality)),documentType:Op(o(i.documentType)),documentNumber:Dp(o(i.documentNumber)),dateOfExpiry:ta(i.dateOfExpiry),dateOfBirth:ta(i.dateOfBirth),name:ve(p),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("<"),p=u>=0?d.substring(0,u):d,m=d+" "+l;return new Ll({issuingCountry:ea(s(n.issuingCountry)),nationality:ea(s(n.nationality)),documentType:Op(s(n.documentType)),documentNumber:Dp(s(n.documentNumber)),dateOfExpiry:ta(n.dateOfExpiry),dateOfBirth:ta(n.dateOfBirth),name:ve(m),firstName:ve(p),lastName:ve(l),gender:s(n.gender)})}};function ta(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 Vp(t,e){return await Me([BigInt(0),BigInt(se[0].standard),jC(t,253),...Ab(new Uint8Array(e),31).map(r=>BigInt(r))])}async function Eb(t,e){let r=ot(new Uint8Array([0,...Te(se[0].evm,2),...t.map(i=>Number(i)),...e.map(i=>Number(i))]));return Mo(r,31)}function Bb(t){return t.minAge}function Tb(t){return t.maxAge}async function jp(t,e){return await Me([BigInt(1),BigInt(se[1].standard),BigInt(t),BigInt(e)])}async function kb(t,e){let r=ot(new Uint8Array([1,...Te(se[1].evm,2),t,e]));return Mo(r,31)}function ZC(t){return t.charCodeAt(0)*65536+t.charCodeAt(1)*256+t.charCodeAt(2)}async function Oi(t,e,r=false){let i=e.map(o=>ZC(o)),n=Oo(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 ic(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),...Oo(i,600)]));return Mo(n,31)}var Uo=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 Pb(t,e=Uo){return zl(t).getTime()===0?new Date(0):new Date(zl(t).getTime()+e*1e3)}function Nb(t,e=Uo){return ql(t).getTime()===0?new Date(0):new Date(ql(t).getTime()+e*1e3)}async function nc(t,e,r,i=Uo){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 Xp(t,e,r,i=Uo){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 Mo(n,31)}function Rb(t){return BigInt(t.publicInputs[0])}function Db(t){return BigInt(t.publicInputs[1])}function YC(){return 2}var QC=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(QC||{});function oc(t){let e=[];if(t.user_address&&t.user_address.length>0){let r=Hl.fromHex(t.user_address).toNumberArray();e=[...e,1,...wb([r.length],2),...r];}if(t.chain){let r=Di(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 Wp(t,e=509){let r=Oo(t,e);return await Me([BigInt(8),BigInt(se[8].standard),...Ab(new Uint8Array(r),31).map(i=>BigInt(i))])}async function Ob(t,e=509){let r=Oo(t,e),i=ot(new Uint8Array([8,...Te(se[8].evm,2),...r]));return Mo(i,31)}var Mb=8544227306600425492560068004835614964118871262589609739238120993689090208159n,Ub=0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615dn;async function Zp(t,e,r,i){return await Me([BigInt(10),BigInt(se[10].standard),t,e,r,r===Ub?Mb:0n,i])}async function Fb(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===Ub?Mb:0n,32),...Te(i,1)]));return Mo(n,31)}function Pr(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function Lb(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function Nr(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 Yp(t){return BigInt(t.publicInputs[3])}function Qp(t){return BigInt(t.publicInputs[2])}function hr(t){return BigInt(t.publicInputs[0])}function Jp(t){return new Date(Number(BigInt(t.publicInputs[1]))*1e3)}function ra(t){return t.startsWith("data_check_integrity")?WC():t.startsWith("sig_check_id_data")?YC():t.startsWith("sig_check_dsc")?XC():t.startsWith("oprf_auth")?3:t.startsWith("outer")?8+(Number(t.substring(t.lastIndexOf("_")+1))-3):8}function Hb(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 Kb=["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"],zb=[...Vl,"Iceland","Liechtenstein","Norway"],qb=[...Vl.filter(t=>t!=="Cyprus"&&t!=="Ireland"),"Switzerland","Iceland","Liechtenstein","Norway"],Gb=["Brunei Darussalam","Cambodia","Indonesia","Lao People's Democratic Republic","Malaysia","Myanmar","Philippines","Singapore","Thailand","Vietnam"],$b=["Argentina","Brazil","Chile","Colombia","Paraguay","Uruguay"];Gl();var Up=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,Up.prototype);}};Up=Dt([N({type:B.Set,itemType:At})],Up);var Fp=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Dt([y({type:S.Integer})],Fp.prototype,"number",2),Dt([y({type:S.OctetString})],Fp.prototype,"hash",2);var Lp=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Dt([y({type:S.PrintableString})],Lp.prototype,"ldsVersion",2),Dt([y({type:S.PrintableString})],Lp.prototype,"unicodeVersion",2);var Mp=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Dt([y({type:S.ObjectIdentifier})],Mp.prototype,"value",2),Mp=Dt([N({type:B.Choice})],Mp);var Ul=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Dt([y({type:S.Integer})],Ul.prototype,"version",2),Dt([y({type:mt})],Ul.prototype,"hashAlgorithm",2),Dt([y({type:Fp,repeated:"sequence"})],Ul.prototype,"dataGroups",2),Dt([y({type:Lp,optional:true})],Ul.prototype,"versionInfo",2);var Fl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Dt([y({type:S.Integer})],Fl.prototype,"version",2),Dt([y({type:$t,repeated:"set"})],Fl.prototype,"certificates",2),Fl=Dt([N({type:B.Sequence})],Fl);Gl();var JC=["https://eu.node0.zkp.oprf.taceo.network","https://eu.node1.zkp.oprf.taceo.network","https://eu.node2.zkp.oprf.taceo.network"],Vb="1";Gt.Point.fromAffine(Bn);Js.ORDER;async function jb(t,e){let r=JC,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 Xb(t){return Me([t.x,t.y])}async function Wb(t,e){let r=Array.from(Buffer.from(xb(t).padStart(64,"0"),"hex")),i=wb(r,32),n=ot(new Uint8Array([9,...Te(se[9].evm,2),...i,e?1:0]));return Mo(n,31)}async function eh(t,e){return Me([BigInt(9),BigInt(se[9].standard),BigInt(`0x${xb(t)}`),e?1n:0n])}function ia(t){if(!t)return 0n;let e=ot(new TextEncoder().encode(t)).slice(0,31);return VC(Array.from(e))}function sc(t){return ia(t)}function eI(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 tI(t,e){return t.slice(0,e)}function rI(t,e){return t.slice(e)}function na(t,e,r=0){let i=eI(Buffer.from(t,"hex"),r),n=rI(i,e),o=tI(i,e);return {proof:n,publicInputs:o.map(s=>s.startsWith("0x")?s:`0x${s}`)}}function Zb(t){return BigInt(t.publicInputs[0])}function Yb(t){return BigInt(t.publicInputs[1])}function Qb(t){return new Date(Number(BigInt(t.publicInputs[2]))*1e3)}function th(t){return BigInt(t.publicInputs[3])}function rh(t){return BigInt(t.publicInputs[4])}function Jb(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 e6(t){return BigInt(t.publicInputs[t.publicInputs.length-2])}function t6(t){return BigInt(t.publicInputs[t.publicInputs.length-1])}function ih(t){return t.publicInputs.slice(5,t.publicInputs.length-3).map(BigInt)}if(typeof window>"u")try{let t=xC("crypto");crypto=t;}catch{}GC();var Jo=It(Il(),1);var iI=Object.defineProperty,nI=Object.getOwnPropertyDescriptor,oI=(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')}),o6=(t,e)=>()=>(t&&(e=t(t=0)),e),Ot=(t,e,r,i)=>{for(var n=i>1?void 0:i?nI(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&&iI(e,r,n),n},Mi,ac,Wl=o6(()=>{Mi={"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}},ac={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}};}),r6,i6,n6,sI=o6(()=>{Wl(),r6={p:ac.brainpoolP224r1.p,a:ac.brainpoolP224r1.a,b:ac.brainpoolP224r1.b,n:ac.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(r6),Fr),i6={p:Mi["P-192"].p,a:Mi["P-192"].a,b:Mi["P-192"].b,n:Mi["P-192"].n,h:BigInt(1),Gx:BigInt("0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"),Gy:BigInt("0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811")},Ge(qe(i6),Qn),n6={p:Mi["P-224"].p,a:Mi["P-224"].a,b:Mi["P-224"].b,n:Mi["P-224"].n,h:BigInt(1),Gx:BigInt("0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21"),Gy:BigInt("0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34")},Ge(qe(n6),Fr);});BigInt("0x2523648240000001ba344d80000000086121000000000013a700000000000012");Wl();Wl();var oh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,oh.prototype);}};oh=Ot([N({type:B.Set,itemType:At})],oh);var sh=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Ot([y({type:S.Integer})],sh.prototype,"number",2),Ot([y({type:S.OctetString})],sh.prototype,"hash",2);var ah=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Ot([y({type:S.PrintableString})],ah.prototype,"ldsVersion",2),Ot([y({type:S.PrintableString})],ah.prototype,"unicodeVersion",2);var nh=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Ot([y({type:S.ObjectIdentifier})],nh.prototype,"value",2),nh=Ot([N({type:B.Choice})],nh);var jl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Ot([y({type:S.Integer})],jl.prototype,"version",2),Ot([y({type:mt})],jl.prototype,"hashAlgorithm",2),Ot([y({type:sh,repeated:"sequence"})],jl.prototype,"dataGroups",2),Ot([y({type:ah,optional:true})],jl.prototype,"versionInfo",2);var Xl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Ot([y({type:S.Integer})],Xl.prototype,"version",2),Ot([y({type:$t,repeated:"set"})],Xl.prototype,"certificates",2),Xl=Ot([N({type:B.Sequence})],Xl);Wl();Gt.Point.fromAffine(Bn);Js.ORDER;if(typeof window>"u")try{let t=oI("crypto");crypto=t;}catch{}sI();function aI(t){return "0x"+Buffer.from(t).toString("hex").padStart(64,"0")}function s6(t){let e=[];for(let r=0;r<t.length;r+=32)e.push(aI(t.slice(r,r+32)));return e}var cI=(t=>(t[t.USER_ADDRESS=1]="USER_ADDRESS",t[t.CHAIN_ID=2]="CHAIN_ID",t[t.CUSTOM_DATA=3]="CUSTOM_DATA",t))(cI||{});var lI=(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))(lI||{});var dI=Object.defineProperty,uI=Object.getOwnPropertyDescriptor,fI=(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')}),f6=(t,e)=>()=>(t&&(e=t(t=0)),e),Mt=(t,e,r,i)=>{for(var n=i>1?void 0:i?uI(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&&dI(e,r,n),n},Ui,cc,Jl=f6(()=>{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}},cc={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}};}),a6,c6,l6,pI=f6(()=>{Jl(),a6={p:cc.brainpoolP224r1.p,a:cc.brainpoolP224r1.a,b:cc.brainpoolP224r1.b,n:cc.brainpoolP224r1.n,h:BigInt(1),Gx:BigInt("0xd9029ad2c7e5cf4340823b2a87dc68c9e4ce3174c1e6efdee12c07d"),Gy:BigInt("0x58aa56f772c0726f24c6b89e4ecdac24354b9e99caa3f6d3761402cd")},Ge(qe(a6),Fr),c6={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(c6),Qn),l6={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(l6),Fr);}),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 Rr(t,e){if(!t)throw new Error(e)}function oa(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 dh=class extends ie{constructor(t){super(t),Object.setPrototypeOf(this,dh.prototype);}};dh=Mt([N({type:B.Set,itemType:At})],dh);var uh=class{constructor(t={}){this.number=1,this.hash=new ArrayBuffer(0),Object.assign(this,t);}};Mt([y({type:S.Integer})],uh.prototype,"number",2),Mt([y({type:S.OctetString})],uh.prototype,"hash",2);var fh=class{constructor(t={}){this.ldsVersion="",this.unicodeVersion="",Object.assign(this,t);}};Mt([y({type:S.PrintableString})],fh.prototype,"ldsVersion",2),Mt([y({type:S.PrintableString})],fh.prototype,"unicodeVersion",2);var ch=class{constructor(t){this.value="",t&&(typeof t=="string"?this.value=t:Object.assign(this,t));}};Mt([y({type:S.ObjectIdentifier})],ch.prototype,"value",2),ch=Mt([N({type:B.Choice})],ch);var Zl=class{constructor(t={}){this.version=1,this.hashAlgorithm=new mt,this.dataGroups=[],Object.assign(this,t);}};Mt([y({type:S.Integer})],Zl.prototype,"version",2),Mt([y({type:mt})],Zl.prototype,"hashAlgorithm",2),Mt([y({type:uh,repeated:"sequence"})],Zl.prototype,"dataGroups",2),Mt([y({type:fh,optional:true})],Zl.prototype,"versionInfo",2);var Yl=class{constructor(t={}){this.version=0,this.certificates=[],Object.assign(this,t);}};Mt([y({type:S.Integer})],Yl.prototype,"version",2),Mt([y({type:$t,repeated:"set"})],Yl.prototype,"certificates",2),Yl=Mt([N({type:B.Sequence})],Yl);Jl();Gt.Point.fromAffine(Bn);Js.ORDER;if(typeof window>"u")try{let t=fI("crypto");crypto=t;}catch{}pI();var hI="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",d6=[18,32];function mI(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=hI[n]+i,r=r/BigInt(58);}return "1".repeat(e)+i}function ph(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]=d6[0],e[1]=d6[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 mI(e)}var gI=16,yI=14,bI=8,SI=12,td=0n;var xI=1;var Fo=1,Lo=2,rd=3;function u6(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 wI(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 AI(t,e){let r=e?.version??0;Rr(r===0||r===1,`Unsupported Packaged Certificates version: ${r}`);let i=e?.tags?u6(e.tags):t?.tags?u6(t.tags):[0n,0n,0n];Rr(i.length===3,"Tags must be exactly 3 fields");let n=e?.type??xI;Rr(n>=0&&n<=255,`Certificate type must fit in a single byte: ${n}`),Rr(t?.country?.length===3,`Country code must be 3 characters: ${t?.country}`);let o=wI(t.public_key);if(r===0)return Me([...i,BigInt(oa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2)]),31)[0]),...oa(o,31).map(s=>BigInt(s))]);if(r===1){Rr(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(oa(new Uint8Array([n,t.country.charCodeAt(0),t.country.charCodeAt(1),t.country.charCodeAt(2),...a]),31)[0]),s,...oa(o,31).map(c=>BigInt(c))])}else throw new Error(`Unsupported Packaged Certificates version: ${r}`)}async function _I(t,e=0){let r=await Promise.all(t.map(i=>AI(i,{version:e})));return r.sort((i,n)=>i>n?1:i<n?-1:0),r}async function CI(t,e=0){let r=await _I(t,e),i=new ed(gI,2);return await i.initialize(td,r),i}async function II(t){Rr(t.fingerprint!==void 0,"Revocation fingerprint required"),Rr(t.serial!==void 0,"Revocation serial required"),Rr(typeof t.fingerprint=="string"&&t.fingerprint.startsWith("0x"),`Revocation fingerprint must be a 0x-prefixed hex string: ${t.fingerprint}`),Rr(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(oa(e,31).map(i=>BigInt(i)));return Me([BigInt(t.fingerprint),r])}async function vI(t){let e=await Promise.all(t.map(r=>II(r)));return e.sort((r,i)=>r>i?1:r<i?-1:0),e}async function EI(t){let e=await vI(t),r=new ed(yI,2);return await r.initialize(td,e),r}async function BI(t){let e=t.map(i=>BigInt(i));e.sort((i,n)=>i>n?1:i<n?-1:0);let r=new ed(bI,2);return await r.initialize(td,e),r}var TI=21888242871839275222246405745257275088548364400416034343698204186575808495617n;function lh(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>=TI)throw new Error(`${t} must be in [0, BN254_FIELD_MODULUS): ${r}`);return r}async function kI(t){let{schemaVersion:e,timestamp:r,certificateRoot:i,revocationRoot:n,masterlistRoot:o}=t;Rr(Number.isInteger(e)&&e>=0&&e<=65535,`Schema version must be an integer that fits in 2 bytes: ${e}`),Rr(Number.isInteger(r)&&r>=0&&r<=4294967295,`Timestamp must be an integer that fits in 4 bytes: ${r}`);let s=lh("certificateRoot",i),a=lh("revocationRoot",n),c=lh("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(oa(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 p6(t){let e=t.version??0,r=await CI(t.certificates,e);if(e===0)return r.root;if(e===1){let i=t,n=await EI(i.revocations??[]),o=await BI(i.masterlists??[]),{certificateRoot:s}=await kI({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 h6(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(SI,2);return await r.initialize(td,e),r.root}var w6=It(lc(),1);function yh(t){return jI.find(e=>e.chainId===t)}function ad(t){let e=yh(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e}var hh="https://certificates.zkpassport.id/mainnet",qI="https://certificates.zkpassport.id/testnet",GI="http://localhost:8000/root",mh="https://circuits2.zkpassport.id/mainnet",$I="https://circuits2.zkpassport.id/testnet",VI="http://localhost:8000",jI=[{chainId:Di("ethereum"),chain:"ethereum",type:"mainnet",rpcUrl:"https://eth-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x8C93bB3a7ED88dA0647Ea53f8cd3f57832a513Cd",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("base"),chain:"base",type:"mainnet",rpcUrl:"https://base-mainnet.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0xC404C605130F3345E1A2BFdf3BAFABED7234cCa7",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("robinhood"),chain:"robinhood",type:"mainnet",rpcUrl:"https://rpc.mainnet.chain.robinhood.com",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x0A55cA59e98e17666C1A9a099d546E676088bC1A",packagedCertificatesUrl:hh,circuitUrl:mh},{chainId:Di("ethereum_sepolia"),chain:"ethereum_sepolia",type:"testnet",rpcUrl:"https://eth-sepolia.g.alchemy.com/v2/in6UjcATST36yyKuk83yb1yukKs65u8G",rootRegistry:"0x1D0000020038d6E40E1d98e09fA1bb3A7DAA8B70",registryHelper:"0x6Ee299B1E8049fadc3494f1110A3479f5BE8EC0e",packagedCertificatesUrl:qI,circuitUrl:$I},{chainId:Di("local"),chain:"local",type:"dev",rpcUrl:"http://localhost:8545",rootRegistry:"0x5FbDB2315678afecb367f032d93F642f64180aa3",registryHelper:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",packagedCertificatesUrl:GI,circuitUrl:VI}];function la(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${la(t).toLowerCase().padStart(64,"0")}`}var XI=3,WI=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).packagedCertificatesUrl}/${e}.json`),ZI="https://sanctions.zkpassport.id/mainnet",YI="https://sanctions.zkpassport.id/testnet",QI="http://localhost:8000/sanctions",JI=(t,e)=>(e=_t(e),t===1||t===8453?`${ZI}/${e}.tree.json.gz`:t===11155111?`${YI}/${e}.tree.json.gz`:`${QI}/${e}.tree.json.gz`),ev=(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")},tv=(t,e,r)=>r?`https://ipfs.zkpassport.id/ipfs/${r}`:(e=_t(e),`${ad(t).circuitUrl}/by-hash/${e}.json`),od=100,rv="0xc3bc16e8",S6="0x06ac4103",x6="0xcb0c82c7",iv="0x76785af8",nv="0x5d8d57a6",ov="0xbb3dd539",sv="0x2aae4296",av=[{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, w6.default)("zkpassport:registry"),sd=t=>t.toString(16).padStart(64,"0");function bh(t,e={}){let r=typeof t=="number"?t:Di(t);if(!yh(r))throw new Error(`Unsupported chain: ${t}`);return new cv({...e,chainId:r})}var cv=class gh{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=yh(i),u=e||d?.rpcUrl,p=r||d?.rootRegistry,m=n||d?.registryHelper;if(!u||!p||!m)throw new Error(`Unsupported chain ID: ${i}`);this.rpcUrl=u,this.rootRegistry=p,this.registryHelper=m,this.packagedCertsUrlGenerator=o||WI,this.circuitManifestUrlGenerator=s||ev,this.packagedCircuitUrlGenerator=a||tv,this.sanctionsTreeUrlGenerator=c||JI,this.retryCount=l||XI;}async getLatestCertificateRoot(){return this.getLatestRoot(Fo,"certificate")}async isCertificateRootValid(e,r){return this.isRootValid(Fo,"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 gh.validateCertificates(n,e))throw new Error(`Validation failed for packaged certificates: ${e}`);return n}static async validateCertificates(e,r){try{let i=await p6(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"?la(e):e??1,n=typeof i=="number"?`${S6}${Fo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${x6}${Fo.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(Fo,"certificate",e)}async getLatestCircuitRoot(){return this.getLatestRoot(Lo,"circuit")}async isCircuitRootValid(e,r){return this.isRootValid(Lo,"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 h6({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=s6(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 gh.validatePackagedCircuit(s,o))throw new Error(`Validation failed for packaged circuit: ${e}`);return s}async getHistoricalCircuitRoots(e,r=od){let i=typeof e=="string"?la(e):e??1,n=typeof i=="number"?`${S6}${Lo.toString(16).padStart(64,"0")}${i.toString(16).padStart(64,"0")}${r.toString(16).padStart(64,"0")}`:`${x6}${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 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(Lo,"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,`${nv}${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=av.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(Fo)}async getCircuitRegistryAddress(){return this.getRegistryAddress(Lo)}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,rv+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,sv+sd(e)+la(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(la(a.result))===1}async getRootDetails(e,r,i){if(i){Ft(`Getting ${r} root details`);let o=await this.rpcRequest(this.registryHelper,ov+sd(e)+la(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,iv+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 Gp(()=>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 Gp(()=>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=ph(`0x${i.slice(384,448)}`),p=i.slice(448,512),m=i.slice(512,576),b=i.slice(576,640),w=p===""?void 0:`0x${p}`,x=m===""?void 0:`0x${m}`,g=b===""?void 0:`0x${b}`;return {index:n,root:o,validFrom:s,validTo:c,revoked:l,leaves:d,cid:u,...w!==void 0&&{metadata1:w},...x!==void 0&&{metadata2:x},...g!==void 0&&{metadata3:g},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,p=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),w=parseInt(s.slice(u+192,u+256),16),x=w===0?void 0:new Date(w*1e3),g=parseInt(s.slice(u+256,u+320),16)===1,A=parseInt(s.slice(u+320,u+384),16),I=ph(`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:g,cid:I,leaves:A,...T!==void 0&&{metadata1:T},...G!==void 0&&{metadata2:G},...F!==void 0&&{metadata3:F},isLatest:d===a-1&&o,index:p});}return {roots:c,isLastPage:o}}return {roots:[],isLastPage:true}}};var A6=(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 lv(){return typeof process<"u"&&process.versions!=null&&typeof window>"u"}async function cd(t,e){if(lv())try{let r=await Promise.resolve().then(()=>It(C6(),1)).catch(()=>{try{return {default:A6("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 I6=10,v6="wss://bridge.zkpassport.id",E6=3e4,da="1";var dv=typeof window<"u"?{getRandomValues:t=>window.crypto.getRandomValues(t)}:globalThis.crypto,Sh=typeof window<"u"?window.crypto:typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:dv;function B6(t){let e=new Uint8Array(t);if(Sh&&typeof Sh.getRandomValues=="function")return Sh.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 xh(t){try{let e=new URL(t);return `${e.protocol}//${e.host.split(":")[0]}`}catch{return t}}function ua(t=16){let e=B6(t);return Buffer.from(e).toString("hex")}function T6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(t,...e){if(!T6(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 dc(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 wh(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 k6(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Dr(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Or(...t){for(let e=0;e<t.length;e++)t[e].fill(0);}function fa(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}var fv=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,pv=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function uc(t){if(at(t),pv)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=hv[t[r]];return e}function Ah(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function pa(t){if(typeof t=="string")t=Ah(t);else if(T6(t))t=Ko(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function P6(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 N6=(t,e)=>{function r(i,...n){if(at(i),!fv)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 R6(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&&!fc(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 D6(t,e,r){let i=new Uint8Array(16),n=fa(i);return ld(n,0,BigInt(e),r),ld(n,8,BigInt(t),r),i}function fc(t){return t.byteOffset%4===0}function Ko(t){return Uint8Array.from(t)}var Fi=16,Ch=new Uint8Array(16),ei=Dr(Ch),mv=225,gv=(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^mv<<24&-(n&1)}},mr=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function yv(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 bv=t=>t>64*1024?8:t>1024?4:2,dd=class{constructor(e,r){this.blockLen=Fi,this.outputLen=Fi,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=false,e=pa(e),at(e,16);let i=fa(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}=gv(n,o,s,a);let l=bv(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,p=this.windowSize=2**l,m=[];for(let b=0;b<u;b++)for(let w=0;w<p;w++){let x=0,g=0,A=0,I=0;for(let _=0;_<l;_++){if(!(w>>>l-_-1&1))continue;let{s0:v,s1:T,s2:G,s3:F}=c[l*b+_];x^=v,g^=T,A^=G,I^=F;}m.push({s0:x,s1:g,s2:A,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,p=(1<<o)-1,m=0;for(let b of [e,r,i,n])for(let w=0;w<4;w++){let x=b>>>8*w&255;for(let g=8/o-1;g>=0;g--){let A=x>>>o*g&p,{s0:I,s1:_,s2:C,s3:v}=s[m*a+A];c^=I,l^=_,d^=C,u^=v,m+=1;}}this.s0=c,this.s1=l,this.s2=d,this.s3=u;}update(e){dc(this),e=pa(e),at(e);let r=Dr(e),i=Math.floor(e.length/Fi),n=e.length%Fi;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&&(Ch.set(e.subarray(i*Fi)),this._updateBlock(ei[0],ei[1],ei[2],ei[3]),Or(ei)),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){dc(this),wh(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Dr(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e}digest(){let e=new Uint8Array(Fi);return this.digestInto(e),this.destroy(),e}},_h=class extends dd{constructor(e,r){e=pa(e),at(e);let i=yv(Ko(e));super(i,r),Or(i);}update(e){e=pa(e),dc(this);let r=Dr(e),i=e.length%Fi,n=Math.floor(e.length/Fi);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&&(Ch.set(e.subarray(n*Fi)),this._updateBlock(mr(ei[3]),mr(ei[2]),mr(ei[1]),mr(ei[0])),Or(ei)),this}digestInto(e){dc(this),wh(e,this),this.finished=true;let{s0:r,s1:i,s2:n,s3:o}=this,s=Dr(e);return s[0]=r,s[1]=i,s[2]=n,s[3]=o,e.reverse()}};function O6(t){let e=(i,n)=>t(n,i.length).update(pa(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 Ih=O6((t,e)=>new dd(t,e));O6((t,e)=>new _h(t,e));var Eh=16,xv=4,ud=new Uint8Array(Eh),wv=283;function Bh(t){return t<<1^wv&-(t>>7)}function M6(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(e&1),t=Bh(t);return r}var Av=(()=>{let t=new Uint8Array(256);for(let r=0,i=1;r<256;r++,i^=Bh(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 Or(t),e})();var _v=t=>t<<24|t>>>8,vh=t=>t<<8|t>>>24;function Cv(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(vh),n=i.map(vh),o=n.map(vh),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 F6=Cv(Av,t=>M6(t,3)<<24|t<<16|t<<8|M6(t,2));var Iv=(()=>{let t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=Bh(r))t[e]=r;return t})();function vv(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}=F6,i=[];fc(t)||i.push(t=Ko(t));let n=Dr(t),o=n.length,s=c=>pc(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(_v(l))^Iv[c/o-1]:o>6&&c%o===4&&(l=s(l)),a[c]=a[c-o]^l;}return Or(...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 pc(t,e,r,i,n){return t[e&255|r&65280]|t[i>>>16&255|n>>>16&65280]<<16}function U6(t,e,r,i,n){let{sbox2:o,T01:s,T23:a}=F6,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 w=t[c++]^fd(s,a,e,r,i,n),x=t[c++]^fd(s,a,r,i,n,e),g=t[c++]^fd(s,a,i,n,e,r),A=t[c++]^fd(s,a,n,e,r,i);e=w,r=x,i=g,n=A;}let d=t[c++]^pc(o,e,r,i,n),u=t[c++]^pc(o,r,i,n,e),p=t[c++]^pc(o,i,n,e,r),m=t[c++]^pc(o,n,e,r,i);return {s0:d,s1:u,s2:p,s3:m}}function pd(t,e,r,i,n){at(r,Eh),at(i),n=R6(i.length,n);let o=r,s=Dr(o),a=fa(o),c=Dr(i),l=Dr(n),d=12,u=i.length,p=a.getUint32(d,e),{s0:m,s1:b,s2:w,s3:x}=U6(t,s[0],s[1],s[2],s[3]);for(let A=0;A+4<=c.length;A+=4)l[A+0]=c[A+0]^m,l[A+1]=c[A+1]^b,l[A+2]=c[A+2]^w,l[A+3]=c[A+3]^x,p=p+1>>>0,a.setUint32(d,p,e),{s0:m,s1:b,s2:w,s3:x}=U6(t,s[0],s[1],s[2],s[3]);let g=Eh*Math.floor(c.length/xv);if(g<u){let A=new Uint32Array([m,b,w,x]),I=k6(A);for(let _=g,C=0;_<u;_++,C++)n[_]=i[_]^I[C];Or(A);}return n}function Ev(t,e,r,i,n){let o=n?n.length:0,s=t.create(r,i.length+o);n&&s.update(n);let a=D6(8*i.length,8*o,e);s.update(i),s.update(a);let c=s.digest();return Or(a),c}var Th=N6({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=Ev(Ih,false,a,l,i);for(let u=0;u<c.length;u++)d[u]^=c[u];return d}function s(){let a=vv(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(),p=fa(u);ld(p,8,BigInt(r.length*8),false);let m=Ih.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(),p=new Uint8Array(a.length+n),m=[c,l,d,u];fc(a)||m.push(a=Ko(a)),pd(c,false,d,a,p.subarray(0,a.length));let b=o(l,u,p.subarray(0,p.length-n));return m.push(b),p.set(b,a.length),Or(...m),p},decrypt(a){let{xk:c,authKey:l,counter:d,tagMask:u}=s(),p=[c,l,u,d];fc(a)||p.push(a=Ko(a));let m=a.subarray(0,-n),b=a.subarray(-n),w=o(l,u,m);if(p.push(w),!P6(w,b))throw new Error("aes/gcm: invalid ghash tag");let x=pd(c,false,d,m);return Or(...p),x}}});var Bv={p:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,n:0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,b:7n,Gx:0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Gy:0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n},{p:qo,n:Dh,Gx:Tv,Gy:kv,b:V6}=Bv,Go=32,kh=64,Vt=(t="")=>{throw new Error(t)},j6=t=>typeof t=="bigint",X6=t=>typeof t=="string",Pv=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",hc=(t,e)=>!Pv(t)||typeof e=="number"&&e>0&&t.length!==e?Vt("Uint8Array expected"):t,Oh=t=>new Uint8Array(t),Nv=t=>Uint8Array.from(t),W6=(t,e)=>t.toString(16).padStart(e,"0"),Z6=t=>Array.from(hc(t)).map(e=>W6(e,2)).join(""),Li={_0:48,_9:57,A:65,F:70,a:97,f:102},L6=t=>{if(t>=Li._0&&t<=Li._9)return t-Li._0;if(t>=Li.A&&t<=Li.F)return t-(Li.A-10);if(t>=Li.a&&t<=Li.f)return t-(Li.a-10)},Y6=t=>{let e="hex invalid";if(!X6(t))return Vt(e);let r=t.length,i=r/2;if(r%2)return Vt(e);let n=Oh(i);for(let o=0,s=0;o<i;o++,s+=2){let a=L6(t.charCodeAt(s)),c=L6(t.charCodeAt(s+1));if(a===void 0||c===void 0)return Vt(e);n[o]=a*16+c;}return n},yd=(t,e)=>hc(X6(t)?Y6(t):Nv(hc(t)),e),Rv=()=>globalThis?.crypto;var H6=(...t)=>{let e=Oh(t.reduce((i,n)=>i+hc(n).length,0)),r=0;return t.forEach(i=>{e.set(i,r),r+=i.length;}),e},Dv=(t=Go)=>Rv().getRandomValues(Oh(t)),md=BigInt,gc=(t,e,r,i="bad number: out of range")=>j6(t)&&e<=t&&t<r?t:Vt(i),ee=(t,e=qo)=>{let r=t%e;return r>=0n?r:e+r};var Ov=(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 K6=t=>t instanceof Pn?t:Vt("Point expected"),Q6=t=>ee(ee(t*t)*t+V6),z6=t=>gc(t,0n,qo),hd=t=>gc(t,1n,qo),Mv=t=>gc(t,1n,Dh),Ph=t=>(t&1n)===0n,J6=t=>Uint8Array.of(t),Uv=t=>J6(Ph(t)?2:3),Fv=t=>{let e=Q6(hd(t)),r=1n;for(let i=e,n=(qo+1n)/4n;n>0n;n>>=1n)n&1n&&(r=r*i%qo),i=i*i%qo;return ee(r*r)===e?r:Vt("sqrt invalid")},ti=class ti{constructor(e,r,i){f(this,"px");f(this,"py");f(this,"pz");this.px=z6(e),this.py=hd(r),this.pz=z6(i),Object.freeze(this);}static fromBytes(e){hc(e);let r,i=e[0],n=e.subarray(1),o=q6(n,0,Go),s=e.length;if(s===Go+1&&[2,3].includes(i)){let a=Fv(o),c=Ph(a);Ph(md(i))!==c&&(a=ee(-a)),r=new ti(o,a,1n);}return s===kh+1&&i===4&&(r=new ti(o,q6(n,Go,kh),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}=K6(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(zo)}negate(){return new ti(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}=K6(e),c=0n,l=V6,d=0n,u=0n,p=0n,m=ee(l*3n),b=ee(r*o),w=ee(i*s),x=ee(n*a),g=ee(r+i),A=ee(o+s);g=ee(g*A),A=ee(b+w),g=ee(g-A),A=ee(r+n);let I=ee(o+a);return A=ee(A*I),I=ee(b+x),A=ee(A-I),I=ee(i+n),d=ee(s+a),I=ee(I*d),d=ee(w+x),I=ee(I-d),p=ee(c*A),d=ee(m*x),p=ee(d+p),d=ee(w-p),p=ee(w+p),u=ee(d*p),w=ee(b+b),w=ee(w+b),x=ee(c*x),A=ee(m*A),w=ee(w+x),x=ee(b-x),x=ee(c*x),A=ee(A+x),b=ee(w*A),u=ee(u+b),b=ee(I*A),d=ee(g*d),d=ee(d-b),b=ee(g*w),p=ee(I*p),p=ee(p+b),new ti(d,u,p)}multiply(e,r=true){if(!r&&e===0n)return zo;if(Mv(e),e===1n)return this;if(this.equals(kn))return Gv(e).p;let i=zo,n=kn;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(zo))return {x:0n,y:0n};if(i===1n)return {x:e,y:r};let n=Ov(i,qo);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)===Q6(e)?this:Vt("bad point: not on curve")}toBytes(e=true){let{x:r,y:i}=this.assertValidity().toAffine(),n=Nh(r);return e?H6(Uv(i),n):H6(J6(4),n,Nh(i))}static fromAffine(e){let{x:r,y:i}=e;return r===0n&&i===0n?zo:new ti(r,i,1n)}toHex(e){return Z6(this.toBytes(e))}static fromPrivateKey(e){return kn.multiply(mc(e))}static fromHex(e){return ti.fromBytes(yd(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}};f(ti,"BASE"),f(ti,"ZERO");var Pn=ti,kn=new Pn(Tv,kv,1n),zo=new Pn(0n,1n,0n);Pn.BASE=kn;Pn.ZERO=zo;var Mh=t=>md("0x"+(Z6(t)||"0")),q6=(t,e,r)=>Mh(t.subarray(e,r)),Lv=2n**256n,Nh=t=>Y6(W6(gc(t,0n,Lv),kh)),mc=t=>{let e=j6(t)?t:Mh(yd(t,Go));return gc(e,1n,Dh,"private key invalid 3")};var e5=(t,e=true)=>kn.multiply(mc(t)).toBytes(e);var t5=(t,e,r=true)=>Pn.fromBytes(yd(e)).multiply(mc(t)).toBytes(r),Hv=t=>{t=yd(t),(t.length<Go+8||t.length>1024)&&Vt("expected 40-1024b");let e=ee(Mh(t),Dh-1n);return Nh(e+1n)},Kv=()=>Hv(Dv(Go+16));var r5={normPrivateKeyToScalar:mc,isValidPrivateKey:t=>{try{return !!mc(t)}catch{return false}},randomPrivateKey:Kv,precompute:(t=8,e=kn)=>(e.multiply(3n),e)},gd=8,zv=256,i5=Math.ceil(zv/gd)+1,Rh=2**(gd-1),qv=()=>{let t=[],e=kn,r=e;for(let i=0;i<i5;i++){r=e,t.push(r);for(let n=1;n<Rh;n++)r=r.add(e),t.push(r);e=r.double();}return t},G6,$6=(t,e)=>{let r=e.negate();return t?r:e},Gv=t=>{let e=G6||(G6=qv()),r=zo,i=kn,n=2**gd,o=n,s=md(n-1),a=md(gd);for(let c=0;c<i5;c++){let l=Number(t&s);t>>=a,l>Rh&&(l-=o,t+=1n);let d=c*Rh,u=d,p=d+Math.abs(l)-1,m=c%2!==0,b=l<0;l===0?i=i.add($6(m,e[u])):r=r.add($6(b,e[p]));}return {p:r,f:i}};function $v(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Sd(t,...e){if(!$v(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 Uh(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 n5(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 yc(...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 Mr(t,e){return t<<32-e|t>>>e}function Vv(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Fh(t){return typeof t=="string"&&(t=Vv(t)),Sd(t),t}var bd=class{};function o5(t){let e=i=>t().update(Fh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function jv(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 s5(t,e,r){return t&e^~t&r}function a5(t,e,r){return t&e^t&r^e&r}var wd=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){Uh(this),e=Fh(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){Uh(this),n5(e,this),this.finished=true;let{buffer:r,view:i,blockLen:n,isLE:o}=this,{pos:s}=this;r[s++]=128,yc(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(i,0),s=0);for(let u=s;u<n;u++)r[u]=0;jv(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()}},Hi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Xv=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]),Nn=new Uint32Array(64),Lh=class extends wd{constructor(e=32){super(64,e,8,false),this.A=Hi[0]|0,this.B=Hi[1]|0,this.C=Hi[2]|0,this.D=Hi[3]|0,this.E=Hi[4]|0,this.F=Hi[5]|0,this.G=Hi[6]|0,this.H=Hi[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)Nn[u]=e.getUint32(r,false);for(let u=16;u<64;u++){let p=Nn[u-15],m=Nn[u-2],b=Mr(p,7)^Mr(p,18)^p>>>3,w=Mr(m,17)^Mr(m,19)^m>>>10;Nn[u]=w+Nn[u-7]+b+Nn[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 p=Mr(a,6)^Mr(a,11)^Mr(a,25),m=d+p+s5(a,c,l)+Xv[u]+Nn[u]|0,w=(Mr(i,2)^Mr(i,13)^Mr(i,22))+a5(i,n,o)|0;d=l,l=c,c=a,a=s+m|0,s=o,o=n,n=i,i=m+w|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(){yc(Nn);}destroy(){this.set(0,0,0,0,0,0,0,0),yc(this.buffer);}};var c5=o5(()=>new Lh);async function l5(t){let r=new TextEncoder().encode(t),i=await c5(r);return new Uint8Array(i).slice(0,12)}function Ad(){let t=r5.randomPrivateKey(),e=e5(t);return {privateKey:t,publicKey:e}}function Hh(t,e){return t5(t,e).slice(0,32)}async function bc(t,e,r){let i=await l5(r),n=Th(e,i),o=Ah(t);return n.encrypt(o)}async function Kh(t,e,r){let i=await l5(r),o=Th(e,i).decrypt(t);return new TextDecoder().decode(o)}var D8=It(lc(),1);function xa(t){let e=t.length;for(;--e>=0;)t[e]=0;}var Wv=0,Z5=1,Zv=2,Yv=3,Qv=258,u2=29,Nc=256,Ic=Nc+1+u2,ga=30,f2=19,Y5=2*Ic+1,$o=15,zh=16,Jv=7,p2=256,Q5=16,J5=17,e8=18,r2=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]),e9=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),t8=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t9=512,zi=new Array((Ic+2)*2);xa(zi);var Ac=new Array(ga*2);xa(Ac);var vc=new Array(t9);xa(vc);var Ec=new Array(Qv-Yv+1);xa(Ec);var h2=new Array(u2);xa(h2);var Td=new Array(ga);xa(Td);function qh(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 r8,i8,n8;function Gh(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e;}var o8=t=>t<256?vc[t]:vc[256+(t>>>7)],Bc=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255;},Lt=(t,e,r)=>{t.bi_valid>zh-r?(t.bi_buf|=e<<t.bi_valid&65535,Bc(t,t.bi_buf),t.bi_buf=e>>zh-t.bi_valid,t.bi_valid+=r-zh):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r);},ni=(t,e,r)=>{Lt(t,r[e*2],r[e*2+1]);},s8=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},r9=t=>{t.bi_valid===16?(Bc(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);},i9=(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,p,m,b,w=0;for(p=0;p<=$o;p++)t.bl_count[p]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<Y5;l++)d=t.heap[l],p=r[r[d*2+1]*2+1]+1,p>c&&(p=c,w++),r[d*2+1]=p,!(d>i)&&(t.bl_count[p]++,m=0,d>=a&&(m=s[d-a]),b=r[d*2],t.opt_len+=b*(p+m),o&&(t.static_len+=b*(n[d*2+1]+m)));if(w!==0){do{for(p=c-1;t.bl_count[p]===0;)p--;t.bl_count[p]--,t.bl_count[p+1]+=2,t.bl_count[c]--,w-=2;}while(w>0);for(p=c;p!==0;p--)for(d=t.bl_count[p];d!==0;)u=t.heap[--l],!(u>i)&&(r[u*2+1]!==p&&(t.opt_len+=(p-r[u*2+1])*r[u*2],r[u*2+1]=p),d--);}},a8=(t,e,r)=>{let i=new Array($o+1),n=0,o,s;for(o=1;o<=$o;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]=s8(i[a]++,a));}},n9=()=>{let t,e,r,i,n,o=new Array($o+1);for(r=0,i=0;i<u2-1;i++)for(h2[i]=r,t=0;t<1<<r2[i];t++)Ec[r++]=i;for(Ec[r-1]=i,n=0,i=0;i<16;i++)for(Td[i]=n,t=0;t<1<<Bd[i];t++)vc[n++]=i;for(n>>=7;i<ga;i++)for(Td[i]=n<<7,t=0;t<1<<Bd[i]-7;t++)vc[256+n++]=i;for(e=0;e<=$o;e++)o[e]=0;for(t=0;t<=143;)zi[t*2+1]=8,t++,o[8]++;for(;t<=255;)zi[t*2+1]=9,t++,o[9]++;for(;t<=279;)zi[t*2+1]=7,t++,o[7]++;for(;t<=287;)zi[t*2+1]=8,t++,o[8]++;for(a8(zi,Ic+1,o),t=0;t<ga;t++)Ac[t*2+1]=5,Ac[t*2]=s8(t,5);r8=new qh(zi,r2,Nc+1,Ic,$o),i8=new qh(Ac,Bd,0,ga,$o),n8=new qh(new Array(0),e9,0,f2,Jv);},c8=t=>{let e;for(e=0;e<Ic;e++)t.dyn_ltree[e*2]=0;for(e=0;e<ga;e++)t.dyn_dtree[e*2]=0;for(e=0;e<f2;e++)t.bl_tree[e*2]=0;t.dyn_ltree[p2*2]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0;},l8=t=>{t.bi_valid>8?Bc(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0;},d5=(t,e,r,i)=>{let n=e*2,o=r*2;return t[n]<t[o]||t[n]===t[o]&&i[e]<=i[r]},$h=(t,e,r)=>{let i=t.heap[r],n=r<<1;for(;n<=t.heap_len&&(n<t.heap_len&&d5(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!d5(e,i,t.heap[n],t.depth));)t.heap[r]=t.heap[n],r=n,n<<=1;t.heap[r]=i;},u5=(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?ni(t,n,e):(s=Ec[n],ni(t,s+Nc+1,e),a=r2[s],a!==0&&(n-=h2[s],Lt(t,n,a)),i--,s=o8(i),ni(t,s,r),a=Bd[s],a!==0&&(i-=Td[s],Lt(t,i,a)));while(o<t.sym_next);ni(t,p2,e);},i2=(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=Y5,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--)$h(t,r,s);l=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$h(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++,$h(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],i9(t,e),a8(r,c,t.bl_count);},f5=(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[Q5*2]++):a<=10?t.bl_tree[J5*2]++:t.bl_tree[e8*2]++,a=0,n=o,s===0?(c=138,l=3):o===s?(c=6,l=3):(c=7,l=4));},p5=(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 ni(t,o,t.bl_tree);while(--a!==0);else o!==0?(o!==n&&(ni(t,o,t.bl_tree),a--),ni(t,Q5,t.bl_tree),Lt(t,a-3,2)):a<=10?(ni(t,J5,t.bl_tree),Lt(t,a-3,3)):(ni(t,e8,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);}},o9=t=>{let e;for(f5(t,t.dyn_ltree,t.l_desc.max_code),f5(t,t.dyn_dtree,t.d_desc.max_code),i2(t,t.bl_desc),e=f2-1;e>=3&&t.bl_tree[t8[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},s9=(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[t8[n]*2+1],3);p5(t,t.dyn_ltree,e-1),p5(t,t.dyn_dtree,r-1);},a9=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<Nc;r++)if(t.dyn_ltree[r*2]!==0)return 1;return 0},h5=false,c9=t=>{h5||(n9(),h5=true),t.l_desc=new Gh(t.dyn_ltree,r8),t.d_desc=new Gh(t.dyn_dtree,i8),t.bl_desc=new Gh(t.bl_tree,n8),t.bi_buf=0,t.bi_valid=0,c8(t);},d8=(t,e,r,i)=>{Lt(t,(Wv<<1)+(i?1:0),3),l8(t),Bc(t,r),Bc(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r;},l9=t=>{Lt(t,Z5<<1,3),ni(t,p2,zi),r9(t);},d9=(t,e,r,i)=>{let n,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=a9(t)),i2(t,t.l_desc),i2(t,t.d_desc),s=o9(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?d8(t,e,r,i):t.strategy===4||o===n?(Lt(t,(Z5<<1)+(i?1:0),3),u5(t,zi,Ac)):(Lt(t,(Zv<<1)+(i?1:0),3),s9(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),u5(t,t.dyn_ltree,t.dyn_dtree)),c8(t),i&&l8(t);},u9=(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[(Ec[r]+Nc+1)*2]++,t.dyn_dtree[o8(e)*2]++),t.sym_next===t.sym_end),f9=c9,p9=d8,h9=d9,m9=u9,g9=l9,y9={_tr_init:f9,_tr_stored_block:p9,_tr_flush_block:h9,_tr_tally:m9,_tr_align:g9},b9=(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},Tc=b9,S9=()=>{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},x9=new Uint32Array(S9()),w9=(t,e,r,i)=>{let n=x9,o=i+r;t^=-1;for(let s=i;s<o;s++)t=t>>>8^n[(t^e[s])&255];return t^-1},it=w9,Xo={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:A9,_tr_stored_block:n2,_tr_flush_block:_9,_tr_tally:On,_tr_align:C9}=y9,{Z_NO_FLUSH:Mn,Z_PARTIAL_FLUSH:I9,Z_FULL_FLUSH:v9,Z_FINISH:gr,Z_BLOCK:m5,Z_OK:ct,Z_STREAM_END:g5,Z_STREAM_ERROR:oi,Z_DATA_ERROR:E9,Z_BUF_ERROR:Vh,Z_DEFAULT_COMPRESSION:B9,Z_FILTERED:T9,Z_HUFFMAN_ONLY:_d,Z_RLE:k9,Z_FIXED:P9,Z_DEFAULT_STRATEGY:N9,Z_UNKNOWN:R9,Z_DEFLATED:Nd}=wa,D9=9,O9=15,M9=8,U9=29,F9=256,o2=F9+1+U9,L9=30,H9=19,K9=2*o2+1,z9=15,be=3,Dn=258,si=Dn+be+1,q9=32,ba=42,m2=57,s2=69,a2=73,c2=91,l2=103,Vo=113,xc=666,Ct=1,Aa=2,Wo=3,_a=4,G9=3,jo=(t,e)=>(t.msg=Xo[e],e),y5=t=>t*2-(t>4?9:0),Rn=t=>{let e=t.length;for(;--e>=0;)t[e]=0;},$9=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)},g2=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask,Zo=(t,e)=>{let r;if(t.legacy_hash)r=t.ins_h=g2(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)=>{_9(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;},Sc=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255;},d2=(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=Tc(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)},u8=(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-si?t.strstart-(t.w_size-si):0,l=t.window,d=t.w_mask,u=t.prev,p=t.strstart+Dn,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<p);if(o=Dn-(p-i),i=p-Dn,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},Sa=t=>{let e=t.w_size,r,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-si)&&(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),$9(t),i+=e),t.strm.avail_in===0)break;if(r=d2(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=g2(t,t.ins_h,t.window[n+1]);t.insert&&(Zo(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&&(Zo(t,n),n++,t.insert--,!(t.lookahead+t.insert<=be)););}while(t.lookahead<si&&t.strm.avail_in!==0)},f8=(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===Mn||i!==n+t.strm.avail_in)))break;s=e===gr&&i===n+t.strm.avail_in?1:0,n2(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&&(d2(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?_a:e!==Mn&&e!==gr&&t.strm.avail_in===0&&t.strstart===t.block_start?Aa:(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&&(d2(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!==Mn&&t.strm.avail_in===0&&n<=o)&&(i=n>o?o:n,s=e===gr&&t.strm.avail_in===0&&i===n?1:0,n2(t,t.block_start,i,s),t.block_start+=i,jt(t.strm)),s?Wo:Ct)},jh=(t,e)=>{let r,i;for(;;){if(t.lookahead<si){if(Sa(t),t.lookahead<si&&e===Mn)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Zo(t,t.strstart)),r!==0&&t.strstart-r<=t.w_size-si&&(t.match_length=u8(t,r)),t.match_length>=be)if(i=On(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=Zo(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=g2(t,t.ins_h,t.window[t.strstart+1]));else i=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},ha=(t,e)=>{let r,i,n;for(;;){if(t.lookahead<si){if(Sa(t),t.lookahead<si&&e===Mn)return Ct;if(t.lookahead===0)break}if(r=0,t.lookahead>=be&&(r=Zo(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-si&&(t.match_length=u8(t,r),t.match_length<=5&&(t.strategy===T9||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=On(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=Zo(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=On(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=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},V9=(t,e)=>{let r,i,n,o,s=t.window;for(;;){if(t.lookahead<=Dn){if(Sa(t),t.lookahead<=Dn&&e===Mn)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+Dn;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=Dn-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead);}if(t.match_length>=be?(r=On(t,1,t.match_length-be),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa},j9=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(Sa(t),t.lookahead===0)){if(e===Mn)return Ct;break}if(t.match_length=0,r=On(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?Wo:_a):t.sym_next&&(Xt(t,false),t.strm.avail_out===0)?Ct:Aa};function ri(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 wc=[new ri(0,0,0,0,f8),new ri(4,4,8,4,jh),new ri(4,5,16,8,jh),new ri(4,6,32,32,jh),new ri(4,4,16,16,ha),new ri(8,16,32,32,ha),new ri(8,16,128,128,ha),new ri(8,32,128,256,ha),new ri(32,128,258,1024,ha),new ri(32,258,258,4096,ha)],X9=t=>{t.window_size=2*t.w_size,Rn(t.head),t.max_lazy_match=wc[t.level].max_lazy,t.good_match=wc[t.level].good_length,t.nice_match=wc[t.level].nice_length,t.max_chain_length=wc[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 W9(){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(K9*2),this.dyn_dtree=new Uint16Array((2*L9+1)*2),this.bl_tree=new Uint16Array((2*H9+1)*2),Rn(this.dyn_ltree),Rn(this.dyn_dtree),Rn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(z9+1),this.heap=new Uint16Array(2*o2+1),Rn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*o2+1),Rn(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 Rc=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.status!==ba&&e.status!==m2&&e.status!==s2&&e.status!==a2&&e.status!==c2&&e.status!==l2&&e.status!==Vo&&e.status!==xc?1:0},p8=t=>{if(Rc(t))return jo(t,oi);t.total_in=t.total_out=0,t.data_type=R9;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?m2:e.wrap?ba:Vo,t.adler=e.wrap===2?0:1,e.last_flush=-2,A9(e),ct},h8=t=>{let e=p8(t);return e===ct&&X9(t.state),e},Z9=(t,e)=>Rc(t)||t.state.wrap!==2?oi:(t.state.gzhead=e,ct),m8=(t,e,r,i,n,o,s)=>{if(!t)return oi;let a=1;if(e===B9&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>D9||r!==Nd||i<8||i>15||e<0||e>9||o<0||o>P9||i===8&&a!==1)return jo(t,oi);i===8&&(i=9);let c=new W9;return t.state=c,c.strm=t,c.status=ba,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,h8(t)},Y9=(t,e)=>m8(t,e,Nd,O9,M9,N9),Q9=(t,e)=>{if(Rc(t)||e>m5||e<0)return t?jo(t,oi):oi;let r=t.state;if(!t.output||t.avail_in!==0&&!t.input||r.status===xc&&e!==gr)return jo(t,t.avail_out===0?Vh:oi);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&&y5(e)<=y5(i)&&e!==gr)return jo(t,Vh);if(r.status===xc&&t.avail_in!==0)return jo(t,Vh);if(r.status===ba&&r.wrap===0&&(r.status=Vo),r.status===ba){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|=q9),n+=31-n%31,Sc(r,n),r.strstart!==0&&(Sc(r,t.adler>>>16),Sc(r,t.adler&65535)),t.adler=1,r.status=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===m2){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=s2;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,G9),r.status=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(r.status===s2){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=a2;}if(r.status===a2){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=c2;}if(r.status===c2){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=l2;}if(r.status===l2){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=Vo,jt(t),r.pending!==0)return r.last_flush=-1,ct}if(t.avail_in!==0||r.lookahead!==0||e!==Mn&&r.status!==xc){let n=r.level===0?f8(r,e):r.strategy===_d?j9(r,e):r.strategy===k9?V9(r,e):wc[r.level].func(r,e);if((n===Wo||n===_a)&&(r.status=xc),n===Ct||n===Wo)return t.avail_out===0&&(r.last_flush=-1),ct;if(n===Aa&&(e===I9?C9(r):e!==m5&&(n2(r,0,0,false),e===v9&&(Rn(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?g5:(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)):(Sc(r,t.adler>>>16),Sc(r,t.adler&65535)),jt(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?ct:g5)},J9=t=>{if(Rc(t))return oi;let e=t.state.status;return t.state=null,e===Vo?jo(t,E9):ct},e7=(t,e)=>{let r=e.length;if(Rc(t))return oi;let i=t.state,n=i.wrap;if(n===2||n===1&&i.status!==ba||i.lookahead)return oi;if(n===1&&(t.adler=Tc(t.adler,e,r,0)),i.wrap=0,r>=i.w_size){n===0&&(Rn(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,Sa(i);i.lookahead>=be;){let c=i.strstart,l=i.lookahead-(be-1);do Zo(i,c),c++;while(--l);i.strstart=c,i.lookahead=be-1,Sa(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},t7=Y9,r7=m8,i7=h8,n7=p8,o7=Z9,s7=Q9,a7=J9,c7=e7,l7="pako deflate (from Nodeca project)",_c={deflateInit:t7,deflateInit2:r7,deflateReset:i7,deflateResetKeep:n7,deflateSetHeader:o7,deflate:s7,deflateEnd:a7,deflateSetDictionary:c7,deflateInfo:l7},d7=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),u7=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)d7(r,i)&&(t[i]=r[i]);}}return t},f7=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:u7,flattenChunks:f7},g8=true;try{String.fromCharCode.apply(null,new Uint8Array(1));}catch{g8=false;}var kc=new Uint8Array(256);for(let t=0;t<256;t++)kc[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;kc[254]=kc[255]=1;var p7=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},h7=(t,e)=>{if(e<65534&&t.subarray&&g8)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},m7=(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=kc[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 h7(o,n)},g7=(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+kc[t[r]]>e?r:e},Pc={string2buf:p7,buf2string:m7,utf8border:g7};function y7(){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 y8=y7,b8=Object.prototype.toString,{Z_NO_FLUSH:b7,Z_SYNC_FLUSH:S7,Z_FULL_FLUSH:x7,Z_FINISH:w7,Z_OK:kd,Z_STREAM_END:A7,Z_DEFAULT_COMPRESSION:_7,Z_DEFAULT_STRATEGY:C7,Z_DEFLATED:I7}=wa,v7={level:_7,method:I7,chunkSize:16384,windowBits:15,memLevel:8,strategy:C7,legacyHash:true};function Dc(t){this.options=Rd.assign({},v7,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 y8,this.strm.avail_out=0;let r=_c.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy,e.legacyHash);if(r!==kd)throw new Error(Xo[r]);if(e.header&&_c.deflateSetHeader(this.strm,e.header),e.dictionary){let i;if(typeof e.dictionary=="string"?i=Pc.string2buf(e.dictionary):b8.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,r=_c.deflateSetDictionary(this.strm,i),r!==kd)throw new Error(Xo[r]);this._dict_set=true;}}Dc.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?w7:b7,typeof t=="string"?r.input=Pc.string2buf(t):b8.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===S7||o===x7)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(n=_c.deflate(r,o),n===A7)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=_c.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};Dc.prototype.onData=function(t){this.chunks.push(t);};Dc.prototype.onEnd=function(t){t===kd&&(this.result=Rd.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg;};function y2(t,e){let r=new Dc(e);if(r.push(t,true),r.err)throw r.msg||Xo[r.err];return r.result}var k7=y2,D7={deflate:k7},Cd=16209,O7=16191,M7=function(e,r){let i,n,o,s,a,c,l,d,u,p,m,b,w,x,g,A,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,p=k.window,m=k.hold,b=k.bits,w=k.lencode,x=k.distcode,g=(1<<k.lenbits)-1,A=(1<<k.distbits)-1;e:do{b<15&&(m+=F[i++]<<b,b+=8,m+=F[i++]<<b,b+=8),I=w[m&g];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&A];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=p,u===0){if(T+=l-_,_<C){C-=_;do H[o++]=p[T++];while(--_);T=o-v,G=H;}}else if(u<_){if(T+=l+u-_,_-=u,_<C){C-=_;do H[o++]=p[T++];while(--_);if(T=0,u<C){_=u,C-=_;do H[o++]=p[T++];while(--_);T=o-v,G=H;}}}else if(T+=u-_,_<C){C-=_;do H[o++]=p[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=w[(I&65535)+(m&(1<<_)-1)];continue t}else if(_&32){k.mode=O7;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;},ma=15,b5=852,S5=592,x5=0,Xh=1,w5=2,U7=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]),F7=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]),L7=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]),H7=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]),K7=(t,e,r,i,n,o,s,a)=>{let c=a.bits,l=0,d=0,u=0,p=0,m=0,b=0,w=0,x=0,g=0,A=0,I,_,C,v,T,G=null,F,H=new Uint16Array(ma+1),k=new Uint16Array(ma+1),E=null,q,O,z;for(l=0;l<=ma;l++)H[l]=0;for(d=0;d<i;d++)H[e[r+d]]++;for(m=c,p=ma;p>=1&&H[p]===0;p--);if(m>p&&(m=p),p===0)return n[o++]=1<<24|64<<16|0,n[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<p&&H[u]===0;u++);for(m<u&&(m=u),x=1,l=1;l<=ma;l++)if(x<<=1,x-=H[l],x<0)return -1;if(x>0&&(t===x5||p!==1))return -1;for(k[1]=0,l=1;l<ma;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===x5?(G=E=s,F=20):t===Xh?(G=U7,E=F7,F=257):(G=L7,E=H7,F=0),A=0,d=0,l=u,T=o,b=m,w=0,C=-1,g=1<<m,v=g-1,t===Xh&&g>b5||t===w5&&g>S5)return 1;for(;;){q=l-w,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-w,_=1<<b,u=_;do _-=I,n[T+(A>>w)+_]=q<<24|O<<16|z|0;while(_!==0);for(I=1<<l-1;A&I;)I>>=1;if(I!==0?(A&=I-1,A+=I):A=0,d++,--H[l]===0){if(l===p)break;l=e[r+s[d]];}if(l>m&&(A&v)!==C){for(w===0&&(w=m),T+=u,b=l-w,x=1<<b;b+w<p&&(x-=H[b+w],!(x<=0));)b++,x<<=1;if(g+=1<<b,t===Xh&&g>b5||t===w5&&g>S5)return 1;C=A&v,n[C]=m<<24|b<<16|T-o|0;}}return A!==0&&(n[T+A]=l-w<<24|64<<16|0),a.bits=m,0},Cc=K7,z7=0,S8=1,x8=2,{Z_FINISH:A5,Z_BLOCK:q7,Z_TREES:Id,Z_OK:Yo,Z_STREAM_END:G7,Z_NEED_DICT:$7,Z_STREAM_ERROR:yr,Z_DATA_ERROR:w8,Z_MEM_ERROR:A8,Z_BUF_ERROR:V7,Z_DEFLATED:_5}=wa,Dd=16180,C5=16181,I5=16182,v5=16183,E5=16184,B5=16185,T5=16186,k5=16187,P5=16188,N5=16189,Pd=16190,Ki=16191,Wh=16192,R5=16193,Zh=16194,D5=16195,O5=16196,M5=16197,U5=16198,vd=16199,Ed=16200,F5=16201,L5=16202,H5=16203,K5=16204,z5=16205,Yh=16206,q5=16207,G5=16208,De=16209,_8=16210,C8=16211,j7=852,X7=592,W7=15,Z7=W7,$5=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function Y7(){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 Qo=t=>{if(!t)return 1;let e=t.state;return !e||e.strm!==t||e.mode<Dd||e.mode>C8?1:0},I8=t=>{if(Qo(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(j7),e.distcode=e.distdyn=new Int32Array(X7),e.sane=1,e.back=-1,Yo},v8=t=>{if(Qo(t))return yr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,I8(t)},E8=(t,e)=>{let r;if(Qo(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,v8(t))},B8=(t,e)=>{if(!t)return yr;let r=new Y7;t.state=r,r.strm=t,r.window=null,r.mode=Dd;let i=E8(t,e);return i!==Yo&&(t.state=null),i},Q7=t=>B8(t,Z7),V5=true,Qh,Jh,J7=t=>{if(V5){Qh=new Int32Array(512),Jh=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(Cc(S8,t.lens,0,288,Qh,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Cc(x8,t.lens,0,32,Jh,0,t.work,{bits:5}),V5=false;}t.lencode=Qh,t.lenbits=9,t.distcode=Jh,t.distbits=5;},T8=(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},eE=(t,e)=>{let r,i,n,o,s,a,c,l,d,u,p,m,b,w,x=0,g,A,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(Qo(t)||!t.output||!t.input&&t.avail_in!==0)return yr;r=t.state,r.mode===Ki&&(r.mode=Wh),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,p=c,G=Yo;e:for(;;)switch(r.mode){case Dd:if(r.wrap===0){r.mode=Wh;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=C5;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)!==_5){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?N5:Ki,l=0,d=0;break;case C5:for(;d<16;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(r.flags=l,(r.flags&255)!==_5){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=I5;case I5: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=v5;case v5: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=E5;case E5: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=B5;case B5: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=T5;case T5: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=k5;case k5: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=P5;case P5: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=Ki;break;case N5:for(;d<32;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}t.adler=r.check=$5(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,$7;t.adler=r.check=1,r.mode=Ki;case Ki:if(e===q7||e===Id)break e;case Wh:if(r.last){l>>>=d&7,d-=d&7,r.mode=Yh;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=R5;break;case 1:if(J7(r),r.mode=vd,e===Id){l>>>=2,d-=2;break e}break;case 2:r.mode=O5;break;case 3:t.msg="invalid block type",r.mode=De;}l>>>=2,d-=2;break;case R5: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=Zh,e===Id)break e;case Zh:r.mode=D5;case D5: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=Ki;break;case O5: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=M5;case M5: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=Cc(z7,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=U5;case U5:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[l&(1<<r.lenbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(I<16)l>>>=g,d-=g,r.lens[r.have++]=I;else {if(I===16){for(k=g+2;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(l>>>=g,d-=g,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=g+3;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=g,d-=g,T=0,m=3+(l&7),l>>>=3,d-=3;}else {for(k=g+7;d<k;){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=g,d-=g,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=Cc(S8,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=Cc(x8,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,M7(t,p),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===Ki&&(r.back=-1);break}for(r.back=0;x=r.lencode[l&(1<<r.lenbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if(A&&(A&240)===0){for(_=g,C=A,v=I;x=r.lencode[v+((l&(1<<_+C)-1)>>_)],g=x>>>24,A=x>>>16&255,I=x&65535,!(_+g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=g,d-=g,r.back+=g,r.length=I,A===0){r.mode=z5;break}if(A&32){r.back=-1,r.mode=Ki;break}if(A&64){t.msg="invalid literal/length code",r.mode=De;break}r.extra=A&15,r.mode=F5;case F5: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=L5;case L5:for(;x=r.distcode[l&(1<<r.distbits)-1],g=x>>>24,A=x>>>16&255,I=x&65535,!(g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}if((A&240)===0){for(_=g,C=A,v=I;x=r.distcode[v+((l&(1<<_+C)-1)>>_)],g=x>>>24,A=x>>>16&255,I=x&65535,!(_+g<=d);){if(a===0)break e;a--,l+=i[o++]<<d,d+=8;}l>>>=_,d-=_,r.back+=_;}if(l>>>=g,d-=g,r.back+=g,A&64){t.msg="invalid distance code",r.mode=De;break}r.offset=I,r.extra=A&15,r.mode=H5;case H5: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=K5;case K5:if(c===0)break e;if(m=p-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),w=r.window;}else w=n,b=s-r.offset,m=r.length;m>c&&(m=c),c-=m,r.length-=m;do n[s++]=w[b++];while(--m);r.length===0&&(r.mode=Ed);break;case z5:if(c===0)break e;n[s++]=r.length,c--,r.mode=Ed;break;case Yh:if(r.wrap){for(;d<32;){if(a===0)break e;a--,l|=i[o++]<<d,d+=8;}if(p-=c,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?it(r.check,n,p,s-p):Tc(r.check,n,p,s-p)),p=c,r.wrap&4&&(r.flags?l:$5(l))!==r.check){t.msg="incorrect data check",r.mode=De;break}l=0,d=0;}r.mode=q5;case q5: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=G5;case G5:G=G7;break e;case De:G=w8;break e;case _8:return A8;case C8: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||p!==t.avail_out&&r.mode<De&&(r.mode<Yh||e!==A5))&&T8(t,t.output,t.next_out,p-t.avail_out),u-=t.avail_in,p-=t.avail_out,t.total_in+=u,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?it(r.check,n,p,t.next_out-p):Tc(r.check,n,p,t.next_out-p)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ki?128:0)+(r.mode===vd||r.mode===Zh?256:0),(u===0&&p===0||e===A5)&&G===Yo&&(G=V7),G},tE=t=>{if(Qo(t))return yr;let e=t.state;return e.window&&(e.window=null),t.state=null,Yo},rE=(t,e)=>{if(Qo(t))return yr;let r=t.state;return (r.wrap&2)===0?yr:(r.head=e,e.done=false,Yo)},iE=(t,e)=>{let r=e.length,i,n,o;return Qo(t)||(i=t.state,i.wrap!==0&&i.mode!==Pd)?yr:i.mode===Pd&&(n=1,n=Tc(n,e,r,0),n!==i.check)?w8:(o=T8(t,e,r,r),o?(i.mode=_8,A8):(i.havedict=1,Yo))},nE=v8,oE=E8,sE=I8,aE=Q7,cE=B8,lE=eE,dE=tE,uE=rE,fE=iE,pE="pako inflate (from Nodeca project)",ii={inflateReset:nE,inflateReset2:oE,inflateResetKeep:sE,inflateInit:aE,inflateInit2:cE,inflate:lE,inflateEnd:dE,inflateGetHeader:uE,inflateSetDictionary:fE,inflateInfo:pE};function hE(){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 mE=hE,k8=Object.prototype.toString,{Z_NO_FLUSH:gE,Z_FINISH:j5,Z_OK:ya,Z_STREAM_END:e2,Z_NEED_DICT:t2,Z_STREAM_ERROR:yE,Z_DATA_ERROR:X5,Z_MEM_ERROR:bE,Z_BUF_ERROR:W5}=wa,SE={chunkSize:1024*64,windowBits:15,to:""};function Oc(t){this.options=Rd.assign({},SE,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 y8,this.strm.avail_out=0;let r=ii.inflateInit2(this.strm,e.windowBits);if(r!==ya)throw new Error(Xo[r]);if(this.header=new mE,ii.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Pc.string2buf(e.dictionary):k8.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=ii.inflateSetDictionary(this.strm,e.dictionary),r!==ya)))throw new Error(Xo[r])}Oc.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?j5:gE,k8.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=ii.inflate(r,s),o===t2&&n&&(o=ii.inflateSetDictionary(r,n),o===ya?o=ii.inflate(r,s):o===X5&&(o=t2));r.avail_in>0&&o===e2&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)ii.inflateReset(r),o=ii.inflate(r,s);switch(o){case yE:case X5:case t2:case bE:return this.onEnd(o),this.ended=true,false}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===e2||s>0))if(this.options.to==="string"){let c=Pc.utf8border(r.output,r.next_out),l=r.next_out-c,d=Pc.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===ya||o===W5)&&a===0)){if(o===e2)return o=ii.inflateEnd(this.strm),this.onEnd(o),this.ended=true,true;if(r.avail_in===0){if(s===j5)return o=ii.inflateEnd(this.strm),this.onEnd(o===ya?W5:o),this.ended=true,false;break}}}return true};Oc.prototype.onData=function(t){this.chunks.push(t);};Oc.prototype.onEnd=function(t){t===ya&&(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 b2(t,e){let r=new Oc(e);if(r.push(t,true),r.err)throw r.msg||Xo[r.err];return r.result}var AE=b2,vE={inflate:AE},{deflate:EE}=D7,{inflate:BE}=vE;var P8=EE;var S2=BE;var TE=(0, D8.default)("bridge"),N8=32*1024,x2=1024*16,kE=1;function R8(t,e){return {jsonrpc:"2.0",id:ua(16),method:t,params:e}}async function PE(t,e,r,i){let n=[],o=[];if(e){let s=Buffer.from(P8(JSON.stringify(e))).toString("base64"),a=Math.ceil(s.length/x2),c=ua(16);for(let l=0;l<a;l++){let d=l*x2,u=Math.min(d+x2,s.length),p=s.slice(d,u),m=JSON.stringify({method:t,params:p,chunk:{id:c,index:l,length:a}}),b=await bc(m,r,i),w=R8("encryptedMessage",{payload:Buffer.from(b).toString("base64")});o.push(w.id),n.push(JSON.stringify(w));}}else {let s=JSON.stringify({method:t,params:e||{}}),a=await bc(s,r,i),c=R8("encryptedMessage",{payload:Buffer.from(a).toString("base64")});o.push(c.id),n.push(JSON.stringify(c));}return {chunks:n,messageIds:o}}async function w2(t,e,r,i,n){try{let{chunks:o,messageIds:s}=await PE(t,e,r,i);for(let a of o){if(a.length>N8)throw new Error(`Payload exceeds max size of ${N8} bytes`);n.send(a),o.length>1&&await new Promise(c=>setTimeout(c,kE));}return {success:!0,messageIds:s}}catch(o){return TE("Error sending encrypted message:",o),{success:false,messageIds:[]}}}var A2=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 O8=It(lc(),1);var _2=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, O8.default)(`bridge:${this.role}`),this.bridgeId=t.bridgeId||ua(16),this.keyPair=t.keyPair,this.reconnect=t.reconnect??true,this.keepalive=t.keepalive??true,this.maxReconnectAttempts=t.reconnectAttempts??I6,this.pingInterval=t.pingInterval||E6,this.bridgeUrl=t.bridgeUrl??v6,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 A2({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=xh(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?xh(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=Hh(this.keyPair.privateKey,e),await Kh(Buffer.from(t.params.greeting,"hex"),this.sharedSecret,this.bridgeId)!=="hello")throw new Error("Invalid greeting");this.websocket&&(await w2("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 Kh(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=S2(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=S2(d),p=new TextDecoder().decode(u),m=JSON.parse(p);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 w2(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=Hh(this.keyPair.privateKey,this.remotePublicKey);}async createEncryptedGreeting(){if(!this.sharedSecret)throw new Error("Shared secret not available");let t=await bc("hello",this.sharedSecret,this.bridgeId);return Buffer.from(t).toString("hex")}async _getWsConnectionUrl(){if(this.role==="creator")return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}`;{let t=this.originOnConnect?"&ooc":"";if(this.isSecureChannelEstablished())return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}`;{let e=await this.createEncryptedGreeting(),r=JSON.stringify({jsonrpc:"2.0",id:ua(16),method:"handshake",params:{pubkey:this.getPublicKey(),greeting:e}}),i=Buffer.from(r).toString("base64");return `${this.bridgeUrl}?id=${this.getBridgeId()}&v=${da}&moc=${encodeURIComponent(i)}${t}`}}}getPublicKey(){return uc(this.keyPair.publicKey)}getRemotePublicKey(){if(!this.remotePublicKey)throw new Error("Remote public key not set");return uc(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=${da}${e}`:`obsidion:${this.getBridgeId()}?d=${t}&v=${da}${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 C2=It(lc(),1),I2=class M8{static async create(e={}){e.debug&&C2.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||Ad(),o=uc(n.publicKey),s=new _2({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&&C2.default.enable("bridge*"),r.resume&&!r.keyPair)throw new Error("Resuming a bridge session requires a keyPair");let i=r.keyPair||Ad(),{domain:n,pubkey:o,ooc:s}=M8.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 _2({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 Ad()}};var Kd=It(q8(),1);var G8={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 Y8={debug:(...t)=>{},info:(...t)=>{},warn:(...t)=>{},error:(...t)=>{}};(0, Kd.registerLocale)(G8);function qi(t){if(t==="Zero Knowledge Republic")return "ZKR";let e;return e=(0, Kd.getAlpha3Code)(t,"en")||t||"ZKR",e}function Fn(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function dS(t,e,r,i){i[r][t]={...i[r][t],range:e};}function Ia(t,e,r,i,n){n[i][e]={...n[i][e],[t]:r};}function qE(){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=qi(s)),Ia("eq",o,s,e,t),n),gte:(o,s)=>{if(i("gte"),Fn("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"),Fn("gt",o,s,e,t),n),lte:(o,s)=>(i("lte"),Fn("lte",o,s,e,t),n),lt:(o,s)=>(i("lt"),Fn("lt",o,s,e,t),n),range:(o,s,a)=>(i("range"),dS(o,[s,a],e,t),n),in:(o,s)=>(i("in"),s=s.map(a=>qi(a)),Ia("in",o,s,e,t),n),out:(o,s)=>(i("out"),s=s.map(a=>qi(a)),Ia("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 GE="0.19.2",R2=GE,gt=10080*60,Un=new Date(0),uS="https://dashboard-api.zkpassport.id",$E="https://verifier.zkpassport.id",Q8="0x1fa73686cf510f8f85757b0602de0dd72a13e68ae2092462be8b72662e7f179b",J8="0x24d9929b248be7eeecaa98e105c034a50539610f3fdd4cb9c8983ef4100d615d",eS="0x2532418a107c5306fa8308c22255792cf77e4a290cbce8a840a642a3e591340b",tS="0x16700a2d9168a194fc85f237af5829b5a2be05b8ae8ac4879ada34cf54a9c211",rS="0x0e1889bec6c1d686abcf08360ff404f803ab345881ea8cba6aad33b7f7f7ffe0",iS=1440*60*1e3,VE=class{static checkDiscloseBytesPublicInputs(t,e,r){let i={},n=true,o=t.committedInputs?.disclose_bytes?.disclosedBytes??t.committedInputs?.disclose_bytes_evm?.disclosedBytes,s=$p.fromDisclosedBytes(o,"passport"),a=$p.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=Bb(t.committedInputs?.compare_age??t.committedInputs?.compare_age_evm),a=Tb(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=Pb(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Uo),a=Nb(t.committedInputs?.compare_birthdate??t.committedInputs?.compare_birthdate_evm,-1*Uo);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,Un)&&(console.warn("Maximum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Un.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,Un)&&(console.warn("Minimum birthdate should be equal to default date value"),n=false,i.birthdate={...i.birthdate,disclose:{expected:`${Un.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,Un)&&(console.warn("Maximum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Un.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,Un)&&(console.warn("Minimum expiry date should be equal to default date value"),n=false,i.expiry_date={...i.expiry_date,disclose:{expected:`${Un.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(sc(t)!==Qp(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: ${sc(t).toString()}`,received:`Scope: ${Qp(e).toString()}`,message:"The proof comes from a different domain than the one expected"}),ia(n)!==Yp(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: ${ia(n).toString()}`,received:`Scope: ${Yp(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??bh(zp(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!==eS&&r.rootKeyLeaf!==tS&&r.rootKeyLeaf!==rS&&(console.warn("Invalid facematch root key hash"),i=false,n.facematch={...n.facematch,eq:{expected:`${eS} (iOS) or ${tS} (Android) or ${rS} (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!==Q8&&r.appIdHash!==J8&&(console.warn("Invalid facematch app id hash, the attestation should be coming from the ZKPassport app"),i=false,n.facematch={...n.facematch,eq:{expected:`${Q8} (iOS) or ${J8} (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=Jp(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()>iS&&(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 p=["firstname","lastname","fullname","document_number","document_type","gender"];for(let m of p)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,p,m,b,w=new Date,x=new Date(w.getFullYear(),w.getMonth(),w.getDate(),0,0,0,0),g={},A=["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 A.findIndex(W=>z.startsWith(W))};return q(k)-q(E)}),_=A.slice(3),C=I.find(k=>_.some(E=>k.name?.startsWith(E))),v=C?Jp(na(C.proof,ra(C.name))):void 0,T=v?Math.floor(v.getTime()/1e3):void 0;for(let k of I){let E=na(k.proof,ra(k.name));if(k.name?.startsWith("outer")){let q=k.name?.startsWith("outer_evm"),O=Qb(E),z=Math.floor(O.getTime()/1e3),W=Zb(E),{isCorrect:Y,queryResultErrors:oe}=await this.checkCertificateRegistryRoot(W.toString(16),g,true,a,z,r,c);u=u&&Y,g={...g,...oe};let te=Yb(E),{isCorrect:$,queryResultErrors:R}=await this.checkCircuitRegistryRoot(te.toString(16),g,a,z,r,c);u=u&&$,g={...g,...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,g.outer={...g.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()>iS&&(console.warn("The date used to check the validity of the ID is in the future"),u=false,g.outer={...g.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=ih(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,g.outer={...g.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"}}),sc(t)!==th(E)&&(console.warn("The proof comes from a different domain than the one expected"),u=false,g.outer={...g.outer,scope:{expected:`Scope: ${sc(t).toString()}`,received:`Scope: ${th(E).toString()}`,message:"The proof comes from a different domain than the one expected"}}),ia(o)!==rh(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,g.outer={...g.outer,scope:{expected:`Scope: ${ia(o).toString()}`,received:`Scope: ${rh(E).toString()}`,message:D}};}if(L?.compare_age||L?.compare_age_evm){let D=L?.compare_age??L?.compare_age_evm,X=q?await kb(D.minAge,D.maxAge):await jp(D.minAge,D.maxAge);K.includes(X)||(console.warn("This proof does not verify the age"),u=false,g.age={...g.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,g={...g,...ne};}if(L?.compare_birthdate||L?.compare_birthdate_evm){let D=L?.compare_birthdate??L?.compare_birthdate_evm,X=q?await Xp(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0):await nc(fe.BIRTHDATE,D.minDateTimestamp,D.maxDateTimestamp,0);K.includes(X)||(console.warn("This proof does not verify the birthdate"),u=false,g.birthdate={...g.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,g={...g,...ne};}if(L?.compare_expiry||L?.compare_expiry_evm){let D=L?.compare_expiry??L?.compare_expiry_evm,X=q?await Xp(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp):await nc(fe.EXPIRY_DATE,D.minDateTimestamp,D.maxDateTimestamp);K.includes(X)||(console.warn("This proof does not verify the expiry date"),u=false,g.expiry_date={...g.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,g={...g,...ne};}if(L?.disclose_bytes||L?.disclose_bytes_evm){let D=L?.disclose_bytes??L?.disclose_bytes_evm,X=q?await Eb(D.discloseMask,D.disclosedBytes):await Vp(D.discloseMask,D.disclosedBytes);K.includes(X)||(console.warn("This proof does not verify any of the data disclosed"),u=false,g.disclose={...g.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,g={...g,...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 ic(fe.NATIONALITY_INCLUSION,D.countries):await Oi(fe.NATIONALITY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the nationality"),u=false,g.nationality={...g.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,g={...g,...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 ic(fe.ISSUING_COUNTRY_INCLUSION,D.countries):await Oi(fe.ISSUING_COUNTRY_INCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the inclusion of the issuing country"),u=false,g.issuing_country={...g.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,g={...g,...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 ic(fe.NATIONALITY_EXCLUSION,D.countries):await Oi(fe.NATIONALITY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the nationality"),u=false,g.nationality={...g.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,g={...g,...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 ic(fe.ISSUING_COUNTRY_EXCLUSION,D.countries):await Oi(fe.ISSUING_COUNTRY_EXCLUSION,D.countries);K.includes(X)||(console.warn("This proof does not verify the exclusion of the issuing country"),u=false,g.issuing_country={...g.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,g={...g,...le};}if(L?.bind||L?.bind_evm){let D=L?.bind??L?.bind_evm,X=q?await Ob(oc(D.data)):await Wp(oc(D.data));K.includes(X)||(console.warn("This proof does not verify the bound data"),u=false,g.bind={...g.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,g={...g,...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 Wb(D.rootHash,D.isStrict):await eh(D.rootHash,D.isStrict);K.includes(X)||(console.warn("This proof does not verify the exclusion from the sanction lists"),u=false,g.sanctions={...g.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,g={...g,...ne};}if(L?.facematch||L?.facematch_evm){let D=L?.facematch??L?.facematch_evm,X=q?await Fb(BigInt(D.rootKeyLeaf),D.environment==="development"?0n:1n,BigInt(D.appIdHash),D.mode==="regular"?1n:2n):await Zp(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,g.facematch={...g.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,g={...g,...ne};}p=e6(E).toString(10),m=Jb(E),b=t6(E);}else if(k.name?.startsWith("sig_check_dsc")){d=Cb(E);let q=_b(E),{isCorrect:O,queryResultErrors:z}=await this.checkCertificateRegistryRoot(q.toString(16),g,false,a,T,r,c);u=u&&O,g={...g,...z};}else if(k.name?.startsWith("sig_check_id_data"))l=Rb(E),l!==d&&(console.warn("Failed to check the link between the certificate signature and ID signature"),u=false,g.sig_check_id_data={...g.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=Db(E);else if(k.name?.startsWith("data_check_integrity"))l=Ib(E),l!==d&&(console.warn("Failed to check the link between the ID signature and the data signed"),u=false,g.data_check_integrity={...g.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=vb(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,g.disclose={...g.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 Vp((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,g.disclose={...g.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,g,"disclose",o);u=u&&z,g={...g,...W};let{isCorrect:Y,queryResultErrors:oe}=this.checkDiscloseBytesPublicInputs(k,r,i);u=u&&Y&&z,g={...g,...oe,...W};let{isCorrect:te,queryResultErrors:$}=await this.checkCurrentDate("disclose",E,n??gt,g);u=u&&te,g={...g,...$},p=Pr(E).toString(10),m=Nr(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,g.age={...g.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 jp(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,g.age={...g.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,g,"age",o),{isCorrect:oe,queryResultErrors:te}=this.checkAgePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("age",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.birthdate={...g.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 nc(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,g.birthdate={...g.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,g,"birthdate",o),{isCorrect:oe,queryResultErrors:te}=this.checkBirthdatePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("birthdate",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.expiry_date={...g.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 nc(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,g.expiry_date={...g.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,g,"expiry_date",o),{isCorrect:oe,queryResultErrors:te}=this.checkExpiryDatePublicInputs(k,r,i);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("expiry_date",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.nationality={...g.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 Oi(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,g.nationality={...g.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,g,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityExclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.issuing_country={...g.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 Oi(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,g.issuing_country={...g.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,g,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryExclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.nationality={...g.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 Oi(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,g.nationality={...g.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,g,"nationality",o),{isCorrect:oe,queryResultErrors:te}=this.checkNationalityInclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("nationality",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.issuing_country={...g.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 Oi(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,g.issuing_country={...g.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,g,"issuing_country",o),{isCorrect:oe,queryResultErrors:te}=this.checkIssuingCountryInclusionPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("issuing_country",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.bind={...g.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 Wp(oc(q.data));O!==z&&(console.warn("The bound data does not match the one from the proof"),u=false,g.bind={...g.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,g,"bind",o),{isCorrect:oe,queryResultErrors:te}=this.checkBindPublicInputs(r,i,q.data);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("bind",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.sanctions={...g.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 eh(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,g.sanctions={...g.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,g,"sanctions",o),{isCorrect:oe,queryResultErrors:te}=await this.checkSanctionsExclusionPublicInputs(r,i,q,a,T,c);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("sanctions",E,n??gt,g);u=u&&$,g={...g,...R},p=Pr(E).toString(10),m=Nr(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,g.facematch={...g.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 Zp(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,g.facematch={...g.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,g,"facematch",o),{isCorrect:oe,queryResultErrors:te}=await this.checkFacematchPublicInputs(r,i,q);u=u&&oe&&W,g={...g,...te,...Y};let{isCorrect:$,queryResultErrors:R}=await this.checkCurrentDate("facematch",E,n??gt,g);u=u&&$,g={...g,...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,g={...g,...H},u&&m&&(m===Pe.SALTED||m===Pe.SALTED_MOCK))try{let k=await jb(s??Vb),E=await Xb(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=na(O.proof,ra(O.name));q=Lb(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?(p!==void 0&&BigInt(p)!==0n&&(console.warn("Proofs with the NONE nullifier type cannot carry a unique identifier"),u=false),p=void 0):p!==void 0&&BigInt(p)===0n&&(p=void 0),{isCorrect:u,uniqueIdentifier:p,uniqueIdentifierType:m,queryResultErrors:g}}},jE={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}]},nS=class{static getDetails(){return {functionName:"verify",abi:jE.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=na(t.proof,ra(t.name)),s=[],a=[];for(let p in t.committedInputs){let m=Hb(p),b=p;s.push({circuitName:b,count:m});let w="";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((A,I)=>A.localeCompare(I));let g=(()=>{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}})();w=g.toString(16).padStart(2,"0")+se[g].evm.toString(16).padStart(4,"0")+Oo(x.map(A=>Array.from(new TextEncoder().encode(A))).flat(),600).map(A=>A.toString(16).padStart(2,"0")).join("");}else if(b==="compare_age_evm"){let x=t.committedInputs[b];w=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],g=Array.from(Te(x.minDateTimestamp,8)),A=Array.from(Te(x.maxDateTimestamp,8));w=fe.BIRTHDATE.toString(16).padStart(2,"0")+se[fe.BIRTHDATE].evm.toString(16).padStart(4,"0")+g.map(I=>I.toString(16).padStart(2,"0")).join("")+A.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="compare_expiry_evm"){let x=t.committedInputs[b],g=Array.from(Te(x.minDateTimestamp,8)),A=Array.from(Te(x.maxDateTimestamp,8));w=fe.EXPIRY_DATE.toString(16).padStart(2,"0")+se[fe.EXPIRY_DATE].evm.toString(16).padStart(4,"0")+g.map(I=>I.toString(16).padStart(2,"0")).join("")+A.map(I=>I.toString(16).padStart(2,"0")).join("");}else if(b==="disclose_bytes_evm"){let x=t.committedInputs[b];w=fe.DISCLOSE.toString(16).padStart(2,"0")+se[fe.DISCLOSE].evm.toString(16).padStart(4,"0")+x.discloseMask.map(g=>g.toString(16).padStart(2,"0")).join("")+x.disclosedBytes.map(g=>g.toString(16).padStart(2,"0")).join("");}else if(b==="bind_evm"){let x=t.committedInputs[b];w=fe.BIND.toString(16).padStart(2,"0")+se[fe.BIND].evm.toString(16).padStart(4,"0")+Oo(oc(x.data),509).map(g=>g.toString(16).padStart(2,"0")).join("");}else if(b==="exclusion_check_sanctions_evm"){let x=t.committedInputs[b];w+=fe.SANCTIONS_EXCLUSION.toString(16).padStart(2,"0"),w+=se[fe.SANCTIONS_EXCLUSION].evm.toString(16).padStart(4,"0"),w+=Array.from(Te(BigInt(x.rootHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.isStrict?"01":"00";}else if(b.startsWith("facematch")&&b.endsWith("_evm")){let x=t.committedInputs[b];w+=fe.FACEMATCH.toString(16).padStart(2,"0"),w+=se[fe.FACEMATCH].evm.toString(16).padStart(4,"0"),w+=Array.from(Te(BigInt(x.rootKeyLeaf),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.environment==="development"?"00":"01",w+=Array.from(Te(BigInt(x.appIdHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=Array.from(Te(BigInt(x.integrityPubkeyHash),32)).map(g=>g.toString(16).padStart(2,"0")).join(""),w+=x.mode==="regular"?"01":"02";}else throw new Error(`Unsupported circuit for EVM verification: ${b}`);a.push({circuitName:b,inputs:w});}let c=ih(o).map(p=>p.toString(16).padStart(64,"0")),l="";for(let p of c){let m=a.find(b=>{let w=ot(Vn(b.inputs)),x=new Uint8Array(w.length);for(let g=0;g<w.length-1;g++)x[g+1]=w[g];return x[0]=0,$n(x)===p.replace("0x","")});if(m)if(s.find(w=>w.circuitName===m.circuitName)?.count)l+=m.inputs;else throw new Error(`Unknown circuit name: ${m.circuitName}`);else throw new Error(`Invalid commitment: ${p}`)}let d=t.version?.split(".").map(p=>Number(p));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${$n(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 XE({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(`${uS}/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:R2,requestId:s}),signal:AbortSignal.timeout(3e4)});c.ok?Y8.debug("API response status:",c.status):Y8.warn("API request failed with status:",c.status);}catch{}}var WE=[0,20,0];function ZE(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]=WE;return r!==o?r>o?"v5":"v4":i!==s?i>s?"v5":"v4":n>=a?"v5":"v4"}async function YE(t,{writingDirectory:e}={}){await QE(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(V8(),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(X8(),1)),o=await n.new({crsPath:r});return {verifier:new i(o),destroy:()=>o.destroy()}}var oS="__zkpassport_bb_version",sS="keyval-store";async function QE(t){if(!(typeof indexedDB>"u"))try{let e=typeof localStorage<"u"?localStorage:void 0;if((e?.getItem(oS)??"v4")===t)return;let r=!0;if(typeof indexedDB.databases=="function")try{r=(await indexedDB.databases()).some(i=>i.name===sS);}catch{r=!0;}r&&await new Promise(i=>{let n=indexedDB.deleteDatabase(sS);n.onsuccess=n.onerror=n.onblocked=()=>i();}),e?.setItem(oS,t);}catch{}}async function aS({proofs:t,originalQuery:e,queryResult:r,domain:i,validity:n,scope:o,devMode:s,oprfKeyId:a}){try{let c=await fetch(`${$E}/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=Jo.Buffer,typeof window<"u"&&(window.Buffer=Jo.Buffer));var cS="Verify identity privately";function JE({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 eB(t,e){if(e==null||!t.verified||JE(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 lS=false;function tB(){lS||(lS=true,console.warn("[zkpassport] onResult is deprecated. Use onSuccess and verify the proofs on your backend with verify()."));}function rB(t){let e=t.connection.getWebSocket();if(e)try{e.send(JSON.stringify({method:"replay",params:{timestamp:1}}));}catch{}}var D2=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&&XE({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]=qp(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=qi(r)),Ia("eq",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),gte:(e,r)=>{if(this.assertNotPolicyLocked(t,"gte"),Fn("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"),Fn("gt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lte:(e,r)=>(this.assertNotPolicyLocked(t,"lte"),Fn("lte",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),lt:(e,r)=>(this.assertNotPolicyLocked(t,"lt"),Fn("lt",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),range:(e,r,i)=>(this.assertNotPolicyLocked(t,"range"),dS(e,[r,i],t,this.topicToConfig),this.getZkPassportRequest(t)),in:(e,r)=>(this.assertNotPolicyLocked(t,"in"),r=r.map(i=>qi(i)),Ia("in",e,r,t,this.topicToConfig),this.getZkPassportRequest(t)),out:(e,r)=>(this.assertNotPolicyLocked(t,"out"),r=r.map(i=>qi(i)),Ia("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||cS),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=>{tB(),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=`${uS}/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:p,cloudProverUrl:m,bridgeUrl:b,returnDeepLink:w,verifierMode:x,config:g,overrides:A}){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 I2.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||cS,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:w,verifierMode:x,config:g,appClip:A?.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=>{p&&!v&&rB(_),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 qE()}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 p={proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o,oprfKeyId:a},m={...p,writingDirectory:s,config:d},b={...p,domain:this.domain},w=a?Pe.SALTED:c,x;if(l==="local")x=await this.verifyLocally(m);else if(l==="api")x=await aS(b)??u;else {let g;try{g=await this.verifyLocally(m);}catch(A){console.warn("Local proof verification failed:",A);}x=g?.verified?g:await aS(b)??g??u;}return eB(x,w)}async verifyLocally({proofs:t,originalQuery:e,queryResult:r,validity:i,scope:n,devMode:o=false,writingDirectory:s,oprfKeyId:a,config:c}){let l=qp(r);typeof window>"u"&&!s&&(s="/tmp");let d=ZE(t[0]?.version),u,p=true,m,b,w;try{let x=bh(zp(e,o),c),{isCorrect:g,uniqueIdentifier:A,uniqueIdentifierType:I,queryResultErrors:_}=await VE.checkPublicInputs(this.domain,t,e,l,i,n,a,o,x);if(m=A,b=I,p=g,w=g?void 0:_,(b===Pe.SALTED_MOCK||b===Pe.NON_SALTED_MOCK)&&!o&&(p=!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.")),p){let C=await x.getCircuitManifest(void 0,{version:t[0].version});u=await YE(d,{writingDirectory:s});for(let v of t){let T=v.name?.startsWith("outer_evm_"),G=v.name,F=na(v.proof,ra(G)),H=await x.getPackagedCircuit(G,C,{validate:!T});if(T)try{let{createPublicClient:k,http:E}=await Promise.resolve().then(()=>It(Z8(),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]});p=Array.isArray(oe)?!!oe[0]:!1;}catch(k){console.warn("Error verifying proof",k),p=!1;}else {let k=Jo.Buffer.from(H.vkey,"base64");try{p=await u.verifier.verifyProof({proof:Jo.Buffer.from(F.proof.join(""),"hex"),publicInputs:F.publicInputs,verificationKey:new Uint8Array(k)});}catch(E){console.warn(`Error verifying proof ${G}`,E),p=!1;}}if(!p)break}}}finally{await u?.destroy();}return m=p?m:void 0,b=p?b:void 0,{uniqueIdentifier:m,uniqueIdentifierType:b,verified:p,queryResultErrors:w}}getSolidityVerifierDetails(){return nS.getDetails()}getSolidityVerifierParameters({proof:t,validityPeriodInSeconds:e=gt,domain:r,scope:i,devMode:n=false}){return nS.getParameters({proof:t,validityPeriodInSeconds:e,domain:r??this.domain,scope:i,devMode:n})}_getUrl(t){let e=Jo.Buffer.from(JSON.stringify(this.topicToConfig[t])).toString("base64"),r=Jo.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=${R2}&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 iB(){try{return typeof localStorage<"u"&&localStorage.getItem("zkpassport:debug")==="1"}catch{return false}}var ai={error(...t){console.error(zd,...t);},warn(...t){console.warn(zd,...t);},info(...t){console.info(zd,...t);},debug(...t){iB()&&console.debug(zd,...t);}};function pS(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),[p,m]=Ht(null),[b,w]=Ht(0),[x,g]=Ht({received:0,total:null}),A=Ur(t);A.current=t;let I=Ur(null),_=Ur("preparing"),C=Ur(e),v=Ur(false),T=Ur(null),G=Ur(null);G.current===null&&(G.current=new D2(t.domain)),rs(()=>{let k=G.current,E=false,q=false,O=null,z=A.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),g({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}=A.current;X&&A.current.onSuccess&&ai.warn("onResult is deprecated and drives the card; onSuccess return values are ignored");let _e=()=>{q||(q=true,br(A.current.onReady));},Oe=false,Ne=yt=>{Oe=true,C.current=false,v.current=true,i(yt);},Fe=(yt,ye)=>{ai.error(ye),Ne("error");let Gi=ye instanceof Error?ye.message:String(ye);br(A.current.onError,`${yt}: ${Gi}`);},ge=yt=>(...ye)=>{if(!E)try{yt(...ye);}catch(Gi){Fe("Failed to handle a verification update",Gi);}},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(A.current.onBridgeConnect);})),ye.onBridgeConnectionLost(ge(()=>{Oe||(Ne("error"),br(A.current.onError,"The connection to your phone was lost."));})),ye.onRequestReceived(ge(()=>{Le("scanned",!0),br(A.current.onRequestReceived);})),ye.onGeneratingProof(ge(()=>{Le("generating",!0),br(A.current.onGeneratingProof);})),ye.onProofGenerated(ge(Re=>{g($i=>({received:$i.received+1,total:Re.total??$i.total})),br(A.current.onProofGenerated,Re);})),ye.onSuccess(ge(Re=>{if(X){br(A.current.onSuccess,Re);return}let $i=Ln=>{E||Ne(Ln);},L2;try{L2=A.current.onSuccess?.(Re);}catch(Ln){ai.error(Ln),$i("error");return}Promise.resolve(L2).then(Ln=>$i(Ln===!1?"error":"success"),Ln=>{ai.error(Ln),$i("error");});})),X&&ye.onResult(ge(Re=>{Ne(Re.verified?"success":"error"),br(A.current.onResult,Re);})),ye.onReject(ge(()=>{Ne("error"),br(A.current.onReject);})),ye.onError(ge(Re=>{Ne("error"),br(A.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){ai.error(Re);}let Gi=JSON.stringify(ye.query);z&&v.current&&Gi!==T.current&&(C.current=true,i("intro")),T.current=Gi;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(nB(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=su(()=>{br(A.current.onRetryClicked),w(k=>k+1);},[]),H=su(()=>{C.current=false,v.current=true,i(_.current);},[]);return {state:r,url:n,qrSvg:s,query:c,serviceName:d,serviceLogo:p,retry:F,continueWithPhone:H,proofProgress:x}}function nB(t){let e=fS.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,p)=>s.some(([m,b])=>u>=m&&u<m+7&&p>=b&&p<b+7),c="",l=n*.47;for(let u=0;u<r;u++)for(let p=0;p<r;p++){if(!i[u*r+p]||a(u,p))continue;let m=(p+.5)*n,b=(u+.5)*n;c+=`<circle cx="${o(m)}" cy="${o(b)}" r="${o(l)}"/>`;}let d="";for(let[u,p]of s){let m=(p+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 hS(t,{probe:e}){let[r,i]=Ht("idle"),n=Ur(null);return rs(()=>(i("idle"),()=>n.current?.()),[t]),{openState:r,openApp:()=>{if(t){if(n.current?.(),!e){n.current=uu(t);return}i("opening"),n.current=uu(t,s=>i(s?"opened":"nothing-opened"));}}}}var oB={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"},sB=["birthdate","expiry_date"],mS=["nationality","issuing_country"],gS=["firstname","lastname","fullname","gender","birthdate","age","document_type","document_number","nationality","issuing_country","expiry_date"],ci={disclose:0,age:1,date:2,country:3,field:4,sanctions:5,facematch:6,bind:7},aB=3,cB={year:"numeric",month:"long",day:"numeric"};function yS(t){return t.toLocaleDateString(void 0,cB)}var lB={passport:"passport",id_card:"ID card",residence_permit:"residence permit"},dB={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 yS(e);if(sB.includes(t)&&(typeof e=="string"||typeof e=="number")){let r=new Date(e);if(!Number.isNaN(r.getTime()))return yS(r)}return t==="document_type"&&typeof e=="string"?lB[e]??e.replace(/_/g," "):String(e)}function uB(t,e){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} ${e} ${t[t.length-1]}`}function O2(t){return oB[t]??String(t).replace(/_/g," ")}function bS(t,e,r){let i=O2(t),n=e.map(c=>Wt(t,c)).sort((c,l)=>c.localeCompare(l)),o=mS.includes(t)?ci.country:ci.field;if(n.length<=aB){let c=r?n.length===1?`is not ${n[0]}`:`is not any of ${n.join(", ")}`:`is ${uB(n,"or")}`;return {title:`Your ${i} ${c}`,group:o}}let s=mS.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 fB(t,e,r){let i=O2(t);if(t==="age"){let n=ci.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=ci.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=ci.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 ${dB[String(e.eq)]??Wt(t,e.eq)}`:`Your ${i} is ${Wt(t,e.eq)}`,group:ci.field}),e.in!=null&&r.push(bS(t,e.in,false)),e.out!=null&&r.push(bS(t,e.out,true));}function pB(t){return t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function hB(t){let{user_address:e,chain:r,custom_data:i}=t,n="Bound to",o=[];if(r&&o.push({label:"Chain",value:pB(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 mB(t){let e=i=>{let n=gS.indexOf(i);return n===-1?gS.length:n};return (t.includes("fullname")?t.filter(i=>i!=="firstname"&&i!=="lastname"):t).map(i=>({title:`Share your ${O2(i)}`,group:ci.disclose,order:e(i)}))}function SS(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:ci.sanctions});continue}if(i==="facematch"){e.push({title:"Your face matches your ID photo",group:ci.facematch});continue}if(i==="bind"){e.push({...hB(n),group:ci.bind});continue}if(i==="policy")continue;let o=i;n.disclose&&r.push(o),fB(o,n,e);}return e.push(...mB(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:gB()?false:!!(/iPhone|iPad|iPod/.test(t)&&/AppleWebKit/.test(t)&&!/Safari\//.test(t))}function gB(){return navigator.standalone===true}var yB=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:--yB,__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 M2({options:t,controlRef:e}){lm(BB,[]);let{state:r,url:i,qrSvg:n,query:o,serviceName:s,serviceLogo:a,retry:c,continueWithPhone:l,proofProgress:d}=pS(t);rs(()=>{if(e)return e.current={retry:c},()=>{e.current=null;}},[c,e]);let u=t.display?.header??true,p=t.display?.steps??true,m=t.display?.appLinks??true,b=t.display?.frame??true,w=t.name??s??t.domain??"",x=t.logo??a??"",g=r==="scanned"||r==="generating"||r==="success"||r==="error",A=!!o?.facematch,I=AB(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=_B(r,g,A,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:bm}}):null,u?U(Sr,{children:[U("div",{className:"zkp-header",children:[U("div",{className:"zkp-header-icons",children:[U("div",{className:"zkp-zkp-icon",dangerouslySetInnerHTML:{__html:Ba}}),x?U(Sr,{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:w?`${w} icon`:""})})]}):null]}),U("p",{className:"zkp-title",children:[U("strong",{children:w||"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(wB,{appName:w||"This app",items:SS(o),purpose:t.purpose,loading:o===null,onContinue:l}):U("div",{className:"zkp-screen",children:[H?U(vB,{requestUrl:r==="waiting"?i:null,inAppBrowser:G,onRevealQr:()=>v(true)}):U(CB,{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,p&&k.length>0?U(Sr,{children:[U("div",{className:"zkp-divider zkp-divider-top"}),U("div",{className:"zkp-steps",children:k.map(E=>U(IB,{status:E.status,icon:E.icon,children:E.label},E.key))})]}):null,m&&!H?U("div",{className:`zkp-collapse${g?" 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:lu}),U($d,{href:is,badge:du})]})]})]})}):null,r==="error"?U("div",{className:"zkp-result-actions",children:U("button",{type:"button",className:"zkp-retry",onClick:c,children:"Try again"})}):null]})]})}var bB=2;function SB({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 xB='<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 wB({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:bB},(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(SB,{item:o},s):U("li",{children:[U("span",{className:"zkp-intro-check",dangerouslySetInnerHTML:{__html:ns}}),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:xB}}),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 AB(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 _B(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(Sr,{children:[U("a",{href:fm,target:"_blank",rel:"noopener noreferrer",children:"Download"})," the ZKPassport mobile app."]}),status:d,icon:e?null:mm},{key:"scan",label:n?"Tap \u201COpen ZKPassport App\u201D above.":"Scan this QR code with the ZKPassport app.",status:d,icon:e?null:pm},{key:"approve",label:"Approve the request on your phone.",status:t==="scanned"?"current":s||o?"done":"pending",icon:e?null:hm}];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 CB({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:Ba}}):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:cu}}):null,t==="scanned"?U("div",{className:"zkp-scanned-phone",dangerouslySetInnerHTML:{__html:ym}}):null,t==="success"?U("div",{className:"zkp-check",dangerouslySetInnerHTML:{__html:ns}}):null,t==="error"?U("div",{className:"zkp-error-icon",dangerouslySetInnerHTML:{__html:gm}}):null]}),r?U("div",{className:"zkp-overlay-caption",children:r},t):null]})]})}function IB({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??ns}}),U("div",{className:"zkp-step-text",children:r})]})}function vB({requestUrl:t,inAppBrowser:e,onRevealQr:r}){let{openState:i,openApp:n}=hS(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:cu}}):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(EB,{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 EB({requestUrl:t,appNotFound:e}){let r=wm();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:lu}):null,r!=="ios"?U($d,{href:xm(t),badge:du}):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 BB(){e1(Am,"card");}var xS=`@layer zkpassport {
1030
1030
  /* "Verify with ZKPassport" button (opens the hosted popup).
1031
1031
  Customize via CSS custom properties on the mount element or any ancestor:
1032
1032
  --zkp-btn-bg/-fg/-border-color/-radius/-padding/-font/-font-size/-letter-spacing/