@antigane/wallet-adapters 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/dist/assets/wallets/metamask.svg +31 -0
- package/dist/assets/wallets/peridotwallet.svg +12 -0
- package/dist/assets/wallets/phantom.svg +11 -0
- package/dist/index.cjs +565 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +41640 -0
- package/dist/wallet-adapters.css +1 -0
- package/package.json +59 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xe=require("react");function OT(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Rf=OT(Xe);var su=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Bm(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var i=!1;try{i=this instanceof r}catch{}return i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var ou={exports:{}},Nc={};var Vy;function NT(){if(Vy)return Nc;Vy=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Nc.Fragment=e,Nc.jsx=n,Nc.jsxs=n,Nc}var Pc={};var jy;function PT(){return jy||(jy=1,process.env.NODE_ENV!=="production"&&(function(){function t(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===H?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case b:return"Fragment";case M:return"Profiler";case E:return"StrictMode";case z:return"Suspense";case X:return"SuspenseList";case B:return"Activity"}if(typeof x=="object")switch(typeof x.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),x.$$typeof){case w:return"Portal";case F:return x.displayName||"Context";case S:return(x._context.displayName||"Context")+".Consumer";case D:var h=x.render;return x=x.displayName,x||(x=h.displayName||h.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case Y:return h=x.displayName||null,h!==null?h:t(x.type)||"Memo";case U:h=x._payload,x=x._init;try{return t(x(h))}catch{}}return null}function e(x){return""+x}function n(x){try{e(x);var h=!1}catch{h=!0}if(h){h=console;var m=h.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&x[Symbol.toStringTag]||x.constructor.name||"Object";return m.call(h,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),e(x)}}function r(x){if(x===b)return"<>";if(typeof x=="object"&&x!==null&&x.$$typeof===U)return"<...>";try{var h=t(x);return h?"<"+h+">":"<...>"}catch{return"<...>"}}function i(){var x=V.A;return x===null?null:x.getOwner()}function s(){return Error("react-stack-top-frame")}function o(x){if(T.call(x,"key")){var h=Object.getOwnPropertyDescriptor(x,"key").get;if(h&&h.isReactWarning)return!1}return x.key!==void 0}function a(x,h){function m(){R||(R=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",h))}m.isReactWarning=!0,Object.defineProperty(x,"key",{get:m,configurable:!0})}function c(){var x=t(this.type);return P[x]||(P[x]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),x=this.props.ref,x!==void 0?x:null}function l(x,h,m,A,C,$){var j=m.ref;return x={$$typeof:v,type:x,key:h,props:m,_owner:A},(j!==void 0?j:null)!==null?Object.defineProperty(x,"ref",{enumerable:!1,get:c}):Object.defineProperty(x,"ref",{enumerable:!1,value:null}),x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(x,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(x,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.defineProperty(x,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x}function u(x,h,m,A,C,$){var j=h.children;if(j!==void 0)if(A)if(p(j)){for(A=0;A<j.length;A++)d(j[A]);Object.freeze&&Object.freeze(j)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else d(j);if(T.call(h,"key")){j=t(x);var Z=Object.keys(h).filter(function(se){return se!=="key"});A=0<Z.length?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}",N[j+A]||(Z=0<Z.length?"{"+Z.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,A,j,Z,j),N[j+A]=!0)}if(j=null,m!==void 0&&(n(m),j=""+m),o(h)&&(n(h.key),j=""+h.key),"key"in h){m={};for(var ne in h)ne!=="key"&&(m[ne]=h[ne])}else m=h;return j&&a(m,typeof x=="function"?x.displayName||x.name||"Unknown":x),l(x,j,m,i(),C,$)}function d(x){f(x)?x._store&&(x._store.validated=1):typeof x=="object"&&x!==null&&x.$$typeof===U&&(x._payload.status==="fulfilled"?f(x._payload.value)&&x._payload.value._store&&(x._payload.value._store.validated=1):x._store&&(x._store.validated=1))}function f(x){return typeof x=="object"&&x!==null&&x.$$typeof===v}var g=Xe,v=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),F=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),V=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=Object.prototype.hasOwnProperty,p=Array.isArray,y=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(x){return x()}};var R,P={},_=g.react_stack_bottom_frame.bind(g,s)(),I=y(r(s)),N={};Pc.Fragment=b,Pc.jsx=function(x,h,m){var A=1e4>V.recentlyCreatedOwnerStacks++;return u(x,h,m,!1,A?Error("react-stack-top-frame"):_,A?y(r(x)):I)},Pc.jsxs=function(x,h,m){var A=1e4>V.recentlyCreatedOwnerStacks++;return u(x,h,m,!0,A?Error("react-stack-top-frame"):_,A?y(r(x)):I)}})()),Pc}var Hy;function MT(){return Hy||(Hy=1,process.env.NODE_ENV==="production"?ou.exports=NT():ou.exports=PT()),ou.exports}var vt=MT();function kT(t,e=5,n=4){return t?t.length<=e+n+3?t:`${t.slice(0,e)}...${t.slice(-n)}`:"-"}const Um=Xe.createContext({});function $m(t){const e=Xe.useRef(null);return e.current===null&&(e.current=t()),e.current}const Fm=typeof window<"u",c_=Fm?Xe.useLayoutEffect:Xe.useEffect,If=Xe.createContext(null);function Km(t,e){t.indexOf(e)===-1&&t.push(e)}function Vm(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const As=(t,e,n)=>n>e?e:n<t?t:n;function s0(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let pc=()=>{},Rs=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&(pc=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(s0(e,n))},Rs=(t,e,n)=>{if(!t)throw new Error(s0(e,n))});const Is={},l_=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function u_(t){return typeof t=="object"&&t!==null}const d_=t=>/^0[^.\s]+$/u.test(t);function jm(t){let e;return()=>(e===void 0&&(e=t()),e)}const hi=t=>t,DT=(t,e)=>n=>e(t(n)),Ll=(...t)=>t.reduce(DT),fl=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Hm{constructor(){this.subscriptions=[]}add(e){return Km(this.subscriptions,e),()=>Vm(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let s=0;s<i;s++){const o=this.subscriptions[s];o&&o(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const xi=t=>t*1e3,di=t=>t/1e3;function f_(t,e){return e?t*(1e3/e):0}const zy=new Set;function zm(t,e,n){t||zy.has(e)||(console.warn(s0(e,n)),zy.add(e))}const h_=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,LT=1e-7,BT=12;function UT(t,e,n,r,i){let s,o,a=0;do o=e+(n-e)/2,s=h_(o,r,i)-t,s>0?n=o:e=o;while(Math.abs(s)>LT&&++a<BT);return o}function Bl(t,e,n,r){if(t===e&&n===r)return hi;const i=s=>UT(s,0,1,t,n);return s=>s===0||s===1?s:h_(i(s),e,r)}const p_=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,m_=t=>e=>1-t(1-e),g_=Bl(.33,1.53,.69,.99),qm=m_(g_),y_=p_(qm),w_=t=>(t*=2)<1?.5*qm(t):.5*(2-Math.pow(2,-10*(t-1))),Wm=t=>1-Math.sin(Math.acos(t)),v_=m_(Wm),E_=p_(Wm),$T=Bl(.42,0,1,1),FT=Bl(0,0,.58,1),b_=Bl(.42,0,.58,1),KT=t=>Array.isArray(t)&&typeof t[0]!="number",__=t=>Array.isArray(t)&&typeof t[0]=="number",qy={linear:hi,easeIn:$T,easeInOut:b_,easeOut:FT,circIn:Wm,circInOut:E_,circOut:v_,backIn:qm,backInOut:y_,backOut:g_,anticipate:w_},VT=t=>typeof t=="string",Wy=t=>{if(__(t)){Rs(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return Bl(e,n,r,i)}else if(VT(t))return Rs(qy[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),qy[t];return t},au=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function jT(t,e){let n=new Set,r=new Set,i=!1,s=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(u){o.has(u)&&(l.schedule(u),t()),u(a)}const l={schedule:(u,d=!1,f=!1)=>{const v=f&&i?n:r;return d&&o.add(u),v.has(u)||v.add(u),u},cancel:u=>{r.delete(u),o.delete(u)},process:u=>{if(a=u,i){s=!0;return}i=!0,[n,r]=[r,n],n.forEach(c),n.clear(),i=!1,s&&(s=!1,l.process(u))}};return l}const HT=40;function S_(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,o=au.reduce((S,F)=>(S[F]=jT(s),S),{}),{setup:a,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:g,postRender:v}=o,w=()=>{const S=Is.useManualTiming?i.timestamp:performance.now();n=!1,Is.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(S-i.timestamp,HT),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),g.process(i),v.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(w))},b=()=>{n=!0,r=!0,i.isProcessing||t(w)};return{schedule:au.reduce((S,F)=>{const D=o[F];return S[F]=(z,X=!1,Y=!1)=>(n||b(),D.schedule(z,X,Y)),S},{}),cancel:S=>{for(let F=0;F<au.length;F++)o[au[F]].cancel(S)},state:i,steps:o}}const{schedule:dn,cancel:po,state:Jn,steps:uh}=S_(typeof requestAnimationFrame<"u"?requestAnimationFrame:hi,!0);let Ju;function zT(){Ju=void 0}const Lr={now:()=>(Ju===void 0&&Lr.set(Jn.isProcessing||Is.useManualTiming?Jn.timestamp:performance.now()),Ju),set:t=>{Ju=t,queueMicrotask(zT)}},x_=t=>e=>typeof e=="string"&&e.startsWith(t),A_=x_("--"),qT=x_("var(--"),Gm=t=>qT(t)?WT.test(t.split("/*")[0].trim()):!1,WT=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Gy(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const mc={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},hl={...mc,transform:t=>As(0,1,t)},cu={...mc,default:1},Qc=t=>Math.round(t*1e5)/1e5,Ym=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function GT(t){return t==null}const YT=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Jm=(t,e)=>n=>!!(typeof n=="string"&&YT.test(n)&&n.startsWith(t)||e&&!GT(n)&&Object.prototype.hasOwnProperty.call(n,e)),R_=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,s,o,a]=r.match(Ym);return{[t]:parseFloat(i),[e]:parseFloat(s),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},JT=t=>As(0,255,t),dh={...mc,transform:t=>Math.round(JT(t))},Oo={test:Jm("rgb","red"),parse:R_("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+dh.transform(t)+", "+dh.transform(e)+", "+dh.transform(n)+", "+Qc(hl.transform(r))+")"};function ZT(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const o0={test:Jm("#"),parse:ZT,transform:Oo.transform},Ul=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Hs=Ul("deg"),zi=Ul("%"),rt=Ul("px"),XT=Ul("vh"),QT=Ul("vw"),Yy={...zi,parse:t=>zi.parse(t)/100,transform:t=>zi.transform(t*100)},xa={test:Jm("hsl","hue"),parse:R_("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+zi.transform(Qc(e))+", "+zi.transform(Qc(n))+", "+Qc(hl.transform(r))+")"},Mn={test:t=>Oo.test(t)||o0.test(t)||xa.test(t),parse:t=>Oo.test(t)?Oo.parse(t):xa.test(t)?xa.parse(t):o0.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Oo.transform(t):xa.transform(t),getAnimatableNone:t=>{const e=Mn.parse(t);return e.alpha=0,Mn.transform(e)}},eC=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tC(t){return isNaN(t)&&typeof t=="string"&&(t.match(Ym)?.length||0)+(t.match(eC)?.length||0)>0}const I_="number",T_="color",nC="var",rC="var(",Jy="${}",iC=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function pl(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(iC,c=>(Mn.test(c)?(r.color.push(s),i.push(T_),n.push(Mn.parse(c))):c.startsWith(rC)?(r.var.push(s),i.push(nC),n.push(c)):(r.number.push(s),i.push(I_),n.push(parseFloat(c))),++s,Jy)).split(Jy);return{values:n,split:a,indexes:r,types:i}}function C_(t){return pl(t).values}function O_(t){const{split:e,types:n}=pl(t),r=e.length;return i=>{let s="";for(let o=0;o<r;o++)if(s+=e[o],i[o]!==void 0){const a=n[o];a===I_?s+=Qc(i[o]):a===T_?s+=Mn.transform(i[o]):s+=i[o]}return s}}const sC=t=>typeof t=="number"?0:Mn.test(t)?Mn.getAnimatableNone(t):t;function oC(t){const e=C_(t);return O_(t)(e.map(sC))}const mo={test:tC,parse:C_,createTransformer:O_,getAnimatableNone:oC};function fh(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function aC({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,s=0,o=0;if(!e)i=s=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=fh(c,a,t+1/3),s=fh(c,a,t),o=fh(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:r}}function Id(t,e){return n=>n>0?e:t}const gn=(t,e,n)=>t+(e-t)*n,hh=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},cC=[o0,Oo,xa],lC=t=>cC.find(e=>e.test(t));function Zy(t){const e=lC(t);if(pc(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===xa&&(n=aC(n)),n}const Xy=(t,e)=>{const n=Zy(t),r=Zy(e);if(!n||!r)return Id(t,e);const i={...n};return s=>(i.red=hh(n.red,r.red,s),i.green=hh(n.green,r.green,s),i.blue=hh(n.blue,r.blue,s),i.alpha=gn(n.alpha,r.alpha,s),Oo.transform(i))},a0=new Set(["none","hidden"]);function uC(t,e){return a0.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function dC(t,e){return n=>gn(t,e,n)}function Zm(t){return typeof t=="number"?dC:typeof t=="string"?Gm(t)?Id:Mn.test(t)?Xy:pC:Array.isArray(t)?N_:typeof t=="object"?Mn.test(t)?Xy:fC:Id}function N_(t,e){const n=[...t],r=n.length,i=t.map((s,o)=>Zm(s)(s,e[o]));return s=>{for(let o=0;o<r;o++)n[o]=i[o](s);return n}}function fC(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=Zm(t[i])(t[i],e[i]));return i=>{for(const s in r)n[s]=r[s](i);return n}}function hC(t,e){const n=[],r={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const s=e.types[i],o=t.indexes[s][r[s]],a=t.values[o]??0;n[i]=a,r[s]++}return n}const pC=(t,e)=>{const n=mo.createTransformer(e),r=pl(t),i=pl(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?a0.has(t)&&!i.values.length||a0.has(e)&&!r.values.length?uC(t,e):Ll(N_(hC(r,i),i.values),n):(pc(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Id(t,e))};function P_(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?gn(t,e,n):Zm(t)(t,e)}const mC=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>dn.update(e,n),stop:()=>po(e),now:()=>Jn.isProcessing?Jn.timestamp:Lr.now()}},M_=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let s=0;s<i;s++)r+=Math.round(t(s/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Td=2e4;function Xm(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<Td;)e+=n,r=t.next(e);return e>=Td?1/0:e}function gC(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(Xm(r),Td);return{type:"keyframes",ease:s=>r.next(i*s).value/e,duration:di(i)}}const yC=5;function k_(t,e,n){const r=Math.max(e-yC,0);return f_(n-t(r),e-r)}const hn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},ph=.001;function wC({duration:t=hn.duration,bounce:e=hn.bounce,velocity:n=hn.velocity,mass:r=hn.mass}){let i,s;pc(t<=xi(hn.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=As(hn.minDamping,hn.maxDamping,o),t=As(hn.minDuration,hn.maxDuration,di(t)),o<1?(i=l=>{const u=l*o,d=u*t,f=u-n,g=c0(l,o),v=Math.exp(-d);return ph-f/g*v},s=l=>{const d=l*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(l,2)*t,v=Math.exp(-d),w=c0(Math.pow(l,2),o);return(-i(l)+ph>0?-1:1)*((f-g)*v)/w}):(i=l=>{const u=Math.exp(-l*t),d=(l-n)*t+1;return-ph+u*d},s=l=>{const u=Math.exp(-l*t),d=(n-l)*(t*t);return u*d});const a=5/t,c=EC(i,s,a);if(t=xi(t),isNaN(c))return{stiffness:hn.stiffness,damping:hn.damping,duration:t};{const l=Math.pow(c,2)*r;return{stiffness:l,damping:o*2*Math.sqrt(r*l),duration:t}}}const vC=12;function EC(t,e,n){let r=n;for(let i=1;i<vC;i++)r=r-t(r)/e(r);return r}function c0(t,e){return t*Math.sqrt(1-e*e)}const bC=["duration","bounce"],_C=["stiffness","damping","mass"];function Qy(t,e){return e.some(n=>t[n]!==void 0)}function SC(t){let e={velocity:hn.velocity,stiffness:hn.stiffness,damping:hn.damping,mass:hn.mass,isResolvedFromDuration:!1,...t};if(!Qy(t,_C)&&Qy(t,bC))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,s=2*As(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:hn.mass,stiffness:i,damping:s}}else{const n=wC(t);e={...e,...n,mass:hn.mass},e.isResolvedFromDuration=!0}return e}function Cd(t=hn.visualDuration,e=hn.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const s=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:s},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:g}=SC({...n,velocity:-di(n.velocity||0)}),v=f||0,w=l/(2*Math.sqrt(c*u)),b=o-s,E=di(Math.sqrt(c/u)),M=Math.abs(b)<5;r||(r=M?hn.restSpeed.granular:hn.restSpeed.default),i||(i=M?hn.restDelta.granular:hn.restDelta.default);let S;if(w<1){const D=c0(E,w);S=z=>{const X=Math.exp(-w*E*z);return o-X*((v+w*E*b)/D*Math.sin(D*z)+b*Math.cos(D*z))}}else if(w===1)S=D=>o-Math.exp(-E*D)*(b+(v+E*b)*D);else{const D=E*Math.sqrt(w*w-1);S=z=>{const X=Math.exp(-w*E*z),Y=Math.min(D*z,300);return o-X*((v+w*E*b)*Math.sinh(Y)+D*b*Math.cosh(Y))/D}}const F={calculatedDuration:g&&d||null,next:D=>{const z=S(D);if(g)a.done=D>=d;else{let X=D===0?v:0;w<1&&(X=D===0?xi(v):k_(S,D,z));const Y=Math.abs(X)<=r,U=Math.abs(o-z)<=i;a.done=Y&&U}return a.value=a.done?o:z,a},toString:()=>{const D=Math.min(Xm(F),Td),z=M_(X=>F.next(D*X).value,D,30);return D+"ms "+z},toTransition:()=>{}};return F}Cd.applyToOptions=t=>{const e=gC(t,100,Cd);return t.ease=e.ease,t.duration=xi(e.duration),t.type="keyframes",t};function l0({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:c,restDelta:l=.5,restSpeed:u}){const d=t[0],f={done:!1,value:d},g=Y=>a!==void 0&&Y<a||c!==void 0&&Y>c,v=Y=>a===void 0?c:c===void 0||Math.abs(a-Y)<Math.abs(c-Y)?a:c;let w=n*e;const b=d+w,E=o===void 0?b:o(b);E!==b&&(w=E-d);const M=Y=>-w*Math.exp(-Y/r),S=Y=>E+M(Y),F=Y=>{const U=M(Y),B=S(Y);f.done=Math.abs(U)<=l,f.value=f.done?E:B};let D,z;const X=Y=>{g(f.value)&&(D=Y,z=Cd({keyframes:[f.value,v(f.value)],velocity:k_(S,Y,f.value),damping:i,stiffness:s,restDelta:l,restSpeed:u}))};return X(0),{calculatedDuration:null,next:Y=>{let U=!1;return!z&&D===void 0&&(U=!0,F(Y),X(Y)),D!==void 0&&Y>=D?z.next(Y-D):(!U&&F(Y),f)}}}function xC(t,e,n){const r=[],i=n||Is.mix||P_,s=t.length-1;for(let o=0;o<s;o++){let a=i(t[o],t[o+1]);if(e){const c=Array.isArray(e)?e[o]||hi:e;a=Ll(c,a)}r.push(a)}return r}function AC(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const s=t.length;if(Rs(s===e.length,"Both input and output ranges must be the same length","range-length"),s===1)return()=>e[0];if(s===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=xC(e,r,i),c=a.length,l=u=>{if(o&&u<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(u<t[d+1]);d++);const f=fl(t[d],t[d+1],u);return a[d](f)};return n?u=>l(As(t[0],t[s-1],u)):l}function RC(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=fl(0,e,r);t.push(gn(n,1,i))}}function IC(t){const e=[0];return RC(e,t.length-1),e}function TC(t,e){return t.map(n=>n*e)}function CC(t,e){return t.map(()=>e||b_).splice(0,t.length-1)}function Aa({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=KT(r)?r.map(Wy):Wy(r),s={done:!1,value:e[0]},o=TC(n&&n.length===e.length?n:IC(e),t),a=AC(o,e,{ease:Array.isArray(i)?i:CC(e,i)});return{calculatedDuration:t,next:c=>(s.value=a(c),s.done=c>=t,s)}}const OC=t=>t!==null;function Qm(t,{repeat:e,repeatType:n="loop"},r,i=1){const s=t.filter(OC),a=i<0||e&&n!=="loop"&&e%2===1?0:s.length-1;return!a||r===void 0?s[a]:r}const NC={decay:l0,inertia:l0,tween:Aa,keyframes:Aa,spring:Cd};function D_(t){typeof t.type=="string"&&(t.type=NC[t.type])}class eg{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const PC=t=>t/100;class tg extends eg{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Lr.now()&&this.tick(Lr.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;D_(e);const{type:n=Aa,repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:o=0}=e;let{keyframes:a}=e;const c=n||Aa;process.env.NODE_ENV!=="production"&&c!==Aa&&Rs(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==Aa&&typeof a[0]!="number"&&(this.mixKeyframes=Ll(PC,P_(a[0],a[1])),a=[0,100]);const l=c({...e,keyframes:a});s==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-o})),l.calculatedDuration===null&&(l.calculatedDuration=Xm(l));const{calculatedDuration:u}=l;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=l}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:i,mixKeyframes:s,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return r.next(0);const{delay:l=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:g,type:v,onUpdate:w,finalKeyframe:b}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const E=this.currentTime-l*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?E<0:E>i;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,F=r;if(d){const Y=Math.min(this.currentTime,i)/a;let U=Math.floor(Y),B=Y%1;!B&&Y>=1&&(B=1),B===1&&U--,U=Math.min(U,d+1),U%2&&(f==="reverse"?(B=1-B,g&&(B-=g/a)):f==="mirror"&&(F=o)),S=As(0,1,B)*a}const D=M?{done:!1,value:u[0]}:F.next(S);s&&(D.value=s(D.value));let{done:z}=D;!M&&c!==null&&(z=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const X=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&z);return X&&v!==l0&&(D.value=Qm(u,this.options,b,this.speed)),w&&w(D.value),X&&this.finish(),D}then(e,n){return this.finished.then(e,n)}get duration(){return di(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+di(e)}get time(){return di(this.currentTime)}set time(e){e=xi(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Lr.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=di(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=mC,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Lr.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function MC(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const No=t=>t*180/Math.PI,u0=t=>{const e=No(Math.atan2(t[1],t[0]));return d0(e)},kC={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:u0,rotateZ:u0,skewX:t=>No(Math.atan(t[1])),skewY:t=>No(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},d0=t=>(t=t%360,t<0&&(t+=360),t),ew=u0,tw=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),nw=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),DC={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:tw,scaleY:nw,scale:t=>(tw(t)+nw(t))/2,rotateX:t=>d0(No(Math.atan2(t[6],t[5]))),rotateY:t=>d0(No(Math.atan2(-t[2],t[0]))),rotateZ:ew,rotate:ew,skewX:t=>No(Math.atan(t[4])),skewY:t=>No(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function f0(t){return t.includes("scale")?1:0}function h0(t,e){if(!t||t==="none")return f0(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=DC,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=kC,i=a}if(!i)return f0(e);const s=r[e],o=i[1].split(",").map(BC);return typeof s=="function"?s(o):o[s]}const LC=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return h0(n,e)};function BC(t){return parseFloat(t.trim())}const gc=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],yc=new Set(gc),rw=t=>t===mc||t===rt,UC=new Set(["x","y","z"]),$C=gc.filter(t=>!UC.has(t));function FC(t){const e=[];return $C.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const ro={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>h0(e,"x"),y:(t,{transform:e})=>h0(e,"y")};ro.translateX=ro.x;ro.translateY=ro.y;const jo=new Set;let p0=!1,m0=!1,g0=!1;function L_(){if(m0){const t=Array.from(jo).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=FC(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([s,o])=>{r.getValue(s)?.set(o)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}m0=!1,p0=!1,jo.forEach(t=>t.complete(g0)),jo.clear()}function B_(){jo.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(m0=!0)})}function KC(){g0=!0,B_(),L_(),g0=!1}class ng{constructor(e,n,r,i,s,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=s,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(jo.add(this),p0||(p0=!0,dn.read(B_),dn.resolveKeyframes(L_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;if(e[0]===null){const s=i?.get(),o=e[e.length-1];if(s!==void 0)e[0]=s;else if(r&&n){const a=r.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&s===void 0&&i.set(e[0])}MC(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),jo.delete(this)}cancel(){this.state==="scheduled"&&(jo.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const VC=t=>t.startsWith("--");function jC(t,e,n){VC(e)?t.style.setProperty(e,n):t.style[e]=n}const HC=jm(()=>window.ScrollTimeline!==void 0),zC={};function qC(t,e){const n=jm(t);return()=>zC[e]??n()}const U_=qC(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Hc=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,iw={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Hc([0,.65,.55,1]),circOut:Hc([.55,0,1,.45]),backIn:Hc([.31,.01,.66,-.59]),backOut:Hc([.33,1.53,.69,.99])};function $_(t,e){if(t)return typeof t=="function"?U_()?M_(t,e):"ease-out":__(t)?Hc(t):Array.isArray(t)?t.map(n=>$_(n,e)||iw.easeOut):iw[t]}function WC(t,e,n,{delay:r=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeOut",times:c}={},l=void 0){const u={[e]:n};c&&(u.offset=c);const d=$_(a,i);Array.isArray(d)&&(u.easing=d);const f={delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"};return l&&(f.pseudoElement=l),t.animate(u,f)}function F_(t){return typeof t=="function"&&"applyToOptions"in t}function GC({type:t,...e}){return F_(t)&&U_()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class YC extends eg{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:r,keyframes:i,pseudoElement:s,allowFlatten:o=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!s,this.allowFlatten=o,this.options=e,Rs(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const l=GC(e);this.animation=WC(n,r,i,l,s),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const u=Qm(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):jC(n,r,u),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return di(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+di(e)}get time(){return di(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=xi(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&HC()?(this.animation.timeline=e,hi):n(this)}}const K_={anticipate:w_,backInOut:y_,circInOut:E_};function JC(t){return t in K_}function ZC(t){typeof t.ease=="string"&&JC(t.ease)&&(t.ease=K_[t.ease])}const sw=10;class XC extends YC{constructor(e){ZC(e),D_(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:i,element:s,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new tg({...o,autoplay:!1}),c=xi(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-sw).value,a.sample(c).value,sw),a.stop()}}const ow=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(mo.test(t)||t==="0")&&!t.startsWith("url("));function QC(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function eO(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const s=t[t.length-1],o=ow(i,e),a=ow(s,e);return pc(o===a,`You are trying to animate ${e} from "${i}" to "${s}". "${o?s:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:QC(t)||(n==="spring"||F_(n))&&r}function y0(t){t.duration=0,t.type="keyframes"}const tO=new Set(["opacity","clipPath","filter","transform"]),nO=jm(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function rO(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:i,damping:s,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:l}=e.owner.getProps();return nO()&&n&&tO.has(n)&&(n!=="transform"||!l)&&!c&&!r&&i!=="mirror"&&s!==0&&o!=="inertia"}const iO=40;class sO extends eg{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:o="loop",keyframes:a,name:c,motionValue:l,element:u,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Lr.now();const f={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:s,repeatType:o,name:c,motionValue:l,element:u,...d},g=u?.KeyframeResolver||ng;this.keyframeResolver=new g(a,(v,w,b)=>this.onKeyframesResolved(v,w,f,!b),c,l,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,i){this.keyframeResolver=void 0;const{name:s,type:o,velocity:a,delay:c,isHandoff:l,onUpdate:u}=r;this.resolvedAt=Lr.now(),eO(e,s,o,a)||((Is.instantAnimations||!c)&&u?.(Qm(e,r,n)),e[0]=e[e.length-1],y0(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>iO?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},g=!l&&rO(f)?new XC({...f,element:f.motionValue.owner.current}):new tg(f);g.finished.then(()=>this.notifyFinished()).catch(hi),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),KC()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const oO=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function aO(t){const e=oO.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const cO=4;function V_(t,e,n=1){Rs(n<=cO,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=aO(t);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const o=s.trim();return l_(o)?parseFloat(o):o}return Gm(i)?V_(i,e,n+1):i}function rg(t,e){return t?.[e]??t?.default??t}const j_=new Set(["width","height","top","left","right","bottom",...gc]),lO={test:t=>t==="auto",parse:t=>t},H_=t=>e=>e.test(t),z_=[mc,rt,zi,Hs,QT,XT,lO],aw=t=>z_.find(H_(t));function uO(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||d_(t):!0}const dO=new Set(["brightness","contrast","saturate","opacity"]);function fO(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(Ym)||[];if(!r)return t;const i=n.replace(r,"");let s=dO.has(e)?1:0;return r!==n&&(s*=100),e+"("+s+i+")"}const hO=/\b([a-z-]*)\(.*?\)/gu,w0={...mo,getAnimatableNone:t=>{const e=t.match(hO);return e?e.map(fO).join(" "):t}},cw={...mc,transform:Math.round},pO={rotate:Hs,rotateX:Hs,rotateY:Hs,rotateZ:Hs,scale:cu,scaleX:cu,scaleY:cu,scaleZ:cu,skew:Hs,skewX:Hs,skewY:Hs,distance:rt,translateX:rt,translateY:rt,translateZ:rt,x:rt,y:rt,z:rt,perspective:rt,transformPerspective:rt,opacity:hl,originX:Yy,originY:Yy,originZ:rt},ig={borderWidth:rt,borderTopWidth:rt,borderRightWidth:rt,borderBottomWidth:rt,borderLeftWidth:rt,borderRadius:rt,radius:rt,borderTopLeftRadius:rt,borderTopRightRadius:rt,borderBottomRightRadius:rt,borderBottomLeftRadius:rt,width:rt,maxWidth:rt,height:rt,maxHeight:rt,top:rt,right:rt,bottom:rt,left:rt,inset:rt,insetBlock:rt,insetBlockStart:rt,insetBlockEnd:rt,insetInline:rt,insetInlineStart:rt,insetInlineEnd:rt,padding:rt,paddingTop:rt,paddingRight:rt,paddingBottom:rt,paddingLeft:rt,paddingBlock:rt,paddingBlockStart:rt,paddingBlockEnd:rt,paddingInline:rt,paddingInlineStart:rt,paddingInlineEnd:rt,margin:rt,marginTop:rt,marginRight:rt,marginBottom:rt,marginLeft:rt,marginBlock:rt,marginBlockStart:rt,marginBlockEnd:rt,marginInline:rt,marginInlineStart:rt,marginInlineEnd:rt,backgroundPositionX:rt,backgroundPositionY:rt,...pO,zIndex:cw,fillOpacity:hl,strokeOpacity:hl,numOctaves:cw},mO={...ig,color:Mn,backgroundColor:Mn,outlineColor:Mn,fill:Mn,stroke:Mn,borderColor:Mn,borderTopColor:Mn,borderRightColor:Mn,borderBottomColor:Mn,borderLeftColor:Mn,filter:w0,WebkitFilter:w0},q_=t=>mO[t];function W_(t,e){let n=q_(t);return n!==w0&&(n=mo),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const gO=new Set(["auto","none","0"]);function yO(t,e,n){let r=0,i;for(;r<t.length&&!i;){const s=t[r];typeof s=="string"&&!gO.has(s)&&pl(s).values.length&&(i=t[r]),r++}if(i&&n)for(const s of e)t[s]=W_(n,i)}class wO extends ng{constructor(e,n,r,i,s){super(e,n,r,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let u=0;u<e.length;u++){let d=e[u];if(typeof d=="string"&&(d=d.trim(),Gm(d))){const f=V_(d,n.current);f!==void 0&&(e[u]=f),u===e.length-1&&(this.finalKeyframe=d)}}if(this.resolveNoneKeyframes(),!j_.has(r)||e.length!==2)return;const[i,s]=e,o=aw(i),a=aw(s),c=Gy(i),l=Gy(s);if(c!==l&&ro[r]){this.needsMeasurement=!0;return}if(o!==a)if(rw(o)&&rw(a))for(let u=0;u<e.length;u++){const d=e[u];typeof d=="string"&&(e[u]=parseFloat(d))}else ro[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||uO(e[i]))&&r.push(i);r.length&&yO(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ro[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const s=r.length-1,o=r[s];r[s]=ro[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function vO(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const i=n?.[t]??r.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const G_=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Y_(t){return u_(t)&&"offsetHeight"in t}const lw=30,EO=t=>!isNaN(parseFloat(t));class bO{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=Lr.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const s of this.dependents)s.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=Lr.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=EO(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&zm(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Hm);const r=this.events[e].add(n);return e==="change"?()=>{r(),dn.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Lr.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>lw)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,lw);return f_(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ja(t,e){return new bO(t,e)}const{schedule:sg}=S_(queueMicrotask,!1),wi={x:!1,y:!1};function J_(){return wi.x||wi.y}function _O(t){return t==="x"||t==="y"?wi[t]?null:(wi[t]=!0,()=>{wi[t]=!1}):wi.x||wi.y?null:(wi.x=wi.y=!0,()=>{wi.x=wi.y=!1})}function Z_(t,e){const n=vO(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function uw(t){return!(t.pointerType==="touch"||J_())}function SO(t,e,n={}){const[r,i,s]=Z_(t,n),o=a=>{if(!uw(a))return;const{target:c}=a,l=e(c,a);if(typeof l!="function"||!c)return;const u=d=>{uw(d)&&(l(d),c.removeEventListener("pointerleave",u))};c.addEventListener("pointerleave",u,i)};return r.forEach(a=>{a.addEventListener("pointerenter",o,i)}),s}const X_=(t,e)=>e?t===e?!0:X_(t,e.parentElement):!1,og=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,xO=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Q_(t){return xO.has(t.tagName)||t.isContentEditable===!0}const Zu=new WeakSet;function dw(t){return e=>{e.key==="Enter"&&t(e)}}function mh(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const AO=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=dw(()=>{if(Zu.has(n))return;mh(n,"down");const i=dw(()=>{mh(n,"up")}),s=()=>mh(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",s,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function fw(t){return og(t)&&!J_()}function RO(t,e,n={}){const[r,i,s]=Z_(t,n),o=a=>{const c=a.currentTarget;if(!fw(a))return;Zu.add(c);const l=e(c,a),u=(g,v)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Zu.has(c)&&Zu.delete(c),fw(g)&&typeof l=="function"&&l(g,{success:v})},d=g=>{u(g,c===window||c===document||n.useGlobalTarget||X_(c,g.target))},f=g=>{u(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Y_(a)&&(a.addEventListener("focus",l=>AO(l,i)),!Q_(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),s}function eS(t){return u_(t)&&"ownerSVGElement"in t}function IO(t){return eS(t)&&t.tagName==="svg"}const vr=t=>!!(t&&t.getVelocity),TO=[...z_,Mn,mo],CO=t=>TO.find(H_(t)),ag=Xe.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function hw(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function OO(...t){return e=>{let n=!1;const r=t.map(i=>{const s=hw(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():hw(t[i],null)}}}}function NO(...t){return Rf.useCallback(OO(...t),t)}class PO extends Rf.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const r=n.offsetParent,i=Y_(r)&&r.offsetWidth||0,s=this.props.sizeRef.current;s.height=n.offsetHeight||0,s.width=n.offsetWidth||0,s.top=n.offsetTop,s.left=n.offsetLeft,s.right=i-s.width-s.left}return null}componentDidUpdate(){}render(){return this.props.children}}function MO({children:t,isPresent:e,anchorX:n,root:r}){const i=Xe.useId(),s=Xe.useRef(null),o=Xe.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=Xe.useContext(ag),c=t.props?.ref??t?.ref,l=NO(s,c);return Xe.useInsertionEffect(()=>{const{width:u,height:d,top:f,left:g,right:v}=o.current;if(e||!s.current||!u||!d)return;const w=n==="left"?`left: ${g}`:`right: ${v}`;s.current.dataset.motionPopId=i;const b=document.createElement("style");a&&(b.nonce=a);const E=r??document.head;return E.appendChild(b),b.sheet&&b.sheet.insertRule(`
|
|
7
|
+
[data-motion-pop-id="${i}"] {
|
|
8
|
+
position: absolute !important;
|
|
9
|
+
width: ${u}px !important;
|
|
10
|
+
height: ${d}px !important;
|
|
11
|
+
${w}px !important;
|
|
12
|
+
top: ${f}px !important;
|
|
13
|
+
}
|
|
14
|
+
`),()=>{E.contains(b)&&E.removeChild(b)}},[e]),vt.jsx(PO,{isPresent:e,childRef:s,sizeRef:o,children:Rf.cloneElement(t,{ref:l})})}const kO=({children:t,initial:e,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:o,anchorX:a,root:c})=>{const l=$m(DO),u=Xe.useId();let d=!0,f=Xe.useMemo(()=>(d=!1,{id:u,initial:e,isPresent:n,custom:i,onExitComplete:g=>{l.set(g,!0);for(const v of l.values())if(!v)return;r&&r()},register:g=>(l.set(g,!1),()=>l.delete(g))}),[n,l,r]);return s&&d&&(f={...f}),Xe.useMemo(()=>{l.forEach((g,v)=>l.set(v,!1))},[n]),Rf.useEffect(()=>{!n&&!l.size&&r&&r()},[n]),o==="popLayout"&&(t=vt.jsx(MO,{isPresent:n,anchorX:a,root:c,children:t})),vt.jsx(If.Provider,{value:f,children:t})};function DO(){return new Map}function tS(t=!0){const e=Xe.useContext(If);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=e,s=Xe.useId();Xe.useEffect(()=>{if(t)return i(s)},[t]);const o=Xe.useCallback(()=>t&&r&&r(s),[s,r,t]);return!n&&r?[!1,o]:[!0]}const lu=t=>t.key||"";function pw(t){const e=[];return Xe.Children.forEach(t,n=>{Xe.isValidElement(n)&&e.push(n)}),e}const LO=({children:t,custom:e,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:o=!1,anchorX:a="left",root:c})=>{const[l,u]=tS(o),d=Xe.useMemo(()=>pw(t),[t]),f=o&&!l?[]:d.map(lu),g=Xe.useRef(!0),v=Xe.useRef(d),w=$m(()=>new Map),b=Xe.useRef(new Set),[E,M]=Xe.useState(d),[S,F]=Xe.useState(d);c_(()=>{g.current=!1,v.current=d;for(let X=0;X<S.length;X++){const Y=lu(S[X]);f.includes(Y)?(w.delete(Y),b.current.delete(Y)):w.get(Y)!==!0&&w.set(Y,!1)}},[S,f.length,f.join("-")]);const D=[];if(d!==E){let X=[...d];for(let Y=0;Y<S.length;Y++){const U=S[Y],B=lu(U);f.includes(B)||(X.splice(Y,0,U),D.push(U))}return s==="wait"&&D.length&&(X=D),F(pw(X)),M(d),null}process.env.NODE_ENV!=="production"&&s==="wait"&&S.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:z}=Xe.useContext(Um);return vt.jsx(vt.Fragment,{children:S.map(X=>{const Y=lu(X),U=o&&!l?!1:d===S||f.includes(Y),B=()=>{if(b.current.has(Y))return;if(b.current.add(Y),w.has(Y))w.set(Y,!0);else return;let H=!0;w.forEach(V=>{V||(H=!1)}),H&&(z?.(),F(v.current),o&&u?.(),r&&r())};return vt.jsx(kO,{isPresent:U,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:s,root:c,onExitComplete:U?void 0:B,anchorX:a,children:X},Y)})})},nS=Xe.createContext({strict:!1}),mw={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Za={};for(const t in mw)Za[t]={isEnabled:e=>mw[t].some(n=>!!e[n])};function BO(t){for(const e in t)Za[e]={...Za[e],...t[e]}}const UO=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Od(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||UO.has(t)}let rS=t=>!Od(t);function $O(t){typeof t=="function"&&(rS=e=>e.startsWith("on")?!Od(e):t(e))}try{$O(require("@emotion/is-prop-valid").default)}catch{}function FO(t,e,n){const r={};for(const i in t)i==="values"&&typeof t.values=="object"||(rS(i)||n===!0&&Od(i)||!e&&!Od(i)||t.draggable&&i.startsWith("onDrag"))&&(r[i]=t[i]);return r}const Tf=Xe.createContext({});function Cf(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function ml(t){return typeof t=="string"||Array.isArray(t)}const cg=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],lg=["initial",...cg];function Of(t){return Cf(t.animate)||lg.some(e=>ml(t[e]))}function iS(t){return!!(Of(t)||t.variants)}function KO(t,e){if(Of(t)){const{initial:n,animate:r}=t;return{initial:n===!1||ml(n)?n:void 0,animate:ml(r)?r:void 0}}return t.inherit!==!1?e:{}}function VO(t){const{initial:e,animate:n}=KO(t,Xe.useContext(Tf));return Xe.useMemo(()=>({initial:e,animate:n}),[gw(e),gw(n)])}function gw(t){return Array.isArray(t)?t.join(" "):t}function yw(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Mc={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(rt.test(t))t=parseFloat(t);else return t;const n=yw(t,e.target.x),r=yw(t,e.target.y);return`${n}% ${r}%`}},jO={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=mo.parse(t);if(i.length>5)return r;const s=mo.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=c;const l=gn(a,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=l),typeof i[3+o]=="number"&&(i[3+o]/=l),s(i)}},v0={borderRadius:{...Mc,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Mc,borderTopRightRadius:Mc,borderBottomLeftRadius:Mc,borderBottomRightRadius:Mc,boxShadow:jO};function sS(t,{layout:e,layoutId:n}){return yc.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!v0[t]||t==="opacity")}const HO={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},zO=gc.length;function qO(t,e,n){let r="",i=!0;for(let s=0;s<zO;s++){const o=gc[s],a=t[o];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(o.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const l=G_(a,ig[o]);if(!c){i=!1;const u=HO[o]||o;r+=`${u}(${l}) `}n&&(e[o]=l)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function ug(t,e,n){const{style:r,vars:i,transformOrigin:s}=t;let o=!1,a=!1;for(const c in e){const l=e[c];if(yc.has(c)){o=!0;continue}else if(A_(c)){i[c]=l;continue}else{const u=G_(l,ig[c]);c.startsWith("origin")?(a=!0,s[c]=u):r[c]=u}}if(e.transform||(o||n?r.transform=qO(e,t.transform,n):r.transform&&(r.transform="none")),a){const{originX:c="50%",originY:l="50%",originZ:u=0}=s;r.transformOrigin=`${c} ${l} ${u}`}}const dg=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function oS(t,e,n){for(const r in e)!vr(e[r])&&!sS(r,n)&&(t[r]=e[r])}function WO({transformTemplate:t},e){return Xe.useMemo(()=>{const n=dg();return ug(n,e,t),Object.assign({},n.vars,n.style)},[e])}function GO(t,e){const n=t.style||{},r={};return oS(r,n,t),Object.assign(r,WO(t,e)),r}function YO(t,e){const n={},r=GO(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const JO={offset:"stroke-dashoffset",array:"stroke-dasharray"},ZO={offset:"strokeDashoffset",array:"strokeDasharray"};function XO(t,e,n=1,r=0,i=!0){t.pathLength=1;const s=i?JO:ZO;t[s.offset]=rt.transform(-r);const o=rt.transform(e),a=rt.transform(n);t[s.array]=`${o} ${a}`}const QO=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function aS(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:s=1,pathOffset:o=0,...a},c,l,u){if(ug(t,a,l),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??"fill-box",delete d.transformBox);for(const g of QO)d[g]!==void 0&&(f[g]=d[g],delete d[g]);e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&XO(d,i,s,o,!1)}const cS=()=>({...dg(),attrs:{}}),lS=t=>typeof t=="string"&&t.toLowerCase()==="svg";function e3(t,e,n,r){const i=Xe.useMemo(()=>{const s=cS();return aS(s,e,lS(r),t.transformTemplate,t.style),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};oS(s,t.style,t),i.style={...s,...i.style}}return i}const t3=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function fg(t){return typeof t!="string"||t.includes("-")?!1:!!(t3.indexOf(t)>-1||/[A-Z]/u.test(t))}function n3(t,e,n,{latestValues:r},i,s=!1,o){const c=(o??fg(t)?e3:YO)(e,r,i,t),l=FO(e,typeof t=="string",s),u=t!==Xe.Fragment?{...l,...c,ref:n}:{},{children:d}=e,f=Xe.useMemo(()=>vr(d)?d.get():d,[d]);return Xe.createElement(t,{...u,children:f})}function ww(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function hg(t,e,n,r){if(typeof e=="function"){const[i,s]=ww(r);e=e(n!==void 0?n:t.custom,i,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,s]=ww(r);e=e(n!==void 0?n:t.custom,i,s)}return e}function Xu(t){return vr(t)?t.get():t}function r3({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,i){return{latestValues:i3(n,r,i,t),renderState:e()}}function i3(t,e,n,r){const i={},s=r(t,{});for(const f in s)i[f]=Xu(s[f]);let{initial:o,animate:a}=t;const c=Of(t),l=iS(t);e&&l&&!c&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!Cf(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const v=hg(t,f[g]);if(v){const{transitionEnd:w,transition:b,...E}=v;for(const M in E){let S=E[M];if(Array.isArray(S)){const F=u?S.length-1:0;S=S[F]}S!==null&&(i[M]=S)}for(const M in w)i[M]=w[M]}}}return i}const uS=t=>(e,n)=>{const r=Xe.useContext(Tf),i=Xe.useContext(If),s=()=>r3(t,e,r,i);return n?s():$m(s)};function pg(t,e,n){const{style:r}=t,i={};for(const s in r)(vr(r[s])||e.style&&vr(e.style[s])||sS(s,t)||n?.getValue(s)?.liveStyle!==void 0)&&(i[s]=r[s]);return i}const s3=uS({scrapeMotionValuesFromProps:pg,createRenderState:dg});function dS(t,e,n){const r=pg(t,e,n);for(const i in t)if(vr(t[i])||vr(e[i])){const s=gc.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=t[i]}return r}const o3=uS({scrapeMotionValuesFromProps:dS,createRenderState:cS}),a3=Symbol.for("motionComponentSymbol");function c3(t,e,n){const r=Xe.useRef(n);Xe.useInsertionEffect(()=>{r.current=n});const i=Xe.useRef(null);return Xe.useCallback(s=>{s&&t.onMount?.(s),e&&(s?e.mount(s):e.unmount());const o=r.current;if(typeof o=="function")if(s){const a=o(s);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):o(s);else o&&(o.current=s)},[e])}const mg=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),l3="framerAppearId",fS="data-"+mg(l3),hS=Xe.createContext({});function zc(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function u3(t,e,n,r,i,s){const{visualElement:o}=Xe.useContext(Tf),a=Xe.useContext(nS),c=Xe.useContext(If),l=Xe.useContext(ag).reducedMotion,u=Xe.useRef(null);r=r||a.renderer,!u.current&&r&&(u.current=r(t,{visualState:e,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:l,isSVG:s}));const d=u.current,f=Xe.useContext(hS);d&&!d.projection&&i&&(d.type==="html"||d.type==="svg")&&d3(u.current,n,i,f);const g=Xe.useRef(!1);Xe.useInsertionEffect(()=>{d&&g.current&&d.update(n,c)});const v=n[fS],w=Xe.useRef(!!v&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return c_(()=>{d&&(g.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),w.current&&d.animationState&&d.animationState.animateChanges())}),Xe.useEffect(()=>{d&&(!w.current&&d.animationState&&d.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),w.current=!1),d.enteringChildren=void 0)}),d}function d3(t,e,n,r){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:c,layoutRoot:l,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:pS(t.parent)),t.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&zc(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:u,layoutScroll:c,layoutRoot:l})}function pS(t){if(t)return t.options.allowProjection!==!1?t.projection:pS(t.parent)}function gh(t,{forwardMotionProps:e=!1,type:n}={},r,i){r&&BO(r);const s=n?n==="svg":fg(t),o=s?o3:s3;function a(l,u){let d;const f={...Xe.useContext(ag),...l,layoutId:f3(l)},{isStatic:g}=f,v=VO(l),w=o(l,g);if(!g&&Fm){h3(f,r);const b=p3(f);d=b.MeasureLayout,v.visualElement=u3(t,w,f,i,b.ProjectionNode,s)}return vt.jsxs(Tf.Provider,{value:v,children:[d&&v.visualElement?vt.jsx(d,{visualElement:v.visualElement,...f}):null,n3(t,l,c3(w,v.visualElement,u),w,g,e,s)]})}a.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=Xe.forwardRef(a);return c[a3]=t,c}function f3({layoutId:t}){const e=Xe.useContext(Um).id;return e&&t!==void 0?e+"-"+t:t}function h3(t,e){const n=Xe.useContext(nS).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?pc(!1,r,"lazy-strict-mode"):Rs(!1,r,"lazy-strict-mode")}}function p3(t){const{drag:e,layout:n}=Za;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function m3(t,e){if(typeof Proxy>"u")return gh;const n=new Map,r=(s,o)=>gh(s,o,t,e),i=(s,o)=>(process.env.NODE_ENV!=="production"&&zm(!1,"motion() is deprecated. Use motion.create() instead."),r(s,o));return new Proxy(i,{get:(s,o)=>o==="create"?r:(n.has(o)||n.set(o,gh(o,void 0,t,e)),n.get(o))})}function mS({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function g3({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function y3(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function yh(t){return t===void 0||t===1}function E0({scale:t,scaleX:e,scaleY:n}){return!yh(t)||!yh(e)||!yh(n)}function Ro(t){return E0(t)||gS(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function gS(t){return vw(t.x)||vw(t.y)}function vw(t){return t&&t!=="0%"}function Nd(t,e,n){const r=t-n,i=e*r;return n+i}function Ew(t,e,n,r,i){return i!==void 0&&(t=Nd(t,i,r)),Nd(t,n,r)+e}function b0(t,e=0,n=1,r,i){t.min=Ew(t.min,e,n,r,i),t.max=Ew(t.max,e,n,r,i)}function yS(t,{x:e,y:n}){b0(t.x,e.translate,e.scale,e.originPoint),b0(t.y,n.translate,n.scale,n.originPoint)}const bw=.999999999999,_w=1.0000000000001;function w3(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let s,o;for(let a=0;a<i;a++){s=n[a],o=s.projectionDelta;const{visualElement:c}=s.options;c&&c.props.style&&c.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&Ia(t,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,yS(t,o)),r&&Ro(s.latestValues)&&Ia(t,s.latestValues))}e.x<_w&&e.x>bw&&(e.x=1),e.y<_w&&e.y>bw&&(e.y=1)}function Ra(t,e){t.min=t.min+e,t.max=t.max+e}function Sw(t,e,n,r,i=.5){const s=gn(t.min,t.max,i);b0(t,e,n,s,r)}function Ia(t,e){Sw(t.x,e.x,e.scaleX,e.scale,e.originX),Sw(t.y,e.y,e.scaleY,e.scale,e.originY)}function wS(t,e){return mS(y3(t.getBoundingClientRect(),e))}function v3(t,e,n){const r=wS(t,n),{scroll:i}=e;return i&&(Ra(r.x,i.offset.x),Ra(r.y,i.offset.y)),r}const xw=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ta=()=>({x:xw(),y:xw()}),Aw=()=>({min:0,max:0}),Un=()=>({x:Aw(),y:Aw()}),_0={current:null},vS={current:!1};function E3(){if(vS.current=!0,!!Fm)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>_0.current=t.matches;t.addEventListener("change",e),e()}else _0.current=!1}const b3=new WeakMap;function _3(t,e,n){for(const r in e){const i=e[r],s=n[r];if(vr(i))t.addValue(r,i);else if(vr(s))t.addValue(r,Ja(i,{owner:t}));else if(s!==i)if(t.hasValue(r)){const o=t.getValue(r);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(r);t.addValue(r,Ja(o!==void 0?o:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const Rw=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class S3{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ng,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=Lr.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,dn.render(this.render,!1,!0))};const{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!s,this.isControllingVariants=Of(n),this.isVariantNode=iS(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&vr(g)&&g.set(c[f])}}mount(e){this.current=e,b3.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(vS.current||E3(),this.shouldReduceMotion=_0.current),process.env.NODE_ENV!=="production"&&zm(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),po(this.notifyUpdate),po(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=yc.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&dn.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),s&&s(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Za){const n=Za[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Un()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Rw.length;r++){const i=Rw[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const s="on"+i,o=e[s];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=_3(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=Ja(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(l_(r)||d_(r))?r=parseFloat(r):!CO(r)&&mo.test(n)&&(r=W_(e,n)),this.setBaseTarget(e,vr(r)?r.get():r)),vr(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const s=hg(this.props,n,this.presenceContext?.custom);s&&(r=s[e])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!vr(i)?i:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Hm),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){sg.render(this.render)}}class ES extends S3{constructor(){super(...arguments),this.KeyframeResolver=wO}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;vr(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function bS(t,{style:e,vars:n},r,i){const s=t.style;let o;for(o in e)s[o]=e[o];i?.applyProjectionStyles(s,r);for(o in n)s.setProperty(o,n[o])}function x3(t){return window.getComputedStyle(t)}class A3 extends ES{constructor(){super(...arguments),this.type="html",this.renderInstance=bS}readValueFromInstance(e,n){if(yc.has(n))return this.projection?.isProjecting?f0(n):LC(e,n);{const r=x3(e),i=(A_(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return wS(e,n)}build(e,n,r){ug(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return pg(e,n,r)}}const _S=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function R3(t,e,n,r){bS(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(_S.has(i)?i:mg(i),e.attrs[i])}class I3 extends ES{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Un}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(yc.has(n)){const r=q_(n);return r&&r.default||0}return n=_S.has(n)?n:mg(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return dS(e,n,r)}build(e,n,r){aS(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){R3(e,n,r,i)}mount(e){this.isSVGTag=lS(e.tagName),super.mount(e)}}const T3=(t,e)=>e.isSVG??fg(t)?new I3(e):new A3(e,{allowProjection:t!==Xe.Fragment});function Ka(t,e,n){const r=t.getProps();return hg(r,e,n!==void 0?n:r.custom,t)}const S0=t=>Array.isArray(t);function C3(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Ja(n))}function O3(t){return S0(t)?t[t.length-1]||0:t}function N3(t,e){const n=Ka(t,e);let{transitionEnd:r={},transition:i={},...s}=n||{};s={...s,...r};for(const o in s){const a=O3(s[o]);C3(t,o,a)}}function P3(t){return!!(vr(t)&&t.add)}function x0(t,e){const n=t.getValue("willChange");if(P3(n))return n.add(e);if(!n&&Is.WillChange){const r=new Is.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function SS(t){return t.props[fS]}const M3=t=>t!==null;function k3(t,{repeat:e,repeatType:n="loop"},r){const i=t.filter(M3),s=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[s]}const D3={type:"spring",stiffness:500,damping:25,restSpeed:10},L3=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),B3={type:"keyframes",duration:.8},U3={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},$3=(t,{keyframes:e})=>e.length>2?B3:yc.has(t)?t.startsWith("scale")?L3(e[1]):D3:U3;function F3({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:o,repeatDelay:a,from:c,elapsed:l,...u}){return!!Object.keys(u).length}const gg=(t,e,n,r={},i,s)=>o=>{const a=rg(r,t)||{},c=a.delay||r.delay||0;let{elapsed:l=0}=r;l=l-xi(c);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-l,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:i};F3(a)||Object.assign(u,$3(t,u)),u.duration&&(u.duration=xi(u.duration)),u.repeatDelay&&(u.repeatDelay=xi(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(y0(u),u.delay===0&&(d=!0)),(Is.instantAnimations||Is.skipAnimations)&&(d=!0,y0(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!s&&e.get()!==void 0){const f=k3(u.keyframes,a);if(f!==void 0){dn.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new tg(u):new sO(u)};function K3({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function xS(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:s=t.getDefaultTransition(),transitionEnd:o,...a}=e;r&&(s=r);const c=[],l=i&&t.animationState&&t.animationState.getState()[i];for(const u in a){const d=t.getValue(u,t.latestValues[u]??null),f=a[u];if(f===void 0||l&&K3(l,u))continue;const g={delay:n,...rg(s||{},u)},v=d.get();if(v!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===v&&!g.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const E=SS(t);if(E){const M=window.MotionHandoffAnimation(E,u,dn);M!==null&&(g.startTime=M,w=!0)}}x0(t,u),d.start(gg(u,d,f,t.shouldReduceMotion&&j_.has(u)?{type:!1}:g,t,w));const b=d.animation;b&&c.push(b)}return o&&Promise.all(c).then(()=>{dn.update(()=>{o&&N3(t,o)})}),c}function AS(t,e,n,r=0,i=1){const s=Array.from(t).sort((l,u)=>l.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*r;return typeof n=="function"?n(s,o):i===1?s*r:a-s*r}function A0(t,e,n={}){const r=Ka(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const s=r?()=>Promise.all(xS(t,r,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:l=0,staggerChildren:u,staggerDirection:d}=i;return V3(t,e,c,l,u,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,l]=a==="beforeChildren"?[s,o]:[o,s];return c().then(()=>l())}else return Promise.all([s(),o(n.delay)])}function V3(t,e,n=0,r=0,i=0,s=1,o){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(A0(c,e,{...o,delay:n+(typeof r=="function"?0:r)+AS(t.variantChildren,c,r,i,s)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function j3(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>A0(t,s,n));r=Promise.all(i)}else if(typeof e=="string")r=A0(t,e,n);else{const i=typeof e=="function"?Ka(t,e,n.custom):e;r=Promise.all(xS(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function RS(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const H3=lg.length;function IS(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?IS(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<H3;n++){const r=lg[n],i=t.props[r];(ml(i)||i===!1)&&(e[r]=i)}return e}const z3=[...cg].reverse(),q3=cg.length;function W3(t){return e=>Promise.all(e.map(({animation:n,options:r})=>j3(t,n,r)))}function G3(t){let e=W3(t),n=Iw(),r=!0;const i=c=>(l,u)=>{const d=Ka(t,u,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...v}=d;l={...l,...v,...g}}return l};function s(c){e=c(t)}function o(c){const{props:l}=t,u=IS(t.parent)||{},d=[],f=new Set;let g={},v=1/0;for(let b=0;b<q3;b++){const E=z3[b],M=n[E],S=l[E]!==void 0?l[E]:u[E],F=ml(S),D=E===c?M.isActive:null;D===!1&&(v=b);let z=S===u[E]&&S!==l[E]&&F;if(z&&r&&t.manuallyAnimateOnMount&&(z=!1),M.protectedKeys={...g},!M.isActive&&D===null||!S&&!M.prevProp||Cf(S)||typeof S=="boolean")continue;const X=Y3(M.prevProp,S);let Y=X||E===c&&M.isActive&&!z&&F||b>v&&F,U=!1;const B=Array.isArray(S)?S:[S];let H=B.reduce(i(E),{});D===!1&&(H={});const{prevResolvedValues:V={}}=M,T={...V,...H},p=P=>{Y=!0,f.has(P)&&(U=!0,f.delete(P)),M.needsAnimating[P]=!0;const _=t.getValue(P);_&&(_.liveStyle=!1)};for(const P in T){const _=H[P],I=V[P];if(g.hasOwnProperty(P))continue;let N=!1;S0(_)&&S0(I)?N=!RS(_,I):N=_!==I,N?_!=null?p(P):f.add(P):_!==void 0&&f.has(P)?p(P):M.protectedKeys[P]=!0}M.prevProp=S,M.prevResolvedValues=H,M.isActive&&(g={...g,...H}),r&&t.blockInitialAnimation&&(Y=!1);const y=z&&X;Y&&(!y||U)&&d.push(...B.map(P=>{const _={type:E};if(typeof P=="string"&&r&&!y&&t.manuallyAnimateOnMount&&t.parent){const{parent:I}=t,N=Ka(I,P);if(I.enteringChildren&&N){const{delayChildren:x}=N.transition||{};_.delay=AS(I.enteringChildren,t,x)}}return{animation:P,options:_}}))}if(f.size){const b={};if(typeof l.initial!="boolean"){const E=Ka(t,Array.isArray(l.initial)?l.initial[0]:l.initial);E&&E.transition&&(b.transition=E.transition)}f.forEach(E=>{const M=t.getBaseTarget(E),S=t.getValue(E);S&&(S.liveStyle=!0),b[E]=M??null}),d.push({animation:b})}let w=!!d.length;return r&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(w=!1),r=!1,w?e(d):Promise.resolve()}function a(c,l){if(n[c].isActive===l)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,l)),n[c].isActive=l;const u=o(c);for(const d in n)n[d].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>n,reset:()=>{n=Iw()}}}function Y3(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!RS(e,t):!1}function _o(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Iw(){return{animate:_o(!0),whileInView:_o(),whileHover:_o(),whileTap:_o(),whileDrag:_o(),whileFocus:_o(),exit:_o()}}class bo{constructor(e){this.isMounted=!1,this.node=e}update(){}}class J3 extends bo{constructor(e){super(e),e.animationState||(e.animationState=G3(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Cf(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Z3=0;class X3 extends bo{constructor(){super(...arguments),this.id=Z3++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Q3={animation:{Feature:J3},exit:{Feature:X3}};function gl(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function $l(t){return{point:{x:t.pageX,y:t.pageY}}}const eN=t=>e=>og(e)&&t(e,$l(e));function el(t,e,n,r){return gl(t,e,eN(n),r)}const TS=1e-4,tN=1-TS,nN=1+TS,CS=.01,rN=0-CS,iN=0+CS;function Rr(t){return t.max-t.min}function sN(t,e,n){return Math.abs(t-e)<=n}function Tw(t,e,n,r=.5){t.origin=r,t.originPoint=gn(e.min,e.max,t.origin),t.scale=Rr(n)/Rr(e),t.translate=gn(n.min,n.max,t.origin)-t.originPoint,(t.scale>=tN&&t.scale<=nN||isNaN(t.scale))&&(t.scale=1),(t.translate>=rN&&t.translate<=iN||isNaN(t.translate))&&(t.translate=0)}function tl(t,e,n,r){Tw(t.x,e.x,n.x,r?r.originX:void 0),Tw(t.y,e.y,n.y,r?r.originY:void 0)}function Cw(t,e,n){t.min=n.min+e.min,t.max=t.min+Rr(e)}function oN(t,e,n){Cw(t.x,e.x,n.x),Cw(t.y,e.y,n.y)}function Ow(t,e,n){t.min=e.min-n.min,t.max=t.min+Rr(e)}function Pd(t,e,n){Ow(t.x,e.x,n.x),Ow(t.y,e.y,n.y)}function ri(t){return[t("x"),t("y")]}const OS=({current:t})=>t?t.ownerDocument.defaultView:null,Nw=(t,e)=>Math.abs(t-e);function aN(t,e){const n=Nw(t.x,e.x),r=Nw(t.y,e.y);return Math.sqrt(n**2+r**2)}class NS{constructor(e,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:s=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=vh(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,v=aN(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!v)return;const{point:w}=f,{timestamp:b}=Jn;this.history.push({...w,timestamp:b});const{onStart:E,onMove:M}=this.handlers;g||(E&&E(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=wh(g,this.transformPagePoint),dn.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:v,onSessionEnd:w,resumeAnimation:b}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=vh(f.type==="pointercancel"?this.lastMoveEventInfo:wh(g,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,E),w&&w(f,E)},!og(e))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=o,this.contextWindow=i||window;const a=$l(e),c=wh(a,this.transformPagePoint),{point:l}=c,{timestamp:u}=Jn;this.history=[{...l,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,vh(c,this.history)),this.removeListeners=Ll(el(this.contextWindow,"pointermove",this.handlePointerMove),el(this.contextWindow,"pointerup",this.handlePointerUp),el(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),po(this.updatePoint)}}function wh(t,e){return e?{point:e(t.point)}:t}function Pw(t,e){return{x:t.x-e.x,y:t.y-e.y}}function vh({point:t},e){return{point:t,delta:Pw(t,PS(e)),offset:Pw(t,cN(e)),velocity:lN(e,.1)}}function cN(t){return t[0]}function PS(t){return t[t.length-1]}function lN(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const i=PS(t);for(;n>=0&&(r=t[n],!(i.timestamp-r.timestamp>xi(e)));)n--;if(!r)return{x:0,y:0};const s=di(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function uN(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?gn(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?gn(n,t,r.max):Math.min(t,n)),t}function Mw(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function dN(t,{top:e,left:n,bottom:r,right:i}){return{x:Mw(t.x,n,i),y:Mw(t.y,e,r)}}function kw(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function fN(t,e){return{x:kw(t.x,e.x),y:kw(t.y,e.y)}}function hN(t,e){let n=.5;const r=Rr(t),i=Rr(e);return i>r?n=fl(e.min,e.max-r,t.min):r>i&&(n=fl(t.min,t.max-i,e.min)),As(0,1,n)}function pN(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const R0=.35;function mN(t=R0){return t===!1?t=0:t===!0&&(t=R0),{x:Dw(t,"left","right"),y:Dw(t,"top","bottom")}}function Dw(t,e,n){return{min:Lw(t,e),max:Lw(t,n)}}function Lw(t,e){return typeof t=="number"?t:t[e]||0}const gN=new WeakMap;class yN{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Un(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const s=d=>{n?(this.stopAnimation(),this.snapToCursor($l(d).point)):this.pauseAnimation()},o=(d,f)=>{this.stopAnimation();const{drag:g,dragPropagation:v,onDragStart:w}=this.getProps();if(g&&!v&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_O(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ri(E=>{let M=this.getAxisMotionValue(E).get()||0;if(zi.test(M)){const{projection:S}=this.visualElement;if(S&&S.layout){const F=S.layout.layoutBox[E];F&&(M=Rr(F)*(parseFloat(M)/100))}}this.originPoint[E]=M}),w&&dn.postRender(()=>w(d,f)),x0(this.visualElement,"transform");const{animationState:b}=this.visualElement;b&&b.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:v,onDirectionLock:w,onDrag:b}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:E}=f;if(v&&this.currentDirection===null){this.currentDirection=wN(E),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",f.point,E),this.updateAxis("y",f.point,E),this.visualElement.render(),b&&b(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>ri(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:u}=this.getProps();this.panSession=new NS(e,{onSessionStart:s,onStart:o,onMove:a,onSessionEnd:c,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:r,contextWindow:OS(this.visualElement)})}stop(e,n){const r=e||this.latestPointerEvent,i=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!i||!r)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&dn.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,r){const{drag:i}=this.getProps();if(!r||!uu(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(o=uN(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&zc(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=dN(r.layoutBox,e):this.constraints=!1,this.elastic=mN(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&ri(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=pN(r.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!zc(e))return!1;const r=e.current;Rs(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=v3(r,i.root,this.visualElement.getTransformPagePoint());let o=fN(i.layout.layoutBox,s);if(n){const a=n(g3(o));this.hasMutatedConstraints=!!a,a&&(o=mS(a))}return o}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},l=ri(u=>{if(!uu(u,n,this.currentDirection))return;let d=c&&c[u]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,v={type:"inertia",velocity:r?e[u]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...s,...d};return this.startAxisValueAnimation(u,v)});return Promise.all(l).then(a)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return x0(this.visualElement,e),r.start(gg(e,r,0,n,this.visualElement,!1))}stopAnimation(){ri(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){ri(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){ri(n=>{const{drag:r}=this.getProps();if(!uu(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n],c=s.get()||0;s.set(e[n]-gn(o,a,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!zc(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ri(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const c=a.get();i[o]=hN({min:c,max:c},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),ri(o=>{if(!uu(o,e,null))return;const a=this.getAxisMotionValue(o),{min:c,max:l}=this.constraints[o];a.set(gn(c,l,i[o]))})}addListeners(){if(!this.visualElement.current)return;gN.set(this.visualElement,this);const e=this.visualElement.current,n=el(e,"pointerdown",c=>{const{drag:l,dragListener:u=!0}=this.getProps();l&&u&&!Q_(c.target)&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();zc(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),dn.read(r);const o=gl(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:c,hasLayoutChanged:l})=>{this.isDragging&&l&&(ri(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=c[u].translate,d.set(d.get()+c[u].translate))}),this.visualElement.render())}));return()=>{o(),n(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=R0,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function uu(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function wN(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class vN extends bo{constructor(e){super(e),this.removeGroupControls=hi,this.removeListeners=hi,this.controls=new yN(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||hi}update(){const{dragControls:e}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners()}}const Bw=t=>(e,n)=>{t&&dn.postRender(()=>t(e,n))};class EN extends bo{constructor(){super(...arguments),this.removePointerDownListener=hi}onPointerDown(e){this.session=new NS(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:OS(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:Bw(e),onStart:Bw(n),onMove:r,onEnd:(s,o)=>{delete this.session,i&&dn.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=el(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Qu={hasAnimatedSinceResize:!0,hasEverUpdated:!1};let Eh=!1;class bN extends Xe.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;s&&(n.group&&n.group.add(s),r&&r.register&&i&&r.register(s),Eh&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Qu.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:i,isPresent:s}=this.props,{projection:o}=r;return o&&(o.isPresent=s,Eh=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==s?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||dn.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),sg.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=e;Eh=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function MS(t){const[e,n]=tS(),r=Xe.useContext(Um);return vt.jsx(bN,{...t,layoutGroup:r,switchLayoutGroup:Xe.useContext(hS),isPresent:e,safeToRemove:n})}function _N(t,e,n){const r=vr(t)?t:Ja(t);return r.start(gg("",r,e,n)),r.animation}const SN=(t,e)=>t.depth-e.depth;class xN{constructor(){this.children=[],this.isDirty=!1}add(e){Km(this.children,e),this.isDirty=!0}remove(e){Vm(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(SN),this.isDirty=!1,this.children.forEach(e)}}function AN(t,e){const n=Lr.now(),r=({timestamp:i})=>{const s=i-n;s>=e&&(po(r),t(s-e))};return dn.setup(r,!0),()=>po(r)}const kS=["TopLeft","TopRight","BottomLeft","BottomRight"],RN=kS.length,Uw=t=>typeof t=="string"?parseFloat(t):t,$w=t=>typeof t=="number"||rt.test(t);function IN(t,e,n,r,i,s){i?(t.opacity=gn(0,n.opacity??1,TN(r)),t.opacityExit=gn(e.opacity??1,0,CN(r))):s&&(t.opacity=gn(e.opacity??1,n.opacity??1,r));for(let o=0;o<RN;o++){const a=`border${kS[o]}Radius`;let c=Fw(e,a),l=Fw(n,a);if(c===void 0&&l===void 0)continue;c||(c=0),l||(l=0),c===0||l===0||$w(c)===$w(l)?(t[a]=Math.max(gn(Uw(c),Uw(l),r),0),(zi.test(l)||zi.test(c))&&(t[a]+="%")):t[a]=l}(e.rotate||n.rotate)&&(t.rotate=gn(e.rotate||0,n.rotate||0,r))}function Fw(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const TN=DS(0,.5,v_),CN=DS(.5,.95,hi);function DS(t,e,n){return r=>r<t?0:r>e?1:n(fl(t,e,r))}function Kw(t,e){t.min=e.min,t.max=e.max}function pi(t,e){Kw(t.x,e.x),Kw(t.y,e.y)}function Vw(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function jw(t,e,n,r,i){return t-=e,t=Nd(t,1/n,r),i!==void 0&&(t=Nd(t,1/i,r)),t}function ON(t,e=0,n=1,r=.5,i,s=t,o=t){if(zi.test(e)&&(e=parseFloat(e),e=gn(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=gn(s.min,s.max,r);t===s&&(a-=e),t.min=jw(t.min,e,n,a,i),t.max=jw(t.max,e,n,a,i)}function Hw(t,e,[n,r,i],s,o){ON(t,e[n],e[r],e[i],e.scale,s,o)}const NN=["x","scaleX","originX"],PN=["y","scaleY","originY"];function zw(t,e,n,r){Hw(t.x,e,NN,n?n.x:void 0,r?r.x:void 0),Hw(t.y,e,PN,n?n.y:void 0,r?r.y:void 0)}function qw(t){return t.translate===0&&t.scale===1}function LS(t){return qw(t.x)&&qw(t.y)}function Ww(t,e){return t.min===e.min&&t.max===e.max}function MN(t,e){return Ww(t.x,e.x)&&Ww(t.y,e.y)}function Gw(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function BS(t,e){return Gw(t.x,e.x)&&Gw(t.y,e.y)}function Yw(t){return Rr(t.x)/Rr(t.y)}function Jw(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class kN{constructor(){this.members=[]}add(e){Km(this.members,e),e.scheduleRender()}remove(e){if(Vm(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function DN(t,e,n){let r="";const i=t.x.translate/e.x,s=t.y.translate/e.y,o=n?.z||0;if((i||s||o)&&(r=`translate3d(${i}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:l,rotate:u,rotateX:d,rotateY:f,skewX:g,skewY:v}=n;l&&(r=`perspective(${l}px) ${r}`),u&&(r+=`rotate(${u}deg) `),d&&(r+=`rotateX(${d}deg) `),f&&(r+=`rotateY(${f}deg) `),g&&(r+=`skewX(${g}deg) `),v&&(r+=`skewY(${v}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(r+=`scale(${a}, ${c})`),r||"none"}const bh=["","X","Y","Z"],LN=1e3;let BN=0;function _h(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function US(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=SS(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",dn,!(i||s))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&US(r)}function $S({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=BN++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(FN),this.nodes.forEach(HN),this.nodes.forEach(zN),this.nodes.forEach(KN)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new xN)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Hm),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const c=this.eventHandlers.get(o);c&&c.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=eS(o)&&!IO(o),this.instance=o;const{layoutId:a,layout:c,visualElement:l}=this.options;if(l&&!l.current&&l.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;dn.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,u&&u(),u=AN(f,250),Qu.hasAnimatedSinceResize&&(Qu.hasAnimatedSinceResize=!1,this.nodes.forEach(Qw)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&l&&(a||c)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const v=this.options.transition||l.getDefaultTransition()||JN,{onLayoutAnimationStart:w,onLayoutAnimationComplete:b}=l.getProps(),E=!this.targetLayout||!BS(this.targetLayout,g),M=!d&&f;if(this.options.layoutRoot||this.resumeFrom||M||d&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...rg(v,"layout"),onPlay:w,onComplete:b};(l.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(u,M)}else d||Qw(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),po(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(qN),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&US(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const l=this.getTransformTemplate();this.prevTransformTemplateValue=l?l(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Zw);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Xw);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(jN),this.nodes.forEach(UN),this.nodes.forEach($N)):this.nodes.forEach(Xw),this.clearAllSnapshots();const a=Lr.now();Jn.delta=As(0,1e3/60,a-Jn.timestamp),Jn.timestamp=a,Jn.isProcessing=!0,uh.update.process(Jn),uh.preRender.process(Jn),uh.render.process(Jn),Jn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,sg.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(VN),this.sharedNodes.forEach(WN)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,dn.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){dn.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Rr(this.snapshot.measuredBox.x)&&!Rr(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=Un(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!LS(this.projectionDelta),c=this.getTransformTemplate(),l=c?c(this.latestValues,""):void 0,u=l!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ro(this.latestValues)||u)&&(i(this.instance,l),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return o&&(c=this.removeTransform(c)),ZN(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return Un();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(XN))){const{scroll:l}=this.root;l&&(Ra(a.x,l.offset.x),Ra(a.y,l.offset.y))}return a}removeElementScroll(o){const a=Un();if(pi(a,o),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const l=this.path[c],{scroll:u,options:d}=l;l!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&pi(a,o),Ra(a.x,u.offset.x),Ra(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const c=Un();pi(c,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Ia(c,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),Ro(u.latestValues)&&Ia(c,u.latestValues)}return Ro(this.latestValues)&&Ia(c,this.latestValues),c}removeTransform(o){const a=Un();pi(a,o);for(let c=0;c<this.path.length;c++){const l=this.path[c];if(!l.instance||!Ro(l.latestValues))continue;E0(l.latestValues)&&l.updateSnapshot();const u=Un(),d=l.measurePageBox();pi(u,d),zw(a,l.latestValues,l.snapshot?l.snapshot.layoutBox:void 0,u)}return Ro(this.latestValues)&&zw(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Jn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(o||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:d}=this.options;if(!this.layout||!(u||d))return;this.resolvedRelativeTargetAt=Jn.timestamp;const f=this.getClosestProjectingParent();f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Un(),this.targetWithTransforms=Un()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),oN(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):pi(this.target,this.layout.layoutBox),yS(this.target,this.targetDelta)):pi(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||E0(this.parent.latestValues)||gS(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,a,c){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Un(),this.relativeTargetOrigin=Un(),Pd(this.relativeTargetOrigin,a,c),pi(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Jn.timestamp&&(c=!1),c)return;const{layout:l,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(l||u))return;pi(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;w3(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Un());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Vw(this.prevProjectionDelta.x,this.projectionDelta.x),Vw(this.prevProjectionDelta.y,this.projectionDelta.y)),tl(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Jw(this.projectionDelta.x,this.prevProjectionDelta.x)||!Jw(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ta(),this.projectionDelta=Ta(),this.projectionDeltaWithTransform=Ta()}setAnimationOrigin(o,a=!1){const c=this.snapshot,l=c?c.latestValues:{},u={...this.latestValues},d=Ta();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Un(),g=c?c.source:void 0,v=this.layout?this.layout.source:void 0,w=g!==v,b=this.getStack(),E=!b||b.members.length<=1,M=!!(w&&!E&&this.options.crossfade===!0&&!this.path.some(YN));this.animationProgress=0;let S;this.mixTargetDelta=F=>{const D=F/1e3;ev(d.x,o.x,D),ev(d.y,o.y,D),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pd(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),GN(this.relativeTarget,this.relativeTargetOrigin,f,D),S&&MN(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=Un()),pi(S,this.relativeTarget)),w&&(this.animationValues=u,IN(u,l,this.latestValues,D,M,E)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(po(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=dn.update(()=>{Qu.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ja(0)),this.currentAnimation=_N(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(LN),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:c,layout:l,latestValues:u}=o;if(!(!a||!c||!l)){if(this!==o&&this.layout&&l&&FS(this.options.animationType,this.layout.layoutBox,l.layoutBox)){c=this.target||Un();const d=Rr(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+d;const f=Rr(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}pi(a,c),Ia(a,u),tl(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new kN),this.sharedNodes.get(o).add(a);const l=a.options.initialPromotionConfig;a.promote({transition:l?l.transition:void 0,preserveFollowOpacity:l&&l.shouldPreserveFollowOpacity?l.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:c}={}){const l=this.getStack();l&&l.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const l={};c.z&&_h("z",o,l,this.animationValues);for(let u=0;u<bh.length;u++)_h(`rotate${bh[u]}`,o,l,this.animationValues),_h(`skew${bh[u]}`,o,l,this.animationValues);o.render();for(const u in l)o.setStaticValue(u,l[u]),this.animationValues&&(this.animationValues[u]=l[u]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Xu(a?.pointerEvents)||"",o.transform=c?c(this.latestValues,""):"none";return}const l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Xu(a?.pointerEvents)||""),this.hasProjected&&!Ro(this.latestValues)&&(o.transform=c?c({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=l.animationValues||l.latestValues;this.applyTransformsToTarget();let d=DN(this.projectionDeltaWithTransform,this.treeScale,u);c&&(d=c(u,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,l.animationValues?o.opacity=l===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=l===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const v in v0){if(u[v]===void 0)continue;const{correct:w,applyTo:b,isCSSVariable:E}=v0[v],M=d==="none"?u[v]:w(u[v],l);if(b){const S=b.length;for(let F=0;F<S;F++)o[b[F]]=M}else E?this.options.visualElement.renderState.vars[v]=M:o[v]=M}this.options.layoutId&&(o.pointerEvents=l===this?Xu(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Zw),this.root.sharedNodes.clear()}}}function UN(t){t.updateLayout()}function $N(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,s=e.source!==t.layout.source;i==="size"?ri(u=>{const d=s?e.measuredBox[u]:e.layoutBox[u],f=Rr(d);d.min=n[u].min,d.max=d.min+f}):FS(i,e.layoutBox,n)&&ri(u=>{const d=s?e.measuredBox[u]:e.layoutBox[u],f=Rr(n[u]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=Ta();tl(o,n,e.layoutBox);const a=Ta();s?tl(a,t.applyTransform(r,!0),e.measuredBox):tl(a,n,e.layoutBox);const c=!LS(o);let l=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const g=Un();Pd(g,e.layoutBox,d.layoutBox);const v=Un();Pd(v,n,f.layoutBox),BS(g,v)||(l=!0),u.options.layoutRoot&&(t.relativeTarget=v,t.relativeTargetOrigin=g,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function FN(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function KN(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function VN(t){t.clearSnapshot()}function Zw(t){t.clearMeasurements()}function Xw(t){t.isLayoutDirty=!1}function jN(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Qw(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function HN(t){t.resolveTargetDelta()}function zN(t){t.calcProjection()}function qN(t){t.resetSkewAndRotation()}function WN(t){t.removeLeadSnapshot()}function ev(t,e,n){t.translate=gn(e.translate,0,n),t.scale=gn(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function tv(t,e,n,r){t.min=gn(e.min,n.min,r),t.max=gn(e.max,n.max,r)}function GN(t,e,n,r){tv(t.x,e.x,n.x,r),tv(t.y,e.y,n.y,r)}function YN(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const JN={duration:.45,ease:[.4,0,.1,1]},nv=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),rv=nv("applewebkit/")&&!nv("chrome/")?Math.round:hi;function iv(t){t.min=rv(t.min),t.max=rv(t.max)}function ZN(t){iv(t.x),iv(t.y)}function FS(t,e,n){return t==="position"||t==="preserve-aspect"&&!sN(Yw(e),Yw(n),.2)}function XN(t){return t!==t.root&&t.scroll?.wasRoot}const QN=$S({attachResizeListener:(t,e)=>gl(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Sh={current:void 0},KS=$S({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Sh.current){const t=new QN({});t.mount(window),t.setOptions({layoutScroll:!0}),Sh.current=t}return Sh.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),e6={pan:{Feature:EN},drag:{Feature:vN,ProjectionNode:KS,MeasureLayout:MS}};function sv(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,s=r[i];s&&dn.postRender(()=>s(e,$l(e)))}class t6 extends bo{mount(){const{current:e}=this.node;e&&(this.unmount=SO(e,(n,r)=>(sv(this.node,r,"Start"),i=>sv(this.node,i,"End"))))}unmount(){}}class n6 extends bo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ll(gl(this.node.current,"focus",()=>this.onFocus()),gl(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ov(t,e,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),s=r[i];s&&dn.postRender(()=>s(e,$l(e)))}class r6 extends bo{mount(){const{current:e}=this.node;e&&(this.unmount=RO(e,(n,r)=>(ov(this.node,r,"Start"),(i,{success:s})=>ov(this.node,i,s?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const I0=new WeakMap,xh=new WeakMap,i6=t=>{const e=I0.get(t.target);e&&e(t)},s6=t=>{t.forEach(i6)};function o6({root:t,...e}){const n=t||document;xh.has(n)||xh.set(n,{});const r=xh.get(n),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver(s6,{root:t,...e})),r[i]}function a6(t,e,n){const r=o6(e);return I0.set(t,n),r.observe(t),()=>{I0.delete(t),r.unobserve(t)}}const c6={some:0,all:1};class l6 extends bo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:s}=e,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:c6[i]},a=c=>{const{isIntersecting:l}=c;if(this.isInView===l||(this.isInView=l,s&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=l?u:d;f&&f(c)};return a6(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(u6(e,n))&&this.startObserver()}unmount(){}}function u6({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const d6={inView:{Feature:l6},tap:{Feature:r6},focus:{Feature:n6},hover:{Feature:t6}},f6={layout:{ProjectionNode:KS,MeasureLayout:MS}},h6={...Q3,...d6,...e6,...f6},av=m3(h6,T3),VS=({children:t,className:e,...n})=>vt.jsx("button",{...n,className:`p-4 w-full cursor-pointer text-lg font-medium disabled:cursor-not-allowed ${e||""}`,children:t});var du={exports:{}},cv;function p6(){return cv||(cv=1,(function(t,e){var n=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof su<"u"&&su,r=(function(){function s(){this.fetch=!1,this.DOMException=n.DOMException}return s.prototype=n,new s})();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof su<"u"&&su||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(y){return y&&DataView.prototype.isPrototypeOf(y)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(y){return y&&u.indexOf(Object.prototype.toString.call(y))>-1};function f(y){if(typeof y!="string"&&(y=String(y)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(y)||y==="")throw new TypeError('Invalid character in header field name: "'+y+'"');return y.toLowerCase()}function g(y){return typeof y!="string"&&(y=String(y)),y}function v(y){var R={next:function(){var P=y.shift();return{done:P===void 0,value:P}}};return c.iterable&&(R[Symbol.iterator]=function(){return R}),R}function w(y){this.map={},y instanceof w?y.forEach(function(R,P){this.append(P,R)},this):Array.isArray(y)?y.forEach(function(R){if(R.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+R.length);this.append(R[0],R[1])},this):y&&Object.getOwnPropertyNames(y).forEach(function(R){this.append(R,y[R])},this)}w.prototype.append=function(y,R){y=f(y),R=g(R);var P=this.map[y];this.map[y]=P?P+", "+R:R},w.prototype.delete=function(y){delete this.map[f(y)]},w.prototype.get=function(y){return y=f(y),this.has(y)?this.map[y]:null},w.prototype.has=function(y){return this.map.hasOwnProperty(f(y))},w.prototype.set=function(y,R){this.map[f(y)]=g(R)},w.prototype.forEach=function(y,R){for(var P in this.map)this.map.hasOwnProperty(P)&&y.call(R,this.map[P],P,this)},w.prototype.keys=function(){var y=[];return this.forEach(function(R,P){y.push(P)}),v(y)},w.prototype.values=function(){var y=[];return this.forEach(function(R){y.push(R)}),v(y)},w.prototype.entries=function(){var y=[];return this.forEach(function(R,P){y.push([P,R])}),v(y)},c.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function b(y){if(!y._noBody){if(y.bodyUsed)return Promise.reject(new TypeError("Already read"));y.bodyUsed=!0}}function E(y){return new Promise(function(R,P){y.onload=function(){R(y.result)},y.onerror=function(){P(y.error)}})}function M(y){var R=new FileReader,P=E(R);return R.readAsArrayBuffer(y),P}function S(y){var R=new FileReader,P=E(R),_=/charset=([A-Za-z0-9_-]+)/.exec(y.type),I=_?_[1]:"utf-8";return R.readAsText(y,I),P}function F(y){for(var R=new Uint8Array(y),P=new Array(R.length),_=0;_<R.length;_++)P[_]=String.fromCharCode(R[_]);return P.join("")}function D(y){if(y.slice)return y.slice(0);var R=new Uint8Array(y.byteLength);return R.set(new Uint8Array(y)),R.buffer}function z(){return this.bodyUsed=!1,this._initBody=function(y){this.bodyUsed=this.bodyUsed,this._bodyInit=y,y?typeof y=="string"?this._bodyText=y:c.blob&&Blob.prototype.isPrototypeOf(y)?this._bodyBlob=y:c.formData&&FormData.prototype.isPrototypeOf(y)?this._bodyFormData=y:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)?this._bodyText=y.toString():c.arrayBuffer&&c.blob&&l(y)?(this._bodyArrayBuffer=D(y.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(y)||d(y))?this._bodyArrayBuffer=D(y):this._bodyText=y=Object.prototype.toString.call(y):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof y=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var y=b(this);if(y)return y;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var y=b(this);return y||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(M);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var y=b(this);if(y)return y;if(this._bodyBlob)return S(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(F(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(B)}),this.json=function(){return this.text().then(JSON.parse)},this}var X=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function Y(y){var R=y.toUpperCase();return X.indexOf(R)>-1?R:y}function U(y,R){if(!(this instanceof U))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');R=R||{};var P=R.body;if(y instanceof U){if(y.bodyUsed)throw new TypeError("Already read");this.url=y.url,this.credentials=y.credentials,R.headers||(this.headers=new w(y.headers)),this.method=y.method,this.mode=y.mode,this.signal=y.signal,!P&&y._bodyInit!=null&&(P=y._bodyInit,y.bodyUsed=!0)}else this.url=String(y);if(this.credentials=R.credentials||this.credentials||"same-origin",(R.headers||!this.headers)&&(this.headers=new w(R.headers)),this.method=Y(R.method||this.method||"GET"),this.mode=R.mode||this.mode||null,this.signal=R.signal||this.signal||(function(){if("AbortController"in a){var N=new AbortController;return N.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&P)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(P),(this.method==="GET"||this.method==="HEAD")&&(R.cache==="no-store"||R.cache==="no-cache")){var _=/([?&])_=[^&]*/;if(_.test(this.url))this.url=this.url.replace(_,"$1_="+new Date().getTime());else{var I=/\?/;this.url+=(I.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}U.prototype.clone=function(){return new U(this,{body:this._bodyInit})};function B(y){var R=new FormData;return y.trim().split("&").forEach(function(P){if(P){var _=P.split("="),I=_.shift().replace(/\+/g," "),N=_.join("=").replace(/\+/g," ");R.append(decodeURIComponent(I),decodeURIComponent(N))}}),R}function H(y){var R=new w,P=y.replace(/\r?\n[\t ]+/g," ");return P.split("\r").map(function(_){return _.indexOf(`
|
|
15
|
+
`)===0?_.substr(1,_.length):_}).forEach(function(_){var I=_.split(":"),N=I.shift().trim();if(N){var x=I.join(":").trim();try{R.append(N,x)}catch(h){console.warn("Response "+h.message)}}}),R}z.call(U.prototype);function V(y,R){if(!(this instanceof V))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(R||(R={}),this.type="default",this.status=R.status===void 0?200:R.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=R.statusText===void 0?"":""+R.statusText,this.headers=new w(R.headers),this.url=R.url||"",this._initBody(y)}z.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},V.error=function(){var y=new V(null,{status:200,statusText:""});return y.ok=!1,y.status=0,y.type="error",y};var T=[301,302,303,307,308];V.redirect=function(y,R){if(T.indexOf(R)===-1)throw new RangeError("Invalid status code");return new V(null,{status:R,headers:{location:y}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(R,P){this.message=R,this.name=P;var _=Error(R);this.stack=_.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function p(y,R){return new Promise(function(P,_){var I=new U(y,R);if(I.signal&&I.signal.aborted)return _(new o.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function x(){N.abort()}N.onload=function(){var A={statusText:N.statusText,headers:H(N.getAllResponseHeaders()||"")};I.url.indexOf("file://")===0&&(N.status<200||N.status>599)?A.status=200:A.status=N.status,A.url="responseURL"in N?N.responseURL:A.headers.get("X-Request-URL");var C="response"in N?N.response:N.responseText;setTimeout(function(){P(new V(C,A))},0)},N.onerror=function(){setTimeout(function(){_(new TypeError("Network request failed"))},0)},N.ontimeout=function(){setTimeout(function(){_(new TypeError("Network request timed out"))},0)},N.onabort=function(){setTimeout(function(){_(new o.DOMException("Aborted","AbortError"))},0)};function h(A){try{return A===""&&a.location.href?a.location.href:A}catch{return A}}if(N.open(I.method,h(I.url),!0),I.credentials==="include"?N.withCredentials=!0:I.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&(c.blob?N.responseType="blob":c.arrayBuffer&&(N.responseType="arraybuffer")),R&&typeof R.headers=="object"&&!(R.headers instanceof w||a.Headers&&R.headers instanceof a.Headers)){var m=[];Object.getOwnPropertyNames(R.headers).forEach(function(A){m.push(f(A)),N.setRequestHeader(A,g(R.headers[A]))}),I.headers.forEach(function(A,C){m.indexOf(C)===-1&&N.setRequestHeader(C,A)})}else I.headers.forEach(function(A,C){N.setRequestHeader(C,A)});I.signal&&(I.signal.addEventListener("abort",x),N.onreadystatechange=function(){N.readyState===4&&I.signal.removeEventListener("abort",x)}),N.send(typeof I._bodyInit>"u"?null:I._bodyInit)})}return p.polyfill=!0,a.fetch||(a.fetch=p,a.Headers=w,a.Request=U,a.Response=V),o.Headers=w,o.Request=U,o.Response=V,o.fetch=p,o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=n.fetch?n:r;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(du,du.exports)),du.exports}var m6=p6();const jS=hc(m6);var fu={exports:{}},Ah,lv;function g6(){if(lv)return Ah;lv=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,s=r*365.25;Ah=function(u,d){d=d||{};var f=typeof u;if(f==="string"&&u.length>0)return o(u);if(f==="number"&&isFinite(u))return d.long?c(u):a(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function o(u){if(u=String(u),!(u.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(d){var f=parseFloat(d[1]),g=(d[2]||"ms").toLowerCase();switch(g){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(u){var d=Math.abs(u);return d>=r?Math.round(u/r)+"d":d>=n?Math.round(u/n)+"h":d>=e?Math.round(u/e)+"m":d>=t?Math.round(u/t)+"s":u+"ms"}function c(u){var d=Math.abs(u);return d>=r?l(u,d,r,"day"):d>=n?l(u,d,n,"hour"):d>=e?l(u,d,e,"minute"):d>=t?l(u,d,t,"second"):u+" ms"}function l(u,d,f,g){var v=d>=f*1.5;return Math.round(u/f)+" "+g+(v?"s":"")}return Ah}var Rh,uv;function y6(){if(uv)return Rh;uv=1;function t(e){r.debug=r,r.default=r,r.coerce=l,r.disable=o,r.enable=s,r.enabled=a,r.humanize=g6(),r.destroy=u,Object.keys(e).forEach(d=>{r[d]=e[d]}),r.names=[],r.skips=[],r.formatters={};function n(d){let f=0;for(let g=0;g<d.length;g++)f=(f<<5)-f+d.charCodeAt(g),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=n;function r(d){let f,g=null,v,w;function b(...E){if(!b.enabled)return;const M=b,S=Number(new Date),F=S-(f||S);M.diff=F,M.prev=f,M.curr=S,f=S,E[0]=r.coerce(E[0]),typeof E[0]!="string"&&E.unshift("%O");let D=0;E[0]=E[0].replace(/%([a-zA-Z%])/g,(X,Y)=>{if(X==="%%")return"%";D++;const U=r.formatters[Y];if(typeof U=="function"){const B=E[D];X=U.call(M,B),E.splice(D,1),D--}return X}),r.formatArgs.call(M,E),(M.log||r.log).apply(M,E)}return b.namespace=d,b.useColors=r.useColors(),b.color=r.selectColor(d),b.extend=i,b.destroy=r.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>g!==null?g:(v!==r.namespaces&&(v=r.namespaces,w=r.enabled(d)),w),set:E=>{g=E}}),typeof r.init=="function"&&r.init(b),b}function i(d,f){const g=r(this.namespace+(typeof f>"u"?":":f)+d);return g.log=this.log,g}function s(d){r.save(d),r.namespaces=d,r.names=[],r.skips=[];let f;const g=(typeof d=="string"?d:"").split(/[\s,]+/),v=g.length;for(f=0;f<v;f++)g[f]&&(d=g[f].replace(/\*/g,".*?"),d[0]==="-"?r.skips.push(new RegExp("^"+d.slice(1)+"$")):r.names.push(new RegExp("^"+d+"$")))}function o(){const d=[...r.names.map(c),...r.skips.map(c).map(f=>"-"+f)].join(",");return r.enable(""),d}function a(d){if(d[d.length-1]==="*")return!0;let f,g;for(f=0,g=r.skips.length;f<g;f++)if(r.skips[f].test(d))return!1;for(f=0,g=r.names.length;f<g;f++)if(r.names[f].test(d))return!0;return!1}function c(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}function l(d){return d instanceof Error?d.stack||d.message:d}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return Rh=t,Rh}var dv;function w6(){return dv||(dv=1,(function(t,e){e.formatArgs=r,e.save=i,e.load=s,e.useColors=n,e.storage=o(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const l="color: "+this.color;c.splice(1,0,l,"color: inherit");let u=0,d=0;c[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(u++,f==="%c"&&(d=u))}),c.splice(d,0,l)}e.log=console.debug||console.log||(()=>{});function i(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function s(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function o(){try{return localStorage}catch{}}t.exports=y6()(e);const{formatters:a}=t.exports;a.j=function(c){try{return JSON.stringify(c)}catch(l){return"[UnexpectedJSONParseError]: "+l.message}}})(fu,fu.exports)),fu.exports}var v6=w6();const Ir=hc(v6);var Ih,fv;function E6(){if(fv)return Ih;fv=1;var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(U,B)=>{for(var H in B)t(U,H,{get:B[H],enumerable:!0})},s=(U,B,H,V)=>{if(B&&typeof B=="object"||typeof B=="function")for(let T of n(B))!r.call(U,T)&&T!==H&&t(U,T,{get:()=>B[T],enumerable:!(V=e(B,T))||V.enumerable});return U},o=U=>s(t({},"__esModule",{value:!0}),U),a={};i(a,{createFinalURL:()=>z,createPathBasedClient:()=>w,createQuerySerializer:()=>S,default:()=>d,defaultBodySerializer:()=>D,defaultPathSerializer:()=>F,mergeHeaders:()=>X,randomID:()=>u,removeTrailingSlash:()=>Y,serializeArrayParam:()=>M,serializeObjectParam:()=>E,serializePrimitiveParam:()=>b,wrapAsPathBasedClient:()=>v}),Ih=o(a);var c=/\{[^{}]+\}/g,l=()=>typeof process=="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function u(){return Math.random().toString(36).slice(2,11)}function d(U){let{baseUrl:B="",Request:H=globalThis.Request,fetch:V=globalThis.fetch,querySerializer:T,bodySerializer:p,headers:y,requestInitExt:R=void 0,...P}={...U};R=l()?R:void 0,B=Y(B);const _=[];async function I(N,x){const{baseUrl:h,fetch:m=V,Request:A=H,headers:C,params:$={},parseAs:j="json",querySerializer:Z,bodySerializer:ne=p??D,body:se,...ue}=x||{};let de=B;h&&(de=Y(h)??B);let Ae=typeof T=="function"?T:S(T);Z&&(Ae=typeof Z=="function"?Z:S({...typeof T=="object"?T:{},...Z}));const Ce=se===void 0?void 0:ne(se,X(y,C,$.header)),Ue=X(Ce===void 0||Ce instanceof FormData?{}:{"Content-Type":"application/json"},y,C,$.header),Be={redirect:"follow",...P,...ue,body:Ce,headers:Ue};let Oe,Le,je=new H(z(N,{baseUrl:de,params:$,querySerializer:Ae}),Be),$e;for(const He in ue)He in je||(je[He]=ue[He]);if(_.length){Oe=u(),Le=Object.freeze({baseUrl:de,fetch:m,parseAs:j,querySerializer:Ae,bodySerializer:ne});for(const He of _)if(He&&typeof He=="object"&&typeof He.onRequest=="function"){const Ke=await He.onRequest({request:je,schemaPath:N,params:$,options:Le,id:Oe});if(Ke)if(Ke instanceof H)je=Ke;else if(Ke instanceof Response){$e=Ke;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!$e){try{$e=await m(je,R)}catch(He){let Ke=He;if(_.length)for(let Ge=_.length-1;Ge>=0;Ge--){const Dt=_[Ge];if(Dt&&typeof Dt=="object"&&typeof Dt.onError=="function"){const _t=await Dt.onError({request:je,error:Ke,schemaPath:N,params:$,options:Le,id:Oe});if(_t){if(_t instanceof Response){Ke=void 0,$e=_t;break}if(_t instanceof Error){Ke=_t;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(Ke)throw Ke}if(_.length)for(let He=_.length-1;He>=0;He--){const Ke=_[He];if(Ke&&typeof Ke=="object"&&typeof Ke.onResponse=="function"){const Ge=await Ke.onResponse({request:je,response:$e,schemaPath:N,params:$,options:Le,id:Oe});if(Ge){if(!(Ge instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");$e=Ge}}}}if($e.status===204||je.method==="HEAD"||$e.headers.get("Content-Length")==="0")return $e.ok?{data:void 0,response:$e}:{error:void 0,response:$e};if($e.ok)return j==="stream"?{data:$e.body,response:$e}:{data:await $e[j](),response:$e};let Je=await $e.text();try{Je=JSON.parse(Je)}catch{}return{error:Je,response:$e}}return{request(N,x,h){return I(x,{...h,method:N.toUpperCase()})},GET(N,x){return I(N,{...x,method:"GET"})},PUT(N,x){return I(N,{...x,method:"PUT"})},POST(N,x){return I(N,{...x,method:"POST"})},DELETE(N,x){return I(N,{...x,method:"DELETE"})},OPTIONS(N,x){return I(N,{...x,method:"OPTIONS"})},HEAD(N,x){return I(N,{...x,method:"HEAD"})},PATCH(N,x){return I(N,{...x,method:"PATCH"})},TRACE(N,x){return I(N,{...x,method:"TRACE"})},use(...N){for(const x of N)if(x){if(typeof x!="object"||!("onRequest"in x||"onResponse"in x||"onError"in x))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");_.push(x)}},eject(...N){for(const x of N){const h=_.indexOf(x);h!==-1&&_.splice(h,1)}}}}var f=class{constructor(U,B){this.client=U,this.url=B}GET=U=>this.client.GET(this.url,U);PUT=U=>this.client.PUT(this.url,U);POST=U=>this.client.POST(this.url,U);DELETE=U=>this.client.DELETE(this.url,U);OPTIONS=U=>this.client.OPTIONS(this.url,U);HEAD=U=>this.client.HEAD(this.url,U);PATCH=U=>this.client.PATCH(this.url,U);TRACE=U=>this.client.TRACE(this.url,U)},g=class{constructor(){this.client=null}get(U,B){const H=new f(U,B);return this.client[B]=H,H}};function v(U){const B=new g,H=new Proxy(U,B);function V(){}V.prototype=H;const T=new V;return B.client=T,T}function w(U){return v(d(U))}function b(U,B,H){if(B==null)return"";if(typeof B=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${U}=${H?.allowReserved===!0?B:encodeURIComponent(B)}`}function E(U,B,H){if(!B||typeof B!="object")return"";const V=[],T={simple:",",label:".",matrix:";"}[H.style]||"&";if(H.style!=="deepObject"&&H.explode===!1){for(const R in B)V.push(R,H.allowReserved===!0?B[R]:encodeURIComponent(B[R]));const y=V.join(",");switch(H.style){case"form":return`${U}=${y}`;case"label":return`.${y}`;case"matrix":return`;${U}=${y}`;default:return y}}for(const y in B){const R=H.style==="deepObject"?`${U}[${y}]`:y;V.push(b(R,B[y],H))}const p=V.join(T);return H.style==="label"||H.style==="matrix"?`${T}${p}`:p}function M(U,B,H){if(!Array.isArray(B))return"";if(H.explode===!1){const p={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[H.style]||",",y=(H.allowReserved===!0?B:B.map(R=>encodeURIComponent(R))).join(p);switch(H.style){case"simple":return y;case"label":return`.${y}`;case"matrix":return`;${U}=${y}`;default:return`${U}=${y}`}}const V={simple:",",label:".",matrix:";"}[H.style]||"&",T=[];for(const p of B)H.style==="simple"||H.style==="label"?T.push(H.allowReserved===!0?p:encodeURIComponent(p)):T.push(b(U,p,H));return H.style==="label"||H.style==="matrix"?`${V}${T.join(V)}`:T.join(V)}function S(U){return function(H){const V=[];if(H&&typeof H=="object")for(const T in H){const p=H[T];if(p!=null){if(Array.isArray(p)){if(p.length===0)continue;V.push(M(T,p,{style:"form",explode:!0,...U?.array,allowReserved:U?.allowReserved||!1}));continue}if(typeof p=="object"){V.push(E(T,p,{style:"deepObject",explode:!0,...U?.object,allowReserved:U?.allowReserved||!1}));continue}V.push(b(T,p,U))}}return V.join("&")}}function F(U,B){let H=U;for(const V of U.match(c)??[]){let T=V.substring(1,V.length-1),p=!1,y="simple";if(T.endsWith("*")&&(p=!0,T=T.substring(0,T.length-1)),T.startsWith(".")?(y="label",T=T.substring(1)):T.startsWith(";")&&(y="matrix",T=T.substring(1)),!B||B[T]===void 0||B[T]===null)continue;const R=B[T];if(Array.isArray(R)){H=H.replace(V,M(T,R,{style:y,explode:p}));continue}if(typeof R=="object"){H=H.replace(V,E(T,R,{style:y,explode:p}));continue}if(y==="matrix"){H=H.replace(V,`;${b(T,R)}`);continue}H=H.replace(V,y==="label"?`.${encodeURIComponent(R)}`:encodeURIComponent(R))}return H}function D(U,B){return U instanceof FormData?U:B&&(B.get instanceof Function?B.get("Content-Type")??B.get("content-type"):B["Content-Type"]??B["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(U).toString():JSON.stringify(U)}function z(U,B){let H=`${B.baseUrl}${U}`;B.params?.path&&(H=F(H,B.params.path));let V=B.querySerializer(B.params.query??{});return V.startsWith("?")&&(V=V.substring(1)),V&&(H+=`?${V}`),H}function X(...U){const B=new Headers;for(const H of U){if(!H||typeof H!="object")continue;const V=H instanceof Headers?H.entries():Object.entries(H);for(const[T,p]of V)if(p===null)B.delete(T);else if(Array.isArray(p))for(const y of p)B.append(T,y);else p!==void 0&&B.set(T,p)}return B}function Y(U){return U.endsWith("/")?U.substring(0,U.length-1):U}return Ih}var Th,hv;function b6(){if(hv)return Th;hv=1;var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(D,z)=>{for(var X in z)e(D,X,{get:z[X],enumerable:!0})},a=(D,z,X,Y)=>{if(z&&typeof z=="object"||typeof z=="function")for(let U of r(z))!s.call(D,U)&&U!==X&&e(D,U,{get:()=>z[U],enumerable:!(Y=n(z,U))||Y.enumerable});return D},c=(D,z,X)=>(X=D!=null?t(i(D)):{},a(!D||!D.__esModule?e(X,"default",{value:D,enumerable:!0}):X,D)),l=D=>a(e({},"__esModule",{value:!0}),D),u={};o(u,{analytics:()=>F}),Th=l(u);var d=c(E6()),f=class{constructor(D){this.batch=[],this.maxTimeoutMs=3e4,this.timeoutId=null,this.isSending=!1,this.batchSize=D.batchSize,this.baseTimeoutMs=D.baseTimeoutMs,this.currentTimeoutMs=D.baseTimeoutMs,this.sendFn=D.sendFn}enqueue(D){this.batch.push(D),this.schedule()}schedule(){this.batch.length>0&&!this.timeoutId&&(this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.flush()},this.currentTimeoutMs))}async flush(){if(this.isSending||this.batch.length===0)return;this.isSending=!0;const D=[...this.batch.slice(0,this.batchSize)];this.batch=this.batch.slice(this.batchSize);try{await this.sendFn(D),this.currentTimeoutMs=this.baseTimeoutMs}catch(z){console.error("Sender: Failed to send batch",z),this.batch=[...D,...this.batch],this.currentTimeoutMs=Math.min(this.currentTimeoutMs*2,this.maxTimeoutMs)}finally{this.isSending=!1,this.schedule()}}},g=f,v=class{constructor(D){this.enabled=!1,this.properties={};const z=(0,d.default)({baseUrl:D}),X=async Y=>{const U=await z.POST("/v1/events",{body:Y});if(U.response.status!==200)throw new Error(U.error)};this.sender=new g({batchSize:100,baseTimeoutMs:200,sendFn:X})}enable(){this.enabled=!0}setGlobalProperty(D,z){this.properties[D]=z}track(D,z){if(!this.enabled)return;const X={name:D,...this.properties,...z};this.sender.enqueue(X)}},w=v,b,E;typeof process<"u"&&process.env&&(b=(E=process.env.METAMASK_ANALYTICS_ENDPOINT)!=null?E:process.env.NEXT_PUBLIC_METAMASK_ANALYTICS_ENDPOINT);var M=b??"https://mm-sdk-analytics.api.cx.metamask.io/",S=new w(M),F=S;return Th}var On=b6(),Ch={exports:{}};var pv;function _6(){return pv||(pv=1,(function(t,e){(function(n){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(I){return Object.prototype.toString.call(I)==="[object Array]"},s=10,o=typeof process=="object"&&typeof process.nextTick=="function",a=typeof Symbol=="function",c=typeof Reflect=="object",l=typeof setImmediate=="function",u=l?setImmediate:setTimeout,d=a?c&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(_){var I=Object.getOwnPropertyNames(_);return I.push.apply(I,Object.getOwnPropertySymbols(_)),I}:Object.keys;function f(){this._events={},this._conf&&g.call(this,this._conf)}function g(_){_&&(this._conf=_,_.delimiter&&(this.delimiter=_.delimiter),_.maxListeners!==n&&(this._maxListeners=_.maxListeners),_.wildcard&&(this.wildcard=_.wildcard),_.newListener&&(this._newListener=_.newListener),_.removeListener&&(this._removeListener=_.removeListener),_.verboseMemoryLeak&&(this.verboseMemoryLeak=_.verboseMemoryLeak),_.ignoreErrors&&(this.ignoreErrors=_.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function v(_,I){var N="(node) warning: possible EventEmitter memory leak detected. "+_+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(N+=" Event name: "+I+"."),typeof process<"u"&&process.emitWarning){var x=new Error(N);x.name="MaxListenersExceededWarning",x.emitter=this,x.count=_,process.emitWarning(x)}else console.error(N),console.trace&&console.trace()}var w=function(_,I,N){var x=arguments.length;switch(x){case 0:return[];case 1:return[_];case 2:return[_,I];case 3:return[_,I,N];default:for(var h=new Array(x);x--;)h[x]=arguments[x];return h}};function b(_,I){for(var N={},x,h=_.length,m=0,A=0;A<h;A++)x=_[A],N[x]=A<m?I[A]:n;return N}function E(_,I,N){this._emitter=_,this._target=I,this._listeners={},this._listenersCount=0;var x,h;if((N.on||N.off)&&(x=N.on,h=N.off),I.addEventListener?(x=I.addEventListener,h=I.removeEventListener):I.addListener?(x=I.addListener,h=I.removeListener):I.on&&(x=I.on,h=I.off),!x&&!h)throw Error("target does not implement any known event API");if(typeof x!="function")throw TypeError("on method must be a function");if(typeof h!="function")throw TypeError("off method must be a function");this._on=x,this._off=h;var m=_._observers;m?m.push(this):_._observers=[this]}Object.assign(E.prototype,{subscribe:function(_,I,N){var x=this,h=this._target,m=this._emitter,A=this._listeners,C=function(){var $=w.apply(null,arguments),j={data:$,name:I,original:_};if(N){var Z=N.call(h,j);Z!==!1&&m.emit.apply(m,[j.name].concat($));return}m.emit.apply(m,[I].concat($))};if(A[_])throw Error("Event '"+_+"' is already listening");this._listenersCount++,m._newListener&&m._removeListener&&!x._onNewListener?(this._onNewListener=function($){$===I&&A[_]===null&&(A[_]=C,x._on.call(h,_,C))},m.on("newListener",this._onNewListener),this._onRemoveListener=function($){$===I&&!m.hasListeners($)&&A[_]&&(A[_]=null,x._off.call(h,_,C))},A[_]=null,m.on("removeListener",this._onRemoveListener)):(A[_]=C,x._on.call(h,_,C))},unsubscribe:function(_){var I=this,N=this._listeners,x=this._emitter,h,m,A=this._off,C=this._target,$;if(_&&typeof _!="string")throw TypeError("event must be a string");function j(){I._onNewListener&&(x.off("newListener",I._onNewListener),x.off("removeListener",I._onRemoveListener),I._onNewListener=null,I._onRemoveListener=null);var Z=Y.call(x,I);x._observers.splice(Z,1)}if(_){if(h=N[_],!h)return;A.call(C,_,h),delete N[_],--this._listenersCount||j()}else{for(m=d(N),$=m.length;$-- >0;)_=m[$],A.call(C,_,N[_]);this._listeners={},this._listenersCount=0,j()}}});function M(_,I,N,x){var h=Object.assign({},I);if(!_)return h;if(typeof _!="object")throw TypeError("options must be an object");var m=Object.keys(_),A=m.length,C,$,j;function Z(se){throw Error('Invalid "'+C+'" option value'+(se?". Reason: "+se:""))}for(var ne=0;ne<A;ne++){if(C=m[ne],!r.call(I,C))throw Error('Unknown "'+C+'" option');$=_[C],$!==n&&(j=N[C],h[C]=j?j($,Z):$)}return h}function S(_,I){return(typeof _!="function"||!_.hasOwnProperty("prototype"))&&I("value must be a constructor"),_}function F(_){var I="value must be type of "+_.join("|"),N=_.length,x=_[0],h=_[1];return N===1?function(m,A){if(typeof m===x)return m;A(I)}:N===2?function(m,A){var C=typeof m;if(C===x||C===h)return m;A(I)}:function(m,A){for(var C=typeof m,$=N;$-- >0;)if(C===_[$])return m;A(I)}}var D=F(["function"]),z=F(["object","function"]);function X(_,I,N){var x,h,m=0,A,C=new _(function($,j,Z){N=M(N,{timeout:0,overload:!1},{timeout:function(de,Ae){return de*=1,(typeof de!="number"||de<0||!Number.isFinite(de))&&Ae("timeout must be a positive number"),de}}),x=!N.overload&&typeof _.prototype.cancel=="function"&&typeof Z=="function";function ne(){h&&(h=null),m&&(clearTimeout(m),m=0)}var se=function(de){ne(),$(de)},ue=function(de){ne(),j(de)};x?I(se,ue,Z):(h=[function(de){ue(de||Error("canceled"))}],I(se,ue,function(de){if(A)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof de!="function")throw TypeError("onCancel callback must be a function");h.push(de)}),A=!0),N.timeout>0&&(m=setTimeout(function(){var de=Error("timeout");de.code="ETIMEDOUT",m=0,C.cancel(de),j(de)},N.timeout))});return x||(C.cancel=function($){if(h){for(var j=h.length,Z=1;Z<j;Z++)h[Z]($);h[0]($),h=null}}),C}function Y(_){var I=this._observers;if(!I)return-1;for(var N=I.length,x=0;x<N;x++)if(I[x]._target===_)return x;return-1}function U(_,I,N,x,h){if(!N)return null;if(x===0){var m=typeof I;if(m==="string"){var A,C,$=0,j=0,Z=this.delimiter,ne=Z.length;if((C=I.indexOf(Z))!==-1){A=new Array(5);do A[$++]=I.slice(j,C),j=C+ne;while((C=I.indexOf(Z,j))!==-1);A[$++]=I.slice(j),I=A,h=$}else I=[I],h=1}else m==="object"?h=I.length:(I=[I],h=1)}var se=null,ue,de,Ae,Ce,Ue,Be=I[x],Oe=I[x+1],Le,je;if(x===h)N._listeners&&(typeof N._listeners=="function"?(_&&_.push(N._listeners),se=[N]):(_&&_.push.apply(_,N._listeners),se=[N]));else if(Be==="*"){for(Le=d(N),C=Le.length;C-- >0;)ue=Le[C],ue!=="_listeners"&&(je=U(_,I,N[ue],x+1,h),je&&(se?se.push.apply(se,je):se=je));return se}else if(Be==="**"){for(Ue=x+1===h||x+2===h&&Oe==="*",Ue&&N._listeners&&(se=U(_,I,N,h,h)),Le=d(N),C=Le.length;C-- >0;)ue=Le[C],ue!=="_listeners"&&(ue==="*"||ue==="**"?(N[ue]._listeners&&!Ue&&(je=U(_,I,N[ue],h,h),je&&(se?se.push.apply(se,je):se=je)),je=U(_,I,N[ue],x,h)):ue===Oe?je=U(_,I,N[ue],x+2,h):je=U(_,I,N[ue],x,h),je&&(se?se.push.apply(se,je):se=je));return se}else N[Be]&&(se=U(_,I,N[Be],x+1,h));if(de=N["*"],de&&U(_,I,de,x+1,h),Ae=N["**"],Ae)if(x<h)for(Ae._listeners&&U(_,I,Ae,h,h),Le=d(Ae),C=Le.length;C-- >0;)ue=Le[C],ue!=="_listeners"&&(ue===Oe?U(_,I,Ae[ue],x+2,h):ue===Be?U(_,I,Ae[ue],x+1,h):(Ce={},Ce[ue]=Ae[ue],U(_,I,{"**":Ce},x+1,h)));else Ae._listeners?U(_,I,Ae,h,h):Ae["*"]&&Ae["*"]._listeners&&U(_,I,Ae["*"],h,h);return se}function B(_,I,N){var x=0,h=0,m,A=this.delimiter,C=A.length,$;if(typeof _=="string")if((m=_.indexOf(A))!==-1){$=new Array(5);do $[x++]=_.slice(h,m),h=m+C;while((m=_.indexOf(A,h))!==-1);$[x++]=_.slice(h)}else $=[_],x=1;else $=_,x=_.length;if(x>1){for(m=0;m+1<x;m++)if($[m]==="**"&&$[m+1]==="**")return}var j=this.listenerTree,Z;for(m=0;m<x;m++)if(Z=$[m],j=j[Z]||(j[Z]={}),m===x-1)return j._listeners?(typeof j._listeners=="function"&&(j._listeners=[j._listeners]),N?j._listeners.unshift(I):j._listeners.push(I),!j._listeners.warned&&this._maxListeners>0&&j._listeners.length>this._maxListeners&&(j._listeners.warned=!0,v.call(this,j._listeners.length,Z))):j._listeners=I,!0;return!0}function H(_,I,N,x){for(var h=d(_),m=h.length,A,C,$,j=_._listeners,Z;m-- >0;)C=h[m],A=_[C],C==="_listeners"?$=N:$=N?N.concat(C):[C],Z=x||typeof C=="symbol",j&&I.push(Z?$:$.join(this.delimiter)),typeof A=="object"&&H.call(this,A,I,$,Z);return I}function V(_){for(var I=d(_),N=I.length,x,h,m;N-- >0;)h=I[N],x=_[h],x&&(m=!0,h!=="_listeners"&&!V(x)&&delete _[h]);return m}function T(_,I,N){this.emitter=_,this.event=I,this.listener=N}T.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function p(_,I,N){if(N===!0)h=!0;else if(N===!1)x=!0;else{if(!N||typeof N!="object")throw TypeError("options should be an object or true");var x=N.async,h=N.promisify,m=N.nextTick,A=N.objectify}if(x||m||h){var C=I,$=I._origin||I;if(m&&!o)throw Error("process.nextTick is not supported");h===n&&(h=I.constructor.name==="AsyncFunction"),I=function(){var j=arguments,Z=this,ne=this.event;return h?m?Promise.resolve():new Promise(function(se){u(se)}).then(function(){return Z.event=ne,C.apply(Z,j)}):(m?process.nextTick:u)(function(){Z.event=ne,C.apply(Z,j)})},I._async=!0,I._origin=$}return[I,A?new T(this,_,I):this]}function y(_){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,g.call(this,_)}y.EventEmitter2=y,y.prototype.listenTo=function(_,I,N){if(typeof _!="object")throw TypeError("target musts be an object");var x=this;N=M(N,{on:n,off:n,reducers:n},{on:D,off:D,reducers:z});function h(m){if(typeof m!="object")throw TypeError("events must be an object");var A=N.reducers,C=Y.call(x,_),$;C===-1?$=new E(x,_,N):$=x._observers[C];for(var j=d(m),Z=j.length,ne,se=typeof A=="function",ue=0;ue<Z;ue++)ne=j[ue],$.subscribe(ne,m[ne]||ne,se?A:A&&A[ne])}return i(I)?h(b(I)):h(typeof I=="string"?b(I.split(/\s+/)):I),this},y.prototype.stopListeningTo=function(_,I){var N=this._observers;if(!N)return!1;var x=N.length,h,m=!1;if(_&&typeof _!="object")throw TypeError("target should be an object");for(;x-- >0;)h=N[x],(!_||h._target===_)&&(h.unsubscribe(I),m=!0);return m},y.prototype.delimiter=".",y.prototype.setMaxListeners=function(_){_!==n&&(this._maxListeners=_,this._conf||(this._conf={}),this._conf.maxListeners=_)},y.prototype.getMaxListeners=function(){return this._maxListeners},y.prototype.event="",y.prototype.once=function(_,I,N){return this._once(_,I,!1,N)},y.prototype.prependOnceListener=function(_,I,N){return this._once(_,I,!0,N)},y.prototype._once=function(_,I,N,x){return this._many(_,1,I,N,x)},y.prototype.many=function(_,I,N,x){return this._many(_,I,N,!1,x)},y.prototype.prependMany=function(_,I,N,x){return this._many(_,I,N,!0,x)},y.prototype._many=function(_,I,N,x,h){var m=this;if(typeof N!="function")throw new Error("many only accepts instances of Function");function A(){return--I===0&&m.off(_,A),N.apply(this,arguments)}return A._origin=N,this._on(_,A,x,h)},y.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||f.call(this);var _=arguments[0],I,N=this.wildcard,x,h,m,A,C;if(_==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(N&&(I=_,_!=="newListener"&&_!=="removeListener"&&typeof _=="object")){if(h=_.length,a){for(m=0;m<h;m++)if(typeof _[m]=="symbol"){C=!0;break}}C||(_=_.join(this.delimiter))}var $=arguments.length,j;if(this._all&&this._all.length)for(j=this._all.slice(),m=0,h=j.length;m<h;m++)switch(this.event=_,$){case 1:j[m].call(this,_);break;case 2:j[m].call(this,_,arguments[1]);break;case 3:j[m].call(this,_,arguments[1],arguments[2]);break;default:j[m].apply(this,arguments)}if(N)j=[],U.call(this,j,I,this.listenerTree,0,h);else if(j=this._events[_],typeof j=="function"){switch(this.event=_,$){case 1:j.call(this);break;case 2:j.call(this,arguments[1]);break;case 3:j.call(this,arguments[1],arguments[2]);break;default:for(x=new Array($-1),A=1;A<$;A++)x[A-1]=arguments[A];j.apply(this,x)}return!0}else j&&(j=j.slice());if(j&&j.length){if($>3)for(x=new Array($-1),A=1;A<$;A++)x[A-1]=arguments[A];for(m=0,h=j.length;m<h;m++)switch(this.event=_,$){case 1:j[m].call(this);break;case 2:j[m].call(this,arguments[1]);break;case 3:j[m].call(this,arguments[1],arguments[2]);break;default:j[m].apply(this,x)}return!0}else if(!this.ignoreErrors&&!this._all&&_==="error")throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},y.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||f.call(this);var _=arguments[0],I=this.wildcard,N,x,h,m,A,C;if(_==="newListener"&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(I&&(N=_,_!=="newListener"&&_!=="removeListener"&&typeof _=="object")){if(m=_.length,a){for(A=0;A<m;A++)if(typeof _[A]=="symbol"){x=!0;break}}x||(_=_.join(this.delimiter))}var $=[],j=arguments.length,Z;if(this._all)for(A=0,m=this._all.length;A<m;A++)switch(this.event=_,j){case 1:$.push(this._all[A].call(this,_));break;case 2:$.push(this._all[A].call(this,_,arguments[1]));break;case 3:$.push(this._all[A].call(this,_,arguments[1],arguments[2]));break;default:$.push(this._all[A].apply(this,arguments))}if(I?(Z=[],U.call(this,Z,N,this.listenerTree,0)):Z=this._events[_],typeof Z=="function")switch(this.event=_,j){case 1:$.push(Z.call(this));break;case 2:$.push(Z.call(this,arguments[1]));break;case 3:$.push(Z.call(this,arguments[1],arguments[2]));break;default:for(h=new Array(j-1),C=1;C<j;C++)h[C-1]=arguments[C];$.push(Z.apply(this,h))}else if(Z&&Z.length){if(Z=Z.slice(),j>3)for(h=new Array(j-1),C=1;C<j;C++)h[C-1]=arguments[C];for(A=0,m=Z.length;A<m;A++)switch(this.event=_,j){case 1:$.push(Z[A].call(this));break;case 2:$.push(Z[A].call(this,arguments[1]));break;case 3:$.push(Z[A].call(this,arguments[1],arguments[2]));break;default:$.push(Z[A].apply(this,h))}}else if(!this.ignoreErrors&&!this._all&&_==="error")return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all($)},y.prototype.on=function(_,I,N){return this._on(_,I,!1,N)},y.prototype.prependListener=function(_,I,N){return this._on(_,I,!0,N)},y.prototype.onAny=function(_){return this._onAny(_,!1)},y.prototype.prependAny=function(_){return this._onAny(_,!0)},y.prototype.addListener=y.prototype.on,y.prototype._onAny=function(_,I){if(typeof _!="function")throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),I?this._all.unshift(_):this._all.push(_),this},y.prototype._on=function(_,I,N,x){if(typeof _=="function")return this._onAny(_,I),this;if(typeof I!="function")throw new Error("on only accepts instances of Function");this._events||f.call(this);var h=this,m;return x!==n&&(m=p.call(this,_,I,x),I=m[0],h=m[1]),this._newListener&&this.emit("newListener",_,I),this.wildcard?(B.call(this,_,I,N),h):(this._events[_]?(typeof this._events[_]=="function"&&(this._events[_]=[this._events[_]]),N?this._events[_].unshift(I):this._events[_].push(I),!this._events[_].warned&&this._maxListeners>0&&this._events[_].length>this._maxListeners&&(this._events[_].warned=!0,v.call(this,this._events[_].length,_))):this._events[_]=I,h)},y.prototype.off=function(_,I){if(typeof I!="function")throw new Error("removeListener only takes instances of Function");var N,x=[];if(this.wildcard){var h=typeof _=="string"?_.split(this.delimiter):_.slice();if(x=U.call(this,null,h,this.listenerTree,0),!x)return this}else{if(!this._events[_])return this;N=this._events[_],x.push({_listeners:N})}for(var m=0;m<x.length;m++){var A=x[m];if(N=A._listeners,i(N)){for(var C=-1,$=0,j=N.length;$<j;$++)if(N[$]===I||N[$].listener&&N[$].listener===I||N[$]._origin&&N[$]._origin===I){C=$;break}if(C<0)continue;return this.wildcard?A._listeners.splice(C,1):this._events[_].splice(C,1),N.length===0&&(this.wildcard?delete A._listeners:delete this._events[_]),this._removeListener&&this.emit("removeListener",_,I),this}else(N===I||N.listener&&N.listener===I||N._origin&&N._origin===I)&&(this.wildcard?delete A._listeners:delete this._events[_],this._removeListener&&this.emit("removeListener",_,I))}return this.listenerTree&&V(this.listenerTree),this},y.prototype.offAny=function(_){var I=0,N=0,x;if(_&&this._all&&this._all.length>0){for(x=this._all,I=0,N=x.length;I<N;I++)if(_===x[I])return x.splice(I,1),this._removeListener&&this.emit("removeListenerAny",_),this}else{if(x=this._all,this._removeListener)for(I=0,N=x.length;I<N;I++)this.emit("removeListenerAny",x[I]);this._all=[]}return this},y.prototype.removeListener=y.prototype.off,y.prototype.removeAllListeners=function(_){if(_===n)return!this._events||f.call(this),this;if(this.wildcard){var I=U.call(this,null,_,this.listenerTree,0),N,x;if(!I)return this;for(x=0;x<I.length;x++)N=I[x],N._listeners=null;this.listenerTree&&V(this.listenerTree)}else this._events&&(this._events[_]=null);return this},y.prototype.listeners=function(_){var I=this._events,N,x,h,m,A;if(_===n){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!I)return[];for(N=d(I),m=N.length,h=[];m-- >0;)x=I[N[m]],typeof x=="function"?h.push(x):h.push.apply(h,x);return h}else{if(this.wildcard){if(A=this.listenerTree,!A)return[];var C=[],$=typeof _=="string"?_.split(this.delimiter):_.slice();return U.call(this,C,$,A,0),C}return I?(x=I[_],x?typeof x=="function"?[x]:x:[]):[]}},y.prototype.eventNames=function(_){var I=this._events;return this.wildcard?H.call(this,this.listenerTree,[],null,_):I?d(I):[]},y.prototype.listenerCount=function(_){return this.listeners(_).length},y.prototype.hasListeners=function(_){if(this.wildcard){var I=[],N=typeof _=="string"?_.split(this.delimiter):_.slice();return U.call(this,I,N,this.listenerTree,0),I.length>0}var x=this._events,h=this._all;return!!(h&&h.length||x&&(_===n?d(x).length:x[_]))},y.prototype.listenersAny=function(){return this._all?this._all:[]},y.prototype.waitFor=function(_,I){var N=this,x=typeof I;return x==="number"?I={timeout:I}:x==="function"&&(I={filter:I}),I=M(I,{timeout:0,filter:n,handleError:!1,Promise,overload:!1},{filter:D,Promise:S}),X(I.Promise,function(h,m,A){function C(){var $=I.filter;if(!($&&!$.apply(N,arguments)))if(N.off(_,C),I.handleError){var j=arguments[0];j?m(j):h(w.apply(null,arguments).slice(1))}else h(w.apply(null,arguments))}A(function(){N.off(_,C)}),N._on(_,C,!1)},{timeout:I.timeout,overload:I.overload})};function R(_,I,N){N=M(N,{Promise,timeout:0,overload:!1},{Promise:S});var x=N.Promise;return X(x,function(h,m,A){var C;if(typeof _.addEventListener=="function"){C=function(){h(w.apply(null,arguments))},A(function(){_.removeEventListener(I,C)}),_.addEventListener(I,C,{once:!0});return}var $=function(){j&&_.removeListener("error",j),h(w.apply(null,arguments))},j;I!=="error"&&(j=function(Z){_.removeListener(I,$),m(Z)},_.once("error",j)),A(function(){j&&_.removeListener("error",j),_.removeListener(I,$)}),_.once(I,$)},{timeout:N.timeout,overload:N.overload})}var P=y.prototype;Object.defineProperties(y,{defaultMaxListeners:{get:function(){return P._maxListeners},set:function(_){if(typeof _!="number"||_<0||Number.isNaN(_))throw TypeError("n must be a non-negative number");P._maxListeners=_},enumerable:!0},once:{value:R,writable:!0,configurable:!0}}),Object.defineProperties(P,{_maxListeners:{value:s,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),t.exports=y})()})(Ch)),Ch.exports}var Nf=_6();const S6=hc(Nf);var hu,x6=new Uint8Array(16);function HS(){if(!hu&&(hu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!hu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hu(x6)}const A6=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Xa(t){return typeof t=="string"&&A6.test(t)}var Yn=[];for(var Oh=0;Oh<256;++Oh)Yn.push((Oh+256).toString(16).substr(1));function Pf(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Yn[t[e+0]]+Yn[t[e+1]]+Yn[t[e+2]]+Yn[t[e+3]]+"-"+Yn[t[e+4]]+Yn[t[e+5]]+"-"+Yn[t[e+6]]+Yn[t[e+7]]+"-"+Yn[t[e+8]]+Yn[t[e+9]]+"-"+Yn[t[e+10]]+Yn[t[e+11]]+Yn[t[e+12]]+Yn[t[e+13]]+Yn[t[e+14]]+Yn[t[e+15]]).toLowerCase();if(!Xa(n))throw TypeError("Stringified UUID is invalid");return n}var mv,Nh,Ph=0,Mh=0;function R6(t,e,n){var r=e&&n||0,i=e||new Array(16);t=t||{};var s=t.node||mv,o=t.clockseq!==void 0?t.clockseq:Nh;if(s==null||o==null){var a=t.random||(t.rng||HS)();s==null&&(s=mv=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Nh=(a[6]<<8|a[7])&16383)}var c=t.msecs!==void 0?t.msecs:Date.now(),l=t.nsecs!==void 0?t.nsecs:Mh+1,u=c-Ph+(l-Mh)/1e4;if(u<0&&t.clockseq===void 0&&(o=o+1&16383),(u<0||c>Ph)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ph=c,Mh=l,Nh=o,c+=122192928e5;var d=((c&268435455)*1e4+l)%4294967296;i[r++]=d>>>24&255,i[r++]=d>>>16&255,i[r++]=d>>>8&255,i[r++]=d&255;var f=c/4294967296*1e4&268435455;i[r++]=f>>>8&255,i[r++]=f&255,i[r++]=f>>>24&15|16,i[r++]=f>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var g=0;g<6;++g)i[r+g]=s[g];return e||Pf(i)}function zS(t){if(!Xa(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function I6(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var T6="6ba7b810-9dad-11d1-80b4-00c04fd430c8",C6="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function qS(t,e,n){function r(i,s,o,a){if(typeof i=="string"&&(i=I6(i)),typeof s=="string"&&(s=zS(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var c=new Uint8Array(16+i.length);if(c.set(s),c.set(i,s.length),c=n(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,o){a=a||0;for(var l=0;l<16;++l)o[a+l]=c[l];return o}return Pf(c)}try{r.name=t}catch{}return r.DNS=T6,r.URL=C6,r}function O6(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return N6(P6(M6(t),t.length*8))}function N6(t){for(var e=[],n=t.length*32,r="0123456789abcdef",i=0;i<n;i+=8){var s=t[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function WS(t){return(t+64>>>9<<4)+14+1}function P6(t,e){t[e>>5]|=128<<e%32,t[WS(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<t.length;o+=16){var a=n,c=r,l=i,u=s;n=sr(n,r,i,s,t[o],7,-680876936),s=sr(s,n,r,i,t[o+1],12,-389564586),i=sr(i,s,n,r,t[o+2],17,606105819),r=sr(r,i,s,n,t[o+3],22,-1044525330),n=sr(n,r,i,s,t[o+4],7,-176418897),s=sr(s,n,r,i,t[o+5],12,1200080426),i=sr(i,s,n,r,t[o+6],17,-1473231341),r=sr(r,i,s,n,t[o+7],22,-45705983),n=sr(n,r,i,s,t[o+8],7,1770035416),s=sr(s,n,r,i,t[o+9],12,-1958414417),i=sr(i,s,n,r,t[o+10],17,-42063),r=sr(r,i,s,n,t[o+11],22,-1990404162),n=sr(n,r,i,s,t[o+12],7,1804603682),s=sr(s,n,r,i,t[o+13],12,-40341101),i=sr(i,s,n,r,t[o+14],17,-1502002290),r=sr(r,i,s,n,t[o+15],22,1236535329),n=or(n,r,i,s,t[o+1],5,-165796510),s=or(s,n,r,i,t[o+6],9,-1069501632),i=or(i,s,n,r,t[o+11],14,643717713),r=or(r,i,s,n,t[o],20,-373897302),n=or(n,r,i,s,t[o+5],5,-701558691),s=or(s,n,r,i,t[o+10],9,38016083),i=or(i,s,n,r,t[o+15],14,-660478335),r=or(r,i,s,n,t[o+4],20,-405537848),n=or(n,r,i,s,t[o+9],5,568446438),s=or(s,n,r,i,t[o+14],9,-1019803690),i=or(i,s,n,r,t[o+3],14,-187363961),r=or(r,i,s,n,t[o+8],20,1163531501),n=or(n,r,i,s,t[o+13],5,-1444681467),s=or(s,n,r,i,t[o+2],9,-51403784),i=or(i,s,n,r,t[o+7],14,1735328473),r=or(r,i,s,n,t[o+12],20,-1926607734),n=ar(n,r,i,s,t[o+5],4,-378558),s=ar(s,n,r,i,t[o+8],11,-2022574463),i=ar(i,s,n,r,t[o+11],16,1839030562),r=ar(r,i,s,n,t[o+14],23,-35309556),n=ar(n,r,i,s,t[o+1],4,-1530992060),s=ar(s,n,r,i,t[o+4],11,1272893353),i=ar(i,s,n,r,t[o+7],16,-155497632),r=ar(r,i,s,n,t[o+10],23,-1094730640),n=ar(n,r,i,s,t[o+13],4,681279174),s=ar(s,n,r,i,t[o],11,-358537222),i=ar(i,s,n,r,t[o+3],16,-722521979),r=ar(r,i,s,n,t[o+6],23,76029189),n=ar(n,r,i,s,t[o+9],4,-640364487),s=ar(s,n,r,i,t[o+12],11,-421815835),i=ar(i,s,n,r,t[o+15],16,530742520),r=ar(r,i,s,n,t[o+2],23,-995338651),n=cr(n,r,i,s,t[o],6,-198630844),s=cr(s,n,r,i,t[o+7],10,1126891415),i=cr(i,s,n,r,t[o+14],15,-1416354905),r=cr(r,i,s,n,t[o+5],21,-57434055),n=cr(n,r,i,s,t[o+12],6,1700485571),s=cr(s,n,r,i,t[o+3],10,-1894986606),i=cr(i,s,n,r,t[o+10],15,-1051523),r=cr(r,i,s,n,t[o+1],21,-2054922799),n=cr(n,r,i,s,t[o+8],6,1873313359),s=cr(s,n,r,i,t[o+15],10,-30611744),i=cr(i,s,n,r,t[o+6],15,-1560198380),r=cr(r,i,s,n,t[o+13],21,1309151649),n=cr(n,r,i,s,t[o+4],6,-145523070),s=cr(s,n,r,i,t[o+11],10,-1120210379),i=cr(i,s,n,r,t[o+2],15,718787259),r=cr(r,i,s,n,t[o+9],21,-343485551),n=io(n,a),r=io(r,c),i=io(i,l),s=io(s,u)}return[n,r,i,s]}function M6(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(WS(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function io(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function k6(t,e){return t<<e|t>>>32-e}function Mf(t,e,n,r,i,s){return io(k6(io(io(e,t),io(r,s)),i),n)}function sr(t,e,n,r,i,s,o){return Mf(e&n|~e&r,t,e,i,s,o)}function or(t,e,n,r,i,s,o){return Mf(e&r|n&~r,t,e,i,s,o)}function ar(t,e,n,r,i,s,o){return Mf(e^n^r,t,e,i,s,o)}function cr(t,e,n,r,i,s,o){return Mf(n^(e|~r),t,e,i,s,o)}var D6=qS("v3",48,O6);function hs(t,e,n){t=t||{};var r=t.random||(t.rng||HS)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return Pf(r)}function L6(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function kh(t,e){return t<<e|t>>>32-e}function B6(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var s=t.length/4+2,o=Math.ceil(s/16),a=new Array(o),c=0;c<o;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=t[c*64+u*4]<<24|t[c*64+u*4+1]<<16|t[c*64+u*4+2]<<8|t[c*64+u*4+3];a[c]=l}a[o-1][14]=(t.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(t.length-1)*8&4294967295;for(var d=0;d<o;++d){for(var f=new Uint32Array(80),g=0;g<16;++g)f[g]=a[d][g];for(var v=16;v<80;++v)f[v]=kh(f[v-3]^f[v-8]^f[v-14]^f[v-16],1);for(var w=n[0],b=n[1],E=n[2],M=n[3],S=n[4],F=0;F<80;++F){var D=Math.floor(F/20),z=kh(w,5)+L6(D,b,E,M)+S+e[D]+f[F]>>>0;S=M,M=E,E=kh(b,30)>>>0,b=w,w=z}n[0]=n[0]+w>>>0,n[1]=n[1]+b>>>0,n[2]=n[2]+E>>>0,n[3]=n[3]+M>>>0,n[4]=n[4]+S>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var U6=qS("v5",80,B6);const $6="00000000-0000-0000-0000-000000000000";function F6(t){if(!Xa(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const K6=Object.freeze(Object.defineProperty({__proto__:null,NIL:$6,parse:zS,stringify:Pf,v1:R6,v3:D6,v4:hs,v5:U6,validate:Xa,version:F6},Symbol.toStringTag,{value:"Module"})),Ji=Object.create(null);Ji.open="0";Ji.close="1";Ji.ping="2";Ji.pong="3";Ji.message="4";Ji.upgrade="5";Ji.noop="6";const ed=Object.create(null);Object.keys(Ji).forEach(t=>{ed[Ji[t]]=t});const T0={type:"error",data:"parser error"},GS=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",YS=typeof ArrayBuffer=="function",JS=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,yg=({type:t,data:e},n,r)=>GS&&e instanceof Blob?n?r(e):gv(e,r):YS&&(e instanceof ArrayBuffer||JS(e))?n?r(e):gv(new Blob([e]),r):r(Ji[t]+(e||"")),gv=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function yv(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let Dh;function V6(t,e){if(GS&&t.data instanceof Blob)return t.data.arrayBuffer().then(yv).then(e);if(YS&&(t.data instanceof ArrayBuffer||JS(t.data)))return e(yv(t.data));yg(t,!1,n=>{Dh||(Dh=new TextEncoder),e(Dh.encode(n))})}const wv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qc=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<wv.length;t++)qc[wv.charCodeAt(t)]=t;const j6=t=>{let e=t.length*.75,n=t.length,r,i=0,s,o,a,c;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),u=new Uint8Array(l);for(r=0;r<n;r+=4)s=qc[t.charCodeAt(r)],o=qc[t.charCodeAt(r+1)],a=qc[t.charCodeAt(r+2)],c=qc[t.charCodeAt(r+3)],u[i++]=s<<2|o>>4,u[i++]=(o&15)<<4|a>>2,u[i++]=(a&3)<<6|c&63;return l},H6=typeof ArrayBuffer=="function",wg=(t,e)=>{if(typeof t!="string")return{type:"message",data:ZS(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:z6(t.substring(1),e)}:ed[n]?t.length>1?{type:ed[n],data:t.substring(1)}:{type:ed[n]}:T0},z6=(t,e)=>{if(H6){const n=j6(t);return ZS(n,e)}else return{base64:!0,data:t}},ZS=(t,e)=>e==="blob"?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,XS="",q6=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((s,o)=>{yg(s,!1,a=>{r[o]=a,++i===n&&e(r.join(XS))})})},W6=(t,e)=>{const n=t.split(XS),r=[];for(let i=0;i<n.length;i++){const s=wg(n[i],e);if(r.push(s),s.type==="error")break}return r};function G6(){return new TransformStream({transform(t,e){V6(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const s=new DataView(i.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{i=new Uint8Array(9);const s=new DataView(i.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let Lh;function pu(t){return t.reduce((e,n)=>e+n.length,0)}function mu(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Y6(t,e){Lh||(Lh=new TextDecoder);const n=[];let r=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(r===0){if(pu(n)<1)break;const c=mu(n,1);s=(c[0]&128)===128,i=c[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(pu(n)<2)break;const c=mu(n,2);i=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(pu(n)<8)break;const c=mu(n,8),l=new DataView(c.buffer,c.byteOffset,c.length),u=l.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue(T0);break}i=u*Math.pow(2,32)+l.getUint32(4),r=3}else{if(pu(n)<i)break;const c=mu(n,i);a.enqueue(wg(s?c:Lh.decode(c),e)),r=0}if(i===0||i>t){a.enqueue(T0);break}}}})}const QS=4;function Ln(t){if(t)return J6(t)}function J6(t){for(var e in Ln.prototype)t[e]=Ln.prototype[e];return t}Ln.prototype.on=Ln.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Ln.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};Ln.prototype.off=Ln.prototype.removeListener=Ln.prototype.removeAllListeners=Ln.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};Ln.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this};Ln.prototype.emitReserved=Ln.prototype.emit;Ln.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Ln.prototype.hasListeners=function(t){return!!this.listeners(t).length};const kf=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),ui=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Z6="arraybuffer";function ex(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const X6=ui.setTimeout,Q6=ui.clearTimeout;function Df(t,e){e.useNativeTimers?(t.setTimeoutFn=X6.bind(ui),t.clearTimeoutFn=Q6.bind(ui)):(t.setTimeoutFn=ui.setTimeout.bind(ui),t.clearTimeoutFn=ui.clearTimeout.bind(ui))}const eP=1.33;function tP(t){return typeof t=="string"?nP(t):Math.ceil((t.byteLength||t.size)*eP)}function nP(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function tx(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function rP(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function iP(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let s=n[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}class sP extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class vg extends Ln{constructor(e){super(),this.writable=!1,Df(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new sP(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=wg(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=rP(e);return n.length?"?"+n:""}}class oP extends vg{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};W6(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,q6(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=tx()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let nx=!1;try{nx=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const aP=nx;function cP(){}class lP extends oP{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class qi extends Ln{constructor(e,n,r){super(),this.createRequest=e,Df(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=ex(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=qi.requestsCount++,qi.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=cP,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete qi.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}qi.requestsCount=0;qi.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vv);else if(typeof addEventListener=="function"){const t="onpagehide"in ui?"pagehide":"unload";addEventListener(t,vv,!1)}}function vv(){for(let t in qi.requests)qi.requests.hasOwnProperty(t)&&qi.requests[t].abort()}const uP=(function(){const t=rx({xdomain:!1});return t&&t.responseType!==null})();class dP extends lP{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=uP&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new qi(rx,this.uri(),e)}}function rx(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||aP))return new XMLHttpRequest}catch{}if(!e)try{return new ui[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ix=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class fP extends vg{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=ix?{}:ex(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;yg(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}i&&kf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=tx()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const Bh=ui.WebSocket||ui.MozWebSocket;class hP extends fP{createSocket(e,n,r){return ix?new Bh(e,n,r):n?new Bh(e,n):new Bh(e)}doWrite(e,n){this.ws.send(n)}}class pP extends vg{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=Y6(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=G6();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const s=()=>{r.read().then(({done:a,value:c})=>{a||(this.onPacket(c),s())}).catch(a=>{})};s();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this._writer.write(r).then(()=>{i&&kf(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const mP={websocket:hP,webtransport:pP,polling:dP},gP=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,yP=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function C0(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=gP.exec(t||""),s={},o=14;for(;o--;)s[yP[o]]=i[o]||"";return n!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=wP(s,s.path),s.queryKey=vP(s,s.query),s}function wP(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function vP(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,s){i&&(n[i]=s)}),n}const O0=typeof addEventListener=="function"&&typeof removeEventListener=="function",td=[];O0&&addEventListener("offline",()=>{td.forEach(t=>t())},!1);class ao extends Ln{constructor(e,n){if(super(),this.binaryType=Z6,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=C0(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=C0(n.host).host);Df(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=iP(this.opts.query)),O0&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},td.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=QS,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&ao.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",ao.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=tP(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,kf(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const s={type:e,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(ao.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),O0&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=td.indexOf(this._offlineEventListener);r!==-1&&td.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}ao.protocol=QS;class EP extends ao{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;ao.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",d=>{if(!r)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;ao.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function s(){r||(r=!0,u(),n.close(),n=null)}const o=d=>{const f=new Error("probe error: "+d);f.transport=n.name,s(),this.emitReserved("upgradeError",f)};function a(){o("transport closed")}function c(){o("socket closed")}function l(d){n&&d.name!==n.name&&s()}const u=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};n.once("open",i),n.once("error",o),n.once("close",a),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let bP=class extends EP{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>mP[i]).filter(i=>!!i)),super(e,r)}};function _P(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=C0(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}const SP=typeof ArrayBuffer=="function",xP=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,sx=Object.prototype.toString,AP=typeof Blob=="function"||typeof Blob<"u"&&sx.call(Blob)==="[object BlobConstructor]",RP=typeof File=="function"||typeof File<"u"&&sx.call(File)==="[object FileConstructor]";function Eg(t){return SP&&(t instanceof ArrayBuffer||xP(t))||AP&&t instanceof Blob||RP&&t instanceof File}function nd(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(nd(t[n]))return!0;return!1}if(Eg(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return nd(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&nd(t[n]))return!0;return!1}function IP(t){const e=[],n=t.data,r=t;return r.data=N0(n,e),r.attachments=e.length,{packet:r,buffers:e}}function N0(t,e){if(!t)return t;if(Eg(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=N0(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=N0(t[r],e));return n}return t}function TP(t,e){return t.data=P0(t.data,e),delete t.attachments,t}function P0(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=P0(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=P0(t[n],e));return t}const ox=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],CP=5;var Mt;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(Mt||(Mt={}));class OP{constructor(e){this.replacer=e}encode(e){return(e.type===Mt.EVENT||e.type===Mt.ACK)&&nd(e)?this.encodeAsBinary({type:e.type===Mt.EVENT?Mt.BINARY_EVENT:Mt.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===Mt.BINARY_EVENT||e.type===Mt.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=IP(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class bg extends Ln{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===Mt.BINARY_EVENT;r||n.type===Mt.BINARY_ACK?(n.type=r?Mt.EVENT:Mt.ACK,this.reconstructor=new NP(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Eg(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(Mt[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Mt.BINARY_EVENT||r.type===Mt.BINARY_ACK){const s=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(s,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(n+1)==="/"){const s=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(s,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const s=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}r.id=Number(e.substring(s,n+1))}if(e.charAt(++n)){const s=this.tryParse(e.substr(n));if(bg.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case Mt.CONNECT:return Md(n);case Mt.DISCONNECT:return n===void 0;case Mt.CONNECT_ERROR:return typeof n=="string"||Md(n);case Mt.EVENT:case Mt.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&ox.indexOf(n[0])===-1);case Mt.ACK:case Mt.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class NP{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=TP(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function PP(t){return typeof t=="string"}const MP=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function kP(t){return t===void 0||MP(t)}function Md(t){return Object.prototype.toString.call(t)==="[object Object]"}function DP(t,e){switch(t){case Mt.CONNECT:return e===void 0||Md(e);case Mt.DISCONNECT:return e===void 0;case Mt.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&ox.indexOf(e[0])===-1);case Mt.ACK:return Array.isArray(e);case Mt.CONNECT_ERROR:return typeof e=="string"||Md(e);default:return!1}}function LP(t){return PP(t.nsp)&&kP(t.id)&&DP(t.type,t.data)}const BP=Object.freeze(Object.defineProperty({__proto__:null,Decoder:bg,Encoder:OP,get PacketType(){return Mt},isPacketValid:LP,protocol:CP},Symbol.toStringTag,{value:"Module"}));function Ei(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const UP=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ax extends Ln{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Ei(e,"open",this.onopen.bind(this)),Ei(e,"packet",this.onpacket.bind(this)),Ei(e,"error",this.onerror.bind(this)),Ei(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,i,s;if(UP.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:Mt.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const u=this.ids++,d=n.pop();this._registerAckCallback(u,d),o.id=u}const a=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,c=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!a||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(s),n.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...n){return new Promise((r,i)=>{const s=(o,a)=>o?i(o):r(a);s.withError=!0,n.push(s),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...s)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Mt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Mt.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Mt.EVENT:case Mt.BINARY_EVENT:this.onevent(e);break;case Mt.ACK:case Mt.BINARY_ACK:this.onack(e);break;case Mt.DISCONNECT:this.ondisconnect();break;case Mt.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:Mt.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Mt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function wc(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}wc.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};wc.prototype.reset=function(){this.attempts=0};wc.prototype.setMin=function(t){this.ms=t};wc.prototype.setMax=function(t){this.max=t};wc.prototype.setJitter=function(t){this.jitter=t};class M0 extends Ln{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Df(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new wc({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||BP;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new bP(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=Ei(n,"open",function(){r.onopen(),e&&e()}),s=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=Ei(n,"error",s);if(this._timeout!==!1){const a=this._timeout,c=this.setTimeoutFn(()=>{i(),s(new Error("timeout")),n.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Ei(e,"ping",this.onping.bind(this)),Ei(e,"data",this.ondata.bind(this)),Ei(e,"error",this.onerror.bind(this)),Ei(e,"close",this.onclose.bind(this)),Ei(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){kf(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new ax(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const kc={};function rd(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=_P(t,e.path||"/socket.io"),r=n.source,i=n.id,s=n.path,o=kc[i]&&s in kc[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let c;return a?c=new M0(r,e):(kc[i]||(kc[i]=new M0(r,e)),c=kc[i]),n.query&&!e.query&&(e.query=n.queryKey),c.socket(n.path,e)}Object.assign(rd,{Manager:M0,Socket:ax,io:rd,connect:rd});function _e(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(l){try{c(r.next(l))}catch(u){s(u)}}function a(l){try{c(r.throw(l))}catch(u){s(u)}}function c(l){var u;l.done?i(l.value):(u=l.value,u instanceof n?u:new n((function(d){d(u)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))}var Tr=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Bi=[],oi=[],$P=typeof Uint8Array<"u"?Uint8Array:Array,_g=!1;function cx(){_g=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)Bi[e]=t[e],oi[t.charCodeAt(e)]=e;oi[45]=62,oi[95]=63}function FP(t,e,n){for(var r,i,s=[],o=e;o<n;o+=3)r=(t[o]<<16)+(t[o+1]<<8)+t[o+2],s.push(Bi[(i=r)>>18&63]+Bi[i>>12&63]+Bi[i>>6&63]+Bi[63&i]);return s.join("")}function Ev(t){var e;_g||cx();for(var n=t.length,r=n%3,i="",s=[],o=16383,a=0,c=n-r;a<c;a+=o)s.push(FP(t,a,a+o>c?c:a+o));return r===1?(e=t[n-1],i+=Bi[e>>2],i+=Bi[e<<4&63],i+="=="):r===2&&(e=(t[n-2]<<8)+t[n-1],i+=Bi[e>>10],i+=Bi[e>>4&63],i+=Bi[e<<2&63],i+="="),s.push(i),s.join("")}function gu(t,e,n,r,i){var s,o,a=8*i-r-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,g=t[e+d];for(d+=f,s=g&(1<<-u)-1,g>>=-u,u+=a;u>0;s=256*s+t[e+d],d+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=256*o+t[e+d],d+=f,u-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:1/0*(g?-1:1);o+=Math.pow(2,r),s-=l}return(g?-1:1)*o*Math.pow(2,s-r)}function lx(t,e,n,r,i,s){var o,a,c,l=8*s-i-1,u=(1<<l)-1,d=u>>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=r?0:s-1,v=r?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=u?(a=0,o=u):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[n+g]=255&a,g+=v,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[n+g]=255&o,g+=v,o/=256,l-=8);t[n+g-v]|=128*w}var KP={}.toString,ux=Array.isArray||function(t){return KP.call(t)=="[object Array]"};Se.TYPED_ARRAY_SUPPORT=Tr.TYPED_ARRAY_SUPPORT===void 0||Tr.TYPED_ARRAY_SUPPORT;var VP=kd();function kd(){return Se.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function ws(t,e){if(kd()<e)throw new RangeError("Invalid typed array length");return Se.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Se.prototype:(t===null&&(t=new Se(e)),t.length=e),t}function Se(t,e,n){if(!(Se.TYPED_ARRAY_SUPPORT||this instanceof Se))return new Se(t,e,n);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return k0(this,t)}return dx(this,t,e,n)}function dx(t,e,n,r){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?(function(i,s,o,a){if(s.byteLength,o<0||s.byteLength<o)throw new RangeError("'offset' is out of bounds");if(s.byteLength<o+(a||0))throw new RangeError("'length' is out of bounds");return s=o===void 0&&a===void 0?new Uint8Array(s):a===void 0?new Uint8Array(s,o):new Uint8Array(s,o,a),Se.TYPED_ARRAY_SUPPORT?(i=s).__proto__=Se.prototype:i=Uh(i,s),i})(t,e,n,r):typeof e=="string"?(function(i,s,o){if(typeof o=="string"&&o!==""||(o="utf8"),!Se.isEncoding(o))throw new TypeError('"encoding" must be a valid string encoding');var a=0|hx(s,o);i=ws(i,a);var c=i.write(s,o);return c!==a&&(i=i.slice(0,c)),i})(t,e,n):(function(i,s){if(Ui(s)){var o=0|Sg(s.length);return(i=ws(i,o)).length===0||s.copy(i,0,0,o),i}if(s){if(typeof ArrayBuffer<"u"&&s.buffer instanceof ArrayBuffer||"length"in s)return typeof s.length!="number"||(a=s.length)!=a?ws(i,0):Uh(i,s);if(s.type==="Buffer"&&ux(s.data))return Uh(i,s.data)}var a;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")})(t,e)}function fx(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function k0(t,e){if(fx(e),t=ws(t,e<0?0:0|Sg(e)),!Se.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function Uh(t,e){var n=e.length<0?0:0|Sg(e.length);t=ws(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function Sg(t){if(t>=kd())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kd().toString(16)+" bytes");return 0|t}function Ui(t){return!(t==null||!t._isBuffer)}function hx(t,e){if(Ui(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var n=t.length;if(n===0)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Dd(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return yx(t).length;default:if(r)return Dd(t).length;e=(""+e).toLowerCase(),r=!0}}function jP(t,e,n){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return XP(this,e,n);case"utf8":case"utf-8":return mx(this,e,n);case"ascii":return JP(this,e,n);case"latin1":case"binary":return ZP(this,e,n);case"base64":return YP(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return QP(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function So(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function bv(t,e,n,r,i){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if(typeof e=="string"&&(e=Se.from(e,r)),Ui(e))return e.length===0?-1:_v(t,e,n,r,i);if(typeof e=="number")return e&=255,Se.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):_v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function _v(t,e,n,r,i){var s,o=1,a=t.length,c=e.length;if(r!==void 0&&((r=String(r).toLowerCase())==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function l(g,v){return o===1?g[v]:g.readUInt16BE(v*o)}if(i){var u=-1;for(s=n;s<a;s++)if(l(t,s)===l(e,u===-1?0:s-u)){if(u===-1&&(u=s),s-u+1===c)return u*o}else u!==-1&&(s-=s-u),u=-1}else for(n+c>a&&(n=a-c),s=n;s>=0;s--){for(var d=!0,f=0;f<c;f++)if(l(t,s+f)!==l(e,f)){d=!1;break}if(d)return s}return-1}function HP(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[n+o]=a}return o}function zP(t,e,n,r){return Lf(Dd(e,t.length-n),t,n,r)}function px(t,e,n,r){return Lf((function(i){for(var s=[],o=0;o<i.length;++o)s.push(255&i.charCodeAt(o));return s})(e),t,n,r)}function qP(t,e,n,r){return px(t,e,n,r)}function WP(t,e,n,r){return Lf(yx(e),t,n,r)}function GP(t,e,n,r){return Lf((function(i,s){for(var o,a,c,l=[],u=0;u<i.length&&!((s-=2)<0);++u)a=(o=i.charCodeAt(u))>>8,c=o%256,l.push(c),l.push(a);return l})(e,t.length-n),t,n,r)}function YP(t,e,n){return e===0&&n===t.length?Ev(t):Ev(t.slice(e,n))}function mx(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var s,o,a,c,l=t[i],u=null,d=l>239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:(192&(s=t[i+1]))==128&&(c=(31&l)<<6|63&s)>127&&(u=c);break;case 3:s=t[i+1],o=t[i+2],(192&s)==128&&(192&o)==128&&(c=(15&l)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],(192&s)==128&&(192&o)==128&&(192&a)==128&&(c=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(u=c)}u===null?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return(function(f){var g=f.length;if(g<=Sv)return String.fromCharCode.apply(String,f);for(var v="",w=0;w<g;)v+=String.fromCharCode.apply(String,f.slice(w,w+=Sv));return v})(r)}Se.poolSize=8192,Se._augment=function(t){return t.__proto__=Se.prototype,t},Se.from=function(t,e,n){return dx(null,t,e,n)},Se.TYPED_ARRAY_SUPPORT&&(Se.prototype.__proto__=Uint8Array.prototype,Se.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&Se[Symbol.species]),Se.alloc=function(t,e,n){return(function(r,i,s,o){return fx(i),i<=0?ws(r,i):s!==void 0?typeof o=="string"?ws(r,i).fill(s,o):ws(r,i).fill(s):ws(r,i)})(null,t,e,n)},Se.allocUnsafe=function(t){return k0(null,t)},Se.allocUnsafeSlow=function(t){return k0(null,t)},Se.isBuffer=wx,Se.compare=function(t,e){if(!Ui(t)||!Ui(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,s=Math.min(n,r);i<s;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},Se.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Se.concat=function(t,e){if(!ux(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return Se.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=Se.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var s=t[n];if(!Ui(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},Se.byteLength=hx,Se.prototype._isBuffer=!0,Se.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)So(this,e,e+1);return this},Se.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)So(this,e,e+3),So(this,e+1,e+2);return this},Se.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)So(this,e,e+7),So(this,e+1,e+6),So(this,e+2,e+5),So(this,e+3,e+4);return this},Se.prototype.toString=function(){var t=0|this.length;return t===0?"":arguments.length===0?mx(this,0,t):jP.apply(this,arguments)},Se.prototype.equals=function(t){if(!Ui(t))throw new TypeError("Argument must be a Buffer");return this===t||Se.compare(this,t)===0},Se.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Se.prototype.compare=function(t,e,n,r,i){if(!Ui(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0),a=Math.min(s,o),c=this.slice(r,i),l=t.slice(e,n),u=0;u<a;++u)if(c[u]!==l[u]){s=c[u],o=l[u];break}return s<o?-1:o<s?1:0},Se.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},Se.prototype.indexOf=function(t,e,n){return bv(this,t,e,n,!0)},Se.prototype.lastIndexOf=function(t,e,n){return bv(this,t,e,n,!1)},Se.prototype.write=function(t,e,n,r){if(e===void 0)r="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,r===void 0&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((n===void 0||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return HP(this,t,e,n);case"utf8":case"utf-8":return zP(this,t,e,n);case"ascii":return px(this,t,e,n);case"latin1":case"binary":return qP(this,t,e,n);case"base64":return WP(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return GP(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},Se.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Sv=4096;function JP(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function ZP(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function XP(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=e;s<n;++s)i+=t5(t[s]);return i}function QP(t,e,n){for(var r=t.slice(e,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function Kn(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function Or(t,e,n,r,i,s){if(!Ui(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function yu(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-n,2);i<s;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function wu(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-n,4);i<s;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function gx(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function xv(t,e,n,r,i){return i||gx(t,0,n,4),lx(t,e,n,r,23,4),n+4}function Av(t,e,n,r,i){return i||gx(t,0,n,8),lx(t,e,n,r,52,8),n+8}Se.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=e===void 0?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),Se.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=Se.prototype;else{var i=e-t;n=new Se(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+t]}return n},Se.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||Kn(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r},Se.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||Kn(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},Se.prototype.readUInt8=function(t,e){return e||Kn(t,1,this.length),this[t]},Se.prototype.readUInt16LE=function(t,e){return e||Kn(t,2,this.length),this[t]|this[t+1]<<8},Se.prototype.readUInt16BE=function(t,e){return e||Kn(t,2,this.length),this[t]<<8|this[t+1]},Se.prototype.readUInt32LE=function(t,e){return e||Kn(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Se.prototype.readUInt32BE=function(t,e){return e||Kn(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Se.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||Kn(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},Se.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||Kn(t,e,this.length);for(var r=e,i=1,s=this[t+--r];r>0&&(i*=256);)s+=this[t+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},Se.prototype.readInt8=function(t,e){return e||Kn(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Se.prototype.readInt16LE=function(t,e){e||Kn(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},Se.prototype.readInt16BE=function(t,e){e||Kn(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},Se.prototype.readInt32LE=function(t,e){return e||Kn(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Se.prototype.readInt32BE=function(t,e){return e||Kn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Se.prototype.readFloatLE=function(t,e){return e||Kn(t,4,this.length),gu(this,t,!0,23,4)},Se.prototype.readFloatBE=function(t,e){return e||Kn(t,4,this.length),gu(this,t,!1,23,4)},Se.prototype.readDoubleLE=function(t,e){return e||Kn(t,8,this.length),gu(this,t,!0,52,8)},Se.prototype.readDoubleBE=function(t,e){return e||Kn(t,8,this.length),gu(this,t,!1,52,8)},Se.prototype.writeUIntLE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Or(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[e]=255&t;++s<n&&(i*=256);)this[e+s]=t/i&255;return e+n},Se.prototype.writeUIntBE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Or(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n},Se.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,1,255,0),Se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Se.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,2,65535,0),Se.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yu(this,t,e,!0),e+2},Se.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,2,65535,0),Se.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yu(this,t,e,!1),e+2},Se.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,4,4294967295,0),Se.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):wu(this,t,e,!0),e+4},Se.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,4,4294967295,0),Se.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):wu(this,t,e,!1),e+4},Se.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Or(this,t,e,n,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<n&&(o*=256);)t<0&&a===0&&this[e+s-1]!==0&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+n},Se.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Or(this,t,e,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&a===0&&this[e+s+1]!==0&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+n},Se.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,1,127,-128),Se.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Se.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,2,32767,-32768),Se.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):yu(this,t,e,!0),e+2},Se.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,2,32767,-32768),Se.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):yu(this,t,e,!1),e+2},Se.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,4,2147483647,-2147483648),Se.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):wu(this,t,e,!0),e+4},Se.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||Or(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Se.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):wu(this,t,e,!1),e+4},Se.prototype.writeFloatLE=function(t,e,n){return xv(this,t,e,!0,n)},Se.prototype.writeFloatBE=function(t,e,n){return xv(this,t,e,!1,n)},Se.prototype.writeDoubleLE=function(t,e,n){return Av(this,t,e,!0,n)},Se.prototype.writeDoubleBE=function(t,e,n){return Av(this,t,e,!1,n)},Se.prototype.copy=function(t,e,n,r){if(n||(n=0),r||r===0||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,s=r-n;if(this===t&&n<e&&e<r)for(i=s-1;i>=0;--i)t[i+e]=this[i+n];else if(s<1e3||!Se.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+s),e);return s},Se.prototype.fill=function(t,e,n,r){if(typeof t=="string"){if(typeof e=="string"?(r=e,e=0,n=this.length):typeof n=="string"&&(r=n,n=this.length),t.length===1){var i=t.charCodeAt(0);i<256&&(t=i)}if(r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!Se.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else typeof t=="number"&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=n===void 0?this.length:n>>>0,t||(t=0),typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{var o=Ui(t)?t:Dd(new Se(t,r).toString()),a=o.length;for(s=0;s<n-e;++s)this[s+e]=o[s%a]}return this};var e5=/[^+\/0-9A-Za-z-_]/g;function t5(t){return t<16?"0"+t.toString(16):t.toString(16)}function Dd(t,e){var n;e=e||1/0;for(var r=t.length,i=null,s=[],o=0;o<r;++o){if((n=t.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function yx(t){return(function(e){var n,r,i,s,o,a;_g||cx();var c=e.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=e[c-2]==="="?2:e[c-1]==="="?1:0,a=new $P(3*c/4-o),i=o>0?c-4:c;var l=0;for(n=0,r=0;n<i;n+=4,r+=3)s=oi[e.charCodeAt(n)]<<18|oi[e.charCodeAt(n+1)]<<12|oi[e.charCodeAt(n+2)]<<6|oi[e.charCodeAt(n+3)],a[l++]=s>>16&255,a[l++]=s>>8&255,a[l++]=255&s;return o===2?(s=oi[e.charCodeAt(n)]<<2|oi[e.charCodeAt(n+1)]>>4,a[l++]=255&s):o===1&&(s=oi[e.charCodeAt(n)]<<10|oi[e.charCodeAt(n+1)]<<4|oi[e.charCodeAt(n+2)]>>2,a[l++]=s>>8&255,a[l++]=255&s),a})((function(e){if((e=(function(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")})(e).replace(e5,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e})(t))}function Lf(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function wx(t){return t!=null&&(!!t._isBuffer||Rv(t)||(function(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Rv(e.slice(0,0))})(t))}function Rv(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}var n5=Object.freeze({__proto__:null,Buffer:Se,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),Se.alloc(+t)},isBuffer:wx,kMaxLength:VP}),fi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Fl(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})})),n}var _a={},Xr={},mr={};function Ld(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function vx(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ex(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function xg(t,...e){if(!Ex(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function bx(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");Ld(t.outputLen),Ld(t.blockLen)}function _x(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Sx(t,e){xg(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(mr,"__esModule",{value:!0}),mr.isBytes=Ex,mr.number=Ld,mr.bool=vx,mr.bytes=xg,mr.hash=bx,mr.exists=_x,mr.output=Sx;const r5={number:Ld,bool:vx,bytes:xg,hash:bx,exists:_x,output:Sx};mr.default=r5,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.wrapCipher=t.Hash=t.nextTick=t.isLE=t.createView=t.u32=t.u16=t.u8=void 0,t.bytesToHex=r,t.hexToBytes=o,t.hexToNumber=a,t.bytesToNumberBE=function(d){return a(r(d))},t.numberToBytesBE=function(d,f){return o(d.toString(16).padStart(2*f,"0"))},t.asyncLoop=async function(d,f,g){let v=Date.now();for(let w=0;w<d;w++){g(w);const b=Date.now()-v;b>=0&&b<f||(await(0,t.nextTick)(),v+=b)}},t.utf8ToBytes=c,t.bytesToUtf8=function(d){return new TextDecoder().decode(d)},t.toBytes=function(d){if(typeof d=="string")d=c(d);else{if(!(0,e.isBytes)(d))throw new Error("Uint8Array expected, got "+typeof d);d=u(d)}return d},t.concatBytes=function(...d){let f=0;for(let v=0;v<d.length;v++){const w=d[v];(0,e.bytes)(w),f+=w.length}const g=new Uint8Array(f);for(let v=0,w=0;v<d.length;v++){const b=d[v];g.set(b,w),w+=b.length}return g},t.checkOpts=function(d,f){if(f==null||typeof f!="object")throw new Error("options must be defined");return Object.assign(d,f)},t.equalBytes=function(d,f){if(d.length!==f.length)return!1;let g=0;for(let v=0;v<d.length;v++)g|=d[v]^f[v];return g===0},t.setBigUint64=l,t.u64Lengths=function(d,f){const g=new Uint8Array(16),v=(0,t.createView)(g);return l(v,0,BigInt(f?f.length:0),!0),l(v,8,BigInt(d.length),!0),g},t.isAligned32=function(d){return d.byteOffset%4==0},t.copyBytes=u,t.clean=function(...d){for(let f=0;f<d.length;f++)d[f].fill(0)};const e=mr;if(t.u8=d=>new Uint8Array(d.buffer,d.byteOffset,d.byteLength),t.u16=d=>new Uint16Array(d.buffer,d.byteOffset,Math.floor(d.byteLength/2)),t.u32=d=>new Uint32Array(d.buffer,d.byteOffset,Math.floor(d.byteLength/4)),t.createView=d=>new DataView(d.buffer,d.byteOffset,d.byteLength),t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,!t.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((d,f)=>f.toString(16).padStart(2,"0")));function r(d){(0,e.bytes)(d);let f="";for(let g=0;g<d.length;g++)f+=n[d[g]];return f}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function s(d){return d>=i._0&&d<=i._9?d-i._0:d>=i._A&&d<=i._F?d-(i._A-10):d>=i._a&&d<=i._f?d-(i._a-10):void 0}function o(d){if(typeof d!="string")throw new Error("hex string expected, got "+typeof d);const f=d.length,g=f/2;if(f%2)throw new Error("padded hex string expected, got unpadded hex of length "+f);const v=new Uint8Array(g);for(let w=0,b=0;w<g;w++,b+=2){const E=s(d.charCodeAt(b)),M=s(d.charCodeAt(b+1));if(E===void 0||M===void 0){const S=d[b]+d[b+1];throw new Error('hex string expected, got non-hex character "'+S+'" at index '+b)}v[w]=16*E+M}return v}function a(d){if(typeof d!="string")throw new Error("hex string expected, got "+typeof d);return BigInt(d===""?"0":`0x${d}`)}function c(d){if(typeof d!="string")throw new Error("string expected, got "+typeof d);return new Uint8Array(new TextEncoder().encode(d))}t.nextTick=async()=>{},t.Hash=class{};function l(d,f,g,v){if(typeof d.setBigUint64=="function")return d.setBigUint64(f,g,v);const w=BigInt(32),b=BigInt(4294967295),E=Number(g>>w&b),M=Number(g&b),S=v?4:0,F=v?0:4;d.setUint32(f+S,E,v),d.setUint32(f+F,M,v)}function u(d){return Uint8Array.from(d)}t.wrapCipher=(d,f)=>(Object.assign(f,d),f)})(Xr);var yl={},Vn={};Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.AEAD_TAG_LENGTH=Vn.XCHACHA20_NONCE_LENGTH=Vn.CURVE25519_PUBLIC_KEY_SIZE=Vn.ETH_PUBLIC_KEY_SIZE=Vn.UNCOMPRESSED_PUBLIC_KEY_SIZE=Vn.COMPRESSED_PUBLIC_KEY_SIZE=Vn.SECRET_KEY_LENGTH=void 0,Vn.SECRET_KEY_LENGTH=32,Vn.COMPRESSED_PUBLIC_KEY_SIZE=33,Vn.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,Vn.ETH_PUBLIC_KEY_SIZE=64,Vn.CURVE25519_PUBLIC_KEY_SIZE=32,Vn.XCHACHA20_NONCE_LENGTH=24,Vn.AEAD_TAG_LENGTH=16,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ephemeralKeySize=t.symmetricNonceLength=t.symmetricAlgorithm=t.isHkdfKeyCompressed=t.isEphemeralKeyCompressed=t.ellipticCurve=t.ECIES_CONFIG=void 0;var e=Vn,n=function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16};t.ECIES_CONFIG=new n,t.ellipticCurve=function(){return t.ECIES_CONFIG.ellipticCurve},t.isEphemeralKeyCompressed=function(){return t.ECIES_CONFIG.isEphemeralKeyCompressed},t.isHkdfKeyCompressed=function(){return t.ECIES_CONFIG.isHkdfKeyCompressed},t.symmetricAlgorithm=function(){return t.ECIES_CONFIG.symmetricAlgorithm},t.symmetricNonceLength=function(){return t.ECIES_CONFIG.symmetricNonceLength},t.ephemeralKeySize=function(){var r={secp256k1:t.ECIES_CONFIG.isEphemeralKeyCompressed?e.COMPRESSED_PUBLIC_KEY_SIZE:e.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:e.CURVE25519_PUBLIC_KEY_SIZE,ed25519:e.CURVE25519_PUBLIC_KEY_SIZE};if(t.ECIES_CONFIG.ellipticCurve in r)return r[t.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}})(yl);var $h={},Bd={},Uf={},xx={},Ag={},vu={};Object.defineProperty(vu,"__esModule",{value:!0}),vu.crypto=void 0,vu.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.gcm=t.ctr=t.cbc=t.utils=void 0,t.randomBytes=i,t.getWebcryptoSubtle=s,t.managedNonce=function(c){return(0,n.number)(c.nonceLength),(l,...u)=>({encrypt(d,...f){const{nonceLength:g}=c,v=i(g),w=c(l,v,...u).encrypt(d,...f),b=(0,r.concatBytes)(v,w);return w.fill(0),b},decrypt(d,...f){const{nonceLength:g}=c,v=d.subarray(0,g),w=d.subarray(g);return c(l,v,...u).decrypt(w,...f)}})};const e=vu,n=mr,r=Xr;function i(c=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(c));if(e.crypto&&typeof e.crypto.randomBytes=="function")return e.crypto.randomBytes(c);throw new Error("crypto.getRandomValues must be defined")}function s(){if(e.crypto&&typeof e.crypto.subtle=="object"&&e.crypto.subtle!=null)return e.crypto.subtle;throw new Error("crypto.subtle must be defined")}t.utils={async encrypt(c,l,u,d){const f=s(),g=await f.importKey("raw",c,l,!0,["encrypt"]),v=await f.encrypt(u,g,d);return new Uint8Array(v)},async decrypt(c,l,u,d){const f=s(),g=await f.importKey("raw",c,l,!0,["decrypt"]),v=await f.decrypt(u,g,d);return new Uint8Array(v)}};const o={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(c){return(l,u,d)=>{(0,n.bytes)(l),(0,n.bytes)(u);const f={name:c,length:8*l.length},g=(function(v,w,b){if(v===o.CBC)return{name:o.CBC,iv:w};if(v===o.CTR)return{name:o.CTR,counter:w,length:64};if(v===o.GCM)return b?{name:o.GCM,iv:w,additionalData:b}:{name:o.GCM,iv:w};throw new Error("unknown aes block mode")})(c,u,d);return{encrypt:v=>((0,n.bytes)(v),t.utils.encrypt(l,f,g,v)),decrypt:v=>((0,n.bytes)(v),t.utils.decrypt(l,f,g,v))}}}t.cbc=a(o.CBC),t.ctr=a(o.CTR),t.gcm=a(o.GCM)})(Ag);var Ax={},Hn={},vs={},Wr={};function Ud(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Rx(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ix(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Rg(t,...e){if(!Ix(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Tx(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ud(t.outputLen),Ud(t.blockLen)}function Cx(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ox(t,e){Rg(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.isBytes=Ix,Wr.number=Ud,Wr.bool=Rx,Wr.bytes=Rg,Wr.hash=Tx,Wr.exists=Cx,Wr.output=Ox;const i5={number:Ud,bool:Rx,bytes:Rg,hash:Tx,exists:Cx,output:Ox};Wr.default=i5;var Cs={},Eu={};Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.crypto=void 0,Eu.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.byteSwap=t.isLE=t.rotl=t.rotr=t.createView=t.u32=t.u8=void 0,t.isBytes=function(l){return l instanceof Uint8Array||l!=null&&typeof l=="object"&&l.constructor.name==="Uint8Array"},t.byteSwap32=function(l){for(let u=0;u<l.length;u++)l[u]=(0,t.byteSwap)(l[u])},t.bytesToHex=function(l){(0,n.bytes)(l);let u="";for(let d=0;d<l.length;d++)u+=r[l[d]];return u},t.hexToBytes=function(l){if(typeof l!="string")throw new Error("hex string expected, got "+typeof l);const u=l.length,d=u/2;if(u%2)throw new Error("padded hex string expected, got unpadded hex of length "+u);const f=new Uint8Array(d);for(let g=0,v=0;g<d;g++,v+=2){const w=s(l.charCodeAt(v)),b=s(l.charCodeAt(v+1));if(w===void 0||b===void 0){const E=l[v]+l[v+1];throw new Error('hex string expected, got non-hex character "'+E+'" at index '+v)}f[g]=16*w+b}return f},t.asyncLoop=async function(l,u,d){let f=Date.now();for(let g=0;g<l;g++){d(g);const v=Date.now()-f;v>=0&&v<u||(await(0,t.nextTick)(),f+=v)}},t.utf8ToBytes=o,t.toBytes=a,t.concatBytes=function(...l){let u=0;for(let f=0;f<l.length;f++){const g=l[f];(0,n.bytes)(g),u+=g.length}const d=new Uint8Array(u);for(let f=0,g=0;f<l.length;f++){const v=l[f];d.set(v,g),g+=v.length}return d},t.checkOpts=function(l,u){if(u!==void 0&&c.call(u)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(l,u)},t.wrapConstructor=function(l){const u=f=>l().update(a(f)).digest(),d=l();return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=()=>l(),u},t.wrapConstructorWithOpts=function(l){const u=(f,g)=>l(g).update(a(f)).digest(),d=l({});return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=f=>l(f),u},t.wrapXOFConstructorWithOpts=function(l){const u=(f,g)=>l(g).update(a(f)).digest(),d=l({});return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=f=>l(f),u},t.randomBytes=function(l=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(l));if(e.crypto&&typeof e.crypto.randomBytes=="function")return e.crypto.randomBytes(l);throw new Error("crypto.getRandomValues must be defined")};const e=Eu,n=Wr;t.u8=l=>new Uint8Array(l.buffer,l.byteOffset,l.byteLength),t.u32=l=>new Uint32Array(l.buffer,l.byteOffset,Math.floor(l.byteLength/4)),t.createView=l=>new DataView(l.buffer,l.byteOffset,l.byteLength),t.rotr=(l,u)=>l<<32-u|l>>>u,t.rotl=(l,u)=>l<<u|l>>>32-u>>>0,t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,t.byteSwap=l=>l<<24&4278190080|l<<8&16711680|l>>>8&65280|l>>>24&255,t.byteSwapIfBE=t.isLE?l=>l:l=>(0,t.byteSwap)(l);const r=Array.from({length:256},((l,u)=>u.toString(16).padStart(2,"0"))),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function s(l){return l>=i._0&&l<=i._9?l-i._0:l>=i._A&&l<=i._F?l-(i._A-10):l>=i._a&&l<=i._f?l-(i._a-10):void 0}function o(l){if(typeof l!="string")throw new Error("utf8ToBytes expected string, got "+typeof l);return new Uint8Array(new TextEncoder().encode(l))}function a(l){return typeof l=="string"&&(l=o(l)),(0,n.bytes)(l),l}t.nextTick=async()=>{},t.Hash=class{clone(){return this._cloneInto()}};const c={}.toString})(Cs),Object.defineProperty(vs,"__esModule",{value:!0}),vs.HashMD=vs.Maj=vs.Chi=void 0;const Fh=Wr,Dc=Cs;vs.Chi=(t,e,n)=>t&e^~t&n;vs.Maj=(t,e,n)=>t&e^t&n^e&n;vs.HashMD=class extends Dc.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Dc.createView)(this.buffer)}update(t){(0,Fh.exists)(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=(0,Dc.toBytes)(t)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o!==r)n.set(t.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(e,0),this.pos=0);else{const a=(0,Dc.createView)(t);for(;r<=i-s;s+=r)this.process(a,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,Fh.exists)(this),(0,Fh.output)(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let u=s;u<r;u++)e[u]=0;(function(u,d,f,g){if(typeof u.setBigUint64=="function")return u.setBigUint64(d,f,g);const v=BigInt(32),w=BigInt(4294967295),b=Number(f>>v&w),E=Number(f&w),M=g?4:0,S=g?0:4;u.setUint32(d+M,b,g),u.setUint32(d+S,E,g)})(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=(0,Dc.createView)(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)o.setUint32(4*u,l[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return t.length=r,t.pos=o,t.finished=i,t.destroyed=s,r%e&&t.buffer.set(n),t}};var xt={};Object.defineProperty(xt,"__esModule",{value:!0}),xt.add5L=xt.add5H=xt.add4H=xt.add4L=xt.add3H=xt.add3L=xt.rotlBL=xt.rotlBH=xt.rotlSL=xt.rotlSH=xt.rotr32L=xt.rotr32H=xt.rotrBL=xt.rotrBH=xt.rotrSL=xt.rotrSH=xt.shrSL=xt.shrSH=xt.toBig=void 0,xt.fromBig=Ig,xt.split=Nx,xt.add=zx;const bu=BigInt(2**32-1),D0=BigInt(32);function Ig(t,e=!1){return e?{h:Number(t&bu),l:Number(t>>D0&bu)}:{h:0|Number(t>>D0&bu),l:0|Number(t&bu)}}function Nx(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=Ig(t[i],e);[n[i],r[i]]=[s,o]}return[n,r]}const Px=(t,e)=>BigInt(t>>>0)<<D0|BigInt(e>>>0);xt.toBig=Px;const Mx=(t,e,n)=>t>>>n;xt.shrSH=Mx;const kx=(t,e,n)=>t<<32-n|e>>>n;xt.shrSL=kx;const Dx=(t,e,n)=>t>>>n|e<<32-n;xt.rotrSH=Dx;const Lx=(t,e,n)=>t<<32-n|e>>>n;xt.rotrSL=Lx;const Bx=(t,e,n)=>t<<64-n|e>>>n-32;xt.rotrBH=Bx;const Ux=(t,e,n)=>t>>>n-32|e<<64-n;xt.rotrBL=Ux;const $x=(t,e)=>e;xt.rotr32H=$x;const Fx=(t,e)=>t;xt.rotr32L=Fx;const Kx=(t,e,n)=>t<<n|e>>>32-n;xt.rotlSH=Kx;const Vx=(t,e,n)=>e<<n|t>>>32-n;xt.rotlSL=Vx;const jx=(t,e,n)=>e<<n-32|t>>>64-n;xt.rotlBH=jx;const Hx=(t,e,n)=>t<<n-32|e>>>64-n;function zx(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}xt.rotlBL=Hx;const qx=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0);xt.add3L=qx;const Wx=(t,e,n,r)=>e+n+r+(t/2**32|0)|0;xt.add3H=Wx;const Gx=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0);xt.add4L=Gx;const Yx=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0;xt.add4H=Yx;const Jx=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0);xt.add5L=Jx;const Zx=(t,e,n,r,i,s)=>e+n+r+i+s+(t/2**32|0)|0;xt.add5H=Zx;const s5={fromBig:Ig,split:Nx,toBig:Px,shrSH:Mx,shrSL:kx,rotrSH:Dx,rotrSL:Lx,rotrBH:Bx,rotrBL:Ux,rotr32H:$x,rotr32L:Fx,rotlSH:Kx,rotlSL:Vx,rotlBH:jx,rotlBL:Hx,add:zx,add3L:qx,add3H:Wx,add4L:Gx,add4H:Yx,add5H:Zx,add5L:Jx};xt.default=s5,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.sha384=Hn.sha512_256=Hn.sha512_224=Hn.sha512=Hn.SHA384=Hn.SHA512_256=Hn.SHA512_224=Hn.SHA512=void 0;const o5=vs,Nt=xt,_u=Cs,[a5,c5]=Nt.default.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((t=>BigInt(t)))),Os=new Uint32Array(80),Ns=new Uint32Array(80);class Kl extends o5.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:e,Al:n,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:d,Fl:f,Gh:g,Gl:v,Hh:w,Hl:b}=this;return[e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b]}set(e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b){this.Ah=0|e,this.Al=0|n,this.Bh=0|r,this.Bl=0|i,this.Ch=0|s,this.Cl=0|o,this.Dh=0|a,this.Dl=0|c,this.Eh=0|l,this.El=0|u,this.Fh=0|d,this.Fl=0|f,this.Gh=0|g,this.Gl=0|v,this.Hh=0|w,this.Hl=0|b}process(e,n){for(let S=0;S<16;S++,n+=4)Os[S]=e.getUint32(n),Ns[S]=e.getUint32(n+=4);for(let S=16;S<80;S++){const F=0|Os[S-15],D=0|Ns[S-15],z=Nt.default.rotrSH(F,D,1)^Nt.default.rotrSH(F,D,8)^Nt.default.shrSH(F,D,7),X=Nt.default.rotrSL(F,D,1)^Nt.default.rotrSL(F,D,8)^Nt.default.shrSL(F,D,7),Y=0|Os[S-2],U=0|Ns[S-2],B=Nt.default.rotrSH(Y,U,19)^Nt.default.rotrBH(Y,U,61)^Nt.default.shrSH(Y,U,6),H=Nt.default.rotrSL(Y,U,19)^Nt.default.rotrBL(Y,U,61)^Nt.default.shrSL(Y,U,6),V=Nt.default.add4L(X,H,Ns[S-7],Ns[S-16]),T=Nt.default.add4H(V,z,B,Os[S-7],Os[S-16]);Os[S]=0|T,Ns[S]=0|V}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:f,Fh:g,Fl:v,Gh:w,Gl:b,Hh:E,Hl:M}=this;for(let S=0;S<80;S++){const F=Nt.default.rotrSH(d,f,14)^Nt.default.rotrSH(d,f,18)^Nt.default.rotrBH(d,f,41),D=Nt.default.rotrSL(d,f,14)^Nt.default.rotrSL(d,f,18)^Nt.default.rotrBL(d,f,41),z=d&g^~d&w,X=f&v^~f&b,Y=Nt.default.add5L(M,D,X,c5[S],Ns[S]),U=Nt.default.add5H(Y,E,F,z,a5[S],Os[S]),B=0|Y,H=Nt.default.rotrSH(r,i,28)^Nt.default.rotrBH(r,i,34)^Nt.default.rotrBH(r,i,39),V=Nt.default.rotrSL(r,i,28)^Nt.default.rotrBL(r,i,34)^Nt.default.rotrBL(r,i,39),T=r&s^r&a^s&a,p=i&o^i&c^o&c;E=0|w,M=0|b,w=0|g,b=0|v,g=0|d,v=0|f,{h:d,l:f}=Nt.default.add(0|l,0|u,0|U,0|B),l=0|a,u=0|c,a=0|s,c=0|o,s=0|r,o=0|i;const y=Nt.default.add3L(B,V,p);r=Nt.default.add3H(y,U,H,T),i=0|y}({h:r,l:i}=Nt.default.add(0|this.Ah,0|this.Al,0|r,0|i)),{h:s,l:o}=Nt.default.add(0|this.Bh,0|this.Bl,0|s,0|o),{h:a,l:c}=Nt.default.add(0|this.Ch,0|this.Cl,0|a,0|c),{h:l,l:u}=Nt.default.add(0|this.Dh,0|this.Dl,0|l,0|u),{h:d,l:f}=Nt.default.add(0|this.Eh,0|this.El,0|d,0|f),{h:g,l:v}=Nt.default.add(0|this.Fh,0|this.Fl,0|g,0|v),{h:w,l:b}=Nt.default.add(0|this.Gh,0|this.Gl,0|w,0|b),{h:E,l:M}=Nt.default.add(0|this.Hh,0|this.Hl,0|E,0|M),this.set(r,i,s,o,a,c,l,u,d,f,g,v,w,b,E,M)}roundClean(){Os.fill(0),Ns.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)}}Hn.SHA512=Kl;class Xx extends Kl{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}Hn.SHA512_224=Xx;class Qx extends Kl{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}Hn.SHA512_256=Qx;class Iv extends Kl{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}Hn.SHA384=Iv,Hn.sha512=(0,_u.wrapConstructor)((()=>new Kl)),Hn.sha512_224=(0,_u.wrapConstructor)((()=>new Xx)),Hn.sha512_256=(0,_u.wrapConstructor)((()=>new Qx)),Hn.sha384=(0,_u.wrapConstructor)((()=>new Iv));var L0={},Ca={},Xt={},Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.notImplemented=Bt.bitMask=void 0,Bt.isBytes=$d,Bt.abytes=Fd,Bt.abool=function(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)},Bt.bytesToHex=Kh,Bt.numberToHexUnpadded=Tv,Bt.hexToNumber=Vh,Bt.hexToBytes=sd,Bt.bytesToNumberBE=function(t){return Vh(Kh(t))},Bt.bytesToNumberLE=function(t){return Fd(t),Vh(Kh(Uint8Array.from(t).reverse()))},Bt.numberToBytesBE=Ov,Bt.numberToBytesLE=function(t,e){return Ov(t,e).reverse()},Bt.numberToVarBytesBE=function(t){return sd(Tv(t))},Bt.ensureBytes=function(t,e,n){let r;if(typeof e=="string")try{r=sd(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else{if(!$d(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r},Bt.concatBytes=Nv,Bt.equalBytes=function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0},Bt.utf8ToBytes=function(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))},Bt.inRange=Pv,Bt.aInRange=function(t,e,n,r){if(!Pv(e,n,r))throw new Error(`expected valid ${t}: ${n} <= n < ${r}, got ${typeof e} ${e}`)},Bt.bitLen=function(t){let e;for(e=0;t>B0;t>>=id,e+=1);return e},Bt.bitGet=function(t,e){return t>>BigInt(e)&id},Bt.bitSet=function(t,e,n){return t|(n?id:B0)<<BigInt(e)},Bt.createHmacDrbg=function(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Hh(t),i=Hh(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...u)=>n(i,r,...u),c=(u=Hh())=>{i=a(Mv([0]),u),r=a(),u.length!==0&&(i=a(Mv([1]),u),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){r=a();const f=r.slice();d.push(f),u+=r.length}return Nv(...d)};return(u,d)=>{let f;for(o(),c(u);!(f=d(l()));)c();return o(),f}},Bt.validateObject=function(t,e,n={}){const r=(i,s,o)=>{const a=d5[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const c=t[i];if(!(o&&c===void 0||a(c,t)))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return t},Bt.memoized=function(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const s=t(n,...r);return e.set(n,s),s}};const B0=BigInt(0),id=BigInt(1),l5=BigInt(2);function $d(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Fd(t){if(!$d(t))throw new Error("Uint8Array expected")}const u5=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Kh(t){Fd(t);let e="";for(let n=0;n<t.length;n++)e+=u5[t[n]];return e}function Tv(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Vh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}const ns={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Cv(t){return t>=ns._0&&t<=ns._9?t-ns._0:t>=ns._A&&t<=ns._F?t-(ns._A-10):t>=ns._a&&t<=ns._f?t-(ns._a-10):void 0}function sd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,s=0;i<n;i++,s+=2){const o=Cv(t.charCodeAt(s)),a=Cv(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[i]=16*o+a}return r}function Ov(t,e){return sd(t.toString(16).padStart(2*e,"0"))}function Nv(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];Fd(i),e+=i.length}const n=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const s=t[r];n.set(s,i),i+=s.length}return n}const jh=t=>typeof t=="bigint"&&B0<=t;function Pv(t,e,n){return jh(t)&&jh(e)&&jh(n)&&e<=t&&t<n}Bt.bitMask=t=>(l5<<BigInt(t-1))-id;const Hh=t=>new Uint8Array(t),Mv=t=>Uint8Array.from(t),d5={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||$d(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};Bt.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.isNegativeLE=void 0,Xt.mod=zr,Xt.pow=e2,Xt.pow2=function(t,e,n){let r=t;for(;e-- >qn;)r*=r,r%=n;return r},Xt.invert=Su,Xt.tonelliShanks=t2,Xt.FpSqrt=Lv,Xt.validateField=function(t){const e=h5.reduce(((n,r)=>(n[r]="function",n)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,Vr.validateObject)(t,e)},Xt.FpPow=Bv,Xt.FpInvertBatch=Uv,Xt.FpDiv=function(t,e,n){return t.mul(e,typeof n=="bigint"?Su(n,t.ORDER):t.inv(n))},Xt.FpLegendre=$v,Xt.FpIsSquare=function(t){const e=$v(t.ORDER);return n=>{const r=e(t,n);return t.eql(r,t.ZERO)||t.eql(r,t.ONE)}},Xt.nLength=zh,Xt.Field=function(t,e,n=!1,r={}){if(t<=qn)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=zh(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Lv(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Vr.bitMask)(i),ZERO:qn,ONE:on,create:c=>zr(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("Invalid field element: expected bigint, got "+typeof c);return qn<=c&&c<t},is0:c=>c===qn,isOdd:c=>(c&on)===on,neg:c=>zr(-c,t),eql:(c,l)=>c===l,sqr:c=>zr(c*c,t),add:(c,l)=>zr(c+l,t),sub:(c,l)=>zr(c-l,t),mul:(c,l)=>zr(c*l,t),pow:(c,l)=>Bv(a,c,l),div:(c,l)=>zr(c*Su(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Su(c,t),sqrt:r.sqrt||(c=>o(a,c)),invertBatch:c=>Uv(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>n?(0,Vr.numberToBytesLE)(c,s):(0,Vr.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return n?(0,Vr.bytesToNumberLE)(c):(0,Vr.bytesToNumberBE)(c)}});return Object.freeze(a)},Xt.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const n=t.sqrt(e);return t.isOdd(n)?n:t.neg(n)},Xt.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const n=t.sqrt(e);return t.isOdd(n)?t.neg(n):n},Xt.hashToPrivateScalar=function(t,e,n=!1){t=(0,Vr.ensureBytes)("privateHash",t);const r=t.length,i=zh(e).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);const s=n?(0,Vr.bytesToNumberLE)(t):(0,Vr.bytesToNumberBE)(t);return zr(s,e-on)+on},Xt.getFieldBytesLength=$0,Xt.getMinHashLength=Fv,Xt.mapHashToField=function(t,e,n=!1){const r=t.length,i=$0(e),s=Fv(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=zr(n?(0,Vr.bytesToNumberBE)(t):(0,Vr.bytesToNumberLE)(t),e-on)+on;return n?(0,Vr.numberToBytesLE)(o,i):(0,Vr.numberToBytesBE)(o,i)};const Vr=Bt,qn=BigInt(0),on=BigInt(1),to=BigInt(2),f5=BigInt(3),U0=BigInt(4),kv=BigInt(5),Dv=BigInt(8);function zr(t,e){const n=t%e;return n>=qn?n:e+n}function e2(t,e,n){if(n<=qn||e<qn)throw new Error("Expected power/modulo > 0");if(n===on)return qn;let r=on;for(;e>qn;)e&on&&(r=r*t%n),t=t*t%n,e>>=on;return r}function Su(t,e){if(t===qn||e<=qn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=zr(t,e),r=e,i=qn,s=on;for(;n!==qn;){const o=r%n,a=i-s*(r/n);r=n,n=o,i=s,s=a}if(r!==on)throw new Error("invert: does not exist");return zr(i,e)}function t2(t){const e=(t-on)/to;let n,r,i;for(n=t-on,r=0;n%to===qn;n/=to,r++);for(i=to;i<t&&e2(i,e,t)!==t-on;i++);if(r===1){const o=(t+on)/U0;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const s=(n+on)/to;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=r,l=o.pow(o.mul(o.ONE,i),n),u=o.pow(a,s),d=o.pow(a,n);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let f=1;for(let v=o.sqr(d);f<c&&!o.eql(v,o.ONE);f++)v=o.sqr(v);const g=o.pow(l,on<<BigInt(c-f-1));l=o.sqr(g),u=o.mul(u,g),d=o.mul(d,l),c=f}return u}}function Lv(t){if(t%U0===f5){const e=(t+on)/U0;return function(n,r){const i=n.pow(r,e);if(!n.eql(n.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%Dv===kv){const e=(t-kv)/Dv;return function(n,r){const i=n.mul(r,to),s=n.pow(i,e),o=n.mul(r,s),a=n.mul(n.mul(o,to),s),c=n.mul(o,n.sub(a,n.ONE));if(!n.eql(n.sqr(c),r))throw new Error("Cannot find square root");return c}}return t2(t)}BigInt(9),BigInt(16);Xt.isNegativeLE=(t,e)=>(zr(t,e)&on)===on;const h5=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bv(t,e,n){if(n<qn)throw new Error("Expected power > 0");if(n===qn)return t.ONE;if(n===on)return e;let r=t.ONE,i=e;for(;n>qn;)n&on&&(r=t.mul(r,i)),i=t.sqr(i),n>>=on;return r}function Uv(t,e){const n=new Array(e.length),r=e.reduce(((s,o,a)=>t.is0(o)?s:(n[a]=s,t.mul(s,o))),t.ONE),i=t.inv(r);return e.reduceRight(((s,o,a)=>t.is0(o)?s:(n[a]=t.mul(s,n[a]),t.mul(s,o))),i),n}function $v(t){const e=(t-on)/to;return(n,r)=>n.pow(r,e)}function zh(t,e){const n=e!==void 0?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function $0(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Fv(t){const e=$0(t);return e+Math.ceil(e/2)}Object.defineProperty(Ca,"__esModule",{value:!0}),Ca.wNAF=function(t,e){const n=(s,o)=>{const a=o.negate();return s?a:o},r=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>(r(s),{windows:Math.ceil(e/s)+1,windowSize:2**(s-1)});return{constTimeNegate:n,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>p5;)o&qh&&(a=a.add(c)),c=c.double(),o>>=qh;return a},precomputeWindow(s,o){const{windows:a,windowSize:c}=i(o),l=[];let u=s,d=u;for(let f=0;f<a;f++){d=u,l.push(d);for(let g=1;g<c;g++)d=d.add(u),l.push(d);u=d.double()}return l},wNAF(s,o,a){const{windows:c,windowSize:l}=i(s);let u=t.ZERO,d=t.BASE;const f=BigInt(2**s-1),g=2**s,v=BigInt(s);for(let w=0;w<c;w++){const b=w*l;let E=Number(a&f);a>>=v,E>l&&(E-=g,a+=qh);const M=b,S=b+Math.abs(E)-1,F=w%2!=0,D=E<0;E===0?d=d.add(n(F,o[M])):u=u.add(n(D,o[S]))}return{p:u,f:d}},wNAFCached(s,o,a){const c=jv.get(s)||1;let l=Wh.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&Wh.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){r(o),jv.set(s,o),Wh.delete(s)}}},Ca.pippenger=function(t,e,n,r){if(!Array.isArray(n)||!Array.isArray(r)||r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");r.forEach(((u,d)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${d}`)})),n.forEach(((u,d)=>{if(!(u instanceof t))throw new Error(`wrong point at index ${d}`)}));const i=(0,Vv.bitLen)(BigInt(n.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s;let l=t.ZERO;for(let u=c;u>=0;u-=s){a.fill(t.ZERO);for(let f=0;f<r.length;f++){const g=r[f],v=Number(g>>BigInt(u)&BigInt(o));a[v]=a[v].add(n[f])}let d=t.ZERO;for(let f=a.length-1,g=t.ZERO;f>0;f--)g=g.add(a[f]),d=d.add(g);if(l=l.add(d),u!==0)for(let f=0;f<s;f++)l=l.double()}return l},Ca.validateBasic=function(t){return(0,Kv.validateField)(t.Fp),(0,Vv.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Kv.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const Kv=Xt,Vv=Bt,p5=BigInt(0),qh=BigInt(1),Wh=new WeakMap,jv=new WeakMap;Object.defineProperty(L0,"__esModule",{value:!0}),L0.twistedEdwards=function(t){const e=(function(T){const p=(0,Gh.validateBasic)(T);return Nr.validateObject(T,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...p})})(t),{Fp:n,n:r,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,l=xu<<BigInt(8*a)-Pr,u=n.create,d=(0,Hv.Field)(e.n,e.nBitLength),f=e.uvRatio||((T,p)=>{try{return{isValid:!0,value:n.sqrt(T*n.inv(p))}}catch{return{isValid:!1,value:mi}}}),g=e.adjustScalarBytes||(T=>T),v=e.domain||((T,p,y)=>{if((0,jr.abool)("phflag",y),p.length||y)throw new Error("Contexts/pre-hash are not supported");return T});function w(T,p){Nr.aInRange("coordinate "+T,p,mi,l)}function b(T){if(!(T instanceof S))throw new Error("ExtendedPoint expected")}const E=(0,jr.memoized)(((T,p)=>{const{ex:y,ey:R,ez:P}=T,_=T.is0();p==null&&(p=_?m5:n.inv(P));const I=u(y*p),N=u(R*p),x=u(P*p);if(_)return{x:mi,y:Pr};if(x!==Pr)throw new Error("invZ was invalid");return{x:I,y:N}})),M=(0,jr.memoized)((T=>{const{a:p,d:y}=e;if(T.is0())throw new Error("bad point: ZERO");const{ex:R,ey:P,ez:_,et:I}=T,N=u(R*R),x=u(P*P),h=u(_*_),m=u(h*h),A=u(N*p);if(u(h*u(A+x))!==u(m+u(y*u(N*x))))throw new Error("bad point: equation left != right (1)");if(u(R*P)!==u(_*I))throw new Error("bad point: equation left != right (2)");return!0}));class S{constructor(p,y,R,P){this.ex=p,this.ey=y,this.ez=R,this.et=P,w("x",p),w("y",y),w("z",R),w("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof S)throw new Error("extended point not allowed");const{x:y,y:R}=p||{};return w("x",y),w("y",R),new S(y,R,Pr,u(y*R))}static normalizeZ(p){const y=n.invertBatch(p.map((R=>R.ez)));return p.map(((R,P)=>R.toAffine(y[P]))).map(S.fromAffine)}static msm(p,y){return(0,Gh.pippenger)(S,d,p,y)}_setWindowSize(p){z.setWindowSize(this,p)}assertValidity(){M(this)}equals(p){b(p);const{ex:y,ey:R,ez:P}=this,{ex:_,ey:I,ez:N}=p,x=u(y*N),h=u(_*P),m=u(R*N),A=u(I*P);return x===h&&m===A}is0(){return this.equals(S.ZERO)}negate(){return new S(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:p}=e,{ex:y,ey:R,ez:P}=this,_=u(y*y),I=u(R*R),N=u(xu*u(P*P)),x=u(p*_),h=y+R,m=u(u(h*h)-_-I),A=x+I,C=A-N,$=x-I,j=u(m*C),Z=u(A*$),ne=u(m*$),se=u(C*A);return new S(j,Z,se,ne)}add(p){b(p);const{a:y,d:R}=e,{ex:P,ey:_,ez:I,et:N}=this,{ex:x,ey:h,ez:m,et:A}=p;if(y===BigInt(-1)){const Oe=u((_-P)*(h+x)),Le=u((_+P)*(h-x)),je=u(Le-Oe);if(je===mi)return this.double();const $e=u(I*xu*A),Je=u(N*xu*m),He=Je+$e,Ke=Le+Oe,Ge=Je-$e,Dt=u(He*je),_t=u(Ke*Ge),q=u(He*Ge),k=u(je*Ke);return new S(Dt,_t,k,q)}const C=u(P*x),$=u(_*h),j=u(N*R*A),Z=u(I*m),ne=u((P+_)*(x+h)-C-$),se=Z-j,ue=Z+j,de=u($-y*C),Ae=u(ne*se),Ce=u(ue*de),Ue=u(ne*de),Be=u(se*ue);return new S(Ae,Ce,Be,Ue)}subtract(p){return this.add(p.negate())}wNAF(p){return z.wNAFCached(this,p,S.normalizeZ)}multiply(p){const y=p;Nr.aInRange("scalar",y,Pr,r);const{p:R,f:P}=this.wNAF(y);return S.normalizeZ([R,P])[0]}multiplyUnsafe(p){const y=p;return Nr.aInRange("scalar",y,mi,r),y===mi?D:this.equals(D)||y===Pr?this:this.equals(F)?this.wNAF(y).p:z.unsafeLadder(this,y)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return z.unsafeLadder(this,r).is0()}toAffine(p){return E(this,p)}clearCofactor(){const{h:p}=e;return p===Pr?this:this.multiplyUnsafe(p)}static fromHex(p,y=!1){const{d:R,a:P}=e,_=n.BYTES;p=(0,jr.ensureBytes)("pointHex",p,_),(0,jr.abool)("zip215",y);const I=p.slice(),N=p[_-1];I[_-1]=-129&N;const x=Nr.bytesToNumberLE(I),h=y?l:n.ORDER;Nr.aInRange("pointHex.y",x,mi,h);const m=u(x*x),A=u(m-Pr),C=u(R*m-P);let{isValid:$,value:j}=f(A,C);if(!$)throw new Error("Point.fromHex: invalid y coordinate");const Z=(j&Pr)===Pr,ne=(128&N)!=0;if(!y&&j===mi&&ne)throw new Error("Point.fromHex: x=0 and x_0=1");return ne!==Z&&(j=u(-j)),S.fromAffine({x:j,y:x})}static fromPrivateKey(p){return U(p).point}toRawBytes(){const{x:p,y}=this.toAffine(),R=Nr.numberToBytesLE(y,n.BYTES);return R[R.length-1]|=p&Pr?128:0,R}toHex(){return Nr.bytesToHex(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Pr,u(e.Gx*e.Gy)),S.ZERO=new S(mi,Pr,Pr,mi);const{BASE:F,ZERO:D}=S,z=(0,Gh.wNAF)(S,8*a);function X(T){return(0,Hv.mod)(T,r)}function Y(T){return X(Nr.bytesToNumberLE(T))}function U(T){const p=a;T=(0,jr.ensureBytes)("private key",T,p);const y=(0,jr.ensureBytes)("hashed private key",s(T),2*p),R=g(y.slice(0,p)),P=y.slice(p,2*p),_=Y(R),I=F.multiply(_),N=I.toRawBytes();return{head:R,prefix:P,scalar:_,point:I,pointBytes:N}}function B(T=new Uint8Array,...p){const y=Nr.concatBytes(...p);return Y(s(v(y,(0,jr.ensureBytes)("context",T),!!i)))}const H=g5;return F._setWindowSize(8),{CURVE:e,getPublicKey:function(T){return U(T).pointBytes},sign:function(T,p,y={}){T=(0,jr.ensureBytes)("message",T),i&&(T=i(T));const{prefix:R,scalar:P,pointBytes:_}=U(p),I=B(y.context,R,T),N=F.multiply(I).toRawBytes(),x=X(I+B(y.context,N,_,T)*P);Nr.aInRange("signature.s",x,mi,r);const h=Nr.concatBytes(N,Nr.numberToBytesLE(x,n.BYTES));return(0,jr.ensureBytes)("result",h,2*a)},verify:function(T,p,y,R=H){const{context:P,zip215:_}=R,I=n.BYTES;T=(0,jr.ensureBytes)("signature",T,2*I),p=(0,jr.ensureBytes)("message",p),_!==void 0&&(0,jr.abool)("zip215",_),i&&(p=i(p));const N=Nr.bytesToNumberLE(T.slice(I,2*I));let x,h,m;try{x=S.fromHex(y,_),h=S.fromHex(T.slice(0,I),_),m=F.multiplyUnsafe(N)}catch{return!1}if(!_&&x.isSmallOrder())return!1;const A=B(P,h.toRawBytes(),x.toRawBytes(),p);return h.add(x.multiplyUnsafe(A)).subtract(m).clearCofactor().equals(S.ZERO)},ExtendedPoint:S,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>o(n.BYTES),precompute:(T=8,p=S.BASE)=>(p._setWindowSize(T),p.multiply(BigInt(3)),p)}}};const Gh=Ca,Hv=Xt,Nr=Bt,jr=Bt,mi=BigInt(0),Pr=BigInt(1),xu=BigInt(2),m5=BigInt(8),g5={zip215:!0};var Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.expand_message_xmd=n2,Js.expand_message_xof=r2,Js.hash_to_field=Yh,Js.isogenyMap=function(t,e){const n=e.map((r=>Array.from(r).reverse()));return(r,i)=>{const[s,o,a,c]=n.map((l=>l.reduce(((u,d)=>t.add(t.mul(u,r),d)))));return r=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:r,y:i}}},Js.createHasher=function(t,e,n){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const s=Yh(r,2,{...n,DST:n.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const s=Yh(r,1,{...n,DST:n.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const s of r)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);const i=t.fromAffine(e(r)).clearCofactor();return i.assertValidity(),i}}};const y5=Xt,pr=Bt,w5=pr.bytesToNumberBE;function Zs(t,e){if(wl(t),wl(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const n=Array.from({length:e}).fill(0);for(let r=e-1;r>=0;r--)n[r]=255&t,t>>>=8;return new Uint8Array(n)}function v5(t,e){const n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[r]^e[r];return n}function wl(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function n2(t,e,n,r){(0,pr.abytes)(t),(0,pr.abytes)(e),wl(n),e.length>255&&(e=r((0,pr.concatBytes)((0,pr.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:s}=r,o=Math.ceil(n/i);if(n>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=(0,pr.concatBytes)(e,Zs(e.length,1)),c=Zs(0,s),l=Zs(n,2),u=new Array(o),d=r((0,pr.concatBytes)(c,t,l,Zs(0,1),a));u[0]=r((0,pr.concatBytes)(d,Zs(1,1),a));for(let f=1;f<=o;f++){const g=[v5(d,u[f-1]),Zs(f+1,1),a];u[f]=r((0,pr.concatBytes)(...g))}return(0,pr.concatBytes)(...u).slice(0,n)}function r2(t,e,n,r,i){if((0,pr.abytes)(t),(0,pr.abytes)(e),wl(n),e.length>255){const s=Math.ceil(2*r/8);e=i.create({dkLen:s}).update((0,pr.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(n>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(t).update(Zs(n,2)).update(e).update(Zs(e.length,1)).digest()}function Yh(t,e,n){(0,pr.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:s,hash:o,expand:a,DST:c}=n;(0,pr.abytes)(t),wl(e);const l=typeof c=="string"?(0,pr.utf8ToBytes)(c):c,u=r.toString(2).length,d=Math.ceil((u+i)/8),f=e*s*d;let g;if(a==="xmd")g=n2(t,l,f,o);else if(a==="xof")g=r2(t,l,f,i,o);else{if(a!=="_internal_pass")throw new Error('expand must be "xmd" or "xof"');g=t}const v=new Array(e);for(let w=0;w<e;w++){const b=new Array(s);for(let E=0;E<s;E++){const M=d*(E+w*s),S=g.subarray(M,M+d);b[E]=(0,y5.mod)(w5(S),r)}v[w]=b}return v}var F0={};Object.defineProperty(F0,"__esModule",{value:!0}),F0.montgomery=function(t){const e=(function(w){return(0,Ps.validateObject)(w,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...w})})(t),{P:n}=e,r=w=>(0,zv.mod)(w,n),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>(0,zv.pow)(w,n-BigInt(2),n));function l(w,b,E){const M=r(w*(b-E));return[b=r(b-M),E=r(E+M)]}const u=(e.a-BigInt(2))/BigInt(4);function d(w){return(0,Ps.numberToBytesLE)(r(w),s)}function f(w,b){const E=(function(F){const D=(0,Ps.ensureBytes)("u coordinate",F,s);return o===32&&(D[31]&=127),(0,Ps.bytesToNumberLE)(D)})(b),M=(function(F){const D=(0,Ps.ensureBytes)("scalar",F),z=D.length;if(z!==s&&z!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${z}`);return(0,Ps.bytesToNumberLE)(a(D))})(w),S=(function(F,D){(0,Ps.aInRange)("u",F,ha,n),(0,Ps.aInRange)("scalar",D,ha,n);const z=D,X=F;let Y,U=Jh,B=ha,H=F,V=Jh,T=ha;for(let y=BigInt(i-1);y>=ha;y--){const R=z>>y&Jh;T^=R,Y=l(T,U,H),U=Y[0],H=Y[1],Y=l(T,B,V),B=Y[0],V=Y[1],T=R;const P=U+B,_=r(P*P),I=U-B,N=r(I*I),x=_-N,h=H+V,m=r((H-V)*P),A=r(h*I),C=m+A,$=m-A;H=r(C*C),V=r(X*r($*$)),U=r(_*N),B=r(x*(_+r(u*x)))}Y=l(T,U,H),U=Y[0],H=Y[1],Y=l(T,B,V),B=Y[0],V=Y[1];const p=c(B);return r(U*p)})(E,M);if(S===ha)throw new Error("Invalid private or public key received");return d(S)}const g=d(e.Gu);function v(w){return f(w,g)}return{scalarMult:f,scalarMultBase:v,getSharedSecret:(w,b)=>f(w,b),getPublicKey:w=>v(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:g}};const zv=Xt,Ps=Bt,ha=BigInt(0),Jh=BigInt(1);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hash_to_ristretto255=t.hashToRistretto255=t.RistrettoPoint=t.encodeToCurve=t.hashToCurve=t.edwardsToMontgomery=t.x25519=t.ed25519ph=t.ed25519ctx=t.ed25519=t.ED25519_TORSION_SUBGROUP=void 0,t.edwardsToMontgomeryPub=z,t.edwardsToMontgomeryPriv=function(A){const C=F.hash(A.subarray(0,32));return F.adjustScalarBytes(C).subarray(0,32)};const e=Hn,n=Cs,r=L0,i=Js,s=Xt,o=F0,a=Bt,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),u=BigInt(0),d=BigInt(1),f=BigInt(2),g=BigInt(3),v=BigInt(5),w=BigInt(8);function b(A){const C=BigInt(10),$=BigInt(20),j=BigInt(40),Z=BigInt(80),ne=c,se=A*A%ne*A%ne,ue=(0,s.pow2)(se,f,ne)*se%ne,de=(0,s.pow2)(ue,d,ne)*A%ne,Ae=(0,s.pow2)(de,v,ne)*de%ne,Ce=(0,s.pow2)(Ae,C,ne)*Ae%ne,Ue=(0,s.pow2)(Ce,$,ne)*Ce%ne,Be=(0,s.pow2)(Ue,j,ne)*Ue%ne,Oe=(0,s.pow2)(Be,Z,ne)*Be%ne,Le=(0,s.pow2)(Oe,Z,ne)*Be%ne,je=(0,s.pow2)(Le,C,ne)*Ae%ne;return{pow_p_5_8:(0,s.pow2)(je,f,ne)*A%ne,b2:se}}function E(A){return A[0]&=248,A[31]&=127,A[31]|=64,A}function M(A,C){const $=c,j=(0,s.mod)(C*C*C,$),Z=b(A*(0,s.mod)(j*j*C,$)).pow_p_5_8;let ne=(0,s.mod)(A*j*Z,$);const se=(0,s.mod)(C*ne*ne,$),ue=ne,de=(0,s.mod)(ne*l,$),Ae=se===A,Ce=se===(0,s.mod)(-A,$),Ue=se===(0,s.mod)(-A*l,$);return Ae&&(ne=ue),(Ce||Ue)&&(ne=de),(0,s.isNegativeLE)(ne,$)&&(ne=(0,s.mod)(-ne,$)),{isValid:Ae||Ce,value:ne}}t.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const S=(0,s.Field)(c,void 0,!0),F={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:S,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:w,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:e.sha512,randomBytes:n.randomBytes,adjustScalarBytes:E,uvRatio:M};function D(A,C,$){if(C.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([$?1:0,C.length]),C,A)}function z(A){const{y:C}=t.ed25519.ExtendedPoint.fromHex(A),$=BigInt(1);return S.toBytes(S.create(($+C)*S.inv($-C)))}t.ed25519=(0,r.twistedEdwards)(F),t.ed25519ctx=(0,r.twistedEdwards)({...F,domain:D}),t.ed25519ph=(0,r.twistedEdwards)(Object.assign({},F,{domain:D,prehash:e.sha512})),t.x25519=(0,o.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:A=>{const C=c,{pow_p_5_8:$,b2:j}=b(A);return(0,s.mod)((0,s.pow2)($,g,C)*j,C)},adjustScalarBytes:E,randomBytes:n.randomBytes}),t.edwardsToMontgomery=z;const X=(S.ORDER+g)/w,Y=S.pow(f,X),U=S.sqrt(S.neg(S.ONE)),B=(0,s.FpSqrtEven)(S,S.neg(BigInt(486664)));function H(A){const{xMn:C,xMd:$,yMn:j,yMd:Z}=(function(Be){const Oe=(S.ORDER-v)/w,Le=BigInt(486662);let je=S.sqr(Be);je=S.mul(je,f);let $e=S.add(je,S.ONE),Je=S.neg(Le),He=S.sqr($e),Ke=S.mul(He,$e),Ge=S.mul(je,Le);Ge=S.mul(Ge,Je),Ge=S.add(Ge,He),Ge=S.mul(Ge,Je);let Dt=S.sqr(Ke);He=S.sqr(Dt),Dt=S.mul(Dt,Ke),Dt=S.mul(Dt,Ge),He=S.mul(He,Dt);let _t=S.pow(He,Oe);_t=S.mul(_t,Dt);let q=S.mul(_t,U);He=S.sqr(_t),He=S.mul(He,Ke);let k=S.eql(He,Ge),L=S.cmov(q,_t,k),Q=S.mul(Je,je),oe=S.mul(_t,Be);oe=S.mul(oe,Y);let le=S.mul(oe,U),we=S.mul(Ge,je);He=S.sqr(oe),He=S.mul(He,Ke);let wt=S.eql(He,we),ut=S.cmov(le,oe,wt);He=S.sqr(L),He=S.mul(He,Ke);let at=S.eql(He,Ge),Gt=S.cmov(Q,Je,at),ot=S.cmov(ut,L,at),tn=S.isOdd(ot);return ot=S.cmov(ot,S.neg(ot),at!==tn),{xMn:Gt,xMd:$e,yMn:ot,yMd:d}})(A);let ne=S.mul(C,Z);ne=S.mul(ne,B);let se=S.mul($,j),ue=S.sub(C,$),de=S.add(C,$),Ae=S.mul(se,de),Ce=S.eql(Ae,S.ZERO);ne=S.cmov(ne,S.ZERO,Ce),se=S.cmov(se,S.ONE,Ce),ue=S.cmov(ue,S.ONE,Ce),de=S.cmov(de,S.ONE,Ce);const Ue=S.invertBatch([se,de]);return{x:S.mul(ne,Ue[0]),y:S.mul(ue,Ue[1])}}const V=(0,i.createHasher)(t.ed25519.ExtendedPoint,(A=>H(A[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:S.ORDER,m:1,k:128,expand:"xmd",hash:e.sha512});function T(A){if(!(A instanceof m))throw new Error("RistrettoPoint expected")}t.hashToCurve=V.hashToCurve,t.encodeToCurve=V.encodeToCurve;const p=l,y=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),R=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),P=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),_=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),I=A=>M(d,A),N=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),x=A=>t.ed25519.CURVE.Fp.create((0,a.bytesToNumberLE)(A)&N);function h(A){const{d:C}=t.ed25519.CURVE,$=t.ed25519.CURVE.Fp.ORDER,j=t.ed25519.CURVE.Fp.create,Z=j(p*A*A),ne=j((Z+d)*P);let se=BigInt(-1);const ue=j((se-C*Z)*j(Z+C));let{isValid:de,value:Ae}=M(ne,ue),Ce=j(Ae*A);(0,s.isNegativeLE)(Ce,$)||(Ce=j(-Ce)),de||(Ae=Ce),de||(se=Z);const Ue=j(se*(Z-d)*_-ue),Be=Ae*Ae,Oe=j((Ae+Ae)*ue),Le=j(Ue*y),je=j(d-Be),$e=j(d+Be);return new t.ed25519.ExtendedPoint(j(Oe*$e),j(je*Le),j(Le*$e),j(Oe*je))}class m{constructor(C){this.ep=C}static fromAffine(C){return new m(t.ed25519.ExtendedPoint.fromAffine(C))}static hashToCurve(C){C=(0,a.ensureBytes)("ristrettoHash",C,64);const $=h(x(C.slice(0,32))),j=h(x(C.slice(32,64)));return new m($.add(j))}static fromHex(C){C=(0,a.ensureBytes)("ristrettoHex",C,32);const{a:$,d:j}=t.ed25519.CURVE,Z=t.ed25519.CURVE.Fp.ORDER,ne=t.ed25519.CURVE.Fp.create,se="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",ue=x(C);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(ue,32),C)||(0,s.isNegativeLE)(ue,Z))throw new Error(se);const de=ne(ue*ue),Ae=ne(d+$*de),Ce=ne(d-$*de),Ue=ne(Ae*Ae),Be=ne(Ce*Ce),Oe=ne($*j*Ue-Be),{isValid:Le,value:je}=I(ne(Oe*Be)),$e=ne(je*Ce),Je=ne(je*$e*Oe);let He=ne((ue+ue)*$e);(0,s.isNegativeLE)(He,Z)&&(He=ne(-He));const Ke=ne(Ae*Je),Ge=ne(He*Ke);if(!Le||(0,s.isNegativeLE)(Ge,Z)||Ke===u)throw new Error(se);return new m(new t.ed25519.ExtendedPoint(He,Ke,d,Ge))}toRawBytes(){let{ex:C,ey:$,ez:j,et:Z}=this.ep;const ne=t.ed25519.CURVE.Fp.ORDER,se=t.ed25519.CURVE.Fp.create,ue=se(se(j+$)*se(j-$)),de=se(C*$),Ae=se(de*de),{value:Ce}=I(se(ue*Ae)),Ue=se(Ce*ue),Be=se(Ce*de),Oe=se(Ue*Be*Z);let Le;if((0,s.isNegativeLE)(Z*Oe,ne)){let $e=se($*p),Je=se(C*p);C=$e,$=Je,Le=se(Ue*R)}else Le=Be;(0,s.isNegativeLE)(C*Oe,ne)&&($=se(-$));let je=se((j-$)*Le);return(0,s.isNegativeLE)(je,ne)&&(je=se(-je)),(0,a.numberToBytesLE)(je,32)}toHex(){return(0,a.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(C){T(C);const{ex:$,ey:j}=this.ep,{ex:Z,ey:ne}=C.ep,se=t.ed25519.CURVE.Fp.create,ue=se($*ne)===se(j*Z),de=se(j*ne)===se($*Z);return ue||de}add(C){return T(C),new m(this.ep.add(C.ep))}subtract(C){return T(C),new m(this.ep.subtract(C.ep))}multiply(C){return new m(this.ep.multiply(C))}multiplyUnsafe(C){return new m(this.ep.multiplyUnsafe(C))}double(){return new m(this.ep.double())}negate(){return new m(this.ep.negate())}}t.RistrettoPoint=(m.BASE||(m.BASE=new m(t.ed25519.ExtendedPoint.BASE)),m.ZERO||(m.ZERO=new m(t.ed25519.ExtendedPoint.ZERO)),m),t.hashToRistretto255=(A,C)=>{const $=C.DST,j=typeof $=="string"?(0,n.utf8ToBytes)($):$,Z=(0,i.expand_message_xmd)(A,j,64,e.sha512);return m.hashToCurve(Z)},t.hash_to_ristretto255=t.hashToRistretto255})(Ax);var i2={},Es={};Object.defineProperty(Es,"__esModule",{value:!0}),Es.sha224=Es.sha256=Es.SHA256=void 0;const Zh=vs,ii=Cs,E5=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]),Ms=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ks=new Uint32Array(64);class Tg extends Zh.HashMD{constructor(){super(64,32,8,!1),this.A=0|Ms[0],this.B=0|Ms[1],this.C=0|Ms[2],this.D=0|Ms[3],this.E=0|Ms[4],this.F=0|Ms[5],this.G=0|Ms[6],this.H=0|Ms[7]}get(){const{A:e,B:n,C:r,D:i,E:s,F:o,G:a,H:c}=this;return[e,n,r,i,s,o,a,c]}set(e,n,r,i,s,o,a,c){this.A=0|e,this.B=0|n,this.C=0|r,this.D=0|i,this.E=0|s,this.F=0|o,this.G=0|a,this.H=0|c}process(e,n){for(let d=0;d<16;d++,n+=4)ks[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const f=ks[d-15],g=ks[d-2],v=(0,ii.rotr)(f,7)^(0,ii.rotr)(f,18)^f>>>3,w=(0,ii.rotr)(g,17)^(0,ii.rotr)(g,19)^g>>>10;ks[d]=w+ks[d-7]+v+ks[d-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const f=u+((0,ii.rotr)(a,6)^(0,ii.rotr)(a,11)^(0,ii.rotr)(a,25))+(0,Zh.Chi)(a,c,l)+E5[d]+ks[d]|0,g=((0,ii.rotr)(r,2)^(0,ii.rotr)(r,13)^(0,ii.rotr)(r,22))+(0,Zh.Maj)(r,i,s)|0;u=l,l=c,c=a,a=o+f|0,o=s,s=i,i=r,r=f+g|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,s,o,a,c,l,u)}roundClean(){ks.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Es.SHA256=Tg;class b5 extends Tg{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Es.sha256=(0,ii.wrapConstructor)((()=>new Tg)),Es.sha224=(0,ii.wrapConstructor)((()=>new b5));var od={},Cg={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const e=Wr,n=Cs;class r extends n.Hash{constructor(s,o){super(),this.finished=!1,this.destroyed=!1,(0,e.hash)(s);const a=(0,n.toBytes)(o);if(this.iHash=s.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 c=this.blockLen,l=new Uint8Array(c);l.set(a.length>c?s.create().update(a).digest():a);for(let u=0;u<l.length;u++)l[u]^=54;this.iHash.update(l),this.oHash=s.create();for(let u=0;u<l.length;u++)l[u]^=106;this.oHash.update(l),l.fill(0)}update(s){return(0,e.exists)(this),this.iHash.update(s),this}digestInto(s){(0,e.exists)(this),(0,e.bytes)(s,this.outputLen),this.finished=!0,this.iHash.digestInto(s),this.oHash.update(s),this.oHash.digestInto(s),this.destroy()}digest(){const s=new Uint8Array(this.oHash.outputLen);return this.digestInto(s),s}_cloneInto(s){s||(s=Object.create(Object.getPrototypeOf(this),{}));const{oHash:o,iHash:a,finished:c,destroyed:l,blockLen:u,outputLen:d}=this;return s.finished=c,s.destroyed=l,s.blockLen=u,s.outputLen=d,s.oHash=o._cloneInto(s.oHash),s.iHash=a._cloneInto(s.iHash),s}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=r,t.hmac=(i,s,o)=>new r(i,s).update(o).digest(),t.hmac.create=(i,s)=>new r(i,s)})(Cg);var Og={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DER=void 0,t.weierstrassPoints=g,t.weierstrass=function(w){const b=(function(A){const C=(0,e.validateBasic)(A);return r.validateObject(C,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...C})})(w),{Fp:E,n:M}=b,S=E.BYTES+1,F=2*E.BYTES+1;function D(A){return n.mod(A,M)}function z(A){return n.invert(A,M)}const{ProjectivePoint:X,normPrivateKeyToScalar:Y,weierstrassEquation:U,isWithinCurveOrder:B}=g({...b,toBytes(A,C,$){const j=C.toAffine(),Z=E.toBytes(j.x),ne=r.concatBytes;return(0,i.abool)("isCompressed",$),$?ne(Uint8Array.from([C.hasEvenY()?2:3]),Z):ne(Uint8Array.from([4]),Z,E.toBytes(j.y))},fromBytes(A){const C=A.length,$=A[0],j=A.subarray(1);if(C!==S||$!==2&&$!==3){if(C===F&&$===4)return{x:E.fromBytes(j.subarray(0,E.BYTES)),y:E.fromBytes(j.subarray(E.BYTES,2*E.BYTES))};throw new Error(`Point of length ${C} was invalid. Expected ${S} compressed bytes or ${F} uncompressed bytes`)}{const Z=r.bytesToNumberBE(j);if(!r.inRange(Z,l,E.ORDER))throw new Error("Point is not on curve");const ne=U(Z);let se;try{se=E.sqrt(ne)}catch(ue){const de=ue instanceof Error?": "+ue.message:"";throw new Error("Point is not on curve"+de)}return(1&$)==1!=((se&l)===l)&&(se=E.neg(se)),{x:Z,y:se}}}}),H=A=>r.bytesToHex(r.numberToBytesBE(A,b.nByteLength));function V(A){return A>M>>l}const T=(A,C,$)=>r.bytesToNumberBE(A.slice(C,$));class p{constructor(C,$,j){this.r=C,this.s=$,this.recovery=j,this.assertValidity()}static fromCompact(C){const $=b.nByteLength;return C=(0,i.ensureBytes)("compactSignature",C,2*$),new p(T(C,0,$),T(C,$,2*$))}static fromDER(C){const{r:$,s:j}=t.DER.toSig((0,i.ensureBytes)("DER",C));return new p($,j)}assertValidity(){r.aInRange("r",this.r,l,M),r.aInRange("s",this.s,l,M)}addRecoveryBit(C){return new p(this.r,this.s,C)}recoverPublicKey(C){const{r:$,s:j,recovery:Z}=this,ne=_((0,i.ensureBytes)("msgHash",C));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const se=Z===2||Z===3?$+b.n:$;if(se>=E.ORDER)throw new Error("recovery id 2 or 3 invalid");const ue=(1&Z)==0?"02":"03",de=X.fromHex(ue+H(se)),Ae=z(se),Ce=D(-ne*Ae),Ue=D(j*Ae),Be=X.BASE.multiplyAndAddUnsafe(de,Ce,Ue);if(!Be)throw new Error("point at infinify");return Be.assertValidity(),Be}hasHighS(){return V(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,D(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return t.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return H(this.r)+H(this.s)}}const y={isValidPrivateKey(A){try{return Y(A),!0}catch{return!1}},normPrivateKeyToScalar:Y,randomPrivateKey:()=>{const A=n.getMinHashLength(b.n);return n.mapHashToField(b.randomBytes(A),b.n)},precompute:(A=8,C=X.BASE)=>(C._setWindowSize(A),C.multiply(BigInt(3)),C)};function R(A){const C=r.isBytes(A),$=typeof A=="string",j=(C||$)&&A.length;return C?j===S||j===F:$?j===2*S||j===2*F:A instanceof X}const P=b.bits2int||function(A){const C=r.bytesToNumberBE(A),$=8*A.length-b.nBitLength;return $>0?C>>BigInt($):C},_=b.bits2int_modN||function(A){return D(P(A))},I=r.bitMask(b.nBitLength);function N(A){return r.aInRange(`num < 2^${b.nBitLength}`,A,c,I),r.numberToBytesBE(A,b.nByteLength)}function x(A,C,$=h){if(["recovered","canonical"].some((Oe=>Oe in $)))throw new Error("sign() legacy options not supported");const{hash:j,randomBytes:Z}=b;let{lowS:ne,prehash:se,extraEntropy:ue}=$;ne==null&&(ne=!0),A=(0,i.ensureBytes)("msgHash",A),s($),se&&(A=(0,i.ensureBytes)("prehashed msgHash",j(A)));const de=_(A),Ae=Y(C),Ce=[N(Ae),N(de)];if(ue!=null&&ue!==!1){const Oe=ue===!0?Z(E.BYTES):ue;Ce.push((0,i.ensureBytes)("extraEntropy",Oe))}const Ue=r.concatBytes(...Ce),Be=de;return{seed:Ue,k2sig:function(Oe){const Le=P(Oe);if(!B(Le))return;const je=z(Le),$e=X.BASE.multiply(Le).toAffine(),Je=D($e.x);if(Je===c)return;const He=D(je*D(Be+Je*Ae));if(He===c)return;let Ke=($e.x===Je?0:2)|Number($e.y&l),Ge=He;return ne&&V(He)&&(Ge=(function(Dt){return V(Dt)?D(-Dt):Dt})(He),Ke^=1),new p(Je,Ge,Ke)}}}const h={lowS:b.lowS,prehash:!1},m={lowS:b.lowS,prehash:!1};return X.BASE._setWindowSize(8),{CURVE:b,getPublicKey:function(A,C=!0){return X.fromPrivateKey(A).toRawBytes(C)},getSharedSecret:function(A,C,$=!0){if(R(A))throw new Error("first arg must be private key");if(!R(C))throw new Error("second arg must be public key");return X.fromHex(C).multiply(Y(A)).toRawBytes($)},sign:function(A,C,$=h){const{seed:j,k2sig:Z}=x(A,C,$),ne=b;return r.createHmacDrbg(ne.hash.outputLen,ne.nByteLength,ne.hmac)(j,Z)},verify:function(A,C,$,j=m){const Z=A;if(C=(0,i.ensureBytes)("msgHash",C),$=(0,i.ensureBytes)("publicKey",$),"strict"in j)throw new Error("options.strict was renamed to lowS");s(j);const{lowS:ne,prehash:se}=j;let ue,de;try{if(typeof Z=="string"||r.isBytes(Z))try{ue=p.fromDER(Z)}catch(Je){if(!(Je instanceof t.DER.Err))throw Je;ue=p.fromCompact(Z)}else{if(typeof Z!="object"||typeof Z.r!="bigint"||typeof Z.s!="bigint")throw new Error("PARSE");{const{r:Je,s:He}=Z;ue=new p(Je,He)}}de=X.fromHex($)}catch(Je){if(Je.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ne&&ue.hasHighS())return!1;se&&(C=b.hash(C));const{r:Ae,s:Ce}=ue,Ue=_(C),Be=z(Ce),Oe=D(Ue*Be),Le=D(Ae*Be),je=X.BASE.multiplyAndAddUnsafe(de,Oe,Le)?.toAffine();return je?D(je.x)===Ae:!1},ProjectivePoint:X,Signature:p,utils:y}},t.SWUFpSqrtRatio=v,t.mapToCurveSimpleSWU=function(w,b){if(n.validateField(w),!w.isValid(b.A)||!w.isValid(b.B)||!w.isValid(b.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const E=v(w,b.Z);if(!w.isOdd)throw new Error("Fp.isOdd is not implemented!");return M=>{let S,F,D,z,X,Y,U,B;S=w.sqr(M),S=w.mul(S,b.Z),F=w.sqr(S),F=w.add(F,S),D=w.add(F,w.ONE),D=w.mul(D,b.B),z=w.cmov(b.Z,w.neg(F),!w.eql(F,w.ZERO)),z=w.mul(z,b.A),F=w.sqr(D),Y=w.sqr(z),X=w.mul(Y,b.A),F=w.add(F,X),F=w.mul(F,D),Y=w.mul(Y,z),X=w.mul(Y,b.B),F=w.add(F,X),U=w.mul(S,D);const{isValid:H,value:V}=E(F,Y);B=w.mul(S,M),B=w.mul(B,V),U=w.cmov(U,D,H),B=w.cmov(B,V,H);const T=w.isOdd(M)===w.isOdd(B);return B=w.cmov(w.neg(B),B,T),U=w.div(U,z),{x:U,y:B}}};const e=Ca,n=Xt,r=Bt,i=Bt;function s(w){w.lowS!==void 0&&(0,i.abool)("lowS",w.lowS),w.prehash!==void 0&&(0,i.abool)("prehash",w.prehash)}const{bytesToNumberBE:o,hexToBytes:a}=r;t.DER={Err:class extends Error{constructor(w=""){super(w)}},_tlv:{encode:(w,b)=>{const{Err:E}=t.DER;if(w<0||w>256)throw new E("tlv.encode: wrong tag");if(1&b.length)throw new E("tlv.encode: unpadded data");const M=b.length/2,S=r.numberToHexUnpadded(M);if(S.length/2&128)throw new E("tlv.encode: long form length too big");const F=M>127?r.numberToHexUnpadded(S.length/2|128):"";return`${r.numberToHexUnpadded(w)}${F}${S}${b}`},decode(w,b){const{Err:E}=t.DER;let M=0;if(w<0||w>256)throw new E("tlv.encode: wrong tag");if(b.length<2||b[M++]!==w)throw new E("tlv.decode: wrong tlv");const S=b[M++];let F=0;if(128&S){const z=127&S;if(!z)throw new E("tlv.decode(long): indefinite length not supported");if(z>4)throw new E("tlv.decode(long): byte length is too big");const X=b.subarray(M,M+z);if(X.length!==z)throw new E("tlv.decode: length bytes not complete");if(X[0]===0)throw new E("tlv.decode(long): zero leftmost byte");for(const Y of X)F=F<<8|Y;if(M+=z,F<128)throw new E("tlv.decode(long): not minimal encoding")}else F=S;const D=b.subarray(M,M+F);if(D.length!==F)throw new E("tlv.decode: wrong value length");return{v:D,l:b.subarray(M+F)}}},_int:{encode(w){const{Err:b}=t.DER;if(w<c)throw new b("integer: negative integers are not allowed");let E=r.numberToHexUnpadded(w);if(8&Number.parseInt(E[0],16)&&(E="00"+E),1&E.length)throw new b("unexpected assertion");return E},decode(w){const{Err:b}=t.DER;if(128&w[0])throw new b("Invalid signature integer: negative");if(w[0]===0&&!(128&w[1]))throw new b("Invalid signature integer: unnecessary leading zero");return o(w)}},toSig(w){const{Err:b,_int:E,_tlv:M}=t.DER,S=typeof w=="string"?a(w):w;r.abytes(S);const{v:F,l:D}=M.decode(48,S);if(D.length)throw new b("Invalid signature: left bytes after parsing");const{v:z,l:X}=M.decode(2,F),{v:Y,l:U}=M.decode(2,X);if(U.length)throw new b("Invalid signature: left bytes after parsing");return{r:E.decode(z),s:E.decode(Y)}},hexFromSig(w){const{_tlv:b,_int:E}=t.DER,M=`${b.encode(2,E.encode(w.r))}${b.encode(2,E.encode(w.s))}`;return b.encode(48,M)}};const c=BigInt(0),l=BigInt(1),u=BigInt(2),d=BigInt(3),f=BigInt(4);function g(w){const b=(function(T){const p=(0,e.validateBasic)(T);r.validateObject(p,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:y,Fp:R,a:P}=p;if(y){if(!R.eql(P,R.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof y!="object"||typeof y.beta!="bigint"||typeof y.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...p})})(w),{Fp:E}=b,M=n.Field(b.n,b.nBitLength),S=b.toBytes||((T,p,y)=>{const R=p.toAffine();return r.concatBytes(Uint8Array.from([4]),E.toBytes(R.x),E.toBytes(R.y))}),F=b.fromBytes||(T=>{const p=T.subarray(1);return{x:E.fromBytes(p.subarray(0,E.BYTES)),y:E.fromBytes(p.subarray(E.BYTES,2*E.BYTES))}});function D(T){const{a:p,b:y}=b,R=E.sqr(T),P=E.mul(R,T);return E.add(E.add(P,E.mul(T,p)),y)}if(!E.eql(E.sqr(b.Gy),D(b.Gx)))throw new Error("bad generator point: equation left != right");function z(T){const{allowedPrivateKeyLengths:p,nByteLength:y,wrapPrivateKey:R,n:P}=b;if(p&&typeof T!="bigint"){if(r.isBytes(T)&&(T=r.bytesToHex(T)),typeof T!="string"||!p.includes(T.length))throw new Error("Invalid key");T=T.padStart(2*y,"0")}let _;try{_=typeof T=="bigint"?T:r.bytesToNumberBE((0,i.ensureBytes)("private key",T,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof T}`)}return R&&(_=n.mod(_,P)),r.aInRange("private key",_,l,P),_}function X(T){if(!(T instanceof B))throw new Error("ProjectivePoint expected")}const Y=(0,i.memoized)(((T,p)=>{const{px:y,py:R,pz:P}=T;if(E.eql(P,E.ONE))return{x:y,y:R};const _=T.is0();p==null&&(p=_?E.ONE:E.inv(P));const I=E.mul(y,p),N=E.mul(R,p),x=E.mul(P,p);if(_)return{x:E.ZERO,y:E.ZERO};if(!E.eql(x,E.ONE))throw new Error("invZ was invalid");return{x:I,y:N}})),U=(0,i.memoized)((T=>{if(T.is0()){if(b.allowInfinityPoint&&!E.is0(T.py))return;throw new Error("bad point: ZERO")}const{x:p,y}=T.toAffine();if(!E.isValid(p)||!E.isValid(y))throw new Error("bad point: x or y not FE");const R=E.sqr(y),P=D(p);if(!E.eql(R,P))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class B{constructor(p,y,R){if(this.px=p,this.py=y,this.pz=R,p==null||!E.isValid(p))throw new Error("x required");if(y==null||!E.isValid(y))throw new Error("y required");if(R==null||!E.isValid(R))throw new Error("z required");Object.freeze(this)}static fromAffine(p){const{x:y,y:R}=p||{};if(!p||!E.isValid(y)||!E.isValid(R))throw new Error("invalid affine point");if(p instanceof B)throw new Error("projective point not allowed");const P=_=>E.eql(_,E.ZERO);return P(y)&&P(R)?B.ZERO:new B(y,R,E.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){const y=E.invertBatch(p.map((R=>R.pz)));return p.map(((R,P)=>R.toAffine(y[P]))).map(B.fromAffine)}static fromHex(p){const y=B.fromAffine(F((0,i.ensureBytes)("pointHex",p)));return y.assertValidity(),y}static fromPrivateKey(p){return B.BASE.multiply(z(p))}static msm(p,y){return(0,e.pippenger)(B,M,p,y)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){U(this)}hasEvenY(){const{y:p}=this.toAffine();if(E.isOdd)return!E.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){X(p);const{px:y,py:R,pz:P}=this,{px:_,py:I,pz:N}=p,x=E.eql(E.mul(y,N),E.mul(_,P)),h=E.eql(E.mul(R,N),E.mul(I,P));return x&&h}negate(){return new B(this.px,E.neg(this.py),this.pz)}double(){const{a:p,b:y}=b,R=E.mul(y,d),{px:P,py:_,pz:I}=this;let N=E.ZERO,x=E.ZERO,h=E.ZERO,m=E.mul(P,P),A=E.mul(_,_),C=E.mul(I,I),$=E.mul(P,_);return $=E.add($,$),h=E.mul(P,I),h=E.add(h,h),N=E.mul(p,h),x=E.mul(R,C),x=E.add(N,x),N=E.sub(A,x),x=E.add(A,x),x=E.mul(N,x),N=E.mul($,N),h=E.mul(R,h),C=E.mul(p,C),$=E.sub(m,C),$=E.mul(p,$),$=E.add($,h),h=E.add(m,m),m=E.add(h,m),m=E.add(m,C),m=E.mul(m,$),x=E.add(x,m),C=E.mul(_,I),C=E.add(C,C),m=E.mul(C,$),N=E.sub(N,m),h=E.mul(C,A),h=E.add(h,h),h=E.add(h,h),new B(N,x,h)}add(p){X(p);const{px:y,py:R,pz:P}=this,{px:_,py:I,pz:N}=p;let x=E.ZERO,h=E.ZERO,m=E.ZERO;const A=b.a,C=E.mul(b.b,d);let $=E.mul(y,_),j=E.mul(R,I),Z=E.mul(P,N),ne=E.add(y,R),se=E.add(_,I);ne=E.mul(ne,se),se=E.add($,j),ne=E.sub(ne,se),se=E.add(y,P);let ue=E.add(_,N);return se=E.mul(se,ue),ue=E.add($,Z),se=E.sub(se,ue),ue=E.add(R,P),x=E.add(I,N),ue=E.mul(ue,x),x=E.add(j,Z),ue=E.sub(ue,x),m=E.mul(A,se),x=E.mul(C,Z),m=E.add(x,m),x=E.sub(j,m),m=E.add(j,m),h=E.mul(x,m),j=E.add($,$),j=E.add(j,$),Z=E.mul(A,Z),se=E.mul(C,se),j=E.add(j,Z),Z=E.sub($,Z),Z=E.mul(A,Z),se=E.add(se,Z),$=E.mul(j,se),h=E.add(h,$),$=E.mul(ue,se),x=E.mul(ne,x),x=E.sub(x,$),$=E.mul(ne,j),m=E.mul(ue,m),m=E.add(m,$),new B(x,h,m)}subtract(p){return this.add(p.negate())}is0(){return this.equals(B.ZERO)}wNAF(p){return V.wNAFCached(this,p,B.normalizeZ)}multiplyUnsafe(p){r.aInRange("scalar",p,c,b.n);const y=B.ZERO;if(p===c)return y;if(p===l)return this;const{endo:R}=b;if(!R)return V.unsafeLadder(this,p);let{k1neg:P,k1:_,k2neg:I,k2:N}=R.splitScalar(p),x=y,h=y,m=this;for(;_>c||N>c;)_&l&&(x=x.add(m)),N&l&&(h=h.add(m)),m=m.double(),_>>=l,N>>=l;return P&&(x=x.negate()),I&&(h=h.negate()),h=new B(E.mul(h.px,R.beta),h.py,h.pz),x.add(h)}multiply(p){const{endo:y,n:R}=b;let P,_;if(r.aInRange("scalar",p,l,R),y){const{k1neg:I,k1:N,k2neg:x,k2:h}=y.splitScalar(p);let{p:m,f:A}=this.wNAF(N),{p:C,f:$}=this.wNAF(h);m=V.constTimeNegate(I,m),C=V.constTimeNegate(x,C),C=new B(E.mul(C.px,y.beta),C.py,C.pz),P=m.add(C),_=A.add($)}else{const{p:I,f:N}=this.wNAF(p);P=I,_=N}return B.normalizeZ([P,_])[0]}multiplyAndAddUnsafe(p,y,R){const P=B.BASE,_=(N,x)=>x!==c&&x!==l&&N.equals(P)?N.multiply(x):N.multiplyUnsafe(x),I=_(this,y).add(_(p,R));return I.is0()?void 0:I}toAffine(p){return Y(this,p)}isTorsionFree(){const{h:p,isTorsionFree:y}=b;if(p===l)return!0;if(y)return y(B,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:p,clearCofactor:y}=b;return p===l?this:y?y(B,this):this.multiplyUnsafe(b.h)}toRawBytes(p=!0){return(0,i.abool)("isCompressed",p),this.assertValidity(),S(B,this,p)}toHex(p=!0){return(0,i.abool)("isCompressed",p),r.bytesToHex(this.toRawBytes(p))}}B.BASE=new B(b.Gx,b.Gy,E.ONE),B.ZERO=new B(E.ZERO,E.ONE,E.ZERO);const H=b.nBitLength,V=(0,e.wNAF)(B,b.endo?Math.ceil(H/2):H);return{CURVE:b,ProjectivePoint:B,normPrivateKeyToScalar:z,weierstrassEquation:D,isWithinCurveOrder:function(T){return r.inRange(T,l,b.n)}}}function v(w,b){const E=w.ORDER;let M=c;for(let T=E-l;T%u===c;T/=u)M+=l;const S=M,F=u<<S-l-l,D=F*u,z=(E-l)/D,X=(z-l)/u,Y=D-l,U=F,B=w.pow(b,z),H=w.pow(b,(z+l)/u);let V=(T,p)=>{let y=B,R=w.pow(p,Y),P=w.sqr(R);P=w.mul(P,p);let _=w.mul(T,P);_=w.pow(_,X),_=w.mul(_,R),R=w.mul(_,p),P=w.mul(_,T);let I=w.mul(P,R);_=w.pow(I,U);let N=w.eql(_,w.ONE);R=w.mul(P,H),_=w.mul(I,y),P=w.cmov(R,P,N),I=w.cmov(_,I,N);for(let x=S;x>l;x--){let h=x-u;h=u<<h-l;let m=w.pow(I,h);const A=w.eql(m,w.ONE);R=w.mul(P,y),y=w.mul(y,y),m=w.mul(I,y),P=w.cmov(R,P,A),I=w.cmov(m,I,A)}return{isValid:N,value:P}};if(w.ORDER%f===d){const T=(w.ORDER-d)/f,p=w.sqrt(w.neg(b));V=(y,R)=>{let P=w.sqr(R);const _=w.mul(y,R);P=w.mul(P,_);let I=w.pow(P,T);I=w.mul(I,_);const N=w.mul(I,p),x=w.mul(w.sqr(I),R),h=w.eql(x,y);return{isValid:h,value:w.cmov(N,I,h)}}}return V}})(Og),Object.defineProperty(od,"__esModule",{value:!0}),od.getHash=Wv,od.createCurve=function(t,e){const n=r=>(0,S5.weierstrass)({...t,...Wv(r)});return Object.freeze({...n(e),create:n})};const _5=Cg,qv=Cs,S5=Og;function Wv(t){return{hash:t,hmac:(e,...n)=>(0,_5.hmac)(t,e,(0,qv.concatBytes)(...n)),randomBytes:qv.randomBytes}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.schnorr=t.secp256k1=void 0;const e=Es,n=Cs,r=od,i=Js,s=Xt,o=Bt,a=Og,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),u=BigInt(1),d=BigInt(2),f=(_,I)=>(_+I/d)/I;function g(_){const I=c,N=BigInt(3),x=BigInt(6),h=BigInt(11),m=BigInt(22),A=BigInt(23),C=BigInt(44),$=BigInt(88),j=_*_*_%I,Z=j*j*_%I,ne=(0,s.pow2)(Z,N,I)*Z%I,se=(0,s.pow2)(ne,N,I)*Z%I,ue=(0,s.pow2)(se,d,I)*j%I,de=(0,s.pow2)(ue,h,I)*ue%I,Ae=(0,s.pow2)(de,m,I)*de%I,Ce=(0,s.pow2)(Ae,C,I)*Ae%I,Ue=(0,s.pow2)(Ce,$,I)*Ce%I,Be=(0,s.pow2)(Ue,C,I)*Ae%I,Oe=(0,s.pow2)(Be,N,I)*Z%I,Le=(0,s.pow2)(Oe,A,I)*de%I,je=(0,s.pow2)(Le,x,I)*j%I,$e=(0,s.pow2)(je,d,I);if(!v.eql(v.sqr($e),_))throw new Error("Cannot find square root");return $e}const v=(0,s.Field)(c,void 0,void 0,{sqrt:g});t.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:v,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:_=>{const I=l,N=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),x=-u*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),h=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),m=N,A=BigInt("0x100000000000000000000000000000000"),C=f(m*_,I),$=f(-x*_,I);let j=(0,s.mod)(_-C*N-$*h,I),Z=(0,s.mod)(-C*x-$*m,I);const ne=j>A,se=Z>A;if(ne&&(j=I-j),se&&(Z=I-Z),j>A||Z>A)throw new Error("splitScalar: Endomorphism failed, k="+_);return{k1neg:ne,k1:j,k2neg:se,k2:Z}}}},e.sha256);const w=BigInt(0),b={};function E(_,...I){let N=b[_];if(N===void 0){const x=(0,e.sha256)(Uint8Array.from(_,(h=>h.charCodeAt(0))));N=(0,o.concatBytes)(x,x),b[_]=N}return(0,e.sha256)((0,o.concatBytes)(N,...I))}const M=_=>_.toRawBytes(!0).slice(1),S=_=>(0,o.numberToBytesBE)(_,32),F=_=>(0,s.mod)(_,c),D=_=>(0,s.mod)(_,l),z=t.secp256k1.ProjectivePoint,X=(_,I,N)=>z.BASE.multiplyAndAddUnsafe(_,I,N);function Y(_){let I=t.secp256k1.utils.normPrivateKeyToScalar(_),N=z.fromPrivateKey(I);return{scalar:N.hasEvenY()?I:D(-I),bytes:M(N)}}function U(_){(0,o.aInRange)("x",_,u,c);const I=F(_*_);let N=g(F(I*_+BigInt(7)));N%d!==w&&(N=F(-N));const x=new z(_,N,u);return x.assertValidity(),x}const B=o.bytesToNumberBE;function H(..._){return D(B(E("BIP0340/challenge",..._)))}function V(_){return Y(_).bytes}function T(_,I,N=(0,n.randomBytes)(32)){const x=(0,o.ensureBytes)("message",_),{bytes:h,scalar:m}=Y(I),A=(0,o.ensureBytes)("auxRand",N,32),C=S(m^B(E("BIP0340/aux",A))),$=E("BIP0340/nonce",C,h,x),j=D(B($));if(j===w)throw new Error("sign failed: k is zero");const{bytes:Z,scalar:ne}=Y(j),se=H(Z,h,x),ue=new Uint8Array(64);if(ue.set(Z,0),ue.set(S(D(ne+se*m)),32),!p(ue,x,h))throw new Error("sign: Invalid signature produced");return ue}function p(_,I,N){const x=(0,o.ensureBytes)("signature",_,64),h=(0,o.ensureBytes)("message",I),m=(0,o.ensureBytes)("publicKey",N,32);try{const A=U(B(m)),C=B(x.subarray(0,32));if(!(0,o.inRange)(C,u,c))return!1;const $=B(x.subarray(32,64));if(!(0,o.inRange)($,u,l))return!1;const j=H(S(C),M(A),h),Z=X(A,$,D(-j));return!(!Z||!Z.hasEvenY()||Z.toAffine().x!==C)}catch{return!1}}t.schnorr={getPublicKey:V,sign:T,verify:p,utils:{randomPrivateKey:t.secp256k1.utils.randomPrivateKey,lift_x:U,pointToBytes:M,numberToBytesBE:o.numberToBytesBE,bytesToNumberBE:o.bytesToNumberBE,taggedHash:E,mod:s.mod}};const y=(0,i.isogenyMap)(v,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((_=>_.map((I=>BigInt(I)))))),R=(0,a.mapToCurveSimpleSWU)(v,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:v.create(BigInt("-11"))}),P=(0,i.createHasher)(t.secp256k1.ProjectivePoint,(_=>{const{x:I,y:N}=R(v.create(_[0]));return y(I,N)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:v.ORDER,m:1,k:128,expand:"xmd",hash:e.sha256});t.hashToCurve=P.hashToCurve,t.encodeToCurve=P.encodeToCurve})(i2);var K0={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeHex=t.remove0x=void 0;var e=Xr;t.remove0x=function(n){return n.startsWith("0x")||n.startsWith("0X")?n.slice(2):n},t.decodeHex=function(n){return(0,e.hexToBytes)((0,t.remove0x)(n))}})(K0),(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hexToPublicKey=t.convertPublicKeyFormat=t.getSharedPoint=t.getPublicKey=t.isValidPrivateKey=t.getValidSecret=void 0;var e=Ag,n=Ax,r=i2,i=yl,s=Vn,o=K0;t.getValidSecret=function(){var u;do u=(0,e.randomBytes)(s.SECRET_KEY_LENGTH);while(!(0,t.isValidPrivateKey)(u));return u},t.isValidPrivateKey=function(u){return a((0,i.ellipticCurve)(),(function(d){return d.utils.isValidPrivateKey(u)}),(function(){return!0}),(function(){return!0}))},t.getPublicKey=function(u){return a((0,i.ellipticCurve)(),(function(d){return d.getPublicKey(u)}),(function(d){return d.getPublicKey(u)}),(function(d){return d.getPublicKey(u)}))},t.getSharedPoint=function(u,d,f){return a((0,i.ellipticCurve)(),(function(g){return g.getSharedSecret(u,d,f)}),(function(g){return g.getSharedSecret(u,d)}),(function(g){return l(g,u,d)}))},t.convertPublicKeyFormat=function(u,d){return a((0,i.ellipticCurve)(),(function(f){return f.getSharedSecret(BigInt(1),u,d)}),(function(){return u}),(function(){return u}))};function a(u,d,f,g){if(u==="secp256k1")return d(r.secp256k1);if(u==="x25519")return f(n.x25519);if(u==="ed25519")return g(n.ed25519);throw new Error("Not implemented")}t.hexToPublicKey=function(u){var d=(0,o.decodeHex)(u);return a((0,i.ellipticCurve)(),(function(){return c(d)}),(function(){return d}),(function(){return d}))};var c=function(u){if(u.length===s.ETH_PUBLIC_KEY_SIZE){var d=new Uint8Array(1+u.length);return d.set([4]),d.set(u,1),d}return u},l=function(u,d,f){var g=u.utils.getExtendedPublicKey(d).scalar;return u.ExtendedPoint.fromHex(f).multiply(g).toRawBytes()}})(xx);var s2={},Oa={};Object.defineProperty(Oa,"__esModule",{value:!0}),Oa.hkdf=void 0,Oa.extract=a2,Oa.expand=c2;const V0=Wr,Gv=Cs,o2=Cg;function a2(t,e,n){return(0,V0.hash)(t),n===void 0&&(n=new Uint8Array(t.outputLen)),(0,o2.hmac)(t,(0,Gv.toBytes)(n),(0,Gv.toBytes)(e))}const Xh=new Uint8Array([0]),Yv=new Uint8Array;function c2(t,e,n,r=32){if((0,V0.hash)(t),(0,V0.number)(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);n===void 0&&(n=Yv);const s=new Uint8Array(i*t.outputLen),o=o2.hmac.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<i;l++)Xh[0]=l+1,a.update(l===0?Yv:c).update(n).update(Xh).digestInto(c),s.set(c,t.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Xh.fill(0),s.slice(0,r)}Oa.hkdf=(t,e,n,r,i)=>c2(t,a2(t,e,n),r,i),(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getSharedKey=t.deriveKey=void 0;var e=Xr,n=Oa,r=Es;t.deriveKey=function(i,s,o){return(0,n.hkdf)(r.sha256,i,s,o,32)},t.getSharedKey=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return(0,t.deriveKey)(e.concatBytes.apply(void 0,i))}})(s2);var Jv={},Va={},xn={},Po={};Object.defineProperty(Po,"__esModule",{value:!0}),Po.polyval=Po.ghash=void 0,Po._toGHASHKey=l2;const Mo=mr,_r=Xr,cs=16,Ng=new Uint8Array(16),$i=(0,_r.u32)(Ng),ai=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function l2(t){t.reverse();const e=1&t[15];let n=0;for(let r=0;r<t.length;r++){const i=t[r];t[r]=i>>>1|n,n=(1&i)<<7}return t[0]^=225&-e,t}class u2{constructor(e,n){this.blockLen=cs,this.outputLen=cs,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,_r.toBytes)(e),(0,Mo.bytes)(e,16);const r=(0,_r.createView)(e);let i=r.getUint32(0,!1),s=r.getUint32(4,!1),o=r.getUint32(8,!1),a=r.getUint32(12,!1);const c=[];for(let E=0;E<128;E++)c.push({s0:ai(i),s1:ai(s),s2:ai(o),s3:ai(a)}),{s0:i,s1:s,s2:o,s3:a}={s3:(d=o)<<31|(f=a)>>>1,s2:(u=s)<<31|d>>>1,s1:(l=i)<<31|u>>>1,s0:l>>>1^225<<24&-(1&f)};var l,u,d,f;const g=(E=>E>65536?8:E>1024?4:2)(n||1024);if(![1,2,4,8].includes(g))throw new Error(`ghash: wrong window size=${g}, should be 2, 4 or 8`);this.W=g;const v=128/g,w=this.windowSize=2**g,b=[];for(let E=0;E<v;E++)for(let M=0;M<w;M++){let S=0,F=0,D=0,z=0;for(let X=0;X<g;X++){if(!(M>>>g-X-1&1))continue;const{s0:Y,s1:U,s2:B,s3:H}=c[g*E+X];S^=Y,F^=U,D^=B,z^=H}b.push({s0:S,s1:F,s2:D,s3:z})}this.t=b}_updateBlock(e,n,r,i){e^=this.s0,n^=this.s1,r^=this.s2,i^=this.s3;const{W:s,t:o,windowSize:a}=this;let c=0,l=0,u=0,d=0;const f=(1<<s)-1;let g=0;for(const v of[e,n,r,i])for(let w=0;w<4;w++){const b=v>>>8*w&255;for(let E=8/s-1;E>=0;E--){const M=b>>>s*E&f,{s0:S,s1:F,s2:D,s3:z}=o[g*a+M];c^=S,l^=F,u^=D,d^=z,g+=1}}this.s0=c,this.s1=l,this.s2=u,this.s3=d}update(e){e=(0,_r.toBytes)(e),(0,Mo.exists)(this);const n=(0,_r.u32)(e),r=Math.floor(e.length/cs),i=e.length%cs;for(let s=0;s<r;s++)this._updateBlock(n[4*s+0],n[4*s+1],n[4*s+2],n[4*s+3]);return i&&(Ng.set(e.subarray(r*cs)),this._updateBlock($i[0],$i[1],$i[2],$i[3]),(0,_r.clean)($i)),this}destroy(){const{t:e}=this;for(const n of e)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(e){(0,Mo.exists)(this),(0,Mo.output)(e,this),this.finished=!0;const{s0:n,s1:r,s2:i,s3:s}=this,o=(0,_r.u32)(e);return o[0]=n,o[1]=r,o[2]=i,o[3]=s,e}digest(){const e=new Uint8Array(cs);return this.digestInto(e),this.destroy(),e}}class x5 extends u2{constructor(e,n){e=(0,_r.toBytes)(e);const r=l2((0,_r.copyBytes)(e));super(r,n),(0,_r.clean)(r)}update(e){e=(0,_r.toBytes)(e),(0,Mo.exists)(this);const n=(0,_r.u32)(e),r=e.length%cs,i=Math.floor(e.length/cs);for(let s=0;s<i;s++)this._updateBlock(ai(n[4*s+3]),ai(n[4*s+2]),ai(n[4*s+1]),ai(n[4*s+0]));return r&&(Ng.set(e.subarray(i*cs)),this._updateBlock(ai($i[3]),ai($i[2]),ai($i[1]),ai($i[0])),(0,_r.clean)($i)),this}digestInto(e){(0,Mo.exists)(this),(0,Mo.output)(e,this),this.finished=!0;const{s0:n,s1:r,s2:i,s3:s}=this,o=(0,_r.u32)(e);return o[0]=n,o[1]=r,o[2]=i,o[3]=s,e.reverse()}}function Zv(t){const e=(r,i)=>t(i,r.length).update((0,_r.toBytes)(r)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(r,i)=>t(r,i),e}Po.ghash=Zv(((t,e)=>new u2(t,e))),Po.polyval=Zv(((t,e)=>new x5(t,e))),Object.defineProperty(xn,"__esModule",{value:!0}),xn.unsafe=xn.aeskwp=xn.aeskw=xn.siv=xn.gcm=xn.cfb=xn.cbc=xn.ecb=xn.ctr=void 0,xn.expandKeyLE=_i,xn.expandKeyDecLE=vl;const Ht=mr,j0=Po,Te=Xr,$r=16,Au=new Uint8Array($r),A5=283;function Pg(t){return t<<1^A5&-(t>>7)}function Na(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=Pg(t);return n}const H0=(()=>{const t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Pg(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,Te.clean)(t),e})(),R5=H0.map(((t,e)=>H0.indexOf(e))),I5=t=>t<<24|t>>>8,Qh=t=>t<<8|t>>>24,Kd=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function d2(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((l,u)=>e(t[u]))),r=n.map(Qh),i=r.map(Qh),s=i.map(Qh),o=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let l=0;l<256;l++)for(let u=0;u<256;u++){const d=256*l+u;o[d]=n[l]^r[u],a[d]=i[l]^s[u],c[d]=t[l]<<8|t[u]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:i,T3:s,T01:o,T23:a}}const Mg=d2(H0,(t=>Na(t,3)<<24|t<<16|t<<8|Na(t,2))),f2=d2(R5,(t=>Na(t,11)<<24|Na(t,13)<<16|Na(t,9)<<8|Na(t,14))),T5=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=Pg(n))t[e]=n;return t})();function _i(t){(0,Ht.bytes)(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=Mg,r=[];(0,Te.isAligned32)(t)||r.push(t=(0,Te.copyBytes)(t));const i=(0,Te.u32)(t),s=i.length,o=c=>Vi(n,c,c,c,c),a=new Uint32Array(e+28);a.set(i);for(let c=s;c<a.length;c++){let l=a[c-1];c%s==0?l=o(I5(l))^T5[c/s-1]:s>6&&c%s==4&&(l=o(l)),a[c]=a[c-s]^l}return(0,Te.clean)(...r),a}function vl(t){const e=_i(t),n=e.slice(),r=e.length,{sbox2:i}=Mg,{T0:s,T1:o,T2:a,T3:c}=f2;for(let l=0;l<r;l+=4)for(let u=0;u<4;u++)n[l+u]=e[r-l-4+u];(0,Te.clean)(e);for(let l=4;l<r-4;l++){const u=n[l],d=Vi(i,u,u,u,u);n[l]=s[255&d]^o[d>>>8&255]^a[d>>>16&255]^c[d>>>24]}return n}function so(t,e,n,r,i,s){return t[n<<8&65280|r>>>8&255]^e[i>>>8&65280|s>>>24&255]}function Vi(t,e,n,r,i){return t[255&e|65280&n]|t[r>>>16&255|i>>>16&65280]<<16}function xr(t,e,n,r,i){const{sbox2:s,T01:o,T23:a}=Mg;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],i^=t[c++];const l=t.length/4-2;for(let u=0;u<l;u++){const d=t[c++]^so(o,a,e,n,r,i),f=t[c++]^so(o,a,n,r,i,e),g=t[c++]^so(o,a,r,i,e,n),v=t[c++]^so(o,a,i,e,n,r);e=d,n=f,r=g,i=v}return{s0:t[c++]^Vi(s,e,n,r,i),s1:t[c++]^Vi(s,n,r,i,e),s2:t[c++]^Vi(s,r,i,e,n),s3:t[c++]^Vi(s,i,e,n,r)}}function El(t,e,n,r,i){const{sbox2:s,T01:o,T23:a}=f2;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],i^=t[c++];const l=t.length/4-2;for(let u=0;u<l;u++){const d=t[c++]^so(o,a,e,i,r,n),f=t[c++]^so(o,a,n,e,i,r),g=t[c++]^so(o,a,r,n,e,i),v=t[c++]^so(o,a,i,r,n,e);e=d,n=f,r=g,i=v}return{s0:t[c++]^Vi(s,e,i,r,n),s1:t[c++]^Vi(s,n,e,i,r),s2:t[c++]^Vi(s,r,n,e,i),s3:t[c++]^Vi(s,i,r,n,e)}}function ja(t,e){if(e===void 0)return new Uint8Array(t);if((0,Ht.bytes)(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);if(!(0,Te.isAligned32)(e))throw new Error("unaligned dst");return e}function h2(t,e,n,r){(0,Ht.bytes)(e,$r),(0,Ht.bytes)(n);const i=n.length;r=ja(i,r);const s=e,o=(0,Te.u32)(s);let{s0:a,s1:c,s2:l,s3:u}=xr(t,o[0],o[1],o[2],o[3]);const d=(0,Te.u32)(n),f=(0,Te.u32)(r);for(let v=0;v+4<=d.length;v+=4){f[v+0]=d[v+0]^a,f[v+1]=d[v+1]^c,f[v+2]=d[v+2]^l,f[v+3]=d[v+3]^u;let w=1;for(let b=s.length-1;b>=0;b--)w=w+(255&s[b])|0,s[b]=255&w,w>>>=8;({s0:a,s1:c,s2:l,s3:u}=xr(t,o[0],o[1],o[2],o[3]))}const g=$r*Math.floor(d.length/4);if(g<i){const v=new Uint32Array([a,c,l,u]),w=(0,Te.u8)(v);for(let b=g,E=0;b<i;b++,E++)r[b]=n[b]^w[E];(0,Te.clean)(v)}return r}function Pa(t,e,n,r,i){(0,Ht.bytes)(n,$r),(0,Ht.bytes)(r),i=ja(r.length,i);const s=n,o=(0,Te.u32)(s),a=(0,Te.createView)(s),c=(0,Te.u32)(r),l=(0,Te.u32)(i),u=e?0:12,d=r.length;let f=a.getUint32(u,e),{s0:g,s1:v,s2:w,s3:b}=xr(t,o[0],o[1],o[2],o[3]);for(let M=0;M+4<=c.length;M+=4)l[M+0]=c[M+0]^g,l[M+1]=c[M+1]^v,l[M+2]=c[M+2]^w,l[M+3]=c[M+3]^b,f=f+1>>>0,a.setUint32(u,f,e),{s0:g,s1:v,s2:w,s3:b}=xr(t,o[0],o[1],o[2],o[3]);const E=$r*Math.floor(c.length/4);if(E<d){const M=new Uint32Array([g,v,w,b]),S=(0,Te.u8)(M);for(let F=E,D=0;F<d;F++,D++)i[F]=r[F]^S[D];(0,Te.clean)(M)}return i}function Xv(t){if((0,Ht.bytes)(t),t.length%$r!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function Qv(t,e,n){(0,Ht.bytes)(t);let r=t.length;const i=r%$r;if(!e&&i!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,Te.isAligned32)(t)||(t=(0,Te.copyBytes)(t));const s=(0,Te.u32)(t);if(e){let a=$r-i;a||(a=$r),r+=a}const o=ja(r,n);return{b:s,o:(0,Te.u32)(o),out:o}}function e1(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=t.subarray(0,-r);for(let s=0;s<r;s++)if(t[n-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function t1(t){const e=new Uint8Array(16),n=(0,Te.u32)(e);e.set(t);const r=$r-t.length;for(let i=$r-r;i<$r;i++)e[i]=r;return n}function p2(t,e,n,r,i){const s=i==null?0:i.length,o=t.create(n,r.length+s);i&&o.update(i),o.update(r);const a=new Uint8Array(16),c=(0,Te.createView)(a);i&&(0,Te.setBigUint64)(c,0,BigInt(8*s),e),(0,Te.setBigUint64)(c,8,BigInt(8*r.length),e),o.update(a);const l=o.digest();return(0,Te.clean)(a),l}xn.ctr=(0,Te.wrapCipher)({blockSize:16,nonceLength:16},(function(t,e){function n(r,i){if((0,Ht.bytes)(r),i!==void 0&&((0,Ht.bytes)(i),!(0,Te.isAligned32)(i)))throw new Error("unaligned destination");const s=_i(t),o=(0,Te.copyBytes)(e),a=[s,o];(0,Te.isAligned32)(r)||a.push(r=(0,Te.copyBytes)(r));const c=h2(s,o,r,i);return(0,Te.clean)(...a),c}return(0,Ht.bytes)(t),(0,Ht.bytes)(e,$r),{encrypt:(r,i)=>n(r,i),decrypt:(r,i)=>n(r,i)}})),xn.ecb=(0,Te.wrapCipher)({blockSize:16},(function(t,e={}){(0,Ht.bytes)(t);const n=!e.disablePadding;return{encrypt(r,i){const{b:s,o,out:a}=Qv(r,n,i),c=_i(t);let l=0;for(;l+4<=s.length;){const{s0:u,s1:d,s2:f,s3:g}=xr(c,s[l+0],s[l+1],s[l+2],s[l+3]);o[l++]=u,o[l++]=d,o[l++]=f,o[l++]=g}if(n){const u=t1(r.subarray(4*l)),{s0:d,s1:f,s2:g,s3:v}=xr(c,u[0],u[1],u[2],u[3]);o[l++]=d,o[l++]=f,o[l++]=g,o[l++]=v}return(0,Te.clean)(c),a},decrypt(r,i){Xv(r);const s=vl(t),o=ja(r.length,i),a=[s];(0,Te.isAligned32)(r)||a.push(r=(0,Te.copyBytes)(r));const c=(0,Te.u32)(r),l=(0,Te.u32)(o);for(let u=0;u+4<=c.length;){const{s0:d,s1:f,s2:g,s3:v}=El(s,c[u+0],c[u+1],c[u+2],c[u+3]);l[u++]=d,l[u++]=f,l[u++]=g,l[u++]=v}return(0,Te.clean)(...a),e1(o,n)}}})),xn.cbc=(0,Te.wrapCipher)({blockSize:16,nonceLength:16},(function(t,e,n={}){(0,Ht.bytes)(t),(0,Ht.bytes)(e,16);const r=!n.disablePadding;return{encrypt(i,s){const o=_i(t),{b:a,o:c,out:l}=Qv(i,r,s);let u=e;const d=[o];(0,Te.isAligned32)(u)||d.push(u=(0,Te.copyBytes)(u));const f=(0,Te.u32)(u);let g=f[0],v=f[1],w=f[2],b=f[3],E=0;for(;E+4<=a.length;)g^=a[E+0],v^=a[E+1],w^=a[E+2],b^=a[E+3],{s0:g,s1:v,s2:w,s3:b}=xr(o,g,v,w,b),c[E++]=g,c[E++]=v,c[E++]=w,c[E++]=b;if(r){const M=t1(i.subarray(4*E));g^=M[0],v^=M[1],w^=M[2],b^=M[3],{s0:g,s1:v,s2:w,s3:b}=xr(o,g,v,w,b),c[E++]=g,c[E++]=v,c[E++]=w,c[E++]=b}return(0,Te.clean)(...d),l},decrypt(i,s){Xv(i);const o=vl(t);let a=e;const c=[o];(0,Te.isAligned32)(a)||c.push(a=(0,Te.copyBytes)(a));const l=(0,Te.u32)(a),u=ja(i.length,s);(0,Te.isAligned32)(i)||c.push(i=(0,Te.copyBytes)(i));const d=(0,Te.u32)(i),f=(0,Te.u32)(u);let g=l[0],v=l[1],w=l[2],b=l[3];for(let E=0;E+4<=d.length;){const M=g,S=v,F=w,D=b;g=d[E+0],v=d[E+1],w=d[E+2],b=d[E+3];const{s0:z,s1:X,s2:Y,s3:U}=El(o,g,v,w,b);f[E++]=z^M,f[E++]=X^S,f[E++]=Y^F,f[E++]=U^D}return(0,Te.clean)(...c),e1(u,r)}}})),xn.cfb=(0,Te.wrapCipher)({blockSize:16,nonceLength:16},(function(t,e){function n(r,i,s){(0,Ht.bytes)(r);const o=r.length;s=ja(o,s);const a=_i(t);let c=e;const l=[a];(0,Te.isAligned32)(c)||l.push(c=(0,Te.copyBytes)(c)),(0,Te.isAligned32)(r)||l.push(r=(0,Te.copyBytes)(r));const u=(0,Te.u32)(r),d=(0,Te.u32)(s),f=i?d:u,g=(0,Te.u32)(c);let v=g[0],w=g[1],b=g[2],E=g[3];for(let S=0;S+4<=u.length;){const{s0:F,s1:D,s2:z,s3:X}=xr(a,v,w,b,E);d[S+0]=u[S+0]^F,d[S+1]=u[S+1]^D,d[S+2]=u[S+2]^z,d[S+3]=u[S+3]^X,v=f[S++],w=f[S++],b=f[S++],E=f[S++]}const M=$r*Math.floor(u.length/4);if(M<o){({s0:v,s1:w,s2:b,s3:E}=xr(a,v,w,b,E));const S=(0,Te.u8)(new Uint32Array([v,w,b,E]));for(let F=M,D=0;F<o;F++,D++)s[F]=r[F]^S[D];(0,Te.clean)(S)}return(0,Te.clean)(...l),s}return(0,Ht.bytes)(t),(0,Ht.bytes)(e,16),{encrypt:(r,i)=>n(r,!0,i),decrypt:(r,i)=>n(r,!1,i)}})),xn.gcm=(0,Te.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(t,e,n){if((0,Ht.bytes)(t),(0,Ht.bytes)(e),n!==void 0&&(0,Ht.bytes)(n),e.length<8)throw new Error("aes/gcm: invalid nonce length");const r=16;function i(o,a,c){const l=p2(j0.ghash,!1,o,c,n);for(let u=0;u<a.length;u++)l[u]^=a[u];return l}function s(){const o=_i(t),a=Au.slice(),c=Au.slice();if(Pa(o,!1,c,c,a),e.length===12)c.set(e);else{const l=Au.slice(),u=(0,Te.createView)(l);(0,Te.setBigUint64)(u,8,BigInt(8*e.length),!1);const d=j0.ghash.create(a).update(e).update(l);d.digestInto(c),d.destroy()}return{xk:o,authKey:a,counter:c,tagMask:Pa(o,!1,c,Au)}}return{encrypt(o){(0,Ht.bytes)(o);const{xk:a,authKey:c,counter:l,tagMask:u}=s(),d=new Uint8Array(o.length+r),f=[a,c,l,u];(0,Te.isAligned32)(o)||f.push(o=(0,Te.copyBytes)(o)),Pa(a,!1,l,o,d);const g=i(c,u,d.subarray(0,d.length-r));return f.push(g),d.set(g,o.length),(0,Te.clean)(...f),d},decrypt(o){if((0,Ht.bytes)(o),o.length<r)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:a,authKey:c,counter:l,tagMask:u}=s(),d=[a,c,u,l];(0,Te.isAligned32)(o)||d.push(o=(0,Te.copyBytes)(o));const f=o.subarray(0,-16),g=o.subarray(-16),v=i(c,u,f);if(d.push(v),!(0,Te.equalBytes)(v,g))throw new Error("aes/gcm: invalid ghash tag");const w=Pa(a,!1,l,f);return(0,Te.clean)(...d),w}}}));const Ru=(t,e,n)=>r=>{if(!Number.isSafeInteger(r)||e>r||r>n)throw new Error(`${t}: invalid value=${r}, must be [${e}..${n}]`)};function m2(t){return t!=null&&typeof t=="object"&&(t instanceof Uint32Array||t.constructor.name==="Uint32Array")}function g2(t,e){if((0,Ht.bytes)(e,16),!m2(t))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,Te.u32)(e);let{s0:r,s1:i,s2:s,s3:o}=xr(t,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=s,n[3]=o,e}function y2(t,e){if((0,Ht.bytes)(e,16),!m2(t))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,Te.u32)(e);let{s0:r,s1:i,s2:s,s3:o}=El(t,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=s,n[3]=o,e}xn.siv=(0,Te.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(t,e,n){const r=Ru("AAD",0,68719476736),i=Ru("plaintext",0,2**36),s=Ru("nonce",12,12),o=Ru("ciphertext",16,2**36+16);function a(){const u=_i(t),d=new Uint8Array(t.length),f=new Uint8Array(16),g=[u,d];let v=e;(0,Te.isAligned32)(v)||g.push(v=(0,Te.copyBytes)(v));const w=(0,Te.u32)(v);let b=0,E=w[0],M=w[1],S=w[2],F=0;for(const z of[f,d].map(Te.u32)){const X=(0,Te.u32)(z);for(let Y=0;Y<X.length;Y+=2){const{s0:U,s1:B}=xr(u,b,E,M,S);X[Y+0]=U,X[Y+1]=B,b=++F}}const D={authKey:f,encKey:_i(d)};return(0,Te.clean)(...g),D}function c(u,d,f){const g=p2(j0.polyval,!0,d,f,n);for(let S=0;S<12;S++)g[S]^=e[S];g[15]&=127;const v=(0,Te.u32)(g);let w=v[0],b=v[1],E=v[2],M=v[3];return{s0:w,s1:b,s2:E,s3:M}=xr(u,w,b,E,M),v[0]=w,v[1]=b,v[2]=E,v[3]=M,g}function l(u,d,f){let g=(0,Te.copyBytes)(d);g[15]|=128;const v=Pa(u,!0,g,f);return(0,Te.clean)(g),v}return(0,Ht.bytes)(t,16,24,32),(0,Ht.bytes)(e),s(e.length),n!==void 0&&((0,Ht.bytes)(n),r(n.length)),{encrypt(u){(0,Ht.bytes)(u),i(u.length);const{encKey:d,authKey:f}=a(),g=c(d,f,u),v=[d,f,g];(0,Te.isAligned32)(u)||v.push(u=(0,Te.copyBytes)(u));const w=new Uint8Array(u.length+16);return w.set(g,u.length),w.set(l(d,g,u)),(0,Te.clean)(...v),w},decrypt(u){(0,Ht.bytes)(u),o(u.length);const d=u.subarray(-16),{encKey:f,authKey:g}=a(),v=[f,g];(0,Te.isAligned32)(u)||v.push(u=(0,Te.copyBytes)(u));const w=l(f,d,u.subarray(0,-16)),b=c(f,g,w);if(v.push(b),!(0,Te.equalBytes)(d,b))throw(0,Te.clean)(...v),new Error("invalid polyval tag");return(0,Te.clean)(...v),w}}}));const Vd={encrypt(t,e){if(e.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=_i(t);if(e.length===16)g2(n,e);else{const r=(0,Te.u32)(e);let i=r[0],s=r[1];for(let o=0,a=1;o<6;o++)for(let c=2;c<r.length;c+=2,a++){const{s0:l,s1:u,s2:d,s3:f}=xr(n,i,s,r[c],r[c+1]);i=l,s=u^Kd(a),r[c]=d,r[c+1]=f}r[0]=i,r[1]=s}n.fill(0)},decrypt(t,e){if(e.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=vl(t),r=e.length/8-1;if(r===1)y2(n,e);else{const i=(0,Te.u32)(e);let s=i[0],o=i[1];for(let a=0,c=6*r;a<6;a++)for(let l=2*r;l>=1;l-=2,c--){o^=Kd(c);const{s0:u,s1:d,s2:f,s3:g}=El(n,s,o,i[l],i[l+1]);s=u,o=d,i[l]=f,i[l+1]=g}i[0]=s,i[1]=o}n.fill(0)}},n1=new Uint8Array(8).fill(166);xn.aeskw=(0,Te.wrapCipher)({blockSize:8},(t=>({encrypt(e){if((0,Ht.bytes)(e),!e.length||e.length%8!=0)throw new Error("invalid plaintext length");if(e.length===8)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,Te.concatBytes)(n1,e);return Vd.encrypt(t,n),n},decrypt(e){if((0,Ht.bytes)(e),e.length%8!=0||e.length<24)throw new Error("invalid ciphertext length");const n=(0,Te.copyBytes)(e);if(Vd.decrypt(t,n),!(0,Te.equalBytes)(n.subarray(0,8),n1))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const r1=2790873510;xn.aeskwp=(0,Te.wrapCipher)({blockSize:8},(t=>({encrypt(e){if((0,Ht.bytes)(e),!e.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(e.length/8),r=new Uint8Array(8+n);r.set(e,8);const i=(0,Te.u32)(r);return i[0]=r1,i[1]=Kd(e.length),Vd.encrypt(t,r),r},decrypt(e){if((0,Ht.bytes)(e),e.length<16)throw new Error("invalid ciphertext length");const n=(0,Te.copyBytes)(e),r=(0,Te.u32)(n);Vd.decrypt(t,n);const i=Kd(r[1])>>>0,s=8*Math.ceil(i/8);if(r[0]!==r1||n.length-8!==s)throw new Error("integrity check failed");for(let o=i;o<s;o++)if(n[8+o]!==0)throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}}))),xn.unsafe={expandKeyLE:_i,expandKeyDecLE:vl,encrypt:xr,decrypt:El,encryptBlock:g2,decryptBlock:y2,ctrCounter:h2,ctr32:Pa},Object.defineProperty(Va,"__esModule",{value:!0}),Va.aes256cbc=Va.aes256gcm=void 0;var w2=xn;Va.aes256gcm=function(t,e,n){return(0,w2.gcm)(t,e,n)};Va.aes256cbc=function(t,e,n){return(0,w2.cbc)(t,e)};var jd={},v2={},Ma={};Object.defineProperty(Ma,"__esModule",{value:!0}),Ma.sigma=void 0,Ma.rotl=function(t,e){return t<<e|t>>>32-e},Ma.createCipher=function(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:s,rounds:o}=(0,si.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return(0,rs.number)(i),(0,rs.number)(o),(0,rs.bool)(s),(0,rs.bool)(n),(a,c,l,u,d=0)=>{(0,rs.bytes)(a),(0,rs.bytes)(c),(0,rs.bytes)(l);const f=l.length;if(u===void 0&&(u=new Uint8Array(f)),(0,rs.bytes)(u),(0,rs.number)(d),d<0||d>=i1)throw new Error("arx: counter overflow");if(u.length<f)throw new Error(`arx: output (${u.length}) is shorter than data (${f})`);const g=[];let v,w,b=a.length;if(b===32)g.push(v=(0,si.copyBytes)(a)),w=b2;else{if(b!==16||!n)throw new Error(`arx: invalid 32-byte key, got length=${b}`);v=new Uint8Array(32),v.set(a),v.set(a,16),w=N5,g.push(v)}ep(c)||g.push(c=(0,si.copyBytes)(c));const E=(0,si.u32)(v);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(w,E,(0,si.u32)(c.subarray(0,16)),E),c=c.subarray(16)}const M=16-i;if(M!==c.length)throw new Error(`arx: nonce must be ${M} or 16 bytes`);if(M!==12){const F=new Uint8Array(12);F.set(c,s?0:12-c.length),c=F,g.push(c)}const S=(0,si.u32)(c);return(function(F,D,z,X,Y,U,B,H){const V=Y.length,T=new Uint8Array(Iu),p=(0,si.u32)(T),y=ep(Y)&&ep(U),R=y?(0,si.u32)(Y):s1,P=y?(0,si.u32)(U):s1;for(let _=0;_<V;B++){if(F(D,z,X,p,B,H),B>=i1)throw new Error("arx: counter overflow");const I=Math.min(Iu,V-_);if(y&&I===Iu){const N=_/4;if(_%4!=0)throw new Error("arx: invalid block position");for(let x,h=0;h<P5;h++)x=N+h,P[x]=R[x]^p[h];_+=Iu}else{for(let N,x=0;x<I;x++)N=_+x,U[N]=Y[N]^T[x];_+=I}}})(t,w,E,S,l,u,d,o),(0,si.clean)(...g),u}};const rs=mr,si=Xr,E2=t=>Uint8Array.from(t.split("").map((e=>e.charCodeAt(0)))),C5=E2("expand 16-byte k"),O5=E2("expand 32-byte k"),N5=(0,si.u32)(C5),b2=(0,si.u32)(O5);function ep(t){return t.byteOffset%4==0}Ma.sigma=b2.slice();const Iu=64,P5=16,i1=2**32-1,s1=new Uint32Array;var nl={};Object.defineProperty(nl,"__esModule",{value:!0}),nl.poly1305=void 0,nl.wrapConstructorWithKey=_2;const Tu=mr,Wc=Xr,Gn=(t,e)=>255&t[e++]|(255&t[e++])<<8;class M5{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=(0,Wc.toBytes)(e),(0,Tu.bytes)(e,32);const n=Gn(e,0),r=Gn(e,2),i=Gn(e,4),s=Gn(e,6),o=Gn(e,8),a=Gn(e,10),c=Gn(e,12),l=Gn(e,14);this.r[0]=8191&n,this.r[1]=8191&(n>>>13|r<<3),this.r[2]=7939&(r>>>10|i<<6),this.r[3]=8191&(i>>>7|s<<9),this.r[4]=255&(s>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|a<<2),this.r[7]=8065&(a>>>11|c<<5),this.r[8]=8191&(c>>>8|l<<8),this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Gn(e,16+2*u)}process(e,n,r=!1){const i=r?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],d=o[4],f=o[5],g=o[6],v=o[7],w=o[8],b=o[9],E=Gn(e,n+0),M=Gn(e,n+2),S=Gn(e,n+4),F=Gn(e,n+6),D=Gn(e,n+8),z=Gn(e,n+10),X=Gn(e,n+12),Y=Gn(e,n+14);let U=s[0]+(8191&E),B=s[1]+(8191&(E>>>13|M<<3)),H=s[2]+(8191&(M>>>10|S<<6)),V=s[3]+(8191&(S>>>7|F<<9)),T=s[4]+(8191&(F>>>4|D<<12)),p=s[5]+(D>>>1&8191),y=s[6]+(8191&(D>>>14|z<<2)),R=s[7]+(8191&(z>>>11|X<<5)),P=s[8]+(8191&(X>>>8|Y<<8)),_=s[9]+(Y>>>5|i),I=0,N=I+U*a+B*(5*b)+H*(5*w)+V*(5*v)+T*(5*g);I=N>>>13,N&=8191,N+=p*(5*f)+y*(5*d)+R*(5*u)+P*(5*l)+_*(5*c),I+=N>>>13,N&=8191;let x=I+U*c+B*a+H*(5*b)+V*(5*w)+T*(5*v);I=x>>>13,x&=8191,x+=p*(5*g)+y*(5*f)+R*(5*d)+P*(5*u)+_*(5*l),I+=x>>>13,x&=8191;let h=I+U*l+B*c+H*a+V*(5*b)+T*(5*w);I=h>>>13,h&=8191,h+=p*(5*v)+y*(5*g)+R*(5*f)+P*(5*d)+_*(5*u),I+=h>>>13,h&=8191;let m=I+U*u+B*l+H*c+V*a+T*(5*b);I=m>>>13,m&=8191,m+=p*(5*w)+y*(5*v)+R*(5*g)+P*(5*f)+_*(5*d),I+=m>>>13,m&=8191;let A=I+U*d+B*u+H*l+V*c+T*a;I=A>>>13,A&=8191,A+=p*(5*b)+y*(5*w)+R*(5*v)+P*(5*g)+_*(5*f),I+=A>>>13,A&=8191;let C=I+U*f+B*d+H*u+V*l+T*c;I=C>>>13,C&=8191,C+=p*a+y*(5*b)+R*(5*w)+P*(5*v)+_*(5*g),I+=C>>>13,C&=8191;let $=I+U*g+B*f+H*d+V*u+T*l;I=$>>>13,$&=8191,$+=p*c+y*a+R*(5*b)+P*(5*w)+_*(5*v),I+=$>>>13,$&=8191;let j=I+U*v+B*g+H*f+V*d+T*u;I=j>>>13,j&=8191,j+=p*l+y*c+R*a+P*(5*b)+_*(5*w),I+=j>>>13,j&=8191;let Z=I+U*w+B*v+H*g+V*f+T*d;I=Z>>>13,Z&=8191,Z+=p*u+y*l+R*c+P*a+_*(5*b),I+=Z>>>13,Z&=8191;let ne=I+U*b+B*w+H*v+V*g+T*f;I=ne>>>13,ne&=8191,ne+=p*d+y*u+R*l+P*c+_*a,I+=ne>>>13,ne&=8191,I=(I<<2)+I|0,I=I+N|0,N=8191&I,I>>>=13,x+=I,s[0]=N,s[1]=x,s[2]=h,s[3]=m,s[4]=A,s[5]=C,s[6]=$,s[7]=j,s[8]=Z,s[9]=ne}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let s=(1^i)-1;for(let a=0;a<10;a++)r[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|r[a];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let o=e[0]+n[0];e[0]=65535&o;for(let a=1;a<8;a++)o=(e[a]+n[a]|0)+(o>>>16)|0,e[a]=65535&o;(0,Wc.clean)(r)}update(e){(0,Tu.exists)(this);const{buffer:n,blockLen:r}=this,i=(e=(0,Wc.toBytes)(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o!==r)n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(n,0,!1),this.pos=0);else for(;r<=i-s;s+=r)this.process(e,s)}return this}destroy(){(0,Wc.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,Tu.exists)(this),(0,Tu.output)(e,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:i}=this;if(i){for(n[i++]=1;i<16;i++)n[i]=0;this.process(n,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=r[o]>>>0,e[s++]=r[o]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function _2(t){const e=(r,i)=>t(i).update((0,Wc.toBytes)(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}nl.poly1305=_2((t=>new M5(t))),(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.xchacha20poly1305=t.chacha20poly1305=t._poly1305_aead=t.chacha12=t.chacha8=t.xchacha20=t.chacha20=t.chacha20orig=void 0,t.hchacha=o;const e=Ma,n=mr,r=nl,i=Xr;function s(d,f,g,v,w,b=20){let E=d[0],M=d[1],S=d[2],F=d[3],D=f[0],z=f[1],X=f[2],Y=f[3],U=f[4],B=f[5],H=f[6],V=f[7],T=w,p=g[0],y=g[1],R=g[2],P=E,_=M,I=S,N=F,x=D,h=z,m=X,A=Y,C=U,$=B,j=H,Z=V,ne=T,se=p,ue=y,de=R;for(let Ce=0;Ce<b;Ce+=2)P=P+x|0,ne=(0,e.rotl)(ne^P,16),C=C+ne|0,x=(0,e.rotl)(x^C,12),P=P+x|0,ne=(0,e.rotl)(ne^P,8),C=C+ne|0,x=(0,e.rotl)(x^C,7),_=_+h|0,se=(0,e.rotl)(se^_,16),$=$+se|0,h=(0,e.rotl)(h^$,12),_=_+h|0,se=(0,e.rotl)(se^_,8),$=$+se|0,h=(0,e.rotl)(h^$,7),I=I+m|0,ue=(0,e.rotl)(ue^I,16),j=j+ue|0,m=(0,e.rotl)(m^j,12),I=I+m|0,ue=(0,e.rotl)(ue^I,8),j=j+ue|0,m=(0,e.rotl)(m^j,7),N=N+A|0,de=(0,e.rotl)(de^N,16),Z=Z+de|0,A=(0,e.rotl)(A^Z,12),N=N+A|0,de=(0,e.rotl)(de^N,8),Z=Z+de|0,A=(0,e.rotl)(A^Z,7),P=P+h|0,de=(0,e.rotl)(de^P,16),j=j+de|0,h=(0,e.rotl)(h^j,12),P=P+h|0,de=(0,e.rotl)(de^P,8),j=j+de|0,h=(0,e.rotl)(h^j,7),_=_+m|0,ne=(0,e.rotl)(ne^_,16),Z=Z+ne|0,m=(0,e.rotl)(m^Z,12),_=_+m|0,ne=(0,e.rotl)(ne^_,8),Z=Z+ne|0,m=(0,e.rotl)(m^Z,7),I=I+A|0,se=(0,e.rotl)(se^I,16),C=C+se|0,A=(0,e.rotl)(A^C,12),I=I+A|0,se=(0,e.rotl)(se^I,8),C=C+se|0,A=(0,e.rotl)(A^C,7),N=N+x|0,ue=(0,e.rotl)(ue^N,16),$=$+ue|0,x=(0,e.rotl)(x^$,12),N=N+x|0,ue=(0,e.rotl)(ue^N,8),$=$+ue|0,x=(0,e.rotl)(x^$,7);let Ae=0;v[Ae++]=E+P|0,v[Ae++]=M+_|0,v[Ae++]=S+I|0,v[Ae++]=F+N|0,v[Ae++]=D+x|0,v[Ae++]=z+h|0,v[Ae++]=X+m|0,v[Ae++]=Y+A|0,v[Ae++]=U+C|0,v[Ae++]=B+$|0,v[Ae++]=H+j|0,v[Ae++]=V+Z|0,v[Ae++]=T+ne|0,v[Ae++]=p+se|0,v[Ae++]=y+ue|0,v[Ae++]=R+de|0}function o(d,f,g,v){let w=d[0],b=d[1],E=d[2],M=d[3],S=f[0],F=f[1],D=f[2],z=f[3],X=f[4],Y=f[5],U=f[6],B=f[7],H=g[0],V=g[1],T=g[2],p=g[3];for(let R=0;R<20;R+=2)w=w+S|0,H=(0,e.rotl)(H^w,16),X=X+H|0,S=(0,e.rotl)(S^X,12),w=w+S|0,H=(0,e.rotl)(H^w,8),X=X+H|0,S=(0,e.rotl)(S^X,7),b=b+F|0,V=(0,e.rotl)(V^b,16),Y=Y+V|0,F=(0,e.rotl)(F^Y,12),b=b+F|0,V=(0,e.rotl)(V^b,8),Y=Y+V|0,F=(0,e.rotl)(F^Y,7),E=E+D|0,T=(0,e.rotl)(T^E,16),U=U+T|0,D=(0,e.rotl)(D^U,12),E=E+D|0,T=(0,e.rotl)(T^E,8),U=U+T|0,D=(0,e.rotl)(D^U,7),M=M+z|0,p=(0,e.rotl)(p^M,16),B=B+p|0,z=(0,e.rotl)(z^B,12),M=M+z|0,p=(0,e.rotl)(p^M,8),B=B+p|0,z=(0,e.rotl)(z^B,7),w=w+F|0,p=(0,e.rotl)(p^w,16),U=U+p|0,F=(0,e.rotl)(F^U,12),w=w+F|0,p=(0,e.rotl)(p^w,8),U=U+p|0,F=(0,e.rotl)(F^U,7),b=b+D|0,H=(0,e.rotl)(H^b,16),B=B+H|0,D=(0,e.rotl)(D^B,12),b=b+D|0,H=(0,e.rotl)(H^b,8),B=B+H|0,D=(0,e.rotl)(D^B,7),E=E+z|0,V=(0,e.rotl)(V^E,16),X=X+V|0,z=(0,e.rotl)(z^X,12),E=E+z|0,V=(0,e.rotl)(V^E,8),X=X+V|0,z=(0,e.rotl)(z^X,7),M=M+S|0,T=(0,e.rotl)(T^M,16),Y=Y+T|0,S=(0,e.rotl)(S^Y,12),M=M+S|0,T=(0,e.rotl)(T^M,8),Y=Y+T|0,S=(0,e.rotl)(S^Y,7);let y=0;v[y++]=w,v[y++]=b,v[y++]=E,v[y++]=M,v[y++]=H,v[y++]=V,v[y++]=T,v[y++]=p}t.chacha20orig=(0,e.createCipher)(s,{counterRight:!1,counterLength:8,allowShortKeys:!0}),t.chacha20=(0,e.createCipher)(s,{counterRight:!1,counterLength:4,allowShortKeys:!1}),t.xchacha20=(0,e.createCipher)(s,{counterRight:!1,counterLength:8,extendNonceFn:o,allowShortKeys:!1}),t.chacha8=(0,e.createCipher)(s,{counterRight:!1,counterLength:4,rounds:8}),t.chacha12=(0,e.createCipher)(s,{counterRight:!1,counterLength:4,rounds:12});const a=new Uint8Array(16),c=(d,f)=>{d.update(f);const g=f.length%16;g&&d.update(a.subarray(g))},l=new Uint8Array(32);function u(d,f,g,v,w){const b=d(f,g,l),E=r.poly1305.create(b);w&&c(E,w),c(E,v);const M=new Uint8Array(16),S=(0,i.createView)(M);(0,i.setBigUint64)(S,0,BigInt(w?w.length:0),!0),(0,i.setBigUint64)(S,8,BigInt(v.length),!0),E.update(M);const F=E.digest();return(0,i.clean)(b,M),F}t._poly1305_aead=d=>(f,g,v)=>((0,n.bytes)(f,32),(0,n.bytes)(g),{encrypt(b,E){const M=b.length,S=M+16;E?(0,n.bytes)(E,S):E=new Uint8Array(S),d(f,g,b,E,1);const F=u(d,f,g,E.subarray(0,-16),v);return E.set(F,M),(0,i.clean)(F),E},decrypt(b,E){const M=b.length,S=M-16;if(M<16)throw new Error("encrypted data must be at least 16 bytes");E?(0,n.bytes)(E,S):E=new Uint8Array(S);const F=b.subarray(0,-16),D=b.subarray(-16),z=u(d,f,g,F,v);if(!(0,i.equalBytes)(D,z))throw new Error("invalid tag");return d(f,g,F,E,1),(0,i.clean)(z),E}}),t.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,t._poly1305_aead)(t.chacha20)),t.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,t._poly1305_aead)(t.xchacha20))})(v2),Object.defineProperty(jd,"__esModule",{value:!0}),jd.xchacha20=void 0;var pa,o1,Lc,k5=v2;jd.xchacha20=function(t,e,n){return(0,k5.xchacha20poly1305)(t,e,n)},(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.aesDecrypt=t.aesEncrypt=t.symDecrypt=t.symEncrypt=void 0;var e=Xr,n=Ag,r=Va,i=jd,s=yl,o=Vn;t.symEncrypt=function(u,d,f){return a(c,u,d,f)};function a(u,d,f,g){var v=(0,s.symmetricAlgorithm)();if(v==="aes-256-gcm")return u(r.aes256gcm,d,f,(0,s.symmetricNonceLength)(),o.AEAD_TAG_LENGTH,g);if(v==="xchacha20")return u(i.xchacha20,d,f,o.XCHACHA20_NONCE_LENGTH,o.AEAD_TAG_LENGTH,g);if(v==="aes-256-cbc")return u(r.aes256cbc,d,f,16,0);throw new Error("Not implemented")}function c(u,d,f,g,v,w){var b=(0,n.randomBytes)(g),E=u(d,b,w).encrypt(f);if(v===0)return(0,e.concatBytes)(b,E);var M=E.length-v,S=E.subarray(0,M),F=E.subarray(M);return(0,e.concatBytes)(b,F,S)}function l(u,d,f,g,v,w){var b=f.subarray(0,g),E=u(d,Uint8Array.from(b),w),M=f.subarray(g);if(v===0)return E.decrypt(M);var S=M.subarray(0,v),F=M.subarray(v);return E.decrypt((0,e.concatBytes)(F,S))}t.symDecrypt=function(u,d,f){return a(l,u,d,f)},t.aesEncrypt=t.symEncrypt,t.aesDecrypt=t.symDecrypt})(Jv),pa=Uf,o1=fi&&fi.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Lc=fi&&fi.__exportStar||function(t,e){for(var n in t)n==="default"||Object.prototype.hasOwnProperty.call(e,n)||o1(e,t,n)},Object.defineProperty(pa,"__esModule",{value:!0}),Lc(xx,pa),Lc(s2,pa),Lc(K0,pa),Lc(Jv,pa);var bl={};Object.defineProperty(bl,"__esModule",{value:!0}),bl.PublicKey=void 0;var a1=Xr,Cu=Uf,D5=(function(){function t(e){this.data=(0,Cu.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,Cu.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return Se.from((0,Cu.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"compressed",{get:function(){return Se.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(e){return e===void 0&&(e=!0),(0,a1.bytesToHex)(e?this.data:this.uncompressed)},t.prototype.decapsulate=function(e,n){n===void 0&&(n=!1);var r=n?this.data:this.uncompressed,i=e.multiply(this,n);return(0,Cu.getSharedKey)(r,i)},t.prototype.equals=function(e){return(0,a1.equalBytes)(this.data,e.data)},t})();bl.PublicKey=D5,Object.defineProperty(Bd,"__esModule",{value:!0}),Bd.PrivateKey=void 0;var c1=Xr,ma=Uf,L5=bl,B5=(function(){function t(e){if(e===void 0)this.data=(0,ma.getValidSecret)();else{if(!(0,ma.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new L5.PublicKey((0,ma.getPublicKey)(this.data))}return t.fromHex=function(e){return new t((0,ma.decodeHex)(e))},Object.defineProperty(t.prototype,"secret",{get:function(){return Se.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(){return(0,c1.bytesToHex)(this.data)},t.prototype.encapsulate=function(e,n){n===void 0&&(n=!1);var r=n?this.publicKey.compressed:this.publicKey.uncompressed,i=this.multiply(e,n);return(0,ma.getSharedKey)(r,i)},t.prototype.multiply=function(e,n){return n===void 0&&(n=!1),(0,ma.getSharedPoint)(this.data,e.compressed,n)},t.prototype.equals=function(e){return(0,c1.equalBytes)(this.data,e.data)},t})();Bd.PrivateKey=B5,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=t.PrivateKey=void 0;var e=Bd;Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return e.PrivateKey}});var n=bl;Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})})($h),(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.PublicKey=t.PrivateKey=t.ECIES_CONFIG=void 0,t.encrypt=function(a,c){var l=new r.PrivateKey,u=a instanceof Uint8Array?new r.PublicKey(a):r.PublicKey.fromHex(a),d=l.encapsulate(u,(0,n.isHkdfKeyCompressed)()),f=(0,n.isEphemeralKeyCompressed)()?l.publicKey.compressed:l.publicKey.uncompressed,g=(0,i.symEncrypt)(d,c);return Se.from((0,e.concatBytes)(f,g))},t.decrypt=function(a,c){var l=a instanceof Uint8Array?new r.PrivateKey(a):r.PrivateKey.fromHex(a),u=(0,n.ephemeralKeySize)(),d=new r.PublicKey(c.subarray(0,u)),f=c.subarray(u),g=d.decapsulate(l,(0,n.isHkdfKeyCompressed)());return Se.from((0,i.symDecrypt)(g,f))};var e=Xr,n=yl,r=$h,i=Uf,s=yl;Object.defineProperty(t,"ECIES_CONFIG",{enumerable:!0,get:function(){return s.ECIES_CONFIG}});var o=$h;Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return o.PrivateKey}}),Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return o.PublicKey}}),t.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}})(_a);const S2=Ir("KeyExchange:Layer"),x2=Ir("SocketService:Layer"),A2=Ir("Ecies:Layer"),R2=Ir("RemoteCommunication:Layer");S2.color="##95c44e",x2.color="#f638d7",A2.color="#465b9c",R2.color="#47a2be";const pe={KeyExchange:S2,SocketService:x2,Ecies:A2,RemoteCommunication:R2};let Bc,Ou=[],tp=[];const Ts=(t,e)=>_e(void 0,void 0,void 0,(function*(){Bc=e,tp.push(t),(function(n){return _e(this,void 0,void 0,(function*(){if(!Bc||!n)return;(function(){const o=tp;tp=Ou,Ou=o})();const r=Bc.endsWith("/")?`${Bc}evt`:`${Bc}/evt`,i=Object.assign({},n);if(delete i.params,n.params)for(const[o,a]of Object.entries(n.params))i[o]=a;const s=JSON.stringify(i);pe.RemoteCommunication(`[sendBufferedEvents] Sending ${Ou.length} analytics events to ${r}`);try{const o=yield jS(r,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:s}),a=yield o.text();pe.RemoteCommunication(`[sendBufferedEvents] Response: ${a}`),Ou.length=0}catch{}}))})(t).catch((()=>{}))}));class np{constructor(e){this.enabled=!0,e?.debug&&Ir.enable("Ecies:Layer"),this.ecies=e?.privateKey?_a.PrivateKey.fromHex(e.privateKey):new _a.PrivateKey,pe.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),pe.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),pe.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new _a.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,n){let r=e;if(this.enabled)try{pe.Ecies("[ECIES: encrypt()] using otherPublicKey",n);const i=Se.from(e),s=_a.encrypt(n,i);r=Se.from(s).toString("base64")}catch(i){throw pe.Ecies("[ECIES: encrypt()] error encrypt:",i),pe.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),pe.Ecies("[ECIES: encrypt()] data: ",e),pe.Ecies("[ECIES: encrypt()] otherkey: ",n),i}return r}decrypt(e){let n=e;if(this.enabled)try{pe.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const r=Se.from(e.toString(),"base64");n=_a.decrypt(this.ecies.toHex(),r).toString()}catch(r){throw pe.Ecies("[ECIES: decrypt()] error decrypt",r),pe.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),pe.Ecies("[ECIES: decrypt()] encryptedData: ",e),r}return n}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){pe.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var go={version:"0.33.1"};const Qa="https://metamask-sdk.api.cx.metamask.io/",U5=["websocket"],ec=6048e5,$5=3e3,dr={METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_WATCHASSET:"wallet_watchAsset",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},F5=[dr.METAMASK_CONNECTSIGN,dr.METAMASK_CONNECTWITH,dr.METAMASK_OPEN,dr.METAMASK_BATCH,dr.PERSONAL_SIGN,dr.WALLET_REQUESTPERMISSIONS,dr.WALLET_REVOKEPERMISSIONS,dr.WALLET_WATCHASSET,dr.ETH_SENDTRANSACTION,dr.ETH_SIGNTYPEDDATA,dr.ETH_SIGNTYPEDDATA_V3,dr.ETH_SIGNTYPEDDATA_V4,dr.ETH_SIGNTRANSACTION,dr.ETH_SIGN,dr.PERSONAL_EC_RECOVER];function Vl(t){return F5.includes(t)}function I2(t){const{context:e}=t;pe.RemoteCommunication(`[RemoteCommunication: clean()] context=${e}`),t.channelConfig=void 0,t.ready=!1,t.originatorConnectStarted=!1}var Qn,Ne,Hd,Zt,pn,Pn,ga;(ga=Qn||(Qn={})).DISCONNECTED="disconnected",ga.WAITING="waiting",ga.TIMEOUT="timeout",ga.LINKED="linked",ga.PAUSED="paused",ga.TERMINATED="terminated",(function(t){t.KEY_INFO="key_info",t.SERVICE_STATUS="service_status",t.PROVIDER_UPDATE="provider_update",t.RPC_UPDATE="rpc_update",t.KEYS_EXCHANGED="keys_exchanged",t.JOIN_CHANNEL="join_channel",t.PUBLIC_KEY="public_key",t.CHANNEL_CREATED="channel_created",t.CLIENTS_CONNECTED="clients_connected",t.CLIENTS_DISCONNECTED="clients_disconnected",t.CLIENTS_WAITING="clients_waiting",t.CLIENTS_READY="clients_ready",t.REJECTED="rejected",t.WALLET_INIT="wallet_init",t.CHANNEL_PERSISTENCE="channel_persistence",t.CONFIG="config",t.MESSAGE_ACK="ack",t.SOCKET_DISCONNECTED="socket_disconnected",t.SOCKET_RECONNECT="socket_reconnect",t.OTP="otp",t.SDK_RPC_CALL="sdk_rpc_call",t.AUTHORIZED="authorized",t.CONNECTION_STATUS="connection_status",t.MESSAGE="message",t.TERMINATE="terminate"})(Ne||(Ne={})),(Hd||(Hd={})).KEY_EXCHANGE="key_exchange",(function(t){t.KEY_HANDSHAKE_START="key_handshake_start",t.KEY_HANDSHAKE_CHECK="key_handshake_check",t.KEY_HANDSHAKE_SYN="key_handshake_SYN",t.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",t.KEY_HANDSHAKE_ACK="key_handshake_ACK",t.KEY_HANDSHAKE_WALLET="key_handshake_wallet",t.KEY_HANDSHAKE_NONE="none"})(Zt||(Zt={}));class K5 extends Nf.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:n,context:r,ecies:i,logging:s}){super(),this.keysExchanged=!1,this.step=Zt.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=r,this.communicationLayer=e,i?.privateKey&&n&&(pe.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${n} set keysExchanged to true!`,i),this.keysExchanged=!0),this.myECIES=new np(Object.assign(Object.assign({},i),{debug:s?.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=s?.keyExchangeLayer===!0,n&&this.setOtherPublicKey(n),this.communicationLayer.on(Hd.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:n}=this.communicationLayer.remote.state;if(pe.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${n}`,e),n)return void pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:r}=e;this.keysExchanged&&pe.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(Ne.KEY_INFO,r.type),r.type===Zt.KEY_HANDSHAKE_SYN?(this.checkStep([Zt.KEY_HANDSHAKE_NONE,Zt.KEY_HANDSHAKE_ACK]),pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",r),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:Zt.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((i=>{pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",i)})),this.setStep(Zt.KEY_HANDSHAKE_ACK)):r.type===Zt.KEY_HANDSHAKE_SYNACK?(this.checkStep([Zt.KEY_HANDSHAKE_SYNACK,Zt.KEY_HANDSHAKE_ACK,Zt.KEY_HANDSHAKE_NONE]),pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:Zt.KEY_HANDSHAKE_ACK}).catch((i=>{pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",i)})),this.keysExchanged=!0,this.setStep(Zt.KEY_HANDSHAKE_ACK),this.emit(Ne.KEYS_EXCHANGED)):r.type===Zt.KEY_HANDSHAKE_ACK&&(pe.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Zt.KEY_HANDSHAKE_ACK,Zt.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Zt.KEY_HANDSHAKE_ACK),this.emit(Ne.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new np(e)}clean(){pe.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Zt.KEY_HANDSHAKE_NONE),this.emit(Ne.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:n}){const{relayPersistence:r,protocolVersion:i}=this.communicationLayer.remote.state,s=i>=2;r?pe.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(pe.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${i} isOriginator=${e} step=${this.step} force=${n} relayPersistence=${r} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Zt.KEY_HANDSHAKE_NONE&&this.step!==Zt.KEY_HANDSHAKE_SYNACK)||n?(pe.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${n}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Zt.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Zt.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((o=>{pe.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",o)}))):pe.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&n!==!0?pe.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):s?this.communicationLayer.sendMessage({type:Zt.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((o=>{pe.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",o)})):(this.communicationLayer.sendMessage({type:Zt.KEY_HANDSHAKE_START}).catch((o=>{pe.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",o)})),this.clean()))}setStep(e){this.step=e,this.emit(Ne.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:n}){this.otherPublicKey=n,this.myECIES=new np({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){pe.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}(function(t){t.TERMINATE="terminate",t.ANSWER="answer",t.OFFER="offer",t.CANDIDATE="candidate",t.JSONRPC="jsonrpc",t.WALLET_INFO="wallet_info",t.WALLET_INIT="wallet_init",t.ORIGINATOR_INFO="originator_info",t.PAUSE="pause",t.OTP="otp",t.AUTHORIZED="authorized",t.PING="ping",t.READY="ready"})(pn||(pn={})),(function(t){t.REQUEST="sdk_connect_request_started",t.REQUEST_MOBILE="sdk_connect_request_started_mobile",t.RECONNECT="sdk_reconnect_request_started",t.CONNECTED="sdk_connection_established",t.CONNECTED_MOBILE="sdk_connection_established_mobile",t.AUTHORIZED="sdk_connection_authorized",t.REJECTED="sdk_connection_rejected",t.TERMINATED="sdk_connection_terminated",t.DISCONNECTED="sdk_disconnected",t.SDK_USE_EXTENSION="sdk_use_extension",t.SDK_RPC_REQUEST="sdk_rpc_request",t.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",t.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",t.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",t.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"})(Pn||(Pn={}));const ad=(t,e,n)=>_e(void 0,void 0,void 0,(function*(){var r,i,s,o,a,c;const{remote:l,state:u}=t,{channelId:d,isOriginator:f}=u;if(e==="error_terminated")return pe.SocketService(`handleJoinChannelResults: Channel ${d} terminated`),void t.emit(Ne.TERMINATE);if(!n)return void pe.SocketService(`handleJoinChannelResults: No result for channel ${d}`);const{persistence:g,walletKey:v,rejected:w}=n;if(pe.SocketService(`handleJoinChannelResults: Channel ${d} persistence=${g} walletKey=${v} rejected=${w}`),w)return pe.SocketService(`handleJoinChannelResults: Channel ${d} rejected`),yield t.remote.disconnect({terminate:!0}),t.remote.emit(Ne.REJECTED,{channelId:d}),void t.remote.emitServiceStatusEvent();if(v&&!(!((r=l.state.channelConfig)===null||r===void 0)&&r.otherKey)){t.getKeyExchange().setOtherPublicKey(v),(i=t.state.keyExchange)===null||i===void 0||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Ne.AUTHORIZED);const{communicationLayer:b,storageManager:E}=l.state,M=Object.assign(Object.assign({},l.state.channelConfig),{channelId:(s=l.state.channelId)!==null&&s!==void 0?s:"",validUntil:Date.now()+ec,localKey:b?.getKeyInfo().ecies.private,otherKey:v});t.sendMessage({type:Zt.KEY_HANDSHAKE_ACK}).catch((S=>{})),(o=t.state.socket)===null||o===void 0||o.emit(pn.PING,{id:d,clientType:f?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield E?.persistChannelConfig(M),l.emitServiceStatusEvent(),l.setConnectionStatus(Qn.LINKED)}g&&(t.emit(Ne.CHANNEL_PERSISTENCE),(a=t.state.keyExchange)===null||a===void 0||a.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Ne.AUTHORIZED),Ts(Object.assign(Object.assign({id:d??"",event:f?Pn.CONNECTED:Pn.CONNECTED_MOBILE},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:go.version,walletVersion:(c=t.remote.state.walletInfo)===null||c===void 0?void 0:c.version}),u.communicationServerUrl).catch((b=>{})))})),Ha=t=>new Promise((e=>{setTimeout(e,t)})),l1=(t,e,...n)=>_e(void 0,[t,e,...n],void 0,(function*(r,i,s=200){let o;const a=Date.now();let c=!1;for(;!c;){if(c=Date.now()-a>3e5,o=i[r],o.elapsedTime!==void 0)return o;yield Ha(s)}throw new Error(`RPC ${r} timed out`)})),z0=t=>_e(void 0,void 0,void 0,(function*(){const{state:e}=t,{socket:n,channelId:r,context:i,isOriginator:s,isReconnecting:o}=e;if(o)return pe.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",t),!1;if(!n)return pe.SocketService("[SocketService: reconnectSocket()] socket is not defined",t),!1;if(!r)return!1;const{connected:a}=n;e.isReconnecting=!0,e.reconnectionAttempts=0,pe.SocketService(`[SocketService: reconnectSocket()] connected=${a} trying to reconnect after socketio disconnection`,t);try{for(;3>e.reconnectionAttempts;){if(pe.SocketService(`[SocketService: reconnectSocket()] Attempt ${e.reconnectionAttempts+1} of 3`,t),yield Ha(200),n.connected)return pe.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(pn.PING,{id:r,clientType:s?"dapp":"wallet",context:"on_channel_config",message:""}),!0;e.resumed=!0,n.connect(),t.emit(Ne.SOCKET_RECONNECT);try{if(yield new Promise(((c,l)=>{n.emit(Ne.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:s?"dapp":"wallet"},((u,d)=>_e(void 0,void 0,void 0,(function*(){try{yield ad(t,u,d),c()}catch(f){l(f)}}))))})),yield Ha(100),n.connected)return pe.SocketService(`Reconnection successful on attempt ${e.reconnectionAttempts+1}`),!0}catch(c){pe.SocketService(`Error during reconnection attempt ${e.reconnectionAttempts+1}:`,c)}e.reconnectionAttempts+=1,3>e.reconnectionAttempts&&(yield Ha(200))}return pe.SocketService("Failed to reconnect after 3 attempts"),!1}finally{e.isReconnecting=!1,e.reconnectionAttempts=0}}));function T2(t,e){return _e(this,void 0,void 0,(function*(){var n;const r=(n=t.state.keyExchange)===null||n===void 0?void 0:n.encryptMessage(JSON.stringify(e)),i={id:t.state.channelId,context:t.state.context,clientType:t.state.isOriginator?"dapp":"wallet",message:r,plaintext:t.state.hasPlaintext?JSON.stringify(e):void 0};return pe.SocketService(`[SocketService: encryptAndSendMessage()] context=${t.state.context}`,i),e.type===pn.TERMINATE&&(t.state.manualDisconnect=!0),new Promise(((s,o)=>{var a;(a=t.state.socket)===null||a===void 0||a.emit(Ne.MESSAGE,i,((c,l)=>{var u;c&&(pe.SocketService(`[SocketService: encryptAndSendMessage()] error=${c}`),o(c)),pe.SocketService("[encryptAndSendMessage] response",l),s((u=l?.success)!==null&&u!==void 0&&u)}))}))}))}var ka;(function(t){t.RPC_CHECK="rpcCheck",t.SKIPPED_RPC="skippedRpc"})(ka||(ka={}));const C2=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map((t=>t.toLowerCase())),V5=[{event:Ne.CLIENTS_CONNECTED,handler:function(t,e){return n=>_e(this,void 0,void 0,(function*(){var r,i,s,o,a,c,l,u,d,f,g;const v=(i=(r=t.remote.state.channelConfig)===null||r===void 0?void 0:r.relayPersistence)!==null&&i!==void 0&&i;if(pe.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected-${e}' relayPersistence=${v} resumed=${t.state.resumed} clientsPaused=${t.state.clientsPaused} keysExchanged=${(s=t.state.keyExchange)===null||s===void 0?void 0:s.areKeysExchanged()} isOriginator=${t.state.isOriginator}`),t.emit(Ne.CLIENTS_CONNECTED,{isOriginator:t.state.isOriginator,keysExchanged:(o=t.state.keyExchange)===null||o===void 0?void 0:o.areKeysExchanged(),context:t.state.context}),t.state.resumed)t.state.isOriginator||(pe.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} 'clients_connected' / keysExchanged=${(a=t.state.keyExchange)===null||a===void 0?void 0:a.areKeysExchanged()} -- backward compatibility`),(c=t.state.keyExchange)===null||c===void 0||c.start({isOriginator:(l=t.state.isOriginator)!==null&&l!==void 0&&l})),t.state.resumed=!1;else if(t.state.clientsPaused)pe.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!t.state.isOriginator){const w=!v;pe.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${(u=t.state.keyExchange)===null||u===void 0?void 0:u.areKeysExchanged()} -- force=${w} -- backward compatibility`),pe.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${(d=t.state.keyExchange)===null||d===void 0?void 0:d.areKeysExchanged()} -- force=${w} -- backward compatibility`),(f=t.state.keyExchange)===null||f===void 0||f.start({isOriginator:(g=t.state.isOriginator)!==null&&g!==void 0&&g,force:w})}t.state.clientsConnected=!0,t.state.clientsPaused=!1}))}},{event:Ne.CHANNEL_CREATED,handler:function(t,e){return n=>{pe.SocketService(`[SocketService: handleChannelCreated()] context=${t.state.context} on 'channel_created-${e}'`,n),t.emit(Ne.CHANNEL_CREATED,n)}}},{event:Ne.CLIENTS_DISCONNECTED,handler:function(t,e){return()=>{var n;t.state.clientsConnected=!1,pe.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${e}'`),t.remote.state.relayPersistence?pe.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${e}' - relayPersistence enabled, skipping key exchange cleanup.`):(t.state.isOriginator&&!t.state.clientsPaused&&((n=t.state.keyExchange)===null||n===void 0||n.clean()),t.emit(Ne.CLIENTS_DISCONNECTED,e))}}},{event:Ne.CONFIG,handler:function(t,e){return n=>_e(this,void 0,void 0,(function*(){var r,i,s;pe.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${e}'`,n);const{persistence:o,walletKey:a}=n;t.state.isOriginator&&t.remote.state.channelConfig?(n.walletKey&&!t.remote.state.channelConfig.otherKey&&(pe.SocketService(`Setting wallet key ${a}`),t.remote.state.channelConfig.otherKey=a,t.getKeyExchange().setOtherPublicKey(n.walletKey),(r=t.state.keyExchange)===null||r===void 0||r.setKeysExchanged(!0),yield t.remote.sendMessage({type:Zt.KEY_HANDSHAKE_ACK}),yield t.remote.sendMessage({type:pn.PING}),yield(i=t.remote.state.storageManager)===null||i===void 0?void 0:i.persistChannelConfig(t.remote.state.channelConfig)),o!==!0||t.remote.state.channelConfig.relayPersistence||(pe.SocketService(`Setting relay persistence ${o}`),t.remote.state.channelConfig.relayPersistence=o,t.remote.state.relayPersistence=!0,t.remote.emit(Ne.CHANNEL_PERSISTENCE),t.remote.state.authorized=!0,t.remote.state.ready=!0,t.remote.emit(Ne.AUTHORIZED),yield(s=t.remote.state.storageManager)===null||s===void 0?void 0:s.persistChannelConfig(t.remote.state.channelConfig))):t.state.isOriginator||n.persistence&&(t.remote.state.relayPersistence=!0,t.remote.emit(Ne.CHANNEL_PERSISTENCE))}))}},{event:Ne.MESSAGE,handler:function(t,e){return n=>{var r,i,s,o,a,c,l,u,d,f,g,v,w,b,E,M,S,F;const{ackId:D,message:z,error:X}=n,Y=(r=t.remote.state.relayPersistence)!==null&&r!==void 0&&r;if(pe.SocketService(`[SocketService handleMessage()] relayPersistence=${Y} context=${t.state.context} on 'message' ${e} keysExchanged=${(i=t.state.keyExchange)===null||i===void 0?void 0:i.areKeysExchanged()}`,n),X)throw pe.SocketService(`
|
|
16
|
+
[SocketService handleMessage()] context=${t.state.context}::on 'message' error=${X}`),new Error(X);const U=typeof z=="string";if(!U&&z?.type===Zt.KEY_HANDSHAKE_START)return Y?void 0:(pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received HANDSHAKE_START isOriginator=${t.state.isOriginator}`,z),void((s=t.state.keyExchange)===null||s===void 0||s.start({isOriginator:(o=t.state.isOriginator)!==null&&o!==void 0&&o,force:!0})));if(!U&&(!((a=z?.type)===null||a===void 0)&&a.startsWith("key_handshake")))return Y?void 0:(pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' emit KEY_EXCHANGE`,z),void t.emit(Hd.KEY_EXCHANGE,{message:z,context:t.state.context}));if(U&&!(!((c=t.state.keyExchange)===null||c===void 0)&&c.areKeysExchanged())){let V=!1;try{pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' trying to decrypt message`),(l=t.state.keyExchange)===null||l===void 0||l.decryptMessage(z),V=!0}catch(T){pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' error`,T)}if(!V)return t.state.isOriginator?(d=t.state.keyExchange)===null||d===void 0||d.start({isOriginator:(f=t.state.isOriginator)!==null&&f!==void 0&&f}):t.sendMessage({type:Zt.KEY_HANDSHAKE_START}).catch((T=>{})),void pe.SocketService(`Message ignored because invalid key exchange status. step=${(g=t.state.keyExchange)===null||g===void 0?void 0:g.getKeyInfo().step}`,(v=t.state.keyExchange)===null||v===void 0?void 0:v.getKeyInfo(),z);pe.SocketService("Invalid key exchange status detected --- updating it."),(u=t.state.keyExchange)===null||u===void 0||u.setKeysExchanged(!0)}else if(!U&&z?.type)return void t.emit(Ne.MESSAGE,z);if(!U)return void t.emit(Ne.MESSAGE,z);const B=(w=t.state.keyExchange)===null||w===void 0?void 0:w.decryptMessage(z),H=JSON.parse(B??"{}");if(D&&D?.length>0&&(pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' ackid=${D} channelId=${e}`),(b=t.state.socket)===null||b===void 0||b.emit(Ne.MESSAGE_ACK,{ackId:D,channelId:e,clientType:t.state.isOriginator?"dapp":"wallet"})),t.state.clientsPaused=H?.type===pn.PAUSE,t.state.isOriginator&&H.data){const V=H.data,T=t.state.rpcMethodTracker[V.id];if(T){const p=Date.now()-T.timestamp;pe.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received answer for id=${V.id} method=${T.method} responseTime=${p}`,H),t.remote.state.analytics&&C2.includes(T.method.toLowerCase())&&Ts(Object.assign(Object.assign({id:(E=t.remote.state.channelId)!==null&&E!==void 0?E:"",event:Pn.SDK_RPC_REQUEST_DONE,sdkVersion:t.remote.state.sdkVersion,commLayerVersion:go.version},t.remote.state.originatorInfo),{walletVersion:(M=t.remote.state.walletInfo)===null||M===void 0?void 0:M.version,params:{method:T.method,from:"mobile"}}),t.remote.state.communicationServerUrl).catch((R=>{})),Vl(T.method)&&On.analytics.track(V.error?V.error.code===4001?"sdk_action_rejected":"sdk_action_failed":"sdk_action_succeeded",{action:T.method});const y=Object.assign(Object.assign({},T),{result:V.result,error:V.error?{code:(S=V.error)===null||S===void 0?void 0:S.code,message:(F=V.error)===null||F===void 0?void 0:F.message}:void 0,elapsedTime:p});t.state.rpcMethodTracker[V.id]=y,t.emit(Ne.RPC_UPDATE,y)}}t.emit(Ne.MESSAGE,{message:H})}}},{event:Ne.REJECTED,handler:function(t,e){return n=>_e(this,void 0,void 0,(function*(){var r;t.state.isOriginator&&!t.remote.state.ready?(pe.SocketService(`[SocketService: handleChannelRejected()] context=${t.state.context} channelId=${e} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`,t.remote.state.originatorInfo),Ts(Object.assign(Object.assign({id:e,event:Pn.REJECTED},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:go.version,walletVersion:(r=t.remote.state.walletInfo)===null||r===void 0?void 0:r.version}),t.remote.state.communicationServerUrl).catch((i=>{})),On.analytics.track("sdk_connection_rejected",{transport_type:"websocket"}),yield t.remote.disconnect({terminate:!0}),t.remote.emit(Ne.REJECTED,{channelId:e}),t.remote.setConnectionStatus(Qn.DISCONNECTED)):pe.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${e} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`)}))}},{event:"clients_waiting_to_join",handler:function(t,e){return n=>{pe.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${t.state.context} on 'clients_waiting_to_join-${e}'`,n),t.emit(Ne.CLIENTS_WAITING,n)}}}],j5=[{event:Ne.KEY_INFO,handler:function(t){return e=>{pe.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",e),t.emit(Ne.KEY_INFO,e)}}},{event:Ne.KEYS_EXCHANGED,handler:function(t){return()=>{var e,n,r;pe.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${(e=t.state.keyExchange)===null||e===void 0?void 0:e.areKeysExchanged()}`);const{channelConfig:i}=t.remote.state;if(i){const o=t.getKeyExchange().getKeyInfo().ecies;i.localKey=o.private,i.otherKey=o.otherPubKey,t.remote.state.channelConfig=i,(n=t.remote.state.storageManager)===null||n===void 0||n.persistChannelConfig(i).catch((a=>{}))}t.emit(Ne.KEYS_EXCHANGED,{keysExchanged:(r=t.state.keyExchange)===null||r===void 0?void 0:r.areKeysExchanged(),isOriginator:t.state.isOriginator});const s={keyInfo:t.getKeyInfo()};t.emit(Ne.SERVICE_STATUS,s)}}}];function u1(t,e){pe.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} setting socket listeners for channel ${e}...`);const{socket:n}=t.state,{keyExchange:r}=t.state;n&&t.state.isOriginator&&(t.state.debug&&(n?.io.on("error",(i=>{pe.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=error`,i)})),n?.io.on("reconnect",(i=>{pe.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect`,i),z0(t).catch((s=>{}))})),n?.io.on("reconnect_error",(i=>{pe.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_error`,i)})),n?.io.on("reconnect_failed",(()=>{pe.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_failed`)}))),n?.on("disconnect",(i=>(pe.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${i}' begin recovery...`),(function(s){return o=>{pe.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${s.state.manualDisconnect}`,o),s.state.manualDisconnect||(s.emit(Ne.SOCKET_DISCONNECTED),z0(s).catch((a=>{})))}})(t)(i))))),V5.forEach((({event:i,handler:s})=>{n?.on(`${i}-${e}`,s(t,e))})),j5.forEach((({event:i,handler:s})=>{r?.on(i,s(t))})),t.state.setupChannelListeners=!0}class H5 extends Nf.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:n,communicationLayerPreference:r,communicationServerUrl:i,context:s,remote:o,logging:a}=e;this.state.resumed=n,this.state.context=s,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=r,this.state.debug=a?.serviceLayer===!0,this.remote=o,a?.serviceLayer===!0&&Ir.enable("SocketService:Layer"),this.state.communicationServerUrl=i,this.state.hasPlaintext=this.state.communicationServerUrl!==Qa&&a?.plaintext===!0,pe.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:n,ecies:r,logging:i}=this.options,s={autoConnect:!1,transports:U5,withCredentials:!0},o=this.state.communicationServerUrl;pe.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=rd(o,s),(function(c){if(typeof window<"u"&&typeof document<"u"&&(pe.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,c),!c.state.focusListenerAdded)){const l=()=>{pe.SocketService("Document has focus --- reconnecting socket"),z0(c).catch((u=>{}))};window.addEventListener("focus",l),c.state.focusListenerAdded=!0,c.state.removeFocusListener=()=>{window.removeEventListener("focus",l),c.state.focusListenerAdded=!1}}})(this);const a={communicationLayer:this,otherPublicKey:n,sendPublicKey:!1,context:(e=this.state.context)!==null&&e!==void 0?e:"",ecies:r,logging:i};this.state.keyExchange=new K5(a)}resetKeys(){return pe.SocketService("[SocketService: resetKeys()] Resetting keys."),void((e=this.state.keyExchange)===null||e===void 0||e.resetKeys());var e}createChannel(){return _e(this,void 0,void 0,(function*(){return(function(e){return _e(this,void 0,void 0,(function*(){var n,r,i;if(pe.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),(n=e.state.socket)===null||n===void 0?void 0:n.connected)throw new Error("socket already connected");(r=e.state.socket)===null||r===void 0||r.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const s=hs();e.state.channelId=s,u1(e,s),yield new Promise(((a,c)=>{var l;(l=e.state.socket)===null||l===void 0||l.emit(Ne.JOIN_CHANNEL,{channelId:s,context:`${e.state.context}createChannel`,clientType:"dapp"},((u,d)=>_e(this,void 0,void 0,(function*(){try{yield ad(e,u,d),a()}catch(f){c(f)}}))))}));const o=(i=e.state.keyExchange)===null||i===void 0?void 0:i.getKeyInfo();return{channelId:s,pubKey:o?.ecies.public||"",privKey:o?.ecies.private||""}}))})(this)}))}connectToChannel({channelId:e,withKeyExchange:n=!1,authorized:r}){return(function(i){return _e(this,arguments,void 0,(function*({options:s,instance:o}){const{channelId:a,authorized:c,withKeyExchange:l}=s,{state:u,remote:d}=o,{isOriginator:f=!1,socket:g,keyExchange:v}=u,{channelConfig:w}=d.state;if(g?.connected)throw new Error("socket already connected");if(f&&w?.relayPersistence){const{localKey:b,otherKey:E}=w;b&&E&&v?.setRelayPersistence({localKey:b,otherKey:E})}return Object.assign(u,{manualDisconnect:!1,withKeyExchange:l,isOriginator:f,channelId:a}),g?.connect(),u1(o,a),!f&&c&&(v?.setKeysExchanged(!0),Object.assign(d.state,{ready:!0,authorized:!0})),new Promise((b=>{var E;const M=(E=v?.getKeyInfo())===null||E===void 0?void 0:E.ecies.public;g?.emit(Ne.JOIN_CHANNEL,{channelId:a,context:`${u.context}_connectToChannel`,clientType:f?"dapp":"wallet",publicKey:c&&!f?M:void 0},((S,F)=>_e(this,void 0,void 0,(function*(){yield ad(o,S,F),b()}))))}))}))})({options:{channelId:e,withKeyExchange:n,authorized:r},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,n;(n=(e=this).state.socket)===null||n===void 0||n.emit(Ne.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Zt.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return _e(this,void 0,void 0,(function*(){return(function(n,r){return _e(this,void 0,void 0,(function*(){var i,s,o;if(!n.state.channelId)throw pe.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(pe.SocketService(`[SocketService: handleSendMessage()] context=${n.state.context} areKeysExchanged=${(i=n.state.keyExchange)===null||i===void 0?void 0:i.areKeysExchanged()}`,r),(s=r?.type)===null||s===void 0?void 0:s.startsWith("key_handshake"))return(function(c,l){var u;pe.SocketService(`[SocketService: handleKeyHandshake()] context=${c.state.context}`,l),(u=c.state.socket)===null||u===void 0||u.emit(Ne.MESSAGE,{id:c.state.channelId,context:c.state.context,clientType:c.state.isOriginator?"dapp":"wallet",message:l})})(n,r),!0;(function(c,l){var u;if(!(!((u=c.state.keyExchange)===null||u===void 0)&&u.areKeysExchanged())&&!c.remote.state.relayPersistence)throw pe.SocketService(`[SocketService: validateKeyExchange()] context=${c.state.context} ERROR keys not exchanged`,l),new Error("Keys not exchanged BBB")})(n,r),(function(c,l){var u;const d=(u=l?.method)!==null&&u!==void 0?u:"",f=l?.id;c.state.isOriginator&&f&&(c.state.rpcMethodTracker[f]={id:f,timestamp:Date.now(),method:d},c.emit(Ne.RPC_UPDATE,c.state.rpcMethodTracker[f]))})(n,r);const a=yield T2(n,r);return n.remote.state.analytics&&n.remote.state.isOriginator&&r.method&&C2.includes(r.method.toLowerCase())&&Ts({id:(o=n.remote.state.channelId)!==null&&o!==void 0?o:"",event:Pn.SDK_RPC_REQUEST,params:{method:r.method,from:"mobile"}},n.remote.state.communicationServerUrl).catch((c=>{})),n.remote.state.isOriginator&&r.method&&Vl(r.method)&&On.analytics.track("sdk_action_requested",{action:r.method}),(function(c,l){return _e(this,void 0,void 0,(function*(){var u;const d=l?.id,f=(u=l?.method)!==null&&u!==void 0?u:"";if(c.state.isOriginator&&d)try{const g=l1(d,c.state.rpcMethodTracker,200).then((b=>({type:ka.RPC_CHECK,result:b}))),v=_e(this,void 0,void 0,(function*(){const b=yield(M=>_e(void 0,[M],void 0,(function*({rpcId:S,instance:F}){for(;F.state.lastRpcId===S||F.state.lastRpcId===void 0;)yield Ha(200);return F.state.lastRpcId})))({instance:c,rpcId:d}),E=yield l1(b,c.state.rpcMethodTracker,200);return{type:ka.SKIPPED_RPC,result:E}})),w=yield Promise.race([g,v]);if(w.type===ka.RPC_CHECK){const b=w.result;pe.SocketService(`[SocketService:handleRpcReplies()] id=${l.id} ${f} ( ${b.elapsedTime} ms)`,b.result)}else{if(w.type!==ka.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${d}`);{const b=Object.assign(Object.assign({},c.state.rpcMethodTracker[d]),{error:new Error("SDK_CONNECTION_ISSUE")});c.emit(Ne.RPC_UPDATE,b);const E={data:Object.assign(Object.assign({},b),{jsonrpc:"2.0"}),name:"metamask-provider"};c.emit(Ne.MESSAGE,{message:E})}}}catch(g){throw g}}))})(n,r).catch((c=>{})),a}))})(this,e)}))}ping(){return(function(e){return _e(this,void 0,void 0,(function*(){var n,r;pe.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${(n=e.state.keyExchange)===null||n===void 0?void 0:n.areKeysExchanged()}`),(r=e.state.socket)===null||r===void 0||r.emit(pn.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})}))})(this)}pause(){return(function(e){return _e(this,void 0,void 0,(function*(){var n,r;pe.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,!((n=e.state.keyExchange)===null||n===void 0)&&n.areKeysExchanged()&&(yield e.sendMessage({type:pn.PAUSE})),(r=e.state.socket)===null||r===void 0||r.disconnect()}))})(this)}isConnected(){var e;return(e=this.state.socket)===null||e===void 0?void 0:e.connected}resume(){return(function(e){return _e(this,void 0,void 0,(function*(){const{state:n,remote:r}=e,{socket:i,channelId:s,context:o,keyExchange:a,isOriginator:c}=n,{isOriginator:l}=r.state;if(pe.SocketService(`[SocketService: resume()] channelId=${s} context=${o} connected=${i?.connected} manualDisconnect=${n.manualDisconnect} resumed=${n.resumed} keysExchanged=${a?.areKeysExchanged()}`),!s)throw pe.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");i?.connected?(pe.SocketService("[SocketService: resume()] already connected."),i.emit(pn.PING,{id:s,clientType:l?"dapp":"wallet",context:"on_channel_config",message:""}),r.hasRelayPersistence()||a?.areKeysExchanged()||(c?yield e.sendMessage({type:pn.READY}):a?.start({isOriginator:!1}))):(i?.connect(),pe.SocketService(`[SocketService: resume()] after connecting socket --> connected=${i?.connected}`),i?.emit(Ne.JOIN_CHANNEL,{channelId:s,context:`${o}_resume`,clientType:l?"dapp":"wallet"},((u,d)=>_e(this,void 0,void 0,(function*(){try{yield ad(e,u,d)}catch{}}))))),n.manualDisconnect=!1,n.resumed=!0}))})(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return(function(n,r){var i,s,o,a,c;pe.SocketService(`[SocketService: disconnect()] context=${n.state.context}`,r),r?.terminate&&((s=(i=n.state).removeFocusListener)===null||s===void 0||s.call(i),n.state.channelId=r.channelId,(o=n.state.socket)===null||o===void 0||o.removeAllListeners(),(a=n.state.keyExchange)===null||a===void 0||a.clean(),n.remote.state.ready=!1,n.state.socket=void 0,n.state.rpcMethodTracker={}),n.state.manualDisconnect=!0,(c=n.state.socket)===null||c===void 0||c.disconnect()})(this,e)}}var Jo,gr,d1;function z5(t){return()=>_e(this,void 0,void 0,(function*(){var e,n,r;const{state:i}=t;if(i.authorized)return;yield _e(this,void 0,void 0,(function*(){for(;!i.walletInfo;)yield Ha(500)}));const s="7.3".localeCompare(((e=i.walletInfo)===null||e===void 0?void 0:e.version)||"");if(pe.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${(n=i.walletInfo)===null||n===void 0?void 0:n.version} compareValue=${s}`),s!==1)return;const o=i.platformType===gr.MobileWeb||i.platformType===gr.ReactNative||i.platformType===gr.MetaMaskMobileWebview;pe.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${o} channel=${i.channelId} walletVersion=${(r=i.walletInfo)===null||r===void 0?void 0:r.version}`),o&&(i.authorized=!0,t.emit(Ne.AUTHORIZED))}))}function q5(t){return e=>{const{state:n}=t;pe.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${e}`),t.emit(Ne.CHANNEL_CREATED,e)}}function W5(t,e){return()=>{var n,r,i,s;const{state:o}=t;pe.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${o.channelId} keysExchanged=${(r=(n=o.communicationLayer)===null||n===void 0?void 0:n.getKeyInfo())===null||r===void 0?void 0:r.keysExchanged}`),o.analytics&&Ts(Object.assign(Object.assign({id:(i=o.channelId)!==null&&i!==void 0?i:"",event:o.reconnection?Pn.RECONNECT:o.isOriginator?Pn.REQUEST:Pn.REQUEST_MOBILE},o.originatorInfo),{commLayer:e,sdkVersion:o.sdkVersion,walletVersion:(s=o.walletInfo)===null||s===void 0?void 0:s.version,commLayerVersion:go.version}),o.communicationServerUrl).catch((a=>{})),o.isOriginator&&!o.reconnection&&On.analytics.track("sdk_connection_established",{transport_type:"websocket"}),o.clientsConnected=!0,o.originatorInfoSent=!1,t.emit(Ne.CLIENTS_CONNECTED)}}function G5(t){return e=>{const{state:n}=t;pe.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${e}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),t.emit(Ne.CLIENTS_DISCONNECTED,n.channelId),t.setConnectionStatus(Qn.DISCONNECTED)}}function Y5(t){return e=>{var n;const{state:r}=t;if(pe.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${e} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),t.setConnectionStatus(Qn.WAITING),t.emit(Ne.CLIENTS_WAITING,e),r.originatorConnectStarted){pe.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const i=((n=r.autoConnectOptions)===null||n===void 0?void 0:n.timeout)||3e3,s=setTimeout((()=>{pe.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${i}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||t.setConnectionStatus(Qn.TIMEOUT),clearTimeout(s)}),i)}}}function J5(t,e){return n=>{var r,i,s,o,a,c,l,u;const{state:d}=t;if(pe.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${d.context} on commLayer.'keys_exchanged' channel=${d.channelId}`,n),(i=(r=d.communicationLayer)===null||r===void 0?void 0:r.getKeyInfo())===null||i===void 0?void 0:i.keysExchanged){const f=Object.assign(Object.assign({},d.channelConfig),{channelId:(s=d.channelId)!==null&&s!==void 0?s:"",validUntil:((o=d.channelConfig)===null||o===void 0?void 0:o.validUntil)||ec,localKey:d.communicationLayer.getKeyInfo().ecies.private,otherKey:d.communicationLayer.getKeyInfo().ecies.otherPubKey});(a=d.storageManager)===null||a===void 0||a.persistChannelConfig(f).catch((g=>{})),t.setConnectionStatus(Qn.LINKED)}(function(f,g){var v,w,b,E,M,S,F,D;const{state:z}=f;pe.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${z.channelId}`,g);const X=Object.assign(Object.assign({},z.channelConfig),{channelId:(v=z.channelId)!==null&&v!==void 0?v:"",validUntil:(b=(w=z.channelConfig)===null||w===void 0?void 0:w.validUntil)!==null&&b!==void 0?b:0,relayPersistence:z.relayPersistence,localKey:(M=(E=z.communicationLayer)===null||E===void 0?void 0:E.state.keyExchange)===null||M===void 0?void 0:M.getKeyInfo().ecies.private,otherKey:(F=(S=z.communicationLayer)===null||S===void 0?void 0:S.state.keyExchange)===null||F===void 0?void 0:F.getKeyInfo().ecies.otherPubKey,lastActive:g.getTime()});(D=z.storageManager)===null||D===void 0||D.persistChannelConfig(X)})(t,new Date),d.analytics&&d.channelId&&Ts(Object.assign(Object.assign({id:d.channelId,event:n.isOriginator?Pn.CONNECTED:Pn.CONNECTED_MOBILE},d.originatorInfo),{sdkVersion:d.sdkVersion,commLayer:e,commLayerVersion:go.version,walletVersion:(c=d.walletInfo)===null||c===void 0?void 0:c.version}),d.communicationServerUrl).catch((f=>{})),d.isOriginator=n.isOriginator,n.isOriginator||((l=d.communicationLayer)===null||l===void 0||l.sendMessage({type:pn.READY}),d.ready=!0,d.paused=!1),n.isOriginator&&!d.originatorInfoSent&&((u=d.communicationLayer)===null||u===void 0||u.sendMessage({type:pn.ORIGINATOR_INFO,originatorInfo:d.originatorInfo,originator:d.originatorInfo}),d.originatorInfoSent=!0)}}function Z5(t){return e=>{let n=e;e.message&&(n=n.message),(function(r,i){const{state:s}=i;if(pe.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${s.context} on 'message' typeof=${typeof r}`,r),i.state.ready=!0,s.isOriginator||r.type!==pn.ORIGINATOR_INFO)if(s.isOriginator&&r.type===pn.WALLET_INFO)(function(o,a){const{state:c}=o;c.walletInfo=a.walletInfo,c.paused=!1})(i,r);else{if(s.isOriginator&&r.type===pn.WALLET_INIT)(function(o,a){return _e(this,void 0,void 0,(function*(){var c,l,u;const{state:d}=o;if(d.isOriginator){const f=a.data||{};if(typeof f=="object"&&"accounts"in f&&"chainId"in f&&"walletKey"in f)try{const{channelConfig:g}=o.state;if(pe.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(g,null,2)),g){const v=f.accounts,w=f.chainId,b=f.walletKey;let E,M=!1;"deeplinkProtocol"in f&&(M=!!f.deeplinkProtocol,o.state.deeplinkProtocolAvailable=M),"walletVersion"in f&&(E=f.walletVersion),yield(c=o.state.storageManager)===null||c===void 0?void 0:c.persistChannelConfig(Object.assign(Object.assign({},g),{otherKey:b,walletVersion:E,deeplinkProtocolAvailable:M,relayPersistence:!0})),yield(l=o.state.storageManager)===null||l===void 0?void 0:l.persistAccounts(v),yield(u=o.state.storageManager)===null||u===void 0?void 0:u.persistChainId(w)}o.emit(Ne.WALLET_INIT,{accounts:f.accounts,chainId:f.chainId})}catch{}}}))})(i,r).catch((o=>{pe.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${o}`)}));else if(r.type===pn.TERMINATE)(function(o){return _e(this,void 0,void 0,(function*(){const{state:a}=o;a.isOriginator&&(yield O2({options:{terminate:!0,sendMessage:!1},instance:o}),o.emit(Ne.TERMINATE))}))})(i).catch((o=>{pe.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${o}`)}));else if(r.type===pn.PAUSE)(function(o){const{state:a}=o;a.paused=!0,o.setConnectionStatus(Qn.PAUSED)})(i);else if(r.type===pn.READY&&s.isOriginator)(function(o){const{state:a}=o;o.setConnectionStatus(Qn.LINKED);const c=a.paused;a.paused=!1,o.emit(Ne.CLIENTS_READY,{isOriginator:a.isOriginator,walletInfo:a.walletInfo}),c&&(a.authorized=!0,o.emit(Ne.AUTHORIZED))})(i);else{if(r.type===pn.OTP&&s.isOriginator)return void(function(o,a){var c;const{state:l}=o;o.emit(Ne.OTP,a.otpAnswer),"6.6".localeCompare(((c=l.walletInfo)===null||c===void 0?void 0:c.version)||"")===1&&o.emit(Ne.SDK_RPC_CALL,{method:dr.ETH_REQUESTACCOUNTS,params:[]})})(i,r);r.type===pn.AUTHORIZED&&s.isOriginator&&(function(o){const{state:a}=o;a.authorized=!0,o.emit(Ne.AUTHORIZED)})(i)}i.emit(Ne.MESSAGE,r)}else(function(o,a){var c;const{state:l}=o;(c=l.communicationLayer)===null||c===void 0||c.sendMessage({type:pn.WALLET_INFO,walletInfo:l.walletInfo}),l.originatorInfo=a.originatorInfo||a.originator,o.emit(Ne.CLIENTS_READY,{isOriginator:l.isOriginator,originatorInfo:l.originatorInfo}),l.paused=!1})(i,r)})(n,t)}}function X5(t){return()=>{const{state:e}=t;pe.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),e.ready=!1,e.authorized=!1,I2(e),t.emitServiceStatusEvent({context:"socket_reconnect"})}}function Q5(t){return()=>{const{state:e}=t;pe.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),e.ready=!1}}function eM(t){return()=>_e(this,void 0,void 0,(function*(){var e,n,r,i,s,o,a;const{state:c}=t;pe.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),t.state.ready=!0,t.state.clientsConnected=!0,t.state.authorized=!0,t.state.relayPersistence=!0,(e=t.state.communicationLayer)===null||e===void 0||e.getKeyExchange().setKeysExchanged(!0),t.emit(Ne.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),t.emit(Ne.AUTHORIZED),t.emit(Ne.CLIENTS_READY),t.emit(Ne.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:(n=c.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:(r=c.communicationLayer)===null||r===void 0?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:(i=c.channelId)!==null&&i!==void 0?i:"",validUntil:(o=(s=c.channelConfig)===null||s===void 0?void 0:s.validUntil)!==null&&o!==void 0?o:ec,relayPersistence:!0}),yield(a=c.storageManager)===null||a===void 0?void 0:a.persistChannelConfig(c.channelConfig)}catch{}}))}function f1({communicationLayerPreference:t,otherPublicKey:e,reconnect:n,ecies:r,communicationServerUrl:i=Qa,instance:s}){var o,a,c,l,u,d,f,g,v,w,b;const{state:E}=s;if(pe.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(E,null,2)),t!==Jo.SOCKET)throw new Error("Invalid communication protocol");E.communicationLayer=new H5({communicationLayerPreference:t,otherPublicKey:e,reconnect:n,transports:E.transports,communicationServerUrl:i,context:E.context,ecies:r,logging:E.logging,remote:s});let M=typeof document<"u"&&document.URL||"",S=typeof document<"u"&&document.title||"";!((o=E.dappMetadata)===null||o===void 0)&&o.url&&(M=E.dappMetadata.url),!((a=E.dappMetadata)===null||a===void 0)&&a.name&&(S=E.dappMetadata.name);const F=(d=(l=(c=E.dappMetadata)===null||c===void 0?void 0:c.name)!==null&&l!==void 0?l:(u=E.dappMetadata)===null||u===void 0?void 0:u.url)!==null&&d!==void 0?d:"N/A",D=typeof window<"u"&&window.location!==void 0&&(f=window.location.hostname)!==null&&f!==void 0?f:F,z={url:M,title:S,source:(g=E.dappMetadata)===null||g===void 0?void 0:g.source,dappId:D,anonId:E.anonId,icon:((v=E.dappMetadata)===null||v===void 0?void 0:v.iconUrl)||((w=E.dappMetadata)===null||w===void 0?void 0:w.base64Icon),platform:E.platformType,apiVersion:go.version,connector:(b=E.dappMetadata)===null||b===void 0?void 0:b.connector};E.originatorInfo=z;const X={[Ne.AUTHORIZED]:z5(s),[Ne.MESSAGE]:Z5(s),[Ne.CHANNEL_PERSISTENCE]:eM(s),[Ne.CLIENTS_CONNECTED]:W5(s,t),[Ne.KEYS_EXCHANGED]:J5(s,t),[Ne.SOCKET_DISCONNECTED]:Q5(s),[Ne.SOCKET_RECONNECT]:X5(s),[Ne.CLIENTS_DISCONNECTED]:G5(s),[Ne.KEY_INFO]:()=>{},[Ne.CHANNEL_CREATED]:q5(s),[Ne.CLIENTS_WAITING]:Y5(s),[Ne.RPC_UPDATE]:Y=>{s.emit(Ne.RPC_UPDATE,Y)}};for(const[Y,U]of Object.entries(X))try{E.communicationLayer.on(Y,U)}catch{}}function O2(t){return _e(this,arguments,void 0,(function*({options:e,instance:n}){const{state:r}=n;return pe.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${r.channelId}`,e),new Promise(((i,s)=>{var o,a,c,l,u,d;e?.terminate?(n.state.ready&&Ts({id:(o=n.state.channelId)!==null&&o!==void 0?o:"",event:Pn.TERMINATED},n.state.communicationServerUrl).catch((f=>{})),r.ready=!1,r.paused=!1,(a=r.storageManager)===null||a===void 0||a.terminate((c=r.channelId)!==null&&c!==void 0?c:""),n.state.terminated=!0,e.sendMessage?!((l=r.communicationLayer)===null||l===void 0)&&l.getKeyInfo().keysExchanged&&n.state.communicationLayer&&T2(n.state.communicationLayer,{type:pn.TERMINATE}).then((()=>{i(!0)})).catch((f=>{s(f)})):i(!0),r.authorized=!1,r.relayPersistence=!1,r.channelId=hs(),e.channelId=r.channelId,r.channelConfig=void 0,r.originatorConnectStarted=!1,(u=r.communicationLayer)===null||u===void 0||u.disconnect(e),n.setConnectionStatus(Qn.TERMINATED)):((d=r.communicationLayer)===null||d===void 0||d.disconnect(e),n.setConnectionStatus(Qn.DISCONNECTED),i(!0))}))}))}(Jo||(Jo={})).SOCKET="socket",(function(t){t.NonBrowser="nodejs",t.MetaMaskMobileWebview="in-app-browser",t.DesktopWeb="web-desktop",t.MobileWeb="web-mobile",t.ReactNative="react-native"})(gr||(gr={}));class tM extends Nf.EventEmitter2{constructor(e){super(),this.state={ready:!1,anonId:"",authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:Qa,context:"",persist:!1,clientsConnected:!1,sessionDuration:ec,originatorConnectStarted:!1,debug:!1,_connectionStatus:Qn.DISCONNECTED},this._options=e;const{anonId:n,platformType:r,communicationLayerPreference:i,otherPublicKey:s,reconnect:o,walletInfo:a,dappMetadata:c,protocolVersion:l,transports:u,context:d,relayPersistence:f,ecies:g,analytics:v=!1,storage:w,sdkVersion:b,communicationServerUrl:E=Qa,logging:M,autoConnect:S={timeout:$5}}=e;this.state.anonId=n,this.state.otherPublicKey=s,this.state.dappMetadata=c,this.state.walletInfo=a,this.state.transports=u,this.state.platformType=r,this.state.analytics=v,this.state.protocolVersion=l??1,this.state.isOriginator=!s,this.state.relayPersistence=f,this.state.communicationServerUrl=E,this.state.context=d,this.state.terminated=!1,this.state.sdkVersion=b,this.setMaxListeners(50),this.setConnectionStatus(Qn.DISCONNECTED),w?.duration&&(this.state.sessionDuration=ec),this.state.storageOptions=w,this.state.autoConnectOptions=S,this.state.debug=M?.remoteLayer===!0,M?.remoteLayer===!0&&Ir.enable("RemoteCommunication:Layer"),M?.serviceLayer===!0&&Ir.enable("SocketService:Layer"),M?.eciesLayer===!0&&Ir.enable("ECIES:Layer"),M?.keyExchangeLayer===!0&&Ir.enable("KeyExchange:Layer"),this.state.logging=M,w?.storageManager&&(this.state.storageManager=w.storageManager),pe.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${l} relayPersistence=${f} isOriginator=${this.state.isOriginator} communicationLayerPreference=${i} otherPublicKey=${s} reconnect=${o}`),this.state.isOriginator||f1({communicationLayerPreference:i,otherPublicKey:s,reconnect:o,ecies:g,communicationServerUrl:E,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return _e(this,void 0,void 0,(function*(){var e;if(this.state.storageManager){const n=yield this.state.storageManager.getPersistedChannelConfig({});n&&(this.state.channelConfig=n,this.state.channelId=n.channelId,this.state.deeplinkProtocolAvailable=(e=n.deeplinkProtocolAvailable)!==null&&e!==void 0&&e,n.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(Qn.LINKED),yield this.connectToChannel({channelId:n.channelId})))}f1({communicationLayerPreference:Jo.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return _e(this,void 0,void 0,(function*(){return yield(function(e){return _e(this,void 0,void 0,(function*(){var n;const{state:r}=e;if(!r.storageManager)return void pe.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const i=yield r.storageManager.getPersistedChannelConfig({});if(pe.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${r.originatorConnectStarted} channelConfig`,i),(n=r.communicationLayer)===null||n===void 0?void 0:n.isConnected())return pe.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),i;if(i){if(i.validUntil>Date.now())return r.channelConfig=i,r.originatorConnectStarted=!0,r.channelId=i?.channelId,r.reconnection=!0,i;pe.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}r.originatorConnectStarted=!1}))})(this)}))}generateChannelIdConnect(){return _e(this,void 0,void 0,(function*(){return(function(e){return _e(this,void 0,void 0,(function*(){var n,r,i,s,o,a;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(!((n=e.communicationLayer)===null||n===void 0)&&n.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),(r=e.storageManager)===null||r===void 0||r.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:(s=(i=e.communicationLayer)===null||i===void 0?void 0:i.getKeyInfo())===null||s===void 0?void 0:s.ecies.private,pubKey:(a=(o=e.communicationLayer)===null||o===void 0?void 0:o.getKeyInfo())===null||a===void 0?void 0:a.ecies.public};pe.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const c=yield e.communicationLayer.createChannel();pe.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",c);const l=Object.assign(Object.assign({},e.channelConfig),{channelId:c.channelId,localKey:c.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=c.channelId,e.channelConfig=l,{channelId:e.channelId,pubKey:c.pubKey,privKey:c.privKey}}))})(this.state)}))}clean(){return I2(this.state)}connectToChannel({channelId:e,withKeyExchange:n,authorized:r}){return(function(i){return _e(this,arguments,void 0,(function*({channelId:s,withKeyExchange:o,authorized:a,state:c}){var l,u,d;if(!Xa(s))throw pe.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} invalid channel channelId=${s}`),new Error(`Invalid channel ${s}`);if(pe.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} channelId=${s} withKeyExchange=${o}`),(l=c.communicationLayer)===null||l===void 0?void 0:l.isConnected())return void pe.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} already connected - interrupt connection.`);c.channelId=s,yield(u=c.communicationLayer)===null||u===void 0?void 0:u.connectToChannel({channelId:s,authorized:a,withKeyExchange:o});const f=Object.assign(Object.assign({},c.channelConfig),{channelId:s,validUntil:Date.now()+c.sessionDuration});c.channelConfig=f,(d=c.storageManager)===null||d===void 0||d.persistChannelConfig(f)}))})({channelId:e,authorized:r,withKeyExchange:n,state:this.state})}sendMessage(e){return _e(this,void 0,void 0,(function*(){const n=this.state.isOriginator&&e.method&&Vl(e.method);n&&On.analytics.track("sdk_action_requested",{action:e.method});try{return yield(function(r,i){return _e(this,void 0,void 0,(function*(){var s,o;const{state:a}=r;pe.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${a.context} paused=${a.paused} ready=${a.ready} relayPersistence=${a.relayPersistence} authorized=${a.authorized} socket=${(s=a.communicationLayer)===null||s===void 0?void 0:s.isConnected()} clientsConnected=${a.clientsConnected} status=${a._connectionStatus}`,i),a.relayPersistence||a.ready&&(!((o=a.communicationLayer)===null||o===void 0)&&o.isConnected())&&a.clientsConnected||(pe.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${a.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((c=>{r.once(Ne.CLIENTS_READY,c)})),pe.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${a.context} AFTER SKIP / READY -- sending pending message`));try{return yield(function(l,u){return _e(this,void 0,void 0,(function*(){return new Promise((d=>{var f;const{state:g}=l;pe.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${g.context} ready=${g.ready} authorized=${g.authorized} method=${u.method}`),!g.isOriginator||g.authorized||g.relayPersistence?(f=g.communicationLayer)===null||f===void 0||f.sendMessage(u).then((v=>{d(v)})).catch((v=>{d(!1)})):l.once(Ne.AUTHORIZED,(()=>{var v;pe.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${g.context} AFTER SKIP / AUTHORIZED -- sending pending message`),(v=g.communicationLayer)===null||v===void 0||v.sendMessage(u).then((w=>{d(w)})).catch((w=>{d(!1)}))}))}))}))})(r,i)}catch(c){throw c}}))})(this,e)}catch(r){throw n&&On.analytics.track("sdk_action_failed",{action:e.method}),r}}))}testStorage(){return _e(this,void 0,void 0,(function*(){return(function(e){return _e(this,void 0,void 0,(function*(){var n;const r=yield(n=e.storageManager)===null||n===void 0?void 0:n.getPersistedChannelConfig();pe.RemoteCommunication("[RemoteCommunication: testStorage()] res",r)}))})(this.state)}))}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return _e(this,void 0,void 0,(function*(){var e;pe.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield(e=this.state.communicationLayer)===null||e===void 0?void 0:e.ping()}))}testLogger(){pe.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),pe.SocketService(`testLogger() channel=${this.state.channelId}`),pe.Ecies(`testLogger() channel=${this.state.channelId}`),pe.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;pe.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),(e=this.state.communicationLayer)===null||e===void 0||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(Ne.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(Ne.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.getKeyInfo()}resetKeys(){var e;(e=this.state.communicationLayer)===null||e===void 0||e.resetKeys()}setOtherPublicKey(e){var n;const r=(n=this.state.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange();if(!r)throw new Error("KeyExchange is not initialized.");r.getOtherPublicKey()!==e&&r.setOtherPublicKey(e)}pause(){return _e(this,void 0,void 0,(function*(){var e;pe.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield(e=this.state.communicationLayer)===null||e===void 0?void 0:e.pause(),this.setConnectionStatus(Qn.PAUSED)}))}getVersion(){return go.version}hasRelayPersistence(){var e;return(e=this.state.relayPersistence)!==null&&e!==void 0&&e}resume(){return _e(this,void 0,void 0,(function*(){return(function(e){return _e(this,void 0,void 0,(function*(){var n;const{state:r}=e;pe.RemoteCommunication(`[RemoteCommunication: resume()] channel=${r.channelId}`),yield(n=r.communicationLayer)===null||n===void 0?void 0:n.resume(),e.setConnectionStatus(Qn.LINKED)}))})(this)}))}encrypt(e){var n,r,i;const s=(n=this.state.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange(),o=s?.getOtherPublicKey();if(!o)throw new Error("KeyExchange not completed");return(i=(r=this.state.communicationLayer)===null||r===void 0?void 0:r.state.eciesInstance)===null||i===void 0?void 0:i.encrypt(e,o)}decrypt(e){var n,r,i;if(!(!((n=this.state.communicationLayer)===null||n===void 0)&&n.state.eciesInstance))throw new Error("ECIES instance is not initialized");return(i=(r=this.state.communicationLayer)===null||r===void 0?void 0:r.state.eciesInstance)===null||i===void 0?void 0:i.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return(function(n){return _e(this,arguments,void 0,(function*({channelId:r,state:i}){var s,o,a;if(!Xa(r))throw pe.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} invalid channel channelId=${r}`),new Error(`Invalid channel ${r}`);if(i.isOriginator)return void pe.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} isOriginator=${i.isOriginator} channelId=${r}`);const{socket:c}=(o=(s=i.communicationLayer)===null||s===void 0?void 0:s.state)!==null&&o!==void 0?o:{};c?.connected||(pe.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} socket already connected`),c?.connect()),Ts(Object.assign(Object.assign({id:r,event:Pn.REJECTED},i.originatorInfo),{sdkVersion:i.sdkVersion,commLayerVersion:go.version,walletVersion:(a=i.walletInfo)===null||a===void 0?void 0:a.version}),i.communicationServerUrl).catch((l=>{})),yield new Promise(((l,u)=>{c?.emit(Ne.REJECTED,{channelId:r},((d,f)=>{pe.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} socket=${c?.id}`,{error:d,response:f}),d?u(d):l(f)}))}))}))})({channelId:e,state:this.state})}disconnect(e){return _e(this,void 0,void 0,(function*(){return O2({options:e,instance:this})}))}}(function(t){t.RENEW="renew",t.LINK="link"})(d1||(d1={}));var nM="ERC721",rM="ERC1155",In={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:t=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${t} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:t=>`'args.logger' must include required method '${t}'.`},info:{connected:t=>`MetaMask: Connected to chain with ID "${t}".`},warnings:{chainIdDeprecation:`MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.
|
|
17
|
+
For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,networkVersionDeprecation:`MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.
|
|
18
|
+
For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,selectedAddressDeprecation:`MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.
|
|
19
|
+
For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,enableDeprecation:`MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.
|
|
20
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1102`,sendDeprecation:`MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.
|
|
21
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1193`,events:{close:`MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.
|
|
22
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect`,data:`MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.
|
|
23
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`,networkChanged:`MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.
|
|
24
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged`,notification:`MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.
|
|
25
|
+
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`},rpc:{ethDecryptDeprecation:`MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.
|
|
26
|
+
For more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686`,ethGetEncryptionPublicKeyDeprecation:`MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.
|
|
27
|
+
For more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686`,walletWatchAssetNFTExperimental:`MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.
|
|
28
|
+
For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle`},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function iM(t){const e={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{e.ethDecryptDeprecation||n.method!=="eth_decrypt"?e.ethGetEncryptionPublicKeyDeprecation||n.method!=="eth_getEncryptionPublicKey"?!e.walletWatchAssetNFTExperimental&&n.method==="wallet_watchAsset"&&[nM,rM].includes(n.params?.type||"")&&(t.warn(In.warnings.rpc.walletWatchAssetNFTExperimental),e.walletWatchAssetNFTExperimental=!0):(t.warn(In.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),e.ethGetEncryptionPublicKeyDeprecation=!0):(t.warn(In.warnings.rpc.ethDecryptDeprecation),e.ethDecryptDeprecation=!0),i()}}var N2=4294967295,h1=Math.floor(Math.random()*N2);function sM(){return(t,e,n,r)=>{const i=t.id,s=h1=(h1+1)%N2;t.id=s,e.id=s,n((o=>{t.id=i,e.id=i,o()}))}}var kg=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},no=(t,e,n)=>(kg(t,e,"read from private field"),n?n.call(t):e.get(t)),bi=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Nu=(t,e,n,r)=>(kg(t,e,"write to private field"),e.set(t,n),n),br=(t,e,n)=>(kg(t,e,"access private method"),n),Xs={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},p1={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function m1(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}var zd=(t,e)=>Object.hasOwnProperty.call(t,e);class oM extends TypeError{constructor(e,n){let r;const{message:i,explanation:s,...o}=e,{path:a}=e,c=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??c),s!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function xs(t){return typeof t=="object"&&t!=null}function Zi(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function aM(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:o}=n,{refinement:a,message:c=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Zi(r)}\``}=t;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:c}}function*g1(t,e,n,r){(function(i){return xs(i)&&typeof i[Symbol.iterator]=="function"})(t)||(t=[t]);for(const i of t){const s=aM(i,e,n,r);s&&(yield s)}}function*Dg(t,e,n={}){const{path:r=[],branch:i=[t],coerce:s=!1,mask:o=!1}=n,a={path:r,branch:i};if(s&&(t=e.coercer(t,a),o&&e.type!=="type"&&xs(e.schema)&&xs(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let c="valid";for(const l of e.validator(t,a))l.explanation=n.message,c="not_valid",yield[l,void 0];for(let[l,u,d]of e.entries(t,a)){const f=Dg(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:s,mask:o,message:n.message});for(const g of f)g[0]?(c=g[0].refinement!=null?"not_refined":"not_valid",yield[g[0],void 0]):s&&(u=g[1],l===void 0?t=u:t instanceof Map?t.set(l,u):t instanceof Set?t.add(u):xs(t)&&(u!==void 0||l in t)&&(t[l]=u))}if(c!=="not_valid")for(const l of e.refiner(t,a))l.explanation=n.message,c="not_refined",yield[l,void 0];c==="valid"&&(yield[void 0,t])}class Ii{constructor(e){const{type:n,schema:r,validator:i,refiner:s,coercer:o=(c=>c),entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,this.validator=i?(c,l)=>g1(i(c,l),l,this,c):()=>[],this.refiner=s?(c,l)=>g1(s(c,l),l,this,c):()=>[]}assert(e,n){return P2(e,this,n)}create(e,n){return M2(e,this,n)}is(e){return vc(e,this)}mask(e,n){return(function(r,i,s){const o=_l(r,i,{coerce:!0,mask:!0,message:s});if(o[0])throw o[0];return o[1]})(e,this,n)}validate(e,n={}){return _l(e,this,n)}}function P2(t,e,n){const r=_l(t,e,{message:n});if(r[0])throw r[0]}function M2(t,e,n){const r=_l(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function vc(t,e){return!_l(t,e)[0]}function _l(t,e,n={}){const r=Dg(t,e,n),i=(function(s){const{done:o,value:a}=s.next();return o?void 0:a})(r);return i[0]?[new oM(i[0],(function*(){for(const o of r)o[0]&&(yield o[0])})),void 0]:[void 0,i[1]]}function yo(t,e){return new Ii({type:t,schema:null,validator:e})}function y1(t){let e;return new Ii({type:"lazy",schema:null,*entries(n,r){e??(e=t()),yield*e.entries(n,r)},validator:(n,r)=>(e??(e=t()),e.validator(n,r)),coercer:(n,r)=>(e??(e=t()),e.coercer(n,r)),refiner:(n,r)=>(e??(e=t()),e.refiner(n,r))})}function k2(t){return new Ii({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Zi(e)}`})}function D2(t){const e=Zi(t),n=typeof t;return new Ii({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator:r=>r===t||`Expected the literal \`${e}\`, but received: ${Zi(r)}`})}function L2(){return yo("number",(t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${Zi(t)}`))}function B2(t){const e=t?Object.keys(t):[],n=yo("never",(()=>!1));return new Ii({type:"object",schema:t||null,*entries(r){if(t&&xs(r)){const i=new Set(Object.keys(r));for(const s of e)i.delete(s),yield[s,r[s],t[s]];for(const s of i)yield[s,r[s],n]}},validator:r=>xs(r)||`Expected an object, but received: ${Zi(r)}`,coercer:r=>xs(r)?{...r}:r})}function w1(t){return new Ii({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function U2(t,e){return new Ii({type:"record",schema:null,*entries(n){if(xs(n))for(const r in n){const i=n[r];yield[r,r,t],yield[r,i,e]}},validator:n=>xs(n)||`Expected an object, but received: ${Zi(n)}`})}function wo(){return yo("string",(t=>typeof t=="string"||`Expected a string, but received: ${Zi(t)}`))}function $f(t){const e=t.map((n=>n.type)).join(" | ");return new Ii({type:"union",schema:null,coercer(n){for(const r of t){const[i,s]=r.validate(n,{coerce:!0});if(!i)return s}return n},validator(n,r){const i=[];for(const s of t){const[...o]=Dg(n,s,r),[a]=o;if(!a[0])return[];for(const[c]of o)c&&i.push(c)}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Zi(n)}`,...i]}})}function cM(t){return(function(e){return(function(n){return typeof n=="object"&&n!==null&&"message"in n})(e)&&typeof e.message=="string"?e.message:e==null?"":String(e)})(t).replace(/\.$/u,"")}function lM(t,e){return n=t,typeof n?.prototype?.constructor?.name=="string"?new t({message:e}):t({message:e});var n}var uM=class extends Error{constructor(t){super(t.message),this.code="ERR_ASSERTION"}};function $2(){throw new Error("setTimeout has not been defined")}function F2(){throw new Error("clearTimeout has not been defined")}var zs=$2,qs=F2;function K2(t){if(zs===setTimeout)return setTimeout(t,0);if((zs===$2||!zs)&&setTimeout)return zs=setTimeout,setTimeout(t,0);try{return zs(t,0)}catch{try{return zs.call(null,t,0)}catch{return zs.call(this,t,0)}}}typeof Tr.setTimeout=="function"&&(zs=setTimeout),typeof Tr.clearTimeout=="function"&&(qs=clearTimeout);var ko,bs=[],za=!1,cd=-1;function dM(){za&&ko&&(za=!1,ko.length?bs=ko.concat(bs):cd=-1,bs.length&&V2())}function V2(){if(!za){var t=K2(dM);za=!0;for(var e=bs.length;e;){for(ko=bs,bs=[];++cd<e;)ko&&ko[cd].run();cd=-1,e=bs.length}ko=null,za=!1,(function(n){if(qs===clearTimeout)return clearTimeout(n);if((qs===F2||!qs)&&clearTimeout)return qs=clearTimeout,clearTimeout(n);try{return qs(n)}catch{try{return qs.call(null,n)}catch{return qs.call(this,n)}}})(t)}}function j2(t,e){this.fun=t,this.array=e}j2.prototype.run=function(){this.fun.apply(null,this.array)};function na(){}var fM=na,hM=na,pM=na,mM=na,gM=na,yM=na,wM=na,Sa=Tr.performance||{},vM=Sa.now||Sa.mozNow||Sa.msNow||Sa.oNow||Sa.webkitNow||function(){return new Date().getTime()},EM=new Date,Wt={nextTick:function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];bs.push(new j2(t,e)),bs.length!==1||za||K2(V2)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:fM,addListener:hM,once:pM,off:mM,removeListener:gM,removeAllListeners:yM,emit:wM,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*vM.call(Sa),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],(r-=t[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-EM)/1e3}},Sl=t=>B2(t);function v1({path:t,branch:e}){const n=t[t.length-1];return zd(e[e.length-2],n)}function qd(t){return new Ii({...t,type:`optional ${t.type}`,validator:(e,n)=>!v1(n)||t.validator(e,n),refiner:(e,n)=>!v1(n)||t.refiner(e,n)})}var Pu,E1,b1,Wd=$f([D2(null),yo("boolean",(t=>typeof t=="boolean")),yo("finite number",(t=>vc(t,L2())&&Number.isFinite(t))),wo(),k2(y1((()=>Wd))),U2(wo(),y1((()=>Wd)))]),xl=(Pu=Wd,E1=yo("any",(()=>!0)),b1=t=>((function(e,n,r="Assertion failed",i=uM){try{P2(e,n)}catch(s){throw lM(i,`${r}: ${cM(s)}.`)}})(t,Wd),JSON.parse(JSON.stringify(t,((e,n)=>{if(e!=="__proto__"&&e!=="constructor")return n})))),new Ii({...Pu,coercer:(t,e)=>vc(t,E1)?Pu.coercer(b1(t,e),e):Pu.coercer(t,e)}));function q0(t){try{return(function(e){M2(e,xl)})(t),!0}catch{return!1}}var rl=D2("2.0"),ld=(function(t){return new Ii({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})})($f([L2(),wo()])),W0=Sl({code:yo("integer",(t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${Zi(t)}`)),message:wo(),data:qd(xl),stack:qd(wo())}),H2=$f([U2(wo(),xl),k2(xl)]),bM=Sl({id:ld,jsonrpc:rl,method:wo(),params:qd(H2)}),_M=Sl({jsonrpc:rl,method:wo(),params:qd(H2)});function _1(t){return vc(t,bM)}function S1(t){return vc(t,W0)}B2({id:ld,jsonrpc:rl,result:w1(yo("unknown",(()=>!0))),error:w1(W0)}),$f([Sl({id:ld,jsonrpc:rl,result:xl}),Sl({id:ld,jsonrpc:rl,error:W0})]);var x1=Xs.internal,SM="Unspecified error message. This is a bug, please report it.",xM={code:x1,message:z2(x1)},AM="Unspecified server error.";function z2(t,e=SM){if((function(n){return Number.isInteger(n)})(t)){const n=t.toString();if(zd(p1,n))return p1[n].message;if((function(r){return r>=-32099&&r<=-32e3})(t))return AM}return e}function A1(t,{fallbackError:e=xM,shouldIncludeStack:n=!0}={}){if(!S1(e))throw new Error("Must provide fallback error with integer number code and string message.");const r=(function(i,s){if(i&&typeof i=="object"&&"serialize"in i&&typeof i.serialize=="function")return i.serialize();if(S1(i))return i;const o=q2(i);return{...s,data:{cause:o}}})(t,e);return n||delete r.stack,r}function q2(t){return Array.isArray(t)?t.map((e=>q0(e)?e:m1(e)?R1(e):null)):m1(t)?R1(t):q0(t)?t:null}function R1(t){return Object.getOwnPropertyNames(t).reduce(((e,n)=>{const r=t[n];return q0(r)&&(e[n]=r),e}),{})}var W2=Gc;Gc.default=Gc,Gc.stable=I1,Gc.stableStringify=I1;var Gd="[...]",G2="[Circular]",Zo=[],Do=[];function Y2(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Gc(t,e,n,r){var i;r===void 0&&(r=Y2()),G0(t,"",0,[],void 0,0,r);try{i=Do.length===0?JSON.stringify(t,e,n):JSON.stringify(t,J2(e),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Zo.length!==0;){var s=Zo.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function qa(t,e,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:t}),Zo.push([r,n,e,i])):Do.push([e,n,t]):(r[n]=t,Zo.push([r,n,e]))}function G0(t,e,n,r,i,s,o){var a;if(s+=1,typeof t=="object"&&t!==null){for(a=0;a<r.length;a++)if(r[a]===t)return void qa(G2,t,e,i);if(o.depthLimit!==void 0&&s>o.depthLimit||o.edgesLimit!==void 0&&n+1>o.edgesLimit)return void qa(Gd,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)G0(t[a],a,a,r,t,s,o);else{var c=Object.keys(t);for(a=0;a<c.length;a++){var l=c[a];G0(t[l],l,a,r,t,s,o)}}r.pop()}}function RM(t,e){return t<e?-1:t>e?1:0}function I1(t,e,n,r){r===void 0&&(r=Y2());var i,s=Y0(t,"",0,[],void 0,0,r)||t;try{i=Do.length===0?JSON.stringify(s,e,n):JSON.stringify(s,J2(e),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Zo.length!==0;){var o=Zo.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function Y0(t,e,n,r,i,s,o){var a;if(s+=1,typeof t=="object"&&t!==null){for(a=0;a<r.length;a++)if(r[a]===t)return void qa(G2,t,e,i);try{if(typeof t.toJSON=="function")return}catch{return}if(o.depthLimit!==void 0&&s>o.depthLimit||o.edgesLimit!==void 0&&n+1>o.edgesLimit)return void qa(Gd,t,e,i);if(r.push(t),Array.isArray(t))for(a=0;a<t.length;a++)Y0(t[a],a,a,r,t,s,o);else{var c={},l=Object.keys(t).sort(RM);for(a=0;a<l.length;a++){var u=l[a];Y0(t[u],u,a,r,t,s,o),c[u]=t[u]}if(i===void 0)return c;Zo.push([i,e,t]),i[e]=c}r.pop()}}function J2(t){return t=t!==void 0?t:function(e,n){return n},function(e,n){if(Do.length>0)for(var r=0;r<Do.length;r++){var i=Do[r];if(i[1]===e&&i[0]===n){n=i[2],Do.splice(r,1);break}}return t.call(this,e,n)}}var IM=Bf(W2),ls=class extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||typeof e!="string")throw new Error('"message" must be a non-empty string.');super(e),this.code=t,n!==void 0&&(this.data=n)}serialize(){const t={code:this.code,message:this.message};return this.data!==void 0&&(t.data=this.data,(function(e){if(typeof e!="object"||e===null)return!1;try{let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}catch{return!1}})(this.data)&&(t.data.cause=q2(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return IM(this.serialize(),TM,2)}};function TM(t,e){if(e!=="[Circular]")return e}var il=t=>CM(Xs.invalidRequest,t);function CM(t,e){const[n,r]=(function(i){if(i){if(typeof i=="string")return[i];if(typeof i=="object"&&!Array.isArray(i)){const{message:s,data:o}=i;if(s&&typeof s!="string")throw new Error("Must specify string message.");return[s??void 0,o]}}return[]})(e);return new ls(t,n??z2(t),r)}var Z2={};function Ws(){}function Jt(){Jt.init.call(this)}function X2(t){return t._maxListeners===void 0?Jt.defaultMaxListeners:t._maxListeners}function T1(t,e,n,r){var i,s,o;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]):(s=t._events=new Ws,t._eventsCount=0),o){if(typeof o=="function"?o=s[e]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=X2(t))&&i>0&&o.length>i){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,(function(c){typeof console.warn=="function"?console.warn(c):console.log(c)})(a)}}else o=s[e]=n,++t._eventsCount;return t}function C1(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function O1(t){var e=this._events;if(e){var n=e[t];if(typeof n=="function")return 1;if(n)return n.length}return 0}function Uc(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}Ws.prototype=Object.create(null),Jt.EventEmitter=Jt,Jt.usingDomains=!1,Jt.prototype.domain=void 0,Jt.prototype._events=void 0,Jt.prototype._maxListeners=void 0,Jt.defaultMaxListeners=10,Jt.init=function(){this.domain=null,Jt.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ws,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Jt.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},Jt.prototype.getMaxListeners=function(){return X2(this)},Jt.prototype.emit=function(t){var e,n,r,i,s,o,a,c=t==="error";if(o=this._events)c=c&&o.error==null;else if(!c)return!1;if(a=this.domain,c){if(e=arguments[1],!a){if(e instanceof Error)throw e;var l=new Error('Uncaught, unspecified "error" event. ('+e+")");throw l.context=e,l}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=o[t]))return!1;var u=typeof n=="function";switch(r=arguments.length){case 1:(function(d,f,g){if(f)d.call(g);else for(var v=d.length,w=Uc(d,v),b=0;b<v;++b)w[b].call(g)})(n,u,this);break;case 2:(function(d,f,g,v){if(f)d.call(g,v);else for(var w=d.length,b=Uc(d,w),E=0;E<w;++E)b[E].call(g,v)})(n,u,this,arguments[1]);break;case 3:(function(d,f,g,v,w){if(f)d.call(g,v,w);else for(var b=d.length,E=Uc(d,b),M=0;M<b;++M)E[M].call(g,v,w)})(n,u,this,arguments[1],arguments[2]);break;case 4:(function(d,f,g,v,w,b){if(f)d.call(g,v,w,b);else for(var E=d.length,M=Uc(d,E),S=0;S<E;++S)M[S].call(g,v,w,b)})(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];(function(d,f,g,v){if(f)d.apply(g,v);else for(var w=d.length,b=Uc(d,w),E=0;E<w;++E)b[E].apply(g,v)})(n,u,this,i)}return!0},Jt.prototype.addListener=function(t,e){return T1(this,t,e,!1)},Jt.prototype.on=Jt.prototype.addListener,Jt.prototype.prependListener=function(t,e){return T1(this,t,e,!0)},Jt.prototype.once=function(t,e){if(typeof e!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,C1(this,t,e)),this},Jt.prototype.prependOnceListener=function(t,e){if(typeof e!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,C1(this,t,e)),this},Jt.prototype.removeListener=function(t,e){var n,r,i,s,o;if(typeof e!="function")throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)--this._eventsCount==0?this._events=new Ws:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(i=-1,s=n.length;s-- >0;)if(n[s]===e||n[s].listener&&n[s].listener===e){o=n[s].listener,i=s;break}if(i<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount==0)return this._events=new Ws,this;delete r[t]}else(function(a,c){for(var l=c,u=l+1,d=a.length;u<d;l+=1,u+=1)a[l]=a[u];a.pop()})(n,i);r.removeListener&&this.emit("removeListener",t,o||e)}return this},Jt.prototype.off=function(t,e){return this.removeListener(t,e)},Jt.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ws,this._eventsCount=0):n[t]&&(--this._eventsCount==0?this._events=new Ws:delete n[t]),this;if(arguments.length===0){for(var r,i=Object.keys(n),s=0;s<i.length;++s)(r=i[s])!=="removeListener"&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Ws,this._eventsCount=0,this}if(typeof(e=n[t])=="function")this.removeListener(t,e);else if(e)do this.removeListener(t,e[e.length-1]);while(e[0]);return this},Jt.prototype.listeners=function(t){var e,n,r=this._events;return n=r&&(e=r[t])?typeof e=="function"?[e.listener||e]:(function(i){for(var s=new Array(i.length),o=0;o<s.length;++o)s[o]=i[o].listener||i[o];return s})(e):[],n},Jt.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):O1.call(t,e)},Jt.prototype.listenerCount=O1,Jt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Lg=Fl(Object.freeze({__proto__:null,EventEmitter:Jt,default:Jt}));Object.defineProperty(Z2,"__esModule",{value:!0});const OM=Lg;function N1(t,e,n){try{Reflect.apply(t,e,n)}catch(r){setTimeout((()=>{throw r}))}}let NM=class extends OM.EventEmitter{emit(t,...e){let n=t==="error";const r=this._events;if(r!==void 0)n=n&&r.error===void 0;else if(!n)return!1;if(n){let s;if(e.length>0&&([s]=e),s instanceof Error)throw s;const o=new Error("Unhandled error."+(s?` (${s.message})`:""));throw o.context=s,o}const i=r[t];if(i===void 0)return!1;if(typeof i=="function")N1(i,this,e);else{const s=i.length,o=(function(a){const c=a.length,l=new Array(c);for(let u=0;u<c;u+=1)l[u]=a[u];return l})(i);for(let a=0;a<s;a+=1)N1(o[a],this,e)}return!0}};var Yd,Qs,Da,Yc,ud,dd,J0,fd,Z0,rp,P1,hd,X0,ip,M1,sl,Jd,sp,k1,Q2=Z2.default=NM,gi=class pd extends Q2{constructor({notificationHandler:e}={}){super(),bi(this,Yc),bi(this,dd),bi(this,fd),bi(this,Yd,!1),bi(this,Qs,void 0),bi(this,Da,void 0),Nu(this,Qs,[]),Nu(this,Da,e)}destroy(){no(this,Qs).forEach((e=>{"destroy"in e&&typeof e.destroy=="function"&&e.destroy()})),Nu(this,Qs,[]),Nu(this,Yd,!0)}push(e){br(this,Yc,ud).call(this),no(this,Qs).push(e)}handle(e,n){if(br(this,Yc,ud).call(this),n&&typeof n!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?n?br(this,dd,J0).call(this,e,n):br(this,dd,J0).call(this,e):n?br(this,fd,Z0).call(this,e,n):this._promiseHandle(e)}asMiddleware(){return br(this,Yc,ud).call(this),async(e,n,r,i)=>{var s,o;try{const[a,c,l]=await br(s=pd,hd,X0).call(s,e,n,no(this,Qs));return c?(await br(o=pd,sl,Jd).call(o,l),i(a)):r((async u=>{var d;try{await br(d=pd,sl,Jd).call(d,l)}catch(f){return u(f)}return u()}))}catch(a){return i(a)}}}async _promiseHandle(e){return new Promise(((n,r)=>{br(this,fd,Z0).call(this,e,((i,s)=>{i&&s===void 0?r(i):n(s)})).catch(r)}))}};Yd=new WeakMap,Qs=new WeakMap,Da=new WeakMap,Yc=new WeakSet,ud=function(){if(no(this,Yd))throw new Error("This engine is destroyed and can no longer be used.")},dd=new WeakSet,J0=async function(t,e){try{if(t.length===0){const r=[{id:null,jsonrpc:"2.0",error:new ls(Xs.invalidRequest,"Request batch must contain plain objects. Received an empty array")}];return e?e(null,r):r}const n=(await Promise.all(t.map(this._promiseHandle.bind(this)))).filter((r=>r!==void 0));return e?e(null,n):n}catch(n){if(e)return e(n);throw n}},fd=new WeakSet,Z0=async function(t,e){var n;if(!t||Array.isArray(t)||typeof t!="object"){const o=new ls(Xs.invalidRequest,"Requests must be plain objects. Received: "+typeof t,{request:t});return e(o,{id:null,jsonrpc:"2.0",error:o})}if(typeof t.method!="string"){const o=new ls(Xs.invalidRequest,"Must specify a string method. Received: "+typeof t.method,{request:t});return no(this,Da)&&!_1(t)?e(null):e(o,{id:t.id??null,jsonrpc:"2.0",error:o})}if(no(this,Da)&&vc(t,_M)&&!_1(t)){try{await no(this,Da).call(this,t)}catch(o){return e(o)}return e(null)}let r=null;const i={...t},s={id:i.id,jsonrpc:i.jsonrpc};try{await br(n=gi,rp,P1).call(n,i,s,no(this,Qs))}catch(o){r=o}return r&&(delete s.result,s.error||(s.error=A1(r))),e(r,s)},rp=new WeakSet,P1=async function(t,e,n){var r,i,s;const[o,a,c]=await br(r=gi,hd,X0).call(r,t,e,n);if(br(i=gi,sp,k1).call(i,t,e,a),await br(s=gi,sl,Jd).call(s,c),o)throw o},hd=new WeakSet,X0=async function(t,e,n){var r;const i=[];let s=null,o=!1;for(const a of n)if([s,o]=await br(r=gi,ip,M1).call(r,t,e,a,i),o)break;return[s,o,i.reverse()]},ip=new WeakSet,M1=async function(t,e,n,r){return new Promise((i=>{const s=a=>{const c=a||e.error;c&&(e.error=A1(c)),i([c,!0])},o=a=>{e.error?s(e.error):(a&&(typeof a!="function"&&s(new ls(Xs.internal,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof a}" for request:
|
|
29
|
+
${op(t)}`,{request:t})),r.push(a)),i([null,!1]))};try{n(t,e,o,s)}catch(a){s(a)}}))},sl=new WeakSet,Jd=async function(t){for(const e of t)await new Promise(((n,r)=>{e((i=>i?r(i):n()))}))},sp=new WeakSet,k1=function(t,e,n){if(!zd(e,"result")&&!zd(e,"error"))throw new ls(Xs.internal,`JsonRpcEngine: Response has no error or result for request:
|
|
30
|
+
${op(t)}`,{request:t});if(!n)throw new ls(Xs.internal,`JsonRpcEngine: Nothing ended request:
|
|
31
|
+
${op(t)}`,{request:t})},bi(gi,rp),bi(gi,hd),bi(gi,ip),bi(gi,sl),bi(gi,sp);var PM=gi;function op(t){return JSON.stringify(t,null,2)}var eA=Object.freeze(["eth_subscription"]),MM=(t=console)=>[sM(),kM(t),iM(t)];function kM(t){return(e,n,r)=>{typeof e.method=="string"&&e.method||(n.error=il({message:"The request 'method' must be a non-empty string.",data:e})),r((i=>{const{error:s}=n;return s&&t.error(`MetaMask - RPC Error: ${s.message}`,s),i()}))}}var md=(t,e,n=!0)=>(r,i)=>{r||i.error?e(r||i.error):!n||Array.isArray(i)?t(i):t(i.result)},tA=t=>!!t&&typeof t=="string"&&t.startsWith("0x"),nA=()=>{};async function D1(t,e){try{const n=await(async function(){return{name:DM(window),icon:await LM(window)}})();t.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:n},nA)}catch(n){e.error({message:In.errors.sendSiteMetadata(),originalError:n})}}function DM(t){const{document:e}=t,n=e.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=e.querySelector('head > meta[name="title"]');return r?r.content:e.title&&e.title.length>0?e.title:window.location.hostname}async function LM(t){const{document:e}=t,n=e.querySelectorAll('head > link[rel~="icon"]');for(const r of Array.from(n))if(r&&await BM(r.href))return r.href;return null}async function BM(t){return new Promise(((e,n)=>{try{const r=document.createElement("img");r.onload=()=>e(!0),r.onerror=()=>e(!1),r.src=t}catch(r){n(r)}}))}var rA=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},Fi=(t,e,n)=>(rA(t,e,"read from private field"),n?n.call(t):e.get(t)),Q0=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},us=(t,e,n,r)=>(rA(t,e,"write to private field"),e.set(t,n),n);function L1(t,e,n){try{Reflect.apply(t,e,n)}catch(r){setTimeout((()=>{throw r}))}}class UM extends Jt{emit(e,...n){let r=e==="error";const i=this._events;if(i!==void 0)r=r&&i.error===void 0;else if(!r)return!1;if(r){let o;if(n.length>0&&([o]=n),o instanceof Error)throw o;const a=new Error("Unhandled error."+(o?` (${o.message})`:""));throw a.context=o,a}const s=i[e];if(s===void 0)return!1;if(typeof s=="function")L1(s,this,n);else{const o=s.length,a=(function(c){const l=c.length,u=new Array(l);for(let d=0;d<l;d+=1)u[d]=c[d];return u})(s);for(let c=0;c<o;c+=1)L1(a[c],this,n)}return!0}}var Gs,Io,$M=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;i--!=0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(s=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;i--!=0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!=0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!=e&&n!=n},FM=Bf($M),iA=class sA extends UM{constructor({logger:e=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),Q0(this,Gs,void 0),Q0(this,Io,void 0),this._log=e,this.setMaxListeners(n),this._state={...sA._defaultState},us(this,Io,null),us(this,Gs,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new PM;r.forEach((s=>i.push(s))),this._rpcEngine=i}get chainId(){return Fi(this,Gs)}get selectedAddress(){return Fi(this,Io)}isConnected(){return this._state.isConnected}async request(e){if(!e||typeof e!="object"||Array.isArray(e))throw il({message:In.errors.invalidRequestArgs(),data:e});const{method:n,params:r}=e;if(typeof n!="string"||n.length===0)throw il({message:In.errors.invalidRequestMethod(),data:e});if(r!==void 0&&!Array.isArray(r)&&(typeof r!="object"||r===null))throw il({message:In.errors.invalidRequestParams(),data:e});const i=r==null?{method:n}:{method:n,params:r};return new Promise(((s,o)=>{this._rpcRequest(i,md(s,o))}))}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:n,chainId:r,isUnlocked:i,networkVersion:s}=e;this._handleConnect(r),this._handleChainChanged({chainId:r,networkVersion:s}),this._handleUnlockStateChanged({accounts:n,isUnlocked:i}),this._handleAccountsChanged(n)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,n){let r=n;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),e.method!=="eth_accounts"&&e.method!=="eth_requestAccounts"||(r=(i,s)=>{this._handleAccountsChanged(s.result??[],e.method==="eth_accounts"),n(i,s)})),this._rpcEngine.handle(e,r)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(In.info.connected(e)))}_handleDisconnect(e,n){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let r;this._state.isConnected=!1,e?(r=new ls(1013,n??In.errors.disconnected()),this._log.debug(r)):(r=new ls(1011,n??In.errors.permanentlyDisconnected()),this._log.error(r),us(this,Gs,null),this._state.accounts=null,us(this,Io,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",r)}}_handleChainChanged({chainId:e}={}){tA(e)?(this._handleConnect(e),e!==Fi(this,Gs)&&(us(this,Gs,e),this._state.initialized&&this.emit("chainChanged",Fi(this,Gs)))):this._log.error(In.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,n=!1){let r=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),r=[]);for(const i of e)if(typeof i!="string"){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),r=[];break}if(!FM(this._state.accounts,r)&&(n&&this._state.accounts!==null&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",r),this._state.accounts=r,Fi(this,Io)!==r[0]&&us(this,Io,r[0]||null),this._state.initialized)){const i=[...r];this.emit("accountsChanged",i)}}_handleUnlockStateChanged({accounts:e,isUnlocked:n}={}){typeof n=="boolean"?n!==this._state.isUnlocked&&(this._state.isUnlocked=n,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};Gs=new WeakMap,Io=new WeakMap,iA._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var Bg,KM=iA,em={exports:{}},oA=Lg.EventEmitter,Ug=Fl(n5);Bg=typeof Object.create=="function"?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t};var aA=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r<e.length;r++)n[e[r]]=Object.getOwnPropertyDescriptor(t,e[r]);return n},VM=/%[sdj%]/g;function Ff(t){if(!Al(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(Wi(arguments[n]));return e.join(" ")}n=1;for(var r=arguments,i=r.length,s=String(t).replace(VM,(function(a){if(a==="%%")return"%";if(n>=i)return a;switch(a){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch{return"[Circular]"}default:return a}})),o=r[n];n<i;o=r[++n])jl(o)||!ra(o)?s+=" "+o:s+=" "+Wi(o);return s}function $g(t,e){if(ji(Tr.process))return function(){return $g(t,e).apply(this,arguments)};if(Wt.noDeprecation===!0)return t;var n=!1;return function(){if(!n){if(Wt.throwDeprecation)throw new Error(e);Wt.traceDeprecation?console.trace(e):console.error(e),n=!0}return t.apply(this,arguments)}}var ap,Mu={};function cA(t){return ji(ap)&&(ap=Wt.env.NODE_DEBUG||""),t=t.toUpperCase(),!Mu[t]&&(new RegExp("\\b"+t+"\\b","i").test(ap)?Mu[t]=function(){var e=Ff.apply(null,arguments);console.error("%s %d: %s",t,0,e)}:Mu[t]=function(){}),Mu[t]}function Wi(t,e){var n={seen:[],stylize:HM};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),Kf(e)?n.showHidden=e:e&&jg(n,e),ji(n.showHidden)&&(n.showHidden=!1),ji(n.depth)&&(n.depth=2),ji(n.colors)&&(n.colors=!1),ji(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=jM),Zd(n,t,n.depth)}function jM(t,e){var n=Wi.styles[e];return n?"\x1B["+Wi.colors[n][0]+"m"+t+"\x1B["+Wi.colors[n][1]+"m":t}function HM(t,e){return t}function Zd(t,e,n){if(t.customInspect&&e&&cl(e.inspect)&&e.inspect!==Wi&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(n,t);return Al(r)||(r=Zd(t,r,n)),r}var i=(function(f,g){if(ji(g))return f.stylize("undefined","undefined");if(Al(g)){var v="'"+JSON.stringify(g).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f.stylize(v,"string")}if(Kg(g))return f.stylize(""+g,"number");if(Kf(g))return f.stylize(""+g,"boolean");if(jl(g))return f.stylize("null","null")})(t,e);if(i)return i;var s=Object.keys(e),o=(function(f){var g={};return f.forEach((function(v,w){g[v]=!0})),g})(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),al(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return cp(e);if(s.length===0){if(cl(e)){var a=e.name?": "+e.name:"";return t.stylize("[Function"+a+"]","special")}if(ol(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(Xd(e))return t.stylize(Date.prototype.toString.call(e),"date");if(al(e))return cp(e)}var c,l="",u=!1,d=["{","}"];return Fg(e)&&(u=!0,d=["[","]"]),cl(e)&&(l=" [Function"+(e.name?": "+e.name:"")+"]"),ol(e)&&(l=" "+RegExp.prototype.toString.call(e)),Xd(e)&&(l=" "+Date.prototype.toUTCString.call(e)),al(e)&&(l=" "+cp(e)),s.length!==0||u&&e.length!=0?n<0?ol(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=u?(function(f,g,v,w,b){for(var E=[],M=0,S=g.length;M<S;++M)pA(g,String(M))?E.push(lp(f,g,v,w,String(M),!0)):E.push("");return b.forEach((function(F){F.match(/^\d+$/)||E.push(lp(f,g,v,w,F,!0))})),E})(t,e,n,o,s):s.map((function(f){return lp(t,e,n,o,f,u)})),t.seen.pop(),(function(f,g,v){var w=f.reduce((function(b,E){return E.indexOf(`
|
|
32
|
+
`),b+E.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return w>60?v[0]+(g===""?"":g+`
|
|
33
|
+
`)+" "+f.join(`,
|
|
34
|
+
`)+" "+v[1]:v[0]+g+" "+f.join(", ")+" "+v[1]})(c,l,d)):d[0]+l+d[1]}function cp(t){return"["+Error.prototype.toString.call(t)+"]"}function lp(t,e,n,r,i,s){var o,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),pA(r,i)||(o="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=jl(n)?Zd(t,c.value,null):Zd(t,c.value,n-1)).indexOf(`
|
|
35
|
+
`)>-1&&(a=s?a.split(`
|
|
36
|
+
`).map((function(l){return" "+l})).join(`
|
|
37
|
+
`).substr(2):`
|
|
38
|
+
`+a.split(`
|
|
39
|
+
`).map((function(l){return" "+l})).join(`
|
|
40
|
+
`)):a=t.stylize("[Circular]","special")),ji(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function Fg(t){return Array.isArray(t)}function Kf(t){return typeof t=="boolean"}function jl(t){return t===null}function lA(t){return t==null}function Kg(t){return typeof t=="number"}function Al(t){return typeof t=="string"}function uA(t){return typeof t=="symbol"}function ji(t){return t===void 0}function ol(t){return ra(t)&&Vg(t)==="[object RegExp]"}function ra(t){return typeof t=="object"&&t!==null}function Xd(t){return ra(t)&&Vg(t)==="[object Date]"}function al(t){return ra(t)&&(Vg(t)==="[object Error]"||t instanceof Error)}function cl(t){return typeof t=="function"}function dA(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||t===void 0}function fA(t){return Se.isBuffer(t)}function Vg(t){return Object.prototype.toString.call(t)}function up(t){return t<10?"0"+t.toString(10):t.toString(10)}Wi.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Wi.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var zM=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hA(){var t,e;console.log("%s - %s",(t=new Date,e=[up(t.getHours()),up(t.getMinutes()),up(t.getSeconds())].join(":"),[t.getDate(),zM[t.getMonth()],e].join(" ")),Ff.apply(null,arguments))}function jg(t,e){if(!e||!ra(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}function pA(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var To=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;function Hg(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(To&&t[To]){var e;if(typeof(e=t[To])!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,To,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var n,r,i=new Promise((function(a,c){n=a,r=c})),s=[],o=0;o<arguments.length;o++)s.push(arguments[o]);s.push((function(a,c){a?r(a):n(c)}));try{t.apply(this,s)}catch(a){r(a)}return i}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),To&&Object.defineProperty(e,To,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,aA(t))}function qM(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}function mA(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');function e(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var i=n.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var s=this,o=function(){return i.apply(s,arguments)};t.apply(this,n).then((function(a){Wt.nextTick(o.bind(null,null,a))}),(function(a){Wt.nextTick(qM.bind(null,a,o))}))}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,aA(t)),e}Hg.custom=To;var dp,B1,WM={inherits:Bg,_extend:jg,log:hA,isBuffer:fA,isPrimitive:dA,isFunction:cl,isError:al,isDate:Xd,isObject:ra,isRegExp:ol,isUndefined:ji,isSymbol:uA,isString:Al,isNumber:Kg,isNullOrUndefined:lA,isNull:jl,isBoolean:Kf,isArray:Fg,inspect:Wi,deprecate:$g,format:Ff,debuglog:cA,promisify:Hg,callbackify:mA},gA=Fl(Object.freeze({__proto__:null,_extend:jg,callbackify:mA,debuglog:cA,default:WM,deprecate:$g,format:Ff,inherits:Bg,inspect:Wi,isArray:Fg,isBoolean:Kf,isBuffer:fA,isDate:Xd,isError:al,isFunction:cl,isNull:jl,isNullOrUndefined:lA,isNumber:Kg,isObject:ra,isPrimitive:dA,isRegExp:ol,isString:Al,isSymbol:uA,isUndefined:ji,log:hA,promisify:Hg}));function GM(){if(B1)return dp;function t(c,l){var u=Object.keys(c);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(c);l&&(d=d.filter((function(f){return Object.getOwnPropertyDescriptor(c,f).enumerable}))),u.push.apply(u,d)}return u}function e(c){for(var l=1;l<arguments.length;l++){var u=arguments[l]!=null?arguments[l]:{};l%2?t(Object(u),!0).forEach((function(d){n(c,d,u[d])})):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(u)):t(Object(u)).forEach((function(d){Object.defineProperty(c,d,Object.getOwnPropertyDescriptor(u,d))}))}return c}function n(c,l,u){return(l=i(l))in c?Object.defineProperty(c,l,{value:u,enumerable:!0,configurable:!0,writable:!0}):c[l]=u,c}function r(c,l,u){return l&&(function(d,f){for(var g=0;g<f.length;g++){var v=f[g];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(d,i(v.key),v)}})(c.prototype,l),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var l=(function(u,d){if(typeof u!="object"||u===null)return u;var f=u[Symbol.toPrimitive];if(f!==void 0){var g=f.call(u,d);if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)})(c,"string");return typeof l=="symbol"?l:String(l)}B1=1;var s=Ug.Buffer,o=gA.inspect,a=o&&o.custom||"inspect";return dp=(function(){function c(){(function(l,u){if(!(l instanceof u))throw new TypeError("Cannot call a class as a function")})(this,c),this.head=null,this.tail=null,this.length=0}return r(c,[{key:"push",value:function(l){var u={data:l,next:null};this.length>0?this.tail.next=u:this.head=u,this.tail=u,++this.length}},{key:"unshift",value:function(l){var u={data:l,next:this.head};this.length===0&&(this.tail=u),this.head=u,++this.length}},{key:"shift",value:function(){if(this.length!==0){var l=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,l}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(l){if(this.length===0)return"";for(var u=this.head,d=""+u.data;u=u.next;)d+=l+u.data;return d}},{key:"concat",value:function(l){if(this.length===0)return s.alloc(0);for(var u,d,f,g=s.allocUnsafe(l>>>0),v=this.head,w=0;v;)u=v.data,d=g,f=w,s.prototype.copy.call(u,d,f),w+=v.data.length,v=v.next;return g}},{key:"consume",value:function(l,u){var d;return l<this.head.data.length?(d=this.head.data.slice(0,l),this.head.data=this.head.data.slice(l)):d=l===this.head.data.length?this.shift():u?this._getString(l):this._getBuffer(l),d}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(l){var u=this.head,d=1,f=u.data;for(l-=f.length;u=u.next;){var g=u.data,v=l>g.length?g.length:l;if(v===g.length?f+=g:f+=g.slice(0,l),(l-=v)===0){v===g.length?(++d,u.next?this.head=u.next:this.head=this.tail=null):(this.head=u,u.data=g.slice(v));break}++d}return this.length-=d,f}},{key:"_getBuffer",value:function(l){var u=s.allocUnsafe(l),d=this.head,f=1;for(d.data.copy(u),l-=d.data.length;d=d.next;){var g=d.data,v=l>g.length?g.length:l;if(g.copy(u,u.length-l,0,v),(l-=v)===0){v===g.length?(++f,d.next?this.head=d.next:this.head=this.tail=null):(this.head=d,d.data=g.slice(v));break}++f}return this.length-=f,u}},{key:a,value:function(l,u){return o(this,e(e({},u),{},{depth:0,customInspect:!1}))}}]),c})(),dp}function U1(t,e){tm(t,e),gd(t)}function gd(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function tm(t,e){t.emit("error",e)}var yA={destroy:function(t,e){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Wt.nextTick(tm,this,t)):Wt.nextTick(tm,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(s){!e&&s?n._writableState?n._writableState.errorEmitted?Wt.nextTick(gd,n):(n._writableState.errorEmitted=!0,Wt.nextTick(U1,n,s)):Wt.nextTick(U1,n,s):e?(Wt.nextTick(gd,n),e(s)):Wt.nextTick(gd,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}},ia={},wA={};function ei(t,e,n){n||(n=Error);var r=(function(i){var s,o;function a(c,l,u){return i.call(this,(function(d,f,g){return typeof e=="string"?e:e(d,f,g)})(c,l,u))||this}return o=i,(s=a).prototype=Object.create(o.prototype),s.prototype.constructor=s,s.__proto__=o,a})(n);r.prototype.name=n.name,r.prototype.code=t,wA[t]=r}function $1(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(r){return String(r)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:n===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}ei("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),ei("ERR_INVALID_ARG_TYPE",(function(t,e,n){var r,i,s;if(typeof e=="string"&&(i="not ",e.substr(0,i.length)===i)?(r="must not be",e=e.replace(/^not /,"")):r="must be",(function(a,c,l){return(l===void 0||l>a.length)&&(l=a.length),a.substring(l-c.length,l)===c})(t," argument"))s="The ".concat(t," ").concat(r," ").concat($1(e,"type"));else{var o=(function(a,c,l){return typeof l!="number"&&(l=0),!(l+c.length>a.length)&&a.indexOf(c,l)!==-1})(t,".")?"property":"argument";s='The "'.concat(t,'" ').concat(o," ").concat(r," ").concat($1(e,"type"))}return s+=". Received type ".concat(typeof n)}),TypeError),ei("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),ei("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),ei("ERR_STREAM_PREMATURE_CLOSE","Premature close"),ei("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),ei("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),ei("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),ei("ERR_STREAM_WRITE_AFTER_END","write after end"),ei("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),ei("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),ei("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),ia.codes=wA;var YM=ia.codes.ERR_INVALID_OPT_VALUE,fp,F1,hp,K1,vA={getHighWaterMark:function(t,e,n,r){var i=(function(s,o,a){return s.highWaterMark!=null?s.highWaterMark:o?s[a]:null})(e,r,n);if(i!=null){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new YM(r?n:"highWaterMark",i);return Math.floor(i)}return t.objectMode?16:16384}},JM=typeof Object.create=="function"?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t},Hl=Fl(Object.freeze({__proto__:null,default:JM})),ZM=function(t,e){if(pp("noDeprecation"))return t;var n=!1;return function(){if(!n){if(pp("throwDeprecation"))throw new Error(e);pp("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}};function pp(t){try{if(!fi.localStorage)return!1}catch{return!1}var e=fi.localStorage[t];return e!=null&&String(e).toLowerCase()==="true"}function EA(){if(F1)return fp;function t(V){var T=this;this.next=null,this.entry=null,this.finish=function(){(function(p,y,R){var P=p.entry;for(p.entry=null;P;){var _=P.callback;y.pendingcb--,_(R),P=P.next}y.corkedRequestsFree.next=p})(T,V)}}var e;F1=1,fp=D,D.WritableState=F;var n={deprecate:ZM},r=oA,i=Ug.Buffer,s=(fi!==void 0?fi:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){},o,a=yA,c=vA.getHighWaterMark,l=ia.codes,u=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,f=l.ERR_MULTIPLE_CALLBACK,g=l.ERR_STREAM_CANNOT_PIPE,v=l.ERR_STREAM_DESTROYED,w=l.ERR_STREAM_NULL_VALUES,b=l.ERR_STREAM_WRITE_AFTER_END,E=l.ERR_UNKNOWN_ENCODING,M=a.errorOrDestroy;function S(){}function F(V,T,p){e=e||tc(),V=V||{},typeof p!="boolean"&&(p=T instanceof e),this.objectMode=!!V.objectMode,p&&(this.objectMode=this.objectMode||!!V.writableObjectMode),this.highWaterMark=c(this,V,"writableHighWaterMark",p),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var y=V.decodeStrings===!1;this.decodeStrings=!y,this.defaultEncoding=V.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(R){(function(P,_){var I=P._writableState,N=I.sync,x=I.writecb;if(typeof x!="function")throw new f;if((function(m){m.writing=!1,m.writecb=null,m.length-=m.writelen,m.writelen=0})(I),_)(function(m,A,C,$,j){--A.pendingcb,C?(Wt.nextTick(j,$),Wt.nextTick(H,m,A),m._writableState.errorEmitted=!0,M(m,$)):(j($),m._writableState.errorEmitted=!0,M(m,$),H(m,A))})(P,I,N,_,x);else{var h=U(I)||P.destroyed;h||I.corked||I.bufferProcessing||!I.bufferedRequest||Y(P,I),N?Wt.nextTick(X,P,I,h,x):X(P,I,h,x)}})(T,R)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=V.emitClose!==!1,this.autoDestroy=!!V.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function D(V){var T=this instanceof(e=e||tc());if(!T&&!o.call(D,this))return new D(V);this._writableState=new F(V,this,T),this.writable=!0,V&&(typeof V.write=="function"&&(this._write=V.write),typeof V.writev=="function"&&(this._writev=V.writev),typeof V.destroy=="function"&&(this._destroy=V.destroy),typeof V.final=="function"&&(this._final=V.final)),r.call(this)}function z(V,T,p,y,R,P,_){T.writelen=y,T.writecb=_,T.writing=!0,T.sync=!0,T.destroyed?T.onwrite(new v("write")):p?V._writev(R,T.onwrite):V._write(R,P,T.onwrite),T.sync=!1}function X(V,T,p,y){p||(function(R,P){P.length===0&&P.needDrain&&(P.needDrain=!1,R.emit("drain"))})(V,T),T.pendingcb--,y(),H(V,T)}function Y(V,T){T.bufferProcessing=!0;var p=T.bufferedRequest;if(V._writev&&p&&p.next){var y=T.bufferedRequestCount,R=new Array(y),P=T.corkedRequestsFree;P.entry=p;for(var _=0,I=!0;p;)R[_]=p,p.isBuf||(I=!1),p=p.next,_+=1;R.allBuffers=I,z(V,T,!0,T.length,R,"",P.finish),T.pendingcb++,T.lastBufferedRequest=null,P.next?(T.corkedRequestsFree=P.next,P.next=null):T.corkedRequestsFree=new t(T),T.bufferedRequestCount=0}else{for(;p;){var N=p.chunk,x=p.encoding,h=p.callback;if(z(V,T,!1,T.objectMode?1:N.length,N,x,h),p=p.next,T.bufferedRequestCount--,T.writing)break}p===null&&(T.lastBufferedRequest=null)}T.bufferedRequest=p,T.bufferProcessing=!1}function U(V){return V.ending&&V.length===0&&V.bufferedRequest===null&&!V.finished&&!V.writing}function B(V,T){V._final((function(p){T.pendingcb--,p&&M(V,p),T.prefinished=!0,V.emit("prefinish"),H(V,T)}))}function H(V,T){var p=U(T);if(p&&((function(R,P){P.prefinished||P.finalCalled||(typeof R._final!="function"||P.destroyed?(P.prefinished=!0,R.emit("prefinish")):(P.pendingcb++,P.finalCalled=!0,Wt.nextTick(B,R,P)))})(V,T),T.pendingcb===0&&(T.finished=!0,V.emit("finish"),T.autoDestroy))){var y=V._readableState;(!y||y.autoDestroy&&y.endEmitted)&&V.destroy()}return p}return Hl(D,r),F.prototype.getBuffer=function(){for(var V=this.bufferedRequest,T=[];V;)T.push(V),V=V.next;return T},(function(){try{Object.defineProperty(F.prototype,"buffer",{get:n.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(V){return!!o.call(this,V)||this===D&&V&&V._writableState instanceof F}})):o=function(V){return V instanceof this},D.prototype.pipe=function(){M(this,new g)},D.prototype.write=function(V,T,p){var y,R=this._writableState,P=!1,_=!R.objectMode&&(y=V,i.isBuffer(y)||y instanceof s);return _&&!i.isBuffer(V)&&(V=(function(I){return i.from(I)})(V)),typeof T=="function"&&(p=T,T=null),_?T="buffer":T||(T=R.defaultEncoding),typeof p!="function"&&(p=S),R.ending?(function(I,N){var x=new b;M(I,x),Wt.nextTick(N,x)})(this,p):(_||(function(I,N,x,h){var m;return x===null?m=new w:typeof x=="string"||N.objectMode||(m=new u("chunk",["string","Buffer"],x)),!m||(M(I,m),Wt.nextTick(h,m),!1)})(this,R,V,p))&&(R.pendingcb++,P=(function(I,N,x,h,m,A){if(!x){var C=(function(ne,se,ue){return ne.objectMode||ne.decodeStrings===!1||typeof se!="string"||(se=i.from(se,ue)),se})(N,h,m);h!==C&&(x=!0,m="buffer",h=C)}var $=N.objectMode?1:h.length;N.length+=$;var j=N.length<N.highWaterMark;if(j||(N.needDrain=!0),N.writing||N.corked){var Z=N.lastBufferedRequest;N.lastBufferedRequest={chunk:h,encoding:m,isBuf:x,callback:A,next:null},Z?Z.next=N.lastBufferedRequest:N.bufferedRequest=N.lastBufferedRequest,N.bufferedRequestCount+=1}else z(I,N,!1,$,h,m,A);return j})(this,R,_,V,T,p)),P},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var V=this._writableState;V.corked&&(V.corked--,V.writing||V.corked||V.bufferProcessing||!V.bufferedRequest||Y(this,V))},D.prototype.setDefaultEncoding=function(V){if(typeof V=="string"&&(V=V.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((V+"").toLowerCase())>-1))throw new E(V);return this._writableState.defaultEncoding=V,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),D.prototype._write=function(V,T,p){p(new d("_write()"))},D.prototype._writev=null,D.prototype.end=function(V,T,p){var y=this._writableState;return typeof V=="function"?(p=V,V=null,T=null):typeof T=="function"&&(p=T,T=null),V!=null&&this.write(V,T),y.corked&&(y.corked=1,this.uncork()),y.ending||(function(R,P,_){P.ending=!0,H(R,P),_&&(P.finished?Wt.nextTick(_):R.once("finish",_)),P.ended=!0,R.writable=!1})(this,y,p),this},Object.defineProperty(D.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(V){this._writableState&&(this._writableState.destroyed=V)}}),D.prototype.destroy=a.destroy,D.prototype._undestroy=a.undestroy,D.prototype._destroy=function(V,T){T(V)},fp}function tc(){if(K1)return hp;K1=1;var t=Object.keys||function(l){var u=[];for(var d in l)u.push(d);return u};hp=o;var e=bA(),n=EA();Hl(o,e);for(var r=t(n.prototype),i=0;i<r.length;i++){var s=r[i];o.prototype[s]||(o.prototype[s]=n.prototype[s])}function o(l){if(!(this instanceof o))return new o(l);e.call(this,l),n.call(this,l),this.allowHalfOpen=!0,l&&(l.readable===!1&&(this.readable=!1),l.writable===!1&&(this.writable=!1),l.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",a)))}function a(){this._writableState.ended||Wt.nextTick(c,this)}function c(l){l.end()}return Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(o.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(o.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(o.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(l){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=l,this._writableState.destroyed=l)}}),hp}var XM=Se.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function yd(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),(function(e){if(e&&!XM(e))throw new Error("Unknown encoding: "+e)})(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=e8;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=t8;break;default:return void(this.write=QM)}this.charBuffer=new Se(6),this.charReceived=0,this.charLength=0}function QM(t){return t.toString(this.encoding)}function e8(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function t8(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}yd.prototype.write=function(t){for(var e="";this.charLength;){var n=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(t=t.slice(n,t.length),!((i=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&i<=56319)){if(this.charReceived=this.charLength=0,t.length===0)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived);var i;if(r=(e+=t.toString(this.encoding,0,r)).length-1,(i=e.charCodeAt(r))>=55296&&i<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),t.copy(this.charBuffer,0,0,s),e.substring(0,r)}return e},yd.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(e==1&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},yd.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e};var V1=Fl(Object.freeze({__proto__:null,StringDecoder:yd})),j1=ia.codes.ERR_STREAM_PREMATURE_CLOSE;function n8(){}var mp,H1,z1,q1,gp,W1,zg=function t(e,n,r){if(typeof n=="function")return t(e,null,n);n||(n={}),r=(function(v){var w=!1;return function(){if(!w){w=!0;for(var b=arguments.length,E=new Array(b),M=0;M<b;M++)E[M]=arguments[M];v.apply(this,E)}}})(r||n8);var i=n.readable||n.readable!==!1&&e.readable,s=n.writable||n.writable!==!1&&e.writable,o=function(){e.writable||c()},a=e._writableState&&e._writableState.finished,c=function(){s=!1,a=!0,i||r.call(e)},l=e._readableState&&e._readableState.endEmitted,u=function(){i=!1,l=!0,s||r.call(e)},d=function(v){r.call(e,v)},f=function(){var v;return i&&!l?(e._readableState&&e._readableState.ended||(v=new j1),r.call(e,v)):s&&!a?(e._writableState&&e._writableState.ended||(v=new j1),r.call(e,v)):void 0},g=function(){e.req.on("finish",c)};return(function(v){return v.setHeader&&typeof v.abort=="function"})(e)?(e.on("complete",c),e.on("abort",f),e.req?g():e.on("request",g)):s&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",u),e.on("finish",c),n.error!==!1&&e.on("error",d),e.on("close",f),function(){e.removeListener("complete",c),e.removeListener("abort",f),e.removeListener("request",g),e.req&&e.req.removeListener("finish",c),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",c),e.removeListener("end",u),e.removeListener("error",d),e.removeListener("close",f)}};function r8(){if(H1)return mp;var t;function e(w,b,E){return(b=(function(M){var S=(function(F,D){if(typeof F!="object"||F===null)return F;var z=F[Symbol.toPrimitive];if(z!==void 0){var X=z.call(F,D);if(typeof X!="object")return X;throw new TypeError("@@toPrimitive must return a primitive value.")}return(D==="string"?String:Number)(F)})(M,"string");return typeof S=="symbol"?S:String(S)})(b))in w?Object.defineProperty(w,b,{value:E,enumerable:!0,configurable:!0,writable:!0}):w[b]=E,w}H1=1;var n=zg,r=Symbol("lastResolve"),i=Symbol("lastReject"),s=Symbol("error"),o=Symbol("ended"),a=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function u(w,b){return{value:w,done:b}}function d(w){var b=w[r];if(b!==null){var E=w[l].read();E!==null&&(w[a]=null,w[r]=null,w[i]=null,b(u(E,!1)))}}function f(w){Wt.nextTick(d,w)}var g=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((e(t={get stream(){return this[l]},next:function(){var w=this,b=this[s];if(b!==null)return Promise.reject(b);if(this[o])return Promise.resolve(u(void 0,!0));if(this[l].destroyed)return new Promise((function(F,D){Wt.nextTick((function(){w[s]?D(w[s]):F(u(void 0,!0))}))}));var E,M=this[a];if(M)E=new Promise((function(F,D){return function(z,X){F.then((function(){D[o]?z(u(void 0,!0)):D[c](z,X)}),X)}})(M,this));else{var S=this[l].read();if(S!==null)return Promise.resolve(u(S,!1));E=new Promise(this[c])}return this[a]=E,E}},Symbol.asyncIterator,(function(){return this})),e(t,"return",(function(){var w=this;return new Promise((function(b,E){w[l].destroy(null,(function(M){M?E(M):b(u(void 0,!0))}))}))})),t),g);return mp=function(w){var b,E=Object.create(v,(e(b={},l,{value:w,writable:!0}),e(b,r,{value:null,writable:!0}),e(b,i,{value:null,writable:!0}),e(b,s,{value:null,writable:!0}),e(b,o,{value:w._readableState.endEmitted,writable:!0}),e(b,c,{value:function(M,S){var F=E[l].read();F?(E[a]=null,E[r]=null,E[i]=null,M(u(F,!1))):(E[r]=M,E[i]=S)},writable:!0}),b));return E[a]=null,n(w,(function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var S=E[i];return S!==null&&(E[a]=null,E[r]=null,E[i]=null,S(M)),void(E[s]=M)}var F=E[r];F!==null&&(E[a]=null,E[r]=null,E[i]=null,F(u(void 0,!0))),E[o]=!0})),w.on("readable",f.bind(null,E)),E},mp}function bA(){if(W1)return gp;var t;W1=1,gp=D,D.ReadableState=F,Lg.EventEmitter;var e=function(h,m){return h.listeners(m).length},n=oA,r=Ug.Buffer,i=(fi!==void 0?fi:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){},s,o=gA;s=o&&o.debuglog?o.debuglog("stream"):function(){};var a,c,l,u=GM(),d=yA,f=vA.getHighWaterMark,g=ia.codes,v=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,b=g.ERR_METHOD_NOT_IMPLEMENTED,E=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Hl(D,n);var M=d.errorOrDestroy,S=["error","close","destroy","pause","resume"];function F(h,m,A){t=t||tc(),h=h||{},typeof A!="boolean"&&(A=m instanceof t),this.objectMode=!!h.objectMode,A&&(this.objectMode=this.objectMode||!!h.readableObjectMode),this.highWaterMark=f(this,h,"readableHighWaterMark",A),this.buffer=new u,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=h.emitClose!==!1,this.autoDestroy=!!h.autoDestroy,this.destroyed=!1,this.defaultEncoding=h.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,h.encoding&&(a||(a=V1.StringDecoder),this.decoder=new a(h.encoding),this.encoding=h.encoding)}function D(h){if(t=t||tc(),!(this instanceof D))return new D(h);var m=this instanceof t;this._readableState=new F(h,this,m),this.readable=!0,h&&(typeof h.read=="function"&&(this._read=h.read),typeof h.destroy=="function"&&(this._destroy=h.destroy)),n.call(this)}function z(h,m,A,C,$){s("readableAddChunk",m);var j,Z=h._readableState;if(m===null)Z.reading=!1,(function(ne,se){if(s("onEofChunk"),!se.ended){if(se.decoder){var ue=se.decoder.end();ue&&ue.length&&(se.buffer.push(ue),se.length+=se.objectMode?1:ue.length)}se.ended=!0,se.sync?B(ne):(se.needReadable=!1,se.emittedReadable||(se.emittedReadable=!0,H(ne)))}})(h,Z);else if($||(j=(function(ne,se){var ue;de=se,r.isBuffer(de)||de instanceof i||typeof se=="string"||se===void 0||ne.objectMode||(ue=new v("chunk",["string","Buffer","Uint8Array"],se));var de;return ue})(Z,m)),j)M(h,j);else if(Z.objectMode||m&&m.length>0)if(typeof m=="string"||Z.objectMode||Object.getPrototypeOf(m)===r.prototype||(m=(function(ne){return r.from(ne)})(m)),C)Z.endEmitted?M(h,new E):X(h,Z,m,!0);else if(Z.ended)M(h,new w);else{if(Z.destroyed)return!1;Z.reading=!1,Z.decoder&&!A?(m=Z.decoder.write(m),Z.objectMode||m.length!==0?X(h,Z,m,!1):V(h,Z)):X(h,Z,m,!1)}else C||(Z.reading=!1,V(h,Z));return!Z.ended&&(Z.length<Z.highWaterMark||Z.length===0)}function X(h,m,A,C){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,h.emit("data",A)):(m.length+=m.objectMode?1:A.length,C?m.buffer.unshift(A):m.buffer.push(A),m.needReadable&&B(h)),V(h,m)}Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(h){this._readableState&&(this._readableState.destroyed=h)}}),D.prototype.destroy=d.destroy,D.prototype._undestroy=d.undestroy,D.prototype._destroy=function(h,m){m(h)},D.prototype.push=function(h,m){var A,C=this._readableState;return C.objectMode?A=!0:typeof h=="string"&&((m=m||C.defaultEncoding)!==C.encoding&&(h=r.from(h,m),m=""),A=!0),z(this,h,m,!1,A)},D.prototype.unshift=function(h){return z(this,h,null,!0,!1)},D.prototype.isPaused=function(){return this._readableState.flowing===!1},D.prototype.setEncoding=function(h){a||(a=V1.StringDecoder);var m=new a(h);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,C="";A!==null;)C+=m.write(A.data),A=A.next;return this._readableState.buffer.clear(),C!==""&&this._readableState.buffer.push(C),this._readableState.length=C.length,this};var Y=1073741824;function U(h,m){return h<=0||m.length===0&&m.ended?0:m.objectMode?1:h!=h?m.flowing&&m.length?m.buffer.head.data.length:m.length:(h>m.highWaterMark&&(m.highWaterMark=(function(A){return A>=Y?A=Y:(A--,A|=A>>>1,A|=A>>>2,A|=A>>>4,A|=A>>>8,A|=A>>>16,A++),A})(h)),h<=m.length?h:m.ended?m.length:(m.needReadable=!0,0))}function B(h){var m=h._readableState;s("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(s("emitReadable",m.flowing),m.emittedReadable=!0,Wt.nextTick(H,h))}function H(h){var m=h._readableState;s("emitReadable_",m.destroyed,m.length,m.ended),m.destroyed||!m.length&&!m.ended||(h.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,P(h)}function V(h,m){m.readingMore||(m.readingMore=!0,Wt.nextTick(T,h,m))}function T(h,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var A=m.length;if(s("maybeReadMore read 0"),h.read(0),A===m.length)break}m.readingMore=!1}function p(h){var m=h._readableState;m.readableListening=h.listenerCount("readable")>0,m.resumeScheduled&&!m.paused?m.flowing=!0:h.listenerCount("data")>0&&h.resume()}function y(h){s("readable nexttick read 0"),h.read(0)}function R(h,m){s("resume",m.reading),m.reading||h.read(0),m.resumeScheduled=!1,h.emit("resume"),P(h),m.flowing&&!m.reading&&h.read(0)}function P(h){var m=h._readableState;for(s("flow",m.flowing);m.flowing&&h.read()!==null;);}function _(h,m){return m.length===0?null:(m.objectMode?A=m.buffer.shift():!h||h>=m.length?(A=m.decoder?m.buffer.join(""):m.buffer.length===1?m.buffer.first():m.buffer.concat(m.length),m.buffer.clear()):A=m.buffer.consume(h,m.decoder),A);var A}function I(h){var m=h._readableState;s("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,Wt.nextTick(N,m,h))}function N(h,m){if(s("endReadableNT",h.endEmitted,h.length),!h.endEmitted&&h.length===0&&(h.endEmitted=!0,m.readable=!1,m.emit("end"),h.autoDestroy)){var A=m._writableState;(!A||A.autoDestroy&&A.finished)&&m.destroy()}}function x(h,m){for(var A=0,C=h.length;A<C;A++)if(h[A]===m)return A;return-1}return D.prototype.read=function(h){s("read",h),h=parseInt(h,10);var m=this._readableState,A=h;if(h!==0&&(m.emittedReadable=!1),h===0&&m.needReadable&&((m.highWaterMark!==0?m.length>=m.highWaterMark:m.length>0)||m.ended))return s("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?I(this):B(this),null;if((h=U(h,m))===0&&m.ended)return m.length===0&&I(this),null;var C,$=m.needReadable;return s("need readable",$),(m.length===0||m.length-h<m.highWaterMark)&&s("length less than watermark",$=!0),m.ended||m.reading?s("reading or ended",$=!1):$&&(s("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,m.reading||(h=U(A,m))),(C=h>0?_(h,m):null)===null?(m.needReadable=m.length<=m.highWaterMark,h=0):(m.length-=h,m.awaitDrain=0),m.length===0&&(m.ended||(m.needReadable=!0),A!==h&&m.ended&&I(this)),C!==null&&this.emit("data",C),C},D.prototype._read=function(h){M(this,new b("_read()"))},D.prototype.pipe=function(h,m){var A=this,C=this._readableState;switch(C.pipesCount){case 0:C.pipes=h;break;case 1:C.pipes=[C.pipes,h];break;default:C.pipes.push(h)}C.pipesCount+=1,s("pipe count=%d opts=%j",C.pipesCount,m);var $=(!m||m.end!==!1)&&h!==Wt.stdout&&h!==Wt.stderr?Z:Ue;function j(Be,Oe){s("onunpipe"),Be===A&&Oe&&Oe.hasUnpiped===!1&&(Oe.hasUnpiped=!0,s("cleanup"),h.removeListener("close",Ae),h.removeListener("finish",Ce),h.removeListener("drain",ne),h.removeListener("error",de),h.removeListener("unpipe",j),A.removeListener("end",Z),A.removeListener("end",Ue),A.removeListener("data",ue),se=!0,!C.awaitDrain||h._writableState&&!h._writableState.needDrain||ne())}function Z(){s("onend"),h.end()}C.endEmitted?Wt.nextTick($):A.once("end",$),h.on("unpipe",j);var ne=(function(Be){return function(){var Oe=Be._readableState;s("pipeOnDrain",Oe.awaitDrain),Oe.awaitDrain&&Oe.awaitDrain--,Oe.awaitDrain===0&&e(Be,"data")&&(Oe.flowing=!0,P(Be))}})(A);h.on("drain",ne);var se=!1;function ue(Be){s("ondata");var Oe=h.write(Be);s("dest.write",Oe),Oe===!1&&((C.pipesCount===1&&C.pipes===h||C.pipesCount>1&&x(C.pipes,h)!==-1)&&!se&&(s("false write response, pause",C.awaitDrain),C.awaitDrain++),A.pause())}function de(Be){s("onerror",Be),Ue(),h.removeListener("error",de),e(h,"error")===0&&M(h,Be)}function Ae(){h.removeListener("finish",Ce),Ue()}function Ce(){s("onfinish"),h.removeListener("close",Ae),Ue()}function Ue(){s("unpipe"),A.unpipe(h)}return A.on("data",ue),(function(Be,Oe,Le){if(typeof Be.prependListener=="function")return Be.prependListener(Oe,Le);Be._events&&Be._events[Oe]?Array.isArray(Be._events[Oe])?Be._events[Oe].unshift(Le):Be._events[Oe]=[Le,Be._events[Oe]]:Be.on(Oe,Le)})(h,"error",de),h.once("close",Ae),h.once("finish",Ce),h.emit("pipe",A),C.flowing||(s("pipe resume"),A.resume()),h},D.prototype.unpipe=function(h){var m=this._readableState,A={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return h&&h!==m.pipes||(h||(h=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,h&&h.emit("unpipe",this,A)),this;if(!h){var C=m.pipes,$=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var j=0;j<$;j++)C[j].emit("unpipe",this,{hasUnpiped:!1});return this}var Z=x(m.pipes,h);return Z===-1||(m.pipes.splice(Z,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),h.emit("unpipe",this,A)),this},D.prototype.on=function(h,m){var A=n.prototype.on.call(this,h,m),C=this._readableState;return h==="data"?(C.readableListening=this.listenerCount("readable")>0,C.flowing!==!1&&this.resume()):h==="readable"&&(C.endEmitted||C.readableListening||(C.readableListening=C.needReadable=!0,C.flowing=!1,C.emittedReadable=!1,s("on readable",C.length,C.reading),C.length?B(this):C.reading||Wt.nextTick(y,this))),A},D.prototype.addListener=D.prototype.on,D.prototype.removeListener=function(h,m){var A=n.prototype.removeListener.call(this,h,m);return h==="readable"&&Wt.nextTick(p,this),A},D.prototype.removeAllListeners=function(h){var m=n.prototype.removeAllListeners.apply(this,arguments);return h!=="readable"&&h!==void 0||Wt.nextTick(p,this),m},D.prototype.resume=function(){var h=this._readableState;return h.flowing||(s("resume"),h.flowing=!h.readableListening,(function(m,A){A.resumeScheduled||(A.resumeScheduled=!0,Wt.nextTick(R,m,A))})(this,h)),h.paused=!1,this},D.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},D.prototype.wrap=function(h){var m=this,A=this._readableState,C=!1;for(var $ in h.on("end",(function(){if(s("wrapped end"),A.decoder&&!A.ended){var Z=A.decoder.end();Z&&Z.length&&m.push(Z)}m.push(null)})),h.on("data",(function(Z){s("wrapped data"),A.decoder&&(Z=A.decoder.write(Z)),A.objectMode&&Z==null||(A.objectMode||Z&&Z.length)&&(m.push(Z)||(C=!0,h.pause()))})),h)this[$]===void 0&&typeof h[$]=="function"&&(this[$]=(function(Z){return function(){return h[Z].apply(h,arguments)}})($));for(var j=0;j<S.length;j++)h.on(S[j],this.emit.bind(this,S[j]));return this._read=function(Z){s("wrapped _read",Z),C&&(C=!1,h.resume())},this},typeof Symbol=="function"&&(D.prototype[Symbol.asyncIterator]=function(){return c===void 0&&(c=r8()),c(this)}),Object.defineProperty(D.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(D.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(D.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(h){this._readableState&&(this._readableState.flowing=h)}}),D._fromList=_,Object.defineProperty(D.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(D.from=function(h,m){return l===void 0&&(l=q1?z1:(q1=1,z1=function(){throw new Error("Readable.from is not available in the browser")})),l(D,h,m)}),gp}var _A=ds,Vf=ia.codes,i8=Vf.ERR_METHOD_NOT_IMPLEMENTED,s8=Vf.ERR_MULTIPLE_CALLBACK,o8=Vf.ERR_TRANSFORM_ALREADY_TRANSFORMING,a8=Vf.ERR_TRANSFORM_WITH_LENGTH_0,wd=tc();function c8(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit("error",new s8);n.writechunk=null,n.writecb=null,e!=null&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function ds(t){if(!(this instanceof ds))return new ds(t);wd.call(this,t),this._transformState={afterTransform:c8.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",l8)}function l8(){var t=this;typeof this._flush!="function"||this._readableState.destroyed?G1(this,null,null):this._flush((function(e,n){G1(t,e,n)}))}function G1(t,e,n){if(e)return t.emit("error",e);if(n!=null&&t.push(n),t._writableState.length)throw new a8;if(t._transformState.transforming)throw new o8;return t.push(null)}Hl(ds,wd),ds.prototype.push=function(t,e){return this._transformState.needTransform=!1,wd.prototype.push.call(this,t,e)},ds.prototype._transform=function(t,e,n){n(new i8("_transform()"))},ds.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},ds.prototype._read=function(t){var e=this._transformState;e.writechunk===null||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},ds.prototype._destroy=function(t,e){wd.prototype._destroy.call(this,t,(function(n){e(n)}))};var yp,u8=Rl,SA=_A;function Rl(t){if(!(this instanceof Rl))return new Rl(t);SA.call(this,t)}Hl(Rl,SA),Rl.prototype._transform=function(t,e,n){n(null,t)};var xA=ia.codes,d8=xA.ERR_MISSING_ARGS,f8=xA.ERR_STREAM_DESTROYED;function Y1(t){if(t)throw t}function J1(t){t()}function h8(t,e){return t.pipe(e)}var p8=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r,i=(function(o){return o.length?typeof o[o.length-1]!="function"?Y1:o.pop():Y1})(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new d8("streams");var s=e.map((function(o,a){var c=a<e.length-1;return(function(l,u,d,f){f=(function(w){var b=!1;return function(){b||(b=!0,w.apply(void 0,arguments))}})(f);var g=!1;l.on("close",(function(){g=!0})),yp===void 0&&(yp=zg),yp(l,{readable:u,writable:d},(function(w){if(w)return f(w);g=!0,f()}));var v=!1;return function(w){if(!g&&!v)return v=!0,(function(b){return b.setHeader&&typeof b.abort=="function"})(l)?l.abort():typeof l.destroy=="function"?l.destroy():void f(w||new f8("pipe"))}})(o,c,a>0,(function(l){r||(r=l),l&&s.forEach(J1),c||(s.forEach(J1),i(r))}))}));return e.reduce(h8)};(function(t,e){(e=em.exports=bA()).Stream=e,e.Readable=e,e.Writable=EA(),e.Duplex=tc(),e.Transform=_A,e.PassThrough=u8,e.finished=zg,e.pipeline=p8})(0,em.exports);var nc=em.exports;function m8(t={}){const e={},n=new nc.Duplex({objectMode:!0,read:()=>{},write:function(s,o,a){let c=null;try{s.id?(function(l){const{id:u}=l;if(u===null)return;const d=e[u];if(!d)return void console.warn(`StreamMiddleware - Unknown response id "${u}"`);delete e[u],Object.assign(d.res,l),setTimeout(d.end)})(s):(function(l){t?.retryOnMessage&&l.method===t.retryOnMessage&&Object.values(e).forEach((({req:u,retryCount:d=0})=>{if(!u.id)return;if(d>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${u.id}"`);const f=e[u.id];f&&(f.retryCount=d+1),i(u)})),r.emit("notification",l)})(s)}catch(l){c=l}a(c)}}),r=new Q2;return{events:r,middleware:(s,o,a,c)=>{e[s.id]={req:s,res:o,next:a,end:c},i(s)},stream:n};function i(s){n.push(s)}}var Qd={},nm={exports:{}},g8=function t(e,n){if(e&&n)return t(e)(n);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(i){r[i]=e[i]})),r;function r(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];var o=e.apply(this,i),a=i[i.length-1];return typeof o=="function"&&o!==a&&Object.keys(a).forEach((function(c){o[c]=a[c]})),o}},Z1=g8;function ku(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function X1(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},n=t.name||"Function wrapped with `once`";return e.onceError=n+" shouldn't be called more than once",e.called=!1,e}nm.exports=Z1(ku),nm.exports.strict=Z1(X1),ku.proto=ku((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return ku(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return X1(this)},configurable:!0})}));var y8=nm.exports,ef={};Object.defineProperty(ef,"__esModule",{value:!0}),ef.Substream=void 0;const w8=nc;class v8 extends w8.Duplex{constructor({parent:e,name:n}){super({objectMode:!0}),this._parent=e,this._name=n}_read(){}_write(e,n,r){this._parent.push({name:this._name,data:e}),r()}}ef.Substream=v8;var E8=fi&&fi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Qd,"__esModule",{value:!0}),Qd.ObjectMultiplex=void 0;const wp=nc,b8=E8(y8),_8=ef,Q1=Symbol("IGNORE_SUBSTREAM");let S8=class extends wp.Duplex{constructor(t={}){super(Object.assign(Object.assign({},t),{objectMode:!0})),this._substreams={}}createStream(t){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${t}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${t}" already ended`);if(!t)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[t])throw new Error(`ObjectMultiplex - Substream for name "${t}" already exists`);const e=new _8.Substream({parent:this,name:t});return this._substreams[t]=e,(function(n,r){const i=(0,b8.default)(r);(0,wp.finished)(n,{readable:!1},i),(0,wp.finished)(n,{writable:!1},i)})(this,(n=>e.destroy(n||void 0))),e}ignoreStream(t){if(!t)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[t])throw new Error(`ObjectMultiplex - Substream for name "${t}" already exists`);this._substreams[t]=Q1}_read(){}_write(t,e,n){const{name:r,data:i}=t;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${t}"`),n();const s=this._substreams[r];return s?(s!==Q1&&s.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};Qd.ObjectMultiplex=S8;var x8=Bf(Qd.ObjectMultiplex);const Di=t=>t!==null&&typeof t=="object"&&typeof t.pipe=="function";Di.writable=t=>Di(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object",Di.readable=t=>Di(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object",Di.duplex=t=>Di.writable(t)&&Di.readable(t),Di.transform=t=>Di.duplex(t)&&typeof t._transform=="function";var Li,A8=Di,R8=class extends KM{constructor(t,{jsonRpcStreamName:e,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!A8.duplex(t))throw new Error(In.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const s=new x8;nc.pipeline(t,s,t,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=m8({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),nc.pipeline(this._jsonRpcConnection.stream,s.createStream(e),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",(o=>{const{method:a,params:c}=o;a==="metamask_accountsChanged"?this._handleAccountsChanged(c):a==="metamask_unlockStateChanged"?this._handleUnlockStateChanged(c):a==="metamask_chainChanged"?this._handleChainChanged(c):eA.includes(a)?this.emit("message",{type:a,data:c}):a==="METAMASK_STREAM_FAILURE"&&t.destroy(new Error(In.errors.permanentlyDisconnected()))}))}async _initializeStateAsync(){let t;try{t=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(t)}_handleStreamDisconnect(t,e){let n=`MetaMask: Lost connection to "${t}".`;e?.stack&&(n+=`
|
|
41
|
+
${e.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,e?e.message:void 0)}_handleChainChanged({chainId:t,networkVersion:e}={}){tA(t)&&(n=>!!n&&typeof n=="string")(e)?e==="loading"?this._handleDisconnect(!0):super._handleChainChanged({chainId:t}):this._log.error(In.errors.invalidNetworkParams(),{chainId:t,networkVersion:e})}},I8=class extends R8{constructor(t,{jsonRpcStreamName:e="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(t,{jsonRpcStreamName:e,logger:n,maxEventListeners:r,rpcMiddleware:MM(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},Q0(this,Li,void 0),this._initializeStateAsync(),us(this,Li,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",(s=>{const{method:o}=s;eA.includes(o)&&(this.emit("data",s),this.emit("notification",s.params.result))})),i)if(document.readyState==="complete")D1(this._rpcEngine,this._log);else{const s=()=>{D1(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",s)};window.addEventListener("DOMContentLoaded",s)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(In.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(In.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),Fi(this,Li)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(In.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(t,e){this._rpcRequest(t,e)}addListener(t,e){return this._warnOfDeprecation(t),super.addListener(t,e)}on(t,e){return this._warnOfDeprecation(t),super.on(t,e)}once(t,e){return this._warnOfDeprecation(t),super.once(t,e)}prependListener(t,e){return this._warnOfDeprecation(t),super.prependListener(t,e)}prependOnceListener(t,e){return this._warnOfDeprecation(t),super.prependOnceListener(t,e)}_handleDisconnect(t,e){super._handleDisconnect(t,e),Fi(this,Li)&&!t&&us(this,Li,null)}_warnOfDeprecation(t){this._sentWarnings?.events[t]===!1&&(this._log.warn(In.warnings.events[t]),this._sentWarnings.events[t]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(In.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((t,e)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},md(t,e))}catch(n){e(n)}}))}send(t,e){return this._sentWarnings.send||(this._log.warn(In.warnings.sendDeprecation),this._sentWarnings.send=!0),typeof t!="string"||e&&!Array.isArray(e)?t&&typeof t=="object"&&typeof e=="function"?this._rpcRequest(t,e):this._sendSync(t):new Promise(((n,r)=>{try{this._rpcRequest({method:t,params:e},md(n,r,!1))}catch(i){r(i)}}))}_sendSync(t){let e;switch(t.method){case"eth_accounts":e=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":e=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(t,nA),e=!0;break;case"net_version":e=Fi(this,Li)??null;break;default:throw new Error(In.errors.unsupportedSync(t.method))}return{id:t.id,jsonrpc:t.jsonrpc,result:e}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise((t=>{this.on("_initialized",(()=>t()))})),this._state.isUnlocked),requestBatch:async t=>{if(!Array.isArray(t))throw il({message:"Batch requests must be made with an array of request objects.",data:t});return new Promise(((e,n)=>{this._rpcRequest(t,md(e,n))}))}},{get:(t,e,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(In.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(t,e,...n))})}_handleChainChanged({chainId:t,networkVersion:e}={}){super._handleChainChanged({chainId:t,networkVersion:e}),this._state.isConnected&&e!==Fi(this,Li)&&(us(this,Li,e),this._state.initialized&&this.emit("networkChanged",Fi(this,Li)))}};Li=new WeakMap;const ve=Ir("MM_SDK");let eE;ve.color="#FFAC1C";var AA={},co={};Object.defineProperty(co,"__esModule",{value:!0}),co.EthereumProviderError=co.EthereumRpcError=void 0;const T8=W2;class RA extends Error{constructor(e,n,r){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string.');super(n),this.code=e,r!==void 0&&(this.data=r)}serialize(){const e={code:this.code,message:this.message};return this.data!==void 0&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return T8.default(this.serialize(),C8,2)}}co.EthereumRpcError=RA;function C8(t,e){if(e!=="[Circular]")return e}co.EthereumProviderError=class extends RA{constructor(t,e,n){if(!(function(r){return Number.isInteger(r)&&r>=1e3&&r<=4999})(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}};var qg={},eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.errorValues=eo.errorCodes=void 0,eo.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},eo.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=eo,n=co,r=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:r,message:o(r)};function o(d,f=i){if(Number.isInteger(d)){const g=d.toString();if(u(e.errorValues,g))return e.errorValues[g].message;if(c(d))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return f}function a(d){if(!Number.isInteger(d))return!1;const f=d.toString();return!!e.errorValues[f]||!!c(d)}function c(d){return d>=-32099&&d<=-32e3}function l(d){return d&&typeof d=="object"&&!Array.isArray(d)?Object.assign({},d):d}function u(d,f){return Object.prototype.hasOwnProperty.call(d,f)}t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",t.getMessageFromCode=o,t.isValidCode=a,t.serializeError=function(d,{fallbackError:f=s,shouldIncludeStack:g=!1}={}){var v,w;if(!f||!Number.isInteger(f.code)||typeof f.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(d instanceof n.EthereumRpcError)return d.serialize();const b={};if(d&&typeof d=="object"&&!Array.isArray(d)&&u(d,"code")&&a(d.code)){const M=d;b.code=M.code,M.message&&typeof M.message=="string"?(b.message=M.message,u(M,"data")&&(b.data=M.data)):(b.message=o(b.code),b.data={originalError:l(d)})}else{b.code=f.code;const M=(v=d)===null||v===void 0?void 0:v.message;b.message=M&&typeof M=="string"?M:f.message,b.data={originalError:l(d)}}const E=(w=d)===null||w===void 0?void 0:w.stack;return g&&d&&E&&typeof E=="string"&&(b.stack=E),b}})(qg);var tf={};Object.defineProperty(tf,"__esModule",{value:!0}),tf.ethErrors=void 0;const Wg=co,IA=qg,lr=eo;function ti(t,e){const[n,r]=TA(e);return new Wg.EthereumRpcError(t,n||IA.getMessageFromCode(t),r)}function $c(t,e){const[n,r]=TA(e);return new Wg.EthereumProviderError(t,n||IA.getMessageFromCode(t),r)}function TA(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}tf.ethErrors={rpc:{parse:t=>ti(lr.errorCodes.rpc.parse,t),invalidRequest:t=>ti(lr.errorCodes.rpc.invalidRequest,t),invalidParams:t=>ti(lr.errorCodes.rpc.invalidParams,t),methodNotFound:t=>ti(lr.errorCodes.rpc.methodNotFound,t),internal:t=>ti(lr.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return ti(e,t)},invalidInput:t=>ti(lr.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>ti(lr.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>ti(lr.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>ti(lr.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>ti(lr.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>ti(lr.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>$c(lr.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>$c(lr.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>$c(lr.errorCodes.provider.unsupportedMethod,t),disconnected:t=>$c(lr.errorCodes.provider.disconnected,t),chainDisconnected:t=>$c(lr.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new Wg.EthereumProviderError(e,n,r)}}},(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=co;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const n=qg;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=tf;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=eo;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})})(AA);var CA={exports:{}};CA.exports=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(r,i,s){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:s})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var o in r)n.d(s,o,(function(a){return r[a]}).bind(null,o));return s},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=90)})({17:function(t,e,n){e.__esModule=!0,e.default=void 0;var r=n(18),i=(function(){function s(){}return s.getFirstMatch=function(o,a){var c=a.match(o);return c&&c.length>0&&c[1]||""},s.getSecondMatch=function(o,a){var c=a.match(o);return c&&c.length>1&&c[2]||""},s.matchAndReturnConst=function(o,a,c){if(o.test(a))return c},s.getWindowsVersionName=function(o){switch(o){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},s.getMacOSVersionName=function(o){var a=o.split(".").splice(0,2).map((function(c){return parseInt(c,10)||0}));if(a.push(0),a[0]===10)switch(a[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},s.getAndroidVersionName=function(o){var a=o.split(".").splice(0,2).map((function(c){return parseInt(c,10)||0}));if(a.push(0),!(a[0]===1&&a[1]<5))return a[0]===1&&a[1]<6?"Cupcake":a[0]===1&&a[1]>=6?"Donut":a[0]===2&&a[1]<2?"Eclair":a[0]===2&&a[1]===2?"Froyo":a[0]===2&&a[1]>2?"Gingerbread":a[0]===3?"Honeycomb":a[0]===4&&a[1]<1?"Ice Cream Sandwich":a[0]===4&&a[1]<4?"Jelly Bean":a[0]===4&&a[1]>=4?"KitKat":a[0]===5?"Lollipop":a[0]===6?"Marshmallow":a[0]===7?"Nougat":a[0]===8?"Oreo":a[0]===9?"Pie":void 0},s.getVersionPrecision=function(o){return o.split(".").length},s.compareVersions=function(o,a,c){c===void 0&&(c=!1);var l=s.getVersionPrecision(o),u=s.getVersionPrecision(a),d=Math.max(l,u),f=0,g=s.map([o,a],(function(v){var w=d-s.getVersionPrecision(v),b=v+new Array(w+1).join(".0");return s.map(b.split("."),(function(E){return new Array(20-E.length).join("0")+E})).reverse()}));for(c&&(f=d-Math.min(l,u)),d-=1;d>=f;){if(g[0][d]>g[1][d])return 1;if(g[0][d]===g[1][d]){if(d===f)return 0;d-=1}else if(g[0][d]<g[1][d])return-1}},s.map=function(o,a){var c,l=[];if(Array.prototype.map)return Array.prototype.map.call(o,a);for(c=0;c<o.length;c+=1)l.push(a(o[c]));return l},s.find=function(o,a){var c,l;if(Array.prototype.find)return Array.prototype.find.call(o,a);for(c=0,l=o.length;c<l;c+=1){var u=o[c];if(a(u,c))return u}},s.assign=function(o){for(var a,c,l=o,u=arguments.length,d=new Array(u>1?u-1:0),f=1;f<u;f++)d[f-1]=arguments[f];if(Object.assign)return Object.assign.apply(Object,[o].concat(d));var g=function(){var v=d[a];typeof v=="object"&&v!==null&&Object.keys(v).forEach((function(w){l[w]=v[w]}))};for(a=0,c=d.length;a<c;a+=1)g();return o},s.getBrowserAlias=function(o){return r.BROWSER_ALIASES_MAP[o]},s.getBrowserTypeByAlias=function(o){return r.BROWSER_MAP[o]||""},s})();e.default=i,t.exports=e.default},18:function(t,e,n){e.__esModule=!0,e.ENGINE_MAP=e.OS_MAP=e.PLATFORMS_MAP=e.BROWSER_MAP=e.BROWSER_ALIASES_MAP=void 0,e.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},e.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},e.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},e.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},e.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},s=n(18);function o(c,l){for(var u=0;u<l.length;u++){var d=l[u];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(c,d.key,d)}}var a=(function(){function c(){}var l,u,d;return c.getParser=function(f,g){if(g===void 0&&(g=!1),typeof f!="string")throw new Error("UserAgent should be a string");return new i.default(f,g)},c.parse=function(f){return new i.default(f).getResult()},l=c,d=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(u=null)&&o(l.prototype,u),d&&o(l,d),c})();e.default=a,t.exports=e.default},91:function(t,e,n){e.__esModule=!0,e.default=void 0;var r=c(n(92)),i=c(n(93)),s=c(n(94)),o=c(n(95)),a=c(n(17));function c(u){return u&&u.__esModule?u:{default:u}}var l=(function(){function u(f,g){if(g===void 0&&(g=!1),f==null||f==="")throw new Error("UserAgent parameter can't be empty");this._ua=f,this.parsedResult={},g!==!0&&this.parse()}var d=u.prototype;return d.getUA=function(){return this._ua},d.test=function(f){return f.test(this._ua)},d.parseBrowser=function(){var f=this;this.parsedResult.browser={};var g=a.default.find(r.default,(function(v){if(typeof v.test=="function")return v.test(f);if(v.test instanceof Array)return v.test.some((function(w){return f.test(w)}));throw new Error("Browser's test function is not valid")}));return g&&(this.parsedResult.browser=g.describe(this.getUA())),this.parsedResult.browser},d.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},d.getBrowserName=function(f){return f?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},d.getBrowserVersion=function(){return this.getBrowser().version},d.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},d.parseOS=function(){var f=this;this.parsedResult.os={};var g=a.default.find(i.default,(function(v){if(typeof v.test=="function")return v.test(f);if(v.test instanceof Array)return v.test.some((function(w){return f.test(w)}));throw new Error("Browser's test function is not valid")}));return g&&(this.parsedResult.os=g.describe(this.getUA())),this.parsedResult.os},d.getOSName=function(f){var g=this.getOS().name;return f?String(g).toLowerCase()||"":g||""},d.getOSVersion=function(){return this.getOS().version},d.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},d.getPlatformType=function(f){f===void 0&&(f=!1);var g=this.getPlatform().type;return f?String(g).toLowerCase()||"":g||""},d.parsePlatform=function(){var f=this;this.parsedResult.platform={};var g=a.default.find(s.default,(function(v){if(typeof v.test=="function")return v.test(f);if(v.test instanceof Array)return v.test.some((function(w){return f.test(w)}));throw new Error("Browser's test function is not valid")}));return g&&(this.parsedResult.platform=g.describe(this.getUA())),this.parsedResult.platform},d.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},d.getEngineName=function(f){return f?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},d.parseEngine=function(){var f=this;this.parsedResult.engine={};var g=a.default.find(o.default,(function(v){if(typeof v.test=="function")return v.test(f);if(v.test instanceof Array)return v.test.some((function(w){return f.test(w)}));throw new Error("Browser's test function is not valid")}));return g&&(this.parsedResult.engine=g.describe(this.getUA())),this.parsedResult.engine},d.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},d.getResult=function(){return a.default.assign({},this.parsedResult)},d.satisfies=function(f){var g=this,v={},w=0,b={},E=0;if(Object.keys(f).forEach((function(U){var B=f[U];typeof B=="string"?(b[U]=B,E+=1):typeof B=="object"&&(v[U]=B,w+=1)})),w>0){var M=Object.keys(v),S=a.default.find(M,(function(U){return g.isOS(U)}));if(S){var F=this.satisfies(v[S]);if(F!==void 0)return F}var D=a.default.find(M,(function(U){return g.isPlatform(U)}));if(D){var z=this.satisfies(v[D]);if(z!==void 0)return z}}if(E>0){var X=Object.keys(b),Y=a.default.find(X,(function(U){return g.isBrowser(U,!0)}));if(Y!==void 0)return this.compareVersion(b[Y])}},d.isBrowser=function(f,g){g===void 0&&(g=!1);var v=this.getBrowserName().toLowerCase(),w=f.toLowerCase(),b=a.default.getBrowserTypeByAlias(w);return g&&b&&(w=b.toLowerCase()),w===v},d.compareVersion=function(f){var g=[0],v=f,w=!1,b=this.getBrowserVersion();if(typeof b=="string")return f[0]===">"||f[0]==="<"?(v=f.substr(1),f[1]==="="?(w=!0,v=f.substr(2)):g=[],f[0]===">"?g.push(1):g.push(-1)):f[0]==="="?v=f.substr(1):f[0]==="~"&&(w=!0,v=f.substr(1)),g.indexOf(a.default.compareVersions(b,v,w))>-1},d.isOS=function(f){return this.getOSName(!0)===String(f).toLowerCase()},d.isPlatform=function(f){return this.getPlatformType(!0)===String(f).toLowerCase()},d.isEngine=function(f){return this.getEngineName(!0)===String(f).toLowerCase()},d.is=function(f,g){return g===void 0&&(g=!1),this.isBrowser(f,g)||this.isOS(f)||this.isPlatform(f)},d.some=function(f){var g=this;return f===void 0&&(f=[]),f.some((function(v){return g.is(v)}))},u})();e.default=l,t.exports=e.default},92:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(a){var c={name:"Googlebot"},l=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/opera/i],describe:function(a){var c={name:"Opera"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/opr\/|opios/i],describe:function(a){var c={name:"Opera"},l=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/SamsungBrowser/i],describe:function(a){var c={name:"Samsung Internet for Android"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/Whale/i],describe:function(a){var c={name:"NAVER Whale Browser"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/MZBrowser/i],describe:function(a){var c={name:"MZ Browser"},l=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/focus/i],describe:function(a){var c={name:"Focus"},l=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/swing/i],describe:function(a){var c={name:"Swing"},l=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/coast/i],describe:function(a){var c={name:"Opera Coast"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(a){var c={name:"Opera Touch"},l=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/yabrowser/i],describe:function(a){var c={name:"Yandex Browser"},l=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/ucbrowser/i],describe:function(a){var c={name:"UC Browser"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/Maxthon|mxios/i],describe:function(a){var c={name:"Maxthon"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/epiphany/i],describe:function(a){var c={name:"Epiphany"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/puffin/i],describe:function(a){var c={name:"Puffin"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/sleipnir/i],describe:function(a){var c={name:"Sleipnir"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/k-meleon/i],describe:function(a){var c={name:"K-Meleon"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/micromessenger/i],describe:function(a){var c={name:"WeChat"},l=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/qqbrowser/i],describe:function(a){var c={name:/qqbrowserlite/i.test(a)?"QQ Browser Lite":"QQ Browser"},l=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/msie|trident/i],describe:function(a){var c={name:"Internet Explorer"},l=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/\sedg\//i],describe:function(a){var c={name:"Microsoft Edge"},l=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/edg([ea]|ios)/i],describe:function(a){var c={name:"Microsoft Edge"},l=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/vivaldi/i],describe:function(a){var c={name:"Vivaldi"},l=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/seamonkey/i],describe:function(a){var c={name:"SeaMonkey"},l=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/sailfish/i],describe:function(a){var c={name:"Sailfish"},l=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,a);return l&&(c.version=l),c}},{test:[/silk/i],describe:function(a){var c={name:"Amazon Silk"},l=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/phantom/i],describe:function(a){var c={name:"PhantomJS"},l=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/slimerjs/i],describe:function(a){var c={name:"SlimerJS"},l=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(a){var c={name:"BlackBerry"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/(web|hpw)[o0]s/i],describe:function(a){var c={name:"WebOS Browser"},l=i.default.getFirstMatch(s,a)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/bada/i],describe:function(a){var c={name:"Bada"},l=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/tizen/i],describe:function(a){var c={name:"Tizen"},l=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/qupzilla/i],describe:function(a){var c={name:"QupZilla"},l=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/firefox|iceweasel|fxios/i],describe:function(a){var c={name:"Firefox"},l=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/electron/i],describe:function(a){var c={name:"Electron"},l=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/MiuiBrowser/i],describe:function(a){var c={name:"Miui"},l=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/chromium/i],describe:function(a){var c={name:"Chromium"},l=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,a)||i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/chrome|crios|crmo/i],describe:function(a){var c={name:"Chrome"},l=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/GSA/i],describe:function(a){var c={name:"Google Search"},l=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:function(a){var c=!a.test(/like android/i),l=a.test(/android/i);return c&&l},describe:function(a){var c={name:"Android Browser"},l=i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/playstation 4/i],describe:function(a){var c={name:"PlayStation 4"},l=i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/safari|applewebkit/i],describe:function(a){var c={name:"Safari"},l=i.default.getFirstMatch(s,a);return l&&(c.version=l),c}},{test:[/.*/i],describe:function(a){var c=a.search("\\(")!==-1?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(c,a),version:i.default.getSecondMatch(c,a)}}}];e.default=o,t.exports=e.default},93:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:[/Roku\/DVP/],describe:function(a){var c=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,a);return{name:s.OS_MAP.Roku,version:c}}},{test:[/windows phone/i],describe:function(a){var c=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,a);return{name:s.OS_MAP.WindowsPhone,version:c}}},{test:[/windows /i],describe:function(a){var c=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,a),l=i.default.getWindowsVersionName(c);return{name:s.OS_MAP.Windows,version:c,versionName:l}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(a){var c={name:s.OS_MAP.iOS},l=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,a);return l&&(c.version=l),c}},{test:[/macintosh/i],describe:function(a){var c=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,a).replace(/[_\s]/g,"."),l=i.default.getMacOSVersionName(c),u={name:s.OS_MAP.MacOS,version:c};return l&&(u.versionName=l),u}},{test:[/(ipod|iphone|ipad)/i],describe:function(a){var c=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,a).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:c}}},{test:function(a){var c=!a.test(/like android/i),l=a.test(/android/i);return c&&l},describe:function(a){var c=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,a),l=i.default.getAndroidVersionName(c),u={name:s.OS_MAP.Android,version:c};return l&&(u.versionName=l),u}},{test:[/(web|hpw)[o0]s/i],describe:function(a){var c=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,a),l={name:s.OS_MAP.WebOS};return c&&c.length&&(l.version=c),l}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(a){var c=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,a)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,a)||i.default.getFirstMatch(/\bbb(\d+)/i,a);return{name:s.OS_MAP.BlackBerry,version:c}}},{test:[/bada/i],describe:function(a){var c=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,a);return{name:s.OS_MAP.Bada,version:c}}},{test:[/tizen/i],describe:function(a){var c=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,a);return{name:s.OS_MAP.Tizen,version:c}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(a){var c=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,a);return{name:s.OS_MAP.PlayStation4,version:c}}}];e.default=o,t.exports=e.default},94:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(a){var c=i.default.getFirstMatch(/(can-l01)/i,a)&&"Nova",l={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return c&&(l.model=c),l}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(a){var c=a.test(/ipod|iphone/i),l=a.test(/like (ipod|iphone)/i);return c&&!l},describe:function(a){var c=i.default.getFirstMatch(/(ipod|iphone)/i,a);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:c}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(a){return a.getBrowserName(!0)==="blackberry"},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(a){return a.getBrowserName(!0)==="bada"},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(a){return a.getBrowserName()==="windows phone"},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(a){var c=Number(String(a.getOSVersion()).split(".")[0]);return a.getOSName(!0)==="android"&&c>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(a){return a.getOSName(!0)==="android"},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(a){return a.getOSName(!0)==="macos"},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(a){return a.getOSName(!0)==="windows"},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(a){return a.getOSName(!0)==="linux"},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(a){return a.getOSName(!0)==="playstation 4"},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(a){return a.getOSName(!0)==="roku"},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];e.default=o,t.exports=e.default},95:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},s=n(18),o=[{test:function(a){return a.getBrowserName(!0)==="microsoft edge"},describe:function(a){if(/\sedg\//i.test(a))return{name:s.ENGINE_MAP.Blink};var c=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,a);return{name:s.ENGINE_MAP.EdgeHTML,version:c}}},{test:[/trident/i],describe:function(a){var c={name:s.ENGINE_MAP.Trident},l=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:function(a){return a.test(/presto/i)},describe:function(a){var c={name:s.ENGINE_MAP.Presto},l=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:function(a){var c=a.test(/gecko/i),l=a.test(/like gecko/i);return c&&!l},describe:function(a){var c={name:s.ENGINE_MAP.Gecko},l=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(a){var c={name:s.ENGINE_MAP.WebKit},l=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,a);return l&&(c.version=l),c}}];e.default=o,t.exports=e.default}});var OA=Bf(CA.exports);const Br={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class Ai{constructor({shouldSetOnWindow:e,connectionStream:n,shouldSendMetadata:r=!1,shouldShimWeb3:i,sdkInstance:s}){const o=new O8({connectionStream:n,shouldSendMetadata:r,shouldSetOnWindow:e,shouldShimWeb3:i,autoRequestAccounts:!1}),a=new Proxy(o,{deleteProperty:()=>!0});if(this.provider=a,this.sdkInstance=s,e&&typeof window<"u")try{c=o,window.ethereum=c,window.dispatchEvent(new Event("ethereum#initialized"))}catch(l){ve("[Ethereum] Unable to set global provider - window.ethereum may be read-only",l)}var c;if(i&&typeof window<"u")try{(function(l,u=console){let d=!1,f=!1;if(!window.web3){const g="__isMetaMaskShim__";let v={currentProvider:l};Object.defineProperty(v,g,{value:!0,enumerable:!0,configurable:!1,writable:!1}),v=new Proxy(v,{get:(w,b,...E)=>(b!=="currentProvider"||d?b==="currentProvider"||b===g||f||(f=!0,u.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),l.request({method:"metamask_logWeb3ShimUsage"}).catch((M=>{u.debug("MetaMask: Failed to log web3 shim usage.",M)}))):(d=!0,u.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(w,b,...E)),set:(...w)=>(u.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...w))}),Object.defineProperty(window,"web3",{value:v,enumerable:!1,configurable:!0,writable:!0})}})(this.provider)}catch(l){ve("[Ethereum] Unable to shim web3 - window.web3 may be read-only",l)}this.provider.on("display_uri",(l=>{this.sdkInstance.emit(Br.DisplayURI,l)})),this.provider.on("_initialized",(()=>{const l={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(Br.Initialized,l),ve("[Ethereum: constructor()] provider initialized",l)}))}static init(e){var n;return ve("[Ethereum: init()] Initializing Ethereum service"),this.instance=new Ai(e),(n=this.instance)===null||n===void 0?void 0:n.provider}static destroy(){}static getInstance(){var e;if(!(!((e=this.instance)===null||e===void 0)&&e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(!((e=this.instance)===null||e===void 0)&&e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class Il{constructor({useDeepLink:e,preferredOpenLink:n,debug:r=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=n,this.state.debug=r}openDeeplink(e,n,r){return(function(i,s,o,a){const{state:c}=i;ve(`[PlatfformManager: openDeeplink()] universalLink --> ${s}`),ve(`[PlatfformManager: openDeeplink()] deepLink --> ${o}`);try{if(c.preferredOpenLink)return void c.preferredOpenLink(c.useDeeplink?o:s,a);if(ve(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${c.useDeeplink} link=${c.useDeeplink?o:s}`),c.useDeeplink)typeof window<"u"&&(window.location.href=o);else if(typeof document<"u"){const l=document.createElement("a");l.href=s,l.target="_self",l.rel="noreferrer noopener",l.click()}}catch(l){console.log("[PlatfformManager: openDeeplink()] can't open link",l)}})(this,e,n,r)}isReactNative(){var e;return this.isNotBrowser()&&typeof window<"u"&&window?.navigator&&((e=window.navigator)===null||e===void 0?void 0:e.product)==="ReactNative"}isMetaMaskInstalled(){return(function(){const e=Ai.getProvider()||window?.ethereum;return ve(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${e?.isMetaMask} isConnected=${e?.isConnected()}`),e?.isMetaMask&&e?.isConnected()})()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,n;const r=OA.parse(window.navigator.userAgent);return((e=r?.platform)===null||e===void 0?void 0:e.type)==="mobile"||((n=r?.platform)===null||n===void 0?void 0:n.type)==="tablet"}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return typeof window<"u"&&!!window.ReactNativeWebView&&!!navigator.userAgent.endsWith("MetaMaskMobile")}isMobileWeb(){return this.state.platformType===gr.MobileWeb}static isNotBrowser(){var e;return typeof window>"u"||!window?.navigator||Tr!==void 0&&((e=Tr?.navigator)===null||e===void 0?void 0:e.product)==="ReactNative"||navigator?.product==="ReactNative"}isNotBrowser(){return Il.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return Il.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return(function(e){const{state:n}=e;return n.platformType?n.platformType:e.isReactNative()?gr.ReactNative:e.isNotBrowser()?gr.NonBrowser:e.isMetaMaskMobileWebView()?gr.MetaMaskMobileWebview:e.isMobile()?gr.MobileWeb:gr.DesktopWeb})(this)}}const NA=t=>_e(void 0,void 0,void 0,(function*(){if(Il.isBrowser()){const{StorageManagerWeb:n}=yield Promise.resolve().then((function(){return ok}));return new n(t)}const e={persistChannelConfig:()=>_e(void 0,void 0,void 0,(function*(){})),getPersistedChannelConfig:()=>_e(void 0,void 0,void 0,(function*(){})),persistAccounts:()=>_e(void 0,void 0,void 0,(function*(){})),getCachedAccounts:()=>_e(void 0,void 0,void 0,(function*(){return[]})),persistChainId:()=>_e(void 0,void 0,void 0,(function*(){})),getCachedChainId:()=>_e(void 0,void 0,void 0,(function*(){})),terminate:()=>_e(void 0,void 0,void 0,(function*(){}))};return Promise.resolve(e)}));class O8 extends I8{constructor({connectionStream:e,shouldSendMetadata:n,autoRequestAccounts:r=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:n}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},ve(`[SDKProvider: constructor()] autoRequestAccounts=${r}`),this.state.autoRequestAccounts=r}forceInitializeState(){return _e(this,void 0,void 0,(function*(){return ve(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){ve("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:n}=this._state;return n&&n.length!==0?((e=n[0])===null||e===void 0?void 0:e.toLowerCase())||"":(ve("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,n){return this._handleAccountsChanged(e,n)}handleDisconnect({terminate:e=!1}){(function({terminate:n=!1,instance:r}){const{state:i}=r;ve(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${n}`,r),n&&(r._state.accounts=null,r._state.isUnlocked=!1,r._state.isPermanentlyDisconnected=!0,r._state.initialized=!1),r._handleAccountsChanged([]),r._state.isConnected=!1,r.emit("disconnect",AA.ethErrors.provider.disconnected()),i.providerStateRequested=!1})({terminate:e,instance:this})}_initializeStateAsync(){return _e(this,void 0,void 0,(function*(){return(function(e){var n,r;return _e(this,void 0,void 0,(function*(){e.state===void 0&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:i}=e;let s;if(i.providerStateRequested)ve("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let o;i.providerStateRequested=!0;let a=null,c=!1,l=!1;const u=yield NA({enabled:!0});if(u){const d=yield u.getPersistedChannelConfig({});c=(n=d?.relayPersistence)!==null&&n!==void 0&&n,o=yield u.getCachedChainId();const f=yield u.getCachedAccounts();f.length>0&&(a=f[0])}if(ve(`[SDKProvider: initializeStateAsync()] relayPersistence=${c}`,{relayPersistence:c,cachedChainId:o,cachedSelectedAddress:a}),c)if(o&&a)s={accounts:[a],chainId:o,isUnlocked:!1},l=!0;else try{s=yield e.request({method:"metamask_getProviderState"})}catch(d){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",d),void(i.providerStateRequested=!1)}if(((r=s?.accounts)===null||r===void 0?void 0:r.length)===0)if(e.getSelectedAddress())s.accounts=[e.getSelectedAddress()];else{ve("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const d=yield e.request({method:"eth_requestAccounts",params:[]});s.accounts=d}e._initializeState(s),i.providerStateRequested=!1,l&&(e._state.isConnected=!0,e.emit("connect",{chainId:s?.chainId}))}}))})(this)}))}_initializeState(e){return ve("[SDKProvider: _initializeState()]",e),(function(n,r,i){return ve("[SDKProvider: initializeState()] set state._initialized to false"),n._state.initialized=!1,r(i)})(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:n}={}){this.state.chainId=e,this.state.networkVersion=n,(function({instance:r,chainId:i,networkVersion:s,superHandleChainChanged:o}){ve(`[SDKProvider: handleChainChanged()] chainId=${i} networkVersion=${s}`);let a=s;s||(ve("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),a="1"),i!==eE&&(On.analytics.track("sdk_used_chain",{caip_chain_id:`eip155:${parseInt(i??"0x1",16)}`}),eE=i),r._state.isConnected=!0,r.emit("connect",{chainId:i}),o({chainId:i,networkVersion:a})})({instance:this,chainId:e,networkVersion:n,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var Tl,sa={name:"@metamask/sdk",version:"0.34.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-analytics":"workspace:*","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};(function(t){t.INPAGE="metamask-inpage",t.CONTENT_SCRIPT="metamask-contentscript",t.PROVIDER="metamask-provider"})(Tl||(Tl={}));const Cl="https://metamask.app.link/connect",Ol="metamask://connect",tE={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},N8=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,ct={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},Nl={[ct.ETH_REQUESTACCOUNTS]:!0,[ct.ETH_SENDTRANSACTION]:!0,[ct.ETH_SIGNTRANSACTION]:!0,[ct.ETH_SIGN]:!0,[ct.PERSONAL_SIGN]:!0,[ct.ETH_ACCOUNTS]:!1,[ct.ETH_CHAINID]:!1,[ct.PERSONAL_SIGN]:!0,[ct.ETH_SIGNTYPEDDATA]:!0,[ct.ETH_SIGNTYPEDDATA_V3]:!0,[ct.ETH_SIGNTYPEDDATA_V4]:!0,[ct.WALLET_REQUESTPERMISSIONS]:!0,[ct.WALLET_GETPERMISSIONS]:!0,[ct.WALLET_WATCHASSET]:!0,[ct.WALLET_ADDETHEREUMCHAIN]:!0,[ct.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[ct.METAMASK_CONNECTSIGN]:!0,[ct.METAMASK_CONNECTWITH]:!0,[ct.PERSONAL_EC_RECOVER]:!0,[ct.METAMASK_BATCH]:!0,[ct.METAMASK_OPEN]:!0},P8=Object.keys(Nl).filter((t=>Nl[t]===!0)).map((t=>t.toLowerCase())),PA=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map((t=>t.toLowerCase())),vp=".sdk-comm",nf="providerType",rm=".MMSDK_cached_address",im=".MMSDK_cached_chainId",Oi={CHAIN_CHANGED:"chainChanged",ACCOUNTS_CHANGED:"accountsChanged",DISCONNECT:"disconnect",CONNECT:"connect",CONNECTED:"connected"},M8=1e6;var Gi;(function(t){t.TERMINATE="terminate",t.EXTENSION="extension",t.INITIALIZED="initialized"})(Gi||(Gi={}));const k8=typeof window<"u"&&window.localStorage;function D8({instance:t,msg:e}){return _e(this,void 0,void 0,(function*(){if(t._initialized||(ve("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield t.init()),ve(`[MetaMaskSDK: connectAndSign()] activeProvider=${t.activeProvider}`),!t.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(e)?e:(function(r){let i;if(Se!==void 0)i=Se.from(r,"utf8").toString("hex");else if(typeof TextEncoder<"u"){const s=new TextEncoder().encode(r);i=Array.from(s).map((o=>o.toString(16).padStart(2,"0"))).join("")}else{if(typeof Tr!="object"||!("Buffer"in Tr))throw new Error("Unable to convert string to hex: No available method.");i=Tr.Buffer.from(r,"utf8").toString("hex")}return`0x${i}`})(e);return t.activeProvider.request({method:ct.METAMASK_CONNECTWITH,params:[{method:ct.PERSONAL_SIGN,params:[n]}]})}))}function nE(t){var e,n;return _e(this,void 0,void 0,(function*(){ve("[MetaMaskSDK: connectWithExtensionProvider()] ",t),t.sdkProvider=t.activeProvider,t.activeProvider=window.extension,window.ethereum=window.extension;try{const r=yield(e=window.extension)===null||e===void 0?void 0:e.request({method:"eth_requestAccounts"});ve(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${r}`)}catch(r){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",r)}localStorage.setItem(nf,"extension"),t.extensionActive=!0,t.emit(Br.ProviderUpdate,Gi.EXTENSION),t.options.enableAnalytics&&((n=t.analytics)===null||n===void 0||n.send({event:Pn.SDK_USE_EXTENSION}))}))}function rf(t){let e;if(Se!==void 0)e=Se.from(t,"utf8").toString("base64");else if(typeof btoa=="function")e=btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/gu,((n,r)=>String.fromCharCode(parseInt(r,16)))));else{if(typeof Tr!="object"||!("Buffer"in Tr))throw new Error("Unable to base64 encode: No available method.");e=Tr.Buffer.from(t,"utf8").toString("base64")}return e}function L8(t,e,n,r){var i,s,o,a,c,l,u,d,f,g,v,w,b,E,M,S,F,D,z,X;return _e(this,void 0,void 0,(function*(){const Y=(i=t.state.remote)===null||i===void 0?void 0:i.isReady(),U=(s=t.state.remote)===null||s===void 0?void 0:s.isConnected(),B=(o=t.state.remote)===null||o===void 0?void 0:o.isPaused(),H=Ai.getProvider(),V=(a=t.state.remote)===null||a===void 0?void 0:a.getChannelId(),T=(c=t.state.remote)===null||c===void 0?void 0:c.isAuthorized(),{deeplinkProtocol:p}=t.state,{method:y,data:R,triggeredInstaller:P}=(x=>{var h,m,A,C;let $;Se.isBuffer(x)?($=x.toJSON(),$._isBuffer=!0):$=x;const j=(h=$?.data)===null||h===void 0?void 0:h.method;let Z=!1;return typeof((m=$?.data)===null||m===void 0?void 0:m.params)=="object"&&((C=(A=$?.data)===null||A===void 0?void 0:A.params)===null||C===void 0?void 0:C.__triggeredInstaller)===!0&&(Z=!0,$.data.params=$.data.params.wrappedParams),{method:j,data:$,triggeredInstaller:Z}})(e);if(ve(`[RCPMS: write()] method='${y}' isRemoteReady=${Y} channelId=${V} isSocketConnected=${U} isRemotePaused=${B} providerConnected=${H.isConnected()}`,e),!V)return y!==ct.METAMASK_GETPROVIDERSTATE&&ve(`[RCPMS: write()] ${y} --> channelId is undefined`),r(new Error("disconnected"));ve(`[RCPMS: write()] remote.isPaused()=${(l=t.state.remote)===null||l===void 0?void 0:l.isPaused()} authorized=${T} ready=${Y} socketConnected=${U}`,e);const _=(u=t.state.platformManager)===null||u===void 0?void 0:u.isSecure(),I=(f=(d=t.state.platformManager)===null||d===void 0?void 0:d.isMobileWeb())!==null&&f!==void 0&&f,N=(v=(g=t.state.remote)===null||g===void 0?void 0:g.hasDeeplinkProtocol())!==null&&v!==void 0&&v&&I&&T;try{if(!P){const m=JSON.stringify(R?.data);if(m.length>M8)return r(new Error(`Message size ${m.length} exceeds maximum allowed size of 1000000 bytes`));(w=t.state.remote)===null||w===void 0||w.sendMessage(R?.data).then((()=>{ve(`[RCPMS: _write()] ${y} sent successfully`)})).catch((A=>{ve("[RCPMS: _write()] error sending message",A)}))}if(!_)return ve(`[RCPMS: _write()] unsecure platform for method ${y} -- return callback`),r();if(P)return ve("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const x=(M=(E=(b=t.state.remote)===null||b===void 0?void 0:b.getKeyInfo())===null||E===void 0?void 0:E.ecies.public)!==null&&M!==void 0?M:"";let h=encodeURI(`channelId=${V}&pubkey=${x}&comm=socket&t=d&v=2&hr=${t.state.hideReturnToAppNotification?1:0}`);if(N){const m=JSON.stringify(R?.data),A=(S=t.state.remote)===null||S===void 0?void 0:S.encrypt(m);if(!A)return ve("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));h+=`&scheme=${p}&rpc=${rf(A)}`}if(!(!((F=t.state.platformManager)===null||F===void 0)&&F.isMetaMaskInstalled()))return ve("[RCPMS: _write()] prevent deeplink until installation is completed."),r();Nl[y]?(ve(`[RCPMS: _write()] redirect link for '${y}' socketConnected=${U} connect?${h}`),(D=t.state.platformManager)===null||D===void 0||D.openDeeplink(`${Cl}?${h}`,`${Ol}?${h}`,"_self")):!((z=t.state.remote)===null||z===void 0)&&z.isPaused()?(ve(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${y}`),(X=t.state.platformManager)===null||X===void 0||X.openDeeplink(`${Cl}?redirect=true&${h}`,`${Ol}?redirect=true&${h}`,"_self")):ve(`[RCPMS: _write()] method ${y} doesn't need redirect.`)}catch(x){return ve("[RCPMS: _write()] error sending message",x),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()}))}class B8 extends nc.Duplex{constructor({name:e,remote:n,deeplinkProtocol:r,hideReturnToAppNotification:i,platformManager:s}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,hideReturnToAppNotification:!1,platformManager:null},this.state._name=e,this.state.remote=n,this.state.deeplinkProtocol=r,this.state.hideReturnToAppNotification=i??this.state.hideReturnToAppNotification,this.state.platformManager=s,this._onMessage=this._onMessage.bind(this),this.state.remote.on(Ne.MESSAGE,this._onMessage)}_write(e,n,r){return _e(this,void 0,void 0,(function*(){return L8(this,e,0,r)}))}_read(){}_onMessage(e){return(function(n,r){try{if(ve("[RCPMS: onMessage()] message",r),!r||typeof r!="object"||typeof r?.data!="object")return;if(!r?.name)return void ve("[RCPMS: onMessage()] ignore message without name",r);if(r?.name!==Tl.PROVIDER)return void ve(`[RCPMS: onMessage()] ignore message with wrong name message=${r}`);if(Se.isBuffer(r)){const i=Se.from(r);n.push(i)}else n.push(r)}catch(i){ve(`[RCPMS: onMessage()] ignore message error err=${i}`)}})(this,e)}start(){}}let rE=1;const MA=t=>new Promise((e=>{setTimeout((()=>{e(!0)}),t)})),U8=({checkInstallationOnAllCalls:t=!1,communicationLayerPreference:e,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:s,sdk:o,remoteConnection:a,debug:c})=>_e(void 0,void 0,void 0,(function*(){var l,u;const d=(({name:B,remoteConnection:H})=>{if(!H||!H?.getConnector())throw new Error("Missing remote connection parameter");return new B8({name:B,remote:H?.getConnector(),deeplinkProtocol:H?.state.deeplinkProtocol,hideReturnToAppNotification:H?.state.hideReturnToAppNotification,platformManager:H?.getPlatformManager()})})({name:Tl.INPAGE,target:Tl.CONTENT_SCRIPT,remoteConnection:a}),f=i.getPlatformType(),g=o.options.dappMetadata,v=`Sdk/Javascript SdkVersion/${sa.version} Platform/${f} dApp/${(l=g.url)!==null&&l!==void 0?l:g.name} dAppTitle/${g.name}`;let w=null,b=null;const E=(u=o.options.storage)===null||u===void 0?void 0:u.storageManager;if(E){try{const B=yield E.getCachedAccounts();B.length>0&&(w=B[0])}catch(B){console.error(`[initializeMobileProvider] failed to get cached addresses: ${B}`)}try{const B=yield E.getCachedChainId();B&&(b=B)}catch(B){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${B}`)}}ve(`[initializeMobileProvider] cachedAccountAddress: ${w}, cachedChainId: ${b}`);const M=!(!n||f===gr.NonBrowser||f===gr.ReactNative),S=Ai.init({shouldSetOnWindow:M,connectionStream:d,shouldShimWeb3:r,sdkInstance:o});let F=!1;const D=B=>{F=B},z=()=>F,X=(B,H,V,T)=>_e(void 0,void 0,void 0,(function*(){var p,y,R,P,_,I,N,x,h;const m=Ai.getProvider();if(F){m.emit("display_uri",a?.state.qrcodeLink||""),a?.showActiveModal();let de=z();for(;de;){const Ae=z(),Ce=a?.isAuthorized();de=Ae&&!Ce,ve(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${Ae} authorized: ${Ce}`),yield MA(1e3)}return ve("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),V(...H)}const A=i.isMetaMaskInstalled(),C=a?.isConnected();let $=null,j=null,Z=null;if($=(p=m.getSelectedAddress())!==null&&p!==void 0?p:w,Z=m.getChainId()||b,$&&E&&$!==w&&E.persistAccounts([$]).catch((de=>{console.error(`[initializeMobileProvider] failed to persist account: ${de}`)})),Z&&(b=Z,E&&E.persistChainId(Z).catch((de=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${de}`)}))),ve("[initializeMobileProvider: sendRequest()]",{selectedAddress:$,chainId:Z}),T&&ve(`[initializeMobileProvider: sendRequest()] method=${B} ongoing=${F} selectedAddress=${$} isInstalled=${A} checkInstallationOnAllCalls=${t} socketConnected=${C}`),$&&B.toLowerCase()===ct.ETH_ACCOUNTS.toLowerCase())return[$];if(Z&&B.toLowerCase()===ct.ETH_CHAINID.toLowerCase())return Z;const ne=[ct.ETH_REQUESTACCOUNTS,ct.WALLET_REQUESTPERMISSIONS,ct.METAMASK_CONNECTSIGN,ct.METAMASK_CONNECTWITH],se=!Nl[B],ue=(y=o.options.readonlyRPCMap)===null||y===void 0?void 0:y[Z];if(ue&&se)try{const de=(R=H?.[0])===null||R===void 0?void 0:R.params,Ae=yield(({rpcEndpoint:Ce,method:Ue,sdkInfo:Be,params:Oe})=>_e(void 0,void 0,void 0,(function*(){const Le=JSON.stringify({jsonrpc:"2.0",method:Ue,params:Oe,id:(rE+=1,rE)}),je={Accept:"application/json","Content-Type":"application/json"};let $e;Ce.includes("infura")&&(je["Metamask-Sdk-Info"]=Be);try{$e=yield jS(Ce,{method:"POST",headers:je,body:Le})}catch(Je){throw Je instanceof Error?new Error(`Failed to fetch from RPC: ${Je.message}`):new Error(`Failed to fetch from RPC: ${Je}`)}if(!$e.ok)throw new Error(`Server responded with a status of ${$e.status}`);return(yield $e.json()).result})))({rpcEndpoint:ue,sdkInfo:v,method:B,params:de||[]});return T&&ve(`initializeProvider::ReadOnlyRPCResponse ${Ae}`),Ae}catch(de){console.warn(`[initializeMobileProvider: sendRequest()] method=${B} readOnlyRPCRequest failed:`,de)}if((!A||A&&!C)&&B!==ct.METAMASK_GETPROVIDERSTATE){const de=((P=H?.[0])===null||P===void 0?void 0:P.params)||[];if(ne.indexOf(B)!==-1||t){D(!0);const Ae=B===ct.METAMASK_CONNECTWITH,Ce=`${Date.now()}`;try{yield s.start({wait:!1,connectWith:Ae?{method:B,id:Ce,params:de}:void 0}),yield new Promise(((Ue,Be)=>{a?.isAuthorized()&&(ve("[initializeMobileProvider: sendRequest()] already authorized"),Ue(!0)),a?.getConnector().once(Ne.AUTHORIZED,(()=>{Ue(!0)})),o.once(Ne.PROVIDER_UPDATE,(Oe=>{ve(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${Oe}`),Oe===Gi.EXTENSION?Be(Ne.PROVIDER_UPDATE):Be(new Error("Connection Terminated"))}))}))}catch(Ue){if(Gi.EXTENSION===Ue){if(ve(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${B} on the active provider`),B.toLowerCase()===ct.METAMASK_CONNECTSIGN.toLowerCase()){const Be=yield(_=o.getProvider())===null||_===void 0?void 0:_.request({method:ct.ETH_REQUESTACCOUNTS,params:[]});if(!Be.length)throw new Error("SDK state invalid -- undefined accounts");const Oe=yield(I=o.getProvider())===null||I===void 0?void 0:I.request({method:ct.PERSONAL_SIGN,params:[de[0],Be[0]]});return o.emit(Br.ConnectWithResponse,Oe),Oe}if(B.toLowerCase()===ct.METAMASK_CONNECTWITH.toLowerCase()){const[Be]=de,Oe=yield(({method:Le,sdk:je,params:$e})=>_e(void 0,void 0,void 0,(function*(){var Je,He,Ke,Ge;if(!je.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");ve("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",Le,$e);const Dt=yield(Je=je.getProvider())===null||Je===void 0?void 0:Je.request({method:ct.ETH_REQUESTACCOUNTS,params:[]});if(!Dt.length)throw new Error("SDK state invalid -- undefined accounts");if(Le?.toLowerCase()===ct.PERSONAL_SIGN.toLowerCase()){const _t={method:Le,params:[$e[0],Dt[0]]};return yield(He=je.getProvider())===null||He===void 0?void 0:He.request(_t)}if(Le?.toLowerCase()===ct.ETH_SENDTRANSACTION.toLowerCase()){const _t={method:Le,params:[Object.assign(Object.assign({},$e[0]),{from:Dt[0]})]};return yield(Ke=je.getProvider())===null||Ke===void 0?void 0:Ke.request(_t)}return PA.includes(Le.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${Le} -- not handled by the extension -- call separately`),Dt):yield(Ge=je.getProvider())===null||Ge===void 0?void 0:Ge.request({method:Le,params:$e})})))({method:Be.method,sdk:o,params:Be.params});return o.emit(Br.ConnectWithResponse,Oe),Oe}return ve(`[initializeMobileProvider: sendRequest()] sending '${B}' on active provider`,de),yield(N=o.getProvider())===null||N===void 0?void 0:N.request({method:B,params:de})}throw Ue===Ne.REJECTED?(a?.closeModal(),(x=o.getProvider())===null||x===void 0||x.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001})):(ve(`[initializeMobileProvider: sendRequest()] failed to start installer: ${Ue}`),Ue)}finally{D(!1)}if(B===ct.ETH_REQUESTACCOUNTS)return j=yield new Promise((Ue=>{const Be=setInterval((()=>{const{accounts:Oe}=m.getState();Oe&&(clearInterval(Be),Ue(Oe))}),100)})),ve(`[initializeMobileProvider: sendRequest()] selectedAddress: ${$} --- SKIP rpc call`),j;if(B===ct.METAMASK_CONNECTWITH)try{let Ue=0;const Be=5,Oe=({resolve:Je,reject:He})=>{Ue+=1;const Ke=a?.getConnector().getRPCMethodTracker(),Ge=Ke?.[Ce];return ve(`TRACKER: update method ${Ce}`,Ge),Ge?.result?(ve("[initializeMobileProvider: sendRequest()] found result",Ge.result),o.emit(Br.ConnectWithResponse,Ge.result),void Je(Ge.result)):Ge?.error?(ve("[initializeMobileProvider: sendRequest()] found error",Ge.error),void He(Ge.error)):Ue>=Be?(ve("[initializeMobileProvider: sendRequest()] max message count reached without result"),void He(new Error("Max message count reached without result"))):void ve("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let Le,je;const $e=yield new Promise(((Je,He)=>{const Ke=a?.getConnector().getRPCMethodTracker();ve(`TRACKER: method ${Ce}`,Ke),Ke?.[Ce].result?(ve("[initializeMobileProvider: sendRequest()] found result",Ke?.[Ce].result),Je(Ke?.[Ce].result)):Ke?.[Ce].error&&(ve("[initializeMobileProvider: sendRequest()] found error",Ke?.[Ce].error),He(Ke?.[Ce].error)),je=()=>Oe({resolve:Je,reject:He}),Le=a?.getConnector().on(Ne.RPC_UPDATE,je)}));return je&&Le?.off(Ne.RPC_UPDATE,je),ve("TRACKER: result",$e),$e}catch(Ue){throw ve("[initializeMobileProvider: sendRequest()] error:",Ue),Ue}return H[0]&&typeof H[0]=="object"&&(H[0].params={__triggeredInstaller:!0,wrappedParams:H[0].params}),V(...H)}if(i.isSecure()&&Nl[B])return V(...H);if(o.isExtensionActive())return ve(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${B}' to it`,H,de),yield(h=o.getProvider())===null||h===void 0?void 0:h.request({method:B,params:de});throw ve(`[initializeMobileProvider: sendRequest()] method=${B} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const de=yield V(...H);if(ve(`[initializeMobileProvider: sendRequest()] method=${B} rpcResponse`,de),B===ct.WALLET_REQUESTPERMISSIONS){const Ae=de.reduce(((Ce,Ue)=>{var Be;if(Ue.parentCapability==="eth_accounts"){const Oe=(Be=Ue.caveats.find((Le=>Le.type==="restrictReturnedAccounts")))===null||Be===void 0?void 0:Be.value;Oe&&Ce.push(...Oe)}return Ce}),[]);ve("[initializeMobileProvider: sendRequest()] accountsToPersist:",Ae),Ae.length>0&&(m.handleAccountsChanged(Ae,!1),E?.persistAccounts(Ae))}return de}catch(de){throw console.error("[initializeMobileProvider: sendRequest()] error:",de),de}})),{request:Y}=S;S.request=(...B)=>_e(void 0,void 0,void 0,(function*(){return X(B?.[0].method,B,Y,c)}));const{send:U}=S;return S.send=(...B)=>_e(void 0,void 0,void 0,(function*(){return X(B?.[0],B,U,c)})),ve("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),d.start(),S}));function $8(t){var e,n,r,i;return _e(this,void 0,void 0,(function*(){const{options:s}=t,o={communicationLayerPreference:(e=s.communicationLayerPreference)!==null&&e!==void 0?e:Jo.SOCKET,platformManager:t.platformManager,sdk:t,checkInstallationOnAllCalls:s.checkInstallationOnAllCalls,injectProvider:(n=s.injectProvider)===null||n===void 0||n,shouldShimWeb3:(r=s.shouldShimWeb3)===null||r===void 0||r,extensionOnly:(i=s.extensionOnly)===null||i===void 0||i,installer:t.installer,remoteConnection:t.remoteConnection,debug:t.debug},a=yield U8(o);t.activeProvider=a,(function(c){var l,u,d,f;(u=(l=c.remoteConnection)===null||l===void 0?void 0:l.getConnector())===null||u===void 0||u.on(Br.ConnectionStatus,(g=>{c.emit(Br.ConnectionStatus,g)})),(f=(d=c.remoteConnection)===null||d===void 0?void 0:d.getConnector())===null||f===void 0||f.on(Br.ServiceStatus,(g=>{c.emit(Br.ServiceStatus,g)}))})(t)}))}const F8="sdk";class K8{constructor({serverUrl:e,enabled:n,originatorInfo:r}){this.serverURL=Qa,this.serverURL=e,this.originatorInfo=r,this.enabled=n==null||n}send({event:e,params:n}){if(!this.enabled)return;const r=Object.assign(Object.assign({id:F8,event:e,sdkVersion:sa.version},this.originatorInfo),{params:n});ve(`[Analytics: send()] event: ${e}`,r),Ts(r,this.serverURL).catch((i=>{ve(`[Analytics: send()] error: ${i}`)}))}}const V8=()=>{if(typeof document>"u")return;let t;const e=document.getElementsByTagName("link");for(let n=0;n<e.length;n++)e[n].getAttribute("rel")!=="icon"&&e[n].getAttribute("rel")!=="shortcut icon"||(t=e[n].getAttribute("href"));return t},j8=163400;function iE(t){var e,n,r;const{dappMetadata:i}=t,s=(function({url:u,name:d}){var f;const g=u+d,v=rf(g);if(!localStorage)return"";let w=(f=localStorage.getItem(v))!==null&&f!==void 0?f:"";if(!w){w=hs();try{localStorage.setItem(v,w)}catch{return""}}return w})({url:(e=i?.url)!==null&&e!==void 0?e:"no_url",name:(n=i?.name)!==null&&n!==void 0?n:"no_name"}),o=(r=t.platformManager)===null||r===void 0?void 0:r.getPlatformType(),a=o===gr.DesktopWeb,c=o===gr.MetaMaskMobileWebview;let l="N/A";return a?l="extension":c&&(l="mobile"),{id:s,from:l}}const Du=(t,e,n)=>{if(Vl(t))if(n||e&&typeof e=="object"&&e!==null&&"error"in e){const r=n||e?.error;r&&r.code===4001?On.analytics.track("sdk_action_rejected",{action:t}):On.analytics.track("sdk_action_failed",{action:t})}else On.analytics.track("sdk_action_succeeded",{action:t})},kA=({provider:t,sdkInstance:e})=>{if("state"in t)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(t,{get:(n,r)=>r==="request"?function(i){var s,o;return _e(this,void 0,void 0,(function*(){ve("[wrapExtensionProvider()] Overwriting request method",i);const{method:a,params:c}=i,l=P8.includes(a.toLowerCase()),{id:u,from:d}=iE(e);if(l&&((s=e.analytics)===null||s===void 0||s.send({event:Pn.SDK_RPC_REQUEST,params:{method:a,from:d,id:u}})),Vl(a)&&On.analytics.track("sdk_action_requested",{action:a}),a===ct.METAMASK_BATCH&&Array.isArray(c))return(({target:v,args:w,trackEvent:b,sdkInstance:E})=>_e(void 0,void 0,void 0,(function*(){var M,S;if(w.method!=="metamask_batch")throw new Error("Invalid usage");const F=[],D=(M=w?.params)!==null&&M!==void 0?M:[];for(const Y of D){const U=yield v?.request({method:Y.method,params:Y.params});F.push(U)}const{id:z,from:X}=iE(E);b&&((S=E.analytics)===null||S===void 0||S.send({event:Pn.SDK_RPC_REQUEST_DONE,params:{method:w.method,from:X,id:z}}));for(const Y of F)Du(w.method,Y,null);return F})))({target:n,args:i,trackEvent:l,sdkInstance:e});if(a.toLowerCase()===ct.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(c))return(({target:v,params:w})=>_e(void 0,void 0,void 0,(function*(){let b,E=null;try{const M=yield v.request({method:ct.ETH_REQUESTACCOUNTS,params:[]});if(!M.length)throw new Error("SDK state invalid -- undefined accounts");return b=yield v.request({method:ct.PERSONAL_SIGN,params:[w[0],M[0]]}),b}catch(M){throw E=M,M}finally{Du(ct.PERSONAL_SIGN,b,E)}})))({target:n,params:c});if(a.toLowerCase()===ct.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(c))return(({target:v,params:w})=>_e(void 0,void 0,void 0,(function*(){const[b]=w,E=b.method,M=b.params;let S,F=null;try{const D=yield v.request({method:ct.ETH_REQUESTACCOUNTS,params:[]});if(!Array.isArray(D)||!D.length)throw new Error("SDK state invalid -- undefined accounts");return E?.toLowerCase()===ct.PERSONAL_SIGN.toLowerCase()?(S=yield v.request({method:E,params:[M[0],D[0]]}),S):E?.toLowerCase()===ct.ETH_SENDTRANSACTION.toLowerCase()?(S=yield v.request({method:E,params:[Object.assign(Object.assign({},M[0]),{from:D[0]})]}),S):PA.includes(E.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${E} -- not handled by the extension -- call separately`),S=D,S):(S=yield v.request({method:E,params:M}),S)}catch(D){throw F=D,D}finally{Du(E,S,F)}})))({target:n,params:c});let f,g=null;try{return f=yield n.request(i),f}catch(v){throw g=v,v}finally{l&&((o=e.analytics)===null||o===void 0||o.send({event:Pn.SDK_RPC_REQUEST_DONE,params:{method:a,from:d,id:u}})),Du(a,f,g)}}))}:r==="getChainId"?function(){return t.chainId}:r==="getNetworkVersion"?function(){return t.networkVersion}:r==="getSelectedAddress"?function(){return t.selectedAddress}:r==="isConnected"?function(){return t._state.isConnected}:n[r]})};var sf;function H8({mustBeMetaMask:t,sdkInstance:e}){return _e(this,void 0,void 0,(function*(){if(typeof window>"u")throw new Error("window not available");try{const n=yield new Promise(((r,i)=>{const s=setTimeout((()=>{i(new Error("eip6963RequestProvider timed out"))}),500);window.addEventListener(sf.Announce,(o=>{const a=o,{detail:{info:c,provider:l}={}}=a,{name:u,rdns:d,uuid:f}=c??{};N8.test(f)&&u.startsWith(tE.NAME)&&tE.RDNS.includes(d)&&(clearTimeout(s),r(l))})),window.dispatchEvent(new Event(sf.Request))}));return kA({provider:n,sdkInstance:e})}catch{throw new Error("Provider not found")}}))}(function(t){t.Announce="eip6963:announceProvider",t.Request="eip6963:requestProvider"})(sf||(sf={}));const z8=t=>_e(void 0,void 0,void 0,(function*(){const{options:e}=t,{infuraAPIKey:n}=e;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};t.options.readonlyRPCMap?t.options.readonlyRPCMap=Object.assign(Object.assign({},t.options.readonlyRPCMap),r):t.options.readonlyRPCMap=r})),q8=t=>_e(void 0,void 0,void 0,(function*(){const{options:e}=t,{readonlyRPCMap:n}=e;if(n)try{ve("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),t.setReadOnlyRPCCalls(!0)}catch{throw new Error("Invalid Infura Settings")}}));function W8(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(l){try{c(r.next(l))}catch(u){s(u)}}function a(l){try{c(r.throw(l))}catch(u){s(u)}}function c(l){var u;l.done?i(l.value):(u=l.value,u instanceof n?u:new n((function(d){d(u)}))).then(o,a)}c((r=r.apply(t,[])).next())}))}function G8(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(l){return(function(u){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||u[0]!==6&&u[0]!==2)){o=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(u[0]===6&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(d){u=[6,d],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}})([c,l])}}}var sE="INSTALLED",oE="NOT_INSTALLED",aE="REGISTERED",cE="REGISTERING",lE="RELOADING",uE={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},Lu="REGISTRATION_IN_PROGRESS",dE="FORWARDER_ID",Y8=(function(){function t(e){var n=e===void 0?{}:e,r=n.forwarderOrigin,i=r===void 0?"https://fwd.metamask.io":r,s=n.forwarderMode,o=s===void 0?t.FORWARDER_MODE.INJECT:s;this.forwarderOrigin=i,this.forwarderMode=o,this.state=t.isMetaMaskInstalled()?sE:oE;var a=t._detectBrowser();this.downloadUrl=a?uE[a]:uE.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),o===t.FORWARDER_MODE.INJECT&&sessionStorage.getItem(Lu)==="true"&&t._injectForwarder(this.forwarderOrigin)}return t.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return e.data.type==="metamask:reload"?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},t.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},t.prototype._onMessageFromForwarder=function(e){return W8(this,0,void 0,(function(){return G8(this,(function(n){switch(n.label){case 0:switch(this.state){case lE:return[3,1];case oE:return[3,2];case sE:return[3,3];case cE:return[3,5];case aE:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=lE,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=cE,[4,t._register()];case 4:return n.sent(),this.state=aE,e.source.postMessage({type:"metamask:registrationCompleted"},e.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}}))}))},t.prototype.startOnboarding=function(){sessionStorage.setItem(Lu,"true"),this._openDownloadPage(),this._openForwarder()},t.prototype.stopOnboarding=function(){sessionStorage.getItem(Lu)==="true"&&(this.forwarderMode===t.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),t._removeForwarder()),sessionStorage.setItem(Lu,"false"))},t.prototype._openForwarder=function(){this.forwarderMode===t.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):t._injectForwarder(this.forwarderOrigin)},t.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},t.isMetaMaskInstalled=function(){return!!(window.ethereum&&window.ethereum.isMetaMask)},t._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},t._injectForwarder=function(e){var n=document.body,r=document.createElement("iframe");r.setAttribute("height","0"),r.setAttribute("width","0"),r.setAttribute("style","display: none;"),r.setAttribute("src",e),r.setAttribute("id",dE),n.insertBefore(r,n.children[0])},t._removeForwarder=function(){var e;(e=document.getElementById(dE))===null||e===void 0||e.remove()},t._detectBrowser=function(){var e=OA.parse(window.navigator.userAgent);return e.browser.name==="Firefox"?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},t.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},t})();function J8(t,{wait:e=!1}){return _e(this,void 0,void 0,(function*(){return ve(`[MetamaskInstaller: startInstaller()] wait=${e}`),e&&(yield MA(1e3)),yield t.checkInstallation()}))}class Z8{constructor({remote:e,preferDesktop:n,platformManager:r,debug:i=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=n,this.state.platformManager=r,this.state.debug=i}startDesktopOnboarding(){return(function(){return _e(this,void 0,void 0,(function*(){ve("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),new Y8().startOnboarding()}))})()}redirectToProperInstall(){return _e(this,void 0,void 0,(function*(){return(function(e){var n,r;return _e(this,void 0,void 0,(function*(){const{state:i}=e,s=(n=i.platformManager)===null||n===void 0?void 0:n.getPlatformType();if(ve(`[MetamaskInstaller: redirectToProperInstall()] platform=${s}`),s===gr.MetaMaskMobileWebview)return!1;i.isInstalling=!0;try{yield(r=i.remote)===null||r===void 0?void 0:r.startConnection({connectWith:i.connectWith}),i.isInstalling=!1,i.hasInstalled=!0}catch(o){throw i.isInstalling=!1,o}return!0}))})(this)}))}checkInstallation(){return _e(this,void 0,void 0,(function*(){return(function(e){var n;return _e(this,void 0,void 0,(function*(){const{state:r}=e,i=(n=r.platformManager)===null||n===void 0?void 0:n.isMetaMaskInstalled();return ve(`[MetamaskInstaller: checkInstallation()] isInstalled=${i}`),!!i||(yield e.redirectToProperInstall())}))})(this)}))}start({wait:e=!1,connectWith:n}){return _e(this,void 0,void 0,(function*(){this.state.connectWith=n,ve(`[MetaMaskInstaller: start()] wait=${e}`,n),yield J8(this,{wait:e})}))}}class DA{constructor({debug:e,sdkVersion:n}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=e!=null&&e,this.sdkVersion=n}loadComponent(e){return _e(this,void 0,void 0,(function*(){if(!this.defined[e]){this.defined[e]=!0;try{const n=yield Promise.resolve().then((function(){return Pk}));console.log("loader",n),n.defineCustomElements()}catch(n){console.error(`Failed to load ${e} modal:`,n)}}}))}renderInstallModal(e){var n;return _e(this,void 0,void 0,(function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const r=document.createElement("mm-install-modal");r.link=e.link,r.preferDesktop=e.preferDesktop,r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.addEventListener("close",(({detail:{shouldTerminate:i}})=>e.onClose(i))),r.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),r.addEventListener("trackAnalytics",(i=>{var s;return(s=e.onAnalyticsEvent)===null||s===void 0?void 0:s.call(e,i.detail)})),e.parentElement.appendChild(r)}))}renderSelectModal(e){var n;return _e(this,void 0,void 0,(function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const r=document.createElement("mm-select-modal");r.link=e.link,r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.preferDesktop=e.preferDesktop,r.addEventListener("close",(({detail:{shouldTerminate:i}})=>e.onClose(i))),r.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(r),setTimeout((()=>this.updateQRCode(e.link)),100)}))}renderPendingModal(e){var n;return _e(this,void 0,void 0,(function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const r=document.createElement("mm-pending-modal");r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.displayOTP=e.displayOTP,r.addEventListener("close",e.onClose),r.addEventListener("updateOTPValue",(({detail:{otpValue:i}})=>e.updateOTPValue(i))),e.onDisconnect&&r.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(r)}))}updateOTPValue(e){const n=()=>{var r;const i=(r=this.containers.pending)===null||r===void 0?void 0:r.querySelector("mm-pending-modal");return!!i&&(i.otpCode=e,!0)};setTimeout((()=>{n()}),800)}updateQRCode(e){var n,r;const i=(n=this.containers.install)===null||n===void 0?void 0:n.querySelector("mm-install-modal");if(i)i.link=e;else{const s=(r=this.containers.select)===null||r===void 0?void 0:r.querySelector("mm-select-modal");s&&(s.link=e)}}unmount(){Object.entries(this.containers).forEach((([e,n])=>{var r;(r=n?.parentNode)===null||r===void 0||r.removeChild(n),this.containers[e]=void 0}))}}const X8=({link:t,debug:e,installer:n,terminate:r,connectWithExtension:i,preferDesktop:s,onAnalyticsEvent:o})=>{let a=null,c=null;ve("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),ve(`[UI: InstallModal-web: sdkWebInstallModal()] link=${t}`),ve(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${t}" --ios`),ve(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${t}" --android`),ve(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${t}"`);const l=u=>{var d;ve("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",u,c),c?.parentNode&&((d=c.parentNode)===null||d===void 0||d.removeChild(c)),c=null,a=null,u===!0&&r?.()};return{mount:u=>{if(ve("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(a==null||a.updateQRCode(u));a=new DA({debug:e,sdkVersion:sa.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?a.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),i?.()},onClose:l,link:t,preferDesktop:s!=null&&s}).catch((d=>{console.error(d)})):a.renderInstallModal({parentElement:c,preferDesktop:s!=null&&s,link:t,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:o}).catch((d=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",d)}))},unmount:l}},Q8=({onDisconnect:t,debug:e})=>{let n=null,r=null;const i=()=>{ve("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),n?.parentNode&&n.parentNode.removeChild(n),n=null,r=null},s=a=>{ve("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",a),r&&r.updateOTPValue(a)},o=({displayOTP:a}={displayOTP:!0})=>{ve("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new DA({debug:e,sdkVersion:sa.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:t,updateOTPValue:s,displayOTP:a}).catch((c=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",c)})))};return o(),{mount:o,unmount:i,updateOTPValue:s}};function LA(t,e){var n,r,i,s;t.connector||(ve("[RemoteConnection: initializeConnector()] initialize connector"),t.connector=new tM({anonId:e.anonId,platformType:e.platformManager.getPlatformType(),communicationLayerPreference:e.communicationLayerPreference,transports:e.transports,dappMetadata:Object.assign(Object.assign({},e.dappMetadata),{source:e._source}),analytics:e.enableAnalytics,communicationServerUrl:e.communicationServerUrl,sdkVersion:sa.version,context:"dapp",ecies:e.ecies,storage:e.storage,logging:e.logging}),e.timer&&(ve("[RemoteConnection: initializeConnector()] reset background timer",e.timer),(r=(n=e.timer)===null||n===void 0?void 0:n.stopBackgroundTimer)===null||r===void 0||r.call(n),(s=(i=e.timer)===null||i===void 0?void 0:i.runBackgroundTimer)===null||s===void 0||s.call(i,(()=>!1),1e4)))}function sm(t){t.listeners.forEach((({event:e,handler:n})=>{var r;(r=t.connector)===null||r===void 0||r.off(e,n)})),t.listeners=[]}function ek(t,e,n){return _e(this,void 0,void 0,(function*(){const r=setTimeout((()=>{On.analytics.track("sdk_connection_failed",{transport_type:"websocket"})}),6e4);return new Promise(((i,s)=>{if(!t.connector)return void s(new Error("No connector available"));ve("[RemoteConnection: connectWithModalInstaller()]",{state:t,options:e,linkParams:n});const o=`${t.useDeeplink?Ol:Cl}?${n}`;(function(a,c,l){var u,d,f,g;a.installModal=(d=(u=c.modals).install)===null||d===void 0?void 0:d.call(u,{link:l,preferDesktop:a.preferDesktop,installer:c.getMetaMaskInstaller(),terminate:()=>{ve("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),c.sdk.terminate().catch((v=>{console.warn("[MMSDK] failed to terminate connection",v)}))},debug:a.developerMode,connectWithExtension:()=>{var v;return(v=c.connectWithExtensionProvider)===null||v===void 0||v.call(c),!1},onAnalyticsEvent:({event:v,params:w})=>{var b,E,M;const S=Object.assign(Object.assign({},w),{sdkVersion:c.sdk.getVersion(),dappId:(b=c.dappMetadata)===null||b===void 0?void 0:b.name,source:c._source,url:(E=c.dappMetadata)===null||E===void 0?void 0:E.url});(M=a.analytics)===null||M===void 0||M.send({event:v,params:S})}}),(g=(f=a.installModal)===null||f===void 0?void 0:f.mount)===null||g===void 0||g.call(f,l)})(t,e,o),e.sdk.once(Ne.PROVIDER_UPDATE,(a=>_e(this,void 0,void 0,(function*(){if(ve("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),a===Gi.TERMINATE){const c={code:4001,message:"User rejected the request."};return clearTimeout(r),void s(c)}s(a)})))),t.connector.once(Ne.AUTHORIZED,(()=>{clearTimeout(r),i()})),t.connector.once(Ne.REJECTED,(()=>{clearTimeout(r),s(Ne.REJECTED)})),t.connector.once(Ne.CLIENTS_READY,(()=>_e(this,void 0,void 0,(function*(){ve("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),clearTimeout(r),i()}))))}))}))}function BA(t,e){function n(r,i){var s;(s=t.connector)===null||s===void 0||s.on(r,i),t.listeners.push({event:r,handler:i})}t.connector&&(sm(t),n(Ne.WALLET_INIT,(({accounts:r,chainId:i})=>_e(this,void 0,void 0,(function*(){ve(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${r} chainId=${i}`);const s=Ai.getProvider();s._setConnected();const o={accounts:r,chainId:i,isUnlocked:!1};s._initializeState(o),s.emit("chainChanged",i),s.emit("accountsChanged",r)})))),n(Ne.AUTHORIZED,(()=>_e(this,void 0,void 0,(function*(){var r,i,s,o;try{ve("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",t.pendingModal,t.installModal);const a=Ai.getProvider();a._setConnected(),(i=(r=t.pendingModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r),(o=(s=t.installModal)===null||s===void 0?void 0:s.unmount)===null||o===void 0||o.call(s,!1),t.otpAnswer=void 0,t.authorized=!0,ve("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",a.getState()),yield a.forceInitializeState()}catch{}})))),n(Ne.TERMINATE,(()=>{var r,i,s,o,a;(i=(r=t.pendingModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r),(o=(s=t.installModal)===null||s===void 0?void 0:s.unmount)===null||o===void 0||o.call(s,!0),t.pendingModal=void 0,t.installModal=void 0,t.otpAnswer=void 0,(a=t.connector)===null||a===void 0||a.disconnect({terminate:!0}),t.authorized=!1,Ai.getProvider().handleDisconnect({terminate:!0}),sm(t),ve("[RemoteConnection: setupListeners()] All listeners cleaned up")})))}function tk(t,e,{initialCheck:n,connectWith:r}={}){var i,s,o,a,c,l,u,d,f,g,v,w,b,E,M,S,F,D,z;return _e(this,void 0,void 0,(function*(){try{if(LA(t,e),!t.connector)throw new Error("no connector defined");BA(t);const X=Ai.getProvider();t.authorized=!1,X.emit("connecting");const Y=yield(i=t.connector)===null||i===void 0?void 0:i.originatorSessionConnect();ve(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,Y);let U=(s=Y?.channelId)!==null&&s!==void 0?s:"",B=(a=(o=t.connector.getKeyInfo())===null||o===void 0?void 0:o.ecies.public)!==null&&a!==void 0?a:"",H=(l=(c=t.connector.getKeyInfo())===null||c===void 0?void 0:c.ecies.private)!==null&&l!==void 0?l:"";if(n&&!Y)return Promise.resolve();if(!Y&&!n){const C=yield t.connector.generateChannelIdConnect();U=(u=C.channelId)!==null&&u!==void 0?u:"",B=(d=C.pubKey)!==null&&d!==void 0?d:"",H=(f=C.privKey)!==null&&f!==void 0?f:"";const $=Date.now();(g=t.connector.state.storageManager)===null||g===void 0||g.persistChannelConfig({channelId:U,localKey:H,lastActive:$,validUntil:$+ec})}if(n&&Y?.channelId)return!((v=t.connector)===null||v===void 0)&&v.isConnected()||(ve(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,Y),yield(w=t.connector)===null||w===void 0?void 0:w.connectToChannel({channelId:U})),Promise.resolve();Y&&!(!((b=t.connector)===null||b===void 0)&&b.isConnected())&&(ve("[RemoteConnection: startConnection()] reconnecting to channel",Y),yield(E=t.connector)===null||E===void 0?void 0:E.connectToChannel({channelId:U}));const V=!((M=t.platformManager)===null||M===void 0)&&M.isSecure()?"":"&t=q",T=sa.version,{iconUrl:p,name:y,url:R,scheme:P}=e.dappMetadata||{},_=(S=t.platformManager)===null||S===void 0?void 0:S.getPlatformType();let I="N/A";typeof window<"u"&&window.location&&window.location.hostname?I=window.location.hostname:y!==void 0?I=y:R!==void 0&&(I=R);const N={url:R??"",title:y??"",icon:p,scheme:P??"",apiVersion:T,dappId:I||R||"N/A",anonId:e.anonId,platform:_??"",source:(F=e._source)!==null&&F!==void 0?F:""},x=rf(JSON.stringify(N));let h=`channelId=${U}&v=2&comm=${(D=t.communicationLayerPreference)!==null&&D!==void 0?D:""}&pubkey=${B}${V}&originatorInfo=${x}&hr=${t.hideReturnToAppNotification?1:0}`;if(r){h+=`&rpc=${rf(JSON.stringify(r))}`;const C=t.connector.getRPCMethodTracker();C&&(C[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const m=encodeURI(h),A=`${t.useDeeplink?Ol:Cl}?${h}`;if(t.qrcodeLink=A,t.developerMode&&ve(`[RemoteConnection: startConnection()] qrcodeLink=${m}`),X.emit("display_uri",A),On.analytics.track("sdk_connection_initiated",{transport_type:"websocket"}),(z=t.platformManager)===null||z===void 0?void 0:z.isSecure()){const C=setTimeout((()=>{On.analytics.track("sdk_connection_failed",{transport_type:"websocket"})}),6e4);return yield(function($,j){var Z,ne;return _e(this,void 0,void 0,(function*(){const se=`${Cl}?${j}`,ue=`${Ol}?${j}`;(ne=(Z=$.platformManager)===null||Z===void 0?void 0:Z.openDeeplink)===null||ne===void 0||ne.call(Z,se,ue,"_self")}))})(t,m),new Promise((($,j)=>{var Z,ne,se;if(!((Z=t.connector)===null||Z===void 0)&&Z.isAuthorized())return clearTimeout(C),void $();(ne=t.connector)===null||ne===void 0||ne.once(Ne.AUTHORIZED,(()=>{clearTimeout(C),$()})),(se=t.connector)===null||se===void 0||se.once(Ne.REJECTED,(()=>{clearTimeout(C),j(Ne.REJECTED)}))}))}return ek(t,e,m)}catch(X){throw console.error("[startConnection] error",X),X}}))}class nk{constructor(e){var n,r,i;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const s=((n=e.logging)===null||n===void 0?void 0:n.developerMode)===!0||((r=e.logging)===null||r===void 0?void 0:r.sdk)===!0;this.state.developerMode=s,this.state.analytics=e.analytics,this.state.preferDesktop=(i=e.preferDesktop)!==null&&i!==void 0&&i,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.hideReturnToAppNotification=e.sdk.options.hideReturnToAppNotification,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=X8),e.modals.otp||(e.modals.otp=Q8)}startConnection(e){return _e(this,void 0,void 0,(function*(){return tk(this.state,this.options,e)}))}initRemoteCommunication({sdkInstance:e}){var n,r,i;return _e(this,void 0,void 0,(function*(){const s=yield(r=(n=e.options.storage)===null||n===void 0?void 0:n.storageManager)===null||r===void 0?void 0:r.getPersistedChannelConfig();if(!this.options.ecies){const o={privateKey:s?.localKey};this.options.ecies=o}LA(this.state,this.options),yield(i=this.getConnector())===null||i===void 0?void 0:i.initFromDappStorage(),BA(this.state,this.options)}))}showActiveModal(){return(function(e){var n,r,i,s;e.authorized?ve("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?(r=(n=e.pendingModal).mount)===null||r===void 0||r.call(n):e.installModal&&((s=(i=e.installModal).mount)===null||s===void 0||s.call(i,e.qrcodeLink||""))})(this.state)}closeModal(){var e,n,r,i;(n=(e=this.state.pendingModal)===null||e===void 0?void 0:e.unmount)===null||n===void 0||n.call(e),(i=(r=this.state.installModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.getChannelConfig()}getKeyInfo(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return((e=this.state.connector)===null||e===void 0?void 0:e.isReady())||!1}isAuthorized(){var e;return((e=this.state.connector)===null||e===void 0?void 0:e.isAuthorized())||!1}isPaused(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.isPaused()}disconnect(e){var n,r,i;ve("[RemoteConnection: disconnect()]",e),e?.terminate&&(Ai.getProvider().handleDisconnect({terminate:!0}),(r=(n=this.state.pendingModal)===null||n===void 0?void 0:n.unmount)===null||r===void 0||r.call(n),this.state.otpAnswer=void 0),(i=this.state.connector)===null||i===void 0||i.disconnect(e),(function(s){ve("[RemoteConnection: cleanupConnector()] cleaning up connector"),s.connector&&(sm(s),s.connector.disconnect({terminate:!0}).catch((o=>{ve("[RemoteConnection: cleanupConnector()] error disconnecting connector",o)})))})(this.state)}}function rk(t){var e,n,r,i,s,o,a,c,l,u,d,f;return _e(this,void 0,void 0,(function*(){const{options:g}=t;if(g.logging=(e=g.logging)!==null&&e!==void 0?e:{},g.communicationLayerPreference=(n=g.communicationLayerPreference)!==null&&n!==void 0?n:Jo.SOCKET,g.enableDebug!==void 0&&(Ir.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),g.enableAnalytics=(r=g.enableAnalytics)===null||r===void 0||r,g.injectProvider=(i=g.injectProvider)===null||i===void 0||i,g.shouldShimWeb3=(s=g.shouldShimWeb3)===null||s===void 0||s,g.extensionOnly=(o=g.extensionOnly)===null||o===void 0||o,g.useDeeplink=(a=g.useDeeplink)===null||a===void 0||a,g.hideReturnToAppNotification=(c=g.hideReturnToAppNotification)!==null&&c!==void 0&&c,g.storage=(l=g.storage)!==null&&l!==void 0?l:{enabled:!0},g.headless){Ir("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const S=()=>{},F={install:()=>({mount:S,unmount:S})},D={installer:S};g.modals=F,g.ui=D}const v=((u=g.logging)===null||u===void 0?void 0:u.developerMode)===!0;t.debug=((d=g.logging)===null||d===void 0?void 0:d.sdk)||v,ve("[MetaMaskSDK: performSDKInitialization()] options",t.options);const w=Object.assign({},g.logging);v&&(w.sdk=!0,w.eciesLayer=!0,w.keyExchangeLayer=!0,w.remoteLayer=!0,w.serviceLayer=!0,w.plaintext=!0),yield(function(S){var F;return _e(this,void 0,void 0,(function*(){const{options:D}=S;S.platformManager=new Il({useDeepLink:(F=D.useDeeplink)!==null&&F!==void 0&&F,preferredOpenLink:D.openDeeplink,debug:S.debug})}))})(t),yield(function(S){var F,D,z,X,Y;return _e(this,void 0,void 0,(function*(){const{options:U}=S,B=(F=S.platformManager)===null||F===void 0?void 0:F.getPlatformType();S.analytics=new K8({serverUrl:(D=U.communicationServerUrl)!==null&&D!==void 0?D:Qa,enabled:U.enableAnalytics,originatorInfo:{url:(z=U.dappMetadata.url)!==null&&z!==void 0?z:"",title:(X=U.dappMetadata.name)!==null&&X!==void 0?X:"",dappId:S.getDappId(),platform:B??"",source:(Y=U._source)!==null&&Y!==void 0?Y:"",anonId:""}})}))})(t),yield(function(S){var F,D,z;return _e(this,void 0,void 0,(function*(){if(!S.options.enableAnalytics||!(!((F=S.platformManager)===null||F===void 0)&&F.isBrowser())&&!(!((D=S.platformManager)===null||D===void 0)&&D.isReactNative()))return;const X=S.getVersion(),Y=S.getDappId(),U=yield S.getAnonId(),B=(z=S.platformManager)===null||z===void 0?void 0:z.getPlatformType(),H=S.options._source;On.analytics.setGlobalProperty("sdk_version",X),On.analytics.setGlobalProperty("dapp_id",Y),On.analytics.setGlobalProperty("anon_id",U),On.analytics.setGlobalProperty("platform",B),On.analytics.setGlobalProperty("integration_type",H),On.analytics.enable(),On.analytics.track("sdk_initialized",{})}))})(t),yield(function(S){var F;return _e(this,void 0,void 0,(function*(){const{options:D}=S;((F=D.storage)===null||F===void 0?void 0:F.enabled)!==!0||D.storage.storageManager||(D.storage.storageManager=yield NA(D.storage))}))})(t),yield(function(S){return _e(this,void 0,void 0,(function*(){const{options:F}=S,D=/^(http|https):\/\/[^\s]*$/;if(F.dappMetadata){F.dappMetadata.iconUrl&&!D.test(F.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),F.dappMetadata.iconUrl=void 0),F.dappMetadata.base64Icon&&F.dappMetadata.base64Icon.length>j8&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),F.dappMetadata.base64Icon=void 0),F.dappMetadata.url&&!D.test(F.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const z=V8();if(z&&!F.dappMetadata.iconUrl&&!F.dappMetadata.base64Icon){const X=`${window.location.protocol}//${window.location.host}${z}`;F.dappMetadata.iconUrl=X}}S.dappMetadata=F.dappMetadata}))})(t),yield z8(t),yield q8(t);const{metamaskBrowserExtension:b,preferExtension:E,shouldReturn:M}=yield(function(S){var F,D,z,X;return _e(this,void 0,void 0,(function*(){const{options:Y}=S;let U,B=!1,H=!1;if(typeof window<"u"&&window.ethereum&&!(!((F=S.platformManager)===null||F===void 0)&&F.isMetaMaskMobileWebView())){B=localStorage.getItem(nf)==="extension";try{U=yield H8({mustBeMetaMask:!0,sdkInstance:S}),window.extension=U,U.on(Oi.CHAIN_CHANGED,(V=>{ve(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${V}`),S.sdkProvider&&S.getMobileProvider().emit(Oi.CHAIN_CHANGED,V)})),U.on(Oi.ACCOUNTS_CHANGED,(V=>_e(this,void 0,void 0,(function*(){var T;ve(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${V}`);const p=!!S.sdkProvider,y=!!S.extensionActive;if(p&&S.getMobileProvider().emit(Oi.ACCOUNTS_CHANGED,V),y&&V?.length===0&&(yield(T=S.getProvider())===null||T===void 0?void 0:T.request({method:ct.WALLET_GETPERMISSIONS,params:[]})).length===0)try{yield S.terminate()}catch(R){ve("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",R)}})))),U.on(Oi.DISCONNECT,(V=>{ve(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${V}`),S.sdkProvider&&S.getMobileProvider().emit(Oi.DISCONNECT,V)})),U.on(Oi.CONNECT,(V=>{ve(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${V}`),S.sdkProvider&&S.getMobileProvider().emit(Oi.CONNECT,V)})),U.on(Oi.CONNECTED,(V=>{ve("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",V),S.sdkProvider&&S.getMobileProvider().emit(Oi.CONNECTED,V)}))}catch{window.extension=void 0}}else!((D=S.platformManager)===null||D===void 0)&&D.isMetaMaskMobileWebView()&&((z=S.analytics)===null||z===void 0||z.send({event:Pn.SDK_USE_INAPP_BROWSER}),S.activeProvider=kA({provider:window.ethereum,sdkInstance:S}),S._initialized=!0,H=!0);return U&&Y.extensionOnly&&(ve("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),(X=S.analytics)===null||X===void 0||X.send({event:Pn.SDK_USE_EXTENSION}),S.activeProvider=U,S.extensionActive=!0,S.extension=U,S._initialized=!0,H=!0),{preferExtension:B,shouldReturn:H,metamaskBrowserExtension:U}}))})(t);if(M)ve("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield(function(S,F){var D,z,X,Y,U;return _e(this,void 0,void 0,(function*(){const{options:B}=S,H=Object.assign({},B.logging);S.remoteConnection=new nk({anonId:yield S.getAnonId(),preferDesktop:(D=B.preferDesktop)!==null&&D!==void 0&&D,communicationLayerPreference:(z=B.communicationLayerPreference)!==null&&z!==void 0?z:Jo.SOCKET,analytics:S.analytics,dappMetadata:B.dappMetadata,_source:B._source,enableAnalytics:(X=B.enableAnalytics)===null||X===void 0||X,timer:B.timer,sdk:S,platformManager:S.platformManager,transports:B.transports,communicationServerUrl:B.communicationServerUrl,storage:(Y=B.storage)!==null&&Y!==void 0?Y:{enabled:!0},getMetaMaskInstaller:()=>{if(!S.installer)throw new Error("Invalid SDK status -- installer not initialized");return S.installer},logging:H,connectWithExtensionProvider:F===void 0?void 0:()=>nE(S),modals:Object.assign(Object.assign({},B.modals),{onPendingModalDisconnect:S.terminate.bind(S)})}),yield S.remoteConnection.initRemoteCommunication({sdkInstance:S}),S.installer=new Z8({remote:S.remoteConnection,preferDesktop:(U=B.preferDesktop)!==null&&U!==void 0&&U,platformManager:S.platformManager,debug:S.debug})}))})(t,b),yield $8(t),yield(function(S,F){var D,z;return _e(this,void 0,void 0,(function*(){const{options:X}=S;F?(ve("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),(D=S.analytics)===null||D===void 0||D.send({event:Pn.SDK_EXTENSION_UTILIZED}),nE(S).catch((Y=>{console.warn("Can't connect with MetaMask extension...",Y),localStorage.removeItem(nf)}))):X.checkInstallationImmediately&&(!((z=S.platformManager)===null||z===void 0)&&z.isDesktopWeb()?(ve("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),S.connect().catch((Y=>{ve(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${Y}`)}))):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),S._initialized=!0}))})(t,E);try{yield(f=t.remoteConnection)===null||f===void 0?void 0:f.startConnection({initialCheck:!0})}catch(S){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",S)}t.emit(Br.ProviderUpdate,Gi.INITIALIZED)}}))}const ik={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,hideReturnToAppNotification:!1,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:"direct",i18nOptions:{enabled:!1}};class sk extends S6{constructor(e){var n,r,i;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],this.ANON_ID_STORAGE_KEY="mm-sdk-anon-id",Ir.disable(),this.options=Object.assign(Object.assign({},ik),e);const s=((n=this.options.logging)===null||n===void 0?void 0:n.developerMode)===!0;if((!((r=this.options.logging)===null||r===void 0)&&r.sdk||s)&&Ir.enable("MM_SDK"),ve("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(!((i=this.options.dappMetadata)===null||i===void 0)&&i.url)){if(typeof window>"u"||typeof document>"u")throw new Error("You must provide dAppMetadata url");this.options.dappMetadata=Object.assign(Object.assign({},this.options.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.init().then((()=>{ve("[MetaMaskSDK: constructor()]: initialized successfully."),typeof window<"u"&&(window.mmsdk=this)})).catch((o=>{console.error("[MetaMaskSDK: constructor()] error during initialization",o)}))}init(){return _e(this,void 0,void 0,(function*(){return(function(e){var n;return _e(this,void 0,void 0,(function*(){if(typeof window<"u"&&(!((n=window.mmsdk)===null||n===void 0)&&n.isInitialized()))return ve("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return ve("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return ve("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=rk(e),yield e.sdkInitPromise}catch(r){throw console.error(r),r}return e.sdkInitPromise}))})(this)}))}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return typeof window<"u"&&!!(!((e=window.ethereum)===null||e===void 0)&&e.isMetaMask)}connect(){return _e(this,void 0,void 0,(function*(){return(function(e){return _e(this,void 0,void 0,(function*(){if(e._initialized||(ve("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),ve(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=e.activeProvider.getSelectedAddress();return n?[n]:e.activeProvider.request({method:ct.ETH_REQUESTACCOUNTS,params:[]})}))})(this)}))}connectAndSign({msg:e}){return _e(this,void 0,void 0,(function*(){return D8({instance:this,msg:e})}))}connectWith(e){return _e(this,void 0,void 0,(function*(){return(function({instance:n,rpc:r}){return _e(this,void 0,void 0,(function*(){if(n._initialized||(ve("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield n.init()),ve(`[MetaMaskSDK: connectWith()] method: ${r.method} rpc=${r}`),!n.activeProvider)throw new Error("SDK state invalid -- undefined provider");return n.activeProvider.request({method:ct.METAMASK_CONNECTWITH,params:[r]})}))})({instance:this,rpc:e})}))}resume(){return(function(e){var n,r,i;return _e(this,void 0,void 0,(function*(){if(!(!((r=(n=e.remoteConnection)===null||n===void 0?void 0:n.getConnector())===null||r===void 0)&&r.isReady()))return ve("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void((i=e.remoteConnection)===null||i===void 0||i.startConnection());ve("[MetaMaskSDK: resume()] channel is ready")}))})(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;(e=this.remoteConnection)===null||e===void 0||e.isAuthorized()}terminate(){return(function(e){var n,r,i;return _e(this,void 0,void 0,(function*(){if(!(!((n=e.platformManager)===null||n===void 0)&&n.isMetaMaskMobileWebView())){if(k8&&(window.localStorage.removeItem(nf),window.localStorage.removeItem(im),window.localStorage.removeItem(rm)),e.extensionActive){try{yield(r=e.activeProvider)===null||r===void 0?void 0:r.request({method:ct.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(s){ve("[MetaMaskSDK: terminate()] error revoking permissions",s)}return e.options.extensionOnly?(e.emit(Br.ProviderUpdate,Gi.TERMINATE),void ve("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(Br.ProviderUpdate,Gi.TERMINATE))}e.emit(Br.ProviderUpdate,Gi.TERMINATE),ve(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),(i=e.remoteConnection)===null||i===void 0||i.disconnect({terminate:!0,sendMessage:!0})}}))})(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getUniversalLink();if(!n)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return n}getChannelId(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getChannelConfig())===null||n===void 0?void 0:n.channelId}getRPCHistory(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getRPCMethodTracker()}getVersion(){return sa.version}getDappId(){var e,n,r,i;return typeof window>"u"||window.location===void 0?(i=(n=(e=this.options.dappMetadata)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:(r=this.options.dappMetadata)===null||r===void 0?void 0:r.url)!==null&&i!==void 0?i:"N/A":window.location.hostname}getAnonId(){var e,n;return _e(this,void 0,void 0,(function*(){if(this._anonId)return this._anonId;let r;return r=!((e=this.platformManager)===null||e===void 0)&&e.isBrowser()?this.getBrowserAnonId():!((n=this.platformManager)===null||n===void 0)&&n.isReactNative()?yield this.getReactNativeAnonId():hs(),this._anonId=r,r}))}getBrowserAnonId(){const e=this.ANON_ID_STORAGE_KEY;try{const n=localStorage.getItem(e);if(n)return n;const r=hs();return localStorage.setItem(e,r),r}catch(n){return console.error("[MetaMaskSDK: getBrowserAnonId()] LocalStorage access error:",n),hs()}}getReactNativeAnonId(){return _e(this,void 0,void 0,(function*(){const e=this.ANON_ID_STORAGE_KEY;try{const n=require("@react-native-async-storage/async-storage").default,r=yield n.getItem(e);if(r)return r;const i=hs();return yield n.setItem(e,i),i}catch(n){return console.error("[MetaMaskSDK: getReactNativeAnonId()] Error accessing AsyncStorage:",n),hs()}}))}getWalletStatus(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getConnectionStatus()}_getChannelConfig(){var e;return(e=this.remoteConnection)===null||e===void 0?void 0:e.getChannelConfig()}_ping(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.ping()}_keyCheck(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.keyCheck()}_getServiceStatus(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return(e=this.remoteConnection)===null||e===void 0?void 0:e.getKeyInfo()}_resetKeys(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,n){return super.emit(e,n)}on(e,n){return super.on(e,n)}}var ok=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:t}={enabled:!1}){this.enabled=!1,this.enabled=t}persistChannelConfig(t){return _e(this,void 0,void 0,(function*(){const e=JSON.stringify(t);ve(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,t),localStorage.setItem(vp,e)}))}getPersistedChannelConfig(){return _e(this,void 0,void 0,(function*(){let t;try{if(ve(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),t=localStorage.getItem(vp),ve("[StorageManagerWeb: getPersistedChannelConfig()]",t),!t)return;const e=JSON.parse(t);return ve("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",e),e}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}}))}persistAccounts(t){return _e(this,void 0,void 0,(function*(){ve(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,t);const e=JSON.stringify(t);localStorage.setItem(rm,e)}))}getCachedAccounts(){return _e(this,void 0,void 0,(function*(){try{const t=localStorage.getItem(rm);return t?JSON.parse(t):[]}catch(t){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",t),t}}))}persistChainId(t){return _e(this,void 0,void 0,(function*(){ve(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,t),localStorage.setItem(im,t)}))}getCachedChainId(){return _e(this,void 0,void 0,(function*(){try{const t=localStorage.getItem(im);return t??void 0}catch(t){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",t),t}}))}terminate(){return _e(this,void 0,void 0,(function*(){ve(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(vp)}))}}});const ak="hydrated",ck=!1,lk=!0;var uk=Object.defineProperty,Gg=new WeakMap,oo=t=>Gg.get(t),Yg=(t,e)=>Gg.set(e.$lazyInstance$=t,e),fE=(t,e)=>e in t,Ho=(t,e)=>(0,console.error)(t,e),Ep=new Map,vd=new Map,UA="slot-fb{display:contents}slot-fb[hidden]{display:none}",jf=typeof window<"u"?window:{},Hi=jf.document||{head:{}},Zn={$flags$:0,$resourcesUrl$:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,r)=>t.addEventListener(e,n,r),rel:(t,e,n,r)=>t.removeEventListener(e,n,r),ce:(t,e)=>new CustomEvent(t,e)},$A=(()=>{try{return new CSSStyleSheet,typeof new CSSStyleSheet().replaceSync=="function"}catch{}return!1})(),om=!1,hE=[],FA=[],dk=(t,e)=>n=>{t.push(n),om||(om=!0,4&Zn.$flags$?Jg(am):Zn.raf(am))},pE=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(n){Ho(n)}t.length=0},am=()=>{pE(hE),pE(FA),(om=hE.length>0)&&Zn.raf(am)},Jg=t=>(e=>Promise.resolve(e))().then(t),fk=dk(FA),mE={},Zg=t=>(t=typeof t)=="object"||t==="function";function KA(t){var e,n,r;return(r=(n=(e=t.head)==null?void 0:e.querySelector('meta[name="csp-nonce"]'))==null?void 0:n.getAttribute("content"))!=null?r:void 0}((t,e)=>{for(var n in e)uk(t,n,{get:e[n],enumerable:!0})})({},{err:()=>VA,map:()=>hk,ok:()=>cm,unwrap:()=>pk,unwrapErr:()=>mk});var cm=t=>({isOk:!0,isErr:!1,value:t}),VA=t=>({isOk:!1,isErr:!0,value:t});function hk(t,e){if(t.isOk){const n=e(t.value);return n instanceof Promise?n.then((r=>cm(r))):cm(n)}if(t.isErr){const n=t.value;return VA(n)}throw"should never get here"}var Xg,pk=t=>{if(t.isOk)return t.value;throw t.value},mk=t=>{if(t.isErr)return t.value;throw t.value},be=(t,e,...n)=>{let r=null,i=!1,s=!1;const o=[],a=l=>{for(let u=0;u<l.length;u++)r=l[u],Array.isArray(r)?a(r):r!=null&&typeof r!="boolean"&&((i=typeof t!="function"&&!Zg(r))&&(r=String(r)),i&&s?o[o.length-1].$text$+=r:o.push(i?of(null,r):r),s=i)};if(a(n),e){const l=e.className||e.class;l&&(e.class=typeof l!="object"?l:Object.keys(l).filter((u=>l[u])).join(" "))}if(typeof t=="function")return t(e===null?{}:e,o,yk);const c=of(t,null);return c.$attrs$=e,o.length>0&&(c.$children$=o),c},of=(t,e)=>({$flags$:0,$tag$:t,$text$:e,$elm$:null,$children$:null,$attrs$:null}),gk={},yk={forEach:(t,e)=>t.map(gE).forEach(e),map:(t,e)=>t.map(gE).map(e).map(wk)},gE=t=>({vattrs:t.$attrs$,vchildren:t.$children$,vkey:t.$key$,vname:t.$name$,vtag:t.$tag$,vtext:t.$text$}),wk=t=>{if(typeof t.vtag=="function"){const n={...t.vattrs};return t.vkey&&(n.key=t.vkey),t.vname&&(n.name=t.vname),be(t.vtag,n,...t.vchildren||[])}const e=of(t.vtag,t.vtext);return e.$attrs$=t.vattrs,e.$children$=t.vchildren,e.$key$=t.vkey,e.$name$=t.vname,e},Hf=t=>oo(t).$hostElement$,lo=(t,e,n)=>{const r=Hf(t);return{emit:i=>jA(r,e,{bubbles:!0,composed:!0,cancelable:!0,detail:i})}},jA=(t,e,n)=>{const r=Zn.ce(e,n);return t.dispatchEvent(r),r},yE=new WeakMap,vk=t=>{const e=t.$cmpMeta$,n=t.$hostElement$,r=e.$flags$;e.$tagName$;const i=((s,o,a)=>{var c;const l=HA(o),u=vd.get(l);if(s=s.nodeType===11?s:Hi,u)if(typeof u=="string"){s=s.head||s;let d,f=yE.get(s);if(f||yE.set(s,f=new Set),!f.has(l)){{d=Hi.createElement("style"),d.innerHTML=u;const g=(c=Zn.$nonce$)!=null?c:KA(Hi);if(g!=null&&d.setAttribute("nonce",g),!(1&o.$flags$))if(s.nodeName==="HEAD"){const v=s.querySelectorAll("link[rel=preconnect]"),w=v.length>0?v[v.length-1].nextSibling:s.querySelector("style");s.insertBefore(d,w)}else if("host"in s)if($A){const v=new CSSStyleSheet;v.replaceSync(u),s.adoptedStyleSheets=[v,...s.adoptedStyleSheets]}else{const v=s.querySelector("style");v?v.innerHTML=u+v.innerHTML:s.prepend(d)}else s.append(d);1&o.$flags$&&s.nodeName!=="HEAD"&&s.insertBefore(d,null)}4&o.$flags$&&(d.innerHTML+=UA),f&&f.add(l)}}else s.adoptedStyleSheets.includes(u)||(s.adoptedStyleSheets=[...s.adoptedStyleSheets,u]);return l})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))},HA=(t,e)=>"sc-"+t.$tagName$,wE=(t,e,n,r,i,s)=>{if(n!==r){let o=fE(t,e),a=e.toLowerCase();if(e==="class"){const c=t.classList,l=vE(n),u=vE(r);c.remove(...l.filter((d=>d&&!u.includes(d)))),c.add(...u.filter((d=>d&&!l.includes(d))))}else if(e==="style"){for(const c in n)r&&r[c]!=null||(c.includes("-")?t.style.removeProperty(c):t.style[c]="");for(const c in r)n&&r[c]===n[c]||(c.includes("-")?t.style.setProperty(c,r[c]):t.style[c]=r[c])}else if(o||e[0]!=="o"||e[1]!=="n"){const c=Zg(r);if((o||c&&r!==null)&&!i)try{if(t.tagName.includes("-"))t[e]=r;else{const l=r??"";e==="list"?o=!1:n!=null&&t[e]==l||(typeof t.__lookupSetter__(e)=="function"?t[e]=l:t.setAttribute(e,l))}}catch{}r==null||r===!1?r===!1&&t.getAttribute(e)!==""||t.removeAttribute(e):(!o||4&s||i)&&!c&&(r=r===!0?"":r,t.setAttribute(e,r))}else if(e=e[2]==="-"?e.slice(3):fE(jf,a)?a.slice(2):a[2]+e.slice(3),n||r){const c=e.endsWith(zA);e=e.replace(bk,""),n&&Zn.rel(t,e,n,c),r&&Zn.ael(t,e,r,c)}}},Ek=/\s/,vE=t=>t?t.split(Ek):[],zA="Capture",bk=new RegExp(zA+"$"),qA=(t,e,n)=>{const r=e.$elm$.nodeType===11&&e.$elm$.host?e.$elm$.host:e.$elm$,i=t&&t.$attrs$||mE,s=e.$attrs$||mE;for(const o of EE(Object.keys(i)))o in s||wE(r,o,i[o],void 0,n,e.$flags$);for(const o of EE(Object.keys(s)))wE(r,o,i[o],s[o],n,e.$flags$)};function EE(t){return t.includes("ref")?[...t.filter((e=>e!=="ref")),"ref"]:t}var ci=!1,Qg=(t,e,n,r)=>{const i=e.$children$[n];let s,o,a=0;if(i.$text$!==null)s=i.$elm$=Hi.createTextNode(i.$text$);else{if(ci||(ci=i.$tag$==="svg"),s=i.$elm$=Hi.createElementNS(ci?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),ci&&i.$tag$==="foreignObject"&&(ci=!1),qA(null,i,ci),s.getRootNode().querySelector("body"),i.$children$)for(a=0;a<i.$children$.length;++a)o=Qg(t,i,a),o&&s.appendChild(o);i.$tag$==="svg"?ci=!1:s.tagName==="foreignObject"&&(ci=!0)}return s["s-hn"]=Xg,s},bE=(t,e,n,r,i,s)=>{let o,a=t;for(a.shadowRoot&&a.tagName===Xg&&(a=a.shadowRoot);i<=s;++i)r[i]&&(o=Qg(null,n,i),o&&(r[i].$elm$=o,Ed(a,o,e)))},_E=(t,e,n)=>{for(let r=e;r<=n;++r){const i=t[r];if(i){const s=i.$elm$;s&&s.remove()}}},Bu=(t,e,n=!1)=>t.$tag$===e.$tag$,Jc=(t,e,n=!1)=>{const r=e.$elm$=t.$elm$,i=t.$children$,s=e.$children$,o=e.$tag$,a=e.$text$;a===null?(qA(t,e,ci=o==="svg"||o!=="foreignObject"&&ci),i!==null&&s!==null?((c,l,u,d,f=!1)=>{let g,v=0,w=0,b=l.length-1,E=l[0],M=l[b],S=d.length-1,F=d[0],D=d[S];for(;v<=b&&w<=S;)E==null?E=l[++v]:M==null?M=l[--b]:F==null?F=d[++w]:D==null?D=d[--S]:Bu(E,F,f)?(Jc(E,F,f),E=l[++v],F=d[++w]):Bu(M,D,f)?(Jc(M,D,f),M=l[--b],D=d[--S]):Bu(E,D,f)?(Jc(E,D,f),Ed(c,E.$elm$,M.$elm$.nextSibling),E=l[++v],D=d[--S]):Bu(M,F,f)?(Jc(M,F,f),Ed(c,M.$elm$,E.$elm$),M=l[--b],F=d[++w]):(g=Qg(l&&l[w],u,w),F=d[++w],g&&Ed(E.$elm$.parentNode,g,E.$elm$));v>b?bE(c,d[S+1]==null?null:d[S+1].$elm$,u,d,w,S):w>S&&_E(l,v,b)})(r,i,e,s,n):s!==null?(t.$text$!==null&&(r.textContent=""),bE(r,null,e,s,0,s.length-1)):!n&&lk&&i!==null&&_E(i,0,i.length-1),ci&&o==="svg"&&(ci=!1)):t.$text$!==a&&(r.data=a)},Ed=(t,e,n)=>t?.insertBefore(e,n),_k=(t,e,n=!1)=>{const r=t.$hostElement$,i=t.$cmpMeta$,s=t.$vnode$||of(null,null),o=(a=e)&&a.$tag$===gk?e:be(null,null,e);var a;if(Xg=r.tagName,n&&o.$attrs$)for(const c of Object.keys(o.$attrs$))r.hasAttribute(c)&&!["key","ref","style","class"].includes(c)&&(o.$attrs$[c]=r[c]);o.$tag$=null,o.$flags$|=4,t.$vnode$=o,o.$elm$=s.$elm$=r.shadowRoot||r,r["s-sc"],1&i.$flags$,Jc(s,o,n)},WA=(t,e)=>{e&&!t.$onRenderResolve$&&e["s-p"]&&e["s-p"].push(new Promise((n=>t.$onRenderResolve$=n)))},ey=(t,e)=>(t.$flags$|=16,4&t.$flags$?void(t.$flags$|=512):(WA(t,t.$ancestorComponent$),fk((()=>Sk(t,e))))),Sk=(t,e)=>{const n=t.$hostElement$;t.$cmpMeta$.$tagName$;const r=t.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return xk(void 0,(()=>Rk(t,r,e)))},xk=(t,e)=>Ak(t)?t.then(e).catch((n=>{console.error(n),e()})):e(),Ak=t=>t instanceof Promise||t&&t.then&&typeof t.then=="function",Rk=async(t,e,n)=>{var r;const i=t.$hostElement$;t.$cmpMeta$.$tagName$;const s=i["s-rc"];n&&vk(t),t.$cmpMeta$.$tagName$,Ik(t,e,i,n),s&&(s.map((o=>o())),i["s-rc"]=void 0);{const o=(r=i["s-p"])!=null?r:[],a=()=>Tk(t);o.length===0?a():(Promise.all(o).then(a),t.$flags$|=4,o.length=0)}},Ik=(t,e,n,r)=>{try{e=e.render(),t.$flags$&=-17,t.$flags$|=2,_k(t,e,r)}catch(i){Ho(i,t.$hostElement$)}return null},Tk=t=>{t.$cmpMeta$.$tagName$;const e=t.$hostElement$,n=()=>{},r=t.$lazyInstance$,i=t.$ancestorComponent$;64&t.$flags$?n():(t.$flags$|=64,YA(e),ty(r,"componentDidLoad"),t.$onReadyResolve$(e),i||GA()),t.$onRenderResolve$&&(t.$onRenderResolve$(),t.$onRenderResolve$=void 0),512&t.$flags$&&Jg((()=>ey(t,!1))),t.$flags$&=-517},GA=t=>{YA(Hi.documentElement),Jg((()=>jA(jf,"appload",{detail:{namespace:"sdk-install-modal-web"}})))},ty=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(r){Ho(r)}},YA=t=>{var e;return t.classList.add((e=ak)!=null?e:"hydrated")},Ck=(t,e,n,r)=>{const i=oo(t);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const s=i.$hostElement$,o=i.$instanceValues$.get(e),a=i.$flags$,c=i.$lazyInstance$;var l,u;l=n,u=r.$members$[e][0],n=l==null||Zg(l)?l:4&u?l!=="false"&&(l===""||!!l):1&u?String(l):l;const d=Number.isNaN(o)&&Number.isNaN(n);if((!(8&a)||o===void 0)&&n!==o&&!d&&(i.$instanceValues$.set(e,n),c)){if(r.$watchers$&&128&a){const f=r.$watchers$[e];f&&f.map((g=>{try{c[g](n,o,e)}catch(v){Ho(v,s)}}))}(18&a)==2&&ey(i,!1)}},JA=(t,e,n)=>{var r,i;const s=t.prototype;if(e.$members$||e.$watchers$||t.watchers){t.watchers&&!e.$watchers$&&(e.$watchers$=t.watchers);const o=Object.entries((r=e.$members$)!=null?r:{});if(o.map((([a,[c]])=>{(31&c||2&n&&32&c)&&Object.defineProperty(s,a,{get(){return l=a,oo(this).$instanceValues$.get(l);var l},set(l){Ck(this,a,l,e)},configurable:!0,enumerable:!0})})),1&n){const a=new Map;s.attributeChangedCallback=function(c,l,u){Zn.jmp((()=>{var d;const f=a.get(c);if(this.hasOwnProperty(f))u=this[f],delete this[f];else{if(s.hasOwnProperty(f)&&typeof this[f]=="number"&&this[f]==u)return;if(f==null){const g=oo(this),v=g?.$flags$;if(v&&!(8&v)&&128&v&&u!==l){const w=g.$lazyInstance$,b=(d=e.$watchers$)==null?void 0:d[c];b?.forEach((E=>{w[E]!=null&&w[E].call(w,u,l,c)}))}return}}this[f]=(u!==null||typeof this[f]!="boolean")&&u}))},t.observedAttributes=Array.from(new Set([...Object.keys((i=e.$watchers$)!=null?i:{}),...o.filter((([c,l])=>15&l[0])).map((([c,l])=>{const u=l[1]||c;return a.set(u,c),u}))]))}}return t},Ok=async(t,e,n,r)=>{let i;if((32&e.$flags$)==0){if(e.$flags$|=32,n.$lazyBundleId$){const a=((c,l,u)=>{const d=c.$tagName$.replace(/-/g,"_"),f=c.$lazyBundleId$;if(!f)return;const g=Ep.get(f);if(g)return g[d];{const v=w=>(Ep.set(f,w),w[d]);if(f==="mm-install-modal_3")return Promise.resolve().then((function(){return zk})).then(v,Ho)}return import(`./${f}.entry.js`).then((v=>(Ep.set(f,v),v[d])),Ho)})(n);if(a&&"then"in a?i=await a:i=a,!i)throw new Error(`Constructor for "${n.$tagName$}#${e.$modeName$}" was not found`);i.isProxied||(n.$watchers$=i.watchers,JA(i,n,2),i.isProxied=!0),n.$tagName$,e.$flags$|=8;try{new i(e)}catch(c){Ho(c)}e.$flags$&=-9,e.$flags$|=128,lm(e.$lazyInstance$)}else{i=t.constructor;const a=t.localName;customElements.whenDefined(a).then((()=>e.$flags$|=128))}if(i&&i.style){let a;typeof i.style=="string"&&(a=i.style);const c=HA(n);vd.has(c)||(n.$tagName$,((l,u,d)=>{let f=vd.get(l);$A&&d?(f=f||new CSSStyleSheet,typeof f=="string"?f=u:f.replaceSync(u)):f=u,vd.set(l,f)})(c,a,!!(1&n.$flags$)))}}const s=e.$ancestorComponent$,o=()=>ey(e,!0);s&&s["s-rc"]?s["s-rc"].push(o):o()},lm=t=>{ty(t,"connectedCallback")},SE=t=>{ty(t,"disconnectedCallback")},Nk=(t,e={})=>{var n;const r=[],i=e.exclude||[],s=jf.customElements,o=Hi.head,a=o.querySelector("meta[charset]"),c=Hi.createElement("style"),l=[];let u,d=!0;Object.assign(Zn,e),Zn.$resourcesUrl$=new URL(e.resourcesUrl||"./",Hi.baseURI).href;let f=!1;if(t.map((g=>{g[1].map((v=>{var w;const b={$flags$:v[0],$tagName$:v[1],$members$:v[2],$listeners$:v[3]};4&b.$flags$&&(f=!0),b.$members$=v[2],b.$watchers$=(w=v[4])!=null?w:{};const E=b.$tagName$,M=class extends HTMLElement{constructor(S){if(super(S),this.hasRegisteredEventListeners=!1,((F,D)=>{const z={$flags$:0,$hostElement$:F,$cmpMeta$:D,$instanceValues$:new Map};z.$onReadyPromise$=new Promise((X=>z.$onReadyResolve$=X)),F["s-p"]=[],F["s-rc"]=[],Gg.set(F,z)})(S=this,b),1&b.$flags$)if(S.shadowRoot){if(S.shadowRoot.mode!=="open")throw new Error(`Unable to re-use existing shadow root for ${b.$tagName$}! Mode is set to ${S.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else S.attachShadow({mode:"open"})}connectedCallback(){oo(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),u&&(clearTimeout(u),u=null),d?l.push(this):Zn.jmp((()=>(S=>{if((1&Zn.$flags$)==0){const F=oo(S),D=F.$cmpMeta$;if(D.$tagName$,1&F.$flags$)F?.$lazyInstance$?lm(F.$lazyInstance$):F?.$onReadyPromise$&&F.$onReadyPromise$.then((()=>lm(F.$lazyInstance$)));else{F.$flags$|=1;{let z=S;for(;z=z.parentNode||z.host;)if(z["s-p"]){WA(F,F.$ancestorComponent$=z);break}}D.$members$&&Object.entries(D.$members$).map((([z,[X]])=>{if(31&X&&S.hasOwnProperty(z)){const Y=S[z];delete S[z],S[z]=Y}})),Ok(S,F,D)}}})(this)))}disconnectedCallback(){Zn.jmp((()=>(async S=>{if((1&Zn.$flags$)==0){const F=oo(S);F?.$lazyInstance$?SE(F.$lazyInstance$):F?.$onReadyPromise$&&F.$onReadyPromise$.then((()=>SE(F.$lazyInstance$)))}})(this)))}componentOnReady(){return oo(this).$onReadyPromise$}};b.$lazyBundleId$=g[0],i.includes(E)||s.get(E)||(r.push(E),s.define(E,JA(M,b,1)))}))})),r.length>0&&(f&&(c.textContent+=UA),c.textContent+=r.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const g=(n=Zn.$nonce$)!=null?n:KA(Hi);g!=null&&c.setAttribute("nonce",g),o.insertBefore(c,a?a.nextSibling:o.firstChild)}d=!1,l.length?l.map((g=>g.connectedCallback())):Zn.jmp((()=>u=setTimeout(GA,30)))};(function(){if(typeof window<"u"&&window.Reflect!==void 0&&window.customElements!==void 0){var t=HTMLElement;window.HTMLElement=function(){return Reflect.construct(t,[],this.constructor)},HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}})();var Pk=Object.freeze({__proto__:null,defineCustomElements:async(t,e)=>{if(typeof window<"u")return await void 0,Nk([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],e)},setNonce:t=>Zn.$nonce$=t});const Mk={fontFamily:"Roboto, sans-serif"},ny=({className:t},e)=>be("div",{style:Mk,class:t},e),bp=({Icon:t,text:e})=>be("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},be("div",{class:"flexItem1"},be(t,null)),be("div",{class:"flexItem11"},be("span",{style:{lineHeight:"2",color:"black"}},e))),kk=()=>be("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),be("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Dk=()=>be("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),Lk=()=>be("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),Bk=()=>be("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),be("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),be("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function ry({version:t}){return be("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",t?`v${t}`:"unknown")}const iy=()=>be("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("rect",{width:"16",height:"16",fill:"white"}),be("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),sy=()=>be("svg",{width:"120",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 127 63"},be("path",{fill:"currentColor",d:"M71.554 48.607v13.81h-7.072v-9.568l-8.059.945c-1.77.205-2.548.79-2.548 1.864 0 1.575 1.478 2.239 4.648 2.239 1.932 0 4.073-.29 5.963-.79l-3.66 5.225c-1.479.332-2.92.496-4.44.496-6.414 0-10.074-2.57-10.074-7.132 0-4.023 2.877-6.136 9.416-6.884l8.638-1.012c-.467-2.532-2.362-3.633-6.13-3.633-3.537 0-7.443.912-10.937 2.613l1.111-6.18c3.248-1.369 6.95-2.074 10.69-2.074 8.226 0 12.461 3.444 12.461 10.075l-.008.005ZM7.938 31.315.208 62.416h7.73l3.836-15.628 6.65 8.039h8.06l6.65-8.039 3.836 15.628h7.73l-7.73-31.105-14.518 17.388L7.934 31.311l.004.004ZM36.97.21 22.452 17.598 7.938.21.208 31.315h7.73l3.836-15.628 6.65 8.039h8.06l6.65-8.039 3.836 15.628h7.73L36.97.21Zm53.17 48.107-6.25-.912c-1.562-.247-2.178-.747-2.178-1.617 0-1.41 1.52-2.032 4.647-2.032 3.62 0 6.868.747 10.283 2.364l-.862-6.094c-2.757-.995-5.922-1.491-9.212-1.491-7.688 0-11.886 2.696-11.886 7.547 0 3.776 2.303 5.889 7.196 6.636l6.335.954c1.603.248 2.261.87 2.261 1.865 0 1.41-1.478 2.074-4.481 2.074-3.948 0-8.225-.953-11.72-2.654l.7 6.094c3.003 1.122 6.91 1.785 10.57 1.785 7.896 0 12.007-2.78 12.007-7.715 0-3.94-2.303-6.057-7.4-6.8l-.01-.004ZM100.3 34.09v28.325h7.071V34.091H100.3Zm15.334 15.595 9.833-10.744h-8.8l-9.296 11.114 9.912 12.356h8.925l-10.574-12.73v.004Zm-16.321-25.09c0 4.56 3.66 7.13 10.074 7.13 1.52 0 2.961-.167 4.44-.495l3.66-5.225c-1.89.496-4.031.79-5.963.79-3.166 0-4.648-.664-4.648-2.239 0-1.079.783-1.659 2.549-1.864l8.058-.945v9.567h7.072v-13.81c0-6.635-4.236-10.075-12.461-10.075-3.744 0-7.442.705-10.691 2.075l-1.112 6.178c3.495-1.701 7.401-2.613 10.937-2.613 3.769 0 5.664 1.1 6.13 3.633l-8.637 1.013c-6.539.747-9.417 2.86-9.417 6.883l.009-.004Zm-19.779-1.492c0 5.725 3.29 8.627 9.787 8.627 2.59 0 4.732-.416 6.785-1.37l.903-6.261c-1.974 1.2-3.99 1.822-6.005 1.822-3.044 0-4.402-1.243-4.402-4.023v-8.295h10.732V7.84H86.601V2.948l-13.448 7.174v3.482h6.372V23.1l.008.004Zm-6.95-2.612v1.411H53.47c.862 2.873 3.423 4.187 7.97 4.187 3.62 0 6.993-.747 9.992-2.196l-.862 6.056c-2.757 1.16-6.251 1.785-9.829 1.785-9.5 0-14.68-4.23-14.68-12.066 0-7.838 5.264-12.235 13.406-12.235s13.119 4.771 13.119 13.062l-.005-.004ZM53.378 17.09h12.086c-.637-2.751-2.732-4.188-6.08-4.188-3.349 0-5.335 1.399-6.006 4.188Z"}));function xo(t,e){return t.toString(2).padStart(e,"0")}function xE(t,e){const n=t%e;return n>=0?n:e+n}function Gr(t,e){return new Array(t).fill(e)}function AE(...t){let e=0;for(const r of t)e=Math.max(e,r.length);const n=[];for(let r=0;r<e;r++)for(const i of t)r>=i.length||n.push(i[r]);return new Uint8Array(n)}function RE(t,e,n){if(n<0||n+e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}function IE(t){return{has:e=>t.includes(e),decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map((n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r}))},encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map((n=>{if((function(r){if(!Number.isSafeInteger(r))throw new Error(`Wrong integer: ${r}`)})(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]}))}}}class qr{static size(e,n){if(typeof e=="number"&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return n!==void 0&&(e={width:Math.min(e.width,n.width),height:Math.min(e.height,n.height)}),e}static fromString(e){const n=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split(`
|
|
42
|
+
`),r=n.length,i=new Array(r);let s;for(const o of n){const a=o.split("").map((c=>{if(c==="X")return!0;if(c===" ")return!1;if(c!=="?")throw new Error(`Bitmap.fromString: unknown symbol=${c}`)}));if(s&&a.length!==s)throw new Error(`Bitmap.fromString different row sizes: width=${s} cur=${a.length}`);s=a.length,i.push(a)}return s||(s=0),new qr({height:r,width:s},i)}constructor(e,n){const{height:r,width:i}=qr.size(e);this.data=n||Array.from({length:r},(()=>Gr(i,void 0))),this.height=r,this.width=i}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:n,y:r}=this.xy(e);return{height:this.height-r,width:this.width-n}}xy(e){if(typeof e=="number"&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=xE(e.x,this.width),e.y=xE(e.y,this.height),e}rect(e,n,r){const{x:i,y:s}=this.xy(e),{height:o,width:a}=qr.size(n,this.size({x:i,y:s}));for(let c=0;c<o;c++)for(let l=0;l<a;l++)this.data[s+c][i+l]=typeof r=="function"?r({x:l,y:c},this.data[s+c][i+l]):r;return this}rectRead(e,n,r){return this.rect(e,n,((i,s)=>(r(i,s),s)))}hLine(e,n,r){return this.rect(e,{width:n,height:1},r)}vLine(e,n,r){return this.rect(e,{width:1,height:n},r)}border(e=2,n){const r=this.height+2*e,i=this.width+2*e,s=Gr(e,n),o=Array.from({length:e},(()=>Gr(i,n)));return new qr({height:r,width:i},[...o,...this.data.map((a=>[...s,...a,...s])),...o])}embed(e,n){return this.rect(e,n.size(),(({x:r,y:i})=>n.data[i][r]))}rectSlice(e,n=this.size()){const r=new qr(qr.size(n,this.size(this.xy(e))));return this.rect(e,n,(({x:i,y:s},o)=>r.data[s][i]=o)),r}inverse(){const{height:e,width:n}=this;return new qr({height:n,width:e}).rect({x:0,y:0},1/0,(({x:r,y:i})=>this.data[r][i]))}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:n,width:r}=this;return new qr({height:e*n,width:e*r}).rect({x:0,y:0},1/0,(({x:i,y:s})=>this.data[Math.floor(s/e)][Math.floor(i/e)]))}clone(){return new qr(this.size()).rect({x:0,y:0},this.size(),(({x:e,y:n})=>this.data[n][e]))}assertDrawn(){this.rectRead(0,1/0,((e,n)=>{if(typeof n!="boolean")throw new Error("Invalid color type="+typeof n)}))}toString(){return this.data.map((e=>e.map((n=>n===void 0?"?":n?"X":" ")).join(""))).join(`
|
|
43
|
+
`)}toASCII(){const{height:e,width:n,data:r}=this;let i="";for(let s=0;s<e;s+=2){for(let o=0;o<n;o++){const a=r[s][o],c=s+1>=e||r[s+1][o];a||c?!a&&c?i+="▀":a&&!c?i+="▄":a&&c&&(i+=" "):i+="█"}i+=`
|
|
44
|
+
`}return i}toTerm(){const e="\x1B[0m",n=`\x1B[1;47m ${e}`,r=`\x1B[40m ${e}`;return this.data.map((i=>i.map((s=>s?r:n)).join(""))).join(`
|
|
45
|
+
`)}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,(({x:n,y:r},i)=>{i&&(e+=`<rect x="${n}" y="${r}" width="1" height="1" />`)})),e+="</svg>",e}toGIF(){const e=a=>[255&a,a>>>8&255],n=[...e(this.width),...e(this.height)],r=[];this.rectRead(0,1/0,((a,c)=>r.push(+(c===!0))));const i=126,s=[71,73,70,56,55,97,...n,246,0,0,255,255,255,...Gr(381,0),44,0,0,0,0,...n,0,7],o=Math.floor(r.length/i);for(let a=0;a<o;a++)s.push(127,128,...r.slice(i*a,i*(a+1)).map((c=>+c)));return s.push(r.length%i+1,128,...r.slice(o*i).map((a=>+a))),s.push(1,129,0,59),new Uint8Array(s)}toImage(e=!1){const{height:n,width:r}=this.size(),i=new Uint8Array(n*r*(e?3:4));let s=0;for(let o=0;o<n;o++)for(let a=0;a<r;a++){const c=this.data[o][a]?0:255;i[s++]=c,i[s++]=c,i[s++]=c,e||(i[s++]=255)}return{height:n,width:r,data:i}}}const TE=["low","medium","quartile","high"],CE=["numeric","alphanumeric","byte","kanji","eci"],Uk=[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],$k={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},Fk={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},yr={size:{encode:t=>21+4*(t-1),decode:t=>(t-17)/4},sizeType:t=>Math.floor((t+7)/17),alignmentPatterns(t){if(t===1)return[];const e=yr.size.encode(t)-6-1,n=e-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const s=[6];for(let o=1;o<r;o++)s.push(e-(r-o)*i);return s.push(e),s},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(t,e){const n=yr.ECCode[t]<<3|e;let r=n;for(let i=0;i<10;i++)r=r<<1^1335*(r>>9);return(n<<10|r)^yr.formatMask},versionBits(t){let e=t;for(let n=0;n<12;n++)e=e<<1^7973*(e>>11);return t<<12|e},alphabet:{numeric:IE("0123456789"),alphanumerc:IE("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(t,e)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]})[e][yr.sizeType(t)],modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(t,e){const n=Uk[t-1],r=$k[e][t-1],i=Fk[e][t-1],s=Math.floor(n/i)-r,o=i-n%i;return{words:r,numBlocks:i,shortBlocks:o,blockLen:s,capacity:8*(n-r*i),total:(r+s)*i+i-o}}},um=[(t,e)=>(t+e)%2==0,(t,e)=>e%2==0,(t,e)=>t%3==0,(t,e)=>(t+e)%3==0,(t,e)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(t,e)=>t*e%2+t*e%3==0,(t,e)=>(t*e%2+t*e%3)%2==0,(t,e)=>((t+e)%2+t*e%3)%2==0],et={tables:(t=>{const e=Gr(256,0),n=Gr(256,0);for(let r=0,i=1;r<256;r++)e[r]=i,n[i]=r,i<<=1,256&i&&(i^=285);return{exp:e,log:n}})(),exp:t=>et.tables.exp[t],log(t){if(t===0)throw new Error(`GF.log: wrong arg=${t}`);return et.tables.log[t]%255},mul:(t,e)=>t===0||e===0?0:et.tables.exp[(et.tables.log[t]+et.tables.log[e])%255],add:(t,e)=>t^e,pow:(t,e)=>et.tables.exp[et.tables.log[t]*e%255],inv(t){if(t===0)throw new Error(`GF.inverse: wrong arg=${t}`);return et.tables.exp[255-et.tables.log[t]]},polynomial(t){if(t.length==0)throw new Error("GF.polymomial: wrong length");if(t[0]!==0)return t;let e=0;for(;e<t.length-1&&t[e]==0;e++);return t.slice(e)},monomial(t,e){if(t<0)throw new Error(`GF.monomial: wrong degree=${t}`);if(e==0)return[0];let n=Gr(t+1,0);return n[0]=e,et.polynomial(n)},degree:t=>t.length-1,coefficient:(t,e)=>t[et.degree(t)-e],mulPoly(t,e){if(t[0]===0||e[0]===0)return[0];const n=Gr(t.length+e.length-1,0);for(let r=0;r<t.length;r++)for(let i=0;i<e.length;i++)n[r+i]=et.add(n[r+i],et.mul(t[r],e[i]));return et.polynomial(n)},mulPolyScalar(t,e){if(e==0)return[0];if(e==1)return t;const n=Gr(t.length,0);for(let r=0;r<t.length;r++)n[r]=et.mul(t[r],e);return et.polynomial(n)},mulPolyMonomial(t,e,n){if(e<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(n==0)return[0];const r=Gr(t.length+e,0);for(let i=0;i<t.length;i++)r[i]=et.mul(t[i],n);return et.polynomial(r)},addPoly(t,e){if(t[0]===0)return e;if(e[0]===0)return t;let n=t,r=e;n.length>r.length&&([n,r]=[r,n]);let i=Gr(r.length,0),s=r.length-n.length,o=r.slice(0,s);for(let a=0;a<o.length;a++)i[a]=o[a];for(let a=s;a<r.length;a++)i[a]=et.add(n[a-s],r[a]);return et.polynomial(i)},remainderPoly(t,e){const n=Array.from(t);for(let r=0;r<t.length-e.length+1;r++){const i=n[r];if(i!==0)for(let s=1;s<e.length;s++)e[s]!==0&&(n[r+s]=et.add(n[r+s],et.mul(e[s],i)))}return n.slice(t.length-e.length+1,n.length)},divisorPoly(t){let e=[1];for(let n=0;n<t;n++)e=et.mulPoly(e,[1,et.pow(2,n)]);return e},evalPoly(t,e){if(e==0)return et.coefficient(t,0);let n=t[0];for(let r=1;r<t.length;r++)n=et.add(et.mul(e,n),t[r]);return n},euclidian(t,e,n){et.degree(t)<et.degree(e)&&([t,e]=[e,t]);let r=t,i=e,s=[0],o=[1];for(;2*et.degree(i)>=n;){let l=r,u=s;if(r=i,s=o,r[0]===0)throw new Error("rLast[0] === 0");i=l;let d=[0];const f=et.inv(r[0]);for(;et.degree(i)>=et.degree(r)&&i[0]!==0;){const g=et.degree(i)-et.degree(r),v=et.mul(i[0],f);d=et.addPoly(d,et.monomial(g,v)),i=et.addPoly(i,et.mulPolyMonomial(r,g,v))}if(d=et.mulPoly(d,s),o=et.addPoly(d,u),et.degree(i)>=et.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const a=et.coefficient(o,0);if(a==0)throw new Error("sigmaTilde(0) was zero");const c=et.inv(a);return[et.mulPolyScalar(o,c),et.mulPolyScalar(i,c)]}};function Kk(t,e){const{words:n,shortBlocks:r,numBlocks:i,blockLen:s,total:o}=yr.capacity(t,e),a=(c=n,{encode(l){const u=et.divisorPoly(c),d=Array.from(l);return d.push(...u.slice(0,-1).fill(0)),Uint8Array.from(et.remainderPoly(d,u))},decode(l){const u=l.slice(),d=et.polynomial(Array.from(l));let f=Gr(c,0),g=!1;for(let S=0;S<c;S++){const F=et.evalPoly(d,et.exp(S));f[f.length-1-S]=F,F!==0&&(g=!0)}if(!g)return u;f=et.polynomial(f);const v=et.monomial(c,1),[w,b]=et.euclidian(v,f,c),E=Gr(et.degree(w),0);let M=0;for(let S=1;S<256&&M<E.length;S++)et.evalPoly(w,S)===0&&(E[M++]=et.inv(S));if(M!==E.length)throw new Error("RS.decode: wrong errors number");for(let S=0;S<E.length;S++){const F=u.length-1-et.log(E[S]);if(F<0)throw new Error("RS.decode: wrong error location");const D=et.inv(E[S]);let z=1;for(let X=0;X<E.length;X++)S!==X&&(z=et.mul(z,et.add(1,et.mul(E[X],D))));u[F]=et.add(u[F],et.mul(et.evalPoly(b,D),et.inv(z)))}return u}});var c;return{encode(l){const u=[],d=[];for(let w=0;w<i;w++){const b=s+(w<r?0:1);u.push(l.subarray(0,b)),d.push(a.encode(l.subarray(0,b))),l=l.subarray(b)}const f=AE(...u),g=AE(...d),v=new Uint8Array(f.length+g.length);return v.set(f),v.set(g,f.length),v},decode(l){if(l.length!==o)throw new Error(`interleave.decode: len(data)=${l.length}, total=${o}`);const u=[];for(let g=0;g<i;g++){const v=g<r;u.push(new Uint8Array(n+s+(v?0:1)))}let d=0;for(let g=0;g<s;g++)for(let v=0;v<i;v++)u[v][g]=l[d++];for(let g=r;g<i;g++)u[g][s]=l[d++];for(let g=s;g<s+n;g++)for(let v=0;v<i;v++){const w=v<r;u[v][g+(w?0:1)]=l[d++]}const f=[];for(const g of u)f.push(...Array.from(a.decode(g)).slice(0,-n));return Uint8Array.from(f)}}}function OE(t,e,n,r){let i="",s=n.length;if(r==="numeric"){const d=yr.alphabet.numeric.decode(n.split("")),f=d.length;for(let g=0;g<f-2;g+=3)i+=xo(100*d[g]+10*d[g+1]+d[g+2],10);f%3==1?i+=xo(d[f-1],4):f%3==2&&(i+=xo(10*d[f-2]+d[f-1],7))}else if(r==="alphanumeric"){const d=yr.alphabet.alphanumerc.decode(n.split("")),f=d.length;for(let g=0;g<f-1;g+=2)i+=xo(45*d[g]+d[g+1],11);f%2==1&&(i+=xo(d[f-1],6))}else{if(r!=="byte")throw new Error("encode: unsupported type");{const d=(function(f){if(typeof f!="string")throw new Error("utf8ToBytes expected string, got "+typeof f);return new Uint8Array(new TextEncoder().encode(f))})(n);s=d.length,i=Array.from(d).map((f=>xo(f,8))).join("")}}const{capacity:o}=yr.capacity(t,e),a=xo(s,yr.lengthBits(t,r));let c=yr.modeBits[r]+a+i;if(c.length>o)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,o-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));const l="1110110000010001";for(let d=0;c.length!==o;d++)c+=l[d%16];const u=Uint8Array.from(c.match(/(.{8})/g).map((d=>+`0b${d}`)));return Kk(t,e).encode(u)}function NE(t,e,n,r,i=!1){const s=(function(c,l,u,d=!1){const f=yr.size.encode(c);let g=new qr(f+2);const v=new qr(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);g=g.embed(0,v).embed({x:-v.width,y:0},v).embed({x:0,y:-v.height},v),g=g.rectSlice(1,f);const w=new qr(1).rect(0,1,!0).border(1,!1).border(1,!0),b=yr.alignmentPatterns(c);for(const E of b)for(const M of b)g.data[E][M]===void 0&&g.embed({x:M-2,y:E-2},w);g=g.hLine({x:0,y:6},1/0,(({x:E},M)=>M===void 0?E%2==0:M)).vLine({x:6,y:0},1/0,(({y:E},M)=>M===void 0?E%2==0:M));{const E=yr.formatBits(l,u),M=S=>!d&&(E>>S&1)==1;for(let S=0;S<6;S++)g.data[S][8]=M(S);for(let S=6;S<8;S++)g.data[S+1][8]=M(S);for(let S=8;S<15;S++)g.data[f-15+S][8]=M(S);for(let S=0;S<8;S++)g.data[8][f-S-1]=M(S);for(let S=8;S<9;S++)g.data[8][15-S-1+1]=M(S);for(let S=9;S<15;S++)g.data[8][15-S-1]=M(S);g.data[f-8][8]=!d}if(c>=7){const E=yr.versionBits(c);for(let M=0;M<18;M+=1){const S=!d&&(E>>M&1)==1,F=Math.floor(M/3),D=M%3+f-8-3;g.data[F][D]=S,g.data[D][F]=S}}return g})(t,e,r,i);let o=0;const a=8*n.length;if((function(c,l,u){const d=c.height,f=um[l];let g=-1,v=d-1;for(let w=d-1;w>0;w-=2){for(w==6&&(w=5);;v+=g){for(let b=0;b<2;b+=1){const E=w-b;c.data[v][E]===void 0&&u(E,v,f(E,v))}if(v+g<0||v+g>=d)break}g=-g}})(s,r,((c,l,u)=>{let d=!1;o<a&&(d=(n[o>>>3]>>(7-o&7)&1)!=0,o++),s.data[l][c]=d!==u})),o!==a)throw new Error("QR: bytes left after draw");return s}function Vk(t){const e=t.inverse(),n=g=>{let v=0;for(let w,b=0,E=1;b<g.length;b++)w===g[b]&&(E++,b!==g.length-1)||(E>=5&&(v+=E-5+3),w=g[b],E=1);return v};let r=0;t.data.forEach((g=>r+=n(g))),e.data.forEach((g=>r+=n(g)));let i=0,s=t.data;const o=t.width-1,a=t.height-1;for(let g=0;g<o;g++)for(let v=0;v<a;v++){const w=g+1,b=v+1;s[g][v]===s[w][v]&&s[w][v]===s[g][b]&&s[w][v]===s[w][b]&&(i+=3)}const c=g=>{const v=[!0,!1,!0,!0,!0,!1,!0],w=[!1,!1,!1,!1],b=[...v,...w],E=[...w,...v];let M=0;for(let S=0;S<g.length;S++)RE(g,b,S)&&(M+=40),RE(g,E,S)&&(M+=40);return M};let l=0;for(const g of t.data)l+=c(g);for(const g of e.data)l+=c(g);let u=0;t.rectRead(0,1/0,((g,v)=>u+=v?1:0));const d=u/(t.height*t.width)*100,f=10*Math.floor(Math.abs(d-50)/5);return r+i+l+f}function ZA(t,e="raw",n={}){const r=n.ecc!==void 0?n.ecc:"medium";(function(u){if(!TE.includes(u))throw new Error(`Invalid error correction mode=${u}. Expected: ${TE}`)})(r);const i=n.encoding!==void 0?n.encoding:(function(u){let d="numeric";for(let f of u)if(!yr.alphabet.numeric.has(f)&&(d="alphanumeric",!yr.alphabet.alphanumerc.has(f)))return"byte";return d})(t);(function(u){if(!CE.includes(u))throw new Error(`Encoding: invalid mode=${u}. Expected: ${CE}`);if(u==="kanji"||u==="eci")throw new Error(`Encoding: ${u} is not supported (yet?).`)})(i),n.mask!==void 0&&(function(u){if(![0,1,2,3,4,5,6,7].includes(u)||!um[u])throw new Error(`Invalid mask=${u}. Expected number [0..7]`)})(n.mask);let s,o=n.version,a=new Error("Unknown error");if(o!==void 0)(function(u){if(!Number.isSafeInteger(u)||u<1||u>40)throw new Error(`Invalid version=${u}. Expected number [1..40]`)})(o),s=OE(o,r,t,i);else for(let u=1;u<=40;u++)try{s=OE(u,r,t,i),o=u;break}catch(d){a=d}if(!o||!s)throw a;let c=(function(u,d,f,g){if(g===void 0){const v=(function(){let w,b=1/0;return{add(E,M){E>=b||(w=M,b=E)},get:()=>w,score:()=>b}})();for(let w=0;w<um.length;w++)v.add(Vk(NE(u,d,f,w,!0)),w);g=v.get()}if(g===void 0)throw new Error("Cannot find mask");return NE(u,d,f,g)})(o,r,s,n.mask);c.assertDrawn();const l=n.border===void 0?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),n.scale!==void 0&&(c=c.scale(n.scale)),e==="raw")return c.data;if(e==="ascii")return c.toASCII();if(e==="svg")return c.toSVG();if(e==="gif")return c.toGIF();if(e==="term")return c.toTerm();throw new Error(`Unknown output: ${e}`)}const _p={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class oy{constructor(e){var n;this.translations=_p,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=(n=e?.baseUrl)!==null&&n!==void 0?n:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some((n=>n.toLowerCase().startsWith("en"))))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const n=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(n)}async loadTranslations(e){const n=e.split("-")[0];if(n!=="en"&&this.supportedLocales.includes(n))try{const r=`${this.baseUrl}/${n}.json`,i=await fetch(r);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);this.translations=await i.json()}catch(r){console.warn(`❌ Failed to load ${n} translations, falling back to English:`,r),this.translations=_p}else this.translations=_p}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,n){const r=e.split(".");let i=n;for(const s of r){if(typeof i!="object")return"";i=i[s]}return typeof i=="string"?i:""}}var ll;(function(t){t.SDK_MODAL_VIEWED="sdk_modal_viewed",t.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",t.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"})(ll||(ll={}));const XA=class{constructor(t){Yg(this,t),this.close=lo(this,"close"),this.startDesktopOnboarding=lo(this,"startDesktopOnboarding"),this.trackAnalytics=lo(this,"trackAnalytics"),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new oy}componentDidLoad(){this.trackAnalytics.emit({event:ll.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:this.tab===1?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(t){t?this.setTab(1):this.setTab(2)}onClose(t=!1){this.close.emit({shouldTerminate:t})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:ll.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(t,e=!1){e&&this.trackAnalytics.emit({event:ll.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:this.tab===1?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=t,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const t=r=>this.i18nInstance.t(r),e=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=ZA(this.link,"svg",{ecc:"medium",scale:2});return be(ny,{className:"install-model"},be("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),be("div",{class:"modal"},be("div",{class:"closeButtonContainer"},be("div",{class:"right"},be("span",{class:"closeButton",onClick:()=>this.onClose(!0)},be(iy,null)))),be("div",{class:"logoContainer"},be(sy,null)),be("div",null,be("div",{class:"tabcontainer"},be("div",{class:"flexContainer"},be("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(e===1?"tabactive":"")},t("DESKTOP")),be("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(e===2?"tabactive":"")},t("MOBILE")))),be("div",{style:{display:e===1?"none":"block"}},be("div",{class:"flexContainer"},be("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&be("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),be("div",{class:"connectMobileText"},t("SCAN_TO_CONNECT")," ",be("br",null),be("span",{class:"blue"},be("b",null,t("META_MASK_MOBILE_APP"))))))),be("div",{style:{display:e===2?"none":"block"}},be("div",{class:"item"},be(bp,{Icon:Dk,text:t("INSTALL_MODAL.TRUSTED_BY_USERS")})),be("div",{class:"item"},be(bp,{Icon:kk,text:t("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),be("div",{class:"item"},be(bp,{Icon:Lk,text:t("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),be("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},be(Bk,null),be("span",{class:"installExtensionText"},t("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),be(ry,{version:this.sdkVersion})))}get el(){return Hf(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};XA.style=`.flexContainer {
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.flexItem {
|
|
53
|
+
flex: 1;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
align-items: center;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.flexItem11 {
|
|
59
|
+
flex: 11;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.flexItem1 {
|
|
65
|
+
flex: 1;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
align-items: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.tab {
|
|
71
|
+
padding: 8px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
background-color: #F2F4F6;
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
text-align: center;
|
|
76
|
+
color: #24292E;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.tabcontainer {
|
|
80
|
+
padding: 4px;
|
|
81
|
+
background-color: #F2F4F6;
|
|
82
|
+
border-radius: 8px;
|
|
83
|
+
margin-bottom: 30px;
|
|
84
|
+
margin-top: 30px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.tabactive {
|
|
88
|
+
background-color: white;
|
|
89
|
+
-webkit-transition: background-color 300ms linear;
|
|
90
|
+
-ms-transition: background-color 300ms linear;
|
|
91
|
+
transition: background-color 300ms linear;
|
|
92
|
+
border-radius: 8px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.item {
|
|
96
|
+
font-size: 12px;
|
|
97
|
+
margin-bottom: 16px;
|
|
98
|
+
border-radius: 8px;
|
|
99
|
+
padding: 10px;
|
|
100
|
+
border: 2px #F2F4F6 solid;
|
|
101
|
+
color: #24292E;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.extensionLabel {
|
|
105
|
+
font-style: normal;
|
|
106
|
+
font-weight: bold;
|
|
107
|
+
font-size: 14px;
|
|
108
|
+
text-align: cetner;
|
|
109
|
+
color: #24272A;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.notice {
|
|
113
|
+
font-size: 12px;
|
|
114
|
+
margin-left: 10px;
|
|
115
|
+
margin-right: 10px;
|
|
116
|
+
color: grey;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.button {
|
|
120
|
+
margin-top: 41.5px;
|
|
121
|
+
margin-bottom: 20px;
|
|
122
|
+
width: 100%;
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: row;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
align-items: center;
|
|
127
|
+
padding: 12px 20px;
|
|
128
|
+
background: #037DD6;
|
|
129
|
+
border-radius: 32px;
|
|
130
|
+
color: white;
|
|
131
|
+
border: 0;
|
|
132
|
+
font-size: 14px;
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.backdrop {
|
|
137
|
+
visibility: visible;
|
|
138
|
+
position: fixed;
|
|
139
|
+
top: 0;
|
|
140
|
+
left: 0;
|
|
141
|
+
right: 0;
|
|
142
|
+
bottom: 0;
|
|
143
|
+
width: 100%;
|
|
144
|
+
z-index: 99998;
|
|
145
|
+
background: rgba(0, 0, 0, 0.87);
|
|
146
|
+
opacity: 0.3;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.modal {
|
|
150
|
+
visibility: visible;
|
|
151
|
+
position: fixed;
|
|
152
|
+
left: 50%;
|
|
153
|
+
transform: translate(-50%, -50%);
|
|
154
|
+
z-index: 99999;
|
|
155
|
+
background: white;
|
|
156
|
+
padding: 20px;
|
|
157
|
+
border-radius: 8px;
|
|
158
|
+
top: 50%;
|
|
159
|
+
max-width: 100%;
|
|
160
|
+
width: 460px;
|
|
161
|
+
min-width: 300px;
|
|
162
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
|
|
163
|
+
-webkit-font-smoothing: antialiased;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.closeButton {
|
|
167
|
+
color: #BBC0C5;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.logoContainer {
|
|
172
|
+
margin-left: 24px;
|
|
173
|
+
margin-right: 24px;
|
|
174
|
+
margin-top: 24px;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.connectMobileText {
|
|
181
|
+
font-size: 14px;
|
|
182
|
+
color: black;
|
|
183
|
+
margin-top: 28px;
|
|
184
|
+
margin-bottom: 28px;
|
|
185
|
+
line-height: 2;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.blue {
|
|
189
|
+
color: #037DD6;
|
|
190
|
+
font-weight: 700;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.installExtensionText {
|
|
194
|
+
margin-left: 10px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.center {
|
|
198
|
+
display: flex;
|
|
199
|
+
justify-content: center;
|
|
200
|
+
align-items: center;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.right {
|
|
204
|
+
display: flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: right;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
#sdk-mm-qrcode {
|
|
210
|
+
svg {
|
|
211
|
+
width: 50%;
|
|
212
|
+
}
|
|
213
|
+
}`;const QA=class{constructor(t){Yg(this,t),this.close=lo(this,"close"),this.disconnect=lo(this,"disconnect"),this.updateOTPValue=lo(this,"updateOTPValue"),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new oy}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(t){this.updateOTPValue.emit({otpValue:t})}disconnectedCallback(){this.onClose()}render(){var t;if(!this.translationsLoaded)return null;const e=(t=this.displayOTP)===null||t===void 0||t,n=this.sdkVersion,r=i=>this.i18nInstance.t(i);return be(ny,{className:"pending-modal"},be("div",{class:"backdrop",onClick:()=>this.onClose()}),be("div",{class:"modal"},be("div",{class:"closeButtonContainer"},be("div",{class:"right"},be("span",{class:"closeButton",onClick:()=>this.onClose()},be(iy,null)))),be("div",{class:"logoContainer"},be(sy,null)),be("div",null,be("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},be("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(e?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),be("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),e&&be("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),be("div",{style:{marginTop:"20px"}},be("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),be(ry,{version:n})))}get el(){return Hf(this)}};QA.style=`.flexContainer {
|
|
214
|
+
display: flex;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
align-items: center;
|
|
217
|
+
flex-direction: row;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.flexItem {
|
|
221
|
+
flex: 1;
|
|
222
|
+
justify-content: center;
|
|
223
|
+
align-items: center;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.flexItem11 {
|
|
227
|
+
flex: 11;
|
|
228
|
+
justify-content: center;
|
|
229
|
+
align-items: center;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.flexItem1 {
|
|
233
|
+
flex: 1;
|
|
234
|
+
justify-content: center;
|
|
235
|
+
align-items: center;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.tab {
|
|
239
|
+
padding: 8px;
|
|
240
|
+
cursor: pointer;
|
|
241
|
+
background-color: #F2F4F6;
|
|
242
|
+
font-size: 12px;
|
|
243
|
+
text-align: center;
|
|
244
|
+
color: #24292E;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.tabcontainer {
|
|
248
|
+
padding: 4px;
|
|
249
|
+
background-color: #F2F4F6;
|
|
250
|
+
border-radius: 8px;
|
|
251
|
+
margin-bottom: 30px;
|
|
252
|
+
margin-top: 30px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.tabactive {
|
|
256
|
+
background-color: white;
|
|
257
|
+
-webkit-transition: background-color 300ms linear;
|
|
258
|
+
-ms-transition: background-color 300ms linear;
|
|
259
|
+
transition: background-color 300ms linear;
|
|
260
|
+
border-radius: 8px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.item {
|
|
264
|
+
font-size: 12px;
|
|
265
|
+
margin-bottom: 16px;
|
|
266
|
+
border-radius: 8px;
|
|
267
|
+
padding: 10px;
|
|
268
|
+
border: 2px #F2F4F6 solid;
|
|
269
|
+
color: #24292E;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.extensionLabel {
|
|
273
|
+
font-style: normal;
|
|
274
|
+
font-weight: bold;
|
|
275
|
+
font-size: 14px;
|
|
276
|
+
text-align: cetner;
|
|
277
|
+
color: #24272A;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.notice {
|
|
281
|
+
font-size: 12px;
|
|
282
|
+
margin-left: 10px;
|
|
283
|
+
margin-right: 10px;
|
|
284
|
+
color: grey;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.button {
|
|
288
|
+
margin-top: 41.5px;
|
|
289
|
+
margin-bottom: 20px;
|
|
290
|
+
width: 100%;
|
|
291
|
+
display: flex;
|
|
292
|
+
flex-direction: row;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
align-items: center;
|
|
295
|
+
padding: 12px 20px;
|
|
296
|
+
background: #037DD6;
|
|
297
|
+
border-radius: 32px;
|
|
298
|
+
color: white;
|
|
299
|
+
border: 0;
|
|
300
|
+
font-size: 14px;
|
|
301
|
+
cursor: pointer;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.backdrop {
|
|
305
|
+
visibility: visible;
|
|
306
|
+
position: fixed;
|
|
307
|
+
top: 0;
|
|
308
|
+
left: 0;
|
|
309
|
+
right: 0;
|
|
310
|
+
bottom: 0;
|
|
311
|
+
width: 100%;
|
|
312
|
+
z-index: 99998;
|
|
313
|
+
background: rgba(0, 0, 0, 0.87);
|
|
314
|
+
opacity: 0.3;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.modal {
|
|
318
|
+
visibility: visible;
|
|
319
|
+
position: fixed;
|
|
320
|
+
left: 50%;
|
|
321
|
+
transform: translate(-50%, -50%);
|
|
322
|
+
z-index: 99999;
|
|
323
|
+
background: white;
|
|
324
|
+
padding: 20px;
|
|
325
|
+
border-radius: 8px;
|
|
326
|
+
top: 50%;
|
|
327
|
+
max-width: 100%;
|
|
328
|
+
width: 460px;
|
|
329
|
+
min-width: 300px;
|
|
330
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
|
|
331
|
+
-webkit-font-smoothing: antialiased;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.closeButton {
|
|
335
|
+
color: #BBC0C5;
|
|
336
|
+
cursor: pointer;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.logoContainer {
|
|
340
|
+
margin-left: 24px;
|
|
341
|
+
margin-right: 24px;
|
|
342
|
+
margin-top: 24px;
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
justify-content: center;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.connectMobileText {
|
|
349
|
+
font-size: 14px;
|
|
350
|
+
color: black;
|
|
351
|
+
margin-top: 28px;
|
|
352
|
+
margin-bottom: 28px;
|
|
353
|
+
line-height: 2;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.blue {
|
|
357
|
+
color: #037DD6;
|
|
358
|
+
font-weight: 700;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.installExtensionText {
|
|
362
|
+
margin-left: 10px;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.center {
|
|
366
|
+
display: flex;
|
|
367
|
+
justify-content: center;
|
|
368
|
+
align-items: center;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.right {
|
|
372
|
+
display: flex;
|
|
373
|
+
align-items: center;
|
|
374
|
+
justify-content: right;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#sdk-mm-qrcode {
|
|
378
|
+
svg {
|
|
379
|
+
width: 50%;
|
|
380
|
+
}
|
|
381
|
+
}`;const jk=()=>be("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),Hk=()=>be("svg",{width:"400",height:"300",viewBox:"0 0 400 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},be("rect",{width:"400",height:"300",fill:"white"}),be("path",{d:"M300.116 242.46L250.485 227.681L213.057 250.055L186.944 250.045L149.493 227.681L99.8843 242.46L84.7939 191.518L99.8843 134.979L84.7939 87.1777L99.8843 27.9336L177.402 74.2466H222.598L300.116 27.9336L315.206 87.1777L300.116 134.979L315.206 191.518L300.116 242.46Z",fill:"#FF5C16"}),be("path",{d:"M99.8955 27.9336L177.414 74.2792L174.331 106.085L99.8955 27.9336Z",fill:"#FF5C16"}),be("path",{d:"M149.505 191.539L183.612 217.521L149.505 227.681V191.539Z",fill:"#FF5C16"}),be("path",{d:"M180.886 148.585L174.33 106.107L132.369 134.991L132.348 134.98V135.001L132.477 164.732L149.493 148.585H149.504H180.886Z",fill:"#FF5C16"}),be("path",{d:"M300.116 27.9336L222.598 74.2792L225.67 106.085L300.116 27.9336Z",fill:"#FF5C16"}),be("path",{d:"M250.508 191.539L216.4 217.521L250.508 227.681V191.539Z",fill:"#FF5C16"}),be("path",{d:"M267.652 135.001H267.663H267.652V134.98L267.641 134.991L225.68 106.107L219.125 148.585H250.507L267.533 164.732L267.652 135.001Z",fill:"#FF5C16"}),be("path",{d:"M149.493 227.681L99.8843 242.46L84.7939 191.54H149.493V227.681Z",fill:"#E34807"}),be("path",{d:"M180.875 148.574L190.351 209.98L177.219 175.838L132.456 164.732L149.483 148.574H180.864H180.875Z",fill:"#E34807"}),be("path",{d:"M250.507 227.681L300.116 242.46L315.206 191.54H250.507V227.681Z",fill:"#E34807"}),be("path",{d:"M219.126 148.574L209.649 209.98L222.782 175.838L267.545 164.732L250.507 148.574H219.126Z",fill:"#E34807"}),be("path",{d:"M84.7939 191.517L99.8843 134.979H132.337L132.456 164.721L177.219 175.826L190.351 209.969L183.601 217.488L149.493 191.506H84.7939V191.517Z",fill:"#FF8D5D"}),be("path",{d:"M315.206 191.517L300.116 134.979H267.664L267.545 164.721L222.782 175.826L209.649 209.969L216.4 217.488L250.507 191.506H315.206V191.517Z",fill:"#FF8D5D"}),be("path",{d:"M222.598 74.2466H200H177.402L174.33 106.053L190.351 209.936H209.649L225.681 106.053L222.598 74.2466Z",fill:"#FF8D5D"}),be("path",{d:"M99.8843 27.9336L84.7939 87.1777L99.8843 134.979H132.337L174.319 106.085L99.8843 27.9336Z",fill:"#661800"}),be("path",{d:"M171.496 160.906H156.795L148.79 168.752L177.229 175.804L171.496 160.896V160.906Z",fill:"#661800"}),be("path",{d:"M300.116 27.9336L315.206 87.1777L300.116 134.979H267.663L225.681 106.085L300.116 27.9336Z",fill:"#661800"}),be("path",{d:"M228.525 160.906H243.248L251.253 168.763L222.781 175.826L228.525 160.896V160.906Z",fill:"#661800"}),be("path",{d:"M213.046 229.789L216.399 217.51L209.649 209.991H190.34L183.59 217.51L186.943 229.789",fill:"#661800"}),be("path",{d:"M213.047 229.789V250.066H186.944V229.789H213.047Z",fill:"#C0C4CD"}),be("path",{d:"M149.504 227.66L186.965 250.056V229.779L183.611 217.5L149.504 227.66Z",fill:"#E7EBF6"}),be("path",{d:"M250.506 227.66L213.045 250.056V229.779L216.398 217.5L250.506 227.66Z",fill:"#E7EBF6"})),eR=class{constructor(t){Yg(this,t),this.close=lo(this,"close"),this.connectWithExtension=lo(this,"connectWithExtension"),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new oy,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(t=!1){this.close.emit({shouldTerminate:t})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(t){this.tab=t,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(t){t?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const t=i=>this.i18nInstance.t(i),e=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=ZA(this.link,"svg",{ecc:"medium",scale:2});return be(ny,{className:"select-modal"},be("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),be("div",{class:"modal"},be("div",{class:"closeButtonContainer"},be("div",{class:"right"},be("span",{class:"closeButton",onClick:()=>this.onClose(!0)},be(iy,null)))),be("div",{class:"logoContainer"},be(sy,null)),be("div",null,be("div",{class:"tabcontainer"},be("div",{class:"flexContainer"},be("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(n===1?"tabactive":"")},t("DESKTOP")),be("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(n===2?"tabactive":"")},t("MOBILE")))),be("div",{style:{display:n===1?"none":"block"}},be("div",{class:"flexContainer"},be("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},be("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),be("div",{class:"connectMobileText"},t("SCAN_TO_CONNECT"),be("br",null),be("span",{class:"blue"},be("b",null,t("META_MASK_MOBILE_APP"))))))),be("div",{style:{display:n===2?"none":"block"}},be("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},be(Hk,null)),be("div",{class:"extensionLabel"},t("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),be("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},be(jk,null),be("span",{class:"installExtensionText"},t("CONNECT_WITH_EXTENSION"))))),be(ry,{version:e})))}get el(){return Hf(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};eR.style=`.flexContainer {
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: center;
|
|
384
|
+
align-items: center;
|
|
385
|
+
flex-direction: row;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.flexItem {
|
|
389
|
+
flex: 1;
|
|
390
|
+
justify-content: center;
|
|
391
|
+
align-items: center;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.flexItem11 {
|
|
395
|
+
flex: 11;
|
|
396
|
+
justify-content: center;
|
|
397
|
+
align-items: center;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.flexItem1 {
|
|
401
|
+
flex: 1;
|
|
402
|
+
justify-content: center;
|
|
403
|
+
align-items: center;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.tab {
|
|
407
|
+
padding: 8px;
|
|
408
|
+
cursor: pointer;
|
|
409
|
+
background-color: #F2F4F6;
|
|
410
|
+
font-size: 12px;
|
|
411
|
+
text-align: center;
|
|
412
|
+
color: #24292E;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.tabcontainer {
|
|
416
|
+
padding: 4px;
|
|
417
|
+
background-color: #F2F4F6;
|
|
418
|
+
border-radius: 8px;
|
|
419
|
+
margin-bottom: 30px;
|
|
420
|
+
margin-top: 30px;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.tabactive {
|
|
424
|
+
background-color: white;
|
|
425
|
+
-webkit-transition: background-color 300ms linear;
|
|
426
|
+
-ms-transition: background-color 300ms linear;
|
|
427
|
+
transition: background-color 300ms linear;
|
|
428
|
+
border-radius: 8px;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.item {
|
|
432
|
+
font-size: 12px;
|
|
433
|
+
margin-bottom: 16px;
|
|
434
|
+
border-radius: 8px;
|
|
435
|
+
padding: 10px;
|
|
436
|
+
border: 2px #F2F4F6 solid;
|
|
437
|
+
color: #24292E;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.extensionLabel {
|
|
441
|
+
font-style: normal;
|
|
442
|
+
font-weight: bold;
|
|
443
|
+
font-size: 14px;
|
|
444
|
+
text-align: cetner;
|
|
445
|
+
color: #24272A;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.notice {
|
|
449
|
+
font-size: 12px;
|
|
450
|
+
margin-left: 10px;
|
|
451
|
+
margin-right: 10px;
|
|
452
|
+
color: grey;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.button {
|
|
456
|
+
margin-top: 41.5px;
|
|
457
|
+
margin-bottom: 20px;
|
|
458
|
+
width: 100%;
|
|
459
|
+
display: flex;
|
|
460
|
+
flex-direction: row;
|
|
461
|
+
justify-content: center;
|
|
462
|
+
align-items: center;
|
|
463
|
+
padding: 12px 20px;
|
|
464
|
+
background: #037DD6;
|
|
465
|
+
border-radius: 32px;
|
|
466
|
+
color: white;
|
|
467
|
+
border: 0;
|
|
468
|
+
font-size: 14px;
|
|
469
|
+
cursor: pointer;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.backdrop {
|
|
473
|
+
visibility: visible;
|
|
474
|
+
position: fixed;
|
|
475
|
+
top: 0;
|
|
476
|
+
left: 0;
|
|
477
|
+
right: 0;
|
|
478
|
+
bottom: 0;
|
|
479
|
+
width: 100%;
|
|
480
|
+
z-index: 99998;
|
|
481
|
+
background: rgba(0, 0, 0, 0.87);
|
|
482
|
+
opacity: 0.3;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.modal {
|
|
486
|
+
visibility: visible;
|
|
487
|
+
position: fixed;
|
|
488
|
+
left: 50%;
|
|
489
|
+
transform: translate(-50%, -50%);
|
|
490
|
+
z-index: 99999;
|
|
491
|
+
background: white;
|
|
492
|
+
padding: 20px;
|
|
493
|
+
border-radius: 8px;
|
|
494
|
+
top: 50%;
|
|
495
|
+
max-width: 100%;
|
|
496
|
+
width: 460px;
|
|
497
|
+
min-width: 300px;
|
|
498
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
|
|
499
|
+
-webkit-font-smoothing: antialiased;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.closeButton {
|
|
503
|
+
color: #BBC0C5;
|
|
504
|
+
cursor: pointer;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.logoContainer {
|
|
508
|
+
margin-left: 24px;
|
|
509
|
+
margin-right: 24px;
|
|
510
|
+
margin-top: 24px;
|
|
511
|
+
display: flex;
|
|
512
|
+
align-items: center;
|
|
513
|
+
justify-content: center;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.connectMobileText {
|
|
517
|
+
font-size: 14px;
|
|
518
|
+
color: black;
|
|
519
|
+
margin-top: 28px;
|
|
520
|
+
margin-bottom: 28px;
|
|
521
|
+
line-height: 2;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.blue {
|
|
525
|
+
color: #037DD6;
|
|
526
|
+
font-weight: 700;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
.installExtensionText {
|
|
530
|
+
margin-left: 10px;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.center {
|
|
534
|
+
display: flex;
|
|
535
|
+
justify-content: center;
|
|
536
|
+
align-items: center;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.right {
|
|
540
|
+
display: flex;
|
|
541
|
+
align-items: center;
|
|
542
|
+
justify-content: right;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
#sdk-mm-qrcode {
|
|
546
|
+
svg {
|
|
547
|
+
width: 50%;
|
|
548
|
+
}
|
|
549
|
+
}`;var zk=Object.freeze({__proto__:null,mm_install_modal:XA,mm_pending_modal:QA,mm_select_modal:eR});let Sp=null;function qk(){if(typeof window>"u")throw new Error("MetaMask SDK can only be initialized in the browser.");return Sp||(Sp=new sk({dappMetadata:{name:"PeridotVault",url:window.location.origin}})),Sp}class tR{async Login(e){if(!e||e.trim().length===0)throw new Error("Message is required.");const n=qk(),i=(await n.connect())?.[0];if(!i)throw new Error("No account returned from MetaMask.");return{signature:await n.connectAndSign({msg:e}),message:e,accountId:i,accountType:"EVM"}}isMetamaskInstalled(){if(typeof window>"u")return!1;const e=window.ethereum;return e?Array.isArray(e.providers)?e.providers.some(n=>n.isMetaMask===!0):e.isMetaMask===!0:!1}}function nR(t,e){return function(){return t.apply(e,arguments)}}const{toString:Wk}=Object.prototype,{getPrototypeOf:ay}=Object,{iterator:zf,toStringTag:rR}=Symbol,qf=(t=>e=>{const n=Wk.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ti=t=>(t=t.toLowerCase(),e=>qf(e)===t),Wf=t=>e=>typeof e===t,{isArray:Ec}=Array,rc=Wf("undefined");function zl(t){return t!==null&&!rc(t)&&t.constructor!==null&&!rc(t.constructor)&&Fr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const iR=Ti("ArrayBuffer");function Gk(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&iR(t.buffer),e}const Yk=Wf("string"),Fr=Wf("function"),sR=Wf("number"),ql=t=>t!==null&&typeof t=="object",Jk=t=>t===!0||t===!1,bd=t=>{if(qf(t)!=="object")return!1;const e=ay(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(rR in t)&&!(zf in t)},Zk=t=>{if(!ql(t)||zl(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Xk=Ti("Date"),Qk=Ti("File"),e4=Ti("Blob"),t4=Ti("FileList"),n4=t=>ql(t)&&Fr(t.pipe),r4=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Fr(t.append)&&((e=qf(t))==="formdata"||e==="object"&&Fr(t.toString)&&t.toString()==="[object FormData]"))},i4=Ti("URLSearchParams"),[s4,o4,a4,c4]=["ReadableStream","Request","Response","Headers"].map(Ti),l4=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Wl(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,i;if(typeof t!="object"&&(t=[t]),Ec(t))for(r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else{if(zl(t))return;const s=n?Object.getOwnPropertyNames(t):Object.keys(t),o=s.length;let a;for(r=0;r<o;r++)a=s[r],e.call(null,t[a],a,t)}}function oR(t,e){if(zl(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,i;for(;r-- >0;)if(i=n[r],e===i.toLowerCase())return i;return null}const Lo=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,aR=t=>!rc(t)&&t!==Lo;function dm(){const{caseless:t,skipUndefined:e}=aR(this)&&this||{},n={},r=(i,s)=>{const o=t&&oR(n,s)||s;bd(n[o])&&bd(i)?n[o]=dm(n[o],i):bd(i)?n[o]=dm({},i):Ec(i)?n[o]=i.slice():(!e||!rc(i))&&(n[o]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&Wl(arguments[i],r);return n}const u4=(t,e,n,{allOwnKeys:r}={})=>(Wl(e,(i,s)=>{n&&Fr(i)?t[s]=nR(i,n):t[s]=i},{allOwnKeys:r}),t),d4=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),f4=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},h4=(t,e,n,r)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)o=i[s],(!r||r(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=n!==!1&&ay(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},p4=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},m4=t=>{if(!t)return null;if(Ec(t))return t;let e=t.length;if(!sR(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},g4=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&ay(Uint8Array)),y4=(t,e)=>{const r=(t&&t[zf]).call(t);let i;for(;(i=r.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},w4=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},v4=Ti("HTMLFormElement"),E4=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),PE=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),b4=Ti("RegExp"),cR=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};Wl(n,(i,s)=>{let o;(o=e(i,s,t))!==!1&&(r[s]=o||i)}),Object.defineProperties(t,r)},_4=t=>{cR(t,(e,n)=>{if(Fr(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(Fr(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},S4=(t,e)=>{const n={},r=i=>{i.forEach(s=>{n[s]=!0})};return Ec(t)?r(t):r(String(t).split(e)),n},x4=()=>{},A4=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function R4(t){return!!(t&&Fr(t.append)&&t[rR]==="FormData"&&t[zf])}const I4=t=>{const e=new Array(10),n=(r,i)=>{if(ql(r)){if(e.indexOf(r)>=0)return;if(zl(r))return r;if(!("toJSON"in r)){e[i]=r;const s=Ec(r)?[]:{};return Wl(r,(o,a)=>{const c=n(o,i+1);!rc(c)&&(s[a]=c)}),e[i]=void 0,s}}return r};return n(t,0)},T4=Ti("AsyncFunction"),C4=t=>t&&(ql(t)||Fr(t))&&Fr(t.then)&&Fr(t.catch),lR=((t,e)=>t?setImmediate:e?((n,r)=>(Lo.addEventListener("message",({source:i,data:s})=>{i===Lo&&s===n&&r.length&&r.shift()()},!1),i=>{r.push(i),Lo.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Fr(Lo.postMessage)),O4=typeof queueMicrotask<"u"?queueMicrotask.bind(Lo):typeof process<"u"&&process.nextTick||lR,N4=t=>t!=null&&Fr(t[zf]),ye={isArray:Ec,isArrayBuffer:iR,isBuffer:zl,isFormData:r4,isArrayBufferView:Gk,isString:Yk,isNumber:sR,isBoolean:Jk,isObject:ql,isPlainObject:bd,isEmptyObject:Zk,isReadableStream:s4,isRequest:o4,isResponse:a4,isHeaders:c4,isUndefined:rc,isDate:Xk,isFile:Qk,isBlob:e4,isRegExp:b4,isFunction:Fr,isStream:n4,isURLSearchParams:i4,isTypedArray:g4,isFileList:t4,forEach:Wl,merge:dm,extend:u4,trim:l4,stripBOM:d4,inherits:f4,toFlatObject:h4,kindOf:qf,kindOfTest:Ti,endsWith:p4,toArray:m4,forEachEntry:y4,matchAll:w4,isHTMLForm:v4,hasOwnProperty:PE,hasOwnProp:PE,reduceDescriptors:cR,freezeMethods:_4,toObjectSet:S4,toCamelCase:E4,noop:x4,toFiniteNumber:A4,findKey:oR,global:Lo,isContextDefined:aR,isSpecCompliantForm:R4,toJSONObject:I4,isAsyncFn:T4,isThenable:C4,setImmediate:lR,asap:O4,isIterable:N4};function Tt(t,e,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}ye.inherits(Tt,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ye.toJSONObject(this.config),code:this.code,status:this.status}}});const uR=Tt.prototype,dR={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{dR[t]={value:t}});Object.defineProperties(Tt,dR);Object.defineProperty(uR,"isAxiosError",{value:!0});Tt.from=(t,e,n,r,i,s)=>{const o=Object.create(uR);ye.toFlatObject(t,o,function(u){return u!==Error.prototype},l=>l!=="isAxiosError");const a=t&&t.message?t.message:"Error",c=e==null&&t?t.code:e;return Tt.call(o,a,c,n,r,i),t&&o.cause==null&&Object.defineProperty(o,"cause",{value:t,configurable:!0}),o.name=t&&t.name||"Error",s&&Object.assign(o,s),o};const P4=null;function fm(t){return ye.isPlainObject(t)||ye.isArray(t)}function fR(t){return ye.endsWith(t,"[]")?t.slice(0,-2):t}function ME(t,e,n){return t?t.concat(e).map(function(i,s){return i=fR(i),!n&&s?"["+i+"]":i}).join(n?".":""):e}function M4(t){return ye.isArray(t)&&!t.some(fm)}const k4=ye.toFlatObject(ye,{},null,function(e){return/^is[A-Z]/.test(e)});function Gf(t,e,n){if(!ye.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=ye.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,b){return!ye.isUndefined(b[w])});const r=n.metaTokens,i=n.visitor||u,s=n.dots,o=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&ye.isSpecCompliantForm(e);if(!ye.isFunction(i))throw new TypeError("visitor must be a function");function l(v){if(v===null)return"";if(ye.isDate(v))return v.toISOString();if(ye.isBoolean(v))return v.toString();if(!c&&ye.isBlob(v))throw new Tt("Blob is not supported. Use a Buffer instead.");return ye.isArrayBuffer(v)||ye.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,w,b){let E=v;if(v&&!b&&typeof v=="object"){if(ye.endsWith(w,"{}"))w=r?w:w.slice(0,-2),v=JSON.stringify(v);else if(ye.isArray(v)&&M4(v)||(ye.isFileList(v)||ye.endsWith(w,"[]"))&&(E=ye.toArray(v)))return w=fR(w),E.forEach(function(S,F){!(ye.isUndefined(S)||S===null)&&e.append(o===!0?ME([w],F,s):o===null?w:w+"[]",l(S))}),!1}return fm(v)?!0:(e.append(ME(b,w,s),l(v)),!1)}const d=[],f=Object.assign(k4,{defaultVisitor:u,convertValue:l,isVisitable:fm});function g(v,w){if(!ye.isUndefined(v)){if(d.indexOf(v)!==-1)throw Error("Circular reference detected in "+w.join("."));d.push(v),ye.forEach(v,function(E,M){(!(ye.isUndefined(E)||E===null)&&i.call(e,E,ye.isString(M)?M.trim():M,w,f))===!0&&g(E,w?w.concat(M):[M])}),d.pop()}}if(!ye.isObject(t))throw new TypeError("data must be an object");return g(t),e}function kE(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function cy(t,e){this._pairs=[],t&&Gf(t,this,e)}const hR=cy.prototype;hR.append=function(e,n){this._pairs.push([e,n])};hR.toString=function(e){const n=e?function(r){return e.call(this,r,kE)}:kE;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function D4(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function pR(t,e,n){if(!e)return t;const r=n&&n.encode||D4;ye.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let s;if(i?s=i(e,n):s=ye.isURLSearchParams(e)?e.toString():new cy(e,n).toString(r),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class DE{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ye.forEach(this.handlers,function(r){r!==null&&e(r)})}}const mR={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},L4=typeof URLSearchParams<"u"?URLSearchParams:cy,B4=typeof FormData<"u"?FormData:null,U4=typeof Blob<"u"?Blob:null,$4={isBrowser:!0,classes:{URLSearchParams:L4,FormData:B4,Blob:U4},protocols:["http","https","file","blob","url","data"]},ly=typeof window<"u"&&typeof document<"u",hm=typeof navigator=="object"&&navigator||void 0,F4=ly&&(!hm||["ReactNative","NativeScript","NS"].indexOf(hm.product)<0),K4=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",V4=ly&&window.location.href||"http://localhost",j4=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ly,hasStandardBrowserEnv:F4,hasStandardBrowserWebWorkerEnv:K4,navigator:hm,origin:V4},Symbol.toStringTag,{value:"Module"})),wr={...j4,...$4};function H4(t,e){return Gf(t,new wr.classes.URLSearchParams,{visitor:function(n,r,i,s){return wr.isNode&&ye.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function z4(t){return ye.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function q4(t){const e={},n=Object.keys(t);let r;const i=n.length;let s;for(r=0;r<i;r++)s=n[r],e[s]=t[s];return e}function gR(t){function e(n,r,i,s){let o=n[s++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),c=s>=n.length;return o=!o&&ye.isArray(i)?i.length:o,c?(ye.hasOwnProp(i,o)?i[o]=[i[o],r]:i[o]=r,!a):((!i[o]||!ye.isObject(i[o]))&&(i[o]=[]),e(n,r,i[o],s)&&ye.isArray(i[o])&&(i[o]=q4(i[o])),!a)}if(ye.isFormData(t)&&ye.isFunction(t.entries)){const n={};return ye.forEachEntry(t,(r,i)=>{e(z4(r),i,n,0)}),n}return null}function W4(t,e,n){if(ye.isString(t))try{return(e||JSON.parse)(t),ye.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const Gl={transitional:mR,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,s=ye.isObject(e);if(s&&ye.isHTMLForm(e)&&(e=new FormData(e)),ye.isFormData(e))return i?JSON.stringify(gR(e)):e;if(ye.isArrayBuffer(e)||ye.isBuffer(e)||ye.isStream(e)||ye.isFile(e)||ye.isBlob(e)||ye.isReadableStream(e))return e;if(ye.isArrayBufferView(e))return e.buffer;if(ye.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return H4(e,this.formSerializer).toString();if((a=ye.isFileList(e))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Gf(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return s||i?(n.setContentType("application/json",!1),W4(e)):e}],transformResponse:[function(e){const n=this.transitional||Gl.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(ye.isResponse(e)||ye.isReadableStream(e))return e;if(e&&ye.isString(e)&&(r&&!this.responseType||i)){const o=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?Tt.from(a,Tt.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wr.classes.FormData,Blob:wr.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ye.forEach(["delete","get","head","post","put","patch"],t=>{Gl.headers[t]={}});const G4=ye.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Y4=t=>{const e={};let n,r,i;return t&&t.split(`
|
|
550
|
+
`).forEach(function(o){i=o.indexOf(":"),n=o.substring(0,i).trim().toLowerCase(),r=o.substring(i+1).trim(),!(!n||e[n]&&G4[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},LE=Symbol("internals");function Fc(t){return t&&String(t).trim().toLowerCase()}function _d(t){return t===!1||t==null?t:ye.isArray(t)?t.map(_d):String(t)}function J4(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const Z4=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function xp(t,e,n,r,i){if(ye.isFunction(r))return r.call(this,e,n);if(i&&(e=n),!!ye.isString(e)){if(ye.isString(r))return e.indexOf(r)!==-1;if(ye.isRegExp(r))return r.test(e)}}function X4(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function Q4(t,e){const n=ye.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(i,s,o){return this[r].call(this,e,i,s,o)},configurable:!0})})}let Kr=class{constructor(e){e&&this.set(e)}set(e,n,r){const i=this;function s(a,c,l){const u=Fc(c);if(!u)throw new Error("header name must be a non-empty string");const d=ye.findKey(i,u);(!d||i[d]===void 0||l===!0||l===void 0&&i[d]!==!1)&&(i[d||c]=_d(a))}const o=(a,c)=>ye.forEach(a,(l,u)=>s(l,u,c));if(ye.isPlainObject(e)||e instanceof this.constructor)o(e,n);else if(ye.isString(e)&&(e=e.trim())&&!Z4(e))o(Y4(e),n);else if(ye.isObject(e)&&ye.isIterable(e)){let a={},c,l;for(const u of e){if(!ye.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[l=u[0]]=(c=a[l])?ye.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}o(a,n)}else e!=null&&s(n,e,r);return this}get(e,n){if(e=Fc(e),e){const r=ye.findKey(this,e);if(r){const i=this[r];if(!n)return i;if(n===!0)return J4(i);if(ye.isFunction(n))return n.call(this,i,r);if(ye.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Fc(e),e){const r=ye.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||xp(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let i=!1;function s(o){if(o=Fc(o),o){const a=ye.findKey(r,o);a&&(!n||xp(r,r[a],a,n))&&(delete r[a],i=!0)}}return ye.isArray(e)?e.forEach(s):s(e),i}clear(e){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const s=n[r];(!e||xp(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const n=this,r={};return ye.forEach(this,(i,s)=>{const o=ye.findKey(r,s);if(o){n[o]=_d(i),delete n[s];return}const a=e?X4(s):String(s).trim();a!==s&&delete n[s],n[a]=_d(i),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return ye.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=e&&ye.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
|
|
551
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[LE]=this[LE]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Fc(o);r[a]||(Q4(i,o),r[a]=!0)}return ye.isArray(e)?e.forEach(s):s(e),this}};Kr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ye.reduceDescriptors(Kr.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});ye.freezeMethods(Kr);function Ap(t,e){const n=this||Gl,r=e||n,i=Kr.from(r.headers);let s=r.data;return ye.forEach(t,function(a){s=a.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function yR(t){return!!(t&&t.__CANCEL__)}function bc(t,e,n){Tt.call(this,t??"canceled",Tt.ERR_CANCELED,e,n),this.name="CanceledError"}ye.inherits(bc,Tt,{__CANCEL__:!0});function wR(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new Tt("Request failed with status code "+n.status,[Tt.ERR_BAD_REQUEST,Tt.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function eD(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function tD(t,e){t=t||10;const n=new Array(t),r=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(c){const l=Date.now(),u=r[s];o||(o=l),n[i]=c,r[i]=l;let d=s,f=0;for(;d!==i;)f+=n[d++],d=d%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),l-o<e)return;const g=u&&l-u;return g?Math.round(f*1e3/g):void 0}}function nD(t,e){let n=0,r=1e3/e,i,s;const o=(l,u=Date.now())=>{n=u,i=null,s&&(clearTimeout(s),s=null),t(...l)};return[(...l)=>{const u=Date.now(),d=u-n;d>=r?o(l,u):(i=l,s||(s=setTimeout(()=>{s=null,o(i)},r-d)))},()=>i&&o(i)]}const af=(t,e,n=3)=>{let r=0;const i=tD(50,250);return nD(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,c=o-r,l=i(c),u=o<=a;r=o;const d={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&u?(a-o)/l:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(d)},n)},BE=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},UE=t=>(...e)=>ye.asap(()=>t(...e)),rD=wr.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,wr.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(wr.origin),wr.navigator&&/(msie|trident)/i.test(wr.navigator.userAgent)):()=>!0,iD=wr.hasStandardBrowserEnv?{write(t,e,n,r,i,s,o){if(typeof document>"u")return;const a=[`${t}=${encodeURIComponent(e)}`];ye.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),ye.isString(r)&&a.push(`path=${r}`),ye.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),ye.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function sD(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function oD(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function vR(t,e,n){let r=!sD(e);return t&&(r||n==!1)?oD(t,e):e}const $E=t=>t instanceof Kr?{...t}:t;function Xo(t,e){e=e||{};const n={};function r(l,u,d,f){return ye.isPlainObject(l)&&ye.isPlainObject(u)?ye.merge.call({caseless:f},l,u):ye.isPlainObject(u)?ye.merge({},u):ye.isArray(u)?u.slice():u}function i(l,u,d,f){if(ye.isUndefined(u)){if(!ye.isUndefined(l))return r(void 0,l,d,f)}else return r(l,u,d,f)}function s(l,u){if(!ye.isUndefined(u))return r(void 0,u)}function o(l,u){if(ye.isUndefined(u)){if(!ye.isUndefined(l))return r(void 0,l)}else return r(void 0,u)}function a(l,u,d){if(d in e)return r(l,u);if(d in t)return r(void 0,l)}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,u,d)=>i($E(l),$E(u),d,!0)};return ye.forEach(Object.keys({...t,...e}),function(u){const d=c[u]||i,f=d(t[u],e[u],u);ye.isUndefined(f)&&d!==a||(n[u]=f)}),n}const ER=t=>{const e=Xo({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;if(e.headers=o=Kr.from(o),e.url=pR(vR(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),ye.isFormData(n)){if(wr.hasStandardBrowserEnv||wr.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(ye.isFunction(n.getHeaders)){const c=n.getHeaders(),l=["content-type","content-length"];Object.entries(c).forEach(([u,d])=>{l.includes(u.toLowerCase())&&o.set(u,d)})}}if(wr.hasStandardBrowserEnv&&(r&&ye.isFunction(r)&&(r=r(e)),r||r!==!1&&rD(e.url))){const c=i&&s&&iD.read(s);c&&o.set(i,c)}return e},aD=typeof XMLHttpRequest<"u",cD=aD&&function(t){return new Promise(function(n,r){const i=ER(t);let s=i.data;const o=Kr.from(i.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=i,u,d,f,g,v;function w(){g&&g(),v&&v(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(i.method.toUpperCase(),i.url,!0),b.timeout=i.timeout;function E(){if(!b)return;const S=Kr.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),D={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:S,config:t,request:b};wR(function(X){n(X),w()},function(X){r(X),w()},D),b=null}"onloadend"in b?b.onloadend=E:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(E)},b.onabort=function(){b&&(r(new Tt("Request aborted",Tt.ECONNABORTED,t,b)),b=null)},b.onerror=function(F){const D=F&&F.message?F.message:"Network Error",z=new Tt(D,Tt.ERR_NETWORK,t,b);z.event=F||null,r(z),b=null},b.ontimeout=function(){let F=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const D=i.transitional||mR;i.timeoutErrorMessage&&(F=i.timeoutErrorMessage),r(new Tt(F,D.clarifyTimeoutError?Tt.ETIMEDOUT:Tt.ECONNABORTED,t,b)),b=null},s===void 0&&o.setContentType(null),"setRequestHeader"in b&&ye.forEach(o.toJSON(),function(F,D){b.setRequestHeader(D,F)}),ye.isUndefined(i.withCredentials)||(b.withCredentials=!!i.withCredentials),a&&a!=="json"&&(b.responseType=i.responseType),l&&([f,v]=af(l,!0),b.addEventListener("progress",f)),c&&b.upload&&([d,g]=af(c),b.upload.addEventListener("progress",d),b.upload.addEventListener("loadend",g)),(i.cancelToken||i.signal)&&(u=S=>{b&&(r(!S||S.type?new bc(null,t,b):S),b.abort(),b=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const M=eD(i.url);if(M&&wr.protocols.indexOf(M)===-1){r(new Tt("Unsupported protocol "+M+":",Tt.ERR_BAD_REQUEST,t));return}b.send(s||null)})},lD=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,i;const s=function(l){if(!i){i=!0,a();const u=l instanceof Error?l:this.reason;r.abort(u instanceof Tt?u:new bc(u instanceof Error?u.message:u))}};let o=e&&setTimeout(()=>{o=null,s(new Tt(`timeout ${e} of ms exceeded`,Tt.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),t=null)};t.forEach(l=>l.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>ye.asap(a),c}},uD=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,i;for(;r<n;)i=r+e,yield t.slice(r,i),r=i},dD=async function*(t,e){for await(const n of fD(t))yield*uD(n,e)},fD=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},FE=(t,e,n,r)=>{const i=dD(t,e);let s=0,o,a=c=>{o||(o=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:l,value:u}=await i.next();if(l){a(),c.close();return}let d=u.byteLength;if(n){let f=s+=d;n(f)}c.enqueue(new Uint8Array(u))}catch(l){throw a(l),l}},cancel(c){return a(c),i.return()}},{highWaterMark:2})},KE=64*1024,{isFunction:Uu}=ye,hD=(({Request:t,Response:e})=>({Request:t,Response:e}))(ye.global),{ReadableStream:VE,TextEncoder:jE}=ye.global,HE=(t,...e)=>{try{return!!t(...e)}catch{return!1}},pD=t=>{t=ye.merge.call({skipUndefined:!0},hD,t);const{fetch:e,Request:n,Response:r}=t,i=e?Uu(e):typeof fetch=="function",s=Uu(n),o=Uu(r);if(!i)return!1;const a=i&&Uu(VE),c=i&&(typeof jE=="function"?(v=>w=>v.encode(w))(new jE):async v=>new Uint8Array(await new n(v).arrayBuffer())),l=s&&a&&HE(()=>{let v=!1;const w=new n(wr.origin,{body:new VE,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!w}),u=o&&a&&HE(()=>ye.isReadableStream(new r("").body)),d={stream:u&&(v=>v.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!d[v]&&(d[v]=(w,b)=>{let E=w&&w[v];if(E)return E.call(w);throw new Tt(`Response type '${v}' is not supported`,Tt.ERR_NOT_SUPPORT,b)})});const f=async v=>{if(v==null)return 0;if(ye.isBlob(v))return v.size;if(ye.isSpecCompliantForm(v))return(await new n(wr.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(ye.isArrayBufferView(v)||ye.isArrayBuffer(v))return v.byteLength;if(ye.isURLSearchParams(v)&&(v=v+""),ye.isString(v))return(await c(v)).byteLength},g=async(v,w)=>{const b=ye.toFiniteNumber(v.getContentLength());return b??f(w)};return async v=>{let{url:w,method:b,data:E,signal:M,cancelToken:S,timeout:F,onDownloadProgress:D,onUploadProgress:z,responseType:X,headers:Y,withCredentials:U="same-origin",fetchOptions:B}=ER(v),H=e||fetch;X=X?(X+"").toLowerCase():"text";let V=lD([M,S&&S.toAbortSignal()],F),T=null;const p=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let y;try{if(z&&l&&b!=="get"&&b!=="head"&&(y=await g(Y,E))!==0){let x=new n(w,{method:"POST",body:E,duplex:"half"}),h;if(ye.isFormData(E)&&(h=x.headers.get("content-type"))&&Y.setContentType(h),x.body){const[m,A]=BE(y,af(UE(z)));E=FE(x.body,KE,m,A)}}ye.isString(U)||(U=U?"include":"omit");const R=s&&"credentials"in n.prototype,P={...B,signal:V,method:b.toUpperCase(),headers:Y.normalize().toJSON(),body:E,duplex:"half",credentials:R?U:void 0};T=s&&new n(w,P);let _=await(s?H(T,B):H(w,P));const I=u&&(X==="stream"||X==="response");if(u&&(D||I&&p)){const x={};["status","statusText","headers"].forEach(C=>{x[C]=_[C]});const h=ye.toFiniteNumber(_.headers.get("content-length")),[m,A]=D&&BE(h,af(UE(D),!0))||[];_=new r(FE(_.body,KE,m,()=>{A&&A(),p&&p()}),x)}X=X||"text";let N=await d[ye.findKey(d,X)||"text"](_,v);return!I&&p&&p(),await new Promise((x,h)=>{wR(x,h,{data:N,headers:Kr.from(_.headers),status:_.status,statusText:_.statusText,config:v,request:T})})}catch(R){throw p&&p(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new Tt("Network Error",Tt.ERR_NETWORK,v,T),{cause:R.cause||R}):Tt.from(R,R&&R.code,v,T)}}},mD=new Map,bR=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:i}=e,s=[r,i,n];let o=s.length,a=o,c,l,u=mD;for(;a--;)c=s[a],l=u.get(c),l===void 0&&u.set(c,l=a?new Map:pD(e)),u=l;return l};bR();const uy={http:P4,xhr:cD,fetch:{get:bR}};ye.forEach(uy,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const zE=t=>`- ${t}`,gD=t=>ye.isFunction(t)||t===null||t===!1;function yD(t,e){t=ye.isArray(t)?t:[t];const{length:n}=t;let r,i;const s={};for(let o=0;o<n;o++){r=t[o];let a;if(i=r,!gD(r)&&(i=uy[(a=String(r)).toLowerCase()],i===void 0))throw new Tt(`Unknown adapter '${a}'`);if(i&&(ye.isFunction(i)||(i=i.get(e))))break;s[a||"#"+o]=i}if(!i){const o=Object.entries(s).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?o.length>1?`since :
|
|
552
|
+
`+o.map(zE).join(`
|
|
553
|
+
`):" "+zE(o[0]):"as no adapter specified";throw new Tt("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const _R={getAdapter:yD,adapters:uy};function Rp(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new bc(null,t)}function qE(t){return Rp(t),t.headers=Kr.from(t.headers),t.data=Ap.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),_R.getAdapter(t.adapter||Gl.adapter,t)(t).then(function(r){return Rp(t),r.data=Ap.call(t,t.transformResponse,r),r.headers=Kr.from(r.headers),r},function(r){return yR(r)||(Rp(t),r&&r.response&&(r.response.data=Ap.call(t,t.transformResponse,r.response),r.response.headers=Kr.from(r.response.headers))),Promise.reject(r)})}const SR="1.13.2",Yf={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Yf[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const WE={};Yf.transitional=function(e,n,r){function i(s,o){return"[Axios v"+SR+"] Transitional option '"+s+"'"+o+(r?". "+r:"")}return(s,o,a)=>{if(e===!1)throw new Tt(i(o," has been removed"+(n?" in "+n:"")),Tt.ERR_DEPRECATED);return n&&!WE[o]&&(WE[o]=!0,console.warn(i(o," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,o,a):!0}};Yf.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function wD(t,e,n){if(typeof t!="object")throw new Tt("options must be an object",Tt.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const s=r[i],o=e[s];if(o){const a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new Tt("option "+s+" must be "+c,Tt.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Tt("Unknown option "+s,Tt.ERR_BAD_OPTION)}}const Sd={assertOptions:wD,validators:Yf},Ni=Sd.validators;let zo=class{constructor(e){this.defaults=e||{},this.interceptors={request:new DE,response:new DE}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
554
|
+
`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Xo(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&Sd.assertOptions(r,{silentJSONParsing:Ni.transitional(Ni.boolean),forcedJSONParsing:Ni.transitional(Ni.boolean),clarifyTimeoutError:Ni.transitional(Ni.boolean)},!1),i!=null&&(ye.isFunction(i)?n.paramsSerializer={serialize:i}:Sd.assertOptions(i,{encode:Ni.function,serialize:Ni.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Sd.assertOptions(n,{baseUrl:Ni.spelling("baseURL"),withXsrfToken:Ni.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=s&&ye.merge(s.common,s[n.method]);s&&ye.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Kr.concat(o,s);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const l=[];this.interceptors.response.forEach(function(w){l.push(w.fulfilled,w.rejected)});let u,d=0,f;if(!c){const v=[qE.bind(this),void 0];for(v.unshift(...a),v.push(...l),f=v.length,u=Promise.resolve(n);d<f;)u=u.then(v[d++],v[d++]);return u}f=a.length;let g=n;for(;d<f;){const v=a[d++],w=a[d++];try{g=v(g)}catch(b){w.call(this,b);break}}try{u=qE.call(this,g)}catch(v){return Promise.reject(v)}for(d=0,f=l.length;d<f;)u=u.then(l[d++],l[d++]);return u}getUri(e){e=Xo(this.defaults,e);const n=vR(e.baseURL,e.url,e.allowAbsoluteUrls);return pR(n,e.params,e.paramsSerializer)}};ye.forEach(["delete","get","head","options"],function(e){zo.prototype[e]=function(n,r){return this.request(Xo(r||{},{method:e,url:n,data:(r||{}).data}))}});ye.forEach(["post","put","patch"],function(e){function n(r){return function(s,o,a){return this.request(Xo(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}zo.prototype[e]=n(),zo.prototype[e+"Form"]=n(!0)});let vD=class xR{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{r.subscribe(a),s=a}).then(i);return o.cancel=function(){r.unsubscribe(s)},o},e(function(s,o,a){r.reason||(r.reason=new bc(s,o,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new xR(function(i){e=i}),cancel:e}}};function ED(t){return function(n){return t.apply(null,n)}}function bD(t){return ye.isObject(t)&&t.isAxiosError===!0}const pm={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(pm).forEach(([t,e])=>{pm[e]=t});function AR(t){const e=new zo(t),n=nR(zo.prototype.request,e);return ye.extend(n,zo.prototype,e,{allOwnKeys:!0}),ye.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return AR(Xo(t,i))},n}const yn=AR(Gl);yn.Axios=zo;yn.CanceledError=bc;yn.CancelToken=vD;yn.isCancel=yR;yn.VERSION=SR;yn.toFormData=Gf;yn.AxiosError=Tt;yn.Cancel=yn.CanceledError;yn.all=function(e){return Promise.all(e)};yn.spread=ED;yn.isAxiosError=bD;yn.mergeConfig=Xo;yn.AxiosHeaders=Kr;yn.formToJSON=t=>gR(ye.isHTMLForm(t)?new FormData(t):t);yn.getAdapter=_R.getAdapter;yn.HttpStatusCode=pm;yn.default=yn;const{Axios:DH,AxiosError:LH,CanceledError:BH,isCancel:UH,CancelToken:$H,VERSION:FH,all:KH,Cancel:VH,isAxiosError:_D,spread:jH,toFormData:HH,AxiosHeaders:zH,HttpStatusCode:qH,formToJSON:WH,getAdapter:GH,mergeConfig:YH}=yn,RR="http://localhost:8000".replace(/\/+$/,"");class SD{constructor(e,n=RR,r=yn){var i;this.basePath=n,this.axios=r,e&&(this.configuration=e,this.basePath=(i=e.basePath)!==null&&i!==void 0?i:n)}}class xD extends Error{constructor(e,n){super(n),this.field=e,this.name="RequiredError"}}const AD={},RD="https://example.com",ID=function(t,e,n){if(n==null)throw new xD(e,`Required parameter ${e} was null or undefined when calling ${t}.`)};function mm(t,e,n=""){e!=null&&(typeof e=="object"?Array.isArray(e)?e.forEach(r=>mm(t,r,n)):Object.keys(e).forEach(r=>mm(t,e[r],`${n}${n!==""?".":""}${r}`)):t.has(n)?t.append(n,e):t.set(n,e))}const TD=function(t,...e){const n=new URLSearchParams(t.search);mm(n,e),t.search=n.toString()},CD=function(t,e,n){const r=typeof t!="string";return(r&&n&&n.isJsonMime?n.isJsonMime(e.headers["Content-Type"]):r)?JSON.stringify(t!==void 0?t:{}):t||""},OD=function(t){return t.pathname+t.search+t.hash},ND=function(t,e,n,r){return(i=e,s=n)=>{var o;const a=Object.assign(Object.assign({},t.options),{url:(i.defaults.baseURL?"":(o=r?.basePath)!==null&&o!==void 0?o:s)+t.url});return i.request(a)}};var IR=function(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(d){o(d)}}function c(u){try{l(r.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(t,e||[])).next())})};const PD=function(t){return{postKmsRpc:(e,...n)=>IR(this,[e,...n],void 0,function*(r,i={}){ID("postKmsRpc","kmsRpcRequest",r);const s="/kms/rpc",o=new URL(s,RD);let a;t&&(a=t.baseOptions);const c=Object.assign(Object.assign({method:"POST"},a),i),l={},u={};l["Content-Type"]="application/json",TD(o,u);let d=a&&a.headers?a.headers:{};return c.headers=Object.assign(Object.assign(Object.assign({},l),d),i.headers),c.data=CD(r,c,t),{url:OD(o),options:c}})}},MD=function(t){const e=PD(t);return{postKmsRpc(n,r){return IR(this,void 0,void 0,function*(){var i,s,o;const a=yield e.postKmsRpc(n,r),c=(i=t?.serverIndex)!==null&&i!==void 0?i:0,l=(o=(s=AD["KMSRPCApi.postKmsRpc"])===null||s===void 0?void 0:s[c])===null||o===void 0?void 0:o.url;return(u,d)=>ND(a,yn,RR,t)(u,l||d)})}}};class kD extends SD{postKmsRpc(e,n){return MD(this.configuration).postKmsRpc(e,n).then(r=>r(this.axios,this.basePath))}}class DD{constructor(e={}){var n;this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.serverIndex=e.serverIndex,this.baseOptions=Object.assign(Object.assign({},e.baseOptions),{headers:Object.assign({},(n=e.baseOptions)===null||n===void 0?void 0:n.headers)}),this.formDataCtor=e.formDataCtor}isJsonMime(e){const n=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(n.test(e)||e.toLowerCase()==="application/json-patch+json")}}var gm;(function(t){t.addUserToOrganization="addUserToOrganization"})(gm||(gm={}));var Bo;(function(t){t.ed25519="Ed25519",t.secp256r1="Secp256r1",t.secp256k1="Secp256k1",t.secp256k1Keccak256="Secp256k1Keccak256",t.secp256k1Schnorr="Secp256k1Schnorr"})(Bo||(Bo={}));var ym;(function(t){t.createAuthenticator="createAuthenticator"})(ym||(ym={}));var wm;(function(t){t.createOrganization="createOrganization"})(wm||(wm={}));var vm;(function(t){t.createWallet="createWallet"})(vm||(vm={}));var Em;(function(t){t.deleteAuthenticator="deleteAuthenticator"})(Em||(Em={}));var La;(function(t){t.ed25519="Ed25519",t.secp256k1="Secp256k1"})(La||(La={}));var yt;(function(t){t.ethereum="Ethereum",t.solana="Solana",t.bitcoinSegwit="BitcoinSegwit",t.sui="Sui"})(yt||(yt={}));var cf;(function(t){t.getAccounts="getAccounts"})(cf||(cf={}));var bm;(function(t){t.grantOrganizationAccess="grantOrganizationAccess"})(bm||(bm={}));var _m;(function(t){t.signTransaction="signTransaction"})(_m||(_m={}));var Sm;(function(t){t.signUtf8Message="signUtf8Message"})(Sm||(Sm={}));var xm;(function(t){t.root="ROOT"})(xm||(xm={}));var Ip={},Kc={},GE;function LD(){if(GE)return Kc;GE=1,Kc.byteLength=a,Kc.toByteArray=l,Kc.fromByteArray=f;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,s=r.length;i<s;++i)t[i]=r[i],e[r.charCodeAt(i)]=i;e[45]=62,e[95]=63;function o(g){var v=g.length;if(v%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=g.indexOf("=");w===-1&&(w=v);var b=w===v?0:4-w%4;return[w,b]}function a(g){var v=o(g),w=v[0],b=v[1];return(w+b)*3/4-b}function c(g,v,w){return(v+w)*3/4-w}function l(g){var v,w=o(g),b=w[0],E=w[1],M=new n(c(g,b,E)),S=0,F=E>0?b-4:b,D;for(D=0;D<F;D+=4)v=e[g.charCodeAt(D)]<<18|e[g.charCodeAt(D+1)]<<12|e[g.charCodeAt(D+2)]<<6|e[g.charCodeAt(D+3)],M[S++]=v>>16&255,M[S++]=v>>8&255,M[S++]=v&255;return E===2&&(v=e[g.charCodeAt(D)]<<2|e[g.charCodeAt(D+1)]>>4,M[S++]=v&255),E===1&&(v=e[g.charCodeAt(D)]<<10|e[g.charCodeAt(D+1)]<<4|e[g.charCodeAt(D+2)]>>2,M[S++]=v>>8&255,M[S++]=v&255),M}function u(g){return t[g>>18&63]+t[g>>12&63]+t[g>>6&63]+t[g&63]}function d(g,v,w){for(var b,E=[],M=v;M<w;M+=3)b=(g[M]<<16&16711680)+(g[M+1]<<8&65280)+(g[M+2]&255),E.push(u(b));return E.join("")}function f(g){for(var v,w=g.length,b=w%3,E=[],M=16383,S=0,F=w-b;S<F;S+=M)E.push(d(g,S,S+M>F?F:S+M));return b===1?(v=g[w-1],E.push(t[v>>2]+t[v<<4&63]+"==")):b===2&&(v=(g[w-2]<<8)+g[w-1],E.push(t[v>>10]+t[v>>4&63]+t[v<<2&63]+"=")),E.join("")}return Kc}var $u={};var YE;function BD(){return YE||(YE=1,$u.read=function(t,e,n,r,i){var s,o,a=i*8-r-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,g=t[e+d];for(d+=f,s=g&(1<<-u)-1,g>>=-u,u+=a;u>0;s=s*256+t[e+d],d+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=o*256+t[e+d],d+=f,u-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(g?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-l}return(g?-1:1)*o*Math.pow(2,s-r)},$u.write=function(t,e,n,r,i,s){var o,a,c,l=s*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=r?0:s-1,v=r?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=f/c:e+=f*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=u?(a=0,o=u):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[n+g]=a&255,g+=v,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[n+g]=o&255,g+=v,o/=256,l-=8);t[n+g-v]|=w*128}),$u}var JE;function dy(){return JE||(JE=1,(function(t){const e=LD(),n=BD(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=M,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=s(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const q=new Uint8Array(1),k={foo:function(){return 42}};return Object.setPrototypeOf(k,Uint8Array.prototype),Object.setPrototypeOf(q,k),q.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(q){if(q>i)throw new RangeError('The value "'+q+'" is invalid for option "size"');const k=new Uint8Array(q);return Object.setPrototypeOf(k,a.prototype),k}function a(q,k,L){if(typeof q=="number"){if(typeof k=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return d(q)}return c(q,k,L)}a.poolSize=8192;function c(q,k,L){if(typeof q=="string")return f(q,k);if(ArrayBuffer.isView(q))return v(q);if(q==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q);if(He(q,ArrayBuffer)||q&&He(q.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(He(q,SharedArrayBuffer)||q&&He(q.buffer,SharedArrayBuffer)))return w(q,k,L);if(typeof q=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Q=q.valueOf&&q.valueOf();if(Q!=null&&Q!==q)return a.from(Q,k,L);const oe=b(q);if(oe)return oe;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]=="function")return a.from(q[Symbol.toPrimitive]("string"),k,L);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q)}a.from=function(q,k,L){return c(q,k,L)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function l(q){if(typeof q!="number")throw new TypeError('"size" argument must be of type number');if(q<0)throw new RangeError('The value "'+q+'" is invalid for option "size"')}function u(q,k,L){return l(q),q<=0?o(q):k!==void 0?typeof L=="string"?o(q).fill(k,L):o(q).fill(k):o(q)}a.alloc=function(q,k,L){return u(q,k,L)};function d(q){return l(q),o(q<0?0:E(q)|0)}a.allocUnsafe=function(q){return d(q)},a.allocUnsafeSlow=function(q){return d(q)};function f(q,k){if((typeof k!="string"||k==="")&&(k="utf8"),!a.isEncoding(k))throw new TypeError("Unknown encoding: "+k);const L=S(q,k)|0;let Q=o(L);const oe=Q.write(q,k);return oe!==L&&(Q=Q.slice(0,oe)),Q}function g(q){const k=q.length<0?0:E(q.length)|0,L=o(k);for(let Q=0;Q<k;Q+=1)L[Q]=q[Q]&255;return L}function v(q){if(He(q,Uint8Array)){const k=new Uint8Array(q);return w(k.buffer,k.byteOffset,k.byteLength)}return g(q)}function w(q,k,L){if(k<0||q.byteLength<k)throw new RangeError('"offset" is outside of buffer bounds');if(q.byteLength<k+(L||0))throw new RangeError('"length" is outside of buffer bounds');let Q;return k===void 0&&L===void 0?Q=new Uint8Array(q):L===void 0?Q=new Uint8Array(q,k):Q=new Uint8Array(q,k,L),Object.setPrototypeOf(Q,a.prototype),Q}function b(q){if(a.isBuffer(q)){const k=E(q.length)|0,L=o(k);return L.length===0||q.copy(L,0,0,k),L}if(q.length!==void 0)return typeof q.length!="number"||Ke(q.length)?o(0):g(q);if(q.type==="Buffer"&&Array.isArray(q.data))return g(q.data)}function E(q){if(q>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return q|0}function M(q){return+q!=q&&(q=0),a.alloc(+q)}a.isBuffer=function(k){return k!=null&&k._isBuffer===!0&&k!==a.prototype},a.compare=function(k,L){if(He(k,Uint8Array)&&(k=a.from(k,k.offset,k.byteLength)),He(L,Uint8Array)&&(L=a.from(L,L.offset,L.byteLength)),!a.isBuffer(k)||!a.isBuffer(L))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(k===L)return 0;let Q=k.length,oe=L.length;for(let le=0,we=Math.min(Q,oe);le<we;++le)if(k[le]!==L[le]){Q=k[le],oe=L[le];break}return Q<oe?-1:oe<Q?1:0},a.isEncoding=function(k){switch(String(k).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(k,L){if(!Array.isArray(k))throw new TypeError('"list" argument must be an Array of Buffers');if(k.length===0)return a.alloc(0);let Q;if(L===void 0)for(L=0,Q=0;Q<k.length;++Q)L+=k[Q].length;const oe=a.allocUnsafe(L);let le=0;for(Q=0;Q<k.length;++Q){let we=k[Q];if(He(we,Uint8Array))le+we.length>oe.length?(a.isBuffer(we)||(we=a.from(we)),we.copy(oe,le)):Uint8Array.prototype.set.call(oe,we,le);else if(a.isBuffer(we))we.copy(oe,le);else throw new TypeError('"list" argument must be an Array of Buffers');le+=we.length}return oe};function S(q,k){if(a.isBuffer(q))return q.length;if(ArrayBuffer.isView(q)||He(q,ArrayBuffer))return q.byteLength;if(typeof q!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof q);const L=q.length,Q=arguments.length>2&&arguments[2]===!0;if(!Q&&L===0)return 0;let oe=!1;for(;;)switch(k){case"ascii":case"latin1":case"binary":return L;case"utf8":case"utf-8":return Oe(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L*2;case"hex":return L>>>1;case"base64":return $e(q).length;default:if(oe)return Q?-1:Oe(q).length;k=(""+k).toLowerCase(),oe=!0}}a.byteLength=S;function F(q,k,L){let Q=!1;if((k===void 0||k<0)&&(k=0),k>this.length||((L===void 0||L>this.length)&&(L=this.length),L<=0)||(L>>>=0,k>>>=0,L<=k))return"";for(q||(q="utf8");;)switch(q){case"hex":return I(this,k,L);case"utf8":case"utf-8":return p(this,k,L);case"ascii":return P(this,k,L);case"latin1":case"binary":return _(this,k,L);case"base64":return T(this,k,L);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,k,L);default:if(Q)throw new TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),Q=!0}}a.prototype._isBuffer=!0;function D(q,k,L){const Q=q[k];q[k]=q[L],q[L]=Q}a.prototype.swap16=function(){const k=this.length;if(k%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let L=0;L<k;L+=2)D(this,L,L+1);return this},a.prototype.swap32=function(){const k=this.length;if(k%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let L=0;L<k;L+=4)D(this,L,L+3),D(this,L+1,L+2);return this},a.prototype.swap64=function(){const k=this.length;if(k%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let L=0;L<k;L+=8)D(this,L,L+7),D(this,L+1,L+6),D(this,L+2,L+5),D(this,L+3,L+4);return this},a.prototype.toString=function(){const k=this.length;return k===0?"":arguments.length===0?p(this,0,k):F.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(k){if(!a.isBuffer(k))throw new TypeError("Argument must be a Buffer");return this===k?!0:a.compare(this,k)===0},a.prototype.inspect=function(){let k="";const L=t.INSPECT_MAX_BYTES;return k=this.toString("hex",0,L).replace(/(.{2})/g,"$1 ").trim(),this.length>L&&(k+=" ... "),"<Buffer "+k+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(k,L,Q,oe,le){if(He(k,Uint8Array)&&(k=a.from(k,k.offset,k.byteLength)),!a.isBuffer(k))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof k);if(L===void 0&&(L=0),Q===void 0&&(Q=k?k.length:0),oe===void 0&&(oe=0),le===void 0&&(le=this.length),L<0||Q>k.length||oe<0||le>this.length)throw new RangeError("out of range index");if(oe>=le&&L>=Q)return 0;if(oe>=le)return-1;if(L>=Q)return 1;if(L>>>=0,Q>>>=0,oe>>>=0,le>>>=0,this===k)return 0;let we=le-oe,wt=Q-L;const ut=Math.min(we,wt),at=this.slice(oe,le),Gt=k.slice(L,Q);for(let ot=0;ot<ut;++ot)if(at[ot]!==Gt[ot]){we=at[ot],wt=Gt[ot];break}return we<wt?-1:wt<we?1:0};function z(q,k,L,Q,oe){if(q.length===0)return-1;if(typeof L=="string"?(Q=L,L=0):L>2147483647?L=2147483647:L<-2147483648&&(L=-2147483648),L=+L,Ke(L)&&(L=oe?0:q.length-1),L<0&&(L=q.length+L),L>=q.length){if(oe)return-1;L=q.length-1}else if(L<0)if(oe)L=0;else return-1;if(typeof k=="string"&&(k=a.from(k,Q)),a.isBuffer(k))return k.length===0?-1:X(q,k,L,Q,oe);if(typeof k=="number")return k=k&255,typeof Uint8Array.prototype.indexOf=="function"?oe?Uint8Array.prototype.indexOf.call(q,k,L):Uint8Array.prototype.lastIndexOf.call(q,k,L):X(q,[k],L,Q,oe);throw new TypeError("val must be string, number or Buffer")}function X(q,k,L,Q,oe){let le=1,we=q.length,wt=k.length;if(Q!==void 0&&(Q=String(Q).toLowerCase(),Q==="ucs2"||Q==="ucs-2"||Q==="utf16le"||Q==="utf-16le")){if(q.length<2||k.length<2)return-1;le=2,we/=2,wt/=2,L/=2}function ut(Gt,ot){return le===1?Gt[ot]:Gt.readUInt16BE(ot*le)}let at;if(oe){let Gt=-1;for(at=L;at<we;at++)if(ut(q,at)===ut(k,Gt===-1?0:at-Gt)){if(Gt===-1&&(Gt=at),at-Gt+1===wt)return Gt*le}else Gt!==-1&&(at-=at-Gt),Gt=-1}else for(L+wt>we&&(L=we-wt),at=L;at>=0;at--){let Gt=!0;for(let ot=0;ot<wt;ot++)if(ut(q,at+ot)!==ut(k,ot)){Gt=!1;break}if(Gt)return at}return-1}a.prototype.includes=function(k,L,Q){return this.indexOf(k,L,Q)!==-1},a.prototype.indexOf=function(k,L,Q){return z(this,k,L,Q,!0)},a.prototype.lastIndexOf=function(k,L,Q){return z(this,k,L,Q,!1)};function Y(q,k,L,Q){L=Number(L)||0;const oe=q.length-L;Q?(Q=Number(Q),Q>oe&&(Q=oe)):Q=oe;const le=k.length;Q>le/2&&(Q=le/2);let we;for(we=0;we<Q;++we){const wt=parseInt(k.substr(we*2,2),16);if(Ke(wt))return we;q[L+we]=wt}return we}function U(q,k,L,Q){return Je(Oe(k,q.length-L),q,L,Q)}function B(q,k,L,Q){return Je(Le(k),q,L,Q)}function H(q,k,L,Q){return Je($e(k),q,L,Q)}function V(q,k,L,Q){return Je(je(k,q.length-L),q,L,Q)}a.prototype.write=function(k,L,Q,oe){if(L===void 0)oe="utf8",Q=this.length,L=0;else if(Q===void 0&&typeof L=="string")oe=L,Q=this.length,L=0;else if(isFinite(L))L=L>>>0,isFinite(Q)?(Q=Q>>>0,oe===void 0&&(oe="utf8")):(oe=Q,Q=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const le=this.length-L;if((Q===void 0||Q>le)&&(Q=le),k.length>0&&(Q<0||L<0)||L>this.length)throw new RangeError("Attempt to write outside buffer bounds");oe||(oe="utf8");let we=!1;for(;;)switch(oe){case"hex":return Y(this,k,L,Q);case"utf8":case"utf-8":return U(this,k,L,Q);case"ascii":case"latin1":case"binary":return B(this,k,L,Q);case"base64":return H(this,k,L,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,k,L,Q);default:if(we)throw new TypeError("Unknown encoding: "+oe);oe=(""+oe).toLowerCase(),we=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(q,k,L){return k===0&&L===q.length?e.fromByteArray(q):e.fromByteArray(q.slice(k,L))}function p(q,k,L){L=Math.min(q.length,L);const Q=[];let oe=k;for(;oe<L;){const le=q[oe];let we=null,wt=le>239?4:le>223?3:le>191?2:1;if(oe+wt<=L){let ut,at,Gt,ot;switch(wt){case 1:le<128&&(we=le);break;case 2:ut=q[oe+1],(ut&192)===128&&(ot=(le&31)<<6|ut&63,ot>127&&(we=ot));break;case 3:ut=q[oe+1],at=q[oe+2],(ut&192)===128&&(at&192)===128&&(ot=(le&15)<<12|(ut&63)<<6|at&63,ot>2047&&(ot<55296||ot>57343)&&(we=ot));break;case 4:ut=q[oe+1],at=q[oe+2],Gt=q[oe+3],(ut&192)===128&&(at&192)===128&&(Gt&192)===128&&(ot=(le&15)<<18|(ut&63)<<12|(at&63)<<6|Gt&63,ot>65535&&ot<1114112&&(we=ot))}}we===null?(we=65533,wt=1):we>65535&&(we-=65536,Q.push(we>>>10&1023|55296),we=56320|we&1023),Q.push(we),oe+=wt}return R(Q)}const y=4096;function R(q){const k=q.length;if(k<=y)return String.fromCharCode.apply(String,q);let L="",Q=0;for(;Q<k;)L+=String.fromCharCode.apply(String,q.slice(Q,Q+=y));return L}function P(q,k,L){let Q="";L=Math.min(q.length,L);for(let oe=k;oe<L;++oe)Q+=String.fromCharCode(q[oe]&127);return Q}function _(q,k,L){let Q="";L=Math.min(q.length,L);for(let oe=k;oe<L;++oe)Q+=String.fromCharCode(q[oe]);return Q}function I(q,k,L){const Q=q.length;(!k||k<0)&&(k=0),(!L||L<0||L>Q)&&(L=Q);let oe="";for(let le=k;le<L;++le)oe+=Ge[q[le]];return oe}function N(q,k,L){const Q=q.slice(k,L);let oe="";for(let le=0;le<Q.length-1;le+=2)oe+=String.fromCharCode(Q[le]+Q[le+1]*256);return oe}a.prototype.slice=function(k,L){const Q=this.length;k=~~k,L=L===void 0?Q:~~L,k<0?(k+=Q,k<0&&(k=0)):k>Q&&(k=Q),L<0?(L+=Q,L<0&&(L=0)):L>Q&&(L=Q),L<k&&(L=k);const oe=this.subarray(k,L);return Object.setPrototypeOf(oe,a.prototype),oe};function x(q,k,L){if(q%1!==0||q<0)throw new RangeError("offset is not uint");if(q+k>L)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(k,L,Q){k=k>>>0,L=L>>>0,Q||x(k,L,this.length);let oe=this[k],le=1,we=0;for(;++we<L&&(le*=256);)oe+=this[k+we]*le;return oe},a.prototype.readUintBE=a.prototype.readUIntBE=function(k,L,Q){k=k>>>0,L=L>>>0,Q||x(k,L,this.length);let oe=this[k+--L],le=1;for(;L>0&&(le*=256);)oe+=this[k+--L]*le;return oe},a.prototype.readUint8=a.prototype.readUInt8=function(k,L){return k=k>>>0,L||x(k,1,this.length),this[k]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(k,L){return k=k>>>0,L||x(k,2,this.length),this[k]|this[k+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(k,L){return k=k>>>0,L||x(k,2,this.length),this[k]<<8|this[k+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(k,L){return k=k>>>0,L||x(k,4,this.length),(this[k]|this[k+1]<<8|this[k+2]<<16)+this[k+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(k,L){return k=k>>>0,L||x(k,4,this.length),this[k]*16777216+(this[k+1]<<16|this[k+2]<<8|this[k+3])},a.prototype.readBigUInt64LE=Dt(function(k){k=k>>>0,Ae(k,"offset");const L=this[k],Q=this[k+7];(L===void 0||Q===void 0)&&Ce(k,this.length-8);const oe=L+this[++k]*2**8+this[++k]*2**16+this[++k]*2**24,le=this[++k]+this[++k]*2**8+this[++k]*2**16+Q*2**24;return BigInt(oe)+(BigInt(le)<<BigInt(32))}),a.prototype.readBigUInt64BE=Dt(function(k){k=k>>>0,Ae(k,"offset");const L=this[k],Q=this[k+7];(L===void 0||Q===void 0)&&Ce(k,this.length-8);const oe=L*2**24+this[++k]*2**16+this[++k]*2**8+this[++k],le=this[++k]*2**24+this[++k]*2**16+this[++k]*2**8+Q;return(BigInt(oe)<<BigInt(32))+BigInt(le)}),a.prototype.readIntLE=function(k,L,Q){k=k>>>0,L=L>>>0,Q||x(k,L,this.length);let oe=this[k],le=1,we=0;for(;++we<L&&(le*=256);)oe+=this[k+we]*le;return le*=128,oe>=le&&(oe-=Math.pow(2,8*L)),oe},a.prototype.readIntBE=function(k,L,Q){k=k>>>0,L=L>>>0,Q||x(k,L,this.length);let oe=L,le=1,we=this[k+--oe];for(;oe>0&&(le*=256);)we+=this[k+--oe]*le;return le*=128,we>=le&&(we-=Math.pow(2,8*L)),we},a.prototype.readInt8=function(k,L){return k=k>>>0,L||x(k,1,this.length),this[k]&128?(255-this[k]+1)*-1:this[k]},a.prototype.readInt16LE=function(k,L){k=k>>>0,L||x(k,2,this.length);const Q=this[k]|this[k+1]<<8;return Q&32768?Q|4294901760:Q},a.prototype.readInt16BE=function(k,L){k=k>>>0,L||x(k,2,this.length);const Q=this[k+1]|this[k]<<8;return Q&32768?Q|4294901760:Q},a.prototype.readInt32LE=function(k,L){return k=k>>>0,L||x(k,4,this.length),this[k]|this[k+1]<<8|this[k+2]<<16|this[k+3]<<24},a.prototype.readInt32BE=function(k,L){return k=k>>>0,L||x(k,4,this.length),this[k]<<24|this[k+1]<<16|this[k+2]<<8|this[k+3]},a.prototype.readBigInt64LE=Dt(function(k){k=k>>>0,Ae(k,"offset");const L=this[k],Q=this[k+7];(L===void 0||Q===void 0)&&Ce(k,this.length-8);const oe=this[k+4]+this[k+5]*2**8+this[k+6]*2**16+(Q<<24);return(BigInt(oe)<<BigInt(32))+BigInt(L+this[++k]*2**8+this[++k]*2**16+this[++k]*2**24)}),a.prototype.readBigInt64BE=Dt(function(k){k=k>>>0,Ae(k,"offset");const L=this[k],Q=this[k+7];(L===void 0||Q===void 0)&&Ce(k,this.length-8);const oe=(L<<24)+this[++k]*2**16+this[++k]*2**8+this[++k];return(BigInt(oe)<<BigInt(32))+BigInt(this[++k]*2**24+this[++k]*2**16+this[++k]*2**8+Q)}),a.prototype.readFloatLE=function(k,L){return k=k>>>0,L||x(k,4,this.length),n.read(this,k,!0,23,4)},a.prototype.readFloatBE=function(k,L){return k=k>>>0,L||x(k,4,this.length),n.read(this,k,!1,23,4)},a.prototype.readDoubleLE=function(k,L){return k=k>>>0,L||x(k,8,this.length),n.read(this,k,!0,52,8)},a.prototype.readDoubleBE=function(k,L){return k=k>>>0,L||x(k,8,this.length),n.read(this,k,!1,52,8)};function h(q,k,L,Q,oe,le){if(!a.isBuffer(q))throw new TypeError('"buffer" argument must be a Buffer instance');if(k>oe||k<le)throw new RangeError('"value" argument is out of bounds');if(L+Q>q.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(k,L,Q,oe){if(k=+k,L=L>>>0,Q=Q>>>0,!oe){const wt=Math.pow(2,8*Q)-1;h(this,k,L,Q,wt,0)}let le=1,we=0;for(this[L]=k&255;++we<Q&&(le*=256);)this[L+we]=k/le&255;return L+Q},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(k,L,Q,oe){if(k=+k,L=L>>>0,Q=Q>>>0,!oe){const wt=Math.pow(2,8*Q)-1;h(this,k,L,Q,wt,0)}let le=Q-1,we=1;for(this[L+le]=k&255;--le>=0&&(we*=256);)this[L+le]=k/we&255;return L+Q},a.prototype.writeUint8=a.prototype.writeUInt8=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,1,255,0),this[L]=k&255,L+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,2,65535,0),this[L]=k&255,this[L+1]=k>>>8,L+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,2,65535,0),this[L]=k>>>8,this[L+1]=k&255,L+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,4,4294967295,0),this[L+3]=k>>>24,this[L+2]=k>>>16,this[L+1]=k>>>8,this[L]=k&255,L+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,4,4294967295,0),this[L]=k>>>24,this[L+1]=k>>>16,this[L+2]=k>>>8,this[L+3]=k&255,L+4};function m(q,k,L,Q,oe){de(k,Q,oe,q,L,7);let le=Number(k&BigInt(4294967295));q[L++]=le,le=le>>8,q[L++]=le,le=le>>8,q[L++]=le,le=le>>8,q[L++]=le;let we=Number(k>>BigInt(32)&BigInt(4294967295));return q[L++]=we,we=we>>8,q[L++]=we,we=we>>8,q[L++]=we,we=we>>8,q[L++]=we,L}function A(q,k,L,Q,oe){de(k,Q,oe,q,L,7);let le=Number(k&BigInt(4294967295));q[L+7]=le,le=le>>8,q[L+6]=le,le=le>>8,q[L+5]=le,le=le>>8,q[L+4]=le;let we=Number(k>>BigInt(32)&BigInt(4294967295));return q[L+3]=we,we=we>>8,q[L+2]=we,we=we>>8,q[L+1]=we,we=we>>8,q[L]=we,L+8}a.prototype.writeBigUInt64LE=Dt(function(k,L=0){return m(this,k,L,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Dt(function(k,L=0){return A(this,k,L,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(k,L,Q,oe){if(k=+k,L=L>>>0,!oe){const ut=Math.pow(2,8*Q-1);h(this,k,L,Q,ut-1,-ut)}let le=0,we=1,wt=0;for(this[L]=k&255;++le<Q&&(we*=256);)k<0&&wt===0&&this[L+le-1]!==0&&(wt=1),this[L+le]=(k/we>>0)-wt&255;return L+Q},a.prototype.writeIntBE=function(k,L,Q,oe){if(k=+k,L=L>>>0,!oe){const ut=Math.pow(2,8*Q-1);h(this,k,L,Q,ut-1,-ut)}let le=Q-1,we=1,wt=0;for(this[L+le]=k&255;--le>=0&&(we*=256);)k<0&&wt===0&&this[L+le+1]!==0&&(wt=1),this[L+le]=(k/we>>0)-wt&255;return L+Q},a.prototype.writeInt8=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,1,127,-128),k<0&&(k=255+k+1),this[L]=k&255,L+1},a.prototype.writeInt16LE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,2,32767,-32768),this[L]=k&255,this[L+1]=k>>>8,L+2},a.prototype.writeInt16BE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,2,32767,-32768),this[L]=k>>>8,this[L+1]=k&255,L+2},a.prototype.writeInt32LE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,4,2147483647,-2147483648),this[L]=k&255,this[L+1]=k>>>8,this[L+2]=k>>>16,this[L+3]=k>>>24,L+4},a.prototype.writeInt32BE=function(k,L,Q){return k=+k,L=L>>>0,Q||h(this,k,L,4,2147483647,-2147483648),k<0&&(k=4294967295+k+1),this[L]=k>>>24,this[L+1]=k>>>16,this[L+2]=k>>>8,this[L+3]=k&255,L+4},a.prototype.writeBigInt64LE=Dt(function(k,L=0){return m(this,k,L,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Dt(function(k,L=0){return A(this,k,L,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function C(q,k,L,Q,oe,le){if(L+Q>q.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("Index out of range")}function $(q,k,L,Q,oe){return k=+k,L=L>>>0,oe||C(q,k,L,4),n.write(q,k,L,Q,23,4),L+4}a.prototype.writeFloatLE=function(k,L,Q){return $(this,k,L,!0,Q)},a.prototype.writeFloatBE=function(k,L,Q){return $(this,k,L,!1,Q)};function j(q,k,L,Q,oe){return k=+k,L=L>>>0,oe||C(q,k,L,8),n.write(q,k,L,Q,52,8),L+8}a.prototype.writeDoubleLE=function(k,L,Q){return j(this,k,L,!0,Q)},a.prototype.writeDoubleBE=function(k,L,Q){return j(this,k,L,!1,Q)},a.prototype.copy=function(k,L,Q,oe){if(!a.isBuffer(k))throw new TypeError("argument should be a Buffer");if(Q||(Q=0),!oe&&oe!==0&&(oe=this.length),L>=k.length&&(L=k.length),L||(L=0),oe>0&&oe<Q&&(oe=Q),oe===Q||k.length===0||this.length===0)return 0;if(L<0)throw new RangeError("targetStart out of bounds");if(Q<0||Q>=this.length)throw new RangeError("Index out of range");if(oe<0)throw new RangeError("sourceEnd out of bounds");oe>this.length&&(oe=this.length),k.length-L<oe-Q&&(oe=k.length-L+Q);const le=oe-Q;return this===k&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(L,Q,oe):Uint8Array.prototype.set.call(k,this.subarray(Q,oe),L),le},a.prototype.fill=function(k,L,Q,oe){if(typeof k=="string"){if(typeof L=="string"?(oe=L,L=0,Q=this.length):typeof Q=="string"&&(oe=Q,Q=this.length),oe!==void 0&&typeof oe!="string")throw new TypeError("encoding must be a string");if(typeof oe=="string"&&!a.isEncoding(oe))throw new TypeError("Unknown encoding: "+oe);if(k.length===1){const we=k.charCodeAt(0);(oe==="utf8"&&we<128||oe==="latin1")&&(k=we)}}else typeof k=="number"?k=k&255:typeof k=="boolean"&&(k=Number(k));if(L<0||this.length<L||this.length<Q)throw new RangeError("Out of range index");if(Q<=L)return this;L=L>>>0,Q=Q===void 0?this.length:Q>>>0,k||(k=0);let le;if(typeof k=="number")for(le=L;le<Q;++le)this[le]=k;else{const we=a.isBuffer(k)?k:a.from(k,oe),wt=we.length;if(wt===0)throw new TypeError('The value "'+k+'" is invalid for argument "value"');for(le=0;le<Q-L;++le)this[le+L]=we[le%wt]}return this};const Z={};function ne(q,k,L){Z[q]=class extends L{constructor(){super(),Object.defineProperty(this,"message",{value:k.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${q}]`,this.stack,delete this.name}get code(){return q}set code(oe){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:oe,writable:!0})}toString(){return`${this.name} [${q}]: ${this.message}`}}}ne("ERR_BUFFER_OUT_OF_BOUNDS",function(q){return q?`${q} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ne("ERR_INVALID_ARG_TYPE",function(q,k){return`The "${q}" argument must be of type number. Received type ${typeof k}`},TypeError),ne("ERR_OUT_OF_RANGE",function(q,k,L){let Q=`The value of "${q}" is out of range.`,oe=L;return Number.isInteger(L)&&Math.abs(L)>2**32?oe=se(String(L)):typeof L=="bigint"&&(oe=String(L),(L>BigInt(2)**BigInt(32)||L<-(BigInt(2)**BigInt(32)))&&(oe=se(oe)),oe+="n"),Q+=` It must be ${k}. Received ${oe}`,Q},RangeError);function se(q){let k="",L=q.length;const Q=q[0]==="-"?1:0;for(;L>=Q+4;L-=3)k=`_${q.slice(L-3,L)}${k}`;return`${q.slice(0,L)}${k}`}function ue(q,k,L){Ae(k,"offset"),(q[k]===void 0||q[k+L]===void 0)&&Ce(k,q.length-(L+1))}function de(q,k,L,Q,oe,le){if(q>L||q<k){const we=typeof k=="bigint"?"n":"";let wt;throw k===0||k===BigInt(0)?wt=`>= 0${we} and < 2${we} ** ${(le+1)*8}${we}`:wt=`>= -(2${we} ** ${(le+1)*8-1}${we}) and < 2 ** ${(le+1)*8-1}${we}`,new Z.ERR_OUT_OF_RANGE("value",wt,q)}ue(Q,oe,le)}function Ae(q,k){if(typeof q!="number")throw new Z.ERR_INVALID_ARG_TYPE(k,"number",q)}function Ce(q,k,L){throw Math.floor(q)!==q?(Ae(q,L),new Z.ERR_OUT_OF_RANGE("offset","an integer",q)):k<0?new Z.ERR_BUFFER_OUT_OF_BOUNDS:new Z.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${k}`,q)}const Ue=/[^+/0-9A-Za-z-_]/g;function Be(q){if(q=q.split("=")[0],q=q.trim().replace(Ue,""),q.length<2)return"";for(;q.length%4!==0;)q=q+"=";return q}function Oe(q,k){k=k||1/0;let L;const Q=q.length;let oe=null;const le=[];for(let we=0;we<Q;++we){if(L=q.charCodeAt(we),L>55295&&L<57344){if(!oe){if(L>56319){(k-=3)>-1&&le.push(239,191,189);continue}else if(we+1===Q){(k-=3)>-1&&le.push(239,191,189);continue}oe=L;continue}if(L<56320){(k-=3)>-1&&le.push(239,191,189),oe=L;continue}L=(oe-55296<<10|L-56320)+65536}else oe&&(k-=3)>-1&&le.push(239,191,189);if(oe=null,L<128){if((k-=1)<0)break;le.push(L)}else if(L<2048){if((k-=2)<0)break;le.push(L>>6|192,L&63|128)}else if(L<65536){if((k-=3)<0)break;le.push(L>>12|224,L>>6&63|128,L&63|128)}else if(L<1114112){if((k-=4)<0)break;le.push(L>>18|240,L>>12&63|128,L>>6&63|128,L&63|128)}else throw new Error("Invalid code point")}return le}function Le(q){const k=[];for(let L=0;L<q.length;++L)k.push(q.charCodeAt(L)&255);return k}function je(q,k){let L,Q,oe;const le=[];for(let we=0;we<q.length&&!((k-=2)<0);++we)L=q.charCodeAt(we),Q=L>>8,oe=L%256,le.push(oe),le.push(Q);return le}function $e(q){return e.toByteArray(Be(q))}function Je(q,k,L,Q){let oe;for(oe=0;oe<Q&&!(oe+L>=k.length||oe>=q.length);++oe)k[oe+L]=q[oe];return oe}function He(q,k){return q instanceof k||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===k.name}function Ke(q){return q!==q}const Ge=(function(){const q="0123456789abcdef",k=new Array(256);for(let L=0;L<16;++L){const Q=L*16;for(let oe=0;oe<16;++oe)k[Q+oe]=q[L]+q[oe]}return k})();function Dt(q){return typeof BigInt>"u"?_t:q}function _t(){throw new Error("BigInt not supported")}})(Ip)),Ip}var Et=dy(),Sn=(t=>(t.SOLANA_MAINNET="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",t.SOLANA_DEVNET="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",t.SOLANA_TESTNET="solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",t.ETHEREUM_MAINNET="eip155:1",t.ETHEREUM_SEPOLIA="eip155:11155111",t.POLYGON_MAINNET="eip155:137",t.POLYGON_AMOY="eip155:80002",t.BASE_MAINNET="eip155:8453",t.BASE_SEPOLIA="eip155:84532",t.ARBITRUM_ONE="eip155:42161",t.ARBITRUM_SEPOLIA="eip155:421614",t.MONAD_MAINNET="eip155:143",t.MONAD_TESTNET="eip155:10143",t.BITCOIN_MAINNET="bip122:000000000019d6689c085ae165831e93",t.BITCOIN_TESTNET="bip122:000000000933ea01ad0ee984209779ba",t.SUI_MAINNET="sui:35834a8a",t.SUI_TESTNET="sui:4c78adac",t.SUI_DEVNET="sui:devnet",t))(Sn||{}),Qo={"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":{name:"Solana Mainnet",chain:"solana",network:"mainnet",internalCaip:"solana:101",slip44:"501",explorer:{name:"Solscan",transactionUrl:"https://solscan.io/tx/{hash}",addressUrl:"https://solscan.io/account/{address}"}},"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1":{name:"Solana Devnet",chain:"solana",network:"devnet",internalCaip:"solana:103",slip44:"501",explorer:{name:"Solscan",transactionUrl:"https://solscan.io/tx/{hash}?cluster=devnet",addressUrl:"https://solscan.io/account/{address}?cluster=devnet"}},"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":{name:"Solana Testnet",chain:"solana",network:"testnet",internalCaip:"solana:102",slip44:"501",explorer:{name:"Solscan",transactionUrl:"https://solscan.io/tx/{hash}?cluster=testnet",addressUrl:"https://solscan.io/account/{address}?cluster=testnet"}},"eip155:1":{name:"Ethereum Mainnet",chain:"ethereum",network:"mainnet",internalCaip:"eip155:1",chainId:1,slip44:"60",explorer:{name:"Etherscan",transactionUrl:"https://etherscan.io/tx/{hash}",addressUrl:"https://etherscan.io/address/{address}"}},"eip155:11155111":{name:"Ethereum Sepolia",chain:"ethereum",network:"sepolia",internalCaip:"eip155:11155111",chainId:11155111,slip44:"60",explorer:{name:"Etherscan",transactionUrl:"https://sepolia.etherscan.io/tx/{hash}",addressUrl:"https://sepolia.etherscan.io/address/{address}"}},"eip155:137":{name:"Polygon Mainnet",chain:"polygon",network:"mainnet",internalCaip:"eip155:137",chainId:137,slip44:"137",explorer:{name:"Polygonscan",transactionUrl:"https://polygonscan.com/tx/{hash}",addressUrl:"https://polygonscan.com/address/{address}"}},"eip155:80002":{name:"Polygon Amoy",chain:"polygon",network:"amoy",internalCaip:"eip155:80002",chainId:80002,slip44:"137",explorer:{name:"Polygonscan",transactionUrl:"https://amoy.polygonscan.com/tx/{hash}",addressUrl:"https://amoy.polygonscan.com/address/{address}"}},"eip155:8453":{name:"Base Mainnet",chain:"base",network:"mainnet",internalCaip:"eip155:8453",chainId:8453,slip44:"8453",explorer:{name:"Basescan",transactionUrl:"https://basescan.org/tx/{hash}",addressUrl:"https://basescan.org/address/{address}"}},"eip155:84532":{name:"Base Sepolia",chain:"base",network:"sepolia",internalCaip:"eip155:84532",chainId:84532,slip44:"8453",explorer:{name:"Basescan",transactionUrl:"https://sepolia.basescan.org/tx/{hash}",addressUrl:"https://sepolia.basescan.org/address/{address}"}},"eip155:42161":{name:"Arbitrum One",chain:"arbitrum",network:"mainnet",internalCaip:"eip155:42161",chainId:42161,slip44:"42161",explorer:{name:"Arbiscan",transactionUrl:"https://arbiscan.io/tx/{hash}",addressUrl:"https://arbiscan.io/address/{address}"}},"eip155:421614":{name:"Arbitrum Sepolia",chain:"arbitrum",network:"sepolia",internalCaip:"eip155:421614",chainId:421614,slip44:"42161",explorer:{name:"Arbiscan",transactionUrl:"https://sepolia.arbiscan.io/tx/{hash}",addressUrl:"https://sepolia.arbiscan.io/address/{address}"}},"eip155:143":{name:"Monad Mainnet",chain:"monad",network:"mainnet",internalCaip:"eip155:143",chainId:143,slip44:"60",explorer:{name:"Monad Explorer",transactionUrl:"https://monadexplorer.com/tx/{hash}",addressUrl:"https://monadexplorer.com/address/{address}"}},"eip155:10143":{name:"Monad Testnet",chain:"monad",network:"testnet",internalCaip:"eip155:10143",chainId:10143,slip44:"60",explorer:{name:"Monad Testnet Explorer",transactionUrl:"https://testnet.monadexplorer.com/tx/{hash}",addressUrl:"https://testnet.monadexplorer.com/address/{address}"}},"bip122:000000000019d6689c085ae165831e93":{name:"Bitcoin Mainnet",chain:"bitcoin",network:"mainnet",internalCaip:"bip122:000000000019d6689c085ae165831e93",slip44:"0",explorer:{name:"Blockstream",transactionUrl:"https://blockstream.info/tx/{hash}",addressUrl:"https://blockstream.info/address/{address}"}},"bip122:000000000933ea01ad0ee984209779ba":{name:"Bitcoin Testnet",chain:"bitcoin",network:"testnet",internalCaip:"bip122:000000000933ea01ad0ee984209779ba",slip44:"0",explorer:{name:"Blockstream",transactionUrl:"https://blockstream.info/testnet/tx/{hash}",addressUrl:"https://blockstream.info/testnet/address/{address}"}},"sui:35834a8a":{name:"Sui Mainnet",chain:"sui",network:"mainnet",internalCaip:"sui:mainnet",slip44:"784",explorer:{name:"Sui Explorer",transactionUrl:"https://explorer.sui.io/txblock/{hash}?network=mainnet",addressUrl:"https://explorer.sui.io/address/{address}?network=mainnet"}},"sui:4c78adac":{name:"Sui Testnet",chain:"sui",network:"testnet",internalCaip:"sui:testnet",slip44:"784",explorer:{name:"Sui Explorer",transactionUrl:"https://explorer.sui.io/txblock/{hash}?network=testnet",addressUrl:"https://explorer.sui.io/address/{address}?network=testnet"}},"sui:devnet":{name:"Sui Devnet",chain:"sui",network:"devnet",internalCaip:"sui:devnet",slip44:"784",explorer:{name:"Sui Explorer",transactionUrl:"https://explorer.sui.io/txblock/{hash}?network=devnet",addressUrl:"https://explorer.sui.io/address/{address}?network=devnet"}}};function UD(t){return Qo[t]}function $D(t,e,n){const r=UD(t);return r?.explorer?(e==="transaction"?r.explorer.transactionUrl:r.explorer.addressUrl).replace("{hash}",n):void 0}function Fu(t){return Object.keys(Qo).find(e=>Qo[e].chainId===t)}function Tp(t){return Qo[t]?.chainId}function FD(t){const e=Qo[t];if(!e||!e.internalCaip)throw new Error(`No internal CAIP mapping found for NetworkId: ${t}`);return e.internalCaip}function Jf(t){const e=Object.keys(Qo).find(n=>Qo[n].internalCaip===t);if(!e)throw new Error(`No NetworkId mapping found for internal CAIP: ${t}`);return e}var ya={SDK_TYPE:"x-phantom-sdk-type",SDK_VERSION:"x-phantom-sdk-version",PLATFORM:"x-phantom-platform",WALLET_TYPE:"x-phantom-wallet-type",APP_ID:"x-app-id",PLATFORM_VERSION:"x-phantom-platform-version"},TR="https://connect.phantom.app/login",KD="https://api.phantom.app/v1/wallets",CR="user-wallet";function OR(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}var Zc=class{constructor(){this.cache=null,this.CACHE_DURATION=3e4,this.TIME_API_URL="https://time.phantom.app/utc"}static getInstance(){return Zc.instance||(Zc.instance=new Zc),Zc.instance}async now(){const t=Date.now();if(this.cache&&t-this.cache.fetchedAt<this.CACHE_DURATION){const e=t-this.cache.fetchedAt;return this.cache.timestamp+e}try{const e=await fetch(this.TIME_API_URL);if(!e.ok)throw new Error(`Time API responded with status: ${e.status}`);const n=await e.text(),r=parseInt(n,10);if(isNaN(r))throw new Error(`Invalid timestamp received: ${n}`);return this.cache={timestamp:r,fetchedAt:t},r}catch{return Date.now()}}nowSync(){if(this.cache){const t=Date.now()-this.cache.fetchedAt;if(t<this.CACHE_DURATION)return this.cache.timestamp+t}return Date.now()}clearCache(){this.cache=null}},VD=Zc.getInstance(),Mr=()=>VD.now();function NR(t){return t.split(":")[0].toLowerCase()}function PR(t){return NR(t)==="eip155"}function jD(t){return NR(t)==="solana"}function HD(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Cp={exports:{}};const zD={},qD=Object.freeze(Object.defineProperty({__proto__:null,default:zD},Symbol.toStringTag,{value:"Module"})),MR=Bm(qD);var ZE;function WD(){return ZE||(ZE=1,(function(t){(function(e){var n=function(K){var W,G=new Float64Array(16);if(K)for(W=0;W<K.length;W++)G[W]=K[W];return G},r=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=n(),a=n([1]),c=n([56129,1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),f=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),g=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(K,W,G,O){K[W]=G>>24&255,K[W+1]=G>>16&255,K[W+2]=G>>8&255,K[W+3]=G&255,K[W+4]=O>>24&255,K[W+5]=O>>16&255,K[W+6]=O>>8&255,K[W+7]=O&255}function w(K,W,G,O,J){var ce,ae=0;for(ce=0;ce<J;ce++)ae|=K[W+ce]^G[O+ce];return(1&ae-1>>>8)-1}function b(K,W,G,O){return w(K,W,G,O,16)}function E(K,W,G,O){return w(K,W,G,O,32)}function M(K,W,G,O){for(var J=O[0]&255|(O[1]&255)<<8|(O[2]&255)<<16|(O[3]&255)<<24,ce=G[0]&255|(G[1]&255)<<8|(G[2]&255)<<16|(G[3]&255)<<24,ae=G[4]&255|(G[5]&255)<<8|(G[6]&255)<<16|(G[7]&255)<<24,Ee=G[8]&255|(G[9]&255)<<8|(G[10]&255)<<16|(G[11]&255)<<24,ke=G[12]&255|(G[13]&255)<<8|(G[14]&255)<<16|(G[15]&255)<<24,Ve=O[4]&255|(O[5]&255)<<8|(O[6]&255)<<16|(O[7]&255)<<24,De=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ut=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,We=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,ft=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ht=O[8]&255|(O[9]&255)<<8|(O[10]&255)<<16|(O[11]&255)<<24,St=G[16]&255|(G[17]&255)<<8|(G[18]&255)<<16|(G[19]&255)<<24,bt=G[20]&255|(G[21]&255)<<8|(G[22]&255)<<16|(G[23]&255)<<24,pt=G[24]&255|(G[25]&255)<<8|(G[26]&255)<<16|(G[27]&255)<<24,gt=G[28]&255|(G[29]&255)<<8|(G[30]&255)<<16|(G[31]&255)<<24,mt=O[12]&255|(O[13]&255)<<8|(O[14]&255)<<16|(O[15]&255)<<24,Ze=J,st=ce,qe=ae,Qe=Ee,it=ke,ze=Ve,me=De,ge=Ut,Ie=We,xe=ft,Re=ht,Me=St,dt=bt,Rt=pt,Ct=gt,It=mt,re,Lt=0;Lt<20;Lt+=2)re=Ze+dt|0,it^=re<<7|re>>>25,re=it+Ze|0,Ie^=re<<9|re>>>23,re=Ie+it|0,dt^=re<<13|re>>>19,re=dt+Ie|0,Ze^=re<<18|re>>>14,re=ze+st|0,xe^=re<<7|re>>>25,re=xe+ze|0,Rt^=re<<9|re>>>23,re=Rt+xe|0,st^=re<<13|re>>>19,re=st+Rt|0,ze^=re<<18|re>>>14,re=Re+me|0,Ct^=re<<7|re>>>25,re=Ct+Re|0,qe^=re<<9|re>>>23,re=qe+Ct|0,me^=re<<13|re>>>19,re=me+qe|0,Re^=re<<18|re>>>14,re=It+Me|0,Qe^=re<<7|re>>>25,re=Qe+It|0,ge^=re<<9|re>>>23,re=ge+Qe|0,Me^=re<<13|re>>>19,re=Me+ge|0,It^=re<<18|re>>>14,re=Ze+Qe|0,st^=re<<7|re>>>25,re=st+Ze|0,qe^=re<<9|re>>>23,re=qe+st|0,Qe^=re<<13|re>>>19,re=Qe+qe|0,Ze^=re<<18|re>>>14,re=ze+it|0,me^=re<<7|re>>>25,re=me+ze|0,ge^=re<<9|re>>>23,re=ge+me|0,it^=re<<13|re>>>19,re=it+ge|0,ze^=re<<18|re>>>14,re=Re+xe|0,Me^=re<<7|re>>>25,re=Me+Re|0,Ie^=re<<9|re>>>23,re=Ie+Me|0,xe^=re<<13|re>>>19,re=xe+Ie|0,Re^=re<<18|re>>>14,re=It+Ct|0,dt^=re<<7|re>>>25,re=dt+It|0,Rt^=re<<9|re>>>23,re=Rt+dt|0,Ct^=re<<13|re>>>19,re=Ct+Rt|0,It^=re<<18|re>>>14;Ze=Ze+J|0,st=st+ce|0,qe=qe+ae|0,Qe=Qe+Ee|0,it=it+ke|0,ze=ze+Ve|0,me=me+De|0,ge=ge+Ut|0,Ie=Ie+We|0,xe=xe+ft|0,Re=Re+ht|0,Me=Me+St|0,dt=dt+bt|0,Rt=Rt+pt|0,Ct=Ct+gt|0,It=It+mt|0,K[0]=Ze>>>0&255,K[1]=Ze>>>8&255,K[2]=Ze>>>16&255,K[3]=Ze>>>24&255,K[4]=st>>>0&255,K[5]=st>>>8&255,K[6]=st>>>16&255,K[7]=st>>>24&255,K[8]=qe>>>0&255,K[9]=qe>>>8&255,K[10]=qe>>>16&255,K[11]=qe>>>24&255,K[12]=Qe>>>0&255,K[13]=Qe>>>8&255,K[14]=Qe>>>16&255,K[15]=Qe>>>24&255,K[16]=it>>>0&255,K[17]=it>>>8&255,K[18]=it>>>16&255,K[19]=it>>>24&255,K[20]=ze>>>0&255,K[21]=ze>>>8&255,K[22]=ze>>>16&255,K[23]=ze>>>24&255,K[24]=me>>>0&255,K[25]=me>>>8&255,K[26]=me>>>16&255,K[27]=me>>>24&255,K[28]=ge>>>0&255,K[29]=ge>>>8&255,K[30]=ge>>>16&255,K[31]=ge>>>24&255,K[32]=Ie>>>0&255,K[33]=Ie>>>8&255,K[34]=Ie>>>16&255,K[35]=Ie>>>24&255,K[36]=xe>>>0&255,K[37]=xe>>>8&255,K[38]=xe>>>16&255,K[39]=xe>>>24&255,K[40]=Re>>>0&255,K[41]=Re>>>8&255,K[42]=Re>>>16&255,K[43]=Re>>>24&255,K[44]=Me>>>0&255,K[45]=Me>>>8&255,K[46]=Me>>>16&255,K[47]=Me>>>24&255,K[48]=dt>>>0&255,K[49]=dt>>>8&255,K[50]=dt>>>16&255,K[51]=dt>>>24&255,K[52]=Rt>>>0&255,K[53]=Rt>>>8&255,K[54]=Rt>>>16&255,K[55]=Rt>>>24&255,K[56]=Ct>>>0&255,K[57]=Ct>>>8&255,K[58]=Ct>>>16&255,K[59]=Ct>>>24&255,K[60]=It>>>0&255,K[61]=It>>>8&255,K[62]=It>>>16&255,K[63]=It>>>24&255}function S(K,W,G,O){for(var J=O[0]&255|(O[1]&255)<<8|(O[2]&255)<<16|(O[3]&255)<<24,ce=G[0]&255|(G[1]&255)<<8|(G[2]&255)<<16|(G[3]&255)<<24,ae=G[4]&255|(G[5]&255)<<8|(G[6]&255)<<16|(G[7]&255)<<24,Ee=G[8]&255|(G[9]&255)<<8|(G[10]&255)<<16|(G[11]&255)<<24,ke=G[12]&255|(G[13]&255)<<8|(G[14]&255)<<16|(G[15]&255)<<24,Ve=O[4]&255|(O[5]&255)<<8|(O[6]&255)<<16|(O[7]&255)<<24,De=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ut=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,We=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,ft=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ht=O[8]&255|(O[9]&255)<<8|(O[10]&255)<<16|(O[11]&255)<<24,St=G[16]&255|(G[17]&255)<<8|(G[18]&255)<<16|(G[19]&255)<<24,bt=G[20]&255|(G[21]&255)<<8|(G[22]&255)<<16|(G[23]&255)<<24,pt=G[24]&255|(G[25]&255)<<8|(G[26]&255)<<16|(G[27]&255)<<24,gt=G[28]&255|(G[29]&255)<<8|(G[30]&255)<<16|(G[31]&255)<<24,mt=O[12]&255|(O[13]&255)<<8|(O[14]&255)<<16|(O[15]&255)<<24,Ze=J,st=ce,qe=ae,Qe=Ee,it=ke,ze=Ve,me=De,ge=Ut,Ie=We,xe=ft,Re=ht,Me=St,dt=bt,Rt=pt,Ct=gt,It=mt,re,Lt=0;Lt<20;Lt+=2)re=Ze+dt|0,it^=re<<7|re>>>25,re=it+Ze|0,Ie^=re<<9|re>>>23,re=Ie+it|0,dt^=re<<13|re>>>19,re=dt+Ie|0,Ze^=re<<18|re>>>14,re=ze+st|0,xe^=re<<7|re>>>25,re=xe+ze|0,Rt^=re<<9|re>>>23,re=Rt+xe|0,st^=re<<13|re>>>19,re=st+Rt|0,ze^=re<<18|re>>>14,re=Re+me|0,Ct^=re<<7|re>>>25,re=Ct+Re|0,qe^=re<<9|re>>>23,re=qe+Ct|0,me^=re<<13|re>>>19,re=me+qe|0,Re^=re<<18|re>>>14,re=It+Me|0,Qe^=re<<7|re>>>25,re=Qe+It|0,ge^=re<<9|re>>>23,re=ge+Qe|0,Me^=re<<13|re>>>19,re=Me+ge|0,It^=re<<18|re>>>14,re=Ze+Qe|0,st^=re<<7|re>>>25,re=st+Ze|0,qe^=re<<9|re>>>23,re=qe+st|0,Qe^=re<<13|re>>>19,re=Qe+qe|0,Ze^=re<<18|re>>>14,re=ze+it|0,me^=re<<7|re>>>25,re=me+ze|0,ge^=re<<9|re>>>23,re=ge+me|0,it^=re<<13|re>>>19,re=it+ge|0,ze^=re<<18|re>>>14,re=Re+xe|0,Me^=re<<7|re>>>25,re=Me+Re|0,Ie^=re<<9|re>>>23,re=Ie+Me|0,xe^=re<<13|re>>>19,re=xe+Ie|0,Re^=re<<18|re>>>14,re=It+Ct|0,dt^=re<<7|re>>>25,re=dt+It|0,Rt^=re<<9|re>>>23,re=Rt+dt|0,Ct^=re<<13|re>>>19,re=Ct+Rt|0,It^=re<<18|re>>>14;K[0]=Ze>>>0&255,K[1]=Ze>>>8&255,K[2]=Ze>>>16&255,K[3]=Ze>>>24&255,K[4]=ze>>>0&255,K[5]=ze>>>8&255,K[6]=ze>>>16&255,K[7]=ze>>>24&255,K[8]=Re>>>0&255,K[9]=Re>>>8&255,K[10]=Re>>>16&255,K[11]=Re>>>24&255,K[12]=It>>>0&255,K[13]=It>>>8&255,K[14]=It>>>16&255,K[15]=It>>>24&255,K[16]=me>>>0&255,K[17]=me>>>8&255,K[18]=me>>>16&255,K[19]=me>>>24&255,K[20]=ge>>>0&255,K[21]=ge>>>8&255,K[22]=ge>>>16&255,K[23]=ge>>>24&255,K[24]=Ie>>>0&255,K[25]=Ie>>>8&255,K[26]=Ie>>>16&255,K[27]=Ie>>>24&255,K[28]=xe>>>0&255,K[29]=xe>>>8&255,K[30]=xe>>>16&255,K[31]=xe>>>24&255}function F(K,W,G,O){M(K,W,G,O)}function D(K,W,G,O){S(K,W,G,O)}var z=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function X(K,W,G,O,J,ce,ae){var Ee=new Uint8Array(16),ke=new Uint8Array(64),Ve,De;for(De=0;De<16;De++)Ee[De]=0;for(De=0;De<8;De++)Ee[De]=ce[De];for(;J>=64;){for(F(ke,Ee,ae,z),De=0;De<64;De++)K[W+De]=G[O+De]^ke[De];for(Ve=1,De=8;De<16;De++)Ve=Ve+(Ee[De]&255)|0,Ee[De]=Ve&255,Ve>>>=8;J-=64,W+=64,O+=64}if(J>0)for(F(ke,Ee,ae,z),De=0;De<J;De++)K[W+De]=G[O+De]^ke[De];return 0}function Y(K,W,G,O,J){var ce=new Uint8Array(16),ae=new Uint8Array(64),Ee,ke;for(ke=0;ke<16;ke++)ce[ke]=0;for(ke=0;ke<8;ke++)ce[ke]=O[ke];for(;G>=64;){for(F(ae,ce,J,z),ke=0;ke<64;ke++)K[W+ke]=ae[ke];for(Ee=1,ke=8;ke<16;ke++)Ee=Ee+(ce[ke]&255)|0,ce[ke]=Ee&255,Ee>>>=8;G-=64,W+=64}if(G>0)for(F(ae,ce,J,z),ke=0;ke<G;ke++)K[W+ke]=ae[ke];return 0}function U(K,W,G,O,J){var ce=new Uint8Array(32);D(ce,O,J,z);for(var ae=new Uint8Array(8),Ee=0;Ee<8;Ee++)ae[Ee]=O[Ee+16];return Y(K,W,G,ae,ce)}function B(K,W,G,O,J,ce,ae){var Ee=new Uint8Array(32);D(Ee,ce,ae,z);for(var ke=new Uint8Array(8),Ve=0;Ve<8;Ve++)ke[Ve]=ce[Ve+16];return X(K,W,G,O,J,ke,Ee)}var H=function(K){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var W,G,O,J,ce,ae,Ee,ke;W=K[0]&255|(K[1]&255)<<8,this.r[0]=W&8191,G=K[2]&255|(K[3]&255)<<8,this.r[1]=(W>>>13|G<<3)&8191,O=K[4]&255|(K[5]&255)<<8,this.r[2]=(G>>>10|O<<6)&7939,J=K[6]&255|(K[7]&255)<<8,this.r[3]=(O>>>7|J<<9)&8191,ce=K[8]&255|(K[9]&255)<<8,this.r[4]=(J>>>4|ce<<12)&255,this.r[5]=ce>>>1&8190,ae=K[10]&255|(K[11]&255)<<8,this.r[6]=(ce>>>14|ae<<2)&8191,Ee=K[12]&255|(K[13]&255)<<8,this.r[7]=(ae>>>11|Ee<<5)&8065,ke=K[14]&255|(K[15]&255)<<8,this.r[8]=(Ee>>>8|ke<<8)&8191,this.r[9]=ke>>>5&127,this.pad[0]=K[16]&255|(K[17]&255)<<8,this.pad[1]=K[18]&255|(K[19]&255)<<8,this.pad[2]=K[20]&255|(K[21]&255)<<8,this.pad[3]=K[22]&255|(K[23]&255)<<8,this.pad[4]=K[24]&255|(K[25]&255)<<8,this.pad[5]=K[26]&255|(K[27]&255)<<8,this.pad[6]=K[28]&255|(K[29]&255)<<8,this.pad[7]=K[30]&255|(K[31]&255)<<8};H.prototype.blocks=function(K,W,G){for(var O=this.fin?0:2048,J,ce,ae,Ee,ke,Ve,De,Ut,We,ft,ht,St,bt,pt,gt,mt,Ze,st,qe,Qe=this.h[0],it=this.h[1],ze=this.h[2],me=this.h[3],ge=this.h[4],Ie=this.h[5],xe=this.h[6],Re=this.h[7],Me=this.h[8],dt=this.h[9],Rt=this.r[0],Ct=this.r[1],It=this.r[2],re=this.r[3],Lt=this.r[4],zt=this.r[5],qt=this.r[6],Ot=this.r[7],Vt=this.r[8],jt=this.r[9];G>=16;)J=K[W+0]&255|(K[W+1]&255)<<8,Qe+=J&8191,ce=K[W+2]&255|(K[W+3]&255)<<8,it+=(J>>>13|ce<<3)&8191,ae=K[W+4]&255|(K[W+5]&255)<<8,ze+=(ce>>>10|ae<<6)&8191,Ee=K[W+6]&255|(K[W+7]&255)<<8,me+=(ae>>>7|Ee<<9)&8191,ke=K[W+8]&255|(K[W+9]&255)<<8,ge+=(Ee>>>4|ke<<12)&8191,Ie+=ke>>>1&8191,Ve=K[W+10]&255|(K[W+11]&255)<<8,xe+=(ke>>>14|Ve<<2)&8191,De=K[W+12]&255|(K[W+13]&255)<<8,Re+=(Ve>>>11|De<<5)&8191,Ut=K[W+14]&255|(K[W+15]&255)<<8,Me+=(De>>>8|Ut<<8)&8191,dt+=Ut>>>5|O,We=0,ft=We,ft+=Qe*Rt,ft+=it*(5*jt),ft+=ze*(5*Vt),ft+=me*(5*Ot),ft+=ge*(5*qt),We=ft>>>13,ft&=8191,ft+=Ie*(5*zt),ft+=xe*(5*Lt),ft+=Re*(5*re),ft+=Me*(5*It),ft+=dt*(5*Ct),We+=ft>>>13,ft&=8191,ht=We,ht+=Qe*Ct,ht+=it*Rt,ht+=ze*(5*jt),ht+=me*(5*Vt),ht+=ge*(5*Ot),We=ht>>>13,ht&=8191,ht+=Ie*(5*qt),ht+=xe*(5*zt),ht+=Re*(5*Lt),ht+=Me*(5*re),ht+=dt*(5*It),We+=ht>>>13,ht&=8191,St=We,St+=Qe*It,St+=it*Ct,St+=ze*Rt,St+=me*(5*jt),St+=ge*(5*Vt),We=St>>>13,St&=8191,St+=Ie*(5*Ot),St+=xe*(5*qt),St+=Re*(5*zt),St+=Me*(5*Lt),St+=dt*(5*re),We+=St>>>13,St&=8191,bt=We,bt+=Qe*re,bt+=it*It,bt+=ze*Ct,bt+=me*Rt,bt+=ge*(5*jt),We=bt>>>13,bt&=8191,bt+=Ie*(5*Vt),bt+=xe*(5*Ot),bt+=Re*(5*qt),bt+=Me*(5*zt),bt+=dt*(5*Lt),We+=bt>>>13,bt&=8191,pt=We,pt+=Qe*Lt,pt+=it*re,pt+=ze*It,pt+=me*Ct,pt+=ge*Rt,We=pt>>>13,pt&=8191,pt+=Ie*(5*jt),pt+=xe*(5*Vt),pt+=Re*(5*Ot),pt+=Me*(5*qt),pt+=dt*(5*zt),We+=pt>>>13,pt&=8191,gt=We,gt+=Qe*zt,gt+=it*Lt,gt+=ze*re,gt+=me*It,gt+=ge*Ct,We=gt>>>13,gt&=8191,gt+=Ie*Rt,gt+=xe*(5*jt),gt+=Re*(5*Vt),gt+=Me*(5*Ot),gt+=dt*(5*qt),We+=gt>>>13,gt&=8191,mt=We,mt+=Qe*qt,mt+=it*zt,mt+=ze*Lt,mt+=me*re,mt+=ge*It,We=mt>>>13,mt&=8191,mt+=Ie*Ct,mt+=xe*Rt,mt+=Re*(5*jt),mt+=Me*(5*Vt),mt+=dt*(5*Ot),We+=mt>>>13,mt&=8191,Ze=We,Ze+=Qe*Ot,Ze+=it*qt,Ze+=ze*zt,Ze+=me*Lt,Ze+=ge*re,We=Ze>>>13,Ze&=8191,Ze+=Ie*It,Ze+=xe*Ct,Ze+=Re*Rt,Ze+=Me*(5*jt),Ze+=dt*(5*Vt),We+=Ze>>>13,Ze&=8191,st=We,st+=Qe*Vt,st+=it*Ot,st+=ze*qt,st+=me*zt,st+=ge*Lt,We=st>>>13,st&=8191,st+=Ie*re,st+=xe*It,st+=Re*Ct,st+=Me*Rt,st+=dt*(5*jt),We+=st>>>13,st&=8191,qe=We,qe+=Qe*jt,qe+=it*Vt,qe+=ze*Ot,qe+=me*qt,qe+=ge*zt,We=qe>>>13,qe&=8191,qe+=Ie*Lt,qe+=xe*re,qe+=Re*It,qe+=Me*Ct,qe+=dt*Rt,We+=qe>>>13,qe&=8191,We=(We<<2)+We|0,We=We+ft|0,ft=We&8191,We=We>>>13,ht+=We,Qe=ft,it=ht,ze=St,me=bt,ge=pt,Ie=gt,xe=mt,Re=Ze,Me=st,dt=qe,W+=16,G-=16;this.h[0]=Qe,this.h[1]=it,this.h[2]=ze,this.h[3]=me,this.h[4]=ge,this.h[5]=Ie,this.h[6]=xe,this.h[7]=Re,this.h[8]=Me,this.h[9]=dt},H.prototype.finish=function(K,W){var G=new Uint16Array(10),O,J,ce,ae;if(this.leftover){for(ae=this.leftover,this.buffer[ae++]=1;ae<16;ae++)this.buffer[ae]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(O=this.h[1]>>>13,this.h[1]&=8191,ae=2;ae<10;ae++)this.h[ae]+=O,O=this.h[ae]>>>13,this.h[ae]&=8191;for(this.h[0]+=O*5,O=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=O,O=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=O,G[0]=this.h[0]+5,O=G[0]>>>13,G[0]&=8191,ae=1;ae<10;ae++)G[ae]=this.h[ae]+O,O=G[ae]>>>13,G[ae]&=8191;for(G[9]-=8192,J=(O^1)-1,ae=0;ae<10;ae++)G[ae]&=J;for(J=~J,ae=0;ae<10;ae++)this.h[ae]=this.h[ae]&J|G[ae];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,ce=this.h[0]+this.pad[0],this.h[0]=ce&65535,ae=1;ae<8;ae++)ce=(this.h[ae]+this.pad[ae]|0)+(ce>>>16)|0,this.h[ae]=ce&65535;K[W+0]=this.h[0]>>>0&255,K[W+1]=this.h[0]>>>8&255,K[W+2]=this.h[1]>>>0&255,K[W+3]=this.h[1]>>>8&255,K[W+4]=this.h[2]>>>0&255,K[W+5]=this.h[2]>>>8&255,K[W+6]=this.h[3]>>>0&255,K[W+7]=this.h[3]>>>8&255,K[W+8]=this.h[4]>>>0&255,K[W+9]=this.h[4]>>>8&255,K[W+10]=this.h[5]>>>0&255,K[W+11]=this.h[5]>>>8&255,K[W+12]=this.h[6]>>>0&255,K[W+13]=this.h[6]>>>8&255,K[W+14]=this.h[7]>>>0&255,K[W+15]=this.h[7]>>>8&255},H.prototype.update=function(K,W,G){var O,J;if(this.leftover){for(J=16-this.leftover,J>G&&(J=G),O=0;O<J;O++)this.buffer[this.leftover+O]=K[W+O];if(G-=J,W+=J,this.leftover+=J,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(G>=16&&(J=G-G%16,this.blocks(K,W,J),W+=J,G-=J),G){for(O=0;O<G;O++)this.buffer[this.leftover+O]=K[W+O];this.leftover+=G}};function V(K,W,G,O,J,ce){var ae=new H(ce);return ae.update(G,O,J),ae.finish(K,W),0}function T(K,W,G,O,J,ce){var ae=new Uint8Array(16);return V(ae,0,G,O,J,ce),b(K,W,ae,0)}function p(K,W,G,O,J){var ce;if(G<32)return-1;for(B(K,0,W,0,G,O,J),V(K,16,K,32,G-32,K),ce=0;ce<16;ce++)K[ce]=0;return 0}function y(K,W,G,O,J){var ce,ae=new Uint8Array(32);if(G<32||(U(ae,0,32,O,J),T(W,16,W,32,G-32,ae)!==0))return-1;for(B(K,0,W,0,G,O,J),ce=0;ce<32;ce++)K[ce]=0;return 0}function R(K,W){var G;for(G=0;G<16;G++)K[G]=W[G]|0}function P(K){var W,G,O=1;for(W=0;W<16;W++)G=K[W]+O+65535,O=Math.floor(G/65536),K[W]=G-O*65536;K[0]+=O-1+37*(O-1)}function _(K,W,G){for(var O,J=~(G-1),ce=0;ce<16;ce++)O=J&(K[ce]^W[ce]),K[ce]^=O,W[ce]^=O}function I(K,W){var G,O,J,ce=n(),ae=n();for(G=0;G<16;G++)ae[G]=W[G];for(P(ae),P(ae),P(ae),O=0;O<2;O++){for(ce[0]=ae[0]-65517,G=1;G<15;G++)ce[G]=ae[G]-65535-(ce[G-1]>>16&1),ce[G-1]&=65535;ce[15]=ae[15]-32767-(ce[14]>>16&1),J=ce[15]>>16&1,ce[14]&=65535,_(ae,ce,1-J)}for(G=0;G<16;G++)K[2*G]=ae[G]&255,K[2*G+1]=ae[G]>>8}function N(K,W){var G=new Uint8Array(32),O=new Uint8Array(32);return I(G,K),I(O,W),E(G,0,O,0)}function x(K){var W=new Uint8Array(32);return I(W,K),W[0]&1}function h(K,W){var G;for(G=0;G<16;G++)K[G]=W[2*G]+(W[2*G+1]<<8);K[15]&=32767}function m(K,W,G){for(var O=0;O<16;O++)K[O]=W[O]+G[O]}function A(K,W,G){for(var O=0;O<16;O++)K[O]=W[O]-G[O]}function C(K,W,G){var O,J,ce=0,ae=0,Ee=0,ke=0,Ve=0,De=0,Ut=0,We=0,ft=0,ht=0,St=0,bt=0,pt=0,gt=0,mt=0,Ze=0,st=0,qe=0,Qe=0,it=0,ze=0,me=0,ge=0,Ie=0,xe=0,Re=0,Me=0,dt=0,Rt=0,Ct=0,It=0,re=G[0],Lt=G[1],zt=G[2],qt=G[3],Ot=G[4],Vt=G[5],jt=G[6],Cn=G[7],Qt=G[8],En=G[9],bn=G[10],_n=G[11],Bn=G[12],nr=G[13],rr=G[14],ir=G[15];O=W[0],ce+=O*re,ae+=O*Lt,Ee+=O*zt,ke+=O*qt,Ve+=O*Ot,De+=O*Vt,Ut+=O*jt,We+=O*Cn,ft+=O*Qt,ht+=O*En,St+=O*bn,bt+=O*_n,pt+=O*Bn,gt+=O*nr,mt+=O*rr,Ze+=O*ir,O=W[1],ae+=O*re,Ee+=O*Lt,ke+=O*zt,Ve+=O*qt,De+=O*Ot,Ut+=O*Vt,We+=O*jt,ft+=O*Cn,ht+=O*Qt,St+=O*En,bt+=O*bn,pt+=O*_n,gt+=O*Bn,mt+=O*nr,Ze+=O*rr,st+=O*ir,O=W[2],Ee+=O*re,ke+=O*Lt,Ve+=O*zt,De+=O*qt,Ut+=O*Ot,We+=O*Vt,ft+=O*jt,ht+=O*Cn,St+=O*Qt,bt+=O*En,pt+=O*bn,gt+=O*_n,mt+=O*Bn,Ze+=O*nr,st+=O*rr,qe+=O*ir,O=W[3],ke+=O*re,Ve+=O*Lt,De+=O*zt,Ut+=O*qt,We+=O*Ot,ft+=O*Vt,ht+=O*jt,St+=O*Cn,bt+=O*Qt,pt+=O*En,gt+=O*bn,mt+=O*_n,Ze+=O*Bn,st+=O*nr,qe+=O*rr,Qe+=O*ir,O=W[4],Ve+=O*re,De+=O*Lt,Ut+=O*zt,We+=O*qt,ft+=O*Ot,ht+=O*Vt,St+=O*jt,bt+=O*Cn,pt+=O*Qt,gt+=O*En,mt+=O*bn,Ze+=O*_n,st+=O*Bn,qe+=O*nr,Qe+=O*rr,it+=O*ir,O=W[5],De+=O*re,Ut+=O*Lt,We+=O*zt,ft+=O*qt,ht+=O*Ot,St+=O*Vt,bt+=O*jt,pt+=O*Cn,gt+=O*Qt,mt+=O*En,Ze+=O*bn,st+=O*_n,qe+=O*Bn,Qe+=O*nr,it+=O*rr,ze+=O*ir,O=W[6],Ut+=O*re,We+=O*Lt,ft+=O*zt,ht+=O*qt,St+=O*Ot,bt+=O*Vt,pt+=O*jt,gt+=O*Cn,mt+=O*Qt,Ze+=O*En,st+=O*bn,qe+=O*_n,Qe+=O*Bn,it+=O*nr,ze+=O*rr,me+=O*ir,O=W[7],We+=O*re,ft+=O*Lt,ht+=O*zt,St+=O*qt,bt+=O*Ot,pt+=O*Vt,gt+=O*jt,mt+=O*Cn,Ze+=O*Qt,st+=O*En,qe+=O*bn,Qe+=O*_n,it+=O*Bn,ze+=O*nr,me+=O*rr,ge+=O*ir,O=W[8],ft+=O*re,ht+=O*Lt,St+=O*zt,bt+=O*qt,pt+=O*Ot,gt+=O*Vt,mt+=O*jt,Ze+=O*Cn,st+=O*Qt,qe+=O*En,Qe+=O*bn,it+=O*_n,ze+=O*Bn,me+=O*nr,ge+=O*rr,Ie+=O*ir,O=W[9],ht+=O*re,St+=O*Lt,bt+=O*zt,pt+=O*qt,gt+=O*Ot,mt+=O*Vt,Ze+=O*jt,st+=O*Cn,qe+=O*Qt,Qe+=O*En,it+=O*bn,ze+=O*_n,me+=O*Bn,ge+=O*nr,Ie+=O*rr,xe+=O*ir,O=W[10],St+=O*re,bt+=O*Lt,pt+=O*zt,gt+=O*qt,mt+=O*Ot,Ze+=O*Vt,st+=O*jt,qe+=O*Cn,Qe+=O*Qt,it+=O*En,ze+=O*bn,me+=O*_n,ge+=O*Bn,Ie+=O*nr,xe+=O*rr,Re+=O*ir,O=W[11],bt+=O*re,pt+=O*Lt,gt+=O*zt,mt+=O*qt,Ze+=O*Ot,st+=O*Vt,qe+=O*jt,Qe+=O*Cn,it+=O*Qt,ze+=O*En,me+=O*bn,ge+=O*_n,Ie+=O*Bn,xe+=O*nr,Re+=O*rr,Me+=O*ir,O=W[12],pt+=O*re,gt+=O*Lt,mt+=O*zt,Ze+=O*qt,st+=O*Ot,qe+=O*Vt,Qe+=O*jt,it+=O*Cn,ze+=O*Qt,me+=O*En,ge+=O*bn,Ie+=O*_n,xe+=O*Bn,Re+=O*nr,Me+=O*rr,dt+=O*ir,O=W[13],gt+=O*re,mt+=O*Lt,Ze+=O*zt,st+=O*qt,qe+=O*Ot,Qe+=O*Vt,it+=O*jt,ze+=O*Cn,me+=O*Qt,ge+=O*En,Ie+=O*bn,xe+=O*_n,Re+=O*Bn,Me+=O*nr,dt+=O*rr,Rt+=O*ir,O=W[14],mt+=O*re,Ze+=O*Lt,st+=O*zt,qe+=O*qt,Qe+=O*Ot,it+=O*Vt,ze+=O*jt,me+=O*Cn,ge+=O*Qt,Ie+=O*En,xe+=O*bn,Re+=O*_n,Me+=O*Bn,dt+=O*nr,Rt+=O*rr,Ct+=O*ir,O=W[15],Ze+=O*re,st+=O*Lt,qe+=O*zt,Qe+=O*qt,it+=O*Ot,ze+=O*Vt,me+=O*jt,ge+=O*Cn,Ie+=O*Qt,xe+=O*En,Re+=O*bn,Me+=O*_n,dt+=O*Bn,Rt+=O*nr,Ct+=O*rr,It+=O*ir,ce+=38*st,ae+=38*qe,Ee+=38*Qe,ke+=38*it,Ve+=38*ze,De+=38*me,Ut+=38*ge,We+=38*Ie,ft+=38*xe,ht+=38*Re,St+=38*Me,bt+=38*dt,pt+=38*Rt,gt+=38*Ct,mt+=38*It,J=1,O=ce+J+65535,J=Math.floor(O/65536),ce=O-J*65536,O=ae+J+65535,J=Math.floor(O/65536),ae=O-J*65536,O=Ee+J+65535,J=Math.floor(O/65536),Ee=O-J*65536,O=ke+J+65535,J=Math.floor(O/65536),ke=O-J*65536,O=Ve+J+65535,J=Math.floor(O/65536),Ve=O-J*65536,O=De+J+65535,J=Math.floor(O/65536),De=O-J*65536,O=Ut+J+65535,J=Math.floor(O/65536),Ut=O-J*65536,O=We+J+65535,J=Math.floor(O/65536),We=O-J*65536,O=ft+J+65535,J=Math.floor(O/65536),ft=O-J*65536,O=ht+J+65535,J=Math.floor(O/65536),ht=O-J*65536,O=St+J+65535,J=Math.floor(O/65536),St=O-J*65536,O=bt+J+65535,J=Math.floor(O/65536),bt=O-J*65536,O=pt+J+65535,J=Math.floor(O/65536),pt=O-J*65536,O=gt+J+65535,J=Math.floor(O/65536),gt=O-J*65536,O=mt+J+65535,J=Math.floor(O/65536),mt=O-J*65536,O=Ze+J+65535,J=Math.floor(O/65536),Ze=O-J*65536,ce+=J-1+37*(J-1),J=1,O=ce+J+65535,J=Math.floor(O/65536),ce=O-J*65536,O=ae+J+65535,J=Math.floor(O/65536),ae=O-J*65536,O=Ee+J+65535,J=Math.floor(O/65536),Ee=O-J*65536,O=ke+J+65535,J=Math.floor(O/65536),ke=O-J*65536,O=Ve+J+65535,J=Math.floor(O/65536),Ve=O-J*65536,O=De+J+65535,J=Math.floor(O/65536),De=O-J*65536,O=Ut+J+65535,J=Math.floor(O/65536),Ut=O-J*65536,O=We+J+65535,J=Math.floor(O/65536),We=O-J*65536,O=ft+J+65535,J=Math.floor(O/65536),ft=O-J*65536,O=ht+J+65535,J=Math.floor(O/65536),ht=O-J*65536,O=St+J+65535,J=Math.floor(O/65536),St=O-J*65536,O=bt+J+65535,J=Math.floor(O/65536),bt=O-J*65536,O=pt+J+65535,J=Math.floor(O/65536),pt=O-J*65536,O=gt+J+65535,J=Math.floor(O/65536),gt=O-J*65536,O=mt+J+65535,J=Math.floor(O/65536),mt=O-J*65536,O=Ze+J+65535,J=Math.floor(O/65536),Ze=O-J*65536,ce+=J-1+37*(J-1),K[0]=ce,K[1]=ae,K[2]=Ee,K[3]=ke,K[4]=Ve,K[5]=De,K[6]=Ut,K[7]=We,K[8]=ft,K[9]=ht,K[10]=St,K[11]=bt,K[12]=pt,K[13]=gt,K[14]=mt,K[15]=Ze}function $(K,W){C(K,W,W)}function j(K,W){var G=n(),O;for(O=0;O<16;O++)G[O]=W[O];for(O=253;O>=0;O--)$(G,G),O!==2&&O!==4&&C(G,G,W);for(O=0;O<16;O++)K[O]=G[O]}function Z(K,W){var G=n(),O;for(O=0;O<16;O++)G[O]=W[O];for(O=250;O>=0;O--)$(G,G),O!==1&&C(G,G,W);for(O=0;O<16;O++)K[O]=G[O]}function ne(K,W,G){var O=new Uint8Array(32),J=new Float64Array(80),ce,ae,Ee=n(),ke=n(),Ve=n(),De=n(),Ut=n(),We=n();for(ae=0;ae<31;ae++)O[ae]=W[ae];for(O[31]=W[31]&127|64,O[0]&=248,h(J,G),ae=0;ae<16;ae++)ke[ae]=J[ae],De[ae]=Ee[ae]=Ve[ae]=0;for(Ee[0]=De[0]=1,ae=254;ae>=0;--ae)ce=O[ae>>>3]>>>(ae&7)&1,_(Ee,ke,ce),_(Ve,De,ce),m(Ut,Ee,Ve),A(Ee,Ee,Ve),m(Ve,ke,De),A(ke,ke,De),$(De,Ut),$(We,Ee),C(Ee,Ve,Ee),C(Ve,ke,Ut),m(Ut,Ee,Ve),A(Ee,Ee,Ve),$(ke,Ee),A(Ve,De,We),C(Ee,Ve,c),m(Ee,Ee,De),C(Ve,Ve,Ee),C(Ee,De,We),C(De,ke,J),$(ke,Ut),_(Ee,ke,ce),_(Ve,De,ce);for(ae=0;ae<16;ae++)J[ae+16]=Ee[ae],J[ae+32]=Ve[ae],J[ae+48]=ke[ae],J[ae+64]=De[ae];var ft=J.subarray(32),ht=J.subarray(16);return j(ft,ft),C(ht,ht,ft),I(K,ht),0}function se(K,W){return ne(K,W,s)}function ue(K,W){return r(W,32),se(K,W)}function de(K,W,G){var O=new Uint8Array(32);return ne(O,G,W),D(K,i,O,z)}var Ae=p,Ce=y;function Ue(K,W,G,O,J,ce){var ae=new Uint8Array(32);return de(ae,J,ce),Ae(K,W,G,O,ae)}function Be(K,W,G,O,J,ce){var ae=new Uint8Array(32);return de(ae,J,ce),Ce(K,W,G,O,ae)}var Oe=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Le(K,W,G,O){for(var J=new Int32Array(16),ce=new Int32Array(16),ae,Ee,ke,Ve,De,Ut,We,ft,ht,St,bt,pt,gt,mt,Ze,st,qe,Qe,it,ze,me,ge,Ie,xe,Re,Me,dt=K[0],Rt=K[1],Ct=K[2],It=K[3],re=K[4],Lt=K[5],zt=K[6],qt=K[7],Ot=W[0],Vt=W[1],jt=W[2],Cn=W[3],Qt=W[4],En=W[5],bn=W[6],_n=W[7],Bn=0;O>=128;){for(it=0;it<16;it++)ze=8*it+Bn,J[it]=G[ze+0]<<24|G[ze+1]<<16|G[ze+2]<<8|G[ze+3],ce[it]=G[ze+4]<<24|G[ze+5]<<16|G[ze+6]<<8|G[ze+7];for(it=0;it<80;it++)if(ae=dt,Ee=Rt,ke=Ct,Ve=It,De=re,Ut=Lt,We=zt,ft=qt,ht=Ot,St=Vt,bt=jt,pt=Cn,gt=Qt,mt=En,Ze=bn,st=_n,me=qt,ge=_n,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=(re>>>14|Qt<<18)^(re>>>18|Qt<<14)^(Qt>>>9|re<<23),ge=(Qt>>>14|re<<18)^(Qt>>>18|re<<14)^(re>>>9|Qt<<23),Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,me=re&Lt^~re&zt,ge=Qt&En^~Qt&bn,Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,me=Oe[it*2],ge=Oe[it*2+1],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,me=J[it%16],ge=ce[it%16],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,qe=Re&65535|Me<<16,Qe=Ie&65535|xe<<16,me=qe,ge=Qe,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=(dt>>>28|Ot<<4)^(Ot>>>2|dt<<30)^(Ot>>>7|dt<<25),ge=(Ot>>>28|dt<<4)^(dt>>>2|Ot<<30)^(dt>>>7|Ot<<25),Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,me=dt&Rt^dt&Ct^Rt&Ct,ge=Ot&Vt^Ot&jt^Vt&jt,Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,ft=Re&65535|Me<<16,st=Ie&65535|xe<<16,me=Ve,ge=pt,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=qe,ge=Qe,Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,Ve=Re&65535|Me<<16,pt=Ie&65535|xe<<16,Rt=ae,Ct=Ee,It=ke,re=Ve,Lt=De,zt=Ut,qt=We,dt=ft,Vt=ht,jt=St,Cn=bt,Qt=pt,En=gt,bn=mt,_n=Ze,Ot=st,it%16===15)for(ze=0;ze<16;ze++)me=J[ze],ge=ce[ze],Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=J[(ze+9)%16],ge=ce[(ze+9)%16],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,qe=J[(ze+1)%16],Qe=ce[(ze+1)%16],me=(qe>>>1|Qe<<31)^(qe>>>8|Qe<<24)^qe>>>7,ge=(Qe>>>1|qe<<31)^(Qe>>>8|qe<<24)^(Qe>>>7|qe<<25),Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,qe=J[(ze+14)%16],Qe=ce[(ze+14)%16],me=(qe>>>19|Qe<<13)^(Qe>>>29|qe<<3)^qe>>>6,ge=(Qe>>>19|qe<<13)^(qe>>>29|Qe<<3)^(Qe>>>6|qe<<26),Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,J[ze]=Re&65535|Me<<16,ce[ze]=Ie&65535|xe<<16;me=dt,ge=Ot,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[0],ge=W[0],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[0]=dt=Re&65535|Me<<16,W[0]=Ot=Ie&65535|xe<<16,me=Rt,ge=Vt,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[1],ge=W[1],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[1]=Rt=Re&65535|Me<<16,W[1]=Vt=Ie&65535|xe<<16,me=Ct,ge=jt,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[2],ge=W[2],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[2]=Ct=Re&65535|Me<<16,W[2]=jt=Ie&65535|xe<<16,me=It,ge=Cn,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[3],ge=W[3],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[3]=It=Re&65535|Me<<16,W[3]=Cn=Ie&65535|xe<<16,me=re,ge=Qt,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[4],ge=W[4],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[4]=re=Re&65535|Me<<16,W[4]=Qt=Ie&65535|xe<<16,me=Lt,ge=En,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[5],ge=W[5],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[5]=Lt=Re&65535|Me<<16,W[5]=En=Ie&65535|xe<<16,me=zt,ge=bn,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[6],ge=W[6],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[6]=zt=Re&65535|Me<<16,W[6]=bn=Ie&65535|xe<<16,me=qt,ge=_n,Ie=ge&65535,xe=ge>>>16,Re=me&65535,Me=me>>>16,me=K[7],ge=W[7],Ie+=ge&65535,xe+=ge>>>16,Re+=me&65535,Me+=me>>>16,xe+=Ie>>>16,Re+=xe>>>16,Me+=Re>>>16,K[7]=qt=Re&65535|Me<<16,W[7]=_n=Ie&65535|xe<<16,Bn+=128,O-=128}return O}function je(K,W,G){var O=new Int32Array(8),J=new Int32Array(8),ce=new Uint8Array(256),ae,Ee=G;for(O[0]=1779033703,O[1]=3144134277,O[2]=1013904242,O[3]=2773480762,O[4]=1359893119,O[5]=2600822924,O[6]=528734635,O[7]=1541459225,J[0]=4089235720,J[1]=2227873595,J[2]=4271175723,J[3]=1595750129,J[4]=2917565137,J[5]=725511199,J[6]=4215389547,J[7]=327033209,Le(O,J,W,G),G%=128,ae=0;ae<G;ae++)ce[ae]=W[Ee-G+ae];for(ce[G]=128,G=256-128*(G<112?1:0),ce[G-9]=0,v(ce,G-8,Ee/536870912|0,Ee<<3),Le(O,J,ce,G),ae=0;ae<8;ae++)v(K,8*ae,O[ae],J[ae]);return 0}function $e(K,W){var G=n(),O=n(),J=n(),ce=n(),ae=n(),Ee=n(),ke=n(),Ve=n(),De=n();A(G,K[1],K[0]),A(De,W[1],W[0]),C(G,G,De),m(O,K[0],K[1]),m(De,W[0],W[1]),C(O,O,De),C(J,K[3],W[3]),C(J,J,u),C(ce,K[2],W[2]),m(ce,ce,ce),A(ae,O,G),A(Ee,ce,J),m(ke,ce,J),m(Ve,O,G),C(K[0],ae,Ee),C(K[1],Ve,ke),C(K[2],ke,Ee),C(K[3],ae,Ve)}function Je(K,W,G){var O;for(O=0;O<4;O++)_(K[O],W[O],G)}function He(K,W){var G=n(),O=n(),J=n();j(J,W[2]),C(G,W[0],J),C(O,W[1],J),I(K,O),K[31]^=x(G)<<7}function Ke(K,W,G){var O,J;for(R(K[0],o),R(K[1],a),R(K[2],a),R(K[3],o),J=255;J>=0;--J)O=G[J/8|0]>>(J&7)&1,Je(K,W,O),$e(W,K),$e(K,K),Je(K,W,O)}function Ge(K,W){var G=[n(),n(),n(),n()];R(G[0],d),R(G[1],f),R(G[2],a),C(G[3],d,f),Ke(K,G,W)}function Dt(K,W,G){var O=new Uint8Array(64),J=[n(),n(),n(),n()],ce;for(G||r(W,32),je(O,W,32),O[0]&=248,O[31]&=127,O[31]|=64,Ge(J,O),He(K,J),ce=0;ce<32;ce++)W[ce+32]=K[ce];return 0}var _t=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function q(K,W){var G,O,J,ce;for(O=63;O>=32;--O){for(G=0,J=O-32,ce=O-12;J<ce;++J)W[J]+=G-16*W[O]*_t[J-(O-32)],G=Math.floor((W[J]+128)/256),W[J]-=G*256;W[J]+=G,W[O]=0}for(G=0,J=0;J<32;J++)W[J]+=G-(W[31]>>4)*_t[J],G=W[J]>>8,W[J]&=255;for(J=0;J<32;J++)W[J]-=G*_t[J];for(O=0;O<32;O++)W[O+1]+=W[O]>>8,K[O]=W[O]&255}function k(K){var W=new Float64Array(64),G;for(G=0;G<64;G++)W[G]=K[G];for(G=0;G<64;G++)K[G]=0;q(K,W)}function L(K,W,G,O){var J=new Uint8Array(64),ce=new Uint8Array(64),ae=new Uint8Array(64),Ee,ke,Ve=new Float64Array(64),De=[n(),n(),n(),n()];je(J,O,32),J[0]&=248,J[31]&=127,J[31]|=64;var Ut=G+64;for(Ee=0;Ee<G;Ee++)K[64+Ee]=W[Ee];for(Ee=0;Ee<32;Ee++)K[32+Ee]=J[32+Ee];for(je(ae,K.subarray(32),G+32),k(ae),Ge(De,ae),He(K,De),Ee=32;Ee<64;Ee++)K[Ee]=O[Ee];for(je(ce,K,G+64),k(ce),Ee=0;Ee<64;Ee++)Ve[Ee]=0;for(Ee=0;Ee<32;Ee++)Ve[Ee]=ae[Ee];for(Ee=0;Ee<32;Ee++)for(ke=0;ke<32;ke++)Ve[Ee+ke]+=ce[Ee]*J[ke];return q(K.subarray(32),Ve),Ut}function Q(K,W){var G=n(),O=n(),J=n(),ce=n(),ae=n(),Ee=n(),ke=n();return R(K[2],a),h(K[1],W),$(J,K[1]),C(ce,J,l),A(J,J,K[2]),m(ce,K[2],ce),$(ae,ce),$(Ee,ae),C(ke,Ee,ae),C(G,ke,J),C(G,G,ce),Z(G,G),C(G,G,J),C(G,G,ce),C(G,G,ce),C(K[0],G,ce),$(O,K[0]),C(O,O,ce),N(O,J)&&C(K[0],K[0],g),$(O,K[0]),C(O,O,ce),N(O,J)?-1:(x(K[0])===W[31]>>7&&A(K[0],o,K[0]),C(K[3],K[0],K[1]),0)}function oe(K,W,G,O){var J,ce=new Uint8Array(32),ae=new Uint8Array(64),Ee=[n(),n(),n(),n()],ke=[n(),n(),n(),n()];if(G<64||Q(ke,O))return-1;for(J=0;J<G;J++)K[J]=W[J];for(J=0;J<32;J++)K[J+32]=O[J];if(je(ae,K,G),k(ae),Ke(Ee,ke,ae),Ge(ke,W.subarray(32)),$e(Ee,ke),He(ce,Ee),G-=64,E(W,0,ce,0)){for(J=0;J<G;J++)K[J]=0;return-1}for(J=0;J<G;J++)K[J]=W[J+64];return G}var le=32,we=24,wt=32,ut=16,at=32,Gt=32,ot=32,tn=32,fa=32,fn=we,wn=wt,iu=ut,Yt=64,nn=32,ts=64,ln=32,un=64;e.lowlevel={crypto_core_hsalsa20:D,crypto_stream_xor:B,crypto_stream:U,crypto_stream_salsa20_xor:X,crypto_stream_salsa20:Y,crypto_onetimeauth:V,crypto_onetimeauth_verify:T,crypto_verify_16:b,crypto_verify_32:E,crypto_secretbox:p,crypto_secretbox_open:y,crypto_scalarmult:ne,crypto_scalarmult_base:se,crypto_box_beforenm:de,crypto_box_afternm:Ae,crypto_box:Ue,crypto_box_open:Be,crypto_box_keypair:ue,crypto_hash:je,crypto_sign:L,crypto_sign_keypair:Dt,crypto_sign_open:oe,crypto_secretbox_KEYBYTES:le,crypto_secretbox_NONCEBYTES:we,crypto_secretbox_ZEROBYTES:wt,crypto_secretbox_BOXZEROBYTES:ut,crypto_scalarmult_BYTES:at,crypto_scalarmult_SCALARBYTES:Gt,crypto_box_PUBLICKEYBYTES:ot,crypto_box_SECRETKEYBYTES:tn,crypto_box_BEFORENMBYTES:fa,crypto_box_NONCEBYTES:fn,crypto_box_ZEROBYTES:wn,crypto_box_BOXZEROBYTES:iu,crypto_sign_BYTES:Yt,crypto_sign_PUBLICKEYBYTES:nn,crypto_sign_SECRETKEYBYTES:ts,crypto_sign_SEEDBYTES:ln,crypto_hash_BYTES:un,gf:n,D:l,L:_t,pack25519:I,unpack25519:h,M:C,A:m,S:$,Z:A,pow2523:Z,add:$e,set25519:R,modL:q,scalarmult:Ke,scalarbase:Ge};function Cc(K,W){if(K.length!==le)throw new Error("bad key size");if(W.length!==we)throw new Error("bad nonce size")}function vn(K,W){if(K.length!==ot)throw new Error("bad public key size");if(W.length!==tn)throw new Error("bad secret key size")}function Kt(){for(var K=0;K<arguments.length;K++)if(!(arguments[K]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Oc(K){for(var W=0;W<K.length;W++)K[W]=0}e.randomBytes=function(K){var W=new Uint8Array(K);return r(W,K),W},e.secretbox=function(K,W,G){Kt(K,W,G),Cc(G,W);for(var O=new Uint8Array(wt+K.length),J=new Uint8Array(O.length),ce=0;ce<K.length;ce++)O[ce+wt]=K[ce];return p(J,O,O.length,W,G),J.subarray(ut)},e.secretbox.open=function(K,W,G){Kt(K,W,G),Cc(G,W);for(var O=new Uint8Array(ut+K.length),J=new Uint8Array(O.length),ce=0;ce<K.length;ce++)O[ce+ut]=K[ce];return O.length<32||y(J,O,O.length,W,G)!==0?null:J.subarray(wt)},e.secretbox.keyLength=le,e.secretbox.nonceLength=we,e.secretbox.overheadLength=ut,e.scalarMult=function(K,W){if(Kt(K,W),K.length!==Gt)throw new Error("bad n size");if(W.length!==at)throw new Error("bad p size");var G=new Uint8Array(at);return ne(G,K,W),G},e.scalarMult.base=function(K){if(Kt(K),K.length!==Gt)throw new Error("bad n size");var W=new Uint8Array(at);return se(W,K),W},e.scalarMult.scalarLength=Gt,e.scalarMult.groupElementLength=at,e.box=function(K,W,G,O){var J=e.box.before(G,O);return e.secretbox(K,W,J)},e.box.before=function(K,W){Kt(K,W),vn(K,W);var G=new Uint8Array(fa);return de(G,K,W),G},e.box.after=e.secretbox,e.box.open=function(K,W,G,O){var J=e.box.before(G,O);return e.secretbox.open(K,W,J)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var K=new Uint8Array(ot),W=new Uint8Array(tn);return ue(K,W),{publicKey:K,secretKey:W}},e.box.keyPair.fromSecretKey=function(K){if(Kt(K),K.length!==tn)throw new Error("bad secret key size");var W=new Uint8Array(ot);return se(W,K),{publicKey:W,secretKey:new Uint8Array(K)}},e.box.publicKeyLength=ot,e.box.secretKeyLength=tn,e.box.sharedKeyLength=fa,e.box.nonceLength=fn,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(K,W){if(Kt(K,W),W.length!==ts)throw new Error("bad secret key size");var G=new Uint8Array(Yt+K.length);return L(G,K,K.length,W),G},e.sign.open=function(K,W){if(Kt(K,W),W.length!==nn)throw new Error("bad public key size");var G=new Uint8Array(K.length),O=oe(G,K,K.length,W);if(O<0)return null;for(var J=new Uint8Array(O),ce=0;ce<J.length;ce++)J[ce]=G[ce];return J},e.sign.detached=function(K,W){for(var G=e.sign(K,W),O=new Uint8Array(Yt),J=0;J<O.length;J++)O[J]=G[J];return O},e.sign.detached.verify=function(K,W,G){if(Kt(K,W,G),W.length!==Yt)throw new Error("bad signature size");if(G.length!==nn)throw new Error("bad public key size");var O=new Uint8Array(Yt+K.length),J=new Uint8Array(Yt+K.length),ce;for(ce=0;ce<Yt;ce++)O[ce]=W[ce];for(ce=0;ce<K.length;ce++)O[ce+Yt]=K[ce];return oe(J,O,O.length,G)>=0},e.sign.keyPair=function(){var K=new Uint8Array(nn),W=new Uint8Array(ts);return Dt(K,W),{publicKey:K,secretKey:W}},e.sign.keyPair.fromSecretKey=function(K){if(Kt(K),K.length!==ts)throw new Error("bad secret key size");for(var W=new Uint8Array(nn),G=0;G<W.length;G++)W[G]=K[32+G];return{publicKey:W,secretKey:new Uint8Array(K)}},e.sign.keyPair.fromSeed=function(K){if(Kt(K),K.length!==ln)throw new Error("bad seed size");for(var W=new Uint8Array(nn),G=new Uint8Array(ts),O=0;O<32;O++)G[O]=K[O];return Dt(W,G,!0),{publicKey:W,secretKey:G}},e.sign.publicKeyLength=nn,e.sign.secretKeyLength=ts,e.sign.seedLength=ln,e.sign.signatureLength=Yt,e.hash=function(K){Kt(K);var W=new Uint8Array(un);return je(W,K,K.length),W},e.hash.hashLength=un,e.verify=function(K,W){return Kt(K,W),K.length===0||W.length===0||K.length!==W.length?!1:w(K,0,W,0,K.length)===0},e.setPRNG=function(K){r=K},(function(){var K=typeof self<"u"?self.crypto||self.msCrypto:null;if(K&&K.getRandomValues){var W=65536;e.setPRNG(function(G,O){var J,ce=new Uint8Array(O);for(J=0;J<O;J+=W)K.getRandomValues(ce.subarray(J,J+Math.min(O-J,W)));for(J=0;J<O;J++)G[J]=ce[J];Oc(ce)})}else typeof HD<"u"&&(K=MR,K&&K.randomBytes&&e.setPRNG(function(G,O){var J,ce=K.randomBytes(O);for(J=0;J<O;J++)G[J]=ce[J];Oc(ce)}))})()})(t.exports?t.exports:self.nacl=self.nacl||{})})(Cp)),Cp.exports}WD();var Op,XE;function GD(){if(XE)return Op;XE=1;function t(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(n[o]!==255)throw new TypeError(s+" is ambiguous");n[o]=i}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var w=0,b=0,E=0,M=v.length;E!==M&&v[E]===0;)E++,w++;for(var S=(M-E)*u+1>>>0,F=new Uint8Array(S);E!==M;){for(var D=v[E],z=0,X=S-1;(D!==0||z<b)&&X!==-1;X--,z++)D+=256*F[X]>>>0,F[X]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");b=z,E++}for(var Y=S-b;Y!==S&&F[Y]===0;)Y++;for(var U=c.repeat(w);Y<S;++Y)U+=e.charAt(F[Y]);return U}function f(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;for(var w=0,b=0,E=0;v[w]===c;)b++,w++;for(var M=(v.length-w)*l+1>>>0,S=new Uint8Array(M);v[w];){var F=v.charCodeAt(w);if(F>255)return;var D=n[F];if(D===255)return;for(var z=0,X=M-1;(D!==0||z<E)&&X!==-1;X--,z++)D+=a*S[X]>>>0,S[X]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");E=z,w++}for(var Y=M-E;Y!==M&&S[Y]===0;)Y++;for(var U=new Uint8Array(b+(M-Y)),B=b;Y!==M;)U[B++]=S[Y++];return U}function g(v){var w=f(v);if(w)return w;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:f,decode:g}}return Op=t,Op}var Np,QE;function YD(){return QE||(QE=1,Np=GD()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),Np}YD();var JD={[Sn.SOLANA_MAINNET]:{chain:"solana",network:"mainnet",description:"Solana Mainnet-Beta"},[Sn.SOLANA_DEVNET]:{chain:"solana",network:"devnet",description:"Solana Devnet"},[Sn.SOLANA_TESTNET]:{chain:"solana",network:"testnet",description:"Solana Testnet"},[Sn.ETHEREUM_MAINNET]:{chain:"ethereum",network:"mainnet",description:"Ethereum Mainnet"},[Sn.ETHEREUM_SEPOLIA]:{chain:"ethereum",network:"sepolia",description:"Sepolia Testnet"},[Sn.POLYGON_MAINNET]:{chain:"polygon",network:"mainnet",description:"Polygon Mainnet"},[Sn.POLYGON_AMOY]:{chain:"polygon",network:"amoy",description:"Polygon Amoy Testnet"},[Sn.BASE_MAINNET]:{chain:"base",network:"mainnet",description:"Base Mainnet"},[Sn.BASE_SEPOLIA]:{chain:"base",network:"sepolia",description:"Base Sepolia Testnet"},[Sn.ARBITRUM_ONE]:{chain:"arbitrum",network:"mainnet",description:"Arbitrum One"},[Sn.ARBITRUM_SEPOLIA]:{chain:"arbitrum",network:"sepolia",description:"Arbitrum Sepolia Testnet"},[Sn.MONAD_MAINNET]:{chain:"monad",network:"mainnet",description:"Monad Mainnet"},[Sn.MONAD_TESTNET]:{chain:"monad",network:"testnet",description:"Monad Testnet"},[Sn.BITCOIN_MAINNET]:{chain:"bitcoin",network:"mainnet",description:"Bitcoin Mainnet"},[Sn.BITCOIN_TESTNET]:{chain:"bitcoin",network:"testnet",description:"Bitcoin Testnet"},[Sn.SUI_MAINNET]:{chain:"sui",network:"mainnet",description:"Sui Mainnet"},[Sn.SUI_TESTNET]:{chain:"sui",network:"testnet",description:"Sui Testnet"}};function ZD(t){const e=JD[t];if(e)return{chain:e.chain,network:e.network}}var hr={Solana:(t=0)=>`m/44'/501'/${t}'/0'`,Ethereum:(t=0)=>`m/44'/60'/0'/0/${t}`,Bitcoin:(t=0)=>`m/84'/0'/${t}'/0`,Sui:(t=0)=>`m/44'/784'/${t}'/0'/0'`};function Ku(t,e=0){switch(t.split(":")[0].toLowerCase()){case"solana":return{derivationPath:hr.Solana(e),curve:La.ed25519,algorithm:Bo.ed25519,addressFormat:yt.solana};case"sui":return{derivationPath:hr.Sui(e),curve:La.ed25519,algorithm:Bo.ed25519,addressFormat:yt.sui};case"bitcoin":case"btc":return{derivationPath:hr.Bitcoin(e),curve:La.secp256k1,algorithm:Bo.secp256k1,addressFormat:yt.bitcoinSegwit};case"eip155":return{derivationPath:hr.Ethereum(e),curve:La.secp256k1,algorithm:Bo.secp256k1,addressFormat:yt.ethereum};default:return null}}var Pl=class extends Error{constructor(t,e){super(t.detail),this.name=e,this.type=t.type,this.title=t.title,this.detail=t.detail,this.requestId=t.requestId}};function kR(t){if(_D(t))return t.response?.data}function eb(t,e="An error occurred"){if(t instanceof Pl)return t.detail||t.title||t.message||e;const n=kR(t);return n?n.message||n.detail||n.title||e:t instanceof Error?t.message:e}function XD(t){if(!t||!t.type)return null;switch(t.type){case"spending-limit-exceeded":return new DR(t);case"transaction-blocked":return new QD(t);default:return null}}var DR=class extends Pl{constructor(t){super(t,"SpendingLimitError"),this.previousSpendCents=t.previousSpendCents,this.transactionSpendCents=t.transactionSpendCents,this.totalSpendCents=t.totalSpendCents,this.limitCents=t.limitCents}},QD=class extends Pl{constructor(t){super(t,"TransactionBlockedError"),this.scannerResult=t.scannerResult}},Pp=class{constructor(t,e){this.config={...t,walletType:t.walletType||"user-wallet"},this.axiosInstance=yn.create();const n={};t.headers&&Object.assign(n,t.headers),Object.keys(n).length>0&&this.axiosInstance.interceptors.request.use(i=>(Object.assign(i.headers,n),i)),e&&(this.axiosInstance.interceptors.request.use(async i=>await this.stampRequest(i,e)),this.stamper=e);const r=new DD({basePath:t.apiBaseUrl});this.kmsApi=new kD(r,t.apiBaseUrl,this.axiosInstance)}setOrganizationId(t){if(!t)throw new Error("organizationId is required");this.config.organizationId=t}async createWallet(t){try{if(!this.config.organizationId)throw new Error("organizationId is required to create a wallet");const e=await Mr(),n={organizationId:this.config.organizationId,walletName:t||`Wallet ${e}`,accounts:[hr.Solana(),hr.Ethereum(),hr.Bitcoin(),hr.Sui()]},r={method:vm.createWallet,params:n,timestampMs:e},s=(await this.kmsApi.postKmsRpc(r)).data.result,o={method:cf.getAccounts,params:{accounts:[hr.Solana(),hr.Ethereum(),hr.Bitcoin(),hr.Sui()],organizationId:this.config.organizationId,walletId:s.walletId},timestampMs:e},c=(await this.kmsApi.postKmsRpc(o)).data.result;return{walletId:s.walletId,addresses:c.map(l=>({addressType:l.addressFormat,address:l.address}))}}catch(e){throw console.error("Failed to create wallet:",e.response?.data||e.message),new Error(`Failed to create wallet: ${e.response?.data?.message||e.message}`)}}async prepare(t,e,n,r){try{const i={transaction:t,organizationId:e,submissionConfig:n,simulationConfig:{account:r}};return(await this.axiosInstance.post(`${this.config.apiBaseUrl}/prepare`,i,{headers:{"Content-Type":"application/json"}})).data}catch(i){const s=kR(i),o=XD(s);if(o)throw o;const a=s?.detail||eb(i,"Failed to submit transaction");throw new Error(a)}}async getTransactionForSigning(t){const{encodedTransaction:e,networkId:n,submissionConfig:r,account:i}=t,s=PR(n),o=jD(n);if(s)return{kind:"RLP_ENCODED",bytes:e};if(o&&this.config.walletType==="user-wallet"){if(!i)throw new Error("Account is required to simulate Solana transactions with spending limits");try{return(await this.prepare(e,this.config.organizationId,r,i)).transaction}catch(a){if(a instanceof Pl)throw a;const c=a instanceof Error?a.message:String(a);throw new Error(c)}}return e}async performTransactionSigning(t,e){const n=t.walletId,r=t.transaction,i=t.networkId,s=t.derivationIndex??0;try{if(!this.config.organizationId)throw new Error("organizationId is required to sign a transaction");const o=ZD(i);if(!o)throw new Error(`SubmissionConfig could not be derived for network ID: ${i}`);const a=Ku(i,s);if(!a)throw new Error(`Unsupported network ID: ${i}`);const c={derivationPath:a.derivationPath,curve:a.curve,addressFormat:a.addressFormat},l=await this.getTransactionForSigning({encodedTransaction:r,networkId:i,submissionConfig:o,account:t.account}),u={organizationId:this.config.organizationId,walletId:n,transaction:l,derivationInfo:c};e&&(u.submissionConfig=o),e&&t.account&&(u.simulationConfig={account:t.account});const d={method:_m.signTransaction,params:u,timestampMs:await Mr()},f=await this.kmsApi.postKmsRpc(d),g=f.data.result,v=f.data.rpc_submission_result,w=e&&v?v.result:null;return{signedTransaction:g.transaction,hash:w}}catch(o){const a=e?"sign and send":"sign";throw o instanceof Pl?o:new Error(eb(o,`Failed to ${a} transaction`))}}async signTransaction(t){return{rawTransaction:(await this.performTransactionSigning(t,!1)).signedTransaction}}async signAndSendTransaction(t){const e=await this.performTransactionSigning(t,!0);return{rawTransaction:e.signedTransaction,hash:e.hash}}async getWalletAddresses(t,e,n){try{const r=n??0,i=e||[hr.Solana(r),hr.Ethereum(r),hr.Bitcoin(r),hr.Sui(r)],s={method:cf.getAccounts,params:{accounts:i,organizationId:this.config.organizationId,walletId:t},timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(s)).data.result.map(l=>({addressType:l.addressFormat,address:l.address}))}catch(r){throw console.error("Failed to get wallet addresses:",r.response?.data||r.message),new Error(`Failed to get wallet addresses: ${r.response?.data?.message||r.message}`)}}async ethereumSignMessage(t){const e=t.walletId,n=t.message,r=t.networkId,i=t.derivationIndex??0;try{if(!this.config.organizationId)throw new Error("organizationId is required to sign a message");const s=Ku(r,i);if(!s)throw new Error(`Unsupported network ID: ${r}`);const o={derivationPath:s.derivationPath,curve:s.curve,addressFormat:s.addressFormat},c={method:"ethereumSignMessage",params:{message:n,organizationId:this.config.organizationId,walletId:e,derivationInfo:o},timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(c)).data.result.signature}catch(s){throw console.error("Failed to sign Ethereum message:",s.response?.data||s.message),new Error(`Failed to sign Ethereum message: ${s.response?.data?.message||s.message}`)}}async signUtf8Message(t){const e=t.walletId,n=t.message,r=t.networkId,i=t.derivationIndex??0;try{if(!this.config.organizationId)throw new Error("organizationId is required to sign a message");const s=Ku(r,i);if(!s)throw new Error(`Unsupported network ID: ${r}`);const o={derivationPath:s.derivationPath,curve:s.curve,addressFormat:s.addressFormat},a={organizationId:this.config.organizationId,walletId:e,message:n,algorithm:s.algorithm,derivationInfo:o},c={method:Sm.signUtf8Message,params:a,timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(c)).data.result.signature}catch(s){throw console.error("Failed to sign raw payload:",s.response?.data||s.message),new Error(`Failed to sign raw payload: ${s.response?.data?.message||s.message}`)}}async ethereumSignTypedData(t){const e=t.walletId,n=t.typedData,r=t.networkId,i=t.derivationIndex??0;try{if(!this.config.organizationId)throw new Error("organizationId is required to sign typed data");const s=Ku(r,i);if(!s)throw new Error(`Unsupported network ID: ${r}`);const o={derivationPath:s.derivationPath,curve:s.curve,addressFormat:s.addressFormat},a={method:"ethereumSignTypedData",params:{typedData:n,organizationId:this.config.organizationId,walletId:e,derivationInfo:o},timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(a)).data.result.signature}catch(s){throw console.error("Failed to sign typed data:",s.response?.data||s.message),new Error(`Failed to sign typed data: ${s.response?.data?.message||s.message}`)}}async getWallets(t,e){try{const n={method:"getOrganizationWallets",params:{organizationId:this.config.organizationId,limit:t||20,offset:e||0},timestampMs:await Mr()},i=(await this.kmsApi.postKmsRpc(n)).data.result;return{wallets:i.wallets.map(s=>({walletId:s.walletId,walletName:s.walletName})),totalCount:i.totalCount,limit:i.limit,offset:i.offset}}catch(n){throw console.error("Failed to get wallets:",n.response?.data||n.message),new Error(`Failed to get wallets: ${n.response?.data?.message||n.message}`)}}async getOrganization(t){try{const e={method:"getOrganization",params:{organizationId:t},timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(e)).data.result}catch(e){throw console.error("Failed to get organization:",e.response?.data||e.message),new Error(`Failed to get organization: ${e.response?.data?.message||e.message}`)}}validateNameLength(t,e){if(t.length>64)throw new Error(`${e} name cannot exceed 64 characters. Current length: ${t.length}`)}async createOrganization(t,e,n){try{if(!t)throw new Error("Organization name is required");if(this.validateNameLength(t,"Organization"),!e||e.length===0)throw new Error("At least one user is required");for(const a of e){a.username&&this.validateNameLength(a.username,"Username");for(const c of a.authenticators)c.authenticatorName&&this.validateNameLength(c.authenticatorName,"Authenticator")}const r={organizationName:t,users:e.map(a=>({username:a.username||`user-${OR()}`,authenticators:a.authenticators,policy:a.role==="ADMIN"?{type:xm.root}:{type:"CEL",preset:"LEGACY_USER_ROLE"}})),tags:n},i={method:wm.createOrganization,params:r,timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(i)).data.result}catch(r){throw console.error("Failed to create organization:",r.response?.data||r.message),new Error(`Failed to create organization: ${r.response?.data?.message||r.message}`)}}async createAuthenticator(t){try{t.username&&this.validateNameLength(t.username,"Username"),t.authenticatorName&&this.validateNameLength(t.authenticatorName,"Authenticator"),t.authenticator?.authenticatorName&&this.validateNameLength(t.authenticator.authenticatorName,"Authenticator");const e={organizationId:t.organizationId,username:t.username,authenticatorName:t.authenticatorName,authenticator:t.authenticator,replaceExpirable:t.replaceExpirable},n={method:ym.createAuthenticator,params:e,timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(n)).data.result}catch(e){throw console.error("Failed to create authenticator:",e.response?.data||e.message),new Error(`Failed to create authenticator: ${e.response?.data?.message||e.message}`)}}async deleteAuthenticator(t){try{const e={organizationId:t.organizationId,username:t.username,authenticatorId:t.authenticatorId},n={method:Em.deleteAuthenticator,params:e,timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(n)).data.result}catch(e){throw console.error("Failed to delete authenticator:",e.response?.data||e.message),new Error(`Failed to delete authenticator: ${e.response?.data?.message||e.message}`)}}async grantOrganizationAccess(t){try{const e={method:bm.grantOrganizationAccess,params:t,timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(e)).data.result}catch(e){throw console.error("Failed to grant organization access:",e.response?.data||e.message),new Error(`Failed to grant organization access: ${e.response?.data?.message||e.message}`)}}async addUserToOrganization(t){try{const e={method:gm.addUserToOrganization,params:t,timestampMs:await Mr()};await this.kmsApi.postKmsRpc(e)}catch(e){throw console.error("Failed to add user to organization:",e.response?.data||e.message),new Error(`Failed to add user to organization: ${e.response?.data?.message||e.message}`)}}async getWalletWithTag(t){try{const e={method:"getWalletWithTag",params:{organizationId:t.organizationId,tag:t.tag,derivationPaths:t.derivationPaths},timestampMs:await Mr()};return(await this.kmsApi.postKmsRpc(e)).data.result}catch(e){throw console.error("Failed to get wallet with tag:",e.response?.data||e.message),new Error(`Failed to get wallet with tag: ${e.response?.data?.message||e.message}`)}}async stampRequest(t,e){const n=typeof t.data=="string"?t.data:t.data===void 0?"":JSON.stringify(t.data),r=Et.Buffer.from(n,"utf8"),i=await e.stamp({data:r});return t.headers=t.headers||{},t.headers["X-Phantom-Stamp"]=i,t}},eL=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},LR=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},sn=(t,e,n)=>(eL(t,e,"access private method"),n),tL=4,nL=100,fr,Er,rL=class{constructor(){LR(this,fr),this.type="injected"}load(){let t=0;const e=(n,r)=>{const i=nL*Math.pow(2,Math.min(t,5));setTimeout(()=>{if(sn(this,fr,Er).call(this)){n();return}t++,t>=tL?r():e(n,r)},i)};return new Promise((n,r)=>{e(()=>n(this),r)})}getProvider(){return sn(this,fr,Er).call(this)||null}get isConnected(){const t=sn(this,fr,Er).call(this);return!!(t?.isConnected&&t.selectedAddress)}async connect({onlyIfTrusted:t}){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");if(e.isConnected&&e.selectedAddress)return this.getAccounts();try{return await e.request({method:t?"eth_accounts":"eth_requestAccounts"})}catch{return}}async disconnect(){return Promise.resolve()}async getAccounts(){const t=sn(this,fr,Er).call(this);if(!t)return[];try{return await t.request({method:"eth_accounts"})||[]}catch{return[]}}async signMessage(t,e){const n=sn(this,fr,Er).call(this);if(!n)throw new Error("Provider not found.");if(!n.isConnected)throw new Error("Provider is not connected.");return await n.request({method:"eth_sign",params:[e,t]})}async signPersonalMessage(t,e){const n=sn(this,fr,Er).call(this);if(!n)throw new Error("Provider not found.");if(!n.isConnected)throw new Error("Provider is not connected.");return await n.request({method:"personal_sign",params:[t,e]})}async signTypedData(t,e){const n=sn(this,fr,Er).call(this);if(!n)throw new Error("Provider not found.");if(!n.isConnected)throw new Error("Provider is not connected.");return await n.request({method:"eth_signTypedData_v4",params:[e,JSON.stringify(t)]})}async signIn(t){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");const n=`Sign in to ${t.domain||"this application"}`,r=e.selectedAddress;if(!r)throw new Error("No address available.");const i=await this.signPersonalMessage(n,r);return{address:r,signature:i,signedMessage:n}}async sendTransaction(t){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");return await e.request({method:"eth_sendTransaction",params:[t]})}async signTransaction(t){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");return await e.request({method:"eth_signTransaction",params:[t]})}async getChainId(){const t=sn(this,fr,Er).call(this);if(!t)throw new Error("Provider not found.");return await t.request({method:"eth_chainId"})}async switchChain(t){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");await e.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}async request(t){const e=sn(this,fr,Er).call(this);if(!e)throw new Error("Provider not found.");return await e.request(t)}};fr=new WeakSet;Er=function(){if(!(typeof window>"u"))return window?.phantom?.ethereum};async function Qr(t="injected"){if(t==="injected"){const e=new rL;try{return await e.load(),e}catch{throw new Error("Provider not found.")}}else throw new Error("Invalid provider type.")}var ul=new Map;function iL(t,e){return ul.has(t)||ul.set(t,new Set),ul.get(t).add(e),()=>BR(t,e)}function BR(t,e){const n=ul.get(t);n&&n.delete(e)}function Uo(t,e){const n=ul.get(t);n&&n.forEach(r=>{try{r(e)}catch(i){console.error(`Error in ${t} event listener:`,i)}})}async function sL({onlyIfTrusted:t=!1}={}){const e=await Qr();if(!e)throw new Error("Provider not found.");if(e.isConnected)return await e.getAccounts();try{const n=await e.connect({onlyIfTrusted:!0});if(n&&n.length>0)return Uo("connect",n),n}catch{}if(t)throw new Error("No trusted connection available.");try{const n=await e.connect({onlyIfTrusted:!1});if(n&&n.length>0)return Uo("connect",n),n}catch{}throw new Error("Failed to connect to Phantom.")}async function oL(){const t=await Qr();if(!t)throw new Error("Provider not found.");await t.disconnect(),Uo("disconnect",[])}async function aL(){const t=await Qr();if(!t)throw new Error("Provider not found.");return t.getAccounts()}async function cL(t,e){const n=await Qr();if(!n)throw new Error("Provider not found.");return n.isConnected||await n.connect({onlyIfTrusted:!1}),n.signMessage(t,e)}async function lL(t,e){const n=await Qr();if(!n)throw new Error("Provider not found.");return n.isConnected||await n.connect({onlyIfTrusted:!1}),n.signPersonalMessage(t,e)}async function uL(t,e){const n=await Qr();if(!n)throw new Error("Provider not found.");return n.isConnected||await n.connect({onlyIfTrusted:!1}),n.signTypedData(t,e)}async function dL(t){const e=await Qr();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signIn(t)}async function fL(t){const e=await Qr();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.sendTransaction(t)}async function hL(t){const e=await Qr();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signTransaction(t)}async function pL(){const t=await Qr();if(!t)throw new Error("Provider not found.");return t.getChainId()}async function mL(t){const e=await Qr();if(!e)throw new Error("Provider not found.");return e.switchChain(t)}var gL={connect:sL,disconnect:oL,getAccounts:aL,signMessage:cL,signPersonalMessage:lL,signTypedData:uL,signIn:dL,sendTransaction:fL,signTransaction:hL,getChainId:pL,switchChain:mL,getProvider:Qr,addEventListener:iL,removeEventListener:BR};async function yL(){try{const e=(await Qr()).getProvider();e&&(e.on("connect",()=>{e.request({method:"eth_accounts"}).then(n=>{n?.length>0&&Uo("connect",n)}).catch(()=>{})}),e.on("disconnect",()=>Uo("disconnect",[])),e.on("accountsChanged",n=>Uo("accountsChanged",n)),e.on("chainChanged",n=>Uo("chainChanged",n)))}catch{}}function wL(){return{name:"ethereum",create:()=>(yL(),gL)}}function Zf(){try{return!!window?.phantom}catch{return!1}}var vL={isInstalled:Zf};function EL(){return{name:"extension",create:()=>vL}}function bL({plugins:t=[]}){const e={};for(const n of t)e[n.name]=n.create();return e}var _L=4,SL=100,kr,Hr,xL=class{constructor(){LR(this,kr),this.type="injected"}load(){let t=0;const e=(n,r)=>{const i=SL*Math.pow(2,Math.min(t,5));setTimeout(()=>{if(sn(this,kr,Hr).call(this)){n();return}t++,t>=_L?r():e(n,r)},i)};return new Promise((n,r)=>{e(()=>n(this),r)})}getProvider(){return sn(this,kr,Hr).call(this)||null}get isConnected(){const t=sn(this,kr,Hr).call(this);return!!(t?.isConnected&&t.publicKey)}async connect({onlyIfTrusted:t}){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");if(e.isConnected&&e.publicKey)return this.getAccount()??void 0;try{return(await e.connect({onlyIfTrusted:t})).publicKey.toString()}catch{return}}async disconnect(){const t=sn(this,kr,Hr).call(this);if(!t)throw new Error("Provider not found.");await t.disconnect()}async getAccount(){const t=sn(this,kr,Hr).call(this);return t&&t.isConnected&&t.publicKey?Promise.resolve(t.publicKey.toString()):Promise.resolve(void 0)}async signMessage(t,e){const n=sn(this,kr,Hr).call(this);if(!n)throw new Error("Provider not found.");if(!n.isConnected)throw new Error("Provider is not connected.");const r=await n.signMessage(t,e);return{signature:r.signature,address:r.publicKey.toString()}}async signIn(t){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");const n=await e.signIn(t);return{address:n.address.toString(),signature:n.signature,signedMessage:n.signedMessage}}async signAndSendTransaction(t){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");const n=await e.signAndSendTransaction(t);return{signature:n.signature,address:n.publicKey}}async signAndSendAllTransactions(t){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");if(!e.signAndSendAllTransactions)throw new Error("Provider does not support signAndSendAllTransactions.");const n=await e.signAndSendAllTransactions(t);return{signatures:n.signatures,address:n.publicKey}}async signTransaction(t){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");return await e.signTransaction(t)}async signAllTransactions(t){const e=sn(this,kr,Hr).call(this);if(!e)throw new Error("Provider not found.");if(!e.isConnected)throw new Error("Provider is not connected.");return await e.signAllTransactions(t)}};kr=new WeakSet;Hr=function(){if(!(typeof window>"u"))return window?.phantom?.solana};async function Qi(t="injected"){if(t==="injected"){const e=new xL;try{return await e.load(),e}catch{throw new Error("Provider not found.")}}else throw new Error("Invalid provider type.")}var _s=new Map;function AL(t,e){return _s.has(t)||_s.set(t,new Set),_s.get(t).add(e),()=>{UR(t,e)}}function UR(t,e){_s.has(t)&&(_s.get(t).delete(e),_s.get(t).size===0&&_s.delete(t))}function qo(t,...e){_s.has(t)&&_s.get(t).forEach(n=>{t==="connect"&&e[0]&&typeof e[0]=="string"?n(e[0]):t==="disconnect"?n():t==="accountChanged"&&e[0]&&typeof e[0]=="string"&&n(e[0])})}async function RL({onlyIfTrusted:t=!1}={}){const e=await Qi();if(!e)throw new Error("Provider not found.");if(e.isConnected)return e.getAccount();try{const n=await e.connect({onlyIfTrusted:!0});if(n)return qo("connect",n),n}catch{}if(t)throw new Error("No trusted connection available.");try{const n=await e.connect({onlyIfTrusted:!1});if(n)return qo("connect",n),n}catch{}throw new Error("Failed to connect to Phantom.")}async function IL(){const t=await Qi();if(!t)throw new Error("Provider not found.");await t.disconnect(),qo("disconnect")}async function TL(){return(await Qi()).getAccount()}async function CL(t){const e=await Qi();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signAndSendTransaction(t)}async function OL(t){const e=await Qi();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signAndSendAllTransactions(t)}async function NL(t){const e=await Qi();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signTransaction(t)}async function PL(t){const e=await Qi();if(!e)throw new Error("Provider not found.");return e.isConnected||await e.connect({onlyIfTrusted:!1}),e.signAllTransactions(t)}async function ML(t){const e=await Qi();if(!e)throw new Error("Provider not found.");const n=await e.signIn(t);return n.address&&qo("connect",n.address),n}async function kL(t,e){const n=await Qi();if(!n)throw new Error("Provider not found.");return n.isConnected||await n.connect({onlyIfTrusted:!1}),n.signMessage(t,e)}var DL={connect:RL,disconnect:IL,getAccount:TL,signMessage:kL,signIn:ML,signTransaction:NL,signAllTransactions:PL,signAndSendTransaction:CL,signAndSendAllTransactions:OL,addEventListener:AL,removeEventListener:UR};async function LL(){try{const e=(await Qi()).getProvider();e&&(e.on("connect",n=>{n&&qo("connect",n.toString())}),e.on("disconnect",()=>qo("disconnect")),e.on("accountChanged",n=>{n&&qo("accountChanged",n.toString())}))}catch{}}function BL(){return{name:"solana",create:()=>(LL(),DL)}}function Xf(){if(typeof window>"u")return null;const t=window?.phantom?.app;return t||null}async function UL(t){const e=await Xf();if(!e)throw new Error("Provider not found.");const n=t?.chains?{chains:t.chains.map(FD)}:{},r=await e.request({method:"phantom_auto_confirm_enable",params:n});return{...r,chains:r.chains.map(Jf)}}async function $L(){const t=await Xf();if(!t)throw new Error("Provider not found.");const e=await t.request({method:"phantom_auto_confirm_disable",params:{}});return{...e,chains:e.chains.map(Jf)}}async function FL(){const t=await Xf();if(!t)throw new Error("Provider not found.");const e=await t.request({method:"phantom_auto_confirm_status",params:{}});return{...e,chains:e.chains.map(Jf)}}async function KL(){const t=await Xf();if(!t)throw new Error("Provider not found.");return{chains:(await t.request({method:"phantom_auto_confirm_supported_chains",params:{}})).chains.map(Jf)}}var VL={autoConfirmEnable:UL,autoConfirmDisable:$L,autoConfirmStatus:FL,autoConfirmSupportedChains:KL};function jL(){return{name:"autoConfirm",create:()=>VL}}var Mp={exports:{}},tb;function HL(){return tb||(tb=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var g=new i(u,d||c,f),v=n?n+l:l;return c._events[v]?c._events[v].fn?c._events[v]=[c._events[v],g]:c._events[v].push(g):(c._events[v]=g,c._eventsCount++),c}function o(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)e.call(u,d)&&l.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=n?n+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,v=new Array(g);f<g;f++)v[f]=d[f].fn;return v},a.prototype.listenerCount=function(l){var u=n?n+l:l,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,u,d,f,g,v){var w=n?n+l:l;if(!this._events[w])return!1;var b=this._events[w],E=arguments.length,M,S;if(b.fn){switch(b.once&&this.removeListener(l,b.fn,void 0,!0),E){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,u),!0;case 3:return b.fn.call(b.context,u,d),!0;case 4:return b.fn.call(b.context,u,d,f),!0;case 5:return b.fn.call(b.context,u,d,f,g),!0;case 6:return b.fn.call(b.context,u,d,f,g,v),!0}for(S=1,M=new Array(E-1);S<E;S++)M[S-1]=arguments[S];b.fn.apply(b.context,M)}else{var F=b.length,D;for(S=0;S<F;S++)switch(b[S].once&&this.removeListener(l,b[S].fn,void 0,!0),E){case 1:b[S].fn.call(b[S].context);break;case 2:b[S].fn.call(b[S].context,u);break;case 3:b[S].fn.call(b[S].context,u,d);break;case 4:b[S].fn.call(b[S].context,u,d,f);break;default:if(!M)for(D=1,M=new Array(E-1);D<E;D++)M[D-1]=arguments[D];b[S].fn.apply(b[S].context,M)}}return!0},a.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},a.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},a.prototype.removeListener=function(l,u,d,f){var g=n?n+l:l;if(!this._events[g])return this;if(!u)return o(this,g),this;var v=this._events[g];if(v.fn)v.fn===u&&(!f||v.once)&&(!d||v.context===d)&&o(this,g);else{for(var w=0,b=[],E=v.length;w<E;w++)(v[w].fn!==u||f&&!v[w].once||d&&v[w].context!==d)&&b.push(v[w]);b.length?this._events[g]=b.length===1?b[0]:b:o(this,g)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=n?n+l:l,this._events[u]&&o(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Mp)),Mp.exports}var zL=HL();const _c=hc(zL);var lf=typeof window<"u"&&typeof window.btoa<"u";function Fn(t){let e;return lf?typeof t=="string"?e=btoa(t):e=btoa(String.fromCharCode(...Array.from(t))):typeof t=="string"?e=Buffer.from(t,"utf8").toString("base64"):e=Buffer.from(t).toString("base64"),e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Sc(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"=");if(lf){const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r}else return new Uint8Array(Buffer.from(e,"base64"))}function qL(t){if(lf&&typeof TextEncoder<"u"){const e=new TextEncoder().encode(t);return Fn(e)}else return Fn(t)}var WL=1,GL=2,YL=3,JL=4,ZL=5,XL=6,QL=7,eB=8,tB=9,nB=10,rB=-32700,iB=-32603,sB=-32602,oB=-32601,aB=-32600,cB=-32016,lB=-32015,uB=-32014,dB=-32013,fB=-32012,hB=-32011,pB=-32010,mB=-32009,gB=-32008,yB=-32007,wB=-32006,vB=-32005,EB=-32004,bB=-32003,_B=-32002,SB=-32001,xB=28e5,AB=2800001,RB=2800002,IB=2800003,TB=2800004,CB=2800005,OB=2800006,NB=2800007,PB=2800008,MB=2800009,kB=2800010,DB=2800011,LB=323e4,BB=32300001,UB=3230002,$B=3230003,FB=3230004,KB=361e4,VB=3610001,jB=3610002,HB=3610003,zB=3610004,qB=3610005,WB=3610006,GB=3610007,YB=3611e3,JB=3704e3,ZB=3704001,XB=3704002,QB=3704003,eU=3704004,tU=4128e3,nU=4128001,rU=4128002,iU=4615e3,sU=4615001,oU=4615002,aU=4615003,cU=4615004,lU=4615005,uU=4615006,dU=4615007,fU=4615008,hU=4615009,pU=4615010,mU=4615011,gU=4615012,yU=4615013,wU=4615014,vU=4615015,EU=4615016,bU=4615017,_U=4615018,SU=4615019,xU=4615020,AU=4615021,RU=4615022,IU=4615023,TU=4615024,CU=4615025,OU=4615026,NU=4615027,PU=4615028,MU=4615029,kU=4615030,DU=4615031,LU=4615032,BU=4615033,UU=4615034,$U=4615035,FU=4615036,KU=4615037,VU=4615038,jU=4615039,HU=4615040,zU=4615041,qU=4615042,WU=4615043,GU=4615044,YU=4615045,JU=4615046,ZU=4615047,XU=4615048,QU=4615049,e9=4615050,t9=4615051,n9=4615052,r9=4615053,i9=4615054,s9=5508e3,o9=5508001,a9=5508002,c9=5508003,l9=5508004,u9=5508005,d9=5508006,f9=5508007,h9=5508008,p9=5508009,m9=5508010,g9=5508011,y9=5663e3,w9=5663001,v9=5663002,E9=5663003,b9=5663004,_9=5663005,S9=5663006,x9=5663007,A9=5663008,R9=5663009,I9=5663010,T9=5663011,C9=5663012,O9=5663013,N9=5663014,P9=5663015,M9=5663016,k9=5663017,D9=5663018,L9=5663019,B9=5663020,U9=705e4,$9=7050001,F9=7050002,K9=7050003,V9=7050004,j9=7050005,H9=7050006,z9=7050007,q9=7050008,W9=7050009,G9=7050010,Y9=7050011,J9=7050012,Z9=7050013,X9=7050014,Q9=7050015,e7=7050016,t7=7050017,n7=7050018,r7=7050019,i7=7050020,s7=7050021,o7=7050022,a7=7050023,c7=7050024,l7=7050025,u7=7050026,d7=7050027,f7=7050028,h7=7050029,p7=7050030,m7=7050031,g7=7050032,y7=7050033,w7=7050034,v7=7050035,E7=7050036,$R=8078e3,FR=8078001,b7=8078002,_7=8078003,KR=8078004,VR=8078005,jR=8078006,S7=8078007,x7=8078008,A7=8078009,R7=8078010,HR=8078011,I7=8078012,T7=8078013,C7=8078014,O7=8078015,N7=8078016,P7=8078017,M7=8078018,k7=8078019,D7=8078020,L7=8078021,B7=8078022,U7=81e5,$7=8100001,F7=8100002,K7=8100003,V7=819e4,j7=8190001,H7=8190002,z7=8190003,q7=8190004,W7=99e5,G7=9900001,Y7=9900002,J7=9900003,Z7=9900004;function zR(t){return Array.isArray(t)?"%5B"+t.map(zR).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function X7([t,e]){return`${t}=${zR(e)}`}function Q7(t){const e=Object.entries(t).map(X7).join("&");return btoa(e)}var e$={[LB]:"Account not found at address: $address",[FB]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[$B]:"Expected decoded account at address: $address",[UB]:"Failed to decode account data at address: $address",[BB]:"Accounts not found at addresses: $addresses",[MB]:"Unable to find a viable program address bump seed.",[RB]:"$putativeAddress is not a base58-encoded address.",[xB]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[IB]:"The `CryptoKey` must be an `Ed25519` public key.",[DB]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[PB]:"Invalid seeds; point must fall off the Ed25519 curve.",[TB]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[OB]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[NB]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[CB]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[kB]:"Program address cannot end with PDA marker.",[AB]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[JL]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[WL]:"The network has progressed past the last block for which this transaction could have been committed.",[$R]:"Codec [$codecDescription] cannot decode empty byte arrays.",[B7]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[D7]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[VR]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[jR]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[KR]:"Encoder and decoder must either both be fixed-size or variable-size.",[x7]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[b7]:"Expected a fixed-size codec, got a variable-size one.",[T7]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[_7]:"Expected a variable-size codec, got a fixed-size one.",[k7]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[FR]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[M7]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[A7]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[R7]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[O7]:"Invalid literal union variant. Expected one of [$variants], got $value.",[S7]:"Expected [$codecDescription] to have $expected items, got $actual.",[I7]:"Invalid value $value for base $base with alphabet $alphabet.",[N7]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[HR]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[C7]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[L7]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[P7]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[YB]:"No random values implementation could be found.",[hU]:"instruction requires an uninitialized account",[IU]:"instruction tries to borrow reference for an account which is already borrowed",[TU]:"instruction left account with an outstanding borrowed reference",[AU]:"program other than the account's owner changed the size of the account data",[lU]:"account data too small for instruction",[RU]:"instruction expected an executable account",[JU]:"An account does not have enough lamports to be rent-exempt",[XU]:"Program arithmetic overflowed",[YU]:"Failed to serialize or deserialize account data: $encodedData",[i9]:"Builtin programs must consume compute units",[LU]:"Cross-program invocation call depth too deep",[VU]:"Computational budget exceeded",[OU]:"custom program error: #$code",[bU]:"instruction contains duplicate accounts",[CU]:"instruction modifications of multiply-passed account differ",[kU]:"executable accounts must be rent exempt",[PU]:"instruction changed executable accounts data",[MU]:"instruction changed the balance of an executable account",[_U]:"instruction changed executable bit of an account",[wU]:"instruction modified data of an account it does not own",[yU]:"instruction spent from the balance of an account it does not own",[sU]:"generic instruction error",[e9]:"Provided owner is not allowed",[WU]:"Account is immutable",[GU]:"Incorrect authority provided",[dU]:"incorrect program id for instruction",[uU]:"insufficient funds for instruction",[cU]:"invalid account data for instruction",[ZU]:"Invalid account owner",[oU]:"invalid program argument",[NU]:"program returned invalid error code",[aU]:"invalid instruction data",[KU]:"Failed to reallocate account data",[FU]:"Provided seeds do not result in a valid address",[t9]:"Accounts data allocations exceeded the maximum allowed per transaction",[n9]:"Max accounts exceeded",[r9]:"Max instruction trace length exceeded",[$U]:"Length of the seed is too long for address generation",[BU]:"An account required by the instruction is missing",[fU]:"missing required signature for instruction",[gU]:"instruction illegally modified the program id of an account",[xU]:"insufficient account keys for instruction",[jU]:"Cross-program invocation with unauthorized signer or writable account",[HU]:"Failed to create program execution environment",[qU]:"Program failed to compile",[zU]:"Program failed to complete",[EU]:"instruction modified data of a read-only account",[vU]:"instruction changed the balance of a read-only account",[UU]:"Cross-program invocation reentrancy not allowed for this instruction",[SU]:"instruction modified rent epoch of an account",[mU]:"sum of account balances before and after instruction do not match",[pU]:"instruction requires an initialized account",[iU]:"",[DU]:"Unsupported program id",[QU]:"Unsupported sysvar",[tU]:"The instruction does not have any accounts.",[nU]:"The instruction does not have any data.",[rU]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[ZL]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[GL]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Y7]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Z7]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[G7]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[W7]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[J7]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[iB]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[sB]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[aB]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[oB]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[rB]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[fB]:"$__serverMessage",[SB]:"$__serverMessage",[EB]:"$__serverMessage",[uB]:"$__serverMessage",[pB]:"$__serverMessage",[mB]:"$__serverMessage",[cB]:"Minimum context slot has not been reached",[vB]:"Node is unhealthy; behind by $numSlotsBehind slots",[gB]:"No snapshot",[_B]:"Transaction simulation failed",[yB]:"$__serverMessage",[hB]:"Transaction history is not available from this node",[wB]:"$__serverMessage",[dB]:"Transaction signature length mismatch",[bB]:"Transaction signature verification failure",[lB]:"$__serverMessage",[JB]:"Key pair bytes must be of length 64, got $byteLength.",[ZB]:"Expected private key bytes with length 32. Actual length: $actualLength.",[XB]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[eU]:"The provided private key does not match the provided public key.",[QB]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[XL]:"Lamports value must be in the range [0, 2e64-1]",[QL]:"`$value` cannot be parsed as a `BigInt`",[nB]:"$message",[eB]:"`$value` cannot be parsed as a `Number`",[YL]:"No nonce account could be found at address `$nonceAccountAddress`",[V7]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[H7]:"WebSocket was closed before payload could be added to the send buffer",[z7]:"WebSocket connection closed",[q7]:"WebSocket failed to connect",[j7]:"Failed to obtain a subscription id from the server",[K7]:"Could not find an API plan for RPC method: `$method`",[U7]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[F7]:"HTTP error ($statusCode): $message",[$7]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[s9]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[o9]:"The provided value does not implement the `KeyPairSigner` interface",[c9]:"The provided value does not implement the `MessageModifyingSigner` interface",[l9]:"The provided value does not implement the `MessagePartialSigner` interface",[a9]:"The provided value does not implement any of the `MessageSigner` interfaces",[d9]:"The provided value does not implement the `TransactionModifyingSigner` interface",[f9]:"The provided value does not implement the `TransactionPartialSigner` interface",[h9]:"The provided value does not implement the `TransactionSendingSigner` interface",[u9]:"The provided value does not implement any of the `TransactionSigner` interfaces",[p9]:"More than one `TransactionSendingSigner` was identified.",[m9]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[g9]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[GB]:"Cannot export a non-extractable key.",[VB]:"No digest implementation could be found.",[KB]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[jB]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
555
|
+
|
|
556
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
557
|
+
|
|
558
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[HB]:"No signature verification implementation could be found.",[zB]:"No key generation implementation could be found.",[qB]:"No signing implementation could be found.",[WB]:"No key export implementation could be found.",[tB]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[e7]:"Transaction processing left an account with an outstanding borrowed reference",[$9]:"Account in use",[F9]:"Account loaded twice",[K9]:"Attempt to debit an account but found no record of a prior credit.",[a7]:"Transaction loads an address table account that doesn't exist",[z9]:"This transaction has already been processed",[q9]:"Blockhash not found",[W9]:"Loader call chain is too deep",[Q9]:"Transactions are currently disabled due to cluster maintenance",[p7]:"Transaction contains a duplicate instruction ($index) that is not allowed",[j9]:"Insufficient funds for fee",[m7]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[H9]:"This account may not be used to pay transaction fees",[Y9]:"Transaction contains an invalid account reference",[l7]:"Transaction loads an address table account with invalid data",[u7]:"Transaction address table lookup uses an invalid index",[c7]:"Transaction loads an address table account with an invalid owner",[y7]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Z9]:"This program may not be used for executing instructions",[d7]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[r7]:"Transaction loads a writable account that cannot be written",[g7]:"Transaction exceeded max loaded accounts data size cap",[G9]:"Transaction requires a fee but has no signature present",[V9]:"Attempt to load a program that does not exist",[v7]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[w7]:"ResanitizationNeeded",[X9]:"Transaction failed to sanitize accounts offsets correctly",[J9]:"Transaction did not pass signature verification",[o7]:"Transaction locked too many accounts",[E7]:"Sum of account balances before and after transaction do not match",[U9]:"The transaction failed with the error `$errorName`",[n7]:"Transaction version is unsupported",[s7]:"Transaction would exceed account data limit within the block",[h7]:"Transaction would exceed total account data limit",[i7]:"Transaction would exceed max account limit within the block",[t7]:"Transaction would exceed max Block Cost Limit",[f7]:"Transaction would exceed max Vote Cost Limit",[P9]:"Attempted to sign a transaction with an address that is not a signer for it",[I9]:"Transaction is missing an address at index: $index.",[M9]:"Transaction has no expected signers therefore it cannot be encoded",[B9]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[v9]:"Transaction does not have a blockhash lifetime",[E9]:"Transaction is not a durable nonce transaction",[_9]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[S9]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[A9]:"No fee payer set in CompiledTransaction",[x9]:"Could not find program address at index $index",[D9]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[L9]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[T9]:"Transaction is missing a fee payer.",[C9]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[N9]:"Transaction first instruction is not advance nonce account instruction.",[O9]:"Transaction with no instructions cannot be durable nonce transaction.",[y9]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[w9]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[k9]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[R9]:"Transaction is missing signatures for addresses: $addresses.",[b9]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},is="i",Pi="t";function t$(t,e={}){const n=e$[t];if(n.length===0)return"";let r;function i(o){if(r[Pi]===2){const a=n.slice(r[is]+1,o);s.push(a in e?`${e[a]}`:`$${a}`)}else r[Pi]===1&&s.push(n.slice(r[is],o))}const s=[];return n.split("").forEach((o,a)=>{if(a===0){r={[is]:0,[Pi]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[Pi]){case 0:c={[is]:a,[Pi]:1};break;case 1:o==="\\"?c={[is]:a,[Pi]:0}:o==="$"&&(c={[is]:a,[Pi]:2});break;case 2:o==="\\"?c={[is]:a,[Pi]:0}:o==="$"?c={[is]:a,[Pi]:2}:o.match(/\w/)||(c={[is]:a,[Pi]:1});break}c&&(r!==c&&i(a),r=c)}),i(),s.join("")}function n$(t,e={}){if(process.env.NODE_ENV!=="production")return t$(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${Q7(e)}'`),`${n}\``}}var Wa=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:s,...o}=e;s&&(r={cause:s}),Object.keys(o).length>0&&(n=o)}const i=n$(t,n);super(i,r),this.context={__code:t,...n},this.name="SolanaError"}};function r$(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function i$(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(r$(e,t));return t.write(e,n,0),n}})}function s$(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function wa(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function o$(t,e){if(wa(t)!==wa(e))throw new Wa(KR);if(wa(t)&&wa(e)&&t.fixedSize!==e.fixedSize)throw new Wa(VR,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!wa(t)&&!wa(e)&&t.maxSize!==e.maxSize)throw new Wa(jR,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function a$(t,e,n=0){if(e.length-n<=0)throw new Wa($R,{codecDescription:t})}function c$(t,e,n,r=0){const i=n.length-r;if(i<e)throw new Wa(FR,{bytesLength:i,codecDescription:t,expected:e})}function l$(t,e,n,r){if(r<e||r>n)throw new Wa(HR,{codecDescription:t,max:n,min:e,value:r})}function qR(t){return t?.endian!==1}function u$(t){return i$({fixedSize:t.size,write(e,n,r){t.range&&l$(t.name,t.range[0],t.range[1],e);const i=new ArrayBuffer(t.size);return t.set(new DataView(i),e,qR(t.config)),n.set(new Uint8Array(i),r),r+t.size}})}function d$(t){return s$({fixedSize:t.size,read(e,n=0){a$(t.name,e,n),c$(t.name,t.size,e,n);const r=new DataView(f$(e,n,t.size));return[t.get(r,qR(t.config)),n+t.size]}})}function f$(t,e,n){const r=t.byteOffset+(e??0),i=n??t.byteLength;return t.buffer.slice(r,r+i)}var h$=(t={})=>u$({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),p$=(t={})=>d$({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),m$=(t={})=>o$(h$(t),p$(t));const g$="6.16.0";function nb(t,e,n){for(let r in e){let i=e[r];Object.defineProperty(t,r,{enumerable:!0,value:i,writable:!1})}}function Ba(t,e){if(t==null)return"null";if(e==null&&(e=new Set),typeof t=="object"){if(e.has(t))return"[Circular]";e.add(t)}if(Array.isArray(t))return"[ "+t.map(n=>Ba(n,e)).join(", ")+" ]";if(t instanceof Uint8Array){const n="0123456789abcdef";let r="0x";for(let i=0;i<t.length;i++)r+=n[t[i]>>4],r+=n[t[i]&15];return r}if(typeof t=="object"&&typeof t.toJSON=="function")return Ba(t.toJSON(),e);switch(typeof t){case"boolean":case"number":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const n=Object.keys(t);return n.sort(),"{ "+n.map(r=>`${Ba(r,e)}: ${Ba(t[r],e)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function y$(t,e,n){let r=t;{const s=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Ba(n)}`);for(const o in n){if(o==="shortMessage")continue;const a=n[o];s.push(o+"="+Ba(a))}}s.push(`code=${e}`),s.push(`version=${g$}`),s.length&&(t+=" ("+s.join(", ")+")")}let i;switch(e){case"INVALID_ARGUMENT":i=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":i=new RangeError(t);break;default:i=new Error(t)}return nb(i,{code:e}),n&&Object.assign(i,n),i.shortMessage==null&&nb(i,{shortMessage:r}),i}function Sr(t,e,n,r){if(!t)throw y$(e,n,r)}function Ye(t,e,n,r){Sr(t,e,"INVALID_ARGUMENT",{argument:n,value:r})}["NFD","NFC","NFKD","NFKC"].reduce((t,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");t.push(e)}catch{}return t},[]);function w$(t,e,n){if(t!==e){let r=n,i="new";r+=".",i+=" "+n,Sr(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:i})}}function WR(t,e,n){if(t instanceof Uint8Array)return n?new Uint8Array(t):t;if(typeof t=="string"&&t.length%2===0&&t.match(/^0x[0-9a-f]*$/i)){const r=new Uint8Array((t.length-2)/2);let i=2;for(let s=0;s<r.length;s++)r[s]=parseInt(t.substring(i,i+2),16),i+=2;return r}Ye(!1,"invalid BytesLike value",e||"value",t)}function an(t,e){return WR(t,e,!1)}function Vc(t,e){return WR(t,e,!0)}function vo(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&t.length!==2+2*e||e===!0&&t.length%2!==0)}function v$(t){return vo(t,!0)||t instanceof Uint8Array}const rb="0123456789abcdef";function kt(t){const e=an(t);let n="0x";for(let r=0;r<e.length;r++){const i=e[r];n+=rb[(i&240)>>4]+rb[i&15]}return n}function Yi(t){return"0x"+t.map(e=>kt(e).substring(2)).join("")}function dl(t){return vo(t,!0)?(t.length-2)/2:an(t).length}function E$(t,e,n){const r=an(t);Sr(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),i.set(r,e-r.length),kt(i)}function ea(t,e){return E$(t,e)}const fy=BigInt(0);BigInt(1);const Ua=9007199254740991;function Xn(t,e){switch(typeof t){case"bigint":return t;case"number":return Ye(Number.isInteger(t),"underflow",e||"value",t),Ye(t>=-Ua&&t<=Ua,"overflow",e||"value",t),BigInt(t);case"string":try{if(t==="")throw new Error("empty string");return t[0]==="-"&&t[1]!=="-"?-BigInt(t.substring(1)):BigInt(t)}catch(n){Ye(!1,`invalid BigNumberish string: ${n.message}`,e||"value",t)}}Ye(!1,"invalid BigNumberish value",e||"value",t)}function GR(t,e){const n=Xn(t,e);return Sr(n>=fy,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),n}function uo(t,e){switch(typeof t){case"bigint":return Ye(t>=-Ua&&t<=Ua,"overflow",e||"value",t),Number(t);case"number":return Ye(Number.isInteger(t),"underflow",e||"value",t),Ye(t>=-Ua&&t<=Ua,"overflow",e||"value",t),t;case"string":try{if(t==="")throw new Error("empty string");return uo(BigInt(t),e)}catch(n){Ye(!1,`invalid numeric string: ${n.message}`,e||"value",t)}}Ye(!1,"invalid numeric value",e||"value",t)}function ib(t,e){const n=GR(t,"value");let r=n.toString(16);{const i=uo(e,"width");if(i===0&&n===fy)return"0x";for(Sr(i*2>=r.length,`value exceeds width (${i} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<i*2;)r="0"+r}return"0x"+r}function er(t,e){const n=GR(t,"value");if(n===fy)return new Uint8Array(0);let r=n.toString(16);r.length%2&&(r="0"+r);const i=new Uint8Array(r.length/2);for(let s=0;s<i.length;s++){const o=s*2;i[s]=parseInt(r.substring(o,o+2),16)}return i}function b$(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function sb(t,e,n){let r=0;for(let i=0;i<n;i++)r=r*256+t[e+i];return r}function ob(t,e,n,r){const i=[];for(;n<e+1+r;){const s=YR(t,n);i.push(s.result),n+=s.consumed,Sr(n<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:t,length:r,offset:e})}return{consumed:1+r,result:i}}function YR(t,e){Sr(t.length!==0,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const n=r=>{Sr(r<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:r})};if(t[e]>=248){const r=t[e]-247;n(e+1+r);const i=sb(t,e+1,r);return n(e+1+r+i),ob(t,e,e+1+r,r+i)}else if(t[e]>=192){const r=t[e]-192;return n(e+1+r),ob(t,e,e+1,r)}else if(t[e]>=184){const r=t[e]-183;n(e+1+r);const i=sb(t,e+1,r);n(e+1+r+i);const s=kt(t.slice(e+1+r,e+1+r+i));return{consumed:1+r+i,result:s}}else if(t[e]>=128){const r=t[e]-128;n(e+1+r);const i=kt(t.slice(e+1,e+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:b$(t[e])}}function Yl(t){const e=an(t,"data"),n=YR(e,0);return Ye(n.consumed===e.length,"unexpected junk after rlp payload","data",t),n.result}function ab(t){const e=[];for(;t;)e.unshift(t&255),t>>=8;return e}function JR(t){if(Array.isArray(t)){let r=[];if(t.forEach(function(s){r=r.concat(JR(s))}),r.length<=55)return r.unshift(192+r.length),r;const i=ab(r.length);return i.unshift(247+i.length),i.concat(r)}const e=Array.prototype.slice.call(an(t,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const n=ab(e.length);return n.unshift(183+n.length),n.concat(e)}const cb="0123456789abcdef";function fo(t){let e="0x";for(const n of JR(t))e+=cb[n>>4],e+=cb[n&15];return e}function uf(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function hy(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function _$(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");uf(t.outputLen),uf(t.blockLen)}function ic(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ZR(t,e){hy(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const kp=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const XR=t=>t instanceof Uint8Array,S$=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Dp=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Mi=(t,e)=>t<<32-e|t>>>e,x$=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!x$)throw new Error("Non little-endian hardware is not supported");function A$(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Qf(t){if(typeof t=="string"&&(t=A$(t)),!XR(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function R$(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!XR(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let py=class{clone(){return this._cloneInto()}};function my(t){const e=r=>t().update(Qf(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function I$(t=32){if(kp&&typeof kp.getRandomValues=="function")return kp.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}let QR=class extends py{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,_$(e);const r=Qf(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return ic(this),this.iHash.update(e),this}digestInto(e){ic(this),hy(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const eI=(t,e,n)=>new QR(t,e).update(n).digest();eI.create=(t,e)=>new QR(t,e);function T$(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}class tI extends py{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Dp(this.buffer)}update(e){ic(this);const{view:n,buffer:r,blockLen:i}=this;e=Qf(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Dp(e);for(;i<=s-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ic(this),ZR(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;n[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(r,0),o=0);for(let d=o;d<i;d++)n[d]=0;T$(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Dp(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%n&&e.buffer.set(r),e}}const C$=(t,e,n)=>t&e^~t&n,O$=(t,e,n)=>t&e^t&n^e&n,N$=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]),Ds=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ls=new Uint32Array(64);let P$=class extends tI{constructor(){super(64,32,8,!1),this.A=Ds[0]|0,this.B=Ds[1]|0,this.C=Ds[2]|0,this.D=Ds[3]|0,this.E=Ds[4]|0,this.F=Ds[5]|0,this.G=Ds[6]|0,this.H=Ds[7]|0}get(){const{A:e,B:n,C:r,D:i,E:s,F:o,G:a,H:c}=this;return[e,n,r,i,s,o,a,c]}set(e,n,r,i,s,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)Ls[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const f=Ls[d-15],g=Ls[d-2],v=Mi(f,7)^Mi(f,18)^f>>>3,w=Mi(g,17)^Mi(g,19)^g>>>10;Ls[d]=w+Ls[d-7]+v+Ls[d-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const f=Mi(a,6)^Mi(a,11)^Mi(a,25),g=u+f+C$(a,c,l)+N$[d]+Ls[d]|0,w=(Mi(r,2)^Mi(r,13)^Mi(r,22))+O$(r,i,s)|0;u=l,l=c,c=a,a=o+g|0,o=s,s=i,i=r,r=g+w|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,s,o,a,c,l,u)}roundClean(){Ls.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const nI=my(()=>new P$),Vu=BigInt(2**32-1),Am=BigInt(32);function rI(t,e=!1){return e?{h:Number(t&Vu),l:Number(t>>Am&Vu)}:{h:Number(t>>Am&Vu)|0,l:Number(t&Vu)|0}}function iI(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=rI(t[i],e);[n[i],r[i]]=[s,o]}return[n,r]}const M$=(t,e)=>BigInt(t>>>0)<<Am|BigInt(e>>>0),k$=(t,e,n)=>t>>>n,D$=(t,e,n)=>t<<32-n|e>>>n,L$=(t,e,n)=>t>>>n|e<<32-n,B$=(t,e,n)=>t<<32-n|e>>>n,U$=(t,e,n)=>t<<64-n|e>>>n-32,$$=(t,e,n)=>t>>>n-32|e<<64-n,F$=(t,e)=>e,K$=(t,e)=>t,sI=(t,e,n)=>t<<n|e>>>32-n,oI=(t,e,n)=>e<<n|t>>>32-n,aI=(t,e,n)=>e<<n-32|t>>>64-n,cI=(t,e,n)=>t<<n-32|e>>>64-n;function V$(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const j$=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),H$=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,z$=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),q$=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,W$=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),G$=(t,e,n,r,i,s)=>e+n+r+i+s+(t/2**32|0)|0,Pt={fromBig:rI,split:iI,toBig:M$,shrSH:k$,shrSL:D$,rotrSH:L$,rotrSL:B$,rotrBH:U$,rotrBL:$$,rotr32H:F$,rotr32L:K$,rotlSH:sI,rotlSL:oI,rotlBH:aI,rotlBL:cI,add:V$,add3L:j$,add3H:H$,add4L:z$,add4H:q$,add5H:G$,add5L:W$},[Y$,J$]=Pt.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(t=>BigInt(t))),Bs=new Uint32Array(80),Us=new Uint32Array(80);let Z$=class extends tI{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:e,Al:n,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:d,Fl:f,Gh:g,Gl:v,Hh:w,Hl:b}=this;return[e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b]}set(e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=g|0,this.Gl=v|0,this.Hh=w|0,this.Hl=b|0}process(e,n){for(let S=0;S<16;S++,n+=4)Bs[S]=e.getUint32(n),Us[S]=e.getUint32(n+=4);for(let S=16;S<80;S++){const F=Bs[S-15]|0,D=Us[S-15]|0,z=Pt.rotrSH(F,D,1)^Pt.rotrSH(F,D,8)^Pt.shrSH(F,D,7),X=Pt.rotrSL(F,D,1)^Pt.rotrSL(F,D,8)^Pt.shrSL(F,D,7),Y=Bs[S-2]|0,U=Us[S-2]|0,B=Pt.rotrSH(Y,U,19)^Pt.rotrBH(Y,U,61)^Pt.shrSH(Y,U,6),H=Pt.rotrSL(Y,U,19)^Pt.rotrBL(Y,U,61)^Pt.shrSL(Y,U,6),V=Pt.add4L(X,H,Us[S-7],Us[S-16]),T=Pt.add4H(V,z,B,Bs[S-7],Bs[S-16]);Bs[S]=T|0,Us[S]=V|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:f,Fh:g,Fl:v,Gh:w,Gl:b,Hh:E,Hl:M}=this;for(let S=0;S<80;S++){const F=Pt.rotrSH(d,f,14)^Pt.rotrSH(d,f,18)^Pt.rotrBH(d,f,41),D=Pt.rotrSL(d,f,14)^Pt.rotrSL(d,f,18)^Pt.rotrBL(d,f,41),z=d&g^~d&w,X=f&v^~f&b,Y=Pt.add5L(M,D,X,J$[S],Us[S]),U=Pt.add5H(Y,E,F,z,Y$[S],Bs[S]),B=Y|0,H=Pt.rotrSH(r,i,28)^Pt.rotrBH(r,i,34)^Pt.rotrBH(r,i,39),V=Pt.rotrSL(r,i,28)^Pt.rotrBL(r,i,34)^Pt.rotrBL(r,i,39),T=r&s^r&a^s&a,p=i&o^i&c^o&c;E=w|0,M=b|0,w=g|0,b=v|0,g=d|0,v=f|0,{h:d,l:f}=Pt.add(l|0,u|0,U|0,B|0),l=a|0,u=c|0,a=s|0,c=o|0,s=r|0,o=i|0;const y=Pt.add3L(B,V,p);r=Pt.add3H(y,U,H,T),i=y|0}({h:r,l:i}=Pt.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Pt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=Pt.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Pt.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=Pt.add(this.Eh|0,this.El|0,d|0,f|0),{h:g,l:v}=Pt.add(this.Fh|0,this.Fl|0,g|0,v|0),{h:w,l:b}=Pt.add(this.Gh|0,this.Gl|0,w|0,b|0),{h:E,l:M}=Pt.add(this.Hh|0,this.Hl|0,E|0,M|0),this.set(r,i,s,o,a,c,l,u,d,f,g,v,w,b,E,M)}roundClean(){Bs.fill(0),Us.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 X$=my(()=>new Z$);function Q$(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const lb=Q$();lb.crypto||lb.msCrypto;function eF(t){switch(t){case"sha256":return nI.create();case"sha512":return X$.create()}Ye(!1,"invalid hashing algorithm name","algorithm",t)}const[lI,uI,dI]=[[],[],[]],tF=BigInt(0),jc=BigInt(1),nF=BigInt(2),rF=BigInt(7),iF=BigInt(256),sF=BigInt(113);for(let t=0,e=jc,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],lI.push(2*(5*r+n)),uI.push((t+1)*(t+2)/2%64);let i=tF;for(let s=0;s<7;s++)e=(e<<jc^(e>>rF)*sF)%iF,e&nF&&(i^=jc<<(jc<<BigInt(s))-jc);dI.push(i)}const[oF,aF]=iI(dI,!0),ub=(t,e,n)=>n>32?aI(t,e,n):sI(t,e,n),db=(t,e,n)=>n>32?cI(t,e,n):oI(t,e,n);function cF(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=n[c],u=n[c+1],d=ub(l,u,1)^n[a],f=db(l,u,1)^n[a+1];for(let g=0;g<50;g+=10)t[o+g]^=d,t[o+g+1]^=f}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=uI[o],c=ub(i,s,a),l=db(i,s,a),u=lI[o];i=t[u],s=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=oF[r],t[1]^=aF[r]}n.fill(0)}class gy extends py{constructor(e,n,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,uf(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=S$(this.state)}keccak(){cF(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ic(this);const{blockLen:n,state:r}=this;e=Qf(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=e[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:i}=this;e[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ic(this,!1),hy(e),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=e.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);e.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return uf(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ZR(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new gy(n,r,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const lF=(t,e,n)=>my(()=>new gy(e,t,n)),uF=lF(1,136,256/8);let fI=!1;const hI=function(t){return uF(t)};let pI=hI;function Eo(t){const e=an(t,"data");return kt(pI(e))}Eo._=hI;Eo.lock=function(){fI=!0};Eo.register=function(t){if(fI)throw new TypeError("keccak256 is locked");pI=t};Object.freeze(Eo);const mI=function(t){return eF("sha256").update(t).digest()};let gI=mI,yI=!1;function xc(t){const e=an(t,"data");return kt(gI(e))}xc._=mI;xc.lock=function(){yI=!0};xc.register=function(t){if(yI)throw new Error("sha256 is locked");gI=t};Object.freeze(xc);Object.freeze(xc);const wI=BigInt(0),eh=BigInt(1),dF=BigInt(2),th=t=>t instanceof Uint8Array,fF=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function sc(t){if(!th(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=fF[t[n]];return e}function vI(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function yy(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function oc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,s=t.slice(i,i+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[r]=o}return n}function Wo(t){return yy(sc(t))}function wy(t){if(!th(t))throw new Error("Uint8Array expected");return yy(sc(Uint8Array.from(t).reverse()))}function ac(t,e){return oc(t.toString(16).padStart(e*2,"0"))}function vy(t,e){return ac(t,e).reverse()}function hF(t){return oc(vI(t))}function vi(t,e,n){let r;if(typeof e=="string")try{r=oc(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(th(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r}function Ml(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!th(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function pF(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function mF(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function gF(t){let e;for(e=0;t>wI;t>>=eh,e+=1);return e}function yF(t,e){return t>>BigInt(e)&eh}const wF=(t,e,n)=>t|(n?eh:wI)<<BigInt(e),Ey=t=>(dF<<BigInt(t-1))-eh,Lp=t=>new Uint8Array(t),fb=t=>Uint8Array.from(t);function EI(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Lp(t),i=Lp(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...d)=>n(i,r,...d),c=(d=Lp())=>{i=a(fb([0]),d),r=a(),d.length!==0&&(i=a(fb([1]),d),r=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const f=[];for(;d<e;){r=a();const g=r.slice();f.push(g),d+=r.length}return Ml(...f)};return(d,f)=>{o(),c(d);let g;for(;!(g=f(l()));)c();return o(),g}}const vF={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Jl(t,e,n={}){const r=(i,s,o)=>{const a=vF[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return t}const EF=Object.freeze(Object.defineProperty({__proto__:null,bitGet:yF,bitLen:gF,bitMask:Ey,bitSet:wF,bytesToHex:sc,bytesToNumberBE:Wo,bytesToNumberLE:wy,concatBytes:Ml,createHmacDrbg:EI,ensureBytes:vi,equalBytes:pF,hexToBytes:oc,hexToNumber:yy,numberToBytesBE:ac,numberToBytesLE:vy,numberToHexUnpadded:vI,numberToVarBytesBE:hF,utf8ToBytes:mF,validateObject:Jl},Symbol.toStringTag,{value:"Module"}));const Wn=BigInt(0),Nn=BigInt(1),Co=BigInt(2),bF=BigInt(3),Rm=BigInt(4),hb=BigInt(5),pb=BigInt(8);BigInt(9);BigInt(16);function Dr(t,e){const n=t%e;return n>=Wn?n:e+n}function _F(t,e,n){if(n<=Wn||e<Wn)throw new Error("Expected power/modulo > 0");if(n===Nn)return Wn;let r=Nn;for(;e>Wn;)e&Nn&&(r=r*t%n),t=t*t%n,e>>=Nn;return r}function ni(t,e,n){let r=t;for(;e-- >Wn;)r*=r,r%=n;return r}function Im(t,e){if(t===Wn||e<=Wn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Dr(t,e),r=e,i=Wn,s=Nn;for(;n!==Wn;){const a=r/n,c=r%n,l=i-s*a;r=n,n=c,i=s,s=l}if(r!==Nn)throw new Error("invert: does not exist");return Dr(i,e)}function SF(t){const e=(t-Nn)/Co;let n,r,i;for(n=t-Nn,r=0;n%Co===Wn;n/=Co,r++);for(i=Co;i<t&&_F(i,e,t)!==t-Nn;i++);if(r===1){const o=(t+Nn)/Rm;return function(c,l){const u=c.pow(l,o);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}const s=(n+Nn)/Co;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,u=a.pow(a.mul(a.ONE,i),n),d=a.pow(c,s),f=a.pow(c,n);for(;!a.eql(f,a.ONE);){if(a.eql(f,a.ZERO))return a.ZERO;let g=1;for(let w=a.sqr(f);g<l&&!a.eql(w,a.ONE);g++)w=a.sqr(w);const v=a.pow(u,Nn<<BigInt(l-g-1));u=a.sqr(v),d=a.mul(d,v),f=a.mul(f,u),l=g}return d}}function xF(t){if(t%Rm===bF){const e=(t+Nn)/Rm;return function(r,i){const s=r.pow(i,e);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%pb===hb){const e=(t-hb)/pb;return function(r,i){const s=r.mul(i,Co),o=r.pow(s,e),a=r.mul(i,o),c=r.mul(r.mul(a,Co),o),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),i))throw new Error("Cannot find square root");return l}}return SF(t)}const AF=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function RF(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=AF.reduce((r,i)=>(r[i]="function",r),e);return Jl(t,n)}function IF(t,e,n){if(n<Wn)throw new Error("Expected power > 0");if(n===Wn)return t.ONE;if(n===Nn)return e;let r=t.ONE,i=e;for(;n>Wn;)n&Nn&&(r=t.mul(r,i)),i=t.sqr(i),n>>=Nn;return r}function TF(t,e){const n=new Array(e.length),r=e.reduce((s,o,a)=>t.is0(o)?s:(n[a]=s,t.mul(s,o)),t.ONE),i=t.inv(r);return e.reduceRight((s,o,a)=>t.is0(o)?s:(n[a]=t.mul(s,n[a]),t.mul(s,o)),i),n}function bI(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function CF(t,e,n=!1,r={}){if(t<=Wn)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=bI(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=xF(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ey(i),ZERO:Wn,ONE:Nn,create:c=>Dr(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Wn<=c&&c<t},is0:c=>c===Wn,isOdd:c=>(c&Nn)===Nn,neg:c=>Dr(-c,t),eql:(c,l)=>c===l,sqr:c=>Dr(c*c,t),add:(c,l)=>Dr(c+l,t),sub:(c,l)=>Dr(c-l,t),mul:(c,l)=>Dr(c*l,t),pow:(c,l)=>IF(a,c,l),div:(c,l)=>Dr(c*Im(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Im(c,t),sqrt:r.sqrt||(c=>o(a,c)),invertBatch:c=>TF(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>n?vy(c,s):ac(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return n?wy(c):Wo(c)}});return Object.freeze(a)}function _I(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function SI(t){const e=_I(t);return e+Math.ceil(e/2)}function OF(t,e,n=!1){const r=t.length,i=_I(e),s=SI(e);if(r<16||r<s||r>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=n?Wo(t):wy(t),a=Dr(o,e-Nn)+Nn;return n?vy(a,i):ac(a,i)}const NF=BigInt(0),Bp=BigInt(1);function PF(t,e){const n=(i,s)=>{const o=s.negate();return i?o:s},r=i=>{const s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:n,unsafeLadder(i,s){let o=t.ZERO,a=i;for(;s>NF;)s&Bp&&(o=o.add(a)),a=a.double(),s>>=Bp;return o},precomputeWindow(i,s){const{windows:o,windowSize:a}=r(s),c=[];let l=i,u=l;for(let d=0;d<o;d++){u=l,c.push(u);for(let f=1;f<a;f++)u=u.add(l),c.push(u);l=u.double()}return c},wNAF(i,s,o){const{windows:a,windowSize:c}=r(i);let l=t.ZERO,u=t.BASE;const d=BigInt(2**i-1),f=2**i,g=BigInt(i);for(let v=0;v<a;v++){const w=v*c;let b=Number(o&d);o>>=g,b>c&&(b-=f,o+=Bp);const E=w,M=w+Math.abs(b)-1,S=v%2!==0,F=b<0;b===0?u=u.add(n(S,s[E])):l=l.add(n(F,s[M]))}return{p:l,f:u}},wNAFCached(i,s,o,a){const c=i._WINDOW_SIZE||1;let l=s.get(i);return l||(l=this.precomputeWindow(i,c),c!==1&&s.set(i,a(l))),this.wNAF(c,l,o)}}}function xI(t){return RF(t.Fp),Jl(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bI(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function MF(t){const e=xI(t);Jl(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:kF,hexToBytes:DF}=EF,$o={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=$o;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:kF(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=$o,n=typeof t=="string"?DF(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=$o._parseInt(n.subarray(2)),{d:o,l:a}=$o._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const u=l.toString(16);return u.length&1?`0${u}`:u},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),c=n(o);return`30${n(o+s+4)}02${c}${i}02${a}${r}`}},ps=BigInt(0),li=BigInt(1);BigInt(2);const mb=BigInt(3);BigInt(4);function LF(t){const e=MF(t),{Fp:n}=e,r=e.toBytes||((v,w,b)=>{const E=w.toAffine();return Ml(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),i=e.fromBytes||(v=>{const w=v.subarray(1),b=n.fromBytes(w.subarray(0,n.BYTES)),E=n.fromBytes(w.subarray(n.BYTES,2*n.BYTES));return{x:b,y:E}});function s(v){const{a:w,b}=e,E=n.sqr(v),M=n.mul(E,v);return n.add(n.add(M,n.mul(v,w)),b)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(v){return typeof v=="bigint"&&ps<v&&v<e.n}function a(v){if(!o(v))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(v){const{allowedPrivateKeyLengths:w,nByteLength:b,wrapPrivateKey:E,n:M}=e;if(w&&typeof v!="bigint"){if(v instanceof Uint8Array&&(v=sc(v)),typeof v!="string"||!w.includes(v.length))throw new Error("Invalid key");v=v.padStart(b*2,"0")}let S;try{S=typeof v=="bigint"?v:Wo(vi("private key",v,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof v}`)}return E&&(S=Dr(S,M)),a(S),S}const l=new Map;function u(v){if(!(v instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(w,b,E){if(this.px=w,this.py=b,this.pz=E,w==null||!n.isValid(w))throw new Error("x required");if(b==null||!n.isValid(b))throw new Error("y required");if(E==null||!n.isValid(E))throw new Error("z required")}static fromAffine(w){const{x:b,y:E}=w||{};if(!w||!n.isValid(b)||!n.isValid(E))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");const M=S=>n.eql(S,n.ZERO);return M(b)&&M(E)?d.ZERO:new d(b,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const b=n.invertBatch(w.map(E=>E.pz));return w.map((E,M)=>E.toAffine(b[M])).map(d.fromAffine)}static fromHex(w){const b=d.fromAffine(i(vi("pointHex",w)));return b.assertValidity(),b}static fromPrivateKey(w){return d.BASE.multiply(c(w))}_setWindowSize(w){this._WINDOW_SIZE=w,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:w,y:b}=this.toAffine();if(!n.isValid(w)||!n.isValid(b))throw new Error("bad point: x or y not FE");const E=n.sqr(b),M=s(w);if(!n.eql(E,M))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:w}=this.toAffine();if(n.isOdd)return!n.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){u(w);const{px:b,py:E,pz:M}=this,{px:S,py:F,pz:D}=w,z=n.eql(n.mul(b,D),n.mul(S,M)),X=n.eql(n.mul(E,D),n.mul(F,M));return z&&X}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:w,b}=e,E=n.mul(b,mb),{px:M,py:S,pz:F}=this;let D=n.ZERO,z=n.ZERO,X=n.ZERO,Y=n.mul(M,M),U=n.mul(S,S),B=n.mul(F,F),H=n.mul(M,S);return H=n.add(H,H),X=n.mul(M,F),X=n.add(X,X),D=n.mul(w,X),z=n.mul(E,B),z=n.add(D,z),D=n.sub(U,z),z=n.add(U,z),z=n.mul(D,z),D=n.mul(H,D),X=n.mul(E,X),B=n.mul(w,B),H=n.sub(Y,B),H=n.mul(w,H),H=n.add(H,X),X=n.add(Y,Y),Y=n.add(X,Y),Y=n.add(Y,B),Y=n.mul(Y,H),z=n.add(z,Y),B=n.mul(S,F),B=n.add(B,B),Y=n.mul(B,H),D=n.sub(D,Y),X=n.mul(B,U),X=n.add(X,X),X=n.add(X,X),new d(D,z,X)}add(w){u(w);const{px:b,py:E,pz:M}=this,{px:S,py:F,pz:D}=w;let z=n.ZERO,X=n.ZERO,Y=n.ZERO;const U=e.a,B=n.mul(e.b,mb);let H=n.mul(b,S),V=n.mul(E,F),T=n.mul(M,D),p=n.add(b,E),y=n.add(S,F);p=n.mul(p,y),y=n.add(H,V),p=n.sub(p,y),y=n.add(b,M);let R=n.add(S,D);return y=n.mul(y,R),R=n.add(H,T),y=n.sub(y,R),R=n.add(E,M),z=n.add(F,D),R=n.mul(R,z),z=n.add(V,T),R=n.sub(R,z),Y=n.mul(U,y),z=n.mul(B,T),Y=n.add(z,Y),z=n.sub(V,Y),Y=n.add(V,Y),X=n.mul(z,Y),V=n.add(H,H),V=n.add(V,H),T=n.mul(U,T),y=n.mul(B,y),V=n.add(V,T),T=n.sub(H,T),T=n.mul(U,T),y=n.add(y,T),H=n.mul(V,y),X=n.add(X,H),H=n.mul(R,y),z=n.mul(p,z),z=n.sub(z,H),H=n.mul(p,V),Y=n.mul(R,Y),Y=n.add(Y,H),new d(z,X,Y)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return g.wNAFCached(this,l,w,b=>{const E=n.invertBatch(b.map(M=>M.pz));return b.map((M,S)=>M.toAffine(E[S])).map(d.fromAffine)})}multiplyUnsafe(w){const b=d.ZERO;if(w===ps)return b;if(a(w),w===li)return this;const{endo:E}=e;if(!E)return g.unsafeLadder(this,w);let{k1neg:M,k1:S,k2neg:F,k2:D}=E.splitScalar(w),z=b,X=b,Y=this;for(;S>ps||D>ps;)S&li&&(z=z.add(Y)),D&li&&(X=X.add(Y)),Y=Y.double(),S>>=li,D>>=li;return M&&(z=z.negate()),F&&(X=X.negate()),X=new d(n.mul(X.px,E.beta),X.py,X.pz),z.add(X)}multiply(w){a(w);let b=w,E,M;const{endo:S}=e;if(S){const{k1neg:F,k1:D,k2neg:z,k2:X}=S.splitScalar(b);let{p:Y,f:U}=this.wNAF(D),{p:B,f:H}=this.wNAF(X);Y=g.constTimeNegate(F,Y),B=g.constTimeNegate(z,B),B=new d(n.mul(B.px,S.beta),B.py,B.pz),E=Y.add(B),M=U.add(H)}else{const{p:F,f:D}=this.wNAF(b);E=F,M=D}return d.normalizeZ([E,M])[0]}multiplyAndAddUnsafe(w,b,E){const M=d.BASE,S=(D,z)=>z===ps||z===li||!D.equals(M)?D.multiplyUnsafe(z):D.multiply(z),F=S(this,b).add(S(w,E));return F.is0()?void 0:F}toAffine(w){const{px:b,py:E,pz:M}=this,S=this.is0();w==null&&(w=S?n.ONE:n.inv(M));const F=n.mul(b,w),D=n.mul(E,w),z=n.mul(M,w);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(z,n.ONE))throw new Error("invZ was invalid");return{x:F,y:D}}isTorsionFree(){const{h:w,isTorsionFree:b}=e;if(w===li)return!0;if(b)return b(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:b}=e;return w===li?this:b?b(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return this.assertValidity(),r(d,this,w)}toHex(w=!0){return sc(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=e.nBitLength,g=PF(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function BF(t){const e=xI(t);return Jl(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function UF(t){const e=BF(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(y){return ps<y&&y<n.ORDER}function a(y){return Dr(y,r)}function c(y){return Im(y,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=LF({...e,toBytes(y,R,P){const _=R.toAffine(),I=n.toBytes(_.x),N=Ml;return P?N(Uint8Array.from([R.hasEvenY()?2:3]),I):N(Uint8Array.from([4]),I,n.toBytes(_.y))},fromBytes(y){const R=y.length,P=y[0],_=y.subarray(1);if(R===i&&(P===2||P===3)){const I=Wo(_);if(!o(I))throw new Error("Point is not on curve");const N=d(I);let x=n.sqrt(N);const h=(x&li)===li;return(P&1)===1!==h&&(x=n.neg(x)),{x:I,y:x}}else if(R===s&&P===4){const I=n.fromBytes(_.subarray(0,n.BYTES)),N=n.fromBytes(_.subarray(n.BYTES,2*n.BYTES));return{x:I,y:N}}else throw new Error(`Point of length ${R} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),g=y=>sc(ac(y,e.nByteLength));function v(y){const R=r>>li;return y>R}function w(y){return v(y)?a(-y):y}const b=(y,R,P)=>Wo(y.slice(R,P));class E{constructor(R,P,_){this.r=R,this.s=P,this.recovery=_,this.assertValidity()}static fromCompact(R){const P=e.nByteLength;return R=vi("compactSignature",R,P*2),new E(b(R,0,P),b(R,P,2*P))}static fromDER(R){const{r:P,s:_}=$o.toSig(vi("DER",R));return new E(P,_)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new E(this.r,this.s,R)}recoverPublicKey(R){const{r:P,s:_,recovery:I}=this,N=X(vi("msgHash",R));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const x=I===2||I===3?P+e.n:P;if(x>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=(I&1)===0?"02":"03",m=l.fromHex(h+g(x)),A=c(x),C=a(-N*A),$=a(_*A),j=l.BASE.multiplyAndAddUnsafe(m,C,$);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return oc(this.toDERHex())}toDERHex(){return $o.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return oc(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const M={isValidPrivateKey(y){try{return u(y),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const y=SI(e.n);return OF(e.randomBytes(y),e.n)},precompute(y=8,R=l.BASE){return R._setWindowSize(y),R.multiply(BigInt(3)),R}};function S(y,R=!0){return l.fromPrivateKey(y).toRawBytes(R)}function F(y){const R=y instanceof Uint8Array,P=typeof y=="string",_=(R||P)&&y.length;return R?_===i||_===s:P?_===2*i||_===2*s:y instanceof l}function D(y,R,P=!0){if(F(y))throw new Error("first arg must be private key");if(!F(R))throw new Error("second arg must be public key");return l.fromHex(R).multiply(u(y)).toRawBytes(P)}const z=e.bits2int||function(y){const R=Wo(y),P=y.length*8-e.nBitLength;return P>0?R>>BigInt(P):R},X=e.bits2int_modN||function(y){return a(z(y))},Y=Ey(e.nBitLength);function U(y){if(typeof y!="bigint")throw new Error("bigint expected");if(!(ps<=y&&y<Y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ac(y,e.nByteLength)}function B(y,R,P=H){if(["recovered","canonical"].some(ne=>ne in P))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:I}=e;let{lowS:N,prehash:x,extraEntropy:h}=P;N==null&&(N=!0),y=vi("msgHash",y),x&&(y=vi("prehashed msgHash",_(y)));const m=X(y),A=u(R),C=[U(A),U(m)];if(h!=null){const ne=h===!0?I(n.BYTES):h;C.push(vi("extraEntropy",ne))}const $=Ml(...C),j=m;function Z(ne){const se=z(ne);if(!f(se))return;const ue=c(se),de=l.BASE.multiply(se).toAffine(),Ae=a(de.x);if(Ae===ps)return;const Ce=a(ue*a(j+Ae*A));if(Ce===ps)return;let Ue=(de.x===Ae?0:2)|Number(de.y&li),Be=Ce;return N&&v(Ce)&&(Be=w(Ce),Ue^=1),new E(Ae,Be,Ue)}return{seed:$,k2sig:Z}}const H={lowS:e.lowS,prehash:!1},V={lowS:e.lowS,prehash:!1};function T(y,R,P=H){const{seed:_,k2sig:I}=B(y,R,P),N=e;return EI(N.hash.outputLen,N.nByteLength,N.hmac)(_,I)}l.BASE._setWindowSize(8);function p(y,R,P,_=V){const I=y;if(R=vi("msgHash",R),P=vi("publicKey",P),"strict"in _)throw new Error("options.strict was renamed to lowS");const{lowS:N,prehash:x}=_;let h,m;try{if(typeof I=="string"||I instanceof Uint8Array)try{h=E.fromDER(I)}catch(de){if(!(de instanceof $o.Err))throw de;h=E.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:de,s:Ae}=I;h=new E(de,Ae)}else throw new Error("PARSE");m=l.fromHex(P)}catch(de){if(de.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&h.hasHighS())return!1;x&&(R=e.hash(R));const{r:A,s:C}=h,$=X(R),j=c(C),Z=a($*j),ne=a(A*j),se=l.BASE.multiplyAndAddUnsafe(m,Z,ne)?.toAffine();return se?a(se.x)===A:!1}return{CURVE:e,getPublicKey:S,getSharedSecret:D,sign:T,verify:p,ProjectivePoint:l,Signature:E,utils:M}}function $F(t){return{hash:t,hmac:(e,...n)=>eI(t,e,R$(...n)),randomBytes:I$}}function FF(t,e){const n=r=>UF({...t,...$F(r)});return Object.freeze({...n(e),create:n})}const AI=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),gb=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),KF=BigInt(1),Tm=BigInt(2),yb=(t,e)=>(t+e/Tm)/e;function VF(t){const e=AI,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,d=ni(u,n,e)*u%e,f=ni(d,n,e)*u%e,g=ni(f,Tm,e)*l%e,v=ni(g,i,e)*g%e,w=ni(v,s,e)*v%e,b=ni(w,a,e)*w%e,E=ni(b,c,e)*b%e,M=ni(E,a,e)*w%e,S=ni(M,n,e)*u%e,F=ni(S,o,e)*v%e,D=ni(F,r,e)*l%e,z=ni(D,Tm,e);if(!Cm.eql(Cm.sqr(z),t))throw new Error("Cannot find square root");return z}const Cm=CF(AI,void 0,void 0,{sqrt:VF}),Ys=FF({a:BigInt(0),b:BigInt(7),Fp:Cm,n:gb,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=gb,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-KF*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=yb(s*t,e),c=yb(-r*t,e);let l=Dr(t-a*n-c*i,e),u=Dr(-a*r-c*s,e);const d=l>o,f=u>o;if(d&&(l=e-l),f&&(u=e-u),l>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},nI);BigInt(0);Ys.ProjectivePoint;const RI="0x0000000000000000000000000000000000000000",wb="0x0000000000000000000000000000000000000000000000000000000000000000",vb=BigInt(0),Eb=BigInt(1),Om=BigInt(2),bb=BigInt(27),_b=BigInt(28),ju=BigInt(35),II=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),jF=II/Om,HF=Symbol.for("nodejs.util.inspect.custom"),Ao={};function Up(t){return ea(er(t),32)}class kn{#e;#t;#r;#n;get r(){return this.#e}set r(e){Ye(dl(e)===32,"invalid r","value",e),this.#e=kt(e)}get s(){return Ye(parseInt(this.#t.substring(0,3))<8,"non-canonical s; use ._s","s",this.#t),this.#t}set s(e){Ye(dl(e)===32,"invalid s","value",e),this.#t=kt(e)}get _s(){return this.#t}isValid(){return BigInt(this.#t)<=jF}get v(){return this.#r}set v(e){const n=uo(e,"value");Ye(n===27||n===28,"invalid v","v",e),this.#r=n}get networkV(){return this.#n}get legacyChainId(){const e=this.networkV;return e==null?null:kn.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=an(this.s);return this.yParity&&(e[0]|=128),kt(e)}get compactSerialized(){return Yi([this.r,this.yParityAndS])}get serialized(){return Yi([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(e,n,r,i){w$(e,Ao,"Signature"),this.#e=n,this.#t=r,this.#r=i,this.#n=null}getCanonical(){if(this.isValid())return this;const e=II-BigInt(this._s),n=55-this.v,r=new kn(Ao,this.r,Up(e),n);return this.networkV&&(r.#n=this.networkV),r}clone(){const e=new kn(Ao,this.r,this._s,this.v);return this.networkV&&(e.#n=this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this._s,v:this.v}}[HF](){return this.toString()}toString(){return this.isValid()?`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v} }`:`Signature { r: ${this.r}, s: ${this._s}, v: ${this.v}, valid: false }`}static getChainId(e){const n=Xn(e,"v");return n==bb||n==_b?vb:(Ye(n>=ju,"invalid EIP-155 v","v",e),(n-ju)/Om)}static getChainIdV(e,n){return Xn(e)*Om+BigInt(35+n-27)}static getNormalizedV(e){const n=Xn(e);return n===vb||n===bb?27:n===Eb||n===_b?28:(Ye(n>=ju,"invalid v","v",e),n&Eb?27:28)}static from(e){function n(l,u){Ye(l,u,"signature",e)}if(e==null)return new kn(Ao,wb,wb,27);if(typeof e=="string"){const l=an(e,"signature");if(l.length===64){const u=kt(l.slice(0,32)),d=l.slice(32,64),f=d[0]&128?28:27;return d[0]&=127,new kn(Ao,u,kt(d),f)}if(l.length===65){const u=kt(l.slice(0,32)),d=kt(l.slice(32,64)),f=kn.getNormalizedV(l[64]);return new kn(Ao,u,d,f)}n(!1,"invalid raw signature length")}if(e instanceof kn)return e.clone();const r=e.r;n(r!=null,"missing r");const i=Up(r),s=(function(l,u){if(l!=null)return Up(l);if(u!=null){n(vo(u,32),"invalid yParityAndS");const d=an(u);return d[0]&=127,kt(d)}n(!1,"missing s")})(e.s,e.yParityAndS),{networkV:o,v:a}=(function(l,u,d){if(l!=null){const f=Xn(l);return{networkV:f>=ju?f:void 0,v:kn.getNormalizedV(f)}}if(u!=null)return n(vo(u,32),"invalid yParityAndS"),{v:an(u)[0]&128?28:27};if(d!=null){switch(uo(d,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}n(!1,"invalid yParity")}n(!1,"missing v")})(e.v,e.yParityAndS,e.yParity),c=new kn(Ao,i,s,a);return o&&(c.#n=o),n(e.yParity==null||uo(e.yParity,"sig.yParity")===c.yParity,"yParity mismatch"),n(e.yParityAndS==null||e.yParityAndS===c.yParityAndS,"yParityAndS mismatch"),c}}class ms{#e;constructor(e){Ye(dl(e)===32,"invalid private key","privateKey","[REDACTED]"),this.#e=kt(e)}get privateKey(){return this.#e}get publicKey(){return ms.computePublicKey(this.#e)}get compressedPublicKey(){return ms.computePublicKey(this.#e,!0)}sign(e){Ye(dl(e)===32,"invalid digest length","digest",e);const n=Ys.sign(Vc(e),Vc(this.#e),{lowS:!0});return kn.from({r:ib(n.r,32),s:ib(n.s,32),v:n.recovery?28:27})}computeSharedSecret(e){const n=ms.computePublicKey(e);return kt(Ys.getSharedSecret(Vc(this.#e),an(n),!1))}static computePublicKey(e,n){let r=an(e,"key");if(r.length===32){const s=Ys.getPublicKey(r,!!n);return kt(s)}if(r.length===64){const s=new Uint8Array(65);s[0]=4,s.set(r,1),r=s}const i=Ys.ProjectivePoint.fromHex(r);return kt(i.toRawBytes(n))}static recoverPublicKey(e,n){Ye(dl(e)===32,"invalid digest length","digest",e);const r=kn.from(n);let i=Ys.Signature.fromCompact(Vc(Yi([r.r,r.s])));i=i.addRecoveryBit(r.yParity);const s=i.recoverPublicKey(Vc(e));return Ye(s!=null,"invalid signature for digest","signature",n),"0x"+s.toHex(!1)}static addPoints(e,n,r){const i=Ys.ProjectivePoint.fromHex(ms.computePublicKey(e).substring(2)),s=Ys.ProjectivePoint.fromHex(ms.computePublicKey(n).substring(2));return"0x"+i.add(s).toHex(!!r)}}const zF=BigInt(0),qF=BigInt(36);function Sb(t){t=t.toLowerCase();const e=t.substring(2).split(""),n=new Uint8Array(40);for(let i=0;i<40;i++)n[i]=e[i].charCodeAt(0);const r=an(Eo(n));for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(r[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const by={};for(let t=0;t<10;t++)by[String(t)]=String(t);for(let t=0;t<26;t++)by[String.fromCharCode(65+t)]=String(10+t);const xb=15;function WF(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(r=>by[r]).join("");for(;e.length>=xb;){let r=e.substring(0,xb);e=parseInt(r,10)%97+e.substring(r.length)}let n=String(98-parseInt(e,10)%97);for(;n.length<2;)n="0"+n;return n}const GF=(function(){const t={};for(let e=0;e<36;e++){const n="0123456789abcdefghijklmnopqrstuvwxyz"[e];t[n]=BigInt(e)}return t})();function YF(t){t=t.toLowerCase();let e=zF;for(let n=0;n<t.length;n++)e=e*qF+GF[t[n]];return e}function Ac(t){if(Ye(typeof t=="string","invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Sb(t);return Ye(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Ye(t.substring(2,4)===WF(t),"bad icap checksum","address",t);let e=YF(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Sb("0x"+e)}Ye(!1,"invalid address","address",t)}function $p(t,e){return{address:Ac(t),storageKeys:e.map((n,r)=>(Ye(vo(n,32),"invalid slot",`storageKeys[${r}]`,n),n.toLowerCase()))}}function _y(t){if(Array.isArray(t))return t.map((n,r)=>Array.isArray(n)?(Ye(n.length===2,"invalid slot set",`value[${r}]`,n),$p(n[0],n[1])):(Ye(n!=null&&typeof n=="object","invalid address-slot set","value",t),$p(n.address,n.storageKeys)));Ye(t!=null&&typeof t=="object","invalid access list","value",t);const e=Object.keys(t).map(n=>{const r=t[n].reduce((i,s)=>(i[s]=!0,i),{});return $p(n,Object.keys(r).sort())});return e.sort((n,r)=>n.address.localeCompare(r.address)),e}function JF(t){return{address:Ac(t.address),nonce:Xn(t.nonce!=null?t.nonce:0),chainId:Xn(t.chainId!=null?t.chainId:0),signature:kn.from(t.signature)}}function ZF(t){let e;return typeof t=="string"?e=ms.computePublicKey(t,!1):e=t.publicKey,Ac(Eo("0x"+e.substring(4)).substring(26))}function XF(t,e){return ZF(ms.recoverPublicKey(t,e))}const zn=BigInt(0),QF=BigInt(2),eK=BigInt(27),tK=BigInt(28),nK=BigInt(35),rK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),iK=Symbol.for("nodejs.util.inspect.custom"),Fp=4096*32,xd=128;function sK(t){return{blobToKzgCommitment:r=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&typeof t.blobToKzgCommitment=="function")return an(t.blobToKzgCommitment(kt(r)))}else if("blobToKzgCommitment"in t&&typeof t.blobToKzgCommitment=="function")return an(t.blobToKzgCommitment(r));if("blobToKZGCommitment"in t&&typeof t.blobToKZGCommitment=="function")return an(t.blobToKZGCommitment(kt(r)));Ye(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(r,i)=>{if("computeBlobProof"in t&&typeof t.computeBlobProof=="function")return an(t.computeBlobProof(kt(r),kt(i)));if("computeBlobKzgProof"in t&&typeof t.computeBlobKzgProof=="function")return t.computeBlobKzgProof(r,i);if("computeBlobKZGProof"in t&&typeof t.computeBlobKZGProof=="function")return an(t.computeBlobKZGProof(kt(r),kt(i)));Ye(!1,"unsupported KZG library","kzg",t)}}}function Ab(t,e){let n=t.toString(16);for(;n.length<2;)n="0"+n;return n+=xc(e).substring(4),"0x"+n}function Rc(t){return t==="0x"?null:Ac(t)}function nh(t,e){try{return _y(t)}catch(n){Ye(!1,n.message,e,t)}}function oK(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const n=[];for(let r=0;r<t.length;r++){const i=t[r];if(!Array.isArray(i))throw new Error(`authorization[${r}]: invalid array`);if(i.length!==6)throw new Error(`authorization[${r}]: wrong length`);if(!i[1])throw new Error(`authorization[${r}]: null address`);n.push({address:Rc(i[1]),nonce:rn(i[2],"nonce"),chainId:rn(i[0],"chainId"),signature:kn.from({yParity:oa(i[3],"yParity"),r:ea(i[4],32),s:ea(i[5],32)})})}return n}catch(n){Ye(!1,n.message,e,t)}}function oa(t,e){return t==="0x"?0:uo(t,e)}function rn(t,e){if(t==="0x")return zn;const n=Xn(t,e);return Ye(n<=rK,"value exceeds uint size",e,n),n}function Ft(t,e){const n=Xn(t,"value"),r=er(n);return Ye(r.length<=32,"value too large",`tx.${e}`,n),r}function rh(t){return _y(t).map(e=>[e.address,e.storageKeys])}function aK(t){return t.map(e=>[Ft(e.chainId,"chainId"),e.address,Ft(e.nonce,"nonce"),Ft(e.signature.yParity,"yParity"),er(e.signature.r),er(e.signature._s)])}function cK(t,e){Ye(Array.isArray(t),`invalid ${e}`,"value",t);for(let n=0;n<t.length;n++)Ye(vo(t[n],32),"invalid ${ param } hash",`value[${n}]`,t[n]);return t}function lK(t){const e=Yl(t);Ye(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",t);const n={type:0,nonce:oa(e[0],"nonce"),gasPrice:rn(e[1],"gasPrice"),gasLimit:rn(e[2],"gasLimit"),to:Rc(e[3]),value:rn(e[4],"value"),data:kt(e[5]),chainId:zn};if(e.length===6)return n;const r=rn(e[6],"v"),i=rn(e[7],"r"),s=rn(e[8],"s");if(i===zn&&s===zn)n.chainId=r;else{let o=(r-nK)/QF;o<zn&&(o=zn),n.chainId=o,Ye(o!==zn||r===eK||r===tK,"non-canonical legacy v","v",e[6]),n.signature=kn.from({r:ea(e[7],32),s:ea(e[8],32),v:r})}return n}function uK(t,e){const n=[Ft(t.nonce,"nonce"),Ft(t.gasPrice||0,"gasPrice"),Ft(t.gasLimit,"gasLimit"),t.to||"0x",Ft(t.value,"value"),t.data];let r=zn;if(t.chainId!=zn)r=Xn(t.chainId,"tx.chainId"),Ye(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const s=t.signature.legacyChainId;s!=null&&(r=s)}if(!e)return r!==zn&&(n.push(er(r)),n.push("0x"),n.push("0x")),fo(n);let i=BigInt(27+e.yParity);return r!==zn?i=kn.getChainIdV(r,e.v):BigInt(e.v)!==i&&Ye(!1,"tx.chainId/sig.v mismatch","sig",e),n.push(er(i)),n.push(er(e.r)),n.push(er(e._s)),fo(n)}function ih(t,e){let n;try{if(n=oa(e[0],"yParity"),n!==0&&n!==1)throw new Error("bad yParity")}catch{Ye(!1,"invalid yParity","yParity",e[0])}const r=ea(e[1],32),i=ea(e[2],32),s=kn.from({r,s:i,yParity:n});t.signature=s}function dK(t){const e=Yl(an(t).slice(1));Ye(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",kt(t));const n={type:2,chainId:rn(e[0],"chainId"),nonce:oa(e[1],"nonce"),maxPriorityFeePerGas:rn(e[2],"maxPriorityFeePerGas"),maxFeePerGas:rn(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:rn(e[4],"gasLimit"),to:Rc(e[5]),value:rn(e[6],"value"),data:kt(e[7]),accessList:nh(e[8],"accessList")};return e.length===9||ih(n,e.slice(9)),n}function fK(t,e){const n=[Ft(t.chainId,"chainId"),Ft(t.nonce,"nonce"),Ft(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ft(t.maxFeePerGas||0,"maxFeePerGas"),Ft(t.gasLimit,"gasLimit"),t.to||"0x",Ft(t.value,"value"),t.data,rh(t.accessList||[])];return e&&(n.push(Ft(e.yParity,"yParity")),n.push(er(e.r)),n.push(er(e.s))),Yi(["0x02",fo(n)])}function hK(t){const e=Yl(an(t).slice(1));Ye(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",kt(t));const n={type:1,chainId:rn(e[0],"chainId"),nonce:oa(e[1],"nonce"),gasPrice:rn(e[2],"gasPrice"),gasLimit:rn(e[3],"gasLimit"),to:Rc(e[4]),value:rn(e[5],"value"),data:kt(e[6]),accessList:nh(e[7],"accessList")};return e.length===8||ih(n,e.slice(8)),n}function pK(t,e){const n=[Ft(t.chainId,"chainId"),Ft(t.nonce,"nonce"),Ft(t.gasPrice||0,"gasPrice"),Ft(t.gasLimit,"gasLimit"),t.to||"0x",Ft(t.value,"value"),t.data,rh(t.accessList||[])];return e&&(n.push(Ft(e.yParity,"recoveryParam")),n.push(er(e.r)),n.push(er(e.s))),Yi(["0x01",fo(n)])}function mK(t){let e=Yl(an(t).slice(1)),n="3",r=null,i=null;if(e.length===4&&Array.isArray(e[0])){n="3 (network format)";const o=e[1],a=e[2],c=e[3];Ye(Array.isArray(o),"invalid network format: blobs not an array","fields[1]",o),Ye(Array.isArray(a),"invalid network format: commitments not an array","fields[2]",a),Ye(Array.isArray(c),"invalid network format: proofs not an array","fields[3]",c),Ye(o.length===a.length,"invalid network format: blobs/commitments length mismatch","fields",e),Ye(o.length===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),i=[];for(let l=0;l<e[1].length;l++)i.push({data:o[l],commitment:a[l],proof:c[l]});e=e[0]}else if(e.length===5&&Array.isArray(e[0])){n="3 (EIP-7594 network format)",r=uo(e[1]);const o=e[2],a=e[3],c=e[4];Ye(r===1,`unsupported EIP-7594 network format version: ${r}`,"fields[1]",r),Ye(Array.isArray(o),"invalid EIP-7594 network format: blobs not an array","fields[2]",o),Ye(Array.isArray(a),"invalid EIP-7594 network format: commitments not an array","fields[3]",a),Ye(Array.isArray(c),"invalid EIP-7594 network format: proofs not an array","fields[4]",c),Ye(o.length===a.length,"invalid network format: blobs/commitments length mismatch","fields",e),Ye(o.length*xd===c.length,"invalid network format: blobs/proofs length mismatch","fields",e),i=[];for(let l=0;l<o.length;l++){const u=[];for(let d=0;d<xd;d++)u.push(c[l*xd+d]);i.push({data:o[l],commitment:a[l],proof:Yi(u)})}e=e[0]}Ye(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${n}`,"data",kt(t));const s={type:3,chainId:rn(e[0],"chainId"),nonce:oa(e[1],"nonce"),maxPriorityFeePerGas:rn(e[2],"maxPriorityFeePerGas"),maxFeePerGas:rn(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:rn(e[4],"gasLimit"),to:Rc(e[5]),value:rn(e[6],"value"),data:kt(e[7]),accessList:nh(e[8],"accessList"),maxFeePerBlobGas:rn(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10],blobWrapperVersion:r};i&&(s.blobs=i),Ye(s.to!=null,`invalid address for transaction type: ${n}`,"data",t),Ye(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let o=0;o<s.blobVersionedHashes.length;o++)Ye(vo(s.blobVersionedHashes[o],32),`invalid blobVersionedHash at index ${o}: must be length 32`,"data",t);return e.length===11||ih(s,e.slice(11)),s}function gK(t,e,n){const r=[Ft(t.chainId,"chainId"),Ft(t.nonce,"nonce"),Ft(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ft(t.maxFeePerGas||0,"maxFeePerGas"),Ft(t.gasLimit,"gasLimit"),t.to||RI,Ft(t.value,"value"),t.data,rh(t.accessList||[]),Ft(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),cK(t.blobVersionedHashes||[],"blobVersionedHashes")];if(e&&(r.push(Ft(e.yParity,"yParity")),r.push(er(e.r)),r.push(er(e.s)),n)){if(t.blobWrapperVersion!=null){const i=er(t.blobWrapperVersion),s=[];for(const{proof:o}of n){const a=an(o),c=a.length/xd;for(let l=0;l<a.length;l+=c)s.push(a.subarray(l,l+c))}return Yi(["0x03",fo([r,i,n.map(o=>o.data),n.map(o=>o.commitment),s])])}return Yi(["0x03",fo([r,n.map(i=>i.data),n.map(i=>i.commitment),n.map(i=>i.proof)])])}return Yi(["0x03",fo(r)])}function yK(t){const e=Yl(an(t).slice(1));Ye(Array.isArray(e)&&(e.length===10||e.length===13),"invalid field count for transaction type: 4","data",kt(t));const n={type:4,chainId:rn(e[0],"chainId"),nonce:oa(e[1],"nonce"),maxPriorityFeePerGas:rn(e[2],"maxPriorityFeePerGas"),maxFeePerGas:rn(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:rn(e[4],"gasLimit"),to:Rc(e[5]),value:rn(e[6],"value"),data:kt(e[7]),accessList:nh(e[8],"accessList"),authorizationList:oK(e[9],"authorizationList")};return e.length===10||ih(n,e.slice(10)),n}function wK(t,e){const n=[Ft(t.chainId,"chainId"),Ft(t.nonce,"nonce"),Ft(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ft(t.maxFeePerGas||0,"maxFeePerGas"),Ft(t.gasLimit,"gasLimit"),t.to||"0x",Ft(t.value,"value"),t.data,rh(t.accessList||[]),aK(t.authorizationList||[])];return e&&(n.push(Ft(e.yParity,"yParity")),n.push(er(e.r)),n.push(er(e.s))),Yi(["0x04",fo(n)])}let vK=class as{#e;#t;#r;#n;#c;#l;#u;#d;#f;#h;#p;#m;#a;#s;#i;#o;#g;#y;get type(){return this.#e}set type(e){switch(e){case null:this.#e=null;break;case 0:case"legacy":this.#e=0;break;case 1:case"berlin":case"eip-2930":this.#e=1;break;case 2:case"london":case"eip-1559":this.#e=2;break;case 3:case"cancun":case"eip-4844":this.#e=3;break;case 4:case"pectra":case"eip-7702":this.#e=4;break;default:Ye(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const e=this.#t;return e==null&&this.type===3?RI:e}set to(e){this.#t=e==null?null:Ac(e)}get nonce(){return this.#n}set nonce(e){this.#n=uo(e,"value")}get gasLimit(){return this.#c}set gasLimit(e){this.#c=Xn(e)}get gasPrice(){const e=this.#l;return e==null&&(this.type===0||this.type===1)?zn:e}set gasPrice(e){this.#l=e==null?null:Xn(e,"gasPrice")}get maxPriorityFeePerGas(){const e=this.#u;return e??(this.type===2||this.type===3?zn:null)}set maxPriorityFeePerGas(e){this.#u=e==null?null:Xn(e,"maxPriorityFeePerGas")}get maxFeePerGas(){const e=this.#d;return e??(this.type===2||this.type===3?zn:null)}set maxFeePerGas(e){this.#d=e==null?null:Xn(e,"maxFeePerGas")}get data(){return this.#r}set data(e){this.#r=kt(e)}get value(){return this.#f}set value(e){this.#f=Xn(e,"value")}get chainId(){return this.#h}set chainId(e){this.#h=Xn(e)}get signature(){return this.#p||null}set signature(e){this.#p=e==null?null:kn.from(e)}isValid(){const e=this.signature;if(e&&!e.isValid())return!1;const n=this.authorizationList;if(n){for(const r of n)if(!r.signature.isValid())return!1}return!0}get accessList(){const e=this.#m||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){this.#m=e==null?null:_y(e)}get authorizationList(){const e=this.#g||null;return e==null&&this.type===4?[]:e}set authorizationList(e){this.#g=e==null?null:e.map(n=>JF(n))}get maxFeePerBlobGas(){const e=this.#a;return e==null&&this.type===3?zn:e}set maxFeePerBlobGas(e){this.#a=e==null?null:Xn(e,"maxFeePerBlobGas")}get blobVersionedHashes(){let e=this.#s;return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){Ye(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let n=0;n<e.length;n++)Ye(vo(e[n],32),"invalid blobVersionedHash",`value[${n}]`,e[n])}this.#s=e}get blobs(){return this.#o==null?null:this.#o.map(e=>Object.assign({},e))}set blobs(e){if(e==null){this.#o=null;return}const n=[],r=[];for(let i=0;i<e.length;i++){const s=e[i];if(v$(s)){Sr(this.#i,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=an(s);if(Ye(o.length<=Fp,"blob is too large",`blobs[${i}]`,s),o.length!==Fp){const l=new Uint8Array(Fp);l.set(o),o=l}const a=this.#i.blobToKzgCommitment(o),c=kt(this.#i.computeBlobKzgProof(o,a));n.push({data:kt(o),commitment:kt(a),proof:c}),r.push(Ab(1,a))}else{const o=kt(s.data),a=kt(s.commitment),c=kt(s.proof);n.push({data:o,commitment:a,proof:c}),r.push(Ab(1,a))}}this.#o=n,this.#s=r}get kzg(){return this.#i}set kzg(e){e==null?this.#i=null:this.#i=sK(e)}get blobWrapperVersion(){return this.#y}set blobWrapperVersion(e){this.#y=e}constructor(){this.#e=null,this.#t=null,this.#n=0,this.#c=zn,this.#l=null,this.#u=null,this.#d=null,this.#r="0x",this.#f=zn,this.#h=zn,this.#p=null,this.#m=null,this.#a=null,this.#s=null,this.#i=null,this.#o=null,this.#g=null,this.#y=null}get hash(){return this.signature==null?null:Eo(this.#w(!0,!1))}get unsignedHash(){return Eo(this.unsignedSerialized)}get from(){return this.signature==null?null:XF(this.unsignedHash,this.signature.getCanonical())}get fromPublicKey(){return this.signature==null?null:ms.recoverPublicKey(this.unsignedHash,this.signature.getCanonical())}isSigned(){return this.signature!=null}#w(e,n){Sr(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return uK(this,r);case 1:return pK(this,r);case 2:return fK(this,r);case 3:return gK(this,r,n?this.blobs:null);case 4:return wK(this,r)}Sr(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#w(!0,!0)}get unsignedSerialized(){return this.#w(!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,n=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,i=this.#a!=null||this.#s;this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&Sr(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Sr(!n||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Sr(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const s=[];return this.type!=null?s.push(this.type):this.authorizationList&&this.authorizationList.length?s.push(4):n?s.push(2):e?(s.push(1),r||s.push(0)):r?(s.push(1),s.push(2)):(i&&this.to||(s.push(0),s.push(1),s.push(2)),s.push(3)),s.sort(),s}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return as.from(this)}toJSON(){const e=n=>n==null?null:n.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}[iK](){return this.toString()}toString(){const e=[],n=i=>{let s=this[i];typeof s=="string"&&(s=JSON.stringify(s)),e.push(`${i}: ${s}`)};this.type&&n("type"),n("to"),n("data"),n("nonce"),n("gasLimit"),n("value"),this.chainId!=null&&n("chainId"),this.signature&&(n("from"),e.push(`signature: ${this.signature.toString()}`));const r=this.authorizationList;if(r){const i=[];for(const s of r){const o=[];o.push(`address: ${JSON.stringify(s.address)}`),s.nonce!=null&&o.push(`nonce: ${s.nonce}`),s.chainId!=null&&o.push(`chainId: ${s.chainId}`),s.signature&&o.push(`signature: ${s.signature.toString()}`),i.push(`Authorization { ${o.join(", ")} }`)}e.push(`authorizations: [ ${i.join(", ")} ]`)}return`Transaction { ${e.join(", ")} }`}static from(e){if(e==null)return new as;if(typeof e=="string"){const r=an(e);if(r[0]>=127)return as.from(lK(r));switch(r[0]){case 1:return as.from(hK(r));case 2:return as.from(dK(r));case 3:return as.from(mK(r));case 4:return as.from(yK(r))}Sr(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const n=new as;return e.type!=null&&(n.type=e.type),e.to!=null&&(n.to=e.to),e.nonce!=null&&(n.nonce=e.nonce),e.gasLimit!=null&&(n.gasLimit=e.gasLimit),e.gasPrice!=null&&(n.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(n.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(n.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(n.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(n.data=e.data),e.value!=null&&(n.value=e.value),e.chainId!=null&&(n.chainId=e.chainId),e.signature!=null&&(n.signature=kn.from(e.signature)),e.accessList!=null&&(n.accessList=e.accessList),e.authorizationList!=null&&(n.authorizationList=e.authorizationList),e.blobVersionedHashes!=null&&(n.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(n.kzg=e.kzg),e.blobWrapperVersion!=null&&(n.blobWrapperVersion=e.blobWrapperVersion),e.blobs!=null&&(n.blobs=e.blobs),e.hash!=null&&(Ye(n.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Ye(n.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(Ye(n.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Ye(n.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),n}};const va=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Zl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Nm(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function aa(t,...e){if(!Zl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function TI(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Nm(t.outputLen),Nm(t.blockLen)}function df(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function EK(t,e){aa(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function cc(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Kp(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ki(t,e){return t<<32-e|t>>>e}const CI=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bK=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Go(t){if(aa(t),CI)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=bK[t[n]];return e}const ss={_0:48,_9:57,A:65,F:70,a:97,f:102};function Rb(t){if(t>=ss._0&&t<=ss._9)return t-ss._0;if(t>=ss.A&&t<=ss.F)return t-(ss.A-10);if(t>=ss.a&&t<=ss.f)return t-(ss.a-10)}function ff(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(CI)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,s=0;i<n;i++,s+=2){const o=Rb(t.charCodeAt(s)),a=Rb(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[i]=o*16+a}return r}function _K(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Sy(t){return typeof t=="string"&&(t=_K(t)),aa(t),t}function Ki(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];aa(i),e+=i.length}const n=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const s=t[r];n.set(s,i),i+=s.length}return n}class OI{}function NI(t){const e=r=>t().update(Sy(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function xy(t=32){if(va&&typeof va.getRandomValues=="function")return va.getRandomValues(new Uint8Array(t));if(va&&typeof va.randomBytes=="function")return Uint8Array.from(va.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function SK(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,l=r?0:4;t.setUint32(e+c,o,r),t.setUint32(e+l,a,r)}function xK(t,e,n){return t&e^~t&n}function AK(t,e,n){return t&e^t&n^e&n}class PI extends OI{constructor(e,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Kp(this.buffer)}update(e){df(this),e=Sy(e),aa(e);const{view:n,buffer:r,blockLen:i}=this,s=e.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Kp(e);for(;i<=s-o;o+=i)this.process(c,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){df(this),EK(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;n[o++]=128,cc(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(r,0),o=0);for(let d=o;d<i;d++)n[d]=0;SK(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Kp(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=s,e.length=i,e.pos=a,i%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const $s=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ur=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Hu=BigInt(2**32-1),Ib=BigInt(32);function RK(t,e=!1){return e?{h:Number(t&Hu),l:Number(t>>Ib&Hu)}:{h:Number(t>>Ib&Hu)|0,l:Number(t&Hu)|0}}function IK(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let s=0;s<n;s++){const{h:o,l:a}=RK(t[s],e);[r[s],i[s]]=[o,a]}return[r,i]}const Tb=(t,e,n)=>t>>>n,Cb=(t,e,n)=>t<<32-n|e>>>n,Ea=(t,e,n)=>t>>>n|e<<32-n,ba=(t,e,n)=>t<<32-n|e>>>n,zu=(t,e,n)=>t<<64-n|e>>>n-32,qu=(t,e,n)=>t>>>n-32|e<<64-n;function os(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const TK=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),CK=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,OK=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),NK=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,PK=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),MK=(t,e,n,r,i,s)=>e+n+r+i+s+(t/2**32|0)|0,kK=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fs=new Uint32Array(64);class DK extends PI{constructor(e=32){super(64,e,8,!1),this.A=$s[0]|0,this.B=$s[1]|0,this.C=$s[2]|0,this.D=$s[3]|0,this.E=$s[4]|0,this.F=$s[5]|0,this.G=$s[6]|0,this.H=$s[7]|0}get(){const{A:e,B:n,C:r,D:i,E:s,F:o,G:a,H:c}=this;return[e,n,r,i,s,o,a,c]}set(e,n,r,i,s,o,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)Fs[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const f=Fs[d-15],g=Fs[d-2],v=ki(f,7)^ki(f,18)^f>>>3,w=ki(g,17)^ki(g,19)^g>>>10;Fs[d]=w+Fs[d-7]+v+Fs[d-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const f=ki(a,6)^ki(a,11)^ki(a,25),g=u+f+xK(a,c,l)+kK[d]+Fs[d]|0,w=(ki(r,2)^ki(r,13)^ki(r,22))+AK(r,i,s)|0;u=l,l=c,c=a,a=o+g|0,o=s,s=i,i=r,r=g+w|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,s,o,a,c,l,u)}roundClean(){cc(Fs)}destroy(){this.set(0,0,0,0,0,0,0,0),cc(this.buffer)}}const MI=IK(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),LK=MI[0],BK=MI[1],Ks=new Uint32Array(80),Vs=new Uint32Array(80);class UK extends PI{constructor(e=64){super(128,e,16,!1),this.Ah=ur[0]|0,this.Al=ur[1]|0,this.Bh=ur[2]|0,this.Bl=ur[3]|0,this.Ch=ur[4]|0,this.Cl=ur[5]|0,this.Dh=ur[6]|0,this.Dl=ur[7]|0,this.Eh=ur[8]|0,this.El=ur[9]|0,this.Fh=ur[10]|0,this.Fl=ur[11]|0,this.Gh=ur[12]|0,this.Gl=ur[13]|0,this.Hh=ur[14]|0,this.Hl=ur[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:d,Fl:f,Gh:g,Gl:v,Hh:w,Hl:b}=this;return[e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b]}set(e,n,r,i,s,o,a,c,l,u,d,f,g,v,w,b){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=g|0,this.Gl=v|0,this.Hh=w|0,this.Hl=b|0}process(e,n){for(let S=0;S<16;S++,n+=4)Ks[S]=e.getUint32(n),Vs[S]=e.getUint32(n+=4);for(let S=16;S<80;S++){const F=Ks[S-15]|0,D=Vs[S-15]|0,z=Ea(F,D,1)^Ea(F,D,8)^Tb(F,D,7),X=ba(F,D,1)^ba(F,D,8)^Cb(F,D,7),Y=Ks[S-2]|0,U=Vs[S-2]|0,B=Ea(Y,U,19)^zu(Y,U,61)^Tb(Y,U,6),H=ba(Y,U,19)^qu(Y,U,61)^Cb(Y,U,6),V=OK(X,H,Vs[S-7],Vs[S-16]),T=NK(V,z,B,Ks[S-7],Ks[S-16]);Ks[S]=T|0,Vs[S]=V|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:f,Fh:g,Fl:v,Gh:w,Gl:b,Hh:E,Hl:M}=this;for(let S=0;S<80;S++){const F=Ea(d,f,14)^Ea(d,f,18)^zu(d,f,41),D=ba(d,f,14)^ba(d,f,18)^qu(d,f,41),z=d&g^~d&w,X=f&v^~f&b,Y=PK(M,D,X,BK[S],Vs[S]),U=MK(Y,E,F,z,LK[S],Ks[S]),B=Y|0,H=Ea(r,i,28)^zu(r,i,34)^zu(r,i,39),V=ba(r,i,28)^qu(r,i,34)^qu(r,i,39),T=r&s^r&a^s&a,p=i&o^i&c^o&c;E=w|0,M=b|0,w=g|0,b=v|0,g=d|0,v=f|0,{h:d,l:f}=os(l|0,u|0,U|0,B|0),l=a|0,u=c|0,a=s|0,c=o|0,s=r|0,o=i|0;const y=TK(B,V,p);r=CK(y,U,H,T),i=y|0}({h:r,l:i}=os(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=os(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=os(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=os(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=os(this.Eh|0,this.El|0,d|0,f|0),{h:g,l:v}=os(this.Fh|0,this.Fl|0,g|0,v|0),{h:w,l:b}=os(this.Gh|0,this.Gl|0,w|0,b|0),{h:E,l:M}=os(this.Hh|0,this.Hl|0,E|0,M|0),this.set(r,i,s,o,a,c,l,u,d,f,g,v,w,b,E,M)}roundClean(){cc(Ks,Vs)}destroy(){cc(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const kI=NI(()=>new DK),$K=NI(()=>new UK);const Ay=BigInt(0),Pm=BigInt(1);function ta(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Si(t,e,n=""){const r=Zl(t),i=t?.length,s=e!==void 0;if(!r||s&&i!==e){const o=n&&`"${n}" `,a=s?` of length ${e}`:"",c=r?`length=${i}`:`type=${typeof t}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return t}function Wu(t){const e=t.toString(16);return e.length&1?"0"+e:e}function DI(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ay:BigInt("0x"+t)}function sh(t){return DI(Go(t))}function kl(t){return aa(t),DI(Go(Uint8Array.from(t).reverse()))}function Ry(t,e){return ff(t.toString(16).padStart(e*2,"0"))}function LI(t,e){return Ry(t,e).reverse()}function Rn(t,e,n){let r;if(typeof e=="string")try{r=ff(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Zl(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function Ob(t){return Uint8Array.from(t)}const Vp=t=>typeof t=="bigint"&&Ay<=t;function FK(t,e,n){return Vp(t)&&Vp(e)&&Vp(n)&&e<=t&&t<n}function Mm(t,e,n,r){if(!FK(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function BI(t){let e;for(e=0;t>Ay;t>>=Pm,e+=1);return e}const Xl=t=>(Pm<<BigInt(t))-Pm;function KK(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=g=>new Uint8Array(g),i=g=>Uint8Array.of(g);let s=r(t),o=r(t),a=0;const c=()=>{s.fill(1),o.fill(0),a=0},l=(...g)=>n(o,s,...g),u=(g=r(0))=>{o=l(i(0),g),s=l(),g.length!==0&&(o=l(i(1),g),s=l())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const v=[];for(;g<e;){s=l();const w=s.slice();v.push(w),g+=s.length}return Ki(...v)};return(g,v)=>{c(),u(g);let w;for(;!(w=v(d()));)u();return c(),w}}function Ql(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(i,s,o){const a=t[i];if(o&&a===void 0)return;const c=typeof a;if(c!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${c}`)}Object.entries(e).forEach(([i,s])=>r(i,s,!1)),Object.entries(n).forEach(([i,s])=>r(i,s,!0))}function hf(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const s=t(n,...r);return e.set(n,s),s}}const Ur=BigInt(0),tr=BigInt(1),Fo=BigInt(2),UI=BigInt(3),$I=BigInt(4),FI=BigInt(5),VK=BigInt(7),KI=BigInt(8),jK=BigInt(9),VI=BigInt(16);function Dn(t,e){const n=t%e;return n>=Ur?n:e+n}function An(t,e,n){let r=t;for(;e-- >Ur;)r*=r,r%=n;return r}function Nb(t,e){if(t===Ur)throw new Error("invert: expected non-zero number");if(e<=Ur)throw new Error("invert: expected positive modulus, got "+e);let n=Dn(t,e),r=e,i=Ur,s=tr;for(;n!==Ur;){const a=r/n,c=r%n,l=i-s*a;r=n,n=c,i=s,s=l}if(r!==tr)throw new Error("invert: does not exist");return Dn(i,e)}function Iy(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function jI(t,e){const n=(t.ORDER+tr)/$I,r=t.pow(e,n);return Iy(t,r,e),r}function HK(t,e){const n=(t.ORDER-FI)/KI,r=t.mul(e,Fo),i=t.pow(r,n),s=t.mul(e,i),o=t.mul(t.mul(s,Fo),i),a=t.mul(s,t.sub(o,t.ONE));return Iy(t,a,e),a}function zK(t){const e=ca(t),n=HI(t),r=n(e,e.neg(e.ONE)),i=n(e,r),s=n(e,e.neg(r)),o=(t+VK)/VI;return(a,c)=>{let l=a.pow(c,o),u=a.mul(l,r);const d=a.mul(l,i),f=a.mul(l,s),g=a.eql(a.sqr(u),c),v=a.eql(a.sqr(d),c);l=a.cmov(l,u,g),u=a.cmov(f,d,v);const w=a.eql(a.sqr(u),c),b=a.cmov(l,u,w);return Iy(a,b,c),b}}function HI(t){if(t<UI)throw new Error("sqrt is not defined for small field");let e=t-tr,n=0;for(;e%Fo===Ur;)e/=Fo,n++;let r=Fo;const i=ca(t);for(;Pb(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return jI;let s=i.pow(r,e);const o=(e+tr)/Fo;return function(c,l){if(c.is0(l))return l;if(Pb(c,l)!==1)throw new Error("Cannot find square root");let u=n,d=c.mul(c.ONE,s),f=c.pow(l,e),g=c.pow(l,o);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let v=1,w=c.sqr(f);for(;!c.eql(w,c.ONE);)if(v++,w=c.sqr(w),v===u)throw new Error("Cannot find square root");const b=tr<<BigInt(u-v-1),E=c.pow(d,b);u=v,d=c.sqr(E),f=c.mul(f,d),g=c.mul(g,E)}return g}}function qK(t){return t%$I===UI?jI:t%KI===FI?HK:t%VI===jK?zK(t):HI(t)}const WK=(t,e)=>(Dn(t,e)&tr)===tr,GK=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function YK(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=GK.reduce((r,i)=>(r[i]="function",r),e);return Ql(t,n),t}function JK(t,e,n){if(n<Ur)throw new Error("invalid exponent, negatives unsupported");if(n===Ur)return t.ONE;if(n===tr)return e;let r=t.ONE,i=e;for(;n>Ur;)n&tr&&(r=t.mul(r,i)),i=t.sqr(i),n>>=tr;return r}function zI(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((o,a,c)=>t.is0(a)?o:(r[c]=o,t.mul(o,a)),t.ONE),s=t.inv(i);return e.reduceRight((o,a,c)=>t.is0(a)?o:(r[c]=t.mul(o,r[c]),t.mul(o,a)),s),r}function Pb(t,e){const n=(t.ORDER-tr)/Fo,r=t.pow(e,n),i=t.eql(r,t.ONE),s=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!i&&!s&&!o)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function qI(t,e){e!==void 0&&Nm(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ca(t,e,n=!1,r={}){if(t<=Ur)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,s,o=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const f=e;f.BITS&&(i=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(n=f.isLE),typeof f.modFromBytes=="boolean"&&(o=f.modFromBytes),a=f.allowedLengths}else typeof e=="number"&&(i=e),r.sqrt&&(s=r.sqrt);const{nBitLength:c,nByteLength:l}=qI(t,i);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:t,isLE:n,BITS:c,BYTES:l,MASK:Xl(c),ZERO:Ur,ONE:tr,allowedLengths:a,create:f=>Dn(f,t),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Ur<=f&&f<t},is0:f=>f===Ur,isValidNot0:f=>!d.is0(f)&&d.isValid(f),isOdd:f=>(f&tr)===tr,neg:f=>Dn(-f,t),eql:(f,g)=>f===g,sqr:f=>Dn(f*f,t),add:(f,g)=>Dn(f+g,t),sub:(f,g)=>Dn(f-g,t),mul:(f,g)=>Dn(f*g,t),pow:(f,g)=>JK(d,f,g),div:(f,g)=>Dn(f*Nb(g,t),t),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Nb(f,t),sqrt:s||(f=>(u||(u=qK(t)),u(d,f))),toBytes:f=>n?LI(f,l):Ry(f,l),fromBytes:(f,g=!0)=>{if(a){if(!a.includes(f.length)||f.length>l)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);const w=new Uint8Array(l);w.set(f,n?0:w.length-f.length),f=w}if(f.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+f.length);let v=n?kl(f):sh(f);if(o&&(v=Dn(v,t)),!g&&!d.isValid(v))throw new Error("invalid field element: outside of range 0..ORDER");return v},invertBatch:f=>zI(d,f),cmov:(f,g,v)=>v?g:f});return Object.freeze(d)}function WI(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function GI(t){const e=WI(t);return e+Math.ceil(e/2)}function ZK(t,e,n=!1){const r=t.length,i=WI(e),s=GI(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const o=n?kl(t):sh(t),a=Dn(o,e-tr)+tr;return n?LI(a,i):Ry(a,i)}const lc=BigInt(0),Ko=BigInt(1);function pf(t,e){const n=e.negate();return t?n:e}function Vo(t,e){const n=zI(t.Fp,e.map(r=>r.Z));return e.map((r,i)=>t.fromAffine(r.toAffine(n[i])))}function YI(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function jp(t,e){YI(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),i=2**t,s=Xl(t),o=BigInt(t);return{windows:n,windowSize:r,mask:s,maxNumber:i,shiftBy:o}}function Mb(t,e,n){const{windowSize:r,mask:i,maxNumber:s,shiftBy:o}=n;let a=Number(t&i),c=t>>o;a>r&&(a-=s,c+=Ko);const l=e*r,u=l+Math.abs(a)-1,d=a===0,f=a<0,g=e%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:g,offsetF:l}}function XK(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function QK(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Hp=new WeakMap,JI=new WeakMap;function zp(t){return JI.get(t)||1}function kb(t){if(t!==lc)throw new Error("invalid wNAF")}class ZI{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let i=e;for(;n>lc;)n&Ko&&(r=r.add(i)),i=i.double(),n>>=Ko;return r}precomputeWindow(e,n){const{windows:r,windowSize:i}=jp(n,this.bits),s=[];let o=e,a=o;for(let c=0;c<r;c++){a=o,s.push(a);for(let l=1;l<i;l++)a=a.add(o),s.push(a);o=a.double()}return s}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let i=this.ZERO,s=this.BASE;const o=jp(e,this.bits);for(let a=0;a<o.windows;a++){const{nextN:c,offset:l,isZero:u,isNeg:d,isNegF:f,offsetF:g}=Mb(r,a,o);r=c,u?s=s.add(pf(f,n[g])):i=i.add(pf(d,n[l]))}return kb(r),{p:i,f:s}}wNAFUnsafe(e,n,r,i=this.ZERO){const s=jp(e,this.bits);for(let o=0;o<s.windows&&r!==lc;o++){const{nextN:a,offset:c,isZero:l,isNeg:u}=Mb(r,o,s);if(r=a,!l){const d=n[c];i=i.add(u?d.negate():d)}}return kb(r),i}getPrecomputes(e,n,r){let i=Hp.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(i=r(i)),Hp.set(n,i))),i}cached(e,n,r){const i=zp(e);return this.wNAF(i,this.getPrecomputes(i,e,r),n)}unsafe(e,n,r,i){const s=zp(e);return s===1?this._unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,r),n,i)}createCache(e,n){YI(n,this.bits),JI.set(e,n),Hp.delete(e)}hasCache(e){return zp(e)!==1}}function eV(t,e,n,r){let i=e,s=t.ZERO,o=t.ZERO;for(;n>lc||r>lc;)n&Ko&&(s=s.add(i)),r&Ko&&(o=o.add(i)),i=i.double(),n>>=Ko,r>>=Ko;return{p1:s,p2:o}}function XI(t,e,n,r){XK(n,t),QK(r,e);const i=n.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=BI(BigInt(i));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=Xl(c),u=new Array(Number(l)+1).fill(o),d=Math.floor((e.BITS-1)/c)*c;let f=o;for(let g=d;g>=0;g-=c){u.fill(o);for(let w=0;w<s;w++){const b=r[w],E=Number(b>>BigInt(g)&l);u[E]=u[E].add(n[w])}let v=o;for(let w=u.length-1,b=o;w>0;w--)b=b.add(u[w]),v=v.add(b);if(f=f.add(v),g!==0)for(let w=0;w<c;w++)f=f.double()}return f}function Db(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return YK(e),e}else return ca(t,{isLE:n})}function QI(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const l=e[c];if(!(typeof l=="bigint"&&l>lc))throw new Error(`CURVE.${c} must be positive bigint`)}const i=Db(e.p,n.Fp,r),s=Db(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const c of a)if(!i.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:s}}const js=BigInt(0),jn=BigInt(1),qp=BigInt(2),tV=BigInt(8);function nV(t,e,n,r){const i=t.sqr(n),s=t.sqr(r),o=t.add(t.mul(e.a,i),s),a=t.add(t.ONE,t.mul(e.d,t.mul(i,s)));return t.eql(o,a)}function rV(t,e={}){const n=QI("edwards",t,e,e.FpFnLE),{Fp:r,Fn:i}=n;let s=n.CURVE;const{h:o}=s;Ql(e,{},{uvRatio:"function"});const a=qp<<BigInt(i.BYTES*8)-jn,c=b=>r.create(b),l=e.uvRatio||((b,E)=>{try{return{isValid:!0,value:r.sqrt(r.div(b,E))}}catch{return{isValid:!1,value:js}}});if(!nV(r,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function u(b,E,M=!1){const S=M?jn:js;return Mm("coordinate "+b,E,S,a),E}function d(b){if(!(b instanceof v))throw new Error("ExtendedPoint expected")}const f=hf((b,E)=>{const{X:M,Y:S,Z:F}=b,D=b.is0();E==null&&(E=D?tV:r.inv(F));const z=c(M*E),X=c(S*E),Y=r.mul(F,E);if(D)return{x:js,y:jn};if(Y!==jn)throw new Error("invZ was invalid");return{x:z,y:X}}),g=hf(b=>{const{a:E,d:M}=s;if(b.is0())throw new Error("bad point: ZERO");const{X:S,Y:F,Z:D,T:z}=b,X=c(S*S),Y=c(F*F),U=c(D*D),B=c(U*U),H=c(X*E),V=c(U*c(H+Y)),T=c(B+c(M*c(X*Y)));if(V!==T)throw new Error("bad point: equation left != right (1)");const p=c(S*F),y=c(D*z);if(p!==y)throw new Error("bad point: equation left != right (2)");return!0});class v{constructor(E,M,S,F){this.X=u("x",E),this.Y=u("y",M),this.Z=u("z",S,!0),this.T=u("t",F),Object.freeze(this)}static CURVE(){return s}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");const{x:M,y:S}=E||{};return u("x",M),u("y",S),new v(M,S,jn,c(M*S))}static fromBytes(E,M=!1){const S=r.BYTES,{a:F,d:D}=s;E=Ob(Si(E,S,"point")),ta(M,"zip215");const z=Ob(E),X=E[S-1];z[S-1]=X&-129;const Y=kl(z),U=M?a:r.ORDER;Mm("point.y",Y,js,U);const B=c(Y*Y),H=c(B-jn),V=c(D*B-F);let{isValid:T,value:p}=l(H,V);if(!T)throw new Error("bad point: invalid y coordinate");const y=(p&jn)===jn,R=(X&128)!==0;if(!M&&p===js&&R)throw new Error("bad point: x=0 and x_0=1");return R!==y&&(p=c(-p)),v.fromAffine({x:p,y:Y})}static fromHex(E,M=!1){return v.fromBytes(Rn("point",E),M)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=8,M=!0){return w.createCache(this,E),M||this.multiply(qp),this}assertValidity(){g(this)}equals(E){d(E);const{X:M,Y:S,Z:F}=this,{X:D,Y:z,Z:X}=E,Y=c(M*X),U=c(D*F),B=c(S*X),H=c(z*F);return Y===U&&B===H}is0(){return this.equals(v.ZERO)}negate(){return new v(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:E}=s,{X:M,Y:S,Z:F}=this,D=c(M*M),z=c(S*S),X=c(qp*c(F*F)),Y=c(E*D),U=M+S,B=c(c(U*U)-D-z),H=Y+z,V=H-X,T=Y-z,p=c(B*V),y=c(H*T),R=c(B*T),P=c(V*H);return new v(p,y,P,R)}add(E){d(E);const{a:M,d:S}=s,{X:F,Y:D,Z:z,T:X}=this,{X:Y,Y:U,Z:B,T:H}=E,V=c(F*Y),T=c(D*U),p=c(X*S*H),y=c(z*B),R=c((F+D)*(Y+U)-V-T),P=y-p,_=y+p,I=c(T-M*V),N=c(R*P),x=c(_*I),h=c(R*I),m=c(P*_);return new v(N,x,m,h)}subtract(E){return this.add(E.negate())}multiply(E){if(!i.isValidNot0(E))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:M,f:S}=w.cached(this,E,F=>Vo(v,F));return Vo(v,[M,S])[0]}multiplyUnsafe(E,M=v.ZERO){if(!i.isValid(E))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return E===js?v.ZERO:this.is0()||E===jn?this:w.unsafe(this,E,S=>Vo(v,S),M)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return w.unsafe(this,s.n).is0()}toAffine(E){return f(this,E)}clearCofactor(){return o===jn?this:this.multiplyUnsafe(o)}toBytes(){const{x:E,y:M}=this.toAffine(),S=r.toBytes(M);return S[S.length-1]|=E&jn?128:0,S}toHex(){return Go(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(E){return Vo(v,E)}static msm(E,M){return XI(v,i,E,M)}_setWindowSize(E){this.precompute(E)}toRawBytes(){return this.toBytes()}}v.BASE=new v(s.Gx,s.Gy,jn,c(s.Gx*s.Gy)),v.ZERO=new v(js,jn,jn,js),v.Fp=r,v.Fn=i;const w=new ZI(v,i.BITS);return v.BASE.precompute(8),v}function iV(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');Ql(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:s,Fn:o}=t,a=n.randomBytes||xy,c=n.adjustScalarBytes||(U=>U),l=n.domain||((U,B,H)=>{if(ta(H,"phflag"),B.length||H)throw new Error("Contexts/pre-hash are not supported");return U});function u(U){return o.create(kl(U))}function d(U){const B=S.secretKey;U=Rn("private key",U,B);const H=Rn("hashed private key",e(U),2*B),V=c(H.slice(0,B)),T=H.slice(B,2*B),p=u(V);return{head:V,prefix:T,scalar:p}}function f(U){const{head:B,prefix:H,scalar:V}=d(U),T=i.multiply(V),p=T.toBytes();return{head:B,prefix:H,scalar:V,point:T,pointBytes:p}}function g(U){return f(U).pointBytes}function v(U=Uint8Array.of(),...B){const H=Ki(...B);return u(e(l(H,Rn("context",U),!!r)))}function w(U,B,H={}){U=Rn("message",U),r&&(U=r(U));const{prefix:V,scalar:T,pointBytes:p}=f(B),y=v(H.context,V,U),R=i.multiply(y).toBytes(),P=v(H.context,R,p,U),_=o.create(y+P*T);if(!o.isValid(_))throw new Error("sign failed: invalid s");const I=Ki(R,o.toBytes(_));return Si(I,S.signature,"result")}const b={zip215:!0};function E(U,B,H,V=b){const{context:T,zip215:p}=V,y=S.signature;U=Rn("signature",U,y),B=Rn("message",B),H=Rn("publicKey",H,S.publicKey),p!==void 0&&ta(p,"zip215"),r&&(B=r(B));const R=y/2,P=U.subarray(0,R),_=kl(U.subarray(R,y));let I,N,x;try{I=t.fromBytes(H,p),N=t.fromBytes(P,p),x=i.multiplyUnsafe(_)}catch{return!1}if(!p&&I.isSmallOrder())return!1;const h=v(T,N.toBytes(),I.toBytes(),B);return N.add(I.multiplyUnsafe(h)).subtract(x).clearCofactor().is0()}const M=s.BYTES,S={secretKey:M,publicKey:M,signature:2*M,seed:M};function F(U=a(S.seed)){return Si(U,S.seed,"seed")}function D(U){const B=Y.randomSecretKey(U);return{secretKey:B,publicKey:g(B)}}function z(U){return Zl(U)&&U.length===o.BYTES}function X(U,B){try{return!!t.fromBytes(U,B)}catch{return!1}}const Y={getExtendedPublicKey:f,randomSecretKey:F,isValidSecretKey:z,isValidPublicKey:X,toMontgomery(U){const{y:B}=t.fromBytes(U),H=S.publicKey,V=H===32;if(!V&&H!==57)throw new Error("only defined for 25519 and 448");const T=V?s.div(jn+B,jn-B):s.div(B-jn,B+jn);return s.toBytes(T)},toMontgomerySecret(U){const B=S.secretKey;Si(U,B);const H=e(U.subarray(0,B));return c(H).subarray(0,B)},randomPrivateKey:F,precompute(U=8,B=t.BASE){return B.precompute(U,!1)}};return Object.freeze({keygen:D,getPublicKey:g,sign:w,verify:E,utils:Y,Point:t,lengths:S})}function sV(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp,r=ca(e.n,t.nBitLength,!0),i={Fp:n,Fn:r,uvRatio:t.uvRatio},s={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:i,hash:t.hash,eddsaOpts:s}}function oV(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function aV(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:i}=sV(t),s=rV(e,n),o=iV(s,r,i);return oV(t,o)}const cV=BigInt(1),Lb=BigInt(2);BigInt(3);const lV=BigInt(5),uV=BigInt(8),Ty=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),eT={p:Ty,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:uV,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function dV(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),s=Ty,a=t*t%s*t%s,c=An(a,Lb,s)*a%s,l=An(c,cV,s)*t%s,u=An(l,lV,s)*l%s,d=An(u,e,s)*u%s,f=An(d,n,s)*d%s,g=An(f,r,s)*f%s,v=An(g,i,s)*g%s,w=An(v,i,s)*g%s,b=An(w,e,s)*u%s;return{pow_p_5_8:An(b,Lb,s)*t%s,b2:a}}function fV(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Bb=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function hV(t,e){const n=Ty,r=Dn(e*e*e,n),i=Dn(r*r*e,n),s=dV(t*i).pow_p_5_8;let o=Dn(t*r*s,n);const a=Dn(e*o*o,n),c=o,l=Dn(o*Bb,n),u=a===t,d=a===Dn(-t,n),f=a===Dn(-t*Bb,n);return u&&(o=c),(d||f)&&(o=l),WK(o,n)&&(o=Dn(-o,n)),{isValid:u||d,value:o}}const pV=ca(eT.p,{isLE:!0}),mV={...eT,Fp:pV,hash:$K,adjustScalarBytes:fV,uvRatio:hV},eu=aV(mV);var Ad={exports:{}},gV=Ad.exports,Ub;function tT(){return Ub||(Ub=1,(function(t){(function(e,n){function r(T,p){if(!T)throw new Error(p||"Assertion failed")}function i(T,p){T.super_=p;var y=function(){};y.prototype=p.prototype,T.prototype=new y,T.prototype.constructor=T}function s(T,p,y){if(s.isBN(T))return T;this.negative=0,this.words=null,this.length=0,this.red=null,T!==null&&((p==="le"||p==="be")&&(y=p,p=10),this._init(T||0,p||10,y||"be"))}typeof e=="object"?e.exports=s:n.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=MR.Buffer}catch{}s.isBN=function(p){return p instanceof s?!0:p!==null&&typeof p=="object"&&p.constructor.wordSize===s.wordSize&&Array.isArray(p.words)},s.max=function(p,y){return p.cmp(y)>0?p:y},s.min=function(p,y){return p.cmp(y)<0?p:y},s.prototype._init=function(p,y,R){if(typeof p=="number")return this._initNumber(p,y,R);if(typeof p=="object")return this._initArray(p,y,R);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),p=p.toString().replace(/\s+/g,"");var P=0;p[0]==="-"&&(P++,this.negative=1),P<p.length&&(y===16?this._parseHex(p,P,R):(this._parseBase(p,y,P),R==="le"&&this._initArray(this.toArray(),y,R)))},s.prototype._initNumber=function(p,y,R){p<0&&(this.negative=1,p=-p),p<67108864?(this.words=[p&67108863],this.length=1):p<4503599627370496?(this.words=[p&67108863,p/67108864&67108863],this.length=2):(r(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),R==="le"&&this._initArray(this.toArray(),y,R)},s.prototype._initArray=function(p,y,R){if(r(typeof p.length=="number"),p.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(p.length/3),this.words=new Array(this.length);for(var P=0;P<this.length;P++)this.words[P]=0;var _,I,N=0;if(R==="be")for(P=p.length-1,_=0;P>=0;P-=3)I=p[P]|p[P-1]<<8|p[P-2]<<16,this.words[_]|=I<<N&67108863,this.words[_+1]=I>>>26-N&67108863,N+=24,N>=26&&(N-=26,_++);else if(R==="le")for(P=0,_=0;P<p.length;P+=3)I=p[P]|p[P+1]<<8|p[P+2]<<16,this.words[_]|=I<<N&67108863,this.words[_+1]=I>>>26-N&67108863,N+=24,N>=26&&(N-=26,_++);return this._strip()};function a(T,p){var y=T.charCodeAt(p);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+T)}function c(T,p,y){var R=a(T,y);return y-1>=p&&(R|=a(T,y-1)<<4),R}s.prototype._parseHex=function(p,y,R){this.length=Math.ceil((p.length-y)/6),this.words=new Array(this.length);for(var P=0;P<this.length;P++)this.words[P]=0;var _=0,I=0,N;if(R==="be")for(P=p.length-1;P>=y;P-=2)N=c(p,y,P)<<_,this.words[I]|=N&67108863,_>=18?(_-=18,I+=1,this.words[I]|=N>>>26):_+=8;else{var x=p.length-y;for(P=x%2===0?y+1:y;P<p.length;P+=2)N=c(p,y,P)<<_,this.words[I]|=N&67108863,_>=18?(_-=18,I+=1,this.words[I]|=N>>>26):_+=8}this._strip()};function l(T,p,y,R){for(var P=0,_=0,I=Math.min(T.length,y),N=p;N<I;N++){var x=T.charCodeAt(N)-48;P*=R,x>=49?_=x-49+10:x>=17?_=x-17+10:_=x,r(x>=0&&_<R,"Invalid character"),P+=_}return P}s.prototype._parseBase=function(p,y,R){this.words=[0],this.length=1;for(var P=0,_=1;_<=67108863;_*=y)P++;P--,_=_/y|0;for(var I=p.length-R,N=I%P,x=Math.min(I,I-N)+R,h=0,m=R;m<x;m+=P)h=l(p,m,m+P,y),this.imuln(_),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(N!==0){var A=1;for(h=l(p,m,p.length,y),m=0;m<N;m++)A*=y;this.imuln(A),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this._strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var y=0;y<this.length;y++)p.words[y]=this.words[y];p.length=this.length,p.negative=this.negative,p.red=this.red};function u(T,p){T.words=p.words,T.length=p.length,T.negative=p.negative,T.red=p.red}if(s.prototype._move=function(p){u(p,this)},s.prototype.clone=function(){var p=new s(null);return this.copy(p),p},s.prototype._expand=function(p){for(;this.length<p;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=d}catch{s.prototype.inspect=d}else s.prototype.inspect=d;function d(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(p,y){p=p||10,y=y|0||1;var R;if(p===16||p==="hex"){R="";for(var P=0,_=0,I=0;I<this.length;I++){var N=this.words[I],x=((N<<P|_)&16777215).toString(16);_=N>>>24-P&16777215,P+=2,P>=26&&(P-=26,I--),_!==0||I!==this.length-1?R=f[6-x.length]+x+R:R=x+R}for(_!==0&&(R=_.toString(16)+R);R.length%y!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}if(p===(p|0)&&p>=2&&p<=36){var h=g[p],m=v[p];R="";var A=this.clone();for(A.negative=0;!A.isZero();){var C=A.modrn(m).toString(p);A=A.idivn(m),A.isZero()?R=C+R:R=f[h-C.length]+C+R}for(this.isZero()&&(R="0"+R);R.length%y!==0;)R="0"+R;return this.negative!==0&&(R="-"+R),R}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var p=this.words[0];return this.length===2?p+=this.words[1]*67108864:this.length===3&&this.words[2]===1?p+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(p,y){return this.toArrayLike(o,p,y)}),s.prototype.toArray=function(p,y){return this.toArrayLike(Array,p,y)};var w=function(p,y){return p.allocUnsafe?p.allocUnsafe(y):new p(y)};s.prototype.toArrayLike=function(p,y,R){this._strip();var P=this.byteLength(),_=R||Math.max(1,P);r(P<=_,"byte array longer than desired length"),r(_>0,"Requested array length <= 0");var I=w(p,_),N=y==="le"?"LE":"BE";return this["_toArrayLike"+N](I,P),I},s.prototype._toArrayLikeLE=function(p,y){for(var R=0,P=0,_=0,I=0;_<this.length;_++){var N=this.words[_]<<I|P;p[R++]=N&255,R<p.length&&(p[R++]=N>>8&255),R<p.length&&(p[R++]=N>>16&255),I===6?(R<p.length&&(p[R++]=N>>24&255),P=0,I=0):(P=N>>>24,I+=2)}if(R<p.length)for(p[R++]=P;R<p.length;)p[R++]=0},s.prototype._toArrayLikeBE=function(p,y){for(var R=p.length-1,P=0,_=0,I=0;_<this.length;_++){var N=this.words[_]<<I|P;p[R--]=N&255,R>=0&&(p[R--]=N>>8&255),R>=0&&(p[R--]=N>>16&255),I===6?(R>=0&&(p[R--]=N>>24&255),P=0,I=0):(P=N>>>24,I+=2)}if(R>=0)for(p[R--]=P;R>=0;)p[R--]=0},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var y=p,R=0;return y>=4096&&(R+=13,y>>>=13),y>=64&&(R+=7,y>>>=7),y>=8&&(R+=4,y>>>=4),y>=2&&(R+=2,y>>>=2),R+y},s.prototype._zeroBits=function(p){if(p===0)return 26;var y=p,R=0;return(y&8191)===0&&(R+=13,y>>>=13),(y&127)===0&&(R+=7,y>>>=7),(y&15)===0&&(R+=4,y>>>=4),(y&3)===0&&(R+=2,y>>>=2),(y&1)===0&&R++,R},s.prototype.bitLength=function(){var p=this.words[this.length-1],y=this._countBits(p);return(this.length-1)*26+y};function b(T){for(var p=new Array(T.bitLength()),y=0;y<p.length;y++){var R=y/26|0,P=y%26;p[y]=T.words[R]>>>P&1}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,y=0;y<this.length;y++){var R=this._zeroBits(this.words[y]);if(p+=R,R!==26)break}return p},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(p){return this.negative!==0?this.abs().inotn(p).iaddn(1):this.clone()},s.prototype.fromTwos=function(p){return this.testn(p-1)?this.notn(p).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(p){for(;this.length<p.length;)this.words[this.length++]=0;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]|p.words[y];return this._strip()},s.prototype.ior=function(p){return r((this.negative|p.negative)===0),this.iuor(p)},s.prototype.or=function(p){return this.length>p.length?this.clone().ior(p):p.clone().ior(this)},s.prototype.uor=function(p){return this.length>p.length?this.clone().iuor(p):p.clone().iuor(this)},s.prototype.iuand=function(p){var y;this.length>p.length?y=p:y=this;for(var R=0;R<y.length;R++)this.words[R]=this.words[R]&p.words[R];return this.length=y.length,this._strip()},s.prototype.iand=function(p){return r((this.negative|p.negative)===0),this.iuand(p)},s.prototype.and=function(p){return this.length>p.length?this.clone().iand(p):p.clone().iand(this)},s.prototype.uand=function(p){return this.length>p.length?this.clone().iuand(p):p.clone().iuand(this)},s.prototype.iuxor=function(p){var y,R;this.length>p.length?(y=this,R=p):(y=p,R=this);for(var P=0;P<R.length;P++)this.words[P]=y.words[P]^R.words[P];if(this!==y)for(;P<y.length;P++)this.words[P]=y.words[P];return this.length=y.length,this._strip()},s.prototype.ixor=function(p){return r((this.negative|p.negative)===0),this.iuxor(p)},s.prototype.xor=function(p){return this.length>p.length?this.clone().ixor(p):p.clone().ixor(this)},s.prototype.uxor=function(p){return this.length>p.length?this.clone().iuxor(p):p.clone().iuxor(this)},s.prototype.inotn=function(p){r(typeof p=="number"&&p>=0);var y=Math.ceil(p/26)|0,R=p%26;this._expand(y),R>0&&y--;for(var P=0;P<y;P++)this.words[P]=~this.words[P]&67108863;return R>0&&(this.words[P]=~this.words[P]&67108863>>26-R),this._strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,y){r(typeof p=="number"&&p>=0);var R=p/26|0,P=p%26;return this._expand(R+1),y?this.words[R]=this.words[R]|1<<P:this.words[R]=this.words[R]&~(1<<P),this._strip()},s.prototype.iadd=function(p){var y;if(this.negative!==0&&p.negative===0)return this.negative=0,y=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,y=this.isub(p),p.negative=1,y._normSign();var R,P;this.length>p.length?(R=this,P=p):(R=p,P=this);for(var _=0,I=0;I<P.length;I++)y=(R.words[I]|0)+(P.words[I]|0)+_,this.words[I]=y&67108863,_=y>>>26;for(;_!==0&&I<R.length;I++)y=(R.words[I]|0)+_,this.words[I]=y&67108863,_=y>>>26;if(this.length=R.length,_!==0)this.words[this.length]=_,this.length++;else if(R!==this)for(;I<R.length;I++)this.words[I]=R.words[I];return this},s.prototype.add=function(p){var y;return p.negative!==0&&this.negative===0?(p.negative=0,y=this.sub(p),p.negative^=1,y):p.negative===0&&this.negative!==0?(this.negative=0,y=p.sub(this),this.negative=1,y):this.length>p.length?this.clone().iadd(p):p.clone().iadd(this)},s.prototype.isub=function(p){if(p.negative!==0){p.negative=0;var y=this.iadd(p);return p.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var R=this.cmp(p);if(R===0)return this.negative=0,this.length=1,this.words[0]=0,this;var P,_;R>0?(P=this,_=p):(P=p,_=this);for(var I=0,N=0;N<_.length;N++)y=(P.words[N]|0)-(_.words[N]|0)+I,I=y>>26,this.words[N]=y&67108863;for(;I!==0&&N<P.length;N++)y=(P.words[N]|0)+I,I=y>>26,this.words[N]=y&67108863;if(I===0&&N<P.length&&P!==this)for(;N<P.length;N++)this.words[N]=P.words[N];return this.length=Math.max(this.length,N),P!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function E(T,p,y){y.negative=p.negative^T.negative;var R=T.length+p.length|0;y.length=R,R=R-1|0;var P=T.words[0]|0,_=p.words[0]|0,I=P*_,N=I&67108863,x=I/67108864|0;y.words[0]=N;for(var h=1;h<R;h++){for(var m=x>>>26,A=x&67108863,C=Math.min(h,p.length-1),$=Math.max(0,h-T.length+1);$<=C;$++){var j=h-$|0;P=T.words[j]|0,_=p.words[$]|0,I=P*_+A,m+=I/67108864|0,A=I&67108863}y.words[h]=A|0,x=m|0}return x!==0?y.words[h]=x|0:y.length--,y._strip()}var M=function(p,y,R){var P=p.words,_=y.words,I=R.words,N=0,x,h,m,A=P[0]|0,C=A&8191,$=A>>>13,j=P[1]|0,Z=j&8191,ne=j>>>13,se=P[2]|0,ue=se&8191,de=se>>>13,Ae=P[3]|0,Ce=Ae&8191,Ue=Ae>>>13,Be=P[4]|0,Oe=Be&8191,Le=Be>>>13,je=P[5]|0,$e=je&8191,Je=je>>>13,He=P[6]|0,Ke=He&8191,Ge=He>>>13,Dt=P[7]|0,_t=Dt&8191,q=Dt>>>13,k=P[8]|0,L=k&8191,Q=k>>>13,oe=P[9]|0,le=oe&8191,we=oe>>>13,wt=_[0]|0,ut=wt&8191,at=wt>>>13,Gt=_[1]|0,ot=Gt&8191,tn=Gt>>>13,fa=_[2]|0,fn=fa&8191,wn=fa>>>13,iu=_[3]|0,Yt=iu&8191,nn=iu>>>13,ts=_[4]|0,ln=ts&8191,un=ts>>>13,Cc=_[5]|0,vn=Cc&8191,Kt=Cc>>>13,Oc=_[6]|0,K=Oc&8191,W=Oc>>>13,G=_[7]|0,O=G&8191,J=G>>>13,ce=_[8]|0,ae=ce&8191,Ee=ce>>>13,ke=_[9]|0,Ve=ke&8191,De=ke>>>13;R.negative=p.negative^y.negative,R.length=19,x=Math.imul(C,ut),h=Math.imul(C,at),h=h+Math.imul($,ut)|0,m=Math.imul($,at);var Ut=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,x=Math.imul(Z,ut),h=Math.imul(Z,at),h=h+Math.imul(ne,ut)|0,m=Math.imul(ne,at),x=x+Math.imul(C,ot)|0,h=h+Math.imul(C,tn)|0,h=h+Math.imul($,ot)|0,m=m+Math.imul($,tn)|0;var We=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(We>>>26)|0,We&=67108863,x=Math.imul(ue,ut),h=Math.imul(ue,at),h=h+Math.imul(de,ut)|0,m=Math.imul(de,at),x=x+Math.imul(Z,ot)|0,h=h+Math.imul(Z,tn)|0,h=h+Math.imul(ne,ot)|0,m=m+Math.imul(ne,tn)|0,x=x+Math.imul(C,fn)|0,h=h+Math.imul(C,wn)|0,h=h+Math.imul($,fn)|0,m=m+Math.imul($,wn)|0;var ft=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(ft>>>26)|0,ft&=67108863,x=Math.imul(Ce,ut),h=Math.imul(Ce,at),h=h+Math.imul(Ue,ut)|0,m=Math.imul(Ue,at),x=x+Math.imul(ue,ot)|0,h=h+Math.imul(ue,tn)|0,h=h+Math.imul(de,ot)|0,m=m+Math.imul(de,tn)|0,x=x+Math.imul(Z,fn)|0,h=h+Math.imul(Z,wn)|0,h=h+Math.imul(ne,fn)|0,m=m+Math.imul(ne,wn)|0,x=x+Math.imul(C,Yt)|0,h=h+Math.imul(C,nn)|0,h=h+Math.imul($,Yt)|0,m=m+Math.imul($,nn)|0;var ht=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(ht>>>26)|0,ht&=67108863,x=Math.imul(Oe,ut),h=Math.imul(Oe,at),h=h+Math.imul(Le,ut)|0,m=Math.imul(Le,at),x=x+Math.imul(Ce,ot)|0,h=h+Math.imul(Ce,tn)|0,h=h+Math.imul(Ue,ot)|0,m=m+Math.imul(Ue,tn)|0,x=x+Math.imul(ue,fn)|0,h=h+Math.imul(ue,wn)|0,h=h+Math.imul(de,fn)|0,m=m+Math.imul(de,wn)|0,x=x+Math.imul(Z,Yt)|0,h=h+Math.imul(Z,nn)|0,h=h+Math.imul(ne,Yt)|0,m=m+Math.imul(ne,nn)|0,x=x+Math.imul(C,ln)|0,h=h+Math.imul(C,un)|0,h=h+Math.imul($,ln)|0,m=m+Math.imul($,un)|0;var St=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(St>>>26)|0,St&=67108863,x=Math.imul($e,ut),h=Math.imul($e,at),h=h+Math.imul(Je,ut)|0,m=Math.imul(Je,at),x=x+Math.imul(Oe,ot)|0,h=h+Math.imul(Oe,tn)|0,h=h+Math.imul(Le,ot)|0,m=m+Math.imul(Le,tn)|0,x=x+Math.imul(Ce,fn)|0,h=h+Math.imul(Ce,wn)|0,h=h+Math.imul(Ue,fn)|0,m=m+Math.imul(Ue,wn)|0,x=x+Math.imul(ue,Yt)|0,h=h+Math.imul(ue,nn)|0,h=h+Math.imul(de,Yt)|0,m=m+Math.imul(de,nn)|0,x=x+Math.imul(Z,ln)|0,h=h+Math.imul(Z,un)|0,h=h+Math.imul(ne,ln)|0,m=m+Math.imul(ne,un)|0,x=x+Math.imul(C,vn)|0,h=h+Math.imul(C,Kt)|0,h=h+Math.imul($,vn)|0,m=m+Math.imul($,Kt)|0;var bt=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(bt>>>26)|0,bt&=67108863,x=Math.imul(Ke,ut),h=Math.imul(Ke,at),h=h+Math.imul(Ge,ut)|0,m=Math.imul(Ge,at),x=x+Math.imul($e,ot)|0,h=h+Math.imul($e,tn)|0,h=h+Math.imul(Je,ot)|0,m=m+Math.imul(Je,tn)|0,x=x+Math.imul(Oe,fn)|0,h=h+Math.imul(Oe,wn)|0,h=h+Math.imul(Le,fn)|0,m=m+Math.imul(Le,wn)|0,x=x+Math.imul(Ce,Yt)|0,h=h+Math.imul(Ce,nn)|0,h=h+Math.imul(Ue,Yt)|0,m=m+Math.imul(Ue,nn)|0,x=x+Math.imul(ue,ln)|0,h=h+Math.imul(ue,un)|0,h=h+Math.imul(de,ln)|0,m=m+Math.imul(de,un)|0,x=x+Math.imul(Z,vn)|0,h=h+Math.imul(Z,Kt)|0,h=h+Math.imul(ne,vn)|0,m=m+Math.imul(ne,Kt)|0,x=x+Math.imul(C,K)|0,h=h+Math.imul(C,W)|0,h=h+Math.imul($,K)|0,m=m+Math.imul($,W)|0;var pt=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(pt>>>26)|0,pt&=67108863,x=Math.imul(_t,ut),h=Math.imul(_t,at),h=h+Math.imul(q,ut)|0,m=Math.imul(q,at),x=x+Math.imul(Ke,ot)|0,h=h+Math.imul(Ke,tn)|0,h=h+Math.imul(Ge,ot)|0,m=m+Math.imul(Ge,tn)|0,x=x+Math.imul($e,fn)|0,h=h+Math.imul($e,wn)|0,h=h+Math.imul(Je,fn)|0,m=m+Math.imul(Je,wn)|0,x=x+Math.imul(Oe,Yt)|0,h=h+Math.imul(Oe,nn)|0,h=h+Math.imul(Le,Yt)|0,m=m+Math.imul(Le,nn)|0,x=x+Math.imul(Ce,ln)|0,h=h+Math.imul(Ce,un)|0,h=h+Math.imul(Ue,ln)|0,m=m+Math.imul(Ue,un)|0,x=x+Math.imul(ue,vn)|0,h=h+Math.imul(ue,Kt)|0,h=h+Math.imul(de,vn)|0,m=m+Math.imul(de,Kt)|0,x=x+Math.imul(Z,K)|0,h=h+Math.imul(Z,W)|0,h=h+Math.imul(ne,K)|0,m=m+Math.imul(ne,W)|0,x=x+Math.imul(C,O)|0,h=h+Math.imul(C,J)|0,h=h+Math.imul($,O)|0,m=m+Math.imul($,J)|0;var gt=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(gt>>>26)|0,gt&=67108863,x=Math.imul(L,ut),h=Math.imul(L,at),h=h+Math.imul(Q,ut)|0,m=Math.imul(Q,at),x=x+Math.imul(_t,ot)|0,h=h+Math.imul(_t,tn)|0,h=h+Math.imul(q,ot)|0,m=m+Math.imul(q,tn)|0,x=x+Math.imul(Ke,fn)|0,h=h+Math.imul(Ke,wn)|0,h=h+Math.imul(Ge,fn)|0,m=m+Math.imul(Ge,wn)|0,x=x+Math.imul($e,Yt)|0,h=h+Math.imul($e,nn)|0,h=h+Math.imul(Je,Yt)|0,m=m+Math.imul(Je,nn)|0,x=x+Math.imul(Oe,ln)|0,h=h+Math.imul(Oe,un)|0,h=h+Math.imul(Le,ln)|0,m=m+Math.imul(Le,un)|0,x=x+Math.imul(Ce,vn)|0,h=h+Math.imul(Ce,Kt)|0,h=h+Math.imul(Ue,vn)|0,m=m+Math.imul(Ue,Kt)|0,x=x+Math.imul(ue,K)|0,h=h+Math.imul(ue,W)|0,h=h+Math.imul(de,K)|0,m=m+Math.imul(de,W)|0,x=x+Math.imul(Z,O)|0,h=h+Math.imul(Z,J)|0,h=h+Math.imul(ne,O)|0,m=m+Math.imul(ne,J)|0,x=x+Math.imul(C,ae)|0,h=h+Math.imul(C,Ee)|0,h=h+Math.imul($,ae)|0,m=m+Math.imul($,Ee)|0;var mt=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(mt>>>26)|0,mt&=67108863,x=Math.imul(le,ut),h=Math.imul(le,at),h=h+Math.imul(we,ut)|0,m=Math.imul(we,at),x=x+Math.imul(L,ot)|0,h=h+Math.imul(L,tn)|0,h=h+Math.imul(Q,ot)|0,m=m+Math.imul(Q,tn)|0,x=x+Math.imul(_t,fn)|0,h=h+Math.imul(_t,wn)|0,h=h+Math.imul(q,fn)|0,m=m+Math.imul(q,wn)|0,x=x+Math.imul(Ke,Yt)|0,h=h+Math.imul(Ke,nn)|0,h=h+Math.imul(Ge,Yt)|0,m=m+Math.imul(Ge,nn)|0,x=x+Math.imul($e,ln)|0,h=h+Math.imul($e,un)|0,h=h+Math.imul(Je,ln)|0,m=m+Math.imul(Je,un)|0,x=x+Math.imul(Oe,vn)|0,h=h+Math.imul(Oe,Kt)|0,h=h+Math.imul(Le,vn)|0,m=m+Math.imul(Le,Kt)|0,x=x+Math.imul(Ce,K)|0,h=h+Math.imul(Ce,W)|0,h=h+Math.imul(Ue,K)|0,m=m+Math.imul(Ue,W)|0,x=x+Math.imul(ue,O)|0,h=h+Math.imul(ue,J)|0,h=h+Math.imul(de,O)|0,m=m+Math.imul(de,J)|0,x=x+Math.imul(Z,ae)|0,h=h+Math.imul(Z,Ee)|0,h=h+Math.imul(ne,ae)|0,m=m+Math.imul(ne,Ee)|0,x=x+Math.imul(C,Ve)|0,h=h+Math.imul(C,De)|0,h=h+Math.imul($,Ve)|0,m=m+Math.imul($,De)|0;var Ze=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,x=Math.imul(le,ot),h=Math.imul(le,tn),h=h+Math.imul(we,ot)|0,m=Math.imul(we,tn),x=x+Math.imul(L,fn)|0,h=h+Math.imul(L,wn)|0,h=h+Math.imul(Q,fn)|0,m=m+Math.imul(Q,wn)|0,x=x+Math.imul(_t,Yt)|0,h=h+Math.imul(_t,nn)|0,h=h+Math.imul(q,Yt)|0,m=m+Math.imul(q,nn)|0,x=x+Math.imul(Ke,ln)|0,h=h+Math.imul(Ke,un)|0,h=h+Math.imul(Ge,ln)|0,m=m+Math.imul(Ge,un)|0,x=x+Math.imul($e,vn)|0,h=h+Math.imul($e,Kt)|0,h=h+Math.imul(Je,vn)|0,m=m+Math.imul(Je,Kt)|0,x=x+Math.imul(Oe,K)|0,h=h+Math.imul(Oe,W)|0,h=h+Math.imul(Le,K)|0,m=m+Math.imul(Le,W)|0,x=x+Math.imul(Ce,O)|0,h=h+Math.imul(Ce,J)|0,h=h+Math.imul(Ue,O)|0,m=m+Math.imul(Ue,J)|0,x=x+Math.imul(ue,ae)|0,h=h+Math.imul(ue,Ee)|0,h=h+Math.imul(de,ae)|0,m=m+Math.imul(de,Ee)|0,x=x+Math.imul(Z,Ve)|0,h=h+Math.imul(Z,De)|0,h=h+Math.imul(ne,Ve)|0,m=m+Math.imul(ne,De)|0;var st=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(st>>>26)|0,st&=67108863,x=Math.imul(le,fn),h=Math.imul(le,wn),h=h+Math.imul(we,fn)|0,m=Math.imul(we,wn),x=x+Math.imul(L,Yt)|0,h=h+Math.imul(L,nn)|0,h=h+Math.imul(Q,Yt)|0,m=m+Math.imul(Q,nn)|0,x=x+Math.imul(_t,ln)|0,h=h+Math.imul(_t,un)|0,h=h+Math.imul(q,ln)|0,m=m+Math.imul(q,un)|0,x=x+Math.imul(Ke,vn)|0,h=h+Math.imul(Ke,Kt)|0,h=h+Math.imul(Ge,vn)|0,m=m+Math.imul(Ge,Kt)|0,x=x+Math.imul($e,K)|0,h=h+Math.imul($e,W)|0,h=h+Math.imul(Je,K)|0,m=m+Math.imul(Je,W)|0,x=x+Math.imul(Oe,O)|0,h=h+Math.imul(Oe,J)|0,h=h+Math.imul(Le,O)|0,m=m+Math.imul(Le,J)|0,x=x+Math.imul(Ce,ae)|0,h=h+Math.imul(Ce,Ee)|0,h=h+Math.imul(Ue,ae)|0,m=m+Math.imul(Ue,Ee)|0,x=x+Math.imul(ue,Ve)|0,h=h+Math.imul(ue,De)|0,h=h+Math.imul(de,Ve)|0,m=m+Math.imul(de,De)|0;var qe=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(qe>>>26)|0,qe&=67108863,x=Math.imul(le,Yt),h=Math.imul(le,nn),h=h+Math.imul(we,Yt)|0,m=Math.imul(we,nn),x=x+Math.imul(L,ln)|0,h=h+Math.imul(L,un)|0,h=h+Math.imul(Q,ln)|0,m=m+Math.imul(Q,un)|0,x=x+Math.imul(_t,vn)|0,h=h+Math.imul(_t,Kt)|0,h=h+Math.imul(q,vn)|0,m=m+Math.imul(q,Kt)|0,x=x+Math.imul(Ke,K)|0,h=h+Math.imul(Ke,W)|0,h=h+Math.imul(Ge,K)|0,m=m+Math.imul(Ge,W)|0,x=x+Math.imul($e,O)|0,h=h+Math.imul($e,J)|0,h=h+Math.imul(Je,O)|0,m=m+Math.imul(Je,J)|0,x=x+Math.imul(Oe,ae)|0,h=h+Math.imul(Oe,Ee)|0,h=h+Math.imul(Le,ae)|0,m=m+Math.imul(Le,Ee)|0,x=x+Math.imul(Ce,Ve)|0,h=h+Math.imul(Ce,De)|0,h=h+Math.imul(Ue,Ve)|0,m=m+Math.imul(Ue,De)|0;var Qe=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(Qe>>>26)|0,Qe&=67108863,x=Math.imul(le,ln),h=Math.imul(le,un),h=h+Math.imul(we,ln)|0,m=Math.imul(we,un),x=x+Math.imul(L,vn)|0,h=h+Math.imul(L,Kt)|0,h=h+Math.imul(Q,vn)|0,m=m+Math.imul(Q,Kt)|0,x=x+Math.imul(_t,K)|0,h=h+Math.imul(_t,W)|0,h=h+Math.imul(q,K)|0,m=m+Math.imul(q,W)|0,x=x+Math.imul(Ke,O)|0,h=h+Math.imul(Ke,J)|0,h=h+Math.imul(Ge,O)|0,m=m+Math.imul(Ge,J)|0,x=x+Math.imul($e,ae)|0,h=h+Math.imul($e,Ee)|0,h=h+Math.imul(Je,ae)|0,m=m+Math.imul(Je,Ee)|0,x=x+Math.imul(Oe,Ve)|0,h=h+Math.imul(Oe,De)|0,h=h+Math.imul(Le,Ve)|0,m=m+Math.imul(Le,De)|0;var it=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(it>>>26)|0,it&=67108863,x=Math.imul(le,vn),h=Math.imul(le,Kt),h=h+Math.imul(we,vn)|0,m=Math.imul(we,Kt),x=x+Math.imul(L,K)|0,h=h+Math.imul(L,W)|0,h=h+Math.imul(Q,K)|0,m=m+Math.imul(Q,W)|0,x=x+Math.imul(_t,O)|0,h=h+Math.imul(_t,J)|0,h=h+Math.imul(q,O)|0,m=m+Math.imul(q,J)|0,x=x+Math.imul(Ke,ae)|0,h=h+Math.imul(Ke,Ee)|0,h=h+Math.imul(Ge,ae)|0,m=m+Math.imul(Ge,Ee)|0,x=x+Math.imul($e,Ve)|0,h=h+Math.imul($e,De)|0,h=h+Math.imul(Je,Ve)|0,m=m+Math.imul(Je,De)|0;var ze=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(ze>>>26)|0,ze&=67108863,x=Math.imul(le,K),h=Math.imul(le,W),h=h+Math.imul(we,K)|0,m=Math.imul(we,W),x=x+Math.imul(L,O)|0,h=h+Math.imul(L,J)|0,h=h+Math.imul(Q,O)|0,m=m+Math.imul(Q,J)|0,x=x+Math.imul(_t,ae)|0,h=h+Math.imul(_t,Ee)|0,h=h+Math.imul(q,ae)|0,m=m+Math.imul(q,Ee)|0,x=x+Math.imul(Ke,Ve)|0,h=h+Math.imul(Ke,De)|0,h=h+Math.imul(Ge,Ve)|0,m=m+Math.imul(Ge,De)|0;var me=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(me>>>26)|0,me&=67108863,x=Math.imul(le,O),h=Math.imul(le,J),h=h+Math.imul(we,O)|0,m=Math.imul(we,J),x=x+Math.imul(L,ae)|0,h=h+Math.imul(L,Ee)|0,h=h+Math.imul(Q,ae)|0,m=m+Math.imul(Q,Ee)|0,x=x+Math.imul(_t,Ve)|0,h=h+Math.imul(_t,De)|0,h=h+Math.imul(q,Ve)|0,m=m+Math.imul(q,De)|0;var ge=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(ge>>>26)|0,ge&=67108863,x=Math.imul(le,ae),h=Math.imul(le,Ee),h=h+Math.imul(we,ae)|0,m=Math.imul(we,Ee),x=x+Math.imul(L,Ve)|0,h=h+Math.imul(L,De)|0,h=h+Math.imul(Q,Ve)|0,m=m+Math.imul(Q,De)|0;var Ie=(N+x|0)+((h&8191)<<13)|0;N=(m+(h>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,x=Math.imul(le,Ve),h=Math.imul(le,De),h=h+Math.imul(we,Ve)|0,m=Math.imul(we,De);var xe=(N+x|0)+((h&8191)<<13)|0;return N=(m+(h>>>13)|0)+(xe>>>26)|0,xe&=67108863,I[0]=Ut,I[1]=We,I[2]=ft,I[3]=ht,I[4]=St,I[5]=bt,I[6]=pt,I[7]=gt,I[8]=mt,I[9]=Ze,I[10]=st,I[11]=qe,I[12]=Qe,I[13]=it,I[14]=ze,I[15]=me,I[16]=ge,I[17]=Ie,I[18]=xe,N!==0&&(I[19]=N,R.length++),R};Math.imul||(M=E);function S(T,p,y){y.negative=p.negative^T.negative,y.length=T.length+p.length;for(var R=0,P=0,_=0;_<y.length-1;_++){var I=P;P=0;for(var N=R&67108863,x=Math.min(_,p.length-1),h=Math.max(0,_-T.length+1);h<=x;h++){var m=_-h,A=T.words[m]|0,C=p.words[h]|0,$=A*C,j=$&67108863;I=I+($/67108864|0)|0,j=j+N|0,N=j&67108863,I=I+(j>>>26)|0,P+=I>>>26,I&=67108863}y.words[_]=N,R=I,I=P}return R!==0?y.words[_]=R:y.length--,y._strip()}function F(T,p,y){return S(T,p,y)}s.prototype.mulTo=function(p,y){var R,P=this.length+p.length;return this.length===10&&p.length===10?R=M(this,p,y):P<63?R=E(this,p,y):P<1024?R=S(this,p,y):R=F(this,p,y),R},s.prototype.mul=function(p){var y=new s(null);return y.words=new Array(this.length+p.length),this.mulTo(p,y)},s.prototype.mulf=function(p){var y=new s(null);return y.words=new Array(this.length+p.length),F(this,p,y)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){var y=p<0;y&&(p=-p),r(typeof p=="number"),r(p<67108864);for(var R=0,P=0;P<this.length;P++){var _=(this.words[P]|0)*p,I=(_&67108863)+(R&67108863);R>>=26,R+=_/67108864|0,R+=I>>>26,this.words[P]=I&67108863}return R!==0&&(this.words[P]=R,this.length++),this.length=p===0?1:this.length,y?this.ineg():this},s.prototype.muln=function(p){return this.clone().imuln(p)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(p){var y=b(p);if(y.length===0)return new s(1);for(var R=this,P=0;P<y.length&&y[P]===0;P++,R=R.sqr());if(++P<y.length)for(var _=R.sqr();P<y.length;P++,_=_.sqr())y[P]!==0&&(R=R.mul(_));return R},s.prototype.iushln=function(p){r(typeof p=="number"&&p>=0);var y=p%26,R=(p-y)/26,P=67108863>>>26-y<<26-y,_;if(y!==0){var I=0;for(_=0;_<this.length;_++){var N=this.words[_]&P,x=(this.words[_]|0)-N<<y;this.words[_]=x|I,I=N>>>26-y}I&&(this.words[_]=I,this.length++)}if(R!==0){for(_=this.length-1;_>=0;_--)this.words[_+R]=this.words[_];for(_=0;_<R;_++)this.words[_]=0;this.length+=R}return this._strip()},s.prototype.ishln=function(p){return r(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,y,R){r(typeof p=="number"&&p>=0);var P;y?P=(y-y%26)/26:P=0;var _=p%26,I=Math.min((p-_)/26,this.length),N=67108863^67108863>>>_<<_,x=R;if(P-=I,P=Math.max(0,P),x){for(var h=0;h<I;h++)x.words[h]=this.words[h];x.length=I}if(I!==0)if(this.length>I)for(this.length-=I,h=0;h<this.length;h++)this.words[h]=this.words[h+I];else this.words[0]=0,this.length=1;var m=0;for(h=this.length-1;h>=0&&(m!==0||h>=P);h--){var A=this.words[h]|0;this.words[h]=m<<26-_|A>>>_,m=A&N}return x&&m!==0&&(x.words[x.length++]=m),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(p,y,R){return r(this.negative===0),this.iushrn(p,y,R)},s.prototype.shln=function(p){return this.clone().ishln(p)},s.prototype.ushln=function(p){return this.clone().iushln(p)},s.prototype.shrn=function(p){return this.clone().ishrn(p)},s.prototype.ushrn=function(p){return this.clone().iushrn(p)},s.prototype.testn=function(p){r(typeof p=="number"&&p>=0);var y=p%26,R=(p-y)/26,P=1<<y;if(this.length<=R)return!1;var _=this.words[R];return!!(_&P)},s.prototype.imaskn=function(p){r(typeof p=="number"&&p>=0);var y=p%26,R=(p-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=R)return this;if(y!==0&&R++,this.length=Math.min(R,this.length),y!==0){var P=67108863^67108863>>>y<<y;this.words[this.length-1]&=P}return this._strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return r(typeof p=="number"),r(p<67108864),p<0?this.isubn(-p):this.negative!==0?this.length===1&&(this.words[0]|0)<=p?(this.words[0]=p-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(p),this.negative=1,this):this._iaddn(p)},s.prototype._iaddn=function(p){this.words[0]+=p;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},s.prototype.isubn=function(p){if(r(typeof p=="number"),r(p<67108864),p<0)return this.iaddn(-p);if(this.negative!==0)return this.negative=0,this.iaddn(p),this.negative=1,this;if(this.words[0]-=p,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},s.prototype.addn=function(p){return this.clone().iaddn(p)},s.prototype.subn=function(p){return this.clone().isubn(p)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(p,y,R){var P=p.length+R,_;this._expand(P);var I,N=0;for(_=0;_<p.length;_++){I=(this.words[_+R]|0)+N;var x=(p.words[_]|0)*y;I-=x&67108863,N=(I>>26)-(x/67108864|0),this.words[_+R]=I&67108863}for(;_<this.length-R;_++)I=(this.words[_+R]|0)+N,N=I>>26,this.words[_+R]=I&67108863;if(N===0)return this._strip();for(r(N===-1),N=0,_=0;_<this.length;_++)I=-(this.words[_]|0)+N,N=I>>26,this.words[_]=I&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(p,y){var R=this.length-p.length,P=this.clone(),_=p,I=_.words[_.length-1]|0,N=this._countBits(I);R=26-N,R!==0&&(_=_.ushln(R),P.iushln(R),I=_.words[_.length-1]|0);var x=P.length-_.length,h;if(y!=="mod"){h=new s(null),h.length=x+1,h.words=new Array(h.length);for(var m=0;m<h.length;m++)h.words[m]=0}var A=P.clone()._ishlnsubmul(_,1,x);A.negative===0&&(P=A,h&&(h.words[x]=1));for(var C=x-1;C>=0;C--){var $=(P.words[_.length+C]|0)*67108864+(P.words[_.length+C-1]|0);for($=Math.min($/I|0,67108863),P._ishlnsubmul(_,$,C);P.negative!==0;)$--,P.negative=0,P._ishlnsubmul(_,1,C),P.isZero()||(P.negative^=1);h&&(h.words[C]=$)}return h&&h._strip(),P._strip(),y!=="div"&&R!==0&&P.iushrn(R),{div:h||null,mod:P}},s.prototype.divmod=function(p,y,R){if(r(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var P,_,I;return this.negative!==0&&p.negative===0?(I=this.neg().divmod(p,y),y!=="mod"&&(P=I.div.neg()),y!=="div"&&(_=I.mod.neg(),R&&_.negative!==0&&_.iadd(p)),{div:P,mod:_}):this.negative===0&&p.negative!==0?(I=this.divmod(p.neg(),y),y!=="mod"&&(P=I.div.neg()),{div:P,mod:I.mod}):(this.negative&p.negative)!==0?(I=this.neg().divmod(p.neg(),y),y!=="div"&&(_=I.mod.neg(),R&&_.negative!==0&&_.isub(p)),{div:I.div,mod:_}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?y==="div"?{div:this.divn(p.words[0]),mod:null}:y==="mod"?{div:null,mod:new s(this.modrn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modrn(p.words[0]))}:this._wordDiv(p,y)},s.prototype.div=function(p){return this.divmod(p,"div",!1).div},s.prototype.mod=function(p){return this.divmod(p,"mod",!1).mod},s.prototype.umod=function(p){return this.divmod(p,"mod",!0).mod},s.prototype.divRound=function(p){var y=this.divmod(p);if(y.mod.isZero())return y.div;var R=y.div.negative!==0?y.mod.isub(p):y.mod,P=p.ushrn(1),_=p.andln(1),I=R.cmp(P);return I<0||_===1&&I===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},s.prototype.modrn=function(p){var y=p<0;y&&(p=-p),r(p<=67108863);for(var R=(1<<26)%p,P=0,_=this.length-1;_>=0;_--)P=(R*P+(this.words[_]|0))%p;return y?-P:P},s.prototype.modn=function(p){return this.modrn(p)},s.prototype.idivn=function(p){var y=p<0;y&&(p=-p),r(p<=67108863);for(var R=0,P=this.length-1;P>=0;P--){var _=(this.words[P]|0)+R*67108864;this.words[P]=_/p|0,R=_%p}return this._strip(),y?this.ineg():this},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){r(p.negative===0),r(!p.isZero());var y=this,R=p.clone();y.negative!==0?y=y.umod(p):y=y.clone();for(var P=new s(1),_=new s(0),I=new s(0),N=new s(1),x=0;y.isEven()&&R.isEven();)y.iushrn(1),R.iushrn(1),++x;for(var h=R.clone(),m=y.clone();!y.isZero();){for(var A=0,C=1;(y.words[0]&C)===0&&A<26;++A,C<<=1);if(A>0)for(y.iushrn(A);A-- >0;)(P.isOdd()||_.isOdd())&&(P.iadd(h),_.isub(m)),P.iushrn(1),_.iushrn(1);for(var $=0,j=1;(R.words[0]&j)===0&&$<26;++$,j<<=1);if($>0)for(R.iushrn($);$-- >0;)(I.isOdd()||N.isOdd())&&(I.iadd(h),N.isub(m)),I.iushrn(1),N.iushrn(1);y.cmp(R)>=0?(y.isub(R),P.isub(I),_.isub(N)):(R.isub(y),I.isub(P),N.isub(_))}return{a:I,b:N,gcd:R.iushln(x)}},s.prototype._invmp=function(p){r(p.negative===0),r(!p.isZero());var y=this,R=p.clone();y.negative!==0?y=y.umod(p):y=y.clone();for(var P=new s(1),_=new s(0),I=R.clone();y.cmpn(1)>0&&R.cmpn(1)>0;){for(var N=0,x=1;(y.words[0]&x)===0&&N<26;++N,x<<=1);if(N>0)for(y.iushrn(N);N-- >0;)P.isOdd()&&P.iadd(I),P.iushrn(1);for(var h=0,m=1;(R.words[0]&m)===0&&h<26;++h,m<<=1);if(h>0)for(R.iushrn(h);h-- >0;)_.isOdd()&&_.iadd(I),_.iushrn(1);y.cmp(R)>=0?(y.isub(R),P.isub(_)):(R.isub(y),_.isub(P))}var A;return y.cmpn(1)===0?A=P:A=_,A.cmpn(0)<0&&A.iadd(p),A},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var y=this.clone(),R=p.clone();y.negative=0,R.negative=0;for(var P=0;y.isEven()&&R.isEven();P++)y.iushrn(1),R.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;R.isEven();)R.iushrn(1);var _=y.cmp(R);if(_<0){var I=y;y=R,R=I}else if(_===0||R.cmpn(1)===0)break;y.isub(R)}while(!0);return R.iushln(P)},s.prototype.invm=function(p){return this.egcd(p).a.umod(p)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(p){return this.words[0]&p},s.prototype.bincn=function(p){r(typeof p=="number");var y=p%26,R=(p-y)/26,P=1<<y;if(this.length<=R)return this._expand(R+1),this.words[R]|=P,this;for(var _=P,I=R;_!==0&&I<this.length;I++){var N=this.words[I]|0;N+=_,_=N>>>26,N&=67108863,this.words[I]=N}return _!==0&&(this.words[I]=_,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var y=p<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var R;if(this.length>1)R=1;else{y&&(p=-p),r(p<=67108863,"Number is too big");var P=this.words[0]|0;R=P===p?0:P<p?-1:1}return this.negative!==0?-R|0:R},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var y=this.ucmp(p);return this.negative!==0?-y|0:y},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var y=0,R=this.length-1;R>=0;R--){var P=this.words[R]|0,_=p.words[R]|0;if(P!==_){P<_?y=-1:P>_&&(y=1);break}}return y},s.prototype.gtn=function(p){return this.cmpn(p)===1},s.prototype.gt=function(p){return this.cmp(p)===1},s.prototype.gten=function(p){return this.cmpn(p)>=0},s.prototype.gte=function(p){return this.cmp(p)>=0},s.prototype.ltn=function(p){return this.cmpn(p)===-1},s.prototype.lt=function(p){return this.cmp(p)===-1},s.prototype.lten=function(p){return this.cmpn(p)<=0},s.prototype.lte=function(p){return this.cmp(p)<=0},s.prototype.eqn=function(p){return this.cmpn(p)===0},s.prototype.eq=function(p){return this.cmp(p)===0},s.red=function(p){return new H(p)},s.prototype.toRed=function(p){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(p){return this.red=p,this},s.prototype.forceRed=function(p){return r(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return r(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var D={k256:null,p224:null,p192:null,p25519:null};function z(T,p){this.name=T,this.p=new s(p,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},z.prototype.ireduce=function(p){var y=p,R;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),R=y.bitLength();while(R>this.n);var P=R<this.n?-1:y.ucmp(this.p);return P===0?(y.words[0]=0,y.length=1):P>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},z.prototype.split=function(p,y){p.iushrn(this.n,0,y)},z.prototype.imulK=function(p){return p.imul(this.k)};function X(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(X,z),X.prototype.split=function(p,y){for(var R=4194303,P=Math.min(p.length,9),_=0;_<P;_++)y.words[_]=p.words[_];if(y.length=P,p.length<=9){p.words[0]=0,p.length=1;return}var I=p.words[9];for(y.words[y.length++]=I&R,_=10;_<p.length;_++){var N=p.words[_]|0;p.words[_-10]=(N&R)<<4|I>>>22,I=N}I>>>=22,p.words[_-10]=I,I===0&&p.length>10?p.length-=10:p.length-=9},X.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var y=0,R=0;R<p.length;R++){var P=p.words[R]|0;y+=P*977,p.words[R]=y&67108863,y=P*64+(y/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function Y(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(Y,z);function U(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(U,z);function B(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(B,z),B.prototype.imulK=function(p){for(var y=0,R=0;R<p.length;R++){var P=(p.words[R]|0)*19+y,_=P&67108863;P>>>=26,p.words[R]=_,y=P}return y!==0&&(p.words[p.length++]=y),p},s._prime=function(p){if(D[p])return D[p];var y;if(p==="k256")y=new X;else if(p==="p224")y=new Y;else if(p==="p192")y=new U;else if(p==="p25519")y=new B;else throw new Error("Unknown prime "+p);return D[p]=y,y};function H(T){if(typeof T=="string"){var p=s._prime(T);this.m=p.p,this.prime=p}else r(T.gtn(1),"modulus must be greater than 1"),this.m=T,this.prime=null}H.prototype._verify1=function(p){r(p.negative===0,"red works only with positives"),r(p.red,"red works only with red numbers")},H.prototype._verify2=function(p,y){r((p.negative|y.negative)===0,"red works only with positives"),r(p.red&&p.red===y.red,"red works only with red numbers")},H.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):(u(p,p.umod(this.m)._forceRed(this)),p)},H.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},H.prototype.add=function(p,y){this._verify2(p,y);var R=p.add(y);return R.cmp(this.m)>=0&&R.isub(this.m),R._forceRed(this)},H.prototype.iadd=function(p,y){this._verify2(p,y);var R=p.iadd(y);return R.cmp(this.m)>=0&&R.isub(this.m),R},H.prototype.sub=function(p,y){this._verify2(p,y);var R=p.sub(y);return R.cmpn(0)<0&&R.iadd(this.m),R._forceRed(this)},H.prototype.isub=function(p,y){this._verify2(p,y);var R=p.isub(y);return R.cmpn(0)<0&&R.iadd(this.m),R},H.prototype.shl=function(p,y){return this._verify1(p),this.imod(p.ushln(y))},H.prototype.imul=function(p,y){return this._verify2(p,y),this.imod(p.imul(y))},H.prototype.mul=function(p,y){return this._verify2(p,y),this.imod(p.mul(y))},H.prototype.isqr=function(p){return this.imul(p,p.clone())},H.prototype.sqr=function(p){return this.mul(p,p)},H.prototype.sqrt=function(p){if(p.isZero())return p.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var R=this.m.add(new s(1)).iushrn(2);return this.pow(p,R)}for(var P=this.m.subn(1),_=0;!P.isZero()&&P.andln(1)===0;)_++,P.iushrn(1);r(!P.isZero());var I=new s(1).toRed(this),N=I.redNeg(),x=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new s(2*h*h).toRed(this);this.pow(h,x).cmp(N)!==0;)h.redIAdd(N);for(var m=this.pow(h,P),A=this.pow(p,P.addn(1).iushrn(1)),C=this.pow(p,P),$=_;C.cmp(I)!==0;){for(var j=C,Z=0;j.cmp(I)!==0;Z++)j=j.redSqr();r(Z<$);var ne=this.pow(m,new s(1).iushln($-Z-1));A=A.redMul(ne),m=ne.redSqr(),C=C.redMul(m),$=Z}return A},H.prototype.invm=function(p){var y=p._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},H.prototype.pow=function(p,y){if(y.isZero())return new s(1).toRed(this);if(y.cmpn(1)===0)return p.clone();var R=4,P=new Array(1<<R);P[0]=new s(1).toRed(this),P[1]=p;for(var _=2;_<P.length;_++)P[_]=this.mul(P[_-1],p);var I=P[0],N=0,x=0,h=y.bitLength()%26;for(h===0&&(h=26),_=y.length-1;_>=0;_--){for(var m=y.words[_],A=h-1;A>=0;A--){var C=m>>A&1;if(I!==P[0]&&(I=this.sqr(I)),C===0&&N===0){x=0;continue}N<<=1,N|=C,x++,!(x!==R&&(_!==0||A!==0))&&(I=this.mul(I,P[N]),x=0,N=0)}h=26}return I},H.prototype.convertTo=function(p){var y=p.umod(this.m);return y===p?y.clone():y},H.prototype.convertFrom=function(p){var y=p.clone();return y.red=null,y},s.mont=function(p){return new V(p)};function V(T){H.call(this,T),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(V,H),V.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},V.prototype.convertFrom=function(p){var y=this.imod(p.mul(this.rinv));return y.red=null,y},V.prototype.imul=function(p,y){if(p.isZero()||y.isZero())return p.words[0]=0,p.length=1,p;var R=p.imul(y),P=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=R.isub(P).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},V.prototype.mul=function(p,y){if(p.isZero()||y.isZero())return new s(0)._forceRed(this);var R=p.mul(y),P=R.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=R.isub(P).iushrn(this.shift),I=_;return _.cmp(this.m)>=0?I=_.isub(this.m):_.cmpn(0)<0&&(I=_.iadd(this.m)),I._forceRed(this)},V.prototype.invm=function(p){var y=this.imod(p._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(t,gV)})(Ad)),Ad.exports}var yV=tT();const $b=hc(yV);var Gu={exports:{}};var Fb;function wV(){return Fb||(Fb=1,(function(t,e){var n=dy(),r=n.Buffer;function i(o,a){for(var c in o)a[c]=o[c]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=s);function s(o,a,c){return r(o,a,c)}s.prototype=Object.create(r.prototype),i(r,s),s.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,c)},s.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=r(o);return a!==void 0?typeof c=="string"?l.fill(a,c):l.fill(a):l.fill(0),l},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(Gu,Gu.exports)),Gu.exports}var Wp,Kb;function vV(){if(Kb)return Wp;Kb=1;var t=wV().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<n.length;s++){var o=n.charAt(s),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=s}var c=n.length,l=n.charAt(0),u=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function f(w){if((Array.isArray(w)||w instanceof Uint8Array)&&(w=t.from(w)),!t.isBuffer(w))throw new TypeError("Expected Buffer");if(w.length===0)return"";for(var b=0,E=0,M=0,S=w.length;M!==S&&w[M]===0;)M++,b++;for(var F=(S-M)*d+1>>>0,D=new Uint8Array(F);M!==S;){for(var z=w[M],X=0,Y=F-1;(z!==0||X<E)&&Y!==-1;Y--,X++)z+=256*D[Y]>>>0,D[Y]=z%c>>>0,z=z/c>>>0;if(z!==0)throw new Error("Non-zero carry");E=X,M++}for(var U=F-E;U!==F&&D[U]===0;)U++;for(var B=l.repeat(b);U<F;++U)B+=n.charAt(D[U]);return B}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return t.alloc(0);for(var b=0,E=0,M=0;w[b]===l;)E++,b++;for(var S=(w.length-b)*u+1>>>0,F=new Uint8Array(S);b<w.length;){var D=w.charCodeAt(b);if(D>255)return;var z=r[D];if(z===255)return;for(var X=0,Y=S-1;(z!==0||X<M)&&Y!==-1;Y--,X++)z+=c*F[Y]>>>0,F[Y]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");M=X,b++}for(var U=S-M;U!==S&&F[U]===0;)U++;var B=t.allocUnsafe(E+(S-U));B.fill(0,0,E);for(var H=E;U!==S;)B[H++]=F[U++];return B}function v(w){var b=g(w);if(b)return b;throw new Error("Non-base"+c+" character")}return{encode:f,decodeUnsafe:g,decode:v}}return Wp=e,Wp}var Gp,Vb;function nT(){if(Vb)return Gp;Vb=1;var t=vV(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Gp=t(e),Gp}var EV=nT();const Ar=hc(EV),jb=kI;var en={};function gs(t,e,n){return e<=t&&t<=n}function oh(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function bV(t){for(var e=String(t),n=e.length,r=0,i=[];r<n;){var s=e.charCodeAt(r);if(s<55296||s>57343)i.push(s);else if(56320<=s&&s<=57343)i.push(65533);else if(55296<=s&&s<=56319)if(r===n-1)i.push(65533);else{var o=t.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=s&1023,c=o&1023;i.push(65536+(a<<10)+c),r+=1}else i.push(65533)}r+=1}return i}function _V(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var mf=-1;function Cy(t){this.tokens=[].slice.call(t)}Cy.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():mf},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var uc=-1;function Yp(t,e){if(t)throw TypeError("Decoder error");return e||65533}var gf="utf-8";function yf(t,e){if(!(this instanceof yf))return new yf(t,e);if(t=t!==void 0?String(t).toLowerCase():gf,t!==gf)throw new Error("Encoding not supported. Only utf-8 is supported");e=oh(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}yf.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=oh(n),this._streaming||(this._decoder=new SV({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var i=new Cy(r),s=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==uc);)o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===uc)break;o!==null&&(Array.isArray(o)?s.push.apply(s,o):s.push(o))}while(!i.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),_V(s)}};function wf(t,e){if(!(this instanceof wf))return new wf(t,e);if(t=t!==void 0?String(t).toLowerCase():gf,t!==gf)throw new Error("Encoding not supported. Only utf-8 is supported");e=oh(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}wf.prototype={encode:function(e,n){e=e?String(e):"",n=oh(n),this._streaming||(this._encoder=new xV(this._options)),this._streaming=!!n.stream;for(var r=[],i=new Cy(bV(e)),s;!i.endOfStream()&&(s=this._encoder.handler(i,i.read()),s!==uc);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(i,i.read()),s!==uc;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)}};function SV(t){var e=t.fatal,n=0,r=0,i=0,s=128,o=191;this.handler=function(a,c){if(c===mf&&i!==0)return i=0,Yp(e);if(c===mf)return uc;if(i===0){if(gs(c,0,127))return c;if(gs(c,194,223))i=1,n=c-192;else if(gs(c,224,239))c===224&&(s=160),c===237&&(o=159),i=2,n=c-224;else if(gs(c,240,244))c===240&&(s=144),c===244&&(o=143),i=3,n=c-240;else return Yp(e);return n=n<<6*i,null}if(!gs(c,s,o))return n=i=r=0,s=128,o=191,a.prepend(c),Yp(e);if(s=128,o=191,r+=1,n+=c-128<<6*(i-r),r!==i)return null;var l=n;return n=i=r=0,l}}function xV(t){t.fatal,this.handler=function(e,n){if(n===mf)return uc;if(gs(n,0,127))return n;var r,i;gs(n,128,2047)?(r=1,i=192):gs(n,2048,65535)?(r=2,i=224):gs(n,65536,1114111)&&(r=3,i=240);for(var s=[(n>>6*r)+i];r>0;){var o=n>>6*(r-1);s.push(128|o&63),r-=1}return s}}const AV=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:yf,TextEncoder:wf},Symbol.toStringTag,{value:"Module"})),RV=Bm(AV);var Hb;function IV(){if(Hb)return en;Hb=1;var t=en&&en.__createBinding||(Object.create?(function(U,B,H,V){V===void 0&&(V=H),Object.defineProperty(U,V,{enumerable:!0,get:function(){return B[H]}})}):(function(U,B,H,V){V===void 0&&(V=H),U[V]=B[H]})),e=en&&en.__setModuleDefault||(Object.create?(function(U,B){Object.defineProperty(U,"default",{enumerable:!0,value:B})}):function(U,B){U.default=B}),n=en&&en.__decorate||function(U,B,H,V){var T=arguments.length,p=T<3?B:V===null?V=Object.getOwnPropertyDescriptor(B,H):V,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")p=Reflect.decorate(U,B,H,V);else for(var R=U.length-1;R>=0;R--)(y=U[R])&&(p=(T<3?y(p):T>3?y(B,H,p):y(B,H))||p);return T>3&&p&&Object.defineProperty(B,H,p),p},r=en&&en.__importStar||function(U){if(U&&U.__esModule)return U;var B={};if(U!=null)for(var H in U)H!=="default"&&Object.hasOwnProperty.call(U,H)&&t(B,U,H);return e(B,U),B},i=en&&en.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(en,"__esModule",{value:!0}),en.deserializeUnchecked=en.deserialize=en.serialize=en.BinaryReader=en.BinaryWriter=en.BorshError=en.baseDecode=en.baseEncode=void 0;const s=i(tT()),o=i(nT()),a=r(RV),c=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,l=new c("utf-8",{fatal:!0});function u(U){return typeof U=="string"&&(U=Buffer.from(U,"utf8")),o.default.encode(Buffer.from(U))}en.baseEncode=u;function d(U){return Buffer.from(o.default.decode(U))}en.baseDecode=d;const f=1024;class g extends Error{constructor(B){super(B),this.fieldPath=[],this.originalMessage=B}addToFieldPath(B){this.fieldPath.splice(0,0,B),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}en.BorshError=g;class v{constructor(){this.buf=Buffer.alloc(f),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(f)]))}writeU8(B){this.maybeResize(),this.buf.writeUInt8(B,this.length),this.length+=1}writeU16(B){this.maybeResize(),this.buf.writeUInt16LE(B,this.length),this.length+=2}writeU32(B){this.maybeResize(),this.buf.writeUInt32LE(B,this.length),this.length+=4}writeU64(B){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(B).toArray("le",8)))}writeU128(B){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(B).toArray("le",16)))}writeU256(B){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(B).toArray("le",32)))}writeU512(B){this.maybeResize(),this.writeBuffer(Buffer.from(new s.default(B).toArray("le",64)))}writeBuffer(B){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),B,Buffer.alloc(f)]),this.length+=B.length}writeString(B){this.maybeResize();const H=Buffer.from(B,"utf8");this.writeU32(H.length),this.writeBuffer(H)}writeFixedArray(B){this.writeBuffer(Buffer.from(B))}writeArray(B,H){this.maybeResize(),this.writeU32(B.length);for(const V of B)this.maybeResize(),H(V)}toArray(){return this.buf.subarray(0,this.length)}}en.BinaryWriter=v;function w(U,B,H){const V=H.value;H.value=function(...T){try{return V.apply(this,T)}catch(p){if(p instanceof RangeError){const y=p.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(y)>=0)throw new g("Reached the end of buffer when deserializing")}throw p}}}class b{constructor(B){this.buf=B,this.offset=0}readU8(){const B=this.buf.readUInt8(this.offset);return this.offset+=1,B}readU16(){const B=this.buf.readUInt16LE(this.offset);return this.offset+=2,B}readU32(){const B=this.buf.readUInt32LE(this.offset);return this.offset+=4,B}readU64(){const B=this.readBuffer(8);return new s.default(B,"le")}readU128(){const B=this.readBuffer(16);return new s.default(B,"le")}readU256(){const B=this.readBuffer(32);return new s.default(B,"le")}readU512(){const B=this.readBuffer(64);return new s.default(B,"le")}readBuffer(B){if(this.offset+B>this.buf.length)throw new g(`Expected buffer length ${B} isn't within bounds`);const H=this.buf.slice(this.offset,this.offset+B);return this.offset+=B,H}readString(){const B=this.readU32(),H=this.readBuffer(B);try{return l.decode(H)}catch(V){throw new g(`Error decoding UTF-8 string: ${V}`)}}readFixedArray(B){return new Uint8Array(this.readBuffer(B))}readArray(B){const H=this.readU32(),V=Array();for(let T=0;T<H;++T)V.push(B());return V}}n([w],b.prototype,"readU8",null),n([w],b.prototype,"readU16",null),n([w],b.prototype,"readU32",null),n([w],b.prototype,"readU64",null),n([w],b.prototype,"readU128",null),n([w],b.prototype,"readU256",null),n([w],b.prototype,"readU512",null),n([w],b.prototype,"readString",null),n([w],b.prototype,"readFixedArray",null),n([w],b.prototype,"readArray",null),en.BinaryReader=b;function E(U){return U.charAt(0).toUpperCase()+U.slice(1)}function M(U,B,H,V,T){try{if(typeof V=="string")T[`write${E(V)}`](H);else if(V instanceof Array)if(typeof V[0]=="number"){if(H.length!==V[0])throw new g(`Expecting byte array of length ${V[0]}, but got ${H.length} bytes`);T.writeFixedArray(H)}else if(V.length===2&&typeof V[1]=="number"){if(H.length!==V[1])throw new g(`Expecting byte array of length ${V[1]}, but got ${H.length} bytes`);for(let p=0;p<V[1];p++)M(U,null,H[p],V[0],T)}else T.writeArray(H,p=>{M(U,B,p,V[0],T)});else if(V.kind!==void 0)switch(V.kind){case"option":{H==null?T.writeU8(0):(T.writeU8(1),M(U,B,H,V.type,T));break}case"map":{T.writeU32(H.size),H.forEach((p,y)=>{M(U,B,y,V.key,T),M(U,B,p,V.value,T)});break}default:throw new g(`FieldType ${V} unrecognized`)}else S(U,H,T)}catch(p){throw p instanceof g&&p.addToFieldPath(B),p}}function S(U,B,H){if(typeof B.borshSerialize=="function"){B.borshSerialize(H);return}const V=U.get(B.constructor);if(!V)throw new g(`Class ${B.constructor.name} is missing in schema`);if(V.kind==="struct")V.fields.map(([T,p])=>{M(U,T,B[T],p,H)});else if(V.kind==="enum"){const T=B[V.field];for(let p=0;p<V.values.length;++p){const[y,R]=V.values[p];if(y===T){H.writeU8(p),M(U,y,B[y],R,H);break}}}else throw new g(`Unexpected schema kind: ${V.kind} for ${B.constructor.name}`)}function F(U,B,H=v){const V=new H;return S(U,B,V),V.toArray()}en.serialize=F;function D(U,B,H,V){try{if(typeof H=="string")return V[`read${E(H)}`]();if(H instanceof Array){if(typeof H[0]=="number")return V.readFixedArray(H[0]);if(typeof H[1]=="number"){const T=[];for(let p=0;p<H[1];p++)T.push(D(U,null,H[0],V));return T}else return V.readArray(()=>D(U,B,H[0],V))}if(H.kind==="option")return V.readU8()?D(U,B,H.type,V):void 0;if(H.kind==="map"){let T=new Map;const p=V.readU32();for(let y=0;y<p;y++){const R=D(U,B,H.key,V),P=D(U,B,H.value,V);T.set(R,P)}return T}return z(U,H,V)}catch(T){throw T instanceof g&&T.addToFieldPath(B),T}}function z(U,B,H){if(typeof B.borshDeserialize=="function")return B.borshDeserialize(H);const V=U.get(B);if(!V)throw new g(`Class ${B.name} is missing in schema`);if(V.kind==="struct"){const T={};for(const[p,y]of U.get(B).fields)T[p]=D(U,p,y,H);return new B(T)}if(V.kind==="enum"){const T=H.readU8();if(T>=V.values.length)throw new g(`Enum index: ${T} is out of range`);const[p,y]=V.values[T],R=D(U,p,y,H);return new B({[p]:R})}throw new g(`Unexpected schema kind: ${V.kind} for ${B.constructor.name}`)}function X(U,B,H,V=b){const T=new V(H),p=z(U,B,T);if(T.offset<H.length)throw new g(`Unexpected ${H.length-T.offset} bytes after deserialized data`);return p}en.deserialize=X;function Y(U,B,H,V=b){const T=new V(H);return z(U,B,T)}return en.deserializeUnchecked=Y,en}var Jp=IV(),he={},zb;function TV(){if(zb)return he;zb=1,Object.defineProperty(he,"__esModule",{value:!0}),he.s16=he.s8=he.nu64be=he.u48be=he.u40be=he.u32be=he.u24be=he.u16be=he.nu64=he.u48=he.u40=he.u32=he.u24=he.u16=he.u8=he.offset=he.greedy=he.Constant=he.UTF8=he.CString=he.Blob=he.Boolean=he.BitField=he.BitStructure=he.VariantLayout=he.Union=he.UnionLayoutDiscriminator=he.UnionDiscriminator=he.Structure=he.Sequence=he.DoubleBE=he.Double=he.FloatBE=he.Float=he.NearInt64BE=he.NearInt64=he.NearUInt64BE=he.NearUInt64=he.IntBE=he.Int=he.UIntBE=he.UInt=he.OffsetLayout=he.GreedyCount=he.ExternalLayout=he.bindConstructorLayout=he.nameWithProperty=he.Layout=he.uint8ArrayToBuffer=he.checkUint8Array=void 0,he.constant=he.utf8=he.cstr=he.blob=he.unionLayoutDiscriminator=he.union=he.seq=he.bits=he.struct=he.f64be=he.f64=he.f32be=he.f32=he.ns64be=he.s48be=he.s40be=he.s32be=he.s24be=he.s16be=he.ns64=he.s48=he.s40=he.s32=he.s24=void 0;const t=dy();function e(h){if(!(h instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}he.checkUint8Array=e;function n(h){return e(h),t.Buffer.from(h.buffer,h.byteOffset,h.length)}he.uint8ArrayToBuffer=n;let r=class{constructor(m,A){if(!Number.isInteger(m))throw new TypeError("span must be an integer");this.span=m,this.property=A}makeDestinationObject(){return{}}getSpan(m,A){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(m){const A=Object.create(this.constructor.prototype);return Object.assign(A,this),A.property=m,A}fromArray(m){}};he.Layout=r;function i(h,m){return m.property?h+"["+m.property+"]":h}he.nameWithProperty=i;function s(h,m){if(typeof h!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(h,"layout_"))throw new Error("Class is already bound to a layout");if(!(m&&m instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(m,"boundConstructor_"))throw new Error("layout is already bound to a constructor");h.layout_=m,m.boundConstructor_=h,m.makeDestinationObject=(()=>new h),Object.defineProperty(h.prototype,"encode",{value(A,C){return m.encode(this,A,C)},writable:!0}),Object.defineProperty(h,"decode",{value(A,C){return m.decode(A,C)},writable:!0})}he.bindConstructorLayout=s;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}he.ExternalLayout=o;class a extends o{constructor(m=1,A){if(!Number.isInteger(m)||0>=m)throw new TypeError("elementSpan must be a (positive) integer");super(-1,A),this.elementSpan=m}isCount(){return!0}decode(m,A=0){e(m);const C=m.length-A;return Math.floor(C/this.elementSpan)}encode(m,A,C){return 0}}he.GreedyCount=a;class c extends o{constructor(m,A=0,C){if(!(m instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(A))throw new TypeError("offset must be integer or undefined");super(m.span,C||m.property),this.layout=m,this.offset=A}isCount(){return this.layout instanceof l||this.layout instanceof u}decode(m,A=0){return this.layout.decode(m,A+this.offset)}encode(m,A,C=0){return this.layout.encode(m,A,C+this.offset)}}he.OffsetLayout=c;class l extends r{constructor(m,A){if(super(m,A),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(m,A=0){return n(m).readUIntLE(A,this.span)}encode(m,A,C=0){return n(A).writeUIntLE(m,C,this.span),this.span}}he.UInt=l;class u extends r{constructor(m,A){if(super(m,A),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(m,A=0){return n(m).readUIntBE(A,this.span)}encode(m,A,C=0){return n(A).writeUIntBE(m,C,this.span),this.span}}he.UIntBE=u;class d extends r{constructor(m,A){if(super(m,A),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(m,A=0){return n(m).readIntLE(A,this.span)}encode(m,A,C=0){return n(A).writeIntLE(m,C,this.span),this.span}}he.Int=d;class f extends r{constructor(m,A){if(super(m,A),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(m,A=0){return n(m).readIntBE(A,this.span)}encode(m,A,C=0){return n(A).writeIntBE(m,C,this.span),this.span}}he.IntBE=f;const g=Math.pow(2,32);function v(h){const m=Math.floor(h/g),A=h-m*g;return{hi32:m,lo32:A}}function w(h,m){return h*g+m}class b extends r{constructor(m){super(8,m)}decode(m,A=0){const C=n(m),$=C.readUInt32LE(A),j=C.readUInt32LE(A+4);return w(j,$)}encode(m,A,C=0){const $=v(m),j=n(A);return j.writeUInt32LE($.lo32,C),j.writeUInt32LE($.hi32,C+4),8}}he.NearUInt64=b;class E extends r{constructor(m){super(8,m)}decode(m,A=0){const C=n(m),$=C.readUInt32BE(A),j=C.readUInt32BE(A+4);return w($,j)}encode(m,A,C=0){const $=v(m),j=n(A);return j.writeUInt32BE($.hi32,C),j.writeUInt32BE($.lo32,C+4),8}}he.NearUInt64BE=E;class M extends r{constructor(m){super(8,m)}decode(m,A=0){const C=n(m),$=C.readUInt32LE(A),j=C.readInt32LE(A+4);return w(j,$)}encode(m,A,C=0){const $=v(m),j=n(A);return j.writeUInt32LE($.lo32,C),j.writeInt32LE($.hi32,C+4),8}}he.NearInt64=M;class S extends r{constructor(m){super(8,m)}decode(m,A=0){const C=n(m),$=C.readInt32BE(A),j=C.readUInt32BE(A+4);return w($,j)}encode(m,A,C=0){const $=v(m),j=n(A);return j.writeInt32BE($.hi32,C),j.writeUInt32BE($.lo32,C+4),8}}he.NearInt64BE=S;class F extends r{constructor(m){super(4,m)}decode(m,A=0){return n(m).readFloatLE(A)}encode(m,A,C=0){return n(A).writeFloatLE(m,C),4}}he.Float=F;class D extends r{constructor(m){super(4,m)}decode(m,A=0){return n(m).readFloatBE(A)}encode(m,A,C=0){return n(A).writeFloatBE(m,C),4}}he.FloatBE=D;class z extends r{constructor(m){super(8,m)}decode(m,A=0){return n(m).readDoubleLE(A)}encode(m,A,C=0){return n(A).writeDoubleLE(m,C),8}}he.Double=z;class X extends r{constructor(m){super(8,m)}decode(m,A=0){return n(m).readDoubleBE(A)}encode(m,A,C=0){return n(A).writeDoubleBE(m,C),8}}he.DoubleBE=X;class Y extends r{constructor(m,A,C){if(!(m instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(A instanceof o&&A.isCount()||Number.isInteger(A)&&0<=A))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let $=-1;!(A instanceof o)&&0<m.span&&($=A*m.span),super($,C),this.elementLayout=m,this.count=A}getSpan(m,A=0){if(0<=this.span)return this.span;let C=0,$=this.count;if($ instanceof o&&($=$.decode(m,A)),0<this.elementLayout.span)C=$*this.elementLayout.span;else{let j=0;for(;j<$;)C+=this.elementLayout.getSpan(m,A+C),++j}return C}decode(m,A=0){const C=[];let $=0,j=this.count;for(j instanceof o&&(j=j.decode(m,A));$<j;)C.push(this.elementLayout.decode(m,A)),A+=this.elementLayout.getSpan(m,A),$+=1;return C}encode(m,A,C=0){const $=this.elementLayout,j=m.reduce((Z,ne)=>Z+$.encode(ne,A,C+Z),0);return this.count instanceof o&&this.count.encode(m.length,A,C),j}}he.Sequence=Y;class U extends r{constructor(m,A,C){if(!(Array.isArray(m)&&m.reduce((j,Z)=>j&&Z instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof A=="boolean"&&C===void 0&&(C=A,A=void 0);for(const j of m)if(0>j.span&&j.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let $=-1;try{$=m.reduce((j,Z)=>j+Z.getSpan(),0)}catch{}super($,A),this.fields=m,this.decodePrefixes=!!C}getSpan(m,A=0){if(0<=this.span)return this.span;let C=0;try{C=this.fields.reduce(($,j)=>{const Z=j.getSpan(m,A);return A+=Z,$+Z},0)}catch{throw new RangeError("indeterminate span")}return C}decode(m,A=0){e(m);const C=this.makeDestinationObject();for(const $ of this.fields)if($.property!==void 0&&(C[$.property]=$.decode(m,A)),A+=$.getSpan(m,A),this.decodePrefixes&&m.length===A)break;return C}encode(m,A,C=0){const $=C;let j=0,Z=0;for(const ne of this.fields){let se=ne.span;if(Z=0<se?se:0,ne.property!==void 0){const ue=m[ne.property];ue!==void 0&&(Z=ne.encode(ue,A,C),0>se&&(se=ne.getSpan(A,C)))}j=C,C+=se}return j+Z-$}fromArray(m){const A=this.makeDestinationObject();for(const C of this.fields)C.property!==void 0&&0<m.length&&(A[C.property]=m.shift());return A}layoutFor(m){if(typeof m!="string")throw new TypeError("property must be string");for(const A of this.fields)if(A.property===m)return A}offsetOf(m){if(typeof m!="string")throw new TypeError("property must be string");let A=0;for(const C of this.fields){if(C.property===m)return A;0>C.span?A=-1:0<=A&&(A+=C.span)}}}he.Structure=U;class B{constructor(m){this.property=m}decode(m,A){throw new Error("UnionDiscriminator is abstract")}encode(m,A,C){throw new Error("UnionDiscriminator is abstract")}}he.UnionDiscriminator=B;class H extends B{constructor(m,A){if(!(m instanceof o&&m.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(A||m.property||"variant"),this.layout=m}decode(m,A){return this.layout.decode(m,A)}encode(m,A,C){return this.layout.encode(m,A,C)}}he.UnionLayoutDiscriminator=H;class V extends r{constructor(m,A,C){let $;if(m instanceof l||m instanceof u)$=new H(new c(m));else if(m instanceof o&&m.isCount())$=new H(m);else if(m instanceof B)$=m;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(A===void 0&&(A=null),!(A===null||A instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(A!==null){if(0>A.span)throw new Error("defaultLayout must have constant span");A.property===void 0&&(A=A.replicate("content"))}let j=-1;A&&(j=A.span,0<=j&&(m instanceof l||m instanceof u)&&(j+=$.layout.span)),super(j,C),this.discriminator=$,this.usesPrefixDiscriminator=m instanceof l||m instanceof u,this.defaultLayout=A,this.registry={};let Z=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ne){return Z(ne)},this.configGetSourceVariant=function(ne){Z=ne.bind(this)}}getSpan(m,A=0){if(0<=this.span)return this.span;const C=this.getVariant(m,A);if(!C)throw new Error("unable to determine span for unrecognized variant");return C.getSpan(m,A)}defaultGetSourceVariant(m){if(Object.prototype.hasOwnProperty.call(m,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(m,this.defaultLayout.property))return;const A=this.registry[m[this.discriminator.property]];if(A&&(!A.layout||A.property&&Object.prototype.hasOwnProperty.call(m,A.property)))return A}else for(const A in this.registry){const C=this.registry[A];if(C.property&&Object.prototype.hasOwnProperty.call(m,C.property))return C}throw new Error("unable to infer src variant")}decode(m,A=0){let C;const $=this.discriminator,j=$.decode(m,A),Z=this.registry[j];if(Z===void 0){const ne=this.defaultLayout;let se=0;this.usesPrefixDiscriminator&&(se=$.layout.span),C=this.makeDestinationObject(),C[$.property]=j,C[ne.property]=ne.decode(m,A+se)}else C=Z.decode(m,A);return C}encode(m,A,C=0){const $=this.getSourceVariant(m);if($===void 0){const j=this.discriminator,Z=this.defaultLayout;let ne=0;return this.usesPrefixDiscriminator&&(ne=j.layout.span),j.encode(m[j.property],A,C),ne+Z.encode(m[Z.property],A,C+ne)}return $.encode(m,A,C)}addVariant(m,A,C){const $=new T(this,m,A,C);return this.registry[m]=$,$}getVariant(m,A=0){let C;return m instanceof Uint8Array?C=this.discriminator.decode(m,A):C=m,this.registry[C]}}he.Union=V;class T extends r{constructor(m,A,C,$){if(!(m instanceof V))throw new TypeError("union must be a Union");if(!Number.isInteger(A)||0>A)throw new TypeError("variant must be a (non-negative) integer");if(typeof C=="string"&&$===void 0&&($=C,C=null),C){if(!(C instanceof r))throw new TypeError("layout must be a Layout");if(m.defaultLayout!==null&&0<=C.span&&C.span>m.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof $!="string")throw new TypeError("variant must have a String property")}let j=m.span;0>m.span&&(j=C?C.span:0,0<=j&&m.usesPrefixDiscriminator&&(j+=m.discriminator.layout.span)),super(j,$),this.union=m,this.variant=A,this.layout=C||null}getSpan(m,A=0){if(0<=this.span)return this.span;let C=0;this.union.usesPrefixDiscriminator&&(C=this.union.discriminator.layout.span);let $=0;return this.layout&&($=this.layout.getSpan(m,A+C)),C+$}decode(m,A=0){const C=this.makeDestinationObject();if(this!==this.union.getVariant(m,A))throw new Error("variant mismatch");let $=0;return this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout?C[this.property]=this.layout.decode(m,A+$):this.property?C[this.property]=!0:this.union.usesPrefixDiscriminator&&(C[this.union.discriminator.property]=this.variant),C}encode(m,A,C=0){let $=0;if(this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(m,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,A,C);let j=$;if(this.layout&&(this.layout.encode(m[this.property],A,C+$),j+=this.layout.getSpan(A,C+$),0<=this.union.span&&j>this.union.span))throw new Error("encoded variant overruns containing union");return j}fromArray(m){if(this.layout)return this.layout.fromArray(m)}}he.VariantLayout=T;function p(h){return 0>h&&(h+=4294967296),h}class y extends r{constructor(m,A,C){if(!(m instanceof l||m instanceof u))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof A=="string"&&C===void 0&&(C=A,A=!1),4<m.span)throw new RangeError("word cannot exceed 32 bits");super(m.span,C),this.word=m,this.msb=!!A,this.fields=[];let $=0;this._packedSetValue=function(j){return $=p(j),this},this._packedGetValue=function(){return $}}decode(m,A=0){const C=this.makeDestinationObject(),$=this.word.decode(m,A);this._packedSetValue($);for(const j of this.fields)j.property!==void 0&&(C[j.property]=j.decode(m));return C}encode(m,A,C=0){const $=this.word.decode(A,C);this._packedSetValue($);for(const j of this.fields)if(j.property!==void 0){const Z=m[j.property];Z!==void 0&&j.encode(Z)}return this.word.encode(this._packedGetValue(),A,C)}addField(m,A){const C=new R(this,m,A);return this.fields.push(C),C}addBoolean(m){const A=new P(this,m);return this.fields.push(A),A}fieldFor(m){if(typeof m!="string")throw new TypeError("property must be string");for(const A of this.fields)if(A.property===m)return A}}he.BitStructure=y;class R{constructor(m,A,C){if(!(m instanceof y))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(A)||0>=A)throw new TypeError("bits must be positive integer");const $=8*m.span,j=m.fields.reduce((Z,ne)=>Z+ne.bits,0);if(A+j>$)throw new Error("bits too long for span remainder ("+($-j)+" of "+$+" remain)");this.container=m,this.bits=A,this.valueMask=(1<<A)-1,A===32&&(this.valueMask=4294967295),this.start=j,this.container.msb&&(this.start=$-j-A),this.wordMask=p(this.valueMask<<this.start),this.property=C}decode(m,A){const C=this.container._packedGetValue();return p(C&this.wordMask)>>>this.start}encode(m){if(typeof m!="number"||!Number.isInteger(m)||m!==p(m&this.valueMask))throw new TypeError(i("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const A=this.container._packedGetValue(),C=p(m<<this.start);this.container._packedSetValue(p(A&~this.wordMask)|C)}}he.BitField=R;class P extends R{constructor(m,A){super(m,1,A)}decode(m,A){return!!super.decode(m,A)}encode(m){typeof m=="boolean"&&(m=+m),super.encode(m)}}he.Boolean=P;class _ extends r{constructor(m,A){if(!(m instanceof o&&m.isCount()||Number.isInteger(m)&&0<=m))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let C=-1;m instanceof o||(C=m),super(C,A),this.length=m}getSpan(m,A){let C=this.span;return 0>C&&(C=this.length.decode(m,A)),C}decode(m,A=0){let C=this.span;return 0>C&&(C=this.length.decode(m,A)),n(m).slice(A,A+C)}encode(m,A,C){let $=this.length;if(this.length instanceof o&&($=m.length),!(m instanceof Uint8Array&&$===m.length))throw new TypeError(i("Blob.encode",this)+" requires (length "+$+") Uint8Array as src");if(C+$>A.length)throw new RangeError("encoding overruns Uint8Array");const j=n(m);return n(A).write(j.toString("hex"),C,$,"hex"),this.length instanceof o&&this.length.encode($,A,C),$}}he.Blob=_;class I extends r{constructor(m){super(-1,m)}getSpan(m,A=0){e(m);let C=A;for(;C<m.length&&m[C]!==0;)C+=1;return 1+C-A}decode(m,A=0){const C=this.getSpan(m,A);return n(m).slice(A,A+C-1).toString("utf-8")}encode(m,A,C=0){typeof m!="string"&&(m=String(m));const $=t.Buffer.from(m,"utf8"),j=$.length;if(C+j>A.length)throw new RangeError("encoding overruns Buffer");const Z=n(A);return $.copy(Z,C),Z[C+j]=0,j+1}}he.CString=I;class N extends r{constructor(m,A){if(typeof m=="string"&&A===void 0&&(A=m,m=void 0),m===void 0)m=-1;else if(!Number.isInteger(m))throw new TypeError("maxSpan must be an integer");super(-1,A),this.maxSpan=m}getSpan(m,A=0){return e(m),m.length-A}decode(m,A=0){const C=this.getSpan(m,A);if(0<=this.maxSpan&&this.maxSpan<C)throw new RangeError("text length exceeds maxSpan");return n(m).slice(A,A+C).toString("utf-8")}encode(m,A,C=0){typeof m!="string"&&(m=String(m));const $=t.Buffer.from(m,"utf8"),j=$.length;if(0<=this.maxSpan&&this.maxSpan<j)throw new RangeError("text length exceeds maxSpan");if(C+j>A.length)throw new RangeError("encoding overruns Buffer");return $.copy(n(A),C),j}}he.UTF8=N;class x extends r{constructor(m,A){super(0,A),this.value=m}decode(m,A){return this.value}encode(m,A,C){return 0}}return he.Constant=x,he.greedy=((h,m)=>new a(h,m)),he.offset=((h,m,A)=>new c(h,m,A)),he.u8=(h=>new l(1,h)),he.u16=(h=>new l(2,h)),he.u24=(h=>new l(3,h)),he.u32=(h=>new l(4,h)),he.u40=(h=>new l(5,h)),he.u48=(h=>new l(6,h)),he.nu64=(h=>new b(h)),he.u16be=(h=>new u(2,h)),he.u24be=(h=>new u(3,h)),he.u32be=(h=>new u(4,h)),he.u40be=(h=>new u(5,h)),he.u48be=(h=>new u(6,h)),he.nu64be=(h=>new E(h)),he.s8=(h=>new d(1,h)),he.s16=(h=>new d(2,h)),he.s24=(h=>new d(3,h)),he.s32=(h=>new d(4,h)),he.s40=(h=>new d(5,h)),he.s48=(h=>new d(6,h)),he.ns64=(h=>new M(h)),he.s16be=(h=>new f(2,h)),he.s24be=(h=>new f(3,h)),he.s32be=(h=>new f(4,h)),he.s40be=(h=>new f(5,h)),he.s48be=(h=>new f(6,h)),he.ns64be=(h=>new S(h)),he.f32=(h=>new F(h)),he.f32be=(h=>new D(h)),he.f64=(h=>new z(h)),he.f64be=(h=>new X(h)),he.struct=((h,m,A)=>new U(h,m,A)),he.bits=((h,m,A)=>new y(h,m,A)),he.seq=((h,m,A)=>new Y(h,m,A)),he.union=((h,m,A)=>new V(h,m,A)),he.unionLayoutDiscriminator=((h,m)=>new H(h,m)),he.blob=((h,m)=>new _(h,m)),he.cstr=(h=>new I(h)),he.utf8=((h,m)=>new N(h,m)),he.constant=((h,m)=>new x(h,m)),he}var ie=TV();class CV extends TypeError{constructor(e,n){let r;const{message:i,explanation:s,...o}=e,{path:a}=e,c=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??c),s!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function OV(t){return tu(t)&&typeof t[Symbol.iterator]=="function"}function tu(t){return typeof t=="object"&&t!=null}function vf(t){return tu(t)&&!Array.isArray(t)}function Ri(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function NV(t){const{done:e,value:n}=t.next();return e?void 0:n}function PV(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:s}=e,{type:o}=n,{refinement:a,message:c=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Ri(r)}\``}=t;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...t,message:c}}function*qb(t,e,n,r){OV(t)||(t=[t]);for(const i of t){const s=PV(i,e,n,r);s&&(yield s)}}function*Oy(t,e,n={}){const{path:r=[],branch:i=[t],coerce:s=!1,mask:o=!1}=n,a={path:r,branch:i,mask:o};s&&(t=e.coercer(t,a));let c="valid";for(const l of e.validator(t,a))l.explanation=n.message,c="not_valid",yield[l,void 0];for(let[l,u,d]of e.entries(t,a)){const f=Oy(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:s,mask:o,message:n.message});for(const g of f)g[0]?(c=g[0].refinement!=null?"not_refined":"not_valid",yield[g[0],void 0]):s&&(u=g[1],l===void 0?t=u:t instanceof Map?t.set(l,u):t instanceof Set?t.add(u):tu(t)&&(u!==void 0||l in t)&&(t[l]=u))}if(c!=="not_valid")for(const l of e.refiner(t,a))l.explanation=n.message,c="not_refined",yield[l,void 0];c==="valid"&&(yield[void 0,t])}let es=class{constructor(e){const{type:n,schema:r,validator:i,refiner:s,coercer:o=c=>c,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,i?this.validator=(c,l)=>{const u=i(c,l);return qb(u,l,this,c)}:this.validator=()=>[],s?this.refiner=(c,l)=>{const u=s(c,l);return qb(u,l,this,c)}:this.refiner=()=>[]}assert(e,n){return MV(e,this,n)}create(e,n){return Dl(e,this,n)}is(e){return rT(e,this)}mask(e,n){return kV(e,this,n)}validate(e,n={}){return nu(e,this,n)}};function MV(t,e,n){const r=nu(t,e,{message:n});if(r[0])throw r[0]}function Dl(t,e,n){const r=nu(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function kV(t,e,n){const r=nu(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function rT(t,e){return!nu(t,e)[0]}function nu(t,e,n={}){const r=Oy(t,e,n),i=NV(r);return i[0]?[new CV(i[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function la(t,e){return new es({type:t,schema:null,validator:e})}function DV(){return la("any",()=>!0)}function tt(t){return new es({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Ri(e)}`}})}function Xi(){return la("boolean",t=>typeof t=="boolean")}function Ny(t){return la("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${Ri(e)}`)}function mn(t){const e=Ri(t),n=typeof t;return new es({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${Ri(r)}`}})}function LV(){return la("never",()=>!1)}function nt(t){return new es({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function fe(){return la("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${Ri(t)}`)}function lt(t){return new es({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function iT(t,e){return new es({type:"record",schema:null,*entries(n){if(tu(n))for(const r in n){const i=n[r];yield[r,r,t],yield[r,i,e]}},validator(n){return vf(n)||`Expected an object, but received: ${Ri(n)}`},coercer(n){return vf(n)?{...n}:n}})}function Fe(){return la("string",t=>typeof t=="string"||`Expected a string, but received: ${Ri(t)}`)}function Py(t){const e=LV();return new es({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],t[i]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${Ri(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function Pe(t){const e=Object.keys(t);return new es({type:"type",schema:t,*entries(n){if(tu(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return vf(n)||`Expected an object, but received: ${Ri(n)}`},coercer(n){return vf(n)?{...n}:n}})}function Cr(t){const e=t.map(n=>n.type).join(" | ");return new es({type:"union",schema:null,coercer(n,r){for(const i of t){const[s,o]=i.validate(n,{coerce:!0,mask:r.mask});if(!s)return o}return n},validator(n,r){const i=[];for(const s of t){const[...o]=Oy(n,s,r),[a]=o;if(a[0])for(const[c]of o)c&&i.push(c);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Ri(n)}`,...i]}})}function Ic(){return la("unknown",()=>!0)}function ru(t,e,n){return new es({...t,coercer:(r,i)=>rT(r,e)?t.coercer(n(r,i),i):t.coercer(r,i)})}const sT=Bm(K6);var Zp,Wb;function BV(){if(Wb)return Zp;Wb=1;const t=sT.v4;return Zp=function(n,r,i,s){if(typeof n!="string")throw new TypeError(n+" must be a string");s=s||{};const o=typeof s.version=="number"?s.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:n};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof i>"u"){const c=typeof s.generator=="function"?s.generator:function(){return t()};a.id=c(a,s)}else o===2&&i===null?s.notificationIdNull&&(a.id=null):a.id=i;return a},Zp}var Xp,Gb;function UV(){if(Gb)return Xp;Gb=1;const t=sT.v4,e=BV(),n=function(r,i){if(!(this instanceof n))return new n(r,i);i||(i={}),this.options={reviver:typeof i.reviver<"u"?i.reviver:null,replacer:typeof i.replacer<"u"?i.replacer:null,generator:typeof i.generator<"u"?i.generator:function(){return t()},version:typeof i.version<"u"?i.version:2,notificationIdNull:typeof i.notificationIdNull=="boolean"?i.notificationIdNull:!1},this.callServer=r};return Xp=n,n.prototype.request=function(r,i,s,o){const a=this;let c=null;const l=Array.isArray(r)&&typeof i=="function";if(this.options.version===1&&l)throw new TypeError("JSON-RPC 1.0 does not support batching");if(l||!l&&r&&typeof r=="object"&&typeof i=="function")o=i,c=r;else{typeof s=="function"&&(o=s,s=void 0);const f=typeof o=="function";try{c=e(r,i,s,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(g){if(f){o(g);return}throw g}if(!f)return c}let d;try{d=JSON.stringify(c,this.options.replacer)}catch(f){o(f);return}return this.callServer(d,function(f,g){a._parseResponse(f,g,o)}),c},n.prototype._parseResponse=function(r,i,s){if(r){s(r);return}if(!i){s();return}let o;try{o=JSON.parse(i,this.options.reviver)}catch(a){s(a);return}if(s.length===3)if(Array.isArray(o)){const a=function(l){return typeof l.error<"u"},c=function(l){return!a(l)};s(null,o.filter(a),o.filter(c));return}else{s(null,o.error,o.result);return}s(null,o)},Xp}UV();class oT extends OI{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,TI(e);const r=Sy(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),cc(s)}update(e){return df(this),this.iHash.update(e),this}digestInto(e){df(this),aa(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const aT=(t,e,n)=>new oT(t,e).update(n).digest();aT.create=(t,e)=>new oT(t,e);const Yb=(t,e)=>(t+(t>=0?e:-e)/cT)/e;function $V(t,e,n){const[[r,i],[s,o]]=e,a=Yb(o*t,n),c=Yb(-i*t,n);let l=t-a*r-c*s,u=-a*i-c*o;const d=l<Ss,f=u<Ss;d&&(l=-l),f&&(u=-u);const g=Xl(Math.ceil(BI(n)/2))+Ga;if(l<Ss||l>=g||u<Ss||u>=g)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:l,k2neg:f,k2:u}}function km(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Qp(t,e){const n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return ta(n.lowS,"lowS"),ta(n.prehash,"prehash"),n.format!==void 0&&km(n.format),n}class FV extends Error{constructor(e=""){super(e)}}const fs={Err:FV,_tlv:{encode:(t,e)=>{const{Err:n}=fs;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=Wu(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?Wu(i.length/2|128):"";return Wu(t)+s+i+e},decode(t,e){const{Err:n}=fs;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++],s=!!(i&128);let o=0;if(!s)o=i;else{const c=i&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+c);if(l.length!==c)throw new n("tlv.decode: length bytes not complete");if(l[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(r+=c,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=fs;if(t<Ss)throw new e("integer: negative integers are not allowed");let n=Wu(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=fs;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return sh(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=fs,i=Rn("signature",t),{v:s,l:o}=r.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,s),{v:l,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(l)}},hexFromSig(t){const{_tlv:e,_int:n}=fs,r=e.encode(2,n.encode(t.r)),i=e.encode(2,n.encode(t.s)),s=r+i;return e.encode(48,s)}},Ss=BigInt(0),Ga=BigInt(1),cT=BigInt(2),Yu=BigInt(3),KV=BigInt(4);function $a(t,e){const{BYTES:n}=t;let r;if(typeof e=="bigint")r=e;else{let i=Rn("private key",e);try{r=t.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof e}`)}}if(!t.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function VV(t,e={}){const n=QI("weierstrass",t,e),{Fp:r,Fn:i}=n;let s=n.CURVE;const{h:o,n:a}=s;Ql(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=e;if(c&&(!r.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=uT(r,i);function u(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(V,T,p){const{x:y,y:R}=T.toAffine(),P=r.toBytes(y);if(ta(p,"isCompressed"),p){u();const _=!r.isOdd(R);return Ki(lT(_),P)}else return Ki(Uint8Array.of(4),P,r.toBytes(R))}function f(V){Si(V,void 0,"Point");const{publicKey:T,publicKeyUncompressed:p}=l,y=V.length,R=V[0],P=V.subarray(1);if(y===T&&(R===2||R===3)){const _=r.fromBytes(P);if(!r.isValid(_))throw new Error("bad point: is not on curve, wrong x");const I=w(_);let N;try{N=r.sqrt(I)}catch(m){const A=m instanceof Error?": "+m.message:"";throw new Error("bad point: is not on curve, sqrt error"+A)}u();const x=r.isOdd(N);return(R&1)===1!==x&&(N=r.neg(N)),{x:_,y:N}}else if(y===p&&R===4){const _=r.BYTES,I=r.fromBytes(P.subarray(0,_)),N=r.fromBytes(P.subarray(_,_*2));if(!b(I,N))throw new Error("bad point: is not on curve");return{x:I,y:N}}else throw new Error(`bad point: got length ${y}, expected compressed=${T} or uncompressed=${p}`)}const g=e.toBytes||d,v=e.fromBytes||f;function w(V){const T=r.sqr(V),p=r.mul(T,V);return r.add(r.add(p,r.mul(V,s.a)),s.b)}function b(V,T){const p=r.sqr(T),y=w(V);return r.eql(p,y)}if(!b(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const E=r.mul(r.pow(s.a,Yu),KV),M=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(E,M)))throw new Error("bad curve params: a or b");function S(V,T,p=!1){if(!r.isValid(T)||p&&r.is0(T))throw new Error(`bad point coordinate ${V}`);return T}function F(V){if(!(V instanceof U))throw new Error("ProjectivePoint expected")}function D(V){if(!c||!c.basises)throw new Error("no endo");return $V(V,c.basises,i.ORDER)}const z=hf((V,T)=>{const{X:p,Y:y,Z:R}=V;if(r.eql(R,r.ONE))return{x:p,y};const P=V.is0();T==null&&(T=P?r.ONE:r.inv(R));const _=r.mul(p,T),I=r.mul(y,T),N=r.mul(R,T);if(P)return{x:r.ZERO,y:r.ZERO};if(!r.eql(N,r.ONE))throw new Error("invZ was invalid");return{x:_,y:I}}),X=hf(V=>{if(V.is0()){if(e.allowInfinityPoint&&!r.is0(V.Y))return;throw new Error("bad point: ZERO")}const{x:T,y:p}=V.toAffine();if(!r.isValid(T)||!r.isValid(p))throw new Error("bad point: x or y not field elements");if(!b(T,p))throw new Error("bad point: equation left != right");if(!V.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function Y(V,T,p,y,R){return p=new U(r.mul(p.X,V),p.Y,p.Z),T=pf(y,T),p=pf(R,p),T.add(p)}class U{constructor(T,p,y){this.X=S("x",T),this.Y=S("y",p,!0),this.Z=S("z",y),Object.freeze(this)}static CURVE(){return s}static fromAffine(T){const{x:p,y}=T||{};if(!T||!r.isValid(p)||!r.isValid(y))throw new Error("invalid affine point");if(T instanceof U)throw new Error("projective point not allowed");return r.is0(p)&&r.is0(y)?U.ZERO:new U(p,y,r.ONE)}static fromBytes(T){const p=U.fromAffine(v(Si(T,void 0,"point")));return p.assertValidity(),p}static fromHex(T){return U.fromBytes(Rn("pointHex",T))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(T=8,p=!0){return H.createCache(this,T),p||this.multiply(Yu),this}assertValidity(){X(this)}hasEvenY(){const{y:T}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(T)}equals(T){F(T);const{X:p,Y:y,Z:R}=this,{X:P,Y:_,Z:I}=T,N=r.eql(r.mul(p,I),r.mul(P,R)),x=r.eql(r.mul(y,I),r.mul(_,R));return N&&x}negate(){return new U(this.X,r.neg(this.Y),this.Z)}double(){const{a:T,b:p}=s,y=r.mul(p,Yu),{X:R,Y:P,Z:_}=this;let I=r.ZERO,N=r.ZERO,x=r.ZERO,h=r.mul(R,R),m=r.mul(P,P),A=r.mul(_,_),C=r.mul(R,P);return C=r.add(C,C),x=r.mul(R,_),x=r.add(x,x),I=r.mul(T,x),N=r.mul(y,A),N=r.add(I,N),I=r.sub(m,N),N=r.add(m,N),N=r.mul(I,N),I=r.mul(C,I),x=r.mul(y,x),A=r.mul(T,A),C=r.sub(h,A),C=r.mul(T,C),C=r.add(C,x),x=r.add(h,h),h=r.add(x,h),h=r.add(h,A),h=r.mul(h,C),N=r.add(N,h),A=r.mul(P,_),A=r.add(A,A),h=r.mul(A,C),I=r.sub(I,h),x=r.mul(A,m),x=r.add(x,x),x=r.add(x,x),new U(I,N,x)}add(T){F(T);const{X:p,Y:y,Z:R}=this,{X:P,Y:_,Z:I}=T;let N=r.ZERO,x=r.ZERO,h=r.ZERO;const m=s.a,A=r.mul(s.b,Yu);let C=r.mul(p,P),$=r.mul(y,_),j=r.mul(R,I),Z=r.add(p,y),ne=r.add(P,_);Z=r.mul(Z,ne),ne=r.add(C,$),Z=r.sub(Z,ne),ne=r.add(p,R);let se=r.add(P,I);return ne=r.mul(ne,se),se=r.add(C,j),ne=r.sub(ne,se),se=r.add(y,R),N=r.add(_,I),se=r.mul(se,N),N=r.add($,j),se=r.sub(se,N),h=r.mul(m,ne),N=r.mul(A,j),h=r.add(N,h),N=r.sub($,h),h=r.add($,h),x=r.mul(N,h),$=r.add(C,C),$=r.add($,C),j=r.mul(m,j),ne=r.mul(A,ne),$=r.add($,j),j=r.sub(C,j),j=r.mul(m,j),ne=r.add(ne,j),C=r.mul($,ne),x=r.add(x,C),C=r.mul(se,ne),N=r.mul(Z,N),N=r.sub(N,C),C=r.mul(Z,$),h=r.mul(se,h),h=r.add(h,C),new U(N,x,h)}subtract(T){return this.add(T.negate())}is0(){return this.equals(U.ZERO)}multiply(T){const{endo:p}=e;if(!i.isValidNot0(T))throw new Error("invalid scalar: out of range");let y,R;const P=_=>H.cached(this,_,I=>Vo(U,I));if(p){const{k1neg:_,k1:I,k2neg:N,k2:x}=D(T),{p:h,f:m}=P(I),{p:A,f:C}=P(x);R=m.add(C),y=Y(p.beta,h,A,_,N)}else{const{p:_,f:I}=P(T);y=_,R=I}return Vo(U,[y,R])[0]}multiplyUnsafe(T){const{endo:p}=e,y=this;if(!i.isValid(T))throw new Error("invalid scalar: out of range");if(T===Ss||y.is0())return U.ZERO;if(T===Ga)return y;if(H.hasCache(this))return this.multiply(T);if(p){const{k1neg:R,k1:P,k2neg:_,k2:I}=D(T),{p1:N,p2:x}=eV(U,y,P,I);return Y(p.beta,N,x,R,_)}else return H.unsafe(y,T)}multiplyAndAddUnsafe(T,p,y){const R=this.multiplyUnsafe(p).add(T.multiplyUnsafe(y));return R.is0()?void 0:R}toAffine(T){return z(this,T)}isTorsionFree(){const{isTorsionFree:T}=e;return o===Ga?!0:T?T(U,this):H.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:T}=e;return o===Ga?this:T?T(U,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(T=!0){return ta(T,"isCompressed"),this.assertValidity(),g(U,this,T)}toHex(T=!0){return Go(this.toBytes(T))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(T=!0){return this.toBytes(T)}_setWindowSize(T){this.precompute(T)}static normalizeZ(T){return Vo(U,T)}static msm(T,p){return XI(U,i,T,p)}static fromPrivateKey(T){return U.BASE.multiply($a(i,T))}}U.BASE=new U(s.Gx,s.Gy,r.ONE),U.ZERO=new U(r.ZERO,r.ONE,r.ZERO),U.Fp=r,U.Fn=i;const B=i.BITS,H=new ZI(U,e.endo?Math.ceil(B/2):B);return U.BASE.precompute(8),U}function lT(t){return Uint8Array.of(t?2:3)}function uT(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function jV(t,e={}){const{Fn:n}=t,r=e.randomBytes||xy,i=Object.assign(uT(t.Fp,n),{seed:GI(n.ORDER)});function s(g){try{return!!$a(n,g)}catch{return!1}}function o(g,v){const{publicKey:w,publicKeyUncompressed:b}=i;try{const E=g.length;return v===!0&&E!==w||v===!1&&E!==b?!1:!!t.fromBytes(g)}catch{return!1}}function a(g=r(i.seed)){return ZK(Si(g,i.seed,"seed"),n.ORDER)}function c(g,v=!0){return t.BASE.multiply($a(n,g)).toBytes(v)}function l(g){const v=a(g);return{secretKey:v,publicKey:c(v)}}function u(g){if(typeof g=="bigint")return!1;if(g instanceof t)return!0;const{secretKey:v,publicKey:w,publicKeyUncompressed:b}=i;if(n.allowedLengths||v===w)return;const E=Rn("key",g).length;return E===w||E===b}function d(g,v,w=!0){if(u(g)===!0)throw new Error("first arg must be private key");if(u(v)===!1)throw new Error("second arg must be public key");const b=$a(n,g);return t.fromHex(v).multiply(b).toBytes(w)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:s,randomPrivateKey:a,normPrivateKeyToScalar:g=>$a(n,g),precompute(g=8,v=t.BASE){return v.precompute(g,!1)}},lengths:i})}function HV(t,e,n={}){TI(e),Ql(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||xy,i=n.hmac||((p,...y)=>aT(e,p,Ki(...y))),{Fp:s,Fn:o}=t,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:g}=jV(t,n),v={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},w="compact";function b(p){const y=a>>Ga;return p>y}function E(p,y){if(!o.isValidNot0(y))throw new Error(`invalid signature ${p}: out of range 1..Point.Fn.ORDER`);return y}function M(p,y){km(y);const R=g.signature,P=y==="compact"?R:y==="recovered"?R+1:void 0;return Si(p,P,`${y} signature`)}class S{constructor(y,R,P){this.r=E("r",y),this.s=E("s",R),P!=null&&(this.recovery=P),Object.freeze(this)}static fromBytes(y,R=w){M(y,R);let P;if(R==="der"){const{r:x,s:h}=fs.toSig(Si(y));return new S(x,h)}R==="recovered"&&(P=y[0],R="compact",y=y.subarray(1));const _=o.BYTES,I=y.subarray(0,_),N=y.subarray(_,_*2);return new S(o.fromBytes(I),o.fromBytes(N),P)}static fromHex(y,R){return this.fromBytes(ff(y),R)}addRecoveryBit(y){return new S(this.r,this.s,y)}recoverPublicKey(y){const R=s.ORDER,{r:P,s:_,recovery:I}=this;if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");if(a*cT<R&&I>1)throw new Error("recovery id is ambiguous for h>1 curve");const x=I===2||I===3?P+a:P;if(!s.isValid(x))throw new Error("recovery id 2 or 3 invalid");const h=s.toBytes(x),m=t.fromBytes(Ki(lT((I&1)===0),h)),A=o.inv(x),C=D(Rn("msgHash",y)),$=o.create(-C*A),j=o.create(_*A),Z=t.BASE.multiplyUnsafe($).add(m.multiplyUnsafe(j));if(Z.is0())throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return b(this.s)}toBytes(y=w){if(km(y),y==="der")return ff(fs.hexFromSig(this));const R=o.toBytes(this.r),P=o.toBytes(this.s);if(y==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Ki(Uint8Array.of(this.recovery),R,P)}return Ki(R,P)}toHex(y){return Go(this.toBytes(y))}assertValidity(){}static fromCompact(y){return S.fromBytes(Rn("sig",y),"compact")}static fromDER(y){return S.fromBytes(Rn("sig",y),"der")}normalizeS(){return this.hasHighS()?new S(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Go(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Go(this.toBytes("compact"))}}const F=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const R=sh(y),P=y.length*8-c;return P>0?R>>BigInt(P):R},D=n.bits2int_modN||function(y){return o.create(F(y))},z=Xl(c);function X(p){return Mm("num < 2^"+c,p,Ss,z),o.toBytes(p)}function Y(p,y){return Si(p,void 0,"message"),y?Si(e(p),void 0,"prehashed message"):p}function U(p,y,R){if(["recovered","canonical"].some($=>$ in R))throw new Error("sign() legacy options not supported");const{lowS:P,prehash:_,extraEntropy:I}=Qp(R,v);p=Y(p,_);const N=D(p),x=$a(o,y),h=[X(x),X(N)];if(I!=null&&I!==!1){const $=I===!0?r(g.secretKey):I;h.push(Rn("extraEntropy",$))}const m=Ki(...h),A=N;function C($){const j=F($);if(!o.isValidNot0(j))return;const Z=o.inv(j),ne=t.BASE.multiply(j).toAffine(),se=o.create(ne.x);if(se===Ss)return;const ue=o.create(Z*o.create(A+se*x));if(ue===Ss)return;let de=(ne.x===se?0:2)|Number(ne.y&Ga),Ae=ue;return P&&b(ue)&&(Ae=o.neg(ue),de^=1),new S(se,Ae,de)}return{seed:m,k2sig:C}}function B(p,y,R={}){p=Rn("message",p);const{seed:P,k2sig:_}=U(p,y,R);return KK(e.outputLen,o.BYTES,i)(P,_)}function H(p){let y;const R=typeof p=="string"||Zl(p),P=!R&&p!==null&&typeof p=="object"&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!R&&!P)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(P)y=new S(p.r,p.s);else if(R){try{y=S.fromBytes(Rn("sig",p),"der")}catch(_){if(!(_ instanceof fs.Err))throw _}if(!y)try{y=S.fromBytes(Rn("sig",p),"compact")}catch{return!1}}return y||!1}function V(p,y,R,P={}){const{lowS:_,prehash:I,format:N}=Qp(P,v);if(R=Rn("publicKey",R),y=Y(Rn("message",y),I),"strict"in P)throw new Error("options.strict was renamed to lowS");const x=N===void 0?H(p):S.fromBytes(Rn("sig",p),N);if(x===!1)return!1;try{const h=t.fromBytes(R);if(_&&x.hasHighS())return!1;const{r:m,s:A}=x,C=D(y),$=o.inv(A),j=o.create(C*$),Z=o.create(m*$),ne=t.BASE.multiplyUnsafe(j).add(h.multiplyUnsafe(Z));return ne.is0()?!1:o.create(ne.x)===m}catch{return!1}}function T(p,y,R={}){const{prehash:P}=Qp(R,v);return y=Y(y,P),S.fromBytes(p,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:g,Point:t,sign:B,verify:V,recoverPublicKey:T,Signature:S,hash:e})}function zV(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp;let r=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const i=ca(e.n,{BITS:t.nBitLength,allowedLengths:r,modFromBytes:t.wrapPrivateKey}),s={Fp:n,Fn:i,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:s}}function qV(t){const{CURVE:e,curveOpts:n}=zV(t),r={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:n,hash:t.hash,ecdsaOpts:r}}function WV(t,e){const n=e.Point;return Object.assign({},e,{ProjectivePoint:n,CURVE:Object.assign({},t,qI(n.Fn.ORDER,n.Fn.BITS))})}function GV(t){const{CURVE:e,curveOpts:n,hash:r,ecdsaOpts:i}=qV(t),s=VV(e,n),o=HV(s,r,i);return WV(t,o)}function YV(t,e){const n=r=>GV({...t,hash:r});return{...n(e),create:n}}const My={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},JV={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Jb=BigInt(2);function ZV(t){const e=My.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,d=An(u,n,e)*u%e,f=An(d,n,e)*u%e,g=An(f,Jb,e)*l%e,v=An(g,i,e)*g%e,w=An(v,s,e)*v%e,b=An(w,a,e)*w%e,E=An(b,c,e)*b%e,M=An(E,a,e)*w%e,S=An(M,n,e)*u%e,F=An(S,o,e)*v%e,D=An(F,r,e)*l%e,z=An(D,Jb,e);if(!Dm.eql(Dm.sqr(z),t))throw new Error("Cannot find square root");return z}const Dm=ca(My.p,{sqrt:ZV}),XV=YV({...My,Fp:Dm,lowS:!0,endo:JV},kI);eu.utils.randomPrivateKey;eu.getPublicKey;function Zb(t){try{return eu.ExtendedPoint.fromHex(t),!0}catch{return!1}}const dT=(t,e)=>eu.sign(t,e.slice(0,32)),QV=eu.verify,ky=t=>Et.Buffer.isBuffer(t)?t:t instanceof Uint8Array?Et.Buffer.from(t.buffer,t.byteOffset,t.byteLength):Et.Buffer.from(t);class ej{constructor(e){Object.assign(this,e)}encode(){return Et.Buffer.from(Jp.serialize(Rd,this))}static decode(e){return Jp.deserialize(Rd,this,e)}static decodeUnchecked(e){return Jp.deserializeUnchecked(Rd,this,e)}}const Rd=new Map;var fT;const tj=32,ho=32;function nj(t){return t._bn!==void 0}let Xb=1;class At extends ej{constructor(e){if(super({}),this._bn=void 0,nj(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Ar.decode(e);if(n.length!=ho)throw new Error("Invalid public key input");this._bn=new $b(n)}else this._bn=new $b(e);if(this._bn.byteLength()>ho)throw new Error("Invalid public key input")}}static unique(){const e=new At(Xb);return Xb+=1,new At(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ar.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Et.Buffer);if(e.length===ho)return e;const n=Et.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const i=Et.Buffer.concat([e.toBuffer(),Et.Buffer.from(n),r.toBuffer()]),s=jb(i);return new At(s)}static createProgramAddressSync(e,n){let r=Et.Buffer.alloc(0);e.forEach(function(s){if(s.length>tj)throw new TypeError("Max seed length exceeded");r=Et.Buffer.concat([r,ky(s)])}),r=Et.Buffer.concat([r,n.toBuffer(),Et.Buffer.from("ProgramDerivedAddress")]);const i=jb(r);if(Zb(i))throw new Error("Invalid seeds, address must fall off the curve");return new At(i)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,i;for(;r!=0;){try{const s=e.concat(Et.Buffer.from([r]));i=this.createProgramAddressSync(s,n)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[i,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new At(e);return Zb(n.toBytes())}}fT=At;At.default=new fT("11111111111111111111111111111111");Rd.set(At,{kind:"struct",fields:[["_bn","u256"]]});new At("BPFLoader1111111111111111111111111111111111");const Ya=1232,Dy=127,Ef=64;class bf{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((s,o)=>{r.set(s.toBase58(),o)});const i=s=>{const o=r.get(s.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(s=>({programIdIndex:i(s.programId),accountKeyIndexes:s.keys.map(o=>i(o.pubkey)),data:s.data}))}}const $t=(t="publicKey")=>ie.blob(32,t),rj=(t="signature")=>ie.blob(64,t),Fa=(t="string")=>{const e=ie.struct([ie.u32("length"),ie.u32("lengthPadding"),ie.blob(ie.offset(ie.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),i=e;return i.decode=(s,o)=>n(s,o).chars.toString(),i.encode=(s,o,a)=>{const c={chars:Et.Buffer.from(s,"utf8")};return r(c,o,a)},i.alloc=s=>ie.u32().span+ie.u32().span+Et.Buffer.from(s,"utf8").length,i},ij=(t="authorized")=>ie.struct([$t("staker"),$t("withdrawer")],t),sj=(t="lockup")=>ie.struct([ie.ns64("unixTimestamp"),ie.ns64("epoch"),$t("custodian")],t),oj=(t="voteInit")=>ie.struct([$t("nodePubkey"),$t("authorizedVoter"),$t("authorizedWithdrawer"),ie.u8("commission")],t),aj=(t="voteAuthorizeWithSeedArgs")=>ie.struct([ie.u32("voteAuthorizationType"),$t("currentAuthorityDerivedKeyOwnerPubkey"),Fa("currentAuthorityDerivedKeySeed"),$t("newAuthorized")],t);function Yr(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function Jr(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function $n(t,e){if(!t)throw new Error(e||"Assertion failed")}class ah{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,i=o=>{const a=o.toBase58();let c=r.get(a);return c===void 0&&(c={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,c)),c},s=i(n);s.isSigner=!0,s.isWritable=!0;for(const o of e){i(o.programId).isInvoked=!0;for(const a of o.keys){const c=i(a.pubkey);c.isSigner||=a.isSigner,c.isWritable||=a.isWritable}}return new ah(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];$n(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,c])=>c.isSigner&&c.isWritable),r=e.filter(([,c])=>c.isSigner&&!c.isWritable),i=e.filter(([,c])=>!c.isSigner&&c.isWritable),s=e.filter(([,c])=>!c.isSigner&&!c.isWritable),o={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{$n(n.length>0,"Expected at least one writable signer key");const[c]=n[0];$n(c===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([c])=>new At(c)),...r.map(([c])=>new At(c)),...i.map(([c])=>new At(c)),...s.map(([c])=>new At(c))];return[o,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,s]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(n.length===0&&i.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:i},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(e,n){const r=new Array,i=new Array;for(const[s,o]of this.keyMetaMap.entries())if(n(o)){const a=new At(s),c=e.findIndex(l=>l.equals(a));c>=0&&($n(c<256,"Max lookup table index exceeded"),r.push(c),i.push(a),this.keyMetaMap.delete(s))}return[r,i]}}const hT="Reached end of buffer unexpectedly";function ys(t){if(t.length===0)throw new Error(hT);return t.shift()}function Zr(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(hT);return t.splice(...e)}class dc{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new At(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ar.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new bf(this.staticAccountKeys)}static compile(e){const n=ah.compile(e.instructions,e.payerKey),[r,i]=n.getMessageComponents(),o=new bf(i).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Ar.encode(a.data)}));return new dc({header:r,accountKeys:i,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,s=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<s}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];Jr(n,e);const r=this.instructions.map(d=>{const{accounts:f,programIdIndex:g}=d,v=Array.from(Ar.decode(d.data));let w=[];Jr(w,f.length);let b=[];return Jr(b,v.length),{programIdIndex:g,keyIndicesCount:Et.Buffer.from(w),keyIndices:f,dataLength:Et.Buffer.from(b),data:v}});let i=[];Jr(i,r.length);let s=Et.Buffer.alloc(Ya);Et.Buffer.from(i).copy(s);let o=i.length;r.forEach(d=>{const g=ie.struct([ie.u8("programIdIndex"),ie.blob(d.keyIndicesCount.length,"keyIndicesCount"),ie.seq(ie.u8("keyIndex"),d.keyIndices.length,"keyIndices"),ie.blob(d.dataLength.length,"dataLength"),ie.seq(ie.u8("userdatum"),d.data.length,"data")]).encode(d,s,o);o+=g}),s=s.slice(0,o);const a=ie.struct([ie.blob(1,"numRequiredSignatures"),ie.blob(1,"numReadonlySignedAccounts"),ie.blob(1,"numReadonlyUnsignedAccounts"),ie.blob(n.length,"keyCount"),ie.seq($t("key"),e,"keys"),$t("recentBlockhash")]),c={numRequiredSignatures:Et.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Et.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Et.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Et.Buffer.from(n),keys:this.accountKeys.map(d=>ky(d.toBytes())),recentBlockhash:Ar.decode(this.recentBlockhash)};let l=Et.Buffer.alloc(2048);const u=a.encode(c,l);return s.copy(l,u),l.slice(0,u+s.length)}static from(e){let n=[...e];const r=ys(n);if(r!==(r&Dy))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=ys(n),s=ys(n),o=Yr(n);let a=[];for(let f=0;f<o;f++){const g=Zr(n,0,ho);a.push(new At(Et.Buffer.from(g)))}const c=Zr(n,0,ho),l=Yr(n);let u=[];for(let f=0;f<l;f++){const g=ys(n),v=Yr(n),w=Zr(n,0,v),b=Yr(n),E=Zr(n,0,b),M=Ar.encode(Et.Buffer.from(E));u.push({programIdIndex:g,accounts:w,data:M})}const d={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:Ar.encode(Et.Buffer.from(c)),accountKeys:a,instructions:u};return new dc(d)}}class _f{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new bf(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const i=e-r,s=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<s}else if(e>=this.header.numRequiredSignatures){const i=e-n,o=r-n-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=n-this.header.numReadonlySignedAccounts;return e<i}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const i=e.find(s=>s.key.equals(r.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const s of r.writableIndexes)if(s<i.state.addresses.length)n.writable.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(const s of r.readonlyIndexes)if(s<i.state.addresses.length)n.readonly.push(i.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=ah.compile(e.instructions,e.payerKey),r=new Array,i={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(const u of s){const d=n.extractTableLookup(u);if(d!==void 0){const[f,{writable:g,readonly:v}]=d;r.push(f),i.writable.push(...g),i.readonly.push(...v)}}const[o,a]=n.getMessageComponents(),l=new bf(a,i).compileInstructions(e.instructions);return new _f({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:l,addressTableLookups:r})}serialize(){const e=Array();Jr(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Jr(r,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),s=Array();Jr(s,this.addressTableLookups.length);const o=ie.struct([ie.u8("prefix"),ie.struct([ie.u8("numRequiredSignatures"),ie.u8("numReadonlySignedAccounts"),ie.u8("numReadonlyUnsignedAccounts")],"header"),ie.blob(e.length,"staticAccountKeysLength"),ie.seq($t(),this.staticAccountKeys.length,"staticAccountKeys"),$t("recentBlockhash"),ie.blob(r.length,"instructionsLength"),ie.blob(n.length,"serializedInstructions"),ie.blob(s.length,"addressTableLookupsLength"),ie.blob(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(Ya),l=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(u=>u.toBytes()),recentBlockhash:Ar.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:i},a);return a.slice(0,l)}serializeInstructions(){let e=0;const n=new Uint8Array(Ya);for(const r of this.compiledInstructions){const i=Array();Jr(i,r.accountKeyIndexes.length);const s=Array();Jr(s,r.data.length);const o=ie.struct([ie.u8("programIdIndex"),ie.blob(i.length,"encodedAccountKeyIndexesLength"),ie.seq(ie.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),ie.blob(s.length,"encodedDataLength"),ie.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(Ya);for(const r of this.addressTableLookups){const i=Array();Jr(i,r.writableIndexes.length);const s=Array();Jr(s,r.readonlyIndexes.length);const o=ie.struct([$t("accountKey"),ie.blob(i.length,"encodedWritableIndexesLength"),ie.seq(ie.u8(),r.writableIndexes.length,"writableIndexes"),ie.blob(s.length,"encodedReadonlyIndexesLength"),ie.seq(ie.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=ys(n),i=r&Dy;$n(r!==i,"Expected versioned message but received legacy message");const s=i;$n(s===0,`Expected versioned message with version 0 but found version ${s}`);const o={numRequiredSignatures:ys(n),numReadonlySignedAccounts:ys(n),numReadonlyUnsignedAccounts:ys(n)},a=[],c=Yr(n);for(let v=0;v<c;v++)a.push(new At(Zr(n,0,ho)));const l=Ar.encode(Zr(n,0,ho)),u=Yr(n),d=[];for(let v=0;v<u;v++){const w=ys(n),b=Yr(n),E=Zr(n,0,b),M=Yr(n),S=new Uint8Array(Zr(n,0,M));d.push({programIdIndex:w,accountKeyIndexes:E,data:S})}const f=Yr(n),g=[];for(let v=0;v<f;v++){const w=new At(Zr(n,0,ho)),b=Yr(n),E=Zr(n,0,b),M=Yr(n),S=Zr(n,0,M);g.push({accountKey:w,writableIndexes:E,readonlyIndexes:S})}return new _f({header:o,staticAccountKeys:a,recentBlockhash:l,compiledInstructions:d,addressTableLookups:g})}}const pT={deserializeMessageVersion(t){const e=t[0],n=e&Dy;return n===e?"legacy":n},deserialize:t=>{const e=pT.deserializeMessageVersion(t);if(e==="legacy")return dc.from(t);if(e===0)return _f.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},cj=Et.Buffer.alloc(Ef).fill(0);class Qb{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Et.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Sf{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new Qb(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let w=0;w<n.length;w++)if(n[w].programId===void 0)throw new Error(`Transaction instruction index ${w} has undefined program id`);const i=[],s=[];n.forEach(w=>{w.keys.forEach(E=>{s.push({...E})});const b=w.programId.toString();i.includes(b)||i.push(b)}),i.forEach(w=>{s.push({pubkey:new At(w),isSigner:!1,isWritable:!1})});const o=[];s.forEach(w=>{const b=w.pubkey.toString(),E=o.findIndex(M=>M.pubkey.toString()===b);E>-1?(o[E].isWritable=o[E].isWritable||w.isWritable,o[E].isSigner=o[E].isSigner||w.isSigner):o.push(w)}),o.sort(function(w,b){if(w.isSigner!==b.isSigner)return w.isSigner?-1:1;if(w.isWritable!==b.isWritable)return w.isWritable?-1:1;const E={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return w.pubkey.toBase58().localeCompare(b.pubkey.toBase58(),"en",E)});const a=o.findIndex(w=>w.pubkey.equals(r));if(a>-1){const[w]=o.splice(a,1);w.isSigner=!0,w.isWritable=!0,o.unshift(w)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const w of this.signatures){const b=o.findIndex(E=>E.pubkey.equals(w.publicKey));if(b>-1)o[b].isSigner||(o[b].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${w.publicKey.toString()}`)}let c=0,l=0,u=0;const d=[],f=[];o.forEach(({pubkey:w,isSigner:b,isWritable:E})=>{b?(d.push(w.toString()),c+=1,E||(l+=1)):(f.push(w.toString()),E||(u+=1))});const g=d.concat(f),v=n.map(w=>{const{data:b,programId:E}=w;return{programIdIndex:g.indexOf(E.toString()),accounts:w.keys.map(M=>g.indexOf(M.pubkey.toString())),data:Ar.encode(b)}});return v.forEach(w=>{$n(w.programIdIndex>=0),w.accounts.forEach(b=>$n(b>=0))}),new dc({header:{numRequiredSignatures:c,numReadonlySignedAccounts:l,numReadonlyUnsignedAccounts:u},accountKeys:g,recentBlockhash:e,instructions:v})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((i,s)=>n[s].equals(i.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const i=r.toString();return n.has(i)?!1:(n.add(i),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const s of e){const o=s.publicKey.toString();n.has(o)||(n.add(o),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));const i=this._compile();this._partialSign(i,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const s of e){const o=s.publicKey.toString();n.has(o)||(n.add(o),r.push(s))}const i=this._compile();this._partialSign(i,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(i=>{const s=dT(r,i.secretKey);this._addSignature(i.publicKey,ky(s))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){$n(n.length===64);const r=this.signatures.findIndex(i=>e.equals(i.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=Et.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:i,publicKey:s}of this.signatures)i===null?n&&(r.missing||=[]).push(s):QV(i,e,s.toBytes())||(r.invalid||=[]).push(s);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),i=this.serializeMessage();if(r){const s=this._getMessageSignednessErrors(i,n);if(s){let o="Signature verification failed.";throw s.invalid&&(o+=`
|
|
559
|
+
Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),s.missing&&(o+=`
|
|
560
|
+
Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(e){const{signatures:n}=this,r=[];Jr(r,n.length);const i=r.length+n.length*64+e.length,s=Et.Buffer.alloc(i);return $n(n.length<256),Et.Buffer.from(r).copy(s,0),n.forEach(({signature:o},a)=>{o!==null&&($n(o.length===64,"signature has invalid length"),Et.Buffer.from(o).copy(s,r.length+a*64))}),e.copy(s,r.length+n.length*64),$n(s.length<=Ya,`Transaction too large: ${s.length} > ${Ya}`),s}get keys(){return $n(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return $n(this.instructions.length===1),this.instructions[0].programId}get data(){return $n(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Yr(n);let i=[];for(let s=0;s<r;s++){const o=Zr(n,0,Ef);i.push(Ar.encode(Et.Buffer.from(o)))}return Sf.populate(dc.from(n),i)}static populate(e,n=[]){const r=new Sf;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((i,s)=>{const o={signature:i==Ar.encode(cj)?null:Ar.decode(i),publicKey:e.accountKeys[s]};r.signatures.push(o)}),e.instructions.forEach(i=>{const s=i.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(c=>c.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new Qb({keys:s,programId:e.accountKeys[i.programIdIndex],data:Ar.decode(i.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Ly{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)$n(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let i=0;i<e.header.numRequiredSignatures;i++)r.push(new Uint8Array(Ef));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Jr(n,this.signatures.length);const r=ie.struct([ie.blob(n.length,"encodedSignaturesLength"),ie.seq(rj(),this.signatures.length,"signatures"),ie.blob(e.length,"serializedMessage")]),i=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},i);return i.slice(0,s)}static deserialize(e){let n=[...e];const r=[],i=Yr(n);for(let o=0;o<i;o++)r.push(new Uint8Array(Zr(n,0,Ef)));const s=pT.deserialize(new Uint8Array(n));return new Ly(s,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const i of e){const s=r.findIndex(o=>o.equals(i.publicKey));$n(s>=0,`Cannot sign with non signer key ${i.publicKey.toBase58()}`),this.signatures[s]=dT(n,i.secretKey)}}addSignature(e,n){$n(n.byteLength===64,"Signature must be 64 bytes long");const i=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));$n(i>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[i]=n}}new At("SysvarC1ock11111111111111111111111111111111");new At("SysvarEpochSchedu1e111111111111111111111111");new At("Sysvar1nstructions1111111111111111111111111");new At("SysvarRecentB1ockHashes11111111111111111111");new At("SysvarRent111111111111111111111111111111111");new At("SysvarRewards111111111111111111111111111111");new At("SysvarS1otHashes111111111111111111111111111");new At("SysvarS1otHistory11111111111111111111111111");new At("SysvarStakeHistory1111111111111111111111111");const lj=ie.nu64("lamportsPerSignature"),uj=ie.struct([ie.u32("version"),ie.u32("state"),$t("authorizedPubkey"),$t("nonce"),ie.struct([lj],"feeCalculator")]);uj.span;function fc(t){const e=ie.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),i=e,s=m$();return i.decode=(o,a)=>{const c=n(o,a);return s.decode(c)},i.encode=(o,a,c)=>{const l=s.encode(o);return r(l,a,c)},i}Object.freeze({Create:{index:0,layout:ie.struct([ie.u32("instruction"),ie.ns64("lamports"),ie.ns64("space"),$t("programId")])},Assign:{index:1,layout:ie.struct([ie.u32("instruction"),$t("programId")])},Transfer:{index:2,layout:ie.struct([ie.u32("instruction"),fc("lamports")])},CreateWithSeed:{index:3,layout:ie.struct([ie.u32("instruction"),$t("base"),Fa("seed"),ie.ns64("lamports"),ie.ns64("space"),$t("programId")])},AdvanceNonceAccount:{index:4,layout:ie.struct([ie.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:ie.struct([ie.u32("instruction"),ie.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:ie.struct([ie.u32("instruction"),$t("authorized")])},AuthorizeNonceAccount:{index:7,layout:ie.struct([ie.u32("instruction"),$t("authorized")])},Allocate:{index:8,layout:ie.struct([ie.u32("instruction"),ie.ns64("space")])},AllocateWithSeed:{index:9,layout:ie.struct([ie.u32("instruction"),$t("base"),Fa("seed"),ie.ns64("space"),$t("programId")])},AssignWithSeed:{index:10,layout:ie.struct([ie.u32("instruction"),$t("base"),Fa("seed"),$t("programId")])},TransferWithSeed:{index:11,layout:ie.struct([ie.u32("instruction"),fc("lamports"),Fa("seed"),$t("programId")])},UpgradeNonceAccount:{index:12,layout:ie.struct([ie.u32("instruction")])}});new At("11111111111111111111111111111111");new At("BPFLoader2111111111111111111111111111111111");ie.struct([ie.u32("typeIndex"),fc("deactivationSlot"),ie.nu64("lastExtendedSlot"),ie.u8("lastExtendedStartIndex"),ie.u8(),ie.seq($t(),ie.offset(ie.u8(),-1),"authority")]);const Tn=ru(Ny(At),Fe(),t=>new At(t)),mT=Py([Fe(),mn("base64")]),By=ru(Ny(Et.Buffer),mT,t=>Et.Buffer.from(t[0],"base64"));function gT(t){return Cr([Pe({jsonrpc:mn("2.0"),id:Fe(),result:t}),Pe({jsonrpc:mn("2.0"),id:Fe(),error:Pe({code:Ic(),message:Fe(),data:lt(DV())})})])}const dj=gT(Ic());function cn(t){return ru(gT(t),dj,e=>"error"in e?e:{...e,result:Dl(e.result,t)})}function Ci(t){return cn(Pe({context:Pe({slot:fe()}),value:t}))}function ch(t){return Pe({context:Pe({slot:fe()}),value:t})}const fj=Pe({foundation:fe(),foundationTerm:fe(),initial:fe(),taper:fe(),terminal:fe()});cn(tt(nt(Pe({epoch:fe(),effectiveSlot:fe(),amount:fe(),postBalance:fe(),commission:lt(nt(fe()))}))));const hj=tt(Pe({slot:fe(),prioritizationFee:fe()})),pj=Pe({total:fe(),validator:fe(),foundation:fe(),epoch:fe()}),mj=Pe({epoch:fe(),slotIndex:fe(),slotsInEpoch:fe(),absoluteSlot:fe(),blockHeight:lt(fe()),transactionCount:lt(fe())}),gj=Pe({slotsPerEpoch:fe(),leaderScheduleSlotOffset:fe(),warmup:Xi(),firstNormalEpoch:fe(),firstNormalSlot:fe()}),yj=iT(Fe(),tt(fe())),ua=nt(Cr([Pe({}),Fe()])),wj=Pe({err:ua}),vj=mn("receivedSignature");Pe({"solana-core":Fe(),"feature-set":lt(fe())});const Ej=Pe({program:Fe(),programId:Tn,parsed:Ic()}),bj=Pe({programId:Tn,accounts:tt(Tn),data:Fe()});Ci(Pe({err:nt(Cr([Pe({}),Fe()])),logs:nt(tt(Fe())),accounts:lt(nt(tt(nt(Pe({executable:Xi(),owner:Fe(),lamports:fe(),data:tt(Fe()),rentEpoch:lt(fe())}))))),unitsConsumed:lt(fe()),returnData:lt(nt(Pe({programId:Fe(),data:Py([Fe(),mn("base64")])}))),innerInstructions:lt(nt(tt(Pe({index:fe(),instructions:tt(Cr([Ej,bj]))}))))}));Ci(Pe({byIdentity:iT(Fe(),tt(fe())),range:Pe({firstSlot:fe(),lastSlot:fe()})}));cn(fj);cn(pj);cn(hj);cn(mj);cn(gj);cn(yj);cn(fe());Ci(Pe({total:fe(),circulating:fe(),nonCirculating:fe(),nonCirculatingAccounts:tt(Tn)}));const _j=Pe({amount:Fe(),uiAmount:nt(fe()),decimals:fe(),uiAmountString:lt(Fe())});Ci(tt(Pe({address:Tn,amount:Fe(),uiAmount:nt(fe()),decimals:fe(),uiAmountString:lt(Fe())})));Ci(tt(Pe({pubkey:Tn,account:Pe({executable:Xi(),owner:Tn,lamports:fe(),data:By,rentEpoch:fe()})})));const Lm=Pe({program:Fe(),parsed:Ic(),space:fe()});Ci(tt(Pe({pubkey:Tn,account:Pe({executable:Xi(),owner:Tn,lamports:fe(),data:Lm,rentEpoch:fe()})})));Ci(tt(Pe({lamports:fe(),address:Tn})));const Uy=Pe({executable:Xi(),owner:Tn,lamports:fe(),data:By,rentEpoch:fe()});Pe({pubkey:Tn,account:Uy});const Sj=ru(Cr([Ny(Et.Buffer),Lm]),Cr([mT,Lm]),t=>Array.isArray(t)?Dl(t,By):t),xj=Pe({executable:Xi(),owner:Tn,lamports:fe(),data:Sj,rentEpoch:fe()});Pe({pubkey:Tn,account:xj});Pe({state:Cr([mn("active"),mn("inactive"),mn("activating"),mn("deactivating")]),active:fe(),inactive:fe()});cn(tt(Pe({signature:Fe(),slot:fe(),err:ua,memo:nt(Fe()),blockTime:lt(nt(fe()))})));cn(tt(Pe({signature:Fe(),slot:fe(),err:ua,memo:nt(Fe()),blockTime:lt(nt(fe()))})));Pe({subscription:fe(),result:ch(Uy)});const Aj=Pe({pubkey:Tn,account:Uy});Pe({subscription:fe(),result:ch(Aj)});const Rj=Pe({parent:fe(),slot:fe(),root:fe()});Pe({subscription:fe(),result:Rj});const Ij=Cr([Pe({type:Cr([mn("firstShredReceived"),mn("completed"),mn("optimisticConfirmation"),mn("root")]),slot:fe(),timestamp:fe()}),Pe({type:mn("createdBank"),parent:fe(),slot:fe(),timestamp:fe()}),Pe({type:mn("frozen"),slot:fe(),timestamp:fe(),stats:Pe({numTransactionEntries:fe(),numSuccessfulTransactions:fe(),numFailedTransactions:fe(),maxTransactionsPerEntry:fe()})}),Pe({type:mn("dead"),slot:fe(),timestamp:fe(),err:Fe()})]);Pe({subscription:fe(),result:Ij});Pe({subscription:fe(),result:ch(Cr([wj,vj]))});Pe({subscription:fe(),result:fe()});Pe({pubkey:Fe(),gossip:nt(Fe()),tpu:nt(Fe()),rpc:nt(Fe()),version:nt(Fe())});const e_=Pe({votePubkey:Fe(),nodePubkey:Fe(),activatedStake:fe(),epochVoteAccount:Xi(),epochCredits:tt(Py([fe(),fe(),fe()])),commission:fe(),lastVote:fe(),rootSlot:nt(fe())});cn(Pe({current:tt(e_),delinquent:tt(e_)}));const Tj=Cr([mn("processed"),mn("confirmed"),mn("finalized")]),Cj=Pe({slot:fe(),confirmations:nt(fe()),err:ua,confirmationStatus:lt(Tj)});Ci(tt(nt(Cj)));cn(fe());const yT=Pe({accountKey:Tn,writableIndexes:tt(fe()),readonlyIndexes:tt(fe())}),$y=Pe({signatures:tt(Fe()),message:Pe({accountKeys:tt(Fe()),header:Pe({numRequiredSignatures:fe(),numReadonlySignedAccounts:fe(),numReadonlyUnsignedAccounts:fe()}),instructions:tt(Pe({accounts:tt(fe()),data:Fe(),programIdIndex:fe()})),recentBlockhash:Fe(),addressTableLookups:lt(tt(yT))})}),wT=Pe({pubkey:Tn,signer:Xi(),writable:Xi(),source:lt(Cr([mn("transaction"),mn("lookupTable")]))}),vT=Pe({accountKeys:tt(wT),signatures:tt(Fe())}),ET=Pe({parsed:Ic(),program:Fe(),programId:Tn}),bT=Pe({accounts:tt(Tn),data:Fe(),programId:Tn}),Oj=Cr([bT,ET]),Nj=Cr([Pe({parsed:Ic(),program:Fe(),programId:Fe()}),Pe({accounts:tt(Fe()),data:Fe(),programId:Fe()})]),_T=ru(Oj,Nj,t=>"accounts"in t?Dl(t,bT):Dl(t,ET)),ST=Pe({signatures:tt(Fe()),message:Pe({accountKeys:tt(wT),instructions:tt(_T),recentBlockhash:Fe(),addressTableLookups:lt(nt(tt(yT)))})}),xf=Pe({accountIndex:fe(),mint:Fe(),owner:lt(Fe()),programId:lt(Fe()),uiTokenAmount:_j}),xT=Pe({writable:tt(Tn),readonly:tt(Tn)}),lh=Pe({err:ua,fee:fe(),innerInstructions:lt(nt(tt(Pe({index:fe(),instructions:tt(Pe({accounts:tt(fe()),data:Fe(),programIdIndex:fe()}))})))),preBalances:tt(fe()),postBalances:tt(fe()),logMessages:lt(nt(tt(Fe()))),preTokenBalances:lt(nt(tt(xf))),postTokenBalances:lt(nt(tt(xf))),loadedAddresses:lt(xT),computeUnitsConsumed:lt(fe()),costUnits:lt(fe())}),Fy=Pe({err:ua,fee:fe(),innerInstructions:lt(nt(tt(Pe({index:fe(),instructions:tt(_T)})))),preBalances:tt(fe()),postBalances:tt(fe()),logMessages:lt(nt(tt(Fe()))),preTokenBalances:lt(nt(tt(xf))),postTokenBalances:lt(nt(tt(xf))),loadedAddresses:lt(xT),computeUnitsConsumed:lt(fe()),costUnits:lt(fe())}),Tc=Cr([mn(0),mn("legacy")]),da=Pe({pubkey:Fe(),lamports:fe(),postBalance:nt(fe()),rewardType:nt(Fe()),commission:lt(nt(fe()))});cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),transactions:tt(Pe({transaction:$y,meta:nt(lh),version:lt(Tc)})),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),transactions:tt(Pe({transaction:vT,meta:nt(lh),version:lt(Tc)})),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),transactions:tt(Pe({transaction:ST,meta:nt(Fy),version:lt(Tc)})),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),transactions:tt(Pe({transaction:vT,meta:nt(Fy),version:lt(Tc)})),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),rewards:lt(tt(da)),blockTime:nt(fe()),blockHeight:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),transactions:tt(Pe({transaction:$y,meta:nt(lh)})),rewards:lt(tt(da)),blockTime:nt(fe())})));cn(nt(Pe({blockhash:Fe(),previousBlockhash:Fe(),parentSlot:fe(),signatures:tt(Fe()),blockTime:nt(fe())})));cn(nt(Pe({slot:fe(),meta:nt(lh),blockTime:lt(nt(fe())),transaction:$y,version:lt(Tc)})));cn(nt(Pe({slot:fe(),transaction:ST,meta:nt(Fy),blockTime:lt(nt(fe())),version:lt(Tc)})));Ci(Pe({blockhash:Fe(),lastValidBlockHeight:fe()}));Ci(Xi());const Pj=Pe({slot:fe(),numTransactions:fe(),numSlots:fe(),samplePeriodSecs:fe()});cn(tt(Pj));Ci(nt(Pe({feeCalculator:Pe({lamportsPerSignature:fe()})})));cn(Fe());cn(Fe());const Mj=Pe({err:ua,logs:tt(Fe()),signature:Fe()});Pe({result:ch(Mj),subscription:fe()});Object.freeze({CreateLookupTable:{index:0,layout:ie.struct([ie.u32("instruction"),fc("recentSlot"),ie.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:ie.struct([ie.u32("instruction")])},ExtendLookupTable:{index:2,layout:ie.struct([ie.u32("instruction"),fc(),ie.seq($t(),ie.offset(ie.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:ie.struct([ie.u32("instruction")])},CloseLookupTable:{index:4,layout:ie.struct([ie.u32("instruction")])}});new At("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:ie.struct([ie.u8("instruction"),ie.u32("units"),ie.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:ie.struct([ie.u8("instruction"),ie.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:ie.struct([ie.u8("instruction"),ie.u32("units")])},SetComputeUnitPrice:{index:3,layout:ie.struct([ie.u8("instruction"),fc("microLamports")])}});new At("ComputeBudget111111111111111111111111111111");ie.struct([ie.u8("numSignatures"),ie.u8("padding"),ie.u16("signatureOffset"),ie.u16("signatureInstructionIndex"),ie.u16("publicKeyOffset"),ie.u16("publicKeyInstructionIndex"),ie.u16("messageDataOffset"),ie.u16("messageDataSize"),ie.u16("messageInstructionIndex")]);new At("Ed25519SigVerify111111111111111111111111111");XV.utils.isValidPrivateKey;ie.struct([ie.u8("numSignatures"),ie.u16("signatureOffset"),ie.u8("signatureInstructionIndex"),ie.u16("ethAddressOffset"),ie.u8("ethAddressInstructionIndex"),ie.u16("messageDataOffset"),ie.u16("messageDataSize"),ie.u8("messageInstructionIndex"),ie.blob(20,"ethAddress"),ie.blob(64,"signature"),ie.u8("recoveryId")]);new At("KeccakSecp256k11111111111111111111111111111");var AT;new At("StakeConfig11111111111111111111111111111111");class RT{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}AT=RT;RT.default=new AT(0,0,At.default);Object.freeze({Initialize:{index:0,layout:ie.struct([ie.u32("instruction"),ij(),sj()])},Authorize:{index:1,layout:ie.struct([ie.u32("instruction"),$t("newAuthorized"),ie.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:ie.struct([ie.u32("instruction")])},Split:{index:3,layout:ie.struct([ie.u32("instruction"),ie.ns64("lamports")])},Withdraw:{index:4,layout:ie.struct([ie.u32("instruction"),ie.ns64("lamports")])},Deactivate:{index:5,layout:ie.struct([ie.u32("instruction")])},Merge:{index:7,layout:ie.struct([ie.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:ie.struct([ie.u32("instruction"),$t("newAuthorized"),ie.u32("stakeAuthorizationType"),Fa("authoritySeed"),$t("authorityOwner")])}});new At("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:ie.struct([ie.u32("instruction"),oj()])},Authorize:{index:1,layout:ie.struct([ie.u32("instruction"),$t("newAuthorized"),ie.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:ie.struct([ie.u32("instruction"),ie.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:ie.struct([ie.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:ie.struct([ie.u32("instruction"),aj()])}});new At("Vote111111111111111111111111111111111111111");new At("Va1idator1nfo111111111111111111111111111111");Pe({name:Fe(),website:lt(Fe()),details:lt(Fe()),iconUrl:lt(Fe()),keybaseUsername:lt(Fe())});new At("Vote111111111111111111111111111111111111111");ie.struct([$t("nodePubkey"),$t("authorizedWithdrawer"),ie.u8("commission"),ie.nu64(),ie.seq(ie.struct([ie.nu64("slot"),ie.u32("confirmationCount")]),ie.offset(ie.u32(),-8),"votes"),ie.u8("rootSlotValid"),ie.nu64("rootSlot"),ie.nu64(),ie.seq(ie.struct([ie.nu64("epoch"),$t("authorizedVoter")]),ie.offset(ie.u32(),-8),"authorizedVoters"),ie.struct([ie.seq(ie.struct([$t("authorizedPubkey"),ie.nu64("epochOfLastAuthorizedSwitch"),ie.nu64("targetEpoch")]),32,"buf"),ie.nu64("idx"),ie.u8("isEmpty")],"priorVoters"),ie.nu64(),ie.seq(ie.struct([ie.nu64("epoch"),ie.nu64("credits"),ie.nu64("prevCredits")]),ie.offset(ie.u32(),-8),"epochCredits"),ie.struct([ie.nu64("slot"),ie.nu64("timestamp")],"lastTimestamp")]);function kj(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let l=0;l<e.length;l++)e[l]=255;for(let l=0;l<t.length;l++){const u=t.charAt(l),d=u.charCodeAt(0);if(e[d]!==255)throw new TypeError(u+" is ambiguous");e[d]=l}const n=t.length,r=t.charAt(0),i=Math.log(n)/Math.log(256),s=Math.log(256)/Math.log(n);function o(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";let u=0,d=0,f=0;const g=l.length;for(;f!==g&&l[f]===0;)f++,u++;const v=(g-f)*s+1>>>0,w=new Uint8Array(v);for(;f!==g;){let M=l[f],S=0;for(let F=v-1;(M!==0||S<d)&&F!==-1;F--,S++)M+=256*w[F]>>>0,w[F]=M%n>>>0,M=M/n>>>0;if(M!==0)throw new Error("Non-zero carry");d=S,f++}let b=v-d;for(;b!==v&&w[b]===0;)b++;let E=r.repeat(u);for(;b<v;++b)E+=t.charAt(w[b]);return E}function a(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;let u=0,d=0,f=0;for(;l[u]===r;)d++,u++;const g=(l.length-u)*i+1>>>0,v=new Uint8Array(g);for(;u<l.length;){const M=l.charCodeAt(u);if(M>255)return;let S=e[M];if(S===255)return;let F=0;for(let D=g-1;(S!==0||F<f)&&D!==-1;D--,F++)S+=n*v[D]>>>0,v[D]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");f=F,u++}let w=g-f;for(;w!==g&&v[w]===0;)w++;const b=new Uint8Array(d+(g-w));let E=d;for(;w!==g;)b[E++]=v[w++];return b}function c(l){const u=a(l);if(u)return u;throw new Error("Non-base"+n+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var Dj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Yo=kj(Dj);function e0(t,e){switch(e.split(":")[0].toLowerCase()){case"solana":return Lj(t);case"eip155":case"ethereum":return Bj(t);case"sui":return Uj(t);case"bip122":case"bitcoin":return $j(t);default:return{signature:t,rawSignature:t}}}function t_(t,e,n){let r=t;if(PR(e))try{const i=Sc(t);r="0x"+Et.Buffer.from(i).toString("hex")}catch{r=t.startsWith("0x")?t:"0x"+t}return n?{hash:n,rawTransaction:r,blockExplorer:$D(e,"transaction",n)}:{rawTransaction:r}}function Lj(t){try{const e=Sc(t);return{signature:Yo.encode(e),rawSignature:t}}catch{return{signature:t,rawSignature:t}}}function Bj(t){const e=Sc(t);return{signature:"0x"+Et.Buffer.from(e).toString("hex"),rawSignature:t}}function Uj(t){try{const e=Sc(t);return{signature:Et.Buffer.from(e).toString("base64"),rawSignature:t}}catch{return{signature:t,rawSignature:t}}}function $j(t){try{const e=Sc(t);return{signature:Et.Buffer.from(e).toString("hex"),rawSignature:t}}catch{return{signature:t,rawSignature:t}}}function Fj(t){try{const e=Sc(t);return IT(e)}catch{return null}}function IT(t){try{return Sf.from(t)}catch(e){if(e instanceof Error&&e.message.includes("Versioned messages"))return Ly.deserialize(t);throw e}}async function n_(t,e){const n=e.split(":")[0].toLowerCase();switch(n){case"solana":return Kj(t);case"ethereum":case"eip155":case"polygon":case"optimism":case"arbitrum":case"base":return Vj(t);case"sui":return await jj(t);case"bitcoin":return Hj(t);default:throw new Error(`Unsupported network: ${n}`)}}function Kj(t){if(t?.messageBytes!=null)return{parsed:Fn(t.messageBytes),originalFormat:"@solana/kit"};if(typeof t?.serialize=="function"){const e=t.serialize({requireAllSignatures:!1,verifySignatures:!1});return{parsed:Fn(e),originalFormat:"@solana/web3.js"}}if(t instanceof Uint8Array)return{parsed:Fn(t),originalFormat:"bytes"};if(typeof t=="string")try{const e=Et.Buffer.from(t,"base64");return{parsed:Fn(new Uint8Array(e)),originalFormat:"base64"}}catch{throw new Error("Unsupported Solana transaction format")}throw new Error("Unsupported Solana transaction format")}function Vj(t){if(typeof t=="string"&&t.startsWith("0x"))return{parsed:t,originalFormat:"hex"};if(t?.serialize&&typeof t.serialize=="function"){const e=t.serialize();return{parsed:e.startsWith("0x")?e:"0x"+e,originalFormat:"ethers"}}if(t instanceof Uint8Array)return{parsed:"0x"+Et.Buffer.from(t).toString("hex"),originalFormat:"bytes"};if(t&&typeof t=="object"&&(t.to||t.data||t.from))try{const{from:e,gas:n,...r}=t;if(n&&(r.gasLimit=n),r.gasLimit||r.to&&r.value&&!r.data&&(r.gasLimit="0x5208"),r.to&&typeof r.to=="string")try{r.to=Ac(r.to)}catch{r.to=r.to.toLowerCase()}const i=vK.from(r).unsignedSerialized;return{parsed:i.startsWith("0x")?i:"0x"+i,originalFormat:"json"}}catch(e){const n=e instanceof Error?e.message:"Unknown error",r=t?Object.keys(t).join(", "):"N/A",i=t?JSON.stringify(t,null,2):"N/A";throw new Error(`Failed to RLP encode EVM transaction: ${n}.
|
|
561
|
+
Transaction keys: [${r}].
|
|
562
|
+
Transaction: ${i}
|
|
563
|
+
Please ensure the transaction object includes required fields (to, value, chainId, gasLimit or gasPrice, etc.)`)}throw new Error("Unsupported EVM transaction format. Expected hex string, bytes, or transaction object with 'to', 'data', or 'from' fields.")}async function jj(t){if(t?.serialize&&typeof t.serialize=="function"){const e=t.serialize();return{parsed:Fn(e),originalFormat:"sui-sdk"}}if(t instanceof Uint8Array)return{parsed:Fn(t),originalFormat:"bytes"};if(t?.build&&typeof t.build=="function"){const e=await t.build();if(e?.serialize&&typeof e.serialize=="function"){const n=e.serialize();return{parsed:Fn(n),originalFormat:"transaction-block"}}}throw new Error("Unsupported Sui transaction format")}function Hj(t){if(t?.toBuffer&&typeof t.toBuffer=="function"){const e=t.toBuffer();return{parsed:Fn(new Uint8Array(e)),originalFormat:"bitcoinjs-lib"}}if(t instanceof Uint8Array)return{parsed:Fn(t),originalFormat:"bytes"};if(typeof t=="string"){const e=new Uint8Array(Et.Buffer.from(t,"hex"));return{parsed:Fn(e),originalFormat:"hex"}}throw new Error("Unsupported Bitcoin transaction format")}var r_=10080*60*1e3,Af=["google","apple","phantom"],zj=class{constructor(t){this.provider=t,this.currentNetworkId=Sn.SOLANA_MAINNET,this._connected=!1,this._publicKey=null,this.eventEmitter=new _c,this.setupEventListeners(),this.syncInitialState()}get connected(){return this._connected}get publicKey(){return this._publicKey}ensureConnected(){if(!this.provider.isConnected())throw new Error("Solana chain not available. Ensure SDK is connected.")}async signMessage(t){this.ensureConnected();const e=typeof t=="string"?t:new TextDecoder().decode(t),n=await this.provider.signMessage({message:e,networkId:this.currentNetworkId});return{signature:typeof n.signature=="string"?new Uint8Array(Yo.decode(n.signature)):n.signature,publicKey:this._publicKey||""}}async signTransaction(t){this.ensureConnected();const e=await this.provider.signTransaction({transaction:t,networkId:this.currentNetworkId}),n=Fj(e.rawTransaction);if(!n)throw new Error("Failed to parse signed transaction");return n}async signAndSendTransaction(t){this.ensureConnected();const e=await this.provider.signAndSendTransaction({transaction:t,networkId:this.currentNetworkId});if(!e.hash)throw new Error("Transaction not submitted");return{signature:e.hash}}async signAllTransactions(t){return this.ensureConnected(),await Promise.all(t.map(n=>this.signTransaction(n)))}async signAndSendAllTransactions(t){return{signatures:(await Promise.all(t.map(n=>this.signAndSendTransaction(n)))).map(n=>n.signature)}}connect(t){if(!this.provider.isConnected())throw new Error("Provider not connected. Call provider connect first.");const n=this.provider.getAddresses().find(r=>r.addressType==="Solana");if(!n)throw new Error("No Solana address found");return this.updateConnectionState(!0,n.address),Promise.resolve({publicKey:n.address})}async disconnect(){return this.provider.disconnect()}switchNetwork(t){return this.currentNetworkId=t==="mainnet"?Sn.SOLANA_MAINNET:Sn.SOLANA_DEVNET,Promise.resolve()}getPublicKey(){if(!this.provider.isConnected())return Promise.resolve(null);const e=this.provider.getAddresses().find(n=>n.addressType==="Solana");return Promise.resolve(e?.address||null)}isConnected(){return this._connected&&this.provider.isConnected()}setupEventListeners(){this.provider.on("connect",t=>{const e=t.addresses?.find(n=>n.addressType==="Solana");e&&(this.updateConnectionState(!0,e.address),this.eventEmitter.emit("connect",e.address))}),this.provider.on("disconnect",()=>{this.updateConnectionState(!1,null),this.eventEmitter.emit("disconnect")})}syncInitialState(){if(this.provider.isConnected()){const e=this.provider.getAddresses().find(n=>n.addressType==="Solana");e&&this.updateConnectionState(!0,e.address)}}updateConnectionState(t,e){this._connected=t,this._publicKey=e}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}},qj=class{constructor(t){this.provider=t,this.currentNetworkId=Sn.ETHEREUM_MAINNET,this._connected=!1,this._accounts=[],this.eventEmitter=new _c,this.setupEventListeners(),this.syncInitialState()}get connected(){return this._connected}get chainId(){return`0x${(Tp(this.currentNetworkId)||1).toString(16)}`}get accounts(){return this._accounts}ensureConnected(){if(!this.provider.isConnected())throw new Error("Ethereum chain not available. Ensure SDK is connected.")}async request(t){return this.ensureConnected(),this.handleEmbeddedRequest(t)}connect(){if(!this.provider.isConnected())throw new Error("Provider not connected. Call provider connect first.");const e=this.provider.getAddresses().filter(n=>n.addressType==="Ethereum").map(n=>n.address);return this.updateConnectionState(!0,e),Promise.resolve(e)}async disconnect(){await this.provider.disconnect()}async signPersonalMessage(t,e){return await this.request({method:"personal_sign",params:[t,e]})}async signTypedData(t,e){return await this.request({method:"eth_signTypedData_v4",params:[e,JSON.stringify(t)]})}async signTransaction(t){let e=this.currentNetworkId;if(t.chainId){const r=typeof t.chainId=="number"?t.chainId:parseInt(t.chainId,16),i=Fu(r);i&&(e=i)}return(await this.provider.signTransaction({transaction:t,networkId:e})).rawTransaction}async sendTransaction(t){if(t.chainId){const n=typeof t.chainId=="number"?t.chainId:parseInt(t.chainId,16);await this.switchChain(n)}const e=await this.provider.signAndSendTransaction({transaction:t,networkId:this.currentNetworkId});if(!e.hash)throw new Error("Transaction not submitted");return e.hash}switchChain(t){const e=typeof t=="string"?t.toLowerCase().startsWith("0x")?parseInt(t,16):parseInt(t,10):t,n=Fu(e);if(!n)throw new Error(`Unsupported chainId: ${t}`);return this.currentNetworkId=n,this.eventEmitter.emit("chainChanged",`0x${e.toString(16)}`),Promise.resolve()}getChainId(){const t=Tp(this.currentNetworkId);return Promise.resolve(t||1)}async getAccounts(){return this.request({method:"eth_accounts"})}isConnected(){return this._connected&&this.provider.isConnected()}setupEventListeners(){this.provider.on("connect",t=>{const e=t.addresses?.filter(n=>n.addressType==="Ethereum")?.map(n=>n.address)||[];e.length>0&&(this.updateConnectionState(!0,e),this.eventEmitter.emit("connect",{chainId:this.chainId}),this.eventEmitter.emit("accountsChanged",e))}),this.provider.on("disconnect",()=>{this.updateConnectionState(!1,[]),this.eventEmitter.emit("disconnect",{code:4900,message:"Provider disconnected"}),this.eventEmitter.emit("accountsChanged",[])})}syncInitialState(){if(this.provider.isConnected()){const e=this.provider.getAddresses().filter(n=>n.addressType==="Ethereum").map(n=>n.address);e.length>0&&this.updateConnectionState(!0,e)}}updateConnectionState(t,e){this._connected=t,this._accounts=e}async handleEmbeddedRequest(t){switch(t.method){case"personal_sign":{const[e,n]=t.params;return(await this.provider.signEthereumMessage({message:e,networkId:this.currentNetworkId})).signature}case"eth_signTypedData_v4":{const[e,n]=t.params,r=JSON.parse(n);return(await this.provider.signTypedDataV4({typedData:r,networkId:this.currentNetworkId})).signature}case"eth_signTransaction":{const[e]=t.params,n=e.chainId?Fu(typeof e.chainId=="number"?e.chainId:parseInt(e.chainId,16)):null;return(await this.provider.signTransaction({transaction:e,networkId:n||this.currentNetworkId})).rawTransaction}case"eth_sendTransaction":{const[e]=t.params,n=e.chainId?Fu(typeof e.chainId=="number"?e.chainId:parseInt(e.chainId,16)):null;return(await this.provider.signAndSendTransaction({transaction:e,networkId:n||this.currentNetworkId})).hash}case"eth_accounts":{const n=this.provider.getAddresses().find(r=>r.addressType==="Ethereum");return n?[n.address]:[]}case"eth_chainId":return`0x${(Tp(this.currentNetworkId)||1).toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:e}]=t.params,n=parseInt(e,16);await this.switchChain(n);return}default:throw new Error(`Embedded provider doesn't support method: ${t.method}`)}}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}};async function Wj(t,e,n,r=3,i=1e3){let s;for(let o=1;o<=r;o++)try{return n.log("EMBEDDED_PROVIDER",`Attempting ${e}`,{attempt:o,maxRetries:r}),await t()}catch(a){if(s=a,n.warn("EMBEDDED_PROVIDER",`${e} failed`,{attempt:o,maxRetries:r,error:a instanceof Error?a.message:String(a)}),o===r){n.error("EMBEDDED_PROVIDER",`${e} failed after ${r} attempts`,{finalError:a instanceof Error?a.message:String(a)});break}const c=i*Math.pow(2,o-1);n.log("EMBEDDED_PROVIDER",`Retrying ${e} in ${c}ms`,{attempt:o+1,delay:c}),await new Promise(l=>setTimeout(l,c))}throw s}function t0(){return"session_"+Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)+"_"+Date.now()}var Gj=class{constructor(e,n,r){if(this.client=null,this.walletId=null,this.addresses=[],this.eventListeners=new Map,this.logger=r,this.logger.log("EMBEDDED_PROVIDER","Initializing EmbeddedProvider",{config:e}),e.embeddedWalletType==="app-wallet")throw new Error("app-wallet type is not currently supported. Please use 'user-wallet' instead.");this.config=e,this.platform=n,this.storage=n.storage,this.authProvider=n.authProvider,this.phantomAppProvider=n.phantomAppProvider,this.urlParamsAccessor=n.urlParamsAccessor,this.stamper=n.stamper,this.solana=new zj(this),this.ethereum=new qj(this),this.logger.info("EMBEDDED_PROVIDER","EmbeddedProvider initialized")}on(e,n){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(n),this.logger.log("EMBEDDED_PROVIDER","Event listener added",{event:e})}off(e,n){const r=this.eventListeners.get(e);r&&(r.delete(n),this.logger.log("EMBEDDED_PROVIDER","Event listener removed",{event:e}))}emit(e,n){const r=this.eventListeners.get(e);r&&r.size>0&&(this.logger.log("EMBEDDED_PROVIDER","Emitting event",{event:e,listenerCount:r.size,data:n}),r.forEach(i=>{try{i(n)}catch(s){this.logger.error("EMBEDDED_PROVIDER","Event callback error",{event:e,error:s})}}))}getAddressForNetwork(e){const n=e.split(":")[0].toLowerCase();let r;switch(n){case"solana":r=yt.solana;break;case"eip155":r=yt.ethereum;break;case"bitcoin":case"btc":r=yt.bitcoinSegwit;break;case"sui":r=yt.sui;break;default:r=yt.ethereum;break}return this.addresses.find(s=>s.addressType.toLowerCase()===r.toLowerCase())?.address}async getAndFilterWalletAddresses(e){const r=(await this.storage.getSession())?.accountDerivationIndex??0;return(await Wj(()=>this.client.getWalletAddresses(e,void 0,r),"getWalletAddresses",this.logger).catch(async s=>{throw this.logger.error("EMBEDDED_PROVIDER","getWalletAddresses failed after retries, disconnecting",{walletId:e,error:s.message,derivationIndex:r}),await this.storage.clearSession(),this.client=null,this.walletId=null,this.addresses=[],s})).filter(s=>this.config.addressTypes.some(o=>o===s.addressType))}async validateAndCleanSession(e){if(!e)return null;if(this.logger.log("EMBEDDED_PROVIDER","Found existing session, validating",{sessionId:e.sessionId,status:e.status,walletId:e.walletId}),e.status!=="completed"){const n=this.urlParamsAccessor.getParam("session_id");if(e.status==="pending"&&!n)return this.logger.warn("EMBEDDED_PROVIDER","Session mismatch detected - pending session without redirect context",{sessionId:e.sessionId,status:e.status}),await this.storage.clearSession(),null;if(n&&n!==e.sessionId)return this.logger.warn("EMBEDDED_PROVIDER","Session ID mismatch detected",{storedSessionId:e.sessionId,urlSessionId:n}),await this.storage.clearSession(),null}return e.status==="completed"&&!this.isSessionValid(e)?(this.logger.warn("EMBEDDED_PROVIDER","Session invalid due to authenticator expiration, will regenerate keypair",{sessionId:e.sessionId,authenticatorExpiresAt:e.authenticatorExpiresAt,currentTime:Date.now(),expired:e.authenticatorExpiresAt<Date.now()}),await this.storage.clearSession(),null):e}async tryExistingConnection(e){this.logger.log("EMBEDDED_PROVIDER","Getting existing session");let n=await this.storage.getSession();if(n=await this.validateAndCleanSession(n),!n)return this.logger.log("EMBEDDED_PROVIDER","No existing session found"),null;if(n.status==="completed"){this.logger.info("EMBEDDED_PROVIDER","Using existing completed session",{sessionId:n.sessionId,walletId:n.walletId}),await this.initializeClientFromSession(n),n.lastUsed=Date.now(),await this.storage.saveSession(n),this.logger.info("EMBEDDED_PROVIDER","Connection from existing session successful",{walletId:this.walletId,addressCount:this.addresses.length}),await this.ensureValidAuthenticator();const r={walletId:this.walletId,addresses:this.addresses,status:"completed",authUserId:n.authUserId,authProvider:n.authProvider};return this.emit("connect",{...r,source:"existing-session"}),r}if(this.logger.log("EMBEDDED_PROVIDER","No completed session found, checking for redirect resume"),this.authProvider.resumeAuthFromRedirect){const r=this.authProvider.resumeAuthFromRedirect(n.authProvider);if(r){this.logger.info("EMBEDDED_PROVIDER","Resuming from redirect",{walletId:r.walletId,provider:r.provider});try{return await this.completeAuthConnection(r)}catch(i){if(i instanceof Error&&i.message.includes("No session found after redirect")&&!e)return this.logger.warn("EMBEDDED_PROVIDER","Session missing during redirect resume - will start fresh auth flow",{error:i.message,walletId:r.walletId}),await this.storage.clearSession(),null;throw i}}}return null}validateAuthOptions(e){if(!Af.includes(e.provider))throw new Error(`Invalid auth provider: ${e.provider}. Must be ${Af.join(", ")}`)}isSessionValid(e){return e?!e.walletId||!e.organizationId||!e.stamperInfo?(this.logger.log("EMBEDDED_PROVIDER","Session missing required fields",{hasWalletId:!!e.walletId,hasOrganizationId:!!e.organizationId,hasStamperInfo:!!e.stamperInfo}),!1):e.status!=="completed"?(this.logger.log("EMBEDDED_PROVIDER","Session not completed",{status:e.status}),!1):e.authenticatorExpiresAt?Date.now()>=e.authenticatorExpiresAt?(this.logger.log("EMBEDDED_PROVIDER","Authenticator expired, session invalid",{authenticatorExpiresAt:new Date(e.authenticatorExpiresAt).toISOString(),now:new Date().toISOString()}),!1):(this.logger.log("EMBEDDED_PROVIDER","Session is valid",{sessionId:e.sessionId,walletId:e.walletId,authenticatorExpires:new Date(e.authenticatorExpiresAt).toISOString()}),!0):(this.logger.log("EMBEDDED_PROVIDER","Session invalid - missing authenticator timing",{sessionId:e.sessionId}),!1):!1}async autoConnect(){try{this.logger.log("EMBEDDED_PROVIDER","Starting auto-connect attempt"),this.emit("connect_start",{source:"auto-connect"});const e=await this.tryExistingConnection(!0);if(e){this.logger.info("EMBEDDED_PROVIDER","Auto-connect successful",{walletId:e.walletId,addressCount:e.addresses.length}),this.emit("connect",{...e,source:"auto-connect"});return}this.logger.log("EMBEDDED_PROVIDER","Auto-connect failed: no valid session found"),this.emit("connect_error",{error:"No valid session found",source:"auto-connect"})}catch(e){this.logger.error("EMBEDDED_PROVIDER","Auto-connect failed",{error:e instanceof Error?e.message:String(e)}),this.emit("connect_error",{error:e instanceof Error?e.message:"Auto-connect failed",source:"auto-connect"}),await this.storage.setShouldClearPreviousSession(!0)}}async initializeStamper(){this.logger.log("EMBEDDED_PROVIDER","Initializing stamper"),await this.stamper.init(),this.logger.log("EMBEDDED_PROVIDER","Resetting keypair to avoid conflicts with existing keypairs");const e=await this.stamper.resetKeyPair();this.logger.log("EMBEDDED_PROVIDER","Stamper initialized with fresh keypair",{publicKey:e.publicKey,keyId:e.keyId,algorithm:this.stamper.algorithm});const n=r_;return this.logger.info("EMBEDDED_PROVIDER","Stamper ready for auth flow with fresh keypair",{publicKey:e.publicKey,keyId:e.keyId}),{stamperInfo:e,expiresInMs:n}}async createOrganizationForAppWallet(e,n){const r=new Pp({apiBaseUrl:this.config.apiBaseUrl,headers:{...this.platform.analyticsHeaders||{}}}),i=this.platform.name||"unknown",s=e.publicKey.slice(0,8),o=`${this.config.appId.substring(0,8)}-${i}-${s}`;this.logger.log("EMBEDDED_PROVIDER","Creating organization for app-wallet",{organizationName:o,publicKey:e.publicKey,platform:i});const a=Fn(Yo.decode(e.publicKey)),c=`user-${OR()}`,{organizationId:l}=await r.createOrganization(o,[{username:c,role:"ADMIN",authenticators:[{authenticatorName:`auth-${s}`,authenticatorKind:"keypair",publicKey:a,algorithm:"Ed25519",expiresInMs:n}]}]);return this.logger.info("EMBEDDED_PROVIDER","Organization created for app-wallet",{organizationId:l}),l}async connect(e){try{this.logger.info("EMBEDDED_PROVIDER","Starting embedded provider connect",{authOptions:{provider:e.provider}}),this.emit("connect_start",{source:"manual-connect",authOptions:{provider:e.provider}});const n=await this.tryExistingConnection(!1);if(n)return this.logger.info("EMBEDDED_PROVIDER","Manual connect using existing connection",{walletId:n.walletId,addressCount:n.addresses.length}),this.emit("connect",{...n,source:"manual-existing"}),n;this.validateAuthOptions(e),this.logger.info("EMBEDDED_PROVIDER","No existing connection available, creating new auth flow with fresh keypair");const{stamperInfo:r,expiresInMs:i}=await this.initializeStamper(),s=await this.handleAuthFlow(r.publicKey,r,e,i);if(!s)return{addresses:[],status:"pending",authProvider:e.provider};this.config.embeddedWalletType==="app-wallet"&&(s.lastUsed=Date.now(),await this.storage.saveSession(s)),await this.initializeClientFromSession(s),await this.ensureValidAuthenticator();const o={walletId:this.walletId,addresses:this.addresses,status:"completed",authUserId:s?.authUserId,authProvider:s?.authProvider};return this.emit("connect",{...o,source:"manual"}),o}catch(n){throw this.logger.error("EMBEDDED_PROVIDER","Connect failed with error",{error:n instanceof Error?{name:n.name,message:n.message,stack:n.stack}:n}),this.emit("connect_error",{error:n instanceof Error?n.message:String(n),source:"manual-connect"}),n instanceof Error?n.message.includes("IndexedDB")||n.message.includes("storage")?new Error("Storage error: Unable to access browser storage. Please ensure storage is available and try again."):n.message.includes("network")||n.message.includes("fetch")?new Error("Network error: Unable to connect to authentication server. Please check your internet connection and try again."):n.message.includes("JWT")||n.message.includes("jwt")?new Error(`JWT Authentication error: ${n.message}`):n.message.includes("Authentication")||n.message.includes("auth")?new Error(`Authentication error: ${n.message}`):n.message.includes("organization")||n.message.includes("wallet")?new Error(`Wallet creation error: ${n.message}`):n:new Error(`Embedded wallet connection failed: ${String(n)}`)}}async disconnect(e=!0){const n=this.client!==null;await this.storage.setShouldClearPreviousSession(e),this.logger.log("EMBEDDED_PROVIDER","Set flag to clear previous session on next login"),await this.storage.clearSession(),this.client=null,this.walletId=null,this.addresses=[],this.logger.info("EMBEDDED_PROVIDER","Disconnected from embedded wallet"),n&&this.emit("disconnect",{source:"manual"})}async signMessage(e){if(!this.client||!this.walletId)throw new Error("Not connected");await this.ensureValidAuthenticator(),this.logger.info("EMBEDDED_PROVIDER","Signing message",{walletId:this.walletId,message:e.message});const r=(await this.storage.getSession())?.accountDerivationIndex??0,i=await this.client.signUtf8Message({walletId:this.walletId,message:e.message,networkId:e.networkId,derivationIndex:r});return this.logger.info("EMBEDDED_PROVIDER","Message signed successfully",{walletId:this.walletId,message:e.message}),e0(i,e.networkId)}async signEthereumMessage(e){if(!this.client||!this.walletId)throw new Error("Not connected");await this.ensureValidAuthenticator(),this.logger.info("EMBEDDED_PROVIDER","Signing message",{walletId:this.walletId,message:e.message});const n=c=>/^0x[0-9a-fA-F]+$/.test(c),r=(()=>{if(n(e.message)){const c=e.message.slice(2),l=c.length%2===0?c:`0${c}`;return Et.Buffer.from(l,"hex").toString("utf8")}return e.message})(),i=qL(r),o=(await this.storage.getSession())?.accountDerivationIndex??0,a=await this.client.ethereumSignMessage({walletId:this.walletId,message:i,networkId:e.networkId,derivationIndex:o});return this.logger.info("EMBEDDED_PROVIDER","Message signed successfully",{walletId:this.walletId,message:e.message}),e0(a,e.networkId)}async signTypedDataV4(e){if(!this.client||!this.walletId)throw new Error("Not connected");await this.ensureValidAuthenticator(),this.logger.info("EMBEDDED_PROVIDER","Signing typed data",{walletId:this.walletId,typedData:e.typedData});const r=(await this.storage.getSession())?.accountDerivationIndex??0,i=await this.client.ethereumSignTypedData({walletId:this.walletId,typedData:e.typedData,networkId:e.networkId,derivationIndex:r});return this.logger.info("EMBEDDED_PROVIDER","Typed data signed successfully",{walletId:this.walletId}),e0(i,e.networkId)}async signTransaction(e){if(!this.client||!this.walletId)throw new Error("Not connected");await this.ensureValidAuthenticator(),this.logger.info("EMBEDDED_PROVIDER","Signing transaction",{walletId:this.walletId,networkId:e.networkId});const n=await n_(e.transaction,e.networkId),i=(await this.storage.getSession())?.accountDerivationIndex??0;this.logger.log("EMBEDDED_PROVIDER","Parsed transaction for signing",{walletId:this.walletId,transaction:n,derivationIndex:i});const s=n.parsed;if(!s)throw new Error("Failed to parse transaction: no valid encoding found");const o=this.getAddressForNetwork(e.networkId);if(!o)throw new Error(`No address found for network ${e.networkId}`);const a=await this.client.signTransaction({walletId:this.walletId,transaction:s,networkId:e.networkId,derivationIndex:i,account:o});return this.logger.info("EMBEDDED_PROVIDER","Transaction signed successfully",{walletId:this.walletId,networkId:e.networkId,rawTransaction:a.rawTransaction}),await t_(a.rawTransaction,e.networkId)}async signAndSendTransaction(e){if(!this.client||!this.walletId)throw new Error("Not connected");await this.ensureValidAuthenticator(),this.logger.info("EMBEDDED_PROVIDER","Signing and sending transaction",{walletId:this.walletId,networkId:e.networkId});const n=await n_(e.transaction,e.networkId),i=(await this.storage.getSession())?.accountDerivationIndex??0;this.logger.log("EMBEDDED_PROVIDER","Parsed transaction for signing",{walletId:this.walletId,transaction:n,derivationIndex:i});const s=n.parsed;if(!s)throw new Error("Failed to parse transaction: no valid encoding found");const o=this.getAddressForNetwork(e.networkId);if(!o)throw new Error(`No address found for network ${e.networkId}`);let a;try{a=await this.client.signAndSendTransaction({walletId:this.walletId,transaction:s,networkId:e.networkId,derivationIndex:i,account:o})}catch(c){throw c instanceof DR&&this.emit("spending_limit_reached",{error:c}),c}return this.logger.info("EMBEDDED_PROVIDER","Transaction signed and sent successfully",{walletId:this.walletId,networkId:e.networkId,hash:a.hash,rawTransaction:a.rawTransaction}),await t_(a.rawTransaction,e.networkId,a.hash)}getAddresses(){return this.addresses}isConnected(){return this.client!==null&&this.walletId!==null}async handleAuthFlow(e,n,r,i){if(this.config.embeddedWalletType==="user-wallet")return this.logger.info("EMBEDDED_PROVIDER","Creating user-wallet, routing authentication",{authProvider:r.provider}),r.provider==="phantom"?await this.handlePhantomAuth(e,n,i):(this.logger.info("EMBEDDED_PROVIDER","Starting redirect-based authentication flow",{publicKey:e,provider:r?.provider}),await this.handleRedirectAuth(e,n,r));{this.logger.info("EMBEDDED_PROVIDER","Creating app-wallet",{publicKey:e});const s=await this.createOrganizationForAppWallet(n,i),c=(await new Pp({apiBaseUrl:this.config.apiBaseUrl,organizationId:s,headers:{...this.platform.analyticsHeaders||{}}},this.stamper).createWallet(`Wallet ${Date.now()}`)).walletId,l=Date.now(),u={sessionId:t0(),walletId:c,organizationId:s,appId:this.config.appId,stamperInfo:n,authProvider:"device",accountDerivationIndex:0,status:"completed",createdAt:l,lastUsed:l,authenticatorCreatedAt:l,authenticatorExpiresAt:Date.now()+i,lastRenewalAttempt:void 0};return await this.storage.saveSession(u),this.logger.info("EMBEDDED_PROVIDER","App-wallet created successfully",{walletId:c,organizationId:s}),u}}async handlePhantomAuth(e,n,r){if(this.logger.info("EMBEDDED_PROVIDER","Starting Phantom authentication flow"),!this.phantomAppProvider.isAvailable())throw this.logger.error("EMBEDDED_PROVIDER","Phantom app not available"),new Error("Phantom app is not available. Please install the Phantom browser extension or mobile app to use this authentication method.");this.logger.info("EMBEDDED_PROVIDER","Phantom app detected, proceeding with authentication");const s=t0(),o=await this.phantomAppProvider.authenticate({publicKey:e,appId:this.config.appId,sessionId:s});this.logger.info("EMBEDDED_PROVIDER","Phantom authentication completed",{walletId:o.walletId,organizationId:o.organizationId});const a=o.expiresInMs>0?o.expiresInMs:r,c=Date.now(),l={sessionId:s,walletId:o.walletId,organizationId:o.organizationId,appId:this.config.appId,stamperInfo:n,authProvider:"phantom",accountDerivationIndex:o.accountDerivationIndex,status:"completed",createdAt:c,lastUsed:c,authenticatorCreatedAt:c,authenticatorExpiresAt:c+a,lastRenewalAttempt:void 0,authUserId:o.authUserId};return this.logger.log("EMBEDDED_PROVIDER","Saving Phantom session"),await this.storage.saveSession(l),l}async handleRedirectAuth(e,n,r){this.logger.info("EMBEDDED_PROVIDER","Using Phantom Connect authentication flow (redirect-based)",{provider:r.provider,hasRedirectUrl:!!this.config.authOptions.redirectUrl,authUrl:this.config.authOptions.authUrl});const i=Date.now(),s=t0(),o={sessionId:s,walletId:`temp-wallet-${i}`,organizationId:`temp-org-${i}`,appId:this.config.appId,stamperInfo:n,authProvider:r.provider,accountDerivationIndex:void 0,status:"pending",createdAt:i,lastUsed:i,authenticatorCreatedAt:i,authenticatorExpiresAt:i+r_,lastRenewalAttempt:void 0};this.logger.log("EMBEDDED_PROVIDER","Saving temporary session before redirect",{sessionId:o.sessionId,tempWalletId:o.walletId}),o.lastUsed=Date.now(),await this.storage.saveSession(o);const a=await this.storage.getShouldClearPreviousSession();this.logger.info("EMBEDDED_PROVIDER","Starting Phantom Connect redirect",{publicKey:e,appId:this.config.appId,provider:r?.provider,authUrl:this.config.authOptions.authUrl,clearPreviousSession:a,allowRefresh:!a});const c=await this.authProvider.authenticate({publicKey:e,appId:this.config.appId,provider:r?.provider,redirectUrl:this.config.authOptions.redirectUrl,authUrl:this.config.authOptions.authUrl,sessionId:s,clearPreviousSession:a,allowRefresh:!a});if(c&&"walletId"in c){if(this.logger.info("EMBEDDED_PROVIDER","Authentication completed after redirect",{walletId:c.walletId,organizationId:c.organizationId,provider:c.provider}),o.walletId=c.walletId,o.organizationId=c.organizationId,o.authProvider=c.provider||o.authProvider,o.accountDerivationIndex=c.accountDerivationIndex,o.authUserId=c.authUserId,o.status="completed",o.lastUsed=Date.now(),c.expiresInMs>0){const l=Date.now();o.authenticatorCreatedAt=l,o.authenticatorExpiresAt=l+c.expiresInMs,this.logger.log("EMBEDDED_PROVIDER","Updated authenticator expiration from immediate auth response",{expiresInMs:c.expiresInMs,expiresAt:new Date(o.authenticatorExpiresAt).toISOString()})}return await this.storage.saveSession(o),await this.storage.setShouldClearPreviousSession(!1),this.logger.log("EMBEDDED_PROVIDER","Cleared logout flag after successful authentication"),o}return this.logger.info("EMBEDDED_PROVIDER","Redirect authentication initiated, waiting for redirect completion"),null}async completeAuthConnection(e){const n=await this.storage.getSession();if(!n)throw new Error("No session found after redirect - session may have expired");if(n.walletId=e.walletId,n.authProvider=e.provider||n.authProvider,n.organizationId=e.organizationId,n.accountDerivationIndex=e.accountDerivationIndex,n.authUserId=e.authUserId,n.status="completed",n.lastUsed=Date.now(),e.expiresInMs>0){const r=Date.now();n.authenticatorCreatedAt=r,n.authenticatorExpiresAt=r+e.expiresInMs,this.logger.log("EMBEDDED_PROVIDER","Updated authenticator expiration from auth response",{expiresInMs:e.expiresInMs,expiresAt:new Date(n.authenticatorExpiresAt).toISOString()})}return await this.storage.saveSession(n),await this.storage.setShouldClearPreviousSession(!1),this.logger.log("EMBEDDED_PROVIDER","Cleared logout flag after successful authentication"),await this.initializeClientFromSession(n),await this.ensureValidAuthenticator(),{walletId:this.walletId,addresses:this.addresses,status:"completed",authUserId:n.authUserId,authProvider:n.authProvider}}async ensureValidAuthenticator(){const e=await this.storage.getSession();if(!e)throw new Error("No active session found");const n=Date.now();if(!e.authenticatorExpiresAt)throw this.logger.warn("EMBEDDED_PROVIDER","Session missing authenticator timing - treating as invalid session"),await this.disconnect(!1),new Error("Invalid session - missing authenticator timing");const r=e.authenticatorExpiresAt-n;if(this.logger.log("EMBEDDED_PROVIDER","Checking authenticator expiration",{expiresAt:new Date(e.authenticatorExpiresAt).toISOString(),timeUntilExpiry:r}),r<=0)throw this.logger.error("EMBEDDED_PROVIDER","Authenticator has expired, disconnecting"),await this.disconnect(!1),new Error("Authenticator expired")}async initializeClientFromSession(e){this.logger.log("EMBEDDED_PROVIDER","Initializing PhantomClient from session",{organizationId:e.organizationId,walletId:e.walletId,appId:e.appId}),this.stamper.getKeyInfo()||await this.stamper.init(),this.client=new Pp({apiBaseUrl:this.config.apiBaseUrl,organizationId:e.organizationId,headers:{...this.platform.analyticsHeaders||{}}},this.stamper),this.walletId=e.walletId,this.addresses=await this.getAndFilterWalletAddresses(e.walletId)}},Yj=class{constructor(t={}){if(this.db=null,this.activeKeyPairRecord=null,this.pendingKeyPairRecord=null,this.algorithm=Bo.ed25519,this.type="PKI",typeof window>"u"||!window.indexedDB)throw new Error("IndexedDbStamper requires a browser environment with IndexedDB support");this.dbName=t.dbName||"phantom-indexed-db-stamper",this.storeName=t.storeName||"crypto-keys",this.keyName=t.keyName||"signing-key",this.type=t.type||"PKI",this.idToken=t.idToken,this.salt=t.salt}async init(){return await this.openDB(),this.activeKeyPairRecord=await this.loadActiveKeyPairRecord(),this.activeKeyPairRecord||(this.activeKeyPairRecord=await this.generateAndStoreNewKeyPair("active")),this.pendingKeyPairRecord=await this.loadPendingKeyPairRecord(),this.activeKeyPairRecord.keyInfo}getKeyInfo(){return this.activeKeyPairRecord?.keyInfo||null}async resetKeyPair(){return await this.clearStoredKeys(),this.activeKeyPairRecord=await this.generateAndStoreNewKeyPair("active"),this.pendingKeyPairRecord=null,this.activeKeyPairRecord.keyInfo}async stamp(t){const{data:e}=t;if(!this.activeKeyPairRecord)throw new Error("Stamper not initialized. Call init() first.");const n=new Uint8Array(e),r=await crypto.subtle.sign({name:this.algorithm,hash:"SHA-256"},this.activeKeyPairRecord.keyPair.privateKey,n),i=Fn(new Uint8Array(r)),s=t.type||this.type,o=t.type==="OIDC"?t.idToken:this.idToken,a=t.type==="OIDC"?t.salt:this.salt,c=s==="PKI"?{publicKey:Fn(Yo.decode(this.activeKeyPairRecord.keyInfo.publicKey)),signature:i,kind:"PKI",algorithm:this.algorithm}:{kind:"OIDC",idToken:o,publicKey:Fn(Yo.decode(this.activeKeyPairRecord.keyInfo.publicKey)),salt:a,algorithm:this.algorithm,signature:i},l=JSON.stringify(c);return Fn(l)}async clear(){await this.clearStoredKeys(),this.activeKeyPairRecord=null,this.pendingKeyPairRecord=null}async clearStoredKeys(){return this.db||await this.openDB(),new Promise((t,e)=>{const r=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName),i=r.delete(`${this.keyName}-active`),s=r.delete(`${this.keyName}-pending`);let o=0;const a=2,c=()=>{o++,o===a&&t()};i.onsuccess=c,s.onsuccess=c,i.onerror=()=>e(i.error),s.onerror=()=>e(s.error)})}async openDB(){return new Promise((t,e)=>{const n=indexedDB.open(this.dbName,1);n.onerror=()=>e(n.error),n.onsuccess=()=>{this.db=n.result,t()},n.onupgradeneeded=r=>{const i=r.target.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)}})}async rotateKeyPair(){return this.db||await this.openDB(),this.pendingKeyPairRecord=await this.generateAndStoreNewKeyPair("pending"),this.pendingKeyPairRecord.keyInfo}async commitRotation(t){if(!this.pendingKeyPairRecord)throw new Error("No pending keypair to commit");this.activeKeyPairRecord&&await this.removeKeyPairRecord("active"),this.pendingKeyPairRecord.status="active",this.pendingKeyPairRecord.authenticatorId=t,this.pendingKeyPairRecord.keyInfo.authenticatorId=t,this.activeKeyPairRecord=this.pendingKeyPairRecord,this.pendingKeyPairRecord=null,await this.storeKeyPairRecord(this.activeKeyPairRecord,"active"),await this.removeKeyPairRecord("pending")}async rollbackRotation(){this.pendingKeyPairRecord&&(await this.removeKeyPairRecord("pending"),this.pendingKeyPairRecord=null)}async generateAndStoreNewKeyPair(t){const e=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]),n=await crypto.subtle.exportKey("raw",e.publicKey),r=Yo.encode(new Uint8Array(n)),i=await crypto.subtle.digest("SHA-256",n),s=Fn(new Uint8Array(i)).substring(0,16),o=Date.now(),c={keyPair:e,keyInfo:{keyId:s,publicKey:r,createdAt:o},createdAt:o,expiresAt:0,status:t};return await this.storeKeyPairRecord(c,t),c}async storeKeyPairRecord(t,e){if(!this.db)throw new Error("Database not initialized");return new Promise((n,r)=>{const o=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(t,`${this.keyName}-${e}`);o.onsuccess=()=>n(),o.onerror=()=>r(o.error)})}async loadActiveKeyPairRecord(){return this.db?new Promise((t,e)=>{const i=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).get(`${this.keyName}-active`);i.onsuccess=()=>t(i.result||null),i.onerror=()=>e(i.error)}):null}async loadPendingKeyPairRecord(){return this.db?new Promise((t,e)=>{const i=this.db.transaction([this.storeName],"readonly").objectStore(this.storeName).get(`${this.keyName}-pending`);i.onsuccess=()=>t(i.result||null),i.onerror=()=>e(i.error)}):null}async removeKeyPairRecord(t){if(this.db)return new Promise((e,n)=>{const s=this.db.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete(`${this.keyName}-${t}`);s.onsuccess=()=>e(),s.onerror=()=>n(s.error)})}},Xc=class{constructor(){this.level=0,this.enabled=!1}static getInstance(){return Xc.instance||(Xc.instance=new Xc),Xc.instance}setCallback(t){this.callback=t}setLevel(t){this.level=t}enable(){this.enabled=!0}disable(){this.enabled=!1}writeLog(t,e,n,r){if(!this.enabled||t>this.level)return;const i={timestamp:Date.now(),level:t,category:e,message:n,data:r};this.callback&&this.callback(i)}error(t,e,n){this.writeLog(0,t,e,n)}warn(t,e,n){this.writeLog(1,t,e,n)}info(t,e,n){this.writeLog(2,t,e,n)}debug(t,e,n){this.writeLog(3,t,e,n)}log(t,e,n){this.writeLog(3,t,e,n)}},ee=Xc.getInstance(),te={BROWSER_SDK:"BrowserSDK",PROVIDER_MANAGER:"ProviderManager",EMBEDDED_PROVIDER:"EmbeddedProvider",INJECTED_PROVIDER:"InjectedProvider",PHANTOM_CONNECT_AUTH:"PhantomConnectAuth",JWT_AUTH:"JWTAuth",STORAGE:"Storage",SESSION:"Session"};function Jj(t){return t.rdns?t.rdns.split(".").reverse().join("-"):t.name.toLowerCase().replace(/\s+/g,"-")}function Zj(t){return t.toLowerCase().replace(/\s+/g,"-")}function Xj(t){const e=[];ee.log(te.BROWSER_SDK,"Processing EIP-6963 providers",{providerCount:t.size,providerNames:Array.from(t.values()).map(n=>n.info.name)});for(const[,n]of t){const{info:r,provider:i}=n;if(r.name.toLowerCase().includes("phantom")||r.rdns&&(r.rdns.toLowerCase().includes("phantom")||r.rdns.toLowerCase()==="app.phantom")){ee.log(te.BROWSER_SDK,"Skipping Phantom from EIP-6963",{name:r.name,rdns:r.rdns});continue}const o=Jj(r);ee.log(te.BROWSER_SDK,"Discovered EIP-6963 wallet",{walletId:o,walletName:r.name,rdns:r.rdns}),e.push({id:o,name:r.name,icon:r.icon,addressTypes:[yt.ethereum],providers:{ethereum:i},rdns:r.rdns,discovery:"eip6963"})}return ee.log(te.BROWSER_SDK,"EIP-6963 discovery completed",{discoveredCount:e.length,walletIds:e.map(n=>n.id)}),e}function Qj(){return new Promise(t=>{const e=new Map;if(typeof window>"u"){t([]);return}const n=i=>{const s=i.detail;s?.info&&s?.provider&&e.set(s.info.uuid,s)};window.addEventListener("eip6963:announceProvider",n),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{const i=Xj(e);window.removeEventListener("eip6963:announceProvider",n),t(i)},400)})}async function eH(){const t=[];if(typeof window>"u"||typeof navigator>"u")return ee.log(te.BROWSER_SDK,"Wallet Standard discovery skipped (not in browser environment)"),t;const e=new Set;let n;function r(w){n=void 0,e.add(w);const b=w.features?Object.keys(w.features):[];ee.log(te.BROWSER_SDK,"Wallet registered",{name:w.name,chains:w.chains,featureKeys:b,totalWallets:e.size})}function i(w){n=void 0,e.delete(w)}function s(){return n||(n=[...e]),n}function o(...w){return w=w.filter(b=>!e.has(b)),w.length?(w.forEach(b=>r(b)),function(){w.forEach(E=>i(E))}):()=>{}}const a=Object.freeze({register:o}),c=w=>{const b=w.detail;if(typeof b=="function")try{b(a)}catch(E){ee.warn(te.BROWSER_SDK,"Error calling wallet registration callback",{error:E})}};try{window.addEventListener("wallet-standard:register-wallet",c)}catch(w){ee.warn(te.BROWSER_SDK,"Could not add register-wallet event listener",{error:w})}class l extends Event{constructor(b){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),this.detail=b}}try{window.dispatchEvent(new l(a)),ee.log(te.BROWSER_SDK,"Dispatched wallet-standard:app-ready event")}catch(w){ee.warn(te.BROWSER_SDK,"Could not dispatch app-ready event",{error:w})}const u={getWallets:()=>({get:s,on:(w,b)=>()=>{},register:o})};navigator.wallets||(navigator.wallets=u),ee.log(te.BROWSER_SDK,"Initialized Wallet Standard registry"),await new Promise(w=>setTimeout(w,100));const d=navigator.wallets||window.wallets;if(!d||typeof d.getWallets!="function"){const w={hasNavigator:!!navigator,hasWindow:typeof window<"u",note:"Wallet Standard API not properly initialized"};return ee.log(te.BROWSER_SDK,"Wallet Standard API not available",w),t}const f=d.getWallets(),g=()=>Promise.resolve([...f.get()]);ee.log(te.BROWSER_SDK,"Wallet Standard API detected, starting discovery");try{let w=[],b=0;const E=5,M=100,S=400;for(await new Promise(D=>setTimeout(D,M));b<E;){w=await g();const D={attempt:b+1,walletCount:w.length,walletNames:w.map(z=>z.name),chains:w.flatMap(z=>z.chains)};if(ee.log(te.BROWSER_SDK,`Wallet Standard getWallets attempt ${b+1}`,D),w.length>0||b===E-1)break;await new Promise(z=>setTimeout(z,M)),b++}const F=M+b*M;if(F<S){const D=S-F;await new Promise(z=>setTimeout(z,D)),w=await g()}ee.log(te.BROWSER_SDK,"Wallet Standard getWallets final result",{walletCount:w.length,walletNames:w.map(D=>D.name),attempts:b+1});for(const D of w){if(!(D.chains.some(U=>{const B=U.toLowerCase();return B.startsWith("solana:")||B==="solana"})||D.features&&typeof D.features=="object"&&Object.keys(D.features).some(U=>{const B=U.toLowerCase();return B.includes("solana")||B.includes("standard:connect")||B.includes("standard:signTransaction")}))){const U=D.features?Object.keys(D.features):[];ee.log(te.BROWSER_SDK,"Wallet does not support Solana",{walletName:D.name,chains:D.chains,featureKeys:U});continue}if(D.name.toLowerCase().includes("phantom")){ee.log(te.BROWSER_SDK,"Skipping Phantom from Wallet Standard (handled separately)");continue}const X=Zj(D.name),Y=D.features?Object.keys(D.features):[];ee.log(te.BROWSER_SDK,"Discovered Wallet Standard Solana wallet",{walletId:X,walletName:D.name,chains:D.chains,featureKeys:Y,icon:D.icon,version:D.version,accountCount:D.accounts?.length||0}),t.push({id:X,name:D.name,icon:D.icon,addressTypes:[yt.solana],providers:{solana:D},discovery:"standard"})}}catch(w){ee.warn(te.BROWSER_SDK,"Wallet Standard API error",{error:w instanceof Error?w.message:String(w),stack:w instanceof Error?w.stack:void 0})}const v={discoveredCount:t.length,walletIds:t.map(w=>w.id),walletNames:t.map(w=>w.name)};return ee.log(te.BROWSER_SDK,"Wallet Standard Solana discovery completed",v),t}function tH(t){if(typeof window>"u"||!Zf())return null;const e=[EL()];t.includes(yt.solana)&&e.push(BL()),t.includes(yt.ethereum)&&e.push(wL()),e.push(jL());const n=bL({plugins:e});return{id:"phantom",name:"Phantom",icon:void 0,addressTypes:t,providers:{solana:t.includes(yt.solana)?n.solana:void 0,ethereum:t.includes(yt.ethereum)?n.ethereum:void 0},isPhantom:!0,phantomInstance:n,discovery:"phantom"}}async function nH(t){const e=t||[];ee.log(te.BROWSER_SDK,"Starting all wallet discovery methods",{addressTypes:e});const[n,r]=await Promise.all([eH(),Qj()]),i=tH(e);ee.log(te.BROWSER_SDK,"All wallet discovery methods completed",{phantomFound:!!i,solanaWalletsCount:n.length,ethereumWalletsCount:r.length,solanaWalletIds:n.map(o=>o.id),ethereumWalletIds:r.map(o=>o.id)});const s=new Map;i&&s.set("phantom",i);for(const o of[...n,...r]){const a=s.get(o.id);if(a){const c=Array.from(new Set([...a.addressTypes,...o.addressTypes])),l={...a.providers,...o.providers},u={...a,addressTypes:c,icon:o.icon||a.icon,providers:l};s.set(o.id,u),ee.log(te.BROWSER_SDK,"Merged wallet by ID",{walletName:o.name,walletId:o.id,existingAddressTypes:a.addressTypes,newAddressTypes:o.addressTypes,mergedAddressTypes:c,existingProviders:Object.keys(a.providers||{}),newProviders:Object.keys(o.providers||{}),mergedProviders:Object.keys(l)}),ee.log(te.BROWSER_SDK,"Merged wallet from multiple discovery methods",{walletId:o.id,walletName:o.name,existingAddressTypes:a.addressTypes,newAddressTypes:o.addressTypes,mergedAddressTypes:c})}else s.set(o.id,o)}return Array.from(s.values())}var rH=class{constructor(t,e,n){this.eventEmitter=new _c,this._connected=!1,this._publicKey=null,this.provider=t,this.walletId=e,this.walletName=n,this.setupEventListeners()}get connected(){return this._connected}get publicKey(){return this._publicKey}async connect(t){ee.log(te.INJECTED_PROVIDER,"External wallet Solana connect",{walletId:this.walletId,walletName:this.walletName,onlyIfTrusted:t?.onlyIfTrusted});try{const e=await this.provider.connect(t);if(typeof e=="string")return this._connected=!0,this._publicKey=e,ee.info(te.INJECTED_PROVIDER,"External wallet Solana connected",{walletId:this.walletId,walletName:this.walletName,publicKey:e}),{publicKey:e};if(typeof e=="object"&&e!==null&&"publicKey"in e)return this._connected=!0,this._publicKey=e.publicKey,ee.info(te.INJECTED_PROVIDER,"External wallet Solana connected",{walletId:this.walletId,walletName:this.walletName,publicKey:e.publicKey}),e;if(Array.isArray(e)&&e.length>0){const n=e[0];if(typeof n=="object"&&n!==null&&"address"in n)return this._connected=!0,this._publicKey=n.address,ee.info(te.INJECTED_PROVIDER,"External wallet Solana connected",{walletId:this.walletId,walletName:this.walletName,publicKey:n.address}),{publicKey:n.address}}throw new Error("Unexpected connect result format")}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana connect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async disconnect(){ee.log(te.INJECTED_PROVIDER,"External wallet Solana disconnect",{walletId:this.walletId,walletName:this.walletName});try{await this.provider.disconnect(),this._connected=!1,this._publicKey=null,ee.info(te.INJECTED_PROVIDER,"External wallet Solana disconnected",{walletId:this.walletId,walletName:this.walletName})}catch(t){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:t instanceof Error?t.message:String(t)}),t}}async signMessage(t){const e=typeof t=="string"?new TextEncoder().encode(t):t,n=typeof t=="string"?t.substring(0,50):`${e.length} bytes`;ee.log(te.INJECTED_PROVIDER,"External wallet Solana signMessage",{walletId:this.walletId,walletName:this.walletName,messagePreview:n,messageLength:e.length});try{const r=await this.provider.signMessage(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Solana signMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:r.signature.length}),{signature:r.signature instanceof Uint8Array?r.signature:new Uint8Array(Et.Buffer.from(r.signature,"base64")),publicKey:r.publicKey||this._publicKey||""}}catch(r){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana signMessage failed",{walletId:this.walletId,walletName:this.walletName,error:r instanceof Error?r.message:String(r)}),r}}async signTransaction(t){ee.log(te.INJECTED_PROVIDER,"External wallet Solana signTransaction",{walletId:this.walletId,walletName:this.walletName});try{const e=await this.provider.signTransaction(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Solana signTransaction success",{walletId:this.walletId,walletName:this.walletName}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendTransaction(t){ee.log(te.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction",{walletId:this.walletId,walletName:this.walletName});try{const e=await this.provider.signAndSendTransaction(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction success",{walletId:this.walletId,walletName:this.walletName,signature:e.signature}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana signAndSendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAllTransactions(t){ee.log(te.INJECTED_PROVIDER,"External wallet Solana signAllTransactions",{walletId:this.walletId,walletName:this.walletName,transactionCount:t.length});try{const e=await this.provider.signAllTransactions(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Solana signAllTransactions success",{walletId:this.walletId,walletName:this.walletName,signedCount:e.length}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana signAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendAllTransactions(t){ee.log(te.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions",{walletId:this.walletId,walletName:this.walletName,transactionCount:t.length});try{const e=await this.provider.signAndSendAllTransactions(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions success",{walletId:this.walletId,walletName:this.walletName,signatureCount:e.signatures.length}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Solana signAndSendAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}switchNetwork(t){return Promise.resolve()}getPublicKey(){return Promise.resolve(this._publicKey)}isConnected(){return this._connected}setupEventListeners(){typeof this.provider.on=="function"&&(this.provider.on("connect",t=>{this._connected=!0,this._publicKey=t,this.eventEmitter.emit("connect",t)}),this.provider.on("disconnect",()=>{this._connected=!1,this._publicKey=null,this.eventEmitter.emit("disconnect")}),this.provider.on("accountChanged",t=>{this._publicKey=t,this.eventEmitter.emit("accountChanged",t)}))}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}},iH=class{constructor(t,e,n){this._connected=!1,this._publicKey=null,this.wallet=t,this.walletId=e,this.walletName=n}get connected(){return this._connected}get publicKey(){return this._publicKey}async connect(t){try{const e=this.wallet.features?.["standard:connect"];if(!e||typeof e.connect!="function")throw new Error("Wallet Standard connect feature not available");const n=await e.connect();let r;if(Array.isArray(n)&&n.length>0?r=n:this.wallet.accounts&&this.wallet.accounts.length>0&&(r=Array.from(this.wallet.accounts)),!r||r.length===0)throw new Error("No accounts available after connecting to wallet");const i=r[0];if(!i)throw new Error("First account is null or undefined");let s;if(typeof i=="string"?s=i:typeof i=="object"&&i!==null&&(s=i.address||i.publicKey?.toString()||(i.publicKey instanceof Uint8Array?Buffer.from(i.publicKey).toString("hex"):void 0)),!s)throw new Error(`Could not extract address from account. Account structure: ${JSON.stringify(i,null,2)}`);return this._connected=!0,this._publicKey=s,{publicKey:s}}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana connect failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async disconnect(){try{const t=this.wallet.features?.["standard:disconnect"];t&&typeof t.disconnect=="function"&&await t.disconnect(),this._connected=!1,this._publicKey=null}catch(t){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:t instanceof Error?t.message:String(t)}),t}}async signMessage(t){try{const e=this.wallet.features?.["solana:signMessage"];if(!e||typeof e.signMessage!="function")throw new Error("Wallet Standard signMessage feature not available");const n=typeof t=="string"?new TextEncoder().encode(t):t,r=await e.signMessage({message:n,account:this.wallet.accounts?.[0]});if(!Array.isArray(r)||r.length===0)throw new Error(`Expected array result from signMessage, got: ${typeof r}`);const i=r[0];if(!i||!i.signature)throw new Error(`Invalid signMessage result structure: ${JSON.stringify(r)}`);const s=this.parseUint8Array(i.signature);if(s.length===0)throw new Error("Signature is empty");const o=i.account?.address||this.wallet.accounts?.[0]?.address||this._publicKey||"";return{signature:s,publicKey:o}}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana signMessage failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signTransaction(t){try{const e=this.wallet.features?.["solana:signTransaction"];if(!e||typeof e.signTransaction!="function")throw new Error("Wallet Standard signTransaction feature not available");if(!this.wallet.accounts||this.wallet.accounts.length===0)throw new Error("No accounts available. Please connect first.");const n=this.wallet.accounts[0],r=this.serializeTransaction(t),i=await e.signTransaction({transaction:r,account:n});let s;if(Array.isArray(i)&&i.length>0){const c=i[0];c&&typeof c=="object"&&(s=c.signedTransaction||c.transaction)}else i&&typeof i=="object"&&!Array.isArray(i)&&(s=i.transaction||i.signedTransaction);if(!s)throw new Error("No transaction data found in Wallet Standard result");const o=this.parseUint8Array(s);if(o.length===0)throw new Error("Empty signed transaction returned from Wallet Standard");return IT(o)}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendTransaction(t){try{const e=this.wallet.features?.["solana:signAndSendTransaction"];if(!e||typeof e.signAndSendTransaction!="function")throw new Error("Wallet Standard signAndSendTransaction feature not available");if(!this.wallet.accounts||this.wallet.accounts.length===0)throw new Error("No accounts available. Please connect first.");const n=this.wallet.accounts[0],r=n.chains?.[0]||"solana:mainnet",i=this.serializeTransaction(t),s=await e.signAndSendTransaction({transaction:i,account:n,chain:r});let o;if(Array.isArray(s)&&s.length>0)o=s[0];else if(s&&typeof s=="object"&&!Array.isArray(s))o=s;else throw new Error("Invalid signAndSendTransaction result format");if(!o.signature)throw new Error("No signature found in signAndSendTransaction result");const a=this.parseUint8Array(o.signature);return{signature:Yo.encode(a)}}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana signAndSendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAllTransactions(t){try{const e=[];for(const n of t){const r=await this.signTransaction(n);e.push(r)}return e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana signAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async signAndSendAllTransactions(t){try{const e=[];for(const n of t){const r=await this.signAndSendTransaction(n);e.push(r.signature)}return{signatures:e}}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana signAndSendAllTransactions failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async switchNetwork(t){try{const e=this.wallet.features?.["standard:switchNetwork"];if(e&&typeof e.switchNetwork=="function"){const n=t==="mainnet"?"solana:mainnet":"solana:devnet";await e.switchNetwork({chain:n})}}catch(e){throw ee.error(te.INJECTED_PROVIDER,"Wallet Standard Solana switchNetwork failed",{walletId:this.walletId,walletName:this.walletName,network:t,error:e instanceof Error?e.message:String(e)}),e}}getPublicKey(){return Promise.resolve(this._publicKey)}isConnected(){return this._connected}on(t,e){const n=this.wallet.features?.["standard:events"];n&&typeof n.on=="function"&&n.on(t,e)}off(t,e){const n=this.wallet.features?.["standard:events"];n&&typeof n.off=="function"&&n.off(t,e)}serializeTransaction(t){return typeof t.serialize=="function"?t.serialize({requireAllSignatures:!1,verifySignatures:!1}):t instanceof Uint8Array?t:new Uint8Array(0)}parseUint8Array(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&t!==null){const e=Object.keys(t).map(Number).filter(n=>!isNaN(n)&&n>=0).sort((n,r)=>n-r);if(e.length>0){const n=Math.max(...e),r=new Uint8Array(n+1);for(const i of e)r[i]=Number(t[i])||0;return r}}return new Uint8Array(0)}},sH=class{constructor(t,e,n){this.eventEmitter=new _c,this._connected=!1,this._chainId="0x1",this._accounts=[],this.provider=t,this.walletId=e,this.walletName=n,this.setupEventListeners()}get connected(){return this._connected}get chainId(){return this._chainId}get accounts(){return this._accounts}async request(t){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum request",{walletId:this.walletId,walletName:this.walletName,method:t.method});try{["personal_sign","eth_sign","eth_signTypedData","eth_signTypedData_v4","eth_sendTransaction","eth_signTransaction"].includes(t.method)&&(!this._connected||this._accounts.length===0)&&(ee.log(te.INJECTED_PROVIDER,"Method requires authorization, ensuring connection",{walletId:this.walletId,walletName:this.walletName,method:t.method}),await this.connect());const n=await this.provider.request(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum request success",{walletId:this.walletId,walletName:this.walletName,method:t.method}),n}catch(e){if(e?.code===4100){ee.log(te.INJECTED_PROVIDER,"Got 4100 Unauthorized, attempting to re-authorize",{walletId:this.walletId,walletName:this.walletName,method:t.method});try{await this.provider.request({method:"eth_requestAccounts"});const n=await this.provider.request(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum request success (after re-auth)",{walletId:this.walletId,walletName:this.walletName,method:t.method}),n}catch(n){throw ee.error(te.INJECTED_PROVIDER,"Failed after re-authorization",{walletId:this.walletId,walletName:this.walletName,method:t.method,error:n instanceof Error?n.message:String(n)}),n}}throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum request failed",{walletId:this.walletId,walletName:this.walletName,method:t.method,error:e instanceof Error?e.message:String(e),errorCode:e?.code}),e}}async connect(){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum connect",{walletId:this.walletId,walletName:this.walletName});try{const t=await this.provider.request({method:"eth_requestAccounts"});return this._connected=t.length>0,this._accounts=t,ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum connected (via eth_requestAccounts)",{walletId:this.walletId,walletName:this.walletName,accountCount:t.length,accounts:t}),t}catch(t){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum connect failed",{walletId:this.walletId,walletName:this.walletName,error:t instanceof Error?t.message:String(t)}),t}}async disconnect(){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum disconnect",{walletId:this.walletId,walletName:this.walletName});try{await this.provider.disconnect(),this._connected=!1,this._accounts=[],ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum disconnected",{walletId:this.walletId,walletName:this.walletName})}catch(t){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum disconnect failed",{walletId:this.walletId,walletName:this.walletName,error:t instanceof Error?t.message:String(t)}),t}}async signPersonalMessage(t,e){const n=t.length>50?t.substring(0,50)+"...":t;ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage",{walletId:this.walletId,walletName:this.walletName,messagePreview:n,messageLength:t.length,address:e});try{const r=this.provider.isConnected?.()||this.provider.connected||!1;(!this._connected||this._accounts.length===0||!r)&&(ee.log(te.INJECTED_PROVIDER,"Not connected, attempting to connect before signing",{walletId:this.walletId,walletName:this.walletName,internalConnected:this._connected,accountsLength:this._accounts.length,providerConnected:r}),await this.connect());const i=e.toLowerCase();if(!this._accounts.map(a=>a.toLowerCase()).includes(i)){ee.warn(te.INJECTED_PROVIDER,"Address not in connected accounts, refreshing connection",{walletId:this.walletId,walletName:this.walletName,requestedAddress:e,connectedAccounts:this._accounts});const a=await this.getAccounts();if(!a.map(l=>l.toLowerCase()).includes(i))throw new Error(`Address ${e} is not connected. Connected accounts: ${a.join(", ")}`);this._accounts=a}if(typeof this.provider.signPersonalMessage=="function"){const a=await this.provider.signPersonalMessage(t,e);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:a.length}),a}const o=await this.request({method:"personal_sign",params:[t,e]});return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage success",{walletId:this.walletId,walletName:this.walletName,signatureLength:o.length}),o}catch(r){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum signPersonalMessage failed",{walletId:this.walletId,walletName:this.walletName,error:r instanceof Error?r.message:String(r),errorCode:r?.code}),r}}async signTypedData(t,e){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum signTypedData",{walletId:this.walletId,walletName:this.walletName,primaryType:t?.primaryType,address:e});try{if(typeof this.provider.signTypedData=="function"){const r=await this.provider.signTypedData(t,e);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signTypedData success",{walletId:this.walletId,walletName:this.walletName,signatureLength:r.length}),r}const n=await this.request({method:"eth_signTypedData_v4",params:[e,t]});return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signTypedData success",{walletId:this.walletId,walletName:this.walletName,signatureLength:n.length}),n}catch(n){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum signTypedData failed",{walletId:this.walletId,walletName:this.walletName,error:n instanceof Error?n.message:String(n)}),n}}async signTransaction(t){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum signTransaction",{walletId:this.walletId,walletName:this.walletName,from:t.from,to:t.to});try{if(typeof this.provider.signTransaction=="function"){const n=await this.provider.signTransaction(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signTransaction success",{walletId:this.walletId,walletName:this.walletName,signatureLength:n.length}),n}const e=await this.request({method:"eth_signTransaction",params:[t]});return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum signTransaction success",{walletId:this.walletId,walletName:this.walletName,signatureLength:e.length}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum signTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async sendTransaction(t){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction",{walletId:this.walletId,walletName:this.walletName,from:t.from,to:t.to,value:t.value});try{if(typeof this.provider.sendTransaction=="function"){const n=await this.provider.sendTransaction(t);return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction success",{walletId:this.walletId,walletName:this.walletName,txHash:n}),n}const e=await this.request({method:"eth_sendTransaction",params:[t]});return ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction success",{walletId:this.walletId,walletName:this.walletName,txHash:e}),e}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum sendTransaction failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async switchChain(t){ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum switchChain",{walletId:this.walletId,walletName:this.walletName,chainId:t});try{const e=typeof t=="string"?t.toLowerCase().startsWith("0x")?t:`0x${parseInt(t,10).toString(16)}`:`0x${t.toString(16)}`;typeof this.provider.switchChain=="function"?await this.provider.switchChain(e):await this.request({method:"wallet_switchEthereumChain",params:[{chainId:e}]}),this._chainId=e,this.eventEmitter.emit("chainChanged",this._chainId),ee.info(te.INJECTED_PROVIDER,"External wallet Ethereum switchChain success",{walletId:this.walletId,walletName:this.walletName,chainId:e})}catch(e){throw ee.error(te.INJECTED_PROVIDER,"External wallet Ethereum switchChain failed",{walletId:this.walletId,walletName:this.walletName,error:e instanceof Error?e.message:String(e)}),e}}async getChainId(){if(typeof this.provider.getChainId=="function"){const n=await this.provider.getChainId();return this._chainId=`0x${n.toString(16)}`,n}const t=await this.request({method:"eth_chainId"}),e=parseInt(t,16);return this._chainId=t,e}async getAccounts(){if(typeof this.provider.getAccounts=="function"){const e=await this.provider.getAccounts();return this._accounts=e,e}const t=await this.request({method:"eth_accounts"});return this._accounts=t,t}isConnected(){return this._connected}setupEventListeners(){typeof this.provider.on=="function"&&(this.provider.on("connect",t=>{this._connected=!0,this._chainId=t.chainId,this.eventEmitter.emit("connect",t)}),this.provider.on("disconnect",t=>{this._connected=!1,this._accounts=[],this.eventEmitter.emit("disconnect",t),this.eventEmitter.emit("accountsChanged",[])}),this.provider.on("accountsChanged",t=>{this._accounts=t,this.eventEmitter.emit("accountsChanged",t)}),this.provider.on("chainChanged",t=>{this._chainId=t,this.eventEmitter.emit("chainChanged",t)}))}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}},oH=class{constructor(t){this._publicKey=null,this.eventEmitter=new _c,this.phantom=t,this.setupEventListeners()}get connected(){return this._publicKey!==null}get publicKey(){return this._publicKey}async connect(t){const e=await this.phantom.solana.connect(t);if(!e)throw new Error("Failed to connect to Solana wallet");const n=typeof e=="string"?e:"";return this._publicKey=n,{publicKey:n}}async disconnect(){await this.phantom.solana.disconnect(),this._publicKey=null}async signMessage(t){const e=typeof t=="string"?new TextEncoder().encode(t):t,n=await this.phantom.solana.signMessage(e);return{signature:n.signature instanceof Uint8Array?n.signature:new Uint8Array(Et.Buffer.from(n.signature,"base64")),publicKey:this._publicKey||""}}async signTransaction(t){if(!this.connected)return Promise.reject(new Error("Provider not connected. Call provider connect first."));try{return await this.phantom.solana.signTransaction(t)}catch(e){return Promise.reject(e)}}async signAndSendTransaction(t){return{signature:(await this.phantom.solana.signAndSendTransaction(t)).signature}}async signAllTransactions(t){if(!this.connected)return Promise.reject(new Error("Provider not connected. Call provider connect first."));try{return await this.phantom.solana.signAllTransactions(t)}catch(e){return Promise.reject(e)}}async signAndSendAllTransactions(t){if(!this.connected)return Promise.reject(new Error("Provider not connected. Call provider connect first."));try{return{signatures:(await this.phantom.solana.signAndSendAllTransactions(t)).signatures}}catch(e){return Promise.reject(e)}}switchNetwork(t){return Promise.resolve()}getPublicKey(){return Promise.resolve(this._publicKey)}isConnected(){return this.connected}setupEventListeners(){this.phantom.solana.addEventListener("connect",t=>{this._publicKey=t,this.eventEmitter.emit("connect",t)}),this.phantom.solana.addEventListener("disconnect",()=>{this._publicKey=null,this.eventEmitter.emit("disconnect")}),this.phantom.solana.addEventListener("accountChanged",t=>{this._publicKey=t,this.eventEmitter.emit("accountChanged",t)})}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}},aH=class{constructor(t){this._chainId="0x1",this._accounts=[],this.eventEmitter=new _c,this.phantom=t,this.setupEventListeners()}get connected(){return this._accounts.length>0}get chainId(){return this._chainId}get accounts(){return this._accounts}async request(t){if(t.method==="eth_signTransaction"){const[n]=t.params;return await this.signTransaction(n)}return await(await this.phantom.ethereum.getProvider()).request(t)}async connect(){const t=await this.phantom.ethereum.getAccounts();return this._accounts=t,t}async disconnect(){await this.phantom.ethereum.disconnect(),this._accounts=[]}async signPersonalMessage(t,e){return await this.phantom.ethereum.signPersonalMessage(t,e)}async signTypedData(t,e){return await this.phantom.ethereum.signTypedData(t,e)}async signTransaction(t){return await this.phantom.ethereum.signTransaction(t)}async sendTransaction(t){return await this.phantom.ethereum.sendTransaction(t)}async switchChain(t){const e=typeof t=="string"?t.toLowerCase().startsWith("0x")?t:`0x${parseInt(t,10).toString(16)}`:`0x${t.toString(16)}`;await this.phantom.ethereum.switchChain(e),this._chainId=e,this.eventEmitter.emit("chainChanged",this._chainId)}async getChainId(){const t=await this.phantom.ethereum.getChainId();return parseInt(t,16)}async getAccounts(){return await this.phantom.ethereum.getAccounts()}isConnected(){return this.connected}setupEventListeners(){this.phantom.ethereum.addEventListener("connect",t=>{this._accounts=t,this.eventEmitter.emit("connect",{chainId:this._chainId}),this.eventEmitter.emit("accountsChanged",t)}),this.phantom.ethereum.addEventListener("disconnect",()=>{this._accounts=[],this.eventEmitter.emit("disconnect",{code:4900,message:"Provider disconnected"}),this.eventEmitter.emit("accountsChanged",[])}),this.phantom.ethereum.addEventListener("accountsChanged",t=>{this._accounts=t,this.eventEmitter.emit("accountsChanged",t)}),this.phantom.ethereum.addEventListener("chainChanged",t=>{this._chainId=t,this.eventEmitter.emit("chainChanged",t)})}on(t,e){this.eventEmitter.on(t,e)}off(t,e){this.eventEmitter.off(t,e)}};function yi(t){return t!==void 0&&t.id==="phantom"&&"isPhantom"in t&&t.isPhantom===!0}var cH=class{constructor(){this.wallets=new Map,this.discoveryPromise=null}register(t){const e={};t.providers?.solana&&(t.providers.solana&&typeof t.providers.solana=="object"&&"features"in t.providers.solana&&typeof t.providers.solana.features=="object"?(e.solana=new iH(t.providers.solana,t.id,t.name),ee.log(te.BROWSER_SDK,"Wrapped Wallet Standard Solana wallet with adapter",{walletId:t.id,walletName:t.name})):(e.solana=new rH(t.providers.solana,t.id,t.name),ee.log(te.BROWSER_SDK,"Wrapped Solana provider with InjectedWalletSolanaChain",{walletId:t.id,walletName:t.name}))),t.providers?.ethereum&&(e.ethereum=new sH(t.providers.ethereum,t.id,t.name),ee.log(te.BROWSER_SDK,"Wrapped Ethereum provider with InjectedWalletEthereumChain",{walletId:t.id,walletName:t.name}));const n={...t,providers:Object.keys(e).length>0?e:t.providers};this.wallets.set(t.id,n)}registerPhantom(t,e){const n={};e.includes(yt.solana)&&t.solana&&(n.solana=new oH(t),ee.log(te.BROWSER_SDK,"Created PhantomSolanaChain wrapper",{walletId:"phantom"})),e.includes(yt.ethereum)&&t.ethereum&&(n.ethereum=new aH(t),ee.log(te.BROWSER_SDK,"Created PhantomEthereumChain wrapper",{walletId:"phantom"}));const r={id:"phantom",name:"Phantom",icon:"",addressTypes:e,providers:n,isPhantom:!0,phantomInstance:t,discovery:"phantom"};this.wallets.set("phantom",r),ee.log(te.BROWSER_SDK,"Registered Phantom wallet with chain wrappers",{addressTypes:e,hasSolana:!!n.solana,hasEthereum:!!n.ethereum})}unregister(t){this.wallets.delete(t)}has(t){return this.wallets.has(t)}getById(t){return this.wallets.get(t)}getAll(){return Array.from(this.wallets.values())}getByAddressTypes(t){if(t.length===0)return this.getAll();const e=new Set(t);return this.getAll().filter(n=>n.addressTypes.some(r=>e.has(r)))}discover(t){return this.discoveryPromise?this.discoveryPromise:(ee.log(te.BROWSER_SDK,"Starting wallet discovery",{addressTypes:t}),this.discoveryPromise=nH(t).then(e=>{const n=t?e.filter(r=>r.addressTypes.some(i=>t.includes(i))):e;for(const r of n)r.id==="phantom"&&yi(r)?this.registerPhantom(r.phantomInstance,r.addressTypes):this.register(r),ee.log(te.BROWSER_SDK,"Registered discovered wallet",{id:r.id,name:r.name,addressTypes:r.addressTypes});ee.info(te.BROWSER_SDK,"Wallet discovery completed",{totalDiscovered:e.length,relevantWallets:n.length})}).catch(e=>{throw ee.warn(te.BROWSER_SDK,"Wallet discovery failed",{error:e}),this.discoveryPromise=null,e}),this.discoveryPromise)}},n0=null;function TT(){return n0||(n0=new cH),n0}var r0="phantom-injected-was-connected",i_="true",s_="phantom-injected-last-wallet-id",lH=class{constructor(t){this.selectedWalletId=null,this.walletStates=new Map,this.eventListeners=new Map,this.browserInjectedCleanupFunctions=[],this.eventsInitialized=!1,this.externalWalletEventListenersSetup=new Set,ee.log(te.INJECTED_PROVIDER,"Initializing InjectedProvider",{config:t}),this.addressTypes=t.addressTypes,this.walletRegistry=TT(),ee.log(te.INJECTED_PROVIDER,"Address types configured",{addressTypes:this.addressTypes}),this.walletRegistry.discover(this.addressTypes).catch(e=>{ee.warn(te.INJECTED_PROVIDER,"Wallet discovery failed during initialization",{error:e})}),ee.info(te.INJECTED_PROVIDER,"InjectedProvider initialized")}async waitForWalletDiscovery(t){if(!this.walletRegistry.has(t)){ee.log(te.INJECTED_PROVIDER,"Wallet not found in registry, waiting for discovery",{walletId:t});try{await this.walletRegistry.discover(this.addressTypes),ee.log(te.INJECTED_PROVIDER,"Wallet discovery completed",{walletId:t})}catch(e){ee.warn(te.INJECTED_PROVIDER,"Wallet discovery failed",{walletId:t,error:e instanceof Error?e.message:String(e)})}}}get solana(){if(!this.addressTypes.includes(yt.solana))throw new Error("Solana not enabled for this provider");const t=this.selectedWalletId||"phantom",e=this.walletRegistry.getById(t);if(!e)throw this.walletRegistry.discoveryPromise?new Error(`Wallet "${t}" not found. Wallet discovery is still in progress. Please wait for sdk.discoverWallets() to complete before accessing chain properties.`):new Error(`Wallet "${t}" not found. Please ensure wallet discovery has completed. Make sure you call sdk.discoverWallets() and await it before accessing chain properties.`);if(!e.providers?.solana)throw new Error(`Selected wallet "${e.name}" does not support Solana. This wallet only supports: ${e.addressTypes.join(", ")}. Make sure your SDK config includes Solana in addressTypes.`);return e.providers.solana}get ethereum(){if(!this.addressTypes.includes(yt.ethereum))throw new Error("Ethereum not enabled for this provider");const t=this.selectedWalletId||"phantom",e=this.walletRegistry.getById(t);if(!e)throw this.walletRegistry.discoveryPromise?new Error(`Wallet "${t}" not found. Wallet discovery is still in progress. Please wait for sdk.discoverWallets() to complete before accessing chain properties.`):new Error(`Wallet "${t}" not found. Please ensure wallet discovery has completed. Make sure you call sdk.discoverWallets() and await it before accessing chain properties.`);if(!e.providers?.ethereum)throw new Error(`Selected wallet "${e.name}" does not support Ethereum. This wallet only supports: ${e.addressTypes.join(", ")}. Make sure your SDK config includes Ethereum in addressTypes.`);return e.providers.ethereum}validateAndSelectWallet(t){if(!this.walletRegistry.has(t))throw ee.error(te.INJECTED_PROVIDER,"Unknown injected wallet id requested",{walletId:t}),new Error(`Unknown injected wallet id: ${t}`);const e=this.walletRegistry.getById(t);if(!e||!e.providers)throw ee.warn(te.INJECTED_PROVIDER,"Wallet not available for connection",{walletId:t}),new Error(`Wallet not available for connection: ${t}`);return this.selectedWalletId=t,ee.log(te.INJECTED_PROVIDER,"Selected injected wallet for connection",{walletId:t}),e}async connectToWallet(t,e){if(!t.providers){const r=new Error(`Wallet adapter not available for wallet: ${this.selectedWalletId}`);throw ee.error(te.INJECTED_PROVIDER,"Wallet adapter not available",{walletId:this.selectedWalletId}),this.emit("connect_error",{error:r.message,source:e?.skipEventListeners?"auto-connect":"manual-connect"}),r}ee.log(te.INJECTED_PROVIDER,"Connecting via wallet",{walletId:this.selectedWalletId,walletName:t.name,options:e}),e?.skipEventListeners||(this.setupExternalWalletEvents(t),this.selectedWalletId==="phantom"&&yi(t)&&(this.browserInjectedCleanupFunctions.forEach(r=>r()),this.browserInjectedCleanupFunctions=[],this.setupBrowserInjectedEvents(),this.eventsInitialized=!0));const n=[];if(this.addressTypes.includes(yt.solana)&&t.providers?.solana){ee.log(te.INJECTED_PROVIDER,"Attempting Solana connection",{walletId:this.selectedWalletId,walletName:t.name,onlyIfTrusted:e?.onlyIfTrusted});try{const i=(await t.providers.solana.connect(e?.onlyIfTrusted?{onlyIfTrusted:!0}:void 0)).publicKey;n.push({addressType:yt.solana,address:i}),ee.info(te.INJECTED_PROVIDER,"Solana connected successfully",{address:i,walletId:this.selectedWalletId,walletName:t.name})}catch(r){throw ee.warn(te.INJECTED_PROVIDER,"Failed to connect Solana, stopping",{error:r,walletId:this.selectedWalletId,walletName:t.name}),this.emit("connect_error",{error:r instanceof Error?r.message:"Failed to connect",source:e?.skipEventListeners?"auto-connect":"manual-connect"}),r}}if(this.addressTypes.includes(yt.ethereum)&&t.providers?.ethereum){ee.log(te.INJECTED_PROVIDER,"Attempting Ethereum connection",{walletId:this.selectedWalletId,walletName:t.name,silent:e?.silent});try{let r;e?.silent?r=await t.providers.ethereum.request({method:"eth_accounts"}):r=await t.providers.ethereum.connect(),r.length>0&&(n.push(...r.map(i=>({addressType:yt.ethereum,address:i}))),ee.info(te.INJECTED_PROVIDER,"Ethereum connected successfully",{addresses:r,walletId:this.selectedWalletId,walletName:t.name}))}catch(r){throw ee.warn(te.INJECTED_PROVIDER,"Failed to connect Ethereum, stopping",{error:r,walletId:this.selectedWalletId,walletName:t.name}),this.emit("connect_error",{error:r instanceof Error?r.message:"Failed to connect",source:e?.skipEventListeners?"auto-connect":"manual-connect"}),r}}return n}async finalizeConnection(t,e,n){if(t.length===0){const a=new Error("Failed to connect to any supported wallet provider");throw this.emit("connect_error",{error:a.message,source:"manual-connect"}),a}this.selectedWalletId&&this.setWalletState(this.selectedWalletId,{connected:!0,addresses:t}),ee.log(te.INJECTED_PROVIDER,"Finalized connection with addresses",{addressCount:t.length,addresses:t.map(a=>({type:a.addressType,address:a.address.substring(0,10)+"..."}))});const r=await this.getAuthUserId("manual-connect");try{localStorage.setItem(r0,i_),ee.log(te.INJECTED_PROVIDER,"Set was-connected flag - auto-reconnect enabled"),this.selectedWalletId&&(localStorage.setItem(s_,this.selectedWalletId),ee.log(te.INJECTED_PROVIDER,"Stored last injected wallet id",{walletId:this.selectedWalletId}))}catch(a){ee.warn(te.INJECTED_PROVIDER,"Failed to persist injected provider state",{error:a})}const i=n?this.walletRegistry.getById(n):void 0,s=i?{id:i.id,name:i.name,icon:i.icon,addressTypes:i.addressTypes,rdns:i.rdns,discovery:i.discovery}:void 0,o={addresses:t,status:"completed",authUserId:r,authProvider:e,walletId:n,wallet:s};return this.emit("connect",{addresses:t,source:"manual-connect",authUserId:r}),o}async connect(t){if(ee.info(te.INJECTED_PROVIDER,"Starting injected provider connect",{addressTypes:this.addressTypes,provider:t.provider}),t.provider!=="injected")throw new Error(`Invalid provider for injected connection: ${t.provider}. Must be "injected"`);this.emit("connect_start",{source:"manual-connect",providerType:"injected"});try{const e=t.walletId||"phantom",n=this.validateAndSelectWallet(e),r=await this.connectToWallet(n);return await this.finalizeConnection(r,"injected",this.selectedWalletId||void 0)}catch(e){throw this.emit("connect_error",{error:e instanceof Error?e.message:"Failed to connect",source:"manual-connect"}),e}}async disconnect(){ee.info(te.INJECTED_PROVIDER,"Starting injected provider disconnect");const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(t?.providers){if(this.addressTypes.includes(yt.solana)&&t.providers.solana)try{await t.providers.solana.disconnect(),ee.log(te.INJECTED_PROVIDER,"Solana disconnected successfully")}catch(e){ee.warn(te.INJECTED_PROVIDER,"Failed to disconnect Solana",{error:e})}if(this.addressTypes.includes(yt.ethereum)&&t.providers.ethereum)try{await t.providers.ethereum.disconnect(),ee.log(te.INJECTED_PROVIDER,"Ethereum disconnected successfully")}catch(e){ee.warn(te.INJECTED_PROVIDER,"Failed to disconnect Ethereum",{error:e})}}this.browserInjectedCleanupFunctions.forEach(e=>e()),this.browserInjectedCleanupFunctions=[],this.selectedWalletId&&(this.externalWalletEventListenersSetup.delete(this.selectedWalletId),this.setWalletState(this.selectedWalletId,{connected:!1,addresses:[]}));try{localStorage.removeItem(r0),ee.log(te.INJECTED_PROVIDER,"Cleared was connected flag to prevent auto-reconnect")}catch(e){ee.warn(te.INJECTED_PROVIDER,"Failed to clear was-connected flag",{error:e})}this.emit("disconnect",{source:"manual-disconnect"}),ee.info(te.INJECTED_PROVIDER,"Injected provider disconnected successfully")}async autoConnect(){ee.log(te.INJECTED_PROVIDER,"Attempting auto-connect");let t=null;try{if(localStorage.getItem(r0)!==i_){ee.log(te.INJECTED_PROVIDER,"Skipping auto-connect: user was not previously connected");return}t=localStorage.getItem(s_),ee.log(te.INJECTED_PROVIDER,"User was previously connected, attempting auto-connect",{lastWalletId:t||"phantom"})}catch(e){ee.warn(te.INJECTED_PROVIDER,"Failed to check was-connected flag",{error:e});return}this.emit("connect_start",{source:"auto-connect",providerType:"injected"});try{const e=t||"phantom";await this.waitForWalletDiscovery(e);const n=this.validateAndSelectWallet(e);let r=[];try{r=await this.connectToWallet(n,{onlyIfTrusted:!0,silent:!0,skipEventListeners:!0})}catch(s){ee.log(te.INJECTED_PROVIDER,"Auto-connect failed (expected if not trusted)",{error:s,walletId:this.selectedWalletId})}if(r.length===0){ee.log(te.INJECTED_PROVIDER,"Auto-connect failed: no trusted connections available"),this.emit("connect_error",{error:"No trusted connections available",source:"auto-connect"});return}this.setupExternalWalletEvents(n),this.selectedWalletId==="phantom"&&yi(n)&&(this.browserInjectedCleanupFunctions.forEach(s=>s()),this.browserInjectedCleanupFunctions=[],this.setupBrowserInjectedEvents(),this.eventsInitialized=!0),this.selectedWalletId&&this.setWalletState(this.selectedWalletId,{connected:!0,addresses:r});const i=await this.getAuthUserId("auto-connect");this.emit("connect",{addresses:r,source:"auto-connect",authUserId:i}),ee.info(te.INJECTED_PROVIDER,"Auto-connect successful",{addressCount:r.length,addresses:r.map(s=>({type:s.addressType,address:s.address.substring(0,8)+"..."})),walletId:this.selectedWalletId,authUserId:i})}catch(e){ee.log(te.INJECTED_PROVIDER,"Auto-connect failed with error",{error:e instanceof Error?e.message:String(e)}),this.emit("connect_error",{error:e instanceof Error?e.message:"Auto-connect failed",source:"auto-connect"})}}getWalletState(t){return this.walletStates.has(t)||this.walletStates.set(t,{connected:!1,addresses:[]}),this.walletStates.get(t)}setWalletState(t,e){this.walletStates.set(t,e)}getAddresses(){const t=this.selectedWalletId||"phantom";return this.getWalletState(t).addresses}getEnabledAddressTypes(){if(!this.selectedWalletId||this.selectedWalletId==="phantom")return this.addressTypes;const t=this.walletRegistry.getById(this.selectedWalletId);return t?t.addressTypes:this.addressTypes}isConnected(){const t=this.selectedWalletId||"phantom";return this.getWalletState(t).connected}async enableAutoConfirm(t){const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!yi(e))throw new Error("Auto-confirm is only available for Phantom wallet");return ee.log(te.INJECTED_PROVIDER,"Enabling autoConfirm",{params:t}),await e.phantomInstance.autoConfirm.autoConfirmEnable(t)}async disableAutoConfirm(){const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!yi(t))throw new Error("Auto-confirm is only available for Phantom wallet");ee.log(te.INJECTED_PROVIDER,"Disabling autoConfirm"),await t.phantomInstance.autoConfirm.autoConfirmDisable()}async getAutoConfirmStatus(){const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!yi(t))throw new Error("Auto-confirm is only available for Phantom wallet");return ee.log(te.INJECTED_PROVIDER,"Getting autoConfirm status"),await t.phantomInstance.autoConfirm.autoConfirmStatus()}async getSupportedAutoConfirmChains(){const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!yi(t))throw new Error("Auto-confirm is only available for Phantom wallet");return ee.log(te.INJECTED_PROVIDER,"Getting supported autoConfirm chains"),await t.phantomInstance.autoConfirm.autoConfirmSupportedChains()}async getAuthUserId(t){const e=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(yi(e))try{if(window.phantom?.app?.getUser){const r=(await window.phantom.app.getUser())?.authUserId;return r&&ee.log(te.INJECTED_PROVIDER,`Retrieved authUserId from window.phantom.app.getUser() during ${t}`,{authUserId:r}),r}}catch(n){ee.log(te.INJECTED_PROVIDER,`Failed to get user info during ${t} (method may not be supported)`,{error:n})}}on(t,e){ee.log(te.INJECTED_PROVIDER,"Adding event listener",{event:t}),this.eventsInitialized||(this.setupBrowserInjectedEvents(),this.eventsInitialized=!0),this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){ee.log(te.INJECTED_PROVIDER,"Removing event listener",{event:t}),this.eventListeners.has(t)&&(this.eventListeners.get(t).delete(e),this.eventListeners.get(t).size===0&&this.eventListeners.delete(t))}emit(t,e){ee.log(te.INJECTED_PROVIDER,"Emitting event",{event:t,listenerCount:this.eventListeners.get(t)?.size||0,data:e});const n=this.eventListeners.get(t);n&&n.size>0&&n.forEach(r=>{try{r(e)}catch(i){ee.error(te.INJECTED_PROVIDER,"Event callback error",{event:t,error:i})}})}setupBrowserInjectedEvents(){const t=this.walletRegistry.getById(this.selectedWalletId||"phantom");if(!yi(t)){ee.log(te.INJECTED_PROVIDER,"Skipping browser-injected-sdk event setup - not Phantom wallet");return}ee.log(te.INJECTED_PROVIDER,"Setting up browser-injected-sdk event listeners"),this.selectedWalletId==="phantom"&&yi(t)&&(this.addressTypes.includes(yt.solana)&&this.setupSolanaEvents(t.phantomInstance),this.addressTypes.includes(yt.ethereum)&&this.setupEthereumEvents(t.phantomInstance))}setupSolanaEvents(t){ee.log(te.INJECTED_PROVIDER,"Setting up Solana event listeners");const e=async a=>{ee.log(te.INJECTED_PROVIDER,"Solana connect event received",{publicKey:a});const c=this.selectedWalletId||"phantom",l=this.getWalletState(c),u={addressType:yt.solana,address:a},f=l.addresses.some(v=>v.addressType===yt.solana)?l.addresses.map(v=>v.addressType===yt.solana?u:v):[...l.addresses,u];this.setWalletState(c,{connected:!0,addresses:f});const g=await this.getAuthUserId("Solana connect event");this.emit("connect",{addresses:f,source:"injected-extension",authUserId:g})},n=()=>{ee.log(te.INJECTED_PROVIDER,"Solana disconnect event received");const a=this.selectedWalletId||"phantom",l=this.getWalletState(a).addresses.filter(u=>u.addressType!==yt.solana);this.setWalletState(a,{connected:l.length>0,addresses:l}),this.emit("disconnect",{source:"injected-extension"})},r=async a=>{ee.log(te.INJECTED_PROVIDER,"Solana account changed event received",{publicKey:a});const c=this.selectedWalletId||"phantom",l=this.getWalletState(c),u=l.addresses.findIndex(g=>g.addressType===yt.solana),d=u>=0?l.addresses.map((g,v)=>v===u?{addressType:yt.solana,address:a}:g):[...l.addresses,{addressType:yt.solana,address:a}];this.setWalletState(c,{connected:!0,addresses:d});const f=await this.getAuthUserId("Solana account changed event");this.emit("connect",{addresses:d,source:"injected-extension-account-change",authUserId:f})},i=t.solana.addEventListener("connect",e),s=t.solana.addEventListener("disconnect",n),o=t.solana.addEventListener("accountChanged",r);this.browserInjectedCleanupFunctions.push(i,s,o)}setupEthereumEvents(t){ee.log(te.INJECTED_PROVIDER,"Setting up Ethereum event listeners");const e=async a=>{ee.log(te.INJECTED_PROVIDER,"Ethereum connect event received",{accounts:a});const c=this.selectedWalletId||"phantom",l=this.getWalletState(c),u=a.map(v=>({addressType:yt.ethereum,address:v})),f=[...l.addresses.filter(v=>v.addressType!==yt.ethereum),...u];this.setWalletState(c,{connected:!0,addresses:f});const g=await this.getAuthUserId("Ethereum connect event");this.emit("connect",{addresses:f,source:"injected-extension",authUserId:g})},n=()=>{ee.log(te.INJECTED_PROVIDER,"Ethereum disconnect event received");const a=this.selectedWalletId||"phantom",l=this.getWalletState(a).addresses.filter(u=>u.addressType!==yt.ethereum);this.setWalletState(a,{connected:l.length>0,addresses:l}),this.emit("disconnect",{source:"injected-extension"})},r=async a=>{ee.log(te.INJECTED_PROVIDER,"Ethereum accounts changed event received",{accounts:a});const c=this.selectedWalletId||"phantom",u=this.getWalletState(c).addresses.filter(d=>d.addressType!==yt.ethereum);if(a&&a.length>0){const d=a.map(v=>({addressType:yt.ethereum,address:v})),f=[...u,...d];this.setWalletState(c,{connected:!0,addresses:f});const g=await this.getAuthUserId("Ethereum accounts changed event");this.emit("connect",{addresses:f,source:"injected-extension-account-change",authUserId:g})}else this.setWalletState(c,{connected:u.length>0,addresses:u}),this.emit("disconnect",{source:"injected-extension-account-change"})},i=t.ethereum.addEventListener("connect",e),s=t.ethereum.addEventListener("disconnect",n),o=t.ethereum.addEventListener("accountsChanged",r);this.browserInjectedCleanupFunctions.push(i,s,o)}setupExternalWalletEvents(t){if(!yi(t)&&!(!this.selectedWalletId||this.externalWalletEventListenersSetup.has(this.selectedWalletId))){if(ee.log(te.INJECTED_PROVIDER,"Setting up external wallet event listeners",{walletId:this.selectedWalletId}),t.providers?.ethereum){const e=async n=>{ee.log(te.INJECTED_PROVIDER,"External wallet Ethereum accounts changed event received",{walletId:this.selectedWalletId,accounts:n});const r=this.selectedWalletId,s=this.getWalletState(r).addresses.filter(o=>o.addressType!==yt.ethereum);if(n&&n.length>0){const o=n.map(l=>({addressType:yt.ethereum,address:l})),a=[...s,...o];this.setWalletState(r,{connected:!0,addresses:a}),ee.log(te.INJECTED_PROVIDER,"Updated Ethereum addresses after account change",{walletId:r,oldCount:0,newCount:n.length,addresses:a.filter(l=>l.addressType===yt.ethereum)});const c=await this.getAuthUserId("External wallet Ethereum accounts changed event");this.emit("connect",{addresses:a,source:"external-wallet-account-change",authUserId:c})}else this.setWalletState(r,{connected:s.length>0,addresses:s}),this.emit("disconnect",{source:"external-wallet-account-change"})};typeof t.providers.ethereum.on=="function"&&(t.providers.ethereum.on("accountsChanged",e),this.browserInjectedCleanupFunctions.push(()=>{typeof t.providers?.ethereum?.off=="function"&&t.providers.ethereum.off("accountsChanged",e)}))}if(t.providers?.solana){const e=async n=>{ee.log(te.INJECTED_PROVIDER,"External wallet Solana account changed event received",{walletId:this.selectedWalletId,publicKey:n});const r=this.selectedWalletId,s=this.getWalletState(r).addresses.filter(o=>o.addressType!==yt.solana);if(n){const o=[...s,{addressType:yt.solana,address:n}];this.setWalletState(r,{connected:!0,addresses:o});const a=await this.getAuthUserId("External wallet Solana account changed event");this.emit("connect",{addresses:o,source:"external-wallet-account-change",authUserId:a})}else this.setWalletState(r,{connected:s.length>0,addresses:s}),this.emit("disconnect",{source:"external-wallet-account-change"})};typeof t.providers.solana.on=="function"&&(t.providers.solana.on("accountChanged",e),this.browserInjectedCleanupFunctions.push(()=>{typeof t.providers?.solana?.off=="function"&&t.providers.solana.off("accountChanged",e)}))}this.selectedWalletId&&this.externalWalletEventListenersSetup.add(this.selectedWalletId)}}},uH=class{constructor(){this.dbName="phantom-browser-sdk",this.storeName="sessions",this.version=1}async getDB(){return new Promise((t,e)=>{const n=indexedDB.open(this.dbName,this.version);n.onerror=()=>e(n.error),n.onsuccess=()=>t(n.result),n.onupgradeneeded=r=>{const i=r.target.result;i.objectStoreNames.contains(this.storeName)||i.createObjectStore(this.storeName)}})}async getSession(){ee.log(te.STORAGE,"Getting session from IndexedDB");const t=await this.getDB();return new Promise((e,n)=>{const s=t.transaction([this.storeName],"readonly").objectStore(this.storeName).get("currentSession");s.onsuccess=()=>{const o=s.result||null;ee.log(te.STORAGE,"Retrieved session from IndexedDB",{hasSession:!!o,sessionId:o?.sessionId}),e(o)},s.onerror=()=>{ee.error(te.STORAGE,"Failed to get session from IndexedDB",{error:s.error}),n(s.error)}})}async saveSession(t){ee.log(te.STORAGE,"Saving session to IndexedDB",{sessionId:t.sessionId,walletId:t.walletId,status:t.status});const e=await this.getDB();return new Promise((n,r)=>{const o=e.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(t,"currentSession");o.onsuccess=()=>{ee.log(te.STORAGE,"Successfully saved session to IndexedDB"),n()},o.onerror=()=>{ee.error(te.STORAGE,"Failed to save session to IndexedDB",{error:o.error}),r(o.error)}})}async clearSession(){ee.log(te.STORAGE,"Clearing session from IndexedDB");const t=await this.getDB();return new Promise((e,n)=>{const s=t.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete("currentSession");s.onsuccess=()=>{ee.log(te.STORAGE,"Successfully cleared session from IndexedDB"),e()},s.onerror=()=>{ee.error(te.STORAGE,"Failed to clear session from IndexedDB",{error:s.error}),n(s.error)}})}async getShouldClearPreviousSession(){ee.log(te.STORAGE,"Getting shouldClearPreviousSession flag from IndexedDB");const t=await this.getDB();return new Promise((e,n)=>{const s=t.transaction([this.storeName],"readonly").objectStore(this.storeName).get("shouldClearPreviousSession");s.onsuccess=()=>{const o=s.result??!1;ee.log(te.STORAGE,"Retrieved shouldClearPreviousSession flag from IndexedDB",{shouldClear:o}),e(o)},s.onerror=()=>{ee.error(te.STORAGE,"Failed to get shouldClearPreviousSession flag from IndexedDB",{error:s.error}),n(s.error)}})}async setShouldClearPreviousSession(t){ee.log(te.STORAGE,"Setting shouldClearPreviousSession flag in IndexedDB",{should:t});const e=await this.getDB();return new Promise((n,r)=>{const o=e.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(t,"shouldClearPreviousSession");o.onsuccess=()=>{ee.log(te.STORAGE,"Successfully set shouldClearPreviousSession flag in IndexedDB"),n()},o.onerror=()=>{ee.error(te.STORAGE,"Failed to set shouldClearPreviousSession flag in IndexedDB",{error:o.error}),r(o.error)}})}},dH=class{getParam(t){return new URLSearchParams(window.location.search).get(t)}};function fH(t,e){let n="unknown",r="unknown";if(!t||typeof t!="string")return{name:n,version:r,userAgent:"unknown"};try{if(t.includes("Edg/")){n="edge";const i=t.match(/Edg\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("OPR/")||t.includes("Opera/")){n="opera";const i=t.match(/(?:OPR|Opera)\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("SamsungBrowser/")){n="samsung";const i=t.match(/SamsungBrowser\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("DuckDuckGo/")){n="duckduckgo";const i=t.match(/DuckDuckGo\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Chrome/")&&e){n="brave";const i=t.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Mobile/")||t.includes("Android"))if(t.includes("Chrome/")){n="chrome-mobile";const i=t.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Firefox/")){n="firefox-mobile";const i=t.match(/Firefox\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Safari/")&&t.includes("Mobile/")){n="safari-mobile";const i=t.match(/Version\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else n="mobile";else if(t.includes("Chrome/")){n="chrome";const i=t.match(/Chrome\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Firefox/")){n="firefox";const i=t.match(/Firefox\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}else if(t.includes("Safari/")&&!t.includes("Chrome/")){n="safari";const i=t.match(/Version\/([0-9]+(?:\.[0-9]+)*)/);i&&(r=i[1].split(".")[0])}if(n==="unknown"){const i=[{regex:/Chrome\/([0-9]+)/,name:"chrome"},{regex:/Firefox\/([0-9]+)/,name:"firefox"},{regex:/Safari\/([0-9]+)/,name:"safari"},{regex:/Edge\/([0-9]+)/,name:"edge"},{regex:/Opera\/([0-9]+)/,name:"opera"}];for(const s of i){const o=t.match(s.regex);if(o){n=s.name,r=o[1];break}}}}catch{}return{name:n,version:r,userAgent:t}}function Ky(){if(typeof window>"u"||!window.navigator?.userAgent)return{name:"unknown",version:"unknown",userAgent:"unknown"};const t=window.navigator.userAgent,e=!!navigator.brave;return fH(t,e)}function hH(){const{name:t,version:e}=Ky();return e!=="unknown"?`${t}-v${e}`:t}var pH=class{constructor(t){this.urlParamsAccessor=t}getValidatedCurrentUrl(){const t=window.location.href;if(!t.startsWith("http:")&&!t.startsWith("https:"))throw new Error("Invalid URL protocol - only HTTP/HTTPS URLs are supported");return t}authenticate(t){return new Promise(e=>{if("jwtToken"in t)throw new Error("JWT authentication should be handled by the core JWTAuth class");const n=t;ee.info(te.PHANTOM_CONNECT_AUTH,"Starting Phantom Connect authentication",{publicKey:n.publicKey,appId:n.appId,provider:n.provider,authUrl:n.authUrl});const r=n.authUrl||TR;ee.log(te.PHANTOM_CONNECT_AUTH,"Using auth URL",{baseUrl:r});const i=new URLSearchParams({public_key:n.publicKey,app_id:n.appId,redirect_uri:n.redirectUrl||(typeof window<"u"?this.getValidatedCurrentUrl():""),session_id:n.sessionId,clear_previous_session:(n.clearPreviousSession??!1).toString(),allow_refresh:(n.allowRefresh??!0).toString(),sdk_version:"1.0.0",sdk_type:"browser",platform:Ky().name});n.provider?(ee.log(te.PHANTOM_CONNECT_AUTH,"Provider specified, will skip selection",{provider:n.provider}),i.append("provider",n.provider)):(ee.log(te.PHANTOM_CONNECT_AUTH,"No provider specified, defaulting to Google"),i.append("provider","google"));const s={publicKey:n.publicKey,appId:n.appId,provider:n.provider,sessionId:n.sessionId};sessionStorage.setItem("phantom-auth-context",JSON.stringify(s)),ee.log(te.PHANTOM_CONNECT_AUTH,"Stored auth context in session storage",{authContext:s});const o=`${r}?${i.toString()}`;if(ee.info(te.PHANTOM_CONNECT_AUTH,"Redirecting to Phantom Connect",{authUrl:o}),!o.startsWith("https:")&&!o.startsWith("http://localhost"))throw new Error("Invalid auth URL - only HTTPS URLs are allowed for authentication");window.location.href=o,e()})}resumeAuthFromRedirect(t){try{const e=this.urlParamsAccessor.getParam("wallet_id"),n=this.urlParamsAccessor.getParam("session_id"),r=this.urlParamsAccessor.getParam("selected_account_index"),i=this.urlParamsAccessor.getParam("error"),s=this.urlParamsAccessor.getParam("error_description");if(i){const d=s||i;switch(i){case"access_denied":throw new Error(`Authentication cancelled: ${d}`);case"invalid_request":throw new Error(`Invalid authentication request: ${d}`);case"server_error":throw new Error(`Authentication server error: ${d}`);case"temporarily_unavailable":throw new Error(`Authentication service temporarily unavailable: ${d}`);default:throw new Error(`Authentication failed: ${d}`)}}if(!e||!n)return ee.log(te.PHANTOM_CONNECT_AUTH,"Missing auth parameters in URL",{hasWalletId:!!e,hasSessionId:!!n}),null;const o=sessionStorage.getItem("phantom-auth-context");let a={};if(o)try{a=JSON.parse(o)}catch(d){ee.warn(te.PHANTOM_CONNECT_AUTH,"Failed to parse stored auth context",{error:d})}if(a.sessionId&&n!==a.sessionId)throw ee.error(te.PHANTOM_CONNECT_AUTH,"Session ID mismatch",{urlSessionId:n,storedSessionId:a.sessionId}),new Error("Session ID mismatch - possible session corruption or replay attack");sessionStorage.removeItem("phantom-auth-context"),ee.info(te.PHANTOM_CONNECT_AUTH,"Successfully resumed auth from redirect",{walletId:e,sessionId:n,accountDerivationIndex:r?parseInt(r):void 0});const c=this.urlParamsAccessor.getParam("organization_id"),l=this.urlParamsAccessor.getParam("expires_in_ms"),u=this.urlParamsAccessor.getParam("auth_user_id");if(ee.log(te.PHANTOM_CONNECT_AUTH,"Auth redirect parameters",{walletId:e,organizationId:c,sessionId:n,accountDerivationIndex:r,expiresInMs:l,authUserId:u}),!c)throw ee.error(te.PHANTOM_CONNECT_AUTH,"Missing organization_id in auth response"),new Error("Missing organization_id in auth response");return c.startsWith("temp-")&&ee.warn(te.PHANTOM_CONNECT_AUTH,"Received temporary organization_id, server may not be configured properly",{organizationId:c}),{walletId:e,organizationId:c,accountDerivationIndex:r?parseInt(r):0,expiresInMs:l?parseInt(l):0,authUserId:u||void 0,provider:t}}catch(e){throw sessionStorage.removeItem("phantom-auth-context"),e}}};async function mH(t=3e3){if(!await gH(t))return!1;try{if(!window.phantom?.app?.features||typeof window.phantom.app.features!="function")return!1;const n=await window.phantom.app.features();return Array.isArray(n.features)?n.features.includes("phantom_login"):!1}catch(n){return console.error("Error checking Phantom extension features",n),!1}}async function gH(t){return new Promise(e=>{const n=Date.now(),r=100,i=()=>{try{if(Zf()){e(!0);return}}catch{}if(Date.now()-n>=t){e(!1);return}setTimeout(i,r)};i()})}var yH=class{isAvailable(){return Zf()}async authenticate(t){if(!this.isAvailable())throw new Error("Phantom extension is not installed. Please install the Phantom browser extension to use this authentication method.");if(!await mH())throw new Error("Phantom Login is not available. Please update your Phantom extension to use this authentication method.");try{if(!window.phantom?.app?.login)throw new Error("Phantom extension login method not found");const n=await window.phantom.app.login({publicKey:t.publicKey,appId:t.appId,sessionId:t.sessionId});if(!n||!n.walletId||!n.organizationId)throw new Error("Invalid authentication response from Phantom extension");return{walletId:n.walletId,organizationId:n.organizationId,provider:"phantom",accountDerivationIndex:n.accountDerivationIndex??0,expiresInMs:n.expiresInMs??0,authUserId:n.authUserId}}catch(n){throw n instanceof Error?n:new Error(`Phantom extension authentication failed: ${String(n)}`)}}},wH=class{info(t,e,n){ee.info(t,e,n)}warn(t,e,n){ee.warn(t,e,n)}error(t,e,n){ee.error(t,e,n)}log(t,e,n){ee.log(t,e,n)}},vH=class extends Gj{constructor(t){ee.log(te.EMBEDDED_PROVIDER,"Initializing Browser EmbeddedProvider",{config:t});const e=new dH,n=new Yj({dbName:`phantom-embedded-sdk-${t.appId}`,storeName:"crypto-keys",keyName:"signing-key"}),r=hH(),{name:i,version:s}=Ky(),o={storage:new uH,authProvider:new pH(e),phantomAppProvider:new yH,urlParamsAccessor:e,stamper:n,name:r,analyticsHeaders:{[ya.SDK_TYPE]:"browser",[ya.PLATFORM]:i,[ya.PLATFORM_VERSION]:s,[ya.APP_ID]:t.appId,[ya.WALLET_TYPE]:t.embeddedWalletType,[ya.SDK_VERSION]:"1.0.0"}};ee.log(te.EMBEDDED_PROVIDER,"Detected platform",{platformName:r});const a=new wH;super(t,o,a),this.addressTypes=t.addressTypes,ee.info(te.EMBEDDED_PROVIDER,"Browser EmbeddedProvider initialized")}getEnabledAddressTypes(){return this.addressTypes}};function EH(t){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search),n=e.get("response_type"),r=e.get("session_id");return n==="failure"&&!!r}function bH(t){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);return!!(e.get("session_id")&&(e.has("response_type")||e.has("wallet_id")))}function _H(t){if(!window.location.href.startsWith("http:")&&!window.location.href.startsWith("https:"))throw new Error("Invalid URL protocol - only HTTP/HTTPS URLs are supported for deeplinks");return`https://phantom.app/ul/browse/${encodeURIComponent(window.location.href)}`}var SH=class{constructor(t){this.providers=new Map,this.currentProvider=null,this.currentProviderKey=null,this.eventListeners=new Map,this.providerForwardingSetup=new WeakSet,ee.log(te.PROVIDER_MANAGER,"Initializing ProviderManager",{config:t}),this.config=t,ee.log(te.PROVIDER_MANAGER,"Setting default provider"),this.setDefaultProvider(),ee.info(te.PROVIDER_MANAGER,"ProviderManager initialized",{currentProviderKey:this.currentProviderKey})}getValidatedCurrentUrl(){if(typeof window>"u")return"";const t=window.location.href;if(!t.startsWith("http:")&&!t.startsWith("https:"))throw new Error("Invalid URL protocol - only HTTP/HTTPS URLs are supported");return t}switchProvider(t,e){if(e?.embeddedWalletType&&!["app-wallet","user-wallet"].includes(e.embeddedWalletType))throw new Error(`Invalid embeddedWalletType: ${e.embeddedWalletType}. Must be "app-wallet" or "user-wallet".`);const n=this.getProviderKey(t,e?.embeddedWalletType);return this.providers.has(n)||this.createProvider(t,e?.embeddedWalletType),this.currentProvider=this.providers.get(n),this.currentProviderKey=n,this.ensureProviderEventForwarding(),this.currentProvider}getCurrentProvider(){return this.currentProvider}getCurrentProviderInfo(){if(!this.currentProviderKey)return null;const t=this.currentProviderKey.split("-"),[e,n]=t;return{type:e,embeddedWalletType:n}}isProviderAllowed(t){return this.config.providers.includes(t)}async connect(t){if(ee.info(te.PROVIDER_MANAGER,"Starting connection",{currentProviderKey:this.currentProviderKey,authOptions:{provider:t.provider}}),!this.isProviderAllowed(t.provider)){const i=`Provider "${t.provider}" is not in the allowed providers list: ${JSON.stringify(this.config.providers)}`;throw ee.error(te.PROVIDER_MANAGER,i),new Error(i)}const e=t.provider;let n=null;if(e==="injected")n="injected";else if(e==="deeplink")try{const i=_H();return typeof window<"u"&&(window.location.href=i),{addresses:[],walletId:void 0,authUserId:void 0}}catch(i){const s=i instanceof Error?i.message:"Failed to open deeplink";throw ee.error(te.PROVIDER_MANAGER,"Deeplink error",{error:s}),new Error(`Failed to open deeplink: ${s}`)}else Af.includes(e)&&(n="embedded");if(n){const i=this.getCurrentProviderInfo();if(i?.type!==n){ee.log(te.PROVIDER_MANAGER,"Auto-switching provider based on auth options",{from:i?.type,to:n,requestedProvider:e});const s={};n==="embedded"&&(s.embeddedWalletType=i?.embeddedWalletType||this.config.embeddedWalletType),this.switchProvider(n,s)}}if(!this.currentProvider)throw ee.error(te.PROVIDER_MANAGER,"No provider selected"),new Error("No provider selected");ee.log(te.PROVIDER_MANAGER,"Delegating to provider connect method");const r=await this.currentProvider.connect(t);return ee.log(te.PROVIDER_MANAGER,"Connection successful, saving preferences",{addressCount:r.addresses?.length||0,provider:t.provider}),this.saveProviderPreference(),ee.info(te.PROVIDER_MANAGER,"Connect completed",{addresses:r.addresses,provider:t.provider}),r}async disconnect(){this.currentProvider&&await this.currentProvider.disconnect()}getAddresses(){return this.currentProvider?this.currentProvider.getAddresses():[]}isConnected(){return this.currentProvider?.isConnected()??!1}async autoConnect(){if(ee.log(te.PROVIDER_MANAGER,"Starting auto-connect with fallback strategy"),EH())return ee.warn(te.PROVIDER_MANAGER,"Auth failure detected in URL, skipping autoConnect fallback"),!1;const t=this.config.embeddedWalletType||"user-wallet",e=this.getProviderKey("embedded",t);if(this.config.providers.some(s=>s!=="injected")&&this.providers.has(e)){ee.log(te.PROVIDER_MANAGER,"Trying auto-connect with existing embedded provider");const s=this.providers.get(e);try{const o=this.currentProvider,a=this.currentProviderKey;if(this.currentProvider=s,this.currentProviderKey=e,this.ensureProviderEventForwarding(),await s.autoConnect(),s.isConnected())return ee.info(te.PROVIDER_MANAGER,"Embedded auto-connect successful"),this.saveProviderPreference(),!0;ee.log(te.PROVIDER_MANAGER,"Embedded provider did not connect, restoring previous provider"),this.currentProvider=o,this.currentProviderKey=a}catch(o){if(ee.log(te.PROVIDER_MANAGER,"Embedded auto-connect failed",{error:o.message}),bH())return ee.log(te.PROVIDER_MANAGER,"In auth callback URL, not attempting injected fallback"),!1}}const r=this.config.providers.includes("injected"),i=this.getProviderKey("injected");if(r&&this.providers.has(i)){ee.log(te.PROVIDER_MANAGER,"Trying auto-connect with existing injected provider");const s=this.providers.get(i);try{if(this.currentProvider=s,this.currentProviderKey=i,this.ensureProviderEventForwarding(),await s.autoConnect(),s.isConnected())return ee.info(te.PROVIDER_MANAGER,"Injected auto-connect successful"),this.saveProviderPreference(),!0}catch(o){ee.log(te.PROVIDER_MANAGER,"Injected auto-connect failed",{error:o.message})}}return ee.log(te.PROVIDER_MANAGER,"Auto-connect failed for all allowed providers"),!1}on(t,e){ee.log(te.PROVIDER_MANAGER,"Adding event listener",{event:t}),this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e),this.ensureProviderEventForwarding()}off(t,e){ee.log(te.PROVIDER_MANAGER,"Removing event listener",{event:t}),this.eventListeners.has(t)&&(this.eventListeners.get(t).delete(e),this.eventListeners.get(t).size===0&&this.eventListeners.delete(t))}emit(t,e){ee.log(te.PROVIDER_MANAGER,"Emitting event to stored callbacks",{event:t,listenerCount:this.eventListeners.get(t)?.size||0,data:e});const n=this.eventListeners.get(t);n&&n.size>0?n.forEach(r=>{try{ee.log(te.PROVIDER_MANAGER,"Calling stored callback for event",{event:t}),r(e)}catch(i){ee.error(te.PROVIDER_MANAGER,"Event callback error",{event:t,error:i})}}):ee.warn(te.PROVIDER_MANAGER,"No stored callbacks for event",{event:t})}ensureProviderEventForwarding(){if(!this.currentProvider||!("on"in this.currentProvider)){ee.warn(te.PROVIDER_MANAGER,"Current provider does not support events",{providerType:this.getCurrentProviderInfo()?.type});return}if(this.providerForwardingSetup.has(this.currentProvider)){ee.log(te.PROVIDER_MANAGER,"Event forwarding already set up for current provider");return}ee.log(te.PROVIDER_MANAGER,"Setting up event forwarding from current provider");const t=["connect_start","connect","connect_error","disconnect","error","spending_limit_reached"];for(const e of t){const n=r=>{ee.log(te.PROVIDER_MANAGER,"Forwarding event from provider",{event:e,data:r}),this.emit(e,r)};ee.log(te.PROVIDER_MANAGER,"Attaching forwarding callback for event",{event:e}),this.currentProvider.on(e,n)}this.providerForwardingSetup.add(this.currentProvider)}setDefaultProvider(){const t=this.config.embeddedWalletType||"user-wallet",e=this.config.providers.includes("injected"),n=this.config.providers.some(s=>s!=="injected"&&s!=="deeplink");e&&(ee.log(te.PROVIDER_MANAGER,"Creating injected provider (allowed by providers array)"),this.createProvider("injected")),n&&(ee.log(te.PROVIDER_MANAGER,"Creating embedded provider (allowed by providers array)"),this.createProvider("embedded",t));let r;if(n&&this.providers.has(`embedded-${t}`))r="embedded";else if(e&&this.providers.has("injected"))r="injected";else throw new Error("No valid providers could be created from the providers array");const i={};r==="embedded"&&(i.embeddedWalletType=t),this.switchProvider(r,i)}createProvider(t,e){const n=this.getProviderKey(t,e);if(this.providers.has(n))return;let r;if(t==="injected")r=new lH({addressTypes:this.config.addressTypes||[yt.solana]});else if(t==="embedded"){if(!this.config.appId)throw new Error("appId is required for embedded provider");const i=this.config.apiBaseUrl||KD,s=this.config.authOptions?.authUrl||TR;r=new vH({apiBaseUrl:i,appId:this.config.appId,authOptions:{...this.config.authOptions||{},authUrl:s,redirectUrl:this.config.authOptions?.redirectUrl||this.getValidatedCurrentUrl()},embeddedWalletType:e||CR,addressTypes:this.config.addressTypes||[yt.solana]})}else throw new Error(`Unsupported provider type: ${t}`);this.providers.set(n,r)}getProviderKey(t,e){if(t==="injected")return"injected";if(t==="embedded")return`embedded-${e||"app-wallet"}`;throw new Error(`Unsupported provider type: ${t}`)}saveProviderPreference(){try{const t=this.getCurrentProviderInfo();t&&localStorage.setItem("phantom-provider-preference",JSON.stringify(t))}catch(t){console.error("Failed to save provider preference:",t)}}},i0=[...Af,"injected","deeplink"],xH=class{constructor(t){if(this.walletRegistry=TT(),this.isLoading=!0,ee.info(te.BROWSER_SDK,"Initializing BrowserSDK",{providers:t.providers,embeddedWalletType:t.embeddedWalletType,addressTypes:t.addressTypes}),!Array.isArray(t.providers)||t.providers.length===0)throw ee.error(te.BROWSER_SDK,"Invalid providers array",{providers:t.providers}),new Error("providers must be a non-empty array of AuthProviderType");const e=t.providers.filter(i=>!i0.includes(i));if(e.length>0)throw ee.error(te.BROWSER_SDK,"Invalid provider types",{invalidProviders:e,validProviders:i0}),new Error(`Invalid provider type(s): ${e.join(", ")}. Valid providers are: ${i0.join(", ")}`);if(t.providers.some(i=>i!=="injected")&&!t.appId)throw ee.error(te.BROWSER_SDK,"appId required for embedded providers",{providers:t.providers}),new Error("appId is required when using embedded providers (google, apple, phantom, etc.)");const r=t.embeddedWalletType||CR;if(!["app-wallet","user-wallet"].includes(r))throw ee.error(te.BROWSER_SDK,"Invalid embeddedWalletType",{embeddedWalletType:t.embeddedWalletType}),new Error(`Invalid embeddedWalletType: ${t.embeddedWalletType}. Must be "app-wallet" or "user-wallet".`);this.config=t,this.providerManager=new SH(t),this.discoverWallets()}discoverWallets(){return this.walletRegistry.discover(this.config.addressTypes).finally(()=>{this.isLoading=!1})}get solana(){const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");return t.solana}get ethereum(){const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");return t.ethereum}async connect(t){ee.info(te.BROWSER_SDK,"Starting connection",t);try{const e=await this.providerManager.connect(t);return ee.info(te.BROWSER_SDK,"Connection successful",{addressCount:e.addresses.length,status:e.status}),e}catch(e){throw ee.error(te.BROWSER_SDK,"Connection failed",{error:e.message}),e}}async disconnect(){ee.info(te.BROWSER_SDK,"Disconnecting");try{await this.providerManager.disconnect(),ee.info(te.BROWSER_SDK,"Disconnection successful")}catch(t){throw ee.error(te.BROWSER_SDK,"Disconnection failed",{error:t.message}),t}}isConnected(){return this.providerManager.isConnected()}getAddresses(){return this.providerManager.getAddresses()}getCurrentProviderInfo(){return this.providerManager.getCurrentProviderInfo()}getEnabledAddressTypes(){const t=this.providerManager.getCurrentProvider();return t?t.getEnabledAddressTypes():[]}on(t,e){ee.log(te.BROWSER_SDK,"Adding event listener",{event:t}),this.providerManager.on(t,e)}off(t,e){ee.log(te.BROWSER_SDK,"Removing event listener",{event:t}),this.providerManager.off(t,e)}async autoConnect(){ee.log(te.BROWSER_SDK,"Attempting auto-connect with fallback strategy"),await this.providerManager.autoConnect()?ee.info(te.BROWSER_SDK,"Auto-connect successful",{providerType:this.getCurrentProviderInfo()?.type}):ee.log(te.BROWSER_SDK,"Auto-connect failed for all providers")}enableDebug(){ee.enable(),ee.info(te.BROWSER_SDK,"Debug logging enabled")}disableDebug(){ee.disable()}setDebugLevel(t){ee.setLevel(t),ee.info(te.BROWSER_SDK,"Debug level updated",{level:t})}setDebugCallback(t){ee.setCallback(t),ee.info(te.BROWSER_SDK,"Debug callback updated")}configureDebug(t){t.enabled!==void 0&&(t.enabled?this.enableDebug():this.disableDebug()),t.level!==void 0&&this.setDebugLevel(t.level),t.callback!==void 0&&this.setDebugCallback(t.callback)}async enableAutoConfirm(t){ee.info(te.BROWSER_SDK,"Enabling auto-confirm",{params:t});const e=this.providerManager.getCurrentProvider();if(!e)throw new Error("No provider available. Call connect() first.");if(!("enableAutoConfirm"in e))throw new Error("Auto-confirm is only available for injected providers");try{const n=await e.enableAutoConfirm(t);return ee.info(te.BROWSER_SDK,"Auto-confirm enabled successfully",{result:n}),n}catch(n){throw ee.error(te.BROWSER_SDK,"Failed to enable auto-confirm",{error:n.message}),n}}async disableAutoConfirm(){ee.info(te.BROWSER_SDK,"Disabling auto-confirm");const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");if(!("disableAutoConfirm"in t))throw new Error("Auto-confirm is only available for injected providers");try{await t.disableAutoConfirm(),ee.info(te.BROWSER_SDK,"Auto-confirm disabled successfully")}catch(e){throw ee.error(te.BROWSER_SDK,"Failed to disable auto-confirm",{error:e.message}),e}}async getAutoConfirmStatus(){ee.info(te.BROWSER_SDK,"Getting auto-confirm status");const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");if(!("getAutoConfirmStatus"in t))throw new Error("Auto-confirm is only available for injected providers");try{const e=await t.getAutoConfirmStatus();return ee.info(te.BROWSER_SDK,"Got auto-confirm status",{result:e}),e}catch(e){throw ee.error(te.BROWSER_SDK,"Failed to get auto-confirm status",{error:e.message}),e}}async getSupportedAutoConfirmChains(){ee.info(te.BROWSER_SDK,"Getting supported auto-confirm chains");const t=this.providerManager.getCurrentProvider();if(!t)throw new Error("No provider available. Call connect() first.");if(!("getSupportedAutoConfirmChains"in t))throw new Error("Auto-confirm is only available for injected providers");try{const e=await t.getSupportedAutoConfirmChains();return ee.info(te.BROWSER_SDK,"Got supported auto-confirm chains",{result:e}),e}catch(e){throw ee.error(te.BROWSER_SDK,"Failed to get supported auto-confirm chains",{error:e.message}),e}}getDiscoveredWallets(){ee.log(te.BROWSER_SDK,"Getting discovered wallets");try{const t=this.walletRegistry.getByAddressTypes(this.config.addressTypes);return ee.log(te.BROWSER_SDK,"Retrieved discovered wallets",{count:t.length,walletIds:t.map(e=>e.id)}),t}catch(t){return ee.error(te.BROWSER_SDK,"Failed to get discovered wallets",{error:t.message}),[]}}};function AH(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}const o_=new xH({providers:["injected"],addressTypes:[yt.solana]});class CT{async Login(e){if(!e||e.trim().length===0)throw new Error("Message is required.");const{addresses:n}=await o_.connect({provider:"injected"});if(console.log("Connected addresses:",n[0].address),!n?.[0])throw new Error("No account returned from MetaMask.");const i=await o_.solana.signMessage(e);return{signature:AH(i.signature),message:e,accountId:n[0].address,accountType:"SOLANA"}}isPhantomInstalled(){if(typeof window>"u")return!1;const e=window.isPhantomInstalled;return e||!1}}function a_(t){const e=new Date,n=new Date(Date.now()+300*1e3);return[t,`Issued At: ${e.toISOString()}`,`Expires At: ${n.toISOString()}`].join(`
|
|
564
|
+
`)}function RH(t){window.open(t,"_blank","noopener,noreferrer")}const IH=({open:t,onClose:e,onSigned:n})=>{const[r,i]=Xe.useState(null),[,s]=Xe.useState(null),o=Xe.useMemo(()=>new tR,[]),a=o.isMetamaskInstalled(),c=Xe.useMemo(()=>new CT,[]),l=c.isPhantomInstalled(),u=[{name:"metamask",title:"Metamask",logoUrl:"/assets/wallets/metamask.svg",downloadUrl:"https://metamask.io/download",detected:a,onClick:async()=>{s(null),i("metamask");try{const d=a_("PeridotVault Login"),f=await o.Login(d);await n(f),e()}catch(d){const f=d instanceof Error?d.message:"Failed to connect MetaMask.";s(f)}finally{i(null)}}},{name:"phantom",title:"Phantom",logoUrl:"/assets/wallets/phantom.svg",downloadUrl:"https://phantom.com/download",detected:l,onClick:async()=>{s(null),i("phantom");try{const d=a_("PeridotVault Login"),f=await c.Login(d);await n(f),e()}catch(d){const f=d instanceof Error?d.message:"Failed to connect Phantom.";s(f)}finally{i(null)}}}];return vt.jsx(LO,{children:t&&vt.jsx(av.div,{className:"backdrop-blur-sm top-0 left-0 bg-black/50 fixed z-50 w-full h-full flex justify-center items-start",onClick:e,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:vt.jsxs(av.div,{className:"bg-card rounded-b-4xl p-8 max-w-130 w-full flex flex-col gap-8 items-center border-x border-b border-foreground/20",role:"dialog","aria-label":"Required Password",initial:{y:"-100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"-100%",opacity:0},transition:{type:"spring",stiffness:480,damping:42,mass:.8},onClick:d=>d.stopPropagation(),children:[vt.jsxs("div",{className:"flex flex-col items-center text-center",children:[vt.jsx("h2",{className:"text-xl font-medium",children:"Connect a Wallet"}),vt.jsx("p",{children:"Connect your wallet to Login PeridotVault"})]}),vt.jsx(TH,{}),vt.jsxs("div",{className:"w-full flex justify-center text-center relative",children:[vt.jsx("hr",{className:"border-foreground/10 absolute w-full top-1/2"}),vt.jsx("span",{className:"text-sm text-muted-foreground px-4 z-10 bg-card",children:"Other wallets"})]}),vt.jsx("div",{className:"bg-background w-full rounded-xl overflow-hidden",children:u.map((d,f)=>vt.jsx(CH,{isFirst:f==0,item:d,loading:r===d.name},f))}),vt.jsx("div",{className:"w-full flex justify-center text-center",children:vt.jsx("span",{className:"text-sm text-muted-foreground",children:"By connecting a wallet, you agree to PeridotVault Terms of Service and consent to its Privacy Policy"})})]})})})},TH=()=>vt.jsxs(VS,{disabled:!0,className:"relative overflow-hidden bg-linear-to-tr from-highlight/80 from-5% to-accent/80 rounded-xl opacity-50 cursor-not-allowed",children:[vt.jsxs("div",{className:"flex items-center gap-2",children:[vt.jsx("div",{className:"h-12 w-12 overflow-hidden",children:vt.jsx("img",{src:"/assets/wallets/peridotwallet.svg",alt:"",className:"p-2"})}),vt.jsxs("div",{className:"flex flex-col items-start leading-tight",children:[vt.jsx("span",{children:"Get Peridot Wallet"}),vt.jsx("span",{className:"text-sm font-normal",children:"Comming Soon"})]})]}),vt.jsx("div",{className:""})]}),CH=({isFirst:t,item:e,loading:n})=>{const r=()=>{if(!n){if(e.detected){e.onClick();return}RH(e.downloadUrl)}};return vt.jsxs("div",{className:"",children:[!t&&vt.jsx("hr",{className:"border-foreground/10"}),vt.jsxs(VS,{onClick:r,className:"duration-300 flex items-center justify-between hover:bg-foreground/10 cursor-pointer",children:[vt.jsxs("div",{className:"flex items-center gap-4",children:[vt.jsx("div",{className:"h-12 w-12 aspect-square bg-foreground rounded-md overflow-hidden",children:vt.jsx("img",{src:e.logoUrl,alt:"Logo"+e.title})}),vt.jsx("span",{children:e.title})]}),vt.jsx("div",{className:"text-sm font-normal text-muted-foreground",children:e.detected?"Detected":""})]})]})};function OH(){const[t,e]=Xe.useState(),[n,r]=Xe.useState(!1);return t?vt.jsx("div",{children:vt.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-2 active:scale-95 duration-200 cursor-pointer",children:[vt.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent flex items-center justify-center text-highlight text-xl font-black",children:vt.jsx("span",{children:"@"})}),vt.jsx("span",{className:"font-medium",children:kT(t.accountId)})]})}):vt.jsxs("div",{children:[vt.jsx("button",{onClick:()=>r(!n),disabled:n,className:`rounded px-8 py-2 duration-300 font-bold
|
|
565
|
+
${n?"bg-white text-background cursor-not-allowed opacity-60":"bg-accent hover:scale-105 cursor-pointer"} `,children:n?"Connecting...":"Connect"}),vt.jsx(IH,{open:n,onClose:()=>r(!1),onSigned:i=>e(i)})]})}exports.ConnectButton=OH;exports.Metamask=tR;exports.Phantom=CT;
|