diff --git a/crates/context/config/src/client/env/proxy.rs b/crates/context/config/src/client/env/proxy.rs index 7f4d5346c..6845903a0 100644 --- a/crates/context/config/src/client/env/proxy.rs +++ b/crates/context/config/src/client/env/proxy.rs @@ -7,9 +7,9 @@ use mutate::ContextProxyMutate; use query::ContextProxyQuery; #[derive(Copy, Clone, Debug)] -pub enum ContextConfig {} +pub enum ContextProxy {} -impl<'a, T: 'a> Environment<'a, T> for ContextConfig { +impl<'a, T: 'a> Environment<'a, T> for ContextProxy { type Query = ContextProxyQuery<'a, T>; type Mutate = ContextProxyMutate<'a, T>; diff --git a/crates/context/config/src/client/env/proxy/query/proposal.rs b/crates/context/config/src/client/env/proxy/query/proposal.rs index da601b29b..21be47f27 100644 --- a/crates/context/config/src/client/env/proxy/query/proposal.rs +++ b/crates/context/config/src/client/env/proxy/query/proposal.rs @@ -36,7 +36,7 @@ impl Method for ProposalRequest { todo!() } - fn decode(response: Vec) -> eyre::Result { + fn decode(_response: Vec) -> eyre::Result { todo!() } } diff --git a/crates/context/config/src/client/env/proxy/query/proposals.rs b/crates/context/config/src/client/env/proxy/query/proposals.rs index a82affd02..31cd8b025 100644 --- a/crates/context/config/src/client/env/proxy/query/proposals.rs +++ b/crates/context/config/src/client/env/proxy/query/proposals.rs @@ -36,7 +36,7 @@ impl Method for ProposalRequest { todo!() } - fn decode(response: Vec) -> eyre::Result { + fn decode(_response: Vec) -> eyre::Result { todo!() } } diff --git a/crates/context/config/src/client/relayer.rs b/crates/context/config/src/client/relayer.rs index 1a651c30c..605c05a37 100644 --- a/crates/context/config/src/client/relayer.rs +++ b/crates/context/config/src/client/relayer.rs @@ -1,6 +1,7 @@ use std::borrow::Cow; use serde::{Deserialize, Serialize}; +use thiserror::Error; use url::Url; use super::transport::{Operation, Transport, TransportRequest}; @@ -39,8 +40,22 @@ pub struct RelayRequest<'a> { pub payload: Vec, } +#[derive(Debug, Error)] +pub enum RelayerError { + #[error(transparent)] + Raw(#[from] reqwest::Error), + #[error( + "relayer response ({status}): {}", + body.is_empty().then_some("").unwrap_or(body) + )] + Response { + status: reqwest::StatusCode, + body: String, + }, +} + impl Transport for RelayerTransport { - type Error = reqwest::Error; + type Error = RelayerError; async fn send( &self, @@ -60,8 +75,13 @@ impl Transport for RelayerTransport { .send() .await?; - // todo! check response.status code + if !response.status().is_success() { + return Err(RelayerError::Response { + status: response.status(), + body: response.text().await?, + }); + } - response.bytes().await.map(Into::into) + response.bytes().await.map(Into::into).map_err(Into::into) } } diff --git a/crates/meroctl/src/common.rs b/crates/meroctl/src/common.rs index 422ba9cad..b21ac4aa6 100644 --- a/crates/meroctl/src/common.rs +++ b/crates/meroctl/src/common.rs @@ -120,7 +120,6 @@ where // return Ok(result); // } -// pub fn load_config(home: &Utf8Path, node_name: &str) -> EyreResult { let path = home.join(node_name); diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index a1c9e51ad..310a2384c 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -313,7 +313,7 @@ impl Node { } } - todo!() + Ok(()) } async fn handle_state_delta( diff --git a/crates/server-primitives/src/lib.rs b/crates/server-primitives/src/lib.rs index b08297a03..c74dfbc7c 100644 --- a/crates/server-primitives/src/lib.rs +++ b/crates/server-primitives/src/lib.rs @@ -8,5 +8,4 @@ pub mod ws; #[derive(Clone, Copy, Debug, Deserialize, Serialize, ThisError)] #[error("Infallible")] #[expect(clippy::exhaustive_enums, reason = "This will never have any variants")] -//tests pub enum Infallible {} diff --git a/node-ui/build/assets/main-CEAaf8Ev.js b/node-ui/build/assets/main-Bzv535nm.js similarity index 98% rename from node-ui/build/assets/main-CEAaf8Ev.js rename to node-ui/build/assets/main-Bzv535nm.js index 4751ca677..b7df40e79 100644 --- a/node-ui/build/assets/main-CEAaf8Ev.js +++ b/node-ui/build/assets/main-Bzv535nm.js @@ -74,7 +74,7 @@ Error generating stack: `+nt.message+` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...c){const d=new this(a);return c.forEach(tt=>d.set(tt)),d}static accessor(a){const d=(this[$internals]=this[$internals]={accessors:{}}).accessors,tt=this.prototype;function nt($a){const Ys=normalizeHeader($a);d[Ys]||(buildAccessors(tt,$a),d[Ys]=!0)}return utils$A.isArray(a)?a.forEach(nt):nt(a),this}};AxiosHeaders$1.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);utils$A.reduceDescriptors(AxiosHeaders$1.prototype,({value:o},a)=>{let c=a[0].toUpperCase()+a.slice(1);return{get:()=>o,set(d){this[c]=d}}});utils$A.freezeMethods(AxiosHeaders$1);function transformData(o,a){const c=this||defaults$1,d=a||c,tt=AxiosHeaders$1.from(d.headers);let nt=d.data;return utils$A.forEach(o,function(Ys){nt=Ys.call(c,nt,tt.normalize(),a?a.status:void 0)}),tt.normalize(),nt}function isCancel$1(o){return!!(o&&o.__CANCEL__)}function CanceledError$1(o,a,c){AxiosError$1.call(this,o??"canceled",AxiosError$1.ERR_CANCELED,a,c),this.name="CanceledError"}utils$A.inherits(CanceledError$1,AxiosError$1,{__CANCEL__:!0});function settle(o,a,c){const d=c.config.validateStatus;!c.status||!d||d(c.status)?o(c):a(new AxiosError$1("Request failed with status code "+c.status,[AxiosError$1.ERR_BAD_REQUEST,AxiosError$1.ERR_BAD_RESPONSE][Math.floor(c.status/100)-4],c.config,c.request,c))}function parseProtocol(o){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return a&&a[1]||""}function speedometer(o,a){o=o||10;const c=new Array(o),d=new Array(o);let tt=0,nt=0,$a;return a=a!==void 0?a:1e3,function(gu){const xu=Date.now(),$u=d[nt];$a||($a=xu),c[tt]=gu,d[tt]=xu;let Iu=nt,Xu=0;for(;Iu!==tt;)Xu+=c[Iu++],Iu=Iu%o;if(tt=(tt+1)%o,tt===nt&&(nt=(nt+1)%o),xu-$a{c=$u,tt=null,nt&&(clearTimeout(nt),nt=null),o.apply(null,xu)};return[(...xu)=>{const $u=Date.now(),Iu=$u-c;Iu>=d?$a(xu,$u):(tt=xu,nt||(nt=setTimeout(()=>{nt=null,$a(tt)},d-Iu)))},()=>tt&&$a(tt)]}const progressEventReducer=(o,a,c=3)=>{let d=0;const tt=speedometer(50,250);return throttle(nt=>{const $a=nt.loaded,Ys=nt.lengthComputable?nt.total:void 0,gu=$a-d,xu=tt(gu),$u=$a<=Ys;d=$a;const Iu={loaded:$a,total:Ys,progress:Ys?$a/Ys:void 0,bytes:gu,rate:xu||void 0,estimated:xu&&Ys&&$u?(Ys-$a)/xu:void 0,event:nt,lengthComputable:Ys!=null,[a?"download":"upload"]:!0};o(Iu)},c)},progressEventDecorator=(o,a)=>{const c=o!=null;return[d=>a[0]({lengthComputable:c,total:o,loaded:d}),a[1]]},asyncDecorator=o=>(...a)=>utils$A.asap(()=>o(...a)),isURLSameOrigin=platform$1.hasStandardBrowserEnv?function(){const a=/(msie|trident)/i.test(navigator.userAgent),c=document.createElement("a");let d;function tt(nt){let $a=nt;return a&&(c.setAttribute("href",$a),$a=c.href),c.setAttribute("href",$a),{href:c.href,protocol:c.protocol?c.protocol.replace(/:$/,""):"",host:c.host,search:c.search?c.search.replace(/^\?/,""):"",hash:c.hash?c.hash.replace(/^#/,""):"",hostname:c.hostname,port:c.port,pathname:c.pathname.charAt(0)==="/"?c.pathname:"/"+c.pathname}}return d=tt(window.location.href),function($a){const Ys=utils$A.isString($a)?tt($a):$a;return Ys.protocol===d.protocol&&Ys.host===d.host}}():function(){return function(){return!0}}(),cookies=platform$1.hasStandardBrowserEnv?{write(o,a,c,d,tt,nt){const $a=[o+"="+encodeURIComponent(a)];utils$A.isNumber(c)&&$a.push("expires="+new Date(c).toGMTString()),utils$A.isString(d)&&$a.push("path="+d),utils$A.isString(tt)&&$a.push("domain="+tt),nt===!0&&$a.push("secure"),document.cookie=$a.join("; ")},read(o){const a=document.cookie.match(new RegExp("(^|;\\s*)("+o+")=([^;]*)"));return a?decodeURIComponent(a[3]):null},remove(o){this.write(o,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function isAbsoluteURL(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function combineURLs(o,a){return a?o.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):o}function buildFullPath(o,a){return o&&!isAbsoluteURL(a)?combineURLs(o,a):a}const headersToObject=o=>o instanceof AxiosHeaders$1?{...o}:o;function mergeConfig$1(o,a){a=a||{};const c={};function d(xu,$u,Iu){return utils$A.isPlainObject(xu)&&utils$A.isPlainObject($u)?utils$A.merge.call({caseless:Iu},xu,$u):utils$A.isPlainObject($u)?utils$A.merge({},$u):utils$A.isArray($u)?$u.slice():$u}function tt(xu,$u,Iu){if(utils$A.isUndefined($u)){if(!utils$A.isUndefined(xu))return d(void 0,xu,Iu)}else return d(xu,$u,Iu)}function nt(xu,$u){if(!utils$A.isUndefined($u))return d(void 0,$u)}function $a(xu,$u){if(utils$A.isUndefined($u)){if(!utils$A.isUndefined(xu))return d(void 0,xu)}else return d(void 0,$u)}function Ys(xu,$u,Iu){if(Iu in a)return d(xu,$u);if(Iu in o)return d(void 0,xu)}const gu={url:nt,method:nt,data:nt,baseURL:$a,transformRequest:$a,transformResponse:$a,paramsSerializer:$a,timeout:$a,timeoutMessage:$a,withCredentials:$a,withXSRFToken:$a,adapter:$a,responseType:$a,xsrfCookieName:$a,xsrfHeaderName:$a,onUploadProgress:$a,onDownloadProgress:$a,decompress:$a,maxContentLength:$a,maxBodyLength:$a,beforeRedirect:$a,transport:$a,httpAgent:$a,httpsAgent:$a,cancelToken:$a,socketPath:$a,responseEncoding:$a,validateStatus:Ys,headers:(xu,$u)=>tt(headersToObject(xu),headersToObject($u),!0)};return utils$A.forEach(Object.keys(Object.assign({},o,a)),function($u){const Iu=gu[$u]||tt,Xu=Iu(o[$u],a[$u],$u);utils$A.isUndefined(Xu)&&Iu!==Ys||(c[$u]=Xu)}),c}const resolveConfig=o=>{const a=mergeConfig$1({},o);let{data:c,withXSRFToken:d,xsrfHeaderName:tt,xsrfCookieName:nt,headers:$a,auth:Ys}=a;a.headers=$a=AxiosHeaders$1.from($a),a.url=buildURL(buildFullPath(a.baseURL,a.url),o.params,o.paramsSerializer),Ys&&$a.set("Authorization","Basic "+btoa((Ys.username||"")+":"+(Ys.password?unescape(encodeURIComponent(Ys.password)):"")));let gu;if(utils$A.isFormData(c)){if(platform$1.hasStandardBrowserEnv||platform$1.hasStandardBrowserWebWorkerEnv)$a.setContentType(void 0);else if((gu=$a.getContentType())!==!1){const[xu,...$u]=gu?gu.split(";").map(Iu=>Iu.trim()).filter(Boolean):[];$a.setContentType([xu||"multipart/form-data",...$u].join("; "))}}if(platform$1.hasStandardBrowserEnv&&(d&&utils$A.isFunction(d)&&(d=d(a)),d||d!==!1&&isURLSameOrigin(a.url))){const xu=tt&&nt&&cookies.read(nt);xu&&$a.set(tt,xu)}return a},isXHRAdapterSupported=typeof XMLHttpRequest<"u",xhrAdapter=isXHRAdapterSupported&&function(o){return new Promise(function(c,d){const tt=resolveConfig(o);let nt=tt.data;const $a=AxiosHeaders$1.from(tt.headers).normalize();let{responseType:Ys,onUploadProgress:gu,onDownloadProgress:xu}=tt,$u,Iu,Xu,i0,p0;function w0(){i0&&i0(),p0&&p0(),tt.cancelToken&&tt.cancelToken.unsubscribe($u),tt.signal&&tt.signal.removeEventListener("abort",$u)}let A0=new XMLHttpRequest;A0.open(tt.method.toUpperCase(),tt.url,!0),A0.timeout=tt.timeout;function $0(){if(!A0)return;const L0=AxiosHeaders$1.from("getAllResponseHeaders"in A0&&A0.getAllResponseHeaders()),F0={data:!Ys||Ys==="text"||Ys==="json"?A0.responseText:A0.response,status:A0.status,statusText:A0.statusText,headers:L0,config:o,request:A0};settle(function(g1){c(g1),w0()},function(g1){d(g1),w0()},F0),A0=null}"onloadend"in A0?A0.onloadend=$0:A0.onreadystatechange=function(){!A0||A0.readyState!==4||A0.status===0&&!(A0.responseURL&&A0.responseURL.indexOf("file:")===0)||setTimeout($0)},A0.onabort=function(){A0&&(d(new AxiosError$1("Request aborted",AxiosError$1.ECONNABORTED,o,A0)),A0=null)},A0.onerror=function(){d(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,o,A0)),A0=null},A0.ontimeout=function(){let q0=tt.timeout?"timeout of "+tt.timeout+"ms exceeded":"timeout exceeded";const F0=tt.transitional||transitionalDefaults;tt.timeoutErrorMessage&&(q0=tt.timeoutErrorMessage),d(new AxiosError$1(q0,F0.clarifyTimeoutError?AxiosError$1.ETIMEDOUT:AxiosError$1.ECONNABORTED,o,A0)),A0=null},nt===void 0&&$a.setContentType(null),"setRequestHeader"in A0&&utils$A.forEach($a.toJSON(),function(q0,F0){A0.setRequestHeader(F0,q0)}),utils$A.isUndefined(tt.withCredentials)||(A0.withCredentials=!!tt.withCredentials),Ys&&Ys!=="json"&&(A0.responseType=tt.responseType),xu&&([Xu,p0]=progressEventReducer(xu,!0),A0.addEventListener("progress",Xu)),gu&&A0.upload&&([Iu,i0]=progressEventReducer(gu),A0.upload.addEventListener("progress",Iu),A0.upload.addEventListener("loadend",i0)),(tt.cancelToken||tt.signal)&&($u=L0=>{A0&&(d(!L0||L0.type?new CanceledError$1(null,o,A0):L0),A0.abort(),A0=null)},tt.cancelToken&&tt.cancelToken.subscribe($u),tt.signal&&(tt.signal.aborted?$u():tt.signal.addEventListener("abort",$u)));const O0=parseProtocol(tt.url);if(O0&&platform$1.protocols.indexOf(O0)===-1){d(new AxiosError$1("Unsupported protocol "+O0+":",AxiosError$1.ERR_BAD_REQUEST,o));return}A0.send(nt||null)})},composeSignals=(o,a)=>{let c=new AbortController,d;const tt=function(gu){if(!d){d=!0,$a();const xu=gu instanceof Error?gu:this.reason;c.abort(xu instanceof AxiosError$1?xu:new CanceledError$1(xu instanceof Error?xu.message:xu))}};let nt=a&&setTimeout(()=>{tt(new AxiosError$1(`timeout ${a} of ms exceeded`,AxiosError$1.ETIMEDOUT))},a);const $a=()=>{o&&(nt&&clearTimeout(nt),nt=null,o.forEach(gu=>{gu&&(gu.removeEventListener?gu.removeEventListener("abort",tt):gu.unsubscribe(tt))}),o=null)};o.forEach(gu=>gu&&gu.addEventListener&&gu.addEventListener("abort",tt));const{signal:Ys}=c;return Ys.unsubscribe=$a,[Ys,()=>{nt&&clearTimeout(nt),nt=null}]},streamChunk=function*(o,a){let c=o.byteLength;if(!a||c{const nt=readBytes(o,a,tt);let $a=0,Ys,gu=xu=>{Ys||(Ys=!0,d&&d(xu))};return new ReadableStream({async pull(xu){try{const{done:$u,value:Iu}=await nt.next();if($u){gu(),xu.close();return}let Xu=Iu.byteLength;if(c){let i0=$a+=Xu;c(i0)}xu.enqueue(new Uint8Array(Iu))}catch($u){throw gu($u),$u}},cancel(xu){return gu(xu),nt.return()}},{highWaterMark:2})},isFetchSupported=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",isReadableStreamSupported=isFetchSupported&&typeof ReadableStream=="function",encodeText=isFetchSupported&&(typeof TextEncoder=="function"?(o=>a=>o.encode(a))(new TextEncoder):async o=>new Uint8Array(await new Response(o).arrayBuffer())),test$6=(o,...a)=>{try{return!!o(...a)}catch{return!1}},supportsRequestStream=isReadableStreamSupported&&test$6(()=>{let o=!1;const a=new Request(platform$1.origin,{body:new ReadableStream,method:"POST",get duplex(){return o=!0,"half"}}).headers.has("Content-Type");return o&&!a}),DEFAULT_CHUNK_SIZE=64*1024,supportsResponseStream=isReadableStreamSupported&&test$6(()=>utils$A.isReadableStream(new Response("").body)),resolvers={stream:supportsResponseStream&&(o=>o.body)};isFetchSupported&&(o=>{["text","arrayBuffer","blob","formData","stream"].forEach(a=>{!resolvers[a]&&(resolvers[a]=utils$A.isFunction(o[a])?c=>c[a]():(c,d)=>{throw new AxiosError$1(`Response type '${a}' is not supported`,AxiosError$1.ERR_NOT_SUPPORT,d)})})})(new Response);const getBodyLength=async o=>{if(o==null)return 0;if(utils$A.isBlob(o))return o.size;if(utils$A.isSpecCompliantForm(o))return(await new Request(o).arrayBuffer()).byteLength;if(utils$A.isArrayBufferView(o)||utils$A.isArrayBuffer(o))return o.byteLength;if(utils$A.isURLSearchParams(o)&&(o=o+""),utils$A.isString(o))return(await encodeText(o)).byteLength},resolveBodyLength=async(o,a)=>{const c=utils$A.toFiniteNumber(o.getContentLength());return c??getBodyLength(a)},fetchAdapter=isFetchSupported&&(async o=>{let{url:a,method:c,data:d,signal:tt,cancelToken:nt,timeout:$a,onDownloadProgress:Ys,onUploadProgress:gu,responseType:xu,headers:$u,withCredentials:Iu="same-origin",fetchOptions:Xu}=resolveConfig(o);xu=xu?(xu+"").toLowerCase():"text";let[i0,p0]=tt||nt||$a?composeSignals([tt,nt],$a):[],w0,A0;const $0=()=>{!w0&&setTimeout(()=>{i0&&i0.unsubscribe()}),w0=!0};let O0;try{if(gu&&supportsRequestStream&&c!=="get"&&c!=="head"&&(O0=await resolveBodyLength($u,d))!==0){let u1=new Request(a,{method:"POST",body:d,duplex:"half"}),g1;if(utils$A.isFormData(d)&&(g1=u1.headers.get("content-type"))&&$u.setContentType(g1),u1.body){const[E1,B1]=progressEventDecorator(O0,progressEventReducer(asyncDecorator(gu)));d=trackStream(u1.body,DEFAULT_CHUNK_SIZE,E1,B1,encodeText)}}utils$A.isString(Iu)||(Iu=Iu?"include":"omit"),A0=new Request(a,{...Xu,signal:i0,method:c.toUpperCase(),headers:$u.normalize().toJSON(),body:d,duplex:"half",credentials:Iu});let L0=await fetch(A0);const q0=supportsResponseStream&&(xu==="stream"||xu==="response");if(supportsResponseStream&&(Ys||q0)){const u1={};["status","statusText","headers"].forEach(lv=>{u1[lv]=L0[lv]});const g1=utils$A.toFiniteNumber(L0.headers.get("content-length")),[E1,B1]=Ys&&progressEventDecorator(g1,progressEventReducer(asyncDecorator(Ys),!0))||[];L0=new Response(trackStream(L0.body,DEFAULT_CHUNK_SIZE,E1,()=>{B1&&B1(),q0&&$0()},encodeText),u1)}xu=xu||"text";let F0=await resolvers[utils$A.findKey(resolvers,xu)||"text"](L0,o);return!q0&&$0(),p0&&p0(),await new Promise((u1,g1)=>{settle(u1,g1,{data:F0,headers:AxiosHeaders$1.from(L0.headers),status:L0.status,statusText:L0.statusText,config:o,request:A0})})}catch(L0){throw $0(),L0&&L0.name==="TypeError"&&/fetch/i.test(L0.message)?Object.assign(new AxiosError$1("Network Error",AxiosError$1.ERR_NETWORK,o,A0),{cause:L0.cause||L0}):AxiosError$1.from(L0,L0&&L0.code,o,A0)}}),knownAdapters={http:httpAdapter,xhr:xhrAdapter,fetch:fetchAdapter};utils$A.forEach(knownAdapters,(o,a)=>{if(o){try{Object.defineProperty(o,"name",{value:a})}catch{}Object.defineProperty(o,"adapterName",{value:a})}});const renderReason=o=>`- ${o}`,isResolvedHandle=o=>utils$A.isFunction(o)||o===null||o===!1,adapters={getAdapter:o=>{o=utils$A.isArray(o)?o:[o];const{length:a}=o;let c,d;const tt={};for(let nt=0;nt`adapter ${Ys} `+(gu===!1?"is not supported by the environment":"is not available in the build"));let $a=a?nt.length>1?`since : `+nt.map(renderReason).join(` `):" "+renderReason(nt[0]):"as no adapter specified";throw new AxiosError$1("There is no suitable adapter to dispatch the request "+$a,"ERR_NOT_SUPPORT")}return d},adapters:knownAdapters};function throwIfCancellationRequested(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new CanceledError$1(null,o)}function dispatchRequest(o){return throwIfCancellationRequested(o),o.headers=AxiosHeaders$1.from(o.headers),o.data=transformData.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),adapters.getAdapter(o.adapter||defaults$1.adapter)(o).then(function(d){return throwIfCancellationRequested(o),d.data=transformData.call(o,o.transformResponse,d),d.headers=AxiosHeaders$1.from(d.headers),d},function(d){return isCancel$1(d)||(throwIfCancellationRequested(o),d&&d.response&&(d.response.data=transformData.call(o,o.transformResponse,d.response),d.response.headers=AxiosHeaders$1.from(d.response.headers))),Promise.reject(d)})}const VERSION$2="1.7.4",validators$5={};["object","boolean","number","function","string","symbol"].forEach((o,a)=>{validators$5[o]=function(d){return typeof d===o||"a"+(a<1?"n ":" ")+o}});const deprecatedWarnings={};validators$5.transitional=function(a,c,d){function tt(nt,$a){return"[Axios v"+VERSION$2+"] Transitional option '"+nt+"'"+$a+(d?". "+d:"")}return(nt,$a,Ys)=>{if(a===!1)throw new AxiosError$1(tt($a," has been removed"+(c?" in "+c:"")),AxiosError$1.ERR_DEPRECATED);return c&&!deprecatedWarnings[$a]&&(deprecatedWarnings[$a]=!0,console.warn(tt($a," has been deprecated since v"+c+" and will be removed in the near future"))),a?a(nt,$a,Ys):!0}};function assertOptions(o,a,c){if(typeof o!="object")throw new AxiosError$1("options must be an object",AxiosError$1.ERR_BAD_OPTION_VALUE);const d=Object.keys(o);let tt=d.length;for(;tt-- >0;){const nt=d[tt],$a=a[nt];if($a){const Ys=o[nt],gu=Ys===void 0||$a(Ys,nt,o);if(gu!==!0)throw new AxiosError$1("option "+nt+" must be "+gu,AxiosError$1.ERR_BAD_OPTION_VALUE);continue}if(c!==!0)throw new AxiosError$1("Unknown option "+nt,AxiosError$1.ERR_BAD_OPTION)}}const validator={assertOptions,validators:validators$5},validators$4=validator.validators;let Axios$1=class{constructor(a){this.defaults=a,this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}async request(a,c){try{return await this._request(a,c)}catch(d){if(d instanceof Error){let tt;Error.captureStackTrace?Error.captureStackTrace(tt={}):tt=new Error;const nt=tt.stack?tt.stack.replace(/^.+\n/,""):"";try{d.stack?nt&&!String(d.stack).endsWith(nt.replace(/^.+\n.+\n/,""))&&(d.stack+=` -`+nt):d.stack=nt}catch{}}throw d}}_request(a,c){typeof a=="string"?(c=c||{},c.url=a):c=a||{},c=mergeConfig$1(this.defaults,c);const{transitional:d,paramsSerializer:tt,headers:nt}=c;d!==void 0&&validator.assertOptions(d,{silentJSONParsing:validators$4.transitional(validators$4.boolean),forcedJSONParsing:validators$4.transitional(validators$4.boolean),clarifyTimeoutError:validators$4.transitional(validators$4.boolean)},!1),tt!=null&&(utils$A.isFunction(tt)?c.paramsSerializer={serialize:tt}:validator.assertOptions(tt,{encode:validators$4.function,serialize:validators$4.function},!0)),c.method=(c.method||this.defaults.method||"get").toLowerCase();let $a=nt&&utils$A.merge(nt.common,nt[c.method]);nt&&utils$A.forEach(["delete","get","head","post","put","patch","common"],p0=>{delete nt[p0]}),c.headers=AxiosHeaders$1.concat($a,nt);const Ys=[];let gu=!0;this.interceptors.request.forEach(function(w0){typeof w0.runWhen=="function"&&w0.runWhen(c)===!1||(gu=gu&&w0.synchronous,Ys.unshift(w0.fulfilled,w0.rejected))});const xu=[];this.interceptors.response.forEach(function(w0){xu.push(w0.fulfilled,w0.rejected)});let $u,Iu=0,Xu;if(!gu){const p0=[dispatchRequest.bind(this),void 0];for(p0.unshift.apply(p0,Ys),p0.push.apply(p0,xu),Xu=p0.length,$u=Promise.resolve(c);Iu{if(!d._listeners)return;let nt=d._listeners.length;for(;nt-- >0;)d._listeners[nt](tt);d._listeners=null}),this.promise.then=tt=>{let nt;const $a=new Promise(Ys=>{d.subscribe(Ys),nt=Ys}).then(tt);return $a.cancel=function(){d.unsubscribe(nt)},$a},a(function(nt,$a,Ys){d.reason||(d.reason=new CanceledError$1(nt,$a,Ys),c(d.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const c=this._listeners.indexOf(a);c!==-1&&this._listeners.splice(c,1)}static source(){let a;return{token:new Ive(function(tt){a=tt}),cancel:a}}};function spread$1(o){return function(c){return o.apply(null,c)}}function isAxiosError$1(o){return utils$A.isObject(o)&&o.isAxiosError===!0}const HttpStatusCode$1={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode$1).forEach(([o,a])=>{HttpStatusCode$1[a]=o});function createInstance(o){const a=new Axios$1(o),c=bind$f(Axios$1.prototype.request,a);return utils$A.extend(c,Axios$1.prototype,a,{allOwnKeys:!0}),utils$A.extend(c,a,null,{allOwnKeys:!0}),c.create=function(tt){return createInstance(mergeConfig$1(o,tt))},c}const axios=createInstance(defaults$1);axios.Axios=Axios$1;axios.CanceledError=CanceledError$1;axios.CancelToken=CancelToken$1;axios.isCancel=isCancel$1;axios.VERSION=VERSION$2;axios.toFormData=toFormData$1;axios.AxiosError=AxiosError$1;axios.Cancel=axios.CanceledError;axios.all=function(a){return Promise.all(a)};axios.spread=spread$1;axios.isAxiosError=isAxiosError$1;axios.mergeConfig=mergeConfig$1;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=o=>formDataToJSON(utils$A.isHTMLForm(o)?new FormData(o):o);axios.getAdapter=adapters.getAdapter;axios.HttpStatusCode=HttpStatusCode$1;axios.default=axios;const{Axios,AxiosError,CanceledError,isCancel,CancelToken,VERSION:VERSION$1,all:all$1,Cancel,isAxiosError,spread,toFormData,AxiosHeaders,HttpStatusCode,formToJSON,getAdapter,mergeConfig}=axios;class AxiosHttpClient{constructor(a,c){aw(this,"axios");aw(this,"showServerDownPopup");this.axios=a,this.showServerDownPopup=c,this.axios.interceptors.response.use(d=>d,d=>(d.response||this.showServerDownPopup(),Promise.reject(d)))}async get(a,c={}){return this.request(this.axios.get(a,{headers:c}))}async post(a,c,d={}){return this.request(this.axios.post(a,c,{headers:d}))}async put(a,c,d={}){return this.request(this.axios.put(a,c,{headers:d}))}async delete(a,c={}){return this.request(this.axios.delete(a,{headers:c}))}async patch(a,c,d={}){return this.request(this.axios.patch(a,c,{headers:d}))}async head(a,c={}){return this.request(this.axios.head(a,{headers:c}))}async request(a){var c,d,tt;try{const nt=await a;return nt.config.method.toUpperCase()==="HEAD"?{data:void 0}:nt.data}catch(nt){if(nt instanceof AxiosError){if(((d=(c=nt.config)==null?void 0:c.method)==null?void 0:d.toUpperCase())==="HEAD")return{error:{code:nt.request.status,message:nt.message}};const $a=(tt=nt.response)==null?void 0:tt.data,Ys=$a.error;return!$a&&(!Ys||!Ys.message||!Ys.code)?{error:GENERIC_ERROR}:typeof $a=="string"?{error:{code:nt.request.status,message:$a}}:typeof Ys=="string"?{error:{code:nt.request.status,message:Ys}}:{error:{code:(Ys==null?void 0:Ys.code)||nt.request.status,message:Ys==null?void 0:Ys.message}}}return{error:GENERIC_ERROR}}}}const GENERIC_ERROR={code:500,message:"Something went wrong"},useMetamask$1={requestNodeDataError:"Error while requesting node data",noSignatureError:"Signature is empty",noAddressError:"Address is empty",loginError:"Error while login",rootkeyError:"Error while adding root key",applicationNameText:"admin-dashboard"},useNear$1={verifyMessageError:"Error while verifying message",missingUrlParamsError:"Missing url parameters",loginError:"Error while login",rootkeyError:"Error while adding root key",messageNotVerifiedError:"Message not verified",signMessageError:"Error while signing message",signOutError:"Failed to signing out"},useStarknet$1={requestNodeDataError:"Error while requesting node data",noSignatureError:"Signature is empty",noAddressError:"Address is empty",loginError:"Error while login",rootkeyError:"Error while adding root key",applicationNameText:"admin-dashboard",signMessageError:"Error while signing message",signOutError:"Failed to signing out",errorChangingNetwork:"Error changing network",walletNotFound:"Wallet not found",errorLogin:"Error while login"},useIcp$1={requestNodeDataError:"Error while requesting node data",errorChangingNetwork:"Error changing network",loginError:"Error while login",rootkeyError:"Error while adding root key",signMessageError:"Error while signing message"},loginPage={logoDashboardText:"Admin Dashboard",title:"Calimero Node Admin Dashboard",subtitle:"Start using Calimero by selecting your wallet.",buttonConnectText:"Connect Wallet",loginSelector:{title:"Continue with wallet",metamaskButtonText:"Metamask wallet",nearButtonText:"Near wallet",starknetButtonText:"Starknet wallet",IcpButtonText:"Internet Computer"},nearLogin:{title:"Login with NEAR",subtitle:"Choose which account from your wallet you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector"},IcpLogin:{title:"Login with Internet Identity",subtitle:"Choose from which account you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",currentNetwork:"Current network",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backToLoginPage:"Back to login page"},metamaskLogin:{titleLogin:"Login with Metamask",titleRootKey:"Add Metamask root key",subtitle:"Choose which account from your wallet you want to log in with",authButtonText:"Sign authentication transaction",errorTitleText:"Error signing message",backButtonText:"Back to wallet selector"},starknetLogin:{title:"Login with Starknet",subtitle:"Choose which account from your wallet you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector",argentXButton:"Login with ArgentX",metamaskButton:"Login with MetaMask",titleRootKey:"Add Starknet root key",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",backToLoginPage:"Back to login selector"}},addRootKeyPage={nearRootKey:{title:"Add NEAR root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Add root key",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector"},starknetRootKey:{title:"Add Starknet root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",argentXButton:"Add root key with ArgentX",metamaskButton:"Add root key with MetaMask",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",backToLoginPage:"Back to login selector"},IcpKey:{title:"Add Internet Identity root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",authButtonText:"Add root key",backToLoginPage:"Back to login selector"}},footer={title:"Calimero Network"},navigation={logoDashboardText:"Admin Dashboard",pkTest:"Public Key"},applicationsPage={applicationsTable:{title:"Applications",publishNewAppText:"Publish new application",noAvailableAppsText:"No applications available",noAvailableReleasesText:"No available releases",noInstalledAppsText:"No installed applications",noOwnedAppsText:"No owned applications",installNewAppText:"install new application",actionDialog:{title:"Uninstall Application",subtitle:"Are you sure you want to uninstall this application? This action cannot be undone.",buttonActionText:"Uninstall"}},installApplication:{title:"Install Application",backButtonText:"Back to Applications",selectAppLabel:"Select Application to Install",dropdownPlaceholder:"Applications",packageDetailsLabel:"Package Details",releaseSelectionLabel:"Select Application Release",releaseDetailsLabel:"Release Details",installErrorTitle:"Failed to install application",selectApplicationTitle:"Select app from the marketplace or publish new application",selectedApplicationTitle:"Selected Application",installButtonText:"Install application",idLabelText:"Application ID: ",nameLabelText:"Application Name: ",versionLabelText:"Version: ",failInstallTitle:"Error installing application",successInstallTitle:"Application installed successfully"},publishApplication:{title:"Publish new application",addAccountButtonText:"Add wallet account",connectAccountTitle:"Connect owner account",connectAccountSubtitle:"Owner account is holder of application and only that account can publish new releases.",connectAccountButtonText:"Connect account",buttonText:"Publish"},addRelease:{title:"Add new release",buttonText:"Publish",latestReleaseText:"Latest application version is : "}},confirmWallet={logoText:"Admin Dashboard",title:"Confirm Wallet",accountIdText:"Account Id",signatureText:"Signature",publicKeyText:"PublicKey",callbackUrlText:"Callback Url",submitButtonText:"Submit Request",backButtonText:"Back to login"},keysPage={title:"Keys"},keysTable={noKeysText:"No keys found in the node.",headerPkText:"Public Key",headerTypeText:"Type",badgeActiveText:"Active",badgeRevokedText:"Revoked",setActiveText:"Set Active",revokeKeyText:"Revoke Key",addNewText:"Add new Key"},uploadPage={title:"Upload Application",walletButtonText:"Add wallet account",switchPackageText:"Add Package",switchReleaseText:"Add Release"},uploadApplication={title:"Add Release",subtitle:"To install the application first upload the application wasm to the IPFS, select the package you want to add the release for and fill the release details.",uploadIpfsTitle:"IPFS Application upload",inputLabelText:"Select Application .wasm file to upload",buttonUploadLabel:"Upload wasm",buttonUploadText:"Upload",cidLabelText:"File IPFS CID",backButtonText:"Back",releaseTitle:"Add new release",nameLabelText:"Name",pathLabelText:"Path",versionLabelText:"Version",notesLabelText:"Notes",hashLabelText:"Hash",buttonAddReleaseText:"Add Release",versionPlaceholder:"1.0.0",notesPlaceholder:"Initial release",hashPlaceholder:"QmZ3Z8Q7QmZ3Z8Q7QmZ3Z8Q7QmZ3Z8Q7",addReleaseButtonText:"Add Release",loginLableText:"To Deploy new release, you need to sign in using wallet account button!",deployerDropdownlabel:"Select deployer account",deployerDropdownText:"Deployer Account",selectPackageLabel:"Select Package",pathPlaceholder:"url to the wasm file"},addPackageForm={title:"Add application details",subtitle:"To successfully install the application, first you need to add the package details and procceed to add relase.",nameLabelText:"Package Name",repositoryLabelText:"Repository URL",descriptionLabelText:"Description",buttonAddPackageText:"Add Package",buttonNextText:"Next",namePlaceholder:"chat-application",repositoryPlaceholder:"https://github.com/",descriptionPlaceholder:"A chat application built for P2P network",loginLableText:"To Deploy new package, you need to sign in using wallet account button!",deployerDropdownlabel:"Select deployer account",deployerDropdownText:"Deployer Account"},statusModal={buttonContinueText:"Continue",buttonDeleteText:"Delete",buttonCopyText:"Copy",buttonCloseText:"Close",buttonCancelText:"Cancel"},contextPage={contextPageTitle:"Contexts",startNewContextText:"Start new context",joinContextText:"Join existing context",noContextsText:"No contexts found in the node.",contextPageDescription:"Contexts are the core of the Calimero ecosystem. These are application specific networks designed to enable direct communication between users, eliminating the need for intermediaries.",invitedListDescription:"Contexts you have been invited to",noJoinedAppsListText:"You have not joined any contexts.",noInviedAppsListText:"You have not been invited to any contexts.",devApplicationTitle:"Development application",deleteContextText:"Delete Context",contextDetails:{title:"Context Details",clientKeysListDescription:"Client keys are authorization keys used by the application frontend.",noClientKeysText:"No data found.",noUsersText:"No users found in the context.",labelIdText:"Id: ",labelNameText:"Name: ",labelOwnerText:"Owner: ",labelDescriptionText:"Description: ",labelRepositoryText:"Repository URL: ",lableVersionText:"Version: ",labelAppId:"App ID: ",titleApps:"Installed application",localAppTitle:"Metadata not available for locally installed application",titleStorage:"Storage",labelStorageText:"Used: "},actionDialog:{title:"Delete Context",subtitle:"Are you sure you want to delete this context? This action cannot be undone."},contextInvitation:{invitationText:"Invited on ",acceptButtonText:"Accept",declineButtonText:"Decline"}},startContextPage={backButtonText:"back to context select",selectApplicationTitle:"Select app from the marketplace or publish new application",selectedApplicationTitle:"Selected Application",initSectionTitle:"Initialize application state",argsTitleText:"Arguments",methodLabelText:"method name",argsLabelText:"arguments json",buttonFormatText:"format",loginRequestPopupTitle:"Application Sign-in Request - Start Context",detailsText:"Details",applicationList:{listTitle:"Select Available Application",noAvailableAppsText:"No applications available",noOwnedAppsText:"No owned applications installed"},startContextSuccessTitle:"Context started",startedContextMessage:"Application context has been started successfully.",startContextErrorTitle:"Failed to start context",startContextErrorMessage:"Failed to start the application context.",idLabelText:"Application ID: ",nameLabelText:"Application Name: ",versionLabelText:"Version: ",successInstallTitle:"Application installed successfully",failInstallTitle:"Error installing application"},joinContextPage={title:"Join existing Context",buttonJoinText:"Join Context",joinErrorTitle:"Failed to join context",joinSuccessTitle:"Context joined",joinSuccessMessage:"Context joined successfully",contextIdLabel:"Context ID"},exportIdentityPage={title:"Export",description:"Export decentralized identifiers (DIDs) associated with the node.",buttonExportText:"Export Identity",exportErrorTitle:"Failed to export node identity",exportSuccessTitle:"Identity exported"},identityPage={title:"Root keys",addRootKeyText:"Add new root key",loggedInLabel:"Logged in with: ",noRootKeysText:"No root keys found in the node."},serverDown={useHookComponentErrorText:"useServerDown must be used within a ServerDownProvider",popupTitle:"503 - Service Unavailable",popupMessage:"The Node Server at {{nodeApiEndpoint}} is unreachable. Please try again later."},nodeDataSource={joinContextErrorTitle:"Error joining context",joinContextErrorMessage:"Failed to join context",unauthorizedErrorMessage:"Unauthorized"},authHeaders={errorText:"Error extracting private key"},walletSelectorContext={alertErrorText:"Failed to initialise wallet selector",componentErrorText:"useWalletSelector must be used within a WalletSelectorContextProvider"},appLoginPopup={createTokenError:"Error creating token, please try again",selectContext:{title:"Application Sign-in Request",detailsText:"Details",websiteText:"From site: ",appIdText:"Application Id: ",contextsTitle:"Select Context",contextsSubtitle:"To continue select available or start a new context for the application",noContextsText:"No contexts found",selectedContextText:"Selected context Id:",buttonNextText:"Confirm context Id",buttonBackText:"Return to application",buttonCreateText:"Start new"},selectIdentity:{title:"Application Sign-in Request",detailsText:"Details",websiteText:"From site: ",appIdText:"Application Id: ",contextIdText:"Context Id: ",contextsTitle:"Select context identity",contextsSubtitle:"To continue select available context identity for the application",noContextsText:"No contexts identities found",selectedContextText:"Selected context identity:",backButtonText:"back to context select",buttonNextText:"Confirm context identity",buttonBackText:"Return to application"},createToken:{title:"Application Sign-in Request",websiteText:"From site: ",appIdText:"Application Id: ",contextIdText:"Context Id: ",backButtonText:"back to select context identity",contextIdentityText:"Context Identity: ",detailsText:"Details",buttonNextText:"Create token"}},setupModal$1={inputIdLengthError:"Application ID must be between 32 and 44 characters long.",inputEncodeError:"Application ID must contain only base58 characters.",nodeHealthCheckError:"Connection failed. Please check if node url is correct.",modalTitle:"App setup",urlInputPlacerholder:"node url",buttonSetText:"Set node url"},translations={useMetamask:useMetamask$1,useNear:useNear$1,useStarknet:useStarknet$1,useIcp:useIcp$1,loginPage,addRootKeyPage,footer,navigation,applicationsPage,confirmWallet,keysPage,keysTable,uploadPage,uploadApplication,addPackageForm,statusModal,contextPage,startContextPage,joinContextPage,exportIdentityPage,identityPage,serverDown,nodeDataSource,authHeaders,walletSelectorContext,appLoginPopup,setupModal:setupModal$1};function createAppMetadata(o){var a={contractAppId:o};return Array.from(new TextEncoder().encode(JSON.stringify(a)))}function parseAppMetadata(o){try{if(o.length===0)return null;var a=JSON.parse(new TextDecoder().decode(new Uint8Array(o)));return a}catch{return null}}function getNodeUrl(){let o=getAppEndpointKey();if(!o){let a="http://localhost:2428";return setAppEndpointKey(a),a}return o??""}function getNearEnvironment(){return"testnet"}const Ed25519$1="Ed25519";class CodeError extends Error{constructor(c,d,tt){super(c);aw(this,"code");aw(this,"props");this.code=d,this.name=(tt==null?void 0:tt.name)??"CodeError",this.props=tt??{}}}class AggregateCodeError extends AggregateError{constructor(c,d,tt,nt){super(c,d);aw(this,"code");aw(this,"props");this.code=tt,this.name=(nt==null?void 0:nt.name)??"AggregateCodeError",this.props=nt??{}}}var events={exports:{}},R$3=typeof Reflect=="object"?Reflect:null,ReflectApply=R$3&&typeof R$3.apply=="function"?R$3.apply:function(a,c,d){return Function.prototype.apply.call(a,c,d)},ReflectOwnKeys;R$3&&typeof R$3.ownKeys=="function"?ReflectOwnKeys=R$3.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:ReflectOwnKeys=function(a){return Object.getOwnPropertyNames(a)};function ProcessEmitWarning(o){console&&console.warn&&console.warn(o)}var NumberIsNaN=Number.isNaN||function(a){return a!==a};function EventEmitter$1(){EventEmitter$1.init.call(this)}events.exports=EventEmitter$1;events.exports.once=once$2;EventEmitter$1.EventEmitter=EventEmitter$1;EventEmitter$1.prototype._events=void 0;EventEmitter$1.prototype._eventsCount=0;EventEmitter$1.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(EventEmitter$1,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(o){if(typeof o!="number"||o<0||NumberIsNaN(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");defaultMaxListeners=o}});EventEmitter$1.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter$1.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||NumberIsNaN(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function _getMaxListeners(o){return o._maxListeners===void 0?EventEmitter$1.defaultMaxListeners:o._maxListeners}EventEmitter$1.prototype.getMaxListeners=function(){return _getMaxListeners(this)};EventEmitter$1.prototype.emit=function(a){for(var c=[],d=1;d0&&($a=c[0]),$a instanceof Error)throw $a;var Ys=new Error("Unhandled error."+($a?" ("+$a.message+")":""));throw Ys.context=$a,Ys}var gu=nt[a];if(gu===void 0)return!1;if(typeof gu=="function")ReflectApply(gu,this,c);else for(var xu=gu.length,$u=arrayClone(gu,xu),d=0;d0&&$a.length>tt&&!$a.warned){$a.warned=!0;var Ys=new Error("Possible EventEmitter memory leak detected. "+$a.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");Ys.name="MaxListenersExceededWarning",Ys.emitter=o,Ys.type=a,Ys.count=$a.length,ProcessEmitWarning(Ys)}return o}EventEmitter$1.prototype.addListener=function(a,c){return _addListener(this,a,c,!1)};EventEmitter$1.prototype.on=EventEmitter$1.prototype.addListener;EventEmitter$1.prototype.prependListener=function(a,c){return _addListener(this,a,c,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(o,a,c){var d={fired:!1,wrapFn:void 0,target:o,type:a,listener:c},tt=onceWrapper.bind(d);return tt.listener=c,d.wrapFn=tt,tt}EventEmitter$1.prototype.once=function(a,c){return checkListener(c),this.on(a,_onceWrap(this,a,c)),this};EventEmitter$1.prototype.prependOnceListener=function(a,c){return checkListener(c),this.prependListener(a,_onceWrap(this,a,c)),this};EventEmitter$1.prototype.removeListener=function(a,c){var d,tt,nt,$a,Ys;if(checkListener(c),tt=this._events,tt===void 0)return this;if(d=tt[a],d===void 0)return this;if(d===c||d.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete tt[a],tt.removeListener&&this.emit("removeListener",a,d.listener||c));else if(typeof d!="function"){for(nt=-1,$a=d.length-1;$a>=0;$a--)if(d[$a]===c||d[$a].listener===c){Ys=d[$a].listener,nt=$a;break}if(nt<0)return this;nt===0?d.shift():spliceOne(d,nt),d.length===1&&(tt[a]=d[0]),tt.removeListener!==void 0&&this.emit("removeListener",a,Ys||c)}return this};EventEmitter$1.prototype.off=EventEmitter$1.prototype.removeListener;EventEmitter$1.prototype.removeAllListeners=function(a){var c,d,tt;if(d=this._events,d===void 0)return this;if(d.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):d[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete d[a]),this;if(arguments.length===0){var nt=Object.keys(d),$a;for(tt=0;tt=0;tt--)this.removeListener(a,c[tt]);return this};function _listeners(o,a,c){var d=o._events;if(d===void 0)return[];var tt=d[a];return tt===void 0?[]:typeof tt=="function"?c?[tt.listener||tt]:[tt]:c?unwrapListeners(tt):arrayClone(tt,tt.length)}EventEmitter$1.prototype.listeners=function(a){return _listeners(this,a,!0)};EventEmitter$1.prototype.rawListeners=function(a){return _listeners(this,a,!1)};EventEmitter$1.listenerCount=function(o,a){return typeof o.listenerCount=="function"?o.listenerCount(a):listenerCount.call(o,a)};EventEmitter$1.prototype.listenerCount=listenerCount;function listenerCount(o){var a=this._events;if(a!==void 0){var c=a[o];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}EventEmitter$1.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(o,a){for(var c=new Array(a),d=0;d=255)throw new TypeError("Alphabet too long");for(var c=new Uint8Array(256),d=0;d>>0,q0=new Uint8Array(L0);$0!==O0;){for(var F0=p0[$0],u1=0,g1=L0-1;(F0!==0||u1>>0,q0[g1]=F0%Ys>>>0,F0=F0/Ys>>>0;if(F0!==0)throw new Error("Non-zero carry");A0=u1,$0++}for(var E1=L0-A0;E1!==L0&&q0[E1]===0;)E1++;for(var B1=gu.repeat(w0);E1>>0,L0=new Uint8Array(O0);p0[w0];){var q0=c[p0.charCodeAt(w0)];if(q0===255)return;for(var F0=0,u1=O0-1;(q0!==0||F0<$0)&&u1!==-1;u1--,F0++)q0+=Ys*L0[u1]>>>0,L0[u1]=q0%256>>>0,q0=q0/256>>>0;if(q0!==0)throw new Error("Non-zero carry");$0=F0,w0++}if(p0[w0]!==" "){for(var g1=O0-$0;g1!==O0&&L0[g1]===0;)g1++;for(var E1=new Uint8Array(A0+(O0-g1)),B1=A0;g1!==O0;)E1[B1++]=L0[g1++];return E1}}}function i0(p0){var w0=Xu(p0);if(w0)return w0;throw new Error(`Non-${a} character`)}return{encode:Iu,decodeUnsafe:Xu,decode:i0}}var src$2=base$5,_brrp__multiformats_scope_baseX=src$2;class Encoder{constructor(a,c,d){aw(this,"name");aw(this,"prefix");aw(this,"baseEncode");this.name=a,this.prefix=c,this.baseEncode=d}encode(a){if(a instanceof Uint8Array)return`${this.prefix}${this.baseEncode(a)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(a,c,d){aw(this,"name");aw(this,"prefix");aw(this,"baseDecode");aw(this,"prefixCodePoint");if(this.name=a,this.prefix=c,c.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=c.codePointAt(0),this.baseDecode=d}decode(a){if(typeof a=="string"){if(a.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(a)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(a.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(a){return or$1(this,a)}}class ComposedDecoder{constructor(a){aw(this,"decoders");this.decoders=a}or(a){return or$1(this,a)}decode(a){const c=a[0],d=this.decoders[c];if(d!=null)return d.decode(a);throw RangeError(`Unable to decode multibase string ${JSON.stringify(a)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or$1(o,a){return new ComposedDecoder({...o.decoders??{[o.prefix]:o},...a.decoders??{[a.prefix]:a}})}class Codec{constructor(a,c,d,tt){aw(this,"name");aw(this,"prefix");aw(this,"baseEncode");aw(this,"baseDecode");aw(this,"encoder");aw(this,"decoder");this.name=a,this.prefix=c,this.baseEncode=d,this.baseDecode=tt,this.encoder=new Encoder(a,c,d),this.decoder=new Decoder(a,c,tt)}encode(a){return this.encoder.encode(a)}decode(a){return this.decoder.decode(a)}}function from$2({name:o,prefix:a,encode:c,decode:d}){return new Codec(o,a,c,d)}function baseX$1({name:o,prefix:a,alphabet:c}){const{encode:d,decode:tt}=_brrp__multiformats_scope_baseX(c,o);return from$2({prefix:a,name:o,encode:d,decode:nt=>coerce(tt(nt))})}function decode$6(o,a,c,d){const tt={};for(let $u=0;$u=8&&(Ys-=8,$a[xu++]=255&gu>>Ys)}if(Ys>=c||255&gu<<8-Ys)throw new SyntaxError("Unexpected end of data");return $a}function encode$7(o,a,c){const d=a[a.length-1]==="=",tt=(1<c;)$a-=c,nt+=a[tt&Ys>>$a];if($a!==0&&(nt+=a[tt&Ys<=INT;)a[c++]=o&255|MSB$1,o/=128;for(;o&MSBALL;)a[c++]=o&255|MSB$1,o>>>=7;return a[c]=o|0,encode$6.bytes=c-d+1,a}var decode$5=read$2,MSB$1$1=128,REST$1$1=127;function read$2(o,d){var c=0,d=d||0,tt=0,nt=d,$a,Ys=o.length;do{if(nt>=Ys)throw read$2.bytes=0,new RangeError("Could not decode varint");$a=o[nt++],c+=tt<28?($a&REST$1$1)<=MSB$1$1);return read$2.bytes=nt-d,c}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length$2=function(o){return ocreate$8(this.code,d))}else throw Error("Unknown type, must be binary type")}}function sha$5(o){return async a=>new Uint8Array(await crypto.subtle.digest(o,a))}const sha256$6=from$1({name:"sha2-256",code:18,encode:sha$5("SHA-256")});function equals(o,a){if(o===a)return!0;if(o.byteLength!==a.byteLength)return!1;for(let c=0;ctt+nt.length,0));const c=allocUnsafe(a);let d=0;for(const tt of o)c.set(tt,d),d+=tt.length;return c}const base10=baseX$1({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$1=Object.freeze(Object.defineProperty({__proto__:null,base10},Symbol.toStringTag,{value:"Module"})),base16=rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper=rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$1=Object.freeze(Object.defineProperty({__proto__:null,base16,base16upper},Symbol.toStringTag,{value:"Module"})),base2=rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$1=Object.freeze(Object.defineProperty({__proto__:null,base2},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),alphabetBytesToChars=alphabet$1.reduce((o,a,c)=>(o[c]=a,o),[]),alphabetCharsToBytes=alphabet$1.reduce((o,a,c)=>(o[a.codePointAt(0)]=c,o),[]);function encode$4(o){return o.reduce((a,c)=>(a+=alphabetBytesToChars[c],a),"")}function decode$4(o){const a=[];for(const c of o){const d=alphabetCharsToBytes[c.codePointAt(0)];if(d===void 0)throw new Error(`Non-base256emoji character: ${c}`);a.push(d)}return new Uint8Array(a)}const base256emoji=from$2({prefix:"๐Ÿš€",name:"base256emoji",encode:encode$4,decode:decode$4}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX$1({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX$1({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base64$1=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$2=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$1,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity$1=from$2({prefix:"\0",name:"identity",encode:o=>toString$c(o),decode:o=>fromString$1(o)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$2,...base256emoji$1};function createCodec$1(o,a,c,d){return{name:o,prefix:a,encoder:{name:o,prefix:a,encode:c},decoder:{decode:d}}}const string=createCodec$1("utf8","u",o=>"u"+new TextDecoder("utf8").decode(o),o=>new TextEncoder().encode(o.substring(1))),ascii=createCodec$1("ascii","a",o=>{let a="a";for(let c=0;c{o=o.substring(1);const a=allocUnsafe(o.length);for(let c=0;c0&&!a.includes(o.length))throw new Error(`Uint8Array expected of length ${a}, not of length=${o.length}`)}function hash$a(o){if(typeof o!="function"||typeof o.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number$3(o.outputLen),number$3(o.blockLen)}function exists$3(o,a=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(a&&o.finished)throw new Error("Hash#digest() has already been called")}function output$3(o,a){bytes$3(o);const c=a.outputLen;if(o.lengthnew Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)),createView$1=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),rotr$1=(o,a)=>o<<32-a|o>>>a,isLE$1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,byteSwap=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255;function byteSwap32(o){for(let a=0;a{};async function asyncLoop(o,a,c){let d=Date.now();for(let tt=0;tt=0&&nto().update(toBytes$1(d)).digest(),c=o();return a.outputLen=c.outputLen,a.blockLen=c.blockLen,a.create=()=>o(),a}function randomBytes$5(o=32){if(crypto$6&&typeof crypto$6.getRandomValues=="function")return crypto$6.getRandomValues(new Uint8Array(o));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$3(o,a,c,d){if(typeof o.setBigUint64=="function")return o.setBigUint64(a,c,d);const tt=BigInt(32),nt=BigInt(4294967295),$a=Number(c>>tt&nt),Ys=Number(c&nt),gu=d?4:0,xu=d?0:4;o.setUint32(a+gu,$a,d),o.setUint32(a+xu,Ys,d)}const Chi$2=(o,a,c)=>o&a^~o&c,Maj$2=(o,a,c)=>o&a^o&c^a&c;class HashMD extends Hash$9{constructor(a,c,d,tt){super(),this.blockLen=a,this.outputLen=c,this.padOffset=d,this.isLE=tt,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(a),this.view=createView$1(this.buffer)}update(a){exists$3(this);const{view:c,buffer:d,blockLen:tt}=this;a=toBytes$1(a);const nt=a.length;for(let $a=0;$att-$a&&(this.process(d,0),$a=0);for(let Iu=$a;Iu$u.length)throw new Error("_sha2: outputLen bigger than state");for(let Iu=0;Iu>_32n$2&U32_MASK64$2)}:{h:Number(o>>_32n$2&U32_MASK64$2)|0,l:Number(o&U32_MASK64$2)|0}}function split$8(o,a=!1){let c=new Uint32Array(o.length),d=new Uint32Array(o.length);for(let tt=0;ttBigInt(o>>>0)<<_32n$2|BigInt(a>>>0),shrSH$1=(o,a,c)=>o>>>c,shrSL$1=(o,a,c)=>o<<32-c|a>>>c,rotrSH$1=(o,a,c)=>o>>>c|a<<32-c,rotrSL$1=(o,a,c)=>o<<32-c|a>>>c,rotrBH$1=(o,a,c)=>o<<64-c|a>>>c-32,rotrBL$1=(o,a,c)=>o>>>c-32|a<<64-c,rotr32H$1=(o,a)=>a,rotr32L$1=(o,a)=>o,rotlSH$2=(o,a,c)=>o<>>32-c,rotlSL$2=(o,a,c)=>a<>>32-c,rotlBH$2=(o,a,c)=>a<>>64-c,rotlBL$2=(o,a,c)=>o<>>64-c;function add$1(o,a,c,d){const tt=(a>>>0)+(d>>>0);return{h:o+c+(tt/2**32|0)|0,l:tt|0}}const add3L$1=(o,a,c)=>(o>>>0)+(a>>>0)+(c>>>0),add3H$1=(o,a,c,d)=>a+c+d+(o/2**32|0)|0,add4L$1=(o,a,c,d)=>(o>>>0)+(a>>>0)+(c>>>0)+(d>>>0),add4H$1=(o,a,c,d,tt)=>a+c+d+tt+(o/2**32|0)|0,add5L$1=(o,a,c,d,tt)=>(o>>>0)+(a>>>0)+(c>>>0)+(d>>>0)+(tt>>>0),add5H$1=(o,a,c,d,tt,nt)=>a+c+d+tt+nt+(o/2**32|0)|0,u64$1={fromBig:fromBig$2,split:split$8,toBig:toBig$1,shrSH:shrSH$1,shrSL:shrSL$1,rotrSH:rotrSH$1,rotrSL:rotrSL$1,rotrBH:rotrBH$1,rotrBL:rotrBL$1,rotr32H:rotr32H$1,rotr32L:rotr32L$1,rotlSH:rotlSH$2,rotlSL:rotlSL$2,rotlBH:rotlBH$2,rotlBL:rotlBL$2,add:add$1,add3L:add3L$1,add3H:add3H$1,add4L:add4L$1,add4H:add4H$1,add5H:add5H$1,add5L:add5L$1},[SHA512_Kh$1,SHA512_Kl$1]=u64$1.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(o=>BigInt(o))),SHA512_W_H$1=new Uint32Array(80),SHA512_W_L$1=new Uint32Array(80);let SHA512$4=class extends HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:a,Al:c,Bh:d,Bl:tt,Ch:nt,Cl:$a,Dh:Ys,Dl:gu,Eh:xu,El:$u,Fh:Iu,Fl:Xu,Gh:i0,Gl:p0,Hh:w0,Hl:A0}=this;return[a,c,d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0]}set(a,c,d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0){this.Ah=a|0,this.Al=c|0,this.Bh=d|0,this.Bl=tt|0,this.Ch=nt|0,this.Cl=$a|0,this.Dh=Ys|0,this.Dl=gu|0,this.Eh=xu|0,this.El=$u|0,this.Fh=Iu|0,this.Fl=Xu|0,this.Gh=i0|0,this.Gl=p0|0,this.Hh=w0|0,this.Hl=A0|0}process(a,c){for(let L0=0;L0<16;L0++,c+=4)SHA512_W_H$1[L0]=a.getUint32(c),SHA512_W_L$1[L0]=a.getUint32(c+=4);for(let L0=16;L0<80;L0++){const q0=SHA512_W_H$1[L0-15]|0,F0=SHA512_W_L$1[L0-15]|0,u1=u64$1.rotrSH(q0,F0,1)^u64$1.rotrSH(q0,F0,8)^u64$1.shrSH(q0,F0,7),g1=u64$1.rotrSL(q0,F0,1)^u64$1.rotrSL(q0,F0,8)^u64$1.shrSL(q0,F0,7),E1=SHA512_W_H$1[L0-2]|0,B1=SHA512_W_L$1[L0-2]|0,lv=u64$1.rotrSH(E1,B1,19)^u64$1.rotrBH(E1,B1,61)^u64$1.shrSH(E1,B1,6),j1=u64$1.rotrSL(E1,B1,19)^u64$1.rotrBL(E1,B1,61)^u64$1.shrSL(E1,B1,6),r1=u64$1.add4L(g1,j1,SHA512_W_L$1[L0-7],SHA512_W_L$1[L0-16]),t1=u64$1.add4H(r1,u1,lv,SHA512_W_H$1[L0-7],SHA512_W_H$1[L0-16]);SHA512_W_H$1[L0]=t1|0,SHA512_W_L$1[L0]=r1|0}let{Ah:d,Al:tt,Bh:nt,Bl:$a,Ch:Ys,Cl:gu,Dh:xu,Dl:$u,Eh:Iu,El:Xu,Fh:i0,Fl:p0,Gh:w0,Gl:A0,Hh:$0,Hl:O0}=this;for(let L0=0;L0<80;L0++){const q0=u64$1.rotrSH(Iu,Xu,14)^u64$1.rotrSH(Iu,Xu,18)^u64$1.rotrBH(Iu,Xu,41),F0=u64$1.rotrSL(Iu,Xu,14)^u64$1.rotrSL(Iu,Xu,18)^u64$1.rotrBL(Iu,Xu,41),u1=Iu&i0^~Iu&w0,g1=Xu&p0^~Xu&A0,E1=u64$1.add5L(O0,F0,g1,SHA512_Kl$1[L0],SHA512_W_L$1[L0]),B1=u64$1.add5H(E1,$0,q0,u1,SHA512_Kh$1[L0],SHA512_W_H$1[L0]),lv=E1|0,j1=u64$1.rotrSH(d,tt,28)^u64$1.rotrBH(d,tt,34)^u64$1.rotrBH(d,tt,39),r1=u64$1.rotrSL(d,tt,28)^u64$1.rotrBL(d,tt,34)^u64$1.rotrBL(d,tt,39),t1=d&nt^d&Ys^nt&Ys,D0=tt&$a^tt&gu^$a&gu;$0=w0|0,O0=A0|0,w0=i0|0,A0=p0|0,i0=Iu|0,p0=Xu|0,{h:Iu,l:Xu}=u64$1.add(xu|0,$u|0,B1|0,lv|0),xu=Ys|0,$u=gu|0,Ys=nt|0,gu=$a|0,nt=d|0,$a=tt|0;const Z0=u64$1.add3L(lv,r1,D0);d=u64$1.add3H(Z0,B1,j1,t1),tt=Z0|0}({h:d,l:tt}=u64$1.add(this.Ah|0,this.Al|0,d|0,tt|0)),{h:nt,l:$a}=u64$1.add(this.Bh|0,this.Bl|0,nt|0,$a|0),{h:Ys,l:gu}=u64$1.add(this.Ch|0,this.Cl|0,Ys|0,gu|0),{h:xu,l:$u}=u64$1.add(this.Dh|0,this.Dl|0,xu|0,$u|0),{h:Iu,l:Xu}=u64$1.add(this.Eh|0,this.El|0,Iu|0,Xu|0),{h:i0,l:p0}=u64$1.add(this.Fh|0,this.Fl|0,i0|0,p0|0),{h:w0,l:A0}=u64$1.add(this.Gh|0,this.Gl|0,w0|0,A0|0),{h:$0,l:O0}=u64$1.add(this.Hh|0,this.Hl|0,$0|0,O0|0),this.set(d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0,$0,O0)}roundClean(){SHA512_W_H$1.fill(0),SHA512_W_L$1.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sha512$3=wrapConstructor$1(()=>new SHA512$4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$f=BigInt(0),_1n$h=BigInt(1),_2n$c=BigInt(2);function isBytes$6(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function abytes(o){if(!isBytes$6(o))throw new Error("Uint8Array expected")}const hexes$2=Array.from({length:256},(o,a)=>a.toString(16).padStart(2,"0"));function bytesToHex$2(o){abytes(o);let a="";for(let c=0;c=asciis$1._0&&o<=asciis$1._9)return o-asciis$1._0;if(o>=asciis$1._A&&o<=asciis$1._F)return o-(asciis$1._A-10);if(o>=asciis$1._a&&o<=asciis$1._f)return o-(asciis$1._a-10)}function hexToBytes$3(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const a=o.length,c=a/2;if(a%2)throw new Error("padded hex string expected, got unpadded hex of length "+a);const d=new Uint8Array(c);for(let tt=0,nt=0;tt_0n$f;o>>=_1n$h,a+=1);return a}function bitGet$2(o,a){return o>>BigInt(a)&_1n$h}function bitSet$2(o,a,c){return o|(c?_1n$h:_0n$f)<(_2n$c<new Uint8Array(o),u8fr$2=o=>Uint8Array.from(o);function createHmacDrbg$2(o,a,c){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof a!="number"||a<2)throw new Error("qByteLen must be a number");if(typeof c!="function")throw new Error("hmacFn must be a function");let d=u8n$2(o),tt=u8n$2(o),nt=0;const $a=()=>{d.fill(1),tt.fill(0),nt=0},Ys=(...Iu)=>c(tt,d,...Iu),gu=(Iu=u8n$2())=>{tt=Ys(u8fr$2([0]),Iu),d=Ys(),Iu.length!==0&&(tt=Ys(u8fr$2([1]),Iu),d=Ys())},xu=()=>{if(nt++>=1e3)throw new Error("drbg: tried 1000 values");let Iu=0;const Xu=[];for(;Iu{$a(),gu(Iu);let i0;for(;!(i0=Xu(xu()));)gu();return $a(),i0}}const validatorFns$2={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||isBytes$6(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,a)=>a.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function validateObject$2(o,a,c={}){const d=(tt,nt,$a)=>{const Ys=validatorFns$2[nt];if(typeof Ys!="function")throw new Error(`Invalid validator "${nt}", expected function`);const gu=o[tt];if(!($a&&gu===void 0)&&!Ys(gu,o))throw new Error(`Invalid param ${String(tt)}=${gu} (${typeof gu}), expected ${nt}`)};for(const[tt,nt]of Object.entries(a))d(tt,nt,!1);for(const[tt,nt]of Object.entries(c))d(tt,nt,!0);return o}const ut$4=Object.freeze(Object.defineProperty({__proto__:null,abytes,bitGet:bitGet$2,bitLen:bitLen$2,bitMask:bitMask$2,bitSet:bitSet$2,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE$2,bytesToNumberLE:bytesToNumberLE$2,concatBytes:concatBytes$3,createHmacDrbg:createHmacDrbg$2,ensureBytes:ensureBytes$3,equalBytes:equalBytes$2,hexToBytes:hexToBytes$3,hexToNumber:hexToNumber$2,isBytes:isBytes$6,numberToBytesBE:numberToBytesBE$2,numberToBytesLE:numberToBytesLE$2,numberToHexUnpadded:numberToHexUnpadded$2,numberToVarBytesBE:numberToVarBytesBE$2,utf8ToBytes:utf8ToBytes$3,validateObject:validateObject$2},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$e=BigInt(0),_1n$g=BigInt(1),_2n$b=BigInt(2),_3n$4=BigInt(3),_4n$3=BigInt(4),_5n$3=BigInt(5),_8n$4=BigInt(8);BigInt(9);BigInt(16);function mod$2(o,a){const c=o%a;return c>=_0n$e?c:a+c}function pow$4(o,a,c){if(c<=_0n$e||a<_0n$e)throw new Error("Expected power/modulo > 0");if(c===_1n$g)return _0n$e;let d=_1n$g;for(;a>_0n$e;)a&_1n$g&&(d=d*o%c),o=o*o%c,a>>=_1n$g;return d}function pow2$1(o,a,c){let d=o;for(;a-- >_0n$e;)d*=d,d%=c;return d}function invert$2(o,a){if(o===_0n$e||a<=_0n$e)throw new Error(`invert: expected positive integers, got n=${o} mod=${a}`);let c=mod$2(o,a),d=a,tt=_0n$e,nt=_1n$g;for(;c!==_0n$e;){const Ys=d/c,gu=d%c,xu=tt-nt*Ys;d=c,c=gu,tt=nt,nt=xu}if(d!==_1n$g)throw new Error("invert: does not exist");return mod$2(tt,a)}function tonelliShanks$2(o){const a=(o-_1n$g)/_2n$b;let c,d,tt;for(c=o-_1n$g,d=0;c%_2n$b===_0n$e;c/=_2n$b,d++);for(tt=_2n$b;tt(mod$2(o,a)&_1n$g)===_1n$g,FIELD_FIELDS$2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField$2(o){const a={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},c=FIELD_FIELDS$2.reduce((d,tt)=>(d[tt]="function",d),a);return validateObject$2(o,c)}function FpPow$2(o,a,c){if(c<_0n$e)throw new Error("Expected power > 0");if(c===_0n$e)return o.ONE;if(c===_1n$g)return a;let d=o.ONE,tt=a;for(;c>_0n$e;)c&_1n$g&&(d=o.mul(d,tt)),tt=o.sqr(tt),c>>=_1n$g;return d}function FpInvertBatch$2(o,a){const c=new Array(a.length),d=a.reduce((nt,$a,Ys)=>o.is0($a)?nt:(c[Ys]=nt,o.mul(nt,$a)),o.ONE),tt=o.inv(d);return a.reduceRight((nt,$a,Ys)=>o.is0($a)?nt:(c[Ys]=o.mul(nt,c[Ys]),o.mul(nt,$a)),tt),c}function nLength$2(o,a){const c=a!==void 0?a:o.toString(2).length,d=Math.ceil(c/8);return{nBitLength:c,nByteLength:d}}function Field$2(o,a,c=!1,d={}){if(o<=_0n$e)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:tt,nByteLength:nt}=nLength$2(o,a);if(nt>2048)throw new Error("Field lengths over 2048 bytes are not supported");const $a=FpSqrt$2(o),Ys=Object.freeze({ORDER:o,BITS:tt,BYTES:nt,MASK:bitMask$2(tt),ZERO:_0n$e,ONE:_1n$g,create:gu=>mod$2(gu,o),isValid:gu=>{if(typeof gu!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof gu}`);return _0n$e<=gu&&gugu===_0n$e,isOdd:gu=>(gu&_1n$g)===_1n$g,neg:gu=>mod$2(-gu,o),eql:(gu,xu)=>gu===xu,sqr:gu=>mod$2(gu*gu,o),add:(gu,xu)=>mod$2(gu+xu,o),sub:(gu,xu)=>mod$2(gu-xu,o),mul:(gu,xu)=>mod$2(gu*xu,o),pow:(gu,xu)=>FpPow$2(Ys,gu,xu),div:(gu,xu)=>mod$2(gu*invert$2(xu,o),o),sqrN:gu=>gu*gu,addN:(gu,xu)=>gu+xu,subN:(gu,xu)=>gu-xu,mulN:(gu,xu)=>gu*xu,inv:gu=>invert$2(gu,o),sqrt:d.sqrt||(gu=>$a(Ys,gu)),invertBatch:gu=>FpInvertBatch$2(Ys,gu),cmov:(gu,xu,$u)=>$u?xu:gu,toBytes:gu=>c?numberToBytesLE$2(gu,nt):numberToBytesBE$2(gu,nt),fromBytes:gu=>{if(gu.length!==nt)throw new Error(`Fp.fromBytes: expected ${nt}, got ${gu.length}`);return c?bytesToNumberLE$2(gu):bytesToNumberBE$2(gu)}});return Object.freeze(Ys)}function FpSqrtEven$1(o,a){if(!o.isOdd)throw new Error("Field doesn't have isOdd");const c=o.sqrt(a);return o.isOdd(c)?o.neg(c):c}function getFieldBytesLength$2(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const a=o.toString(2).length;return Math.ceil(a/8)}function getMinHashLength$2(o){const a=getFieldBytesLength$2(o);return a+Math.ceil(a/2)}function mapHashToField$2(o,a,c=!1){const d=o.length,tt=getFieldBytesLength$2(a),nt=getMinHashLength$2(a);if(d<16||d1024)throw new Error(`expected ${nt}-1024 bytes of input, got ${d}`);const $a=c?bytesToNumberBE$2(o):bytesToNumberLE$2(o),Ys=mod$2($a,a-_1n$g)+_1n$g;return c?numberToBytesLE$2(Ys,tt):numberToBytesBE$2(Ys,tt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$d=BigInt(0),_1n$f=BigInt(1);function wNAF$2(o,a){const c=(tt,nt)=>{const $a=nt.negate();return tt?$a:nt},d=tt=>{const nt=Math.ceil(a/tt)+1,$a=2**(tt-1);return{windows:nt,windowSize:$a}};return{constTimeNegate:c,unsafeLadder(tt,nt){let $a=o.ZERO,Ys=tt;for(;nt>_0n$d;)nt&_1n$f&&($a=$a.add(Ys)),Ys=Ys.double(),nt>>=_1n$f;return $a},precomputeWindow(tt,nt){const{windows:$a,windowSize:Ys}=d(nt),gu=[];let xu=tt,$u=xu;for(let Iu=0;Iu<$a;Iu++){$u=xu,gu.push($u);for(let Xu=1;Xu>=i0,A0>gu&&(A0-=Xu,$a+=_1n$f);const $0=w0,O0=w0+Math.abs(A0)-1,L0=p0%2!==0,q0=A0<0;A0===0?$u=$u.add(c(L0,nt[$0])):xu=xu.add(c(q0,nt[O0]))}return{p:xu,f:$u}},wNAFCached(tt,nt,$a,Ys){const gu=tt._WINDOW_SIZE||1;let xu=nt.get(tt);return xu||(xu=this.precomputeWindow(tt,gu),gu!==1&&nt.set(tt,Ys(xu))),this.wNAF(gu,xu,$a)}}}function validateBasic$2(o){return validateField$2(o.Fp),validateObject$2(o,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength$2(o.n,o.nBitLength),...o,p:o.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$c=BigInt(0),_1n$e=BigInt(1),_2n$a=BigInt(2),_8n$3=BigInt(8),VERIFY_DEFAULT$1={zip215:!0};function validateOpts$6(o){const a=validateBasic$2(o);return validateObject$2(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...a})}function twistedEdwards$1(o){const a=validateOpts$6(o),{Fp:c,n:d,prehash:tt,hash:nt,randomBytes:$a,nByteLength:Ys,h:gu}=a,xu=_2n$a<{try{return{isValid:!0,value:c.sqrt(m1*c.inv(c1))}}catch{return{isValid:!1,value:_0n$c}}}),Xu=a.adjustScalarBytes||(m1=>m1),i0=a.domain||((m1,c1,G0)=>{if(c1.length||G0)throw new Error("Contexts/pre-hash are not supported");return m1}),p0=m1=>typeof m1=="bigint"&&_0n$cp0(m1)&&p0(c1)&&m1m1===_0n$c||w0(m1,xu);function $0(m1,c1){if(w0(m1,c1))return m1;throw new Error(`Expected valid scalar < ${c1}, got ${typeof m1} ${m1}`)}function O0(m1){return m1===_0n$c?m1:$0(m1,d)}const L0=new Map;function q0(m1){if(!(m1 instanceof F0))throw new Error("ExtendedPoint expected")}class F0{constructor(c1,G0,o1,d1){if(this.ex=c1,this.ey=G0,this.ez=o1,this.et=d1,!A0(c1))throw new Error("x required");if(!A0(G0))throw new Error("y required");if(!A0(o1))throw new Error("z required");if(!A0(d1))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(c1){if(c1 instanceof F0)throw new Error("extended point not allowed");const{x:G0,y:o1}=c1||{};if(!A0(G0)||!A0(o1))throw new Error("invalid affine point");return new F0(G0,o1,_1n$e,$u(G0*o1))}static normalizeZ(c1){const G0=c.invertBatch(c1.map(o1=>o1.ez));return c1.map((o1,d1)=>o1.toAffine(G0[d1])).map(F0.fromAffine)}_setWindowSize(c1){this._WINDOW_SIZE=c1,L0.delete(this)}assertValidity(){const{a:c1,d:G0}=a;if(this.is0())throw new Error("bad point: ZERO");const{ex:o1,ey:d1,ez:R1,et:O1}=this,Q1=$u(o1*o1),rv=$u(d1*d1),D1=$u(R1*R1),ev=$u(D1*D1),Mv=$u(Q1*c1),Zv=$u(D1*$u(Mv+rv)),fv=$u(ev+$u(G0*$u(Q1*rv)));if(Zv!==fv)throw new Error("bad point: equation left != right (1)");const cv=$u(o1*d1),ly=$u(R1*O1);if(cv!==ly)throw new Error("bad point: equation left != right (2)")}equals(c1){q0(c1);const{ex:G0,ey:o1,ez:d1}=this,{ex:R1,ey:O1,ez:Q1}=c1,rv=$u(G0*Q1),D1=$u(R1*d1),ev=$u(o1*Q1),Mv=$u(O1*d1);return rv===D1&&ev===Mv}is0(){return this.equals(F0.ZERO)}negate(){return new F0($u(-this.ex),this.ey,this.ez,$u(-this.et))}double(){const{a:c1}=a,{ex:G0,ey:o1,ez:d1}=this,R1=$u(G0*G0),O1=$u(o1*o1),Q1=$u(_2n$a*$u(d1*d1)),rv=$u(c1*R1),D1=G0+o1,ev=$u($u(D1*D1)-R1-O1),Mv=rv+O1,Zv=Mv-Q1,fv=rv-O1,cv=$u(ev*Zv),ly=$u(Mv*fv),Cy=$u(ev*fv),Ly=$u(Zv*Mv);return new F0(cv,ly,Ly,Cy)}add(c1){q0(c1);const{a:G0,d:o1}=a,{ex:d1,ey:R1,ez:O1,et:Q1}=this,{ex:rv,ey:D1,ez:ev,et:Mv}=c1;if(G0===BigInt(-1)){const vw=$u((R1-d1)*(D1+rv)),Hw=$u((R1+d1)*(D1-rv)),uw=$u(Hw-vw);if(uw===_0n$c)return this.double();const Nw=$u(O1*_2n$a*Mv),lw=$u(Q1*_2n$a*ev),Lw=lw+Nw,zw=Hw+vw,A2=lw-Nw,kv=$u(Lw*uw),Y1=$u(zw*A2),tv=$u(Lw*A2),Yv=$u(uw*zw);return new F0(kv,Y1,Yv,tv)}const Zv=$u(d1*rv),fv=$u(R1*D1),cv=$u(Q1*o1*Mv),ly=$u(O1*ev),Cy=$u((d1+R1)*(rv+D1)-Zv-fv),Ly=ly-cv,Hy=ly+cv,t2=$u(fv-G0*Zv),C2=$u(Cy*Ly),Dy=$u(Hy*t2),jw=$u(Cy*t2),pw=$u(Ly*Hy);return new F0(C2,Dy,pw,jw)}subtract(c1){return this.add(c1.negate())}wNAF(c1){return E1.wNAFCached(this,L0,c1,F0.normalizeZ)}multiply(c1){const{p:G0,f:o1}=this.wNAF($0(c1,d));return F0.normalizeZ([G0,o1])[0]}multiplyUnsafe(c1){let G0=O0(c1);return G0===_0n$c?g1:this.equals(g1)||G0===_1n$e?this:this.equals(u1)?this.wNAF(G0).p:E1.unsafeLadder(this,G0)}isSmallOrder(){return this.multiplyUnsafe(gu).is0()}isTorsionFree(){return E1.unsafeLadder(this,d).is0()}toAffine(c1){const{ex:G0,ey:o1,ez:d1}=this,R1=this.is0();c1==null&&(c1=R1?_8n$3:c.inv(d1));const O1=$u(G0*c1),Q1=$u(o1*c1),rv=$u(d1*c1);if(R1)return{x:_0n$c,y:_1n$e};if(rv!==_1n$e)throw new Error("invZ was invalid");return{x:O1,y:Q1}}clearCofactor(){const{h:c1}=a;return c1===_1n$e?this:this.multiplyUnsafe(c1)}static fromHex(c1,G0=!1){const{d:o1,a:d1}=a,R1=c.BYTES;c1=ensureBytes$3("pointHex",c1,R1);const O1=c1.slice(),Q1=c1[R1-1];O1[R1-1]=Q1&-129;const rv=bytesToNumberLE$2(O1);rv===_0n$c||(G0?$0(rv,xu):$0(rv,c.ORDER));const D1=$u(rv*rv),ev=$u(D1-_1n$e),Mv=$u(o1*D1-d1);let{isValid:Zv,value:fv}=Iu(ev,Mv);if(!Zv)throw new Error("Point.fromHex: invalid y coordinate");const cv=(fv&_1n$e)===_1n$e,ly=(Q1&128)!==0;if(!G0&&fv===_0n$c&&ly)throw new Error("Point.fromHex: x=0 and x_0=1");return ly!==cv&&(fv=$u(-fv)),F0.fromAffine({x:fv,y:rv})}static fromPrivateKey(c1){return j1(c1).point}toRawBytes(){const{x:c1,y:G0}=this.toAffine(),o1=numberToBytesLE$2(G0,c.BYTES);return o1[o1.length-1]|=c1&_1n$e?128:0,o1}toHex(){return bytesToHex$2(this.toRawBytes())}}F0.BASE=new F0(a.Gx,a.Gy,_1n$e,$u(a.Gx*a.Gy)),F0.ZERO=new F0(_0n$c,_1n$e,_1n$e,_0n$c);const{BASE:u1,ZERO:g1}=F0,E1=wNAF$2(F0,Ys*8);function B1(m1){return mod$2(m1,d)}function lv(m1){return B1(bytesToNumberLE$2(m1))}function j1(m1){const c1=Ys;m1=ensureBytes$3("private key",m1,c1);const G0=ensureBytes$3("hashed private key",nt(m1),2*c1),o1=Xu(G0.slice(0,c1)),d1=G0.slice(c1,2*c1),R1=lv(o1),O1=u1.multiply(R1),Q1=O1.toRawBytes();return{head:o1,prefix:d1,scalar:R1,point:O1,pointBytes:Q1}}function r1(m1){return j1(m1).pointBytes}function t1(m1=new Uint8Array,...c1){const G0=concatBytes$3(...c1);return lv(nt(i0(G0,ensureBytes$3("context",m1),!!tt)))}function D0(m1,c1,G0={}){m1=ensureBytes$3("message",m1),tt&&(m1=tt(m1));const{prefix:o1,scalar:d1,pointBytes:R1}=j1(c1),O1=t1(G0.context,o1,m1),Q1=u1.multiply(O1).toRawBytes(),rv=t1(G0.context,Q1,R1,m1),D1=B1(O1+rv*d1);O0(D1);const ev=concatBytes$3(Q1,numberToBytesLE$2(D1,c.BYTES));return ensureBytes$3("result",ev,Ys*2)}const Z0=VERIFY_DEFAULT$1;function f1(m1,c1,G0,o1=Z0){const{context:d1,zip215:R1}=o1,O1=c.BYTES;m1=ensureBytes$3("signature",m1,2*O1),c1=ensureBytes$3("message",c1),tt&&(c1=tt(c1));const Q1=bytesToNumberLE$2(m1.slice(O1,2*O1));let rv,D1,ev;try{rv=F0.fromHex(G0,R1),D1=F0.fromHex(m1.slice(0,O1),R1),ev=u1.multiplyUnsafe(Q1)}catch{return!1}if(!R1&&rv.isSmallOrder())return!1;const Mv=t1(d1,D1.toRawBytes(),rv.toRawBytes(),c1);return D1.add(rv.multiplyUnsafe(Mv)).subtract(ev).clearCofactor().equals(F0.ZERO)}return u1._setWindowSize(8),{CURVE:a,getPublicKey:r1,sign:D0,verify:f1,ExtendedPoint:F0,utils:{getExtendedPublicKey:j1,randomPrivateKey:()=>$a(c.BYTES),precompute(m1=8,c1=F0.BASE){return c1._setWindowSize(m1),c1.multiply(BigInt(3)),c1}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$d=BigInt(1),_2n$9=BigInt(2),_5n$2=BigInt(5),_10n=BigInt(10),_20n=BigInt(20),_40n=BigInt(40),_80n=BigInt(80);function ed25519_pow_2_252_3(o){const a=ED25519_P,d=o*o%a*o%a,tt=pow2$1(d,_2n$9,a)*d%a,nt=pow2$1(tt,_1n$d,a)*o%a,$a=pow2$1(nt,_5n$2,a)*nt%a,Ys=pow2$1($a,_10n,a)*$a%a,gu=pow2$1(Ys,_20n,a)*Ys%a,xu=pow2$1(gu,_40n,a)*gu%a,$u=pow2$1(xu,_80n,a)*xu%a,Iu=pow2$1($u,_80n,a)*xu%a,Xu=pow2$1(Iu,_10n,a)*$a%a;return{pow_p_5_8:pow2$1(Xu,_2n$9,a)*o%a,b2:d}}function adjustScalarBytes(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uvRatio(o,a){const c=ED25519_P,d=mod$2(a*a*a,c),tt=mod$2(d*d*a,c),nt=ed25519_pow_2_252_3(o*tt).pow_p_5_8;let $a=mod$2(o*d*nt,c);const Ys=mod$2(a*$a*$a,c),gu=$a,xu=mod$2($a*ED25519_SQRT_M1,c),$u=Ys===o,Iu=Ys===mod$2(-o,c),Xu=Ys===mod$2(-o*ED25519_SQRT_M1,c);return $u&&($a=gu),(Iu||Xu)&&($a=xu),isNegativeLE$1($a,c)&&($a=mod$2(-$a,c)),{isValid:$u||Iu,value:$a}}const Fp$2=Field$2(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fp$2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512$3,randomBytes:randomBytes$5,adjustScalarBytes,uvRatio},ed25519$1=twistedEdwards$1(ed25519Defaults);function ed25519_domain(o,a,c){if(a.length>255)throw new Error("Context is too big");return concatBytes$4(utf8ToBytes$4("SigEd25519 no Ed25519 collisions"),new Uint8Array([c?1:0,a.length]),a,o)}({...ed25519Defaults});({...ed25519Defaults});const ELL2_C1=(Fp$2.ORDER+BigInt(3))/BigInt(8);Fp$2.pow(_2n$9,ELL2_C1);Fp$2.sqrt(Fp$2.neg(Fp$2.ONE));(Fp$2.ORDER-BigInt(5))/BigInt(8);BigInt(486662);FpSqrtEven$1(Fp$2,Fp$2.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey$2(){const o=ed25519$1.utils.randomPrivateKey(),a=ed25519$1.getPublicKey(o);return{privateKey:concatKeys(o,a),publicKey:a}}function generateKeyFromSeed(o){if(o.length!==KEYS_BYTE_LENGTH)throw new TypeError('"seed" must be 32 bytes in length.');if(!(o instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const a=o,c=ed25519$1.getPublicKey(a);return{privateKey:concatKeys(a,c),publicKey:c}}function hashAndSign$2(o,a){const c=o.subarray(0,KEYS_BYTE_LENGTH);return ed25519$1.sign(a instanceof Uint8Array?a:a.subarray(),c)}function hashAndVerify$2(o,a,c){return ed25519$1.verify(a,c instanceof Uint8Array?c:c.subarray(),o)}function concatKeys(o,a){const c=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let d=0;dNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(o,a,c=0){switch(encodingLength(o)){case 8:a[c++]=o&255|MSB,o/=128;case 7:a[c++]=o&255|MSB,o/=128;case 6:a[c++]=o&255|MSB,o/=128;case 5:a[c++]=o&255|MSB,o/=128;case 4:a[c++]=o&255|MSB,o>>>=7;case 3:a[c++]=o&255|MSB,o>>>=7;case 2:a[c++]=o&255|MSB,o>>>=7;case 1:{a[c++]=o&255,o>>>=7;break}default:throw new Error("unreachable")}return a}function decodeUint8Array(o,a){let c=o[a],d=0;if(d+=c&REST,c>>31>0){const c=~this.lo+1>>>0;let d=~this.hi>>>0;return c===0&&(d=d+1>>>0),-(c+d*4294967296)}return this.lo+this.hi*4294967296}toBigInt(a=!1){if(a)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const c=~this.lo+1>>>0;let d=~this.hi>>>0;return c===0&&(d=d+1>>>0),-(BigInt(c)+(BigInt(d)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(a=!1){return this.toBigInt(a).toString()}zzEncode(){const a=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^a)>>>0,this.lo=(this.lo<<1^a)>>>0,this}zzDecode(){const a=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^a)>>>0,this.hi=(this.hi>>>1^a)>>>0,this}length(){const a=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return d===0?c===0?a<16384?a<128?1:2:a<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:d<128?9:10}static fromBigInt(a){if(a===0n)return zero$2;if(aMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(a));const c=a<0n;c&&(a=-a);let d=a>>32n,tt=a-(d<<32n);return c&&(d=~d|0n,tt=~tt|0n,++tt>TWO_32&&(tt=0n,++d>TWO_32&&(d=0n))),new LongBits(Number(tt),Number(d))}static fromNumber(a){if(a===0)return zero$2;const c=a<0;c&&(a=-a);let d=a>>>0,tt=(a-d)/4294967296>>>0;return c&&(tt=~tt>>>0,d=~d>>>0,++d>4294967295&&(d=0,++tt>4294967295&&(tt=0))),new LongBits(d,tt)}static from(a){return typeof a=="number"?LongBits.fromNumber(a):typeof a=="bigint"?LongBits.fromBigInt(a):typeof a=="string"?LongBits.fromBigInt(BigInt(a)):a.low!=null||a.high!=null?new LongBits(a.low>>>0,a.high>>>0):zero$2}}const zero$2=new LongBits(0,0);zero$2.toBigInt=function(){return 0n};zero$2.zzEncode=zero$2.zzDecode=function(){return this};zero$2.length=function(){return 1};const TWO_32=4294967296n;function length$1(o){let a=0,c=0;for(let d=0;d191&&Ys<224?nt[$a++]=(Ys&31)<<6|o[a++]&63:Ys>239&&Ys<365?(Ys=((Ys&7)<<18|(o[a++]&63)<<12|(o[a++]&63)<<6|o[a++]&63)-65536,nt[$a++]=55296+(Ys>>10),nt[$a++]=56320+(Ys&1023)):nt[$a++]=(Ys&15)<<12|(o[a++]&63)<<6|o[a++]&63,$a>8191&&((tt??(tt=[])).push(String.fromCharCode.apply(String,nt)),$a=0);return tt!=null?($a>0&&tt.push(String.fromCharCode.apply(String,nt.slice(0,$a))),tt.join("")):String.fromCharCode.apply(String,nt.slice(0,$a))}function write$1(o,a,c){const d=c;let tt,nt;for(let $a=0;$a>6|192,a[c++]=tt&63|128):(tt&64512)===55296&&((nt=o.charCodeAt($a+1))&64512)===56320?(tt=65536+((tt&1023)<<10)+(nt&1023),++$a,a[c++]=tt>>18|240,a[c++]=tt>>12&63|128,a[c++]=tt>>6&63|128,a[c++]=tt&63|128):(a[c++]=tt>>12|224,a[c++]=tt>>6&63|128,a[c++]=tt&63|128);return c-d}function indexOutOfRange(o,a){return RangeError(`index out of range: ${o.pos} + ${a??1} > ${o.len}`)}function readFixed32End(o,a){return(o[a-4]|o[a-3]<<8|o[a-2]<<16|o[a-1]<<24)>>>0}class Uint8ArrayReader{constructor(a){aw(this,"buf");aw(this,"pos");aw(this,"len");aw(this,"_slice",Uint8Array.prototype.subarray);this.buf=a,this.pos=0,this.len=a.length}uint32(){let a=4294967295;if(a=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(a=(a|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return a;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return a}int32(){return this.uint32()|0}sint32(){const a=this.uint32();return a>>>1^-(a&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);const a=readFloatLE(this.buf,this.pos);return this.pos+=4,a}double(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);const a=readDoubleLE(this.buf,this.pos);return this.pos+=8,a}bytes(){const a=this.uint32(),c=this.pos,d=this.pos+a;if(d>this.len)throw indexOutOfRange(this,a);return this.pos+=a,c===d?new Uint8Array(0):this.buf.subarray(c,d)}string(){const a=this.bytes();return read$1(a,0,a.length)}skip(a){if(typeof a=="number"){if(this.pos+a>this.len)throw indexOutOfRange(this,a);this.pos+=a}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this}skipType(a){switch(a){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(a=this.uint32()&7)!==4;)this.skipType(a);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${a} at offset ${this.pos}`)}return this}readLongVarint(){const a=new LongBits(0,0);let c=0;if(this.len-this.pos>4){for(;c<4;++c)if(a.lo=(a.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a;if(a.lo=(a.lo|(this.buf[this.pos]&127)<<28)>>>0,a.hi=(a.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return a;c=0}else{for(;c<3;++c){if(this.pos>=this.len)throw indexOutOfRange(this);if(a.lo=(a.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}return a.lo=(a.lo|(this.buf[this.pos++]&127)<>>0,a}if(this.len-this.pos>4){for(;c<5;++c)if(a.hi=(a.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}else for(;c<5;++c){if(this.pos>=this.len)throw indexOutOfRange(this);if(a.hi=(a.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);const a=readFixed32End(this.buf,this.pos+=4),c=readFixed32End(this.buf,this.pos+=4);return new LongBits(a,c)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const a=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength(a),a}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function createReader(o){return new Uint8ArrayReader(o instanceof Uint8Array?o:o.subarray())}function decodeMessage(o,a,c){const d=createReader(o);return a.decode(d,void 0,c)}function pool(o){let d,tt=8192;return function($a){if($a<1||$a>4096)return allocUnsafe($a);tt+$a>8192&&(d=allocUnsafe(8192),tt=0);const Ys=d.subarray(tt,tt+=$a);return tt&7&&(tt=(tt|7)+1),Ys}}let Op$1=class{constructor(a,c,d){aw(this,"fn");aw(this,"len");aw(this,"next");aw(this,"val");this.fn=a,this.len=c,this.next=void 0,this.val=d}};function noop$b(){}class State{constructor(a){aw(this,"head");aw(this,"tail");aw(this,"len");aw(this,"next");this.head=a.head,this.tail=a.tail,this.len=a.len,this.next=a.states}}const bufferPool=pool();function alloc$1(o){return globalThis.Buffer!=null?allocUnsafe(o):bufferPool(o)}class Uint8ArrayWriter{constructor(){aw(this,"len");aw(this,"head");aw(this,"tail");aw(this,"states");this.len=0,this.head=new Op$1(noop$b,0,0),this.tail=this.head,this.states=null}_push(a,c,d){return this.tail=this.tail.next=new Op$1(a,c,d),this.len+=c,this}uint32(a){return this.len+=(this.tail=this.tail.next=new VarintOp((a=a>>>0)<128?1:a<16384?2:a<2097152?3:a<268435456?4:5,a)).len,this}int32(a){return a<0?this._push(writeVarint64,10,LongBits.fromNumber(a)):this.uint32(a)}sint32(a){return this.uint32((a<<1^a>>31)>>>0)}uint64(a){const c=LongBits.fromBigInt(a);return this._push(writeVarint64,c.length(),c)}uint64Number(a){return this._push(encodeUint8Array,encodingLength(a),a)}uint64String(a){return this.uint64(BigInt(a))}int64(a){return this.uint64(a)}int64Number(a){return this.uint64Number(a)}int64String(a){return this.uint64String(a)}sint64(a){const c=LongBits.fromBigInt(a).zzEncode();return this._push(writeVarint64,c.length(),c)}sint64Number(a){const c=LongBits.fromNumber(a).zzEncode();return this._push(writeVarint64,c.length(),c)}sint64String(a){return this.sint64(BigInt(a))}bool(a){return this._push(writeByte,1,a?1:0)}fixed32(a){return this._push(writeFixed32,4,a>>>0)}sfixed32(a){return this.fixed32(a)}fixed64(a){const c=LongBits.fromBigInt(a);return this._push(writeFixed32,4,c.lo)._push(writeFixed32,4,c.hi)}fixed64Number(a){const c=LongBits.fromNumber(a);return this._push(writeFixed32,4,c.lo)._push(writeFixed32,4,c.hi)}fixed64String(a){return this.fixed64(BigInt(a))}sfixed64(a){return this.fixed64(a)}sfixed64Number(a){return this.fixed64Number(a)}sfixed64String(a){return this.fixed64String(a)}float(a){return this._push(writeFloatLE,4,a)}double(a){return this._push(writeDoubleLE,8,a)}bytes(a){const c=a.length>>>0;return c===0?this._push(writeByte,1,0):this.uint32(c)._push(writeBytes,c,a)}string(a){const c=length$1(a);return c!==0?this.uint32(c)._push(write$1,c,a):this._push(writeByte,1,0)}fork(){return this.states=new State(this),this.head=this.tail=new Op$1(noop$b,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op$1(noop$b,0,0),this.len=0),this}ldelim(){const a=this.head,c=this.tail,d=this.len;return this.reset().uint32(d),d!==0&&(this.tail.next=a.next,this.tail=c,this.len+=d),this}finish(){let a=this.head.next;const c=alloc$1(this.len);let d=0;for(;a!=null;)a.fn(a.val,c,d),d+=a.len,a=a.next;return c}}function writeByte(o,a,c){a[c]=o&255}function writeVarint32(o,a,c){for(;o>127;)a[c++]=o&127|128,o>>>=7;a[c]=o}class VarintOp extends Op$1{constructor(c,d){super(writeVarint32,c,d);aw(this,"next");this.next=void 0}}function writeVarint64(o,a,c){for(;o.hi!==0;)a[c++]=o.lo&127|128,o.lo=(o.lo>>>7|o.hi<<25)>>>0,o.hi>>>=7;for(;o.lo>127;)a[c++]=o.lo&127|128,o.lo=o.lo>>>7;a[c++]=o.lo}function writeFixed32(o,a,c){a[c]=o&255,a[c+1]=o>>>8&255,a[c+2]=o>>>16&255,a[c+3]=o>>>24}function writeBytes(o,a,c){a.set(o,c)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(o){const a=o.length>>>0;return this.uint32(a),a>0&&this._push(writeBytesBuffer,a,o),this},Uint8ArrayWriter.prototype.string=function(o){const a=globalThis.Buffer.byteLength(o);return this.uint32(a),a>0&&this._push(writeStringBuffer,a,o),this});function writeBytesBuffer(o,a,c){a.set(o,c)}function writeStringBuffer(o,a,c){o.length<40?write$1(o,a,c):a.utf8Write!=null?a.utf8Write(o,c):a.set(fromString(o),c)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(o,a){const c=createWriter();return a.encode(o,c,{lengthDelimited:!1}),c.finish()}var CODEC_TYPES;(function(o){o[o.VARINT=0]="VARINT",o[o.BIT64=1]="BIT64",o[o.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",o[o.START_GROUP=3]="START_GROUP",o[o.END_GROUP=4]="END_GROUP",o[o.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(o,a,c,d){return{name:o,type:a,encode:c,decode:d}}function enumeration(o){function a(tt){if(o[tt.toString()]==null)throw new Error("Invalid enum value");return o[tt]}const c=function(nt,$a){const Ys=a(nt);$a.int32(Ys)},d=function(nt){const $a=nt.int32();return a($a)};return createCodec("enum",CODEC_TYPES.VARINT,c,d)}function message(o,a){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,o,a)}var KeyType;(function(o){o.RSA="RSA",o.Ed25519="Ed25519",o.Secp256k1="Secp256k1"})(KeyType||(KeyType={}));var __KeyTypeValues;(function(o){o[o.RSA=0]="RSA",o[o.Ed25519=1]="Ed25519",o[o.Secp256k1=2]="Secp256k1"})(__KeyTypeValues||(__KeyTypeValues={}));(function(o){o.codec=()=>enumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey$2;(function(o){let a;o.codec=()=>(a==null&&(a=message((c,d,tt={})=>{tt.lengthDelimited!==!1&&d.fork(),c.Type!=null&&(d.uint32(8),KeyType.codec().encode(c.Type,d)),c.Data!=null&&(d.uint32(18),d.bytes(c.Data)),tt.lengthDelimited!==!1&&d.ldelim()},(c,d)=>{const tt={},nt=d==null?c.len:c.pos+d;for(;c.pos>>3){case 1:tt.Type=KeyType.codec().decode(c);break;case 2:tt.Data=c.bytes();break;default:c.skipType($a&7);break}}return tt})),a),o.encode=c=>encodeMessage(c,o.codec()),o.decode=c=>decodeMessage(c,o.codec())})(PublicKey$2||(PublicKey$2={}));var PrivateKey;(function(o){let a;o.codec=()=>(a==null&&(a=message((c,d,tt={})=>{tt.lengthDelimited!==!1&&d.fork(),c.Type!=null&&(d.uint32(8),KeyType.codec().encode(c.Type,d)),c.Data!=null&&(d.uint32(18),d.bytes(c.Data)),tt.lengthDelimited!==!1&&d.ldelim()},(c,d)=>{const tt={},nt=d==null?c.len:c.pos+d;for(;c.pos>>3){case 1:tt.Type=KeyType.codec().decode(c);break;case 2:tt.Data=c.bytes();break;default:c.skipType($a&7);break}}return tt})),a),o.encode=c=>encodeMessage(c,o.codec()),o.decode=c=>decodeMessage(c,o.codec())})(PrivateKey||(PrivateKey={}));class Ed25519PublicKey{constructor(a){aw(this,"_key");this._key=ensureKey(a,PUBLIC_KEY_BYTE_LENGTH)}verify(a,c){return hashAndVerify$2(this._key,c,a)}marshal(){return this._key}get bytes(){return PublicKey$2.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}}class Ed25519PrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=ensureKey(a,PRIVATE_KEY_BYTE_LENGTH),this._publicKey=ensureKey(c,PUBLIC_KEY_BYTE_LENGTH)}sign(a){return hashAndSign$2(this._key,a)}get public(){return new Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}async hash(){const a=sha256$6.digest(this.bytes);let c;return isPromise(a)?{bytes:c}=await a:c=a.bytes,c}async id(){const a=identity$2.digest(this.public.bytes);return base58btc.encode(a.bytes).substring(1)}async export(a,c="libp2p-key"){if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalEd25519PrivateKey(o){if(o.length>PRIVATE_KEY_BYTE_LENGTH){o=ensureKey(o,PRIVATE_KEY_BYTE_LENGTH+PUBLIC_KEY_BYTE_LENGTH);const d=o.subarray(0,PRIVATE_KEY_BYTE_LENGTH),tt=o.subarray(PRIVATE_KEY_BYTE_LENGTH,o.length);return new Ed25519PrivateKey(d,tt)}o=ensureKey(o,PRIVATE_KEY_BYTE_LENGTH);const a=o.subarray(0,PRIVATE_KEY_BYTE_LENGTH),c=o.subarray(PUBLIC_KEY_BYTE_LENGTH);return new Ed25519PrivateKey(a,c)}function unmarshalEd25519PublicKey(o){return o=ensureKey(o,PUBLIC_KEY_BYTE_LENGTH),new Ed25519PublicKey(o)}async function generateKeyPair$3(){const{privateKey:o,publicKey:a}=generateKey$2();return new Ed25519PrivateKey(o,a)}async function generateKeyPairFromSeed(o){const{privateKey:a,publicKey:c}=generateKeyFromSeed(o);return new Ed25519PrivateKey(a,c)}function ensureKey(o,a){if(o=Uint8Array.from(o??[]),o.length!==a)throw new CodeError(`Key must be a Uint8Array of length ${a}, got ${o.length}`,"ERR_INVALID_KEY_TYPE");return o}const Ed25519=Object.freeze(Object.defineProperty({__proto__:null,Ed25519PrivateKey,Ed25519PublicKey,generateKeyPair:generateKeyPair$3,generateKeyPairFromSeed,unmarshalEd25519PrivateKey,unmarshalEd25519PublicKey},Symbol.toStringTag,{value:"Module"}));function toString$b(o,a="utf8"){const c=BASES[a];if(c==null)throw new Error(`Unsupported encoding "${a}"`);return c.encoder.encode(o).substring(1)}function randomBytes$4(o){if(isNaN(o)||o<=0)throw new CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return randomBytes$5(o)}let HMAC$1=class extends Hash$9{constructor(a,c){super(),this.finished=!1,this.destroyed=!1,hash$a(a);const d=toBytes$1(c);if(this.iHash=a.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const tt=this.blockLen,nt=new Uint8Array(tt);nt.set(d.length>tt?a.create().update(d).digest():d);for(let $a=0;$anew HMAC$1(o,a).update(c).digest();hmac$2.create=(o,a)=>new HMAC$1(o,a);function pbkdf2Init(o,a,c,d){hash$a(o);const tt=checkOpts({dkLen:32,asyncTick:10},d),{c:nt,dkLen:$a,asyncTick:Ys}=tt;if(number$3(nt),number$3($a),number$3(Ys),nt<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const gu=toBytes$1(a),xu=toBytes$1(c),$u=new Uint8Array($a),Iu=hmac$2.create(o,gu),Xu=Iu._cloneInto().update(xu);return{c:nt,dkLen:$a,asyncTick:Ys,DK:$u,PRF:Iu,PRFSalt:Xu}}function pbkdf2Output(o,a,c,d,tt){return o.destroy(),a.destroy(),d&&d.destroy(),tt.fill(0),c}async function pbkdf2Async(o,a,c,d){const{c:tt,dkLen:nt,asyncTick:$a,DK:Ys,PRF:gu,PRFSalt:xu}=pbkdf2Init(o,a,c,d);let $u;const Iu=new Uint8Array(4),Xu=createView$1(Iu),i0=new Uint8Array(gu.outputLen);for(let p0=1,w0=0;w0{gu._cloneInto($u).update(i0).digestInto(i0);for(let $0=0;$0{delete nt[p0]}),c.headers=AxiosHeaders$1.concat($a,nt);const Ys=[];let gu=!0;this.interceptors.request.forEach(function(w0){typeof w0.runWhen=="function"&&w0.runWhen(c)===!1||(gu=gu&&w0.synchronous,Ys.unshift(w0.fulfilled,w0.rejected))});const xu=[];this.interceptors.response.forEach(function(w0){xu.push(w0.fulfilled,w0.rejected)});let $u,Iu=0,Xu;if(!gu){const p0=[dispatchRequest.bind(this),void 0];for(p0.unshift.apply(p0,Ys),p0.push.apply(p0,xu),Xu=p0.length,$u=Promise.resolve(c);Iu{if(!d._listeners)return;let nt=d._listeners.length;for(;nt-- >0;)d._listeners[nt](tt);d._listeners=null}),this.promise.then=tt=>{let nt;const $a=new Promise(Ys=>{d.subscribe(Ys),nt=Ys}).then(tt);return $a.cancel=function(){d.unsubscribe(nt)},$a},a(function(nt,$a,Ys){d.reason||(d.reason=new CanceledError$1(nt,$a,Ys),c(d.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const c=this._listeners.indexOf(a);c!==-1&&this._listeners.splice(c,1)}static source(){let a;return{token:new Ive(function(tt){a=tt}),cancel:a}}};function spread$1(o){return function(c){return o.apply(null,c)}}function isAxiosError$1(o){return utils$A.isObject(o)&&o.isAxiosError===!0}const HttpStatusCode$1={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(HttpStatusCode$1).forEach(([o,a])=>{HttpStatusCode$1[a]=o});function createInstance(o){const a=new Axios$1(o),c=bind$f(Axios$1.prototype.request,a);return utils$A.extend(c,Axios$1.prototype,a,{allOwnKeys:!0}),utils$A.extend(c,a,null,{allOwnKeys:!0}),c.create=function(tt){return createInstance(mergeConfig$1(o,tt))},c}const axios=createInstance(defaults$1);axios.Axios=Axios$1;axios.CanceledError=CanceledError$1;axios.CancelToken=CancelToken$1;axios.isCancel=isCancel$1;axios.VERSION=VERSION$2;axios.toFormData=toFormData$1;axios.AxiosError=AxiosError$1;axios.Cancel=axios.CanceledError;axios.all=function(a){return Promise.all(a)};axios.spread=spread$1;axios.isAxiosError=isAxiosError$1;axios.mergeConfig=mergeConfig$1;axios.AxiosHeaders=AxiosHeaders$1;axios.formToJSON=o=>formDataToJSON(utils$A.isHTMLForm(o)?new FormData(o):o);axios.getAdapter=adapters.getAdapter;axios.HttpStatusCode=HttpStatusCode$1;axios.default=axios;const{Axios,AxiosError,CanceledError,isCancel,CancelToken,VERSION:VERSION$1,all:all$1,Cancel,isAxiosError,spread,toFormData,AxiosHeaders,HttpStatusCode,formToJSON,getAdapter,mergeConfig}=axios;class AxiosHttpClient{constructor(a,c){aw(this,"axios");aw(this,"showServerDownPopup");this.axios=a,this.showServerDownPopup=c,this.axios.interceptors.response.use(d=>d,d=>{var tt;return((tt=d.response)==null?void 0:tt.status)===401&&(window.location.href="/admin-dashboard/"),d.response||this.showServerDownPopup(),Promise.reject(d)})}async get(a,c={}){return this.request(this.axios.get(a,{headers:c}))}async post(a,c,d={}){return this.request(this.axios.post(a,c,{headers:d}))}async put(a,c,d={}){return this.request(this.axios.put(a,c,{headers:d}))}async delete(a,c={}){return this.request(this.axios.delete(a,{headers:c}))}async patch(a,c,d={}){return this.request(this.axios.patch(a,c,{headers:d}))}async head(a,c={}){return this.request(this.axios.head(a,{headers:c}))}async request(a){var c,d,tt;try{const nt=await a;return nt.config.method.toUpperCase()==="HEAD"?{data:void 0}:nt.data}catch(nt){if(nt instanceof AxiosError){if(((d=(c=nt.config)==null?void 0:c.method)==null?void 0:d.toUpperCase())==="HEAD")return{error:{code:nt.request.status,message:nt.message}};const $a=(tt=nt.response)==null?void 0:tt.data,Ys=$a.error;return!$a&&(!Ys||!Ys.message||!Ys.code)?{error:GENERIC_ERROR}:typeof $a=="string"?{error:{code:nt.request.status,message:$a}}:typeof Ys=="string"?{error:{code:nt.request.status,message:Ys}}:{error:{code:(Ys==null?void 0:Ys.code)||nt.request.status,message:Ys==null?void 0:Ys.message}}}return{error:GENERIC_ERROR}}}}const GENERIC_ERROR={code:500,message:"Something went wrong"},useMetamask$1={requestNodeDataError:"Error while requesting node data",noSignatureError:"Signature is empty",noAddressError:"Address is empty",loginError:"Error while login",rootkeyError:"Error while adding root key",applicationNameText:"admin-dashboard"},useNear$1={verifyMessageError:"Error while verifying message",missingUrlParamsError:"Missing url parameters",loginError:"Error while login",rootkeyError:"Error while adding root key",messageNotVerifiedError:"Message not verified",signMessageError:"Error while signing message",signOutError:"Failed to signing out"},useStarknet$1={requestNodeDataError:"Error while requesting node data",noSignatureError:"Signature is empty",noAddressError:"Address is empty",loginError:"Error while login",rootkeyError:"Error while adding root key",applicationNameText:"admin-dashboard",signMessageError:"Error while signing message",signOutError:"Failed to signing out",errorChangingNetwork:"Error changing network",walletNotFound:"Wallet not found",errorLogin:"Error while login"},useIcp$1={requestNodeDataError:"Error while requesting node data",errorChangingNetwork:"Error changing network",loginError:"Error while login",rootkeyError:"Error while adding root key",signMessageError:"Error while signing message"},loginPage={logoDashboardText:"Admin Dashboard",title:"Calimero Node Admin Dashboard",subtitle:"Start using Calimero by selecting your wallet.",buttonConnectText:"Connect Wallet",loginSelector:{title:"Continue with wallet",metamaskButtonText:"Metamask wallet",nearButtonText:"Near wallet",starknetButtonText:"Starknet wallet",IcpButtonText:"Internet Computer"},nearLogin:{title:"Login with NEAR",subtitle:"Choose which account from your wallet you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector"},IcpLogin:{title:"Login with Internet Identity",subtitle:"Choose from which account you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",currentNetwork:"Current network",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backToLoginPage:"Back to login page"},metamaskLogin:{titleLogin:"Login with Metamask",titleRootKey:"Add Metamask root key",subtitle:"Choose which account from your wallet you want to log in with",authButtonText:"Sign authentication transaction",errorTitleText:"Error signing message",backButtonText:"Back to wallet selector"},starknetLogin:{title:"Login with Starknet",subtitle:"Choose which account from your wallet you want to log in with",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Authenticate",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector",argentXButton:"Login with ArgentX",metamaskButton:"Login with MetaMask",titleRootKey:"Add Starknet root key",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",backToLoginPage:"Back to login selector"}},addRootKeyPage={nearRootKey:{title:"Add NEAR root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",switchWalletButtonText:"Switch Wallet",authButtonText:"Add root key",switchAccountButtonText:"Switch Account",backButtonText:"Back to wallet selector"},starknetRootKey:{title:"Add Starknet root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",argentXButton:"Add root key with ArgentX",metamaskButton:"Add root key with MetaMask",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",backToLoginPage:"Back to login selector"},IcpKey:{title:"Add Internet Identity root key",subtitle:"Choose which account from your wallet you want to add a node root key for. Each key, and therefore each account, can only be added once",accountIdText:"Account Id",logoutButtonText:"Logout",currentNetwork:"Current network",signMessage:"Sign authentication message",backToWalletSelector:"Back to wallet selector",authButtonText:"Add root key",backToLoginPage:"Back to login selector"}},footer={title:"Calimero Network"},navigation={logoDashboardText:"Admin Dashboard",pkTest:"Public Key"},applicationsPage={applicationsTable:{title:"Applications",publishNewAppText:"Publish new application",noAvailableAppsText:"No applications available",noAvailableReleasesText:"No available releases",noInstalledAppsText:"No installed applications",noOwnedAppsText:"No owned applications",installNewAppText:"install new application",actionDialog:{title:"Uninstall Application",subtitle:"Are you sure you want to uninstall this application? This action cannot be undone.",buttonActionText:"Uninstall"}},installApplication:{title:"Install Application",backButtonText:"Back to Applications",selectAppLabel:"Select Application to Install",dropdownPlaceholder:"Applications",packageDetailsLabel:"Package Details",releaseSelectionLabel:"Select Application Release",releaseDetailsLabel:"Release Details",installErrorTitle:"Failed to install application",selectApplicationTitle:"Select app from the marketplace or publish new application",selectedApplicationTitle:"Selected Application",installButtonText:"Install application",idLabelText:"Application ID: ",nameLabelText:"Application Name: ",versionLabelText:"Version: ",failInstallTitle:"Error installing application",successInstallTitle:"Application installed successfully"},publishApplication:{title:"Publish new application",addAccountButtonText:"Add wallet account",connectAccountTitle:"Connect owner account",connectAccountSubtitle:"Owner account is holder of application and only that account can publish new releases.",connectAccountButtonText:"Connect account",buttonText:"Publish"},addRelease:{title:"Add new release",buttonText:"Publish",latestReleaseText:"Latest application version is : "}},confirmWallet={logoText:"Admin Dashboard",title:"Confirm Wallet",accountIdText:"Account Id",signatureText:"Signature",publicKeyText:"PublicKey",callbackUrlText:"Callback Url",submitButtonText:"Submit Request",backButtonText:"Back to login"},keysPage={title:"Keys"},keysTable={noKeysText:"No keys found in the node.",headerPkText:"Public Key",headerTypeText:"Type",badgeActiveText:"Active",badgeRevokedText:"Revoked",setActiveText:"Set Active",revokeKeyText:"Revoke Key",addNewText:"Add new Key"},uploadPage={title:"Upload Application",walletButtonText:"Add wallet account",switchPackageText:"Add Package",switchReleaseText:"Add Release"},uploadApplication={title:"Add Release",subtitle:"To install the application first upload the application wasm to the IPFS, select the package you want to add the release for and fill the release details.",uploadIpfsTitle:"IPFS Application upload",inputLabelText:"Select Application .wasm file to upload",buttonUploadLabel:"Upload wasm",buttonUploadText:"Upload",cidLabelText:"File IPFS CID",backButtonText:"Back",releaseTitle:"Add new release",nameLabelText:"Name",pathLabelText:"Path",versionLabelText:"Version",notesLabelText:"Notes",hashLabelText:"Hash",buttonAddReleaseText:"Add Release",versionPlaceholder:"1.0.0",notesPlaceholder:"Initial release",hashPlaceholder:"QmZ3Z8Q7QmZ3Z8Q7QmZ3Z8Q7QmZ3Z8Q7",addReleaseButtonText:"Add Release",loginLableText:"To Deploy new release, you need to sign in using wallet account button!",deployerDropdownlabel:"Select deployer account",deployerDropdownText:"Deployer Account",selectPackageLabel:"Select Package",pathPlaceholder:"url to the wasm file"},addPackageForm={title:"Add application details",subtitle:"To successfully install the application, first you need to add the package details and procceed to add relase.",nameLabelText:"Package Name",repositoryLabelText:"Repository URL",descriptionLabelText:"Description",buttonAddPackageText:"Add Package",buttonNextText:"Next",namePlaceholder:"chat-application",repositoryPlaceholder:"https://github.com/",descriptionPlaceholder:"A chat application built for P2P network",loginLableText:"To Deploy new package, you need to sign in using wallet account button!",deployerDropdownlabel:"Select deployer account",deployerDropdownText:"Deployer Account"},statusModal={buttonContinueText:"Continue",buttonDeleteText:"Delete",buttonCopyText:"Copy",buttonCloseText:"Close",buttonCancelText:"Cancel"},contextPage={contextPageTitle:"Contexts",startNewContextText:"Start new context",joinContextText:"Join existing context",noContextsText:"No contexts found in the node.",contextPageDescription:"Contexts are the core of the Calimero ecosystem. These are application specific networks designed to enable direct communication between users, eliminating the need for intermediaries.",invitedListDescription:"Contexts you have been invited to",noJoinedAppsListText:"You have not joined any contexts.",noInviedAppsListText:"You have not been invited to any contexts.",devApplicationTitle:"Development application",deleteContextText:"Delete Context",contextDetails:{title:"Context Details",clientKeysListDescription:"Client keys are authorization keys used by the application frontend.",noClientKeysText:"No data found.",noUsersText:"No users found in the context.",labelIdText:"Id: ",labelNameText:"Name: ",labelOwnerText:"Owner: ",labelDescriptionText:"Description: ",labelRepositoryText:"Repository URL: ",lableVersionText:"Version: ",labelAppId:"App ID: ",titleApps:"Installed application",localAppTitle:"Metadata not available for locally installed application",titleStorage:"Storage",labelStorageText:"Used: "},actionDialog:{title:"Delete Context",subtitle:"Are you sure you want to delete this context? This action cannot be undone."},contextInvitation:{invitationText:"Invited on ",acceptButtonText:"Accept",declineButtonText:"Decline"}},startContextPage={backButtonText:"back to context select",selectApplicationTitle:"Select app from the marketplace or publish new application",selectedApplicationTitle:"Selected Application",initSectionTitle:"Initialize application state",argsTitleText:"Arguments",methodLabelText:"method name",argsLabelText:"arguments json",buttonFormatText:"format",loginRequestPopupTitle:"Application Sign-in Request - Start Context",detailsText:"Details",applicationList:{listTitle:"Select Available Application",noAvailableAppsText:"No applications available",noOwnedAppsText:"No owned applications installed"},startContextSuccessTitle:"Context started",startedContextMessage:"Application context has been started successfully.",startContextErrorTitle:"Failed to start context",startContextErrorMessage:"Failed to start the application context.",idLabelText:"Application ID: ",nameLabelText:"Application Name: ",versionLabelText:"Version: ",successInstallTitle:"Application installed successfully",failInstallTitle:"Error installing application"},joinContextPage={title:"Join existing Context",buttonJoinText:"Join Context",joinErrorTitle:"Failed to join context",joinSuccessTitle:"Context joined",joinSuccessMessage:"Context joined successfully",contextIdLabel:"Context ID"},exportIdentityPage={title:"Export",description:"Export decentralized identifiers (DIDs) associated with the node.",buttonExportText:"Export Identity",exportErrorTitle:"Failed to export node identity",exportSuccessTitle:"Identity exported"},identityPage={title:"Root keys",addRootKeyText:"Add new root key",loggedInLabel:"Logged in with: ",noRootKeysText:"No root keys found in the node."},serverDown={useHookComponentErrorText:"useServerDown must be used within a ServerDownProvider",popupTitle:"503 - Service Unavailable",popupMessage:"The Node Server at {{nodeApiEndpoint}} is unreachable. Please try again later."},nodeDataSource={joinContextErrorTitle:"Error joining context",joinContextErrorMessage:"Failed to join context",unauthorizedErrorMessage:"Unauthorized"},authHeaders={errorText:"Error extracting private key"},walletSelectorContext={alertErrorText:"Failed to initialise wallet selector",componentErrorText:"useWalletSelector must be used within a WalletSelectorContextProvider"},appLoginPopup={createTokenError:"Error creating token, please try again",selectContext:{title:"Application Sign-in Request",detailsText:"Details",websiteText:"From site: ",appIdText:"Application Id: ",contextsTitle:"Select Context",contextsSubtitle:"To continue select available or start a new context for the application",noContextsText:"No contexts found",selectedContextText:"Selected context Id:",buttonNextText:"Confirm context Id",buttonBackText:"Return to application",buttonCreateText:"Start new"},selectIdentity:{title:"Application Sign-in Request",detailsText:"Details",websiteText:"From site: ",appIdText:"Application Id: ",contextIdText:"Context Id: ",contextsTitle:"Select context identity",contextsSubtitle:"To continue select available context identity for the application",noContextsText:"No contexts identities found",selectedContextText:"Selected context identity:",backButtonText:"back to context select",buttonNextText:"Confirm context identity",buttonBackText:"Return to application"},createToken:{title:"Application Sign-in Request",websiteText:"From site: ",appIdText:"Application Id: ",contextIdText:"Context Id: ",backButtonText:"back to select context identity",contextIdentityText:"Context Identity: ",detailsText:"Details",buttonNextText:"Create token"}},setupModal$1={inputIdLengthError:"Application ID must be between 32 and 44 characters long.",inputEncodeError:"Application ID must contain only base58 characters.",nodeHealthCheckError:"Connection failed. Please check if node url is correct.",modalTitle:"App setup",urlInputPlacerholder:"node url",buttonSetText:"Set node url"},translations={useMetamask:useMetamask$1,useNear:useNear$1,useStarknet:useStarknet$1,useIcp:useIcp$1,loginPage,addRootKeyPage,footer,navigation,applicationsPage,confirmWallet,keysPage,keysTable,uploadPage,uploadApplication,addPackageForm,statusModal,contextPage,startContextPage,joinContextPage,exportIdentityPage,identityPage,serverDown,nodeDataSource,authHeaders,walletSelectorContext,appLoginPopup,setupModal:setupModal$1};function createAppMetadata(o){var a={contractAppId:o};return Array.from(new TextEncoder().encode(JSON.stringify(a)))}function parseAppMetadata(o){try{if(o.length===0)return null;var a=JSON.parse(new TextDecoder().decode(new Uint8Array(o)));return a}catch{return null}}function getNodeUrl(){let o=getAppEndpointKey();if(!o){let a="http://localhost:2428";return setAppEndpointKey(a),a}return o??""}function getNearEnvironment(){return"testnet"}const Ed25519$1="Ed25519";class CodeError extends Error{constructor(c,d,tt){super(c);aw(this,"code");aw(this,"props");this.code=d,this.name=(tt==null?void 0:tt.name)??"CodeError",this.props=tt??{}}}class AggregateCodeError extends AggregateError{constructor(c,d,tt,nt){super(c,d);aw(this,"code");aw(this,"props");this.code=tt,this.name=(nt==null?void 0:nt.name)??"AggregateCodeError",this.props=nt??{}}}var events={exports:{}},R$3=typeof Reflect=="object"?Reflect:null,ReflectApply=R$3&&typeof R$3.apply=="function"?R$3.apply:function(a,c,d){return Function.prototype.apply.call(a,c,d)},ReflectOwnKeys;R$3&&typeof R$3.ownKeys=="function"?ReflectOwnKeys=R$3.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:ReflectOwnKeys=function(a){return Object.getOwnPropertyNames(a)};function ProcessEmitWarning(o){console&&console.warn&&console.warn(o)}var NumberIsNaN=Number.isNaN||function(a){return a!==a};function EventEmitter$1(){EventEmitter$1.init.call(this)}events.exports=EventEmitter$1;events.exports.once=once$2;EventEmitter$1.EventEmitter=EventEmitter$1;EventEmitter$1.prototype._events=void 0;EventEmitter$1.prototype._eventsCount=0;EventEmitter$1.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(EventEmitter$1,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(o){if(typeof o!="number"||o<0||NumberIsNaN(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");defaultMaxListeners=o}});EventEmitter$1.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};EventEmitter$1.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||NumberIsNaN(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function _getMaxListeners(o){return o._maxListeners===void 0?EventEmitter$1.defaultMaxListeners:o._maxListeners}EventEmitter$1.prototype.getMaxListeners=function(){return _getMaxListeners(this)};EventEmitter$1.prototype.emit=function(a){for(var c=[],d=1;d0&&($a=c[0]),$a instanceof Error)throw $a;var Ys=new Error("Unhandled error."+($a?" ("+$a.message+")":""));throw Ys.context=$a,Ys}var gu=nt[a];if(gu===void 0)return!1;if(typeof gu=="function")ReflectApply(gu,this,c);else for(var xu=gu.length,$u=arrayClone(gu,xu),d=0;d0&&$a.length>tt&&!$a.warned){$a.warned=!0;var Ys=new Error("Possible EventEmitter memory leak detected. "+$a.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");Ys.name="MaxListenersExceededWarning",Ys.emitter=o,Ys.type=a,Ys.count=$a.length,ProcessEmitWarning(Ys)}return o}EventEmitter$1.prototype.addListener=function(a,c){return _addListener(this,a,c,!1)};EventEmitter$1.prototype.on=EventEmitter$1.prototype.addListener;EventEmitter$1.prototype.prependListener=function(a,c){return _addListener(this,a,c,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(o,a,c){var d={fired:!1,wrapFn:void 0,target:o,type:a,listener:c},tt=onceWrapper.bind(d);return tt.listener=c,d.wrapFn=tt,tt}EventEmitter$1.prototype.once=function(a,c){return checkListener(c),this.on(a,_onceWrap(this,a,c)),this};EventEmitter$1.prototype.prependOnceListener=function(a,c){return checkListener(c),this.prependListener(a,_onceWrap(this,a,c)),this};EventEmitter$1.prototype.removeListener=function(a,c){var d,tt,nt,$a,Ys;if(checkListener(c),tt=this._events,tt===void 0)return this;if(d=tt[a],d===void 0)return this;if(d===c||d.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete tt[a],tt.removeListener&&this.emit("removeListener",a,d.listener||c));else if(typeof d!="function"){for(nt=-1,$a=d.length-1;$a>=0;$a--)if(d[$a]===c||d[$a].listener===c){Ys=d[$a].listener,nt=$a;break}if(nt<0)return this;nt===0?d.shift():spliceOne(d,nt),d.length===1&&(tt[a]=d[0]),tt.removeListener!==void 0&&this.emit("removeListener",a,Ys||c)}return this};EventEmitter$1.prototype.off=EventEmitter$1.prototype.removeListener;EventEmitter$1.prototype.removeAllListeners=function(a){var c,d,tt;if(d=this._events,d===void 0)return this;if(d.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):d[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete d[a]),this;if(arguments.length===0){var nt=Object.keys(d),$a;for(tt=0;tt=0;tt--)this.removeListener(a,c[tt]);return this};function _listeners(o,a,c){var d=o._events;if(d===void 0)return[];var tt=d[a];return tt===void 0?[]:typeof tt=="function"?c?[tt.listener||tt]:[tt]:c?unwrapListeners(tt):arrayClone(tt,tt.length)}EventEmitter$1.prototype.listeners=function(a){return _listeners(this,a,!0)};EventEmitter$1.prototype.rawListeners=function(a){return _listeners(this,a,!1)};EventEmitter$1.listenerCount=function(o,a){return typeof o.listenerCount=="function"?o.listenerCount(a):listenerCount.call(o,a)};EventEmitter$1.prototype.listenerCount=listenerCount;function listenerCount(o){var a=this._events;if(a!==void 0){var c=a[o];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}EventEmitter$1.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(o,a){for(var c=new Array(a),d=0;d=255)throw new TypeError("Alphabet too long");for(var c=new Uint8Array(256),d=0;d>>0,q0=new Uint8Array(L0);$0!==O0;){for(var F0=p0[$0],u1=0,g1=L0-1;(F0!==0||u1>>0,q0[g1]=F0%Ys>>>0,F0=F0/Ys>>>0;if(F0!==0)throw new Error("Non-zero carry");A0=u1,$0++}for(var E1=L0-A0;E1!==L0&&q0[E1]===0;)E1++;for(var B1=gu.repeat(w0);E1>>0,L0=new Uint8Array(O0);p0[w0];){var q0=c[p0.charCodeAt(w0)];if(q0===255)return;for(var F0=0,u1=O0-1;(q0!==0||F0<$0)&&u1!==-1;u1--,F0++)q0+=Ys*L0[u1]>>>0,L0[u1]=q0%256>>>0,q0=q0/256>>>0;if(q0!==0)throw new Error("Non-zero carry");$0=F0,w0++}if(p0[w0]!==" "){for(var g1=O0-$0;g1!==O0&&L0[g1]===0;)g1++;for(var E1=new Uint8Array(A0+(O0-g1)),B1=A0;g1!==O0;)E1[B1++]=L0[g1++];return E1}}}function i0(p0){var w0=Xu(p0);if(w0)return w0;throw new Error(`Non-${a} character`)}return{encode:Iu,decodeUnsafe:Xu,decode:i0}}var src$2=base$5,_brrp__multiformats_scope_baseX=src$2;class Encoder{constructor(a,c,d){aw(this,"name");aw(this,"prefix");aw(this,"baseEncode");this.name=a,this.prefix=c,this.baseEncode=d}encode(a){if(a instanceof Uint8Array)return`${this.prefix}${this.baseEncode(a)}`;throw Error("Unknown type, must be binary type")}}class Decoder{constructor(a,c,d){aw(this,"name");aw(this,"prefix");aw(this,"baseDecode");aw(this,"prefixCodePoint");if(this.name=a,this.prefix=c,c.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=c.codePointAt(0),this.baseDecode=d}decode(a){if(typeof a=="string"){if(a.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(a)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(a.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(a){return or$1(this,a)}}class ComposedDecoder{constructor(a){aw(this,"decoders");this.decoders=a}or(a){return or$1(this,a)}decode(a){const c=a[0],d=this.decoders[c];if(d!=null)return d.decode(a);throw RangeError(`Unable to decode multibase string ${JSON.stringify(a)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function or$1(o,a){return new ComposedDecoder({...o.decoders??{[o.prefix]:o},...a.decoders??{[a.prefix]:a}})}class Codec{constructor(a,c,d,tt){aw(this,"name");aw(this,"prefix");aw(this,"baseEncode");aw(this,"baseDecode");aw(this,"encoder");aw(this,"decoder");this.name=a,this.prefix=c,this.baseEncode=d,this.baseDecode=tt,this.encoder=new Encoder(a,c,d),this.decoder=new Decoder(a,c,tt)}encode(a){return this.encoder.encode(a)}decode(a){return this.decoder.decode(a)}}function from$2({name:o,prefix:a,encode:c,decode:d}){return new Codec(o,a,c,d)}function baseX$1({name:o,prefix:a,alphabet:c}){const{encode:d,decode:tt}=_brrp__multiformats_scope_baseX(c,o);return from$2({prefix:a,name:o,encode:d,decode:nt=>coerce(tt(nt))})}function decode$6(o,a,c,d){const tt={};for(let $u=0;$u=8&&(Ys-=8,$a[xu++]=255&gu>>Ys)}if(Ys>=c||255&gu<<8-Ys)throw new SyntaxError("Unexpected end of data");return $a}function encode$7(o,a,c){const d=a[a.length-1]==="=",tt=(1<c;)$a-=c,nt+=a[tt&Ys>>$a];if($a!==0&&(nt+=a[tt&Ys<=INT;)a[c++]=o&255|MSB$1,o/=128;for(;o&MSBALL;)a[c++]=o&255|MSB$1,o>>>=7;return a[c]=o|0,encode$6.bytes=c-d+1,a}var decode$5=read$2,MSB$1$1=128,REST$1$1=127;function read$2(o,d){var c=0,d=d||0,tt=0,nt=d,$a,Ys=o.length;do{if(nt>=Ys)throw read$2.bytes=0,new RangeError("Could not decode varint");$a=o[nt++],c+=tt<28?($a&REST$1$1)<=MSB$1$1);return read$2.bytes=nt-d,c}var N1$1=Math.pow(2,7),N2$1=Math.pow(2,14),N3$1=Math.pow(2,21),N4$1=Math.pow(2,28),N5$1=Math.pow(2,35),N6$1=Math.pow(2,42),N7$1=Math.pow(2,49),N8=Math.pow(2,56),N9=Math.pow(2,63),length$2=function(o){return ocreate$8(this.code,d))}else throw Error("Unknown type, must be binary type")}}function sha$5(o){return async a=>new Uint8Array(await crypto.subtle.digest(o,a))}const sha256$6=from$1({name:"sha2-256",code:18,encode:sha$5("SHA-256")});function equals(o,a){if(o===a)return!0;if(o.byteLength!==a.byteLength)return!1;for(let c=0;ctt+nt.length,0));const c=allocUnsafe(a);let d=0;for(const tt of o)c.set(tt,d),d+=tt.length;return c}const base10=baseX$1({prefix:"9",name:"base10",alphabet:"0123456789"}),base10$1=Object.freeze(Object.defineProperty({__proto__:null,base10},Symbol.toStringTag,{value:"Module"})),base16=rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper=rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),base16$1=Object.freeze(Object.defineProperty({__proto__:null,base16,base16upper},Symbol.toStringTag,{value:"Module"})),base2=rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),base2$1=Object.freeze(Object.defineProperty({__proto__:null,base2},Symbol.toStringTag,{value:"Module"})),alphabet$1=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),alphabetBytesToChars=alphabet$1.reduce((o,a,c)=>(o[c]=a,o),[]),alphabetCharsToBytes=alphabet$1.reduce((o,a,c)=>(o[a.codePointAt(0)]=c,o),[]);function encode$4(o){return o.reduce((a,c)=>(a+=alphabetBytesToChars[c],a),"")}function decode$4(o){const a=[];for(const c of o){const d=alphabetCharsToBytes[c.codePointAt(0)];if(d===void 0)throw new Error(`Non-base256emoji character: ${c}`);a.push(d)}return new Uint8Array(a)}const base256emoji=from$2({prefix:"๐Ÿš€",name:"base256emoji",encode:encode$4,decode:decode$4}),base256emoji$1=Object.freeze(Object.defineProperty({__proto__:null,base256emoji},Symbol.toStringTag,{value:"Module"})),base32=rfc4648({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),base32upper=rfc4648({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),base32pad=rfc4648({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),base32padupper=rfc4648({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),base32hex=rfc4648({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),base32hexupper=rfc4648({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),base32hexpad=rfc4648({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper=rfc4648({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z=rfc4648({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),base32$1=Object.freeze(Object.defineProperty({__proto__:null,base32,base32hex,base32hexpad,base32hexpadupper,base32hexupper,base32pad,base32padupper,base32upper,base32z},Symbol.toStringTag,{value:"Module"})),base36=baseX$1({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper=baseX$1({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),base36$1=Object.freeze(Object.defineProperty({__proto__:null,base36,base36upper},Symbol.toStringTag,{value:"Module"})),base64$1=rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),base64pad=rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url=rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad=rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),base64$2=Object.freeze(Object.defineProperty({__proto__:null,base64:base64$1,base64pad,base64url,base64urlpad},Symbol.toStringTag,{value:"Module"})),base8=rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),base8$1=Object.freeze(Object.defineProperty({__proto__:null,base8},Symbol.toStringTag,{value:"Module"})),identity$1=from$2({prefix:"\0",name:"identity",encode:o=>toString$c(o),decode:o=>fromString$1(o)}),identityBase=Object.freeze(Object.defineProperty({__proto__:null,identity:identity$1},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const bases={...identityBase,...base2$1,...base8$1,...base10$1,...base16$1,...base32$1,...base36$1,...base58,...base64$2,...base256emoji$1};function createCodec$1(o,a,c,d){return{name:o,prefix:a,encoder:{name:o,prefix:a,encode:c},decoder:{decode:d}}}const string=createCodec$1("utf8","u",o=>"u"+new TextDecoder("utf8").decode(o),o=>new TextEncoder().encode(o.substring(1))),ascii=createCodec$1("ascii","a",o=>{let a="a";for(let c=0;c{o=o.substring(1);const a=allocUnsafe(o.length);for(let c=0;c0&&!a.includes(o.length))throw new Error(`Uint8Array expected of length ${a}, not of length=${o.length}`)}function hash$a(o){if(typeof o!="function"||typeof o.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number$3(o.outputLen),number$3(o.blockLen)}function exists$3(o,a=!0){if(o.destroyed)throw new Error("Hash instance has been destroyed");if(a&&o.finished)throw new Error("Hash#digest() has already been called")}function output$3(o,a){bytes$3(o);const c=a.outputLen;if(o.lengthnew Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)),createView$1=o=>new DataView(o.buffer,o.byteOffset,o.byteLength),rotr$1=(o,a)=>o<<32-a|o>>>a,isLE$1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,byteSwap=o=>o<<24&4278190080|o<<8&16711680|o>>>8&65280|o>>>24&255;function byteSwap32(o){for(let a=0;a{};async function asyncLoop(o,a,c){let d=Date.now();for(let tt=0;tt=0&&nto().update(toBytes$1(d)).digest(),c=o();return a.outputLen=c.outputLen,a.blockLen=c.blockLen,a.create=()=>o(),a}function randomBytes$5(o=32){if(crypto$6&&typeof crypto$6.getRandomValues=="function")return crypto$6.getRandomValues(new Uint8Array(o));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64$3(o,a,c,d){if(typeof o.setBigUint64=="function")return o.setBigUint64(a,c,d);const tt=BigInt(32),nt=BigInt(4294967295),$a=Number(c>>tt&nt),Ys=Number(c&nt),gu=d?4:0,xu=d?0:4;o.setUint32(a+gu,$a,d),o.setUint32(a+xu,Ys,d)}const Chi$2=(o,a,c)=>o&a^~o&c,Maj$2=(o,a,c)=>o&a^o&c^a&c;class HashMD extends Hash$9{constructor(a,c,d,tt){super(),this.blockLen=a,this.outputLen=c,this.padOffset=d,this.isLE=tt,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(a),this.view=createView$1(this.buffer)}update(a){exists$3(this);const{view:c,buffer:d,blockLen:tt}=this;a=toBytes$1(a);const nt=a.length;for(let $a=0;$att-$a&&(this.process(d,0),$a=0);for(let Iu=$a;Iu$u.length)throw new Error("_sha2: outputLen bigger than state");for(let Iu=0;Iu>_32n$2&U32_MASK64$2)}:{h:Number(o>>_32n$2&U32_MASK64$2)|0,l:Number(o&U32_MASK64$2)|0}}function split$8(o,a=!1){let c=new Uint32Array(o.length),d=new Uint32Array(o.length);for(let tt=0;ttBigInt(o>>>0)<<_32n$2|BigInt(a>>>0),shrSH$1=(o,a,c)=>o>>>c,shrSL$1=(o,a,c)=>o<<32-c|a>>>c,rotrSH$1=(o,a,c)=>o>>>c|a<<32-c,rotrSL$1=(o,a,c)=>o<<32-c|a>>>c,rotrBH$1=(o,a,c)=>o<<64-c|a>>>c-32,rotrBL$1=(o,a,c)=>o>>>c-32|a<<64-c,rotr32H$1=(o,a)=>a,rotr32L$1=(o,a)=>o,rotlSH$2=(o,a,c)=>o<>>32-c,rotlSL$2=(o,a,c)=>a<>>32-c,rotlBH$2=(o,a,c)=>a<>>64-c,rotlBL$2=(o,a,c)=>o<>>64-c;function add$1(o,a,c,d){const tt=(a>>>0)+(d>>>0);return{h:o+c+(tt/2**32|0)|0,l:tt|0}}const add3L$1=(o,a,c)=>(o>>>0)+(a>>>0)+(c>>>0),add3H$1=(o,a,c,d)=>a+c+d+(o/2**32|0)|0,add4L$1=(o,a,c,d)=>(o>>>0)+(a>>>0)+(c>>>0)+(d>>>0),add4H$1=(o,a,c,d,tt)=>a+c+d+tt+(o/2**32|0)|0,add5L$1=(o,a,c,d,tt)=>(o>>>0)+(a>>>0)+(c>>>0)+(d>>>0)+(tt>>>0),add5H$1=(o,a,c,d,tt,nt)=>a+c+d+tt+nt+(o/2**32|0)|0,u64$1={fromBig:fromBig$2,split:split$8,toBig:toBig$1,shrSH:shrSH$1,shrSL:shrSL$1,rotrSH:rotrSH$1,rotrSL:rotrSL$1,rotrBH:rotrBH$1,rotrBL:rotrBL$1,rotr32H:rotr32H$1,rotr32L:rotr32L$1,rotlSH:rotlSH$2,rotlSL:rotlSL$2,rotlBH:rotlBH$2,rotlBL:rotlBL$2,add:add$1,add3L:add3L$1,add3H:add3H$1,add4L:add4L$1,add4H:add4H$1,add5H:add5H$1,add5L:add5L$1},[SHA512_Kh$1,SHA512_Kl$1]=u64$1.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(o=>BigInt(o))),SHA512_W_H$1=new Uint32Array(80),SHA512_W_L$1=new Uint32Array(80);let SHA512$4=class extends HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:a,Al:c,Bh:d,Bl:tt,Ch:nt,Cl:$a,Dh:Ys,Dl:gu,Eh:xu,El:$u,Fh:Iu,Fl:Xu,Gh:i0,Gl:p0,Hh:w0,Hl:A0}=this;return[a,c,d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0]}set(a,c,d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0){this.Ah=a|0,this.Al=c|0,this.Bh=d|0,this.Bl=tt|0,this.Ch=nt|0,this.Cl=$a|0,this.Dh=Ys|0,this.Dl=gu|0,this.Eh=xu|0,this.El=$u|0,this.Fh=Iu|0,this.Fl=Xu|0,this.Gh=i0|0,this.Gl=p0|0,this.Hh=w0|0,this.Hl=A0|0}process(a,c){for(let L0=0;L0<16;L0++,c+=4)SHA512_W_H$1[L0]=a.getUint32(c),SHA512_W_L$1[L0]=a.getUint32(c+=4);for(let L0=16;L0<80;L0++){const q0=SHA512_W_H$1[L0-15]|0,F0=SHA512_W_L$1[L0-15]|0,u1=u64$1.rotrSH(q0,F0,1)^u64$1.rotrSH(q0,F0,8)^u64$1.shrSH(q0,F0,7),g1=u64$1.rotrSL(q0,F0,1)^u64$1.rotrSL(q0,F0,8)^u64$1.shrSL(q0,F0,7),E1=SHA512_W_H$1[L0-2]|0,B1=SHA512_W_L$1[L0-2]|0,lv=u64$1.rotrSH(E1,B1,19)^u64$1.rotrBH(E1,B1,61)^u64$1.shrSH(E1,B1,6),j1=u64$1.rotrSL(E1,B1,19)^u64$1.rotrBL(E1,B1,61)^u64$1.shrSL(E1,B1,6),r1=u64$1.add4L(g1,j1,SHA512_W_L$1[L0-7],SHA512_W_L$1[L0-16]),t1=u64$1.add4H(r1,u1,lv,SHA512_W_H$1[L0-7],SHA512_W_H$1[L0-16]);SHA512_W_H$1[L0]=t1|0,SHA512_W_L$1[L0]=r1|0}let{Ah:d,Al:tt,Bh:nt,Bl:$a,Ch:Ys,Cl:gu,Dh:xu,Dl:$u,Eh:Iu,El:Xu,Fh:i0,Fl:p0,Gh:w0,Gl:A0,Hh:$0,Hl:O0}=this;for(let L0=0;L0<80;L0++){const q0=u64$1.rotrSH(Iu,Xu,14)^u64$1.rotrSH(Iu,Xu,18)^u64$1.rotrBH(Iu,Xu,41),F0=u64$1.rotrSL(Iu,Xu,14)^u64$1.rotrSL(Iu,Xu,18)^u64$1.rotrBL(Iu,Xu,41),u1=Iu&i0^~Iu&w0,g1=Xu&p0^~Xu&A0,E1=u64$1.add5L(O0,F0,g1,SHA512_Kl$1[L0],SHA512_W_L$1[L0]),B1=u64$1.add5H(E1,$0,q0,u1,SHA512_Kh$1[L0],SHA512_W_H$1[L0]),lv=E1|0,j1=u64$1.rotrSH(d,tt,28)^u64$1.rotrBH(d,tt,34)^u64$1.rotrBH(d,tt,39),r1=u64$1.rotrSL(d,tt,28)^u64$1.rotrBL(d,tt,34)^u64$1.rotrBL(d,tt,39),t1=d&nt^d&Ys^nt&Ys,D0=tt&$a^tt&gu^$a&gu;$0=w0|0,O0=A0|0,w0=i0|0,A0=p0|0,i0=Iu|0,p0=Xu|0,{h:Iu,l:Xu}=u64$1.add(xu|0,$u|0,B1|0,lv|0),xu=Ys|0,$u=gu|0,Ys=nt|0,gu=$a|0,nt=d|0,$a=tt|0;const Z0=u64$1.add3L(lv,r1,D0);d=u64$1.add3H(Z0,B1,j1,t1),tt=Z0|0}({h:d,l:tt}=u64$1.add(this.Ah|0,this.Al|0,d|0,tt|0)),{h:nt,l:$a}=u64$1.add(this.Bh|0,this.Bl|0,nt|0,$a|0),{h:Ys,l:gu}=u64$1.add(this.Ch|0,this.Cl|0,Ys|0,gu|0),{h:xu,l:$u}=u64$1.add(this.Dh|0,this.Dl|0,xu|0,$u|0),{h:Iu,l:Xu}=u64$1.add(this.Eh|0,this.El|0,Iu|0,Xu|0),{h:i0,l:p0}=u64$1.add(this.Fh|0,this.Fl|0,i0|0,p0|0),{h:w0,l:A0}=u64$1.add(this.Gh|0,this.Gl|0,w0|0,A0|0),{h:$0,l:O0}=u64$1.add(this.Hh|0,this.Hl|0,$0|0,O0|0),this.set(d,tt,nt,$a,Ys,gu,xu,$u,Iu,Xu,i0,p0,w0,A0,$0,O0)}roundClean(){SHA512_W_H$1.fill(0),SHA512_W_L$1.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sha512$3=wrapConstructor$1(()=>new SHA512$4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$f=BigInt(0),_1n$h=BigInt(1),_2n$c=BigInt(2);function isBytes$6(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function abytes(o){if(!isBytes$6(o))throw new Error("Uint8Array expected")}const hexes$2=Array.from({length:256},(o,a)=>a.toString(16).padStart(2,"0"));function bytesToHex$2(o){abytes(o);let a="";for(let c=0;c=asciis$1._0&&o<=asciis$1._9)return o-asciis$1._0;if(o>=asciis$1._A&&o<=asciis$1._F)return o-(asciis$1._A-10);if(o>=asciis$1._a&&o<=asciis$1._f)return o-(asciis$1._a-10)}function hexToBytes$3(o){if(typeof o!="string")throw new Error("hex string expected, got "+typeof o);const a=o.length,c=a/2;if(a%2)throw new Error("padded hex string expected, got unpadded hex of length "+a);const d=new Uint8Array(c);for(let tt=0,nt=0;tt_0n$f;o>>=_1n$h,a+=1);return a}function bitGet$2(o,a){return o>>BigInt(a)&_1n$h}function bitSet$2(o,a,c){return o|(c?_1n$h:_0n$f)<(_2n$c<new Uint8Array(o),u8fr$2=o=>Uint8Array.from(o);function createHmacDrbg$2(o,a,c){if(typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof a!="number"||a<2)throw new Error("qByteLen must be a number");if(typeof c!="function")throw new Error("hmacFn must be a function");let d=u8n$2(o),tt=u8n$2(o),nt=0;const $a=()=>{d.fill(1),tt.fill(0),nt=0},Ys=(...Iu)=>c(tt,d,...Iu),gu=(Iu=u8n$2())=>{tt=Ys(u8fr$2([0]),Iu),d=Ys(),Iu.length!==0&&(tt=Ys(u8fr$2([1]),Iu),d=Ys())},xu=()=>{if(nt++>=1e3)throw new Error("drbg: tried 1000 values");let Iu=0;const Xu=[];for(;Iu{$a(),gu(Iu);let i0;for(;!(i0=Xu(xu()));)gu();return $a(),i0}}const validatorFns$2={bigint:o=>typeof o=="bigint",function:o=>typeof o=="function",boolean:o=>typeof o=="boolean",string:o=>typeof o=="string",stringOrUint8Array:o=>typeof o=="string"||isBytes$6(o),isSafeInteger:o=>Number.isSafeInteger(o),array:o=>Array.isArray(o),field:(o,a)=>a.Fp.isValid(o),hash:o=>typeof o=="function"&&Number.isSafeInteger(o.outputLen)};function validateObject$2(o,a,c={}){const d=(tt,nt,$a)=>{const Ys=validatorFns$2[nt];if(typeof Ys!="function")throw new Error(`Invalid validator "${nt}", expected function`);const gu=o[tt];if(!($a&&gu===void 0)&&!Ys(gu,o))throw new Error(`Invalid param ${String(tt)}=${gu} (${typeof gu}), expected ${nt}`)};for(const[tt,nt]of Object.entries(a))d(tt,nt,!1);for(const[tt,nt]of Object.entries(c))d(tt,nt,!0);return o}const ut$4=Object.freeze(Object.defineProperty({__proto__:null,abytes,bitGet:bitGet$2,bitLen:bitLen$2,bitMask:bitMask$2,bitSet:bitSet$2,bytesToHex:bytesToHex$2,bytesToNumberBE:bytesToNumberBE$2,bytesToNumberLE:bytesToNumberLE$2,concatBytes:concatBytes$3,createHmacDrbg:createHmacDrbg$2,ensureBytes:ensureBytes$3,equalBytes:equalBytes$2,hexToBytes:hexToBytes$3,hexToNumber:hexToNumber$2,isBytes:isBytes$6,numberToBytesBE:numberToBytesBE$2,numberToBytesLE:numberToBytesLE$2,numberToHexUnpadded:numberToHexUnpadded$2,numberToVarBytesBE:numberToVarBytesBE$2,utf8ToBytes:utf8ToBytes$3,validateObject:validateObject$2},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$e=BigInt(0),_1n$g=BigInt(1),_2n$b=BigInt(2),_3n$4=BigInt(3),_4n$3=BigInt(4),_5n$3=BigInt(5),_8n$4=BigInt(8);BigInt(9);BigInt(16);function mod$2(o,a){const c=o%a;return c>=_0n$e?c:a+c}function pow$4(o,a,c){if(c<=_0n$e||a<_0n$e)throw new Error("Expected power/modulo > 0");if(c===_1n$g)return _0n$e;let d=_1n$g;for(;a>_0n$e;)a&_1n$g&&(d=d*o%c),o=o*o%c,a>>=_1n$g;return d}function pow2$1(o,a,c){let d=o;for(;a-- >_0n$e;)d*=d,d%=c;return d}function invert$2(o,a){if(o===_0n$e||a<=_0n$e)throw new Error(`invert: expected positive integers, got n=${o} mod=${a}`);let c=mod$2(o,a),d=a,tt=_0n$e,nt=_1n$g;for(;c!==_0n$e;){const Ys=d/c,gu=d%c,xu=tt-nt*Ys;d=c,c=gu,tt=nt,nt=xu}if(d!==_1n$g)throw new Error("invert: does not exist");return mod$2(tt,a)}function tonelliShanks$2(o){const a=(o-_1n$g)/_2n$b;let c,d,tt;for(c=o-_1n$g,d=0;c%_2n$b===_0n$e;c/=_2n$b,d++);for(tt=_2n$b;tt(mod$2(o,a)&_1n$g)===_1n$g,FIELD_FIELDS$2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField$2(o){const a={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},c=FIELD_FIELDS$2.reduce((d,tt)=>(d[tt]="function",d),a);return validateObject$2(o,c)}function FpPow$2(o,a,c){if(c<_0n$e)throw new Error("Expected power > 0");if(c===_0n$e)return o.ONE;if(c===_1n$g)return a;let d=o.ONE,tt=a;for(;c>_0n$e;)c&_1n$g&&(d=o.mul(d,tt)),tt=o.sqr(tt),c>>=_1n$g;return d}function FpInvertBatch$2(o,a){const c=new Array(a.length),d=a.reduce((nt,$a,Ys)=>o.is0($a)?nt:(c[Ys]=nt,o.mul(nt,$a)),o.ONE),tt=o.inv(d);return a.reduceRight((nt,$a,Ys)=>o.is0($a)?nt:(c[Ys]=o.mul(nt,c[Ys]),o.mul(nt,$a)),tt),c}function nLength$2(o,a){const c=a!==void 0?a:o.toString(2).length,d=Math.ceil(c/8);return{nBitLength:c,nByteLength:d}}function Field$2(o,a,c=!1,d={}){if(o<=_0n$e)throw new Error(`Expected Field ORDER > 0, got ${o}`);const{nBitLength:tt,nByteLength:nt}=nLength$2(o,a);if(nt>2048)throw new Error("Field lengths over 2048 bytes are not supported");const $a=FpSqrt$2(o),Ys=Object.freeze({ORDER:o,BITS:tt,BYTES:nt,MASK:bitMask$2(tt),ZERO:_0n$e,ONE:_1n$g,create:gu=>mod$2(gu,o),isValid:gu=>{if(typeof gu!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof gu}`);return _0n$e<=gu&&gugu===_0n$e,isOdd:gu=>(gu&_1n$g)===_1n$g,neg:gu=>mod$2(-gu,o),eql:(gu,xu)=>gu===xu,sqr:gu=>mod$2(gu*gu,o),add:(gu,xu)=>mod$2(gu+xu,o),sub:(gu,xu)=>mod$2(gu-xu,o),mul:(gu,xu)=>mod$2(gu*xu,o),pow:(gu,xu)=>FpPow$2(Ys,gu,xu),div:(gu,xu)=>mod$2(gu*invert$2(xu,o),o),sqrN:gu=>gu*gu,addN:(gu,xu)=>gu+xu,subN:(gu,xu)=>gu-xu,mulN:(gu,xu)=>gu*xu,inv:gu=>invert$2(gu,o),sqrt:d.sqrt||(gu=>$a(Ys,gu)),invertBatch:gu=>FpInvertBatch$2(Ys,gu),cmov:(gu,xu,$u)=>$u?xu:gu,toBytes:gu=>c?numberToBytesLE$2(gu,nt):numberToBytesBE$2(gu,nt),fromBytes:gu=>{if(gu.length!==nt)throw new Error(`Fp.fromBytes: expected ${nt}, got ${gu.length}`);return c?bytesToNumberLE$2(gu):bytesToNumberBE$2(gu)}});return Object.freeze(Ys)}function FpSqrtEven$1(o,a){if(!o.isOdd)throw new Error("Field doesn't have isOdd");const c=o.sqrt(a);return o.isOdd(c)?o.neg(c):c}function getFieldBytesLength$2(o){if(typeof o!="bigint")throw new Error("field order must be bigint");const a=o.toString(2).length;return Math.ceil(a/8)}function getMinHashLength$2(o){const a=getFieldBytesLength$2(o);return a+Math.ceil(a/2)}function mapHashToField$2(o,a,c=!1){const d=o.length,tt=getFieldBytesLength$2(a),nt=getMinHashLength$2(a);if(d<16||d1024)throw new Error(`expected ${nt}-1024 bytes of input, got ${d}`);const $a=c?bytesToNumberBE$2(o):bytesToNumberLE$2(o),Ys=mod$2($a,a-_1n$g)+_1n$g;return c?numberToBytesLE$2(Ys,tt):numberToBytesBE$2(Ys,tt)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$d=BigInt(0),_1n$f=BigInt(1);function wNAF$2(o,a){const c=(tt,nt)=>{const $a=nt.negate();return tt?$a:nt},d=tt=>{const nt=Math.ceil(a/tt)+1,$a=2**(tt-1);return{windows:nt,windowSize:$a}};return{constTimeNegate:c,unsafeLadder(tt,nt){let $a=o.ZERO,Ys=tt;for(;nt>_0n$d;)nt&_1n$f&&($a=$a.add(Ys)),Ys=Ys.double(),nt>>=_1n$f;return $a},precomputeWindow(tt,nt){const{windows:$a,windowSize:Ys}=d(nt),gu=[];let xu=tt,$u=xu;for(let Iu=0;Iu<$a;Iu++){$u=xu,gu.push($u);for(let Xu=1;Xu>=i0,A0>gu&&(A0-=Xu,$a+=_1n$f);const $0=w0,O0=w0+Math.abs(A0)-1,L0=p0%2!==0,q0=A0<0;A0===0?$u=$u.add(c(L0,nt[$0])):xu=xu.add(c(q0,nt[O0]))}return{p:xu,f:$u}},wNAFCached(tt,nt,$a,Ys){const gu=tt._WINDOW_SIZE||1;let xu=nt.get(tt);return xu||(xu=this.precomputeWindow(tt,gu),gu!==1&&nt.set(tt,Ys(xu))),this.wNAF(gu,xu,$a)}}}function validateBasic$2(o){return validateField$2(o.Fp),validateObject$2(o,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength$2(o.n,o.nBitLength),...o,p:o.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$c=BigInt(0),_1n$e=BigInt(1),_2n$a=BigInt(2),_8n$3=BigInt(8),VERIFY_DEFAULT$1={zip215:!0};function validateOpts$6(o){const a=validateBasic$2(o);return validateObject$2(o,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...a})}function twistedEdwards$1(o){const a=validateOpts$6(o),{Fp:c,n:d,prehash:tt,hash:nt,randomBytes:$a,nByteLength:Ys,h:gu}=a,xu=_2n$a<{try{return{isValid:!0,value:c.sqrt(m1*c.inv(c1))}}catch{return{isValid:!1,value:_0n$c}}}),Xu=a.adjustScalarBytes||(m1=>m1),i0=a.domain||((m1,c1,G0)=>{if(c1.length||G0)throw new Error("Contexts/pre-hash are not supported");return m1}),p0=m1=>typeof m1=="bigint"&&_0n$cp0(m1)&&p0(c1)&&m1m1===_0n$c||w0(m1,xu);function $0(m1,c1){if(w0(m1,c1))return m1;throw new Error(`Expected valid scalar < ${c1}, got ${typeof m1} ${m1}`)}function O0(m1){return m1===_0n$c?m1:$0(m1,d)}const L0=new Map;function q0(m1){if(!(m1 instanceof F0))throw new Error("ExtendedPoint expected")}class F0{constructor(c1,G0,o1,d1){if(this.ex=c1,this.ey=G0,this.ez=o1,this.et=d1,!A0(c1))throw new Error("x required");if(!A0(G0))throw new Error("y required");if(!A0(o1))throw new Error("z required");if(!A0(d1))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(c1){if(c1 instanceof F0)throw new Error("extended point not allowed");const{x:G0,y:o1}=c1||{};if(!A0(G0)||!A0(o1))throw new Error("invalid affine point");return new F0(G0,o1,_1n$e,$u(G0*o1))}static normalizeZ(c1){const G0=c.invertBatch(c1.map(o1=>o1.ez));return c1.map((o1,d1)=>o1.toAffine(G0[d1])).map(F0.fromAffine)}_setWindowSize(c1){this._WINDOW_SIZE=c1,L0.delete(this)}assertValidity(){const{a:c1,d:G0}=a;if(this.is0())throw new Error("bad point: ZERO");const{ex:o1,ey:d1,ez:R1,et:O1}=this,Q1=$u(o1*o1),rv=$u(d1*d1),D1=$u(R1*R1),ev=$u(D1*D1),Mv=$u(Q1*c1),Zv=$u(D1*$u(Mv+rv)),fv=$u(ev+$u(G0*$u(Q1*rv)));if(Zv!==fv)throw new Error("bad point: equation left != right (1)");const cv=$u(o1*d1),ly=$u(R1*O1);if(cv!==ly)throw new Error("bad point: equation left != right (2)")}equals(c1){q0(c1);const{ex:G0,ey:o1,ez:d1}=this,{ex:R1,ey:O1,ez:Q1}=c1,rv=$u(G0*Q1),D1=$u(R1*d1),ev=$u(o1*Q1),Mv=$u(O1*d1);return rv===D1&&ev===Mv}is0(){return this.equals(F0.ZERO)}negate(){return new F0($u(-this.ex),this.ey,this.ez,$u(-this.et))}double(){const{a:c1}=a,{ex:G0,ey:o1,ez:d1}=this,R1=$u(G0*G0),O1=$u(o1*o1),Q1=$u(_2n$a*$u(d1*d1)),rv=$u(c1*R1),D1=G0+o1,ev=$u($u(D1*D1)-R1-O1),Mv=rv+O1,Zv=Mv-Q1,fv=rv-O1,cv=$u(ev*Zv),ly=$u(Mv*fv),Cy=$u(ev*fv),Ly=$u(Zv*Mv);return new F0(cv,ly,Ly,Cy)}add(c1){q0(c1);const{a:G0,d:o1}=a,{ex:d1,ey:R1,ez:O1,et:Q1}=this,{ex:rv,ey:D1,ez:ev,et:Mv}=c1;if(G0===BigInt(-1)){const vw=$u((R1-d1)*(D1+rv)),Hw=$u((R1+d1)*(D1-rv)),uw=$u(Hw-vw);if(uw===_0n$c)return this.double();const Nw=$u(O1*_2n$a*Mv),lw=$u(Q1*_2n$a*ev),Lw=lw+Nw,zw=Hw+vw,A2=lw-Nw,kv=$u(Lw*uw),Y1=$u(zw*A2),tv=$u(Lw*A2),Yv=$u(uw*zw);return new F0(kv,Y1,Yv,tv)}const Zv=$u(d1*rv),fv=$u(R1*D1),cv=$u(Q1*o1*Mv),ly=$u(O1*ev),Cy=$u((d1+R1)*(rv+D1)-Zv-fv),Ly=ly-cv,Hy=ly+cv,t2=$u(fv-G0*Zv),C2=$u(Cy*Ly),Dy=$u(Hy*t2),jw=$u(Cy*t2),pw=$u(Ly*Hy);return new F0(C2,Dy,pw,jw)}subtract(c1){return this.add(c1.negate())}wNAF(c1){return E1.wNAFCached(this,L0,c1,F0.normalizeZ)}multiply(c1){const{p:G0,f:o1}=this.wNAF($0(c1,d));return F0.normalizeZ([G0,o1])[0]}multiplyUnsafe(c1){let G0=O0(c1);return G0===_0n$c?g1:this.equals(g1)||G0===_1n$e?this:this.equals(u1)?this.wNAF(G0).p:E1.unsafeLadder(this,G0)}isSmallOrder(){return this.multiplyUnsafe(gu).is0()}isTorsionFree(){return E1.unsafeLadder(this,d).is0()}toAffine(c1){const{ex:G0,ey:o1,ez:d1}=this,R1=this.is0();c1==null&&(c1=R1?_8n$3:c.inv(d1));const O1=$u(G0*c1),Q1=$u(o1*c1),rv=$u(d1*c1);if(R1)return{x:_0n$c,y:_1n$e};if(rv!==_1n$e)throw new Error("invZ was invalid");return{x:O1,y:Q1}}clearCofactor(){const{h:c1}=a;return c1===_1n$e?this:this.multiplyUnsafe(c1)}static fromHex(c1,G0=!1){const{d:o1,a:d1}=a,R1=c.BYTES;c1=ensureBytes$3("pointHex",c1,R1);const O1=c1.slice(),Q1=c1[R1-1];O1[R1-1]=Q1&-129;const rv=bytesToNumberLE$2(O1);rv===_0n$c||(G0?$0(rv,xu):$0(rv,c.ORDER));const D1=$u(rv*rv),ev=$u(D1-_1n$e),Mv=$u(o1*D1-d1);let{isValid:Zv,value:fv}=Iu(ev,Mv);if(!Zv)throw new Error("Point.fromHex: invalid y coordinate");const cv=(fv&_1n$e)===_1n$e,ly=(Q1&128)!==0;if(!G0&&fv===_0n$c&&ly)throw new Error("Point.fromHex: x=0 and x_0=1");return ly!==cv&&(fv=$u(-fv)),F0.fromAffine({x:fv,y:rv})}static fromPrivateKey(c1){return j1(c1).point}toRawBytes(){const{x:c1,y:G0}=this.toAffine(),o1=numberToBytesLE$2(G0,c.BYTES);return o1[o1.length-1]|=c1&_1n$e?128:0,o1}toHex(){return bytesToHex$2(this.toRawBytes())}}F0.BASE=new F0(a.Gx,a.Gy,_1n$e,$u(a.Gx*a.Gy)),F0.ZERO=new F0(_0n$c,_1n$e,_1n$e,_0n$c);const{BASE:u1,ZERO:g1}=F0,E1=wNAF$2(F0,Ys*8);function B1(m1){return mod$2(m1,d)}function lv(m1){return B1(bytesToNumberLE$2(m1))}function j1(m1){const c1=Ys;m1=ensureBytes$3("private key",m1,c1);const G0=ensureBytes$3("hashed private key",nt(m1),2*c1),o1=Xu(G0.slice(0,c1)),d1=G0.slice(c1,2*c1),R1=lv(o1),O1=u1.multiply(R1),Q1=O1.toRawBytes();return{head:o1,prefix:d1,scalar:R1,point:O1,pointBytes:Q1}}function r1(m1){return j1(m1).pointBytes}function t1(m1=new Uint8Array,...c1){const G0=concatBytes$3(...c1);return lv(nt(i0(G0,ensureBytes$3("context",m1),!!tt)))}function D0(m1,c1,G0={}){m1=ensureBytes$3("message",m1),tt&&(m1=tt(m1));const{prefix:o1,scalar:d1,pointBytes:R1}=j1(c1),O1=t1(G0.context,o1,m1),Q1=u1.multiply(O1).toRawBytes(),rv=t1(G0.context,Q1,R1,m1),D1=B1(O1+rv*d1);O0(D1);const ev=concatBytes$3(Q1,numberToBytesLE$2(D1,c.BYTES));return ensureBytes$3("result",ev,Ys*2)}const Z0=VERIFY_DEFAULT$1;function f1(m1,c1,G0,o1=Z0){const{context:d1,zip215:R1}=o1,O1=c.BYTES;m1=ensureBytes$3("signature",m1,2*O1),c1=ensureBytes$3("message",c1),tt&&(c1=tt(c1));const Q1=bytesToNumberLE$2(m1.slice(O1,2*O1));let rv,D1,ev;try{rv=F0.fromHex(G0,R1),D1=F0.fromHex(m1.slice(0,O1),R1),ev=u1.multiplyUnsafe(Q1)}catch{return!1}if(!R1&&rv.isSmallOrder())return!1;const Mv=t1(d1,D1.toRawBytes(),rv.toRawBytes(),c1);return D1.add(rv.multiplyUnsafe(Mv)).subtract(ev).clearCofactor().equals(F0.ZERO)}return u1._setWindowSize(8),{CURVE:a,getPublicKey:r1,sign:D0,verify:f1,ExtendedPoint:F0,utils:{getExtendedPublicKey:j1,randomPrivateKey:()=>$a(c.BYTES),precompute(m1=8,c1=F0.BASE){return c1._setWindowSize(m1),c1.multiply(BigInt(3)),c1}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ED25519_P=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _1n$d=BigInt(1),_2n$9=BigInt(2),_5n$2=BigInt(5),_10n=BigInt(10),_20n=BigInt(20),_40n=BigInt(40),_80n=BigInt(80);function ed25519_pow_2_252_3(o){const a=ED25519_P,d=o*o%a*o%a,tt=pow2$1(d,_2n$9,a)*d%a,nt=pow2$1(tt,_1n$d,a)*o%a,$a=pow2$1(nt,_5n$2,a)*nt%a,Ys=pow2$1($a,_10n,a)*$a%a,gu=pow2$1(Ys,_20n,a)*Ys%a,xu=pow2$1(gu,_40n,a)*gu%a,$u=pow2$1(xu,_80n,a)*xu%a,Iu=pow2$1($u,_80n,a)*xu%a,Xu=pow2$1(Iu,_10n,a)*$a%a;return{pow_p_5_8:pow2$1(Xu,_2n$9,a)*o%a,b2:d}}function adjustScalarBytes(o){return o[0]&=248,o[31]&=127,o[31]|=64,o}function uvRatio(o,a){const c=ED25519_P,d=mod$2(a*a*a,c),tt=mod$2(d*d*a,c),nt=ed25519_pow_2_252_3(o*tt).pow_p_5_8;let $a=mod$2(o*d*nt,c);const Ys=mod$2(a*$a*$a,c),gu=$a,xu=mod$2($a*ED25519_SQRT_M1,c),$u=Ys===o,Iu=Ys===mod$2(-o,c),Xu=Ys===mod$2(-o*ED25519_SQRT_M1,c);return $u&&($a=gu),(Iu||Xu)&&($a=xu),isNegativeLE$1($a,c)&&($a=mod$2(-$a,c)),{isValid:$u||Iu,value:$a}}const Fp$2=Field$2(ED25519_P,void 0,!0),ed25519Defaults={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fp$2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sha512$3,randomBytes:randomBytes$5,adjustScalarBytes,uvRatio},ed25519$1=twistedEdwards$1(ed25519Defaults);function ed25519_domain(o,a,c){if(a.length>255)throw new Error("Context is too big");return concatBytes$4(utf8ToBytes$4("SigEd25519 no Ed25519 collisions"),new Uint8Array([c?1:0,a.length]),a,o)}({...ed25519Defaults});({...ed25519Defaults});const ELL2_C1=(Fp$2.ORDER+BigInt(3))/BigInt(8);Fp$2.pow(_2n$9,ELL2_C1);Fp$2.sqrt(Fp$2.neg(Fp$2.ONE));(Fp$2.ORDER-BigInt(5))/BigInt(8);BigInt(486662);FpSqrtEven$1(Fp$2,Fp$2.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const PUBLIC_KEY_BYTE_LENGTH=32,PRIVATE_KEY_BYTE_LENGTH=64,KEYS_BYTE_LENGTH=32;function generateKey$2(){const o=ed25519$1.utils.randomPrivateKey(),a=ed25519$1.getPublicKey(o);return{privateKey:concatKeys(o,a),publicKey:a}}function generateKeyFromSeed(o){if(o.length!==KEYS_BYTE_LENGTH)throw new TypeError('"seed" must be 32 bytes in length.');if(!(o instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const a=o,c=ed25519$1.getPublicKey(a);return{privateKey:concatKeys(a,c),publicKey:c}}function hashAndSign$2(o,a){const c=o.subarray(0,KEYS_BYTE_LENGTH);return ed25519$1.sign(a instanceof Uint8Array?a:a.subarray(),c)}function hashAndVerify$2(o,a,c){return ed25519$1.verify(a,c instanceof Uint8Array?c:c.subarray(),o)}function concatKeys(o,a){const c=new Uint8Array(PRIVATE_KEY_BYTE_LENGTH);for(let d=0;dNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function encodeUint8Array(o,a,c=0){switch(encodingLength(o)){case 8:a[c++]=o&255|MSB,o/=128;case 7:a[c++]=o&255|MSB,o/=128;case 6:a[c++]=o&255|MSB,o/=128;case 5:a[c++]=o&255|MSB,o/=128;case 4:a[c++]=o&255|MSB,o>>>=7;case 3:a[c++]=o&255|MSB,o>>>=7;case 2:a[c++]=o&255|MSB,o>>>=7;case 1:{a[c++]=o&255,o>>>=7;break}default:throw new Error("unreachable")}return a}function decodeUint8Array(o,a){let c=o[a],d=0;if(d+=c&REST,c>>31>0){const c=~this.lo+1>>>0;let d=~this.hi>>>0;return c===0&&(d=d+1>>>0),-(c+d*4294967296)}return this.lo+this.hi*4294967296}toBigInt(a=!1){if(a)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){const c=~this.lo+1>>>0;let d=~this.hi>>>0;return c===0&&(d=d+1>>>0),-(BigInt(c)+(BigInt(d)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(a=!1){return this.toBigInt(a).toString()}zzEncode(){const a=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^a)>>>0,this.lo=(this.lo<<1^a)>>>0,this}zzDecode(){const a=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^a)>>>0,this.hi=(this.hi>>>1^a)>>>0,this}length(){const a=this.lo,c=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return d===0?c===0?a<16384?a<128?1:2:a<2097152?3:4:c<16384?c<128?5:6:c<2097152?7:8:d<128?9:10}static fromBigInt(a){if(a===0n)return zero$2;if(aMIN_SAFE_NUMBER_INTEGER)return this.fromNumber(Number(a));const c=a<0n;c&&(a=-a);let d=a>>32n,tt=a-(d<<32n);return c&&(d=~d|0n,tt=~tt|0n,++tt>TWO_32&&(tt=0n,++d>TWO_32&&(d=0n))),new LongBits(Number(tt),Number(d))}static fromNumber(a){if(a===0)return zero$2;const c=a<0;c&&(a=-a);let d=a>>>0,tt=(a-d)/4294967296>>>0;return c&&(tt=~tt>>>0,d=~d>>>0,++d>4294967295&&(d=0,++tt>4294967295&&(tt=0))),new LongBits(d,tt)}static from(a){return typeof a=="number"?LongBits.fromNumber(a):typeof a=="bigint"?LongBits.fromBigInt(a):typeof a=="string"?LongBits.fromBigInt(BigInt(a)):a.low!=null||a.high!=null?new LongBits(a.low>>>0,a.high>>>0):zero$2}}const zero$2=new LongBits(0,0);zero$2.toBigInt=function(){return 0n};zero$2.zzEncode=zero$2.zzDecode=function(){return this};zero$2.length=function(){return 1};const TWO_32=4294967296n;function length$1(o){let a=0,c=0;for(let d=0;d191&&Ys<224?nt[$a++]=(Ys&31)<<6|o[a++]&63:Ys>239&&Ys<365?(Ys=((Ys&7)<<18|(o[a++]&63)<<12|(o[a++]&63)<<6|o[a++]&63)-65536,nt[$a++]=55296+(Ys>>10),nt[$a++]=56320+(Ys&1023)):nt[$a++]=(Ys&15)<<12|(o[a++]&63)<<6|o[a++]&63,$a>8191&&((tt??(tt=[])).push(String.fromCharCode.apply(String,nt)),$a=0);return tt!=null?($a>0&&tt.push(String.fromCharCode.apply(String,nt.slice(0,$a))),tt.join("")):String.fromCharCode.apply(String,nt.slice(0,$a))}function write$1(o,a,c){const d=c;let tt,nt;for(let $a=0;$a>6|192,a[c++]=tt&63|128):(tt&64512)===55296&&((nt=o.charCodeAt($a+1))&64512)===56320?(tt=65536+((tt&1023)<<10)+(nt&1023),++$a,a[c++]=tt>>18|240,a[c++]=tt>>12&63|128,a[c++]=tt>>6&63|128,a[c++]=tt&63|128):(a[c++]=tt>>12|224,a[c++]=tt>>6&63|128,a[c++]=tt&63|128);return c-d}function indexOutOfRange(o,a){return RangeError(`index out of range: ${o.pos} + ${a??1} > ${o.len}`)}function readFixed32End(o,a){return(o[a-4]|o[a-3]<<8|o[a-2]<<16|o[a-1]<<24)>>>0}class Uint8ArrayReader{constructor(a){aw(this,"buf");aw(this,"pos");aw(this,"len");aw(this,"_slice",Uint8Array.prototype.subarray);this.buf=a,this.pos=0,this.len=a.length}uint32(){let a=4294967295;if(a=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(a=(a|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(a=(a|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return a;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return a}int32(){return this.uint32()|0}sint32(){const a=this.uint32();return a>>>1^-(a&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32End(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32End(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);const a=readFloatLE(this.buf,this.pos);return this.pos+=4,a}double(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);const a=readDoubleLE(this.buf,this.pos);return this.pos+=8,a}bytes(){const a=this.uint32(),c=this.pos,d=this.pos+a;if(d>this.len)throw indexOutOfRange(this,a);return this.pos+=a,c===d?new Uint8Array(0):this.buf.subarray(c,d)}string(){const a=this.bytes();return read$1(a,0,a.length)}skip(a){if(typeof a=="number"){if(this.pos+a>this.len)throw indexOutOfRange(this,a);this.pos+=a}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this}skipType(a){switch(a){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(a=this.uint32()&7)!==4;)this.skipType(a);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${a} at offset ${this.pos}`)}return this}readLongVarint(){const a=new LongBits(0,0);let c=0;if(this.len-this.pos>4){for(;c<4;++c)if(a.lo=(a.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a;if(a.lo=(a.lo|(this.buf[this.pos]&127)<<28)>>>0,a.hi=(a.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return a;c=0}else{for(;c<3;++c){if(this.pos>=this.len)throw indexOutOfRange(this);if(a.lo=(a.lo|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}return a.lo=(a.lo|(this.buf[this.pos++]&127)<>>0,a}if(this.len-this.pos>4){for(;c<5;++c)if(a.hi=(a.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}else for(;c<5;++c){if(this.pos>=this.len)throw indexOutOfRange(this);if(a.hi=(a.hi|(this.buf[this.pos]&127)<>>0,this.buf[this.pos++]<128)return a}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);const a=readFixed32End(this.buf,this.pos+=4),c=readFixed32End(this.buf,this.pos+=4);return new LongBits(a,c)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const a=decodeUint8Array(this.buf,this.pos);return this.pos+=encodingLength(a),a}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}}function createReader(o){return new Uint8ArrayReader(o instanceof Uint8Array?o:o.subarray())}function decodeMessage(o,a,c){const d=createReader(o);return a.decode(d,void 0,c)}function pool(o){let d,tt=8192;return function($a){if($a<1||$a>4096)return allocUnsafe($a);tt+$a>8192&&(d=allocUnsafe(8192),tt=0);const Ys=d.subarray(tt,tt+=$a);return tt&7&&(tt=(tt|7)+1),Ys}}let Op$1=class{constructor(a,c,d){aw(this,"fn");aw(this,"len");aw(this,"next");aw(this,"val");this.fn=a,this.len=c,this.next=void 0,this.val=d}};function noop$b(){}class State{constructor(a){aw(this,"head");aw(this,"tail");aw(this,"len");aw(this,"next");this.head=a.head,this.tail=a.tail,this.len=a.len,this.next=a.states}}const bufferPool=pool();function alloc$1(o){return globalThis.Buffer!=null?allocUnsafe(o):bufferPool(o)}class Uint8ArrayWriter{constructor(){aw(this,"len");aw(this,"head");aw(this,"tail");aw(this,"states");this.len=0,this.head=new Op$1(noop$b,0,0),this.tail=this.head,this.states=null}_push(a,c,d){return this.tail=this.tail.next=new Op$1(a,c,d),this.len+=c,this}uint32(a){return this.len+=(this.tail=this.tail.next=new VarintOp((a=a>>>0)<128?1:a<16384?2:a<2097152?3:a<268435456?4:5,a)).len,this}int32(a){return a<0?this._push(writeVarint64,10,LongBits.fromNumber(a)):this.uint32(a)}sint32(a){return this.uint32((a<<1^a>>31)>>>0)}uint64(a){const c=LongBits.fromBigInt(a);return this._push(writeVarint64,c.length(),c)}uint64Number(a){return this._push(encodeUint8Array,encodingLength(a),a)}uint64String(a){return this.uint64(BigInt(a))}int64(a){return this.uint64(a)}int64Number(a){return this.uint64Number(a)}int64String(a){return this.uint64String(a)}sint64(a){const c=LongBits.fromBigInt(a).zzEncode();return this._push(writeVarint64,c.length(),c)}sint64Number(a){const c=LongBits.fromNumber(a).zzEncode();return this._push(writeVarint64,c.length(),c)}sint64String(a){return this.sint64(BigInt(a))}bool(a){return this._push(writeByte,1,a?1:0)}fixed32(a){return this._push(writeFixed32,4,a>>>0)}sfixed32(a){return this.fixed32(a)}fixed64(a){const c=LongBits.fromBigInt(a);return this._push(writeFixed32,4,c.lo)._push(writeFixed32,4,c.hi)}fixed64Number(a){const c=LongBits.fromNumber(a);return this._push(writeFixed32,4,c.lo)._push(writeFixed32,4,c.hi)}fixed64String(a){return this.fixed64(BigInt(a))}sfixed64(a){return this.fixed64(a)}sfixed64Number(a){return this.fixed64Number(a)}sfixed64String(a){return this.fixed64String(a)}float(a){return this._push(writeFloatLE,4,a)}double(a){return this._push(writeDoubleLE,8,a)}bytes(a){const c=a.length>>>0;return c===0?this._push(writeByte,1,0):this.uint32(c)._push(writeBytes,c,a)}string(a){const c=length$1(a);return c!==0?this.uint32(c)._push(write$1,c,a):this._push(writeByte,1,0)}fork(){return this.states=new State(this),this.head=this.tail=new Op$1(noop$b,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op$1(noop$b,0,0),this.len=0),this}ldelim(){const a=this.head,c=this.tail,d=this.len;return this.reset().uint32(d),d!==0&&(this.tail.next=a.next,this.tail=c,this.len+=d),this}finish(){let a=this.head.next;const c=alloc$1(this.len);let d=0;for(;a!=null;)a.fn(a.val,c,d),d+=a.len,a=a.next;return c}}function writeByte(o,a,c){a[c]=o&255}function writeVarint32(o,a,c){for(;o>127;)a[c++]=o&127|128,o>>>=7;a[c]=o}class VarintOp extends Op$1{constructor(c,d){super(writeVarint32,c,d);aw(this,"next");this.next=void 0}}function writeVarint64(o,a,c){for(;o.hi!==0;)a[c++]=o.lo&127|128,o.lo=(o.lo>>>7|o.hi<<25)>>>0,o.hi>>>=7;for(;o.lo>127;)a[c++]=o.lo&127|128,o.lo=o.lo>>>7;a[c++]=o.lo}function writeFixed32(o,a,c){a[c]=o&255,a[c+1]=o>>>8&255,a[c+2]=o>>>16&255,a[c+3]=o>>>24}function writeBytes(o,a,c){a.set(o,c)}globalThis.Buffer!=null&&(Uint8ArrayWriter.prototype.bytes=function(o){const a=o.length>>>0;return this.uint32(a),a>0&&this._push(writeBytesBuffer,a,o),this},Uint8ArrayWriter.prototype.string=function(o){const a=globalThis.Buffer.byteLength(o);return this.uint32(a),a>0&&this._push(writeStringBuffer,a,o),this});function writeBytesBuffer(o,a,c){a.set(o,c)}function writeStringBuffer(o,a,c){o.length<40?write$1(o,a,c):a.utf8Write!=null?a.utf8Write(o,c):a.set(fromString(o),c)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(o,a){const c=createWriter();return a.encode(o,c,{lengthDelimited:!1}),c.finish()}var CODEC_TYPES;(function(o){o[o.VARINT=0]="VARINT",o[o.BIT64=1]="BIT64",o[o.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",o[o.START_GROUP=3]="START_GROUP",o[o.END_GROUP=4]="END_GROUP",o[o.BIT32=5]="BIT32"})(CODEC_TYPES||(CODEC_TYPES={}));function createCodec(o,a,c,d){return{name:o,type:a,encode:c,decode:d}}function enumeration(o){function a(tt){if(o[tt.toString()]==null)throw new Error("Invalid enum value");return o[tt]}const c=function(nt,$a){const Ys=a(nt);$a.int32(Ys)},d=function(nt){const $a=nt.int32();return a($a)};return createCodec("enum",CODEC_TYPES.VARINT,c,d)}function message(o,a){return createCodec("message",CODEC_TYPES.LENGTH_DELIMITED,o,a)}var KeyType;(function(o){o.RSA="RSA",o.Ed25519="Ed25519",o.Secp256k1="Secp256k1"})(KeyType||(KeyType={}));var __KeyTypeValues;(function(o){o[o.RSA=0]="RSA",o[o.Ed25519=1]="Ed25519",o[o.Secp256k1=2]="Secp256k1"})(__KeyTypeValues||(__KeyTypeValues={}));(function(o){o.codec=()=>enumeration(__KeyTypeValues)})(KeyType||(KeyType={}));var PublicKey$2;(function(o){let a;o.codec=()=>(a==null&&(a=message((c,d,tt={})=>{tt.lengthDelimited!==!1&&d.fork(),c.Type!=null&&(d.uint32(8),KeyType.codec().encode(c.Type,d)),c.Data!=null&&(d.uint32(18),d.bytes(c.Data)),tt.lengthDelimited!==!1&&d.ldelim()},(c,d)=>{const tt={},nt=d==null?c.len:c.pos+d;for(;c.pos>>3){case 1:tt.Type=KeyType.codec().decode(c);break;case 2:tt.Data=c.bytes();break;default:c.skipType($a&7);break}}return tt})),a),o.encode=c=>encodeMessage(c,o.codec()),o.decode=c=>decodeMessage(c,o.codec())})(PublicKey$2||(PublicKey$2={}));var PrivateKey;(function(o){let a;o.codec=()=>(a==null&&(a=message((c,d,tt={})=>{tt.lengthDelimited!==!1&&d.fork(),c.Type!=null&&(d.uint32(8),KeyType.codec().encode(c.Type,d)),c.Data!=null&&(d.uint32(18),d.bytes(c.Data)),tt.lengthDelimited!==!1&&d.ldelim()},(c,d)=>{const tt={},nt=d==null?c.len:c.pos+d;for(;c.pos>>3){case 1:tt.Type=KeyType.codec().decode(c);break;case 2:tt.Data=c.bytes();break;default:c.skipType($a&7);break}}return tt})),a),o.encode=c=>encodeMessage(c,o.codec()),o.decode=c=>decodeMessage(c,o.codec())})(PrivateKey||(PrivateKey={}));class Ed25519PublicKey{constructor(a){aw(this,"_key");this._key=ensureKey(a,PUBLIC_KEY_BYTE_LENGTH)}verify(a,c){return hashAndVerify$2(this._key,c,a)}marshal(){return this._key}get bytes(){return PublicKey$2.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}}class Ed25519PrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=ensureKey(a,PRIVATE_KEY_BYTE_LENGTH),this._publicKey=ensureKey(c,PUBLIC_KEY_BYTE_LENGTH)}sign(a){return hashAndSign$2(this._key,a)}get public(){return new Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Ed25519,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}async hash(){const a=sha256$6.digest(this.bytes);let c;return isPromise(a)?{bytes:c}=await a:c=a.bytes,c}async id(){const a=identity$2.digest(this.public.bytes);return base58btc.encode(a.bytes).substring(1)}async export(a,c="libp2p-key"){if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalEd25519PrivateKey(o){if(o.length>PRIVATE_KEY_BYTE_LENGTH){o=ensureKey(o,PRIVATE_KEY_BYTE_LENGTH+PUBLIC_KEY_BYTE_LENGTH);const d=o.subarray(0,PRIVATE_KEY_BYTE_LENGTH),tt=o.subarray(PRIVATE_KEY_BYTE_LENGTH,o.length);return new Ed25519PrivateKey(d,tt)}o=ensureKey(o,PRIVATE_KEY_BYTE_LENGTH);const a=o.subarray(0,PRIVATE_KEY_BYTE_LENGTH),c=o.subarray(PUBLIC_KEY_BYTE_LENGTH);return new Ed25519PrivateKey(a,c)}function unmarshalEd25519PublicKey(o){return o=ensureKey(o,PUBLIC_KEY_BYTE_LENGTH),new Ed25519PublicKey(o)}async function generateKeyPair$3(){const{privateKey:o,publicKey:a}=generateKey$2();return new Ed25519PrivateKey(o,a)}async function generateKeyPairFromSeed(o){const{privateKey:a,publicKey:c}=generateKeyFromSeed(o);return new Ed25519PrivateKey(a,c)}function ensureKey(o,a){if(o=Uint8Array.from(o??[]),o.length!==a)throw new CodeError(`Key must be a Uint8Array of length ${a}, got ${o.length}`,"ERR_INVALID_KEY_TYPE");return o}const Ed25519=Object.freeze(Object.defineProperty({__proto__:null,Ed25519PrivateKey,Ed25519PublicKey,generateKeyPair:generateKeyPair$3,generateKeyPairFromSeed,unmarshalEd25519PrivateKey,unmarshalEd25519PublicKey},Symbol.toStringTag,{value:"Module"}));function toString$b(o,a="utf8"){const c=BASES[a];if(c==null)throw new Error(`Unsupported encoding "${a}"`);return c.encoder.encode(o).substring(1)}function randomBytes$4(o){if(isNaN(o)||o<=0)throw new CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return randomBytes$5(o)}let HMAC$1=class extends Hash$9{constructor(a,c){super(),this.finished=!1,this.destroyed=!1,hash$a(a);const d=toBytes$1(c);if(this.iHash=a.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const tt=this.blockLen,nt=new Uint8Array(tt);nt.set(d.length>tt?a.create().update(d).digest():d);for(let $a=0;$anew HMAC$1(o,a).update(c).digest();hmac$2.create=(o,a)=>new HMAC$1(o,a);function pbkdf2Init(o,a,c,d){hash$a(o);const tt=checkOpts({dkLen:32,asyncTick:10},d),{c:nt,dkLen:$a,asyncTick:Ys}=tt;if(number$3(nt),number$3($a),number$3(Ys),nt<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const gu=toBytes$1(a),xu=toBytes$1(c),$u=new Uint8Array($a),Iu=hmac$2.create(o,gu),Xu=Iu._cloneInto().update(xu);return{c:nt,dkLen:$a,asyncTick:Ys,DK:$u,PRF:Iu,PRFSalt:Xu}}function pbkdf2Output(o,a,c,d,tt){return o.destroy(),a.destroy(),d&&d.destroy(),tt.fill(0),c}async function pbkdf2Async(o,a,c,d){const{c:tt,dkLen:nt,asyncTick:$a,DK:Ys,PRF:gu,PRFSalt:xu}=pbkdf2Init(o,a,c,d);let $u;const Iu=new Uint8Array(4),Xu=createView$1(Iu),i0=new Uint8Array(gu.outputLen);for(let p0=1,w0=0;w0{gu._cloneInto($u).update(i0).digestInto(i0);for(let $0=0;$00&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=d,c+d>a.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):c+d}toBER(a,c){const d=new ArrayBuffer(2);if(!a){const tt=new Uint8Array(d);tt[0]=5,tt[1]=0}return c&&c.write(d),d}onAsciiEncoding(){return`${this.constructor.NAME}`}}_a$t=Null;typeStore.Null=_a$t;Null.NAME="NULL";class LocalBooleanValueBlock extends HexBlock(ValueBlock){constructor({value:a,...c}={}){super(c),c.valueHex?this.valueHexView=BufferSourceConverter.toUint8Array(c.valueHex):this.valueHexView=new Uint8Array(1),a&&(this.value=a)}get value(){for(const a of this.valueHexView)if(a>0)return!0;return!1}set value(a){this.valueHexView[0]=a?255:0}fromBER(a,c,d){const tt=BufferSourceConverter.toUint8Array(a);return checkBufferParams(this,tt,c,d)?(this.valueHexView=tt.subarray(c,c+d),d>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,utilDecodeTC.call(this),this.blockLength=d,c+d):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}LocalBooleanValueBlock.NAME="BooleanValueBlock";var _a$s;let Boolean$1=class extends BaseBlock{constructor(a={}){super(a,LocalBooleanValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(a){this.valueBlock.value=a}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};_a$s=Boolean$1;typeStore.Boolean=_a$s;Boolean$1.NAME="BOOLEAN";class LocalOctetStringValueBlock extends HexBlock(LocalConstructedValueBlock){constructor({isConstructed:a=!1,...c}={}){super(c),this.isConstructed=a}fromBER(a,c,d){let tt=0;if(this.isConstructed){if(this.isHexOnly=!1,tt=LocalConstructedValueBlock.prototype.fromBER.call(this,a,c,d),tt===-1)return tt;for(let nt=0;nt0&&xu.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=xu.unusedBits}return tt}const nt=BufferSourceConverter.toUint8Array(a);if(!checkBufferParams(this,nt,c,d))return-1;const $a=nt.subarray(c,c+d);if(this.unusedBits=$a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const Ys=$a.subarray(1);try{if(Ys.byteLength){const gu=localFromBER(Ys,0,Ys.byteLength);gu.offset!==-1&&gu.offset===d-1&&(this.value=[gu.result])}}catch{}}return this.valueHexView=$a.subarray(1),this.blockLength=$a.length,c+d}toBER(a,c){if(this.isConstructed)return LocalConstructedValueBlock.prototype.toBER.call(this,a,c);if(a)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return EMPTY_BUFFER;const d=new Uint8Array(this.valueHexView.length+1);return d[0]=this.unusedBits,d.set(this.valueHexView,1),d.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}LocalBitStringValueBlock.NAME="BitStringValueBlock";var _a$q;class BitString extends BaseBlock{constructor({idBlock:a={},lenBlock:c={},...d}={}){var tt,nt;(tt=d.isConstructed)!==null&&tt!==void 0||(d.isConstructed=!!(!((nt=d.value)===null||nt===void 0)&&nt.length)),super({idBlock:{isConstructed:d.isConstructed,...a},lenBlock:{...c,isIndefiniteForm:!!d.isIndefiniteForm},...d},LocalBitStringValueBlock),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(a,c,d){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(a,c,d)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Constructed.prototype.onAsciiEncoding.call(this);{const a=[],c=this.valueBlock.valueHexView;for(const tt of c)a.push(tt.toString(2).padStart(8,"0"));const d=a.join("");return`${this.constructor.NAME} : ${d.substring(0,d.length-this.valueBlock.unusedBits)}`}}}_a$q=BitString;typeStore.BitString=_a$q;BitString.NAME=BIT_STRING_NAME;var _a$p;function viewAdd(o,a){const c=new Uint8Array([0]),d=new Uint8Array(o),tt=new Uint8Array(a);let nt=d.slice(0);const $a=nt.length-1,Ys=tt.slice(0),gu=Ys.length-1;let xu=0;const $u=gu<$a?$a:gu;let Iu=0;for(let Xu=$u;Xu>=0;Xu--,Iu++){switch(!0){case Iu=nt.length:nt=utilConcatView(new Uint8Array([xu%10]),nt);break;default:nt[$a-Iu]=xu%10}}return c[0]>0&&(nt=utilConcatView(c,nt)),nt}function power2(o){if(o>=powers2.length)for(let a=powers2.length;a<=o;a++){const c=new Uint8Array([0]);let d=powers2[a-1].slice(0);for(let tt=d.length-1;tt>=0;tt--){const nt=new Uint8Array([(d[tt]<<1)+c[0]]);c[0]=nt[0]/10,d[tt]=nt[0]%10}c[0]>0&&(d=utilConcatView(c,d)),powers2.push(d)}return powers2[o]}function viewSub(o,a){let c=0;const d=new Uint8Array(o),tt=new Uint8Array(a),nt=d.slice(0),$a=nt.length-1,Ys=tt.slice(0),gu=Ys.length-1;let xu,$u=0;for(let Iu=gu;Iu>=0;Iu--,$u++)switch(xu=nt[$a-$u]-Ys[gu-$u]-c,!0){case xu<0:c=1,nt[$a-$u]=xu+10;break;default:c=0,nt[$a-$u]=xu}if(c>0)for(let Iu=$a-gu+1;Iu>=0;Iu--,$u++)if(xu=nt[$a-$u]-c,xu<0)c=1,nt[$a-$u]=xu+10;else{c=0,nt[$a-$u]=xu;break}return nt.slice()}class LocalIntegerValueBlock extends HexBlock(ValueBlock){constructor({value:a,...c}={}){super(c),this._valueDec=0,c.valueHex&&this.setValueHex(),a!==void 0&&(this.valueDec=a)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=utilDecodeTC.call(this)))}set valueDec(a){this._valueDec=a,this.isHexOnly=!1,this.valueHexView=new Uint8Array(utilEncodeTC(a))}get valueDec(){return this._valueDec}fromDER(a,c,d,tt=0){const nt=this.fromBER(a,c,d);if(nt===-1)return nt;const $a=this.valueHexView;return $a[0]===0&&$a[1]&128?this.valueHexView=$a.subarray(1):tt!==0&&$a.length1&&(tt=$a.length+1),this.valueHexView=$a.subarray(tt-$a.length)),nt}toDER(a=!1){const c=this.valueHexView;switch(!0){case(c[0]&128)!==0:{const d=new Uint8Array(this.valueHexView.length+1);d[0]=0,d.set(c,1),this.valueHexView=d}break;case(c[0]===0&&(c[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(a)}fromBER(a,c,d){const tt=super.fromBER(a,c,d);return tt===-1||this.setValueHex(),tt}toBER(a){return a?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const a=this.valueHexView.length*8-1;let c=new Uint8Array(this.valueHexView.length*8/3),d=0,tt;const nt=this.valueHexView;let $a="",Ys=!1;for(let gu=nt.byteLength-1;gu>=0;gu--){tt=nt[gu];for(let xu=0;xu<8;xu++){if((tt&1)===1)switch(d){case a:c=viewSub(power2(d),c),$a="-";break;default:c=viewAdd(c,power2(d))}d++,tt>>=1}}for(let gu=0;gu0;){const nt=new LocalSidValueBlock;if(tt=nt.fromBER(a,tt,d),tt===-1)return this.blockLength=0,this.error=nt.error,tt;this.value.length===0&&(nt.isFirstSid=!0),this.blockLength+=nt.blockLength,d-=nt.blockLength,this.value.push(nt)}return tt}toBER(a){const c=[];for(let d=0;dNumber.MAX_SAFE_INTEGER){assertBigInt();const Ys=BigInt(tt);$a.valueBigInt=Ys}else if($a.valueDec=parseInt(tt,10),isNaN($a.valueDec))return;this.value.length||($a.isFirstSid=!0,nt=!0),this.value.push($a)}while(d!==-1)}toString(){let a="",c=!1;for(let d=0;d0;){const nt=new LocalRelativeSidValueBlock;if(tt=nt.fromBER(a,tt,d),tt===-1)return this.blockLength=0,this.error=nt.error,tt;this.blockLength+=nt.blockLength,d-=nt.blockLength,this.value.push(nt)}return tt}toBER(a,c){const d=[];for(let tt=0;tt4)continue;const Ys=4-$a.length;for(let gu=$a.length-1;gu>=0;gu--)d[tt*4+gu+Ys]=$a[gu]}this.valueBlock.value=a}}LocalUniversalStringValueBlock.NAME="UniversalStringValueBlock";var _a$g;class UniversalString extends LocalUniversalStringValueBlock{constructor({...a}={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_a$g=UniversalString;typeStore.UniversalString=_a$g;UniversalString.NAME="UniversalString";var _a$f;class NumericString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_a$f=NumericString;typeStore.NumericString=_a$f;NumericString.NAME="NumericString";var _a$e;class PrintableString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}_a$e=PrintableString;typeStore.PrintableString=_a$e;PrintableString.NAME="PrintableString";var _a$d;class TeletexString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}_a$d=TeletexString;typeStore.TeletexString=_a$d;TeletexString.NAME="TeletexString";var _a$c;class VideotexString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}_a$c=VideotexString;typeStore.VideotexString=_a$c;VideotexString.NAME="VideotexString";var _a$b;class IA5String extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}_a$b=IA5String;typeStore.IA5String=_a$b;IA5String.NAME="IA5String";var _a$a;class GraphicString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}_a$a=GraphicString;typeStore.GraphicString=_a$a;GraphicString.NAME="GraphicString";var _a$9;class VisibleString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_a$9=VisibleString;typeStore.VisibleString=_a$9;VisibleString.NAME="VisibleString";var _a$8;class GeneralString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_a$8=GeneralString;typeStore.GeneralString=_a$8;GeneralString.NAME="GeneralString";var _a$7;class CharacterString extends LocalSimpleStringBlock{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}_a$7=CharacterString;typeStore.CharacterString=_a$7;CharacterString.NAME="CharacterString";var _a$6;class UTCTime extends VisibleString{constructor({value:a,valueDate:c,...d}={}){if(super(d),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,a){this.fromString(a),this.valueBlock.valueHexView=new Uint8Array(a.length);for(let tt=0;tt=50?this.year=1900+tt:this.year=2e3+tt,this.month=parseInt(d[2],10),this.day=parseInt(d[3],10),this.hour=parseInt(d[4],10),this.minute=parseInt(d[5],10),this.second=parseInt(d[6],10)}toString(a="iso"){if(a==="iso"){const c=new Array(7);return c[0]=padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),c[1]=padNumber(this.month,2),c[2]=padNumber(this.day,2),c[3]=padNumber(this.hour,2),c[4]=padNumber(this.minute,2),c[5]=padNumber(this.second,2),c[6]="Z",c.join("")}return super.toString(a)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}_a$6=UTCTime;typeStore.UTCTime=_a$6;UTCTime.NAME="UTCTime";var _a$5;class GeneralizedTime extends UTCTime{constructor(a={}){var c;super(a),(c=this.millisecond)!==null&&c!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(a){super.fromDate(a),this.millisecond=a.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(a){let c=!1,d="",tt="",nt=0,$a,Ys=0,gu=0;if(a[a.length-1]==="Z")d=a.substring(0,a.length-1),c=!0;else{const Iu=new Number(a[a.length-1]);if(isNaN(Iu.valueOf()))throw new Error("Wrong input string for conversion");d=a}if(c){if(d.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(d.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let Iu=1,Xu=d.indexOf("+"),i0="";if(Xu===-1&&(Xu=d.indexOf("-"),Iu=-1),Xu!==-1){if(i0=d.substring(Xu+1),d=d.substring(0,Xu),i0.length!==2&&i0.length!==4)throw new Error("Wrong input string for conversion");let p0=parseInt(i0.substring(0,2),10);if(isNaN(p0.valueOf()))throw new Error("Wrong input string for conversion");if(Ys=Iu*p0,i0.length===4){if(p0=parseInt(i0.substring(2,4),10),isNaN(p0.valueOf()))throw new Error("Wrong input string for conversion");gu=Iu*p0}}}let xu=d.indexOf(".");if(xu===-1&&(xu=d.indexOf(",")),xu!==-1){const Iu=new Number(`0${d.substring(xu)}`);if(isNaN(Iu.valueOf()))throw new Error("Wrong input string for conversion");nt=Iu.valueOf(),tt=d.substring(0,xu)}else tt=d;switch(!0){case tt.length===8:if($a=/(\d{4})(\d{2})(\d{2})/ig,xu!==-1)throw new Error("Wrong input string for conversion");break;case tt.length===10:if($a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,xu!==-1){let Iu=60*nt;this.minute=Math.floor(Iu),Iu=60*(Iu-this.minute),this.second=Math.floor(Iu),Iu=1e3*(Iu-this.second),this.millisecond=Math.floor(Iu)}break;case tt.length===12:if($a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,xu!==-1){let Iu=60*nt;this.second=Math.floor(Iu),Iu=1e3*(Iu-this.second),this.millisecond=Math.floor(Iu)}break;case tt.length===14:if($a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,xu!==-1){const Iu=1e3*nt;this.millisecond=Math.floor(Iu)}break;default:throw new Error("Wrong input string for conversion")}const $u=$a.exec(tt);if($u===null)throw new Error("Wrong input string for conversion");for(let Iu=1;Iu<$u.length;Iu++)switch(Iu){case 1:this.year=parseInt($u[Iu],10);break;case 2:this.month=parseInt($u[Iu],10);break;case 3:this.day=parseInt($u[Iu],10);break;case 4:this.hour=parseInt($u[Iu],10)+Ys;break;case 5:this.minute=parseInt($u[Iu],10)+gu;break;case 6:this.second=parseInt($u[Iu],10);break;default:throw new Error("Wrong input string for conversion")}if(c===!1){const Iu=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=Iu.getUTCFullYear(),this.month=Iu.getUTCMonth(),this.day=Iu.getUTCDay(),this.hour=Iu.getUTCHours(),this.minute=Iu.getUTCMinutes(),this.second=Iu.getUTCSeconds(),this.millisecond=Iu.getUTCMilliseconds()}}toString(a="iso"){if(a==="iso"){const c=[];return c.push(padNumber(this.year,4)),c.push(padNumber(this.month,2)),c.push(padNumber(this.day,2)),c.push(padNumber(this.hour,2)),c.push(padNumber(this.minute,2)),c.push(padNumber(this.second,2)),this.millisecond!==0&&(c.push("."),c.push(padNumber(this.millisecond,3))),c.push("Z"),c.join("")}return super.toString(a)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}_a$5=GeneralizedTime;typeStore.GeneralizedTime=_a$5;GeneralizedTime.NAME="GeneralizedTime";var _a$4;class DATE extends Utf8String{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}_a$4=DATE;typeStore.DATE=_a$4;DATE.NAME="DATE";var _a$3;class TimeOfDay extends Utf8String{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}_a$3=TimeOfDay;typeStore.TimeOfDay=_a$3;TimeOfDay.NAME="TimeOfDay";var _a$2;class DateTime extends Utf8String{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}_a$2=DateTime;typeStore.DateTime=_a$2;DateTime.NAME="DateTime";var _a$1$1;class Duration extends Utf8String{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}_a$1$1=Duration;typeStore.Duration=_a$1$1;Duration.NAME="Duration";var _a$x;let TIME$1=class extends Utf8String{constructor(a={}){super(a),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};_a$x=TIME$1;typeStore.TIME=_a$x;TIME$1.NAME="TIME";function pkcs1ToJwk(o){const{result:a}=fromBER(o),c=a.valueBlock.value;return{n:toString$b(bnToBuf(c[1].toBigInt()),"base64url"),e:toString$b(bnToBuf(c[2].toBigInt()),"base64url"),d:toString$b(bnToBuf(c[3].toBigInt()),"base64url"),p:toString$b(bnToBuf(c[4].toBigInt()),"base64url"),q:toString$b(bnToBuf(c[5].toBigInt()),"base64url"),dp:toString$b(bnToBuf(c[6].toBigInt()),"base64url"),dq:toString$b(bnToBuf(c[7].toBigInt()),"base64url"),qi:toString$b(bnToBuf(c[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function jwkToPkcs1(o){if(o.n==null||o.e==null||o.d==null||o.p==null||o.q==null||o.dp==null||o.dq==null||o.qi==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const c=new Sequence({value:[new Integer({value:0}),Integer.fromBigInt(bufToBn(fromString(o.n,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.e,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.d,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.p,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.q,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.dp,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.dq,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.qi,"base64url")))]}).toBER();return new Uint8Array(c,0,c.byteLength)}function pkixToJwk(o){const{result:a}=fromBER(o),c=a.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:toString$b(bnToBuf(c[0].toBigInt()),"base64url"),e:toString$b(bnToBuf(c[1].toBigInt()),"base64url")}}function jwkToPkix(o){if(o.n==null||o.e==null)throw new CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");const c=new Sequence({value:[new Sequence({value:[new ObjectIdentifier({value:"1.2.840.113549.1.1.1"}),new Null]}),new BitString({valueHex:new Sequence({value:[Integer.fromBigInt(bufToBn(fromString(o.n,"base64url"))),Integer.fromBigInt(bufToBn(fromString(o.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(c,0,c.byteLength)}function bnToBuf(o){let a=o.toString(16);a.length%2>0&&(a=`0${a}`);const c=a.length/2,d=new Uint8Array(c);let tt=0,nt=0;for(;tt0&&(d=`0${d}`),a.push(d)}),BigInt("0x"+a.join(""))}const SALT_LENGTH=16,KEY_SIZE=32,ITERATIONS=1e4;async function exportToPem(o,a){const c=webcrypto.get(),tt=new Sequence({value:[new Integer({value:0}),new Sequence({value:[new ObjectIdentifier({value:"1.2.840.113549.1.1.1"}),new Null]}),new OctetString({valueHex:o.marshal()})]}).toBER(),nt=new Uint8Array(tt,0,tt.byteLength),$a=randomBytes$4(SALT_LENGTH),Ys=await pbkdf2Async(sha512$3,a,$a,{c:ITERATIONS,dkLen:KEY_SIZE}),gu=randomBytes$4(16),xu=await c.subtle.importKey("raw",Ys,"AES-CBC",!1,["encrypt"]),$u=await c.subtle.encrypt({name:"AES-CBC",iv:gu},xu,nt),Iu=new Sequence({value:[new OctetString({valueHex:$a}),new Integer({value:ITERATIONS}),new Integer({value:KEY_SIZE}),new Sequence({value:[new ObjectIdentifier({value:"1.2.840.113549.2.11"}),new Null]})]}),Xu=new Sequence({value:[new ObjectIdentifier({value:"1.2.840.113549.1.5.13"}),new Sequence({value:[new Sequence({value:[new ObjectIdentifier({value:"1.2.840.113549.1.5.12"}),Iu]}),new Sequence({value:[new ObjectIdentifier({value:"2.16.840.1.101.3.4.1.42"}),new OctetString({valueHex:gu})]})]})]}),p0=new Sequence({value:[Xu,new OctetString({valueHex:$u})]}).toBER(),w0=new Uint8Array(p0,0,p0.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...toString$b(w0,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(` -`)}async function generateKey$1(o){const a=await webcrypto.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:o,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),c=await exportKey(a);return{privateKey:c[0],publicKey:c[1]}}async function unmarshalPrivateKey$1(o){const c=[await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await derivePublicFromPrivate(o)],d=await exportKey({privateKey:c[0],publicKey:c[1]});return{privateKey:d[0],publicKey:d[1]}}async function hashAndSign$1(o,a){const c=await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),d=await webcrypto.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},c,a instanceof Uint8Array?a:a.subarray());return new Uint8Array(d,0,d.byteLength)}async function hashAndVerify$1(o,a,c){const d=await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return webcrypto.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},d,a,c instanceof Uint8Array?c:c.subarray())}async function exportKey(o){if(o.privateKey==null||o.publicKey==null)throw new CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([webcrypto.get().subtle.exportKey("jwk",o.privateKey),webcrypto.get().subtle.exportKey("jwk",o.publicKey)])}async function derivePublicFromPrivate(o){return webcrypto.get().subtle.importKey("jwk",{kty:o.kty,n:o.n,e:o.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function keySize(o){if(o.kty!=="RSA")throw new CodeError("invalid key type","ERR_INVALID_KEY_TYPE");if(o.n==null)throw new CodeError("invalid key modulus","ERR_INVALID_KEY_MODULUS");return fromString(o.n,"base64url").length*8}const MAX_RSA_KEY_SIZE=8192;class RsaPublicKey{constructor(a){aw(this,"_key");this._key=a}verify(a,c){return hashAndVerify$1(this._key,c,a)}marshal(){return jwkToPkix(this._key)}get bytes(){return PublicKey$2.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}}class RsaPrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=a,this._publicKey=c}genSecret(){return randomBytes$4(16)}sign(a){return hashAndSign$1(this._key,a)}get public(){if(this._publicKey==null)throw new CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new RsaPublicKey(this._publicKey)}marshal(){return jwkToPkcs1(this._key)}get bytes(){return PrivateKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}async id(){const a=await this.public.hash();return toString$b(a,"base58btc")}async export(a,c="pkcs-8"){if(c==="pkcs-8")return exportToPem(this,a);if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function unmarshalRsaPrivateKey(o){const a=pkcs1ToJwk(o);if(keySize(a)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const c=await unmarshalPrivateKey$1(a);return new RsaPrivateKey(c.privateKey,c.publicKey)}function unmarshalRsaPublicKey(o){const a=pkixToJwk(o);if(keySize(a)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new RsaPublicKey(a)}async function fromJwk(o){if(keySize(o)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const a=await unmarshalPrivateKey$1(o);return new RsaPrivateKey(a.privateKey,a.publicKey)}async function generateKeyPair$2(o){if(o>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const a=await generateKey$1(o);return new RsaPrivateKey(a.privateKey,a.publicKey)}const RSA=Object.freeze(Object.defineProperty({__proto__:null,MAX_RSA_KEY_SIZE,RsaPrivateKey,RsaPublicKey,fromJwk,generateKeyPair:generateKeyPair$2,unmarshalRsaPrivateKey,unmarshalRsaPublicKey},Symbol.toStringTag,{value:"Module"})),SHA256_K$2=new Uint32Array([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]),SHA256_IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$2=new Uint32Array(64);let SHA256$4=class extends HashMD{constructor(){super(64,32,8,!1),this.A=SHA256_IV[0]|0,this.B=SHA256_IV[1]|0,this.C=SHA256_IV[2]|0,this.D=SHA256_IV[3]|0,this.E=SHA256_IV[4]|0,this.F=SHA256_IV[5]|0,this.G=SHA256_IV[6]|0,this.H=SHA256_IV[7]|0}get(){const{A:a,B:c,C:d,D:tt,E:nt,F:$a,G:Ys,H:gu}=this;return[a,c,d,tt,nt,$a,Ys,gu]}set(a,c,d,tt,nt,$a,Ys,gu){this.A=a|0,this.B=c|0,this.C=d|0,this.D=tt|0,this.E=nt|0,this.F=$a|0,this.G=Ys|0,this.H=gu|0}process(a,c){for(let Iu=0;Iu<16;Iu++,c+=4)SHA256_W$2[Iu]=a.getUint32(c,!1);for(let Iu=16;Iu<64;Iu++){const Xu=SHA256_W$2[Iu-15],i0=SHA256_W$2[Iu-2],p0=rotr$1(Xu,7)^rotr$1(Xu,18)^Xu>>>3,w0=rotr$1(i0,17)^rotr$1(i0,19)^i0>>>10;SHA256_W$2[Iu]=w0+SHA256_W$2[Iu-7]+p0+SHA256_W$2[Iu-16]|0}let{A:d,B:tt,C:nt,D:$a,E:Ys,F:gu,G:xu,H:$u}=this;for(let Iu=0;Iu<64;Iu++){const Xu=rotr$1(Ys,6)^rotr$1(Ys,11)^rotr$1(Ys,25),i0=$u+Xu+Chi$2(Ys,gu,xu)+SHA256_K$2[Iu]+SHA256_W$2[Iu]|0,w0=(rotr$1(d,2)^rotr$1(d,13)^rotr$1(d,22))+Maj$2(d,tt,nt)|0;$u=xu,xu=gu,gu=Ys,Ys=$a+i0|0,$a=nt,nt=tt,tt=d,d=i0+w0|0}d=d+this.A|0,tt=tt+this.B|0,nt=nt+this.C|0,$a=$a+this.D|0,Ys=Ys+this.E|0,gu=gu+this.F|0,xu=xu+this.G|0,$u=$u+this.H|0,this.set(d,tt,nt,$a,Ys,gu,xu,$u)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$5=wrapConstructor$1(()=>new SHA256$4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts$1(o){const a=validateBasic$2(o);validateObject$2(a,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:c,Fp:d,a:tt}=a;if(c){if(!d.eql(tt,d.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof c!="object"||typeof c.beta!="bigint"||typeof c.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...a})}const{bytesToNumberBE:b2n$1,hexToBytes:h2b$1}=ut$4,DER$1={Err:class extends Error{constructor(a=""){super(a)}},_parseInt(o){const{Err:a}=DER$1;if(o.length<2||o[0]!==2)throw new a("Invalid signature integer tag");const c=o[1],d=o.subarray(2,c+2);if(!c||d.length!==c)throw new a("Invalid signature integer: wrong length");if(d[0]&128)throw new a("Invalid signature integer: negative");if(d[0]===0&&!(d[1]&128))throw new a("Invalid signature integer: unnecessary leading zero");return{d:b2n$1(d),l:o.subarray(c+2)}},toSig(o){const{Err:a}=DER$1,c=typeof o=="string"?h2b$1(o):o;abytes(c);let d=c.length;if(d<2||c[0]!=48)throw new a("Invalid signature tag");if(c[1]!==d-2)throw new a("Invalid signature: incorrect length");const{d:tt,l:nt}=DER$1._parseInt(c.subarray(2)),{d:$a,l:Ys}=DER$1._parseInt(nt);if(Ys.length)throw new a("Invalid signature: left bytes after parsing");return{r:tt,s:$a}},hexFromSig(o){const a=xu=>Number.parseInt(xu[0],16)&8?"00"+xu:xu,c=xu=>{const $u=xu.toString(16);return $u.length&1?`0${$u}`:$u},d=a(c(o.s)),tt=a(c(o.r)),nt=d.length/2,$a=tt.length/2,Ys=c(nt),gu=c($a);return`30${c($a+nt+4)}02${gu}${tt}02${Ys}${d}`}},_0n$b=BigInt(0),_1n$c=BigInt(1),_2n$8=BigInt(2),_3n$3=BigInt(3),_4n$2=BigInt(4);function weierstrassPoints$1(o){const a=validatePointOpts$1(o),{Fp:c}=a,d=a.toBytes||((p0,w0,A0)=>{const $0=w0.toAffine();return concatBytes$3(Uint8Array.from([4]),c.toBytes($0.x),c.toBytes($0.y))}),tt=a.fromBytes||(p0=>{const w0=p0.subarray(1),A0=c.fromBytes(w0.subarray(0,c.BYTES)),$0=c.fromBytes(w0.subarray(c.BYTES,2*c.BYTES));return{x:A0,y:$0}});function nt(p0){const{a:w0,b:A0}=a,$0=c.sqr(p0),O0=c.mul($0,p0);return c.add(c.add(O0,c.mul(p0,w0)),A0)}if(!c.eql(c.sqr(a.Gy),nt(a.Gx)))throw new Error("bad generator point: equation left != right");function $a(p0){return typeof p0=="bigint"&&_0n$bc.eql(L0,c.ZERO);return O0(A0)&&O0($0)?Iu.ZERO:new Iu(A0,$0,c.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w0){const A0=c.invertBatch(w0.map($0=>$0.pz));return w0.map(($0,O0)=>$0.toAffine(A0[O0])).map(Iu.fromAffine)}static fromHex(w0){const A0=Iu.fromAffine(tt(ensureBytes$3("pointHex",w0)));return A0.assertValidity(),A0}static fromPrivateKey(w0){return Iu.BASE.multiply(gu(w0))}_setWindowSize(w0){this._WINDOW_SIZE=w0,xu.delete(this)}assertValidity(){if(this.is0()){if(a.allowInfinityPoint&&!c.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:w0,y:A0}=this.toAffine();if(!c.isValid(w0)||!c.isValid(A0))throw new Error("bad point: x or y not FE");const $0=c.sqr(A0),O0=nt(w0);if(!c.eql($0,O0))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:w0}=this.toAffine();if(c.isOdd)return!c.isOdd(w0);throw new Error("Field doesn't support isOdd")}equals(w0){$u(w0);const{px:A0,py:$0,pz:O0}=this,{px:L0,py:q0,pz:F0}=w0,u1=c.eql(c.mul(A0,F0),c.mul(L0,O0)),g1=c.eql(c.mul($0,F0),c.mul(q0,O0));return u1&&g1}negate(){return new Iu(this.px,c.neg(this.py),this.pz)}double(){const{a:w0,b:A0}=a,$0=c.mul(A0,_3n$3),{px:O0,py:L0,pz:q0}=this;let F0=c.ZERO,u1=c.ZERO,g1=c.ZERO,E1=c.mul(O0,O0),B1=c.mul(L0,L0),lv=c.mul(q0,q0),j1=c.mul(O0,L0);return j1=c.add(j1,j1),g1=c.mul(O0,q0),g1=c.add(g1,g1),F0=c.mul(w0,g1),u1=c.mul($0,lv),u1=c.add(F0,u1),F0=c.sub(B1,u1),u1=c.add(B1,u1),u1=c.mul(F0,u1),F0=c.mul(j1,F0),g1=c.mul($0,g1),lv=c.mul(w0,lv),j1=c.sub(E1,lv),j1=c.mul(w0,j1),j1=c.add(j1,g1),g1=c.add(E1,E1),E1=c.add(g1,E1),E1=c.add(E1,lv),E1=c.mul(E1,j1),u1=c.add(u1,E1),lv=c.mul(L0,q0),lv=c.add(lv,lv),E1=c.mul(lv,j1),F0=c.sub(F0,E1),g1=c.mul(lv,B1),g1=c.add(g1,g1),g1=c.add(g1,g1),new Iu(F0,u1,g1)}add(w0){$u(w0);const{px:A0,py:$0,pz:O0}=this,{px:L0,py:q0,pz:F0}=w0;let u1=c.ZERO,g1=c.ZERO,E1=c.ZERO;const B1=a.a,lv=c.mul(a.b,_3n$3);let j1=c.mul(A0,L0),r1=c.mul($0,q0),t1=c.mul(O0,F0),D0=c.add(A0,$0),Z0=c.add(L0,q0);D0=c.mul(D0,Z0),Z0=c.add(j1,r1),D0=c.sub(D0,Z0),Z0=c.add(A0,O0);let f1=c.add(L0,F0);return Z0=c.mul(Z0,f1),f1=c.add(j1,t1),Z0=c.sub(Z0,f1),f1=c.add($0,O0),u1=c.add(q0,F0),f1=c.mul(f1,u1),u1=c.add(r1,t1),f1=c.sub(f1,u1),E1=c.mul(B1,Z0),u1=c.mul(lv,t1),E1=c.add(u1,E1),u1=c.sub(r1,E1),E1=c.add(r1,E1),g1=c.mul(u1,E1),r1=c.add(j1,j1),r1=c.add(r1,j1),t1=c.mul(B1,t1),Z0=c.mul(lv,Z0),r1=c.add(r1,t1),t1=c.sub(j1,t1),t1=c.mul(B1,t1),Z0=c.add(Z0,t1),j1=c.mul(r1,Z0),g1=c.add(g1,j1),j1=c.mul(f1,Z0),u1=c.mul(D0,u1),u1=c.sub(u1,j1),j1=c.mul(D0,r1),E1=c.mul(f1,E1),E1=c.add(E1,j1),new Iu(u1,g1,E1)}subtract(w0){return this.add(w0.negate())}is0(){return this.equals(Iu.ZERO)}wNAF(w0){return i0.wNAFCached(this,xu,w0,A0=>{const $0=c.invertBatch(A0.map(O0=>O0.pz));return A0.map((O0,L0)=>O0.toAffine($0[L0])).map(Iu.fromAffine)})}multiplyUnsafe(w0){const A0=Iu.ZERO;if(w0===_0n$b)return A0;if(Ys(w0),w0===_1n$c)return this;const{endo:$0}=a;if(!$0)return i0.unsafeLadder(this,w0);let{k1neg:O0,k1:L0,k2neg:q0,k2:F0}=$0.splitScalar(w0),u1=A0,g1=A0,E1=this;for(;L0>_0n$b||F0>_0n$b;)L0&_1n$c&&(u1=u1.add(E1)),F0&_1n$c&&(g1=g1.add(E1)),E1=E1.double(),L0>>=_1n$c,F0>>=_1n$c;return O0&&(u1=u1.negate()),q0&&(g1=g1.negate()),g1=new Iu(c.mul(g1.px,$0.beta),g1.py,g1.pz),u1.add(g1)}multiply(w0){Ys(w0);let A0=w0,$0,O0;const{endo:L0}=a;if(L0){const{k1neg:q0,k1:F0,k2neg:u1,k2:g1}=L0.splitScalar(A0);let{p:E1,f:B1}=this.wNAF(F0),{p:lv,f:j1}=this.wNAF(g1);E1=i0.constTimeNegate(q0,E1),lv=i0.constTimeNegate(u1,lv),lv=new Iu(c.mul(lv.px,L0.beta),lv.py,lv.pz),$0=E1.add(lv),O0=B1.add(j1)}else{const{p:q0,f:F0}=this.wNAF(A0);$0=q0,O0=F0}return Iu.normalizeZ([$0,O0])[0]}multiplyAndAddUnsafe(w0,A0,$0){const O0=Iu.BASE,L0=(F0,u1)=>u1===_0n$b||u1===_1n$c||!F0.equals(O0)?F0.multiplyUnsafe(u1):F0.multiply(u1),q0=L0(this,A0).add(L0(w0,$0));return q0.is0()?void 0:q0}toAffine(w0){const{px:A0,py:$0,pz:O0}=this,L0=this.is0();w0==null&&(w0=L0?c.ONE:c.inv(O0));const q0=c.mul(A0,w0),F0=c.mul($0,w0),u1=c.mul(O0,w0);if(L0)return{x:c.ZERO,y:c.ZERO};if(!c.eql(u1,c.ONE))throw new Error("invZ was invalid");return{x:q0,y:F0}}isTorsionFree(){const{h:w0,isTorsionFree:A0}=a;if(w0===_1n$c)return!0;if(A0)return A0(Iu,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w0,clearCofactor:A0}=a;return w0===_1n$c?this:A0?A0(Iu,this):this.multiplyUnsafe(a.h)}toRawBytes(w0=!0){return this.assertValidity(),d(Iu,this,w0)}toHex(w0=!0){return bytesToHex$2(this.toRawBytes(w0))}}Iu.BASE=new Iu(a.Gx,a.Gy,c.ONE),Iu.ZERO=new Iu(c.ZERO,c.ONE,c.ZERO);const Xu=a.nBitLength,i0=wNAF$2(Iu,a.endo?Math.ceil(Xu/2):Xu);return{CURVE:a,ProjectivePoint:Iu,normPrivateKeyToScalar:gu,weierstrassEquation:nt,isWithinCurveOrder:$a}}function validateOpts$5(o){const a=validateBasic$2(o);return validateObject$2(a,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...a})}function weierstrass$1(o){const a=validateOpts$5(o),{Fp:c,n:d}=a,tt=c.BYTES+1,nt=2*c.BYTES+1;function $a(Z0){return _0n$bbytesToHex$2(numberToBytesBE$2(Z0,a.nByteLength));function p0(Z0){const f1=d>>_1n$c;return Z0>f1}function w0(Z0){return p0(Z0)?Ys(-Z0):Z0}const A0=(Z0,f1,w1)=>bytesToNumberBE$2(Z0.slice(f1,w1));class $0{constructor(f1,w1,m1){this.r=f1,this.s=w1,this.recovery=m1,this.assertValidity()}static fromCompact(f1){const w1=a.nByteLength;return f1=ensureBytes$3("compactSignature",f1,w1*2),new $0(A0(f1,0,w1),A0(f1,w1,2*w1))}static fromDER(f1){const{r:w1,s:m1}=DER$1.toSig(ensureBytes$3("DER",f1));return new $0(w1,m1)}assertValidity(){if(!Xu(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!Xu(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(f1){return new $0(this.r,this.s,f1)}recoverPublicKey(f1){const{r:w1,s:m1,recovery:c1}=this,G0=g1(ensureBytes$3("msgHash",f1));if(c1==null||![0,1,2,3].includes(c1))throw new Error("recovery id invalid");const o1=c1===2||c1===3?w1+a.n:w1;if(o1>=c.ORDER)throw new Error("recovery id 2 or 3 invalid");const d1=c1&1?"03":"02",R1=xu.fromHex(d1+i0(o1)),O1=gu(o1),Q1=Ys(-G0*O1),rv=Ys(m1*O1),D1=xu.BASE.multiplyAndAddUnsafe(R1,Q1,rv);if(!D1)throw new Error("point at infinify");return D1.assertValidity(),D1}hasHighS(){return p0(this.s)}normalizeS(){return this.hasHighS()?new $0(this.r,Ys(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$3(this.toDERHex())}toDERHex(){return DER$1.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$3(this.toCompactHex())}toCompactHex(){return i0(this.r)+i0(this.s)}}const O0={isValidPrivateKey(Z0){try{return $u(Z0),!0}catch{return!1}},normPrivateKeyToScalar:$u,randomPrivateKey:()=>{const Z0=getMinHashLength$2(a.n);return mapHashToField$2(a.randomBytes(Z0),a.n)},precompute(Z0=8,f1=xu.BASE){return f1._setWindowSize(Z0),f1.multiply(BigInt(3)),f1}};function L0(Z0,f1=!0){return xu.fromPrivateKey(Z0).toRawBytes(f1)}function q0(Z0){const f1=isBytes$6(Z0),w1=typeof Z0=="string",m1=(f1||w1)&&Z0.length;return f1?m1===tt||m1===nt:w1?m1===2*tt||m1===2*nt:Z0 instanceof xu}function F0(Z0,f1,w1=!0){if(q0(Z0))throw new Error("first arg must be private key");if(!q0(f1))throw new Error("second arg must be public key");return xu.fromHex(f1).multiply($u(Z0)).toRawBytes(w1)}const u1=a.bits2int||function(Z0){const f1=bytesToNumberBE$2(Z0),w1=Z0.length*8-a.nBitLength;return w1>0?f1>>BigInt(w1):f1},g1=a.bits2int_modN||function(Z0){return Ys(u1(Z0))},E1=bitMask$2(a.nBitLength);function B1(Z0){if(typeof Z0!="bigint")throw new Error("bigint expected");if(!(_0n$b<=Z0&&Z0Mv in w1))throw new Error("sign() legacy options not supported");const{hash:m1,randomBytes:c1}=a;let{lowS:G0,prehash:o1,extraEntropy:d1}=w1;G0==null&&(G0=!0),Z0=ensureBytes$3("msgHash",Z0),o1&&(Z0=ensureBytes$3("prehashed msgHash",m1(Z0)));const R1=g1(Z0),O1=$u(f1),Q1=[B1(O1),B1(R1)];if(d1!=null&&d1!==!1){const Mv=d1===!0?c1(c.BYTES):d1;Q1.push(ensureBytes$3("extraEntropy",Mv))}const rv=concatBytes$3(...Q1),D1=R1;function ev(Mv){const Zv=u1(Mv);if(!Xu(Zv))return;const fv=gu(Zv),cv=xu.BASE.multiply(Zv).toAffine(),ly=Ys(cv.x);if(ly===_0n$b)return;const Cy=Ys(fv*Ys(D1+ly*O1));if(Cy===_0n$b)return;let Ly=(cv.x===ly?0:2)|Number(cv.y&_1n$c),Hy=Cy;return G0&&p0(Cy)&&(Hy=w0(Cy),Ly^=1),new $0(ly,Hy,Ly)}return{seed:rv,k2sig:ev}}const j1={lowS:a.lowS,prehash:!1},r1={lowS:a.lowS,prehash:!1};function t1(Z0,f1,w1=j1){const{seed:m1,k2sig:c1}=lv(Z0,f1,w1),G0=a;return createHmacDrbg$2(G0.hash.outputLen,G0.nByteLength,G0.hmac)(m1,c1)}xu.BASE._setWindowSize(8);function D0(Z0,f1,w1,m1=r1){var cv;const c1=Z0;if(f1=ensureBytes$3("msgHash",f1),w1=ensureBytes$3("publicKey",w1),"strict"in m1)throw new Error("options.strict was renamed to lowS");const{lowS:G0,prehash:o1}=m1;let d1,R1;try{if(typeof c1=="string"||isBytes$6(c1))try{d1=$0.fromDER(c1)}catch(ly){if(!(ly instanceof DER$1.Err))throw ly;d1=$0.fromCompact(c1)}else if(typeof c1=="object"&&typeof c1.r=="bigint"&&typeof c1.s=="bigint"){const{r:ly,s:Cy}=c1;d1=new $0(ly,Cy)}else throw new Error("PARSE");R1=xu.fromHex(w1)}catch(ly){if(ly.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(G0&&d1.hasHighS())return!1;o1&&(f1=a.hash(f1));const{r:O1,s:Q1}=d1,rv=g1(f1),D1=gu(Q1),ev=Ys(rv*D1),Mv=Ys(O1*D1),Zv=(cv=xu.BASE.multiplyAndAddUnsafe(R1,ev,Mv))==null?void 0:cv.toAffine();return Zv?Ys(Zv.x)===O1:!1}return{CURVE:a,getPublicKey:L0,getSharedSecret:F0,sign:t1,verify:D0,ProjectivePoint:xu,Signature:$0,utils:O0}}function SWUFpSqrtRatio(o,a){const c=o.ORDER;let d=_0n$b;for(let p0=c-_1n$c;p0%_2n$8===_0n$b;p0/=_2n$8)d+=_1n$c;const tt=d,nt=_2n$8<{let A0=Iu,$0=o.pow(w0,xu),O0=o.sqr($0);O0=o.mul(O0,w0);let L0=o.mul(p0,O0);L0=o.pow(L0,gu),L0=o.mul(L0,$0),$0=o.mul(L0,w0),O0=o.mul(L0,p0);let q0=o.mul(O0,$0);L0=o.pow(q0,$u);let F0=o.eql(L0,o.ONE);$0=o.mul(O0,Xu),L0=o.mul(q0,A0),O0=o.cmov($0,O0,F0),q0=o.cmov(L0,q0,F0);for(let u1=tt;u1>_1n$c;u1--){let g1=u1-_2n$8;g1=_2n$8<{let O0=o.sqr($0);const L0=o.mul(A0,$0);O0=o.mul(O0,L0);let q0=o.pow(O0,p0);q0=o.mul(q0,L0);const F0=o.mul(q0,w0),u1=o.mul(o.sqr(q0),$0),g1=o.eql(u1,A0);let E1=o.cmov(F0,q0,g1);return{isValid:g1,value:E1}}}return i0}function mapToCurveSimpleSWU(o,a){if(validateField$2(o),!o.isValid(a.A)||!o.isValid(a.B)||!o.isValid(a.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const c=SWUFpSqrtRatio(o,a.Z);if(!o.isOdd)throw new Error("Fp.isOdd is not implemented!");return d=>{let tt,nt,$a,Ys,gu,xu,$u,Iu;tt=o.sqr(d),tt=o.mul(tt,a.Z),nt=o.sqr(tt),nt=o.add(nt,tt),$a=o.add(nt,o.ONE),$a=o.mul($a,a.B),Ys=o.cmov(a.Z,o.neg(nt),!o.eql(nt,o.ZERO)),Ys=o.mul(Ys,a.A),nt=o.sqr($a),xu=o.sqr(Ys),gu=o.mul(xu,a.A),nt=o.add(nt,gu),nt=o.mul(nt,$a),xu=o.mul(xu,Ys),gu=o.mul(xu,a.B),nt=o.add(nt,gu),$u=o.mul(tt,$a);const{isValid:Xu,value:i0}=c(nt,xu);Iu=o.mul(tt,d),Iu=o.mul(Iu,i0),$u=o.cmov($u,$a,Xu),Iu=o.cmov(Iu,i0,Xu);const p0=o.isOdd(d)===o.isOdd(Iu);return Iu=o.cmov(o.neg(Iu),Iu,p0),$u=o.div($u,Ys),{x:$u,y:Iu}}}const weierstrass$2=Object.freeze(Object.defineProperty({__proto__:null,DER:DER$1,SWUFpSqrtRatio,mapToCurveSimpleSWU,weierstrass:weierstrass$1,weierstrassPoints:weierstrassPoints$1},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash$1(o){return{hash:o,hmac:(a,...c)=>hmac$2(o,a,concatBytes$4(...c)),randomBytes:randomBytes$5}}function createCurve(o,a){const c=d=>weierstrass$1({...o,...getHash$1(d)});return Object.freeze({...c(a),create:c})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$b=BigInt(1),_2n$7=BigInt(2),divNearest=(o,a)=>(o+a/_2n$7)/a;function sqrtMod(o){const a=secp256k1P,c=BigInt(3),d=BigInt(6),tt=BigInt(11),nt=BigInt(22),$a=BigInt(23),Ys=BigInt(44),gu=BigInt(88),xu=o*o*o%a,$u=xu*xu*o%a,Iu=pow2$1($u,c,a)*$u%a,Xu=pow2$1(Iu,c,a)*$u%a,i0=pow2$1(Xu,_2n$7,a)*xu%a,p0=pow2$1(i0,tt,a)*i0%a,w0=pow2$1(p0,nt,a)*p0%a,A0=pow2$1(w0,Ys,a)*w0%a,$0=pow2$1(A0,gu,a)*A0%a,O0=pow2$1($0,Ys,a)*w0%a,L0=pow2$1(O0,c,a)*$u%a,q0=pow2$1(L0,$a,a)*p0%a,F0=pow2$1(q0,d,a)*xu%a,u1=pow2$1(F0,_2n$7,a);if(!Fp$1.eql(Fp$1.sqr(u1),o))throw new Error("Cannot find square root");return u1}const Fp$1=Field$2(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1$1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const a=secp256k1N,c=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),d=-_1n$b*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),tt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),nt=c,$a=BigInt("0x100000000000000000000000000000000"),Ys=divNearest(nt*o,a),gu=divNearest(-d*o,a);let xu=mod$2(o-Ys*c-gu*tt,a),$u=mod$2(-Ys*d-gu*nt,a);const Iu=xu>$a,Xu=$u>$a;if(Iu&&(xu=a-xu),Xu&&($u=a-$u),xu>$a||$u>$a)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:Iu,k1:xu,k2neg:Xu,k2:$u}}}},sha256$5);BigInt(0);secp256k1$1.ProjectivePoint;function generateKey(){return secp256k1$1.utils.randomPrivateKey()}function hashAndSign(o,a){const c=sha256$6.digest(a instanceof Uint8Array?a:a.subarray());if(isPromise(c))return c.then(({digest:d})=>secp256k1$1.sign(d,o).toDERRawBytes()).catch(d=>{throw new CodeError(String(d),"ERR_INVALID_INPUT")});try{return secp256k1$1.sign(c.digest,o).toDERRawBytes()}catch(d){throw new CodeError(String(d),"ERR_INVALID_INPUT")}}function hashAndVerify(o,a,c){const d=sha256$6.digest(c instanceof Uint8Array?c:c.subarray());if(isPromise(d))return d.then(({digest:tt})=>secp256k1$1.verify(a,tt,o)).catch(tt=>{throw new CodeError(String(tt),"ERR_INVALID_INPUT")});try{return secp256k1$1.verify(a,d.digest,o)}catch(tt){throw new CodeError(String(tt),"ERR_INVALID_INPUT")}}function compressPublicKey(o){return secp256k1$1.ProjectivePoint.fromHex(o).toRawBytes(!0)}function validatePrivateKey(o){try{secp256k1$1.getPublicKey(o,!0)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PRIVATE_KEY")}}function validatePublicKey(o){try{secp256k1$1.ProjectivePoint.fromHex(o)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PUBLIC_KEY")}}function computePublicKey(o){try{return secp256k1$1.getPublicKey(o,!0)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PRIVATE_KEY")}}class Secp256k1PublicKey{constructor(a){aw(this,"_key");validatePublicKey(a),this._key=a}verify(a,c){return hashAndVerify(this._key,c,a)}marshal(){return compressPublicKey(this._key)}get bytes(){return PublicKey$2.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}async hash(){const a=sha256$6.digest(this.bytes);let c;return isPromise(a)?{bytes:c}=await a:c=a.bytes,c}}class Secp256k1PrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=a,this._publicKey=c??computePublicKey(a),validatePrivateKey(this._key),validatePublicKey(this._publicKey)}sign(a){return hashAndSign(this._key,a)}get public(){return new Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}async id(){const a=await this.public.hash();return toString$b(a,"base58btc")}async export(a,c="libp2p-key"){if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalSecp256k1PrivateKey(o){return new Secp256k1PrivateKey(o)}function unmarshalSecp256k1PublicKey(o){return new Secp256k1PublicKey(o)}async function generateKeyPair$1(){const o=generateKey();return new Secp256k1PrivateKey(o)}const Secp256k1=Object.freeze(Object.defineProperty({__proto__:null,Secp256k1PrivateKey,Secp256k1PublicKey,generateKeyPair:generateKeyPair$1,unmarshalSecp256k1PrivateKey,unmarshalSecp256k1PublicKey},Symbol.toStringTag,{value:"Module"})),supportedKeys={rsa:RSA,ed25519:Ed25519,secp256k1:Secp256k1};function unsupportedKey(o){const a=Object.keys(supportedKeys).join(" / ");return new CodeError(`invalid or unsupported key type ${o}. Must be ${a}`,"ERR_UNSUPPORTED_KEY_TYPE")}function typeToKey(o){if(o=o.toLowerCase(),o==="rsa"||o==="ed25519"||o==="secp256k1")return supportedKeys[o];throw unsupportedKey(o)}async function generateKeyPair(o,a){return typeToKey(o).generateKeyPair(2048)}async function unmarshalPrivateKey(o){const a=PrivateKey.decode(o),c=a.Data??new Uint8Array;switch(a.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPrivateKey(c);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PrivateKey(c);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(c);default:throw unsupportedKey(a.Type??"RSA")}}function base$4(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var a=new Uint8Array(256),c=0;c>>0,L0=new Uint8Array(O0);A0!==$0;){for(var q0=i0[A0],F0=0,u1=O0-1;(q0!==0||F0>>0,L0[u1]=q0%$a>>>0,q0=q0/$a>>>0;if(q0!==0)throw new Error("Non-zero carry");w0=F0,A0++}for(var g1=O0-w0;g1!==O0&&L0[g1]===0;)g1++;for(var E1=Ys.repeat(p0);g1>>0,O0=new Uint8Array($0);i0[p0];){var L0=a[i0.charCodeAt(p0)];if(L0===255)return;for(var q0=0,F0=$0-1;(L0!==0||q0>>0,O0[F0]=L0%256>>>0,L0=L0/256>>>0;if(L0!==0)throw new Error("Non-zero carry");A0=q0,p0++}for(var u1=$0-A0;u1!==$0&&O0[u1]===0;)u1++;for(var g1=new Uint8Array(w0+($0-u1)),E1=w0;u1!==$0;)g1[E1++]=O0[u1++];return g1}function Xu(i0){var p0=Iu(i0);if(p0)return p0;throw new Error("Non-base"+$a+" character")}return{encode:$u,decodeUnsafe:Iu,decode:Xu}}var src$1=base$4;const basex$2=src$1,ALPHABET$2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var bs58$2=basex$2(ALPHABET$2);const bs58$3=getDefaultExportFromCjs$1(bs58$2),CLIENT_KEY$1="client-key",AUTHORIZED$1="node-authorized",CALLBACK_URL="callback-url",APPLICATION_ID="application-id",setStorageCallbackUrl=o=>{localStorage.setItem(CALLBACK_URL,JSON.stringify(o))},getStorageCallbackUrl=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(CALLBACK_URL);return o?JSON.parse(o):null}return null},setStorageApplicationId=o=>{localStorage.setItem(APPLICATION_ID,JSON.stringify(o))},getStorageApplicationId=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(APPLICATION_ID);return o?JSON.parse(o):null}return null},setStorageClientKey=o=>{localStorage.setItem(CLIENT_KEY$1,JSON.stringify(o))},getStorageClientKey=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(CLIENT_KEY$1);if(!o)return null;let a=JSON.parse(o);if(a)return a}return null},setStorageNodeAuthorized=()=>{localStorage.setItem(AUTHORIZED$1,JSON.stringify(!0))},getStorageNodeAuthorized=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(AUTHORIZED$1);if(o!==null){let a=JSON.parse(o);if(a)return a}else return null}return null};async function createAuthHeader(o,a){const c=await getPrivateKey();if(!c)return null;const tt=new TextEncoder().encode(o),nt=bs58$3.encode(c.public.bytes),$a=await crypto.subtle.digest("SHA-256",tt),Ys=new Uint8Array($a),gu=await c.sign(Ys),xu=bs58$3.encode(gu),$u=bs58$3.encode(Ys);return{wallet_type:JSON.stringify(WalletType.NEAR({networkId:a})),signing_key:nt,signature:xu,challenge:$u}}async function getPrivateKey(){try{const o=getStorageClientKey();return o?await unmarshalPrivateKey(bs58$3.decode(o.privateKey)):null}catch(o){return console.error("Error extracting private key:",o),null}}const t$6=translations.nodeDataSource;var Network=(o=>(o.NEAR="NEAR",o.ETH="ETH",o.BNB="BNB",o.ARB="ARB",o.ZK="ZK",o.STARKNET="STARKNET",o.ICP="ICP",o))(Network||{}),WalletType;(o=>{function a({networkId:$a="mainnet"}){return{type:"NEAR",networkId:$a}}o.NEAR=a;function c({chainId:$a=1}){return{type:"ETH",chainId:$a}}o.ETH=c;function d({walletName:$a="MS"}){return{type:"STARKNET",walletName:$a}}o.STARKNET=d;const tt="rdmx6-jaaaa-aaaaa-aaadq-cai";function nt({canisterId:$a=tt,walletName:Ys="II"}){return{type:"ICP",canisterId:$a,walletName:Ys}}o.ICP=nt})(WalletType||(WalletType={}));class NodeDataSource{constructor(a){aw(this,"client");this.client=a}async getInstalledApplications(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/applications`,a??{})}catch(a){return console.error("Error fetching installed applications:",a),{error:{code:500,message:"Failed to fetch installed applications."}}}}async getInstalledApplicationDetails(a){try{const c=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/applications/${a}`,c??{})}catch(c){return console.error("Error fetching installed application:",c),{error:{code:500,message:"Failed to fetch installed application."}}}}async getContexts(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts`,a??{})}catch(a){return console.error("Error fetching contexts:",a),{error:{code:500,message:"Failed to fetch context data."}}}}async getContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context data."}}}}async getContextClientKeys(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/client-keys`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context client keys."}}}}async getContextUsers(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/users`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context users."}}}}async getContextStorageUsage(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/storage`,c??{})}catch(c){return console.error("Error fetching context storage usage:",c),{error:{code:500,message:"Failed to fetch context storage usage."}}}}async deleteContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.delete(`${getAppEndpointKey()}/admin-api/contexts/${a}`,c??{})}catch(c){return console.error("Error deleting context:",c),{error:{code:500,message:"Failed to delete context."}}}}async startContexts(a,c){try{const d=await createAuthHeader(JSON.stringify({applicationId:a,initArguments:c}),getNearEnvironment()),nt=new TextEncoder().encode(JSON.stringify(c)),$a=Array.from(nt);return await this.client.post(`${getAppEndpointKey()}/admin-api/contexts`,{applicationId:a,initializationParams:$a},d??{})}catch(d){return console.error("Error starting contexts:",d),{error:{code:500,message:"Failed to start context."}}}}async getDidList(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/did`,a??{})}catch(a){return console.error("Error fetching root keys:",a),{error:{code:500,message:"Failed to fetch root keys."}}}}async health(a){return await this.client.get(`${a.url}/admin-api/health`)}async installApplication(a,c,d,tt){try{const nt=await createAuthHeader(JSON.stringify({selectedPackageId:a,selectedVersion:c,hash:tt}),getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/install-application`,{url:d,version:c,metadata:createAppMetadata(a)},nt??{})}catch(nt){return console.error("Error installing application:",nt),{error:{code:500,message:"Failed to install application."}}}}async uninstallApplication(a){try{const c=await createAuthHeader(JSON.stringify({applicationId:a}),getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/uninstall-application`,{applicationId:a},c??{})}catch(c){return console.error("Error uninstalling application:",c),{error:{code:500,message:"Failed to uninstall application."}}}}async joinContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/contexts/${a}/join`,{},c??{})}catch(c){return console.error(`${t$6.joinContextErrorTitle}: ${c}`),{error:{code:500,message:t$6.joinContextErrorMessage}}}}async login(a){return await this.client.post(`${getAppEndpointKey()}/admin-api/add-client-key`,{...a})}async requestChallenge(){return await this.client.post(`${getAppEndpointKey()}/admin-api/request-challenge`,{})}async addRootKey(a){const c=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return c?await this.client.post(`${getAppEndpointKey()}/admin-api/root-key`,{...a},c):{error:{code:401,message:"Unauthorized"}}}async getContextIdentity(a){const c=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return c?await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/identities`,c):{error:{code:401,message:t$6.unauthorizedErrorMessage}}}async createAccessToken(a,c){const d=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return d?await this.client.post(`${getAppEndpointKey()}/admin-api/generate-jwt-token`,{contextId:a,executorPublicKey:c},d):{error:{code:401,message:t$6.unauthorizedErrorMessage}}}}class ApiClient{constructor(a){aw(this,"nodeApi");this.nodeApi=new NodeDataSource(a)}node(){return this.nodeApi}}const apiClient=o=>{const a=new AxiosHttpClient(axios,o);return new ApiClient(a)},APP_URL="app-url",AUTHORIZED="node-authorized",CLIENT_KEY="client-key",NODE_URL="node-url",getAppEndpointKey=()=>{try{if(typeof window<"u"&&window.localStorage){let o=localStorage.getItem(APP_URL);if(o){let a=JSON.parse(o);if(a&&a.length>0)return a}}return null}catch{return null}},setAppEndpointKey=o=>{localStorage.setItem(APP_URL,JSON.stringify(o))},getClientKey=()=>localStorage.getItem(CLIENT_KEY)??"",isNodeAuthorized=()=>{const o=localStorage.getItem(AUTHORIZED);return o?JSON.parse(o):!1},setNodeUrlFromQuery=async o=>{const c=new URLSearchParams(window.location.search).get(NODE_URL);if(c&&await verifyNodeUrl(c,o)){setAppEndpointKey(c);const d=`${window.location.pathname}auth`;window.location.href=d}else if(c)window.alert("Node URL is not valid or not reachable. Please try again.");else return},verifyNodeUrl=async(o,a)=>{try{return new URL(o),!!(await apiClient(a).node().health({url:o})).data}catch{return!1}};var classnames={exports:{}};/*! +`)}async function generateKey$1(o){const a=await webcrypto.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:o,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),c=await exportKey(a);return{privateKey:c[0],publicKey:c[1]}}async function unmarshalPrivateKey$1(o){const c=[await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await derivePublicFromPrivate(o)],d=await exportKey({privateKey:c[0],publicKey:c[1]});return{privateKey:d[0],publicKey:d[1]}}async function hashAndSign$1(o,a){const c=await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),d=await webcrypto.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},c,a instanceof Uint8Array?a:a.subarray());return new Uint8Array(d,0,d.byteLength)}async function hashAndVerify$1(o,a,c){const d=await webcrypto.get().subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return webcrypto.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},d,a,c instanceof Uint8Array?c:c.subarray())}async function exportKey(o){if(o.privateKey==null||o.publicKey==null)throw new CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([webcrypto.get().subtle.exportKey("jwk",o.privateKey),webcrypto.get().subtle.exportKey("jwk",o.publicKey)])}async function derivePublicFromPrivate(o){return webcrypto.get().subtle.importKey("jwk",{kty:o.kty,n:o.n,e:o.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function keySize(o){if(o.kty!=="RSA")throw new CodeError("invalid key type","ERR_INVALID_KEY_TYPE");if(o.n==null)throw new CodeError("invalid key modulus","ERR_INVALID_KEY_MODULUS");return fromString(o.n,"base64url").length*8}const MAX_RSA_KEY_SIZE=8192;class RsaPublicKey{constructor(a){aw(this,"_key");this._key=a}verify(a,c){return hashAndVerify$1(this._key,c,a)}marshal(){return jwkToPkix(this._key)}get bytes(){return PublicKey$2.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}}class RsaPrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=a,this._publicKey=c}genSecret(){return randomBytes$4(16)}sign(a){return hashAndSign$1(this._key,a)}get public(){if(this._publicKey==null)throw new CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new RsaPublicKey(this._publicKey)}marshal(){return jwkToPkcs1(this._key)}get bytes(){return PrivateKey.encode({Type:KeyType.RSA,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}async id(){const a=await this.public.hash();return toString$b(a,"base58btc")}async export(a,c="pkcs-8"){if(c==="pkcs-8")return exportToPem(this,a);if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function unmarshalRsaPrivateKey(o){const a=pkcs1ToJwk(o);if(keySize(a)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const c=await unmarshalPrivateKey$1(a);return new RsaPrivateKey(c.privateKey,c.publicKey)}function unmarshalRsaPublicKey(o){const a=pkixToJwk(o);if(keySize(a)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new RsaPublicKey(a)}async function fromJwk(o){if(keySize(o)>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const a=await unmarshalPrivateKey$1(o);return new RsaPrivateKey(a.privateKey,a.publicKey)}async function generateKeyPair$2(o){if(o>MAX_RSA_KEY_SIZE)throw new CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const a=await generateKey$1(o);return new RsaPrivateKey(a.privateKey,a.publicKey)}const RSA=Object.freeze(Object.defineProperty({__proto__:null,MAX_RSA_KEY_SIZE,RsaPrivateKey,RsaPublicKey,fromJwk,generateKeyPair:generateKeyPair$2,unmarshalRsaPrivateKey,unmarshalRsaPublicKey},Symbol.toStringTag,{value:"Module"})),SHA256_K$2=new Uint32Array([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]),SHA256_IV=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA256_W$2=new Uint32Array(64);let SHA256$4=class extends HashMD{constructor(){super(64,32,8,!1),this.A=SHA256_IV[0]|0,this.B=SHA256_IV[1]|0,this.C=SHA256_IV[2]|0,this.D=SHA256_IV[3]|0,this.E=SHA256_IV[4]|0,this.F=SHA256_IV[5]|0,this.G=SHA256_IV[6]|0,this.H=SHA256_IV[7]|0}get(){const{A:a,B:c,C:d,D:tt,E:nt,F:$a,G:Ys,H:gu}=this;return[a,c,d,tt,nt,$a,Ys,gu]}set(a,c,d,tt,nt,$a,Ys,gu){this.A=a|0,this.B=c|0,this.C=d|0,this.D=tt|0,this.E=nt|0,this.F=$a|0,this.G=Ys|0,this.H=gu|0}process(a,c){for(let Iu=0;Iu<16;Iu++,c+=4)SHA256_W$2[Iu]=a.getUint32(c,!1);for(let Iu=16;Iu<64;Iu++){const Xu=SHA256_W$2[Iu-15],i0=SHA256_W$2[Iu-2],p0=rotr$1(Xu,7)^rotr$1(Xu,18)^Xu>>>3,w0=rotr$1(i0,17)^rotr$1(i0,19)^i0>>>10;SHA256_W$2[Iu]=w0+SHA256_W$2[Iu-7]+p0+SHA256_W$2[Iu-16]|0}let{A:d,B:tt,C:nt,D:$a,E:Ys,F:gu,G:xu,H:$u}=this;for(let Iu=0;Iu<64;Iu++){const Xu=rotr$1(Ys,6)^rotr$1(Ys,11)^rotr$1(Ys,25),i0=$u+Xu+Chi$2(Ys,gu,xu)+SHA256_K$2[Iu]+SHA256_W$2[Iu]|0,w0=(rotr$1(d,2)^rotr$1(d,13)^rotr$1(d,22))+Maj$2(d,tt,nt)|0;$u=xu,xu=gu,gu=Ys,Ys=$a+i0|0,$a=nt,nt=tt,tt=d,d=i0+w0|0}d=d+this.A|0,tt=tt+this.B|0,nt=nt+this.C|0,$a=$a+this.D|0,Ys=Ys+this.E|0,gu=gu+this.F|0,xu=xu+this.G|0,$u=$u+this.H|0,this.set(d,tt,nt,$a,Ys,gu,xu,$u)}roundClean(){SHA256_W$2.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const sha256$5=wrapConstructor$1(()=>new SHA256$4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts$1(o){const a=validateBasic$2(o);validateObject$2(a,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:c,Fp:d,a:tt}=a;if(c){if(!d.eql(tt,d.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof c!="object"||typeof c.beta!="bigint"||typeof c.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...a})}const{bytesToNumberBE:b2n$1,hexToBytes:h2b$1}=ut$4,DER$1={Err:class extends Error{constructor(a=""){super(a)}},_parseInt(o){const{Err:a}=DER$1;if(o.length<2||o[0]!==2)throw new a("Invalid signature integer tag");const c=o[1],d=o.subarray(2,c+2);if(!c||d.length!==c)throw new a("Invalid signature integer: wrong length");if(d[0]&128)throw new a("Invalid signature integer: negative");if(d[0]===0&&!(d[1]&128))throw new a("Invalid signature integer: unnecessary leading zero");return{d:b2n$1(d),l:o.subarray(c+2)}},toSig(o){const{Err:a}=DER$1,c=typeof o=="string"?h2b$1(o):o;abytes(c);let d=c.length;if(d<2||c[0]!=48)throw new a("Invalid signature tag");if(c[1]!==d-2)throw new a("Invalid signature: incorrect length");const{d:tt,l:nt}=DER$1._parseInt(c.subarray(2)),{d:$a,l:Ys}=DER$1._parseInt(nt);if(Ys.length)throw new a("Invalid signature: left bytes after parsing");return{r:tt,s:$a}},hexFromSig(o){const a=xu=>Number.parseInt(xu[0],16)&8?"00"+xu:xu,c=xu=>{const $u=xu.toString(16);return $u.length&1?`0${$u}`:$u},d=a(c(o.s)),tt=a(c(o.r)),nt=d.length/2,$a=tt.length/2,Ys=c(nt),gu=c($a);return`30${c($a+nt+4)}02${gu}${tt}02${Ys}${d}`}},_0n$b=BigInt(0),_1n$c=BigInt(1),_2n$8=BigInt(2),_3n$3=BigInt(3),_4n$2=BigInt(4);function weierstrassPoints$1(o){const a=validatePointOpts$1(o),{Fp:c}=a,d=a.toBytes||((p0,w0,A0)=>{const $0=w0.toAffine();return concatBytes$3(Uint8Array.from([4]),c.toBytes($0.x),c.toBytes($0.y))}),tt=a.fromBytes||(p0=>{const w0=p0.subarray(1),A0=c.fromBytes(w0.subarray(0,c.BYTES)),$0=c.fromBytes(w0.subarray(c.BYTES,2*c.BYTES));return{x:A0,y:$0}});function nt(p0){const{a:w0,b:A0}=a,$0=c.sqr(p0),O0=c.mul($0,p0);return c.add(c.add(O0,c.mul(p0,w0)),A0)}if(!c.eql(c.sqr(a.Gy),nt(a.Gx)))throw new Error("bad generator point: equation left != right");function $a(p0){return typeof p0=="bigint"&&_0n$bc.eql(L0,c.ZERO);return O0(A0)&&O0($0)?Iu.ZERO:new Iu(A0,$0,c.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w0){const A0=c.invertBatch(w0.map($0=>$0.pz));return w0.map(($0,O0)=>$0.toAffine(A0[O0])).map(Iu.fromAffine)}static fromHex(w0){const A0=Iu.fromAffine(tt(ensureBytes$3("pointHex",w0)));return A0.assertValidity(),A0}static fromPrivateKey(w0){return Iu.BASE.multiply(gu(w0))}_setWindowSize(w0){this._WINDOW_SIZE=w0,xu.delete(this)}assertValidity(){if(this.is0()){if(a.allowInfinityPoint&&!c.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:w0,y:A0}=this.toAffine();if(!c.isValid(w0)||!c.isValid(A0))throw new Error("bad point: x or y not FE");const $0=c.sqr(A0),O0=nt(w0);if(!c.eql($0,O0))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:w0}=this.toAffine();if(c.isOdd)return!c.isOdd(w0);throw new Error("Field doesn't support isOdd")}equals(w0){$u(w0);const{px:A0,py:$0,pz:O0}=this,{px:L0,py:q0,pz:F0}=w0,u1=c.eql(c.mul(A0,F0),c.mul(L0,O0)),g1=c.eql(c.mul($0,F0),c.mul(q0,O0));return u1&&g1}negate(){return new Iu(this.px,c.neg(this.py),this.pz)}double(){const{a:w0,b:A0}=a,$0=c.mul(A0,_3n$3),{px:O0,py:L0,pz:q0}=this;let F0=c.ZERO,u1=c.ZERO,g1=c.ZERO,E1=c.mul(O0,O0),B1=c.mul(L0,L0),lv=c.mul(q0,q0),j1=c.mul(O0,L0);return j1=c.add(j1,j1),g1=c.mul(O0,q0),g1=c.add(g1,g1),F0=c.mul(w0,g1),u1=c.mul($0,lv),u1=c.add(F0,u1),F0=c.sub(B1,u1),u1=c.add(B1,u1),u1=c.mul(F0,u1),F0=c.mul(j1,F0),g1=c.mul($0,g1),lv=c.mul(w0,lv),j1=c.sub(E1,lv),j1=c.mul(w0,j1),j1=c.add(j1,g1),g1=c.add(E1,E1),E1=c.add(g1,E1),E1=c.add(E1,lv),E1=c.mul(E1,j1),u1=c.add(u1,E1),lv=c.mul(L0,q0),lv=c.add(lv,lv),E1=c.mul(lv,j1),F0=c.sub(F0,E1),g1=c.mul(lv,B1),g1=c.add(g1,g1),g1=c.add(g1,g1),new Iu(F0,u1,g1)}add(w0){$u(w0);const{px:A0,py:$0,pz:O0}=this,{px:L0,py:q0,pz:F0}=w0;let u1=c.ZERO,g1=c.ZERO,E1=c.ZERO;const B1=a.a,lv=c.mul(a.b,_3n$3);let j1=c.mul(A0,L0),r1=c.mul($0,q0),t1=c.mul(O0,F0),D0=c.add(A0,$0),Z0=c.add(L0,q0);D0=c.mul(D0,Z0),Z0=c.add(j1,r1),D0=c.sub(D0,Z0),Z0=c.add(A0,O0);let f1=c.add(L0,F0);return Z0=c.mul(Z0,f1),f1=c.add(j1,t1),Z0=c.sub(Z0,f1),f1=c.add($0,O0),u1=c.add(q0,F0),f1=c.mul(f1,u1),u1=c.add(r1,t1),f1=c.sub(f1,u1),E1=c.mul(B1,Z0),u1=c.mul(lv,t1),E1=c.add(u1,E1),u1=c.sub(r1,E1),E1=c.add(r1,E1),g1=c.mul(u1,E1),r1=c.add(j1,j1),r1=c.add(r1,j1),t1=c.mul(B1,t1),Z0=c.mul(lv,Z0),r1=c.add(r1,t1),t1=c.sub(j1,t1),t1=c.mul(B1,t1),Z0=c.add(Z0,t1),j1=c.mul(r1,Z0),g1=c.add(g1,j1),j1=c.mul(f1,Z0),u1=c.mul(D0,u1),u1=c.sub(u1,j1),j1=c.mul(D0,r1),E1=c.mul(f1,E1),E1=c.add(E1,j1),new Iu(u1,g1,E1)}subtract(w0){return this.add(w0.negate())}is0(){return this.equals(Iu.ZERO)}wNAF(w0){return i0.wNAFCached(this,xu,w0,A0=>{const $0=c.invertBatch(A0.map(O0=>O0.pz));return A0.map((O0,L0)=>O0.toAffine($0[L0])).map(Iu.fromAffine)})}multiplyUnsafe(w0){const A0=Iu.ZERO;if(w0===_0n$b)return A0;if(Ys(w0),w0===_1n$c)return this;const{endo:$0}=a;if(!$0)return i0.unsafeLadder(this,w0);let{k1neg:O0,k1:L0,k2neg:q0,k2:F0}=$0.splitScalar(w0),u1=A0,g1=A0,E1=this;for(;L0>_0n$b||F0>_0n$b;)L0&_1n$c&&(u1=u1.add(E1)),F0&_1n$c&&(g1=g1.add(E1)),E1=E1.double(),L0>>=_1n$c,F0>>=_1n$c;return O0&&(u1=u1.negate()),q0&&(g1=g1.negate()),g1=new Iu(c.mul(g1.px,$0.beta),g1.py,g1.pz),u1.add(g1)}multiply(w0){Ys(w0);let A0=w0,$0,O0;const{endo:L0}=a;if(L0){const{k1neg:q0,k1:F0,k2neg:u1,k2:g1}=L0.splitScalar(A0);let{p:E1,f:B1}=this.wNAF(F0),{p:lv,f:j1}=this.wNAF(g1);E1=i0.constTimeNegate(q0,E1),lv=i0.constTimeNegate(u1,lv),lv=new Iu(c.mul(lv.px,L0.beta),lv.py,lv.pz),$0=E1.add(lv),O0=B1.add(j1)}else{const{p:q0,f:F0}=this.wNAF(A0);$0=q0,O0=F0}return Iu.normalizeZ([$0,O0])[0]}multiplyAndAddUnsafe(w0,A0,$0){const O0=Iu.BASE,L0=(F0,u1)=>u1===_0n$b||u1===_1n$c||!F0.equals(O0)?F0.multiplyUnsafe(u1):F0.multiply(u1),q0=L0(this,A0).add(L0(w0,$0));return q0.is0()?void 0:q0}toAffine(w0){const{px:A0,py:$0,pz:O0}=this,L0=this.is0();w0==null&&(w0=L0?c.ONE:c.inv(O0));const q0=c.mul(A0,w0),F0=c.mul($0,w0),u1=c.mul(O0,w0);if(L0)return{x:c.ZERO,y:c.ZERO};if(!c.eql(u1,c.ONE))throw new Error("invZ was invalid");return{x:q0,y:F0}}isTorsionFree(){const{h:w0,isTorsionFree:A0}=a;if(w0===_1n$c)return!0;if(A0)return A0(Iu,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w0,clearCofactor:A0}=a;return w0===_1n$c?this:A0?A0(Iu,this):this.multiplyUnsafe(a.h)}toRawBytes(w0=!0){return this.assertValidity(),d(Iu,this,w0)}toHex(w0=!0){return bytesToHex$2(this.toRawBytes(w0))}}Iu.BASE=new Iu(a.Gx,a.Gy,c.ONE),Iu.ZERO=new Iu(c.ZERO,c.ONE,c.ZERO);const Xu=a.nBitLength,i0=wNAF$2(Iu,a.endo?Math.ceil(Xu/2):Xu);return{CURVE:a,ProjectivePoint:Iu,normPrivateKeyToScalar:gu,weierstrassEquation:nt,isWithinCurveOrder:$a}}function validateOpts$5(o){const a=validateBasic$2(o);return validateObject$2(a,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...a})}function weierstrass$1(o){const a=validateOpts$5(o),{Fp:c,n:d}=a,tt=c.BYTES+1,nt=2*c.BYTES+1;function $a(Z0){return _0n$bbytesToHex$2(numberToBytesBE$2(Z0,a.nByteLength));function p0(Z0){const f1=d>>_1n$c;return Z0>f1}function w0(Z0){return p0(Z0)?Ys(-Z0):Z0}const A0=(Z0,f1,w1)=>bytesToNumberBE$2(Z0.slice(f1,w1));class $0{constructor(f1,w1,m1){this.r=f1,this.s=w1,this.recovery=m1,this.assertValidity()}static fromCompact(f1){const w1=a.nByteLength;return f1=ensureBytes$3("compactSignature",f1,w1*2),new $0(A0(f1,0,w1),A0(f1,w1,2*w1))}static fromDER(f1){const{r:w1,s:m1}=DER$1.toSig(ensureBytes$3("DER",f1));return new $0(w1,m1)}assertValidity(){if(!Xu(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!Xu(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(f1){return new $0(this.r,this.s,f1)}recoverPublicKey(f1){const{r:w1,s:m1,recovery:c1}=this,G0=g1(ensureBytes$3("msgHash",f1));if(c1==null||![0,1,2,3].includes(c1))throw new Error("recovery id invalid");const o1=c1===2||c1===3?w1+a.n:w1;if(o1>=c.ORDER)throw new Error("recovery id 2 or 3 invalid");const d1=c1&1?"03":"02",R1=xu.fromHex(d1+i0(o1)),O1=gu(o1),Q1=Ys(-G0*O1),rv=Ys(m1*O1),D1=xu.BASE.multiplyAndAddUnsafe(R1,Q1,rv);if(!D1)throw new Error("point at infinify");return D1.assertValidity(),D1}hasHighS(){return p0(this.s)}normalizeS(){return this.hasHighS()?new $0(this.r,Ys(-this.s),this.recovery):this}toDERRawBytes(){return hexToBytes$3(this.toDERHex())}toDERHex(){return DER$1.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return hexToBytes$3(this.toCompactHex())}toCompactHex(){return i0(this.r)+i0(this.s)}}const O0={isValidPrivateKey(Z0){try{return $u(Z0),!0}catch{return!1}},normPrivateKeyToScalar:$u,randomPrivateKey:()=>{const Z0=getMinHashLength$2(a.n);return mapHashToField$2(a.randomBytes(Z0),a.n)},precompute(Z0=8,f1=xu.BASE){return f1._setWindowSize(Z0),f1.multiply(BigInt(3)),f1}};function L0(Z0,f1=!0){return xu.fromPrivateKey(Z0).toRawBytes(f1)}function q0(Z0){const f1=isBytes$6(Z0),w1=typeof Z0=="string",m1=(f1||w1)&&Z0.length;return f1?m1===tt||m1===nt:w1?m1===2*tt||m1===2*nt:Z0 instanceof xu}function F0(Z0,f1,w1=!0){if(q0(Z0))throw new Error("first arg must be private key");if(!q0(f1))throw new Error("second arg must be public key");return xu.fromHex(f1).multiply($u(Z0)).toRawBytes(w1)}const u1=a.bits2int||function(Z0){const f1=bytesToNumberBE$2(Z0),w1=Z0.length*8-a.nBitLength;return w1>0?f1>>BigInt(w1):f1},g1=a.bits2int_modN||function(Z0){return Ys(u1(Z0))},E1=bitMask$2(a.nBitLength);function B1(Z0){if(typeof Z0!="bigint")throw new Error("bigint expected");if(!(_0n$b<=Z0&&Z0Mv in w1))throw new Error("sign() legacy options not supported");const{hash:m1,randomBytes:c1}=a;let{lowS:G0,prehash:o1,extraEntropy:d1}=w1;G0==null&&(G0=!0),Z0=ensureBytes$3("msgHash",Z0),o1&&(Z0=ensureBytes$3("prehashed msgHash",m1(Z0)));const R1=g1(Z0),O1=$u(f1),Q1=[B1(O1),B1(R1)];if(d1!=null&&d1!==!1){const Mv=d1===!0?c1(c.BYTES):d1;Q1.push(ensureBytes$3("extraEntropy",Mv))}const rv=concatBytes$3(...Q1),D1=R1;function ev(Mv){const Zv=u1(Mv);if(!Xu(Zv))return;const fv=gu(Zv),cv=xu.BASE.multiply(Zv).toAffine(),ly=Ys(cv.x);if(ly===_0n$b)return;const Cy=Ys(fv*Ys(D1+ly*O1));if(Cy===_0n$b)return;let Ly=(cv.x===ly?0:2)|Number(cv.y&_1n$c),Hy=Cy;return G0&&p0(Cy)&&(Hy=w0(Cy),Ly^=1),new $0(ly,Hy,Ly)}return{seed:rv,k2sig:ev}}const j1={lowS:a.lowS,prehash:!1},r1={lowS:a.lowS,prehash:!1};function t1(Z0,f1,w1=j1){const{seed:m1,k2sig:c1}=lv(Z0,f1,w1),G0=a;return createHmacDrbg$2(G0.hash.outputLen,G0.nByteLength,G0.hmac)(m1,c1)}xu.BASE._setWindowSize(8);function D0(Z0,f1,w1,m1=r1){var cv;const c1=Z0;if(f1=ensureBytes$3("msgHash",f1),w1=ensureBytes$3("publicKey",w1),"strict"in m1)throw new Error("options.strict was renamed to lowS");const{lowS:G0,prehash:o1}=m1;let d1,R1;try{if(typeof c1=="string"||isBytes$6(c1))try{d1=$0.fromDER(c1)}catch(ly){if(!(ly instanceof DER$1.Err))throw ly;d1=$0.fromCompact(c1)}else if(typeof c1=="object"&&typeof c1.r=="bigint"&&typeof c1.s=="bigint"){const{r:ly,s:Cy}=c1;d1=new $0(ly,Cy)}else throw new Error("PARSE");R1=xu.fromHex(w1)}catch(ly){if(ly.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(G0&&d1.hasHighS())return!1;o1&&(f1=a.hash(f1));const{r:O1,s:Q1}=d1,rv=g1(f1),D1=gu(Q1),ev=Ys(rv*D1),Mv=Ys(O1*D1),Zv=(cv=xu.BASE.multiplyAndAddUnsafe(R1,ev,Mv))==null?void 0:cv.toAffine();return Zv?Ys(Zv.x)===O1:!1}return{CURVE:a,getPublicKey:L0,getSharedSecret:F0,sign:t1,verify:D0,ProjectivePoint:xu,Signature:$0,utils:O0}}function SWUFpSqrtRatio(o,a){const c=o.ORDER;let d=_0n$b;for(let p0=c-_1n$c;p0%_2n$8===_0n$b;p0/=_2n$8)d+=_1n$c;const tt=d,nt=_2n$8<{let A0=Iu,$0=o.pow(w0,xu),O0=o.sqr($0);O0=o.mul(O0,w0);let L0=o.mul(p0,O0);L0=o.pow(L0,gu),L0=o.mul(L0,$0),$0=o.mul(L0,w0),O0=o.mul(L0,p0);let q0=o.mul(O0,$0);L0=o.pow(q0,$u);let F0=o.eql(L0,o.ONE);$0=o.mul(O0,Xu),L0=o.mul(q0,A0),O0=o.cmov($0,O0,F0),q0=o.cmov(L0,q0,F0);for(let u1=tt;u1>_1n$c;u1--){let g1=u1-_2n$8;g1=_2n$8<{let O0=o.sqr($0);const L0=o.mul(A0,$0);O0=o.mul(O0,L0);let q0=o.pow(O0,p0);q0=o.mul(q0,L0);const F0=o.mul(q0,w0),u1=o.mul(o.sqr(q0),$0),g1=o.eql(u1,A0);let E1=o.cmov(F0,q0,g1);return{isValid:g1,value:E1}}}return i0}function mapToCurveSimpleSWU(o,a){if(validateField$2(o),!o.isValid(a.A)||!o.isValid(a.B)||!o.isValid(a.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const c=SWUFpSqrtRatio(o,a.Z);if(!o.isOdd)throw new Error("Fp.isOdd is not implemented!");return d=>{let tt,nt,$a,Ys,gu,xu,$u,Iu;tt=o.sqr(d),tt=o.mul(tt,a.Z),nt=o.sqr(tt),nt=o.add(nt,tt),$a=o.add(nt,o.ONE),$a=o.mul($a,a.B),Ys=o.cmov(a.Z,o.neg(nt),!o.eql(nt,o.ZERO)),Ys=o.mul(Ys,a.A),nt=o.sqr($a),xu=o.sqr(Ys),gu=o.mul(xu,a.A),nt=o.add(nt,gu),nt=o.mul(nt,$a),xu=o.mul(xu,Ys),gu=o.mul(xu,a.B),nt=o.add(nt,gu),$u=o.mul(tt,$a);const{isValid:Xu,value:i0}=c(nt,xu);Iu=o.mul(tt,d),Iu=o.mul(Iu,i0),$u=o.cmov($u,$a,Xu),Iu=o.cmov(Iu,i0,Xu);const p0=o.isOdd(d)===o.isOdd(Iu);return Iu=o.cmov(o.neg(Iu),Iu,p0),$u=o.div($u,Ys),{x:$u,y:Iu}}}const weierstrass$2=Object.freeze(Object.defineProperty({__proto__:null,DER:DER$1,SWUFpSqrtRatio,mapToCurveSimpleSWU,weierstrass:weierstrass$1,weierstrassPoints:weierstrassPoints$1},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash$1(o){return{hash:o,hmac:(a,...c)=>hmac$2(o,a,concatBytes$4(...c)),randomBytes:randomBytes$5}}function createCurve(o,a){const c=d=>weierstrass$1({...o,...getHash$1(d)});return Object.freeze({...c(a),create:c})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1P=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),secp256k1N=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1n$b=BigInt(1),_2n$7=BigInt(2),divNearest=(o,a)=>(o+a/_2n$7)/a;function sqrtMod(o){const a=secp256k1P,c=BigInt(3),d=BigInt(6),tt=BigInt(11),nt=BigInt(22),$a=BigInt(23),Ys=BigInt(44),gu=BigInt(88),xu=o*o*o%a,$u=xu*xu*o%a,Iu=pow2$1($u,c,a)*$u%a,Xu=pow2$1(Iu,c,a)*$u%a,i0=pow2$1(Xu,_2n$7,a)*xu%a,p0=pow2$1(i0,tt,a)*i0%a,w0=pow2$1(p0,nt,a)*p0%a,A0=pow2$1(w0,Ys,a)*w0%a,$0=pow2$1(A0,gu,a)*A0%a,O0=pow2$1($0,Ys,a)*w0%a,L0=pow2$1(O0,c,a)*$u%a,q0=pow2$1(L0,$a,a)*p0%a,F0=pow2$1(q0,d,a)*xu%a,u1=pow2$1(F0,_2n$7,a);if(!Fp$1.eql(Fp$1.sqr(u1),o))throw new Error("Cannot find square root");return u1}const Fp$1=Field$2(secp256k1P,void 0,void 0,{sqrt:sqrtMod}),secp256k1$1=createCurve({a:BigInt(0),b:BigInt(7),Fp:Fp$1,n:secp256k1N,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:o=>{const a=secp256k1N,c=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),d=-_1n$b*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),tt=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),nt=c,$a=BigInt("0x100000000000000000000000000000000"),Ys=divNearest(nt*o,a),gu=divNearest(-d*o,a);let xu=mod$2(o-Ys*c-gu*tt,a),$u=mod$2(-Ys*d-gu*nt,a);const Iu=xu>$a,Xu=$u>$a;if(Iu&&(xu=a-xu),Xu&&($u=a-$u),xu>$a||$u>$a)throw new Error("splitScalar: Endomorphism failed, k="+o);return{k1neg:Iu,k1:xu,k2neg:Xu,k2:$u}}}},sha256$5);BigInt(0);secp256k1$1.ProjectivePoint;function generateKey(){return secp256k1$1.utils.randomPrivateKey()}function hashAndSign(o,a){const c=sha256$6.digest(a instanceof Uint8Array?a:a.subarray());if(isPromise(c))return c.then(({digest:d})=>secp256k1$1.sign(d,o).toDERRawBytes()).catch(d=>{throw new CodeError(String(d),"ERR_INVALID_INPUT")});try{return secp256k1$1.sign(c.digest,o).toDERRawBytes()}catch(d){throw new CodeError(String(d),"ERR_INVALID_INPUT")}}function hashAndVerify(o,a,c){const d=sha256$6.digest(c instanceof Uint8Array?c:c.subarray());if(isPromise(d))return d.then(({digest:tt})=>secp256k1$1.verify(a,tt,o)).catch(tt=>{throw new CodeError(String(tt),"ERR_INVALID_INPUT")});try{return secp256k1$1.verify(a,d.digest,o)}catch(tt){throw new CodeError(String(tt),"ERR_INVALID_INPUT")}}function compressPublicKey(o){return secp256k1$1.ProjectivePoint.fromHex(o).toRawBytes(!0)}function validatePrivateKey(o){try{secp256k1$1.getPublicKey(o,!0)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PRIVATE_KEY")}}function validatePublicKey(o){try{secp256k1$1.ProjectivePoint.fromHex(o)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PUBLIC_KEY")}}function computePublicKey(o){try{return secp256k1$1.getPublicKey(o,!0)}catch(a){throw new CodeError(String(a),"ERR_INVALID_PRIVATE_KEY")}}class Secp256k1PublicKey{constructor(a){aw(this,"_key");validatePublicKey(a),this._key=a}verify(a,c){return hashAndVerify(this._key,c,a)}marshal(){return compressPublicKey(this._key)}get bytes(){return PublicKey$2.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}async hash(){const a=sha256$6.digest(this.bytes);let c;return isPromise(a)?{bytes:c}=await a:c=a.bytes,c}}class Secp256k1PrivateKey{constructor(a,c){aw(this,"_key");aw(this,"_publicKey");this._key=a,this._publicKey=c??computePublicKey(a),validatePrivateKey(this._key),validatePublicKey(this._publicKey)}sign(a){return hashAndSign(this._key,a)}get public(){return new Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return PrivateKey.encode({Type:KeyType.Secp256k1,Data:this.marshal()}).subarray()}equals(a){return equals(this.bytes,a.bytes)}hash(){const a=sha256$6.digest(this.bytes);return isPromise(a)?a.then(({bytes:c})=>c):a.bytes}async id(){const a=await this.public.hash();return toString$b(a,"base58btc")}async export(a,c="libp2p-key"){if(c==="libp2p-key")return exporter(this.bytes,a);throw new CodeError(`export format '${c}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function unmarshalSecp256k1PrivateKey(o){return new Secp256k1PrivateKey(o)}function unmarshalSecp256k1PublicKey(o){return new Secp256k1PublicKey(o)}async function generateKeyPair$1(){const o=generateKey();return new Secp256k1PrivateKey(o)}const Secp256k1=Object.freeze(Object.defineProperty({__proto__:null,Secp256k1PrivateKey,Secp256k1PublicKey,generateKeyPair:generateKeyPair$1,unmarshalSecp256k1PrivateKey,unmarshalSecp256k1PublicKey},Symbol.toStringTag,{value:"Module"})),supportedKeys={rsa:RSA,ed25519:Ed25519,secp256k1:Secp256k1};function unsupportedKey(o){const a=Object.keys(supportedKeys).join(" / ");return new CodeError(`invalid or unsupported key type ${o}. Must be ${a}`,"ERR_UNSUPPORTED_KEY_TYPE")}function typeToKey(o){if(o=o.toLowerCase(),o==="rsa"||o==="ed25519"||o==="secp256k1")return supportedKeys[o];throw unsupportedKey(o)}async function generateKeyPair(o,a){return typeToKey(o).generateKeyPair(2048)}async function unmarshalPrivateKey(o){const a=PrivateKey.decode(o),c=a.Data??new Uint8Array;switch(a.Type){case KeyType.RSA:return supportedKeys.rsa.unmarshalRsaPrivateKey(c);case KeyType.Ed25519:return supportedKeys.ed25519.unmarshalEd25519PrivateKey(c);case KeyType.Secp256k1:return supportedKeys.secp256k1.unmarshalSecp256k1PrivateKey(c);default:throw unsupportedKey(a.Type??"RSA")}}function base$4(o){if(o.length>=255)throw new TypeError("Alphabet too long");for(var a=new Uint8Array(256),c=0;c>>0,L0=new Uint8Array(O0);A0!==$0;){for(var q0=i0[A0],F0=0,u1=O0-1;(q0!==0||F0>>0,L0[u1]=q0%$a>>>0,q0=q0/$a>>>0;if(q0!==0)throw new Error("Non-zero carry");w0=F0,A0++}for(var g1=O0-w0;g1!==O0&&L0[g1]===0;)g1++;for(var E1=Ys.repeat(p0);g1>>0,O0=new Uint8Array($0);i0[p0];){var L0=a[i0.charCodeAt(p0)];if(L0===255)return;for(var q0=0,F0=$0-1;(L0!==0||q0>>0,O0[F0]=L0%256>>>0,L0=L0/256>>>0;if(L0!==0)throw new Error("Non-zero carry");A0=q0,p0++}for(var u1=$0-A0;u1!==$0&&O0[u1]===0;)u1++;for(var g1=new Uint8Array(w0+($0-u1)),E1=w0;u1!==$0;)g1[E1++]=O0[u1++];return g1}function Xu(i0){var p0=Iu(i0);if(p0)return p0;throw new Error("Non-base"+$a+" character")}return{encode:$u,decodeUnsafe:Iu,decode:Xu}}var src$1=base$4;const basex$2=src$1,ALPHABET$2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var bs58$2=basex$2(ALPHABET$2);const bs58$3=getDefaultExportFromCjs$1(bs58$2),CLIENT_KEY$1="client-key",AUTHORIZED$1="node-authorized",CALLBACK_URL="callback-url",APPLICATION_ID="application-id",setStorageCallbackUrl=o=>{localStorage.setItem(CALLBACK_URL,JSON.stringify(o))},getStorageCallbackUrl=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(CALLBACK_URL);return o?JSON.parse(o):null}return null},setStorageApplicationId=o=>{localStorage.setItem(APPLICATION_ID,JSON.stringify(o))},getStorageApplicationId=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(APPLICATION_ID);return o?JSON.parse(o):null}return null},setStorageClientKey=o=>{localStorage.setItem(CLIENT_KEY$1,JSON.stringify(o))},getStorageClientKey=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(CLIENT_KEY$1);if(!o)return null;let a=JSON.parse(o);if(a)return a}return null},setStorageNodeAuthorized=()=>{localStorage.setItem(AUTHORIZED$1,JSON.stringify(!0))},getStorageNodeAuthorized=()=>{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(AUTHORIZED$1);if(o!==null){let a=JSON.parse(o);if(a)return a}else return null}return null};async function createAuthHeader(o,a){const c=await getPrivateKey();if(!c)return null;const tt=new TextEncoder().encode(o),nt=bs58$3.encode(c.public.bytes),$a=await crypto.subtle.digest("SHA-256",tt),Ys=new Uint8Array($a),gu=await c.sign(Ys),xu=bs58$3.encode(gu),$u=bs58$3.encode(Ys);return{wallet_type:JSON.stringify(WalletType.NEAR({networkId:a})),signing_key:nt,signature:xu,challenge:$u}}async function getPrivateKey(){try{const o=getStorageClientKey();return o?await unmarshalPrivateKey(bs58$3.decode(o.privateKey)):null}catch(o){return console.error("Error extracting private key:",o),null}}const t$6=translations.nodeDataSource;var Network=(o=>(o.NEAR="NEAR",o.ETH="ETH",o.BNB="BNB",o.ARB="ARB",o.ZK="ZK",o.STARKNET="STARKNET",o.ICP="ICP",o))(Network||{}),WalletType;(o=>{function a({networkId:$a="mainnet"}){return{type:"NEAR",networkId:$a}}o.NEAR=a;function c({chainId:$a=1}){return{type:"ETH",chainId:$a}}o.ETH=c;function d({walletName:$a="MS"}){return{type:"STARKNET",walletName:$a}}o.STARKNET=d;const tt="rdmx6-jaaaa-aaaaa-aaadq-cai";function nt({canisterId:$a=tt,walletName:Ys="II"}){return{type:"ICP",canisterId:$a,walletName:Ys}}o.ICP=nt})(WalletType||(WalletType={}));class NodeDataSource{constructor(a){aw(this,"client");this.client=a}async getInstalledApplications(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/applications`,a??{})}catch(a){return console.error("Error fetching installed applications:",a),{error:{code:500,message:"Failed to fetch installed applications."}}}}async getInstalledApplicationDetails(a){try{const c=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/applications/${a}`,c??{})}catch(c){return console.error("Error fetching installed application:",c),{error:{code:500,message:"Failed to fetch installed application."}}}}async getContexts(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts`,a??{})}catch(a){return console.error("Error fetching contexts:",a),{error:{code:500,message:"Failed to fetch context data."}}}}async getContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context data."}}}}async getContextClientKeys(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/client-keys`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context client keys."}}}}async getContextUsers(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/users`,c??{})}catch(c){return console.error("Error fetching context:",c),{error:{code:500,message:"Failed to fetch context users."}}}}async getContextStorageUsage(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/storage`,c??{})}catch(c){return console.error("Error fetching context storage usage:",c),{error:{code:500,message:"Failed to fetch context storage usage."}}}}async deleteContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.delete(`${getAppEndpointKey()}/admin-api/contexts/${a}`,c??{})}catch(c){return console.error("Error deleting context:",c),{error:{code:500,message:"Failed to delete context."}}}}async startContexts(a,c){try{const d=await createAuthHeader(JSON.stringify({applicationId:a,initArguments:c}),getNearEnvironment()),nt=new TextEncoder().encode(JSON.stringify(c)),$a=Array.from(nt);return await this.client.post(`${getAppEndpointKey()}/admin-api/contexts`,{applicationId:a,initializationParams:$a},d??{})}catch(d){return console.error("Error starting contexts:",d),{error:{code:500,message:"Failed to start context."}}}}async getDidList(){try{const a=await createAuthHeader(getAppEndpointKey(),getNearEnvironment());return await this.client.get(`${getAppEndpointKey()}/admin-api/did`,a??{})}catch(a){return console.error("Error fetching root keys:",a),{error:{code:500,message:"Failed to fetch root keys."}}}}async health(a){return await this.client.get(`${a.url}/admin-api/health`)}async installApplication(a,c,d,tt){try{const nt=await createAuthHeader(JSON.stringify({selectedPackageId:a,selectedVersion:c,hash:tt}),getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/install-application`,{url:d,version:c,metadata:createAppMetadata(a)},nt??{})}catch(nt){return console.error("Error installing application:",nt),{error:{code:500,message:"Failed to install application."}}}}async uninstallApplication(a){try{const c=await createAuthHeader(JSON.stringify({applicationId:a}),getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/uninstall-application`,{applicationId:a},c??{})}catch(c){return console.error("Error uninstalling application:",c),{error:{code:500,message:"Failed to uninstall application."}}}}async joinContext(a){try{const c=await createAuthHeader(a,getNearEnvironment());return await this.client.post(`${getAppEndpointKey()}/admin-api/contexts/${a}/join`,{},c??{})}catch(c){return console.error(`${t$6.joinContextErrorTitle}: ${c}`),{error:{code:500,message:t$6.joinContextErrorMessage}}}}async login(a){return await this.client.post(`${getAppEndpointKey()}/admin-api/add-client-key`,{...a})}async requestChallenge(){return await this.client.post(`${getAppEndpointKey()}/admin-api/request-challenge`,{})}async addRootKey(a){const c=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return c?await this.client.post(`${getAppEndpointKey()}/admin-api/root-key`,{...a},c):{error:{code:401,message:"Unauthorized"}}}async getContextIdentity(a){const c=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return c?await this.client.get(`${getAppEndpointKey()}/admin-api/contexts/${a}/identities`,c):{error:{code:401,message:t$6.unauthorizedErrorMessage}}}async createAccessToken(a,c){const d=await createAuthHeader(JSON.stringify(a),getNearEnvironment());return d?await this.client.post(`${getAppEndpointKey()}/admin-api/generate-jwt-token`,{contextId:a,executorPublicKey:c},d):{error:{code:401,message:t$6.unauthorizedErrorMessage}}}}class ApiClient{constructor(a){aw(this,"nodeApi");this.nodeApi=new NodeDataSource(a)}node(){return this.nodeApi}}const apiClient=o=>{const a=new AxiosHttpClient(axios,o);return new ApiClient(a)},APP_URL="app-url",AUTHORIZED="node-authorized",CLIENT_KEY="client-key",NODE_URL="node-url",clearStorage=()=>{localStorage.removeItem(APP_URL),localStorage.removeItem(AUTHORIZED),localStorage.removeItem(CLIENT_KEY)},getAppEndpointKey=()=>{try{if(typeof window<"u"&&window.localStorage){let o=localStorage.getItem(APP_URL);if(o){let a=JSON.parse(o);if(a&&a.length>0)return a}}return null}catch{return null}},setAppEndpointKey=o=>{localStorage.setItem(APP_URL,JSON.stringify(o))},getClientKey=()=>localStorage.getItem(CLIENT_KEY)??"",isNodeAuthorized=()=>{const o=localStorage.getItem(AUTHORIZED);return o?JSON.parse(o):!1},setNodeUrlFromQuery=async o=>{const c=new URLSearchParams(window.location.search).get(NODE_URL);if(c&&await verifyNodeUrl(c,o)){setAppEndpointKey(c);const d=`${window.location.pathname}auth`;window.location.href=d}else if(c)window.alert("Node URL is not valid or not reachable. Please try again.");else return},verifyNodeUrl=async(o,a)=>{try{return new URL(o),!!(await apiClient(a).node().health({url:o})).data}catch{return!1}};var classnames={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames @@ -2386,7 +2386,7 @@ You might need to use a local HTTP server (instead of file://): https://reactjs. } } } -`;function SetupModal({successRoute:o,setNodeUrl:a,getNodeUrl:c}){const d=translations.setupModal,[tt,nt]=reactExports.useState(null),[$a,Ys]=reactExports.useState(!1),[gu,xu]=reactExports.useState(null),$u=1e3;reactExports.useEffect(()=>{xu(c())},[c]);function Iu(w0){try{return new URL(w0),!0}catch{return!1}}const Xu=w0=>{nt(""),xu(w0)},i0=reactExports.useCallback(async()=>{if(gu)if(Iu(gu.toString())){Ys(!0);const w0=new Promise(A0=>setTimeout(A0,$u));try{const A0=apiClient(()=>{nt(d.nodeHealthCheckError),Ys(!1)}).node().health({url:gu});Promise.all([w0,A0]).then(([,$0])=>{$0.data?(nt(""),a(gu),o()):nt(d.nodeHealthCheckError),Ys(!1)})}catch(A0){console.log(A0),nt(d.nodeHealthCheckError),Ys(!1)}}else nt(d.nodeHealthCheckError)},[a,o,d.nodeHealthCheckError,gu]),p0=()=>!gu;return jsxRuntimeExports.jsx(Wrapper$5,{children:jsxRuntimeExports.jsx("div",{className:"flex-wrapper",children:jsxRuntimeExports.jsx("div",{className:"inner-wrapper",children:jsxRuntimeExports.jsxs("div",{className:"content-wrapper",children:[jsxRuntimeExports.jsx("div",{className:"title",children:d.modalTitle}),$a?jsxRuntimeExports.jsx(Loading,{loaderColor:"#FF7A00",loaderSize:"48px",borderSize:"5px"}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"popup-wrapper",children:[jsxRuntimeExports.jsx("input",{type:"text",placeholder:d.urlInputPlacerholder,inputMode:"url",value:(gu==null?void 0:gu.toString())||"",onChange:w0=>{Xu(w0.target.value)},className:"input-field"}),jsxRuntimeExports.jsx("div",{className:"error",children:tt}),jsxRuntimeExports.jsx("button",{className:"button",style:{cursor:p0()?"not-allowed":"pointer"},disabled:p0(),onClick:i0,children:jsxRuntimeExports.jsx("span",{children:d.buttonSetText})})]})})]})})})})}function SetupPage(){const o=useNavigate();return jsxRuntimeExports.jsx(ContentWrapper,{children:jsxRuntimeExports.jsx(SetupModal,{successRoute:()=>o("/auth"),setNodeUrl:setAppEndpointKey,getNodeUrl})})}var browser={},canPromise$1=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$2={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$2.getSymbolSize=function o(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17};utils$2.getSymbolTotalCodewords=function o(a){return CODEWORDS_COUNT[a]};utils$2.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a};utils$2.setToSJISFunction=function o(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=a};utils$2.isKanjiModeEnabled=function(){return typeof toSJISFunction<"u"};utils$2.toSJIS=function o(a){return toSJISFunction(a)};var errorCorrectionLevel={};(function(o){o.L={bit:1},o.M={bit:0},o.Q={bit:3},o.H={bit:2};function a(c){if(typeof c!="string")throw new Error("Param is not a string");switch(c.toLowerCase()){case"l":case"low":return o.L;case"m":case"medium":return o.M;case"q":case"quartile":return o.Q;case"h":case"high":return o.H;default:throw new Error("Unknown EC Level: "+c)}}o.isValid=function(d){return d&&typeof d.bit<"u"&&d.bit>=0&&d.bit<4},o.from=function(d,tt){if(o.isValid(d))return d;try{return a(d)}catch{return tt}}})(errorCorrectionLevel);function BitBuffer$1(){this.buffer=[],this.length=0}BitBuffer$1.prototype={get:function(o){const a=Math.floor(o/8);return(this.buffer[a]>>>7-o%8&1)===1},put:function(o,a){for(let c=0;c>>a-c-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(o){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),o&&(this.buffer[a]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(o){if(!o||o<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=o,this.data=new Uint8Array(o*o),this.reservedBit=new Uint8Array(o*o)}BitMatrix$1.prototype.set=function(o,a,c,d){const tt=o*this.size+a;this.data[tt]=c,d&&(this.reservedBit[tt]=!0)};BitMatrix$1.prototype.get=function(o,a){return this.data[o*this.size+a]};BitMatrix$1.prototype.xor=function(o,a,c){this.data[o*this.size+a]^=c};BitMatrix$1.prototype.isReserved=function(o,a){return this.reservedBit[o*this.size+a]};var bitMatrix=BitMatrix$1,alignmentPattern={};(function(o){const a=utils$2.getSymbolSize;o.getRowColCoords=function(d){if(d===1)return[];const tt=Math.floor(d/7)+2,nt=a(d),$a=nt===145?26:Math.ceil((nt-13)/(2*tt-2))*2,Ys=[nt-7];for(let gu=1;gu=0&&tt<=7},o.from=function(tt){return o.isValid(tt)?parseInt(tt,10):void 0},o.getPenaltyN1=function(tt){const nt=tt.size;let $a=0,Ys=0,gu=0,xu=null,$u=null;for(let Iu=0;Iu=5&&($a+=a.N1+(Ys-5)),xu=i0,Ys=1),i0=tt.get(Xu,Iu),i0===$u?gu++:(gu>=5&&($a+=a.N1+(gu-5)),$u=i0,gu=1)}Ys>=5&&($a+=a.N1+(Ys-5)),gu>=5&&($a+=a.N1+(gu-5))}return $a},o.getPenaltyN2=function(tt){const nt=tt.size;let $a=0;for(let Ys=0;Ys=10&&(Ys===1488||Ys===93)&&$a++,gu=gu<<1&2047|tt.get($u,xu),$u>=10&&(gu===1488||gu===93)&&$a++}return $a*a.N3},o.getPenaltyN4=function(tt){let nt=0;const $a=tt.data.length;for(let gu=0;gu<$a;gu++)nt+=tt.data[gu];return Math.abs(Math.ceil(nt*100/$a/5)-10)*a.N4};function c(d,tt,nt){switch(d){case o.Patterns.PATTERN000:return(tt+nt)%2===0;case o.Patterns.PATTERN001:return tt%2===0;case o.Patterns.PATTERN010:return nt%3===0;case o.Patterns.PATTERN011:return(tt+nt)%3===0;case o.Patterns.PATTERN100:return(Math.floor(tt/2)+Math.floor(nt/3))%2===0;case o.Patterns.PATTERN101:return tt*nt%2+tt*nt%3===0;case o.Patterns.PATTERN110:return(tt*nt%2+tt*nt%3)%2===0;case o.Patterns.PATTERN111:return(tt*nt%3+(tt+nt)%2)%2===0;default:throw new Error("bad maskPattern:"+d)}}o.applyMask=function(tt,nt){const $a=nt.size;for(let Ys=0;Ys<$a;Ys++)for(let gu=0;gu<$a;gu++)nt.isReserved(gu,Ys)||nt.xor(gu,Ys,c(tt,gu,Ys))},o.getBestMask=function(tt,nt){const $a=Object.keys(o.Patterns).length;let Ys=0,gu=1/0;for(let xu=0;xu<$a;xu++){nt(xu),o.applyMask(xu,tt);const $u=o.getPenaltyN1(tt)+o.getPenaltyN2(tt)+o.getPenaltyN3(tt)+o.getPenaltyN4(tt);o.applyMask(xu,tt),$u=0;){const $a=nt[0];for(let gu=0;gu0){const nt=new Uint8Array(this.degree);return nt.set(d,tt),nt}return d};var reedSolomonEncoder=ReedSolomonEncoder$1,version$3={},mode={},versionCheck={};versionCheck.isValid=function o(a){return!isNaN(a)&&a>=1&&a<=40};var regex={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+`)(?:.|[\r +`;function SetupModal({successRoute:o,setNodeUrl:a,getNodeUrl:c}){const d=translations.setupModal,[tt,nt]=reactExports.useState(null),[$a,Ys]=reactExports.useState(!1),[gu,xu]=reactExports.useState(null),$u=1e3;reactExports.useEffect(()=>{xu(c())},[c]);function Iu(w0){try{return new URL(w0),!0}catch{return!1}}const Xu=w0=>{nt(""),xu(w0)},i0=reactExports.useCallback(async()=>{if(gu)if(Iu(gu.toString())){Ys(!0);const w0=new Promise(A0=>setTimeout(A0,$u));try{const A0=apiClient(()=>{nt(d.nodeHealthCheckError),Ys(!1)}).node().health({url:gu});Promise.all([w0,A0]).then(([,$0])=>{$0.data?(nt(""),a(gu),o()):nt(d.nodeHealthCheckError),Ys(!1)})}catch(A0){console.log(A0),nt(d.nodeHealthCheckError),Ys(!1)}}else nt(d.nodeHealthCheckError)},[a,o,d.nodeHealthCheckError,gu]),p0=()=>!gu;return jsxRuntimeExports.jsx(Wrapper$5,{children:jsxRuntimeExports.jsx("div",{className:"flex-wrapper",children:jsxRuntimeExports.jsx("div",{className:"inner-wrapper",children:jsxRuntimeExports.jsxs("div",{className:"content-wrapper",children:[jsxRuntimeExports.jsx("div",{className:"title",children:d.modalTitle}),$a?jsxRuntimeExports.jsx(Loading,{loaderColor:"#FF7A00",loaderSize:"48px",borderSize:"5px"}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"popup-wrapper",children:[jsxRuntimeExports.jsx("input",{type:"text",placeholder:d.urlInputPlacerholder,inputMode:"url",value:(gu==null?void 0:gu.toString())||"",onChange:w0=>{Xu(w0.target.value)},className:"input-field"}),jsxRuntimeExports.jsx("div",{className:"error",children:tt}),jsxRuntimeExports.jsx("button",{className:"button",style:{cursor:p0()?"not-allowed":"pointer"},disabled:p0(),onClick:i0,children:jsxRuntimeExports.jsx("span",{children:d.buttonSetText})})]})})]})})})})}function SetupPage(){const o=useNavigate();return reactExports.useEffect(()=>{clearStorage()},[]),jsxRuntimeExports.jsx(ContentWrapper,{children:jsxRuntimeExports.jsx(SetupModal,{successRoute:()=>o("/auth"),setNodeUrl:setAppEndpointKey,getNodeUrl})})}var browser={},canPromise$1=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},qrcode={},utils$2={};let toSJISFunction;const CODEWORDS_COUNT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];utils$2.getSymbolSize=function o(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17};utils$2.getSymbolTotalCodewords=function o(a){return CODEWORDS_COUNT[a]};utils$2.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a};utils$2.setToSJISFunction=function o(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');toSJISFunction=a};utils$2.isKanjiModeEnabled=function(){return typeof toSJISFunction<"u"};utils$2.toSJIS=function o(a){return toSJISFunction(a)};var errorCorrectionLevel={};(function(o){o.L={bit:1},o.M={bit:0},o.Q={bit:3},o.H={bit:2};function a(c){if(typeof c!="string")throw new Error("Param is not a string");switch(c.toLowerCase()){case"l":case"low":return o.L;case"m":case"medium":return o.M;case"q":case"quartile":return o.Q;case"h":case"high":return o.H;default:throw new Error("Unknown EC Level: "+c)}}o.isValid=function(d){return d&&typeof d.bit<"u"&&d.bit>=0&&d.bit<4},o.from=function(d,tt){if(o.isValid(d))return d;try{return a(d)}catch{return tt}}})(errorCorrectionLevel);function BitBuffer$1(){this.buffer=[],this.length=0}BitBuffer$1.prototype={get:function(o){const a=Math.floor(o/8);return(this.buffer[a]>>>7-o%8&1)===1},put:function(o,a){for(let c=0;c>>a-c-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(o){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),o&&(this.buffer[a]|=128>>>this.length%8),this.length++}};var bitBuffer=BitBuffer$1;function BitMatrix$1(o){if(!o||o<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=o,this.data=new Uint8Array(o*o),this.reservedBit=new Uint8Array(o*o)}BitMatrix$1.prototype.set=function(o,a,c,d){const tt=o*this.size+a;this.data[tt]=c,d&&(this.reservedBit[tt]=!0)};BitMatrix$1.prototype.get=function(o,a){return this.data[o*this.size+a]};BitMatrix$1.prototype.xor=function(o,a,c){this.data[o*this.size+a]^=c};BitMatrix$1.prototype.isReserved=function(o,a){return this.reservedBit[o*this.size+a]};var bitMatrix=BitMatrix$1,alignmentPattern={};(function(o){const a=utils$2.getSymbolSize;o.getRowColCoords=function(d){if(d===1)return[];const tt=Math.floor(d/7)+2,nt=a(d),$a=nt===145?26:Math.ceil((nt-13)/(2*tt-2))*2,Ys=[nt-7];for(let gu=1;gu=0&&tt<=7},o.from=function(tt){return o.isValid(tt)?parseInt(tt,10):void 0},o.getPenaltyN1=function(tt){const nt=tt.size;let $a=0,Ys=0,gu=0,xu=null,$u=null;for(let Iu=0;Iu=5&&($a+=a.N1+(Ys-5)),xu=i0,Ys=1),i0=tt.get(Xu,Iu),i0===$u?gu++:(gu>=5&&($a+=a.N1+(gu-5)),$u=i0,gu=1)}Ys>=5&&($a+=a.N1+(Ys-5)),gu>=5&&($a+=a.N1+(gu-5))}return $a},o.getPenaltyN2=function(tt){const nt=tt.size;let $a=0;for(let Ys=0;Ys=10&&(Ys===1488||Ys===93)&&$a++,gu=gu<<1&2047|tt.get($u,xu),$u>=10&&(gu===1488||gu===93)&&$a++}return $a*a.N3},o.getPenaltyN4=function(tt){let nt=0;const $a=tt.data.length;for(let gu=0;gu<$a;gu++)nt+=tt.data[gu];return Math.abs(Math.ceil(nt*100/$a/5)-10)*a.N4};function c(d,tt,nt){switch(d){case o.Patterns.PATTERN000:return(tt+nt)%2===0;case o.Patterns.PATTERN001:return tt%2===0;case o.Patterns.PATTERN010:return nt%3===0;case o.Patterns.PATTERN011:return(tt+nt)%3===0;case o.Patterns.PATTERN100:return(Math.floor(tt/2)+Math.floor(nt/3))%2===0;case o.Patterns.PATTERN101:return tt*nt%2+tt*nt%3===0;case o.Patterns.PATTERN110:return(tt*nt%2+tt*nt%3)%2===0;case o.Patterns.PATTERN111:return(tt*nt%3+(tt+nt)%2)%2===0;default:throw new Error("bad maskPattern:"+d)}}o.applyMask=function(tt,nt){const $a=nt.size;for(let Ys=0;Ys<$a;Ys++)for(let gu=0;gu<$a;gu++)nt.isReserved(gu,Ys)||nt.xor(gu,Ys,c(tt,gu,Ys))},o.getBestMask=function(tt,nt){const $a=Object.keys(o.Patterns).length;let Ys=0,gu=1/0;for(let xu=0;xu<$a;xu++){nt(xu),o.applyMask(xu,tt);const $u=o.getPenaltyN1(tt)+o.getPenaltyN2(tt)+o.getPenaltyN3(tt)+o.getPenaltyN4(tt);o.applyMask(xu,tt),$u=0;){const $a=nt[0];for(let gu=0;gu0){const nt=new Uint8Array(this.degree);return nt.set(d,tt),nt}return d};var reedSolomonEncoder=ReedSolomonEncoder$1,version$3={},mode={},versionCheck={};versionCheck.isValid=function o(a){return!isNaN(a)&&a>=1&&a<=40};var regex={};const numeric="[0-9]+",alphanumeric="[A-Z $%*+\\-./:]+";let kanji="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";kanji=kanji.replace(/u/g,"\\u");const byte="(?:(?![A-Z0-9 $%*+\\-./:]|"+kanji+`)(?:.|[\r ]))+`;regex.KANJI=new RegExp(kanji,"g");regex.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");regex.BYTE=new RegExp(byte,"g");regex.NUMERIC=new RegExp(numeric,"g");regex.ALPHANUMERIC=new RegExp(alphanumeric,"g");const TEST_KANJI=new RegExp("^"+kanji+"$"),TEST_NUMERIC=new RegExp("^"+numeric+"$"),TEST_ALPHANUMERIC=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");regex.testKanji=function o(a){return TEST_KANJI.test(a)};regex.testNumeric=function o(a){return TEST_NUMERIC.test(a)};regex.testAlphanumeric=function o(a){return TEST_ALPHANUMERIC.test(a)};(function(o){const a=versionCheck,c=regex;o.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},o.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},o.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},o.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},o.MIXED={bit:-1},o.getCharCountIndicator=function(nt,$a){if(!nt.ccBits)throw new Error("Invalid mode: "+nt);if(!a.isValid($a))throw new Error("Invalid version: "+$a);return $a>=1&&$a<10?nt.ccBits[0]:$a<27?nt.ccBits[1]:nt.ccBits[2]},o.getBestModeForData=function(nt){return c.testNumeric(nt)?o.NUMERIC:c.testAlphanumeric(nt)?o.ALPHANUMERIC:c.testKanji(nt)?o.KANJI:o.BYTE},o.toString=function(nt){if(nt&&nt.id)return nt.id;throw new Error("Invalid mode")},o.isValid=function(nt){return nt&&nt.bit&&nt.ccBits};function d(tt){if(typeof tt!="string")throw new Error("Param is not a string");switch(tt.toLowerCase()){case"numeric":return o.NUMERIC;case"alphanumeric":return o.ALPHANUMERIC;case"kanji":return o.KANJI;case"byte":return o.BYTE;default:throw new Error("Unknown mode: "+tt)}}o.from=function(nt,$a){if(o.isValid(nt))return nt;try{return d(nt)}catch{return $a}}})(mode);(function(o){const a=utils$2,c=errorCorrectionCode,d=errorCorrectionLevel,tt=mode,nt=versionCheck,$a=7973,Ys=a.getBCHDigit($a);function gu(Xu,i0,p0){for(let w0=1;w0<=40;w0++)if(i0<=o.getCapacity(w0,p0,Xu))return w0}function xu(Xu,i0){return tt.getCharCountIndicator(Xu,i0)+4}function $u(Xu,i0){let p0=0;return Xu.forEach(function(w0){const A0=xu(w0.mode,i0);p0+=A0+w0.getBitsLength()}),p0}function Iu(Xu,i0){for(let p0=1;p0<=40;p0++)if($u(Xu,p0)<=o.getCapacity(p0,i0,tt.MIXED))return p0}o.from=function(i0,p0){return nt.isValid(i0)?parseInt(i0,10):p0},o.getCapacity=function(i0,p0,w0){if(!nt.isValid(i0))throw new Error("Invalid QR Code version");typeof w0>"u"&&(w0=tt.BYTE);const A0=a.getSymbolTotalCodewords(i0),$0=c.getTotalCodewordsCount(i0,p0),O0=(A0-$0)*8;if(w0===tt.MIXED)return O0;const L0=O0-xu(w0,i0);switch(w0){case tt.NUMERIC:return Math.floor(L0/10*3);case tt.ALPHANUMERIC:return Math.floor(L0/11*2);case tt.KANJI:return Math.floor(L0/13);case tt.BYTE:default:return Math.floor(L0/8)}},o.getBestVersionForData=function(i0,p0){let w0;const A0=d.from(p0,d.M);if(Array.isArray(i0)){if(i0.length>1)return Iu(i0,A0);if(i0.length===0)return 1;w0=i0[0]}else w0=i0;return gu(w0.mode,w0.getLength(),A0)},o.getEncodedBits=function(i0){if(!nt.isValid(i0)||i0<7)throw new Error("Invalid QR Code version");let p0=i0<<12;for(;a.getBCHDigit(p0)-Ys>=0;)p0^=$a<=0;)tt^=G15<0&&(d=this.data.substr(c),tt=parseInt(d,10),a.put(tt,nt*3+1))};var numericData=NumericData;const Mode$3=mode,ALPHA_NUM_CHARS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function AlphanumericData(o){this.mode=Mode$3.ALPHANUMERIC,this.data=o}AlphanumericData.getBitsLength=function o(a){return 11*Math.floor(a/2)+6*(a%2)};AlphanumericData.prototype.getLength=function o(){return this.data.length};AlphanumericData.prototype.getBitsLength=function o(){return AlphanumericData.getBitsLength(this.data.length)};AlphanumericData.prototype.write=function o(a){let c;for(c=0;c+2<=this.data.length;c+=2){let d=ALPHA_NUM_CHARS.indexOf(this.data[c])*45;d+=ALPHA_NUM_CHARS.indexOf(this.data[c+1]),a.put(d,11)}this.data.length%2&&a.put(ALPHA_NUM_CHARS.indexOf(this.data[c]),6)};var alphanumericData=AlphanumericData,encodeUtf8$1=function o(a){for(var c=[],d=a.length,tt=0;tt=55296&&nt<=56319&&d>tt+1){var $a=a.charCodeAt(tt+1);$a>=56320&&$a<=57343&&(nt=(nt-55296)*1024+$a-56320+65536,tt+=1)}if(nt<128){c.push(nt);continue}if(nt<2048){c.push(nt>>6|192),c.push(nt&63|128);continue}if(nt<55296||nt>=57344&&nt<65536){c.push(nt>>12|224),c.push(nt>>6&63|128),c.push(nt&63|128);continue}if(nt>=65536&&nt<=1114111){c.push(nt>>18|240),c.push(nt>>12&63|128),c.push(nt>>6&63|128),c.push(nt&63|128);continue}c.push(239,191,189)}return new Uint8Array(c).buffer};const encodeUtf8=encodeUtf8$1,Mode$2=mode;function ByteData(o){this.mode=Mode$2.BYTE,typeof o=="string"&&(o=encodeUtf8(o)),this.data=new Uint8Array(o)}ByteData.getBitsLength=function o(a){return a*8};ByteData.prototype.getLength=function o(){return this.data.length};ByteData.prototype.getBitsLength=function o(){return ByteData.getBitsLength(this.data.length)};ByteData.prototype.write=function(o){for(let a=0,c=this.data.length;a=33088&&c<=40956)c-=33088;else if(c>=57408&&c<=60351)c-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+` Make sure your charset is UTF-8`);c=(c>>>8&255)*192+(c&255),o.put(c,13)}};var kanjiData=KanjiData,dijkstra={exports:{}};(function(o){var a={single_source_shortest_paths:function(c,d,tt){var nt={},$a={};$a[d]=0;var Ys=a.PriorityQueue.make();Ys.push(d,0);for(var gu,xu,$u,Iu,Xu,i0,p0,w0,A0;!Ys.empty();){gu=Ys.pop(),xu=gu.value,Iu=gu.cost,Xu=c[xu]||{};for($u in Xu)Xu.hasOwnProperty($u)&&(i0=Xu[$u],p0=Iu+i0,w0=$a[$u],A0=typeof $a[$u]>"u",(A0||w0>p0)&&($a[$u]=p0,Ys.push($u,p0),nt[$u]=xu))}if(typeof tt<"u"&&typeof $a[tt]>"u"){var $0=["Could not find a path from ",d," to ",tt,"."].join("");throw new Error($0)}return nt},extract_shortest_path_from_predecessor_list:function(c,d){for(var tt=[],nt=d;nt;)tt.push(nt),c[nt],nt=c[nt];return tt.reverse(),tt},find_path:function(c,d,tt){var nt=a.single_source_shortest_paths(c,d,tt);return a.extract_shortest_path_from_predecessor_list(nt,tt)},PriorityQueue:{make:function(c){var d=a.PriorityQueue,tt={},nt;c=c||{};for(nt in d)d.hasOwnProperty(nt)&&(tt[nt]=d[nt]);return tt.queue=[],tt.sorter=c.sorter||d.default_sorter,tt},default_sorter:function(c,d){return c.cost-d.cost},push:function(c,d){var tt={value:c,cost:d};this.queue.push(tt),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};o.exports=a})(dijkstra);var dijkstraExports=dijkstra.exports;(function(o){const a=mode,c=numericData,d=alphanumericData,tt=byteData,nt=kanjiData,$a=regex,Ys=utils$2,gu=dijkstraExports;function xu($0){return unescape(encodeURIComponent($0)).length}function $u($0,O0,L0){const q0=[];let F0;for(;(F0=$0.exec(L0))!==null;)q0.push({data:F0[0],index:F0.index,mode:O0,length:F0[0].length});return q0}function Iu($0){const O0=$u($a.NUMERIC,a.NUMERIC,$0),L0=$u($a.ALPHANUMERIC,a.ALPHANUMERIC,$0);let q0,F0;return Ys.isKanjiModeEnabled()?(q0=$u($a.BYTE,a.BYTE,$0),F0=$u($a.KANJI,a.KANJI,$0)):(q0=$u($a.BYTE_KANJI,a.BYTE,$0),F0=[]),O0.concat(L0,q0,F0).sort(function(g1,E1){return g1.index-E1.index}).map(function(g1){return{data:g1.data,mode:g1.mode,length:g1.length}})}function Xu($0,O0){switch(O0){case a.NUMERIC:return c.getBitsLength($0);case a.ALPHANUMERIC:return d.getBitsLength($0);case a.KANJI:return nt.getBitsLength($0);case a.BYTE:return tt.getBitsLength($0)}}function i0($0){return $0.reduce(function(O0,L0){const q0=O0.length-1>=0?O0[O0.length-1]:null;return q0&&q0.mode===L0.mode?(O0[O0.length-1].data+=L0.data,O0):(O0.push(L0),O0)},[])}function p0($0){const O0=[];for(let L0=0;L0<$0.length;L0++){const q0=$0[L0];switch(q0.mode){case a.NUMERIC:O0.push([q0,{data:q0.data,mode:a.ALPHANUMERIC,length:q0.length},{data:q0.data,mode:a.BYTE,length:q0.length}]);break;case a.ALPHANUMERIC:O0.push([q0,{data:q0.data,mode:a.BYTE,length:q0.length}]);break;case a.KANJI:O0.push([q0,{data:q0.data,mode:a.BYTE,length:xu(q0.data)}]);break;case a.BYTE:O0.push([{data:q0.data,mode:a.BYTE,length:xu(q0.data)}])}}return O0}function w0($0,O0){const L0={},q0={start:{}};let F0=["start"];for(let u1=0;u1<$0.length;u1++){const g1=$0[u1],E1=[];for(let B1=0;B1=0&&Ys<=6&&(gu===0||gu===6)||gu>=0&&gu<=6&&(Ys===0||Ys===6)||Ys>=2&&Ys<=4&&gu>=2&&gu<=4?o.set(nt+Ys,$a+gu,!0,!0):o.set(nt+Ys,$a+gu,!1,!0))}}function setupTimingPattern(o){const a=o.size;for(let c=8;c>Ys&1)===1,o.set(tt,nt,$a,!0),o.set(nt,tt,$a,!0)}function setupFormatInfo(o,a,c){const d=o.size,tt=FormatInfo.getEncodedBits(a,c);let nt,$a;for(nt=0;nt<15;nt++)$a=(tt>>nt&1)===1,nt<6?o.set(nt,8,$a,!0):nt<8?o.set(nt+1,8,$a,!0):o.set(d-15+nt,8,$a,!0),nt<8?o.set(8,d-nt-1,$a,!0):nt<9?o.set(8,15-nt-1+1,$a,!0):o.set(8,15-nt-1,$a,!0);o.set(d-8,8,1,!0)}function setupData(o,a){const c=o.size;let d=-1,tt=c-1,nt=7,$a=0;for(let Ys=c-1;Ys>0;Ys-=2)for(Ys===6&&Ys--;;){for(let gu=0;gu<2;gu++)if(!o.isReserved(tt,Ys-gu)){let xu=!1;$a>>nt&1)===1),o.set(tt,Ys-gu,xu),nt--,nt===-1&&($a++,nt=7)}if(tt+=d,tt<0||c<=tt){tt-=d,d=-d;break}}}function createData(o,a,c){const d=new BitBuffer;c.forEach(function(gu){d.put(gu.mode.bit,4),d.put(gu.getLength(),Mode.getCharCountIndicator(gu.mode,o)),gu.write(d)});const tt=Utils$1.getSymbolTotalCodewords(o),nt=ECCode.getTotalCodewordsCount(o,a),$a=(tt-nt)*8;for(d.getLengthInBits()+4<=$a&&d.put(0,4);d.getLengthInBits()%8!==0;)d.putBit(0);const Ys=($a-d.getLengthInBits())/8;for(let gu=0;gu - + diff --git a/node-ui/src/api/httpClient.ts b/node-ui/src/api/httpClient.ts index cbd57b5e9..f545ffb35 100644 --- a/node-ui/src/api/httpClient.ts +++ b/node-ui/src/api/httpClient.ts @@ -41,6 +41,9 @@ export class AxiosHttpClient implements HttpClient { this.axios.interceptors.response.use( (response: AxiosResponse) => response, (error: AxiosError) => { + if (error.response?.status === 401) { + window.location.href = '/admin-dashboard/'; + } if (!error.response) { this.showServerDownPopup(); } diff --git a/node-ui/src/pages/setup/index.tsx b/node-ui/src/pages/setup/index.tsx index f2e40ddd1..590571664 100644 --- a/node-ui/src/pages/setup/index.tsx +++ b/node-ui/src/pages/setup/index.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { setAppEndpointKey } from '../../utils/storage'; +import { clearStorage, setAppEndpointKey } from '../../utils/storage'; import ContentWrapper from '../../components/login/ContentWrapper'; import { SetupModal } from '../../components/setup/SetupModal'; import { getNodeUrl } from '../../utils/node'; @@ -8,6 +8,10 @@ import { getNodeUrl } from '../../utils/node'; export default function SetupPage() { const navigate = useNavigate(); + useEffect(() => { + clearStorage(); + }, []); + return ( { + localStorage.removeItem(APP_URL); + localStorage.removeItem(AUTHORIZED); + localStorage.removeItem(CLIENT_KEY); +}; + export const getAppEndpointKey = (): string | null => { try { if (typeof window !== 'undefined' && window.localStorage) {