@reown/walletkit 1.1.1-canary-ca-2 → 1.1.1-canary-ca-4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/client.d.ts +4 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/controllers/chainAbstraction.d.ts +8 -2
- package/dist/types/controllers/chainAbstraction.d.ts.map +1 -1
- package/dist/types/controllers/engine.d.ts +4 -1
- package/dist/types/controllers/engine.d.ts.map +1 -1
- package/dist/types/types/chainAbstraction.d.ts +58 -6
- package/dist/types/types/chainAbstraction.d.ts.map +1 -1
- package/dist/types/types/client.d.ts +4 -1
- package/dist/types/types/client.d.ts.map +1 -1
- package/dist/types/types/engine.d.ts +4 -1
- package/dist/types/types/engine.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
@@ -11,23 +11,23 @@
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
14
|
-
***************************************************************************** */var za=function(r,e){return za=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},za(r,e)};function kd(r,e){za(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var ka=function(){return ka=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ka.apply(this,arguments)};function Kd(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function jd(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Hd(r,e){return function(t,i){e(t,i,r)}}function Vd(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Gd(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(y){o(y)}}function u(g){try{h(i.throw(g))}catch(y){o(y)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function Wd(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Jd(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function Yd(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function Ka(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function zf(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Qd(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(zf(arguments[e]));return r}function Xd(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function Ln(r){return this instanceof Ln?(this.v=r,this):new Ln(r)}function Zd(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,P){s.push([I,M,D,P])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){y(s[0][3],D)}}function u(I){I.value instanceof Ln?Promise.resolve(I.value.v).then(h,g):y(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function y(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function el(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Ln(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function tl(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Ka=="function"?Ka(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function rl(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function il(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function nl(r){return r&&r.__esModule?r:{default:r}}function sl(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function al(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var ol=Object.freeze({__proto__:null,__extends:kd,get __assign(){return ka},__rest:Kd,__decorate:jd,__param:Hd,__metadata:Vd,__awaiter:Gd,__generator:Wd,__createBinding:Jd,__exportStar:Yd,__values:Ka,__read:zf,__spread:Qd,__spreadArrays:Xd,__await:Ln,__asyncGenerator:Zd,__asyncDelegator:el,__asyncValues:tl,__makeTemplateObject:rl,__importStar:il,__importDefault:nl,__classPrivateFieldGet:sl,__classPrivateFieldSet:al}),Is=Ua(ol),ja={},qn={},kf;function fl(){if(kf)return qn;kf=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return qn.delay=r,qn}var qi={},Ha={},Ui={},Kf;function cl(){return Kf||(Kf=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.ONE_THOUSAND=Ui.ONE_HUNDRED=void 0,Ui.ONE_HUNDRED=100,Ui.ONE_THOUSAND=1e3),Ui}var Va={},jf;function hl(){return jf||(jf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(Va)),Va}var Hf;function Vf(){return Hf||(Hf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(cl(),r),e.__exportStar(hl(),r)}(Ha)),Ha}var Gf;function ul(){if(Gf)return qi;Gf=1,Object.defineProperty(qi,"__esModule",{value:!0}),qi.fromMiliseconds=qi.toMiliseconds=void 0;const r=Vf();function e(i){return i*r.ONE_THOUSAND}qi.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return qi.fromMiliseconds=t,qi}var Wf;function dl(){return Wf||(Wf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(fl(),r),e.__exportStar(ul(),r)}(ja)),ja}var un={},Jf;function ll(){if(Jf)return un;Jf=1,Object.defineProperty(un,"__esModule",{value:!0}),un.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return un.Watch=r,un.default=r,un}var Ga={},Un={},Yf;function pl(){if(Yf)return Un;Yf=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.IWatch=void 0;class r{}return Un.IWatch=r,Un}var Qf;function gl(){return Qf||(Qf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Is.__exportStar(pl(),r)}(Ga)),Ga}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(dl(),r),e.__exportStar(ll(),r),e.__exportStar(gl(),r),e.__exportStar(Vf(),r)})(ie);class $i{}class bl extends $i{constructor(e){super()}}const Xf=ie.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"};class Wa extends bl{constructor(e){super(e),this.events=new Ut.exports.EventEmitter,this.interval=Xf,this.interval=e?.interval||Xf}static async init(e){const t=new Wa(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),ie.toMiliseconds(this.interval))}pulse(){this.events.emit(dn.pulse)}}const vl=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,ml=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,yl=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function wl(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){_l(r);return}return e}function _l(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Ds(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!yl.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(vl.test(r)||ml.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,wl)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function xl(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function xt(r,...e){try{return xl(r(...e))}catch(t){return Promise.reject(t)}}function Al(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function El(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function Os(r){if(Al(r))return String(r);if(El(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Os(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Zf(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ja="base64:";function Sl(r){if(typeof r=="string")return r;Zf();const e=Buffer.from(r).toString("base64");return Ja+e}function Ml(r){return typeof r!="string"||!r.startsWith(Ja)?r:(Zf(),Buffer.from(r.slice(Ja.length),"base64"))}function Qt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Il(...r){return Qt(r.join(":"))}function Rs(r){return r=Qt(r),r?r+":":""}function x4(r){return r}const Dl="memory",Ol=()=>{const r=new Map;return{name:Dl,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Rl(r={}){const e={mounts:{"":r.driver||Ol()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=h=>{for(const g of e.mountpoints)if(h.startsWith(g))return{base:g,relativeKey:h.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,g)=>e.mountpoints.filter(y=>y.startsWith(h)||g&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,g)=>{if(e.watching){g=Qt(g);for(const y of e.watchListeners)y(h,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await ec(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(const h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},f=(h,g,y)=>{const I=new Map,M=D=>{let P=I.get(D.base);return P||(P={driver:D.driver,base:D.base,items:[]},I.set(D.base,P)),P};for(const D of h){const P=typeof D=="string",k=Qt(P?D:D.key),K=P?void 0:D.value,C=P||!D.options?g:{...g,...D.options},j=t(k);M(j).items.push({key:k,value:K,relativeKey:j.relativeKey,options:C})}return Promise.all([...I.values()].map(D=>y(D))).then(D=>D.flat())},u={hasItem(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return xt(I.hasItem,y,g)},getItem(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return xt(I.getItem,y,g).then(M=>Ds(M))},getItems(h,g){return f(h,g,y=>y.driver.getItems?xt(y.driver.getItems,y.items.map(I=>({key:I.relativeKey,options:I.options})),g).then(I=>I.map(M=>({key:Il(y.base,M.key),value:Ds(M.value)}))):Promise.all(y.items.map(I=>xt(y.driver.getItem,I.relativeKey,I.options).then(M=>({key:I.key,value:Ds(M)})))))},getItemRaw(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return I.getItemRaw?xt(I.getItemRaw,y,g):xt(I.getItem,y,g).then(M=>Ml(M))},async setItem(h,g,y={}){if(g===void 0)return u.removeItem(h);h=Qt(h);const{relativeKey:I,driver:M}=t(h);M.setItem&&(await xt(M.setItem,I,Os(g),y),M.watch||n("update",h))},async setItems(h,g){await f(h,g,async y=>{if(y.driver.setItems)return xt(y.driver.setItems,y.items.map(I=>({key:I.relativeKey,value:Os(I.value),options:I.options})),g);y.driver.setItem&&await Promise.all(y.items.map(I=>xt(y.driver.setItem,I.relativeKey,Os(I.value),I.options)))})},async setItemRaw(h,g,y={}){if(g===void 0)return u.removeItem(h,y);h=Qt(h);const{relativeKey:I,driver:M}=t(h);if(M.setItemRaw)await xt(M.setItemRaw,I,g,y);else if(M.setItem)await xt(M.setItem,I,Sl(g),y);else return;M.watch||n("update",h)},async removeItem(h,g={}){typeof g=="boolean"&&(g={removeMeta:g}),h=Qt(h);const{relativeKey:y,driver:I}=t(h);I.removeItem&&(await xt(I.removeItem,y,g),(g.removeMeta||g.removeMata)&&await xt(I.removeItem,y+"$",g),I.watch||n("remove",h))},async getMeta(h,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),h=Qt(h);const{relativeKey:y,driver:I}=t(h),M=Object.create(null);if(I.getMeta&&Object.assign(M,await xt(I.getMeta,y,g)),!g.nativeOnly){const D=await xt(I.getItem,y+"$",g).then(P=>Ds(P));D&&typeof D=="object"&&(typeof D.atime=="string"&&(D.atime=new Date(D.atime)),typeof D.mtime=="string"&&(D.mtime=new Date(D.mtime)),Object.assign(M,D))}return M},setMeta(h,g,y={}){return this.setItem(h+"$",g,y)},removeMeta(h,g={}){return this.removeItem(h+"$",g)},async getKeys(h,g={}){h=Rs(h);const y=i(h,!0);let I=[];const M=[];for(const D of y){const P=await xt(D.driver.getKeys,D.relativeBase,g);for(const k of P){const K=D.mountpoint+Qt(k);I.some(C=>K.startsWith(C))||M.push(K)}I=[D.mountpoint,...I.filter(k=>!k.startsWith(D.mountpoint))]}return h?M.filter(D=>D.startsWith(h)&&D[D.length-1]!=="$"):M.filter(D=>D[D.length-1]!=="$")},async clear(h,g={}){h=Rs(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return xt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){const I=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(I.map(M=>y.driver.removeItem(M,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>tc(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,g){if(h=Rs(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,I)=>I.length-y.length)),e.mounts[h]=g,e.watching&&Promise.resolve(ec(g,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),u},async unmount(h,g=!0){h=Rs(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),g&&await tc(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=Qt(h)+":";const g=t(h);return{driver:g.driver,base:g.base}},getMounts(h="",g={}){return h=Qt(h),i(h,g.parents).map(I=>({driver:I.driver,base:I.mountpoint}))},keys:(h,g={})=>u.getKeys(h,g),get:(h,g={})=>u.getItem(h,g),set:(h,g,y={})=>u.setItem(h,g,y),has:(h,g={})=>u.hasItem(h,g),del:(h,g={})=>u.removeItem(h,g),remove:(h,g={})=>u.removeItem(h,g)};return u}function ec(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function tc(r){typeof r.dispose=="function"&&await xt(r.dispose)}function zi(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function rc(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=zi(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Ya;function $n(){return Ya||(Ya=rc("keyval-store","keyval")),Ya}function ic(r,e=$n()){return e("readonly",t=>zi(t.get(r)))}function Nl(r,e,t=$n()){return t("readwrite",i=>(i.put(e,r),zi(i.transaction)))}function Pl(r,e=$n()){return e("readwrite",t=>(t.delete(r),zi(t.transaction)))}function Cl(r=$n()){return r("readwrite",e=>(e.clear(),zi(e.transaction)))}function Tl(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},zi(r.transaction)}function Fl(r=$n()){return r("readonly",e=>{if(e.getAllKeys)return zi(e.getAllKeys());const t=[];return Tl(e,i=>t.push(i.key)).then(()=>t)})}const Bl=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Ll=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ln(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Ll(r)}catch{return r}}function ki(r){return typeof r=="string"?r:Bl(r)||""}const ql="idb-keyval";var Ul=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=rc(r.dbName,r.storeName)),{name:ql,options:r,async hasItem(n){return!(typeof await ic(t(n),i)>"u")},async getItem(n){return await ic(t(n),i)??null},setItem(n,s){return Nl(t(n),s,i)},removeItem(n){return Pl(t(n),i)},getKeys(){return Fl(i)},clear(){return Cl(i)}}};const $l="WALLET_CONNECT_V2_INDEXED_DB",zl="keyvaluestorage";class kl{constructor(){this.indexedDb=Rl({driver:Ul({dbName:$l,storeName:zl})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ki(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Qa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ns={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Qa<"u"&&Qa.localStorage?Ns.exports=Qa.localStorage:typeof window<"u"&&window.localStorage?Ns.exports=window.localStorage:Ns.exports=new e})();function Kl(r){var e;return[r[0],ln((e=r[1])!=null?e:"")]}class jl{constructor(){this.localStorage=Ns.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Kl)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ln(t)}async setItem(e,t){this.localStorage.setItem(e,ki(t))}async removeItem(e){this.localStorage.removeItem(e)}}const Hl="wc_storage_version",nc=1,Vl=async(r,e,t)=>{const i=Hl,n=await e.getItem(i);if(n&&n>=nc){t(e);return}const s=await r.getKeys();if(!s.length){t(e);return}const o=[];for(;s.length;){const f=s.shift();if(!f)continue;const u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){const h=await r.getItem(f);await e.setItem(f,h),o.push(f)}}await e.setItem(i,nc),t(e),Gl(r,o)},Gl=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};class Wl{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new jl;this.storage=e;try{const t=new kl;Vl(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}function Jl(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var Yl=Ql;function Ql(r,e,t){var i=t&&t.stringify||Jl,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f<s;f++)o[f]=i(e[f]);return o.join(" ")}if(typeof r!="string")return r;var u=e.length;if(u===0)return r;for(var h="",g=1-n,y=-1,I=r&&r.length||0,M=0;M<I;){if(r.charCodeAt(M)===37&&M+1<I){switch(y=y>-1?y:0,r.charCodeAt(M+1)){case 100:case 102:if(g>=u||e[g]==null)break;y<M&&(h+=r.slice(y,M)),h+=Number(e[g]),y=M+2,M++;break;case 105:if(g>=u||e[g]==null)break;y<M&&(h+=r.slice(y,M)),h+=Math.floor(Number(e[g])),y=M+2,M++;break;case 79:case 111:case 106:if(g>=u||e[g]===void 0)break;y<M&&(h+=r.slice(y,M));var D=typeof e[g];if(D==="string"){h+="'"+e[g]+"'",y=M+2,M++;break}if(D==="function"){h+=e[g].name||"<anonymous>",y=M+2,M++;break}h+=i(e[g]),y=M+2,M++;break;case 115:if(g>=u)break;y<M&&(h+=r.slice(y,M)),h+=String(e[g]),y=M+2,M++;break;case 37:y<M&&(h+=r.slice(y,M)),h+="%",y=M+2,M++,g--;break}++g}++M}return y===-1?r:(y<I&&(h+=r.slice(y)),h)}const sc=Yl;var Zr=Br;const zn=op().console||{},Xl={mapHttpRequest:Cs,mapHttpResponse:Cs,wrapRequestSerializer:Za,wrapResponseSerializer:Za,wrapErrorSerializer:Za,req:Cs,res:Cs,err:ip};function Zl(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Br(r){r=r||{},r.browser=r.browser||{};const e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const t=r.browser.write||zn;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},n=Zl(r.browser.serialize,i);let s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const f=r.level||"info",u=Object.create(t);u.log||(u.log=kn),Object.defineProperty(u,"levelVal",{get:g}),Object.defineProperty(u,"level",{get:y,set:I});const h={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:np(r)};u.levels=Br.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=kn,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=M,e&&(u._logEvent=Xa());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function I(D){if(D!=="silent"&&!this.levels.values[D])throw Error("unknown level "+D);this._level=D,pn(h,u,"error","log"),pn(h,u,"fatal","error"),pn(h,u,"warn","error"),pn(h,u,"info","log"),pn(h,u,"debug","log"),pn(h,u,"trace","log")}function M(D,P){if(!D)throw new Error("missing bindings for child Pino");P=P||{},n&&D.serializers&&(P.serializers=D.serializers);const k=P.serializers;if(n&&k){var K=Object.assign({},i,k),C=r.browser.serialize===!0?Object.keys(K):n;delete D.serializers,Ps([D],C,K,this._stdErrSerialize)}function j(F){this._childLevel=(F._childLevel|0)+1,this.error=gn(F,D,"error"),this.fatal=gn(F,D,"fatal"),this.warn=gn(F,D,"warn"),this.info=gn(F,D,"info"),this.debug=gn(F,D,"debug"),this.trace=gn(F,D,"trace"),K&&(this.serializers=K,this._serialize=C),e&&(this._logEvent=Xa([].concat(F._logEvent.bindings,D)))}return j.prototype=this,new j(this)}return u}Br.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Br.stdSerializers=Xl,Br.stdTimeFunctions=Object.assign({},{nullTime:ac,epochTime:oc,unixTime:sp,isoTime:ap});function pn(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?kn:n[t]?n[t]:zn[t]||zn[i]||kn,ep(r,e,t)}function ep(r,e,t){!r.transmit&&e[t]===kn||(e[t]=function(i){return function(){const s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===zn?zn:this;for(var u=0;u<o.length;u++)o[u]=arguments[u];if(r.serialize&&!r.asObject&&Ps(o,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(f,tp(this,t,o,s)):i.apply(f,o),r.transmit){const h=r.transmit.level||e.level,g=Br.levels.values[h],y=Br.levels.values[t];if(y<g)return;rp(this,{ts:s,methodLevel:t,methodValue:y,transmitLevel:h,transmitValue:Br.levels.values[r.transmit.level||e.level],send:r.transmit.send,val:e.levelVal},o)}}}(e[t]))}function tp(r,e,t,i){r._serialize&&Ps(t,r._serialize,r.serializers,r._stdErrSerialize);const n=t.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Br.levels.values[e];let f=(r._childLevel|0)+1;if(f<1&&(f=1),s!==null&&typeof s=="object"){for(;f--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?sc(n.shift(),n):void 0}else typeof s=="string"&&(s=sc(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Ps(r,e,t,i){for(const n in r)if(i&&r[n]instanceof Error)r[n]=Br.stdSerializers.err(r[n]);else if(typeof r[n]=="object"&&!Array.isArray(r[n]))for(const s in r[n])e&&e.indexOf(s)>-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function gn(r,e,t){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return r[t].apply(this,i)}}function rp(r,e,t){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,f=e.val,u=r._logEvent.bindings;Ps(t,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=n,r._logEvent.messages=t.filter(function(h){return u.indexOf(h)===-1}),r._logEvent.level.label=s,r._logEvent.level.value=o,i(s,r._logEvent,f),r._logEvent=Xa(u)}function Xa(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function ip(r){const e={type:r.constructor.name,msg:r.message,stack:r.stack};for(const t in r)e[t]===void 0&&(e[t]=r[t]);return e}function np(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?ac:oc}function Cs(){return{}}function Za(r){return r}function kn(){}function ac(){return!1}function oc(){return Date.now()}function sp(){return Math.round(Date.now()/1e3)}function ap(){return new Date(Date.now()).toISOString()}function op(){function r(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return r(self)||r(window)||r(this)||{}}}const fp={level:"info"},Kn="custom_context",eo=1e3*1024;class cp{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class fc{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new cp(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}}class cc{constructor(e,t=eo){this.level=e??"error",this.levelValue=Zr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new fc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Zr.levels.values.error?console.error(e):t===Zr.levels.values.warn?console.warn(e):t===Zr.levels.values.debug?console.debug(e):t===Zr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ki({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new fc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(ki({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class hp{constructor(e,t=eo){this.baseChunkLogger=new cc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}}class up{constructor(e,t=eo){this.baseChunkLogger=new cc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var dp=Object.defineProperty,lp=Object.defineProperties,pp=Object.getOwnPropertyDescriptors,hc=Object.getOwnPropertySymbols,gp=Object.prototype.hasOwnProperty,bp=Object.prototype.propertyIsEnumerable,uc=(r,e,t)=>e in r?dp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ts=(r,e)=>{for(var t in e||(e={}))gp.call(e,t)&&uc(r,t,e[t]);if(hc)for(var t of hc(e))bp.call(e,t)&&uc(r,t,e[t]);return r},Fs=(r,e)=>lp(r,pp(e));function to(r){return Fs(Ts({},r),{level:r?.level||fp.level})}function vp(r,e=Kn){return r[e]||""}function mp(r,e,t=Kn){return r[t]=e,r}function Xt(r,e=Kn){let t="";return typeof r.bindings>"u"?t=vp(r,e):t=r.bindings().context||"",t}function yp(r,e,t=Kn){const i=Xt(r,t);return i.trim()?`${i}/${e}`:e}function Vt(r,e,t=Kn){const i=yp(r,e,t),n=r.child({context:i});return mp(n,i,t)}function wp(r){var e,t;const i=new hp((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Zr(Fs(Ts({},r.opts),{level:"trace",browser:Fs(Ts({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function _p(r){var e;const t=new up((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Zr(Fs(Ts({},r.opts),{level:"trace"})),chunkLoggerController:t}}function xp(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?wp(r):_p(r)}class Ap extends $i{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Ep extends $i{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Sp{constructor(e,t){this.logger=e,this.core=t}}class Mp extends $i{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Ip extends $i{constructor(e){super()}}class Dp{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}class Op extends $i{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Rp extends $i{constructor(e,t){super(),this.core=e,this.logger=t}}class Np{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class Pp{constructor(e,t){this.projectId=e,this.logger=t}}class Cp{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}class Tp{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Fp{constructor(e){this.client=e}}var ro={},xi={},Bs={},Ls={};Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.BrowserRandomSource=void 0;const dc=65536;class Bp{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let i=0;i<t.length;i+=dc)this._crypto.getRandomValues(t.subarray(i,i+Math.min(t.length-i,dc)));return t}}Ls.BrowserRandomSource=Bp;function Lp(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qs={},or={};Object.defineProperty(or,"__esModule",{value:!0});function qp(r){for(var e=0;e<r.length;e++)r[e]=0;return r}or.wipe=qp;var Up={},$p=Object.freeze({__proto__:null,default:Up}),Us=Ua($p);Object.defineProperty(qs,"__esModule",{value:!0}),qs.NodeRandomSource=void 0;const zp=or;class kp{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Lp<"u"){const e=Us;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=t[n];return(0,zp.wipe)(t),i}}qs.NodeRandomSource=kp,Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.SystemRandomSource=void 0;const Kp=Ls,jp=qs;class Hp{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Kp.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new jp.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}Bs.SystemRandomSource=Hp;var He={},lc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(f,u){var h=f>>>16&65535,g=f&65535,y=u>>>16&65535,I=u&65535;return g*I+(h*I+g*y<<16>>>0)|0}r.mul=Math.imul||e;function t(f,u){return f+u|0}r.add=t;function i(f,u){return f-u|0}r.sub=i;function n(f,u){return f<<u|f>>>32-u}r.rotl=n;function s(f,u){return f<<32-u|f>>>u}r.rotr=s;function o(f){return typeof f=="number"&&isFinite(f)&&Math.floor(f)===f}r.isInteger=Number.isInteger||o,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(f){return r.isInteger(f)&&f>=-r.MAX_SAFE_INTEGER&&f<=r.MAX_SAFE_INTEGER}})(lc),Object.defineProperty(He,"__esModule",{value:!0});var pc=lc;function Vp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}He.readInt16BE=Vp;function Gp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}He.readUint16BE=Gp;function Wp(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}He.readInt16LE=Wp;function Jp(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}He.readUint16LE=Jp;function gc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}He.writeUint16BE=gc,He.writeInt16BE=gc;function bc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}He.writeUint16LE=bc,He.writeInt16LE=bc;function io(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}He.readInt32BE=io;function no(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}He.readUint32BE=no;function so(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}He.readInt32LE=so;function ao(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}He.readUint32LE=ao;function $s(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}He.writeUint32BE=$s,He.writeInt32BE=$s;function zs(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}He.writeUint32LE=zs,He.writeInt32LE=zs;function Yp(r,e){e===void 0&&(e=0);var t=io(r,e),i=io(r,e+4);return t*4294967296+i-(i>>31)*4294967296}He.readInt64BE=Yp;function Qp(r,e){e===void 0&&(e=0);var t=no(r,e),i=no(r,e+4);return t*4294967296+i}He.readUint64BE=Qp;function Xp(r,e){e===void 0&&(e=0);var t=so(r,e),i=so(r,e+4);return i*4294967296+t-(t>>31)*4294967296}He.readInt64LE=Xp;function Zp(r,e){e===void 0&&(e=0);var t=ao(r,e),i=ao(r,e+4);return i*4294967296+t}He.readUint64LE=Zp;function vc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),$s(r/4294967296>>>0,e,t),$s(r>>>0,e,t+4),e}He.writeUint64BE=vc,He.writeInt64BE=vc;function mc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),zs(r>>>0,e,t),zs(r/4294967296>>>0,e,t+4),e}He.writeUint64LE=mc,He.writeInt64LE=mc;function e1(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}He.readUintBE=e1;function t1(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s<t+r/8;s++)i+=e[s]*n,n*=256;return i}He.readUintLE=t1;function r1(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!pc.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=r/8+i-1;s>=i;s--)t[s]=e/n&255,n*=256;return t}He.writeUintBE=r1;function i1(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!pc.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+r/8;s++)t[s]=e/n&255,n*=256;return t}He.writeUintLE=i1;function n1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}He.readFloat32BE=n1;function s1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}He.readFloat32LE=s1;function a1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}He.readFloat64BE=a1;function o1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}He.readFloat64LE=o1;function f1(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r),e}He.writeFloat32BE=f1;function c1(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r,!0),e}He.writeFloat32LE=c1;function h1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r),e}He.writeFloat64BE=h1;function u1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r,!0),e}He.writeFloat64LE=u1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const e=Bs,t=He,i=or;r.defaultRandomSource=new e.SystemRandomSource;function n(h,g=r.defaultRandomSource){return g.randomBytes(h)}r.randomBytes=n;function s(h=r.defaultRandomSource){const g=n(4,h),y=(0,t.readUint32LE)(g);return(0,i.wipe)(g),y}r.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function f(h,g=o,y=r.defaultRandomSource){if(g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");let I="";const M=g.length,D=256-256%M;for(;h>0;){const P=n(Math.ceil(h*256/D),y);for(let k=0;k<P.length&&h>0;k++){const K=P[k];K<D&&(I+=g.charAt(K%M),h--)}(0,i.wipe)(P)}return I}r.randomString=f;function u(h,g=o,y=r.defaultRandomSource){const I=Math.ceil(h/(Math.log(g.length)/Math.LN2));return f(I,g,y)}r.randomStringForEntropy=u}(xi);var yc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=or;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._tempHi),t.wipe(this._tempLo),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,y=h/536870912|0,I=h<<3,M=h%128<112?128:256;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(y,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/8;D++)e.writeUint32BE(this._stateHi[D],u,D*8),e.writeUint32BE(this._stateLo[D],u,D*8+4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.stateHi),t.wipe(u.stateLo),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA512=i;var n=new Int32Array([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 s(f,u,h,g,y,I,M){for(var D=h[0],P=h[1],k=h[2],K=h[3],C=h[4],j=h[5],F=h[6],U=h[7],z=g[0],_=g[1],R=g[2],J=g[3],Q=g[4],N=g[5],p=g[6],l=g[7],a,c,b,A,E,x,d,w;M>=128;){for(var v=0;v<16;v++){var O=8*v+I;f[v]=e.readUint32BE(y,O),u[v]=e.readUint32BE(y,O+4)}for(var v=0;v<80;v++){var W=D,S=P,H=k,T=K,q=C,B=j,m=F,L=U,G=z,Y=_,X=R,ee=J,we=Q,Se=N,he=p,Ne=l;if(a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(C>>>14|Q<<32-14)^(C>>>18|Q<<32-18)^(Q>>>41-32|C<<32-(41-32)),c=(Q>>>14|C<<32-14)^(Q>>>18|C<<32-18)^(C>>>41-32|Q<<32-(41-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=C&j^~C&F,c=Q&N^~Q&p,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=n[v*2],c=n[v*2+1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=f[v%16],c=u[v%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,b=d&65535|w<<16,A=E&65535|x<<16,a=b,c=A,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(D>>>28|z<<32-28)^(z>>>34-32|D<<32-(34-32))^(z>>>39-32|D<<32-(39-32)),c=(z>>>28|D<<32-28)^(D>>>34-32|z<<32-(34-32))^(D>>>39-32|z<<32-(39-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=D&P^D&k^P&k,c=z&_^z&R^_&R,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,L=d&65535|w<<16,Ne=E&65535|x<<16,a=T,c=ee,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=b,c=A,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,T=d&65535|w<<16,ee=E&65535|x<<16,P=W,k=S,K=H,C=T,j=q,F=B,U=m,D=L,_=G,R=Y,J=X,Q=ee,N=we,p=Se,l=he,z=Ne,v%16===15)for(var O=0;O<16;O++)a=f[O],c=u[O],E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=f[(O+9)%16],c=u[(O+9)%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+1)%16],A=u[(O+1)%16],a=(b>>>1|A<<32-1)^(b>>>8|A<<32-8)^b>>>7,c=(A>>>1|b<<32-1)^(A>>>8|b<<32-8)^(A>>>7|b<<32-7),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+14)%16],A=u[(O+14)%16],a=(b>>>19|A<<32-19)^(A>>>61-32|b<<32-(61-32))^b>>>6,c=(A>>>19|b<<32-19)^(b>>>61-32|A<<32-(61-32))^(A>>>6|b<<32-6),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,f[O]=d&65535|w<<16,u[O]=E&65535|x<<16}a=D,c=z,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[0],c=g[0],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[0]=D=d&65535|w<<16,g[0]=z=E&65535|x<<16,a=P,c=_,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[1],c=g[1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[1]=P=d&65535|w<<16,g[1]=_=E&65535|x<<16,a=k,c=R,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[2],c=g[2],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[2]=k=d&65535|w<<16,g[2]=R=E&65535|x<<16,a=K,c=J,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[3],c=g[3],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[3]=K=d&65535|w<<16,g[3]=J=E&65535|x<<16,a=C,c=Q,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[4],c=g[4],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[4]=C=d&65535|w<<16,g[4]=Q=E&65535|x<<16,a=j,c=N,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[5],c=g[5],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[5]=j=d&65535|w<<16,g[5]=N=E&65535|x<<16,a=F,c=p,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[6],c=g[6],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[6]=F=d&65535|w<<16,g[6]=p=E&65535|x<<16,a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[7],c=g[7],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[7]=U=d&65535|w<<16,g[7]=l=E&65535|x<<16,I+=128,M-=128}return I}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(yc),function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=xi,t=yc,i=or;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(T){const q=new Float64Array(16);if(T)for(let B=0;B<T.length;B++)q[B]=T[B];return q}const s=new Uint8Array(32);s[0]=9;const o=n(),f=n([1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),y=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),I=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(T,q){for(let B=0;B<16;B++)T[B]=q[B]|0}function D(T){let q=1;for(let B=0;B<16;B++){let m=T[B]+q+65535;q=Math.floor(m/65536),T[B]=m-q*65536}T[0]+=q-1+37*(q-1)}function P(T,q,B){const m=~(B-1);for(let L=0;L<16;L++){const G=m&(T[L]^q[L]);T[L]^=G,q[L]^=G}}function k(T,q){const B=n(),m=n();for(let L=0;L<16;L++)m[L]=q[L];D(m),D(m),D(m);for(let L=0;L<2;L++){B[0]=m[0]-65517;for(let Y=1;Y<15;Y++)B[Y]=m[Y]-65535-(B[Y-1]>>16&1),B[Y-1]&=65535;B[15]=m[15]-32767-(B[14]>>16&1);const G=B[15]>>16&1;B[14]&=65535,P(m,B,1-G)}for(let L=0;L<16;L++)T[2*L]=m[L]&255,T[2*L+1]=m[L]>>8}function K(T,q){let B=0;for(let m=0;m<32;m++)B|=T[m]^q[m];return(1&B-1>>>8)-1}function C(T,q){const B=new Uint8Array(32),m=new Uint8Array(32);return k(B,T),k(m,q),K(B,m)}function j(T){const q=new Uint8Array(32);return k(q,T),q[0]&1}function F(T,q){for(let B=0;B<16;B++)T[B]=q[2*B]+(q[2*B+1]<<8);T[15]&=32767}function U(T,q,B){for(let m=0;m<16;m++)T[m]=q[m]+B[m]}function z(T,q,B){for(let m=0;m<16;m++)T[m]=q[m]-B[m]}function _(T,q,B){let m,L,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Ne=0,xe=0,ae=0,ve=0,le=0,ne=0,ue=0,fe=0,te=0,pe=0,_e=0,re=0,Ae=0,Ee=0,oe=0,De=0,Me=0,Oe=0,We=0,Qe=0,Ie=0,et=0,tt=0,Pe=0,Te=B[0],Ce=B[1],de=B[2],Fe=B[3],Be=B[4],ce=B[5],Ue=B[6],$e=B[7],me=B[8],ze=B[9],ke=B[10],ge=B[11],Le=B[12],Re=B[13],ye=B[14],Ke=B[15];m=q[0],G+=m*Te,Y+=m*Ce,X+=m*de,ee+=m*Fe,we+=m*Be,Se+=m*ce,he+=m*Ue,Ne+=m*$e,xe+=m*me,ae+=m*ze,ve+=m*ke,le+=m*ge,ne+=m*Le,ue+=m*Re,fe+=m*ye,te+=m*Ke,m=q[1],Y+=m*Te,X+=m*Ce,ee+=m*de,we+=m*Fe,Se+=m*Be,he+=m*ce,Ne+=m*Ue,xe+=m*$e,ae+=m*me,ve+=m*ze,le+=m*ke,ne+=m*ge,ue+=m*Le,fe+=m*Re,te+=m*ye,pe+=m*Ke,m=q[2],X+=m*Te,ee+=m*Ce,we+=m*de,Se+=m*Fe,he+=m*Be,Ne+=m*ce,xe+=m*Ue,ae+=m*$e,ve+=m*me,le+=m*ze,ne+=m*ke,ue+=m*ge,fe+=m*Le,te+=m*Re,pe+=m*ye,_e+=m*Ke,m=q[3],ee+=m*Te,we+=m*Ce,Se+=m*de,he+=m*Fe,Ne+=m*Be,xe+=m*ce,ae+=m*Ue,ve+=m*$e,le+=m*me,ne+=m*ze,ue+=m*ke,fe+=m*ge,te+=m*Le,pe+=m*Re,_e+=m*ye,re+=m*Ke,m=q[4],we+=m*Te,Se+=m*Ce,he+=m*de,Ne+=m*Fe,xe+=m*Be,ae+=m*ce,ve+=m*Ue,le+=m*$e,ne+=m*me,ue+=m*ze,fe+=m*ke,te+=m*ge,pe+=m*Le,_e+=m*Re,re+=m*ye,Ae+=m*Ke,m=q[5],Se+=m*Te,he+=m*Ce,Ne+=m*de,xe+=m*Fe,ae+=m*Be,ve+=m*ce,le+=m*Ue,ne+=m*$e,ue+=m*me,fe+=m*ze,te+=m*ke,pe+=m*ge,_e+=m*Le,re+=m*Re,Ae+=m*ye,Ee+=m*Ke,m=q[6],he+=m*Te,Ne+=m*Ce,xe+=m*de,ae+=m*Fe,ve+=m*Be,le+=m*ce,ne+=m*Ue,ue+=m*$e,fe+=m*me,te+=m*ze,pe+=m*ke,_e+=m*ge,re+=m*Le,Ae+=m*Re,Ee+=m*ye,oe+=m*Ke,m=q[7],Ne+=m*Te,xe+=m*Ce,ae+=m*de,ve+=m*Fe,le+=m*Be,ne+=m*ce,ue+=m*Ue,fe+=m*$e,te+=m*me,pe+=m*ze,_e+=m*ke,re+=m*ge,Ae+=m*Le,Ee+=m*Re,oe+=m*ye,De+=m*Ke,m=q[8],xe+=m*Te,ae+=m*Ce,ve+=m*de,le+=m*Fe,ne+=m*Be,ue+=m*ce,fe+=m*Ue,te+=m*$e,pe+=m*me,_e+=m*ze,re+=m*ke,Ae+=m*ge,Ee+=m*Le,oe+=m*Re,De+=m*ye,Me+=m*Ke,m=q[9],ae+=m*Te,ve+=m*Ce,le+=m*de,ne+=m*Fe,ue+=m*Be,fe+=m*ce,te+=m*Ue,pe+=m*$e,_e+=m*me,re+=m*ze,Ae+=m*ke,Ee+=m*ge,oe+=m*Le,De+=m*Re,Me+=m*ye,Oe+=m*Ke,m=q[10],ve+=m*Te,le+=m*Ce,ne+=m*de,ue+=m*Fe,fe+=m*Be,te+=m*ce,pe+=m*Ue,_e+=m*$e,re+=m*me,Ae+=m*ze,Ee+=m*ke,oe+=m*ge,De+=m*Le,Me+=m*Re,Oe+=m*ye,We+=m*Ke,m=q[11],le+=m*Te,ne+=m*Ce,ue+=m*de,fe+=m*Fe,te+=m*Be,pe+=m*ce,_e+=m*Ue,re+=m*$e,Ae+=m*me,Ee+=m*ze,oe+=m*ke,De+=m*ge,Me+=m*Le,Oe+=m*Re,We+=m*ye,Qe+=m*Ke,m=q[12],ne+=m*Te,ue+=m*Ce,fe+=m*de,te+=m*Fe,pe+=m*Be,_e+=m*ce,re+=m*Ue,Ae+=m*$e,Ee+=m*me,oe+=m*ze,De+=m*ke,Me+=m*ge,Oe+=m*Le,We+=m*Re,Qe+=m*ye,Ie+=m*Ke,m=q[13],ue+=m*Te,fe+=m*Ce,te+=m*de,pe+=m*Fe,_e+=m*Be,re+=m*ce,Ae+=m*Ue,Ee+=m*$e,oe+=m*me,De+=m*ze,Me+=m*ke,Oe+=m*ge,We+=m*Le,Qe+=m*Re,Ie+=m*ye,et+=m*Ke,m=q[14],fe+=m*Te,te+=m*Ce,pe+=m*de,_e+=m*Fe,re+=m*Be,Ae+=m*ce,Ee+=m*Ue,oe+=m*$e,De+=m*me,Me+=m*ze,Oe+=m*ke,We+=m*ge,Qe+=m*Le,Ie+=m*Re,et+=m*ye,tt+=m*Ke,m=q[15],te+=m*Te,pe+=m*Ce,_e+=m*de,re+=m*Fe,Ae+=m*Be,Ee+=m*ce,oe+=m*Ue,De+=m*$e,Me+=m*me,Oe+=m*ze,We+=m*ke,Qe+=m*ge,Ie+=m*Le,et+=m*Re,tt+=m*ye,Pe+=m*Ke,G+=38*pe,Y+=38*_e,X+=38*re,ee+=38*Ae,we+=38*Ee,Se+=38*oe,he+=38*De,Ne+=38*Me,xe+=38*Oe,ae+=38*We,ve+=38*Qe,le+=38*Ie,ne+=38*et,ue+=38*tt,fe+=38*Pe,L=1,m=G+L+65535,L=Math.floor(m/65536),G=m-L*65536,m=Y+L+65535,L=Math.floor(m/65536),Y=m-L*65536,m=X+L+65535,L=Math.floor(m/65536),X=m-L*65536,m=ee+L+65535,L=Math.floor(m/65536),ee=m-L*65536,m=we+L+65535,L=Math.floor(m/65536),we=m-L*65536,m=Se+L+65535,L=Math.floor(m/65536),Se=m-L*65536,m=he+L+65535,L=Math.floor(m/65536),he=m-L*65536,m=Ne+L+65535,L=Math.floor(m/65536),Ne=m-L*65536,m=xe+L+65535,L=Math.floor(m/65536),xe=m-L*65536,m=ae+L+65535,L=Math.floor(m/65536),ae=m-L*65536,m=ve+L+65535,L=Math.floor(m/65536),ve=m-L*65536,m=le+L+65535,L=Math.floor(m/65536),le=m-L*65536,m=ne+L+65535,L=Math.floor(m/65536),ne=m-L*65536,m=ue+L+65535,L=Math.floor(m/65536),ue=m-L*65536,m=fe+L+65535,L=Math.floor(m/65536),fe=m-L*65536,m=te+L+65535,L=Math.floor(m/65536),te=m-L*65536,G+=L-1+37*(L-1),L=1,m=G+L+65535,L=Math.floor(m/65536),G=m-L*65536,m=Y+L+65535,L=Math.floor(m/65536),Y=m-L*65536,m=X+L+65535,L=Math.floor(m/65536),X=m-L*65536,m=ee+L+65535,L=Math.floor(m/65536),ee=m-L*65536,m=we+L+65535,L=Math.floor(m/65536),we=m-L*65536,m=Se+L+65535,L=Math.floor(m/65536),Se=m-L*65536,m=he+L+65535,L=Math.floor(m/65536),he=m-L*65536,m=Ne+L+65535,L=Math.floor(m/65536),Ne=m-L*65536,m=xe+L+65535,L=Math.floor(m/65536),xe=m-L*65536,m=ae+L+65535,L=Math.floor(m/65536),ae=m-L*65536,m=ve+L+65535,L=Math.floor(m/65536),ve=m-L*65536,m=le+L+65535,L=Math.floor(m/65536),le=m-L*65536,m=ne+L+65535,L=Math.floor(m/65536),ne=m-L*65536,m=ue+L+65535,L=Math.floor(m/65536),ue=m-L*65536,m=fe+L+65535,L=Math.floor(m/65536),fe=m-L*65536,m=te+L+65535,L=Math.floor(m/65536),te=m-L*65536,G+=L-1+37*(L-1),T[0]=G,T[1]=Y,T[2]=X,T[3]=ee,T[4]=we,T[5]=Se,T[6]=he,T[7]=Ne,T[8]=xe,T[9]=ae,T[10]=ve,T[11]=le,T[12]=ne,T[13]=ue,T[14]=fe,T[15]=te}function R(T,q){_(T,q,q)}function J(T,q){const B=n();let m;for(m=0;m<16;m++)B[m]=q[m];for(m=253;m>=0;m--)R(B,B),m!==2&&m!==4&&_(B,B,q);for(m=0;m<16;m++)T[m]=B[m]}function Q(T,q){const B=n();let m;for(m=0;m<16;m++)B[m]=q[m];for(m=250;m>=0;m--)R(B,B),m!==1&&_(B,B,q);for(m=0;m<16;m++)T[m]=B[m]}function N(T,q){const B=n(),m=n(),L=n(),G=n(),Y=n(),X=n(),ee=n(),we=n(),Se=n();z(B,T[1],T[0]),z(Se,q[1],q[0]),_(B,B,Se),U(m,T[0],T[1]),U(Se,q[0],q[1]),_(m,m,Se),_(L,T[3],q[3]),_(L,L,h),_(G,T[2],q[2]),U(G,G,G),z(Y,m,B),z(X,G,L),U(ee,G,L),U(we,m,B),_(T[0],Y,X),_(T[1],we,ee),_(T[2],ee,X),_(T[3],Y,we)}function p(T,q,B){for(let m=0;m<4;m++)P(T[m],q[m],B)}function l(T,q){const B=n(),m=n(),L=n();J(L,q[2]),_(B,q[0],L),_(m,q[1],L),k(T,m),T[31]^=j(B)<<7}function a(T,q,B){M(T[0],o),M(T[1],f),M(T[2],f),M(T[3],o);for(let m=255;m>=0;--m){const L=B[m/8|0]>>(m&7)&1;p(T,q,L),N(q,T),N(T,T),p(T,q,L)}}function c(T,q){const B=[n(),n(),n(),n()];M(B[0],g),M(B[1],y),M(B[2],f),_(B[3],g,y),a(T,B,q)}function b(T){if(T.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const q=(0,t.hash)(T);q[0]&=248,q[31]&=127,q[31]|=64;const B=new Uint8Array(32),m=[n(),n(),n(),n()];c(m,q),l(B,m);const L=new Uint8Array(64);return L.set(T),L.set(B,32),{publicKey:B,secretKey:L}}r.generateKeyPairFromSeed=b;function A(T){const q=(0,e.randomBytes)(32,T),B=b(q);return(0,i.wipe)(q),B}r.generateKeyPair=A;function E(T){if(T.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(T.subarray(32))}r.extractPublicKeyFromSecretKey=E;const x=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 d(T,q){let B,m,L,G;for(m=63;m>=32;--m){for(B=0,L=m-32,G=m-12;L<G;++L)q[L]+=B-16*q[m]*x[L-(m-32)],B=Math.floor((q[L]+128)/256),q[L]-=B*256;q[L]+=B,q[m]=0}for(B=0,L=0;L<32;L++)q[L]+=B-(q[31]>>4)*x[L],B=q[L]>>8,q[L]&=255;for(L=0;L<32;L++)q[L]-=B*x[L];for(m=0;m<32;m++)q[m+1]+=q[m]>>8,T[m]=q[m]&255}function w(T){const q=new Float64Array(64);for(let B=0;B<64;B++)q[B]=T[B];for(let B=0;B<64;B++)T[B]=0;d(T,q)}function v(T,q){const B=new Float64Array(64),m=[n(),n(),n(),n()],L=(0,t.hash)(T.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const G=new Uint8Array(64);G.set(L.subarray(32),32);const Y=new t.SHA512;Y.update(G.subarray(32)),Y.update(q);const X=Y.digest();Y.clean(),w(X),c(m,X),l(G,m),Y.reset(),Y.update(G.subarray(0,32)),Y.update(T.subarray(32)),Y.update(q);const ee=Y.digest();w(ee);for(let we=0;we<32;we++)B[we]=X[we];for(let we=0;we<32;we++)for(let Se=0;Se<32;Se++)B[we+Se]+=ee[we]*L[Se];return d(G.subarray(32),B),G}r.sign=v;function O(T,q){const B=n(),m=n(),L=n(),G=n(),Y=n(),X=n(),ee=n();return M(T[2],f),F(T[1],q),R(L,T[1]),_(G,L,u),z(L,L,T[2]),U(G,T[2],G),R(Y,G),R(X,Y),_(ee,X,Y),_(B,ee,L),_(B,B,G),Q(B,B),_(B,B,L),_(B,B,G),_(B,B,G),_(T[0],B,G),R(m,T[0]),_(m,m,G),C(m,L)&&_(T[0],T[0],I),R(m,T[0]),_(m,m,G),C(m,L)?-1:(j(T[0])===q[31]>>7&&z(T[0],o,T[0]),_(T[3],T[0],T[1]),0)}function W(T,q,B){const m=new Uint8Array(32),L=[n(),n(),n(),n()],G=[n(),n(),n(),n()];if(B.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(O(G,T))return!1;const Y=new t.SHA512;Y.update(B.subarray(0,32)),Y.update(T),Y.update(q);const X=Y.digest();return w(X),a(L,G,X),c(G,B.subarray(32)),N(L,G),l(m,L),!K(B,m)}r.verify=W;function S(T){let q=[n(),n(),n(),n()];if(O(q,T))throw new Error("Ed25519: invalid public key");let B=n(),m=n(),L=q[1];U(B,f,L),z(m,f,L),J(m,m),_(B,B,m);let G=new Uint8Array(32);return k(G,B),G}r.convertPublicKeyToX25519=S;function H(T){const q=(0,t.hash)(T.subarray(0,32));q[0]&=248,q[31]&=127,q[31]|=64;const B=new Uint8Array(q.subarray(0,32));return(0,i.wipe)(q),B}r.convertSecretKeyToX25519=H}(ro);const d1="EdDSA",l1="JWT",ks=".",Ks="base64url",wc="utf8",_c="utf8",p1=":",g1="did",b1="key",xc="base58btc",v1="z",m1="K36",y1=32;function Ac(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function js(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));const t=Ac(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function w1(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function y(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var P=0,k=0,K=0,C=D.length;K!==C&&D[K]===0;)K++,P++;for(var j=(C-K)*g+1>>>0,F=new Uint8Array(j);K!==C;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var R=j-k;R!==j&&F[R]===0;)R++;for(var J=u.repeat(P);R<j;++R)J+=r.charAt(F[R]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var P=0;if(D[P]!==" "){for(var k=0,K=0;D[P]===u;)k++,P++;for(var C=(D.length-P)*h+1>>>0,j=new Uint8Array(C);D[P];){var F=t[D.charCodeAt(P)];if(F===255)return;for(var U=0,z=C-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,P++}if(D[P]!==" "){for(var _=C-K;_!==C&&j[_]===0;)_++;for(var R=new Uint8Array(k+(C-_)),J=k;_!==C;)R[J++]=j[_++];return R}}}function M(D){var P=I(D);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:I,decode:M}}var _1=w1,x1=_1;const Ec=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},A1=r=>new TextEncoder().encode(r),E1=r=>new TextDecoder().decode(r);class S1{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class M1{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Sc(this,e)}}class I1{constructor(e){this.decoders=e}or(e){return Sc(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Sc=(r,e)=>new I1({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class D1{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new S1(e,t,i),this.decoder=new M1(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Hs=({name:r,prefix:e,encode:t,decode:i})=>new D1(r,e,t,i),jn=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=x1(t,e);return Hs({prefix:r,name:e,encode:i,decode:s=>Ec(n(s))})},O1=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const y=n[r[g]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|y,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},R1=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Ct=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Hs({prefix:e,name:r,encode(n){return R1(n,i,t)},decode(n){return O1(n,i,t,r)}}),N1=Hs({prefix:"\0",name:"identity",encode:r=>E1(r),decode:r=>A1(r)});var P1=Object.freeze({__proto__:null,identity:N1});const C1=Ct({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var T1=Object.freeze({__proto__:null,base2:C1});const F1=Ct({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var B1=Object.freeze({__proto__:null,base8:F1});const L1=jn({prefix:"9",name:"base10",alphabet:"0123456789"});var q1=Object.freeze({__proto__:null,base10:L1});const U1=Ct({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$1=Ct({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var z1=Object.freeze({__proto__:null,base16:U1,base16upper:$1});const k1=Ct({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),K1=Ct({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),j1=Ct({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),H1=Ct({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),V1=Ct({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G1=Ct({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),W1=Ct({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),J1=Ct({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Y1=Ct({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Q1=Object.freeze({__proto__:null,base32:k1,base32upper:K1,base32pad:j1,base32padupper:H1,base32hex:V1,base32hexupper:G1,base32hexpad:W1,base32hexpadupper:J1,base32z:Y1});const X1=jn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Z1=jn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var eg=Object.freeze({__proto__:null,base36:X1,base36upper:Z1});const tg=jn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rg=jn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ig=Object.freeze({__proto__:null,base58btc:tg,base58flickr:rg});const ng=Ct({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sg=Ct({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ag=Ct({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),og=Ct({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fg=Object.freeze({__proto__:null,base64:ng,base64pad:sg,base64url:ag,base64urlpad:og});const Mc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),cg=Mc.reduce((r,e,t)=>(r[t]=e,r),[]),hg=Mc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ug(r){return r.reduce((e,t)=>(e+=cg[t],e),"")}function dg(r){const e=[];for(const t of r){const i=hg[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const lg=Hs({prefix:"\u{1F680}",name:"base256emoji",encode:ug,decode:dg});var pg=Object.freeze({__proto__:null,base256emoji:lg}),gg=Dc,Ic=128,bg=127,vg=~bg,mg=Math.pow(2,31);function Dc(r,e,t){e=e||[],t=t||0;for(var i=t;r>=mg;)e[t++]=r&255|Ic,r/=128;for(;r&vg;)e[t++]=r&255|Ic,r>>>=7;return e[t]=r|0,Dc.bytes=t-i+1,e}var yg=oo,wg=128,Oc=127;function oo(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw oo.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Oc)<<n:(o&Oc)*Math.pow(2,n),n+=7}while(o>=wg);return oo.bytes=s-i,t}var _g=Math.pow(2,7),xg=Math.pow(2,14),Ag=Math.pow(2,21),Eg=Math.pow(2,28),Sg=Math.pow(2,35),Mg=Math.pow(2,42),Ig=Math.pow(2,49),Dg=Math.pow(2,56),Og=Math.pow(2,63),Rg=function(r){return r<_g?1:r<xg?2:r<Ag?3:r<Eg?4:r<Sg?5:r<Mg?6:r<Ig?7:r<Dg?8:r<Og?9:10},Ng={encode:gg,decode:yg,encodingLength:Rg},Rc=Ng;const Nc=(r,e,t=0)=>(Rc.encode(r,e,t),e),Pc=r=>Rc.encodingLength(r),fo=(r,e)=>{const t=e.byteLength,i=Pc(r),n=i+Pc(t),s=new Uint8Array(n+t);return Nc(r,s,0),Nc(t,s,i),s.set(e,n),new Pg(r,t,e,s)};class Pg{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Cc=({name:r,code:e,encode:t})=>new Cg(r,e,t);class Cg{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?fo(this.code,t):t.then(i=>fo(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Tc=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Tg=Cc({name:"sha2-256",code:18,encode:Tc("SHA-256")}),Fg=Cc({name:"sha2-512",code:19,encode:Tc("SHA-512")});var Bg=Object.freeze({__proto__:null,sha256:Tg,sha512:Fg});const Fc=0,Lg="identity",Bc=Ec;var qg=Object.freeze({__proto__:null,identity:{code:Fc,name:Lg,encode:Bc,digest:r=>fo(Fc,Bc(r))}});new TextEncoder,new TextDecoder;const Lc={...P1,...T1,...B1,...q1,...z1,...Q1,...eg,...ig,...fg,...pg};({...Bg,...qg});function qc(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Uc=qc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),co=qc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=Ac(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),$c={utf8:Uc,"utf-8":Uc,hex:Lc.base16,latin1:co,ascii:co,binary:co,...Lc};function At(r,e="utf8"){const t=$c[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function Et(r,e="utf8"){const t=$c[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function zc(r){return ln(At(Et(r,Ks),wc))}function Vs(r){return At(Et(ki(r),wc),Ks)}function kc(r){const e=Et(m1,xc),t=v1+At(js([e,r]),xc);return[g1,b1,t].join(p1)}function Ug(r){return At(r,Ks)}function $g(r){return Et(r,Ks)}function zg(r){return Et([Vs(r.header),Vs(r.payload)].join(ks),_c)}function kg(r){return[Vs(r.header),Vs(r.payload),Ug(r.signature)].join(ks)}function ho(r){const e=r.split(ks),t=zc(e[0]),i=zc(e[1]),n=$g(e[2]),s=Et(e.slice(0,2).join(ks),_c);return{header:t,payload:i,signature:n,data:s}}function Kc(r=xi.randomBytes(y1)){return ro.generateKeyPairFromSeed(r)}async function Kg(r,e,t,i,n=ie.fromMiliseconds(Date.now())){const s={alg:d1,typ:l1},o=kc(i.publicKey),f=n+t,u={iss:o,sub:r,aud:e,iat:n,exp:f},h=zg({header:s,payload:u}),g=ro.sign(i.secretKey,h);return kg({header:s,payload:u,signature:g})}var jc=function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return r.concat(s||Array.prototype.slice.call(e))},jg=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Hg=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r}(),Vg=function(){function r(e,t,i,n){this.name=e,this.version=t,this.os=i,this.bot=n,this.type="bot-device"}return r}(),Gg=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Wg=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),Jg=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Yg=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Hc=3,Qg=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Jg]],Vc=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Xg(r){return r?Gc(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Wg:typeof navigator<"u"?Gc(navigator.userAgent):tb()}function Zg(r){return r!==""&&Qg.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function Gc(r){var e=Zg(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Gg;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Hc&&(n=jc(jc([],n,!0),rb(Hc-n.length),!0)):n=[];var s=n.join("."),o=eb(r),f=Yg.exec(r);return f&&f[1]?new Vg(t,s,o,f[1]):new jg(t,s,o)}function eb(r){for(var e=0,t=Vc.length;e<t;e++){var i=Vc[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function tb(){var r=typeof process<"u"&&process.version;return r?new Hg(process.version.slice(1)):null}function rb(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.getLocalStorage=at.getLocalStorageOrThrow=at.getCrypto=at.getCryptoOrThrow=Wc=at.getLocation=at.getLocationOrThrow=uo=at.getNavigator=at.getNavigatorOrThrow=Hn=at.getDocument=at.getDocumentOrThrow=at.getFromWindowOrThrow=at.getFromWindow=void 0;function Ki(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}at.getFromWindow=Ki;function bn(r){const e=Ki(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}at.getFromWindowOrThrow=bn;function ib(){return bn("document")}at.getDocumentOrThrow=ib;function nb(){return Ki("document")}var Hn=at.getDocument=nb;function sb(){return bn("navigator")}at.getNavigatorOrThrow=sb;function ab(){return Ki("navigator")}var uo=at.getNavigator=ab;function ob(){return bn("location")}at.getLocationOrThrow=ob;function fb(){return Ki("location")}var Wc=at.getLocation=fb;function cb(){return bn("crypto")}at.getCryptoOrThrow=cb;function hb(){return Ki("crypto")}at.getCrypto=hb;function ub(){return bn("localStorage")}at.getLocalStorageOrThrow=ub;function db(){return Ki("localStorage")}at.getLocalStorage=db;var lo={};Object.defineProperty(lo,"__esModule",{value:!0});var Jc=lo.getWindowMetadata=void 0;const Yc=at;function lb(){let r,e;try{r=Yc.getDocumentOrThrow(),e=Yc.getLocationOrThrow()}catch{return null}function t(){const y=r.getElementsByTagName("link"),I=[];for(let M=0;M<y.length;M++){const D=y[M],P=D.getAttribute("rel");if(P&&P.toLowerCase().indexOf("icon")>-1){const k=D.getAttribute("href");if(k)if(k.toLowerCase().indexOf("https:")===-1&&k.toLowerCase().indexOf("http:")===-1&&k.indexOf("//")!==0){let K=e.protocol+"//"+e.host;if(k.indexOf("/")===0)K+=k;else{const C=e.pathname.split("/");C.pop();const j=C.join("/");K+=j+"/"+k}I.push(K)}else if(k.indexOf("//")===0){const K=e.protocol+k;I.push(K)}else I.push(k)}}return I}function i(...y){const I=r.getElementsByTagName("meta");for(let M=0;M<I.length;M++){const D=I[M],P=["itemprop","property","name"].map(k=>D.getAttribute(k)).filter(k=>k?y.includes(k):!1);if(P.length&&P){const k=D.getAttribute("content");if(k)return k}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),f=s(),u=e.origin,h=t();return{description:f,url:u,icons:h,name:o}}Jc=lo.getWindowMetadata=lb;var Vn={},pb=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Qc="%[a-f0-9]{2}",Xc=new RegExp("("+Qc+")|([^%]+?)","gi"),Zc=new RegExp("("+Qc+")+","gi");function po(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],po(t),po(i))}function gb(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(Xc)||[],t=1;t<e.length;t++)r=po(e,t).join(""),e=r.match(Xc)||[];return r}}function bb(r){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},t=Zc.exec(r);t;){try{e[t[0]]=decodeURIComponent(t[0])}catch{var i=gb(t[0]);i!==t[0]&&(e[t[0]]=i)}t=Zc.exec(r)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];r=r.replace(new RegExp(o,"g"),e[o])}return r}var vb=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return bb(r)}},mb=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},yb=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],f=r[o];(n?e.indexOf(o)!==-1:e(o,f,r))&&(t[o]=f)}return t};(function(r){const e=pb,t=vb,i=mb,n=yb,s=C=>C==null,o=Symbol("encodeFragmentIdentifier");function f(C){switch(C.arrayFormat){case"index":return j=>(F,U)=>{const z=F.length;return U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),"[",z,"]"].join("")]:[...F,[g(j,C),"[",g(z,C),"]=",g(U,C)].join("")]};case"bracket":return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),"[]"].join("")]:[...F,[g(j,C),"[]=",g(U,C)].join("")];case"colon-list-separator":return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),":list="].join("")]:[...F,[g(j,C),":list=",g(U,C)].join("")];case"comma":case"separator":case"bracket-separator":{const j=C.arrayFormat==="bracket-separator"?"[]=":"=";return F=>(U,z)=>z===void 0||C.skipNull&&z===null||C.skipEmptyString&&z===""?U:(z=z===null?"":z,U.length===0?[[g(F,C),j,g(z,C)].join("")]:[[U,g(z,C)].join(C.arrayFormatSeparator)])}default:return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,g(j,C)]:[...F,[g(j,C),"=",g(U,C)].join("")]}}function u(C){let j;switch(C.arrayFormat){case"index":return(F,U,z)=>{if(j=/\[(\d*)\]$/.exec(F),F=F.replace(/\[\d*\]$/,""),!j){z[F]=U;return}z[F]===void 0&&(z[F]={}),z[F][j[1]]=U};case"bracket":return(F,U,z)=>{if(j=/(\[\])$/.exec(F),F=F.replace(/\[\]$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"colon-list-separator":return(F,U,z)=>{if(j=/(:list)$/.exec(F),F=F.replace(/:list$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"comma":case"separator":return(F,U,z)=>{const _=typeof U=="string"&&U.includes(C.arrayFormatSeparator),R=typeof U=="string"&&!_&&y(U,C).includes(C.arrayFormatSeparator);U=R?y(U,C):U;const J=_||R?U.split(C.arrayFormatSeparator).map(Q=>y(Q,C)):U===null?U:y(U,C);z[F]=J};case"bracket-separator":return(F,U,z)=>{const _=/(\[\])$/.test(F);if(F=F.replace(/\[\]$/,""),!_){z[F]=U&&y(U,C);return}const R=U===null?[]:U.split(C.arrayFormatSeparator).map(J=>y(J,C));if(z[F]===void 0){z[F]=R;return}z[F]=[].concat(z[F],R)};default:return(F,U,z)=>{if(z[F]===void 0){z[F]=U;return}z[F]=[].concat(z[F],U)}}}function h(C){if(typeof C!="string"||C.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(C,j){return j.encode?j.strict?e(C):encodeURIComponent(C):C}function y(C,j){return j.decode?t(C):C}function I(C){return Array.isArray(C)?C.sort():typeof C=="object"?I(Object.keys(C)).sort((j,F)=>Number(j)-Number(F)).map(j=>C[j]):C}function M(C){const j=C.indexOf("#");return j!==-1&&(C=C.slice(0,j)),C}function D(C){let j="";const F=C.indexOf("#");return F!==-1&&(j=C.slice(F)),j}function P(C){C=M(C);const j=C.indexOf("?");return j===-1?"":C.slice(j+1)}function k(C,j){return j.parseNumbers&&!Number.isNaN(Number(C))&&typeof C=="string"&&C.trim()!==""?C=Number(C):j.parseBooleans&&C!==null&&(C.toLowerCase()==="true"||C.toLowerCase()==="false")&&(C=C.toLowerCase()==="true"),C}function K(C,j){j=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},j),h(j.arrayFormatSeparator);const F=u(j),U=Object.create(null);if(typeof C!="string"||(C=C.trim().replace(/^[?#&]/,""),!C))return U;for(const z of C.split("&")){if(z==="")continue;let[_,R]=i(j.decode?z.replace(/\+/g," "):z,"=");R=R===void 0?null:["comma","separator","bracket-separator"].includes(j.arrayFormat)?R:y(R,j),F(y(_,j),R,U)}for(const z of Object.keys(U)){const _=U[z];if(typeof _=="object"&&_!==null)for(const R of Object.keys(_))_[R]=k(_[R],j);else U[z]=k(_,j)}return j.sort===!1?U:(j.sort===!0?Object.keys(U).sort():Object.keys(U).sort(j.sort)).reduce((z,_)=>{const R=U[_];return R&&typeof R=="object"&&!Array.isArray(R)?z[_]=I(R):z[_]=R,z},Object.create(null))}r.extract=P,r.parse=K,r.stringify=(C,j)=>{if(!C)return"";j=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},j),h(j.arrayFormatSeparator);const F=R=>j.skipNull&&s(C[R])||j.skipEmptyString&&C[R]==="",U=f(j),z={};for(const R of Object.keys(C))F(R)||(z[R]=C[R]);const _=Object.keys(z);return j.sort!==!1&&_.sort(j.sort),_.map(R=>{const J=C[R];return J===void 0?"":J===null?g(R,j):Array.isArray(J)?J.length===0&&j.arrayFormat==="bracket-separator"?g(R,j)+"[]":J.reduce(U(R),[]).join("&"):g(R,j)+"="+g(J,j)}).filter(R=>R.length>0).join("&")},r.parseUrl=(C,j)=>{j=Object.assign({decode:!0},j);const[F,U]=i(C,"#");return Object.assign({url:F.split("?")[0]||"",query:K(P(C),j)},j&&j.parseFragmentIdentifier&&U?{fragmentIdentifier:y(U,j)}:{})},r.stringifyUrl=(C,j)=>{j=Object.assign({encode:!0,strict:!0,[o]:!0},j);const F=M(C.url).split("?")[0]||"",U=r.extract(C.url),z=r.parse(U,{sort:!1}),_=Object.assign(z,C.query);let R=r.stringify(_,j);R&&(R=`?${R}`);let J=D(C.url);return C.fragmentIdentifier&&(J=`#${j[o]?g(C.fragmentIdentifier,j):C.fragmentIdentifier}`),`${F}${R}${J}`},r.pick=(C,j,F)=>{F=Object.assign({parseFragmentIdentifier:!0,[o]:!1},F);const{url:U,query:z,fragmentIdentifier:_}=r.parseUrl(C,F);return r.stringifyUrl({url:U,query:n(z,j),fragmentIdentifier:_},F)},r.exclude=(C,j,F)=>{const U=Array.isArray(j)?z=>!j.includes(z):(z,_)=>!j(z,_);return r.pick(C,U,F)}})(Vn);var eh={exports:{}};/**
|
14
|
+
***************************************************************************** */var za=function(r,e){return za=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},za(r,e)};function kd(r,e){za(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var ka=function(){return ka=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},ka.apply(this,arguments)};function Kd(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function jd(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Hd(r,e){return function(t,i){e(t,i,r)}}function Vd(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Gd(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(y){o(y)}}function u(g){try{h(i.throw(g))}catch(y){o(y)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function Wd(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Jd(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function Yd(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function Ka(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function zf(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Qd(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(zf(arguments[e]));return r}function Xd(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function Ln(r){return this instanceof Ln?(this.v=r,this):new Ln(r)}function Zd(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,P){s.push([I,M,D,P])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){y(s[0][3],D)}}function u(I){I.value instanceof Ln?Promise.resolve(I.value.v).then(h,g):y(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function y(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function el(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Ln(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function tl(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Ka=="function"?Ka(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function rl(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function il(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function nl(r){return r&&r.__esModule?r:{default:r}}function sl(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function al(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var ol=Object.freeze({__proto__:null,__extends:kd,get __assign(){return ka},__rest:Kd,__decorate:jd,__param:Hd,__metadata:Vd,__awaiter:Gd,__generator:Wd,__createBinding:Jd,__exportStar:Yd,__values:Ka,__read:zf,__spread:Qd,__spreadArrays:Xd,__await:Ln,__asyncGenerator:Zd,__asyncDelegator:el,__asyncValues:tl,__makeTemplateObject:rl,__importStar:il,__importDefault:nl,__classPrivateFieldGet:sl,__classPrivateFieldSet:al}),Is=Ua(ol),ja={},qn={},kf;function fl(){if(kf)return qn;kf=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return qn.delay=r,qn}var qi={},Ha={},Ui={},Kf;function cl(){return Kf||(Kf=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.ONE_THOUSAND=Ui.ONE_HUNDRED=void 0,Ui.ONE_HUNDRED=100,Ui.ONE_THOUSAND=1e3),Ui}var Va={},jf;function hl(){return jf||(jf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(Va)),Va}var Hf;function Vf(){return Hf||(Hf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(cl(),r),e.__exportStar(hl(),r)}(Ha)),Ha}var Gf;function ul(){if(Gf)return qi;Gf=1,Object.defineProperty(qi,"__esModule",{value:!0}),qi.fromMiliseconds=qi.toMiliseconds=void 0;const r=Vf();function e(i){return i*r.ONE_THOUSAND}qi.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return qi.fromMiliseconds=t,qi}var Wf;function dl(){return Wf||(Wf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(fl(),r),e.__exportStar(ul(),r)}(ja)),ja}var un={},Jf;function ll(){if(Jf)return un;Jf=1,Object.defineProperty(un,"__esModule",{value:!0}),un.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return un.Watch=r,un.default=r,un}var Ga={},Un={},Yf;function pl(){if(Yf)return Un;Yf=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.IWatch=void 0;class r{}return Un.IWatch=r,Un}var Qf;function gl(){return Qf||(Qf=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Is.__exportStar(pl(),r)}(Ga)),Ga}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Is;e.__exportStar(dl(),r),e.__exportStar(ll(),r),e.__exportStar(gl(),r),e.__exportStar(Vf(),r)})(ie);class $i{}class bl extends $i{constructor(e){super()}}const Xf=ie.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"};class Wa extends bl{constructor(e){super(e),this.events=new Ut.exports.EventEmitter,this.interval=Xf,this.interval=e?.interval||Xf}static async init(e){const t=new Wa(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),ie.toMiliseconds(this.interval))}pulse(){this.events.emit(dn.pulse)}}const vl=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,ml=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,yl=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function wl(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){_l(r);return}return e}function _l(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Ds(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!yl.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(vl.test(r)||ml.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,wl)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function xl(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function xt(r,...e){try{return xl(r(...e))}catch(t){return Promise.reject(t)}}function Al(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function El(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function Os(r){if(Al(r))return String(r);if(El(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Os(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Zf(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ja="base64:";function Sl(r){if(typeof r=="string")return r;Zf();const e=Buffer.from(r).toString("base64");return Ja+e}function Ml(r){return typeof r!="string"||!r.startsWith(Ja)?r:(Zf(),Buffer.from(r.slice(Ja.length),"base64"))}function Qt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Il(...r){return Qt(r.join(":"))}function Rs(r){return r=Qt(r),r?r+":":""}function x4(r){return r}const Dl="memory",Ol=()=>{const r=new Map;return{name:Dl,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Rl(r={}){const e={mounts:{"":r.driver||Ol()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=h=>{for(const g of e.mountpoints)if(h.startsWith(g))return{base:g,relativeKey:h.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,g)=>e.mountpoints.filter(y=>y.startsWith(h)||g&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,g)=>{if(e.watching){g=Qt(g);for(const y of e.watchListeners)y(h,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await ec(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(const h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},f=(h,g,y)=>{const I=new Map,M=D=>{let P=I.get(D.base);return P||(P={driver:D.driver,base:D.base,items:[]},I.set(D.base,P)),P};for(const D of h){const P=typeof D=="string",k=Qt(P?D:D.key),K=P?void 0:D.value,C=P||!D.options?g:{...g,...D.options},j=t(k);M(j).items.push({key:k,value:K,relativeKey:j.relativeKey,options:C})}return Promise.all([...I.values()].map(D=>y(D))).then(D=>D.flat())},u={hasItem(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return xt(I.hasItem,y,g)},getItem(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return xt(I.getItem,y,g).then(M=>Ds(M))},getItems(h,g){return f(h,g,y=>y.driver.getItems?xt(y.driver.getItems,y.items.map(I=>({key:I.relativeKey,options:I.options})),g).then(I=>I.map(M=>({key:Il(y.base,M.key),value:Ds(M.value)}))):Promise.all(y.items.map(I=>xt(y.driver.getItem,I.relativeKey,I.options).then(M=>({key:I.key,value:Ds(M)})))))},getItemRaw(h,g={}){h=Qt(h);const{relativeKey:y,driver:I}=t(h);return I.getItemRaw?xt(I.getItemRaw,y,g):xt(I.getItem,y,g).then(M=>Ml(M))},async setItem(h,g,y={}){if(g===void 0)return u.removeItem(h);h=Qt(h);const{relativeKey:I,driver:M}=t(h);M.setItem&&(await xt(M.setItem,I,Os(g),y),M.watch||n("update",h))},async setItems(h,g){await f(h,g,async y=>{if(y.driver.setItems)return xt(y.driver.setItems,y.items.map(I=>({key:I.relativeKey,value:Os(I.value),options:I.options})),g);y.driver.setItem&&await Promise.all(y.items.map(I=>xt(y.driver.setItem,I.relativeKey,Os(I.value),I.options)))})},async setItemRaw(h,g,y={}){if(g===void 0)return u.removeItem(h,y);h=Qt(h);const{relativeKey:I,driver:M}=t(h);if(M.setItemRaw)await xt(M.setItemRaw,I,g,y);else if(M.setItem)await xt(M.setItem,I,Sl(g),y);else return;M.watch||n("update",h)},async removeItem(h,g={}){typeof g=="boolean"&&(g={removeMeta:g}),h=Qt(h);const{relativeKey:y,driver:I}=t(h);I.removeItem&&(await xt(I.removeItem,y,g),(g.removeMeta||g.removeMata)&&await xt(I.removeItem,y+"$",g),I.watch||n("remove",h))},async getMeta(h,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),h=Qt(h);const{relativeKey:y,driver:I}=t(h),M=Object.create(null);if(I.getMeta&&Object.assign(M,await xt(I.getMeta,y,g)),!g.nativeOnly){const D=await xt(I.getItem,y+"$",g).then(P=>Ds(P));D&&typeof D=="object"&&(typeof D.atime=="string"&&(D.atime=new Date(D.atime)),typeof D.mtime=="string"&&(D.mtime=new Date(D.mtime)),Object.assign(M,D))}return M},setMeta(h,g,y={}){return this.setItem(h+"$",g,y)},removeMeta(h,g={}){return this.removeItem(h+"$",g)},async getKeys(h,g={}){h=Rs(h);const y=i(h,!0);let I=[];const M=[];for(const D of y){const P=await xt(D.driver.getKeys,D.relativeBase,g);for(const k of P){const K=D.mountpoint+Qt(k);I.some(C=>K.startsWith(C))||M.push(K)}I=[D.mountpoint,...I.filter(k=>!k.startsWith(D.mountpoint))]}return h?M.filter(D=>D.startsWith(h)&&D[D.length-1]!=="$"):M.filter(D=>D[D.length-1]!=="$")},async clear(h,g={}){h=Rs(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return xt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){const I=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(I.map(M=>y.driver.removeItem(M,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>tc(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,g){if(h=Rs(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,I)=>I.length-y.length)),e.mounts[h]=g,e.watching&&Promise.resolve(ec(g,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),u},async unmount(h,g=!0){h=Rs(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),g&&await tc(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=Qt(h)+":";const g=t(h);return{driver:g.driver,base:g.base}},getMounts(h="",g={}){return h=Qt(h),i(h,g.parents).map(I=>({driver:I.driver,base:I.mountpoint}))},keys:(h,g={})=>u.getKeys(h,g),get:(h,g={})=>u.getItem(h,g),set:(h,g,y={})=>u.setItem(h,g,y),has:(h,g={})=>u.hasItem(h,g),del:(h,g={})=>u.removeItem(h,g),remove:(h,g={})=>u.removeItem(h,g)};return u}function ec(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function tc(r){typeof r.dispose=="function"&&await xt(r.dispose)}function zi(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function rc(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=zi(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Ya;function $n(){return Ya||(Ya=rc("keyval-store","keyval")),Ya}function ic(r,e=$n()){return e("readonly",t=>zi(t.get(r)))}function Nl(r,e,t=$n()){return t("readwrite",i=>(i.put(e,r),zi(i.transaction)))}function Pl(r,e=$n()){return e("readwrite",t=>(t.delete(r),zi(t.transaction)))}function Cl(r=$n()){return r("readwrite",e=>(e.clear(),zi(e.transaction)))}function Tl(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},zi(r.transaction)}function Fl(r=$n()){return r("readonly",e=>{if(e.getAllKeys)return zi(e.getAllKeys());const t=[];return Tl(e,i=>t.push(i.key)).then(()=>t)})}const Bl=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Ll=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ln(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Ll(r)}catch{return r}}function ki(r){return typeof r=="string"?r:Bl(r)||""}const ql="idb-keyval";var Ul=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=rc(r.dbName,r.storeName)),{name:ql,options:r,async hasItem(n){return!(typeof await ic(t(n),i)>"u")},async getItem(n){return await ic(t(n),i)??null},setItem(n,s){return Nl(t(n),s,i)},removeItem(n){return Pl(t(n),i)},getKeys(){return Fl(i)},clear(){return Cl(i)}}};const $l="WALLET_CONNECT_V2_INDEXED_DB",zl="keyvaluestorage";class kl{constructor(){this.indexedDb=Rl({driver:Ul({dbName:$l,storeName:zl})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ki(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Qa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ns={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Qa<"u"&&Qa.localStorage?Ns.exports=Qa.localStorage:typeof window<"u"&&window.localStorage?Ns.exports=window.localStorage:Ns.exports=new e})();function Kl(r){var e;return[r[0],ln((e=r[1])!=null?e:"")]}class jl{constructor(){this.localStorage=Ns.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Kl)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ln(t)}async setItem(e,t){this.localStorage.setItem(e,ki(t))}async removeItem(e){this.localStorage.removeItem(e)}}const Hl="wc_storage_version",nc=1,Vl=async(r,e,t)=>{const i=Hl,n=await e.getItem(i);if(n&&n>=nc){t(e);return}const s=await r.getKeys();if(!s.length){t(e);return}const o=[];for(;s.length;){const f=s.shift();if(!f)continue;const u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){const h=await r.getItem(f);await e.setItem(f,h),o.push(f)}}await e.setItem(i,nc),t(e),Gl(r,o)},Gl=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};class Wl{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new jl;this.storage=e;try{const t=new kl;Vl(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}function Jl(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var Yl=Ql;function Ql(r,e,t){var i=t&&t.stringify||Jl,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f<s;f++)o[f]=i(e[f]);return o.join(" ")}if(typeof r!="string")return r;var u=e.length;if(u===0)return r;for(var h="",g=1-n,y=-1,I=r&&r.length||0,M=0;M<I;){if(r.charCodeAt(M)===37&&M+1<I){switch(y=y>-1?y:0,r.charCodeAt(M+1)){case 100:case 102:if(g>=u||e[g]==null)break;y<M&&(h+=r.slice(y,M)),h+=Number(e[g]),y=M+2,M++;break;case 105:if(g>=u||e[g]==null)break;y<M&&(h+=r.slice(y,M)),h+=Math.floor(Number(e[g])),y=M+2,M++;break;case 79:case 111:case 106:if(g>=u||e[g]===void 0)break;y<M&&(h+=r.slice(y,M));var D=typeof e[g];if(D==="string"){h+="'"+e[g]+"'",y=M+2,M++;break}if(D==="function"){h+=e[g].name||"<anonymous>",y=M+2,M++;break}h+=i(e[g]),y=M+2,M++;break;case 115:if(g>=u)break;y<M&&(h+=r.slice(y,M)),h+=String(e[g]),y=M+2,M++;break;case 37:y<M&&(h+=r.slice(y,M)),h+="%",y=M+2,M++,g--;break}++g}++M}return y===-1?r:(y<I&&(h+=r.slice(y)),h)}const sc=Yl;var ei=Lr;const zn=op().console||{},Xl={mapHttpRequest:Cs,mapHttpResponse:Cs,wrapRequestSerializer:Za,wrapResponseSerializer:Za,wrapErrorSerializer:Za,req:Cs,res:Cs,err:ip};function Zl(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Lr(r){r=r||{},r.browser=r.browser||{};const e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const t=r.browser.write||zn;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},n=Zl(r.browser.serialize,i);let s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const f=r.level||"info",u=Object.create(t);u.log||(u.log=kn),Object.defineProperty(u,"levelVal",{get:g}),Object.defineProperty(u,"level",{get:y,set:I});const h={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:np(r)};u.levels=Lr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=kn,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=M,e&&(u._logEvent=Xa());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function I(D){if(D!=="silent"&&!this.levels.values[D])throw Error("unknown level "+D);this._level=D,pn(h,u,"error","log"),pn(h,u,"fatal","error"),pn(h,u,"warn","error"),pn(h,u,"info","log"),pn(h,u,"debug","log"),pn(h,u,"trace","log")}function M(D,P){if(!D)throw new Error("missing bindings for child Pino");P=P||{},n&&D.serializers&&(P.serializers=D.serializers);const k=P.serializers;if(n&&k){var K=Object.assign({},i,k),C=r.browser.serialize===!0?Object.keys(K):n;delete D.serializers,Ps([D],C,K,this._stdErrSerialize)}function j(F){this._childLevel=(F._childLevel|0)+1,this.error=gn(F,D,"error"),this.fatal=gn(F,D,"fatal"),this.warn=gn(F,D,"warn"),this.info=gn(F,D,"info"),this.debug=gn(F,D,"debug"),this.trace=gn(F,D,"trace"),K&&(this.serializers=K,this._serialize=C),e&&(this._logEvent=Xa([].concat(F._logEvent.bindings,D)))}return j.prototype=this,new j(this)}return u}Lr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Lr.stdSerializers=Xl,Lr.stdTimeFunctions=Object.assign({},{nullTime:ac,epochTime:oc,unixTime:sp,isoTime:ap});function pn(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?kn:n[t]?n[t]:zn[t]||zn[i]||kn,ep(r,e,t)}function ep(r,e,t){!r.transmit&&e[t]===kn||(e[t]=function(i){return function(){const s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===zn?zn:this;for(var u=0;u<o.length;u++)o[u]=arguments[u];if(r.serialize&&!r.asObject&&Ps(o,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(f,tp(this,t,o,s)):i.apply(f,o),r.transmit){const h=r.transmit.level||e.level,g=Lr.levels.values[h],y=Lr.levels.values[t];if(y<g)return;rp(this,{ts:s,methodLevel:t,methodValue:y,transmitLevel:h,transmitValue:Lr.levels.values[r.transmit.level||e.level],send:r.transmit.send,val:e.levelVal},o)}}}(e[t]))}function tp(r,e,t,i){r._serialize&&Ps(t,r._serialize,r.serializers,r._stdErrSerialize);const n=t.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Lr.levels.values[e];let f=(r._childLevel|0)+1;if(f<1&&(f=1),s!==null&&typeof s=="object"){for(;f--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?sc(n.shift(),n):void 0}else typeof s=="string"&&(s=sc(n.shift(),n));return s!==void 0&&(o.msg=s),o}function Ps(r,e,t,i){for(const n in r)if(i&&r[n]instanceof Error)r[n]=Lr.stdSerializers.err(r[n]);else if(typeof r[n]=="object"&&!Array.isArray(r[n]))for(const s in r[n])e&&e.indexOf(s)>-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function gn(r,e,t){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return r[t].apply(this,i)}}function rp(r,e,t){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,f=e.val,u=r._logEvent.bindings;Ps(t,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=n,r._logEvent.messages=t.filter(function(h){return u.indexOf(h)===-1}),r._logEvent.level.label=s,r._logEvent.level.value=o,i(s,r._logEvent,f),r._logEvent=Xa(u)}function Xa(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function ip(r){const e={type:r.constructor.name,msg:r.message,stack:r.stack};for(const t in r)e[t]===void 0&&(e[t]=r[t]);return e}function np(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?ac:oc}function Cs(){return{}}function Za(r){return r}function kn(){}function ac(){return!1}function oc(){return Date.now()}function sp(){return Math.round(Date.now()/1e3)}function ap(){return new Date(Date.now()).toISOString()}function op(){function r(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return r(self)||r(window)||r(this)||{}}}const fp={level:"info"},Kn="custom_context",eo=1e3*1024;class cp{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class fc{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new cp(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}}class cc{constructor(e,t=eo){this.level=e??"error",this.levelValue=ei.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new fc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ei.levels.values.error?console.error(e):t===ei.levels.values.warn?console.warn(e):t===ei.levels.values.debug?console.debug(e):t===ei.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ki({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new fc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(ki({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class hp{constructor(e,t=eo){this.baseChunkLogger=new cc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}}class up{constructor(e,t=eo){this.baseChunkLogger=new cc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var dp=Object.defineProperty,lp=Object.defineProperties,pp=Object.getOwnPropertyDescriptors,hc=Object.getOwnPropertySymbols,gp=Object.prototype.hasOwnProperty,bp=Object.prototype.propertyIsEnumerable,uc=(r,e,t)=>e in r?dp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ts=(r,e)=>{for(var t in e||(e={}))gp.call(e,t)&&uc(r,t,e[t]);if(hc)for(var t of hc(e))bp.call(e,t)&&uc(r,t,e[t]);return r},Fs=(r,e)=>lp(r,pp(e));function to(r){return Fs(Ts({},r),{level:r?.level||fp.level})}function vp(r,e=Kn){return r[e]||""}function mp(r,e,t=Kn){return r[t]=e,r}function Xt(r,e=Kn){let t="";return typeof r.bindings>"u"?t=vp(r,e):t=r.bindings().context||"",t}function yp(r,e,t=Kn){const i=Xt(r,t);return i.trim()?`${i}/${e}`:e}function Vt(r,e,t=Kn){const i=yp(r,e,t),n=r.child({context:i});return mp(n,i,t)}function wp(r){var e,t;const i=new hp((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:ei(Fs(Ts({},r.opts),{level:"trace",browser:Fs(Ts({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function _p(r){var e;const t=new up((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:ei(Fs(Ts({},r.opts),{level:"trace"})),chunkLoggerController:t}}function xp(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?wp(r):_p(r)}class Ap extends $i{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Ep extends $i{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Sp{constructor(e,t){this.logger=e,this.core=t}}class Mp extends $i{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Ip extends $i{constructor(e){super()}}class Dp{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}class Op extends $i{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Rp extends $i{constructor(e,t){super(),this.core=e,this.logger=t}}class Np{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class Pp{constructor(e,t){this.projectId=e,this.logger=t}}class Cp{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}class Tp{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Fp{constructor(e){this.client=e}}var ro={},Ai={},Bs={},Ls={};Object.defineProperty(Ls,"__esModule",{value:!0}),Ls.BrowserRandomSource=void 0;const dc=65536;class Bp{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let i=0;i<t.length;i+=dc)this._crypto.getRandomValues(t.subarray(i,i+Math.min(t.length-i,dc)));return t}}Ls.BrowserRandomSource=Bp;function Lp(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var qs={},or={};Object.defineProperty(or,"__esModule",{value:!0});function qp(r){for(var e=0;e<r.length;e++)r[e]=0;return r}or.wipe=qp;var Up={},$p=Object.freeze({__proto__:null,default:Up}),Us=Ua($p);Object.defineProperty(qs,"__esModule",{value:!0}),qs.NodeRandomSource=void 0;const zp=or;class kp{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Lp<"u"){const e=Us;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=t[n];return(0,zp.wipe)(t),i}}qs.NodeRandomSource=kp,Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.SystemRandomSource=void 0;const Kp=Ls,jp=qs;class Hp{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Kp.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new jp.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}Bs.SystemRandomSource=Hp;var He={},lc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(f,u){var h=f>>>16&65535,g=f&65535,y=u>>>16&65535,I=u&65535;return g*I+(h*I+g*y<<16>>>0)|0}r.mul=Math.imul||e;function t(f,u){return f+u|0}r.add=t;function i(f,u){return f-u|0}r.sub=i;function n(f,u){return f<<u|f>>>32-u}r.rotl=n;function s(f,u){return f<<32-u|f>>>u}r.rotr=s;function o(f){return typeof f=="number"&&isFinite(f)&&Math.floor(f)===f}r.isInteger=Number.isInteger||o,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(f){return r.isInteger(f)&&f>=-r.MAX_SAFE_INTEGER&&f<=r.MAX_SAFE_INTEGER}})(lc),Object.defineProperty(He,"__esModule",{value:!0});var pc=lc;function Vp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}He.readInt16BE=Vp;function Gp(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}He.readUint16BE=Gp;function Wp(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}He.readInt16LE=Wp;function Jp(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}He.readUint16LE=Jp;function gc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}He.writeUint16BE=gc,He.writeInt16BE=gc;function bc(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}He.writeUint16LE=bc,He.writeInt16LE=bc;function io(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}He.readInt32BE=io;function no(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}He.readUint32BE=no;function so(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}He.readInt32LE=so;function ao(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}He.readUint32LE=ao;function $s(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}He.writeUint32BE=$s,He.writeInt32BE=$s;function zs(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}He.writeUint32LE=zs,He.writeInt32LE=zs;function Yp(r,e){e===void 0&&(e=0);var t=io(r,e),i=io(r,e+4);return t*4294967296+i-(i>>31)*4294967296}He.readInt64BE=Yp;function Qp(r,e){e===void 0&&(e=0);var t=no(r,e),i=no(r,e+4);return t*4294967296+i}He.readUint64BE=Qp;function Xp(r,e){e===void 0&&(e=0);var t=so(r,e),i=so(r,e+4);return i*4294967296+t-(t>>31)*4294967296}He.readInt64LE=Xp;function Zp(r,e){e===void 0&&(e=0);var t=ao(r,e),i=ao(r,e+4);return i*4294967296+t}He.readUint64LE=Zp;function vc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),$s(r/4294967296>>>0,e,t),$s(r>>>0,e,t+4),e}He.writeUint64BE=vc,He.writeInt64BE=vc;function mc(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),zs(r>>>0,e,t),zs(r/4294967296>>>0,e,t+4),e}He.writeUint64LE=mc,He.writeInt64LE=mc;function e1(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}He.readUintBE=e1;function t1(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s<t+r/8;s++)i+=e[s]*n,n*=256;return i}He.readUintLE=t1;function r1(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!pc.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=r/8+i-1;s>=i;s--)t[s]=e/n&255,n*=256;return t}He.writeUintBE=r1;function i1(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!pc.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+r/8;s++)t[s]=e/n&255,n*=256;return t}He.writeUintLE=i1;function n1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}He.readFloat32BE=n1;function s1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}He.readFloat32LE=s1;function a1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}He.readFloat64BE=a1;function o1(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}He.readFloat64LE=o1;function f1(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r),e}He.writeFloat32BE=f1;function c1(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r,!0),e}He.writeFloat32LE=c1;function h1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r),e}He.writeFloat64BE=h1;function u1(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r,!0),e}He.writeFloat64LE=u1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const e=Bs,t=He,i=or;r.defaultRandomSource=new e.SystemRandomSource;function n(h,g=r.defaultRandomSource){return g.randomBytes(h)}r.randomBytes=n;function s(h=r.defaultRandomSource){const g=n(4,h),y=(0,t.readUint32LE)(g);return(0,i.wipe)(g),y}r.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function f(h,g=o,y=r.defaultRandomSource){if(g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");let I="";const M=g.length,D=256-256%M;for(;h>0;){const P=n(Math.ceil(h*256/D),y);for(let k=0;k<P.length&&h>0;k++){const K=P[k];K<D&&(I+=g.charAt(K%M),h--)}(0,i.wipe)(P)}return I}r.randomString=f;function u(h,g=o,y=r.defaultRandomSource){const I=Math.ceil(h/(Math.log(g.length)/Math.LN2));return f(I,g,y)}r.randomStringForEntropy=u}(Ai);var yc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=or;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._tempHi),t.wipe(this._tempLo),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,y=h/536870912|0,I=h<<3,M=h%128<112?128:256;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(y,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/8;D++)e.writeUint32BE(this._stateHi[D],u,D*8),e.writeUint32BE(this._stateLo[D],u,D*8+4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.stateHi),t.wipe(u.stateLo),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA512=i;var n=new Int32Array([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 s(f,u,h,g,y,I,M){for(var D=h[0],P=h[1],k=h[2],K=h[3],C=h[4],j=h[5],F=h[6],U=h[7],z=g[0],_=g[1],R=g[2],J=g[3],Q=g[4],N=g[5],p=g[6],l=g[7],a,c,b,A,E,x,d,w;M>=128;){for(var v=0;v<16;v++){var O=8*v+I;f[v]=e.readUint32BE(y,O),u[v]=e.readUint32BE(y,O+4)}for(var v=0;v<80;v++){var W=D,S=P,H=k,T=K,q=C,B=j,m=F,L=U,G=z,Y=_,X=R,ee=J,we=Q,Se=N,he=p,Ne=l;if(a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(C>>>14|Q<<32-14)^(C>>>18|Q<<32-18)^(Q>>>41-32|C<<32-(41-32)),c=(Q>>>14|C<<32-14)^(Q>>>18|C<<32-18)^(C>>>41-32|Q<<32-(41-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=C&j^~C&F,c=Q&N^~Q&p,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=n[v*2],c=n[v*2+1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=f[v%16],c=u[v%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,b=d&65535|w<<16,A=E&65535|x<<16,a=b,c=A,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=(D>>>28|z<<32-28)^(z>>>34-32|D<<32-(34-32))^(z>>>39-32|D<<32-(39-32)),c=(z>>>28|D<<32-28)^(D>>>34-32|z<<32-(34-32))^(D>>>39-32|z<<32-(39-32)),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,a=D&P^D&k^P&k,c=z&_^z&R^_&R,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,L=d&65535|w<<16,Ne=E&65535|x<<16,a=T,c=ee,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=b,c=A,E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,T=d&65535|w<<16,ee=E&65535|x<<16,P=W,k=S,K=H,C=T,j=q,F=B,U=m,D=L,_=G,R=Y,J=X,Q=ee,N=we,p=Se,l=he,z=Ne,v%16===15)for(var O=0;O<16;O++)a=f[O],c=u[O],E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=f[(O+9)%16],c=u[(O+9)%16],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+1)%16],A=u[(O+1)%16],a=(b>>>1|A<<32-1)^(b>>>8|A<<32-8)^b>>>7,c=(A>>>1|b<<32-1)^(A>>>8|b<<32-8)^(A>>>7|b<<32-7),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,b=f[(O+14)%16],A=u[(O+14)%16],a=(b>>>19|A<<32-19)^(A>>>61-32|b<<32-(61-32))^b>>>6,c=(A>>>19|b<<32-19)^(b>>>61-32|A<<32-(61-32))^(A>>>6|b<<32-6),E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,f[O]=d&65535|w<<16,u[O]=E&65535|x<<16}a=D,c=z,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[0],c=g[0],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[0]=D=d&65535|w<<16,g[0]=z=E&65535|x<<16,a=P,c=_,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[1],c=g[1],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[1]=P=d&65535|w<<16,g[1]=_=E&65535|x<<16,a=k,c=R,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[2],c=g[2],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[2]=k=d&65535|w<<16,g[2]=R=E&65535|x<<16,a=K,c=J,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[3],c=g[3],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[3]=K=d&65535|w<<16,g[3]=J=E&65535|x<<16,a=C,c=Q,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[4],c=g[4],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[4]=C=d&65535|w<<16,g[4]=Q=E&65535|x<<16,a=j,c=N,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[5],c=g[5],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[5]=j=d&65535|w<<16,g[5]=N=E&65535|x<<16,a=F,c=p,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[6],c=g[6],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[6]=F=d&65535|w<<16,g[6]=p=E&65535|x<<16,a=U,c=l,E=c&65535,x=c>>>16,d=a&65535,w=a>>>16,a=h[7],c=g[7],E+=c&65535,x+=c>>>16,d+=a&65535,w+=a>>>16,x+=E>>>16,d+=x>>>16,w+=d>>>16,h[7]=U=d&65535|w<<16,g[7]=l=E&65535|x<<16,I+=128,M-=128}return I}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(yc),function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=Ai,t=yc,i=or;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(T){const q=new Float64Array(16);if(T)for(let B=0;B<T.length;B++)q[B]=T[B];return q}const s=new Uint8Array(32);s[0]=9;const o=n(),f=n([1]),u=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),y=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),I=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function M(T,q){for(let B=0;B<16;B++)T[B]=q[B]|0}function D(T){let q=1;for(let B=0;B<16;B++){let m=T[B]+q+65535;q=Math.floor(m/65536),T[B]=m-q*65536}T[0]+=q-1+37*(q-1)}function P(T,q,B){const m=~(B-1);for(let L=0;L<16;L++){const G=m&(T[L]^q[L]);T[L]^=G,q[L]^=G}}function k(T,q){const B=n(),m=n();for(let L=0;L<16;L++)m[L]=q[L];D(m),D(m),D(m);for(let L=0;L<2;L++){B[0]=m[0]-65517;for(let Y=1;Y<15;Y++)B[Y]=m[Y]-65535-(B[Y-1]>>16&1),B[Y-1]&=65535;B[15]=m[15]-32767-(B[14]>>16&1);const G=B[15]>>16&1;B[14]&=65535,P(m,B,1-G)}for(let L=0;L<16;L++)T[2*L]=m[L]&255,T[2*L+1]=m[L]>>8}function K(T,q){let B=0;for(let m=0;m<32;m++)B|=T[m]^q[m];return(1&B-1>>>8)-1}function C(T,q){const B=new Uint8Array(32),m=new Uint8Array(32);return k(B,T),k(m,q),K(B,m)}function j(T){const q=new Uint8Array(32);return k(q,T),q[0]&1}function F(T,q){for(let B=0;B<16;B++)T[B]=q[2*B]+(q[2*B+1]<<8);T[15]&=32767}function U(T,q,B){for(let m=0;m<16;m++)T[m]=q[m]+B[m]}function z(T,q,B){for(let m=0;m<16;m++)T[m]=q[m]-B[m]}function _(T,q,B){let m,L,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Ne=0,xe=0,ae=0,ve=0,le=0,ne=0,ue=0,fe=0,te=0,pe=0,_e=0,re=0,Ae=0,Ee=0,oe=0,De=0,Me=0,Oe=0,We=0,Qe=0,Ie=0,et=0,tt=0,Pe=0,Te=B[0],Ce=B[1],de=B[2],Fe=B[3],Be=B[4],ce=B[5],Ue=B[6],$e=B[7],me=B[8],ze=B[9],ke=B[10],ge=B[11],Le=B[12],Re=B[13],ye=B[14],Ke=B[15];m=q[0],G+=m*Te,Y+=m*Ce,X+=m*de,ee+=m*Fe,we+=m*Be,Se+=m*ce,he+=m*Ue,Ne+=m*$e,xe+=m*me,ae+=m*ze,ve+=m*ke,le+=m*ge,ne+=m*Le,ue+=m*Re,fe+=m*ye,te+=m*Ke,m=q[1],Y+=m*Te,X+=m*Ce,ee+=m*de,we+=m*Fe,Se+=m*Be,he+=m*ce,Ne+=m*Ue,xe+=m*$e,ae+=m*me,ve+=m*ze,le+=m*ke,ne+=m*ge,ue+=m*Le,fe+=m*Re,te+=m*ye,pe+=m*Ke,m=q[2],X+=m*Te,ee+=m*Ce,we+=m*de,Se+=m*Fe,he+=m*Be,Ne+=m*ce,xe+=m*Ue,ae+=m*$e,ve+=m*me,le+=m*ze,ne+=m*ke,ue+=m*ge,fe+=m*Le,te+=m*Re,pe+=m*ye,_e+=m*Ke,m=q[3],ee+=m*Te,we+=m*Ce,Se+=m*de,he+=m*Fe,Ne+=m*Be,xe+=m*ce,ae+=m*Ue,ve+=m*$e,le+=m*me,ne+=m*ze,ue+=m*ke,fe+=m*ge,te+=m*Le,pe+=m*Re,_e+=m*ye,re+=m*Ke,m=q[4],we+=m*Te,Se+=m*Ce,he+=m*de,Ne+=m*Fe,xe+=m*Be,ae+=m*ce,ve+=m*Ue,le+=m*$e,ne+=m*me,ue+=m*ze,fe+=m*ke,te+=m*ge,pe+=m*Le,_e+=m*Re,re+=m*ye,Ae+=m*Ke,m=q[5],Se+=m*Te,he+=m*Ce,Ne+=m*de,xe+=m*Fe,ae+=m*Be,ve+=m*ce,le+=m*Ue,ne+=m*$e,ue+=m*me,fe+=m*ze,te+=m*ke,pe+=m*ge,_e+=m*Le,re+=m*Re,Ae+=m*ye,Ee+=m*Ke,m=q[6],he+=m*Te,Ne+=m*Ce,xe+=m*de,ae+=m*Fe,ve+=m*Be,le+=m*ce,ne+=m*Ue,ue+=m*$e,fe+=m*me,te+=m*ze,pe+=m*ke,_e+=m*ge,re+=m*Le,Ae+=m*Re,Ee+=m*ye,oe+=m*Ke,m=q[7],Ne+=m*Te,xe+=m*Ce,ae+=m*de,ve+=m*Fe,le+=m*Be,ne+=m*ce,ue+=m*Ue,fe+=m*$e,te+=m*me,pe+=m*ze,_e+=m*ke,re+=m*ge,Ae+=m*Le,Ee+=m*Re,oe+=m*ye,De+=m*Ke,m=q[8],xe+=m*Te,ae+=m*Ce,ve+=m*de,le+=m*Fe,ne+=m*Be,ue+=m*ce,fe+=m*Ue,te+=m*$e,pe+=m*me,_e+=m*ze,re+=m*ke,Ae+=m*ge,Ee+=m*Le,oe+=m*Re,De+=m*ye,Me+=m*Ke,m=q[9],ae+=m*Te,ve+=m*Ce,le+=m*de,ne+=m*Fe,ue+=m*Be,fe+=m*ce,te+=m*Ue,pe+=m*$e,_e+=m*me,re+=m*ze,Ae+=m*ke,Ee+=m*ge,oe+=m*Le,De+=m*Re,Me+=m*ye,Oe+=m*Ke,m=q[10],ve+=m*Te,le+=m*Ce,ne+=m*de,ue+=m*Fe,fe+=m*Be,te+=m*ce,pe+=m*Ue,_e+=m*$e,re+=m*me,Ae+=m*ze,Ee+=m*ke,oe+=m*ge,De+=m*Le,Me+=m*Re,Oe+=m*ye,We+=m*Ke,m=q[11],le+=m*Te,ne+=m*Ce,ue+=m*de,fe+=m*Fe,te+=m*Be,pe+=m*ce,_e+=m*Ue,re+=m*$e,Ae+=m*me,Ee+=m*ze,oe+=m*ke,De+=m*ge,Me+=m*Le,Oe+=m*Re,We+=m*ye,Qe+=m*Ke,m=q[12],ne+=m*Te,ue+=m*Ce,fe+=m*de,te+=m*Fe,pe+=m*Be,_e+=m*ce,re+=m*Ue,Ae+=m*$e,Ee+=m*me,oe+=m*ze,De+=m*ke,Me+=m*ge,Oe+=m*Le,We+=m*Re,Qe+=m*ye,Ie+=m*Ke,m=q[13],ue+=m*Te,fe+=m*Ce,te+=m*de,pe+=m*Fe,_e+=m*Be,re+=m*ce,Ae+=m*Ue,Ee+=m*$e,oe+=m*me,De+=m*ze,Me+=m*ke,Oe+=m*ge,We+=m*Le,Qe+=m*Re,Ie+=m*ye,et+=m*Ke,m=q[14],fe+=m*Te,te+=m*Ce,pe+=m*de,_e+=m*Fe,re+=m*Be,Ae+=m*ce,Ee+=m*Ue,oe+=m*$e,De+=m*me,Me+=m*ze,Oe+=m*ke,We+=m*ge,Qe+=m*Le,Ie+=m*Re,et+=m*ye,tt+=m*Ke,m=q[15],te+=m*Te,pe+=m*Ce,_e+=m*de,re+=m*Fe,Ae+=m*Be,Ee+=m*ce,oe+=m*Ue,De+=m*$e,Me+=m*me,Oe+=m*ze,We+=m*ke,Qe+=m*ge,Ie+=m*Le,et+=m*Re,tt+=m*ye,Pe+=m*Ke,G+=38*pe,Y+=38*_e,X+=38*re,ee+=38*Ae,we+=38*Ee,Se+=38*oe,he+=38*De,Ne+=38*Me,xe+=38*Oe,ae+=38*We,ve+=38*Qe,le+=38*Ie,ne+=38*et,ue+=38*tt,fe+=38*Pe,L=1,m=G+L+65535,L=Math.floor(m/65536),G=m-L*65536,m=Y+L+65535,L=Math.floor(m/65536),Y=m-L*65536,m=X+L+65535,L=Math.floor(m/65536),X=m-L*65536,m=ee+L+65535,L=Math.floor(m/65536),ee=m-L*65536,m=we+L+65535,L=Math.floor(m/65536),we=m-L*65536,m=Se+L+65535,L=Math.floor(m/65536),Se=m-L*65536,m=he+L+65535,L=Math.floor(m/65536),he=m-L*65536,m=Ne+L+65535,L=Math.floor(m/65536),Ne=m-L*65536,m=xe+L+65535,L=Math.floor(m/65536),xe=m-L*65536,m=ae+L+65535,L=Math.floor(m/65536),ae=m-L*65536,m=ve+L+65535,L=Math.floor(m/65536),ve=m-L*65536,m=le+L+65535,L=Math.floor(m/65536),le=m-L*65536,m=ne+L+65535,L=Math.floor(m/65536),ne=m-L*65536,m=ue+L+65535,L=Math.floor(m/65536),ue=m-L*65536,m=fe+L+65535,L=Math.floor(m/65536),fe=m-L*65536,m=te+L+65535,L=Math.floor(m/65536),te=m-L*65536,G+=L-1+37*(L-1),L=1,m=G+L+65535,L=Math.floor(m/65536),G=m-L*65536,m=Y+L+65535,L=Math.floor(m/65536),Y=m-L*65536,m=X+L+65535,L=Math.floor(m/65536),X=m-L*65536,m=ee+L+65535,L=Math.floor(m/65536),ee=m-L*65536,m=we+L+65535,L=Math.floor(m/65536),we=m-L*65536,m=Se+L+65535,L=Math.floor(m/65536),Se=m-L*65536,m=he+L+65535,L=Math.floor(m/65536),he=m-L*65536,m=Ne+L+65535,L=Math.floor(m/65536),Ne=m-L*65536,m=xe+L+65535,L=Math.floor(m/65536),xe=m-L*65536,m=ae+L+65535,L=Math.floor(m/65536),ae=m-L*65536,m=ve+L+65535,L=Math.floor(m/65536),ve=m-L*65536,m=le+L+65535,L=Math.floor(m/65536),le=m-L*65536,m=ne+L+65535,L=Math.floor(m/65536),ne=m-L*65536,m=ue+L+65535,L=Math.floor(m/65536),ue=m-L*65536,m=fe+L+65535,L=Math.floor(m/65536),fe=m-L*65536,m=te+L+65535,L=Math.floor(m/65536),te=m-L*65536,G+=L-1+37*(L-1),T[0]=G,T[1]=Y,T[2]=X,T[3]=ee,T[4]=we,T[5]=Se,T[6]=he,T[7]=Ne,T[8]=xe,T[9]=ae,T[10]=ve,T[11]=le,T[12]=ne,T[13]=ue,T[14]=fe,T[15]=te}function R(T,q){_(T,q,q)}function J(T,q){const B=n();let m;for(m=0;m<16;m++)B[m]=q[m];for(m=253;m>=0;m--)R(B,B),m!==2&&m!==4&&_(B,B,q);for(m=0;m<16;m++)T[m]=B[m]}function Q(T,q){const B=n();let m;for(m=0;m<16;m++)B[m]=q[m];for(m=250;m>=0;m--)R(B,B),m!==1&&_(B,B,q);for(m=0;m<16;m++)T[m]=B[m]}function N(T,q){const B=n(),m=n(),L=n(),G=n(),Y=n(),X=n(),ee=n(),we=n(),Se=n();z(B,T[1],T[0]),z(Se,q[1],q[0]),_(B,B,Se),U(m,T[0],T[1]),U(Se,q[0],q[1]),_(m,m,Se),_(L,T[3],q[3]),_(L,L,h),_(G,T[2],q[2]),U(G,G,G),z(Y,m,B),z(X,G,L),U(ee,G,L),U(we,m,B),_(T[0],Y,X),_(T[1],we,ee),_(T[2],ee,X),_(T[3],Y,we)}function p(T,q,B){for(let m=0;m<4;m++)P(T[m],q[m],B)}function l(T,q){const B=n(),m=n(),L=n();J(L,q[2]),_(B,q[0],L),_(m,q[1],L),k(T,m),T[31]^=j(B)<<7}function a(T,q,B){M(T[0],o),M(T[1],f),M(T[2],f),M(T[3],o);for(let m=255;m>=0;--m){const L=B[m/8|0]>>(m&7)&1;p(T,q,L),N(q,T),N(T,T),p(T,q,L)}}function c(T,q){const B=[n(),n(),n(),n()];M(B[0],g),M(B[1],y),M(B[2],f),_(B[3],g,y),a(T,B,q)}function b(T){if(T.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const q=(0,t.hash)(T);q[0]&=248,q[31]&=127,q[31]|=64;const B=new Uint8Array(32),m=[n(),n(),n(),n()];c(m,q),l(B,m);const L=new Uint8Array(64);return L.set(T),L.set(B,32),{publicKey:B,secretKey:L}}r.generateKeyPairFromSeed=b;function A(T){const q=(0,e.randomBytes)(32,T),B=b(q);return(0,i.wipe)(q),B}r.generateKeyPair=A;function E(T){if(T.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(T.subarray(32))}r.extractPublicKeyFromSecretKey=E;const x=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 d(T,q){let B,m,L,G;for(m=63;m>=32;--m){for(B=0,L=m-32,G=m-12;L<G;++L)q[L]+=B-16*q[m]*x[L-(m-32)],B=Math.floor((q[L]+128)/256),q[L]-=B*256;q[L]+=B,q[m]=0}for(B=0,L=0;L<32;L++)q[L]+=B-(q[31]>>4)*x[L],B=q[L]>>8,q[L]&=255;for(L=0;L<32;L++)q[L]-=B*x[L];for(m=0;m<32;m++)q[m+1]+=q[m]>>8,T[m]=q[m]&255}function w(T){const q=new Float64Array(64);for(let B=0;B<64;B++)q[B]=T[B];for(let B=0;B<64;B++)T[B]=0;d(T,q)}function v(T,q){const B=new Float64Array(64),m=[n(),n(),n(),n()],L=(0,t.hash)(T.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const G=new Uint8Array(64);G.set(L.subarray(32),32);const Y=new t.SHA512;Y.update(G.subarray(32)),Y.update(q);const X=Y.digest();Y.clean(),w(X),c(m,X),l(G,m),Y.reset(),Y.update(G.subarray(0,32)),Y.update(T.subarray(32)),Y.update(q);const ee=Y.digest();w(ee);for(let we=0;we<32;we++)B[we]=X[we];for(let we=0;we<32;we++)for(let Se=0;Se<32;Se++)B[we+Se]+=ee[we]*L[Se];return d(G.subarray(32),B),G}r.sign=v;function O(T,q){const B=n(),m=n(),L=n(),G=n(),Y=n(),X=n(),ee=n();return M(T[2],f),F(T[1],q),R(L,T[1]),_(G,L,u),z(L,L,T[2]),U(G,T[2],G),R(Y,G),R(X,Y),_(ee,X,Y),_(B,ee,L),_(B,B,G),Q(B,B),_(B,B,L),_(B,B,G),_(B,B,G),_(T[0],B,G),R(m,T[0]),_(m,m,G),C(m,L)&&_(T[0],T[0],I),R(m,T[0]),_(m,m,G),C(m,L)?-1:(j(T[0])===q[31]>>7&&z(T[0],o,T[0]),_(T[3],T[0],T[1]),0)}function W(T,q,B){const m=new Uint8Array(32),L=[n(),n(),n(),n()],G=[n(),n(),n(),n()];if(B.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(O(G,T))return!1;const Y=new t.SHA512;Y.update(B.subarray(0,32)),Y.update(T),Y.update(q);const X=Y.digest();return w(X),a(L,G,X),c(G,B.subarray(32)),N(L,G),l(m,L),!K(B,m)}r.verify=W;function S(T){let q=[n(),n(),n(),n()];if(O(q,T))throw new Error("Ed25519: invalid public key");let B=n(),m=n(),L=q[1];U(B,f,L),z(m,f,L),J(m,m),_(B,B,m);let G=new Uint8Array(32);return k(G,B),G}r.convertPublicKeyToX25519=S;function H(T){const q=(0,t.hash)(T.subarray(0,32));q[0]&=248,q[31]&=127,q[31]|=64;const B=new Uint8Array(q.subarray(0,32));return(0,i.wipe)(q),B}r.convertSecretKeyToX25519=H}(ro);const d1="EdDSA",l1="JWT",ks=".",Ks="base64url",wc="utf8",_c="utf8",p1=":",g1="did",b1="key",xc="base58btc",v1="z",m1="K36",y1=32;function Ac(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function js(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));const t=Ac(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function w1(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function y(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var P=0,k=0,K=0,C=D.length;K!==C&&D[K]===0;)K++,P++;for(var j=(C-K)*g+1>>>0,F=new Uint8Array(j);K!==C;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var R=j-k;R!==j&&F[R]===0;)R++;for(var J=u.repeat(P);R<j;++R)J+=r.charAt(F[R]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var P=0;if(D[P]!==" "){for(var k=0,K=0;D[P]===u;)k++,P++;for(var C=(D.length-P)*h+1>>>0,j=new Uint8Array(C);D[P];){var F=t[D.charCodeAt(P)];if(F===255)return;for(var U=0,z=C-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,P++}if(D[P]!==" "){for(var _=C-K;_!==C&&j[_]===0;)_++;for(var R=new Uint8Array(k+(C-_)),J=k;_!==C;)R[J++]=j[_++];return R}}}function M(D){var P=I(D);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:I,decode:M}}var _1=w1,x1=_1;const Ec=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},A1=r=>new TextEncoder().encode(r),E1=r=>new TextDecoder().decode(r);class S1{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class M1{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Sc(this,e)}}class I1{constructor(e){this.decoders=e}or(e){return Sc(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Sc=(r,e)=>new I1({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class D1{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new S1(e,t,i),this.decoder=new M1(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Hs=({name:r,prefix:e,encode:t,decode:i})=>new D1(r,e,t,i),jn=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=x1(t,e);return Hs({prefix:r,name:e,encode:i,decode:s=>Ec(n(s))})},O1=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const y=n[r[g]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|y,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},R1=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Ct=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Hs({prefix:e,name:r,encode(n){return R1(n,i,t)},decode(n){return O1(n,i,t,r)}}),N1=Hs({prefix:"\0",name:"identity",encode:r=>E1(r),decode:r=>A1(r)});var P1=Object.freeze({__proto__:null,identity:N1});const C1=Ct({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var T1=Object.freeze({__proto__:null,base2:C1});const F1=Ct({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var B1=Object.freeze({__proto__:null,base8:F1});const L1=jn({prefix:"9",name:"base10",alphabet:"0123456789"});var q1=Object.freeze({__proto__:null,base10:L1});const U1=Ct({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$1=Ct({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var z1=Object.freeze({__proto__:null,base16:U1,base16upper:$1});const k1=Ct({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),K1=Ct({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),j1=Ct({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),H1=Ct({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),V1=Ct({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G1=Ct({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),W1=Ct({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),J1=Ct({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Y1=Ct({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Q1=Object.freeze({__proto__:null,base32:k1,base32upper:K1,base32pad:j1,base32padupper:H1,base32hex:V1,base32hexupper:G1,base32hexpad:W1,base32hexpadupper:J1,base32z:Y1});const X1=jn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Z1=jn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var eg=Object.freeze({__proto__:null,base36:X1,base36upper:Z1});const tg=jn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rg=jn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ig=Object.freeze({__proto__:null,base58btc:tg,base58flickr:rg});const ng=Ct({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sg=Ct({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ag=Ct({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),og=Ct({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fg=Object.freeze({__proto__:null,base64:ng,base64pad:sg,base64url:ag,base64urlpad:og});const Mc=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),cg=Mc.reduce((r,e,t)=>(r[t]=e,r),[]),hg=Mc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ug(r){return r.reduce((e,t)=>(e+=cg[t],e),"")}function dg(r){const e=[];for(const t of r){const i=hg[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const lg=Hs({prefix:"\u{1F680}",name:"base256emoji",encode:ug,decode:dg});var pg=Object.freeze({__proto__:null,base256emoji:lg}),gg=Dc,Ic=128,bg=127,vg=~bg,mg=Math.pow(2,31);function Dc(r,e,t){e=e||[],t=t||0;for(var i=t;r>=mg;)e[t++]=r&255|Ic,r/=128;for(;r&vg;)e[t++]=r&255|Ic,r>>>=7;return e[t]=r|0,Dc.bytes=t-i+1,e}var yg=oo,wg=128,Oc=127;function oo(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw oo.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Oc)<<n:(o&Oc)*Math.pow(2,n),n+=7}while(o>=wg);return oo.bytes=s-i,t}var _g=Math.pow(2,7),xg=Math.pow(2,14),Ag=Math.pow(2,21),Eg=Math.pow(2,28),Sg=Math.pow(2,35),Mg=Math.pow(2,42),Ig=Math.pow(2,49),Dg=Math.pow(2,56),Og=Math.pow(2,63),Rg=function(r){return r<_g?1:r<xg?2:r<Ag?3:r<Eg?4:r<Sg?5:r<Mg?6:r<Ig?7:r<Dg?8:r<Og?9:10},Ng={encode:gg,decode:yg,encodingLength:Rg},Rc=Ng;const Nc=(r,e,t=0)=>(Rc.encode(r,e,t),e),Pc=r=>Rc.encodingLength(r),fo=(r,e)=>{const t=e.byteLength,i=Pc(r),n=i+Pc(t),s=new Uint8Array(n+t);return Nc(r,s,0),Nc(t,s,i),s.set(e,n),new Pg(r,t,e,s)};class Pg{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Cc=({name:r,code:e,encode:t})=>new Cg(r,e,t);class Cg{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?fo(this.code,t):t.then(i=>fo(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Tc=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Tg=Cc({name:"sha2-256",code:18,encode:Tc("SHA-256")}),Fg=Cc({name:"sha2-512",code:19,encode:Tc("SHA-512")});var Bg=Object.freeze({__proto__:null,sha256:Tg,sha512:Fg});const Fc=0,Lg="identity",Bc=Ec;var qg=Object.freeze({__proto__:null,identity:{code:Fc,name:Lg,encode:Bc,digest:r=>fo(Fc,Bc(r))}});new TextEncoder,new TextDecoder;const Lc={...P1,...T1,...B1,...q1,...z1,...Q1,...eg,...ig,...fg,...pg};({...Bg,...qg});function qc(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Uc=qc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),co=qc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=Ac(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),$c={utf8:Uc,"utf-8":Uc,hex:Lc.base16,latin1:co,ascii:co,binary:co,...Lc};function At(r,e="utf8"){const t=$c[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function Et(r,e="utf8"){const t=$c[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function zc(r){return ln(At(Et(r,Ks),wc))}function Vs(r){return At(Et(ki(r),wc),Ks)}function kc(r){const e=Et(m1,xc),t=v1+At(js([e,r]),xc);return[g1,b1,t].join(p1)}function Ug(r){return At(r,Ks)}function $g(r){return Et(r,Ks)}function zg(r){return Et([Vs(r.header),Vs(r.payload)].join(ks),_c)}function kg(r){return[Vs(r.header),Vs(r.payload),Ug(r.signature)].join(ks)}function ho(r){const e=r.split(ks),t=zc(e[0]),i=zc(e[1]),n=$g(e[2]),s=Et(e.slice(0,2).join(ks),_c);return{header:t,payload:i,signature:n,data:s}}function Kc(r=Ai.randomBytes(y1)){return ro.generateKeyPairFromSeed(r)}async function Kg(r,e,t,i,n=ie.fromMiliseconds(Date.now())){const s={alg:d1,typ:l1},o=kc(i.publicKey),f=n+t,u={iss:o,sub:r,aud:e,iat:n,exp:f},h=zg({header:s,payload:u}),g=ro.sign(i.secretKey,h);return kg({header:s,payload:u,signature:g})}var jc=function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return r.concat(s||Array.prototype.slice.call(e))},jg=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Hg=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r}(),Vg=function(){function r(e,t,i,n){this.name=e,this.version=t,this.os=i,this.bot=n,this.type="bot-device"}return r}(),Gg=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Wg=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),Jg=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Yg=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Hc=3,Qg=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Jg]],Vc=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Xg(r){return r?Gc(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Wg:typeof navigator<"u"?Gc(navigator.userAgent):tb()}function Zg(r){return r!==""&&Qg.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function Gc(r){var e=Zg(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Gg;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Hc&&(n=jc(jc([],n,!0),rb(Hc-n.length),!0)):n=[];var s=n.join("."),o=eb(r),f=Yg.exec(r);return f&&f[1]?new Vg(t,s,o,f[1]):new jg(t,s,o)}function eb(r){for(var e=0,t=Vc.length;e<t;e++){var i=Vc[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function tb(){var r=typeof process<"u"&&process.version;return r?new Hg(process.version.slice(1)):null}function rb(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.getLocalStorage=at.getLocalStorageOrThrow=at.getCrypto=at.getCryptoOrThrow=Wc=at.getLocation=at.getLocationOrThrow=uo=at.getNavigator=at.getNavigatorOrThrow=Hn=at.getDocument=at.getDocumentOrThrow=at.getFromWindowOrThrow=at.getFromWindow=void 0;function Ki(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}at.getFromWindow=Ki;function bn(r){const e=Ki(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}at.getFromWindowOrThrow=bn;function ib(){return bn("document")}at.getDocumentOrThrow=ib;function nb(){return Ki("document")}var Hn=at.getDocument=nb;function sb(){return bn("navigator")}at.getNavigatorOrThrow=sb;function ab(){return Ki("navigator")}var uo=at.getNavigator=ab;function ob(){return bn("location")}at.getLocationOrThrow=ob;function fb(){return Ki("location")}var Wc=at.getLocation=fb;function cb(){return bn("crypto")}at.getCryptoOrThrow=cb;function hb(){return Ki("crypto")}at.getCrypto=hb;function ub(){return bn("localStorage")}at.getLocalStorageOrThrow=ub;function db(){return Ki("localStorage")}at.getLocalStorage=db;var lo={};Object.defineProperty(lo,"__esModule",{value:!0});var Jc=lo.getWindowMetadata=void 0;const Yc=at;function lb(){let r,e;try{r=Yc.getDocumentOrThrow(),e=Yc.getLocationOrThrow()}catch{return null}function t(){const y=r.getElementsByTagName("link"),I=[];for(let M=0;M<y.length;M++){const D=y[M],P=D.getAttribute("rel");if(P&&P.toLowerCase().indexOf("icon")>-1){const k=D.getAttribute("href");if(k)if(k.toLowerCase().indexOf("https:")===-1&&k.toLowerCase().indexOf("http:")===-1&&k.indexOf("//")!==0){let K=e.protocol+"//"+e.host;if(k.indexOf("/")===0)K+=k;else{const C=e.pathname.split("/");C.pop();const j=C.join("/");K+=j+"/"+k}I.push(K)}else if(k.indexOf("//")===0){const K=e.protocol+k;I.push(K)}else I.push(k)}}return I}function i(...y){const I=r.getElementsByTagName("meta");for(let M=0;M<I.length;M++){const D=I[M],P=["itemprop","property","name"].map(k=>D.getAttribute(k)).filter(k=>k?y.includes(k):!1);if(P.length&&P){const k=D.getAttribute("content");if(k)return k}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),f=s(),u=e.origin,h=t();return{description:f,url:u,icons:h,name:o}}Jc=lo.getWindowMetadata=lb;var Vn={},pb=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Qc="%[a-f0-9]{2}",Xc=new RegExp("("+Qc+")|([^%]+?)","gi"),Zc=new RegExp("("+Qc+")+","gi");function po(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],po(t),po(i))}function gb(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(Xc)||[],t=1;t<e.length;t++)r=po(e,t).join(""),e=r.match(Xc)||[];return r}}function bb(r){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},t=Zc.exec(r);t;){try{e[t[0]]=decodeURIComponent(t[0])}catch{var i=gb(t[0]);i!==t[0]&&(e[t[0]]=i)}t=Zc.exec(r)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];r=r.replace(new RegExp(o,"g"),e[o])}return r}var vb=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return bb(r)}},mb=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},yb=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],f=r[o];(n?e.indexOf(o)!==-1:e(o,f,r))&&(t[o]=f)}return t};(function(r){const e=pb,t=vb,i=mb,n=yb,s=C=>C==null,o=Symbol("encodeFragmentIdentifier");function f(C){switch(C.arrayFormat){case"index":return j=>(F,U)=>{const z=F.length;return U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),"[",z,"]"].join("")]:[...F,[g(j,C),"[",g(z,C),"]=",g(U,C)].join("")]};case"bracket":return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),"[]"].join("")]:[...F,[g(j,C),"[]=",g(U,C)].join("")];case"colon-list-separator":return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,[g(j,C),":list="].join("")]:[...F,[g(j,C),":list=",g(U,C)].join("")];case"comma":case"separator":case"bracket-separator":{const j=C.arrayFormat==="bracket-separator"?"[]=":"=";return F=>(U,z)=>z===void 0||C.skipNull&&z===null||C.skipEmptyString&&z===""?U:(z=z===null?"":z,U.length===0?[[g(F,C),j,g(z,C)].join("")]:[[U,g(z,C)].join(C.arrayFormatSeparator)])}default:return j=>(F,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?F:U===null?[...F,g(j,C)]:[...F,[g(j,C),"=",g(U,C)].join("")]}}function u(C){let j;switch(C.arrayFormat){case"index":return(F,U,z)=>{if(j=/\[(\d*)\]$/.exec(F),F=F.replace(/\[\d*\]$/,""),!j){z[F]=U;return}z[F]===void 0&&(z[F]={}),z[F][j[1]]=U};case"bracket":return(F,U,z)=>{if(j=/(\[\])$/.exec(F),F=F.replace(/\[\]$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"colon-list-separator":return(F,U,z)=>{if(j=/(:list)$/.exec(F),F=F.replace(/:list$/,""),!j){z[F]=U;return}if(z[F]===void 0){z[F]=[U];return}z[F]=[].concat(z[F],U)};case"comma":case"separator":return(F,U,z)=>{const _=typeof U=="string"&&U.includes(C.arrayFormatSeparator),R=typeof U=="string"&&!_&&y(U,C).includes(C.arrayFormatSeparator);U=R?y(U,C):U;const J=_||R?U.split(C.arrayFormatSeparator).map(Q=>y(Q,C)):U===null?U:y(U,C);z[F]=J};case"bracket-separator":return(F,U,z)=>{const _=/(\[\])$/.test(F);if(F=F.replace(/\[\]$/,""),!_){z[F]=U&&y(U,C);return}const R=U===null?[]:U.split(C.arrayFormatSeparator).map(J=>y(J,C));if(z[F]===void 0){z[F]=R;return}z[F]=[].concat(z[F],R)};default:return(F,U,z)=>{if(z[F]===void 0){z[F]=U;return}z[F]=[].concat(z[F],U)}}}function h(C){if(typeof C!="string"||C.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(C,j){return j.encode?j.strict?e(C):encodeURIComponent(C):C}function y(C,j){return j.decode?t(C):C}function I(C){return Array.isArray(C)?C.sort():typeof C=="object"?I(Object.keys(C)).sort((j,F)=>Number(j)-Number(F)).map(j=>C[j]):C}function M(C){const j=C.indexOf("#");return j!==-1&&(C=C.slice(0,j)),C}function D(C){let j="";const F=C.indexOf("#");return F!==-1&&(j=C.slice(F)),j}function P(C){C=M(C);const j=C.indexOf("?");return j===-1?"":C.slice(j+1)}function k(C,j){return j.parseNumbers&&!Number.isNaN(Number(C))&&typeof C=="string"&&C.trim()!==""?C=Number(C):j.parseBooleans&&C!==null&&(C.toLowerCase()==="true"||C.toLowerCase()==="false")&&(C=C.toLowerCase()==="true"),C}function K(C,j){j=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},j),h(j.arrayFormatSeparator);const F=u(j),U=Object.create(null);if(typeof C!="string"||(C=C.trim().replace(/^[?#&]/,""),!C))return U;for(const z of C.split("&")){if(z==="")continue;let[_,R]=i(j.decode?z.replace(/\+/g," "):z,"=");R=R===void 0?null:["comma","separator","bracket-separator"].includes(j.arrayFormat)?R:y(R,j),F(y(_,j),R,U)}for(const z of Object.keys(U)){const _=U[z];if(typeof _=="object"&&_!==null)for(const R of Object.keys(_))_[R]=k(_[R],j);else U[z]=k(_,j)}return j.sort===!1?U:(j.sort===!0?Object.keys(U).sort():Object.keys(U).sort(j.sort)).reduce((z,_)=>{const R=U[_];return R&&typeof R=="object"&&!Array.isArray(R)?z[_]=I(R):z[_]=R,z},Object.create(null))}r.extract=P,r.parse=K,r.stringify=(C,j)=>{if(!C)return"";j=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},j),h(j.arrayFormatSeparator);const F=R=>j.skipNull&&s(C[R])||j.skipEmptyString&&C[R]==="",U=f(j),z={};for(const R of Object.keys(C))F(R)||(z[R]=C[R]);const _=Object.keys(z);return j.sort!==!1&&_.sort(j.sort),_.map(R=>{const J=C[R];return J===void 0?"":J===null?g(R,j):Array.isArray(J)?J.length===0&&j.arrayFormat==="bracket-separator"?g(R,j)+"[]":J.reduce(U(R),[]).join("&"):g(R,j)+"="+g(J,j)}).filter(R=>R.length>0).join("&")},r.parseUrl=(C,j)=>{j=Object.assign({decode:!0},j);const[F,U]=i(C,"#");return Object.assign({url:F.split("?")[0]||"",query:K(P(C),j)},j&&j.parseFragmentIdentifier&&U?{fragmentIdentifier:y(U,j)}:{})},r.stringifyUrl=(C,j)=>{j=Object.assign({encode:!0,strict:!0,[o]:!0},j);const F=M(C.url).split("?")[0]||"",U=r.extract(C.url),z=r.parse(U,{sort:!1}),_=Object.assign(z,C.query);let R=r.stringify(_,j);R&&(R=`?${R}`);let J=D(C.url);return C.fragmentIdentifier&&(J=`#${j[o]?g(C.fragmentIdentifier,j):C.fragmentIdentifier}`),`${F}${R}${J}`},r.pick=(C,j,F)=>{F=Object.assign({parseFragmentIdentifier:!0,[o]:!1},F);const{url:U,query:z,fragmentIdentifier:_}=r.parseUrl(C,F);return r.stringifyUrl({url:U,query:n(z,j),fragmentIdentifier:_},F)},r.exclude=(C,j,F)=>{const U=Array.isArray(j)?z=>!j.includes(z):(z,_)=>!j(z,_);return r.pick(C,U,F)}})(Vn);var eh={exports:{}};/**
|
15
15
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
16
16
|
*
|
17
17
|
* @version 0.8.0
|
18
18
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
19
19
|
* @copyright Chen, Yi-Cyuan 2015-2018
|
20
20
|
* @license MIT
|
21
|
-
*/(function(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=Pt:s&&(n=self);var f=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,u=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],I=[1,256,65536,16777216],M=[6,1536,393216,100663296],D=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],k=[224,256,384,512],K=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],j={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(S){return Object.prototype.toString.call(S)==="[object Array]"}),u&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(S){return typeof S=="object"&&S.buffer&&S.buffer.constructor===ArrayBuffer});for(var F=function(S,H,T){return function(q){return new v(S,H,S).update(q)[T]()}},U=function(S,H,T){return function(q,B){return new v(S,H,B).update(q)[T]()}},z=function(S,H,T){return function(q,B,m,L){return a["cshake"+S].update(q,B,m,L)[T]()}},_=function(S,H,T){return function(q,B,m,L){return a["kmac"+S].update(q,B,m,L)[T]()}},R=function(S,H,T,q){for(var B=0;B<C.length;++B){var m=C[B];S[m]=H(T,q,m)}return S},J=function(S,H){var T=F(S,H,"hex");return T.create=function(){return new v(S,H,S)},T.update=function(q){return T.create().update(q)},R(T,F,S,H)},Q=function(S,H){var T=U(S,H,"hex");return T.create=function(q){return new v(S,H,q)},T.update=function(q,B){return T.create(B).update(q)},R(T,U,S,H)},N=function(S,H){var T=j[S],q=z(S,H,"hex");return q.create=function(B,m,L){return!m&&!L?a["shake"+S].create(B):new v(S,H,B).bytepad([m,L],T)},q.update=function(B,m,L,G){return q.create(m,L,G).update(B)},R(q,z,S,H)},p=function(S,H){var T=j[S],q=_(S,H,"hex");return q.create=function(B,m,L){return new O(S,H,m).bytepad(["KMAC",L],T).bytepad([B],T)},q.update=function(B,m,L,G){return q.create(B,L,G).update(m)},R(q,_,S,H)},l=[{name:"keccak",padding:I,bits:k,createMethod:J},{name:"sha3",padding:M,bits:k,createMethod:J},{name:"shake",padding:g,bits:K,createMethod:Q},{name:"cshake",padding:y,bits:K,createMethod:N},{name:"kmac",padding:y,bits:K,createMethod:p}],a={},c=[],b=0;b<l.length;++b)for(var A=l[b],E=A.bits,x=0;x<E.length;++x){var d=A.name+"_"+E[x];if(c.push(d),a[d]=A.createMethod(E[x],A.padding),A.name!=="sha3"){var w=A.name+E[x];c.push(w),a[w]=a[d]}}function v(S,H,T){this.blocks=[],this.s=[],this.padding=H,this.outputBits=T,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(S<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=T>>5,this.extraBytes=(T&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}v.prototype.update=function(S){if(this.finalized)throw new Error(t);var H,T=typeof S;if(T!=="string"){if(T==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}for(var q=this.blocks,B=this.byteCount,m=S.length,L=this.blockCount,G=0,Y=this.s,X,ee;G<m;){if(this.reset)for(this.reset=!1,q[0]=this.block,X=1;X<L+1;++X)q[X]=0;if(H)for(X=this.start;G<m&&X<B;++G)q[X>>2]|=S[G]<<D[X++&3];else for(X=this.start;G<m&&X<B;++G)ee=S.charCodeAt(G),ee<128?q[X>>2]|=ee<<D[X++&3]:ee<2048?(q[X>>2]|=(192|ee>>6)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):ee<55296||ee>=57344?(q[X>>2]|=(224|ee>>12)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):(ee=65536+((ee&1023)<<10|S.charCodeAt(++G)&1023),q[X>>2]|=(240|ee>>18)<<D[X++&3],q[X>>2]|=(128|ee>>12&63)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]);if(this.lastByteIndex=X,X>=B){for(this.start=X-B,this.block=q[L],X=0;X<L;++X)Y[X]^=q[X];W(Y),this.reset=!0}else this.start=X}return this},v.prototype.encode=function(S,H){var T=S&255,q=1,B=[T];for(S=S>>8,T=S&255;T>0;)B.unshift(T),S=S>>8,T=S&255,++q;return H?B.push(q):B.unshift(q),this.update(B),B.length},v.prototype.encodeString=function(S){var H,T=typeof S;if(T!=="string"){if(T==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}var q=0,B=S.length;if(H)q=B;else for(var m=0;m<S.length;++m){var L=S.charCodeAt(m);L<128?q+=1:L<2048?q+=2:L<55296||L>=57344?q+=3:(L=65536+((L&1023)<<10|S.charCodeAt(++m)&1023),q+=4)}return q+=this.encode(q*8),this.update(S),q},v.prototype.bytepad=function(S,H){for(var T=this.encode(H),q=0;q<S.length;++q)T+=this.encodeString(S[q]);var B=H-T%H,m=[];return m.length=B,this.update(m),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var S=this.blocks,H=this.lastByteIndex,T=this.blockCount,q=this.s;if(S[H>>2]|=this.padding[H&3],this.lastByteIndex===this.byteCount)for(S[0]=S[T],H=1;H<T+1;++H)S[H]=0;for(S[T-1]|=2147483648,H=0;H<T;++H)q[H]^=S[H];W(q)}},v.prototype.toString=v.prototype.hex=function(){this.finalize();for(var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L="",G;m<T;){for(B=0;B<S&&m<T;++B,++m)G=H[B],L+=h[G>>4&15]+h[G&15]+h[G>>12&15]+h[G>>8&15]+h[G>>20&15]+h[G>>16&15]+h[G>>28&15]+h[G>>24&15];m%S===0&&(W(H),B=0)}return q&&(G=H[B],L+=h[G>>4&15]+h[G&15],q>1&&(L+=h[G>>12&15]+h[G>>8&15]),q>2&&(L+=h[G>>20&15]+h[G>>16&15])),L},v.prototype.arrayBuffer=function(){this.finalize();var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L=this.outputBits>>3,G;q?G=new ArrayBuffer(T+1<<2):G=new ArrayBuffer(L);for(var Y=new Uint32Array(G);m<T;){for(B=0;B<S&&m<T;++B,++m)Y[m]=H[B];m%S===0&&W(H)}return q&&(Y[B]=H[B],G=G.slice(0,L)),G},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.digest=v.prototype.array=function(){this.finalize();for(var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L=[],G,Y;m<T;){for(B=0;B<S&&m<T;++B,++m)G=m<<2,Y=H[B],L[G]=Y&255,L[G+1]=Y>>8&255,L[G+2]=Y>>16&255,L[G+3]=Y>>24&255;m%S===0&&W(H)}return q&&(G=m<<2,Y=H[B],L[G]=Y&255,q>1&&(L[G+1]=Y>>8&255),q>2&&(L[G+2]=Y>>16&255)),L};function O(S,H,T){v.call(this,S,H,T)}O.prototype=new v,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),v.prototype.finalize.call(this)};var W=function(S){var H,T,q,B,m,L,G,Y,X,ee,we,Se,he,Ne,xe,ae,ve,le,ne,ue,fe,te,pe,_e,re,Ae,Ee,oe,De,Me,Oe,We,Qe,Ie,et,tt,Pe,Te,Ce,de,Fe,Be,ce,Ue,$e,me,ze,ke,ge,Le,Re,ye,Ke,it,qe,nt,Je,rt,ir,nr,sr,ar,yt;for(q=0;q<48;q+=2)B=S[0]^S[10]^S[20]^S[30]^S[40],m=S[1]^S[11]^S[21]^S[31]^S[41],L=S[2]^S[12]^S[22]^S[32]^S[42],G=S[3]^S[13]^S[23]^S[33]^S[43],Y=S[4]^S[14]^S[24]^S[34]^S[44],X=S[5]^S[15]^S[25]^S[35]^S[45],ee=S[6]^S[16]^S[26]^S[36]^S[46],we=S[7]^S[17]^S[27]^S[37]^S[47],Se=S[8]^S[18]^S[28]^S[38]^S[48],he=S[9]^S[19]^S[29]^S[39]^S[49],H=Se^(L<<1|G>>>31),T=he^(G<<1|L>>>31),S[0]^=H,S[1]^=T,S[10]^=H,S[11]^=T,S[20]^=H,S[21]^=T,S[30]^=H,S[31]^=T,S[40]^=H,S[41]^=T,H=B^(Y<<1|X>>>31),T=m^(X<<1|Y>>>31),S[2]^=H,S[3]^=T,S[12]^=H,S[13]^=T,S[22]^=H,S[23]^=T,S[32]^=H,S[33]^=T,S[42]^=H,S[43]^=T,H=L^(ee<<1|we>>>31),T=G^(we<<1|ee>>>31),S[4]^=H,S[5]^=T,S[14]^=H,S[15]^=T,S[24]^=H,S[25]^=T,S[34]^=H,S[35]^=T,S[44]^=H,S[45]^=T,H=Y^(Se<<1|he>>>31),T=X^(he<<1|Se>>>31),S[6]^=H,S[7]^=T,S[16]^=H,S[17]^=T,S[26]^=H,S[27]^=T,S[36]^=H,S[37]^=T,S[46]^=H,S[47]^=T,H=ee^(B<<1|m>>>31),T=we^(m<<1|B>>>31),S[8]^=H,S[9]^=T,S[18]^=H,S[19]^=T,S[28]^=H,S[29]^=T,S[38]^=H,S[39]^=T,S[48]^=H,S[49]^=T,Ne=S[0],xe=S[1],me=S[11]<<4|S[10]>>>28,ze=S[10]<<4|S[11]>>>28,oe=S[20]<<3|S[21]>>>29,De=S[21]<<3|S[20]>>>29,nr=S[31]<<9|S[30]>>>23,sr=S[30]<<9|S[31]>>>23,Be=S[40]<<18|S[41]>>>14,ce=S[41]<<18|S[40]>>>14,Ie=S[2]<<1|S[3]>>>31,et=S[3]<<1|S[2]>>>31,ae=S[13]<<12|S[12]>>>20,ve=S[12]<<12|S[13]>>>20,ke=S[22]<<10|S[23]>>>22,ge=S[23]<<10|S[22]>>>22,Me=S[33]<<13|S[32]>>>19,Oe=S[32]<<13|S[33]>>>19,ar=S[42]<<2|S[43]>>>30,yt=S[43]<<2|S[42]>>>30,it=S[5]<<30|S[4]>>>2,qe=S[4]<<30|S[5]>>>2,tt=S[14]<<6|S[15]>>>26,Pe=S[15]<<6|S[14]>>>26,le=S[25]<<11|S[24]>>>21,ne=S[24]<<11|S[25]>>>21,Le=S[34]<<15|S[35]>>>17,Re=S[35]<<15|S[34]>>>17,We=S[45]<<29|S[44]>>>3,Qe=S[44]<<29|S[45]>>>3,_e=S[6]<<28|S[7]>>>4,re=S[7]<<28|S[6]>>>4,nt=S[17]<<23|S[16]>>>9,Je=S[16]<<23|S[17]>>>9,Te=S[26]<<25|S[27]>>>7,Ce=S[27]<<25|S[26]>>>7,ue=S[36]<<21|S[37]>>>11,fe=S[37]<<21|S[36]>>>11,ye=S[47]<<24|S[46]>>>8,Ke=S[46]<<24|S[47]>>>8,Ue=S[8]<<27|S[9]>>>5,$e=S[9]<<27|S[8]>>>5,Ae=S[18]<<20|S[19]>>>12,Ee=S[19]<<20|S[18]>>>12,rt=S[29]<<7|S[28]>>>25,ir=S[28]<<7|S[29]>>>25,de=S[38]<<8|S[39]>>>24,Fe=S[39]<<8|S[38]>>>24,te=S[48]<<14|S[49]>>>18,pe=S[49]<<14|S[48]>>>18,S[0]=Ne^~ae&le,S[1]=xe^~ve&ne,S[10]=_e^~Ae&oe,S[11]=re^~Ee&De,S[20]=Ie^~tt&Te,S[21]=et^~Pe&Ce,S[30]=Ue^~me&ke,S[31]=$e^~ze&ge,S[40]=it^~nt&rt,S[41]=qe^~Je&ir,S[2]=ae^~le&ue,S[3]=ve^~ne&fe,S[12]=Ae^~oe&Me,S[13]=Ee^~De&Oe,S[22]=tt^~Te&de,S[23]=Pe^~Ce&Fe,S[32]=me^~ke&Le,S[33]=ze^~ge&Re,S[42]=nt^~rt&nr,S[43]=Je^~ir&sr,S[4]=le^~ue&te,S[5]=ne^~fe&pe,S[14]=oe^~Me&We,S[15]=De^~Oe&Qe,S[24]=Te^~de&Be,S[25]=Ce^~Fe&ce,S[34]=ke^~Le&ye,S[35]=ge^~Re&Ke,S[44]=rt^~nr&ar,S[45]=ir^~sr&yt,S[6]=ue^~te&Ne,S[7]=fe^~pe&xe,S[16]=Me^~We&_e,S[17]=Oe^~Qe&re,S[26]=de^~Be&Ie,S[27]=Fe^~ce&et,S[36]=Le^~ye&Ue,S[37]=Re^~Ke&$e,S[46]=nr^~ar&it,S[47]=sr^~yt&qe,S[8]=te^~Ne&ae,S[9]=pe^~xe&ve,S[18]=We^~_e&Ae,S[19]=Qe^~re&Ee,S[28]=Be^~Ie&tt,S[29]=ce^~et&Pe,S[38]=ye^~Ue&me,S[39]=Ke^~$e&ze,S[48]=ar^~it&nt,S[49]=yt^~qe&Je,S[0]^=P[q],S[1]^=P[q+1]};if(f)r.exports=a;else for(b=0;b<c.length;++b)n[c[b]]=a[c[b]]})()})(eh);var wb=eh.exports;const _b="logger/5.7.0";let th=!1,rh=!1;const Gs={debug:1,default:2,info:2,warning:3,error:4,off:5};let ih=Gs.default,go=null;function xb(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(r){return r.message}return null}const nh=xb();var bo;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(bo||(bo={}));var Ir;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Ir||(Ir={}));const sh="0123456789abcdef";class Ve{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();Gs[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(ih>Gs[i])&&console.log.apply(console,t)}debug(...e){this._log(Ve.levels.DEBUG,e)}info(...e){this._log(Ve.levels.INFO,e)}warn(...e){this._log(Ve.levels.WARNING,e)}makeError(e,t,i){if(rh)return this.makeError("censored error",t,{});t||(t=Ve.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(u=>{const h=i[u];try{if(h instanceof Uint8Array){let g="";for(let y=0;y<h.length;y++)g+=sh[h[y]>>4],g+=sh[h[y]&15];n.push(u+"=Uint8Array(0x"+g+")")}else n.push(u+"="+JSON.stringify(h))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const s=e;let o="";switch(t){case Ir.NUMERIC_FAULT:{o="NUMERIC_FAULT";const u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Ir.CALL_EXCEPTION:case Ir.INSUFFICIENT_FUNDS:case Ir.MISSING_NEW:case Ir.NONCE_EXPIRED:case Ir.REPLACEMENT_UNDERPRICED:case Ir.TRANSACTION_REPLACED:case Ir.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,Ve.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){nh&&this.throwError("platform missing String.prototype.normalize",Ve.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:nh})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,Ve.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,Ve.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Ve.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return go||(go=new Ve(_b)),go}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),th){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}rh=!!e,th=!!t}static setLogLevel(e){const t=Gs[e.toLowerCase()];if(t==null){Ve.globalLogger().warn("invalid log level - "+e);return}ih=t}static from(e){return new Ve(e)}}Ve.errors=Ir,Ve.levels=bo;const Ab="bytes/5.7.0",vt=new Ve(Ab);function ah(r){return!!r.toHexString}function vn(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return vn(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function Eb(r){return fr(r)&&!(r.length%2)||mn(r)}function oh(r){return typeof r=="number"&&r==r&&r%1===0}function mn(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!oh(r.length)||r.length<0)return!1;for(let e=0;e<r.length;e++){const t=r[e];if(!oh(t)||t<0||t>=256)return!1}return!0}function lt(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),vn(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ah(r)&&(r=r.toHexString()),fr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":vt.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;n<t.length;n+=2)i.push(parseInt(t.substring(n,n+2),16));return vn(new Uint8Array(i))}return mn(r)?vn(new Uint8Array(r)):vt.throwArgumentError("invalid arrayify value","value",r)}function Sb(r){const e=r.map(n=>lt(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),vn(i)}function Mb(r,e){r=lt(r),r.length>e&&vt.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),vn(t)}function fr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const vo="0123456789abcdef";function Gt(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=vo[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ah(r))return r.toHexString();if(fr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":vt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(mn(r)){let t="0x";for(let i=0;i<r.length;i++){let n=r[i];t+=vo[(n&240)>>4]+vo[n&15]}return t}return vt.throwArgumentError("invalid hexlify value","value",r)}function Ib(r){if(typeof r!="string")r=Gt(r);else if(!fr(r)||r.length%2)return null;return(r.length-2)/2}function fh(r,e,t){return typeof r!="string"?r=Gt(r):(!fr(r)||r.length%2)&&vt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Lr(r,e){for(typeof r!="string"?r=Gt(r):fr(r)||vt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&vt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function ch(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Eb(r)){let t=lt(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Gt(t.slice(0,32)),e.s=Gt(t.slice(32,64))):t.length===65?(e.r=Gt(t.slice(0,32)),e.s=Gt(t.slice(32,64)),e.v=t[64]):vt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:vt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Gt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=Mb(lt(e._vs),32);e._vs=Gt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&vt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const o=Gt(n);e.s==null?e.s=o:e.s!==o&&vt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?vt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&vt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!fr(e.r)?vt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Lr(e.r,32),e.s==null||!fr(e.s)?vt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Lr(e.s,32);const t=lt(e.s);t[0]>=128&&vt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=Gt(t);e._vs&&(fr(e._vs)||vt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Lr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&vt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function mo(r){return"0x"+wb.keccak_256(lt(r))}var hh={exports:{}};(function(r){(function(e,t){function i(l,a){if(!l)throw new Error(a||"Assertion failed")}function n(l,a){l.super_=a;var c=function(){};c.prototype=a.prototype,l.prototype=new c,l.prototype.constructor=l}function s(l,a,c){if(s.isBN(l))return l;this.negative=0,this.words=null,this.length=0,this.red=null,l!==null&&((a==="le"||a==="be")&&(c=a,a=10),this._init(l||0,a||10,c||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Us.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,c){return a.cmp(c)>0?a:c},s.min=function(a,c){return a.cmp(c)<0?a:c},s.prototype._init=function(a,c,b){if(typeof a=="number")return this._initNumber(a,c,b);if(typeof a=="object")return this._initArray(a,c,b);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),a=a.toString().replace(/\s+/g,"");var A=0;a[0]==="-"&&(A++,this.negative=1),A<a.length&&(c===16?this._parseHex(a,A,b):(this._parseBase(a,c,A),b==="le"&&this._initArray(this.toArray(),c,b)))},s.prototype._initNumber=function(a,c,b){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),c,b)},s.prototype._initArray=function(a,c,b){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E,x,d=0;if(b==="be")for(A=a.length-1,E=0;A>=0;A-=3)x=a[A]|a[A-1]<<8|a[A-2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);else if(b==="le")for(A=0,E=0;A<a.length;A+=3)x=a[A]|a[A+1]<<8|a[A+2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);return this._strip()};function f(l,a){var c=l.charCodeAt(a);if(c>=48&&c<=57)return c-48;if(c>=65&&c<=70)return c-55;if(c>=97&&c<=102)return c-87;i(!1,"Invalid character in "+l)}function u(l,a,c){var b=f(l,c);return c-1>=a&&(b|=f(l,c-1)<<4),b}s.prototype._parseHex=function(a,c,b){this.length=Math.ceil((a.length-c)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E=0,x=0,d;if(b==="be")for(A=a.length-1;A>=c;A-=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8;else{var w=a.length-c;for(A=w%2===0?c+1:c;A<a.length;A+=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8}this._strip()};function h(l,a,c,b){for(var A=0,E=0,x=Math.min(l.length,c),d=a;d<x;d++){var w=l.charCodeAt(d)-48;A*=b,w>=49?E=w-49+10:w>=17?E=w-17+10:E=w,i(w>=0&&E<b,"Invalid character"),A+=E}return A}s.prototype._parseBase=function(a,c,b){this.words=[0],this.length=1;for(var A=0,E=1;E<=67108863;E*=c)A++;A--,E=E/c|0;for(var x=a.length-b,d=x%A,w=Math.min(x,x-d)+b,v=0,O=b;O<w;O+=A)v=h(a,O,O+A,c),this.imuln(E),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v);if(d!==0){var W=1;for(v=h(a,O,a.length,c),O=0;O<d;O++)W*=c;this.imuln(W),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var c=0;c<this.length;c++)a.words[c]=this.words[c];a.length=this.length,a.negative=this.negative,a.red=this.red};function g(l,a){l.words=a.words,l.length=a.length,l.negative=a.negative,l.red=a.red}if(s.prototype._move=function(a){g(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)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")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","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"],M=[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],D=[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(a,c){a=a||10,c=c|0||1;var b;if(a===16||a==="hex"){b="";for(var A=0,E=0,x=0;x<this.length;x++){var d=this.words[x],w=((d<<A|E)&16777215).toString(16);E=d>>>24-A&16777215,A+=2,A>=26&&(A-=26,x--),E!==0||x!==this.length-1?b=I[6-w.length]+w+b:b=w+b}for(E!==0&&(b=E.toString(16)+b);b.length%c!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(a===(a|0)&&a>=2&&a<=36){var v=M[a],O=D[a];b="";var W=this.clone();for(W.negative=0;!W.isZero();){var S=W.modrn(O).toString(a);W=W.idivn(O),W.isZero()?b=S+b:b=I[v-S.length]+S+b}for(this.isZero()&&(b="0"+b);b.length%c!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,c){return this.toArrayLike(o,a,c)}),s.prototype.toArray=function(a,c){return this.toArrayLike(Array,a,c)};var P=function(a,c){return a.allocUnsafe?a.allocUnsafe(c):new a(c)};s.prototype.toArrayLike=function(a,c,b){this._strip();var A=this.byteLength(),E=b||Math.max(1,A);i(A<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0");var x=P(a,E),d=c==="le"?"LE":"BE";return this["_toArrayLike"+d](x,A),x},s.prototype._toArrayLikeLE=function(a,c){for(var b=0,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b++]=d&255,b<a.length&&(a[b++]=d>>8&255),b<a.length&&(a[b++]=d>>16&255),x===6?(b<a.length&&(a[b++]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b<a.length)for(a[b++]=A;b<a.length;)a[b++]=0},s.prototype._toArrayLikeBE=function(a,c){for(var b=a.length-1,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b--]=d&255,b>=0&&(a[b--]=d>>8&255),b>=0&&(a[b--]=d>>16&255),x===6?(b>=0&&(a[b--]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b>=0)for(a[b--]=A;b>=0;)a[b--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var c=a,b=0;return c>=4096&&(b+=13,c>>>=13),c>=64&&(b+=7,c>>>=7),c>=8&&(b+=4,c>>>=4),c>=2&&(b+=2,c>>>=2),b+c},s.prototype._zeroBits=function(a){if(a===0)return 26;var c=a,b=0;return c&8191||(b+=13,c>>>=13),c&127||(b+=7,c>>>=7),c&15||(b+=4,c>>>=4),c&3||(b+=2,c>>>=2),c&1||b++,b},s.prototype.bitLength=function(){var a=this.words[this.length-1],c=this._countBits(a);return(this.length-1)*26+c};function k(l){for(var a=new Array(l.bitLength()),c=0;c<a.length;c++){var b=c/26|0,A=c%26;a[c]=l.words[b]>>>A&1}return a}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,c=0;c<this.length;c++){var b=this._zeroBits(this.words[c]);if(a+=b,b!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var c=0;c<a.length;c++)this.words[c]=this.words[c]|a.words[c];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var c;this.length>a.length?c=a:c=this;for(var b=0;b<c.length;b++)this.words[b]=this.words[b]&a.words[b];return this.length=c.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var c,b;this.length>a.length?(c=this,b=a):(c=a,b=this);for(var A=0;A<b.length;A++)this.words[A]=c.words[A]^b.words[A];if(this!==c)for(;A<c.length;A++)this.words[A]=c.words[A];return this.length=c.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var c=Math.ceil(a/26)|0,b=a%26;this._expand(c),b>0&&c--;for(var A=0;A<c;A++)this.words[A]=~this.words[A]&67108863;return b>0&&(this.words[A]=~this.words[A]&67108863>>26-b),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,c){i(typeof a=="number"&&a>=0);var b=a/26|0,A=a%26;return this._expand(b+1),c?this.words[b]=this.words[b]|1<<A:this.words[b]=this.words[b]&~(1<<A),this._strip()},s.prototype.iadd=function(a){var c;if(this.negative!==0&&a.negative===0)return this.negative=0,c=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,c=this.isub(a),a.negative=1,c._normSign();var b,A;this.length>a.length?(b=this,A=a):(b=a,A=this);for(var E=0,x=0;x<A.length;x++)c=(b.words[x]|0)+(A.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;for(;E!==0&&x<b.length;x++)c=(b.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;if(this.length=b.length,E!==0)this.words[this.length]=E,this.length++;else if(b!==this)for(;x<b.length;x++)this.words[x]=b.words[x];return this},s.prototype.add=function(a){var c;return a.negative!==0&&this.negative===0?(a.negative=0,c=this.sub(a),a.negative^=1,c):a.negative===0&&this.negative!==0?(this.negative=0,c=a.sub(this),this.negative=1,c):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var c=this.iadd(a);return a.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var b=this.cmp(a);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,E;b>0?(A=this,E=a):(A=a,E=this);for(var x=0,d=0;d<E.length;d++)c=(A.words[d]|0)-(E.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;for(;x!==0&&d<A.length;d++)c=(A.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;if(x===0&&d<A.length&&A!==this)for(;d<A.length;d++)this.words[d]=A.words[d];return this.length=Math.max(this.length,d),A!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function K(l,a,c){c.negative=a.negative^l.negative;var b=l.length+a.length|0;c.length=b,b=b-1|0;var A=l.words[0]|0,E=a.words[0]|0,x=A*E,d=x&67108863,w=x/67108864|0;c.words[0]=d;for(var v=1;v<b;v++){for(var O=w>>>26,W=w&67108863,S=Math.min(v,a.length-1),H=Math.max(0,v-l.length+1);H<=S;H++){var T=v-H|0;A=l.words[T]|0,E=a.words[H]|0,x=A*E+W,O+=x/67108864|0,W=x&67108863}c.words[v]=W|0,w=O|0}return w!==0?c.words[v]=w|0:c.length--,c._strip()}var C=function(a,c,b){var A=a.words,E=c.words,x=b.words,d=0,w,v,O,W=A[0]|0,S=W&8191,H=W>>>13,T=A[1]|0,q=T&8191,B=T>>>13,m=A[2]|0,L=m&8191,G=m>>>13,Y=A[3]|0,X=Y&8191,ee=Y>>>13,we=A[4]|0,Se=we&8191,he=we>>>13,Ne=A[5]|0,xe=Ne&8191,ae=Ne>>>13,ve=A[6]|0,le=ve&8191,ne=ve>>>13,ue=A[7]|0,fe=ue&8191,te=ue>>>13,pe=A[8]|0,_e=pe&8191,re=pe>>>13,Ae=A[9]|0,Ee=Ae&8191,oe=Ae>>>13,De=E[0]|0,Me=De&8191,Oe=De>>>13,We=E[1]|0,Qe=We&8191,Ie=We>>>13,et=E[2]|0,tt=et&8191,Pe=et>>>13,Te=E[3]|0,Ce=Te&8191,de=Te>>>13,Fe=E[4]|0,Be=Fe&8191,ce=Fe>>>13,Ue=E[5]|0,$e=Ue&8191,me=Ue>>>13,ze=E[6]|0,ke=ze&8191,ge=ze>>>13,Le=E[7]|0,Re=Le&8191,ye=Le>>>13,Ke=E[8]|0,it=Ke&8191,qe=Ke>>>13,nt=E[9]|0,Je=nt&8191,rt=nt>>>13;b.negative=a.negative^c.negative,b.length=19,w=Math.imul(S,Me),v=Math.imul(S,Oe),v=v+Math.imul(H,Me)|0,O=Math.imul(H,Oe);var ir=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ir>>>26)|0,ir&=67108863,w=Math.imul(q,Me),v=Math.imul(q,Oe),v=v+Math.imul(B,Me)|0,O=Math.imul(B,Oe),w=w+Math.imul(S,Qe)|0,v=v+Math.imul(S,Ie)|0,v=v+Math.imul(H,Qe)|0,O=O+Math.imul(H,Ie)|0;var nr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(nr>>>26)|0,nr&=67108863,w=Math.imul(L,Me),v=Math.imul(L,Oe),v=v+Math.imul(G,Me)|0,O=Math.imul(G,Oe),w=w+Math.imul(q,Qe)|0,v=v+Math.imul(q,Ie)|0,v=v+Math.imul(B,Qe)|0,O=O+Math.imul(B,Ie)|0,w=w+Math.imul(S,tt)|0,v=v+Math.imul(S,Pe)|0,v=v+Math.imul(H,tt)|0,O=O+Math.imul(H,Pe)|0;var sr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(sr>>>26)|0,sr&=67108863,w=Math.imul(X,Me),v=Math.imul(X,Oe),v=v+Math.imul(ee,Me)|0,O=Math.imul(ee,Oe),w=w+Math.imul(L,Qe)|0,v=v+Math.imul(L,Ie)|0,v=v+Math.imul(G,Qe)|0,O=O+Math.imul(G,Ie)|0,w=w+Math.imul(q,tt)|0,v=v+Math.imul(q,Pe)|0,v=v+Math.imul(B,tt)|0,O=O+Math.imul(B,Pe)|0,w=w+Math.imul(S,Ce)|0,v=v+Math.imul(S,de)|0,v=v+Math.imul(H,Ce)|0,O=O+Math.imul(H,de)|0;var ar=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ar>>>26)|0,ar&=67108863,w=Math.imul(Se,Me),v=Math.imul(Se,Oe),v=v+Math.imul(he,Me)|0,O=Math.imul(he,Oe),w=w+Math.imul(X,Qe)|0,v=v+Math.imul(X,Ie)|0,v=v+Math.imul(ee,Qe)|0,O=O+Math.imul(ee,Ie)|0,w=w+Math.imul(L,tt)|0,v=v+Math.imul(L,Pe)|0,v=v+Math.imul(G,tt)|0,O=O+Math.imul(G,Pe)|0,w=w+Math.imul(q,Ce)|0,v=v+Math.imul(q,de)|0,v=v+Math.imul(B,Ce)|0,O=O+Math.imul(B,de)|0,w=w+Math.imul(S,Be)|0,v=v+Math.imul(S,ce)|0,v=v+Math.imul(H,Be)|0,O=O+Math.imul(H,ce)|0;var yt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yt>>>26)|0,yt&=67108863,w=Math.imul(xe,Me),v=Math.imul(xe,Oe),v=v+Math.imul(ae,Me)|0,O=Math.imul(ae,Oe),w=w+Math.imul(Se,Qe)|0,v=v+Math.imul(Se,Ie)|0,v=v+Math.imul(he,Qe)|0,O=O+Math.imul(he,Ie)|0,w=w+Math.imul(X,tt)|0,v=v+Math.imul(X,Pe)|0,v=v+Math.imul(ee,tt)|0,O=O+Math.imul(ee,Pe)|0,w=w+Math.imul(L,Ce)|0,v=v+Math.imul(L,de)|0,v=v+Math.imul(G,Ce)|0,O=O+Math.imul(G,de)|0,w=w+Math.imul(q,Be)|0,v=v+Math.imul(q,ce)|0,v=v+Math.imul(B,Be)|0,O=O+Math.imul(B,ce)|0,w=w+Math.imul(S,$e)|0,v=v+Math.imul(S,me)|0,v=v+Math.imul(H,$e)|0,O=O+Math.imul(H,me)|0;var ui=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ui>>>26)|0,ui&=67108863,w=Math.imul(le,Me),v=Math.imul(le,Oe),v=v+Math.imul(ne,Me)|0,O=Math.imul(ne,Oe),w=w+Math.imul(xe,Qe)|0,v=v+Math.imul(xe,Ie)|0,v=v+Math.imul(ae,Qe)|0,O=O+Math.imul(ae,Ie)|0,w=w+Math.imul(Se,tt)|0,v=v+Math.imul(Se,Pe)|0,v=v+Math.imul(he,tt)|0,O=O+Math.imul(he,Pe)|0,w=w+Math.imul(X,Ce)|0,v=v+Math.imul(X,de)|0,v=v+Math.imul(ee,Ce)|0,O=O+Math.imul(ee,de)|0,w=w+Math.imul(L,Be)|0,v=v+Math.imul(L,ce)|0,v=v+Math.imul(G,Be)|0,O=O+Math.imul(G,ce)|0,w=w+Math.imul(q,$e)|0,v=v+Math.imul(q,me)|0,v=v+Math.imul(B,$e)|0,O=O+Math.imul(B,me)|0,w=w+Math.imul(S,ke)|0,v=v+Math.imul(S,ge)|0,v=v+Math.imul(H,ke)|0,O=O+Math.imul(H,ge)|0;var di=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(di>>>26)|0,di&=67108863,w=Math.imul(fe,Me),v=Math.imul(fe,Oe),v=v+Math.imul(te,Me)|0,O=Math.imul(te,Oe),w=w+Math.imul(le,Qe)|0,v=v+Math.imul(le,Ie)|0,v=v+Math.imul(ne,Qe)|0,O=O+Math.imul(ne,Ie)|0,w=w+Math.imul(xe,tt)|0,v=v+Math.imul(xe,Pe)|0,v=v+Math.imul(ae,tt)|0,O=O+Math.imul(ae,Pe)|0,w=w+Math.imul(Se,Ce)|0,v=v+Math.imul(Se,de)|0,v=v+Math.imul(he,Ce)|0,O=O+Math.imul(he,de)|0,w=w+Math.imul(X,Be)|0,v=v+Math.imul(X,ce)|0,v=v+Math.imul(ee,Be)|0,O=O+Math.imul(ee,ce)|0,w=w+Math.imul(L,$e)|0,v=v+Math.imul(L,me)|0,v=v+Math.imul(G,$e)|0,O=O+Math.imul(G,me)|0,w=w+Math.imul(q,ke)|0,v=v+Math.imul(q,ge)|0,v=v+Math.imul(B,ke)|0,O=O+Math.imul(B,ge)|0,w=w+Math.imul(S,Re)|0,v=v+Math.imul(S,ye)|0,v=v+Math.imul(H,Re)|0,O=O+Math.imul(H,ye)|0;var li=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(li>>>26)|0,li&=67108863,w=Math.imul(_e,Me),v=Math.imul(_e,Oe),v=v+Math.imul(re,Me)|0,O=Math.imul(re,Oe),w=w+Math.imul(fe,Qe)|0,v=v+Math.imul(fe,Ie)|0,v=v+Math.imul(te,Qe)|0,O=O+Math.imul(te,Ie)|0,w=w+Math.imul(le,tt)|0,v=v+Math.imul(le,Pe)|0,v=v+Math.imul(ne,tt)|0,O=O+Math.imul(ne,Pe)|0,w=w+Math.imul(xe,Ce)|0,v=v+Math.imul(xe,de)|0,v=v+Math.imul(ae,Ce)|0,O=O+Math.imul(ae,de)|0,w=w+Math.imul(Se,Be)|0,v=v+Math.imul(Se,ce)|0,v=v+Math.imul(he,Be)|0,O=O+Math.imul(he,ce)|0,w=w+Math.imul(X,$e)|0,v=v+Math.imul(X,me)|0,v=v+Math.imul(ee,$e)|0,O=O+Math.imul(ee,me)|0,w=w+Math.imul(L,ke)|0,v=v+Math.imul(L,ge)|0,v=v+Math.imul(G,ke)|0,O=O+Math.imul(G,ge)|0,w=w+Math.imul(q,Re)|0,v=v+Math.imul(q,ye)|0,v=v+Math.imul(B,Re)|0,O=O+Math.imul(B,ye)|0,w=w+Math.imul(S,it)|0,v=v+Math.imul(S,qe)|0,v=v+Math.imul(H,it)|0,O=O+Math.imul(H,qe)|0;var pi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(pi>>>26)|0,pi&=67108863,w=Math.imul(Ee,Me),v=Math.imul(Ee,Oe),v=v+Math.imul(oe,Me)|0,O=Math.imul(oe,Oe),w=w+Math.imul(_e,Qe)|0,v=v+Math.imul(_e,Ie)|0,v=v+Math.imul(re,Qe)|0,O=O+Math.imul(re,Ie)|0,w=w+Math.imul(fe,tt)|0,v=v+Math.imul(fe,Pe)|0,v=v+Math.imul(te,tt)|0,O=O+Math.imul(te,Pe)|0,w=w+Math.imul(le,Ce)|0,v=v+Math.imul(le,de)|0,v=v+Math.imul(ne,Ce)|0,O=O+Math.imul(ne,de)|0,w=w+Math.imul(xe,Be)|0,v=v+Math.imul(xe,ce)|0,v=v+Math.imul(ae,Be)|0,O=O+Math.imul(ae,ce)|0,w=w+Math.imul(Se,$e)|0,v=v+Math.imul(Se,me)|0,v=v+Math.imul(he,$e)|0,O=O+Math.imul(he,me)|0,w=w+Math.imul(X,ke)|0,v=v+Math.imul(X,ge)|0,v=v+Math.imul(ee,ke)|0,O=O+Math.imul(ee,ge)|0,w=w+Math.imul(L,Re)|0,v=v+Math.imul(L,ye)|0,v=v+Math.imul(G,Re)|0,O=O+Math.imul(G,ye)|0,w=w+Math.imul(q,it)|0,v=v+Math.imul(q,qe)|0,v=v+Math.imul(B,it)|0,O=O+Math.imul(B,qe)|0,w=w+Math.imul(S,Je)|0,v=v+Math.imul(S,rt)|0,v=v+Math.imul(H,Je)|0,O=O+Math.imul(H,rt)|0;var gi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(gi>>>26)|0,gi&=67108863,w=Math.imul(Ee,Qe),v=Math.imul(Ee,Ie),v=v+Math.imul(oe,Qe)|0,O=Math.imul(oe,Ie),w=w+Math.imul(_e,tt)|0,v=v+Math.imul(_e,Pe)|0,v=v+Math.imul(re,tt)|0,O=O+Math.imul(re,Pe)|0,w=w+Math.imul(fe,Ce)|0,v=v+Math.imul(fe,de)|0,v=v+Math.imul(te,Ce)|0,O=O+Math.imul(te,de)|0,w=w+Math.imul(le,Be)|0,v=v+Math.imul(le,ce)|0,v=v+Math.imul(ne,Be)|0,O=O+Math.imul(ne,ce)|0,w=w+Math.imul(xe,$e)|0,v=v+Math.imul(xe,me)|0,v=v+Math.imul(ae,$e)|0,O=O+Math.imul(ae,me)|0,w=w+Math.imul(Se,ke)|0,v=v+Math.imul(Se,ge)|0,v=v+Math.imul(he,ke)|0,O=O+Math.imul(he,ge)|0,w=w+Math.imul(X,Re)|0,v=v+Math.imul(X,ye)|0,v=v+Math.imul(ee,Re)|0,O=O+Math.imul(ee,ye)|0,w=w+Math.imul(L,it)|0,v=v+Math.imul(L,qe)|0,v=v+Math.imul(G,it)|0,O=O+Math.imul(G,qe)|0,w=w+Math.imul(q,Je)|0,v=v+Math.imul(q,rt)|0,v=v+Math.imul(B,Je)|0,O=O+Math.imul(B,rt)|0;var Er=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(Er>>>26)|0,Er&=67108863,w=Math.imul(Ee,tt),v=Math.imul(Ee,Pe),v=v+Math.imul(oe,tt)|0,O=Math.imul(oe,Pe),w=w+Math.imul(_e,Ce)|0,v=v+Math.imul(_e,de)|0,v=v+Math.imul(re,Ce)|0,O=O+Math.imul(re,de)|0,w=w+Math.imul(fe,Be)|0,v=v+Math.imul(fe,ce)|0,v=v+Math.imul(te,Be)|0,O=O+Math.imul(te,ce)|0,w=w+Math.imul(le,$e)|0,v=v+Math.imul(le,me)|0,v=v+Math.imul(ne,$e)|0,O=O+Math.imul(ne,me)|0,w=w+Math.imul(xe,ke)|0,v=v+Math.imul(xe,ge)|0,v=v+Math.imul(ae,ke)|0,O=O+Math.imul(ae,ge)|0,w=w+Math.imul(Se,Re)|0,v=v+Math.imul(Se,ye)|0,v=v+Math.imul(he,Re)|0,O=O+Math.imul(he,ye)|0,w=w+Math.imul(X,it)|0,v=v+Math.imul(X,qe)|0,v=v+Math.imul(ee,it)|0,O=O+Math.imul(ee,qe)|0,w=w+Math.imul(L,Je)|0,v=v+Math.imul(L,rt)|0,v=v+Math.imul(G,Je)|0,O=O+Math.imul(G,rt)|0;var bi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(bi>>>26)|0,bi&=67108863,w=Math.imul(Ee,Ce),v=Math.imul(Ee,de),v=v+Math.imul(oe,Ce)|0,O=Math.imul(oe,de),w=w+Math.imul(_e,Be)|0,v=v+Math.imul(_e,ce)|0,v=v+Math.imul(re,Be)|0,O=O+Math.imul(re,ce)|0,w=w+Math.imul(fe,$e)|0,v=v+Math.imul(fe,me)|0,v=v+Math.imul(te,$e)|0,O=O+Math.imul(te,me)|0,w=w+Math.imul(le,ke)|0,v=v+Math.imul(le,ge)|0,v=v+Math.imul(ne,ke)|0,O=O+Math.imul(ne,ge)|0,w=w+Math.imul(xe,Re)|0,v=v+Math.imul(xe,ye)|0,v=v+Math.imul(ae,Re)|0,O=O+Math.imul(ae,ye)|0,w=w+Math.imul(Se,it)|0,v=v+Math.imul(Se,qe)|0,v=v+Math.imul(he,it)|0,O=O+Math.imul(he,qe)|0,w=w+Math.imul(X,Je)|0,v=v+Math.imul(X,rt)|0,v=v+Math.imul(ee,Je)|0,O=O+Math.imul(ee,rt)|0;var vi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(vi>>>26)|0,vi&=67108863,w=Math.imul(Ee,Be),v=Math.imul(Ee,ce),v=v+Math.imul(oe,Be)|0,O=Math.imul(oe,ce),w=w+Math.imul(_e,$e)|0,v=v+Math.imul(_e,me)|0,v=v+Math.imul(re,$e)|0,O=O+Math.imul(re,me)|0,w=w+Math.imul(fe,ke)|0,v=v+Math.imul(fe,ge)|0,v=v+Math.imul(te,ke)|0,O=O+Math.imul(te,ge)|0,w=w+Math.imul(le,Re)|0,v=v+Math.imul(le,ye)|0,v=v+Math.imul(ne,Re)|0,O=O+Math.imul(ne,ye)|0,w=w+Math.imul(xe,it)|0,v=v+Math.imul(xe,qe)|0,v=v+Math.imul(ae,it)|0,O=O+Math.imul(ae,qe)|0,w=w+Math.imul(Se,Je)|0,v=v+Math.imul(Se,rt)|0,v=v+Math.imul(he,Je)|0,O=O+Math.imul(he,rt)|0;var jt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(jt>>>26)|0,jt&=67108863,w=Math.imul(Ee,$e),v=Math.imul(Ee,me),v=v+Math.imul(oe,$e)|0,O=Math.imul(oe,me),w=w+Math.imul(_e,ke)|0,v=v+Math.imul(_e,ge)|0,v=v+Math.imul(re,ke)|0,O=O+Math.imul(re,ge)|0,w=w+Math.imul(fe,Re)|0,v=v+Math.imul(fe,ye)|0,v=v+Math.imul(te,Re)|0,O=O+Math.imul(te,ye)|0,w=w+Math.imul(le,it)|0,v=v+Math.imul(le,qe)|0,v=v+Math.imul(ne,it)|0,O=O+Math.imul(ne,qe)|0,w=w+Math.imul(xe,Je)|0,v=v+Math.imul(xe,rt)|0,v=v+Math.imul(ae,Je)|0,O=O+Math.imul(ae,rt)|0;var mi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(mi>>>26)|0,mi&=67108863,w=Math.imul(Ee,ke),v=Math.imul(Ee,ge),v=v+Math.imul(oe,ke)|0,O=Math.imul(oe,ge),w=w+Math.imul(_e,Re)|0,v=v+Math.imul(_e,ye)|0,v=v+Math.imul(re,Re)|0,O=O+Math.imul(re,ye)|0,w=w+Math.imul(fe,it)|0,v=v+Math.imul(fe,qe)|0,v=v+Math.imul(te,it)|0,O=O+Math.imul(te,qe)|0,w=w+Math.imul(le,Je)|0,v=v+Math.imul(le,rt)|0,v=v+Math.imul(ne,Je)|0,O=O+Math.imul(ne,rt)|0;var yi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yi>>>26)|0,yi&=67108863,w=Math.imul(Ee,Re),v=Math.imul(Ee,ye),v=v+Math.imul(oe,Re)|0,O=Math.imul(oe,ye),w=w+Math.imul(_e,it)|0,v=v+Math.imul(_e,qe)|0,v=v+Math.imul(re,it)|0,O=O+Math.imul(re,qe)|0,w=w+Math.imul(fe,Je)|0,v=v+Math.imul(fe,rt)|0,v=v+Math.imul(te,Je)|0,O=O+Math.imul(te,rt)|0;var wi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(wi>>>26)|0,wi&=67108863,w=Math.imul(Ee,it),v=Math.imul(Ee,qe),v=v+Math.imul(oe,it)|0,O=Math.imul(oe,qe),w=w+Math.imul(_e,Je)|0,v=v+Math.imul(_e,rt)|0,v=v+Math.imul(re,Je)|0,O=O+Math.imul(re,rt)|0;var _s=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(_s>>>26)|0,_s&=67108863,w=Math.imul(Ee,Je),v=Math.imul(Ee,rt),v=v+Math.imul(oe,Je)|0,O=Math.imul(oe,rt);var xs=(d+w|0)+((v&8191)<<13)|0;return d=(O+(v>>>13)|0)+(xs>>>26)|0,xs&=67108863,x[0]=ir,x[1]=nr,x[2]=sr,x[3]=ar,x[4]=yt,x[5]=ui,x[6]=di,x[7]=li,x[8]=pi,x[9]=gi,x[10]=Er,x[11]=bi,x[12]=vi,x[13]=jt,x[14]=mi,x[15]=yi,x[16]=wi,x[17]=_s,x[18]=xs,d!==0&&(x[19]=d,b.length++),b};Math.imul||(C=K);function j(l,a,c){c.negative=a.negative^l.negative,c.length=l.length+a.length;for(var b=0,A=0,E=0;E<c.length-1;E++){var x=A;A=0;for(var d=b&67108863,w=Math.min(E,a.length-1),v=Math.max(0,E-l.length+1);v<=w;v++){var O=E-v,W=l.words[O]|0,S=a.words[v]|0,H=W*S,T=H&67108863;x=x+(H/67108864|0)|0,T=T+d|0,d=T&67108863,x=x+(T>>>26)|0,A+=x>>>26,x&=67108863}c.words[E]=d,b=x,x=A}return b!==0?c.words[E]=b:c.length--,c._strip()}function F(l,a,c){return j(l,a,c)}s.prototype.mulTo=function(a,c){var b,A=this.length+a.length;return this.length===10&&a.length===10?b=C(this,a,c):A<63?b=K(this,a,c):A<1024?b=j(this,a,c):b=F(this,a,c),b},s.prototype.mul=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),this.mulTo(a,c)},s.prototype.mulf=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),F(this,a,c)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var c=a<0;c&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var b=0,A=0;A<this.length;A++){var E=(this.words[A]|0)*a,x=(E&67108863)+(b&67108863);b>>=26,b+=E/67108864|0,b+=x>>>26,this.words[A]=x&67108863}return b!==0&&(this.words[A]=b,this.length++),c?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var c=k(a);if(c.length===0)return new s(1);for(var b=this,A=0;A<c.length&&c[A]===0;A++,b=b.sqr());if(++A<c.length)for(var E=b.sqr();A<c.length;A++,E=E.sqr())c[A]!==0&&(b=b.mul(E));return b},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=67108863>>>26-c<<26-c,E;if(c!==0){var x=0;for(E=0;E<this.length;E++){var d=this.words[E]&A,w=(this.words[E]|0)-d<<c;this.words[E]=w|x,x=d>>>26-c}x&&(this.words[E]=x,this.length++)}if(b!==0){for(E=this.length-1;E>=0;E--)this.words[E+b]=this.words[E];for(E=0;E<b;E++)this.words[E]=0;this.length+=b}return this._strip()},s.prototype.ishln=function(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,c,b){i(typeof a=="number"&&a>=0);var A;c?A=(c-c%26)/26:A=0;var E=a%26,x=Math.min((a-E)/26,this.length),d=67108863^67108863>>>E<<E,w=b;if(A-=x,A=Math.max(0,A),w){for(var v=0;v<x;v++)w.words[v]=this.words[v];w.length=x}if(x!==0)if(this.length>x)for(this.length-=x,v=0;v<this.length;v++)this.words[v]=this.words[v+x];else this.words[0]=0,this.length=1;var O=0;for(v=this.length-1;v>=0&&(O!==0||v>=A);v--){var W=this.words[v]|0;this.words[v]=O<<26-E|W>>>E,O=W&d}return w&&O!==0&&(w.words[w.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,c,b){return i(this.negative===0),this.iushrn(a,c,b)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return!1;var E=this.words[b];return!!(E&A)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(c!==0&&b++,this.length=Math.min(b,this.length),c!==0){var A=67108863^67108863>>>c<<c;this.words[this.length-1]&=A}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var c=0;c<this.length&&this.words[c]>=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c<this.length&&this.words[c]<0;c++)this.words[c]+=67108864,this.words[c+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,c,b){var A=a.length+b,E;this._expand(A);var x,d=0;for(E=0;E<a.length;E++){x=(this.words[E+b]|0)+d;var w=(a.words[E]|0)*c;x-=w&67108863,d=(x>>26)-(w/67108864|0),this.words[E+b]=x&67108863}for(;E<this.length-b;E++)x=(this.words[E+b]|0)+d,d=x>>26,this.words[E+b]=x&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,E=0;E<this.length;E++)x=-(this.words[E]|0)+d,d=x>>26,this.words[E]=x&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,c){var b=this.length-a.length,A=this.clone(),E=a,x=E.words[E.length-1]|0,d=this._countBits(x);b=26-d,b!==0&&(E=E.ushln(b),A.iushln(b),x=E.words[E.length-1]|0);var w=A.length-E.length,v;if(c!=="mod"){v=new s(null),v.length=w+1,v.words=new Array(v.length);for(var O=0;O<v.length;O++)v.words[O]=0}var W=A.clone()._ishlnsubmul(E,1,w);W.negative===0&&(A=W,v&&(v.words[w]=1));for(var S=w-1;S>=0;S--){var H=(A.words[E.length+S]|0)*67108864+(A.words[E.length+S-1]|0);for(H=Math.min(H/x|0,67108863),A._ishlnsubmul(E,H,S);A.negative!==0;)H--,A.negative=0,A._ishlnsubmul(E,1,S),A.isZero()||(A.negative^=1);v&&(v.words[S]=H)}return v&&v._strip(),A._strip(),c!=="div"&&b!==0&&A.iushrn(b),{div:v||null,mod:A}},s.prototype.divmod=function(a,c,b){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var A,E,x;return this.negative!==0&&a.negative===0?(x=this.neg().divmod(a,c),c!=="mod"&&(A=x.div.neg()),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.iadd(a)),{div:A,mod:E}):this.negative===0&&a.negative!==0?(x=this.divmod(a.neg(),c),c!=="mod"&&(A=x.div.neg()),{div:A,mod:x.mod}):this.negative&a.negative?(x=this.neg().divmod(a.neg(),c),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.isub(a)),{div:x.div,mod:E}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?c==="div"?{div:this.divn(a.words[0]),mod:null}:c==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,c)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var c=this.divmod(a);if(c.mod.isZero())return c.div;var b=c.div.negative!==0?c.mod.isub(a):c.mod,A=a.ushrn(1),E=a.andln(1),x=b.cmp(A);return x<0||E===1&&x===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},s.prototype.modrn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=(1<<26)%a,A=0,E=this.length-1;E>=0;E--)A=(b*A+(this.words[E]|0))%a;return c?-A:A},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=0,A=this.length-1;A>=0;A--){var E=(this.words[A]|0)+b*67108864;this.words[A]=E/a|0,b=E%a}return this._strip(),c?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=new s(0),d=new s(1),w=0;c.isEven()&&b.isEven();)c.iushrn(1),b.iushrn(1),++w;for(var v=b.clone(),O=c.clone();!c.isZero();){for(var W=0,S=1;!(c.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(c.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(v),E.isub(O)),A.iushrn(1),E.iushrn(1);for(var H=0,T=1;!(b.words[0]&T)&&H<26;++H,T<<=1);if(H>0)for(b.iushrn(H);H-- >0;)(x.isOdd()||d.isOdd())&&(x.iadd(v),d.isub(O)),x.iushrn(1),d.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(x),E.isub(d)):(b.isub(c),x.isub(A),d.isub(E))}return{a:x,b:d,gcd:b.iushln(w)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=b.clone();c.cmpn(1)>0&&b.cmpn(1)>0;){for(var d=0,w=1;!(c.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(c.iushrn(d);d-- >0;)A.isOdd()&&A.iadd(x),A.iushrn(1);for(var v=0,O=1;!(b.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(b.iushrn(v);v-- >0;)E.isOdd()&&E.iadd(x),E.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(E)):(b.isub(c),E.isub(A))}var W;return c.cmpn(1)===0?W=A:W=E,W.cmpn(0)<0&&W.iadd(a),W},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var c=this.clone(),b=a.clone();c.negative=0,b.negative=0;for(var A=0;c.isEven()&&b.isEven();A++)c.iushrn(1),b.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;b.isEven();)b.iushrn(1);var E=c.cmp(b);if(E<0){var x=c;c=b,b=x}else if(E===0||b.cmpn(1)===0)break;c.isub(b)}while(!0);return b.iushln(A)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return this._expand(b+1),this.words[b]|=A,this;for(var E=A,x=b;E!==0&&x<this.length;x++){var d=this.words[x]|0;d+=E,E=d>>>26,d&=67108863,this.words[x]=d}return E!==0&&(this.words[x]=E,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var c=a<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this._strip();var b;if(this.length>1)b=1;else{c&&(a=-a),i(a<=67108863,"Number is too big");var A=this.words[0]|0;b=A===a?0:A<a?-1:1}return this.negative!==0?-b|0:b},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var c=this.ucmp(a);return this.negative!==0?-c|0:c},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var c=0,b=this.length-1;b>=0;b--){var A=this.words[b]|0,E=a.words[b]|0;if(A!==E){A<E?c=-1:A>E&&(c=1);break}}return c},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new N(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var U={k256:null,p224:null,p192:null,p25519:null};function z(l,a){this.name=l,this.p=new s(a,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 a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},z.prototype.ireduce=function(a){var c=a,b;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),b=c.bitLength();while(b>this.n);var A=b<this.n?-1:c.ucmp(this.p);return A===0?(c.words[0]=0,c.length=1):A>0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},z.prototype.split=function(a,c){a.iushrn(this.n,0,c)},z.prototype.imulK=function(a){return a.imul(this.k)};function _(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(_,z),_.prototype.split=function(a,c){for(var b=4194303,A=Math.min(a.length,9),E=0;E<A;E++)c.words[E]=a.words[E];if(c.length=A,a.length<=9){a.words[0]=0,a.length=1;return}var x=a.words[9];for(c.words[c.length++]=x&b,E=10;E<a.length;E++){var d=a.words[E]|0;a.words[E-10]=(d&b)<<4|x>>>22,x=d}x>>>=22,a.words[E-10]=x,x===0&&a.length>10?a.length-=10:a.length-=9},_.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var c=0,b=0;b<a.length;b++){var A=a.words[b]|0;c+=A*977,a.words[b]=c&67108863,c=A*64+(c/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function R(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(R,z);function J(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(J,z);function Q(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,z),Q.prototype.imulK=function(a){for(var c=0,b=0;b<a.length;b++){var A=(a.words[b]|0)*19+c,E=A&67108863;A>>>=26,a.words[b]=E,c=A}return c!==0&&(a.words[a.length++]=c),a},s._prime=function(a){if(U[a])return U[a];var c;if(a==="k256")c=new _;else if(a==="p224")c=new R;else if(a==="p192")c=new J;else if(a==="p25519")c=new Q;else throw new Error("Unknown prime "+a);return U[a]=c,c};function N(l){if(typeof l=="string"){var a=s._prime(l);this.m=a.p,this.prime=a}else i(l.gtn(1),"modulus must be greater than 1"),this.m=l,this.prime=null}N.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},N.prototype._verify2=function(a,c){i((a.negative|c.negative)===0,"red works only with positives"),i(a.red&&a.red===c.red,"red works only with red numbers")},N.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(g(a,a.umod(this.m)._forceRed(this)),a)},N.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},N.prototype.add=function(a,c){this._verify2(a,c);var b=a.add(c);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},N.prototype.iadd=function(a,c){this._verify2(a,c);var b=a.iadd(c);return b.cmp(this.m)>=0&&b.isub(this.m),b},N.prototype.sub=function(a,c){this._verify2(a,c);var b=a.sub(c);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},N.prototype.isub=function(a,c){this._verify2(a,c);var b=a.isub(c);return b.cmpn(0)<0&&b.iadd(this.m),b},N.prototype.shl=function(a,c){return this._verify1(a),this.imod(a.ushln(c))},N.prototype.imul=function(a,c){return this._verify2(a,c),this.imod(a.imul(c))},N.prototype.mul=function(a,c){return this._verify2(a,c),this.imod(a.mul(c))},N.prototype.isqr=function(a){return this.imul(a,a.clone())},N.prototype.sqr=function(a){return this.mul(a,a)},N.prototype.sqrt=function(a){if(a.isZero())return a.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var b=this.m.add(new s(1)).iushrn(2);return this.pow(a,b)}for(var A=this.m.subn(1),E=0;!A.isZero()&&A.andln(1)===0;)E++,A.iushrn(1);i(!A.isZero());var x=new s(1).toRed(this),d=x.redNeg(),w=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new s(2*v*v).toRed(this);this.pow(v,w).cmp(d)!==0;)v.redIAdd(d);for(var O=this.pow(v,A),W=this.pow(a,A.addn(1).iushrn(1)),S=this.pow(a,A),H=E;S.cmp(x)!==0;){for(var T=S,q=0;T.cmp(x)!==0;q++)T=T.redSqr();i(q<H);var B=this.pow(O,new s(1).iushln(H-q-1));W=W.redMul(B),O=B.redSqr(),S=S.redMul(O),H=q}return W},N.prototype.invm=function(a){var c=a._invmp(this.m);return c.negative!==0?(c.negative=0,this.imod(c).redNeg()):this.imod(c)},N.prototype.pow=function(a,c){if(c.isZero())return new s(1).toRed(this);if(c.cmpn(1)===0)return a.clone();var b=4,A=new Array(1<<b);A[0]=new s(1).toRed(this),A[1]=a;for(var E=2;E<A.length;E++)A[E]=this.mul(A[E-1],a);var x=A[0],d=0,w=0,v=c.bitLength()%26;for(v===0&&(v=26),E=c.length-1;E>=0;E--){for(var O=c.words[E],W=v-1;W>=0;W--){var S=O>>W&1;if(x!==A[0]&&(x=this.sqr(x)),S===0&&d===0){w=0;continue}d<<=1,d|=S,w++,!(w!==b&&(E!==0||W!==0))&&(x=this.mul(x,A[d]),w=0,d=0)}v=26}return x},N.prototype.convertTo=function(a){var c=a.umod(this.m);return c===a?c.clone():c},N.prototype.convertFrom=function(a){var c=a.clone();return c.red=null,c},s.mont=function(a){return new p(a)};function p(l){N.call(this,l),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)}n(p,N),p.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},p.prototype.convertFrom=function(a){var c=this.imod(a.mul(this.rinv));return c.red=null,c},p.prototype.imul=function(a,c){if(a.isZero()||c.isZero())return a.words[0]=0,a.length=1,a;var b=a.imul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.mul=function(a,c){if(a.isZero()||c.isZero())return new s(0)._forceRed(this);var b=a.mul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.invm=function(a){var c=this.imod(a._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,Pt)})(hh);var je=hh.exports;const uh="bignumber/5.7.0";var Ws=je.BN;const ei=new Ve(uh),yo={},dh=9007199254740991;function Db(r){return r!=null&&(ot.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||fr(r)||typeof r=="bigint"||mn(r))}let lh=!1;class ot{constructor(e,t){e!==yo&&ei.throwError("cannot call constructor directly; use BigNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Zt(Xe(this).fromTwos(e))}toTwos(e){return Zt(Xe(this).toTwos(e))}abs(){return this._hex[0]==="-"?ot.from(this._hex.substring(1)):this}add(e){return Zt(Xe(this).add(Xe(e)))}sub(e){return Zt(Xe(this).sub(Xe(e)))}div(e){return ot.from(e).isZero()&&pr("division-by-zero","div"),Zt(Xe(this).div(Xe(e)))}mul(e){return Zt(Xe(this).mul(Xe(e)))}mod(e){const t=Xe(e);return t.isNeg()&&pr("division-by-zero","mod"),Zt(Xe(this).umod(t))}pow(e){const t=Xe(e);return t.isNeg()&&pr("negative-power","pow"),Zt(Xe(this).pow(t))}and(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","and"),Zt(Xe(this).and(t))}or(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","or"),Zt(Xe(this).or(t))}xor(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","xor"),Zt(Xe(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&pr("negative-width","mask"),Zt(Xe(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&pr("negative-width","shl"),Zt(Xe(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&pr("negative-width","shr"),Zt(Xe(this).shrn(e))}eq(e){return Xe(this).eq(Xe(e))}lt(e){return Xe(this).lt(Xe(e))}lte(e){return Xe(this).lte(Xe(e))}gt(e){return Xe(this).gt(Xe(e))}gte(e){return Xe(this).gte(Xe(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Xe(this).isZero()}toNumber(){try{return Xe(this).toNumber()}catch{pr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return ei.throwError("this platform does not support BigInt",Ve.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?lh||(lh=!0,ei.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?ei.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ve.errors.UNEXPECTED_ARGUMENT,{}):ei.throwError("BigNumber.toString does not accept parameters",Ve.errors.UNEXPECTED_ARGUMENT,{})),Xe(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof ot)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new ot(yo,Gn(e)):e.match(/^-?[0-9]+$/)?new ot(yo,Gn(new Ws(e))):ei.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&pr("underflow","BigNumber.from",e),(e>=dh||e<=-dh)&&pr("overflow","BigNumber.from",e),ot.from(String(e));const t=e;if(typeof t=="bigint")return ot.from(t.toString());if(mn(t))return ot.from(Gt(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return ot.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(fr(i)||i[0]==="-"&&fr(i.substring(1))))return ot.from(i)}return ei.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function Gn(r){if(typeof r!="string")return Gn(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&ei.throwArgumentError("invalid hex","value",r),r=Gn(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function Zt(r){return ot.from(Gn(r))}function Xe(r){const e=ot.from(r).toHexString();return e[0]==="-"?new Ws("-"+e.substring(3),16):new Ws(e.substring(2),16)}function pr(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),ei.throwError(r,Ve.errors.NUMERIC_FAULT,i)}function Ob(r){return new Ws(r,36).toString(16)}const Wt=new Ve(uh),Wn={},ph=ot.from(0),gh=ot.from(-1);function bh(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Wt.throwError(r,Ve.errors.NUMERIC_FAULT,n)}let Jn="0";for(;Jn.length<256;)Jn+=Jn;function wo(r){if(typeof r!="number")try{r=ot.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Jn.substring(0,r):Wt.throwArgumentError("invalid decimal size","decimals",r)}function _o(r,e){e==null&&(e=0);const t=wo(e);r=ot.from(r);const i=r.lt(ph);i&&(r=r.mul(gh));let n=r.mod(t).toString();for(;n.length<t.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=r.div(t).toString();return t.length===1?r=s:r=s+"."+n,i&&(r="-"+r),r}function ti(r,e){e==null&&(e=0);const t=wo(e);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Wt.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Wt.throwArgumentError("missing value","value",r);const n=r.split(".");n.length>2&&Wt.throwArgumentError("too many decimal points","value",r);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>t.length-1&&bh("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<t.length-1;)o+="0";const f=ot.from(s),u=ot.from(o);let h=f.mul(t).add(u);return i&&(h=h.mul(gh)),h}class yn{constructor(e,t,i,n){e!==Wn&&Wt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=i,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=wo(n),Object.freeze(this)}static from(e){if(e instanceof yn)return e;typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Wt.throwArgumentError("invalid fixed format","format",e),t=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,f,u)=>e[o]==null?u:(typeof e[o]!==f&&Wt.throwArgumentError("invalid fixed format ("+o+" not "+f+")","format."+o,e[o]),e[o]);t=s("signed","boolean",t),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Wt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Wt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new yn(Wn,t,i,n)}}class Tt{constructor(e,t,i,n){e!==Wn&&Wt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Wt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=ti(this._value,this.format.decimals),i=ti(e._value,e.format.decimals);return Tt.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=ti(this._value,this.format.decimals),i=ti(e._value,e.format.decimals);return Tt.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=ti(this._value,this.format.decimals),i=ti(e._value,e.format.decimals);return Tt.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=ti(this._value,this.format.decimals),i=ti(e._value,e.format.decimals);return Tt.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(vh.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(vh.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Wt.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Tt.from("1"+Jn.substring(0,e),this.format),n=Rb.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Wt.throwArgumentError("invalid byte width","width",e);const t=ot.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Lr(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Tt.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!Db(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Tt.fromString(_o(e,t),yn.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=yn.from(t),n=ti(e,i.decimals);!i.signed&&n.lt(ph)&&bh("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Lr(s,i.width/8));const o=_o(n,i.decimals);return new Tt(Wn,s,o,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=yn.from(t);if(lt(e).length>i.width/8)throw new Error("overflow");let n=ot.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=_o(n,i.decimals);return new Tt(Wn,s,o,i)}static from(e,t){if(typeof e=="string")return Tt.fromString(e,t);if(mn(e))return Tt.fromBytes(e,t);try{return Tt.fromValue(e,0,t)}catch(i){if(i.code!==Ve.errors.INVALID_ARGUMENT)throw i}return Wt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const vh=Tt.from(1),Rb=Tt.from("0.5"),Nb="strings/5.7.0",mh=new Ve(Nb);var Js;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Js||(Js={}));var wn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(wn||(wn={}));function Pb(r,e,t,i,n){return mh.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function yh(r,e,t,i,n){if(r===wn.BAD_PREFIX||r===wn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r===wn.OVERRUN?t.length-e-1:0}function Cb(r,e,t,i,n){return r===wn.OVERLONG?(i.push(n),0):(i.push(65533),yh(r,e,t))}Object.freeze({error:Pb,ignore:yh,replace:Cb});function xo(r,e=Js.current){e!=Js.current&&(mh.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);if(n<128)t.push(n);else if(n<2048)t.push(n>>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return lt(t)}function Tb(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t<r.length;t+=4)e.push(parseInt(r.substring(t,t+4),16));return e}function Ao(r,e){e||(e=function(n){return[parseInt(n,16)]});let t=0,i={};return r.split(",").forEach(n=>{let s=n.split(":");t+=parseInt(s[0],16),i[t]=e(s[1])}),i}function wh(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}wh("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(r=>parseInt(r,16)),Ao("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Ao("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Ao("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",Tb),wh("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const _h="hash/5.7.0";function Fb(r){r=atob(r);const e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return lt(e)}function xh(r,e){e==null&&(e=1);const t=[],i=t.forEach,n=function(s,o){i.call(s,function(f){o>0&&Array.isArray(f)?n(f,o-1):t.push(f)})};return n(r,e),t}function Bb(r){const e={};for(let t=0;t<r.length;t++){const i=r[t];e[i[0]]=i[1]}return e}function Lb(r){let e=0;function t(){return r[e++]<<8|r[e++]}let i=t(),n=1,s=[0,1];for(let U=1;U<i;U++)s.push(n+=t());let o=t(),f=e;e+=o;let u=0,h=0;function g(){return u==0&&(h=h<<8|r[e++],u=8),h>>--u&1}const y=31,I=Math.pow(2,y),M=I>>>1,D=M>>1,P=I-1;let k=0;for(let U=0;U<y;U++)k=k<<1|g();let K=[],C=0,j=I;for(;;){let U=Math.floor(((k-C+1)*n-1)/j),z=0,_=i;for(;_-z>1;){let Q=z+_>>>1;U<s[Q]?_=Q:z=Q}if(z==0)break;K.push(z);let R=C+Math.floor(j*s[z]/n),J=C+Math.floor(j*s[z+1]/n)-1;for(;!((R^J)&M);)k=k<<1&P|g(),R=R<<1&P,J=J<<1&P|1;for(;R&~J&D;)k=k&M|k<<1&P>>>1|g(),R=R<<1^M,J=(J^M)<<1|M|1;C=R,j=1+J-R}let F=i-4;return K.map(U=>{switch(U-F){case 3:return F+65792+(r[f++]<<16|r[f++]<<8|r[f++]);case 2:return F+256+(r[f++]<<8|r[f++]);case 1:return F+r[f++];default:return U-1}})}function qb(r){let e=0;return()=>r[e++]}function Ub(r){return qb(Lb(r))}function $b(r){return r&1?~r>>1:r>>1}function zb(r,e){let t=Array(r);for(let i=0;i<r;i++)t[i]=1+e();return t}function Ah(r,e){let t=Array(r);for(let i=0,n=-1;i<r;i++)t[i]=n+=1+e();return t}function kb(r,e){let t=Array(r);for(let i=0,n=0;i<r;i++)t[i]=n+=$b(e());return t}function Ys(r,e){let t=Ah(r(),r),i=r(),n=Ah(i,r),s=zb(i,r);for(let o=0;o<i;o++)for(let f=0;f<s[o];f++)t.push(n[o]+f);return e?t.map(o=>e[o]):t}function Kb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(Hb(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(Vb(t,r))}return Bb(xh(e))}function jb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function Eh(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)kb(r,t).forEach((s,o)=>i[o].push(s));return i}function Hb(r,e){let t=1+e(),i=e(),n=jb(e),s=Eh(n.length,1+r,e);return xh(s.map((o,f)=>{const u=o[0],h=o.slice(1);return Array(n[f]).fill(void 0).map((g,y)=>{let I=y*i;return[u+y*t,h.map(M=>M+I)]})}))}function Vb(r,e){let t=1+e();return Eh(t,1+r,e).map(n=>[n[0],n.slice(1)])}function Gb(r){let e=Ys(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let h=Ys(r,e);if(h.length==0)break;i.push({set:new Set(h),node:t()})}i.sort((h,g)=>g.set.size-h.set.size);let n=r(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let f=n==1,u=n==2;return{branches:i,valid:s,fe0f:o,save:f,check:u}}}function Wb(){return Ub(Fb("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const Qs=Wb();new Set(Ys(Qs)),new Set(Ys(Qs)),Kb(Qs),Gb(Qs),new Ve(_h),new Uint8Array(32).fill(0);const Jb=`Ethereum Signed Message:
|
22
|
-
`;function Sh(r){return typeof r=="string"&&(r=xo(r)),mo(Sb([xo(Jb),xo(String(r.length)),r]))}const Yb="rlp/5.7.0";new Ve(Yb);const Qb="address/5.7.0",Yn=new Ve(Qb);function Mh(r){fr(r,20)||Yn.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=lt(mo(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const Xb=9007199254740991;function Zb(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Eo={};for(let r=0;r<10;r++)Eo[String(r)]=String(r);for(let r=0;r<26;r++)Eo[String.fromCharCode(65+r)]=String(10+r);const Ih=Math.floor(Zb(Xb));function ev(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Eo[i]).join("");for(;e.length>=Ih;){let i=e.substring(0,Ih);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function tv(r){let e=null;if(typeof r!="string"&&Yn.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Mh(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Yn.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==ev(r)&&Yn.throwArgumentError("bad icap checksum","address",r),e=Ob(r.substring(4));e.length<40;)e="0"+e;e=Mh("0x"+e)}else Yn.throwArgumentError("invalid address","address",r);return e}const rv="properties/5.7.0";new Ve(rv);function Qn(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}new Ve(_h),new Uint8Array(32).fill(0),ot.from(-1);const iv=ot.from(0),nv=ot.from(1);ot.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Lr(nv.toHexString(),32),Lr(iv.toHexString(),32);var cr={},Ze={},ji=Dh;function Dh(r,e){if(!r)throw new Error(e||"Assertion failed")}Dh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var _n={exports:{}};typeof Object.create=="function"?_n.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:_n.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}};var sv=ji,av=_n.exports;Ze.inherits=av;function ov(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function fv(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n<r.length;n+=2)t.push(parseInt(r[n]+r[n+1],16))}else for(var i=0,n=0;n<r.length;n++){var s=r.charCodeAt(n);s<128?t[i++]=s:s<2048?(t[i++]=s>>6|192,t[i++]=s&63|128):ov(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n<r.length;n++)t[n]=r[n]|0;return t}Ze.toArray=fv;function cv(r){for(var e="",t=0;t<r.length;t++)e+=Rh(r[t].toString(16));return e}Ze.toHex=cv;function Oh(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ze.htonl=Oh;function hv(r,e){for(var t="",i=0;i<r.length;i++){var n=r[i];e==="little"&&(n=Oh(n)),t+=Nh(n.toString(16))}return t}Ze.toHex32=hv;function Rh(r){return r.length===1?"0"+r:r}Ze.zero2=Rh;function Nh(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Ze.zero8=Nh;function uv(r,e,t,i){var n=t-e;sv(n%4===0);for(var s=new Array(n/4),o=0,f=e;o<s.length;o++,f+=4){var u;i==="big"?u=r[f]<<24|r[f+1]<<16|r[f+2]<<8|r[f+3]:u=r[f+3]<<24|r[f+2]<<16|r[f+1]<<8|r[f],s[o]=u>>>0}return s}Ze.join32=uv;function dv(r,e){for(var t=new Array(r.length*4),i=0,n=0;i<r.length;i++,n+=4){var s=r[i];e==="big"?(t[n]=s>>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ze.split32=dv;function lv(r,e){return r>>>e|r<<32-e}Ze.rotr32=lv;function pv(r,e){return r<<e|r>>>32-e}Ze.rotl32=pv;function gv(r,e){return r+e>>>0}Ze.sum32=gv;function bv(r,e,t){return r+e+t>>>0}Ze.sum32_3=bv;function vv(r,e,t,i){return r+e+t+i>>>0}Ze.sum32_4=vv;function mv(r,e,t,i,n){return r+e+t+i+n>>>0}Ze.sum32_5=mv;function yv(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o<i?1:0)+t+n;r[e]=f>>>0,r[e+1]=o}Ze.sum64=yv;function wv(r,e,t,i){var n=e+i>>>0,s=(n<e?1:0)+r+t;return s>>>0}Ze.sum64_hi=wv;function _v(r,e,t,i){var n=e+i;return n>>>0}Ze.sum64_lo=_v;function xv(r,e,t,i,n,s,o,f){var u=0,h=e;h=h+i>>>0,u+=h<e?1:0,h=h+s>>>0,u+=h<s?1:0,h=h+f>>>0,u+=h<f?1:0;var g=r+t+n+o+u;return g>>>0}Ze.sum64_4_hi=xv;function Av(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ze.sum64_4_lo=Av;function Ev(r,e,t,i,n,s,o,f,u,h){var g=0,y=e;y=y+i>>>0,g+=y<e?1:0,y=y+s>>>0,g+=y<s?1:0,y=y+f>>>0,g+=y<f?1:0,y=y+h>>>0,g+=y<h?1:0;var I=r+t+n+o+u+g;return I>>>0}Ze.sum64_5_hi=Ev;function Sv(r,e,t,i,n,s,o,f,u,h){var g=e+i+s+f+h;return g>>>0}Ze.sum64_5_lo=Sv;function Mv(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ze.rotr64_hi=Mv;function Iv(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.rotr64_lo=Iv;function Dv(r,e,t){return r>>>t}Ze.shr64_hi=Dv;function Ov(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.shr64_lo=Ov;var xn={},Ph=Ze,Rv=ji;function Xs(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}xn.BlockHash=Xs,Xs.prototype.update=function(e,t){if(e=Ph.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Ph.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},Xs.prototype.digest=function(e){return this.update(this._pad()),Rv(this.pending===null),this._digest(e)},Xs.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var An={},qr={},Nv=Ze,Ur=Nv.rotr32;function Pv(r,e,t,i){if(r===0)return Ch(e,t,i);if(r===1||r===3)return Fh(e,t,i);if(r===2)return Th(e,t,i)}qr.ft_1=Pv;function Ch(r,e,t){return r&e^~r&t}qr.ch32=Ch;function Th(r,e,t){return r&e^r&t^e&t}qr.maj32=Th;function Fh(r,e,t){return r^e^t}qr.p32=Fh;function Cv(r){return Ur(r,2)^Ur(r,13)^Ur(r,22)}qr.s0_256=Cv;function Tv(r){return Ur(r,6)^Ur(r,11)^Ur(r,25)}qr.s1_256=Tv;function Fv(r){return Ur(r,7)^Ur(r,18)^r>>>3}qr.g0_256=Fv;function Bv(r){return Ur(r,17)^Ur(r,19)^r>>>10}qr.g1_256=Bv;var En=Ze,Lv=xn,qv=qr,So=En.rotl32,Xn=En.sum32,Uv=En.sum32_5,$v=qv.ft_1,Bh=Lv.BlockHash,zv=[1518500249,1859775393,2400959708,3395469782];function $r(){if(!(this instanceof $r))return new $r;Bh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}En.inherits($r,Bh);var kv=$r;$r.blockSize=512,$r.outSize=160,$r.hmacStrength=80,$r.padLength=64,$r.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=So(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4];for(n=0;n<i.length;n++){var g=~~(n/20),y=Uv(So(s,5),$v(g,o,f,u),h,i[n],zv[g]);h=u,u=f,f=So(o,30),o=s,s=y}this.h[0]=Xn(this.h[0],s),this.h[1]=Xn(this.h[1],o),this.h[2]=Xn(this.h[2],f),this.h[3]=Xn(this.h[3],u),this.h[4]=Xn(this.h[4],h)},$r.prototype._digest=function(e){return e==="hex"?En.toHex32(this.h,"big"):En.split32(this.h,"big")};var Sn=Ze,Kv=xn,Mn=qr,jv=ji,Dr=Sn.sum32,Hv=Sn.sum32_4,Vv=Sn.sum32_5,Gv=Mn.ch32,Wv=Mn.maj32,Jv=Mn.s0_256,Yv=Mn.s1_256,Qv=Mn.g0_256,Xv=Mn.g1_256,Lh=Kv.BlockHash,Zv=[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];function zr(){if(!(this instanceof zr))return new zr;Lh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Zv,this.W=new Array(64)}Sn.inherits(zr,Lh);var qh=zr;zr.blockSize=512,zr.outSize=256,zr.hmacStrength=192,zr.padLength=64,zr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=Hv(Xv(i[n-2]),i[n-7],Qv(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4],g=this.h[5],y=this.h[6],I=this.h[7];for(jv(this.k.length===i.length),n=0;n<i.length;n++){var M=Vv(I,Yv(h),Gv(h,g,y),this.k[n],i[n]),D=Dr(Jv(s),Wv(s,o,f));I=y,y=g,g=h,h=Dr(u,M),u=f,f=o,o=s,s=Dr(M,D)}this.h[0]=Dr(this.h[0],s),this.h[1]=Dr(this.h[1],o),this.h[2]=Dr(this.h[2],f),this.h[3]=Dr(this.h[3],u),this.h[4]=Dr(this.h[4],h),this.h[5]=Dr(this.h[5],g),this.h[6]=Dr(this.h[6],y),this.h[7]=Dr(this.h[7],I)},zr.prototype._digest=function(e){return e==="hex"?Sn.toHex32(this.h,"big"):Sn.split32(this.h,"big")};var Mo=Ze,Uh=qh;function ri(){if(!(this instanceof ri))return new ri;Uh.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Mo.inherits(ri,Uh);var e2=ri;ri.blockSize=512,ri.outSize=224,ri.hmacStrength=192,ri.padLength=64,ri.prototype._digest=function(e){return e==="hex"?Mo.toHex32(this.h.slice(0,7),"big"):Mo.split32(this.h.slice(0,7),"big")};var er=Ze,t2=xn,r2=ji,kr=er.rotr64_hi,Kr=er.rotr64_lo,$h=er.shr64_hi,zh=er.shr64_lo,Ai=er.sum64,Io=er.sum64_hi,Do=er.sum64_lo,i2=er.sum64_4_hi,n2=er.sum64_4_lo,s2=er.sum64_5_hi,a2=er.sum64_5_lo,kh=t2.BlockHash,o2=[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 Or(){if(!(this instanceof Or))return new Or;kh.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=o2,this.W=new Array(160)}er.inherits(Or,kh);var Kh=Or;Or.blockSize=1024,Or.outSize=512,Or.hmacStrength=192,Or.padLength=128,Or.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n<i.length;n+=2){var s=m2(i[n-4],i[n-3]),o=y2(i[n-4],i[n-3]),f=i[n-14],u=i[n-13],h=b2(i[n-30],i[n-29]),g=v2(i[n-30],i[n-29]),y=i[n-32],I=i[n-31];i[n]=i2(s,o,f,u,h,g,y,I),i[n+1]=n2(s,o,f,u,h,g,y,I)}},Or.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],f=this.h[3],u=this.h[4],h=this.h[5],g=this.h[6],y=this.h[7],I=this.h[8],M=this.h[9],D=this.h[10],P=this.h[11],k=this.h[12],K=this.h[13],C=this.h[14],j=this.h[15];r2(this.k.length===i.length);for(var F=0;F<i.length;F+=2){var U=C,z=j,_=p2(I,M),R=g2(I,M),J=f2(I,M,D,P,k),Q=c2(I,M,D,P,k,K),N=this.k[F],p=this.k[F+1],l=i[F],a=i[F+1],c=s2(U,z,_,R,J,Q,N,p,l,a),b=a2(U,z,_,R,J,Q,N,p,l,a);U=d2(n,s),z=l2(n,s),_=h2(n,s,o,f,u),R=u2(n,s,o,f,u,h);var A=Io(U,z,_,R),E=Do(U,z,_,R);C=k,j=K,k=D,K=P,D=I,P=M,I=Io(g,y,c,b),M=Do(y,y,c,b),g=u,y=h,u=o,h=f,o=n,f=s,n=Io(c,b,A,E),s=Do(c,b,A,E)}Ai(this.h,0,n,s),Ai(this.h,2,o,f),Ai(this.h,4,u,h),Ai(this.h,6,g,y),Ai(this.h,8,I,M),Ai(this.h,10,D,P),Ai(this.h,12,k,K),Ai(this.h,14,C,j)},Or.prototype._digest=function(e){return e==="hex"?er.toHex32(this.h,"big"):er.split32(this.h,"big")};function f2(r,e,t,i,n){var s=r&t^~r&n;return s<0&&(s+=4294967296),s}function c2(r,e,t,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function h2(r,e,t,i,n){var s=r&t^r&n^t&n;return s<0&&(s+=4294967296),s}function u2(r,e,t,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function d2(r,e){var t=kr(r,e,28),i=kr(e,r,2),n=kr(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function l2(r,e){var t=Kr(r,e,28),i=Kr(e,r,2),n=Kr(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function p2(r,e){var t=kr(r,e,14),i=kr(r,e,18),n=kr(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function g2(r,e){var t=Kr(r,e,14),i=Kr(r,e,18),n=Kr(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function b2(r,e){var t=kr(r,e,1),i=kr(r,e,8),n=$h(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function v2(r,e){var t=Kr(r,e,1),i=Kr(r,e,8),n=zh(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function m2(r,e){var t=kr(r,e,19),i=kr(e,r,29),n=$h(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}function y2(r,e){var t=Kr(r,e,19),i=Kr(e,r,29),n=zh(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}var Oo=Ze,jh=Kh;function ii(){if(!(this instanceof ii))return new ii;jh.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Oo.inherits(ii,jh);var w2=ii;ii.blockSize=1024,ii.outSize=384,ii.hmacStrength=192,ii.padLength=128,ii.prototype._digest=function(e){return e==="hex"?Oo.toHex32(this.h.slice(0,12),"big"):Oo.split32(this.h.slice(0,12),"big")},An.sha1=kv,An.sha224=e2,An.sha256=qh,An.sha384=w2,An.sha512=Kh;var Hh={},Hi=Ze,_2=xn,Zs=Hi.rotl32,Vh=Hi.sum32,Zn=Hi.sum32_3,Gh=Hi.sum32_4,Wh=_2.BlockHash;function jr(){if(!(this instanceof jr))return new jr;Wh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Hi.inherits(jr,Wh),Hh.ripemd160=jr,jr.blockSize=512,jr.outSize=160,jr.hmacStrength=192,jr.padLength=64,jr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,h=n,g=s,y=o,I=f,M=0;M<80;M++){var D=Vh(Zs(Gh(i,Jh(M,n,s,o),e[E2[M]+t],x2(M)),M2[M]),f);i=f,f=o,o=Zs(s,10),s=n,n=D,D=Vh(Zs(Gh(u,Jh(79-M,h,g,y),e[S2[M]+t],A2(M)),I2[M]),I),u=I,I=y,y=Zs(g,10),g=h,h=D}D=Zn(this.h[1],s,y),this.h[1]=Zn(this.h[2],o,I),this.h[2]=Zn(this.h[3],f,u),this.h[3]=Zn(this.h[4],i,h),this.h[4]=Zn(this.h[0],n,g),this.h[0]=D},jr.prototype._digest=function(e){return e==="hex"?Hi.toHex32(this.h,"little"):Hi.split32(this.h,"little")};function Jh(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function x2(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function A2(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var E2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],S2=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],M2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],I2=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],D2=Ze,O2=ji;function In(r,e,t){if(!(this instanceof In))return new In(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(D2.toArray(e,t))}var R2=In;In.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),O2(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=new this.Hash().update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=new this.Hash().update(e)},In.prototype.update=function(e,t){return this.inner.update(e,t),this},In.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(r){var e=r;e.utils=Ze,e.common=xn,e.sha=An,e.ripemd=Hh,e.hmac=R2,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(cr);function Dn(r,e,t){return t={path:e,exports:{},require:function(i,n){return N2(i,n??t.path)}},r(t,t.exports),t.exports}function N2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ro=Yh;function Yh(r,e){if(!r)throw new Error(e||"Assertion failed")}Yh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Rr=Dn(function(r,e){var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var h=0;h<o.length;h++)u[h]=o[h]|0;return u}if(f==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var h=0;h<o.length;h+=2)u.push(parseInt(o[h]+o[h+1],16))}else for(var h=0;h<o.length;h++){var g=o.charCodeAt(h),y=g>>8,I=g&255;y?u.push(y,I):u.push(I)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u<o.length;u++)f+=n(o[u].toString(16));return f}t.toHex=s,t.encode=function(f,u){return u==="hex"?s(f):f}}),hr=Dn(function(r,e){var t=e;t.assert=Ro,t.toArray=Rr.toArray,t.zero2=Rr.zero2,t.toHex=Rr.toHex,t.encode=Rr.encode;function i(u,h,g){var y=new Array(Math.max(u.bitLength(),g)+1);y.fill(0);for(var I=1<<h+1,M=u.clone(),D=0;D<y.length;D++){var P,k=M.andln(I-1);M.isOdd()?(k>(I>>1)-1?P=(I>>1)-k:P=k,M.isubn(P)):P=0,y[D]=P,M.iushrn(1)}return y}t.getNAF=i;function n(u,h){var g=[[],[]];u=u.clone(),h=h.clone();for(var y=0,I=0,M;u.cmpn(-y)>0||h.cmpn(-I)>0;){var D=u.andln(3)+y&3,P=h.andln(3)+I&3;D===3&&(D=-1),P===3&&(P=-1);var k;D&1?(M=u.andln(7)+y&7,(M===3||M===5)&&P===2?k=-D:k=D):k=0,g[0].push(k);var K;P&1?(M=h.andln(7)+I&7,(M===3||M===5)&&D===2?K=-P:K=P):K=0,g[1].push(K),2*y===k+1&&(y=1-y),2*I===K+1&&(I=1-I),u.iushrn(1),h.iushrn(1)}return g}t.getJSF=n;function s(u,h,g){var y="_"+h;u.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new je(u,"hex","le")}t.intFromLE=f}),ea=hr.getNAF,P2=hr.getJSF,ta=hr.assert;function Ei(r,e){this.type=r,this.p=new je(e.p,16),this.red=e.prime?je.red(e.prime):je.mont(this.p),this.zero=new je(0).toRed(this.red),this.one=new je(1).toRed(this.red),this.two=new je(2).toRed(this.red),this.n=e.n&&new je(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Vi=Ei;Ei.prototype.point=function(){throw new Error("Not implemented")},Ei.prototype.validate=function(){throw new Error("Not implemented")},Ei.prototype._fixedNafMul=function(e,t){ta(e.precomputed);var i=e._getDoubles(),n=ea(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?y=y.mixedAdd(i.points[f]):u===-I&&(y=y.mixedAdd(i.points[f].neg()));g=g.add(y)}return g.toP()},Ei.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=ea(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];ta(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Ei.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,y,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,P=g;if(o[D]!==1||o[P]!==1){u[D]=ea(i[D],o[D],this._bitLength),u[P]=ea(i[P],o[P],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[P].length,h);continue}var k=[t[D],null,null,t[P]];t[D].y.cmp(t[P].y)===0?(k[1]=t[D].add(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg())):t[D].y.cmp(t[P].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].add(t[P].neg())):(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],C=P2(i[D],i[P]);for(h=Math.max(C[0].length,h),u[D]=new Array(h),u[P]=new Array(h),y=0;y<h;y++){var j=C[0][y]|0,F=C[1][y]|0;u[D][y]=K[(j+1)*3+(F+1)],u[P][y]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var R=!0;for(y=0;y<n;y++)z[y]=u[y][g]|0,z[y]!==0&&(R=!1);if(!R)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(y=0;y<n;y++){var J=z[y];J!==0&&(J>0?I=f[y][J-1>>1]:J<0&&(I=f[y][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function gr(r,e){this.curve=r,this.type=e,this.precomputed=null}Ei.BasePoint=gr,gr.prototype.eq=function(){throw new Error("Not implemented")},gr.prototype.validate=function(){return this.curve.validate(this)},Ei.prototype.decodePoint=function(e,t){e=hr.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?ta(e[e.length-1]%2===0):e[0]===7&&ta(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},gr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},gr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},gr.prototype.encode=function(e,t){return hr.encode(this._encode(t),e)},gr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},gr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},gr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},gr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},gr.prototype._getBeta=function(){return null},gr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var No=Dn(function(r){typeof Object.create=="function"?r.exports=function(t,i){i&&(t.super_=i,t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,i){if(i){t.super_=i;var n=function(){};n.prototype=i.prototype,t.prototype=new n,t.prototype.constructor=t}}}),C2=hr.assert;function br(r){Vi.call(this,"short",r),this.a=new je(r.a,16).toRed(this.red),this.b=new je(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}No(br,Vi);var T2=br;br.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new je(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new je(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],C2(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new je(f.a,16),b:new je(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},br.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:je.mont(e),i=new je(2).toRed(t).redInvm(),n=i.redNeg(),s=new je(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},br.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new je(1),o=new je(0),f=new je(0),u=new je(1),h,g,y,I,M,D,P,k=0,K,C;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),C=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!y&&K.cmp(t)<0)h=P.neg(),g=s,y=K.neg(),I=C;else if(y&&++k===2)break;P=K,n=i,i=K,f=s,s=C,u=o,o=F}M=K.neg(),D=C;var U=y.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),y.negative&&(y=y.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:y,b:I},{a:M,b:D}]},br.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),y=e.sub(f).sub(u),I=h.add(g).neg();return{k1:y,k2:I}},br.prototype.pointFromX=function(e,t){e=new je(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},br.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},br.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return g};function St(r,e,t,i){Vi.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new je(e,16),this.y=new je(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}No(St,Vi.BasePoint),br.prototype.point=function(e,t,i){return new St(this,e,t,i)},br.prototype.pointFromJSON=function(e,t){return St.fromJSON(this,e,t)},St.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},St.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},St.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},St.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},St.prototype.isInfinity=function(){return this.inf},St.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},St.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},St.prototype.getX=function(){return this.x.fromRed()},St.prototype.getY=function(){return this.y.fromRed()},St.prototype.mul=function(e){return e=new je(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},St.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},St.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},St.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},St.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t},St.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Ft(r,e,t,i){Vi.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new je(0)):(this.x=new je(e,16),this.y=new je(t,16),this.z=new je(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}No(Ft,Vi.BasePoint),br.prototype.jpoint=function(e,t,i){return new Ft(this,e,t,i)},Ft.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Ft.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ft.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),y=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(y).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,P)},Ft.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),y=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(y).redISub(y),M=u.redMul(y.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Ft.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var y=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),P=o.redMul(I),k=D.redSqr().redISub(P.redAdd(P)),K=P.redISub(k),C=D.redMul(K);C=C.redIAdd(C).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=C}return this.curve.jpoint(o,g.redMul(s),u)},Ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ft.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(y).redISub(M);D=D.redIAdd(D);var P=y.redAdd(y).redIAdd(y),k=P.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=P.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Ft.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(y).redMul(this.x.redAdd(y));D=D.redAdd(D).redIAdd(D);var P=M.redIAdd(M);P=P.redIAdd(P);var k=P.redAdd(P);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(y);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(P.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Ft.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),y=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(y),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),P=i.redAdd(i).redMul(n);return this.curve.jpoint(y,D,P)},Ft.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),y=t.redMul(g);y=y.redIAdd(y),y=y.redIAdd(y);var I=this.x.redMul(u).redISub(y);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Ft.prototype.mul=function(e,t){return e=new je(e,t),this.curve._wnafMul(this,e)},Ft.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Ft.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Ft.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Ft.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ra=Dn(function(r,e){var t=e;t.base=Vi,t.short=T2,t.mont=null,t.edwards=null}),ia=Dn(function(r,e){var t=e,i=hr.assert;function n(f){f.type==="short"?this.curve=new ra.short(f):f.type==="edwards"?this.curve=new ra.edwards(f):this.curve=new ra.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var h=new n(u);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:cr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:cr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:cr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:cr.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:cr.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:cr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:cr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:cr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Si(r){if(!(this instanceof Si))return new Si(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Rr.toArray(r.entropy,r.entropyEnc||"hex"),t=Rr.toArray(r.nonce,r.nonceEnc||"hex"),i=Rr.toArray(r.pers,r.persEnc||"hex");Ro(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var Qh=Si;Si.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Si.prototype._hmac=function(){return new cr.hmac(this.hash,this.K)},Si.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Si.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Rr.toArray(e,t),i=Rr.toArray(i,n),Ro(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Si.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Rr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Rr.encode(o,t)};var Po=hr.assert;function $t(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Co=$t;$t.fromPublic=function(e,t,i){return t instanceof $t?t:new $t(e,{pub:t,pubEnc:i})},$t.fromPrivate=function(e,t,i){return t instanceof $t?t:new $t(e,{priv:t,privEnc:i})},$t.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},$t.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},$t.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},$t.prototype._importPrivate=function(e,t){this.priv=new je(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},$t.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Po(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Po(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},$t.prototype.derive=function(e){return e.validate()||Po(e.validate(),"public point not validated"),e.mul(this.priv).getX()},$t.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},$t.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},$t.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var F2=hr.assert;function na(r,e){if(r instanceof na)return r;this._importDER(r,e)||(F2(r.r&&r.s,"Signature without r or s"),this.r=new je(r.r,16),this.s=new je(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var sa=na;function B2(){this.place=0}function To(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Xh(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}na.prototype._importDER=function(e,t){e=hr.toArray(e,t);var i=new B2;if(e[i.place++]!==48)return!1;var n=To(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=To(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=To(e,i);if(f===!1||e.length!==f+i.place)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new je(o),this.s=new je(u),this.recoveryParam=null,!0};function Fo(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}na.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Xh(t),i=Xh(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Fo(n,t.length),n=n.concat(t),n.push(2),Fo(n,i.length);var s=n.concat(i),o=[48];return Fo(o,s.length),o=o.concat(s),hr.encode(o,e)};var L2=function(){throw new Error("unsupported")},Zh=hr.assert;function vr(r){if(!(this instanceof vr))return new vr(r);typeof r=="string"&&(Zh(Object.prototype.hasOwnProperty.call(ia,r),"Unknown curve "+r),r=ia[r]),r instanceof ia.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var q2=vr;vr.prototype.keyPair=function(e){return new Co(this,e)},vr.prototype.keyFromPrivate=function(e,t){return Co.fromPrivate(this,e,t)},vr.prototype.keyFromPublic=function(e,t){return Co.fromPublic(this,e,t)},vr.prototype.genKeyPair=function(e){e||(e={});for(var t=new Qh({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||L2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new je(2));;){var s=new je(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},vr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},vr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new je(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new Qh({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new je(1)),g=0;;g++){var y=n.k?n.k(g):new je(u.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var I=this.g.mul(y);if(!I.isInfinity()){var M=I.getX(),D=M.umod(this.n);if(D.cmpn(0)!==0){var P=y.invm(this.n).mul(D.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var k=(I.getY().isOdd()?1:0)|(M.cmp(D)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),k^=1),new sa({r:D,s:P,recoveryParam:k})}}}}}},vr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new je(e,16)),i=this.keyFromPublic(i,n),t=new sa(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)},vr.prototype.recoverPubKey=function(r,e,t,i){Zh((3&t)===t,"The recovery param is more than two bits"),e=new sa(e,i);var n=this.n,s=new je(r),o=e.r,f=e.s,u=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(y,o,I)},vr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new sa(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var U2=Dn(function(r,e){var t=e;t.version="6.5.4",t.utils=hr,t.rand=function(){throw new Error("unsupported")},t.curve=ra,t.curves=ia,t.ec=q2,t.eddsa=null}),$2=U2.ec;const z2="signing-key/5.7.0",Bo=new Ve(z2);let Lo=null;function Hr(){return Lo||(Lo=new $2("secp256k1")),Lo}class k2{constructor(e){Qn(this,"curve","secp256k1"),Qn(this,"privateKey",Gt(e)),Ib(this.privateKey)!==32&&Bo.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Hr().keyFromPrivate(lt(this.privateKey));Qn(this,"publicKey","0x"+t.getPublic(!1,"hex")),Qn(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Qn(this,"_isSigningKey",!0)}_addPoint(e){const t=Hr().keyFromPublic(lt(this.publicKey)),i=Hr().keyFromPublic(lt(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Hr().keyFromPrivate(lt(this.privateKey)),i=lt(e);i.length!==32&&Bo.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return ch({recoveryParam:n.recoveryParam,r:Lr("0x"+n.r.toString(16),32),s:Lr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Hr().keyFromPrivate(lt(this.privateKey)),i=Hr().keyFromPublic(lt(eu(e)));return Lr("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function K2(r,e){const t=ch(e),i={r:lt(t.r),s:lt(t.s)};return"0x"+Hr().recoverPubKey(lt(r),i,t.recoveryParam).encode("hex",!1)}function eu(r,e){const t=lt(r);if(t.length===32){const i=new k2(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Gt(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):Gt(t)}return Bo.throwArgumentError("invalid public or private key","key","[REDACTED]")}const j2="transactions/5.7.0";new Ve(j2);var tu;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(tu||(tu={}));function H2(r){const e=eu(r);return tv(fh(mo(fh(e,1)),12))}function V2(r,e){return H2(K2(lt(r),e))}var qo={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});var zt=He,Uo=or,G2=20;function W2(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],I=t[23]<<24|t[22]<<16|t[21]<<8|t[20],M=t[27]<<24|t[26]<<16|t[25]<<8|t[24],D=t[31]<<24|t[30]<<16|t[29]<<8|t[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],K=e[11]<<24|e[10]<<16|e[9]<<8|e[8],C=e[15]<<24|e[14]<<16|e[13]<<8|e[12],j=i,F=n,U=s,z=o,_=f,R=u,J=h,Q=g,N=y,p=I,l=M,a=D,c=P,b=k,A=K,E=C,x=0;x<G2;x+=2)j=j+_|0,c^=j,c=c>>>32-16|c<<16,N=N+c|0,_^=N,_=_>>>32-12|_<<12,F=F+R|0,b^=F,b=b>>>32-16|b<<16,p=p+b|0,R^=p,R=R>>>32-12|R<<12,U=U+J|0,A^=U,A=A>>>32-16|A<<16,l=l+A|0,J^=l,J=J>>>32-12|J<<12,z=z+Q|0,E^=z,E=E>>>32-16|E<<16,a=a+E|0,Q^=a,Q=Q>>>32-12|Q<<12,U=U+J|0,A^=U,A=A>>>32-8|A<<8,l=l+A|0,J^=l,J=J>>>32-7|J<<7,z=z+Q|0,E^=z,E=E>>>32-8|E<<8,a=a+E|0,Q^=a,Q=Q>>>32-7|Q<<7,F=F+R|0,b^=F,b=b>>>32-8|b<<8,p=p+b|0,R^=p,R=R>>>32-7|R<<7,j=j+_|0,c^=j,c=c>>>32-8|c<<8,N=N+c|0,_^=N,_=_>>>32-7|_<<7,j=j+R|0,E^=j,E=E>>>32-16|E<<16,l=l+E|0,R^=l,R=R>>>32-12|R<<12,F=F+J|0,c^=F,c=c>>>32-16|c<<16,a=a+c|0,J^=a,J=J>>>32-12|J<<12,U=U+Q|0,b^=U,b=b>>>32-16|b<<16,N=N+b|0,Q^=N,Q=Q>>>32-12|Q<<12,z=z+_|0,A^=z,A=A>>>32-16|A<<16,p=p+A|0,_^=p,_=_>>>32-12|_<<12,U=U+Q|0,b^=U,b=b>>>32-8|b<<8,N=N+b|0,Q^=N,Q=Q>>>32-7|Q<<7,z=z+_|0,A^=z,A=A>>>32-8|A<<8,p=p+A|0,_^=p,_=_>>>32-7|_<<7,F=F+J|0,c^=F,c=c>>>32-8|c<<8,a=a+c|0,J^=a,J=J>>>32-7|J<<7,j=j+R|0,E^=j,E=E>>>32-8|E<<8,l=l+E|0,R^=l,R=R>>>32-7|R<<7;zt.writeUint32LE(j+i|0,r,0),zt.writeUint32LE(F+n|0,r,4),zt.writeUint32LE(U+s|0,r,8),zt.writeUint32LE(z+o|0,r,12),zt.writeUint32LE(_+f|0,r,16),zt.writeUint32LE(R+u|0,r,20),zt.writeUint32LE(J+h|0,r,24),zt.writeUint32LE(Q+g|0,r,28),zt.writeUint32LE(N+y|0,r,32),zt.writeUint32LE(p+I|0,r,36),zt.writeUint32LE(l+M|0,r,40),zt.writeUint32LE(a+D|0,r,44),zt.writeUint32LE(c+P|0,r,48),zt.writeUint32LE(b+k|0,r,52),zt.writeUint32LE(A+K|0,r,56),zt.writeUint32LE(E+C|0,r,60)}function ru(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<t.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=n}for(var f=new Uint8Array(64),u=0;u<t.length;u+=64){W2(f,s,r);for(var h=u;h<u+64&&h<t.length;h++)i[h]=t[h]^f[h-u];Y2(s,0,o)}return Uo.wipe(f),n===0&&Uo.wipe(s),i}aa.streamXOR=ru;function J2(r,e,t,i){return i===void 0&&(i=0),Uo.wipe(t),ru(r,e,t,t,i)}aa.stream=J2;function Y2(r,e,t){for(var i=1;t--;)i=i+(r[e]&255)|0,r[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var iu={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});function Q2(r,e,t){return~(r-1)&e|r-1&t}Mi.select=Q2;function X2(r,e){return(r|0)-(e|0)-1>>>31&1}Mi.lessOrEqual=X2;function nu(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i<r.length;i++)t|=r[i]^e[i];return 1&t-1>>>8}Mi.compare=nu;function Z2(r,e){return r.length===0||e.length===0?!1:nu(r,e)!==0}Mi.equal=Z2,function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Mi,t=or;r.DIGEST_LENGTH=16;var i=function(){function o(f){this.digestLength=r.DIGEST_LENGTH,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,this._finished=!1;var u=f[0]|f[1]<<8;this._r[0]=u&8191;var h=f[2]|f[3]<<8;this._r[1]=(u>>>13|h<<3)&8191;var g=f[4]|f[5]<<8;this._r[2]=(h>>>10|g<<6)&7939;var y=f[6]|f[7]<<8;this._r[3]=(g>>>7|y<<9)&8191;var I=f[8]|f[9]<<8;this._r[4]=(y>>>4|I<<12)&255,this._r[5]=I>>>1&8190;var M=f[10]|f[11]<<8;this._r[6]=(I>>>14|M<<2)&8191;var D=f[12]|f[13]<<8;this._r[7]=(M>>>11|D<<5)&8065;var P=f[14]|f[15]<<8;this._r[8]=(D>>>8|P<<8)&8191,this._r[9]=P>>>5&127,this._pad[0]=f[16]|f[17]<<8,this._pad[1]=f[18]|f[19]<<8,this._pad[2]=f[20]|f[21]<<8,this._pad[3]=f[22]|f[23]<<8,this._pad[4]=f[24]|f[25]<<8,this._pad[5]=f[26]|f[27]<<8,this._pad[6]=f[28]|f[29]<<8,this._pad[7]=f[30]|f[31]<<8}return o.prototype._blocks=function(f,u,h){for(var g=this._fin?0:2048,y=this._h[0],I=this._h[1],M=this._h[2],D=this._h[3],P=this._h[4],k=this._h[5],K=this._h[6],C=this._h[7],j=this._h[8],F=this._h[9],U=this._r[0],z=this._r[1],_=this._r[2],R=this._r[3],J=this._r[4],Q=this._r[5],N=this._r[6],p=this._r[7],l=this._r[8],a=this._r[9];h>=16;){var c=f[u+0]|f[u+1]<<8;y+=c&8191;var b=f[u+2]|f[u+3]<<8;I+=(c>>>13|b<<3)&8191;var A=f[u+4]|f[u+5]<<8;M+=(b>>>10|A<<6)&8191;var E=f[u+6]|f[u+7]<<8;D+=(A>>>7|E<<9)&8191;var x=f[u+8]|f[u+9]<<8;P+=(E>>>4|x<<12)&8191,k+=x>>>1&8191;var d=f[u+10]|f[u+11]<<8;K+=(x>>>14|d<<2)&8191;var w=f[u+12]|f[u+13]<<8;C+=(d>>>11|w<<5)&8191;var v=f[u+14]|f[u+15]<<8;j+=(w>>>8|v<<8)&8191,F+=v>>>5|g;var O=0,W=O;W+=y*U,W+=I*(5*a),W+=M*(5*l),W+=D*(5*p),W+=P*(5*N),O=W>>>13,W&=8191,W+=k*(5*Q),W+=K*(5*J),W+=C*(5*R),W+=j*(5*_),W+=F*(5*z),O+=W>>>13,W&=8191;var S=O;S+=y*z,S+=I*U,S+=M*(5*a),S+=D*(5*l),S+=P*(5*p),O=S>>>13,S&=8191,S+=k*(5*N),S+=K*(5*Q),S+=C*(5*J),S+=j*(5*R),S+=F*(5*_),O+=S>>>13,S&=8191;var H=O;H+=y*_,H+=I*z,H+=M*U,H+=D*(5*a),H+=P*(5*l),O=H>>>13,H&=8191,H+=k*(5*p),H+=K*(5*N),H+=C*(5*Q),H+=j*(5*J),H+=F*(5*R),O+=H>>>13,H&=8191;var T=O;T+=y*R,T+=I*_,T+=M*z,T+=D*U,T+=P*(5*a),O=T>>>13,T&=8191,T+=k*(5*l),T+=K*(5*p),T+=C*(5*N),T+=j*(5*Q),T+=F*(5*J),O+=T>>>13,T&=8191;var q=O;q+=y*J,q+=I*R,q+=M*_,q+=D*z,q+=P*U,O=q>>>13,q&=8191,q+=k*(5*a),q+=K*(5*l),q+=C*(5*p),q+=j*(5*N),q+=F*(5*Q),O+=q>>>13,q&=8191;var B=O;B+=y*Q,B+=I*J,B+=M*R,B+=D*_,B+=P*z,O=B>>>13,B&=8191,B+=k*U,B+=K*(5*a),B+=C*(5*l),B+=j*(5*p),B+=F*(5*N),O+=B>>>13,B&=8191;var m=O;m+=y*N,m+=I*Q,m+=M*J,m+=D*R,m+=P*_,O=m>>>13,m&=8191,m+=k*z,m+=K*U,m+=C*(5*a),m+=j*(5*l),m+=F*(5*p),O+=m>>>13,m&=8191;var L=O;L+=y*p,L+=I*N,L+=M*Q,L+=D*J,L+=P*R,O=L>>>13,L&=8191,L+=k*_,L+=K*z,L+=C*U,L+=j*(5*a),L+=F*(5*l),O+=L>>>13,L&=8191;var G=O;G+=y*l,G+=I*p,G+=M*N,G+=D*Q,G+=P*J,O=G>>>13,G&=8191,G+=k*R,G+=K*_,G+=C*z,G+=j*U,G+=F*(5*a),O+=G>>>13,G&=8191;var Y=O;Y+=y*a,Y+=I*l,Y+=M*p,Y+=D*N,Y+=P*Q,O=Y>>>13,Y&=8191,Y+=k*J,Y+=K*R,Y+=C*_,Y+=j*z,Y+=F*U,O+=Y>>>13,Y&=8191,O=(O<<2)+O|0,O=O+W|0,W=O&8191,O=O>>>13,S+=O,y=W,I=S,M=H,D=T,P=q,k=B,K=m,C=L,j=G,F=Y,u+=16,h-=16}this._h[0]=y,this._h[1]=I,this._h[2]=M,this._h[3]=D,this._h[4]=P,this._h[5]=k,this._h[6]=K,this._h[7]=C,this._h[8]=j,this._h[9]=F},o.prototype.finish=function(f,u){u===void 0&&(u=0);var h=new Uint16Array(10),g,y,I,M;if(this._leftover){for(M=this._leftover,this._buffer[M++]=1;M<16;M++)this._buffer[M]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,M=2;M<10;M++)this._h[M]+=g,g=this._h[M]>>>13,this._h[M]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,h[0]=this._h[0]+5,g=h[0]>>>13,h[0]&=8191,M=1;M<10;M++)h[M]=this._h[M]+g,g=h[M]>>>13,h[M]&=8191;for(h[9]-=8192,y=(g^1)-1,M=0;M<10;M++)h[M]&=y;for(y=~y,M=0;M<10;M++)this._h[M]=this._h[M]&y|h[M];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,I=this._h[0]+this._pad[0],this._h[0]=I&65535,M=1;M<8;M++)I=(this._h[M]+this._pad[M]|0)+(I>>>16)|0,this._h[M]=I&65535;return f[u+0]=this._h[0]>>>0,f[u+1]=this._h[0]>>>8,f[u+2]=this._h[1]>>>0,f[u+3]=this._h[1]>>>8,f[u+4]=this._h[2]>>>0,f[u+5]=this._h[2]>>>8,f[u+6]=this._h[3]>>>0,f[u+7]=this._h[3]>>>8,f[u+8]=this._h[4]>>>0,f[u+9]=this._h[4]>>>8,f[u+10]=this._h[5]>>>0,f[u+11]=this._h[5]>>>8,f[u+12]=this._h[6]>>>0,f[u+13]=this._h[6]>>>8,f[u+14]=this._h[7]>>>0,f[u+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(f){var u=0,h=f.length,g;if(this._leftover){g=16-this._leftover,g>h&&(g=h);for(var y=0;y<g;y++)this._buffer[this._leftover+y]=f[u+y];if(h-=g,u+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(g=h-h%16,this._blocks(f,u,g),u+=g,h-=g),h){for(var y=0;y<h;y++)this._buffer[this._leftover+y]=f[u+y];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var f=new Uint8Array(16);return this.finish(f),f},o.prototype.clean=function(){return t.wipe(this._buffer),t.wipe(this._r),t.wipe(this._h),t.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();r.Poly1305=i;function n(o,f){var u=new i(o);u.update(f);var h=u.digest();return u.clean(),h}r.oneTimeAuth=n;function s(o,f){return o.length!==r.DIGEST_LENGTH||f.length!==r.DIGEST_LENGTH?!1:e.equal(o,f)}r.equal=s}(iu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=aa,t=iu,i=or,n=He,s=Mi;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var o=new Uint8Array(16),f=function(){function u(h){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,h.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return u.prototype.seal=function(h,g,y,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var P=g.length+this.tagLength,k;if(I){if(I.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");k=I}else k=new Uint8Array(P);return e.streamXOR(this._key,M,g,k,4),this._authenticate(k.subarray(k.length-this.tagLength,k.length),D,k.subarray(0,k.length-this.tagLength),y),i.wipe(M),k},u.prototype.open=function(h,g,y,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var P=new Uint8Array(this.tagLength);if(this._authenticate(P,D,g.subarray(0,g.length-this.tagLength),y),!s.equal(P,g.subarray(g.length-this.tagLength,g.length)))return null;var k=g.length-this.tagLength,K;if(I){if(I.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");K=I}else K=new Uint8Array(k);return e.streamXOR(this._key,M,g.subarray(0,g.length-this.tagLength),K,4),i.wipe(M),K},u.prototype.clean=function(){return i.wipe(this._key),this},u.prototype._authenticate=function(h,g,y,I){var M=new t.Poly1305(g);I&&(M.update(I),I.length%16>0&&M.update(o.subarray(I.length%16))),M.update(y),y.length%16>0&&M.update(o.subarray(y.length%16));var D=new Uint8Array(8);I&&n.writeUint64LE(I.length,D),M.update(D),n.writeUint64LE(y.length,D),M.update(D);for(var P=M.digest(),k=0;k<P.length;k++)h[k]=P[k];M.clean(),i.wipe(P),i.wipe(D)},u}();r.ChaCha20Poly1305=f}(qo);var su={},es={},$o={};Object.defineProperty($o,"__esModule",{value:!0});function e3(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}$o.isSerializableHash=e3,Object.defineProperty(es,"__esModule",{value:!0});var Vr=$o,t3=Mi,r3=or,au=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),Vr.isSerializableHash(this._inner)&&Vr.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),r3.wipe(i)}return r.prototype.reset=function(){if(!Vr.isSerializableHash(this._inner)||!Vr.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){Vr.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Vr.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(e){return this._inner.update(e),this},r.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(!Vr.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(e){if(!Vr.isSerializableHash(this._inner)||!Vr.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(e){if(!Vr.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();es.HMAC=au;function i3(r,e,t){var i=new au(r,e);i.update(t);var n=i.digest();return i.clean(),n}es.hmac=i3,es.equal=t3.equal,Object.defineProperty(su,"__esModule",{value:!0});var ou=es,fu=or,n3=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ou.hmac(this._hash,i,t);this._hmac=new ou.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i<t.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[i]=this._buffer[this._bufpos++];return t},r.prototype.clean=function(){this._hmac.clean(),fu.wipe(this._buffer),fu.wipe(this._counter),this._bufpos=0},r}(),s3=su.HKDF=n3,ts={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=or;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._temp),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._temp,this._state,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,y=h/536870912|0,I=h<<3,M=h%64<56?64:128;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(y,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._temp,this._state,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/4;D++)e.writeUint32BE(this._state[D],u,D*4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.state),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA256=i;var n=new Int32Array([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]);function s(f,u,h,g,y){for(;y>=64;){for(var I=u[0],M=u[1],D=u[2],P=u[3],k=u[4],K=u[5],C=u[6],j=u[7],F=0;F<16;F++){var U=g+F*4;f[F]=e.readUint32BE(h,U)}for(var F=16;F<64;F++){var z=f[F-2],_=(z>>>17|z<<32-17)^(z>>>19|z<<32-19)^z>>>10;z=f[F-15];var R=(z>>>7|z<<32-7)^(z>>>18|z<<32-18)^z>>>3;f[F]=(_+f[F-7]|0)+(R+f[F-16]|0)}for(var F=0;F<64;F++){var _=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&K^~k&C)|0)+(j+(n[F]+f[F]|0)|0)|0,R=((I>>>2|I<<32-2)^(I>>>13|I<<32-13)^(I>>>22|I<<32-22))+(I&M^I&D^M&D)|0;j=C,C=K,K=k,k=P+_|0,P=D,D=M,M=I,I=_+R|0}u[0]+=I,u[1]+=M,u[2]+=D,u[3]+=P,u[4]+=k,u[5]+=K,u[6]+=C,u[7]+=j,g+=64,y-=64}return g}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(ts);var zo={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=xi,t=or;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(F){const U=new Float64Array(16);if(F)for(let z=0;z<F.length;z++)U[z]=F[z];return U}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(F){let U=1;for(let z=0;z<16;z++){let _=F[z]+U+65535;U=Math.floor(_/65536),F[z]=_-U*65536}F[0]+=U-1+37*(U-1)}function f(F,U,z){const _=~(z-1);for(let R=0;R<16;R++){const J=_&(F[R]^U[R]);F[R]^=J,U[R]^=J}}function u(F,U){const z=i(),_=i();for(let R=0;R<16;R++)_[R]=U[R];o(_),o(_),o(_);for(let R=0;R<2;R++){z[0]=_[0]-65517;for(let Q=1;Q<15;Q++)z[Q]=_[Q]-65535-(z[Q-1]>>16&1),z[Q-1]&=65535;z[15]=_[15]-32767-(z[14]>>16&1);const J=z[15]>>16&1;z[14]&=65535,f(_,z,1-J)}for(let R=0;R<16;R++)F[2*R]=_[R]&255,F[2*R+1]=_[R]>>8}function h(F,U){for(let z=0;z<16;z++)F[z]=U[2*z]+(U[2*z+1]<<8);F[15]&=32767}function g(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]+z[_]}function y(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]-z[_]}function I(F,U,z){let _,R,J=0,Q=0,N=0,p=0,l=0,a=0,c=0,b=0,A=0,E=0,x=0,d=0,w=0,v=0,O=0,W=0,S=0,H=0,T=0,q=0,B=0,m=0,L=0,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Ne=0,xe=z[0],ae=z[1],ve=z[2],le=z[3],ne=z[4],ue=z[5],fe=z[6],te=z[7],pe=z[8],_e=z[9],re=z[10],Ae=z[11],Ee=z[12],oe=z[13],De=z[14],Me=z[15];_=U[0],J+=_*xe,Q+=_*ae,N+=_*ve,p+=_*le,l+=_*ne,a+=_*ue,c+=_*fe,b+=_*te,A+=_*pe,E+=_*_e,x+=_*re,d+=_*Ae,w+=_*Ee,v+=_*oe,O+=_*De,W+=_*Me,_=U[1],Q+=_*xe,N+=_*ae,p+=_*ve,l+=_*le,a+=_*ne,c+=_*ue,b+=_*fe,A+=_*te,E+=_*pe,x+=_*_e,d+=_*re,w+=_*Ae,v+=_*Ee,O+=_*oe,W+=_*De,S+=_*Me,_=U[2],N+=_*xe,p+=_*ae,l+=_*ve,a+=_*le,c+=_*ne,b+=_*ue,A+=_*fe,E+=_*te,x+=_*pe,d+=_*_e,w+=_*re,v+=_*Ae,O+=_*Ee,W+=_*oe,S+=_*De,H+=_*Me,_=U[3],p+=_*xe,l+=_*ae,a+=_*ve,c+=_*le,b+=_*ne,A+=_*ue,E+=_*fe,x+=_*te,d+=_*pe,w+=_*_e,v+=_*re,O+=_*Ae,W+=_*Ee,S+=_*oe,H+=_*De,T+=_*Me,_=U[4],l+=_*xe,a+=_*ae,c+=_*ve,b+=_*le,A+=_*ne,E+=_*ue,x+=_*fe,d+=_*te,w+=_*pe,v+=_*_e,O+=_*re,W+=_*Ae,S+=_*Ee,H+=_*oe,T+=_*De,q+=_*Me,_=U[5],a+=_*xe,c+=_*ae,b+=_*ve,A+=_*le,E+=_*ne,x+=_*ue,d+=_*fe,w+=_*te,v+=_*pe,O+=_*_e,W+=_*re,S+=_*Ae,H+=_*Ee,T+=_*oe,q+=_*De,B+=_*Me,_=U[6],c+=_*xe,b+=_*ae,A+=_*ve,E+=_*le,x+=_*ne,d+=_*ue,w+=_*fe,v+=_*te,O+=_*pe,W+=_*_e,S+=_*re,H+=_*Ae,T+=_*Ee,q+=_*oe,B+=_*De,m+=_*Me,_=U[7],b+=_*xe,A+=_*ae,E+=_*ve,x+=_*le,d+=_*ne,w+=_*ue,v+=_*fe,O+=_*te,W+=_*pe,S+=_*_e,H+=_*re,T+=_*Ae,q+=_*Ee,B+=_*oe,m+=_*De,L+=_*Me,_=U[8],A+=_*xe,E+=_*ae,x+=_*ve,d+=_*le,w+=_*ne,v+=_*ue,O+=_*fe,W+=_*te,S+=_*pe,H+=_*_e,T+=_*re,q+=_*Ae,B+=_*Ee,m+=_*oe,L+=_*De,G+=_*Me,_=U[9],E+=_*xe,x+=_*ae,d+=_*ve,w+=_*le,v+=_*ne,O+=_*ue,W+=_*fe,S+=_*te,H+=_*pe,T+=_*_e,q+=_*re,B+=_*Ae,m+=_*Ee,L+=_*oe,G+=_*De,Y+=_*Me,_=U[10],x+=_*xe,d+=_*ae,w+=_*ve,v+=_*le,O+=_*ne,W+=_*ue,S+=_*fe,H+=_*te,T+=_*pe,q+=_*_e,B+=_*re,m+=_*Ae,L+=_*Ee,G+=_*oe,Y+=_*De,X+=_*Me,_=U[11],d+=_*xe,w+=_*ae,v+=_*ve,O+=_*le,W+=_*ne,S+=_*ue,H+=_*fe,T+=_*te,q+=_*pe,B+=_*_e,m+=_*re,L+=_*Ae,G+=_*Ee,Y+=_*oe,X+=_*De,ee+=_*Me,_=U[12],w+=_*xe,v+=_*ae,O+=_*ve,W+=_*le,S+=_*ne,H+=_*ue,T+=_*fe,q+=_*te,B+=_*pe,m+=_*_e,L+=_*re,G+=_*Ae,Y+=_*Ee,X+=_*oe,ee+=_*De,we+=_*Me,_=U[13],v+=_*xe,O+=_*ae,W+=_*ve,S+=_*le,H+=_*ne,T+=_*ue,q+=_*fe,B+=_*te,m+=_*pe,L+=_*_e,G+=_*re,Y+=_*Ae,X+=_*Ee,ee+=_*oe,we+=_*De,Se+=_*Me,_=U[14],O+=_*xe,W+=_*ae,S+=_*ve,H+=_*le,T+=_*ne,q+=_*ue,B+=_*fe,m+=_*te,L+=_*pe,G+=_*_e,Y+=_*re,X+=_*Ae,ee+=_*Ee,we+=_*oe,Se+=_*De,he+=_*Me,_=U[15],W+=_*xe,S+=_*ae,H+=_*ve,T+=_*le,q+=_*ne,B+=_*ue,m+=_*fe,L+=_*te,G+=_*pe,Y+=_*_e,X+=_*re,ee+=_*Ae,we+=_*Ee,Se+=_*oe,he+=_*De,Ne+=_*Me,J+=38*S,Q+=38*H,N+=38*T,p+=38*q,l+=38*B,a+=38*m,c+=38*L,b+=38*G,A+=38*Y,E+=38*X,x+=38*ee,d+=38*we,w+=38*Se,v+=38*he,O+=38*Ne,R=1,_=J+R+65535,R=Math.floor(_/65536),J=_-R*65536,_=Q+R+65535,R=Math.floor(_/65536),Q=_-R*65536,_=N+R+65535,R=Math.floor(_/65536),N=_-R*65536,_=p+R+65535,R=Math.floor(_/65536),p=_-R*65536,_=l+R+65535,R=Math.floor(_/65536),l=_-R*65536,_=a+R+65535,R=Math.floor(_/65536),a=_-R*65536,_=c+R+65535,R=Math.floor(_/65536),c=_-R*65536,_=b+R+65535,R=Math.floor(_/65536),b=_-R*65536,_=A+R+65535,R=Math.floor(_/65536),A=_-R*65536,_=E+R+65535,R=Math.floor(_/65536),E=_-R*65536,_=x+R+65535,R=Math.floor(_/65536),x=_-R*65536,_=d+R+65535,R=Math.floor(_/65536),d=_-R*65536,_=w+R+65535,R=Math.floor(_/65536),w=_-R*65536,_=v+R+65535,R=Math.floor(_/65536),v=_-R*65536,_=O+R+65535,R=Math.floor(_/65536),O=_-R*65536,_=W+R+65535,R=Math.floor(_/65536),W=_-R*65536,J+=R-1+37*(R-1),R=1,_=J+R+65535,R=Math.floor(_/65536),J=_-R*65536,_=Q+R+65535,R=Math.floor(_/65536),Q=_-R*65536,_=N+R+65535,R=Math.floor(_/65536),N=_-R*65536,_=p+R+65535,R=Math.floor(_/65536),p=_-R*65536,_=l+R+65535,R=Math.floor(_/65536),l=_-R*65536,_=a+R+65535,R=Math.floor(_/65536),a=_-R*65536,_=c+R+65535,R=Math.floor(_/65536),c=_-R*65536,_=b+R+65535,R=Math.floor(_/65536),b=_-R*65536,_=A+R+65535,R=Math.floor(_/65536),A=_-R*65536,_=E+R+65535,R=Math.floor(_/65536),E=_-R*65536,_=x+R+65535,R=Math.floor(_/65536),x=_-R*65536,_=d+R+65535,R=Math.floor(_/65536),d=_-R*65536,_=w+R+65535,R=Math.floor(_/65536),w=_-R*65536,_=v+R+65535,R=Math.floor(_/65536),v=_-R*65536,_=O+R+65535,R=Math.floor(_/65536),O=_-R*65536,_=W+R+65535,R=Math.floor(_/65536),W=_-R*65536,J+=R-1+37*(R-1),F[0]=J,F[1]=Q,F[2]=N,F[3]=p,F[4]=l,F[5]=a,F[6]=c,F[7]=b,F[8]=A,F[9]=E,F[10]=x,F[11]=d,F[12]=w,F[13]=v,F[14]=O,F[15]=W}function M(F,U){I(F,U,U)}function D(F,U){const z=i();for(let _=0;_<16;_++)z[_]=U[_];for(let _=253;_>=0;_--)M(z,z),_!==2&&_!==4&&I(z,z,U);for(let _=0;_<16;_++)F[_]=z[_]}function P(F,U){const z=new Uint8Array(32),_=new Float64Array(80),R=i(),J=i(),Q=i(),N=i(),p=i(),l=i();for(let A=0;A<31;A++)z[A]=F[A];z[31]=F[31]&127|64,z[0]&=248,h(_,U);for(let A=0;A<16;A++)J[A]=_[A];R[0]=N[0]=1;for(let A=254;A>=0;--A){const E=z[A>>>3]>>>(A&7)&1;f(R,J,E),f(Q,N,E),g(p,R,Q),y(R,R,Q),g(Q,J,N),y(J,J,N),M(N,p),M(l,R),I(R,Q,R),I(Q,J,p),g(p,R,Q),y(R,R,Q),M(J,R),y(Q,N,l),I(R,Q,s),g(R,R,N),I(Q,Q,R),I(R,N,l),I(N,J,_),M(J,p),f(R,J,E),f(Q,N,E)}for(let A=0;A<16;A++)_[A+16]=R[A],_[A+32]=Q[A],_[A+48]=J[A],_[A+64]=N[A];const a=_.subarray(32),c=_.subarray(16);D(a,a),I(c,c,a);const b=new Uint8Array(32);return u(b,c),b}r.scalarMult=P;function k(F){return P(F,n)}r.scalarMultBase=k;function K(F){if(F.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const U=new Uint8Array(F);return{publicKey:k(U),secretKey:U}}r.generateKeyPairFromSeed=K;function C(F){const U=(0,e.randomBytes)(32,F),z=K(U);return(0,t.wipe)(U),z}r.generateKeyPair=C;function j(F,U,z=!1){if(F.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(U.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const _=P(F,U);if(z){let R=0;for(let J=0;J<_.length;J++)R|=_[J];if(R===0)throw new Error("X25519: invalid shared key")}return _}r.sharedKey=j})(zo);var cu={},a3="elliptic",o3="6.6.1",f3="EC cryptography",c3="lib/elliptic.js",h3=["lib"],u3={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},d3={type:"git",url:"git@github.com:indutny/elliptic"},l3=["EC","Elliptic","curve","Cryptography"],p3="Fedor Indutny <fedor@indutny.com>",g3="MIT",b3={url:"https://github.com/indutny/elliptic/issues"},v3="https://github.com/indutny/elliptic",m3={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},y3={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},w3={name:a3,version:o3,description:f3,main:c3,files:h3,scripts:u3,repository:d3,keywords:l3,author:p3,license:g3,bugs:b3,homepage:v3,devDependencies:m3,dependencies:y3},ur={},Gr={exports:{}};(function(r){(function(e,t){function i(N,p){if(!N)throw new Error(p||"Assertion failed")}function n(N,p){N.super_=p;var l=function(){};l.prototype=p.prototype,N.prototype=new l,N.prototype.constructor=N}function s(N,p,l){if(s.isBN(N))return N;this.negative=0,this.words=null,this.length=0,this.red=null,N!==null&&((p==="le"||p==="be")&&(l=p,p=10),this._init(N||0,p||10,l||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Us.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,l){return p.cmp(l)>0?p:l},s.min=function(p,l){return p.cmp(l)<0?p:l},s.prototype._init=function(p,l,a){if(typeof p=="number")return this._initNumber(p,l,a);if(typeof p=="object")return this._initArray(p,l,a);l==="hex"&&(l=16),i(l===(l|0)&&l>=2&&l<=36),p=p.toString().replace(/\s+/g,"");var c=0;p[0]==="-"&&(c++,this.negative=1),c<p.length&&(l===16?this._parseHex(p,c,a):(this._parseBase(p,l,c),a==="le"&&this._initArray(this.toArray(),l,a)))},s.prototype._initNumber=function(p,l,a){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):(i(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),a==="le"&&this._initArray(this.toArray(),l,a)},s.prototype._initArray=function(p,l,a){if(i(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 c=0;c<this.length;c++)this.words[c]=0;var b,A,E=0;if(a==="be")for(c=p.length-1,b=0;c>=0;c-=3)A=p[c]|p[c-1]<<8|p[c-2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);else if(a==="le")for(c=0,b=0;c<p.length;c+=3)A=p[c]|p[c+1]<<8|p[c+2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);return this.strip()};function f(N,p){var l=N.charCodeAt(p);return l>=65&&l<=70?l-55:l>=97&&l<=102?l-87:l-48&15}function u(N,p,l){var a=f(N,l);return l-1>=p&&(a|=f(N,l-1)<<4),a}s.prototype._parseHex=function(p,l,a){this.length=Math.ceil((p.length-l)/6),this.words=new Array(this.length);for(var c=0;c<this.length;c++)this.words[c]=0;var b=0,A=0,E;if(a==="be")for(c=p.length-1;c>=l;c-=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8;else{var x=p.length-l;for(c=x%2===0?l+1:l;c<p.length;c+=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8}this.strip()};function h(N,p,l,a){for(var c=0,b=Math.min(N.length,l),A=p;A<b;A++){var E=N.charCodeAt(A)-48;c*=a,E>=49?c+=E-49+10:E>=17?c+=E-17+10:c+=E}return c}s.prototype._parseBase=function(p,l,a){this.words=[0],this.length=1;for(var c=0,b=1;b<=67108863;b*=l)c++;c--,b=b/l|0;for(var A=p.length-a,E=A%c,x=Math.min(A,A-E)+a,d=0,w=a;w<x;w+=c)d=h(p,w,w+c,l),this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(E!==0){var v=1;for(d=h(p,w,p.length,l),w=0;w<E;w++)v*=l;this.imuln(v),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var l=0;l<this.length;l++)p.words[l]=this.words[l];p.length=this.length,p.negative=this.negative,p.red=this.red},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},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var g=["","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"],y=[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],I=[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,l){p=p||10,l=l|0||1;var a;if(p===16||p==="hex"){a="";for(var c=0,b=0,A=0;A<this.length;A++){var E=this.words[A],x=((E<<c|b)&16777215).toString(16);b=E>>>24-c&16777215,c+=2,c>=26&&(c-=26,A--),b!==0||A!==this.length-1?a=g[6-x.length]+x+a:a=x+a}for(b!==0&&(a=b.toString(16)+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}if(p===(p|0)&&p>=2&&p<=36){var d=y[p],w=I[p];a="";var v=this.clone();for(v.negative=0;!v.isZero();){var O=v.modn(w).toString(p);v=v.idivn(w),v.isZero()?a=O+a:a=g[d-O.length]+O+a}for(this.isZero()&&(a="0"+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}i(!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&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(p,l){return i(typeof o<"u"),this.toArrayLike(o,p,l)},s.prototype.toArray=function(p,l){return this.toArrayLike(Array,p,l)},s.prototype.toArrayLike=function(p,l,a){var c=this.byteLength(),b=a||Math.max(1,c);i(c<=b,"byte array longer than desired length"),i(b>0,"Requested array length <= 0"),this.strip();var A=l==="le",E=new p(b),x,d,w=this.clone();if(A){for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[d]=x;for(;d<b;d++)E[d]=0}else{for(d=0;d<b-c;d++)E[d]=0;for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[b-d-1]=x}return E},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var l=p,a=0;return l>=4096&&(a+=13,l>>>=13),l>=64&&(a+=7,l>>>=7),l>=8&&(a+=4,l>>>=4),l>=2&&(a+=2,l>>>=2),a+l},s.prototype._zeroBits=function(p){if(p===0)return 26;var l=p,a=0;return l&8191||(a+=13,l>>>=13),l&127||(a+=7,l>>>=7),l&15||(a+=4,l>>>=4),l&3||(a+=2,l>>>=2),l&1||a++,a},s.prototype.bitLength=function(){var p=this.words[this.length-1],l=this._countBits(p);return(this.length-1)*26+l};function M(N){for(var p=new Array(N.bitLength()),l=0;l<p.length;l++){var a=l/26|0,c=l%26;p[l]=(N.words[a]&1<<c)>>>c}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,l=0;l<this.length;l++){var a=this._zeroBits(this.words[l]);if(p+=a,a!==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 l=0;l<p.length;l++)this.words[l]=this.words[l]|p.words[l];return this.strip()},s.prototype.ior=function(p){return i((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 l;this.length>p.length?l=p:l=this;for(var a=0;a<l.length;a++)this.words[a]=this.words[a]&p.words[a];return this.length=l.length,this.strip()},s.prototype.iand=function(p){return i((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 l,a;this.length>p.length?(l=this,a=p):(l=p,a=this);for(var c=0;c<a.length;c++)this.words[c]=l.words[c]^a.words[c];if(this!==l)for(;c<l.length;c++)this.words[c]=l.words[c];return this.length=l.length,this.strip()},s.prototype.ixor=function(p){return i((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){i(typeof p=="number"&&p>=0);var l=Math.ceil(p/26)|0,a=p%26;this._expand(l),a>0&&l--;for(var c=0;c<l;c++)this.words[c]=~this.words[c]&67108863;return a>0&&(this.words[c]=~this.words[c]&67108863>>26-a),this.strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,l){i(typeof p=="number"&&p>=0);var a=p/26|0,c=p%26;return this._expand(a+1),l?this.words[a]=this.words[a]|1<<c:this.words[a]=this.words[a]&~(1<<c),this.strip()},s.prototype.iadd=function(p){var l;if(this.negative!==0&&p.negative===0)return this.negative=0,l=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,l=this.isub(p),p.negative=1,l._normSign();var a,c;this.length>p.length?(a=this,c=p):(a=p,c=this);for(var b=0,A=0;A<c.length;A++)l=(a.words[A]|0)+(c.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;for(;b!==0&&A<a.length;A++)l=(a.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;if(this.length=a.length,b!==0)this.words[this.length]=b,this.length++;else if(a!==this)for(;A<a.length;A++)this.words[A]=a.words[A];return this},s.prototype.add=function(p){var l;return p.negative!==0&&this.negative===0?(p.negative=0,l=this.sub(p),p.negative^=1,l):p.negative===0&&this.negative!==0?(this.negative=0,l=p.sub(this),this.negative=1,l):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 l=this.iadd(p);return p.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var a=this.cmp(p);if(a===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,b;a>0?(c=this,b=p):(c=p,b=this);for(var A=0,E=0;E<b.length;E++)l=(c.words[E]|0)-(b.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;for(;A!==0&&E<c.length;E++)l=(c.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;if(A===0&&E<c.length&&c!==this)for(;E<c.length;E++)this.words[E]=c.words[E];return this.length=Math.max(this.length,E),c!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function D(N,p,l){l.negative=p.negative^N.negative;var a=N.length+p.length|0;l.length=a,a=a-1|0;var c=N.words[0]|0,b=p.words[0]|0,A=c*b,E=A&67108863,x=A/67108864|0;l.words[0]=E;for(var d=1;d<a;d++){for(var w=x>>>26,v=x&67108863,O=Math.min(d,p.length-1),W=Math.max(0,d-N.length+1);W<=O;W++){var S=d-W|0;c=N.words[S]|0,b=p.words[W]|0,A=c*b+v,w+=A/67108864|0,v=A&67108863}l.words[d]=v|0,x=w|0}return x!==0?l.words[d]=x|0:l.length--,l.strip()}var P=function(p,l,a){var c=p.words,b=l.words,A=a.words,E=0,x,d,w,v=c[0]|0,O=v&8191,W=v>>>13,S=c[1]|0,H=S&8191,T=S>>>13,q=c[2]|0,B=q&8191,m=q>>>13,L=c[3]|0,G=L&8191,Y=L>>>13,X=c[4]|0,ee=X&8191,we=X>>>13,Se=c[5]|0,he=Se&8191,Ne=Se>>>13,xe=c[6]|0,ae=xe&8191,ve=xe>>>13,le=c[7]|0,ne=le&8191,ue=le>>>13,fe=c[8]|0,te=fe&8191,pe=fe>>>13,_e=c[9]|0,re=_e&8191,Ae=_e>>>13,Ee=b[0]|0,oe=Ee&8191,De=Ee>>>13,Me=b[1]|0,Oe=Me&8191,We=Me>>>13,Qe=b[2]|0,Ie=Qe&8191,et=Qe>>>13,tt=b[3]|0,Pe=tt&8191,Te=tt>>>13,Ce=b[4]|0,de=Ce&8191,Fe=Ce>>>13,Be=b[5]|0,ce=Be&8191,Ue=Be>>>13,$e=b[6]|0,me=$e&8191,ze=$e>>>13,ke=b[7]|0,ge=ke&8191,Le=ke>>>13,Re=b[8]|0,ye=Re&8191,Ke=Re>>>13,it=b[9]|0,qe=it&8191,nt=it>>>13;a.negative=p.negative^l.negative,a.length=19,x=Math.imul(O,oe),d=Math.imul(O,De),d=d+Math.imul(W,oe)|0,w=Math.imul(W,De);var Je=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Je>>>26)|0,Je&=67108863,x=Math.imul(H,oe),d=Math.imul(H,De),d=d+Math.imul(T,oe)|0,w=Math.imul(T,De),x=x+Math.imul(O,Oe)|0,d=d+Math.imul(O,We)|0,d=d+Math.imul(W,Oe)|0,w=w+Math.imul(W,We)|0;var rt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(rt>>>26)|0,rt&=67108863,x=Math.imul(B,oe),d=Math.imul(B,De),d=d+Math.imul(m,oe)|0,w=Math.imul(m,De),x=x+Math.imul(H,Oe)|0,d=d+Math.imul(H,We)|0,d=d+Math.imul(T,Oe)|0,w=w+Math.imul(T,We)|0,x=x+Math.imul(O,Ie)|0,d=d+Math.imul(O,et)|0,d=d+Math.imul(W,Ie)|0,w=w+Math.imul(W,et)|0;var ir=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ir>>>26)|0,ir&=67108863,x=Math.imul(G,oe),d=Math.imul(G,De),d=d+Math.imul(Y,oe)|0,w=Math.imul(Y,De),x=x+Math.imul(B,Oe)|0,d=d+Math.imul(B,We)|0,d=d+Math.imul(m,Oe)|0,w=w+Math.imul(m,We)|0,x=x+Math.imul(H,Ie)|0,d=d+Math.imul(H,et)|0,d=d+Math.imul(T,Ie)|0,w=w+Math.imul(T,et)|0,x=x+Math.imul(O,Pe)|0,d=d+Math.imul(O,Te)|0,d=d+Math.imul(W,Pe)|0,w=w+Math.imul(W,Te)|0;var nr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,x=Math.imul(ee,oe),d=Math.imul(ee,De),d=d+Math.imul(we,oe)|0,w=Math.imul(we,De),x=x+Math.imul(G,Oe)|0,d=d+Math.imul(G,We)|0,d=d+Math.imul(Y,Oe)|0,w=w+Math.imul(Y,We)|0,x=x+Math.imul(B,Ie)|0,d=d+Math.imul(B,et)|0,d=d+Math.imul(m,Ie)|0,w=w+Math.imul(m,et)|0,x=x+Math.imul(H,Pe)|0,d=d+Math.imul(H,Te)|0,d=d+Math.imul(T,Pe)|0,w=w+Math.imul(T,Te)|0,x=x+Math.imul(O,de)|0,d=d+Math.imul(O,Fe)|0,d=d+Math.imul(W,de)|0,w=w+Math.imul(W,Fe)|0;var sr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(sr>>>26)|0,sr&=67108863,x=Math.imul(he,oe),d=Math.imul(he,De),d=d+Math.imul(Ne,oe)|0,w=Math.imul(Ne,De),x=x+Math.imul(ee,Oe)|0,d=d+Math.imul(ee,We)|0,d=d+Math.imul(we,Oe)|0,w=w+Math.imul(we,We)|0,x=x+Math.imul(G,Ie)|0,d=d+Math.imul(G,et)|0,d=d+Math.imul(Y,Ie)|0,w=w+Math.imul(Y,et)|0,x=x+Math.imul(B,Pe)|0,d=d+Math.imul(B,Te)|0,d=d+Math.imul(m,Pe)|0,w=w+Math.imul(m,Te)|0,x=x+Math.imul(H,de)|0,d=d+Math.imul(H,Fe)|0,d=d+Math.imul(T,de)|0,w=w+Math.imul(T,Fe)|0,x=x+Math.imul(O,ce)|0,d=d+Math.imul(O,Ue)|0,d=d+Math.imul(W,ce)|0,w=w+Math.imul(W,Ue)|0;var ar=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,x=Math.imul(ae,oe),d=Math.imul(ae,De),d=d+Math.imul(ve,oe)|0,w=Math.imul(ve,De),x=x+Math.imul(he,Oe)|0,d=d+Math.imul(he,We)|0,d=d+Math.imul(Ne,Oe)|0,w=w+Math.imul(Ne,We)|0,x=x+Math.imul(ee,Ie)|0,d=d+Math.imul(ee,et)|0,d=d+Math.imul(we,Ie)|0,w=w+Math.imul(we,et)|0,x=x+Math.imul(G,Pe)|0,d=d+Math.imul(G,Te)|0,d=d+Math.imul(Y,Pe)|0,w=w+Math.imul(Y,Te)|0,x=x+Math.imul(B,de)|0,d=d+Math.imul(B,Fe)|0,d=d+Math.imul(m,de)|0,w=w+Math.imul(m,Fe)|0,x=x+Math.imul(H,ce)|0,d=d+Math.imul(H,Ue)|0,d=d+Math.imul(T,ce)|0,w=w+Math.imul(T,Ue)|0,x=x+Math.imul(O,me)|0,d=d+Math.imul(O,ze)|0,d=d+Math.imul(W,me)|0,w=w+Math.imul(W,ze)|0;var yt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(yt>>>26)|0,yt&=67108863,x=Math.imul(ne,oe),d=Math.imul(ne,De),d=d+Math.imul(ue,oe)|0,w=Math.imul(ue,De),x=x+Math.imul(ae,Oe)|0,d=d+Math.imul(ae,We)|0,d=d+Math.imul(ve,Oe)|0,w=w+Math.imul(ve,We)|0,x=x+Math.imul(he,Ie)|0,d=d+Math.imul(he,et)|0,d=d+Math.imul(Ne,Ie)|0,w=w+Math.imul(Ne,et)|0,x=x+Math.imul(ee,Pe)|0,d=d+Math.imul(ee,Te)|0,d=d+Math.imul(we,Pe)|0,w=w+Math.imul(we,Te)|0,x=x+Math.imul(G,de)|0,d=d+Math.imul(G,Fe)|0,d=d+Math.imul(Y,de)|0,w=w+Math.imul(Y,Fe)|0,x=x+Math.imul(B,ce)|0,d=d+Math.imul(B,Ue)|0,d=d+Math.imul(m,ce)|0,w=w+Math.imul(m,Ue)|0,x=x+Math.imul(H,me)|0,d=d+Math.imul(H,ze)|0,d=d+Math.imul(T,me)|0,w=w+Math.imul(T,ze)|0,x=x+Math.imul(O,ge)|0,d=d+Math.imul(O,Le)|0,d=d+Math.imul(W,ge)|0,w=w+Math.imul(W,Le)|0;var ui=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ui>>>26)|0,ui&=67108863,x=Math.imul(te,oe),d=Math.imul(te,De),d=d+Math.imul(pe,oe)|0,w=Math.imul(pe,De),x=x+Math.imul(ne,Oe)|0,d=d+Math.imul(ne,We)|0,d=d+Math.imul(ue,Oe)|0,w=w+Math.imul(ue,We)|0,x=x+Math.imul(ae,Ie)|0,d=d+Math.imul(ae,et)|0,d=d+Math.imul(ve,Ie)|0,w=w+Math.imul(ve,et)|0,x=x+Math.imul(he,Pe)|0,d=d+Math.imul(he,Te)|0,d=d+Math.imul(Ne,Pe)|0,w=w+Math.imul(Ne,Te)|0,x=x+Math.imul(ee,de)|0,d=d+Math.imul(ee,Fe)|0,d=d+Math.imul(we,de)|0,w=w+Math.imul(we,Fe)|0,x=x+Math.imul(G,ce)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(Y,ce)|0,w=w+Math.imul(Y,Ue)|0,x=x+Math.imul(B,me)|0,d=d+Math.imul(B,ze)|0,d=d+Math.imul(m,me)|0,w=w+Math.imul(m,ze)|0,x=x+Math.imul(H,ge)|0,d=d+Math.imul(H,Le)|0,d=d+Math.imul(T,ge)|0,w=w+Math.imul(T,Le)|0,x=x+Math.imul(O,ye)|0,d=d+Math.imul(O,Ke)|0,d=d+Math.imul(W,ye)|0,w=w+Math.imul(W,Ke)|0;var di=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(di>>>26)|0,di&=67108863,x=Math.imul(re,oe),d=Math.imul(re,De),d=d+Math.imul(Ae,oe)|0,w=Math.imul(Ae,De),x=x+Math.imul(te,Oe)|0,d=d+Math.imul(te,We)|0,d=d+Math.imul(pe,Oe)|0,w=w+Math.imul(pe,We)|0,x=x+Math.imul(ne,Ie)|0,d=d+Math.imul(ne,et)|0,d=d+Math.imul(ue,Ie)|0,w=w+Math.imul(ue,et)|0,x=x+Math.imul(ae,Pe)|0,d=d+Math.imul(ae,Te)|0,d=d+Math.imul(ve,Pe)|0,w=w+Math.imul(ve,Te)|0,x=x+Math.imul(he,de)|0,d=d+Math.imul(he,Fe)|0,d=d+Math.imul(Ne,de)|0,w=w+Math.imul(Ne,Fe)|0,x=x+Math.imul(ee,ce)|0,d=d+Math.imul(ee,Ue)|0,d=d+Math.imul(we,ce)|0,w=w+Math.imul(we,Ue)|0,x=x+Math.imul(G,me)|0,d=d+Math.imul(G,ze)|0,d=d+Math.imul(Y,me)|0,w=w+Math.imul(Y,ze)|0,x=x+Math.imul(B,ge)|0,d=d+Math.imul(B,Le)|0,d=d+Math.imul(m,ge)|0,w=w+Math.imul(m,Le)|0,x=x+Math.imul(H,ye)|0,d=d+Math.imul(H,Ke)|0,d=d+Math.imul(T,ye)|0,w=w+Math.imul(T,Ke)|0,x=x+Math.imul(O,qe)|0,d=d+Math.imul(O,nt)|0,d=d+Math.imul(W,qe)|0,w=w+Math.imul(W,nt)|0;var li=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(li>>>26)|0,li&=67108863,x=Math.imul(re,Oe),d=Math.imul(re,We),d=d+Math.imul(Ae,Oe)|0,w=Math.imul(Ae,We),x=x+Math.imul(te,Ie)|0,d=d+Math.imul(te,et)|0,d=d+Math.imul(pe,Ie)|0,w=w+Math.imul(pe,et)|0,x=x+Math.imul(ne,Pe)|0,d=d+Math.imul(ne,Te)|0,d=d+Math.imul(ue,Pe)|0,w=w+Math.imul(ue,Te)|0,x=x+Math.imul(ae,de)|0,d=d+Math.imul(ae,Fe)|0,d=d+Math.imul(ve,de)|0,w=w+Math.imul(ve,Fe)|0,x=x+Math.imul(he,ce)|0,d=d+Math.imul(he,Ue)|0,d=d+Math.imul(Ne,ce)|0,w=w+Math.imul(Ne,Ue)|0,x=x+Math.imul(ee,me)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(we,me)|0,w=w+Math.imul(we,ze)|0,x=x+Math.imul(G,ge)|0,d=d+Math.imul(G,Le)|0,d=d+Math.imul(Y,ge)|0,w=w+Math.imul(Y,Le)|0,x=x+Math.imul(B,ye)|0,d=d+Math.imul(B,Ke)|0,d=d+Math.imul(m,ye)|0,w=w+Math.imul(m,Ke)|0,x=x+Math.imul(H,qe)|0,d=d+Math.imul(H,nt)|0,d=d+Math.imul(T,qe)|0,w=w+Math.imul(T,nt)|0;var pi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(pi>>>26)|0,pi&=67108863,x=Math.imul(re,Ie),d=Math.imul(re,et),d=d+Math.imul(Ae,Ie)|0,w=Math.imul(Ae,et),x=x+Math.imul(te,Pe)|0,d=d+Math.imul(te,Te)|0,d=d+Math.imul(pe,Pe)|0,w=w+Math.imul(pe,Te)|0,x=x+Math.imul(ne,de)|0,d=d+Math.imul(ne,Fe)|0,d=d+Math.imul(ue,de)|0,w=w+Math.imul(ue,Fe)|0,x=x+Math.imul(ae,ce)|0,d=d+Math.imul(ae,Ue)|0,d=d+Math.imul(ve,ce)|0,w=w+Math.imul(ve,Ue)|0,x=x+Math.imul(he,me)|0,d=d+Math.imul(he,ze)|0,d=d+Math.imul(Ne,me)|0,w=w+Math.imul(Ne,ze)|0,x=x+Math.imul(ee,ge)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(we,ge)|0,w=w+Math.imul(we,Le)|0,x=x+Math.imul(G,ye)|0,d=d+Math.imul(G,Ke)|0,d=d+Math.imul(Y,ye)|0,w=w+Math.imul(Y,Ke)|0,x=x+Math.imul(B,qe)|0,d=d+Math.imul(B,nt)|0,d=d+Math.imul(m,qe)|0,w=w+Math.imul(m,nt)|0;var gi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(gi>>>26)|0,gi&=67108863,x=Math.imul(re,Pe),d=Math.imul(re,Te),d=d+Math.imul(Ae,Pe)|0,w=Math.imul(Ae,Te),x=x+Math.imul(te,de)|0,d=d+Math.imul(te,Fe)|0,d=d+Math.imul(pe,de)|0,w=w+Math.imul(pe,Fe)|0,x=x+Math.imul(ne,ce)|0,d=d+Math.imul(ne,Ue)|0,d=d+Math.imul(ue,ce)|0,w=w+Math.imul(ue,Ue)|0,x=x+Math.imul(ae,me)|0,d=d+Math.imul(ae,ze)|0,d=d+Math.imul(ve,me)|0,w=w+Math.imul(ve,ze)|0,x=x+Math.imul(he,ge)|0,d=d+Math.imul(he,Le)|0,d=d+Math.imul(Ne,ge)|0,w=w+Math.imul(Ne,Le)|0,x=x+Math.imul(ee,ye)|0,d=d+Math.imul(ee,Ke)|0,d=d+Math.imul(we,ye)|0,w=w+Math.imul(we,Ke)|0,x=x+Math.imul(G,qe)|0,d=d+Math.imul(G,nt)|0,d=d+Math.imul(Y,qe)|0,w=w+Math.imul(Y,nt)|0;var Er=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Er>>>26)|0,Er&=67108863,x=Math.imul(re,de),d=Math.imul(re,Fe),d=d+Math.imul(Ae,de)|0,w=Math.imul(Ae,Fe),x=x+Math.imul(te,ce)|0,d=d+Math.imul(te,Ue)|0,d=d+Math.imul(pe,ce)|0,w=w+Math.imul(pe,Ue)|0,x=x+Math.imul(ne,me)|0,d=d+Math.imul(ne,ze)|0,d=d+Math.imul(ue,me)|0,w=w+Math.imul(ue,ze)|0,x=x+Math.imul(ae,ge)|0,d=d+Math.imul(ae,Le)|0,d=d+Math.imul(ve,ge)|0,w=w+Math.imul(ve,Le)|0,x=x+Math.imul(he,ye)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Ne,ye)|0,w=w+Math.imul(Ne,Ke)|0,x=x+Math.imul(ee,qe)|0,d=d+Math.imul(ee,nt)|0,d=d+Math.imul(we,qe)|0,w=w+Math.imul(we,nt)|0;var bi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(bi>>>26)|0,bi&=67108863,x=Math.imul(re,ce),d=Math.imul(re,Ue),d=d+Math.imul(Ae,ce)|0,w=Math.imul(Ae,Ue),x=x+Math.imul(te,me)|0,d=d+Math.imul(te,ze)|0,d=d+Math.imul(pe,me)|0,w=w+Math.imul(pe,ze)|0,x=x+Math.imul(ne,ge)|0,d=d+Math.imul(ne,Le)|0,d=d+Math.imul(ue,ge)|0,w=w+Math.imul(ue,Le)|0,x=x+Math.imul(ae,ye)|0,d=d+Math.imul(ae,Ke)|0,d=d+Math.imul(ve,ye)|0,w=w+Math.imul(ve,Ke)|0,x=x+Math.imul(he,qe)|0,d=d+Math.imul(he,nt)|0,d=d+Math.imul(Ne,qe)|0,w=w+Math.imul(Ne,nt)|0;var vi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(vi>>>26)|0,vi&=67108863,x=Math.imul(re,me),d=Math.imul(re,ze),d=d+Math.imul(Ae,me)|0,w=Math.imul(Ae,ze),x=x+Math.imul(te,ge)|0,d=d+Math.imul(te,Le)|0,d=d+Math.imul(pe,ge)|0,w=w+Math.imul(pe,Le)|0,x=x+Math.imul(ne,ye)|0,d=d+Math.imul(ne,Ke)|0,d=d+Math.imul(ue,ye)|0,w=w+Math.imul(ue,Ke)|0,x=x+Math.imul(ae,qe)|0,d=d+Math.imul(ae,nt)|0,d=d+Math.imul(ve,qe)|0,w=w+Math.imul(ve,nt)|0;var jt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(jt>>>26)|0,jt&=67108863,x=Math.imul(re,ge),d=Math.imul(re,Le),d=d+Math.imul(Ae,ge)|0,w=Math.imul(Ae,Le),x=x+Math.imul(te,ye)|0,d=d+Math.imul(te,Ke)|0,d=d+Math.imul(pe,ye)|0,w=w+Math.imul(pe,Ke)|0,x=x+Math.imul(ne,qe)|0,d=d+Math.imul(ne,nt)|0,d=d+Math.imul(ue,qe)|0,w=w+Math.imul(ue,nt)|0;var mi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(mi>>>26)|0,mi&=67108863,x=Math.imul(re,ye),d=Math.imul(re,Ke),d=d+Math.imul(Ae,ye)|0,w=Math.imul(Ae,Ke),x=x+Math.imul(te,qe)|0,d=d+Math.imul(te,nt)|0,d=d+Math.imul(pe,qe)|0,w=w+Math.imul(pe,nt)|0;var yi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(yi>>>26)|0,yi&=67108863,x=Math.imul(re,qe),d=Math.imul(re,nt),d=d+Math.imul(Ae,qe)|0,w=Math.imul(Ae,nt);var wi=(E+x|0)+((d&8191)<<13)|0;return E=(w+(d>>>13)|0)+(wi>>>26)|0,wi&=67108863,A[0]=Je,A[1]=rt,A[2]=ir,A[3]=nr,A[4]=sr,A[5]=ar,A[6]=yt,A[7]=ui,A[8]=di,A[9]=li,A[10]=pi,A[11]=gi,A[12]=Er,A[13]=bi,A[14]=vi,A[15]=jt,A[16]=mi,A[17]=yi,A[18]=wi,E!==0&&(A[19]=E,a.length++),a};Math.imul||(P=D);function k(N,p,l){l.negative=p.negative^N.negative,l.length=N.length+p.length;for(var a=0,c=0,b=0;b<l.length-1;b++){var A=c;c=0;for(var E=a&67108863,x=Math.min(b,p.length-1),d=Math.max(0,b-N.length+1);d<=x;d++){var w=b-d,v=N.words[w]|0,O=p.words[d]|0,W=v*O,S=W&67108863;A=A+(W/67108864|0)|0,S=S+E|0,E=S&67108863,A=A+(S>>>26)|0,c+=A>>>26,A&=67108863}l.words[b]=E,a=A,A=c}return a!==0?l.words[b]=a:l.length--,l.strip()}function K(N,p,l){var a=new C;return a.mulp(N,p,l)}s.prototype.mulTo=function(p,l){var a,c=this.length+p.length;return this.length===10&&p.length===10?a=P(this,p,l):c<63?a=D(this,p,l):c<1024?a=k(this,p,l):a=K(this,p,l),a};function C(N,p){this.x=N,this.y=p}C.prototype.makeRBT=function(p){for(var l=new Array(p),a=s.prototype._countBits(p)-1,c=0;c<p;c++)l[c]=this.revBin(c,a,p);return l},C.prototype.revBin=function(p,l,a){if(p===0||p===a-1)return p;for(var c=0,b=0;b<l;b++)c|=(p&1)<<l-b-1,p>>=1;return c},C.prototype.permute=function(p,l,a,c,b,A){for(var E=0;E<A;E++)c[E]=l[p[E]],b[E]=a[p[E]]},C.prototype.transform=function(p,l,a,c,b,A){this.permute(A,p,l,a,c,b);for(var E=1;E<b;E<<=1)for(var x=E<<1,d=Math.cos(2*Math.PI/x),w=Math.sin(2*Math.PI/x),v=0;v<b;v+=x)for(var O=d,W=w,S=0;S<E;S++){var H=a[v+S],T=c[v+S],q=a[v+S+E],B=c[v+S+E],m=O*q-W*B;B=O*B+W*q,q=m,a[v+S]=H+q,c[v+S]=T+B,a[v+S+E]=H-q,c[v+S+E]=T-B,S!==x&&(m=d*O-w*W,W=d*W+w*O,O=m)}},C.prototype.guessLen13b=function(p,l){var a=Math.max(l,p)|1,c=a&1,b=0;for(a=a/2|0;a;a=a>>>1)b++;return 1<<b+1+c},C.prototype.conjugate=function(p,l,a){if(!(a<=1))for(var c=0;c<a/2;c++){var b=p[c];p[c]=p[a-c-1],p[a-c-1]=b,b=l[c],l[c]=-l[a-c-1],l[a-c-1]=-b}},C.prototype.normalize13b=function(p,l){for(var a=0,c=0;c<l/2;c++){var b=Math.round(p[2*c+1]/l)*8192+Math.round(p[2*c]/l)+a;p[c]=b&67108863,b<67108864?a=0:a=b/67108864|0}return p},C.prototype.convert13b=function(p,l,a,c){for(var b=0,A=0;A<l;A++)b=b+(p[A]|0),a[2*A]=b&8191,b=b>>>13,a[2*A+1]=b&8191,b=b>>>13;for(A=2*l;A<c;++A)a[A]=0;i(b===0),i((b&-8192)===0)},C.prototype.stub=function(p){for(var l=new Array(p),a=0;a<p;a++)l[a]=0;return l},C.prototype.mulp=function(p,l,a){var c=2*this.guessLen13b(p.length,l.length),b=this.makeRBT(c),A=this.stub(c),E=new Array(c),x=new Array(c),d=new Array(c),w=new Array(c),v=new Array(c),O=new Array(c),W=a.words;W.length=c,this.convert13b(p.words,p.length,E,c),this.convert13b(l.words,l.length,w,c),this.transform(E,A,x,d,c,b),this.transform(w,A,v,O,c,b);for(var S=0;S<c;S++){var H=x[S]*v[S]-d[S]*O[S];d[S]=x[S]*O[S]+d[S]*v[S],x[S]=H}return this.conjugate(x,d,c),this.transform(x,d,W,A,c,b),this.conjugate(W,A,c),this.normalize13b(W,c),a.negative=p.negative^l.negative,a.length=p.length+l.length,a.strip()},s.prototype.mul=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),this.mulTo(p,l)},s.prototype.mulf=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),K(this,p,l)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){i(typeof p=="number"),i(p<67108864);for(var l=0,a=0;a<this.length;a++){var c=(this.words[a]|0)*p,b=(c&67108863)+(l&67108863);l>>=26,l+=c/67108864|0,l+=b>>>26,this.words[a]=b&67108863}return l!==0&&(this.words[a]=l,this.length++),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 l=M(p);if(l.length===0)return new s(1);for(var a=this,c=0;c<l.length&&l[c]===0;c++,a=a.sqr());if(++c<l.length)for(var b=a.sqr();c<l.length;c++,b=b.sqr())l[c]!==0&&(a=a.mul(b));return a},s.prototype.iushln=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=67108863>>>26-l<<26-l,b;if(l!==0){var A=0;for(b=0;b<this.length;b++){var E=this.words[b]&c,x=(this.words[b]|0)-E<<l;this.words[b]=x|A,A=E>>>26-l}A&&(this.words[b]=A,this.length++)}if(a!==0){for(b=this.length-1;b>=0;b--)this.words[b+a]=this.words[b];for(b=0;b<a;b++)this.words[b]=0;this.length+=a}return this.strip()},s.prototype.ishln=function(p){return i(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,l,a){i(typeof p=="number"&&p>=0);var c;l?c=(l-l%26)/26:c=0;var b=p%26,A=Math.min((p-b)/26,this.length),E=67108863^67108863>>>b<<b,x=a;if(c-=A,c=Math.max(0,c),x){for(var d=0;d<A;d++)x.words[d]=this.words[d];x.length=A}if(A!==0)if(this.length>A)for(this.length-=A,d=0;d<this.length;d++)this.words[d]=this.words[d+A];else this.words[0]=0,this.length=1;var w=0;for(d=this.length-1;d>=0&&(w!==0||d>=c);d--){var v=this.words[d]|0;this.words[d]=w<<26-b|v>>>b,w=v&E}return x&&w!==0&&(x.words[x.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(p,l,a){return i(this.negative===0),this.iushrn(p,l,a)},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){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return!1;var b=this.words[a];return!!(b&c)},s.prototype.imaskn=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=a)return this;if(l!==0&&a++,this.length=Math.min(a,this.length),l!==0){var c=67108863^67108863>>>l<<l;this.words[this.length-1]&=c}return this.strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return i(typeof p=="number"),i(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 l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(p){if(i(typeof p=="number"),i(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 l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+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,l,a){var c=p.length+a,b;this._expand(c);var A,E=0;for(b=0;b<p.length;b++){A=(this.words[b+a]|0)+E;var x=(p.words[b]|0)*l;A-=x&67108863,E=(A>>26)-(x/67108864|0),this.words[b+a]=A&67108863}for(;b<this.length-a;b++)A=(this.words[b+a]|0)+E,E=A>>26,this.words[b+a]=A&67108863;if(E===0)return this.strip();for(i(E===-1),E=0,b=0;b<this.length;b++)A=-(this.words[b]|0)+E,E=A>>26,this.words[b]=A&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(p,l){var a=this.length-p.length,c=this.clone(),b=p,A=b.words[b.length-1]|0,E=this._countBits(A);a=26-E,a!==0&&(b=b.ushln(a),c.iushln(a),A=b.words[b.length-1]|0);var x=c.length-b.length,d;if(l!=="mod"){d=new s(null),d.length=x+1,d.words=new Array(d.length);for(var w=0;w<d.length;w++)d.words[w]=0}var v=c.clone()._ishlnsubmul(b,1,x);v.negative===0&&(c=v,d&&(d.words[x]=1));for(var O=x-1;O>=0;O--){var W=(c.words[b.length+O]|0)*67108864+(c.words[b.length+O-1]|0);for(W=Math.min(W/A|0,67108863),c._ishlnsubmul(b,W,O);c.negative!==0;)W--,c.negative=0,c._ishlnsubmul(b,1,O),c.isZero()||(c.negative^=1);d&&(d.words[O]=W)}return d&&d.strip(),c.strip(),l!=="div"&&a!==0&&c.iushrn(a),{div:d||null,mod:c}},s.prototype.divmod=function(p,l,a){if(i(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var c,b,A;return this.negative!==0&&p.negative===0?(A=this.neg().divmod(p,l),l!=="mod"&&(c=A.div.neg()),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.iadd(p)),{div:c,mod:b}):this.negative===0&&p.negative!==0?(A=this.divmod(p.neg(),l),l!=="mod"&&(c=A.div.neg()),{div:c,mod:A.mod}):this.negative&p.negative?(A=this.neg().divmod(p.neg(),l),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.isub(p)),{div:A.div,mod:b}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?l==="div"?{div:this.divn(p.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modn(p.words[0]))}:this._wordDiv(p,l)},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 l=this.divmod(p);if(l.mod.isZero())return l.div;var a=l.div.negative!==0?l.mod.isub(p):l.mod,c=p.ushrn(1),b=p.andln(1),A=a.cmp(c);return A<0||b===1&&A===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modn=function(p){i(p<=67108863);for(var l=(1<<26)%p,a=0,c=this.length-1;c>=0;c--)a=(l*a+(this.words[c]|0))%p;return a},s.prototype.idivn=function(p){i(p<=67108863);for(var l=0,a=this.length-1;a>=0;a--){var c=(this.words[a]|0)+l*67108864;this.words[a]=c/p|0,l=c%p}return this.strip()},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=new s(0),E=new s(1),x=0;l.isEven()&&a.isEven();)l.iushrn(1),a.iushrn(1),++x;for(var d=a.clone(),w=l.clone();!l.isZero();){for(var v=0,O=1;!(l.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(l.iushrn(v);v-- >0;)(c.isOdd()||b.isOdd())&&(c.iadd(d),b.isub(w)),c.iushrn(1),b.iushrn(1);for(var W=0,S=1;!(a.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(a.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(d),E.isub(w)),A.iushrn(1),E.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(A),b.isub(E)):(a.isub(l),A.isub(c),E.isub(b))}return{a:A,b:E,gcd:a.iushln(x)}},s.prototype._invmp=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=a.clone();l.cmpn(1)>0&&a.cmpn(1)>0;){for(var E=0,x=1;!(l.words[0]&x)&&E<26;++E,x<<=1);if(E>0)for(l.iushrn(E);E-- >0;)c.isOdd()&&c.iadd(A),c.iushrn(1);for(var d=0,w=1;!(a.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(a.iushrn(d);d-- >0;)b.isOdd()&&b.iadd(A),b.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(b)):(a.isub(l),b.isub(c))}var v;return l.cmpn(1)===0?v=c:v=b,v.cmpn(0)<0&&v.iadd(p),v},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var l=this.clone(),a=p.clone();l.negative=0,a.negative=0;for(var c=0;l.isEven()&&a.isEven();c++)l.iushrn(1),a.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;a.isEven();)a.iushrn(1);var b=l.cmp(a);if(b<0){var A=l;l=a,a=A}else if(b===0||a.cmpn(1)===0)break;l.isub(a)}while(!0);return a.iushln(c)},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){i(typeof p=="number");var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return this._expand(a+1),this.words[a]|=c,this;for(var b=c,A=a;b!==0&&A<this.length;A++){var E=this.words[A]|0;E+=b,b=E>>>26,E&=67108863,this.words[A]=E}return b!==0&&(this.words[A]=b,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var l=p<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this.strip();var a;if(this.length>1)a=1;else{l&&(p=-p),i(p<=67108863,"Number is too big");var c=this.words[0]|0;a=c===p?0:c<p?-1:1}return this.negative!==0?-a|0:a},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var l=this.ucmp(p);return this.negative!==0?-l|0:l},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var l=0,a=this.length-1;a>=0;a--){var c=this.words[a]|0,b=p.words[a]|0;if(c!==b){c<b?l=-1:c>b&&(l=1);break}}return l},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 J(p)},s.prototype.toRed=function(p){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return i(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 i(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return i(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var j={k256:null,p224:null,p192:null,p25519:null};function F(N,p){this.name=N,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()}F.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},F.prototype.ireduce=function(p){var l=p,a;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),a=l.bitLength();while(a>this.n);var c=a<this.n?-1:l.ucmp(this.p);return c===0?(l.words[0]=0,l.length=1):c>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},F.prototype.split=function(p,l){p.iushrn(this.n,0,l)},F.prototype.imulK=function(p){return p.imul(this.k)};function U(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(U,F),U.prototype.split=function(p,l){for(var a=4194303,c=Math.min(p.length,9),b=0;b<c;b++)l.words[b]=p.words[b];if(l.length=c,p.length<=9){p.words[0]=0,p.length=1;return}var A=p.words[9];for(l.words[l.length++]=A&a,b=10;b<p.length;b++){var E=p.words[b]|0;p.words[b-10]=(E&a)<<4|A>>>22,A=E}A>>>=22,p.words[b-10]=A,A===0&&p.length>10?p.length-=10:p.length-=9},U.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var l=0,a=0;a<p.length;a++){var c=p.words[a]|0;l+=c*977,p.words[a]=l&67108863,l=c*64+(l/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(z,F);function _(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(_,F);function R(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(R,F),R.prototype.imulK=function(p){for(var l=0,a=0;a<p.length;a++){var c=(p.words[a]|0)*19+l,b=c&67108863;c>>>=26,p.words[a]=b,l=c}return l!==0&&(p.words[p.length++]=l),p},s._prime=function(p){if(j[p])return j[p];var l;if(p==="k256")l=new U;else if(p==="p224")l=new z;else if(p==="p192")l=new _;else if(p==="p25519")l=new R;else throw new Error("Unknown prime "+p);return j[p]=l,l};function J(N){if(typeof N=="string"){var p=s._prime(N);this.m=p.p,this.prime=p}else i(N.gtn(1),"modulus must be greater than 1"),this.m=N,this.prime=null}J.prototype._verify1=function(p){i(p.negative===0,"red works only with positives"),i(p.red,"red works only with red numbers")},J.prototype._verify2=function(p,l){i((p.negative|l.negative)===0,"red works only with positives"),i(p.red&&p.red===l.red,"red works only with red numbers")},J.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):p.umod(this.m)._forceRed(this)},J.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},J.prototype.add=function(p,l){this._verify2(p,l);var a=p.add(l);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},J.prototype.iadd=function(p,l){this._verify2(p,l);var a=p.iadd(l);return a.cmp(this.m)>=0&&a.isub(this.m),a},J.prototype.sub=function(p,l){this._verify2(p,l);var a=p.sub(l);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},J.prototype.isub=function(p,l){this._verify2(p,l);var a=p.isub(l);return a.cmpn(0)<0&&a.iadd(this.m),a},J.prototype.shl=function(p,l){return this._verify1(p),this.imod(p.ushln(l))},J.prototype.imul=function(p,l){return this._verify2(p,l),this.imod(p.imul(l))},J.prototype.mul=function(p,l){return this._verify2(p,l),this.imod(p.mul(l))},J.prototype.isqr=function(p){return this.imul(p,p.clone())},J.prototype.sqr=function(p){return this.mul(p,p)},J.prototype.sqrt=function(p){if(p.isZero())return p.clone();var l=this.m.andln(3);if(i(l%2===1),l===3){var a=this.m.add(new s(1)).iushrn(2);return this.pow(p,a)}for(var c=this.m.subn(1),b=0;!c.isZero()&&c.andln(1)===0;)b++,c.iushrn(1);i(!c.isZero());var A=new s(1).toRed(this),E=A.redNeg(),x=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,x).cmp(E)!==0;)d.redIAdd(E);for(var w=this.pow(d,c),v=this.pow(p,c.addn(1).iushrn(1)),O=this.pow(p,c),W=b;O.cmp(A)!==0;){for(var S=O,H=0;S.cmp(A)!==0;H++)S=S.redSqr();i(H<W);var T=this.pow(w,new s(1).iushln(W-H-1));v=v.redMul(T),w=T.redSqr(),O=O.redMul(w),W=H}return v},J.prototype.invm=function(p){var l=p._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},J.prototype.pow=function(p,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return p.clone();var a=4,c=new Array(1<<a);c[0]=new s(1).toRed(this),c[1]=p;for(var b=2;b<c.length;b++)c[b]=this.mul(c[b-1],p);var A=c[0],E=0,x=0,d=l.bitLength()%26;for(d===0&&(d=26),b=l.length-1;b>=0;b--){for(var w=l.words[b],v=d-1;v>=0;v--){var O=w>>v&1;if(A!==c[0]&&(A=this.sqr(A)),O===0&&E===0){x=0;continue}E<<=1,E|=O,x++,!(x!==a&&(b!==0||v!==0))&&(A=this.mul(A,c[E]),x=0,E=0)}d=26}return A},J.prototype.convertTo=function(p){var l=p.umod(this.m);return l===p?l.clone():l},J.prototype.convertFrom=function(p){var l=p.clone();return l.red=null,l},s.mont=function(p){return new Q(p)};function Q(N){J.call(this,N),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)}n(Q,J),Q.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},Q.prototype.convertFrom=function(p){var l=this.imod(p.mul(this.rinv));return l.red=null,l},Q.prototype.imul=function(p,l){if(p.isZero()||l.isZero())return p.words[0]=0,p.length=1,p;var a=p.imul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.mul=function(p,l){if(p.isZero()||l.isZero())return new s(0)._forceRed(this);var a=p.mul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.invm=function(p){var l=this.imod(p._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(r,Pt)})(Gr);var ko={};(function(r){var e=r;function t(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var f=[];if(typeof s!="string"){for(var u=0;u<s.length;u++)f[u]=s[u]|0;return f}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var u=0;u<s.length;u+=2)f.push(parseInt(s[u]+s[u+1],16))}else for(var u=0;u<s.length;u++){var h=s.charCodeAt(u),g=h>>8,y=h&255;g?f.push(g,y):f.push(y)}return f}e.toArray=t;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",f=0;f<s.length;f++)o+=i(s[f].toString(16));return o}e.toHex=n,e.encode=function(o,f){return f==="hex"?n(o):o}})(ko),function(r){var e=r,t=Gr.exports,i=ji,n=ko;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(g,y,I){var M=new Array(Math.max(g.bitLength(),I)+1),D;for(D=0;D<M.length;D+=1)M[D]=0;var P=1<<y+1,k=g.clone();for(D=0;D<M.length;D++){var K,C=k.andln(P-1);k.isOdd()?(C>(P>>1)-1?K=(P>>1)-C:K=C,k.isubn(K)):K=0,M[D]=K,k.iushrn(1)}return M}e.getNAF=s;function o(g,y){var I=[[],[]];g=g.clone(),y=y.clone();for(var M=0,D=0,P;g.cmpn(-M)>0||y.cmpn(-D)>0;){var k=g.andln(3)+M&3,K=y.andln(3)+D&3;k===3&&(k=-1),K===3&&(K=-1);var C;k&1?(P=g.andln(7)+M&7,(P===3||P===5)&&K===2?C=-k:C=k):C=0,I[0].push(C);var j;K&1?(P=y.andln(7)+D&7,(P===3||P===5)&&k===2?j=-K:j=K):j=0,I[1].push(j),2*M===C+1&&(M=1-M),2*D===j+1&&(D=1-D),g.iushrn(1),y.iushrn(1)}return I}e.getJSF=o;function f(g,y,I){var M="_"+y;g.prototype[y]=function(){return this[M]!==void 0?this[M]:this[M]=I.call(this)}}e.cachedProperty=f;function u(g){return typeof g=="string"?e.toArray(g,"hex"):g}e.parseBytes=u;function h(g){return new t(g,"hex","le")}e.intFromLE=h}(ur);var oa={exports:{}},Ko;oa.exports=function(e){return Ko||(Ko=new Ii(null)),Ko.generate(e)};function Ii(r){this.rand=r}if(oa.exports.Rand=Ii,Ii.prototype.generate=function(e){return this._rand(e)},Ii.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t},typeof self=="object")self.crypto&&self.crypto.getRandomValues?Ii.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?Ii.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:typeof window=="object"&&(Ii.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var hu=Us;if(typeof hu.randomBytes!="function")throw new Error("Not supported");Ii.prototype._rand=function(e){return hu.randomBytes(e)}}catch{}var jo={},Gi=Gr.exports,rs=ur,fa=rs.getNAF,_3=rs.getJSF,ca=rs.assert;function Di(r,e){this.type=r,this.p=new Gi(e.p,16),this.red=e.prime?Gi.red(e.prime):Gi.mont(this.p),this.zero=new Gi(0).toRed(this.red),this.one=new Gi(1).toRed(this.red),this.two=new Gi(2).toRed(this.red),this.n=e.n&&new Gi(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ha=Di;Di.prototype.point=function(){throw new Error("Not implemented")},Di.prototype.validate=function(){throw new Error("Not implemented")},Di.prototype._fixedNafMul=function(e,t){ca(e.precomputed);var i=e._getDoubles(),n=fa(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?y=y.mixedAdd(i.points[f]):u===-I&&(y=y.mixedAdd(i.points[f].neg()));g=g.add(y)}return g.toP()},Di.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=fa(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];ca(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Di.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,y,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,P=g;if(o[D]!==1||o[P]!==1){u[D]=fa(i[D],o[D],this._bitLength),u[P]=fa(i[P],o[P],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[P].length,h);continue}var k=[t[D],null,null,t[P]];t[D].y.cmp(t[P].y)===0?(k[1]=t[D].add(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg())):t[D].y.cmp(t[P].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].add(t[P].neg())):(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],C=_3(i[D],i[P]);for(h=Math.max(C[0].length,h),u[D]=new Array(h),u[P]=new Array(h),y=0;y<h;y++){var j=C[0][y]|0,F=C[1][y]|0;u[D][y]=K[(j+1)*3+(F+1)],u[P][y]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var R=!0;for(y=0;y<n;y++)z[y]=u[y][g]|0,z[y]!==0&&(R=!1);if(!R)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(y=0;y<n;y++){var J=z[y];J!==0&&(J>0?I=f[y][J-1>>1]:J<0&&(I=f[y][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function mr(r,e){this.curve=r,this.type=e,this.precomputed=null}Di.BasePoint=mr,mr.prototype.eq=function(){throw new Error("Not implemented")},mr.prototype.validate=function(){return this.curve.validate(this)},Di.prototype.decodePoint=function(e,t){e=rs.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?ca(e[e.length-1]%2===0):e[0]===7&&ca(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},mr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},mr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},mr.prototype.encode=function(e,t){return rs.encode(this._encode(t),e)},mr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},mr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},mr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},mr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},mr.prototype._getBeta=function(){return null},mr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var x3=ur,pt=Gr.exports,Ho=_n.exports,On=ha,A3=x3.assert;function yr(r){On.call(this,"short",r),this.a=new pt(r.a,16).toRed(this.red),this.b=new pt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Ho(yr,On);var E3=yr;yr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new pt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new pt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],A3(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new pt(f.a,16),b:new pt(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},yr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:pt.mont(e),i=new pt(2).toRed(t).redInvm(),n=i.redNeg(),s=new pt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},yr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new pt(1),o=new pt(0),f=new pt(0),u=new pt(1),h,g,y,I,M,D,P,k=0,K,C;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),C=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!y&&K.cmp(t)<0)h=P.neg(),g=s,y=K.neg(),I=C;else if(y&&++k===2)break;P=K,n=i,i=K,f=s,s=C,u=o,o=F}M=K.neg(),D=C;var U=y.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),y.negative&&(y=y.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:y,b:I},{a:M,b:D}]},yr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),y=e.sub(f).sub(u),I=h.add(g).neg();return{k1:y,k2:I}},yr.prototype.pointFromX=function(e,t){e=new pt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},yr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},yr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return g};function Mt(r,e,t,i){On.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new pt(e,16),this.y=new pt(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Ho(Mt,On.BasePoint),yr.prototype.point=function(e,t,i){return new Mt(this,e,t,i)},yr.prototype.pointFromJSON=function(e,t){return Mt.fromJSON(this,e,t)},Mt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},Mt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Mt.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Mt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Mt.prototype.isInfinity=function(){return this.inf},Mt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Mt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},Mt.prototype.getX=function(){return this.x.fromRed()},Mt.prototype.getY=function(){return this.y.fromRed()},Mt.prototype.mul=function(e){return e=new pt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Mt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Mt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Mt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Mt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t},Mt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Bt(r,e,t,i){On.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(t,16),this.z=new pt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Ho(Bt,On.BasePoint),yr.prototype.jpoint=function(e,t,i){return new Bt(this,e,t,i)},Bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),y=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(y).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,P)},Bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),y=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(y).redISub(y),M=u.redMul(y.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var y=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),P=o.redMul(I),k=D.redSqr().redISub(P.redAdd(P)),K=P.redISub(k),C=D.redMul(K);C=C.redIAdd(C).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=C}return this.curve.jpoint(o,g.redMul(s),u)},Bt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Bt.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(y).redISub(M);D=D.redIAdd(D);var P=y.redAdd(y).redIAdd(y),k=P.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=P.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Bt.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(y).redMul(this.x.redAdd(y));D=D.redAdd(D).redIAdd(D);var P=M.redIAdd(M);P=P.redIAdd(P);var k=P.redAdd(P);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(y);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(P.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Bt.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),y=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(y),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),P=i.redAdd(i).redMul(n);return this.curve.jpoint(y,D,P)},Bt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),y=t.redMul(g);y=y.redIAdd(y),y=y.redIAdd(y);var I=this.x.redMul(u).redISub(y);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Bt.prototype.mul=function(e,t){return e=new pt(e,t),this.curve._wnafMul(this,e)},Bt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Bt.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Bt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Rn=Gr.exports,uu=_n.exports,ua=ha,S3=ur;function Nn(r){ua.call(this,"mont",r),this.a=new Rn(r.a,16).toRed(this.red),this.b=new Rn(r.b,16).toRed(this.red),this.i4=new Rn(4).toRed(this.red).redInvm(),this.two=new Rn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}uu(Nn,ua);var M3=Nn;Nn.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function It(r,e,t){ua.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Rn(e,16),this.z=new Rn(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}uu(It,ua.BasePoint),Nn.prototype.decodePoint=function(e,t){return this.point(S3.toArray(e,t),1)},Nn.prototype.point=function(e,t){return new It(this,e,t)},Nn.prototype.pointFromJSON=function(e){return It.fromJSON(this,e)},It.prototype.precompute=function(){},It.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},It.fromJSON=function(e,t){return new It(e,t[0],t[1]||e.one)},It.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},It.prototype.isInfinity=function(){return this.z.cmpn(0)===0},It.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)},It.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),h=t.z.redMul(f.redAdd(u).redSqr()),g=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(h,g)},It.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},It.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},It.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},It.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var I3=ur,ni=Gr.exports,du=_n.exports,da=ha,D3=I3.assert;function Wr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,da.call(this,"edwards",r),this.a=new ni(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ni(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ni(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),D3(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}du(Wr,da);var O3=Wr;Wr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},Wr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},Wr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)},Wr.prototype.pointFromX=function(e,t){e=new ni(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)},Wr.prototype.pointFromY=function(e,t){e=new ni(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)},Wr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function ft(r,e,t,i,n){da.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new ni(e,16),this.y=new ni(t,16),this.z=i?new ni(i,16):this.curve.one,this.t=n&&new ni(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}du(ft,da.BasePoint),Wr.prototype.pointFromJSON=function(e){return ft.fromJSON(this,e)},Wr.prototype.point=function(e,t,i,n){return new ft(this,e,t,i,n)},ft.fromJSON=function(e,t){return new ft(e,t[0],t[1],t[2])},ft.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},ft.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ft.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),h=s.redMul(f),g=o.redMul(u),y=s.redMul(u),I=f.redMul(o);return this.curve.point(h,g,I,y)},ft.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,h;if(this.curve.twisted){f=this.curve._mulA(t);var g=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(f.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(u=this.z.redSqr(),h=g.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(h),s=g.redMul(f.redSub(i)),o=g.redMul(h))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),h=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(h),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(h);return this.curve.point(n,s,o)},ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ft.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),h=i.redAdd(t),g=o.redMul(f),y=u.redMul(h),I=o.redMul(h),M=f.redMul(u);return this.curve.point(g,y,M,I)},ft.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(f).redMul(h),y,I;return this.curve.twisted?(y=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),I=f.redMul(u)):(y=t.redMul(u).redMul(s.redSub(n)),I=this.curve._mulC(f).redMul(u)),this.curve.point(g,y,I)},ft.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ft.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ft.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)},ft.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)},ft.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},ft.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ft.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ft.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ft.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}},ft.prototype.toP=ft.prototype.normalize,ft.prototype.mixedAdd=ft.prototype.add,function(r){var e=r;e.base=ha,e.short=E3,e.mont=M3,e.edwards=O3}(jo);var la={},Vo,lu;function R3(){return lu||(lu=1,Vo={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),Vo}(function(r){var e=r,t=cr,i=jo,n=ur,s=n.assert;function o(h){h.type==="short"?this.curve=new i.short(h):h.type==="edwards"?this.curve=new i.edwards(h):this.curve=new i.mont(h),this.g=this.curve.g,this.n=this.curve.n,this.hash=h.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function f(h,g){Object.defineProperty(e,h,{configurable:!0,enumerable:!0,get:function(){var y=new o(g);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:y}),y}})}f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:t.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:t.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:t.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:t.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:t.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=R3()}catch{u=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})})(la);var N3=cr,Wi=ko,pu=ji;function Oi(r){if(!(this instanceof Oi))return new Oi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Wi.toArray(r.entropy,r.entropyEnc||"hex"),t=Wi.toArray(r.nonce,r.nonceEnc||"hex"),i=Wi.toArray(r.pers,r.persEnc||"hex");pu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var P3=Oi;Oi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Oi.prototype._hmac=function(){return new N3.hmac(this.hash,this.K)},Oi.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Oi.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Wi.toArray(e,t),i=Wi.toArray(i,n),pu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Oi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Wi.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Wi.encode(o,t)};var C3=Gr.exports,T3=ur,Go=T3.assert;function kt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var F3=kt;kt.fromPublic=function(e,t,i){return t instanceof kt?t:new kt(e,{pub:t,pubEnc:i})},kt.fromPrivate=function(e,t,i){return t instanceof kt?t:new kt(e,{priv:t,privEnc:i})},kt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},kt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},kt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},kt.prototype._importPrivate=function(e,t){this.priv=new C3(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},kt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Go(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Go(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},kt.prototype.derive=function(e){return e.validate()||Go(e.validate(),"public point not validated"),e.mul(this.priv).getX()},kt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},kt.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)},kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var pa=Gr.exports,Wo=ur,B3=Wo.assert;function ga(r,e){if(r instanceof ga)return r;this._importDER(r,e)||(B3(r.r&&r.s,"Signature without r or s"),this.r=new pa(r.r,16),this.s=new pa(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var L3=ga;function q3(){this.place=0}function Jo(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function gu(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}ga.prototype._importDER=function(e,t){e=Wo.toArray(e,t);var i=new q3;if(e[i.place++]!==48)return!1;var n=Jo(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Jo(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=Jo(e,i);if(f===!1||e.length!==f+i.place||e[i.place]&128)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new pa(o),this.s=new pa(u),this.recoveryParam=null,!0};function Yo(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}ga.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=gu(t),i=gu(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Yo(n,t.length),n=n.concat(t),n.push(2),Yo(n,i.length);var s=n.concat(i),o=[48];return Yo(o,s.length),o=o.concat(s),Wo.encode(o,e)};var Nr=Gr.exports,bu=P3,U3=ur,Qo=la,$3=oa.exports,Ji=U3.assert,Xo=F3,ba=L3;function wr(r){if(!(this instanceof wr))return new wr(r);typeof r=="string"&&(Ji(Object.prototype.hasOwnProperty.call(Qo,r),"Unknown curve "+r),r=Qo[r]),r instanceof Qo.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var z3=wr;wr.prototype.keyPair=function(e){return new Xo(this,e)},wr.prototype.keyFromPrivate=function(e,t){return Xo.fromPrivate(this,e,t)},wr.prototype.keyFromPublic=function(e,t){return Xo.fromPublic(this,e,t)},wr.prototype.genKeyPair=function(e){e||(e={});for(var t=new bu({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$3(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Nr(2));;){var s=new Nr(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},wr.prototype._truncateToN=function(e,t,i){var n;if(Nr.isBN(e)||typeof e=="number")e=new Nr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Nr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Nr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},wr.prototype.sign=function(e,t,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Nr.isBN(e)){Ji(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Ji(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Ji((e[s]&255)===e[s])}t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength),Ji(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),f=t.getPrivate().toArray("be",o),u=e.toArray("be",o);Ji(new Nr(u).eq(e),"Can not sign message");for(var h=new bu({hash:this.hash,entropy:f,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),g=this.n.sub(new Nr(1)),y=0;;y++){var I=n.k?n.k(y):new Nr(h.generate(this.n.byteLength()));if(I=this._truncateToN(I,!0),!(I.cmpn(1)<=0||I.cmp(g)>=0)){var M=this.g.mul(I);if(!M.isInfinity()){var D=M.getX(),P=D.umod(this.n);if(P.cmpn(0)!==0){var k=I.invm(this.n).mul(P.mul(t.getPrivate()).iadd(e));if(k=k.umod(this.n),k.cmpn(0)!==0){var K=(M.getY().isOdd()?1:0)|(D.cmp(P)!==0?2:0);return n.canonical&&k.cmp(this.nh)>0&&(k=this.n.sub(k),K^=1),new ba({r:P,s:k,recoveryParam:K})}}}}}},wr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new ba(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),h=u.mul(e).umod(this.n),g=u.mul(o).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(h,i.getPublic(),g),y.isInfinity()?!1:y.eqXToP(o)):(y=this.g.mulAdd(h,i.getPublic(),g),y.isInfinity()?!1:y.getX().umod(this.n).cmp(o)===0)},wr.prototype.recoverPubKey=function(r,e,t,i){Ji((3&t)===t,"The recovery param is more than two bits"),e=new ba(e,i);var n=this.n,s=new Nr(r),o=e.r,f=e.s,u=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(y,o,I)},wr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ba(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var is=ur,vu=is.assert,mu=is.parseBytes,Pn=is.cachedProperty;function Dt(r,e){this.eddsa=r,this._secret=mu(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=mu(e.pub)}Dt.fromPublic=function(e,t){return t instanceof Dt?t:new Dt(e,{pub:t})},Dt.fromSecret=function(e,t){return t instanceof Dt?t:new Dt(e,{secret:t})},Dt.prototype.secret=function(){return this._secret},Pn(Dt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Pn(Dt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Pn(Dt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),Pn(Dt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Pn(Dt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Pn(Dt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Dt.prototype.sign=function(e){return vu(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Dt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},Dt.prototype.getSecret=function(e){return vu(this._secret,"KeyPair is public only"),is.encode(this.secret(),e)},Dt.prototype.getPublic=function(e){return is.encode(this.pubBytes(),e)};var k3=Dt,K3=Gr.exports,va=ur,yu=va.assert,ma=va.cachedProperty,j3=va.parseBytes;function Yi(r,e){this.eddsa=r,typeof e!="object"&&(e=j3(e)),Array.isArray(e)&&(yu(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),yu(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof K3&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}ma(Yi,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),ma(Yi,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),ma(Yi,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),ma(Yi,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Yi.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Yi.prototype.toHex=function(){return va.encode(this.toBytes(),"hex").toUpperCase()};var H3=Yi,V3=cr,G3=la,Cn=ur,W3=Cn.assert,wu=Cn.parseBytes,_u=k3,xu=H3;function tr(r){if(W3(r==="ed25519","only tested with ed25519 so far"),!(this instanceof tr))return new tr(r);r=G3[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=V3.sha512}var J3=tr;tr.prototype.sign=function(e,t){e=wu(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})},tr.prototype.verify=function(e,t,i){if(e=wu(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)},tr.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return Cn.intFromLE(e.digest()).umod(this.curve.n)},tr.prototype.keyFromPublic=function(e){return _u.fromPublic(this,e)},tr.prototype.keyFromSecret=function(e){return _u.fromSecret(this,e)},tr.prototype.makeSignature=function(e){return e instanceof xu?e:new xu(this,e)},tr.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},tr.prototype.decodePoint=function(e){e=Cn.parseBytes(e);var t=e.length-1,i=e.slice(0,t).concat(e[t]&-129),n=(e[t]&128)!==0,s=Cn.intFromLE(i);return this.curve.pointFromY(s,n)},tr.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},tr.prototype.decodeInt=function(e){return Cn.intFromLE(e)},tr.prototype.isPoint=function(e){return e instanceof this.pointClass},function(r){var e=r;e.version=w3.version,e.utils=ur,e.rand=oa.exports,e.curve=jo,e.curves=la,e.ec=z3,e.eddsa=J3}(cu);const Y3={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},Q3=":";function ya(r){const[e,t]=r.split(Q3);return{namespace:e,reference:t}}function Au(r,e){return r.includes(":")?[r]:e.chains||[]}var X3=Object.defineProperty,Eu=Object.getOwnPropertySymbols,Z3=Object.prototype.hasOwnProperty,em=Object.prototype.propertyIsEnumerable,Su=(r,e,t)=>e in r?X3(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mu=(r,e)=>{for(var t in e||(e={}))Z3.call(e,t)&&Su(r,t,e[t]);if(Eu)for(var t of Eu(e))em.call(e,t)&&Su(r,t,e[t]);return r};const tm="ReactNative",Kt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},rm="js";function wa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ri(){return!Hn()&&!!uo()&&navigator.product===tm}function im(){return Ri()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function nm(){return Ri()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ns(){return!wa()&&!!uo()&&!!Hn()}function Ni(){return Ri()?Kt.reactNative:wa()?Kt.node:ns()?Kt.browser:Kt.unknown}function Iu(){var r;try{return Ri()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function sm(r,e){let t=Vn.parse(r);return t=Mu(Mu({},t),e),r=Vn.stringify(t),r}function Du(){return Jc()||{name:"",description:"",url:"",icons:[""]}}function am(){if(Ni()===Kt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:t,Version:i}=global.Platform;return[t,i].join("-")}const r=Xg();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function om(){var r;const e=Ni();return e===Kt.browser?[e,((r=Wc())==null?void 0:r.host)||"unknown"].join(":"):e}function Ou(r,e,t){const i=am(),n=om();return[[r,e].join("-"),[rm,t].join("-"),i,n].join("/")}function fm({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f,packageName:u}){const h=t.split("?"),g=Ou(r,e,i),y={auth:n,ua:g,projectId:s,useOnCloseEvent:o||void 0,packageName:u||void 0,bundleId:f||void 0},I=sm(h[1]||"",y);return h[0]+"?"+I}function Qi(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Ru(r){return Object.fromEntries(r.entries())}function Nu(r){return new Map(Object.entries(r))}function Xi(r=ie.FIVE_MINUTES,e){const t=ie.toMiliseconds(r||ie.FIVE_MINUTES);let i,n,s,o;return{resolve:f=>{s&&i&&(clearTimeout(s),i(f),o=Promise.resolve(f))},reject:f=>{s&&n&&(clearTimeout(s),n(f))},done:()=>new Promise((f,u)=>{if(o)return f(o);s=setTimeout(()=>{const h=new Error(e);o=Promise.reject(h),u(h)},t),i=f,n=u})}}function Pi(r,e,t){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(t)),e);try{const o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Pu(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function cm(r){return Pu("topic",r)}function hm(r){return Pu("id",r)}function Cu(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function _t(r,e){return ie.fromMiliseconds((e||Date.now())+ie.toMiliseconds(r))}function Ci(r){return Date.now()>=ie.toMiliseconds(r)}function Ye(r,e){return`${r}${e?`:${e}`:""}`}function um(r=[],e=[]){return[...new Set([...r,...e])]}async function dm({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;const o=lm(s,r,e),f=Ni();if(f===Kt.browser){if(!((i=Hn())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,gm()?"_blank":"_self","noreferrer noopener")}else f===Kt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function lm(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${bm(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function pm(r,e){let t="";try{if(ns()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Tu(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Fu(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Zo(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function gm(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function bm(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Bu(r){return Buffer.from(r,"base64").toString("utf-8")}function vm(r){return new Promise(e=>setTimeout(e,r))}const mm="https://rpc.walletconnect.org/v1";async function ym(r,e,t,i,n,s){switch(t.t){case"eip191":return wm(r,e,t.s);case"eip1271":return await _m(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function wm(r,e,t){return V2(Sh(e),t).toLowerCase()===r.toLowerCase()}async function _m(r,e,t,i,n,s){const o=ya(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=Sh(e).substring(2),I=f+y+u+h+g,M=await fetch(`${s||mm}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:xm(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:I},"latest"]})}),{result:D}=await M.json();return D?D.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function xm(){return Date.now()+Math.floor(Math.random()*1e3)}var Am=Object.defineProperty,Em=Object.defineProperties,Sm=Object.getOwnPropertyDescriptors,Lu=Object.getOwnPropertySymbols,Mm=Object.prototype.hasOwnProperty,Im=Object.prototype.propertyIsEnumerable,qu=(r,e,t)=>e in r?Am(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Dm=(r,e)=>{for(var t in e||(e={}))Mm.call(e,t)&&qu(r,t,e[t]);if(Lu)for(var t of Lu(e))Im.call(e,t)&&qu(r,t,e[t]);return r},Om=(r,e)=>Em(r,Sm(e));const Rm="did:pkh:",ef=r=>r?.split(":"),Nm=r=>{const e=r&&ef(r);if(e)return r.includes(Rm)?e[3]:e[1]},tf=r=>{const e=r&&ef(r);if(e)return e[2]+":"+e[3]},_a=r=>{const e=r&&ef(r);if(e)return e.pop()};async function Uu(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=$u(n,n.iss),o=_a(n.iss);return await ym(o,s,i,tf(n.iss),t)}const $u=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=_a(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${Nm(e)}`,u=`Nonce: ${r.nonce}`,h=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,I=r.requestId?`Request ID: ${r.requestId}`:void 0,M=r.resources?`Resources:${r.resources.map(P=>`
|
21
|
+
*/(function(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=Pt:s&&(n=self);var f=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,u=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],I=[1,256,65536,16777216],M=[6,1536,393216,100663296],D=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],k=[224,256,384,512],K=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],j={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(S){return Object.prototype.toString.call(S)==="[object Array]"}),u&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(S){return typeof S=="object"&&S.buffer&&S.buffer.constructor===ArrayBuffer});for(var F=function(S,H,T){return function(q){return new v(S,H,S).update(q)[T]()}},U=function(S,H,T){return function(q,B){return new v(S,H,B).update(q)[T]()}},z=function(S,H,T){return function(q,B,m,L){return a["cshake"+S].update(q,B,m,L)[T]()}},_=function(S,H,T){return function(q,B,m,L){return a["kmac"+S].update(q,B,m,L)[T]()}},R=function(S,H,T,q){for(var B=0;B<C.length;++B){var m=C[B];S[m]=H(T,q,m)}return S},J=function(S,H){var T=F(S,H,"hex");return T.create=function(){return new v(S,H,S)},T.update=function(q){return T.create().update(q)},R(T,F,S,H)},Q=function(S,H){var T=U(S,H,"hex");return T.create=function(q){return new v(S,H,q)},T.update=function(q,B){return T.create(B).update(q)},R(T,U,S,H)},N=function(S,H){var T=j[S],q=z(S,H,"hex");return q.create=function(B,m,L){return!m&&!L?a["shake"+S].create(B):new v(S,H,B).bytepad([m,L],T)},q.update=function(B,m,L,G){return q.create(m,L,G).update(B)},R(q,z,S,H)},p=function(S,H){var T=j[S],q=_(S,H,"hex");return q.create=function(B,m,L){return new O(S,H,m).bytepad(["KMAC",L],T).bytepad([B],T)},q.update=function(B,m,L,G){return q.create(B,L,G).update(m)},R(q,_,S,H)},l=[{name:"keccak",padding:I,bits:k,createMethod:J},{name:"sha3",padding:M,bits:k,createMethod:J},{name:"shake",padding:g,bits:K,createMethod:Q},{name:"cshake",padding:y,bits:K,createMethod:N},{name:"kmac",padding:y,bits:K,createMethod:p}],a={},c=[],b=0;b<l.length;++b)for(var A=l[b],E=A.bits,x=0;x<E.length;++x){var d=A.name+"_"+E[x];if(c.push(d),a[d]=A.createMethod(E[x],A.padding),A.name!=="sha3"){var w=A.name+E[x];c.push(w),a[w]=a[d]}}function v(S,H,T){this.blocks=[],this.s=[],this.padding=H,this.outputBits=T,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(S<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=T>>5,this.extraBytes=(T&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}v.prototype.update=function(S){if(this.finalized)throw new Error(t);var H,T=typeof S;if(T!=="string"){if(T==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}for(var q=this.blocks,B=this.byteCount,m=S.length,L=this.blockCount,G=0,Y=this.s,X,ee;G<m;){if(this.reset)for(this.reset=!1,q[0]=this.block,X=1;X<L+1;++X)q[X]=0;if(H)for(X=this.start;G<m&&X<B;++G)q[X>>2]|=S[G]<<D[X++&3];else for(X=this.start;G<m&&X<B;++G)ee=S.charCodeAt(G),ee<128?q[X>>2]|=ee<<D[X++&3]:ee<2048?(q[X>>2]|=(192|ee>>6)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):ee<55296||ee>=57344?(q[X>>2]|=(224|ee>>12)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]):(ee=65536+((ee&1023)<<10|S.charCodeAt(++G)&1023),q[X>>2]|=(240|ee>>18)<<D[X++&3],q[X>>2]|=(128|ee>>12&63)<<D[X++&3],q[X>>2]|=(128|ee>>6&63)<<D[X++&3],q[X>>2]|=(128|ee&63)<<D[X++&3]);if(this.lastByteIndex=X,X>=B){for(this.start=X-B,this.block=q[L],X=0;X<L;++X)Y[X]^=q[X];W(Y),this.reset=!0}else this.start=X}return this},v.prototype.encode=function(S,H){var T=S&255,q=1,B=[T];for(S=S>>8,T=S&255;T>0;)B.unshift(T),S=S>>8,T=S&255,++q;return H?B.push(q):B.unshift(q),this.update(B),B.length},v.prototype.encodeString=function(S){var H,T=typeof S;if(T!=="string"){if(T==="object"){if(S===null)throw new Error(e);if(u&&S.constructor===ArrayBuffer)S=new Uint8Array(S);else if(!Array.isArray(S)&&(!u||!ArrayBuffer.isView(S)))throw new Error(e)}else throw new Error(e);H=!0}var q=0,B=S.length;if(H)q=B;else for(var m=0;m<S.length;++m){var L=S.charCodeAt(m);L<128?q+=1:L<2048?q+=2:L<55296||L>=57344?q+=3:(L=65536+((L&1023)<<10|S.charCodeAt(++m)&1023),q+=4)}return q+=this.encode(q*8),this.update(S),q},v.prototype.bytepad=function(S,H){for(var T=this.encode(H),q=0;q<S.length;++q)T+=this.encodeString(S[q]);var B=H-T%H,m=[];return m.length=B,this.update(m),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var S=this.blocks,H=this.lastByteIndex,T=this.blockCount,q=this.s;if(S[H>>2]|=this.padding[H&3],this.lastByteIndex===this.byteCount)for(S[0]=S[T],H=1;H<T+1;++H)S[H]=0;for(S[T-1]|=2147483648,H=0;H<T;++H)q[H]^=S[H];W(q)}},v.prototype.toString=v.prototype.hex=function(){this.finalize();for(var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L="",G;m<T;){for(B=0;B<S&&m<T;++B,++m)G=H[B],L+=h[G>>4&15]+h[G&15]+h[G>>12&15]+h[G>>8&15]+h[G>>20&15]+h[G>>16&15]+h[G>>28&15]+h[G>>24&15];m%S===0&&(W(H),B=0)}return q&&(G=H[B],L+=h[G>>4&15]+h[G&15],q>1&&(L+=h[G>>12&15]+h[G>>8&15]),q>2&&(L+=h[G>>20&15]+h[G>>16&15])),L},v.prototype.arrayBuffer=function(){this.finalize();var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L=this.outputBits>>3,G;q?G=new ArrayBuffer(T+1<<2):G=new ArrayBuffer(L);for(var Y=new Uint32Array(G);m<T;){for(B=0;B<S&&m<T;++B,++m)Y[m]=H[B];m%S===0&&W(H)}return q&&(Y[B]=H[B],G=G.slice(0,L)),G},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.digest=v.prototype.array=function(){this.finalize();for(var S=this.blockCount,H=this.s,T=this.outputBlocks,q=this.extraBytes,B=0,m=0,L=[],G,Y;m<T;){for(B=0;B<S&&m<T;++B,++m)G=m<<2,Y=H[B],L[G]=Y&255,L[G+1]=Y>>8&255,L[G+2]=Y>>16&255,L[G+3]=Y>>24&255;m%S===0&&W(H)}return q&&(G=m<<2,Y=H[B],L[G]=Y&255,q>1&&(L[G+1]=Y>>8&255),q>2&&(L[G+2]=Y>>16&255)),L};function O(S,H,T){v.call(this,S,H,T)}O.prototype=new v,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),v.prototype.finalize.call(this)};var W=function(S){var H,T,q,B,m,L,G,Y,X,ee,we,Se,he,Ne,xe,ae,ve,le,ne,ue,fe,te,pe,_e,re,Ae,Ee,oe,De,Me,Oe,We,Qe,Ie,et,tt,Pe,Te,Ce,de,Fe,Be,ce,Ue,$e,me,ze,ke,ge,Le,Re,ye,Ke,it,qe,nt,Je,rt,ir,nr,sr,ar,yt;for(q=0;q<48;q+=2)B=S[0]^S[10]^S[20]^S[30]^S[40],m=S[1]^S[11]^S[21]^S[31]^S[41],L=S[2]^S[12]^S[22]^S[32]^S[42],G=S[3]^S[13]^S[23]^S[33]^S[43],Y=S[4]^S[14]^S[24]^S[34]^S[44],X=S[5]^S[15]^S[25]^S[35]^S[45],ee=S[6]^S[16]^S[26]^S[36]^S[46],we=S[7]^S[17]^S[27]^S[37]^S[47],Se=S[8]^S[18]^S[28]^S[38]^S[48],he=S[9]^S[19]^S[29]^S[39]^S[49],H=Se^(L<<1|G>>>31),T=he^(G<<1|L>>>31),S[0]^=H,S[1]^=T,S[10]^=H,S[11]^=T,S[20]^=H,S[21]^=T,S[30]^=H,S[31]^=T,S[40]^=H,S[41]^=T,H=B^(Y<<1|X>>>31),T=m^(X<<1|Y>>>31),S[2]^=H,S[3]^=T,S[12]^=H,S[13]^=T,S[22]^=H,S[23]^=T,S[32]^=H,S[33]^=T,S[42]^=H,S[43]^=T,H=L^(ee<<1|we>>>31),T=G^(we<<1|ee>>>31),S[4]^=H,S[5]^=T,S[14]^=H,S[15]^=T,S[24]^=H,S[25]^=T,S[34]^=H,S[35]^=T,S[44]^=H,S[45]^=T,H=Y^(Se<<1|he>>>31),T=X^(he<<1|Se>>>31),S[6]^=H,S[7]^=T,S[16]^=H,S[17]^=T,S[26]^=H,S[27]^=T,S[36]^=H,S[37]^=T,S[46]^=H,S[47]^=T,H=ee^(B<<1|m>>>31),T=we^(m<<1|B>>>31),S[8]^=H,S[9]^=T,S[18]^=H,S[19]^=T,S[28]^=H,S[29]^=T,S[38]^=H,S[39]^=T,S[48]^=H,S[49]^=T,Ne=S[0],xe=S[1],me=S[11]<<4|S[10]>>>28,ze=S[10]<<4|S[11]>>>28,oe=S[20]<<3|S[21]>>>29,De=S[21]<<3|S[20]>>>29,nr=S[31]<<9|S[30]>>>23,sr=S[30]<<9|S[31]>>>23,Be=S[40]<<18|S[41]>>>14,ce=S[41]<<18|S[40]>>>14,Ie=S[2]<<1|S[3]>>>31,et=S[3]<<1|S[2]>>>31,ae=S[13]<<12|S[12]>>>20,ve=S[12]<<12|S[13]>>>20,ke=S[22]<<10|S[23]>>>22,ge=S[23]<<10|S[22]>>>22,Me=S[33]<<13|S[32]>>>19,Oe=S[32]<<13|S[33]>>>19,ar=S[42]<<2|S[43]>>>30,yt=S[43]<<2|S[42]>>>30,it=S[5]<<30|S[4]>>>2,qe=S[4]<<30|S[5]>>>2,tt=S[14]<<6|S[15]>>>26,Pe=S[15]<<6|S[14]>>>26,le=S[25]<<11|S[24]>>>21,ne=S[24]<<11|S[25]>>>21,Le=S[34]<<15|S[35]>>>17,Re=S[35]<<15|S[34]>>>17,We=S[45]<<29|S[44]>>>3,Qe=S[44]<<29|S[45]>>>3,_e=S[6]<<28|S[7]>>>4,re=S[7]<<28|S[6]>>>4,nt=S[17]<<23|S[16]>>>9,Je=S[16]<<23|S[17]>>>9,Te=S[26]<<25|S[27]>>>7,Ce=S[27]<<25|S[26]>>>7,ue=S[36]<<21|S[37]>>>11,fe=S[37]<<21|S[36]>>>11,ye=S[47]<<24|S[46]>>>8,Ke=S[46]<<24|S[47]>>>8,Ue=S[8]<<27|S[9]>>>5,$e=S[9]<<27|S[8]>>>5,Ae=S[18]<<20|S[19]>>>12,Ee=S[19]<<20|S[18]>>>12,rt=S[29]<<7|S[28]>>>25,ir=S[28]<<7|S[29]>>>25,de=S[38]<<8|S[39]>>>24,Fe=S[39]<<8|S[38]>>>24,te=S[48]<<14|S[49]>>>18,pe=S[49]<<14|S[48]>>>18,S[0]=Ne^~ae&le,S[1]=xe^~ve&ne,S[10]=_e^~Ae&oe,S[11]=re^~Ee&De,S[20]=Ie^~tt&Te,S[21]=et^~Pe&Ce,S[30]=Ue^~me&ke,S[31]=$e^~ze&ge,S[40]=it^~nt&rt,S[41]=qe^~Je&ir,S[2]=ae^~le&ue,S[3]=ve^~ne&fe,S[12]=Ae^~oe&Me,S[13]=Ee^~De&Oe,S[22]=tt^~Te&de,S[23]=Pe^~Ce&Fe,S[32]=me^~ke&Le,S[33]=ze^~ge&Re,S[42]=nt^~rt&nr,S[43]=Je^~ir&sr,S[4]=le^~ue&te,S[5]=ne^~fe&pe,S[14]=oe^~Me&We,S[15]=De^~Oe&Qe,S[24]=Te^~de&Be,S[25]=Ce^~Fe&ce,S[34]=ke^~Le&ye,S[35]=ge^~Re&Ke,S[44]=rt^~nr&ar,S[45]=ir^~sr&yt,S[6]=ue^~te&Ne,S[7]=fe^~pe&xe,S[16]=Me^~We&_e,S[17]=Oe^~Qe&re,S[26]=de^~Be&Ie,S[27]=Fe^~ce&et,S[36]=Le^~ye&Ue,S[37]=Re^~Ke&$e,S[46]=nr^~ar&it,S[47]=sr^~yt&qe,S[8]=te^~Ne&ae,S[9]=pe^~xe&ve,S[18]=We^~_e&Ae,S[19]=Qe^~re&Ee,S[28]=Be^~Ie&tt,S[29]=ce^~et&Pe,S[38]=ye^~Ue&me,S[39]=Ke^~$e&ze,S[48]=ar^~it&nt,S[49]=yt^~qe&Je,S[0]^=P[q],S[1]^=P[q+1]};if(f)r.exports=a;else for(b=0;b<c.length;++b)n[c[b]]=a[c[b]]})()})(eh);var wb=eh.exports;const _b="logger/5.7.0";let th=!1,rh=!1;const Gs={debug:1,default:2,info:2,warning:3,error:4,off:5};let ih=Gs.default,go=null;function xb(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(r){return r.message}return null}const nh=xb();var bo;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(bo||(bo={}));var Ir;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Ir||(Ir={}));const sh="0123456789abcdef";class Ve{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();Gs[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(ih>Gs[i])&&console.log.apply(console,t)}debug(...e){this._log(Ve.levels.DEBUG,e)}info(...e){this._log(Ve.levels.INFO,e)}warn(...e){this._log(Ve.levels.WARNING,e)}makeError(e,t,i){if(rh)return this.makeError("censored error",t,{});t||(t=Ve.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(u=>{const h=i[u];try{if(h instanceof Uint8Array){let g="";for(let y=0;y<h.length;y++)g+=sh[h[y]>>4],g+=sh[h[y]&15];n.push(u+"=Uint8Array(0x"+g+")")}else n.push(u+"="+JSON.stringify(h))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const s=e;let o="";switch(t){case Ir.NUMERIC_FAULT:{o="NUMERIC_FAULT";const u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Ir.CALL_EXCEPTION:case Ir.INSUFFICIENT_FUNDS:case Ir.MISSING_NEW:case Ir.NONCE_EXPIRED:case Ir.REPLACEMENT_UNDERPRICED:case Ir.TRANSACTION_REPLACED:case Ir.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,Ve.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){nh&&this.throwError("platform missing String.prototype.normalize",Ve.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:nh})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,Ve.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,Ve.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Ve.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return go||(go=new Ve(_b)),go}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),th){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}rh=!!e,th=!!t}static setLogLevel(e){const t=Gs[e.toLowerCase()];if(t==null){Ve.globalLogger().warn("invalid log level - "+e);return}ih=t}static from(e){return new Ve(e)}}Ve.errors=Ir,Ve.levels=bo;const Ab="bytes/5.7.0",vt=new Ve(Ab);function ah(r){return!!r.toHexString}function vn(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return vn(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function Eb(r){return fr(r)&&!(r.length%2)||mn(r)}function oh(r){return typeof r=="number"&&r==r&&r%1===0}function mn(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!oh(r.length)||r.length<0)return!1;for(let e=0;e<r.length;e++){const t=r[e];if(!oh(t)||t<0||t>=256)return!1}return!0}function lt(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),vn(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ah(r)&&(r=r.toHexString()),fr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":vt.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;n<t.length;n+=2)i.push(parseInt(t.substring(n,n+2),16));return vn(new Uint8Array(i))}return mn(r)?vn(new Uint8Array(r)):vt.throwArgumentError("invalid arrayify value","value",r)}function Sb(r){const e=r.map(n=>lt(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),vn(i)}function Mb(r,e){r=lt(r),r.length>e&&vt.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),vn(t)}function fr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const vo="0123456789abcdef";function Gt(r,e){if(e||(e={}),typeof r=="number"){vt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=vo[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),ah(r))return r.toHexString();if(fr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":vt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(mn(r)){let t="0x";for(let i=0;i<r.length;i++){let n=r[i];t+=vo[(n&240)>>4]+vo[n&15]}return t}return vt.throwArgumentError("invalid hexlify value","value",r)}function Ib(r){if(typeof r!="string")r=Gt(r);else if(!fr(r)||r.length%2)return null;return(r.length-2)/2}function fh(r,e,t){return typeof r!="string"?r=Gt(r):(!fr(r)||r.length%2)&&vt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function qr(r,e){for(typeof r!="string"?r=Gt(r):fr(r)||vt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&vt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function ch(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Eb(r)){let t=lt(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Gt(t.slice(0,32)),e.s=Gt(t.slice(32,64))):t.length===65?(e.r=Gt(t.slice(0,32)),e.s=Gt(t.slice(32,64)),e.v=t[64]):vt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:vt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Gt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=Mb(lt(e._vs),32);e._vs=Gt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&vt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const o=Gt(n);e.s==null?e.s=o:e.s!==o&&vt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?vt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&vt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!fr(e.r)?vt.throwArgumentError("signature missing or invalid r","signature",r):e.r=qr(e.r,32),e.s==null||!fr(e.s)?vt.throwArgumentError("signature missing or invalid s","signature",r):e.s=qr(e.s,32);const t=lt(e.s);t[0]>=128&&vt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=Gt(t);e._vs&&(fr(e._vs)||vt.throwArgumentError("signature invalid _vs","signature",r),e._vs=qr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&vt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function mo(r){return"0x"+wb.keccak_256(lt(r))}var hh={exports:{}};(function(r){(function(e,t){function i(l,a){if(!l)throw new Error(a||"Assertion failed")}function n(l,a){l.super_=a;var c=function(){};c.prototype=a.prototype,l.prototype=new c,l.prototype.constructor=l}function s(l,a,c){if(s.isBN(l))return l;this.negative=0,this.words=null,this.length=0,this.red=null,l!==null&&((a==="le"||a==="be")&&(c=a,a=10),this._init(l||0,a||10,c||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Us.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,c){return a.cmp(c)>0?a:c},s.min=function(a,c){return a.cmp(c)<0?a:c},s.prototype._init=function(a,c,b){if(typeof a=="number")return this._initNumber(a,c,b);if(typeof a=="object")return this._initArray(a,c,b);c==="hex"&&(c=16),i(c===(c|0)&&c>=2&&c<=36),a=a.toString().replace(/\s+/g,"");var A=0;a[0]==="-"&&(A++,this.negative=1),A<a.length&&(c===16?this._parseHex(a,A,b):(this._parseBase(a,c,A),b==="le"&&this._initArray(this.toArray(),c,b)))},s.prototype._initNumber=function(a,c,b){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),c,b)},s.prototype._initArray=function(a,c,b){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E,x,d=0;if(b==="be")for(A=a.length-1,E=0;A>=0;A-=3)x=a[A]|a[A-1]<<8|a[A-2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);else if(b==="le")for(A=0,E=0;A<a.length;A+=3)x=a[A]|a[A+1]<<8|a[A+2]<<16,this.words[E]|=x<<d&67108863,this.words[E+1]=x>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);return this._strip()};function f(l,a){var c=l.charCodeAt(a);if(c>=48&&c<=57)return c-48;if(c>=65&&c<=70)return c-55;if(c>=97&&c<=102)return c-87;i(!1,"Invalid character in "+l)}function u(l,a,c){var b=f(l,c);return c-1>=a&&(b|=f(l,c-1)<<4),b}s.prototype._parseHex=function(a,c,b){this.length=Math.ceil((a.length-c)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var E=0,x=0,d;if(b==="be")for(A=a.length-1;A>=c;A-=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8;else{var w=a.length-c;for(A=w%2===0?c+1:c;A<a.length;A+=2)d=u(a,c,A)<<E,this.words[x]|=d&67108863,E>=18?(E-=18,x+=1,this.words[x]|=d>>>26):E+=8}this._strip()};function h(l,a,c,b){for(var A=0,E=0,x=Math.min(l.length,c),d=a;d<x;d++){var w=l.charCodeAt(d)-48;A*=b,w>=49?E=w-49+10:w>=17?E=w-17+10:E=w,i(w>=0&&E<b,"Invalid character"),A+=E}return A}s.prototype._parseBase=function(a,c,b){this.words=[0],this.length=1;for(var A=0,E=1;E<=67108863;E*=c)A++;A--,E=E/c|0;for(var x=a.length-b,d=x%A,w=Math.min(x,x-d)+b,v=0,O=b;O<w;O+=A)v=h(a,O,O+A,c),this.imuln(E),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v);if(d!==0){var W=1;for(v=h(a,O,a.length,c),O=0;O<d;O++)W*=c;this.imuln(W),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var c=0;c<this.length;c++)a.words[c]=this.words[c];a.length=this.length,a.negative=this.negative,a.red=this.red};function g(l,a){l.words=a.words,l.length=a.length,l.negative=a.negative,l.red=a.red}if(s.prototype._move=function(a){g(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)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")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","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"],M=[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],D=[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(a,c){a=a||10,c=c|0||1;var b;if(a===16||a==="hex"){b="";for(var A=0,E=0,x=0;x<this.length;x++){var d=this.words[x],w=((d<<A|E)&16777215).toString(16);E=d>>>24-A&16777215,A+=2,A>=26&&(A-=26,x--),E!==0||x!==this.length-1?b=I[6-w.length]+w+b:b=w+b}for(E!==0&&(b=E.toString(16)+b);b.length%c!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(a===(a|0)&&a>=2&&a<=36){var v=M[a],O=D[a];b="";var W=this.clone();for(W.negative=0;!W.isZero();){var S=W.modrn(O).toString(a);W=W.idivn(O),W.isZero()?b=S+b:b=I[v-S.length]+S+b}for(this.isZero()&&(b="0"+b);b.length%c!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,c){return this.toArrayLike(o,a,c)}),s.prototype.toArray=function(a,c){return this.toArrayLike(Array,a,c)};var P=function(a,c){return a.allocUnsafe?a.allocUnsafe(c):new a(c)};s.prototype.toArrayLike=function(a,c,b){this._strip();var A=this.byteLength(),E=b||Math.max(1,A);i(A<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0");var x=P(a,E),d=c==="le"?"LE":"BE";return this["_toArrayLike"+d](x,A),x},s.prototype._toArrayLikeLE=function(a,c){for(var b=0,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b++]=d&255,b<a.length&&(a[b++]=d>>8&255),b<a.length&&(a[b++]=d>>16&255),x===6?(b<a.length&&(a[b++]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b<a.length)for(a[b++]=A;b<a.length;)a[b++]=0},s.prototype._toArrayLikeBE=function(a,c){for(var b=a.length-1,A=0,E=0,x=0;E<this.length;E++){var d=this.words[E]<<x|A;a[b--]=d&255,b>=0&&(a[b--]=d>>8&255),b>=0&&(a[b--]=d>>16&255),x===6?(b>=0&&(a[b--]=d>>24&255),A=0,x=0):(A=d>>>24,x+=2)}if(b>=0)for(a[b--]=A;b>=0;)a[b--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var c=a,b=0;return c>=4096&&(b+=13,c>>>=13),c>=64&&(b+=7,c>>>=7),c>=8&&(b+=4,c>>>=4),c>=2&&(b+=2,c>>>=2),b+c},s.prototype._zeroBits=function(a){if(a===0)return 26;var c=a,b=0;return c&8191||(b+=13,c>>>=13),c&127||(b+=7,c>>>=7),c&15||(b+=4,c>>>=4),c&3||(b+=2,c>>>=2),c&1||b++,b},s.prototype.bitLength=function(){var a=this.words[this.length-1],c=this._countBits(a);return(this.length-1)*26+c};function k(l){for(var a=new Array(l.bitLength()),c=0;c<a.length;c++){var b=c/26|0,A=c%26;a[c]=l.words[b]>>>A&1}return a}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,c=0;c<this.length;c++){var b=this._zeroBits(this.words[c]);if(a+=b,b!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var c=0;c<a.length;c++)this.words[c]=this.words[c]|a.words[c];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var c;this.length>a.length?c=a:c=this;for(var b=0;b<c.length;b++)this.words[b]=this.words[b]&a.words[b];return this.length=c.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var c,b;this.length>a.length?(c=this,b=a):(c=a,b=this);for(var A=0;A<b.length;A++)this.words[A]=c.words[A]^b.words[A];if(this!==c)for(;A<c.length;A++)this.words[A]=c.words[A];return this.length=c.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var c=Math.ceil(a/26)|0,b=a%26;this._expand(c),b>0&&c--;for(var A=0;A<c;A++)this.words[A]=~this.words[A]&67108863;return b>0&&(this.words[A]=~this.words[A]&67108863>>26-b),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,c){i(typeof a=="number"&&a>=0);var b=a/26|0,A=a%26;return this._expand(b+1),c?this.words[b]=this.words[b]|1<<A:this.words[b]=this.words[b]&~(1<<A),this._strip()},s.prototype.iadd=function(a){var c;if(this.negative!==0&&a.negative===0)return this.negative=0,c=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,c=this.isub(a),a.negative=1,c._normSign();var b,A;this.length>a.length?(b=this,A=a):(b=a,A=this);for(var E=0,x=0;x<A.length;x++)c=(b.words[x]|0)+(A.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;for(;E!==0&&x<b.length;x++)c=(b.words[x]|0)+E,this.words[x]=c&67108863,E=c>>>26;if(this.length=b.length,E!==0)this.words[this.length]=E,this.length++;else if(b!==this)for(;x<b.length;x++)this.words[x]=b.words[x];return this},s.prototype.add=function(a){var c;return a.negative!==0&&this.negative===0?(a.negative=0,c=this.sub(a),a.negative^=1,c):a.negative===0&&this.negative!==0?(this.negative=0,c=a.sub(this),this.negative=1,c):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var c=this.iadd(a);return a.negative=1,c._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var b=this.cmp(a);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,E;b>0?(A=this,E=a):(A=a,E=this);for(var x=0,d=0;d<E.length;d++)c=(A.words[d]|0)-(E.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;for(;x!==0&&d<A.length;d++)c=(A.words[d]|0)+x,x=c>>26,this.words[d]=c&67108863;if(x===0&&d<A.length&&A!==this)for(;d<A.length;d++)this.words[d]=A.words[d];return this.length=Math.max(this.length,d),A!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function K(l,a,c){c.negative=a.negative^l.negative;var b=l.length+a.length|0;c.length=b,b=b-1|0;var A=l.words[0]|0,E=a.words[0]|0,x=A*E,d=x&67108863,w=x/67108864|0;c.words[0]=d;for(var v=1;v<b;v++){for(var O=w>>>26,W=w&67108863,S=Math.min(v,a.length-1),H=Math.max(0,v-l.length+1);H<=S;H++){var T=v-H|0;A=l.words[T]|0,E=a.words[H]|0,x=A*E+W,O+=x/67108864|0,W=x&67108863}c.words[v]=W|0,w=O|0}return w!==0?c.words[v]=w|0:c.length--,c._strip()}var C=function(a,c,b){var A=a.words,E=c.words,x=b.words,d=0,w,v,O,W=A[0]|0,S=W&8191,H=W>>>13,T=A[1]|0,q=T&8191,B=T>>>13,m=A[2]|0,L=m&8191,G=m>>>13,Y=A[3]|0,X=Y&8191,ee=Y>>>13,we=A[4]|0,Se=we&8191,he=we>>>13,Ne=A[5]|0,xe=Ne&8191,ae=Ne>>>13,ve=A[6]|0,le=ve&8191,ne=ve>>>13,ue=A[7]|0,fe=ue&8191,te=ue>>>13,pe=A[8]|0,_e=pe&8191,re=pe>>>13,Ae=A[9]|0,Ee=Ae&8191,oe=Ae>>>13,De=E[0]|0,Me=De&8191,Oe=De>>>13,We=E[1]|0,Qe=We&8191,Ie=We>>>13,et=E[2]|0,tt=et&8191,Pe=et>>>13,Te=E[3]|0,Ce=Te&8191,de=Te>>>13,Fe=E[4]|0,Be=Fe&8191,ce=Fe>>>13,Ue=E[5]|0,$e=Ue&8191,me=Ue>>>13,ze=E[6]|0,ke=ze&8191,ge=ze>>>13,Le=E[7]|0,Re=Le&8191,ye=Le>>>13,Ke=E[8]|0,it=Ke&8191,qe=Ke>>>13,nt=E[9]|0,Je=nt&8191,rt=nt>>>13;b.negative=a.negative^c.negative,b.length=19,w=Math.imul(S,Me),v=Math.imul(S,Oe),v=v+Math.imul(H,Me)|0,O=Math.imul(H,Oe);var ir=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ir>>>26)|0,ir&=67108863,w=Math.imul(q,Me),v=Math.imul(q,Oe),v=v+Math.imul(B,Me)|0,O=Math.imul(B,Oe),w=w+Math.imul(S,Qe)|0,v=v+Math.imul(S,Ie)|0,v=v+Math.imul(H,Qe)|0,O=O+Math.imul(H,Ie)|0;var nr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(nr>>>26)|0,nr&=67108863,w=Math.imul(L,Me),v=Math.imul(L,Oe),v=v+Math.imul(G,Me)|0,O=Math.imul(G,Oe),w=w+Math.imul(q,Qe)|0,v=v+Math.imul(q,Ie)|0,v=v+Math.imul(B,Qe)|0,O=O+Math.imul(B,Ie)|0,w=w+Math.imul(S,tt)|0,v=v+Math.imul(S,Pe)|0,v=v+Math.imul(H,tt)|0,O=O+Math.imul(H,Pe)|0;var sr=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(sr>>>26)|0,sr&=67108863,w=Math.imul(X,Me),v=Math.imul(X,Oe),v=v+Math.imul(ee,Me)|0,O=Math.imul(ee,Oe),w=w+Math.imul(L,Qe)|0,v=v+Math.imul(L,Ie)|0,v=v+Math.imul(G,Qe)|0,O=O+Math.imul(G,Ie)|0,w=w+Math.imul(q,tt)|0,v=v+Math.imul(q,Pe)|0,v=v+Math.imul(B,tt)|0,O=O+Math.imul(B,Pe)|0,w=w+Math.imul(S,Ce)|0,v=v+Math.imul(S,de)|0,v=v+Math.imul(H,Ce)|0,O=O+Math.imul(H,de)|0;var ar=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(ar>>>26)|0,ar&=67108863,w=Math.imul(Se,Me),v=Math.imul(Se,Oe),v=v+Math.imul(he,Me)|0,O=Math.imul(he,Oe),w=w+Math.imul(X,Qe)|0,v=v+Math.imul(X,Ie)|0,v=v+Math.imul(ee,Qe)|0,O=O+Math.imul(ee,Ie)|0,w=w+Math.imul(L,tt)|0,v=v+Math.imul(L,Pe)|0,v=v+Math.imul(G,tt)|0,O=O+Math.imul(G,Pe)|0,w=w+Math.imul(q,Ce)|0,v=v+Math.imul(q,de)|0,v=v+Math.imul(B,Ce)|0,O=O+Math.imul(B,de)|0,w=w+Math.imul(S,Be)|0,v=v+Math.imul(S,ce)|0,v=v+Math.imul(H,Be)|0,O=O+Math.imul(H,ce)|0;var yt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yt>>>26)|0,yt&=67108863,w=Math.imul(xe,Me),v=Math.imul(xe,Oe),v=v+Math.imul(ae,Me)|0,O=Math.imul(ae,Oe),w=w+Math.imul(Se,Qe)|0,v=v+Math.imul(Se,Ie)|0,v=v+Math.imul(he,Qe)|0,O=O+Math.imul(he,Ie)|0,w=w+Math.imul(X,tt)|0,v=v+Math.imul(X,Pe)|0,v=v+Math.imul(ee,tt)|0,O=O+Math.imul(ee,Pe)|0,w=w+Math.imul(L,Ce)|0,v=v+Math.imul(L,de)|0,v=v+Math.imul(G,Ce)|0,O=O+Math.imul(G,de)|0,w=w+Math.imul(q,Be)|0,v=v+Math.imul(q,ce)|0,v=v+Math.imul(B,Be)|0,O=O+Math.imul(B,ce)|0,w=w+Math.imul(S,$e)|0,v=v+Math.imul(S,me)|0,v=v+Math.imul(H,$e)|0,O=O+Math.imul(H,me)|0;var di=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(di>>>26)|0,di&=67108863,w=Math.imul(le,Me),v=Math.imul(le,Oe),v=v+Math.imul(ne,Me)|0,O=Math.imul(ne,Oe),w=w+Math.imul(xe,Qe)|0,v=v+Math.imul(xe,Ie)|0,v=v+Math.imul(ae,Qe)|0,O=O+Math.imul(ae,Ie)|0,w=w+Math.imul(Se,tt)|0,v=v+Math.imul(Se,Pe)|0,v=v+Math.imul(he,tt)|0,O=O+Math.imul(he,Pe)|0,w=w+Math.imul(X,Ce)|0,v=v+Math.imul(X,de)|0,v=v+Math.imul(ee,Ce)|0,O=O+Math.imul(ee,de)|0,w=w+Math.imul(L,Be)|0,v=v+Math.imul(L,ce)|0,v=v+Math.imul(G,Be)|0,O=O+Math.imul(G,ce)|0,w=w+Math.imul(q,$e)|0,v=v+Math.imul(q,me)|0,v=v+Math.imul(B,$e)|0,O=O+Math.imul(B,me)|0,w=w+Math.imul(S,ke)|0,v=v+Math.imul(S,ge)|0,v=v+Math.imul(H,ke)|0,O=O+Math.imul(H,ge)|0;var li=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(li>>>26)|0,li&=67108863,w=Math.imul(fe,Me),v=Math.imul(fe,Oe),v=v+Math.imul(te,Me)|0,O=Math.imul(te,Oe),w=w+Math.imul(le,Qe)|0,v=v+Math.imul(le,Ie)|0,v=v+Math.imul(ne,Qe)|0,O=O+Math.imul(ne,Ie)|0,w=w+Math.imul(xe,tt)|0,v=v+Math.imul(xe,Pe)|0,v=v+Math.imul(ae,tt)|0,O=O+Math.imul(ae,Pe)|0,w=w+Math.imul(Se,Ce)|0,v=v+Math.imul(Se,de)|0,v=v+Math.imul(he,Ce)|0,O=O+Math.imul(he,de)|0,w=w+Math.imul(X,Be)|0,v=v+Math.imul(X,ce)|0,v=v+Math.imul(ee,Be)|0,O=O+Math.imul(ee,ce)|0,w=w+Math.imul(L,$e)|0,v=v+Math.imul(L,me)|0,v=v+Math.imul(G,$e)|0,O=O+Math.imul(G,me)|0,w=w+Math.imul(q,ke)|0,v=v+Math.imul(q,ge)|0,v=v+Math.imul(B,ke)|0,O=O+Math.imul(B,ge)|0,w=w+Math.imul(S,Re)|0,v=v+Math.imul(S,ye)|0,v=v+Math.imul(H,Re)|0,O=O+Math.imul(H,ye)|0;var pi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(pi>>>26)|0,pi&=67108863,w=Math.imul(_e,Me),v=Math.imul(_e,Oe),v=v+Math.imul(re,Me)|0,O=Math.imul(re,Oe),w=w+Math.imul(fe,Qe)|0,v=v+Math.imul(fe,Ie)|0,v=v+Math.imul(te,Qe)|0,O=O+Math.imul(te,Ie)|0,w=w+Math.imul(le,tt)|0,v=v+Math.imul(le,Pe)|0,v=v+Math.imul(ne,tt)|0,O=O+Math.imul(ne,Pe)|0,w=w+Math.imul(xe,Ce)|0,v=v+Math.imul(xe,de)|0,v=v+Math.imul(ae,Ce)|0,O=O+Math.imul(ae,de)|0,w=w+Math.imul(Se,Be)|0,v=v+Math.imul(Se,ce)|0,v=v+Math.imul(he,Be)|0,O=O+Math.imul(he,ce)|0,w=w+Math.imul(X,$e)|0,v=v+Math.imul(X,me)|0,v=v+Math.imul(ee,$e)|0,O=O+Math.imul(ee,me)|0,w=w+Math.imul(L,ke)|0,v=v+Math.imul(L,ge)|0,v=v+Math.imul(G,ke)|0,O=O+Math.imul(G,ge)|0,w=w+Math.imul(q,Re)|0,v=v+Math.imul(q,ye)|0,v=v+Math.imul(B,Re)|0,O=O+Math.imul(B,ye)|0,w=w+Math.imul(S,it)|0,v=v+Math.imul(S,qe)|0,v=v+Math.imul(H,it)|0,O=O+Math.imul(H,qe)|0;var gi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(gi>>>26)|0,gi&=67108863,w=Math.imul(Ee,Me),v=Math.imul(Ee,Oe),v=v+Math.imul(oe,Me)|0,O=Math.imul(oe,Oe),w=w+Math.imul(_e,Qe)|0,v=v+Math.imul(_e,Ie)|0,v=v+Math.imul(re,Qe)|0,O=O+Math.imul(re,Ie)|0,w=w+Math.imul(fe,tt)|0,v=v+Math.imul(fe,Pe)|0,v=v+Math.imul(te,tt)|0,O=O+Math.imul(te,Pe)|0,w=w+Math.imul(le,Ce)|0,v=v+Math.imul(le,de)|0,v=v+Math.imul(ne,Ce)|0,O=O+Math.imul(ne,de)|0,w=w+Math.imul(xe,Be)|0,v=v+Math.imul(xe,ce)|0,v=v+Math.imul(ae,Be)|0,O=O+Math.imul(ae,ce)|0,w=w+Math.imul(Se,$e)|0,v=v+Math.imul(Se,me)|0,v=v+Math.imul(he,$e)|0,O=O+Math.imul(he,me)|0,w=w+Math.imul(X,ke)|0,v=v+Math.imul(X,ge)|0,v=v+Math.imul(ee,ke)|0,O=O+Math.imul(ee,ge)|0,w=w+Math.imul(L,Re)|0,v=v+Math.imul(L,ye)|0,v=v+Math.imul(G,Re)|0,O=O+Math.imul(G,ye)|0,w=w+Math.imul(q,it)|0,v=v+Math.imul(q,qe)|0,v=v+Math.imul(B,it)|0,O=O+Math.imul(B,qe)|0,w=w+Math.imul(S,Je)|0,v=v+Math.imul(S,rt)|0,v=v+Math.imul(H,Je)|0,O=O+Math.imul(H,rt)|0;var bi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(bi>>>26)|0,bi&=67108863,w=Math.imul(Ee,Qe),v=Math.imul(Ee,Ie),v=v+Math.imul(oe,Qe)|0,O=Math.imul(oe,Ie),w=w+Math.imul(_e,tt)|0,v=v+Math.imul(_e,Pe)|0,v=v+Math.imul(re,tt)|0,O=O+Math.imul(re,Pe)|0,w=w+Math.imul(fe,Ce)|0,v=v+Math.imul(fe,de)|0,v=v+Math.imul(te,Ce)|0,O=O+Math.imul(te,de)|0,w=w+Math.imul(le,Be)|0,v=v+Math.imul(le,ce)|0,v=v+Math.imul(ne,Be)|0,O=O+Math.imul(ne,ce)|0,w=w+Math.imul(xe,$e)|0,v=v+Math.imul(xe,me)|0,v=v+Math.imul(ae,$e)|0,O=O+Math.imul(ae,me)|0,w=w+Math.imul(Se,ke)|0,v=v+Math.imul(Se,ge)|0,v=v+Math.imul(he,ke)|0,O=O+Math.imul(he,ge)|0,w=w+Math.imul(X,Re)|0,v=v+Math.imul(X,ye)|0,v=v+Math.imul(ee,Re)|0,O=O+Math.imul(ee,ye)|0,w=w+Math.imul(L,it)|0,v=v+Math.imul(L,qe)|0,v=v+Math.imul(G,it)|0,O=O+Math.imul(G,qe)|0,w=w+Math.imul(q,Je)|0,v=v+Math.imul(q,rt)|0,v=v+Math.imul(B,Je)|0,O=O+Math.imul(B,rt)|0;var Er=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(Er>>>26)|0,Er&=67108863,w=Math.imul(Ee,tt),v=Math.imul(Ee,Pe),v=v+Math.imul(oe,tt)|0,O=Math.imul(oe,Pe),w=w+Math.imul(_e,Ce)|0,v=v+Math.imul(_e,de)|0,v=v+Math.imul(re,Ce)|0,O=O+Math.imul(re,de)|0,w=w+Math.imul(fe,Be)|0,v=v+Math.imul(fe,ce)|0,v=v+Math.imul(te,Be)|0,O=O+Math.imul(te,ce)|0,w=w+Math.imul(le,$e)|0,v=v+Math.imul(le,me)|0,v=v+Math.imul(ne,$e)|0,O=O+Math.imul(ne,me)|0,w=w+Math.imul(xe,ke)|0,v=v+Math.imul(xe,ge)|0,v=v+Math.imul(ae,ke)|0,O=O+Math.imul(ae,ge)|0,w=w+Math.imul(Se,Re)|0,v=v+Math.imul(Se,ye)|0,v=v+Math.imul(he,Re)|0,O=O+Math.imul(he,ye)|0,w=w+Math.imul(X,it)|0,v=v+Math.imul(X,qe)|0,v=v+Math.imul(ee,it)|0,O=O+Math.imul(ee,qe)|0,w=w+Math.imul(L,Je)|0,v=v+Math.imul(L,rt)|0,v=v+Math.imul(G,Je)|0,O=O+Math.imul(G,rt)|0;var vi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(vi>>>26)|0,vi&=67108863,w=Math.imul(Ee,Ce),v=Math.imul(Ee,de),v=v+Math.imul(oe,Ce)|0,O=Math.imul(oe,de),w=w+Math.imul(_e,Be)|0,v=v+Math.imul(_e,ce)|0,v=v+Math.imul(re,Be)|0,O=O+Math.imul(re,ce)|0,w=w+Math.imul(fe,$e)|0,v=v+Math.imul(fe,me)|0,v=v+Math.imul(te,$e)|0,O=O+Math.imul(te,me)|0,w=w+Math.imul(le,ke)|0,v=v+Math.imul(le,ge)|0,v=v+Math.imul(ne,ke)|0,O=O+Math.imul(ne,ge)|0,w=w+Math.imul(xe,Re)|0,v=v+Math.imul(xe,ye)|0,v=v+Math.imul(ae,Re)|0,O=O+Math.imul(ae,ye)|0,w=w+Math.imul(Se,it)|0,v=v+Math.imul(Se,qe)|0,v=v+Math.imul(he,it)|0,O=O+Math.imul(he,qe)|0,w=w+Math.imul(X,Je)|0,v=v+Math.imul(X,rt)|0,v=v+Math.imul(ee,Je)|0,O=O+Math.imul(ee,rt)|0;var mi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(mi>>>26)|0,mi&=67108863,w=Math.imul(Ee,Be),v=Math.imul(Ee,ce),v=v+Math.imul(oe,Be)|0,O=Math.imul(oe,ce),w=w+Math.imul(_e,$e)|0,v=v+Math.imul(_e,me)|0,v=v+Math.imul(re,$e)|0,O=O+Math.imul(re,me)|0,w=w+Math.imul(fe,ke)|0,v=v+Math.imul(fe,ge)|0,v=v+Math.imul(te,ke)|0,O=O+Math.imul(te,ge)|0,w=w+Math.imul(le,Re)|0,v=v+Math.imul(le,ye)|0,v=v+Math.imul(ne,Re)|0,O=O+Math.imul(ne,ye)|0,w=w+Math.imul(xe,it)|0,v=v+Math.imul(xe,qe)|0,v=v+Math.imul(ae,it)|0,O=O+Math.imul(ae,qe)|0,w=w+Math.imul(Se,Je)|0,v=v+Math.imul(Se,rt)|0,v=v+Math.imul(he,Je)|0,O=O+Math.imul(he,rt)|0;var jt=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(jt>>>26)|0,jt&=67108863,w=Math.imul(Ee,$e),v=Math.imul(Ee,me),v=v+Math.imul(oe,$e)|0,O=Math.imul(oe,me),w=w+Math.imul(_e,ke)|0,v=v+Math.imul(_e,ge)|0,v=v+Math.imul(re,ke)|0,O=O+Math.imul(re,ge)|0,w=w+Math.imul(fe,Re)|0,v=v+Math.imul(fe,ye)|0,v=v+Math.imul(te,Re)|0,O=O+Math.imul(te,ye)|0,w=w+Math.imul(le,it)|0,v=v+Math.imul(le,qe)|0,v=v+Math.imul(ne,it)|0,O=O+Math.imul(ne,qe)|0,w=w+Math.imul(xe,Je)|0,v=v+Math.imul(xe,rt)|0,v=v+Math.imul(ae,Je)|0,O=O+Math.imul(ae,rt)|0;var yi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(yi>>>26)|0,yi&=67108863,w=Math.imul(Ee,ke),v=Math.imul(Ee,ge),v=v+Math.imul(oe,ke)|0,O=Math.imul(oe,ge),w=w+Math.imul(_e,Re)|0,v=v+Math.imul(_e,ye)|0,v=v+Math.imul(re,Re)|0,O=O+Math.imul(re,ye)|0,w=w+Math.imul(fe,it)|0,v=v+Math.imul(fe,qe)|0,v=v+Math.imul(te,it)|0,O=O+Math.imul(te,qe)|0,w=w+Math.imul(le,Je)|0,v=v+Math.imul(le,rt)|0,v=v+Math.imul(ne,Je)|0,O=O+Math.imul(ne,rt)|0;var wi=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(wi>>>26)|0,wi&=67108863,w=Math.imul(Ee,Re),v=Math.imul(Ee,ye),v=v+Math.imul(oe,Re)|0,O=Math.imul(oe,ye),w=w+Math.imul(_e,it)|0,v=v+Math.imul(_e,qe)|0,v=v+Math.imul(re,it)|0,O=O+Math.imul(re,qe)|0,w=w+Math.imul(fe,Je)|0,v=v+Math.imul(fe,rt)|0,v=v+Math.imul(te,Je)|0,O=O+Math.imul(te,rt)|0;var _i=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(_i>>>26)|0,_i&=67108863,w=Math.imul(Ee,it),v=Math.imul(Ee,qe),v=v+Math.imul(oe,it)|0,O=Math.imul(oe,qe),w=w+Math.imul(_e,Je)|0,v=v+Math.imul(_e,rt)|0,v=v+Math.imul(re,Je)|0,O=O+Math.imul(re,rt)|0;var _s=(d+w|0)+((v&8191)<<13)|0;d=(O+(v>>>13)|0)+(_s>>>26)|0,_s&=67108863,w=Math.imul(Ee,Je),v=Math.imul(Ee,rt),v=v+Math.imul(oe,Je)|0,O=Math.imul(oe,rt);var xs=(d+w|0)+((v&8191)<<13)|0;return d=(O+(v>>>13)|0)+(xs>>>26)|0,xs&=67108863,x[0]=ir,x[1]=nr,x[2]=sr,x[3]=ar,x[4]=yt,x[5]=di,x[6]=li,x[7]=pi,x[8]=gi,x[9]=bi,x[10]=Er,x[11]=vi,x[12]=mi,x[13]=jt,x[14]=yi,x[15]=wi,x[16]=_i,x[17]=_s,x[18]=xs,d!==0&&(x[19]=d,b.length++),b};Math.imul||(C=K);function j(l,a,c){c.negative=a.negative^l.negative,c.length=l.length+a.length;for(var b=0,A=0,E=0;E<c.length-1;E++){var x=A;A=0;for(var d=b&67108863,w=Math.min(E,a.length-1),v=Math.max(0,E-l.length+1);v<=w;v++){var O=E-v,W=l.words[O]|0,S=a.words[v]|0,H=W*S,T=H&67108863;x=x+(H/67108864|0)|0,T=T+d|0,d=T&67108863,x=x+(T>>>26)|0,A+=x>>>26,x&=67108863}c.words[E]=d,b=x,x=A}return b!==0?c.words[E]=b:c.length--,c._strip()}function F(l,a,c){return j(l,a,c)}s.prototype.mulTo=function(a,c){var b,A=this.length+a.length;return this.length===10&&a.length===10?b=C(this,a,c):A<63?b=K(this,a,c):A<1024?b=j(this,a,c):b=F(this,a,c),b},s.prototype.mul=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),this.mulTo(a,c)},s.prototype.mulf=function(a){var c=new s(null);return c.words=new Array(this.length+a.length),F(this,a,c)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var c=a<0;c&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var b=0,A=0;A<this.length;A++){var E=(this.words[A]|0)*a,x=(E&67108863)+(b&67108863);b>>=26,b+=E/67108864|0,b+=x>>>26,this.words[A]=x&67108863}return b!==0&&(this.words[A]=b,this.length++),c?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var c=k(a);if(c.length===0)return new s(1);for(var b=this,A=0;A<c.length&&c[A]===0;A++,b=b.sqr());if(++A<c.length)for(var E=b.sqr();A<c.length;A++,E=E.sqr())c[A]!==0&&(b=b.mul(E));return b},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=67108863>>>26-c<<26-c,E;if(c!==0){var x=0;for(E=0;E<this.length;E++){var d=this.words[E]&A,w=(this.words[E]|0)-d<<c;this.words[E]=w|x,x=d>>>26-c}x&&(this.words[E]=x,this.length++)}if(b!==0){for(E=this.length-1;E>=0;E--)this.words[E+b]=this.words[E];for(E=0;E<b;E++)this.words[E]=0;this.length+=b}return this._strip()},s.prototype.ishln=function(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,c,b){i(typeof a=="number"&&a>=0);var A;c?A=(c-c%26)/26:A=0;var E=a%26,x=Math.min((a-E)/26,this.length),d=67108863^67108863>>>E<<E,w=b;if(A-=x,A=Math.max(0,A),w){for(var v=0;v<x;v++)w.words[v]=this.words[v];w.length=x}if(x!==0)if(this.length>x)for(this.length-=x,v=0;v<this.length;v++)this.words[v]=this.words[v+x];else this.words[0]=0,this.length=1;var O=0;for(v=this.length-1;v>=0&&(O!==0||v>=A);v--){var W=this.words[v]|0;this.words[v]=O<<26-E|W>>>E,O=W&d}return w&&O!==0&&(w.words[w.length++]=O),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,c,b){return i(this.negative===0),this.iushrn(a,c,b)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return!1;var E=this.words[b];return!!(E&A)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var c=a%26,b=(a-c)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(c!==0&&b++,this.length=Math.min(b,this.length),c!==0){var A=67108863^67108863>>>c<<c;this.words[this.length-1]&=A}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var c=0;c<this.length&&this.words[c]>=67108864;c++)this.words[c]-=67108864,c===this.length-1?this.words[c+1]=1:this.words[c+1]++;return this.length=Math.max(this.length,c+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var c=0;c<this.length&&this.words[c]<0;c++)this.words[c]+=67108864,this.words[c+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,c,b){var A=a.length+b,E;this._expand(A);var x,d=0;for(E=0;E<a.length;E++){x=(this.words[E+b]|0)+d;var w=(a.words[E]|0)*c;x-=w&67108863,d=(x>>26)-(w/67108864|0),this.words[E+b]=x&67108863}for(;E<this.length-b;E++)x=(this.words[E+b]|0)+d,d=x>>26,this.words[E+b]=x&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,E=0;E<this.length;E++)x=-(this.words[E]|0)+d,d=x>>26,this.words[E]=x&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,c){var b=this.length-a.length,A=this.clone(),E=a,x=E.words[E.length-1]|0,d=this._countBits(x);b=26-d,b!==0&&(E=E.ushln(b),A.iushln(b),x=E.words[E.length-1]|0);var w=A.length-E.length,v;if(c!=="mod"){v=new s(null),v.length=w+1,v.words=new Array(v.length);for(var O=0;O<v.length;O++)v.words[O]=0}var W=A.clone()._ishlnsubmul(E,1,w);W.negative===0&&(A=W,v&&(v.words[w]=1));for(var S=w-1;S>=0;S--){var H=(A.words[E.length+S]|0)*67108864+(A.words[E.length+S-1]|0);for(H=Math.min(H/x|0,67108863),A._ishlnsubmul(E,H,S);A.negative!==0;)H--,A.negative=0,A._ishlnsubmul(E,1,S),A.isZero()||(A.negative^=1);v&&(v.words[S]=H)}return v&&v._strip(),A._strip(),c!=="div"&&b!==0&&A.iushrn(b),{div:v||null,mod:A}},s.prototype.divmod=function(a,c,b){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var A,E,x;return this.negative!==0&&a.negative===0?(x=this.neg().divmod(a,c),c!=="mod"&&(A=x.div.neg()),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.iadd(a)),{div:A,mod:E}):this.negative===0&&a.negative!==0?(x=this.divmod(a.neg(),c),c!=="mod"&&(A=x.div.neg()),{div:A,mod:x.mod}):this.negative&a.negative?(x=this.neg().divmod(a.neg(),c),c!=="div"&&(E=x.mod.neg(),b&&E.negative!==0&&E.isub(a)),{div:x.div,mod:E}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?c==="div"?{div:this.divn(a.words[0]),mod:null}:c==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,c)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var c=this.divmod(a);if(c.mod.isZero())return c.div;var b=c.div.negative!==0?c.mod.isub(a):c.mod,A=a.ushrn(1),E=a.andln(1),x=b.cmp(A);return x<0||E===1&&x===0?c.div:c.div.negative!==0?c.div.isubn(1):c.div.iaddn(1)},s.prototype.modrn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=(1<<26)%a,A=0,E=this.length-1;E>=0;E--)A=(b*A+(this.words[E]|0))%a;return c?-A:A},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var c=a<0;c&&(a=-a),i(a<=67108863);for(var b=0,A=this.length-1;A>=0;A--){var E=(this.words[A]|0)+b*67108864;this.words[A]=E/a|0,b=E%a}return this._strip(),c?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=new s(0),d=new s(1),w=0;c.isEven()&&b.isEven();)c.iushrn(1),b.iushrn(1),++w;for(var v=b.clone(),O=c.clone();!c.isZero();){for(var W=0,S=1;!(c.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(c.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(v),E.isub(O)),A.iushrn(1),E.iushrn(1);for(var H=0,T=1;!(b.words[0]&T)&&H<26;++H,T<<=1);if(H>0)for(b.iushrn(H);H-- >0;)(x.isOdd()||d.isOdd())&&(x.iadd(v),d.isub(O)),x.iushrn(1),d.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(x),E.isub(d)):(b.isub(c),x.isub(A),d.isub(E))}return{a:x,b:d,gcd:b.iushln(w)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var c=this,b=a.clone();c.negative!==0?c=c.umod(a):c=c.clone();for(var A=new s(1),E=new s(0),x=b.clone();c.cmpn(1)>0&&b.cmpn(1)>0;){for(var d=0,w=1;!(c.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(c.iushrn(d);d-- >0;)A.isOdd()&&A.iadd(x),A.iushrn(1);for(var v=0,O=1;!(b.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(b.iushrn(v);v-- >0;)E.isOdd()&&E.iadd(x),E.iushrn(1);c.cmp(b)>=0?(c.isub(b),A.isub(E)):(b.isub(c),E.isub(A))}var W;return c.cmpn(1)===0?W=A:W=E,W.cmpn(0)<0&&W.iadd(a),W},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var c=this.clone(),b=a.clone();c.negative=0,b.negative=0;for(var A=0;c.isEven()&&b.isEven();A++)c.iushrn(1),b.iushrn(1);do{for(;c.isEven();)c.iushrn(1);for(;b.isEven();)b.iushrn(1);var E=c.cmp(b);if(E<0){var x=c;c=b,b=x}else if(E===0||b.cmpn(1)===0)break;c.isub(b)}while(!0);return b.iushln(A)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var c=a%26,b=(a-c)/26,A=1<<c;if(this.length<=b)return this._expand(b+1),this.words[b]|=A,this;for(var E=A,x=b;E!==0&&x<this.length;x++){var d=this.words[x]|0;d+=E,E=d>>>26,d&=67108863,this.words[x]=d}return E!==0&&(this.words[x]=E,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var c=a<0;if(this.negative!==0&&!c)return-1;if(this.negative===0&&c)return 1;this._strip();var b;if(this.length>1)b=1;else{c&&(a=-a),i(a<=67108863,"Number is too big");var A=this.words[0]|0;b=A===a?0:A<a?-1:1}return this.negative!==0?-b|0:b},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var c=this.ucmp(a);return this.negative!==0?-c|0:c},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var c=0,b=this.length-1;b>=0;b--){var A=this.words[b]|0,E=a.words[b]|0;if(A!==E){A<E?c=-1:A>E&&(c=1);break}}return c},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new N(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var U={k256:null,p224:null,p192:null,p25519:null};function z(l,a){this.name=l,this.p=new s(a,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 a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},z.prototype.ireduce=function(a){var c=a,b;do this.split(c,this.tmp),c=this.imulK(c),c=c.iadd(this.tmp),b=c.bitLength();while(b>this.n);var A=b<this.n?-1:c.ucmp(this.p);return A===0?(c.words[0]=0,c.length=1):A>0?c.isub(this.p):c.strip!==void 0?c.strip():c._strip(),c},z.prototype.split=function(a,c){a.iushrn(this.n,0,c)},z.prototype.imulK=function(a){return a.imul(this.k)};function _(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(_,z),_.prototype.split=function(a,c){for(var b=4194303,A=Math.min(a.length,9),E=0;E<A;E++)c.words[E]=a.words[E];if(c.length=A,a.length<=9){a.words[0]=0,a.length=1;return}var x=a.words[9];for(c.words[c.length++]=x&b,E=10;E<a.length;E++){var d=a.words[E]|0;a.words[E-10]=(d&b)<<4|x>>>22,x=d}x>>>=22,a.words[E-10]=x,x===0&&a.length>10?a.length-=10:a.length-=9},_.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var c=0,b=0;b<a.length;b++){var A=a.words[b]|0;c+=A*977,a.words[b]=c&67108863,c=A*64+(c/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function R(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(R,z);function J(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(J,z);function Q(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,z),Q.prototype.imulK=function(a){for(var c=0,b=0;b<a.length;b++){var A=(a.words[b]|0)*19+c,E=A&67108863;A>>>=26,a.words[b]=E,c=A}return c!==0&&(a.words[a.length++]=c),a},s._prime=function(a){if(U[a])return U[a];var c;if(a==="k256")c=new _;else if(a==="p224")c=new R;else if(a==="p192")c=new J;else if(a==="p25519")c=new Q;else throw new Error("Unknown prime "+a);return U[a]=c,c};function N(l){if(typeof l=="string"){var a=s._prime(l);this.m=a.p,this.prime=a}else i(l.gtn(1),"modulus must be greater than 1"),this.m=l,this.prime=null}N.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},N.prototype._verify2=function(a,c){i((a.negative|c.negative)===0,"red works only with positives"),i(a.red&&a.red===c.red,"red works only with red numbers")},N.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(g(a,a.umod(this.m)._forceRed(this)),a)},N.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},N.prototype.add=function(a,c){this._verify2(a,c);var b=a.add(c);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},N.prototype.iadd=function(a,c){this._verify2(a,c);var b=a.iadd(c);return b.cmp(this.m)>=0&&b.isub(this.m),b},N.prototype.sub=function(a,c){this._verify2(a,c);var b=a.sub(c);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},N.prototype.isub=function(a,c){this._verify2(a,c);var b=a.isub(c);return b.cmpn(0)<0&&b.iadd(this.m),b},N.prototype.shl=function(a,c){return this._verify1(a),this.imod(a.ushln(c))},N.prototype.imul=function(a,c){return this._verify2(a,c),this.imod(a.imul(c))},N.prototype.mul=function(a,c){return this._verify2(a,c),this.imod(a.mul(c))},N.prototype.isqr=function(a){return this.imul(a,a.clone())},N.prototype.sqr=function(a){return this.mul(a,a)},N.prototype.sqrt=function(a){if(a.isZero())return a.clone();var c=this.m.andln(3);if(i(c%2===1),c===3){var b=this.m.add(new s(1)).iushrn(2);return this.pow(a,b)}for(var A=this.m.subn(1),E=0;!A.isZero()&&A.andln(1)===0;)E++,A.iushrn(1);i(!A.isZero());var x=new s(1).toRed(this),d=x.redNeg(),w=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new s(2*v*v).toRed(this);this.pow(v,w).cmp(d)!==0;)v.redIAdd(d);for(var O=this.pow(v,A),W=this.pow(a,A.addn(1).iushrn(1)),S=this.pow(a,A),H=E;S.cmp(x)!==0;){for(var T=S,q=0;T.cmp(x)!==0;q++)T=T.redSqr();i(q<H);var B=this.pow(O,new s(1).iushln(H-q-1));W=W.redMul(B),O=B.redSqr(),S=S.redMul(O),H=q}return W},N.prototype.invm=function(a){var c=a._invmp(this.m);return c.negative!==0?(c.negative=0,this.imod(c).redNeg()):this.imod(c)},N.prototype.pow=function(a,c){if(c.isZero())return new s(1).toRed(this);if(c.cmpn(1)===0)return a.clone();var b=4,A=new Array(1<<b);A[0]=new s(1).toRed(this),A[1]=a;for(var E=2;E<A.length;E++)A[E]=this.mul(A[E-1],a);var x=A[0],d=0,w=0,v=c.bitLength()%26;for(v===0&&(v=26),E=c.length-1;E>=0;E--){for(var O=c.words[E],W=v-1;W>=0;W--){var S=O>>W&1;if(x!==A[0]&&(x=this.sqr(x)),S===0&&d===0){w=0;continue}d<<=1,d|=S,w++,!(w!==b&&(E!==0||W!==0))&&(x=this.mul(x,A[d]),w=0,d=0)}v=26}return x},N.prototype.convertTo=function(a){var c=a.umod(this.m);return c===a?c.clone():c},N.prototype.convertFrom=function(a){var c=a.clone();return c.red=null,c},s.mont=function(a){return new p(a)};function p(l){N.call(this,l),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)}n(p,N),p.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},p.prototype.convertFrom=function(a){var c=this.imod(a.mul(this.rinv));return c.red=null,c},p.prototype.imul=function(a,c){if(a.isZero()||c.isZero())return a.words[0]=0,a.length=1,a;var b=a.imul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.mul=function(a,c){if(a.isZero()||c.isZero())return new s(0)._forceRed(this);var b=a.mul(c),A=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(A).iushrn(this.shift),x=E;return E.cmp(this.m)>=0?x=E.isub(this.m):E.cmpn(0)<0&&(x=E.iadd(this.m)),x._forceRed(this)},p.prototype.invm=function(a){var c=this.imod(a._invmp(this.m).mul(this.r2));return c._forceRed(this)}})(r,Pt)})(hh);var je=hh.exports;const uh="bignumber/5.7.0";var Ws=je.BN;const ti=new Ve(uh),yo={},dh=9007199254740991;function Db(r){return r!=null&&(ot.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||fr(r)||typeof r=="bigint"||mn(r))}let lh=!1;class ot{constructor(e,t){e!==yo&&ti.throwError("cannot call constructor directly; use BigNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return Zt(Xe(this).fromTwos(e))}toTwos(e){return Zt(Xe(this).toTwos(e))}abs(){return this._hex[0]==="-"?ot.from(this._hex.substring(1)):this}add(e){return Zt(Xe(this).add(Xe(e)))}sub(e){return Zt(Xe(this).sub(Xe(e)))}div(e){return ot.from(e).isZero()&&pr("division-by-zero","div"),Zt(Xe(this).div(Xe(e)))}mul(e){return Zt(Xe(this).mul(Xe(e)))}mod(e){const t=Xe(e);return t.isNeg()&&pr("division-by-zero","mod"),Zt(Xe(this).umod(t))}pow(e){const t=Xe(e);return t.isNeg()&&pr("negative-power","pow"),Zt(Xe(this).pow(t))}and(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","and"),Zt(Xe(this).and(t))}or(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","or"),Zt(Xe(this).or(t))}xor(e){const t=Xe(e);return(this.isNegative()||t.isNeg())&&pr("unbound-bitwise-result","xor"),Zt(Xe(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&pr("negative-width","mask"),Zt(Xe(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&pr("negative-width","shl"),Zt(Xe(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&pr("negative-width","shr"),Zt(Xe(this).shrn(e))}eq(e){return Xe(this).eq(Xe(e))}lt(e){return Xe(this).lt(Xe(e))}lte(e){return Xe(this).lte(Xe(e))}gt(e){return Xe(this).gt(Xe(e))}gte(e){return Xe(this).gte(Xe(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Xe(this).isZero()}toNumber(){try{return Xe(this).toNumber()}catch{pr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return ti.throwError("this platform does not support BigInt",Ve.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?lh||(lh=!0,ti.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?ti.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ve.errors.UNEXPECTED_ARGUMENT,{}):ti.throwError("BigNumber.toString does not accept parameters",Ve.errors.UNEXPECTED_ARGUMENT,{})),Xe(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof ot)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new ot(yo,Gn(e)):e.match(/^-?[0-9]+$/)?new ot(yo,Gn(new Ws(e))):ti.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&pr("underflow","BigNumber.from",e),(e>=dh||e<=-dh)&&pr("overflow","BigNumber.from",e),ot.from(String(e));const t=e;if(typeof t=="bigint")return ot.from(t.toString());if(mn(t))return ot.from(Gt(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return ot.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(fr(i)||i[0]==="-"&&fr(i.substring(1))))return ot.from(i)}return ti.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function Gn(r){if(typeof r!="string")return Gn(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&ti.throwArgumentError("invalid hex","value",r),r=Gn(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function Zt(r){return ot.from(Gn(r))}function Xe(r){const e=ot.from(r).toHexString();return e[0]==="-"?new Ws("-"+e.substring(3),16):new Ws(e.substring(2),16)}function pr(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),ti.throwError(r,Ve.errors.NUMERIC_FAULT,i)}function Ob(r){return new Ws(r,36).toString(16)}const Wt=new Ve(uh),Wn={},ph=ot.from(0),gh=ot.from(-1);function bh(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Wt.throwError(r,Ve.errors.NUMERIC_FAULT,n)}let Jn="0";for(;Jn.length<256;)Jn+=Jn;function wo(r){if(typeof r!="number")try{r=ot.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+Jn.substring(0,r):Wt.throwArgumentError("invalid decimal size","decimals",r)}function _o(r,e){e==null&&(e=0);const t=wo(e);r=ot.from(r);const i=r.lt(ph);i&&(r=r.mul(gh));let n=r.mod(t).toString();for(;n.length<t.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=r.div(t).toString();return t.length===1?r=s:r=s+"."+n,i&&(r="-"+r),r}function ri(r,e){e==null&&(e=0);const t=wo(e);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Wt.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Wt.throwArgumentError("missing value","value",r);const n=r.split(".");n.length>2&&Wt.throwArgumentError("too many decimal points","value",r);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>t.length-1&&bh("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<t.length-1;)o+="0";const f=ot.from(s),u=ot.from(o);let h=f.mul(t).add(u);return i&&(h=h.mul(gh)),h}class yn{constructor(e,t,i,n){e!==Wn&&Wt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=i,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=wo(n),Object.freeze(this)}static from(e){if(e instanceof yn)return e;typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Wt.throwArgumentError("invalid fixed format","format",e),t=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,f,u)=>e[o]==null?u:(typeof e[o]!==f&&Wt.throwArgumentError("invalid fixed format ("+o+" not "+f+")","format."+o,e[o]),e[o]);t=s("signed","boolean",t),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Wt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Wt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new yn(Wn,t,i,n)}}class Tt{constructor(e,t,i,n){e!==Wn&&Wt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Wt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=ri(this._value,this.format.decimals),i=ri(e._value,e.format.decimals);return Tt.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=ri(this._value,this.format.decimals),i=ri(e._value,e.format.decimals);return Tt.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=ri(this._value,this.format.decimals),i=ri(e._value,e.format.decimals);return Tt.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=ri(this._value,this.format.decimals),i=ri(e._value,e.format.decimals);return Tt.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(vh.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(vh.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Wt.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Tt.from("1"+Jn.substring(0,e),this.format),n=Rb.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Wt.throwArgumentError("invalid byte width","width",e);const t=ot.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return qr(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Tt.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!Db(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Tt.fromString(_o(e,t),yn.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=yn.from(t),n=ri(e,i.decimals);!i.signed&&n.lt(ph)&&bh("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=qr(s,i.width/8));const o=_o(n,i.decimals);return new Tt(Wn,s,o,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=yn.from(t);if(lt(e).length>i.width/8)throw new Error("overflow");let n=ot.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=_o(n,i.decimals);return new Tt(Wn,s,o,i)}static from(e,t){if(typeof e=="string")return Tt.fromString(e,t);if(mn(e))return Tt.fromBytes(e,t);try{return Tt.fromValue(e,0,t)}catch(i){if(i.code!==Ve.errors.INVALID_ARGUMENT)throw i}return Wt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const vh=Tt.from(1),Rb=Tt.from("0.5"),Nb="strings/5.7.0",mh=new Ve(Nb);var Js;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Js||(Js={}));var wn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(wn||(wn={}));function Pb(r,e,t,i,n){return mh.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function yh(r,e,t,i,n){if(r===wn.BAD_PREFIX||r===wn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)s++;return s}return r===wn.OVERRUN?t.length-e-1:0}function Cb(r,e,t,i,n){return r===wn.OVERLONG?(i.push(n),0):(i.push(65533),yh(r,e,t))}Object.freeze({error:Pb,ignore:yh,replace:Cb});function xo(r,e=Js.current){e!=Js.current&&(mh.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);if(n<128)t.push(n);else if(n<2048)t.push(n>>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return lt(t)}function Tb(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t<r.length;t+=4)e.push(parseInt(r.substring(t,t+4),16));return e}function Ao(r,e){e||(e=function(n){return[parseInt(n,16)]});let t=0,i={};return r.split(",").forEach(n=>{let s=n.split(":");t+=parseInt(s[0],16),i[t]=e(s[1])}),i}function wh(r){let e=0;return r.split(",").map(t=>{let i=t.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}wh("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(r=>parseInt(r,16)),Ao("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Ao("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Ao("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",Tb),wh("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const _h="hash/5.7.0";function Fb(r){r=atob(r);const e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return lt(e)}function xh(r,e){e==null&&(e=1);const t=[],i=t.forEach,n=function(s,o){i.call(s,function(f){o>0&&Array.isArray(f)?n(f,o-1):t.push(f)})};return n(r,e),t}function Bb(r){const e={};for(let t=0;t<r.length;t++){const i=r[t];e[i[0]]=i[1]}return e}function Lb(r){let e=0;function t(){return r[e++]<<8|r[e++]}let i=t(),n=1,s=[0,1];for(let U=1;U<i;U++)s.push(n+=t());let o=t(),f=e;e+=o;let u=0,h=0;function g(){return u==0&&(h=h<<8|r[e++],u=8),h>>--u&1}const y=31,I=Math.pow(2,y),M=I>>>1,D=M>>1,P=I-1;let k=0;for(let U=0;U<y;U++)k=k<<1|g();let K=[],C=0,j=I;for(;;){let U=Math.floor(((k-C+1)*n-1)/j),z=0,_=i;for(;_-z>1;){let Q=z+_>>>1;U<s[Q]?_=Q:z=Q}if(z==0)break;K.push(z);let R=C+Math.floor(j*s[z]/n),J=C+Math.floor(j*s[z+1]/n)-1;for(;!((R^J)&M);)k=k<<1&P|g(),R=R<<1&P,J=J<<1&P|1;for(;R&~J&D;)k=k&M|k<<1&P>>>1|g(),R=R<<1^M,J=(J^M)<<1|M|1;C=R,j=1+J-R}let F=i-4;return K.map(U=>{switch(U-F){case 3:return F+65792+(r[f++]<<16|r[f++]<<8|r[f++]);case 2:return F+256+(r[f++]<<8|r[f++]);case 1:return F+r[f++];default:return U-1}})}function qb(r){let e=0;return()=>r[e++]}function Ub(r){return qb(Lb(r))}function $b(r){return r&1?~r>>1:r>>1}function zb(r,e){let t=Array(r);for(let i=0;i<r;i++)t[i]=1+e();return t}function Ah(r,e){let t=Array(r);for(let i=0,n=-1;i<r;i++)t[i]=n+=1+e();return t}function kb(r,e){let t=Array(r);for(let i=0,n=0;i<r;i++)t[i]=n+=$b(e());return t}function Ys(r,e){let t=Ah(r(),r),i=r(),n=Ah(i,r),s=zb(i,r);for(let o=0;o<i;o++)for(let f=0;f<s[o];f++)t.push(n[o]+f);return e?t.map(o=>e[o]):t}function Kb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(Hb(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(Vb(t,r))}return Bb(xh(e))}function jb(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function Eh(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)kb(r,t).forEach((s,o)=>i[o].push(s));return i}function Hb(r,e){let t=1+e(),i=e(),n=jb(e),s=Eh(n.length,1+r,e);return xh(s.map((o,f)=>{const u=o[0],h=o.slice(1);return Array(n[f]).fill(void 0).map((g,y)=>{let I=y*i;return[u+y*t,h.map(M=>M+I)]})}))}function Vb(r,e){let t=1+e();return Eh(t,1+r,e).map(n=>[n[0],n.slice(1)])}function Gb(r){let e=Ys(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let h=Ys(r,e);if(h.length==0)break;i.push({set:new Set(h),node:t()})}i.sort((h,g)=>g.set.size-h.set.size);let n=r(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let f=n==1,u=n==2;return{branches:i,valid:s,fe0f:o,save:f,check:u}}}function Wb(){return Ub(Fb("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const Qs=Wb();new Set(Ys(Qs)),new Set(Ys(Qs)),Kb(Qs),Gb(Qs),new Ve(_h),new Uint8Array(32).fill(0);const Jb=`Ethereum Signed Message:
|
22
|
+
`;function Sh(r){return typeof r=="string"&&(r=xo(r)),mo(Sb([xo(Jb),xo(String(r.length)),r]))}const Yb="rlp/5.7.0";new Ve(Yb);const Qb="address/5.7.0",Yn=new Ve(Qb);function Mh(r){fr(r,20)||Yn.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=lt(mo(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const Xb=9007199254740991;function Zb(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const Eo={};for(let r=0;r<10;r++)Eo[String(r)]=String(r);for(let r=0;r<26;r++)Eo[String.fromCharCode(65+r)]=String(10+r);const Ih=Math.floor(Zb(Xb));function ev(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Eo[i]).join("");for(;e.length>=Ih;){let i=e.substring(0,Ih);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function tv(r){let e=null;if(typeof r!="string"&&Yn.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Mh(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Yn.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==ev(r)&&Yn.throwArgumentError("bad icap checksum","address",r),e=Ob(r.substring(4));e.length<40;)e="0"+e;e=Mh("0x"+e)}else Yn.throwArgumentError("invalid address","address",r);return e}const rv="properties/5.7.0";new Ve(rv);function Qn(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}new Ve(_h),new Uint8Array(32).fill(0),ot.from(-1);const iv=ot.from(0),nv=ot.from(1);ot.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),qr(nv.toHexString(),32),qr(iv.toHexString(),32);var cr={},Ze={},ji=Dh;function Dh(r,e){if(!r)throw new Error(e||"Assertion failed")}Dh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var _n={exports:{}};typeof Object.create=="function"?_n.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:_n.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}};var sv=ji,av=_n.exports;Ze.inherits=av;function ov(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function fv(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n<r.length;n+=2)t.push(parseInt(r[n]+r[n+1],16))}else for(var i=0,n=0;n<r.length;n++){var s=r.charCodeAt(n);s<128?t[i++]=s:s<2048?(t[i++]=s>>6|192,t[i++]=s&63|128):ov(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n<r.length;n++)t[n]=r[n]|0;return t}Ze.toArray=fv;function cv(r){for(var e="",t=0;t<r.length;t++)e+=Rh(r[t].toString(16));return e}Ze.toHex=cv;function Oh(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ze.htonl=Oh;function hv(r,e){for(var t="",i=0;i<r.length;i++){var n=r[i];e==="little"&&(n=Oh(n)),t+=Nh(n.toString(16))}return t}Ze.toHex32=hv;function Rh(r){return r.length===1?"0"+r:r}Ze.zero2=Rh;function Nh(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Ze.zero8=Nh;function uv(r,e,t,i){var n=t-e;sv(n%4===0);for(var s=new Array(n/4),o=0,f=e;o<s.length;o++,f+=4){var u;i==="big"?u=r[f]<<24|r[f+1]<<16|r[f+2]<<8|r[f+3]:u=r[f+3]<<24|r[f+2]<<16|r[f+1]<<8|r[f],s[o]=u>>>0}return s}Ze.join32=uv;function dv(r,e){for(var t=new Array(r.length*4),i=0,n=0;i<r.length;i++,n+=4){var s=r[i];e==="big"?(t[n]=s>>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ze.split32=dv;function lv(r,e){return r>>>e|r<<32-e}Ze.rotr32=lv;function pv(r,e){return r<<e|r>>>32-e}Ze.rotl32=pv;function gv(r,e){return r+e>>>0}Ze.sum32=gv;function bv(r,e,t){return r+e+t>>>0}Ze.sum32_3=bv;function vv(r,e,t,i){return r+e+t+i>>>0}Ze.sum32_4=vv;function mv(r,e,t,i,n){return r+e+t+i+n>>>0}Ze.sum32_5=mv;function yv(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o<i?1:0)+t+n;r[e]=f>>>0,r[e+1]=o}Ze.sum64=yv;function wv(r,e,t,i){var n=e+i>>>0,s=(n<e?1:0)+r+t;return s>>>0}Ze.sum64_hi=wv;function _v(r,e,t,i){var n=e+i;return n>>>0}Ze.sum64_lo=_v;function xv(r,e,t,i,n,s,o,f){var u=0,h=e;h=h+i>>>0,u+=h<e?1:0,h=h+s>>>0,u+=h<s?1:0,h=h+f>>>0,u+=h<f?1:0;var g=r+t+n+o+u;return g>>>0}Ze.sum64_4_hi=xv;function Av(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ze.sum64_4_lo=Av;function Ev(r,e,t,i,n,s,o,f,u,h){var g=0,y=e;y=y+i>>>0,g+=y<e?1:0,y=y+s>>>0,g+=y<s?1:0,y=y+f>>>0,g+=y<f?1:0,y=y+h>>>0,g+=y<h?1:0;var I=r+t+n+o+u+g;return I>>>0}Ze.sum64_5_hi=Ev;function Sv(r,e,t,i,n,s,o,f,u,h){var g=e+i+s+f+h;return g>>>0}Ze.sum64_5_lo=Sv;function Mv(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ze.rotr64_hi=Mv;function Iv(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.rotr64_lo=Iv;function Dv(r,e,t){return r>>>t}Ze.shr64_hi=Dv;function Ov(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ze.shr64_lo=Ov;var xn={},Ph=Ze,Rv=ji;function Xs(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}xn.BlockHash=Xs,Xs.prototype.update=function(e,t){if(e=Ph.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Ph.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},Xs.prototype.digest=function(e){return this.update(this._pad()),Rv(this.pending===null),this._digest(e)},Xs.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var An={},Ur={},Nv=Ze,$r=Nv.rotr32;function Pv(r,e,t,i){if(r===0)return Ch(e,t,i);if(r===1||r===3)return Fh(e,t,i);if(r===2)return Th(e,t,i)}Ur.ft_1=Pv;function Ch(r,e,t){return r&e^~r&t}Ur.ch32=Ch;function Th(r,e,t){return r&e^r&t^e&t}Ur.maj32=Th;function Fh(r,e,t){return r^e^t}Ur.p32=Fh;function Cv(r){return $r(r,2)^$r(r,13)^$r(r,22)}Ur.s0_256=Cv;function Tv(r){return $r(r,6)^$r(r,11)^$r(r,25)}Ur.s1_256=Tv;function Fv(r){return $r(r,7)^$r(r,18)^r>>>3}Ur.g0_256=Fv;function Bv(r){return $r(r,17)^$r(r,19)^r>>>10}Ur.g1_256=Bv;var En=Ze,Lv=xn,qv=Ur,So=En.rotl32,Xn=En.sum32,Uv=En.sum32_5,$v=qv.ft_1,Bh=Lv.BlockHash,zv=[1518500249,1859775393,2400959708,3395469782];function zr(){if(!(this instanceof zr))return new zr;Bh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}En.inherits(zr,Bh);var kv=zr;zr.blockSize=512,zr.outSize=160,zr.hmacStrength=80,zr.padLength=64,zr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=So(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4];for(n=0;n<i.length;n++){var g=~~(n/20),y=Uv(So(s,5),$v(g,o,f,u),h,i[n],zv[g]);h=u,u=f,f=So(o,30),o=s,s=y}this.h[0]=Xn(this.h[0],s),this.h[1]=Xn(this.h[1],o),this.h[2]=Xn(this.h[2],f),this.h[3]=Xn(this.h[3],u),this.h[4]=Xn(this.h[4],h)},zr.prototype._digest=function(e){return e==="hex"?En.toHex32(this.h,"big"):En.split32(this.h,"big")};var Sn=Ze,Kv=xn,Mn=Ur,jv=ji,Dr=Sn.sum32,Hv=Sn.sum32_4,Vv=Sn.sum32_5,Gv=Mn.ch32,Wv=Mn.maj32,Jv=Mn.s0_256,Yv=Mn.s1_256,Qv=Mn.g0_256,Xv=Mn.g1_256,Lh=Kv.BlockHash,Zv=[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];function kr(){if(!(this instanceof kr))return new kr;Lh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Zv,this.W=new Array(64)}Sn.inherits(kr,Lh);var qh=kr;kr.blockSize=512,kr.outSize=256,kr.hmacStrength=192,kr.padLength=64,kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=Hv(Xv(i[n-2]),i[n-7],Qv(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],f=this.h[2],u=this.h[3],h=this.h[4],g=this.h[5],y=this.h[6],I=this.h[7];for(jv(this.k.length===i.length),n=0;n<i.length;n++){var M=Vv(I,Yv(h),Gv(h,g,y),this.k[n],i[n]),D=Dr(Jv(s),Wv(s,o,f));I=y,y=g,g=h,h=Dr(u,M),u=f,f=o,o=s,s=Dr(M,D)}this.h[0]=Dr(this.h[0],s),this.h[1]=Dr(this.h[1],o),this.h[2]=Dr(this.h[2],f),this.h[3]=Dr(this.h[3],u),this.h[4]=Dr(this.h[4],h),this.h[5]=Dr(this.h[5],g),this.h[6]=Dr(this.h[6],y),this.h[7]=Dr(this.h[7],I)},kr.prototype._digest=function(e){return e==="hex"?Sn.toHex32(this.h,"big"):Sn.split32(this.h,"big")};var Mo=Ze,Uh=qh;function ii(){if(!(this instanceof ii))return new ii;Uh.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Mo.inherits(ii,Uh);var e2=ii;ii.blockSize=512,ii.outSize=224,ii.hmacStrength=192,ii.padLength=64,ii.prototype._digest=function(e){return e==="hex"?Mo.toHex32(this.h.slice(0,7),"big"):Mo.split32(this.h.slice(0,7),"big")};var er=Ze,t2=xn,r2=ji,Kr=er.rotr64_hi,jr=er.rotr64_lo,$h=er.shr64_hi,zh=er.shr64_lo,Ei=er.sum64,Io=er.sum64_hi,Do=er.sum64_lo,i2=er.sum64_4_hi,n2=er.sum64_4_lo,s2=er.sum64_5_hi,a2=er.sum64_5_lo,kh=t2.BlockHash,o2=[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 Or(){if(!(this instanceof Or))return new Or;kh.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=o2,this.W=new Array(160)}er.inherits(Or,kh);var Kh=Or;Or.blockSize=1024,Or.outSize=512,Or.hmacStrength=192,Or.padLength=128,Or.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n<i.length;n+=2){var s=m2(i[n-4],i[n-3]),o=y2(i[n-4],i[n-3]),f=i[n-14],u=i[n-13],h=b2(i[n-30],i[n-29]),g=v2(i[n-30],i[n-29]),y=i[n-32],I=i[n-31];i[n]=i2(s,o,f,u,h,g,y,I),i[n+1]=n2(s,o,f,u,h,g,y,I)}},Or.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],f=this.h[3],u=this.h[4],h=this.h[5],g=this.h[6],y=this.h[7],I=this.h[8],M=this.h[9],D=this.h[10],P=this.h[11],k=this.h[12],K=this.h[13],C=this.h[14],j=this.h[15];r2(this.k.length===i.length);for(var F=0;F<i.length;F+=2){var U=C,z=j,_=p2(I,M),R=g2(I,M),J=f2(I,M,D,P,k),Q=c2(I,M,D,P,k,K),N=this.k[F],p=this.k[F+1],l=i[F],a=i[F+1],c=s2(U,z,_,R,J,Q,N,p,l,a),b=a2(U,z,_,R,J,Q,N,p,l,a);U=d2(n,s),z=l2(n,s),_=h2(n,s,o,f,u),R=u2(n,s,o,f,u,h);var A=Io(U,z,_,R),E=Do(U,z,_,R);C=k,j=K,k=D,K=P,D=I,P=M,I=Io(g,y,c,b),M=Do(y,y,c,b),g=u,y=h,u=o,h=f,o=n,f=s,n=Io(c,b,A,E),s=Do(c,b,A,E)}Ei(this.h,0,n,s),Ei(this.h,2,o,f),Ei(this.h,4,u,h),Ei(this.h,6,g,y),Ei(this.h,8,I,M),Ei(this.h,10,D,P),Ei(this.h,12,k,K),Ei(this.h,14,C,j)},Or.prototype._digest=function(e){return e==="hex"?er.toHex32(this.h,"big"):er.split32(this.h,"big")};function f2(r,e,t,i,n){var s=r&t^~r&n;return s<0&&(s+=4294967296),s}function c2(r,e,t,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function h2(r,e,t,i,n){var s=r&t^r&n^t&n;return s<0&&(s+=4294967296),s}function u2(r,e,t,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function d2(r,e){var t=Kr(r,e,28),i=Kr(e,r,2),n=Kr(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function l2(r,e){var t=jr(r,e,28),i=jr(e,r,2),n=jr(e,r,7),s=t^i^n;return s<0&&(s+=4294967296),s}function p2(r,e){var t=Kr(r,e,14),i=Kr(r,e,18),n=Kr(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function g2(r,e){var t=jr(r,e,14),i=jr(r,e,18),n=jr(e,r,9),s=t^i^n;return s<0&&(s+=4294967296),s}function b2(r,e){var t=Kr(r,e,1),i=Kr(r,e,8),n=$h(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function v2(r,e){var t=jr(r,e,1),i=jr(r,e,8),n=zh(r,e,7),s=t^i^n;return s<0&&(s+=4294967296),s}function m2(r,e){var t=Kr(r,e,19),i=Kr(e,r,29),n=$h(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}function y2(r,e){var t=jr(r,e,19),i=jr(e,r,29),n=zh(r,e,6),s=t^i^n;return s<0&&(s+=4294967296),s}var Oo=Ze,jh=Kh;function ni(){if(!(this instanceof ni))return new ni;jh.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Oo.inherits(ni,jh);var w2=ni;ni.blockSize=1024,ni.outSize=384,ni.hmacStrength=192,ni.padLength=128,ni.prototype._digest=function(e){return e==="hex"?Oo.toHex32(this.h.slice(0,12),"big"):Oo.split32(this.h.slice(0,12),"big")},An.sha1=kv,An.sha224=e2,An.sha256=qh,An.sha384=w2,An.sha512=Kh;var Hh={},Hi=Ze,_2=xn,Zs=Hi.rotl32,Vh=Hi.sum32,Zn=Hi.sum32_3,Gh=Hi.sum32_4,Wh=_2.BlockHash;function Hr(){if(!(this instanceof Hr))return new Hr;Wh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Hi.inherits(Hr,Wh),Hh.ripemd160=Hr,Hr.blockSize=512,Hr.outSize=160,Hr.hmacStrength=192,Hr.padLength=64,Hr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,h=n,g=s,y=o,I=f,M=0;M<80;M++){var D=Vh(Zs(Gh(i,Jh(M,n,s,o),e[E2[M]+t],x2(M)),M2[M]),f);i=f,f=o,o=Zs(s,10),s=n,n=D,D=Vh(Zs(Gh(u,Jh(79-M,h,g,y),e[S2[M]+t],A2(M)),I2[M]),I),u=I,I=y,y=Zs(g,10),g=h,h=D}D=Zn(this.h[1],s,y),this.h[1]=Zn(this.h[2],o,I),this.h[2]=Zn(this.h[3],f,u),this.h[3]=Zn(this.h[4],i,h),this.h[4]=Zn(this.h[0],n,g),this.h[0]=D},Hr.prototype._digest=function(e){return e==="hex"?Hi.toHex32(this.h,"little"):Hi.split32(this.h,"little")};function Jh(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function x2(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function A2(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var E2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],S2=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],M2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],I2=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],D2=Ze,O2=ji;function In(r,e,t){if(!(this instanceof In))return new In(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(D2.toArray(e,t))}var R2=In;In.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),O2(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=new this.Hash().update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=new this.Hash().update(e)},In.prototype.update=function(e,t){return this.inner.update(e,t),this},In.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(r){var e=r;e.utils=Ze,e.common=xn,e.sha=An,e.ripemd=Hh,e.hmac=R2,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(cr);function Dn(r,e,t){return t={path:e,exports:{},require:function(i,n){return N2(i,n??t.path)}},r(t,t.exports),t.exports}function N2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ro=Yh;function Yh(r,e){if(!r)throw new Error(e||"Assertion failed")}Yh.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Rr=Dn(function(r,e){var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var h=0;h<o.length;h++)u[h]=o[h]|0;return u}if(f==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var h=0;h<o.length;h+=2)u.push(parseInt(o[h]+o[h+1],16))}else for(var h=0;h<o.length;h++){var g=o.charCodeAt(h),y=g>>8,I=g&255;y?u.push(y,I):u.push(I)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u<o.length;u++)f+=n(o[u].toString(16));return f}t.toHex=s,t.encode=function(f,u){return u==="hex"?s(f):f}}),hr=Dn(function(r,e){var t=e;t.assert=Ro,t.toArray=Rr.toArray,t.zero2=Rr.zero2,t.toHex=Rr.toHex,t.encode=Rr.encode;function i(u,h,g){var y=new Array(Math.max(u.bitLength(),g)+1);y.fill(0);for(var I=1<<h+1,M=u.clone(),D=0;D<y.length;D++){var P,k=M.andln(I-1);M.isOdd()?(k>(I>>1)-1?P=(I>>1)-k:P=k,M.isubn(P)):P=0,y[D]=P,M.iushrn(1)}return y}t.getNAF=i;function n(u,h){var g=[[],[]];u=u.clone(),h=h.clone();for(var y=0,I=0,M;u.cmpn(-y)>0||h.cmpn(-I)>0;){var D=u.andln(3)+y&3,P=h.andln(3)+I&3;D===3&&(D=-1),P===3&&(P=-1);var k;D&1?(M=u.andln(7)+y&7,(M===3||M===5)&&P===2?k=-D:k=D):k=0,g[0].push(k);var K;P&1?(M=h.andln(7)+I&7,(M===3||M===5)&&D===2?K=-P:K=P):K=0,g[1].push(K),2*y===k+1&&(y=1-y),2*I===K+1&&(I=1-I),u.iushrn(1),h.iushrn(1)}return g}t.getJSF=n;function s(u,h,g){var y="_"+h;u.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new je(u,"hex","le")}t.intFromLE=f}),ea=hr.getNAF,P2=hr.getJSF,ta=hr.assert;function Si(r,e){this.type=r,this.p=new je(e.p,16),this.red=e.prime?je.red(e.prime):je.mont(this.p),this.zero=new je(0).toRed(this.red),this.one=new je(1).toRed(this.red),this.two=new je(2).toRed(this.red),this.n=e.n&&new je(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Vi=Si;Si.prototype.point=function(){throw new Error("Not implemented")},Si.prototype.validate=function(){throw new Error("Not implemented")},Si.prototype._fixedNafMul=function(e,t){ta(e.precomputed);var i=e._getDoubles(),n=ea(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?y=y.mixedAdd(i.points[f]):u===-I&&(y=y.mixedAdd(i.points[f].neg()));g=g.add(y)}return g.toP()},Si.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=ea(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];ta(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Si.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,y,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,P=g;if(o[D]!==1||o[P]!==1){u[D]=ea(i[D],o[D],this._bitLength),u[P]=ea(i[P],o[P],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[P].length,h);continue}var k=[t[D],null,null,t[P]];t[D].y.cmp(t[P].y)===0?(k[1]=t[D].add(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg())):t[D].y.cmp(t[P].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].add(t[P].neg())):(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],C=P2(i[D],i[P]);for(h=Math.max(C[0].length,h),u[D]=new Array(h),u[P]=new Array(h),y=0;y<h;y++){var j=C[0][y]|0,F=C[1][y]|0;u[D][y]=K[(j+1)*3+(F+1)],u[P][y]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var R=!0;for(y=0;y<n;y++)z[y]=u[y][g]|0,z[y]!==0&&(R=!1);if(!R)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(y=0;y<n;y++){var J=z[y];J!==0&&(J>0?I=f[y][J-1>>1]:J<0&&(I=f[y][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function gr(r,e){this.curve=r,this.type=e,this.precomputed=null}Si.BasePoint=gr,gr.prototype.eq=function(){throw new Error("Not implemented")},gr.prototype.validate=function(){return this.curve.validate(this)},Si.prototype.decodePoint=function(e,t){e=hr.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?ta(e[e.length-1]%2===0):e[0]===7&&ta(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},gr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},gr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},gr.prototype.encode=function(e,t){return hr.encode(this._encode(t),e)},gr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},gr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},gr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},gr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},gr.prototype._getBeta=function(){return null},gr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var No=Dn(function(r){typeof Object.create=="function"?r.exports=function(t,i){i&&(t.super_=i,t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,i){if(i){t.super_=i;var n=function(){};n.prototype=i.prototype,t.prototype=new n,t.prototype.constructor=t}}}),C2=hr.assert;function br(r){Vi.call(this,"short",r),this.a=new je(r.a,16).toRed(this.red),this.b=new je(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}No(br,Vi);var T2=br;br.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new je(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new je(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],C2(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new je(f.a,16),b:new je(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},br.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:je.mont(e),i=new je(2).toRed(t).redInvm(),n=i.redNeg(),s=new je(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},br.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new je(1),o=new je(0),f=new je(0),u=new je(1),h,g,y,I,M,D,P,k=0,K,C;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),C=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!y&&K.cmp(t)<0)h=P.neg(),g=s,y=K.neg(),I=C;else if(y&&++k===2)break;P=K,n=i,i=K,f=s,s=C,u=o,o=F}M=K.neg(),D=C;var U=y.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),y.negative&&(y=y.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:y,b:I},{a:M,b:D}]},br.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),y=e.sub(f).sub(u),I=h.add(g).neg();return{k1:y,k2:I}},br.prototype.pointFromX=function(e,t){e=new je(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},br.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},br.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return g};function St(r,e,t,i){Vi.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new je(e,16),this.y=new je(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}No(St,Vi.BasePoint),br.prototype.point=function(e,t,i){return new St(this,e,t,i)},br.prototype.pointFromJSON=function(e,t){return St.fromJSON(this,e,t)},St.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},St.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},St.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},St.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},St.prototype.isInfinity=function(){return this.inf},St.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},St.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},St.prototype.getX=function(){return this.x.fromRed()},St.prototype.getY=function(){return this.y.fromRed()},St.prototype.mul=function(e){return e=new je(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},St.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},St.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},St.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},St.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t},St.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Ft(r,e,t,i){Vi.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new je(0)):(this.x=new je(e,16),this.y=new je(t,16),this.z=new je(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}No(Ft,Vi.BasePoint),br.prototype.jpoint=function(e,t,i){return new Ft(this,e,t,i)},Ft.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Ft.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ft.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),y=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(y).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,P)},Ft.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),y=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(y).redISub(y),M=u.redMul(y.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Ft.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var y=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),P=o.redMul(I),k=D.redSqr().redISub(P.redAdd(P)),K=P.redISub(k),C=D.redMul(K);C=C.redIAdd(C).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=C}return this.curve.jpoint(o,g.redMul(s),u)},Ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ft.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(y).redISub(M);D=D.redIAdd(D);var P=y.redAdd(y).redIAdd(y),k=P.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=P.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Ft.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(y).redMul(this.x.redAdd(y));D=D.redAdd(D).redIAdd(D);var P=M.redIAdd(M);P=P.redIAdd(P);var k=P.redAdd(P);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(y);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(P.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Ft.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),y=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(y),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),P=i.redAdd(i).redMul(n);return this.curve.jpoint(y,D,P)},Ft.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),y=t.redMul(g);y=y.redIAdd(y),y=y.redIAdd(y);var I=this.x.redMul(u).redISub(y);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Ft.prototype.mul=function(e,t){return e=new je(e,t),this.curve._wnafMul(this,e)},Ft.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Ft.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Ft.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Ft.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ra=Dn(function(r,e){var t=e;t.base=Vi,t.short=T2,t.mont=null,t.edwards=null}),ia=Dn(function(r,e){var t=e,i=hr.assert;function n(f){f.type==="short"?this.curve=new ra.short(f):f.type==="edwards"?this.curve=new ra.edwards(f):this.curve=new ra.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var h=new n(u);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:cr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:cr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:cr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:cr.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:cr.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:cr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:cr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:cr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Mi(r){if(!(this instanceof Mi))return new Mi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Rr.toArray(r.entropy,r.entropyEnc||"hex"),t=Rr.toArray(r.nonce,r.nonceEnc||"hex"),i=Rr.toArray(r.pers,r.persEnc||"hex");Ro(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var Qh=Mi;Mi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Mi.prototype._hmac=function(){return new cr.hmac(this.hash,this.K)},Mi.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Mi.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Rr.toArray(e,t),i=Rr.toArray(i,n),Ro(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Mi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Rr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Rr.encode(o,t)};var Po=hr.assert;function $t(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Co=$t;$t.fromPublic=function(e,t,i){return t instanceof $t?t:new $t(e,{pub:t,pubEnc:i})},$t.fromPrivate=function(e,t,i){return t instanceof $t?t:new $t(e,{priv:t,privEnc:i})},$t.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},$t.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},$t.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},$t.prototype._importPrivate=function(e,t){this.priv=new je(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},$t.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Po(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Po(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},$t.prototype.derive=function(e){return e.validate()||Po(e.validate(),"public point not validated"),e.mul(this.priv).getX()},$t.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},$t.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},$t.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var F2=hr.assert;function na(r,e){if(r instanceof na)return r;this._importDER(r,e)||(F2(r.r&&r.s,"Signature without r or s"),this.r=new je(r.r,16),this.s=new je(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var sa=na;function B2(){this.place=0}function To(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Xh(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}na.prototype._importDER=function(e,t){e=hr.toArray(e,t);var i=new B2;if(e[i.place++]!==48)return!1;var n=To(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=To(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=To(e,i);if(f===!1||e.length!==f+i.place)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new je(o),this.s=new je(u),this.recoveryParam=null,!0};function Fo(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}na.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Xh(t),i=Xh(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Fo(n,t.length),n=n.concat(t),n.push(2),Fo(n,i.length);var s=n.concat(i),o=[48];return Fo(o,s.length),o=o.concat(s),hr.encode(o,e)};var L2=function(){throw new Error("unsupported")},Zh=hr.assert;function vr(r){if(!(this instanceof vr))return new vr(r);typeof r=="string"&&(Zh(Object.prototype.hasOwnProperty.call(ia,r),"Unknown curve "+r),r=ia[r]),r instanceof ia.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var q2=vr;vr.prototype.keyPair=function(e){return new Co(this,e)},vr.prototype.keyFromPrivate=function(e,t){return Co.fromPrivate(this,e,t)},vr.prototype.keyFromPublic=function(e,t){return Co.fromPublic(this,e,t)},vr.prototype.genKeyPair=function(e){e||(e={});for(var t=new Qh({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||L2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new je(2));;){var s=new je(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},vr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},vr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new je(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new Qh({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new je(1)),g=0;;g++){var y=n.k?n.k(g):new je(u.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var I=this.g.mul(y);if(!I.isInfinity()){var M=I.getX(),D=M.umod(this.n);if(D.cmpn(0)!==0){var P=y.invm(this.n).mul(D.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var k=(I.getY().isOdd()?1:0)|(M.cmp(D)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),k^=1),new sa({r:D,s:P,recoveryParam:k})}}}}}},vr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new je(e,16)),i=this.keyFromPublic(i,n),t=new sa(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(u,i.getPublic(),h),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)},vr.prototype.recoverPubKey=function(r,e,t,i){Zh((3&t)===t,"The recovery param is more than two bits"),e=new sa(e,i);var n=this.n,s=new je(r),o=e.r,f=e.s,u=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(y,o,I)},vr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new sa(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var U2=Dn(function(r,e){var t=e;t.version="6.5.4",t.utils=hr,t.rand=function(){throw new Error("unsupported")},t.curve=ra,t.curves=ia,t.ec=q2,t.eddsa=null}),$2=U2.ec;const z2="signing-key/5.7.0",Bo=new Ve(z2);let Lo=null;function Vr(){return Lo||(Lo=new $2("secp256k1")),Lo}class k2{constructor(e){Qn(this,"curve","secp256k1"),Qn(this,"privateKey",Gt(e)),Ib(this.privateKey)!==32&&Bo.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Vr().keyFromPrivate(lt(this.privateKey));Qn(this,"publicKey","0x"+t.getPublic(!1,"hex")),Qn(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Qn(this,"_isSigningKey",!0)}_addPoint(e){const t=Vr().keyFromPublic(lt(this.publicKey)),i=Vr().keyFromPublic(lt(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Vr().keyFromPrivate(lt(this.privateKey)),i=lt(e);i.length!==32&&Bo.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return ch({recoveryParam:n.recoveryParam,r:qr("0x"+n.r.toString(16),32),s:qr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Vr().keyFromPrivate(lt(this.privateKey)),i=Vr().keyFromPublic(lt(eu(e)));return qr("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function K2(r,e){const t=ch(e),i={r:lt(t.r),s:lt(t.s)};return"0x"+Vr().recoverPubKey(lt(r),i,t.recoveryParam).encode("hex",!1)}function eu(r,e){const t=lt(r);if(t.length===32){const i=new k2(t);return e?"0x"+Vr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Gt(t):"0x"+Vr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Vr().keyFromPublic(t).getPublic(!0,"hex"):Gt(t)}return Bo.throwArgumentError("invalid public or private key","key","[REDACTED]")}const j2="transactions/5.7.0";new Ve(j2);var tu;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(tu||(tu={}));function H2(r){const e=eu(r);return tv(fh(mo(fh(e,1)),12))}function V2(r,e){return H2(K2(lt(r),e))}var qo={},aa={};Object.defineProperty(aa,"__esModule",{value:!0});var zt=He,Uo=or,G2=20;function W2(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],I=t[23]<<24|t[22]<<16|t[21]<<8|t[20],M=t[27]<<24|t[26]<<16|t[25]<<8|t[24],D=t[31]<<24|t[30]<<16|t[29]<<8|t[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],K=e[11]<<24|e[10]<<16|e[9]<<8|e[8],C=e[15]<<24|e[14]<<16|e[13]<<8|e[12],j=i,F=n,U=s,z=o,_=f,R=u,J=h,Q=g,N=y,p=I,l=M,a=D,c=P,b=k,A=K,E=C,x=0;x<G2;x+=2)j=j+_|0,c^=j,c=c>>>32-16|c<<16,N=N+c|0,_^=N,_=_>>>32-12|_<<12,F=F+R|0,b^=F,b=b>>>32-16|b<<16,p=p+b|0,R^=p,R=R>>>32-12|R<<12,U=U+J|0,A^=U,A=A>>>32-16|A<<16,l=l+A|0,J^=l,J=J>>>32-12|J<<12,z=z+Q|0,E^=z,E=E>>>32-16|E<<16,a=a+E|0,Q^=a,Q=Q>>>32-12|Q<<12,U=U+J|0,A^=U,A=A>>>32-8|A<<8,l=l+A|0,J^=l,J=J>>>32-7|J<<7,z=z+Q|0,E^=z,E=E>>>32-8|E<<8,a=a+E|0,Q^=a,Q=Q>>>32-7|Q<<7,F=F+R|0,b^=F,b=b>>>32-8|b<<8,p=p+b|0,R^=p,R=R>>>32-7|R<<7,j=j+_|0,c^=j,c=c>>>32-8|c<<8,N=N+c|0,_^=N,_=_>>>32-7|_<<7,j=j+R|0,E^=j,E=E>>>32-16|E<<16,l=l+E|0,R^=l,R=R>>>32-12|R<<12,F=F+J|0,c^=F,c=c>>>32-16|c<<16,a=a+c|0,J^=a,J=J>>>32-12|J<<12,U=U+Q|0,b^=U,b=b>>>32-16|b<<16,N=N+b|0,Q^=N,Q=Q>>>32-12|Q<<12,z=z+_|0,A^=z,A=A>>>32-16|A<<16,p=p+A|0,_^=p,_=_>>>32-12|_<<12,U=U+Q|0,b^=U,b=b>>>32-8|b<<8,N=N+b|0,Q^=N,Q=Q>>>32-7|Q<<7,z=z+_|0,A^=z,A=A>>>32-8|A<<8,p=p+A|0,_^=p,_=_>>>32-7|_<<7,F=F+J|0,c^=F,c=c>>>32-8|c<<8,a=a+c|0,J^=a,J=J>>>32-7|J<<7,j=j+R|0,E^=j,E=E>>>32-8|E<<8,l=l+E|0,R^=l,R=R>>>32-7|R<<7;zt.writeUint32LE(j+i|0,r,0),zt.writeUint32LE(F+n|0,r,4),zt.writeUint32LE(U+s|0,r,8),zt.writeUint32LE(z+o|0,r,12),zt.writeUint32LE(_+f|0,r,16),zt.writeUint32LE(R+u|0,r,20),zt.writeUint32LE(J+h|0,r,24),zt.writeUint32LE(Q+g|0,r,28),zt.writeUint32LE(N+y|0,r,32),zt.writeUint32LE(p+I|0,r,36),zt.writeUint32LE(l+M|0,r,40),zt.writeUint32LE(a+D|0,r,44),zt.writeUint32LE(c+P|0,r,48),zt.writeUint32LE(b+k|0,r,52),zt.writeUint32LE(A+K|0,r,56),zt.writeUint32LE(E+C|0,r,60)}function ru(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<t.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=n}for(var f=new Uint8Array(64),u=0;u<t.length;u+=64){W2(f,s,r);for(var h=u;h<u+64&&h<t.length;h++)i[h]=t[h]^f[h-u];Y2(s,0,o)}return Uo.wipe(f),n===0&&Uo.wipe(s),i}aa.streamXOR=ru;function J2(r,e,t,i){return i===void 0&&(i=0),Uo.wipe(t),ru(r,e,t,t,i)}aa.stream=J2;function Y2(r,e,t){for(var i=1;t--;)i=i+(r[e]&255)|0,r[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var iu={},Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});function Q2(r,e,t){return~(r-1)&e|r-1&t}Ii.select=Q2;function X2(r,e){return(r|0)-(e|0)-1>>>31&1}Ii.lessOrEqual=X2;function nu(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i<r.length;i++)t|=r[i]^e[i];return 1&t-1>>>8}Ii.compare=nu;function Z2(r,e){return r.length===0||e.length===0?!1:nu(r,e)!==0}Ii.equal=Z2,function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Ii,t=or;r.DIGEST_LENGTH=16;var i=function(){function o(f){this.digestLength=r.DIGEST_LENGTH,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,this._finished=!1;var u=f[0]|f[1]<<8;this._r[0]=u&8191;var h=f[2]|f[3]<<8;this._r[1]=(u>>>13|h<<3)&8191;var g=f[4]|f[5]<<8;this._r[2]=(h>>>10|g<<6)&7939;var y=f[6]|f[7]<<8;this._r[3]=(g>>>7|y<<9)&8191;var I=f[8]|f[9]<<8;this._r[4]=(y>>>4|I<<12)&255,this._r[5]=I>>>1&8190;var M=f[10]|f[11]<<8;this._r[6]=(I>>>14|M<<2)&8191;var D=f[12]|f[13]<<8;this._r[7]=(M>>>11|D<<5)&8065;var P=f[14]|f[15]<<8;this._r[8]=(D>>>8|P<<8)&8191,this._r[9]=P>>>5&127,this._pad[0]=f[16]|f[17]<<8,this._pad[1]=f[18]|f[19]<<8,this._pad[2]=f[20]|f[21]<<8,this._pad[3]=f[22]|f[23]<<8,this._pad[4]=f[24]|f[25]<<8,this._pad[5]=f[26]|f[27]<<8,this._pad[6]=f[28]|f[29]<<8,this._pad[7]=f[30]|f[31]<<8}return o.prototype._blocks=function(f,u,h){for(var g=this._fin?0:2048,y=this._h[0],I=this._h[1],M=this._h[2],D=this._h[3],P=this._h[4],k=this._h[5],K=this._h[6],C=this._h[7],j=this._h[8],F=this._h[9],U=this._r[0],z=this._r[1],_=this._r[2],R=this._r[3],J=this._r[4],Q=this._r[5],N=this._r[6],p=this._r[7],l=this._r[8],a=this._r[9];h>=16;){var c=f[u+0]|f[u+1]<<8;y+=c&8191;var b=f[u+2]|f[u+3]<<8;I+=(c>>>13|b<<3)&8191;var A=f[u+4]|f[u+5]<<8;M+=(b>>>10|A<<6)&8191;var E=f[u+6]|f[u+7]<<8;D+=(A>>>7|E<<9)&8191;var x=f[u+8]|f[u+9]<<8;P+=(E>>>4|x<<12)&8191,k+=x>>>1&8191;var d=f[u+10]|f[u+11]<<8;K+=(x>>>14|d<<2)&8191;var w=f[u+12]|f[u+13]<<8;C+=(d>>>11|w<<5)&8191;var v=f[u+14]|f[u+15]<<8;j+=(w>>>8|v<<8)&8191,F+=v>>>5|g;var O=0,W=O;W+=y*U,W+=I*(5*a),W+=M*(5*l),W+=D*(5*p),W+=P*(5*N),O=W>>>13,W&=8191,W+=k*(5*Q),W+=K*(5*J),W+=C*(5*R),W+=j*(5*_),W+=F*(5*z),O+=W>>>13,W&=8191;var S=O;S+=y*z,S+=I*U,S+=M*(5*a),S+=D*(5*l),S+=P*(5*p),O=S>>>13,S&=8191,S+=k*(5*N),S+=K*(5*Q),S+=C*(5*J),S+=j*(5*R),S+=F*(5*_),O+=S>>>13,S&=8191;var H=O;H+=y*_,H+=I*z,H+=M*U,H+=D*(5*a),H+=P*(5*l),O=H>>>13,H&=8191,H+=k*(5*p),H+=K*(5*N),H+=C*(5*Q),H+=j*(5*J),H+=F*(5*R),O+=H>>>13,H&=8191;var T=O;T+=y*R,T+=I*_,T+=M*z,T+=D*U,T+=P*(5*a),O=T>>>13,T&=8191,T+=k*(5*l),T+=K*(5*p),T+=C*(5*N),T+=j*(5*Q),T+=F*(5*J),O+=T>>>13,T&=8191;var q=O;q+=y*J,q+=I*R,q+=M*_,q+=D*z,q+=P*U,O=q>>>13,q&=8191,q+=k*(5*a),q+=K*(5*l),q+=C*(5*p),q+=j*(5*N),q+=F*(5*Q),O+=q>>>13,q&=8191;var B=O;B+=y*Q,B+=I*J,B+=M*R,B+=D*_,B+=P*z,O=B>>>13,B&=8191,B+=k*U,B+=K*(5*a),B+=C*(5*l),B+=j*(5*p),B+=F*(5*N),O+=B>>>13,B&=8191;var m=O;m+=y*N,m+=I*Q,m+=M*J,m+=D*R,m+=P*_,O=m>>>13,m&=8191,m+=k*z,m+=K*U,m+=C*(5*a),m+=j*(5*l),m+=F*(5*p),O+=m>>>13,m&=8191;var L=O;L+=y*p,L+=I*N,L+=M*Q,L+=D*J,L+=P*R,O=L>>>13,L&=8191,L+=k*_,L+=K*z,L+=C*U,L+=j*(5*a),L+=F*(5*l),O+=L>>>13,L&=8191;var G=O;G+=y*l,G+=I*p,G+=M*N,G+=D*Q,G+=P*J,O=G>>>13,G&=8191,G+=k*R,G+=K*_,G+=C*z,G+=j*U,G+=F*(5*a),O+=G>>>13,G&=8191;var Y=O;Y+=y*a,Y+=I*l,Y+=M*p,Y+=D*N,Y+=P*Q,O=Y>>>13,Y&=8191,Y+=k*J,Y+=K*R,Y+=C*_,Y+=j*z,Y+=F*U,O+=Y>>>13,Y&=8191,O=(O<<2)+O|0,O=O+W|0,W=O&8191,O=O>>>13,S+=O,y=W,I=S,M=H,D=T,P=q,k=B,K=m,C=L,j=G,F=Y,u+=16,h-=16}this._h[0]=y,this._h[1]=I,this._h[2]=M,this._h[3]=D,this._h[4]=P,this._h[5]=k,this._h[6]=K,this._h[7]=C,this._h[8]=j,this._h[9]=F},o.prototype.finish=function(f,u){u===void 0&&(u=0);var h=new Uint16Array(10),g,y,I,M;if(this._leftover){for(M=this._leftover,this._buffer[M++]=1;M<16;M++)this._buffer[M]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,M=2;M<10;M++)this._h[M]+=g,g=this._h[M]>>>13,this._h[M]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,h[0]=this._h[0]+5,g=h[0]>>>13,h[0]&=8191,M=1;M<10;M++)h[M]=this._h[M]+g,g=h[M]>>>13,h[M]&=8191;for(h[9]-=8192,y=(g^1)-1,M=0;M<10;M++)h[M]&=y;for(y=~y,M=0;M<10;M++)this._h[M]=this._h[M]&y|h[M];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,I=this._h[0]+this._pad[0],this._h[0]=I&65535,M=1;M<8;M++)I=(this._h[M]+this._pad[M]|0)+(I>>>16)|0,this._h[M]=I&65535;return f[u+0]=this._h[0]>>>0,f[u+1]=this._h[0]>>>8,f[u+2]=this._h[1]>>>0,f[u+3]=this._h[1]>>>8,f[u+4]=this._h[2]>>>0,f[u+5]=this._h[2]>>>8,f[u+6]=this._h[3]>>>0,f[u+7]=this._h[3]>>>8,f[u+8]=this._h[4]>>>0,f[u+9]=this._h[4]>>>8,f[u+10]=this._h[5]>>>0,f[u+11]=this._h[5]>>>8,f[u+12]=this._h[6]>>>0,f[u+13]=this._h[6]>>>8,f[u+14]=this._h[7]>>>0,f[u+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(f){var u=0,h=f.length,g;if(this._leftover){g=16-this._leftover,g>h&&(g=h);for(var y=0;y<g;y++)this._buffer[this._leftover+y]=f[u+y];if(h-=g,u+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(h>=16&&(g=h-h%16,this._blocks(f,u,g),u+=g,h-=g),h){for(var y=0;y<h;y++)this._buffer[this._leftover+y]=f[u+y];this._leftover+=h}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var f=new Uint8Array(16);return this.finish(f),f},o.prototype.clean=function(){return t.wipe(this._buffer),t.wipe(this._r),t.wipe(this._h),t.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();r.Poly1305=i;function n(o,f){var u=new i(o);u.update(f);var h=u.digest();return u.clean(),h}r.oneTimeAuth=n;function s(o,f){return o.length!==r.DIGEST_LENGTH||f.length!==r.DIGEST_LENGTH?!1:e.equal(o,f)}r.equal=s}(iu),function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=aa,t=iu,i=or,n=He,s=Ii;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var o=new Uint8Array(16),f=function(){function u(h){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,h.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(h)}return u.prototype.seal=function(h,g,y,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var P=g.length+this.tagLength,k;if(I){if(I.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");k=I}else k=new Uint8Array(P);return e.streamXOR(this._key,M,g,k,4),this._authenticate(k.subarray(k.length-this.tagLength,k.length),D,k.subarray(0,k.length-this.tagLength),y),i.wipe(M),k},u.prototype.open=function(h,g,y,I){if(h.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var M=new Uint8Array(16);M.set(h,M.length-h.length);var D=new Uint8Array(32);e.stream(this._key,M,D,4);var P=new Uint8Array(this.tagLength);if(this._authenticate(P,D,g.subarray(0,g.length-this.tagLength),y),!s.equal(P,g.subarray(g.length-this.tagLength,g.length)))return null;var k=g.length-this.tagLength,K;if(I){if(I.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");K=I}else K=new Uint8Array(k);return e.streamXOR(this._key,M,g.subarray(0,g.length-this.tagLength),K,4),i.wipe(M),K},u.prototype.clean=function(){return i.wipe(this._key),this},u.prototype._authenticate=function(h,g,y,I){var M=new t.Poly1305(g);I&&(M.update(I),I.length%16>0&&M.update(o.subarray(I.length%16))),M.update(y),y.length%16>0&&M.update(o.subarray(y.length%16));var D=new Uint8Array(8);I&&n.writeUint64LE(I.length,D),M.update(D),n.writeUint64LE(y.length,D),M.update(D);for(var P=M.digest(),k=0;k<P.length;k++)h[k]=P[k];M.clean(),i.wipe(P),i.wipe(D)},u}();r.ChaCha20Poly1305=f}(qo);var su={},es={},$o={};Object.defineProperty($o,"__esModule",{value:!0});function e3(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}$o.isSerializableHash=e3,Object.defineProperty(es,"__esModule",{value:!0});var Gr=$o,t3=Ii,r3=or,au=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),Gr.isSerializableHash(this._inner)&&Gr.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),r3.wipe(i)}return r.prototype.reset=function(){if(!Gr.isSerializableHash(this._inner)||!Gr.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){Gr.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Gr.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(e){return this._inner.update(e),this},r.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(!Gr.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(e){if(!Gr.isSerializableHash(this._inner)||!Gr.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(e){if(!Gr.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();es.HMAC=au;function i3(r,e,t){var i=new au(r,e);i.update(t);var n=i.digest();return i.clean(),n}es.hmac=i3,es.equal=t3.equal,Object.defineProperty(su,"__esModule",{value:!0});var ou=es,fu=or,n3=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ou.hmac(this._hash,i,t);this._hmac=new ou.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i<t.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[i]=this._buffer[this._bufpos++];return t},r.prototype.clean=function(){this._hmac.clean(),fu.wipe(this._buffer),fu.wipe(this._counter),this._bufpos=0},r}(),s3=su.HKDF=n3,ts={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=He,t=or;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._temp),this.reset()},f.prototype.update=function(u,h){if(h===void 0&&(h=u.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=h,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&h>0;)this._buffer[this._bufferLength++]=u[g++],h--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(h>=this.blockSize&&(g=s(this._temp,this._state,u,g,h),h%=this.blockSize);h>0;)this._buffer[this._bufferLength++]=u[g++],h--;return this},f.prototype.finish=function(u){if(!this._finished){var h=this._bytesHashed,g=this._bufferLength,y=h/536870912|0,I=h<<3,M=h%64<56?64:128;this._buffer[g]=128;for(var D=g+1;D<M-8;D++)this._buffer[D]=0;e.writeUint32BE(y,this._buffer,M-8),e.writeUint32BE(I,this._buffer,M-4),s(this._temp,this._state,this._buffer,0,M),this._finished=!0}for(var D=0;D<this.digestLength/4;D++)e.writeUint32BE(this._state[D],u,D*4);return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(u){t.wipe(u.state),u.buffer&&t.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},f}();r.SHA256=i;var n=new Int32Array([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]);function s(f,u,h,g,y){for(;y>=64;){for(var I=u[0],M=u[1],D=u[2],P=u[3],k=u[4],K=u[5],C=u[6],j=u[7],F=0;F<16;F++){var U=g+F*4;f[F]=e.readUint32BE(h,U)}for(var F=16;F<64;F++){var z=f[F-2],_=(z>>>17|z<<32-17)^(z>>>19|z<<32-19)^z>>>10;z=f[F-15];var R=(z>>>7|z<<32-7)^(z>>>18|z<<32-18)^z>>>3;f[F]=(_+f[F-7]|0)+(R+f[F-16]|0)}for(var F=0;F<64;F++){var _=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&K^~k&C)|0)+(j+(n[F]+f[F]|0)|0)|0,R=((I>>>2|I<<32-2)^(I>>>13|I<<32-13)^(I>>>22|I<<32-22))+(I&M^I&D^M&D)|0;j=C,C=K,K=k,k=P+_|0,P=D,D=M,M=I,I=_+R|0}u[0]+=I,u[1]+=M,u[2]+=D,u[3]+=P,u[4]+=k,u[5]+=K,u[6]+=C,u[7]+=j,g+=64,y-=64}return g}function o(f){var u=new i;u.update(f);var h=u.digest();return u.clean(),h}r.hash=o})(ts);var zo={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=Ai,t=or;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(F){const U=new Float64Array(16);if(F)for(let z=0;z<F.length;z++)U[z]=F[z];return U}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(F){let U=1;for(let z=0;z<16;z++){let _=F[z]+U+65535;U=Math.floor(_/65536),F[z]=_-U*65536}F[0]+=U-1+37*(U-1)}function f(F,U,z){const _=~(z-1);for(let R=0;R<16;R++){const J=_&(F[R]^U[R]);F[R]^=J,U[R]^=J}}function u(F,U){const z=i(),_=i();for(let R=0;R<16;R++)_[R]=U[R];o(_),o(_),o(_);for(let R=0;R<2;R++){z[0]=_[0]-65517;for(let Q=1;Q<15;Q++)z[Q]=_[Q]-65535-(z[Q-1]>>16&1),z[Q-1]&=65535;z[15]=_[15]-32767-(z[14]>>16&1);const J=z[15]>>16&1;z[14]&=65535,f(_,z,1-J)}for(let R=0;R<16;R++)F[2*R]=_[R]&255,F[2*R+1]=_[R]>>8}function h(F,U){for(let z=0;z<16;z++)F[z]=U[2*z]+(U[2*z+1]<<8);F[15]&=32767}function g(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]+z[_]}function y(F,U,z){for(let _=0;_<16;_++)F[_]=U[_]-z[_]}function I(F,U,z){let _,R,J=0,Q=0,N=0,p=0,l=0,a=0,c=0,b=0,A=0,E=0,x=0,d=0,w=0,v=0,O=0,W=0,S=0,H=0,T=0,q=0,B=0,m=0,L=0,G=0,Y=0,X=0,ee=0,we=0,Se=0,he=0,Ne=0,xe=z[0],ae=z[1],ve=z[2],le=z[3],ne=z[4],ue=z[5],fe=z[6],te=z[7],pe=z[8],_e=z[9],re=z[10],Ae=z[11],Ee=z[12],oe=z[13],De=z[14],Me=z[15];_=U[0],J+=_*xe,Q+=_*ae,N+=_*ve,p+=_*le,l+=_*ne,a+=_*ue,c+=_*fe,b+=_*te,A+=_*pe,E+=_*_e,x+=_*re,d+=_*Ae,w+=_*Ee,v+=_*oe,O+=_*De,W+=_*Me,_=U[1],Q+=_*xe,N+=_*ae,p+=_*ve,l+=_*le,a+=_*ne,c+=_*ue,b+=_*fe,A+=_*te,E+=_*pe,x+=_*_e,d+=_*re,w+=_*Ae,v+=_*Ee,O+=_*oe,W+=_*De,S+=_*Me,_=U[2],N+=_*xe,p+=_*ae,l+=_*ve,a+=_*le,c+=_*ne,b+=_*ue,A+=_*fe,E+=_*te,x+=_*pe,d+=_*_e,w+=_*re,v+=_*Ae,O+=_*Ee,W+=_*oe,S+=_*De,H+=_*Me,_=U[3],p+=_*xe,l+=_*ae,a+=_*ve,c+=_*le,b+=_*ne,A+=_*ue,E+=_*fe,x+=_*te,d+=_*pe,w+=_*_e,v+=_*re,O+=_*Ae,W+=_*Ee,S+=_*oe,H+=_*De,T+=_*Me,_=U[4],l+=_*xe,a+=_*ae,c+=_*ve,b+=_*le,A+=_*ne,E+=_*ue,x+=_*fe,d+=_*te,w+=_*pe,v+=_*_e,O+=_*re,W+=_*Ae,S+=_*Ee,H+=_*oe,T+=_*De,q+=_*Me,_=U[5],a+=_*xe,c+=_*ae,b+=_*ve,A+=_*le,E+=_*ne,x+=_*ue,d+=_*fe,w+=_*te,v+=_*pe,O+=_*_e,W+=_*re,S+=_*Ae,H+=_*Ee,T+=_*oe,q+=_*De,B+=_*Me,_=U[6],c+=_*xe,b+=_*ae,A+=_*ve,E+=_*le,x+=_*ne,d+=_*ue,w+=_*fe,v+=_*te,O+=_*pe,W+=_*_e,S+=_*re,H+=_*Ae,T+=_*Ee,q+=_*oe,B+=_*De,m+=_*Me,_=U[7],b+=_*xe,A+=_*ae,E+=_*ve,x+=_*le,d+=_*ne,w+=_*ue,v+=_*fe,O+=_*te,W+=_*pe,S+=_*_e,H+=_*re,T+=_*Ae,q+=_*Ee,B+=_*oe,m+=_*De,L+=_*Me,_=U[8],A+=_*xe,E+=_*ae,x+=_*ve,d+=_*le,w+=_*ne,v+=_*ue,O+=_*fe,W+=_*te,S+=_*pe,H+=_*_e,T+=_*re,q+=_*Ae,B+=_*Ee,m+=_*oe,L+=_*De,G+=_*Me,_=U[9],E+=_*xe,x+=_*ae,d+=_*ve,w+=_*le,v+=_*ne,O+=_*ue,W+=_*fe,S+=_*te,H+=_*pe,T+=_*_e,q+=_*re,B+=_*Ae,m+=_*Ee,L+=_*oe,G+=_*De,Y+=_*Me,_=U[10],x+=_*xe,d+=_*ae,w+=_*ve,v+=_*le,O+=_*ne,W+=_*ue,S+=_*fe,H+=_*te,T+=_*pe,q+=_*_e,B+=_*re,m+=_*Ae,L+=_*Ee,G+=_*oe,Y+=_*De,X+=_*Me,_=U[11],d+=_*xe,w+=_*ae,v+=_*ve,O+=_*le,W+=_*ne,S+=_*ue,H+=_*fe,T+=_*te,q+=_*pe,B+=_*_e,m+=_*re,L+=_*Ae,G+=_*Ee,Y+=_*oe,X+=_*De,ee+=_*Me,_=U[12],w+=_*xe,v+=_*ae,O+=_*ve,W+=_*le,S+=_*ne,H+=_*ue,T+=_*fe,q+=_*te,B+=_*pe,m+=_*_e,L+=_*re,G+=_*Ae,Y+=_*Ee,X+=_*oe,ee+=_*De,we+=_*Me,_=U[13],v+=_*xe,O+=_*ae,W+=_*ve,S+=_*le,H+=_*ne,T+=_*ue,q+=_*fe,B+=_*te,m+=_*pe,L+=_*_e,G+=_*re,Y+=_*Ae,X+=_*Ee,ee+=_*oe,we+=_*De,Se+=_*Me,_=U[14],O+=_*xe,W+=_*ae,S+=_*ve,H+=_*le,T+=_*ne,q+=_*ue,B+=_*fe,m+=_*te,L+=_*pe,G+=_*_e,Y+=_*re,X+=_*Ae,ee+=_*Ee,we+=_*oe,Se+=_*De,he+=_*Me,_=U[15],W+=_*xe,S+=_*ae,H+=_*ve,T+=_*le,q+=_*ne,B+=_*ue,m+=_*fe,L+=_*te,G+=_*pe,Y+=_*_e,X+=_*re,ee+=_*Ae,we+=_*Ee,Se+=_*oe,he+=_*De,Ne+=_*Me,J+=38*S,Q+=38*H,N+=38*T,p+=38*q,l+=38*B,a+=38*m,c+=38*L,b+=38*G,A+=38*Y,E+=38*X,x+=38*ee,d+=38*we,w+=38*Se,v+=38*he,O+=38*Ne,R=1,_=J+R+65535,R=Math.floor(_/65536),J=_-R*65536,_=Q+R+65535,R=Math.floor(_/65536),Q=_-R*65536,_=N+R+65535,R=Math.floor(_/65536),N=_-R*65536,_=p+R+65535,R=Math.floor(_/65536),p=_-R*65536,_=l+R+65535,R=Math.floor(_/65536),l=_-R*65536,_=a+R+65535,R=Math.floor(_/65536),a=_-R*65536,_=c+R+65535,R=Math.floor(_/65536),c=_-R*65536,_=b+R+65535,R=Math.floor(_/65536),b=_-R*65536,_=A+R+65535,R=Math.floor(_/65536),A=_-R*65536,_=E+R+65535,R=Math.floor(_/65536),E=_-R*65536,_=x+R+65535,R=Math.floor(_/65536),x=_-R*65536,_=d+R+65535,R=Math.floor(_/65536),d=_-R*65536,_=w+R+65535,R=Math.floor(_/65536),w=_-R*65536,_=v+R+65535,R=Math.floor(_/65536),v=_-R*65536,_=O+R+65535,R=Math.floor(_/65536),O=_-R*65536,_=W+R+65535,R=Math.floor(_/65536),W=_-R*65536,J+=R-1+37*(R-1),R=1,_=J+R+65535,R=Math.floor(_/65536),J=_-R*65536,_=Q+R+65535,R=Math.floor(_/65536),Q=_-R*65536,_=N+R+65535,R=Math.floor(_/65536),N=_-R*65536,_=p+R+65535,R=Math.floor(_/65536),p=_-R*65536,_=l+R+65535,R=Math.floor(_/65536),l=_-R*65536,_=a+R+65535,R=Math.floor(_/65536),a=_-R*65536,_=c+R+65535,R=Math.floor(_/65536),c=_-R*65536,_=b+R+65535,R=Math.floor(_/65536),b=_-R*65536,_=A+R+65535,R=Math.floor(_/65536),A=_-R*65536,_=E+R+65535,R=Math.floor(_/65536),E=_-R*65536,_=x+R+65535,R=Math.floor(_/65536),x=_-R*65536,_=d+R+65535,R=Math.floor(_/65536),d=_-R*65536,_=w+R+65535,R=Math.floor(_/65536),w=_-R*65536,_=v+R+65535,R=Math.floor(_/65536),v=_-R*65536,_=O+R+65535,R=Math.floor(_/65536),O=_-R*65536,_=W+R+65535,R=Math.floor(_/65536),W=_-R*65536,J+=R-1+37*(R-1),F[0]=J,F[1]=Q,F[2]=N,F[3]=p,F[4]=l,F[5]=a,F[6]=c,F[7]=b,F[8]=A,F[9]=E,F[10]=x,F[11]=d,F[12]=w,F[13]=v,F[14]=O,F[15]=W}function M(F,U){I(F,U,U)}function D(F,U){const z=i();for(let _=0;_<16;_++)z[_]=U[_];for(let _=253;_>=0;_--)M(z,z),_!==2&&_!==4&&I(z,z,U);for(let _=0;_<16;_++)F[_]=z[_]}function P(F,U){const z=new Uint8Array(32),_=new Float64Array(80),R=i(),J=i(),Q=i(),N=i(),p=i(),l=i();for(let A=0;A<31;A++)z[A]=F[A];z[31]=F[31]&127|64,z[0]&=248,h(_,U);for(let A=0;A<16;A++)J[A]=_[A];R[0]=N[0]=1;for(let A=254;A>=0;--A){const E=z[A>>>3]>>>(A&7)&1;f(R,J,E),f(Q,N,E),g(p,R,Q),y(R,R,Q),g(Q,J,N),y(J,J,N),M(N,p),M(l,R),I(R,Q,R),I(Q,J,p),g(p,R,Q),y(R,R,Q),M(J,R),y(Q,N,l),I(R,Q,s),g(R,R,N),I(Q,Q,R),I(R,N,l),I(N,J,_),M(J,p),f(R,J,E),f(Q,N,E)}for(let A=0;A<16;A++)_[A+16]=R[A],_[A+32]=Q[A],_[A+48]=J[A],_[A+64]=N[A];const a=_.subarray(32),c=_.subarray(16);D(a,a),I(c,c,a);const b=new Uint8Array(32);return u(b,c),b}r.scalarMult=P;function k(F){return P(F,n)}r.scalarMultBase=k;function K(F){if(F.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const U=new Uint8Array(F);return{publicKey:k(U),secretKey:U}}r.generateKeyPairFromSeed=K;function C(F){const U=(0,e.randomBytes)(32,F),z=K(U);return(0,t.wipe)(U),z}r.generateKeyPair=C;function j(F,U,z=!1){if(F.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(U.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const _=P(F,U);if(z){let R=0;for(let J=0;J<_.length;J++)R|=_[J];if(R===0)throw new Error("X25519: invalid shared key")}return _}r.sharedKey=j})(zo);var cu={},a3="elliptic",o3="6.6.1",f3="EC cryptography",c3="lib/elliptic.js",h3=["lib"],u3={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},d3={type:"git",url:"git@github.com:indutny/elliptic"},l3=["EC","Elliptic","curve","Cryptography"],p3="Fedor Indutny <fedor@indutny.com>",g3="MIT",b3={url:"https://github.com/indutny/elliptic/issues"},v3="https://github.com/indutny/elliptic",m3={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},y3={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},w3={name:a3,version:o3,description:f3,main:c3,files:h3,scripts:u3,repository:d3,keywords:l3,author:p3,license:g3,bugs:b3,homepage:v3,devDependencies:m3,dependencies:y3},ur={},Wr={exports:{}};(function(r){(function(e,t){function i(N,p){if(!N)throw new Error(p||"Assertion failed")}function n(N,p){N.super_=p;var l=function(){};l.prototype=p.prototype,N.prototype=new l,N.prototype.constructor=N}function s(N,p,l){if(s.isBN(N))return N;this.negative=0,this.words=null,this.length=0,this.red=null,N!==null&&((p==="le"||p==="be")&&(l=p,p=10),this._init(N||0,p||10,l||"be"))}typeof e=="object"?e.exports=s:t.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Us.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,l){return p.cmp(l)>0?p:l},s.min=function(p,l){return p.cmp(l)<0?p:l},s.prototype._init=function(p,l,a){if(typeof p=="number")return this._initNumber(p,l,a);if(typeof p=="object")return this._initArray(p,l,a);l==="hex"&&(l=16),i(l===(l|0)&&l>=2&&l<=36),p=p.toString().replace(/\s+/g,"");var c=0;p[0]==="-"&&(c++,this.negative=1),c<p.length&&(l===16?this._parseHex(p,c,a):(this._parseBase(p,l,c),a==="le"&&this._initArray(this.toArray(),l,a)))},s.prototype._initNumber=function(p,l,a){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):(i(p<9007199254740992),this.words=[p&67108863,p/67108864&67108863,1],this.length=3),a==="le"&&this._initArray(this.toArray(),l,a)},s.prototype._initArray=function(p,l,a){if(i(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 c=0;c<this.length;c++)this.words[c]=0;var b,A,E=0;if(a==="be")for(c=p.length-1,b=0;c>=0;c-=3)A=p[c]|p[c-1]<<8|p[c-2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);else if(a==="le")for(c=0,b=0;c<p.length;c+=3)A=p[c]|p[c+1]<<8|p[c+2]<<16,this.words[b]|=A<<E&67108863,this.words[b+1]=A>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);return this.strip()};function f(N,p){var l=N.charCodeAt(p);return l>=65&&l<=70?l-55:l>=97&&l<=102?l-87:l-48&15}function u(N,p,l){var a=f(N,l);return l-1>=p&&(a|=f(N,l-1)<<4),a}s.prototype._parseHex=function(p,l,a){this.length=Math.ceil((p.length-l)/6),this.words=new Array(this.length);for(var c=0;c<this.length;c++)this.words[c]=0;var b=0,A=0,E;if(a==="be")for(c=p.length-1;c>=l;c-=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8;else{var x=p.length-l;for(c=x%2===0?l+1:l;c<p.length;c+=2)E=u(p,l,c)<<b,this.words[A]|=E&67108863,b>=18?(b-=18,A+=1,this.words[A]|=E>>>26):b+=8}this.strip()};function h(N,p,l,a){for(var c=0,b=Math.min(N.length,l),A=p;A<b;A++){var E=N.charCodeAt(A)-48;c*=a,E>=49?c+=E-49+10:E>=17?c+=E-17+10:c+=E}return c}s.prototype._parseBase=function(p,l,a){this.words=[0],this.length=1;for(var c=0,b=1;b<=67108863;b*=l)c++;c--,b=b/l|0;for(var A=p.length-a,E=A%c,x=Math.min(A,A-E)+a,d=0,w=a;w<x;w+=c)d=h(p,w,w+c,l),this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(E!==0){var v=1;for(d=h(p,w,p.length,l),w=0;w<E;w++)v*=l;this.imuln(v),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(p){p.words=new Array(this.length);for(var l=0;l<this.length;l++)p.words[l]=this.words[l];p.length=this.length,p.negative=this.negative,p.red=this.red},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},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var g=["","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"],y=[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],I=[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,l){p=p||10,l=l|0||1;var a;if(p===16||p==="hex"){a="";for(var c=0,b=0,A=0;A<this.length;A++){var E=this.words[A],x=((E<<c|b)&16777215).toString(16);b=E>>>24-c&16777215,c+=2,c>=26&&(c-=26,A--),b!==0||A!==this.length-1?a=g[6-x.length]+x+a:a=x+a}for(b!==0&&(a=b.toString(16)+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}if(p===(p|0)&&p>=2&&p<=36){var d=y[p],w=I[p];a="";var v=this.clone();for(v.negative=0;!v.isZero();){var O=v.modn(w).toString(p);v=v.idivn(w),v.isZero()?a=O+a:a=g[d-O.length]+O+a}for(this.isZero()&&(a="0"+a);a.length%l!==0;)a="0"+a;return this.negative!==0&&(a="-"+a),a}i(!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&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-p:p},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(p,l){return i(typeof o<"u"),this.toArrayLike(o,p,l)},s.prototype.toArray=function(p,l){return this.toArrayLike(Array,p,l)},s.prototype.toArrayLike=function(p,l,a){var c=this.byteLength(),b=a||Math.max(1,c);i(c<=b,"byte array longer than desired length"),i(b>0,"Requested array length <= 0"),this.strip();var A=l==="le",E=new p(b),x,d,w=this.clone();if(A){for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[d]=x;for(;d<b;d++)E[d]=0}else{for(d=0;d<b-c;d++)E[d]=0;for(d=0;!w.isZero();d++)x=w.andln(255),w.iushrn(8),E[b-d-1]=x}return E},Math.clz32?s.prototype._countBits=function(p){return 32-Math.clz32(p)}:s.prototype._countBits=function(p){var l=p,a=0;return l>=4096&&(a+=13,l>>>=13),l>=64&&(a+=7,l>>>=7),l>=8&&(a+=4,l>>>=4),l>=2&&(a+=2,l>>>=2),a+l},s.prototype._zeroBits=function(p){if(p===0)return 26;var l=p,a=0;return l&8191||(a+=13,l>>>=13),l&127||(a+=7,l>>>=7),l&15||(a+=4,l>>>=4),l&3||(a+=2,l>>>=2),l&1||a++,a},s.prototype.bitLength=function(){var p=this.words[this.length-1],l=this._countBits(p);return(this.length-1)*26+l};function M(N){for(var p=new Array(N.bitLength()),l=0;l<p.length;l++){var a=l/26|0,c=l%26;p[l]=(N.words[a]&1<<c)>>>c}return p}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var p=0,l=0;l<this.length;l++){var a=this._zeroBits(this.words[l]);if(p+=a,a!==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 l=0;l<p.length;l++)this.words[l]=this.words[l]|p.words[l];return this.strip()},s.prototype.ior=function(p){return i((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 l;this.length>p.length?l=p:l=this;for(var a=0;a<l.length;a++)this.words[a]=this.words[a]&p.words[a];return this.length=l.length,this.strip()},s.prototype.iand=function(p){return i((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 l,a;this.length>p.length?(l=this,a=p):(l=p,a=this);for(var c=0;c<a.length;c++)this.words[c]=l.words[c]^a.words[c];if(this!==l)for(;c<l.length;c++)this.words[c]=l.words[c];return this.length=l.length,this.strip()},s.prototype.ixor=function(p){return i((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){i(typeof p=="number"&&p>=0);var l=Math.ceil(p/26)|0,a=p%26;this._expand(l),a>0&&l--;for(var c=0;c<l;c++)this.words[c]=~this.words[c]&67108863;return a>0&&(this.words[c]=~this.words[c]&67108863>>26-a),this.strip()},s.prototype.notn=function(p){return this.clone().inotn(p)},s.prototype.setn=function(p,l){i(typeof p=="number"&&p>=0);var a=p/26|0,c=p%26;return this._expand(a+1),l?this.words[a]=this.words[a]|1<<c:this.words[a]=this.words[a]&~(1<<c),this.strip()},s.prototype.iadd=function(p){var l;if(this.negative!==0&&p.negative===0)return this.negative=0,l=this.isub(p),this.negative^=1,this._normSign();if(this.negative===0&&p.negative!==0)return p.negative=0,l=this.isub(p),p.negative=1,l._normSign();var a,c;this.length>p.length?(a=this,c=p):(a=p,c=this);for(var b=0,A=0;A<c.length;A++)l=(a.words[A]|0)+(c.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;for(;b!==0&&A<a.length;A++)l=(a.words[A]|0)+b,this.words[A]=l&67108863,b=l>>>26;if(this.length=a.length,b!==0)this.words[this.length]=b,this.length++;else if(a!==this)for(;A<a.length;A++)this.words[A]=a.words[A];return this},s.prototype.add=function(p){var l;return p.negative!==0&&this.negative===0?(p.negative=0,l=this.sub(p),p.negative^=1,l):p.negative===0&&this.negative!==0?(this.negative=0,l=p.sub(this),this.negative=1,l):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 l=this.iadd(p);return p.negative=1,l._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(p),this.negative=1,this._normSign();var a=this.cmp(p);if(a===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,b;a>0?(c=this,b=p):(c=p,b=this);for(var A=0,E=0;E<b.length;E++)l=(c.words[E]|0)-(b.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;for(;A!==0&&E<c.length;E++)l=(c.words[E]|0)+A,A=l>>26,this.words[E]=l&67108863;if(A===0&&E<c.length&&c!==this)for(;E<c.length;E++)this.words[E]=c.words[E];return this.length=Math.max(this.length,E),c!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(p){return this.clone().isub(p)};function D(N,p,l){l.negative=p.negative^N.negative;var a=N.length+p.length|0;l.length=a,a=a-1|0;var c=N.words[0]|0,b=p.words[0]|0,A=c*b,E=A&67108863,x=A/67108864|0;l.words[0]=E;for(var d=1;d<a;d++){for(var w=x>>>26,v=x&67108863,O=Math.min(d,p.length-1),W=Math.max(0,d-N.length+1);W<=O;W++){var S=d-W|0;c=N.words[S]|0,b=p.words[W]|0,A=c*b+v,w+=A/67108864|0,v=A&67108863}l.words[d]=v|0,x=w|0}return x!==0?l.words[d]=x|0:l.length--,l.strip()}var P=function(p,l,a){var c=p.words,b=l.words,A=a.words,E=0,x,d,w,v=c[0]|0,O=v&8191,W=v>>>13,S=c[1]|0,H=S&8191,T=S>>>13,q=c[2]|0,B=q&8191,m=q>>>13,L=c[3]|0,G=L&8191,Y=L>>>13,X=c[4]|0,ee=X&8191,we=X>>>13,Se=c[5]|0,he=Se&8191,Ne=Se>>>13,xe=c[6]|0,ae=xe&8191,ve=xe>>>13,le=c[7]|0,ne=le&8191,ue=le>>>13,fe=c[8]|0,te=fe&8191,pe=fe>>>13,_e=c[9]|0,re=_e&8191,Ae=_e>>>13,Ee=b[0]|0,oe=Ee&8191,De=Ee>>>13,Me=b[1]|0,Oe=Me&8191,We=Me>>>13,Qe=b[2]|0,Ie=Qe&8191,et=Qe>>>13,tt=b[3]|0,Pe=tt&8191,Te=tt>>>13,Ce=b[4]|0,de=Ce&8191,Fe=Ce>>>13,Be=b[5]|0,ce=Be&8191,Ue=Be>>>13,$e=b[6]|0,me=$e&8191,ze=$e>>>13,ke=b[7]|0,ge=ke&8191,Le=ke>>>13,Re=b[8]|0,ye=Re&8191,Ke=Re>>>13,it=b[9]|0,qe=it&8191,nt=it>>>13;a.negative=p.negative^l.negative,a.length=19,x=Math.imul(O,oe),d=Math.imul(O,De),d=d+Math.imul(W,oe)|0,w=Math.imul(W,De);var Je=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Je>>>26)|0,Je&=67108863,x=Math.imul(H,oe),d=Math.imul(H,De),d=d+Math.imul(T,oe)|0,w=Math.imul(T,De),x=x+Math.imul(O,Oe)|0,d=d+Math.imul(O,We)|0,d=d+Math.imul(W,Oe)|0,w=w+Math.imul(W,We)|0;var rt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(rt>>>26)|0,rt&=67108863,x=Math.imul(B,oe),d=Math.imul(B,De),d=d+Math.imul(m,oe)|0,w=Math.imul(m,De),x=x+Math.imul(H,Oe)|0,d=d+Math.imul(H,We)|0,d=d+Math.imul(T,Oe)|0,w=w+Math.imul(T,We)|0,x=x+Math.imul(O,Ie)|0,d=d+Math.imul(O,et)|0,d=d+Math.imul(W,Ie)|0,w=w+Math.imul(W,et)|0;var ir=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ir>>>26)|0,ir&=67108863,x=Math.imul(G,oe),d=Math.imul(G,De),d=d+Math.imul(Y,oe)|0,w=Math.imul(Y,De),x=x+Math.imul(B,Oe)|0,d=d+Math.imul(B,We)|0,d=d+Math.imul(m,Oe)|0,w=w+Math.imul(m,We)|0,x=x+Math.imul(H,Ie)|0,d=d+Math.imul(H,et)|0,d=d+Math.imul(T,Ie)|0,w=w+Math.imul(T,et)|0,x=x+Math.imul(O,Pe)|0,d=d+Math.imul(O,Te)|0,d=d+Math.imul(W,Pe)|0,w=w+Math.imul(W,Te)|0;var nr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,x=Math.imul(ee,oe),d=Math.imul(ee,De),d=d+Math.imul(we,oe)|0,w=Math.imul(we,De),x=x+Math.imul(G,Oe)|0,d=d+Math.imul(G,We)|0,d=d+Math.imul(Y,Oe)|0,w=w+Math.imul(Y,We)|0,x=x+Math.imul(B,Ie)|0,d=d+Math.imul(B,et)|0,d=d+Math.imul(m,Ie)|0,w=w+Math.imul(m,et)|0,x=x+Math.imul(H,Pe)|0,d=d+Math.imul(H,Te)|0,d=d+Math.imul(T,Pe)|0,w=w+Math.imul(T,Te)|0,x=x+Math.imul(O,de)|0,d=d+Math.imul(O,Fe)|0,d=d+Math.imul(W,de)|0,w=w+Math.imul(W,Fe)|0;var sr=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(sr>>>26)|0,sr&=67108863,x=Math.imul(he,oe),d=Math.imul(he,De),d=d+Math.imul(Ne,oe)|0,w=Math.imul(Ne,De),x=x+Math.imul(ee,Oe)|0,d=d+Math.imul(ee,We)|0,d=d+Math.imul(we,Oe)|0,w=w+Math.imul(we,We)|0,x=x+Math.imul(G,Ie)|0,d=d+Math.imul(G,et)|0,d=d+Math.imul(Y,Ie)|0,w=w+Math.imul(Y,et)|0,x=x+Math.imul(B,Pe)|0,d=d+Math.imul(B,Te)|0,d=d+Math.imul(m,Pe)|0,w=w+Math.imul(m,Te)|0,x=x+Math.imul(H,de)|0,d=d+Math.imul(H,Fe)|0,d=d+Math.imul(T,de)|0,w=w+Math.imul(T,Fe)|0,x=x+Math.imul(O,ce)|0,d=d+Math.imul(O,Ue)|0,d=d+Math.imul(W,ce)|0,w=w+Math.imul(W,Ue)|0;var ar=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,x=Math.imul(ae,oe),d=Math.imul(ae,De),d=d+Math.imul(ve,oe)|0,w=Math.imul(ve,De),x=x+Math.imul(he,Oe)|0,d=d+Math.imul(he,We)|0,d=d+Math.imul(Ne,Oe)|0,w=w+Math.imul(Ne,We)|0,x=x+Math.imul(ee,Ie)|0,d=d+Math.imul(ee,et)|0,d=d+Math.imul(we,Ie)|0,w=w+Math.imul(we,et)|0,x=x+Math.imul(G,Pe)|0,d=d+Math.imul(G,Te)|0,d=d+Math.imul(Y,Pe)|0,w=w+Math.imul(Y,Te)|0,x=x+Math.imul(B,de)|0,d=d+Math.imul(B,Fe)|0,d=d+Math.imul(m,de)|0,w=w+Math.imul(m,Fe)|0,x=x+Math.imul(H,ce)|0,d=d+Math.imul(H,Ue)|0,d=d+Math.imul(T,ce)|0,w=w+Math.imul(T,Ue)|0,x=x+Math.imul(O,me)|0,d=d+Math.imul(O,ze)|0,d=d+Math.imul(W,me)|0,w=w+Math.imul(W,ze)|0;var yt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(yt>>>26)|0,yt&=67108863,x=Math.imul(ne,oe),d=Math.imul(ne,De),d=d+Math.imul(ue,oe)|0,w=Math.imul(ue,De),x=x+Math.imul(ae,Oe)|0,d=d+Math.imul(ae,We)|0,d=d+Math.imul(ve,Oe)|0,w=w+Math.imul(ve,We)|0,x=x+Math.imul(he,Ie)|0,d=d+Math.imul(he,et)|0,d=d+Math.imul(Ne,Ie)|0,w=w+Math.imul(Ne,et)|0,x=x+Math.imul(ee,Pe)|0,d=d+Math.imul(ee,Te)|0,d=d+Math.imul(we,Pe)|0,w=w+Math.imul(we,Te)|0,x=x+Math.imul(G,de)|0,d=d+Math.imul(G,Fe)|0,d=d+Math.imul(Y,de)|0,w=w+Math.imul(Y,Fe)|0,x=x+Math.imul(B,ce)|0,d=d+Math.imul(B,Ue)|0,d=d+Math.imul(m,ce)|0,w=w+Math.imul(m,Ue)|0,x=x+Math.imul(H,me)|0,d=d+Math.imul(H,ze)|0,d=d+Math.imul(T,me)|0,w=w+Math.imul(T,ze)|0,x=x+Math.imul(O,ge)|0,d=d+Math.imul(O,Le)|0,d=d+Math.imul(W,ge)|0,w=w+Math.imul(W,Le)|0;var di=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(di>>>26)|0,di&=67108863,x=Math.imul(te,oe),d=Math.imul(te,De),d=d+Math.imul(pe,oe)|0,w=Math.imul(pe,De),x=x+Math.imul(ne,Oe)|0,d=d+Math.imul(ne,We)|0,d=d+Math.imul(ue,Oe)|0,w=w+Math.imul(ue,We)|0,x=x+Math.imul(ae,Ie)|0,d=d+Math.imul(ae,et)|0,d=d+Math.imul(ve,Ie)|0,w=w+Math.imul(ve,et)|0,x=x+Math.imul(he,Pe)|0,d=d+Math.imul(he,Te)|0,d=d+Math.imul(Ne,Pe)|0,w=w+Math.imul(Ne,Te)|0,x=x+Math.imul(ee,de)|0,d=d+Math.imul(ee,Fe)|0,d=d+Math.imul(we,de)|0,w=w+Math.imul(we,Fe)|0,x=x+Math.imul(G,ce)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(Y,ce)|0,w=w+Math.imul(Y,Ue)|0,x=x+Math.imul(B,me)|0,d=d+Math.imul(B,ze)|0,d=d+Math.imul(m,me)|0,w=w+Math.imul(m,ze)|0,x=x+Math.imul(H,ge)|0,d=d+Math.imul(H,Le)|0,d=d+Math.imul(T,ge)|0,w=w+Math.imul(T,Le)|0,x=x+Math.imul(O,ye)|0,d=d+Math.imul(O,Ke)|0,d=d+Math.imul(W,ye)|0,w=w+Math.imul(W,Ke)|0;var li=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(li>>>26)|0,li&=67108863,x=Math.imul(re,oe),d=Math.imul(re,De),d=d+Math.imul(Ae,oe)|0,w=Math.imul(Ae,De),x=x+Math.imul(te,Oe)|0,d=d+Math.imul(te,We)|0,d=d+Math.imul(pe,Oe)|0,w=w+Math.imul(pe,We)|0,x=x+Math.imul(ne,Ie)|0,d=d+Math.imul(ne,et)|0,d=d+Math.imul(ue,Ie)|0,w=w+Math.imul(ue,et)|0,x=x+Math.imul(ae,Pe)|0,d=d+Math.imul(ae,Te)|0,d=d+Math.imul(ve,Pe)|0,w=w+Math.imul(ve,Te)|0,x=x+Math.imul(he,de)|0,d=d+Math.imul(he,Fe)|0,d=d+Math.imul(Ne,de)|0,w=w+Math.imul(Ne,Fe)|0,x=x+Math.imul(ee,ce)|0,d=d+Math.imul(ee,Ue)|0,d=d+Math.imul(we,ce)|0,w=w+Math.imul(we,Ue)|0,x=x+Math.imul(G,me)|0,d=d+Math.imul(G,ze)|0,d=d+Math.imul(Y,me)|0,w=w+Math.imul(Y,ze)|0,x=x+Math.imul(B,ge)|0,d=d+Math.imul(B,Le)|0,d=d+Math.imul(m,ge)|0,w=w+Math.imul(m,Le)|0,x=x+Math.imul(H,ye)|0,d=d+Math.imul(H,Ke)|0,d=d+Math.imul(T,ye)|0,w=w+Math.imul(T,Ke)|0,x=x+Math.imul(O,qe)|0,d=d+Math.imul(O,nt)|0,d=d+Math.imul(W,qe)|0,w=w+Math.imul(W,nt)|0;var pi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(pi>>>26)|0,pi&=67108863,x=Math.imul(re,Oe),d=Math.imul(re,We),d=d+Math.imul(Ae,Oe)|0,w=Math.imul(Ae,We),x=x+Math.imul(te,Ie)|0,d=d+Math.imul(te,et)|0,d=d+Math.imul(pe,Ie)|0,w=w+Math.imul(pe,et)|0,x=x+Math.imul(ne,Pe)|0,d=d+Math.imul(ne,Te)|0,d=d+Math.imul(ue,Pe)|0,w=w+Math.imul(ue,Te)|0,x=x+Math.imul(ae,de)|0,d=d+Math.imul(ae,Fe)|0,d=d+Math.imul(ve,de)|0,w=w+Math.imul(ve,Fe)|0,x=x+Math.imul(he,ce)|0,d=d+Math.imul(he,Ue)|0,d=d+Math.imul(Ne,ce)|0,w=w+Math.imul(Ne,Ue)|0,x=x+Math.imul(ee,me)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(we,me)|0,w=w+Math.imul(we,ze)|0,x=x+Math.imul(G,ge)|0,d=d+Math.imul(G,Le)|0,d=d+Math.imul(Y,ge)|0,w=w+Math.imul(Y,Le)|0,x=x+Math.imul(B,ye)|0,d=d+Math.imul(B,Ke)|0,d=d+Math.imul(m,ye)|0,w=w+Math.imul(m,Ke)|0,x=x+Math.imul(H,qe)|0,d=d+Math.imul(H,nt)|0,d=d+Math.imul(T,qe)|0,w=w+Math.imul(T,nt)|0;var gi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(gi>>>26)|0,gi&=67108863,x=Math.imul(re,Ie),d=Math.imul(re,et),d=d+Math.imul(Ae,Ie)|0,w=Math.imul(Ae,et),x=x+Math.imul(te,Pe)|0,d=d+Math.imul(te,Te)|0,d=d+Math.imul(pe,Pe)|0,w=w+Math.imul(pe,Te)|0,x=x+Math.imul(ne,de)|0,d=d+Math.imul(ne,Fe)|0,d=d+Math.imul(ue,de)|0,w=w+Math.imul(ue,Fe)|0,x=x+Math.imul(ae,ce)|0,d=d+Math.imul(ae,Ue)|0,d=d+Math.imul(ve,ce)|0,w=w+Math.imul(ve,Ue)|0,x=x+Math.imul(he,me)|0,d=d+Math.imul(he,ze)|0,d=d+Math.imul(Ne,me)|0,w=w+Math.imul(Ne,ze)|0,x=x+Math.imul(ee,ge)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(we,ge)|0,w=w+Math.imul(we,Le)|0,x=x+Math.imul(G,ye)|0,d=d+Math.imul(G,Ke)|0,d=d+Math.imul(Y,ye)|0,w=w+Math.imul(Y,Ke)|0,x=x+Math.imul(B,qe)|0,d=d+Math.imul(B,nt)|0,d=d+Math.imul(m,qe)|0,w=w+Math.imul(m,nt)|0;var bi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(bi>>>26)|0,bi&=67108863,x=Math.imul(re,Pe),d=Math.imul(re,Te),d=d+Math.imul(Ae,Pe)|0,w=Math.imul(Ae,Te),x=x+Math.imul(te,de)|0,d=d+Math.imul(te,Fe)|0,d=d+Math.imul(pe,de)|0,w=w+Math.imul(pe,Fe)|0,x=x+Math.imul(ne,ce)|0,d=d+Math.imul(ne,Ue)|0,d=d+Math.imul(ue,ce)|0,w=w+Math.imul(ue,Ue)|0,x=x+Math.imul(ae,me)|0,d=d+Math.imul(ae,ze)|0,d=d+Math.imul(ve,me)|0,w=w+Math.imul(ve,ze)|0,x=x+Math.imul(he,ge)|0,d=d+Math.imul(he,Le)|0,d=d+Math.imul(Ne,ge)|0,w=w+Math.imul(Ne,Le)|0,x=x+Math.imul(ee,ye)|0,d=d+Math.imul(ee,Ke)|0,d=d+Math.imul(we,ye)|0,w=w+Math.imul(we,Ke)|0,x=x+Math.imul(G,qe)|0,d=d+Math.imul(G,nt)|0,d=d+Math.imul(Y,qe)|0,w=w+Math.imul(Y,nt)|0;var Er=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(Er>>>26)|0,Er&=67108863,x=Math.imul(re,de),d=Math.imul(re,Fe),d=d+Math.imul(Ae,de)|0,w=Math.imul(Ae,Fe),x=x+Math.imul(te,ce)|0,d=d+Math.imul(te,Ue)|0,d=d+Math.imul(pe,ce)|0,w=w+Math.imul(pe,Ue)|0,x=x+Math.imul(ne,me)|0,d=d+Math.imul(ne,ze)|0,d=d+Math.imul(ue,me)|0,w=w+Math.imul(ue,ze)|0,x=x+Math.imul(ae,ge)|0,d=d+Math.imul(ae,Le)|0,d=d+Math.imul(ve,ge)|0,w=w+Math.imul(ve,Le)|0,x=x+Math.imul(he,ye)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Ne,ye)|0,w=w+Math.imul(Ne,Ke)|0,x=x+Math.imul(ee,qe)|0,d=d+Math.imul(ee,nt)|0,d=d+Math.imul(we,qe)|0,w=w+Math.imul(we,nt)|0;var vi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(vi>>>26)|0,vi&=67108863,x=Math.imul(re,ce),d=Math.imul(re,Ue),d=d+Math.imul(Ae,ce)|0,w=Math.imul(Ae,Ue),x=x+Math.imul(te,me)|0,d=d+Math.imul(te,ze)|0,d=d+Math.imul(pe,me)|0,w=w+Math.imul(pe,ze)|0,x=x+Math.imul(ne,ge)|0,d=d+Math.imul(ne,Le)|0,d=d+Math.imul(ue,ge)|0,w=w+Math.imul(ue,Le)|0,x=x+Math.imul(ae,ye)|0,d=d+Math.imul(ae,Ke)|0,d=d+Math.imul(ve,ye)|0,w=w+Math.imul(ve,Ke)|0,x=x+Math.imul(he,qe)|0,d=d+Math.imul(he,nt)|0,d=d+Math.imul(Ne,qe)|0,w=w+Math.imul(Ne,nt)|0;var mi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(mi>>>26)|0,mi&=67108863,x=Math.imul(re,me),d=Math.imul(re,ze),d=d+Math.imul(Ae,me)|0,w=Math.imul(Ae,ze),x=x+Math.imul(te,ge)|0,d=d+Math.imul(te,Le)|0,d=d+Math.imul(pe,ge)|0,w=w+Math.imul(pe,Le)|0,x=x+Math.imul(ne,ye)|0,d=d+Math.imul(ne,Ke)|0,d=d+Math.imul(ue,ye)|0,w=w+Math.imul(ue,Ke)|0,x=x+Math.imul(ae,qe)|0,d=d+Math.imul(ae,nt)|0,d=d+Math.imul(ve,qe)|0,w=w+Math.imul(ve,nt)|0;var jt=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(jt>>>26)|0,jt&=67108863,x=Math.imul(re,ge),d=Math.imul(re,Le),d=d+Math.imul(Ae,ge)|0,w=Math.imul(Ae,Le),x=x+Math.imul(te,ye)|0,d=d+Math.imul(te,Ke)|0,d=d+Math.imul(pe,ye)|0,w=w+Math.imul(pe,Ke)|0,x=x+Math.imul(ne,qe)|0,d=d+Math.imul(ne,nt)|0,d=d+Math.imul(ue,qe)|0,w=w+Math.imul(ue,nt)|0;var yi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(yi>>>26)|0,yi&=67108863,x=Math.imul(re,ye),d=Math.imul(re,Ke),d=d+Math.imul(Ae,ye)|0,w=Math.imul(Ae,Ke),x=x+Math.imul(te,qe)|0,d=d+Math.imul(te,nt)|0,d=d+Math.imul(pe,qe)|0,w=w+Math.imul(pe,nt)|0;var wi=(E+x|0)+((d&8191)<<13)|0;E=(w+(d>>>13)|0)+(wi>>>26)|0,wi&=67108863,x=Math.imul(re,qe),d=Math.imul(re,nt),d=d+Math.imul(Ae,qe)|0,w=Math.imul(Ae,nt);var _i=(E+x|0)+((d&8191)<<13)|0;return E=(w+(d>>>13)|0)+(_i>>>26)|0,_i&=67108863,A[0]=Je,A[1]=rt,A[2]=ir,A[3]=nr,A[4]=sr,A[5]=ar,A[6]=yt,A[7]=di,A[8]=li,A[9]=pi,A[10]=gi,A[11]=bi,A[12]=Er,A[13]=vi,A[14]=mi,A[15]=jt,A[16]=yi,A[17]=wi,A[18]=_i,E!==0&&(A[19]=E,a.length++),a};Math.imul||(P=D);function k(N,p,l){l.negative=p.negative^N.negative,l.length=N.length+p.length;for(var a=0,c=0,b=0;b<l.length-1;b++){var A=c;c=0;for(var E=a&67108863,x=Math.min(b,p.length-1),d=Math.max(0,b-N.length+1);d<=x;d++){var w=b-d,v=N.words[w]|0,O=p.words[d]|0,W=v*O,S=W&67108863;A=A+(W/67108864|0)|0,S=S+E|0,E=S&67108863,A=A+(S>>>26)|0,c+=A>>>26,A&=67108863}l.words[b]=E,a=A,A=c}return a!==0?l.words[b]=a:l.length--,l.strip()}function K(N,p,l){var a=new C;return a.mulp(N,p,l)}s.prototype.mulTo=function(p,l){var a,c=this.length+p.length;return this.length===10&&p.length===10?a=P(this,p,l):c<63?a=D(this,p,l):c<1024?a=k(this,p,l):a=K(this,p,l),a};function C(N,p){this.x=N,this.y=p}C.prototype.makeRBT=function(p){for(var l=new Array(p),a=s.prototype._countBits(p)-1,c=0;c<p;c++)l[c]=this.revBin(c,a,p);return l},C.prototype.revBin=function(p,l,a){if(p===0||p===a-1)return p;for(var c=0,b=0;b<l;b++)c|=(p&1)<<l-b-1,p>>=1;return c},C.prototype.permute=function(p,l,a,c,b,A){for(var E=0;E<A;E++)c[E]=l[p[E]],b[E]=a[p[E]]},C.prototype.transform=function(p,l,a,c,b,A){this.permute(A,p,l,a,c,b);for(var E=1;E<b;E<<=1)for(var x=E<<1,d=Math.cos(2*Math.PI/x),w=Math.sin(2*Math.PI/x),v=0;v<b;v+=x)for(var O=d,W=w,S=0;S<E;S++){var H=a[v+S],T=c[v+S],q=a[v+S+E],B=c[v+S+E],m=O*q-W*B;B=O*B+W*q,q=m,a[v+S]=H+q,c[v+S]=T+B,a[v+S+E]=H-q,c[v+S+E]=T-B,S!==x&&(m=d*O-w*W,W=d*W+w*O,O=m)}},C.prototype.guessLen13b=function(p,l){var a=Math.max(l,p)|1,c=a&1,b=0;for(a=a/2|0;a;a=a>>>1)b++;return 1<<b+1+c},C.prototype.conjugate=function(p,l,a){if(!(a<=1))for(var c=0;c<a/2;c++){var b=p[c];p[c]=p[a-c-1],p[a-c-1]=b,b=l[c],l[c]=-l[a-c-1],l[a-c-1]=-b}},C.prototype.normalize13b=function(p,l){for(var a=0,c=0;c<l/2;c++){var b=Math.round(p[2*c+1]/l)*8192+Math.round(p[2*c]/l)+a;p[c]=b&67108863,b<67108864?a=0:a=b/67108864|0}return p},C.prototype.convert13b=function(p,l,a,c){for(var b=0,A=0;A<l;A++)b=b+(p[A]|0),a[2*A]=b&8191,b=b>>>13,a[2*A+1]=b&8191,b=b>>>13;for(A=2*l;A<c;++A)a[A]=0;i(b===0),i((b&-8192)===0)},C.prototype.stub=function(p){for(var l=new Array(p),a=0;a<p;a++)l[a]=0;return l},C.prototype.mulp=function(p,l,a){var c=2*this.guessLen13b(p.length,l.length),b=this.makeRBT(c),A=this.stub(c),E=new Array(c),x=new Array(c),d=new Array(c),w=new Array(c),v=new Array(c),O=new Array(c),W=a.words;W.length=c,this.convert13b(p.words,p.length,E,c),this.convert13b(l.words,l.length,w,c),this.transform(E,A,x,d,c,b),this.transform(w,A,v,O,c,b);for(var S=0;S<c;S++){var H=x[S]*v[S]-d[S]*O[S];d[S]=x[S]*O[S]+d[S]*v[S],x[S]=H}return this.conjugate(x,d,c),this.transform(x,d,W,A,c,b),this.conjugate(W,A,c),this.normalize13b(W,c),a.negative=p.negative^l.negative,a.length=p.length+l.length,a.strip()},s.prototype.mul=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),this.mulTo(p,l)},s.prototype.mulf=function(p){var l=new s(null);return l.words=new Array(this.length+p.length),K(this,p,l)},s.prototype.imul=function(p){return this.clone().mulTo(p,this)},s.prototype.imuln=function(p){i(typeof p=="number"),i(p<67108864);for(var l=0,a=0;a<this.length;a++){var c=(this.words[a]|0)*p,b=(c&67108863)+(l&67108863);l>>=26,l+=c/67108864|0,l+=b>>>26,this.words[a]=b&67108863}return l!==0&&(this.words[a]=l,this.length++),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 l=M(p);if(l.length===0)return new s(1);for(var a=this,c=0;c<l.length&&l[c]===0;c++,a=a.sqr());if(++c<l.length)for(var b=a.sqr();c<l.length;c++,b=b.sqr())l[c]!==0&&(a=a.mul(b));return a},s.prototype.iushln=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=67108863>>>26-l<<26-l,b;if(l!==0){var A=0;for(b=0;b<this.length;b++){var E=this.words[b]&c,x=(this.words[b]|0)-E<<l;this.words[b]=x|A,A=E>>>26-l}A&&(this.words[b]=A,this.length++)}if(a!==0){for(b=this.length-1;b>=0;b--)this.words[b+a]=this.words[b];for(b=0;b<a;b++)this.words[b]=0;this.length+=a}return this.strip()},s.prototype.ishln=function(p){return i(this.negative===0),this.iushln(p)},s.prototype.iushrn=function(p,l,a){i(typeof p=="number"&&p>=0);var c;l?c=(l-l%26)/26:c=0;var b=p%26,A=Math.min((p-b)/26,this.length),E=67108863^67108863>>>b<<b,x=a;if(c-=A,c=Math.max(0,c),x){for(var d=0;d<A;d++)x.words[d]=this.words[d];x.length=A}if(A!==0)if(this.length>A)for(this.length-=A,d=0;d<this.length;d++)this.words[d]=this.words[d+A];else this.words[0]=0,this.length=1;var w=0;for(d=this.length-1;d>=0&&(w!==0||d>=c);d--){var v=this.words[d]|0;this.words[d]=w<<26-b|v>>>b,w=v&E}return x&&w!==0&&(x.words[x.length++]=w),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(p,l,a){return i(this.negative===0),this.iushrn(p,l,a)},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){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return!1;var b=this.words[a];return!!(b&c)},s.prototype.imaskn=function(p){i(typeof p=="number"&&p>=0);var l=p%26,a=(p-l)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=a)return this;if(l!==0&&a++,this.length=Math.min(a,this.length),l!==0){var c=67108863^67108863>>>l<<l;this.words[this.length-1]&=c}return this.strip()},s.prototype.maskn=function(p){return this.clone().imaskn(p)},s.prototype.iaddn=function(p){return i(typeof p=="number"),i(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 l=0;l<this.length&&this.words[l]>=67108864;l++)this.words[l]-=67108864,l===this.length-1?this.words[l+1]=1:this.words[l+1]++;return this.length=Math.max(this.length,l+1),this},s.prototype.isubn=function(p){if(i(typeof p=="number"),i(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 l=0;l<this.length&&this.words[l]<0;l++)this.words[l]+=67108864,this.words[l+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,l,a){var c=p.length+a,b;this._expand(c);var A,E=0;for(b=0;b<p.length;b++){A=(this.words[b+a]|0)+E;var x=(p.words[b]|0)*l;A-=x&67108863,E=(A>>26)-(x/67108864|0),this.words[b+a]=A&67108863}for(;b<this.length-a;b++)A=(this.words[b+a]|0)+E,E=A>>26,this.words[b+a]=A&67108863;if(E===0)return this.strip();for(i(E===-1),E=0,b=0;b<this.length;b++)A=-(this.words[b]|0)+E,E=A>>26,this.words[b]=A&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(p,l){var a=this.length-p.length,c=this.clone(),b=p,A=b.words[b.length-1]|0,E=this._countBits(A);a=26-E,a!==0&&(b=b.ushln(a),c.iushln(a),A=b.words[b.length-1]|0);var x=c.length-b.length,d;if(l!=="mod"){d=new s(null),d.length=x+1,d.words=new Array(d.length);for(var w=0;w<d.length;w++)d.words[w]=0}var v=c.clone()._ishlnsubmul(b,1,x);v.negative===0&&(c=v,d&&(d.words[x]=1));for(var O=x-1;O>=0;O--){var W=(c.words[b.length+O]|0)*67108864+(c.words[b.length+O-1]|0);for(W=Math.min(W/A|0,67108863),c._ishlnsubmul(b,W,O);c.negative!==0;)W--,c.negative=0,c._ishlnsubmul(b,1,O),c.isZero()||(c.negative^=1);d&&(d.words[O]=W)}return d&&d.strip(),c.strip(),l!=="div"&&a!==0&&c.iushrn(a),{div:d||null,mod:c}},s.prototype.divmod=function(p,l,a){if(i(!p.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var c,b,A;return this.negative!==0&&p.negative===0?(A=this.neg().divmod(p,l),l!=="mod"&&(c=A.div.neg()),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.iadd(p)),{div:c,mod:b}):this.negative===0&&p.negative!==0?(A=this.divmod(p.neg(),l),l!=="mod"&&(c=A.div.neg()),{div:c,mod:A.mod}):this.negative&p.negative?(A=this.neg().divmod(p.neg(),l),l!=="div"&&(b=A.mod.neg(),a&&b.negative!==0&&b.isub(p)),{div:A.div,mod:b}):p.length>this.length||this.cmp(p)<0?{div:new s(0),mod:this}:p.length===1?l==="div"?{div:this.divn(p.words[0]),mod:null}:l==="mod"?{div:null,mod:new s(this.modn(p.words[0]))}:{div:this.divn(p.words[0]),mod:new s(this.modn(p.words[0]))}:this._wordDiv(p,l)},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 l=this.divmod(p);if(l.mod.isZero())return l.div;var a=l.div.negative!==0?l.mod.isub(p):l.mod,c=p.ushrn(1),b=p.andln(1),A=a.cmp(c);return A<0||b===1&&A===0?l.div:l.div.negative!==0?l.div.isubn(1):l.div.iaddn(1)},s.prototype.modn=function(p){i(p<=67108863);for(var l=(1<<26)%p,a=0,c=this.length-1;c>=0;c--)a=(l*a+(this.words[c]|0))%p;return a},s.prototype.idivn=function(p){i(p<=67108863);for(var l=0,a=this.length-1;a>=0;a--){var c=(this.words[a]|0)+l*67108864;this.words[a]=c/p|0,l=c%p}return this.strip()},s.prototype.divn=function(p){return this.clone().idivn(p)},s.prototype.egcd=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=new s(0),E=new s(1),x=0;l.isEven()&&a.isEven();)l.iushrn(1),a.iushrn(1),++x;for(var d=a.clone(),w=l.clone();!l.isZero();){for(var v=0,O=1;!(l.words[0]&O)&&v<26;++v,O<<=1);if(v>0)for(l.iushrn(v);v-- >0;)(c.isOdd()||b.isOdd())&&(c.iadd(d),b.isub(w)),c.iushrn(1),b.iushrn(1);for(var W=0,S=1;!(a.words[0]&S)&&W<26;++W,S<<=1);if(W>0)for(a.iushrn(W);W-- >0;)(A.isOdd()||E.isOdd())&&(A.iadd(d),E.isub(w)),A.iushrn(1),E.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(A),b.isub(E)):(a.isub(l),A.isub(c),E.isub(b))}return{a:A,b:E,gcd:a.iushln(x)}},s.prototype._invmp=function(p){i(p.negative===0),i(!p.isZero());var l=this,a=p.clone();l.negative!==0?l=l.umod(p):l=l.clone();for(var c=new s(1),b=new s(0),A=a.clone();l.cmpn(1)>0&&a.cmpn(1)>0;){for(var E=0,x=1;!(l.words[0]&x)&&E<26;++E,x<<=1);if(E>0)for(l.iushrn(E);E-- >0;)c.isOdd()&&c.iadd(A),c.iushrn(1);for(var d=0,w=1;!(a.words[0]&w)&&d<26;++d,w<<=1);if(d>0)for(a.iushrn(d);d-- >0;)b.isOdd()&&b.iadd(A),b.iushrn(1);l.cmp(a)>=0?(l.isub(a),c.isub(b)):(a.isub(l),b.isub(c))}var v;return l.cmpn(1)===0?v=c:v=b,v.cmpn(0)<0&&v.iadd(p),v},s.prototype.gcd=function(p){if(this.isZero())return p.abs();if(p.isZero())return this.abs();var l=this.clone(),a=p.clone();l.negative=0,a.negative=0;for(var c=0;l.isEven()&&a.isEven();c++)l.iushrn(1),a.iushrn(1);do{for(;l.isEven();)l.iushrn(1);for(;a.isEven();)a.iushrn(1);var b=l.cmp(a);if(b<0){var A=l;l=a,a=A}else if(b===0||a.cmpn(1)===0)break;l.isub(a)}while(!0);return a.iushln(c)},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){i(typeof p=="number");var l=p%26,a=(p-l)/26,c=1<<l;if(this.length<=a)return this._expand(a+1),this.words[a]|=c,this;for(var b=c,A=a;b!==0&&A<this.length;A++){var E=this.words[A]|0;E+=b,b=E>>>26,E&=67108863,this.words[A]=E}return b!==0&&(this.words[A]=b,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(p){var l=p<0;if(this.negative!==0&&!l)return-1;if(this.negative===0&&l)return 1;this.strip();var a;if(this.length>1)a=1;else{l&&(p=-p),i(p<=67108863,"Number is too big");var c=this.words[0]|0;a=c===p?0:c<p?-1:1}return this.negative!==0?-a|0:a},s.prototype.cmp=function(p){if(this.negative!==0&&p.negative===0)return-1;if(this.negative===0&&p.negative!==0)return 1;var l=this.ucmp(p);return this.negative!==0?-l|0:l},s.prototype.ucmp=function(p){if(this.length>p.length)return 1;if(this.length<p.length)return-1;for(var l=0,a=this.length-1;a>=0;a--){var c=this.words[a]|0,b=p.words[a]|0;if(c!==b){c<b?l=-1:c>b&&(l=1);break}}return l},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 J(p)},s.prototype.toRed=function(p){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),p.convertTo(this)._forceRed(p)},s.prototype.fromRed=function(){return i(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 i(!this.red,"Already a number in reduction context"),this._forceRed(p)},s.prototype.redAdd=function(p){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,p)},s.prototype.redIAdd=function(p){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,p)},s.prototype.redSub=function(p){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,p)},s.prototype.redISub=function(p){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,p)},s.prototype.redShl=function(p){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,p)},s.prototype.redMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.mul(this,p)},s.prototype.redIMul=function(p){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,p),this.red.imul(this,p)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(p){return i(this.red&&!p.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,p)};var j={k256:null,p224:null,p192:null,p25519:null};function F(N,p){this.name=N,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()}F.prototype._tmp=function(){var p=new s(null);return p.words=new Array(Math.ceil(this.n/13)),p},F.prototype.ireduce=function(p){var l=p,a;do this.split(l,this.tmp),l=this.imulK(l),l=l.iadd(this.tmp),a=l.bitLength();while(a>this.n);var c=a<this.n?-1:l.ucmp(this.p);return c===0?(l.words[0]=0,l.length=1):c>0?l.isub(this.p):l.strip!==void 0?l.strip():l._strip(),l},F.prototype.split=function(p,l){p.iushrn(this.n,0,l)},F.prototype.imulK=function(p){return p.imul(this.k)};function U(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(U,F),U.prototype.split=function(p,l){for(var a=4194303,c=Math.min(p.length,9),b=0;b<c;b++)l.words[b]=p.words[b];if(l.length=c,p.length<=9){p.words[0]=0,p.length=1;return}var A=p.words[9];for(l.words[l.length++]=A&a,b=10;b<p.length;b++){var E=p.words[b]|0;p.words[b-10]=(E&a)<<4|A>>>22,A=E}A>>>=22,p.words[b-10]=A,A===0&&p.length>10?p.length-=10:p.length-=9},U.prototype.imulK=function(p){p.words[p.length]=0,p.words[p.length+1]=0,p.length+=2;for(var l=0,a=0;a<p.length;a++){var c=p.words[a]|0;l+=c*977,p.words[a]=l&67108863,l=c*64+(l/67108864|0)}return p.words[p.length-1]===0&&(p.length--,p.words[p.length-1]===0&&p.length--),p};function z(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(z,F);function _(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(_,F);function R(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(R,F),R.prototype.imulK=function(p){for(var l=0,a=0;a<p.length;a++){var c=(p.words[a]|0)*19+l,b=c&67108863;c>>>=26,p.words[a]=b,l=c}return l!==0&&(p.words[p.length++]=l),p},s._prime=function(p){if(j[p])return j[p];var l;if(p==="k256")l=new U;else if(p==="p224")l=new z;else if(p==="p192")l=new _;else if(p==="p25519")l=new R;else throw new Error("Unknown prime "+p);return j[p]=l,l};function J(N){if(typeof N=="string"){var p=s._prime(N);this.m=p.p,this.prime=p}else i(N.gtn(1),"modulus must be greater than 1"),this.m=N,this.prime=null}J.prototype._verify1=function(p){i(p.negative===0,"red works only with positives"),i(p.red,"red works only with red numbers")},J.prototype._verify2=function(p,l){i((p.negative|l.negative)===0,"red works only with positives"),i(p.red&&p.red===l.red,"red works only with red numbers")},J.prototype.imod=function(p){return this.prime?this.prime.ireduce(p)._forceRed(this):p.umod(this.m)._forceRed(this)},J.prototype.neg=function(p){return p.isZero()?p.clone():this.m.sub(p)._forceRed(this)},J.prototype.add=function(p,l){this._verify2(p,l);var a=p.add(l);return a.cmp(this.m)>=0&&a.isub(this.m),a._forceRed(this)},J.prototype.iadd=function(p,l){this._verify2(p,l);var a=p.iadd(l);return a.cmp(this.m)>=0&&a.isub(this.m),a},J.prototype.sub=function(p,l){this._verify2(p,l);var a=p.sub(l);return a.cmpn(0)<0&&a.iadd(this.m),a._forceRed(this)},J.prototype.isub=function(p,l){this._verify2(p,l);var a=p.isub(l);return a.cmpn(0)<0&&a.iadd(this.m),a},J.prototype.shl=function(p,l){return this._verify1(p),this.imod(p.ushln(l))},J.prototype.imul=function(p,l){return this._verify2(p,l),this.imod(p.imul(l))},J.prototype.mul=function(p,l){return this._verify2(p,l),this.imod(p.mul(l))},J.prototype.isqr=function(p){return this.imul(p,p.clone())},J.prototype.sqr=function(p){return this.mul(p,p)},J.prototype.sqrt=function(p){if(p.isZero())return p.clone();var l=this.m.andln(3);if(i(l%2===1),l===3){var a=this.m.add(new s(1)).iushrn(2);return this.pow(p,a)}for(var c=this.m.subn(1),b=0;!c.isZero()&&c.andln(1)===0;)b++,c.iushrn(1);i(!c.isZero());var A=new s(1).toRed(this),E=A.redNeg(),x=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,x).cmp(E)!==0;)d.redIAdd(E);for(var w=this.pow(d,c),v=this.pow(p,c.addn(1).iushrn(1)),O=this.pow(p,c),W=b;O.cmp(A)!==0;){for(var S=O,H=0;S.cmp(A)!==0;H++)S=S.redSqr();i(H<W);var T=this.pow(w,new s(1).iushln(W-H-1));v=v.redMul(T),w=T.redSqr(),O=O.redMul(w),W=H}return v},J.prototype.invm=function(p){var l=p._invmp(this.m);return l.negative!==0?(l.negative=0,this.imod(l).redNeg()):this.imod(l)},J.prototype.pow=function(p,l){if(l.isZero())return new s(1).toRed(this);if(l.cmpn(1)===0)return p.clone();var a=4,c=new Array(1<<a);c[0]=new s(1).toRed(this),c[1]=p;for(var b=2;b<c.length;b++)c[b]=this.mul(c[b-1],p);var A=c[0],E=0,x=0,d=l.bitLength()%26;for(d===0&&(d=26),b=l.length-1;b>=0;b--){for(var w=l.words[b],v=d-1;v>=0;v--){var O=w>>v&1;if(A!==c[0]&&(A=this.sqr(A)),O===0&&E===0){x=0;continue}E<<=1,E|=O,x++,!(x!==a&&(b!==0||v!==0))&&(A=this.mul(A,c[E]),x=0,E=0)}d=26}return A},J.prototype.convertTo=function(p){var l=p.umod(this.m);return l===p?l.clone():l},J.prototype.convertFrom=function(p){var l=p.clone();return l.red=null,l},s.mont=function(p){return new Q(p)};function Q(N){J.call(this,N),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)}n(Q,J),Q.prototype.convertTo=function(p){return this.imod(p.ushln(this.shift))},Q.prototype.convertFrom=function(p){var l=this.imod(p.mul(this.rinv));return l.red=null,l},Q.prototype.imul=function(p,l){if(p.isZero()||l.isZero())return p.words[0]=0,p.length=1,p;var a=p.imul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.mul=function(p,l){if(p.isZero()||l.isZero())return new s(0)._forceRed(this);var a=p.mul(l),c=a.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=a.isub(c).iushrn(this.shift),A=b;return b.cmp(this.m)>=0?A=b.isub(this.m):b.cmpn(0)<0&&(A=b.iadd(this.m)),A._forceRed(this)},Q.prototype.invm=function(p){var l=this.imod(p._invmp(this.m).mul(this.r2));return l._forceRed(this)}})(r,Pt)})(Wr);var ko={};(function(r){var e=r;function t(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var f=[];if(typeof s!="string"){for(var u=0;u<s.length;u++)f[u]=s[u]|0;return f}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var u=0;u<s.length;u+=2)f.push(parseInt(s[u]+s[u+1],16))}else for(var u=0;u<s.length;u++){var h=s.charCodeAt(u),g=h>>8,y=h&255;g?f.push(g,y):f.push(y)}return f}e.toArray=t;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",f=0;f<s.length;f++)o+=i(s[f].toString(16));return o}e.toHex=n,e.encode=function(o,f){return f==="hex"?n(o):o}})(ko),function(r){var e=r,t=Wr.exports,i=ji,n=ko;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(g,y,I){var M=new Array(Math.max(g.bitLength(),I)+1),D;for(D=0;D<M.length;D+=1)M[D]=0;var P=1<<y+1,k=g.clone();for(D=0;D<M.length;D++){var K,C=k.andln(P-1);k.isOdd()?(C>(P>>1)-1?K=(P>>1)-C:K=C,k.isubn(K)):K=0,M[D]=K,k.iushrn(1)}return M}e.getNAF=s;function o(g,y){var I=[[],[]];g=g.clone(),y=y.clone();for(var M=0,D=0,P;g.cmpn(-M)>0||y.cmpn(-D)>0;){var k=g.andln(3)+M&3,K=y.andln(3)+D&3;k===3&&(k=-1),K===3&&(K=-1);var C;k&1?(P=g.andln(7)+M&7,(P===3||P===5)&&K===2?C=-k:C=k):C=0,I[0].push(C);var j;K&1?(P=y.andln(7)+D&7,(P===3||P===5)&&k===2?j=-K:j=K):j=0,I[1].push(j),2*M===C+1&&(M=1-M),2*D===j+1&&(D=1-D),g.iushrn(1),y.iushrn(1)}return I}e.getJSF=o;function f(g,y,I){var M="_"+y;g.prototype[y]=function(){return this[M]!==void 0?this[M]:this[M]=I.call(this)}}e.cachedProperty=f;function u(g){return typeof g=="string"?e.toArray(g,"hex"):g}e.parseBytes=u;function h(g){return new t(g,"hex","le")}e.intFromLE=h}(ur);var oa={exports:{}},Ko;oa.exports=function(e){return Ko||(Ko=new Di(null)),Ko.generate(e)};function Di(r){this.rand=r}if(oa.exports.Rand=Di,Di.prototype.generate=function(e){return this._rand(e)},Di.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t},typeof self=="object")self.crypto&&self.crypto.getRandomValues?Di.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?Di.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:typeof window=="object"&&(Di.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var hu=Us;if(typeof hu.randomBytes!="function")throw new Error("Not supported");Di.prototype._rand=function(e){return hu.randomBytes(e)}}catch{}var jo={},Gi=Wr.exports,rs=ur,fa=rs.getNAF,_3=rs.getJSF,ca=rs.assert;function Oi(r,e){this.type=r,this.p=new Gi(e.p,16),this.red=e.prime?Gi.red(e.prime):Gi.mont(this.p),this.zero=new Gi(0).toRed(this.red),this.one=new Gi(1).toRed(this.red),this.two=new Gi(2).toRed(this.red),this.n=e.n&&new Gi(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var ha=Oi;Oi.prototype.point=function(){throw new Error("Not implemented")},Oi.prototype.validate=function(){throw new Error("Not implemented")},Oi.prototype._fixedNafMul=function(e,t){ca(e.precomputed);var i=e._getDoubles(),n=fa(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],f,u;for(f=0;f<n.length;f+=i.step){u=0;for(var h=f+i.step-1;h>=f;h--)u=(u<<1)+n[h];o.push(u)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),I=s;I>0;I--){for(f=0;f<o.length;f++)u=o[f],u===I?y=y.mixedAdd(i.points[f]):u===-I&&(y=y.mixedAdd(i.points[f].neg()));g=g.add(y)}return g.toP()},Oi.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=fa(t,i,this._bitLength),f=this.jpoint(null,null,null),u=o.length-1;u>=0;u--){for(var h=0;u>=0&&o[u]===0;u--)h++;if(u>=0&&h++,f=f.dblp(h),u<0)break;var g=o[u];ca(g!==0),e.type==="affine"?g>0?f=f.mixedAdd(s[g-1>>1]):f=f.mixedAdd(s[-g-1>>1].neg()):g>0?f=f.add(s[g-1>>1]):f=f.add(s[-g-1>>1].neg())}return e.type==="affine"?f.toP():f},Oi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,h=0,g,y,I;for(g=0;g<n;g++){I=t[g];var M=I._getNAFPoints(e);o[g]=M.wnd,f[g]=M.points}for(g=n-1;g>=1;g-=2){var D=g-1,P=g;if(o[D]!==1||o[P]!==1){u[D]=fa(i[D],o[D],this._bitLength),u[P]=fa(i[P],o[P],this._bitLength),h=Math.max(u[D].length,h),h=Math.max(u[P].length,h);continue}var k=[t[D],null,null,t[P]];t[D].y.cmp(t[P].y)===0?(k[1]=t[D].add(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg())):t[D].y.cmp(t[P].y.redNeg())===0?(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].add(t[P].neg())):(k[1]=t[D].toJ().mixedAdd(t[P]),k[2]=t[D].toJ().mixedAdd(t[P].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],C=_3(i[D],i[P]);for(h=Math.max(C[0].length,h),u[D]=new Array(h),u[P]=new Array(h),y=0;y<h;y++){var j=C[0][y]|0,F=C[1][y]|0;u[D][y]=K[(j+1)*3+(F+1)],u[P][y]=0,f[D]=k}}var U=this.jpoint(null,null,null),z=this._wnafT4;for(g=h;g>=0;g--){for(var _=0;g>=0;){var R=!0;for(y=0;y<n;y++)z[y]=u[y][g]|0,z[y]!==0&&(R=!1);if(!R)break;_++,g--}if(g>=0&&_++,U=U.dblp(_),g<0)break;for(y=0;y<n;y++){var J=z[y];J!==0&&(J>0?I=f[y][J-1>>1]:J<0&&(I=f[y][-J-1>>1].neg()),I.type==="affine"?U=U.mixedAdd(I):U=U.add(I))}}for(g=0;g<n;g++)f[g]=null;return s?U:U.toP()};function mr(r,e){this.curve=r,this.type=e,this.precomputed=null}Oi.BasePoint=mr,mr.prototype.eq=function(){throw new Error("Not implemented")},mr.prototype.validate=function(){return this.curve.validate(this)},Oi.prototype.decodePoint=function(e,t){e=rs.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?ca(e[e.length-1]%2===0):e[0]===7&&ca(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},mr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},mr.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},mr.prototype.encode=function(e,t){return rs.encode(this._encode(t),e)},mr.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},mr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},mr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},mr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}},mr.prototype._getBeta=function(){return null},mr.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var x3=ur,pt=Wr.exports,Ho=_n.exports,On=ha,A3=x3.assert;function yr(r){On.call(this,"short",r),this.a=new pt(r.a,16).toRed(this.red),this.b=new pt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Ho(yr,On);var E3=yr;yr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new pt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new pt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],A3(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new pt(f.a,16),b:new pt(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}},yr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:pt.mont(e),i=new pt(2).toRed(t).redInvm(),n=i.redNeg(),s=new pt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]},yr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new pt(1),o=new pt(0),f=new pt(0),u=new pt(1),h,g,y,I,M,D,P,k=0,K,C;i.cmpn(0)!==0;){var j=n.div(i);K=n.sub(j.mul(i)),C=f.sub(j.mul(s));var F=u.sub(j.mul(o));if(!y&&K.cmp(t)<0)h=P.neg(),g=s,y=K.neg(),I=C;else if(y&&++k===2)break;P=K,n=i,i=K,f=s,s=C,u=o,o=F}M=K.neg(),D=C;var U=y.sqr().add(I.sqr()),z=M.sqr().add(D.sqr());return z.cmp(U)>=0&&(M=h,D=g),y.negative&&(y=y.neg(),I=I.neg()),M.negative&&(M=M.neg(),D=D.neg()),[{a:y,b:I},{a:M,b:D}]},yr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),h=s.mul(i.b),g=o.mul(n.b),y=e.sub(f).sub(u),I=h.add(g).neg();return{k1:y,k2:I}},yr.prototype.pointFromX=function(e,t){e=new pt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},yr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},yr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var f=this._endoSplit(t[o]),u=e[o],h=u._getBeta();f.k1.negative&&(f.k1.ineg(),u=u.neg(!0)),f.k2.negative&&(f.k2.ineg(),h=h.neg(!0)),n[o*2]=u,n[o*2+1]=h,s[o*2]=f.k1,s[o*2+1]=f.k2}for(var g=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return g};function Mt(r,e,t,i){On.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new pt(e,16),this.y=new pt(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Ho(Mt,On.BasePoint),yr.prototype.point=function(e,t,i){return new Mt(this,e,t,i)},yr.prototype.pointFromJSON=function(e,t){return Mt.fromJSON(this,e,t)},Mt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},Mt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Mt.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(f){return e.point(f[0],f[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},Mt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Mt.prototype.isInfinity=function(){return this.inf},Mt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},Mt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)},Mt.prototype.getX=function(){return this.x.fromRed()},Mt.prototype.getY=function(){return this.y.fromRed()},Mt.prototype.mul=function(e){return e=new pt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Mt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},Mt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},Mt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},Mt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t},Mt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Bt(r,e,t,i){On.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(t,16),this.z=new pt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Ho(Bt,On.BasePoint),yr.prototype.jpoint=function(e,t,i){return new Bt(this,e,t,i)},Bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)},Bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),h=o.redSub(f);if(u.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),y=g.redMul(u),I=n.redMul(g),M=h.redSqr().redIAdd(y).redISub(I).redISub(I),D=h.redMul(I.redISub(M)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(M,D,P)},Bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),g=h.redMul(f),y=i.redMul(h),I=u.redSqr().redIAdd(g).redISub(y).redISub(y),M=u.redMul(y.redISub(I)).redISub(s.redMul(g)),D=this.z.redMul(f);return this.curve.jpoint(I,M,D)},Bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,f=this.y,u=this.z,h=u.redSqr().redSqr(),g=f.redAdd(f);for(t=0;t<e;t++){var y=o.redSqr(),I=g.redSqr(),M=I.redSqr(),D=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),P=o.redMul(I),k=D.redSqr().redISub(P.redAdd(P)),K=P.redISub(k),C=D.redMul(K);C=C.redIAdd(C).redISub(M);var j=g.redMul(u);t+1<e&&(h=h.redMul(M)),o=k,u=j,g=C}return this.curve.jpoint(o,g.redMul(s),u)},Bt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Bt.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n),h=u.redSqr().redISub(f).redISub(f),g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),e=h,t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),I=this.y.redSqr(),M=I.redSqr(),D=this.x.redAdd(I).redSqr().redISub(y).redISub(M);D=D.redIAdd(D);var P=y.redAdd(y).redIAdd(y),k=P.redSqr(),K=M.redIAdd(M);K=K.redIAdd(K),K=K.redIAdd(K),e=k.redISub(D).redISub(D),t=P.redMul(D.redISub(e)).redISub(K),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)},Bt.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),f=this.x.redAdd(s).redSqr().redISub(n).redISub(o);f=f.redIAdd(f);var u=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=u.redSqr().redISub(f).redISub(f);e=h;var g=o.redIAdd(o);g=g.redIAdd(g),g=g.redIAdd(g),t=u.redMul(f.redISub(h)).redISub(g),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),I=this.y.redSqr(),M=this.x.redMul(I),D=this.x.redSub(y).redMul(this.x.redAdd(y));D=D.redAdd(D).redIAdd(D);var P=M.redIAdd(M);P=P.redIAdd(P);var k=P.redAdd(P);e=D.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(I).redISub(y);var K=I.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),t=D.redMul(P.redISub(e)).redISub(K)}return this.curve.jpoint(e,t,i)},Bt.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),f=i.redSqr(),u=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=t.redAdd(t);h=h.redIAdd(h);var g=h.redMul(f),y=u.redSqr().redISub(g.redAdd(g)),I=g.redISub(y),M=f.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=u.redMul(I).redISub(M),P=i.redAdd(i).redMul(n);return this.curve.jpoint(y,D,P)},Bt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(o);var u=f.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var g=s.redIAdd(f).redSqr().redISub(o).redISub(u).redISub(h),y=t.redMul(g);y=y.redIAdd(y),y=y.redIAdd(y);var I=this.x.redMul(u).redISub(y);I=I.redIAdd(I),I=I.redIAdd(I);var M=this.y.redMul(g.redMul(h.redISub(g)).redISub(f.redMul(u)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var D=this.z.redAdd(f).redSqr().redISub(i).redISub(u);return this.curve.jpoint(I,M,D)},Bt.prototype.mul=function(e,t){return e=new pt(e,t),this.curve._wnafMul(this,e)},Bt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Bt.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Bt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Rn=Wr.exports,uu=_n.exports,ua=ha,S3=ur;function Nn(r){ua.call(this,"mont",r),this.a=new Rn(r.a,16).toRed(this.red),this.b=new Rn(r.b,16).toRed(this.red),this.i4=new Rn(4).toRed(this.red).redInvm(),this.two=new Rn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}uu(Nn,ua);var M3=Nn;Nn.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function It(r,e,t){ua.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Rn(e,16),this.z=new Rn(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}uu(It,ua.BasePoint),Nn.prototype.decodePoint=function(e,t){return this.point(S3.toArray(e,t),1)},Nn.prototype.point=function(e,t){return new It(this,e,t)},Nn.prototype.pointFromJSON=function(e){return It.fromJSON(this,e)},It.prototype.precompute=function(){},It.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},It.fromJSON=function(e,t){return new It(e,t[0],t[1]||e.one)},It.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},It.prototype.isInfinity=function(){return this.z.cmpn(0)===0},It.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)},It.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),h=t.z.redMul(f.redAdd(u).redSqr()),g=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(h,g)},It.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},It.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},It.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},It.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},It.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var I3=ur,si=Wr.exports,du=_n.exports,da=ha,D3=I3.assert;function Jr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,da.call(this,"edwards",r),this.a=new si(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new si(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new si(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),D3(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}du(Jr,da);var O3=Jr;Jr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},Jr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},Jr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)},Jr.prototype.pointFromX=function(e,t){e=new si(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)},Jr.prototype.pointFromY=function(e,t){e=new si(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)},Jr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function ft(r,e,t,i,n){da.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new si(e,16),this.y=new si(t,16),this.z=i?new si(i,16):this.curve.one,this.t=n&&new si(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}du(ft,da.BasePoint),Jr.prototype.pointFromJSON=function(e){return ft.fromJSON(this,e)},Jr.prototype.point=function(e,t,i,n){return new ft(this,e,t,i,n)},ft.fromJSON=function(e,t){return new ft(e,t[0],t[1],t[2])},ft.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},ft.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ft.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),h=s.redMul(f),g=o.redMul(u),y=s.redMul(u),I=f.redMul(o);return this.curve.point(h,g,I,y)},ft.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,h;if(this.curve.twisted){f=this.curve._mulA(t);var g=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(f.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(u=this.z.redSqr(),h=g.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(h),s=g.redMul(f.redSub(i)),o=g.redMul(h))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),h=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(h),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(h);return this.curve.point(n,s,o)},ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ft.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),h=i.redAdd(t),g=o.redMul(f),y=u.redMul(h),I=o.redMul(h),M=f.redMul(u);return this.curve.point(g,y,M,I)},ft.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(f).redMul(h),y,I;return this.curve.twisted?(y=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),I=f.redMul(u)):(y=t.redMul(u).redMul(s.redSub(n)),I=this.curve._mulC(f).redMul(u)),this.curve.point(g,y,I)},ft.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ft.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ft.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)},ft.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)},ft.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},ft.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ft.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ft.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ft.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}},ft.prototype.toP=ft.prototype.normalize,ft.prototype.mixedAdd=ft.prototype.add,function(r){var e=r;e.base=ha,e.short=E3,e.mont=M3,e.edwards=O3}(jo);var la={},Vo,lu;function R3(){return lu||(lu=1,Vo={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),Vo}(function(r){var e=r,t=cr,i=jo,n=ur,s=n.assert;function o(h){h.type==="short"?this.curve=new i.short(h):h.type==="edwards"?this.curve=new i.edwards(h):this.curve=new i.mont(h),this.g=this.curve.g,this.n=this.curve.n,this.hash=h.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function f(h,g){Object.defineProperty(e,h,{configurable:!0,enumerable:!0,get:function(){var y=new o(g);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:y}),y}})}f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:t.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:t.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:t.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:t.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:t.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=R3()}catch{u=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})})(la);var N3=cr,Wi=ko,pu=ji;function Ri(r){if(!(this instanceof Ri))return new Ri(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Wi.toArray(r.entropy,r.entropyEnc||"hex"),t=Wi.toArray(r.nonce,r.nonceEnc||"hex"),i=Wi.toArray(r.pers,r.persEnc||"hex");pu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var P3=Ri;Ri.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Ri.prototype._hmac=function(){return new N3.hmac(this.hash,this.K)},Ri.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Ri.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Wi.toArray(e,t),i=Wi.toArray(i,n),pu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ri.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Wi.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Wi.encode(o,t)};var C3=Wr.exports,T3=ur,Go=T3.assert;function kt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var F3=kt;kt.fromPublic=function(e,t,i){return t instanceof kt?t:new kt(e,{pub:t,pubEnc:i})},kt.fromPrivate=function(e,t,i){return t instanceof kt?t:new kt(e,{priv:t,privEnc:i})},kt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},kt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},kt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},kt.prototype._importPrivate=function(e,t){this.priv=new C3(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},kt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Go(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Go(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},kt.prototype.derive=function(e){return e.validate()||Go(e.validate(),"public point not validated"),e.mul(this.priv).getX()},kt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},kt.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)},kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var pa=Wr.exports,Wo=ur,B3=Wo.assert;function ga(r,e){if(r instanceof ga)return r;this._importDER(r,e)||(B3(r.r&&r.s,"Signature without r or s"),this.r=new pa(r.r,16),this.s=new pa(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var L3=ga;function q3(){this.place=0}function Jo(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function gu(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}ga.prototype._importDER=function(e,t){e=Wo.toArray(e,t);var i=new q3;if(e[i.place++]!==48)return!1;var n=Jo(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Jo(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=Jo(e,i);if(f===!1||e.length!==f+i.place||e[i.place]&128)return!1;var u=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(u[0]===0)if(u[1]&128)u=u.slice(1);else return!1;return this.r=new pa(o),this.s=new pa(u),this.recoveryParam=null,!0};function Yo(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}ga.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=gu(t),i=gu(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Yo(n,t.length),n=n.concat(t),n.push(2),Yo(n,i.length);var s=n.concat(i),o=[48];return Yo(o,s.length),o=o.concat(s),Wo.encode(o,e)};var Nr=Wr.exports,bu=P3,U3=ur,Qo=la,$3=oa.exports,Ji=U3.assert,Xo=F3,ba=L3;function wr(r){if(!(this instanceof wr))return new wr(r);typeof r=="string"&&(Ji(Object.prototype.hasOwnProperty.call(Qo,r),"Unknown curve "+r),r=Qo[r]),r instanceof Qo.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var z3=wr;wr.prototype.keyPair=function(e){return new Xo(this,e)},wr.prototype.keyFromPrivate=function(e,t){return Xo.fromPrivate(this,e,t)},wr.prototype.keyFromPublic=function(e,t){return Xo.fromPublic(this,e,t)},wr.prototype.genKeyPair=function(e){e||(e={});for(var t=new bu({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$3(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Nr(2));;){var s=new Nr(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},wr.prototype._truncateToN=function(e,t,i){var n;if(Nr.isBN(e)||typeof e=="number")e=new Nr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Nr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Nr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},wr.prototype.sign=function(e,t,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Nr.isBN(e)){Ji(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Ji(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Ji((e[s]&255)===e[s])}t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength),Ji(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),f=t.getPrivate().toArray("be",o),u=e.toArray("be",o);Ji(new Nr(u).eq(e),"Can not sign message");for(var h=new bu({hash:this.hash,entropy:f,nonce:u,pers:n.pers,persEnc:n.persEnc||"utf8"}),g=this.n.sub(new Nr(1)),y=0;;y++){var I=n.k?n.k(y):new Nr(h.generate(this.n.byteLength()));if(I=this._truncateToN(I,!0),!(I.cmpn(1)<=0||I.cmp(g)>=0)){var M=this.g.mul(I);if(!M.isInfinity()){var D=M.getX(),P=D.umod(this.n);if(P.cmpn(0)!==0){var k=I.invm(this.n).mul(P.mul(t.getPrivate()).iadd(e));if(k=k.umod(this.n),k.cmpn(0)!==0){var K=(M.getY().isOdd()?1:0)|(D.cmp(P)!==0?2:0);return n.canonical&&k.cmp(this.nh)>0&&(k=this.n.sub(k),K^=1),new ba({r:P,s:k,recoveryParam:K})}}}}}},wr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new ba(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),h=u.mul(e).umod(this.n),g=u.mul(o).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(h,i.getPublic(),g),y.isInfinity()?!1:y.eqXToP(o)):(y=this.g.mulAdd(h,i.getPublic(),g),y.isInfinity()?!1:y.getX().umod(this.n).cmp(o)===0)},wr.prototype.recoverPubKey=function(r,e,t,i){Ji((3&t)===t,"The recovery param is more than two bits"),e=new ba(e,i);var n=this.n,s=new Nr(r),o=e.r,f=e.s,u=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),I=f.mul(g).umod(n);return this.g.mulAdd(y,o,I)},wr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ba(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var is=ur,vu=is.assert,mu=is.parseBytes,Pn=is.cachedProperty;function Dt(r,e){this.eddsa=r,this._secret=mu(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=mu(e.pub)}Dt.fromPublic=function(e,t){return t instanceof Dt?t:new Dt(e,{pub:t})},Dt.fromSecret=function(e,t){return t instanceof Dt?t:new Dt(e,{secret:t})},Dt.prototype.secret=function(){return this._secret},Pn(Dt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Pn(Dt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Pn(Dt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),Pn(Dt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Pn(Dt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Pn(Dt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Dt.prototype.sign=function(e){return vu(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Dt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},Dt.prototype.getSecret=function(e){return vu(this._secret,"KeyPair is public only"),is.encode(this.secret(),e)},Dt.prototype.getPublic=function(e){return is.encode(this.pubBytes(),e)};var k3=Dt,K3=Wr.exports,va=ur,yu=va.assert,ma=va.cachedProperty,j3=va.parseBytes;function Yi(r,e){this.eddsa=r,typeof e!="object"&&(e=j3(e)),Array.isArray(e)&&(yu(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),yu(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof K3&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}ma(Yi,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),ma(Yi,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),ma(Yi,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),ma(Yi,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Yi.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Yi.prototype.toHex=function(){return va.encode(this.toBytes(),"hex").toUpperCase()};var H3=Yi,V3=cr,G3=la,Cn=ur,W3=Cn.assert,wu=Cn.parseBytes,_u=k3,xu=H3;function tr(r){if(W3(r==="ed25519","only tested with ed25519 so far"),!(this instanceof tr))return new tr(r);r=G3[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=V3.sha512}var J3=tr;tr.prototype.sign=function(e,t){e=wu(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})},tr.prototype.verify=function(e,t,i){if(e=wu(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)},tr.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return Cn.intFromLE(e.digest()).umod(this.curve.n)},tr.prototype.keyFromPublic=function(e){return _u.fromPublic(this,e)},tr.prototype.keyFromSecret=function(e){return _u.fromSecret(this,e)},tr.prototype.makeSignature=function(e){return e instanceof xu?e:new xu(this,e)},tr.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},tr.prototype.decodePoint=function(e){e=Cn.parseBytes(e);var t=e.length-1,i=e.slice(0,t).concat(e[t]&-129),n=(e[t]&128)!==0,s=Cn.intFromLE(i);return this.curve.pointFromY(s,n)},tr.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},tr.prototype.decodeInt=function(e){return Cn.intFromLE(e)},tr.prototype.isPoint=function(e){return e instanceof this.pointClass},function(r){var e=r;e.version=w3.version,e.utils=ur,e.rand=oa.exports,e.curve=jo,e.curves=la,e.ec=z3,e.eddsa=J3}(cu);const Y3={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},Q3=":";function ya(r){const[e,t]=r.split(Q3);return{namespace:e,reference:t}}function Au(r,e){return r.includes(":")?[r]:e.chains||[]}var X3=Object.defineProperty,Eu=Object.getOwnPropertySymbols,Z3=Object.prototype.hasOwnProperty,em=Object.prototype.propertyIsEnumerable,Su=(r,e,t)=>e in r?X3(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mu=(r,e)=>{for(var t in e||(e={}))Z3.call(e,t)&&Su(r,t,e[t]);if(Eu)for(var t of Eu(e))em.call(e,t)&&Su(r,t,e[t]);return r};const tm="ReactNative",Kt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},rm="js";function wa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Ni(){return!Hn()&&!!uo()&&navigator.product===tm}function im(){return Ni()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function nm(){return Ni()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ns(){return!wa()&&!!uo()&&!!Hn()}function Pr(){return Ni()?Kt.reactNative:wa()?Kt.node:ns()?Kt.browser:Kt.unknown}function Iu(){var r;try{return Ni()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function sm(r,e){let t=Vn.parse(r);return t=Mu(Mu({},t),e),r=Vn.stringify(t),r}function Du(){return Jc()||{name:"",description:"",url:"",icons:[""]}}function am(){if(Pr()===Kt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:t,Version:i}=global.Platform;return[t,i].join("-")}const r=Xg();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function om(){var r;const e=Pr();return e===Kt.browser?[e,((r=Wc())==null?void 0:r.host)||"unknown"].join(":"):e}function Ou(r,e,t){const i=am(),n=om();return[[r,e].join("-"),[rm,t].join("-"),i,n].join("/")}function fm({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f,packageName:u}){const h=t.split("?"),g=Ou(r,e,i),y={auth:n,ua:g,projectId:s,useOnCloseEvent:o||void 0,packageName:u||void 0,bundleId:f||void 0},I=sm(h[1]||"",y);return h[0]+"?"+I}function Qi(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Ru(r){return Object.fromEntries(r.entries())}function Nu(r){return new Map(Object.entries(r))}function Xi(r=ie.FIVE_MINUTES,e){const t=ie.toMiliseconds(r||ie.FIVE_MINUTES);let i,n,s,o;return{resolve:f=>{s&&i&&(clearTimeout(s),i(f),o=Promise.resolve(f))},reject:f=>{s&&n&&(clearTimeout(s),n(f))},done:()=>new Promise((f,u)=>{if(o)return f(o);s=setTimeout(()=>{const h=new Error(e);o=Promise.reject(h),u(h)},t),i=f,n=u})}}function Pi(r,e,t){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(t)),e);try{const o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Pu(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function cm(r){return Pu("topic",r)}function hm(r){return Pu("id",r)}function Cu(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function _t(r,e){return ie.fromMiliseconds((e||Date.now())+ie.toMiliseconds(r))}function Ci(r){return Date.now()>=ie.toMiliseconds(r)}function Ye(r,e){return`${r}${e?`:${e}`:""}`}function um(r=[],e=[]){return[...new Set([...r,...e])]}async function dm({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;const o=lm(s,r,e),f=Pr();if(f===Kt.browser){if(!((i=Hn())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,gm()?"_blank":"_self","noreferrer noopener")}else f===Kt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function lm(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${bm(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function pm(r,e){let t="";try{if(ns()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Tu(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Fu(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Zo(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function gm(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function bm(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Bu(r){return Buffer.from(r,"base64").toString("utf-8")}function vm(r){return new Promise(e=>setTimeout(e,r))}const mm="https://rpc.walletconnect.org/v1";async function ym(r,e,t,i,n,s){switch(t.t){case"eip191":return wm(r,e,t.s);case"eip1271":return await _m(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function wm(r,e,t){return V2(Sh(e),t).toLowerCase()===r.toLowerCase()}async function _m(r,e,t,i,n,s){const o=ya(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=Sh(e).substring(2),I=f+y+u+h+g,M=await fetch(`${s||mm}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:xm(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:I},"latest"]})}),{result:D}=await M.json();return D?D.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function xm(){return Date.now()+Math.floor(Math.random()*1e3)}var Am=Object.defineProperty,Em=Object.defineProperties,Sm=Object.getOwnPropertyDescriptors,Lu=Object.getOwnPropertySymbols,Mm=Object.prototype.hasOwnProperty,Im=Object.prototype.propertyIsEnumerable,qu=(r,e,t)=>e in r?Am(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Dm=(r,e)=>{for(var t in e||(e={}))Mm.call(e,t)&&qu(r,t,e[t]);if(Lu)for(var t of Lu(e))Im.call(e,t)&&qu(r,t,e[t]);return r},Om=(r,e)=>Em(r,Sm(e));const Rm="did:pkh:",ef=r=>r?.split(":"),Nm=r=>{const e=r&&ef(r);if(e)return r.includes(Rm)?e[3]:e[1]},tf=r=>{const e=r&&ef(r);if(e)return e[2]+":"+e[3]},_a=r=>{const e=r&&ef(r);if(e)return e.pop()};async function Uu(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=$u(n,n.iss),o=_a(n.iss);return await ym(o,s,i,tf(n.iss),t)}const $u=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=_a(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${Nm(e)}`,u=`Nonce: ${r.nonce}`,h=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,I=r.requestId?`Request ID: ${r.requestId}`:void 0,M=r.resources?`Resources:${r.resources.map(P=>`
|
23
23
|
- ${P}`).join("")}`:void 0,D=xa(r.resources);if(D){const P=ss(D);n=$m(n,P)}return[t,i,"",n,"",s,o,f,u,h,g,y,I,M].filter(P=>P!=null).join(`
|
24
|
-
`)};function Pm(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function Cm(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Zi(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Tm(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Fm(e,t,i)}}}function Fm(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function zu(r){return Zi(r),`urn:recap:${Pm(r).replace(/=/g,"")}`}function ss(r){const e=Cm(r.replace("urn:recap:",""));return Zi(e),e}function Bm(r,e,t){const i=Tm(r,e,t);return zu(i)}function Lm(r){return r&&r.includes("urn:recap:")}function qm(r,e){const t=ss(r),i=ss(e),n=Um(t,i);return zu(n)}function Um(r,e){Zi(r),Zi(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,h;i.att[n]=Om(Dm({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((h=e.att[n])==null?void 0:h[f])})})}),i}function $m(r="",e){Zi(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(f=>{const u=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));u.sort((y,I)=>y.action.localeCompare(I.action));const h={};u.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});const g=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${f}'.`));i.push(g.join(", ").replace(".,","."))});const s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function ku(r){var e;const t=ss(r);Zi(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Ku(r){const e=ss(r);Zi(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function xa(r){if(!r)return;const e=r?.[r.length-1];return Lm(e)?e:void 0}const ju="base10",Jt="base16",Ti="base64pad",as="base64url",os="utf8",Hu=0,si=1,fs=2,zm=0,Vu=1,cs=12,rf=32;function km(){const r=zo.generateKeyPair();return{privateKey:At(r.secretKey,Jt),publicKey:At(r.publicKey,Jt)}}function nf(){const r=xi.randomBytes(rf);return At(r,Jt)}function Km(r,e){const t=zo.sharedKey(Et(r,Jt),Et(e,Jt),!0),i=new s3(ts.SHA256,t).expand(rf);return At(i,Jt)}function Aa(r){const e=ts.hash(Et(r,Jt));return At(e,Jt)}function ai(r){const e=ts.hash(Et(r,os));return At(e,Jt)}function Gu(r){return Et(`${r}`,ju)}function en(r){return Number(At(r,ju))}function jm(r){const e=Gu(typeof r.type<"u"?r.type:Hu);if(en(e)===si&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Et(r.senderPublicKey,Jt):void 0,i=typeof r.iv<"u"?Et(r.iv,Jt):xi.randomBytes(cs),n=new qo.ChaCha20Poly1305(Et(r.symKey,Jt)).seal(i,Et(r.message,os));return Wu({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Hm(r,e){const t=Gu(fs),i=xi.randomBytes(cs),n=Et(r,os);return Wu({type:t,sealed:n,iv:i,encoding:e})}function Vm(r){const e=new qo.ChaCha20Poly1305(Et(r.symKey,Jt)),{sealed:t,iv:i}=hs({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return At(n,os)}function Gm(r,e){const{sealed:t}=hs({encoded:r,encoding:e});return At(t,os)}function Wu(r){const{encoding:e=Ti}=r;if(en(r.type)===fs)return At(js([r.type,r.sealed]),e);if(en(r.type)===si){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return At(js([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return At(js([r.type,r.iv,r.sealed]),e)}function hs(r){const{encoded:e,encoding:t=Ti}=r,i=Et(e,t),n=i.slice(zm,Vu),s=Vu;if(en(n)===si){const h=s+rf,g=h+cs,y=i.slice(s,h),I=i.slice(h,g),M=i.slice(g);return{type:n,sealed:M,iv:I,senderPublicKey:y}}if(en(n)===fs){const h=i.slice(s),g=xi.randomBytes(cs);return{type:n,sealed:h,iv:g}}const o=s+cs,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Wm(r,e){const t=hs({encoded:r,encoding:e?.encoding});return Ju({type:en(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?At(t.senderPublicKey,Jt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Ju(r){const e=r?.type||Hu;if(e===si){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Yu(r){return r.type===si&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Qu(r){return r.type===fs}function Jm(r){return new cu.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function Ym(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function Qm(r){return Buffer.from(Ym(r),"base64")}function Xm(r,e){const[t,i,n]=r.split("."),s=Qm(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,h=new ts.SHA256().update(Buffer.from(u)).digest(),g=Jm(e),y=Buffer.from(h).toString("hex");if(!g.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return ho(r).payload}const Zm="irn";function Ea(r){return r?.relay||{protocol:Zm}}function us(r){const e=Y3[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var ey=Object.defineProperty,ty=Object.defineProperties,ry=Object.getOwnPropertyDescriptors,Xu=Object.getOwnPropertySymbols,iy=Object.prototype.hasOwnProperty,ny=Object.prototype.propertyIsEnumerable,Zu=(r,e,t)=>e in r?ey(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e0=(r,e)=>{for(var t in e||(e={}))iy.call(e,t)&&Zu(r,t,e[t]);if(Xu)for(var t of Xu(e))ny.call(e,t)&&Zu(r,t,e[t]);return r},sy=(r,e)=>ty(r,ry(e));function ay(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=r[n];t[s]=o}}),t}function t0(r){if(!r.includes("wc:")){const u=Bu(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Vn.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:oy(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:ay(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function oy(r){return r.startsWith("//")?r.substring(2):r}function fy(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const s=t+e+n;r[n]&&(i[s]=r[n])}),i}function r0(r){return`${r.protocol}:${r.topic}@${r.version}?`+Vn.stringify(e0(sy(e0({symKey:r.symKey},fy(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Sa(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Tn(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function cy(r){const e=[];return Object.values(r).forEach(t=>{e.push(...Tn(t.accounts))}),e}function hy(r,e){const t=[];return Object.values(r).forEach(i=>{Tn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function uy(r,e){const t=[];return Object.values(r).forEach(i=>{Tn(i.accounts).includes(e)&&t.push(...i.events)}),t}function dy(r){const e={};return r?.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function i0(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=dy(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=um(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const ly={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},py={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function se(r,e){const{message:t,code:i}=py[r];return{message:e?`${t} ${e}`:t,code:i}}function ct(r,e){const{message:t,code:i}=ly[r];return{message:e?`${t} ${e}`:t,code:i}}function Ma(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ia(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Yt(r){return typeof r>"u"}function mt(r,e){return e&&Yt(r)?!0:typeof r=="string"&&!!r.trim().length}function sf(r,e){return e&&Yt(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return Qi(n,i)?(i.forEach(o=>{const{accounts:f,methods:u,events:h}=r.namespaces[o],g=Tn(f),y=t[o];(!Qi(Au(o,y),g)||!Qi(y.methods,u)||!Qi(y.events,h))&&(s=!1)}),s):!1}function Da(r){return mt(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function by(r){if(mt(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Da(t)}}return!1}function vy(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(mt(r,!1)){if(e(r))return!0;const t=Bu(r);return e(t)}}catch{}return!1}function my(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function yy(r){return r?.topic}function wy(r,e){let t=null;return mt(r?.publicKey,!1)||(t=se("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function n0(r){let e=!0;return Ma(r)?r.length&&(e=r.every(t=>mt(t,!1))):e=!1,e}function _y(r,e,t){let i=null;return Ma(e)&&e.length?e.forEach(n=>{i||Da(n)||(i=ct("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Da(r)||(i=ct("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function xy(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=_y(n,Au(n,s),`${e} ${t}`);o&&(i=o)}),i}function Ay(r,e){let t=null;return Ma(r)?r.forEach(i=>{t||by(i)||(t=ct("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ct("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Ey(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Ay(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function Sy(r,e){let t=null;return n0(r?.methods)?n0(r?.events)||(t=ct("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ct("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function s0(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Sy(i,`${e}, namespace`);n&&(t=n)}),t}function My(r,e,t){let i=null;if(r&&Ia(r)){const n=s0(r,e);n&&(i=n);const s=xy(r,e,t);s&&(i=s)}else i=se("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function af(r,e){let t=null;if(r&&Ia(r)){const i=s0(r,e);i&&(t=i);const n=Ey(r,e);n&&(t=n)}else t=se("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function a0(r){return mt(r.protocol,!0)}function Iy(r,e){let t=!1;return e&&!r?t=!0:r&&Ma(r)&&r.length&&r.forEach(i=>{t=a0(i)}),t}function Dy(r){return typeof r=="number"}function rr(r){return typeof r<"u"&&typeof r!==null}function Oy(r){return!(!r||typeof r!="object"||!r.code||!sf(r.code,!1)||!r.message||!mt(r.message,!1))}function Ry(r){return!(Yt(r)||!mt(r.method,!1))}function Ny(r){return!(Yt(r)||Yt(r.result)&&Yt(r.error)||!sf(r.id,!1)||!mt(r.jsonrpc,!1))}function Py(r){return!(Yt(r)||!mt(r.name,!1))}function o0(r,e){return!(!Da(e)||!cy(r).includes(e))}function Cy(r,e,t){return mt(t,!1)?hy(r,e).includes(t):!1}function Ty(r,e,t){return mt(t,!1)?uy(r,e).includes(t):!1}function f0(r,e,t){let i=null;const n=Fy(r),s=By(e),o=Object.keys(n),f=Object.keys(s),u=c0(Object.keys(r)),h=c0(Object.keys(e)),g=u.filter(y=>!h.includes(y));return g.length&&(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
24
|
+
`)};function Pm(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function Cm(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Zi(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Tm(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Fm(e,t,i)}}}function Fm(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function zu(r){return Zi(r),`urn:recap:${Pm(r).replace(/=/g,"")}`}function ss(r){const e=Cm(r.replace("urn:recap:",""));return Zi(e),e}function Bm(r,e,t){const i=Tm(r,e,t);return zu(i)}function Lm(r){return r&&r.includes("urn:recap:")}function qm(r,e){const t=ss(r),i=ss(e),n=Um(t,i);return zu(n)}function Um(r,e){Zi(r),Zi(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,h;i.att[n]=Om(Dm({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((h=e.att[n])==null?void 0:h[f])})})}),i}function $m(r="",e){Zi(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(f=>{const u=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));u.sort((y,I)=>y.action.localeCompare(I.action));const h={};u.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});const g=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${f}'.`));i.push(g.join(", ").replace(".,","."))});const s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function ku(r){var e;const t=ss(r);Zi(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Ku(r){const e=ss(r);Zi(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function xa(r){if(!r)return;const e=r?.[r.length-1];return Lm(e)?e:void 0}const ju="base10",Jt="base16",Ti="base64pad",as="base64url",os="utf8",Hu=0,ai=1,fs=2,zm=0,Vu=1,cs=12,rf=32;function km(){const r=zo.generateKeyPair();return{privateKey:At(r.secretKey,Jt),publicKey:At(r.publicKey,Jt)}}function nf(){const r=Ai.randomBytes(rf);return At(r,Jt)}function Km(r,e){const t=zo.sharedKey(Et(r,Jt),Et(e,Jt),!0),i=new s3(ts.SHA256,t).expand(rf);return At(i,Jt)}function Aa(r){const e=ts.hash(Et(r,Jt));return At(e,Jt)}function oi(r){const e=ts.hash(Et(r,os));return At(e,Jt)}function Gu(r){return Et(`${r}`,ju)}function en(r){return Number(At(r,ju))}function jm(r){const e=Gu(typeof r.type<"u"?r.type:Hu);if(en(e)===ai&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Et(r.senderPublicKey,Jt):void 0,i=typeof r.iv<"u"?Et(r.iv,Jt):Ai.randomBytes(cs),n=new qo.ChaCha20Poly1305(Et(r.symKey,Jt)).seal(i,Et(r.message,os));return Wu({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Hm(r,e){const t=Gu(fs),i=Ai.randomBytes(cs),n=Et(r,os);return Wu({type:t,sealed:n,iv:i,encoding:e})}function Vm(r){const e=new qo.ChaCha20Poly1305(Et(r.symKey,Jt)),{sealed:t,iv:i}=hs({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return At(n,os)}function Gm(r,e){const{sealed:t}=hs({encoded:r,encoding:e});return At(t,os)}function Wu(r){const{encoding:e=Ti}=r;if(en(r.type)===fs)return At(js([r.type,r.sealed]),e);if(en(r.type)===ai){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return At(js([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return At(js([r.type,r.iv,r.sealed]),e)}function hs(r){const{encoded:e,encoding:t=Ti}=r,i=Et(e,t),n=i.slice(zm,Vu),s=Vu;if(en(n)===ai){const h=s+rf,g=h+cs,y=i.slice(s,h),I=i.slice(h,g),M=i.slice(g);return{type:n,sealed:M,iv:I,senderPublicKey:y}}if(en(n)===fs){const h=i.slice(s),g=Ai.randomBytes(cs);return{type:n,sealed:h,iv:g}}const o=s+cs,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Wm(r,e){const t=hs({encoded:r,encoding:e?.encoding});return Ju({type:en(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?At(t.senderPublicKey,Jt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Ju(r){const e=r?.type||Hu;if(e===ai){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Yu(r){return r.type===ai&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Qu(r){return r.type===fs}function Jm(r){return new cu.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function Ym(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function Qm(r){return Buffer.from(Ym(r),"base64")}function Xm(r,e){const[t,i,n]=r.split("."),s=Qm(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,h=new ts.SHA256().update(Buffer.from(u)).digest(),g=Jm(e),y=Buffer.from(h).toString("hex");if(!g.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return ho(r).payload}const Zm="irn";function Ea(r){return r?.relay||{protocol:Zm}}function us(r){const e=Y3[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var ey=Object.defineProperty,ty=Object.defineProperties,ry=Object.getOwnPropertyDescriptors,Xu=Object.getOwnPropertySymbols,iy=Object.prototype.hasOwnProperty,ny=Object.prototype.propertyIsEnumerable,Zu=(r,e,t)=>e in r?ey(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e0=(r,e)=>{for(var t in e||(e={}))iy.call(e,t)&&Zu(r,t,e[t]);if(Xu)for(var t of Xu(e))ny.call(e,t)&&Zu(r,t,e[t]);return r},sy=(r,e)=>ty(r,ry(e));function ay(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=r[n];t[s]=o}}),t}function t0(r){if(!r.includes("wc:")){const u=Bu(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Vn.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:oy(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:ay(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function oy(r){return r.startsWith("//")?r.substring(2):r}function fy(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const s=t+e+n;r[n]&&(i[s]=r[n])}),i}function r0(r){return`${r.protocol}:${r.topic}@${r.version}?`+Vn.stringify(e0(sy(e0({symKey:r.symKey},fy(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Sa(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Tn(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function cy(r){const e=[];return Object.values(r).forEach(t=>{e.push(...Tn(t.accounts))}),e}function hy(r,e){const t=[];return Object.values(r).forEach(i=>{Tn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function uy(r,e){const t=[];return Object.values(r).forEach(i=>{Tn(i.accounts).includes(e)&&t.push(...i.events)}),t}function dy(r){const e={};return r?.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function i0(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=dy(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=um(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const ly={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},py={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function se(r,e){const{message:t,code:i}=py[r];return{message:e?`${t} ${e}`:t,code:i}}function ct(r,e){const{message:t,code:i}=ly[r];return{message:e?`${t} ${e}`:t,code:i}}function Ma(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ia(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function Yt(r){return typeof r>"u"}function mt(r,e){return e&&Yt(r)?!0:typeof r=="string"&&!!r.trim().length}function sf(r,e){return e&&Yt(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return Qi(n,i)?(i.forEach(o=>{const{accounts:f,methods:u,events:h}=r.namespaces[o],g=Tn(f),y=t[o];(!Qi(Au(o,y),g)||!Qi(y.methods,u)||!Qi(y.events,h))&&(s=!1)}),s):!1}function Da(r){return mt(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function by(r){if(mt(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Da(t)}}return!1}function vy(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(mt(r,!1)){if(e(r))return!0;const t=Bu(r);return e(t)}}catch{}return!1}function my(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function yy(r){return r?.topic}function wy(r,e){let t=null;return mt(r?.publicKey,!1)||(t=se("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function n0(r){let e=!0;return Ma(r)?r.length&&(e=r.every(t=>mt(t,!1))):e=!1,e}function _y(r,e,t){let i=null;return Ma(e)&&e.length?e.forEach(n=>{i||Da(n)||(i=ct("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Da(r)||(i=ct("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function xy(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=_y(n,Au(n,s),`${e} ${t}`);o&&(i=o)}),i}function Ay(r,e){let t=null;return Ma(r)?r.forEach(i=>{t||by(i)||(t=ct("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ct("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Ey(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Ay(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function Sy(r,e){let t=null;return n0(r?.methods)?n0(r?.events)||(t=ct("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ct("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function s0(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Sy(i,`${e}, namespace`);n&&(t=n)}),t}function My(r,e,t){let i=null;if(r&&Ia(r)){const n=s0(r,e);n&&(i=n);const s=xy(r,e,t);s&&(i=s)}else i=se("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function af(r,e){let t=null;if(r&&Ia(r)){const i=s0(r,e);i&&(t=i);const n=Ey(r,e);n&&(t=n)}else t=se("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function a0(r){return mt(r.protocol,!0)}function Iy(r,e){let t=!1;return e&&!r?t=!0:r&&Ma(r)&&r.length&&r.forEach(i=>{t=a0(i)}),t}function Dy(r){return typeof r=="number"}function rr(r){return typeof r<"u"&&typeof r!==null}function Oy(r){return!(!r||typeof r!="object"||!r.code||!sf(r.code,!1)||!r.message||!mt(r.message,!1))}function Ry(r){return!(Yt(r)||!mt(r.method,!1))}function Ny(r){return!(Yt(r)||Yt(r.result)&&Yt(r.error)||!sf(r.id,!1)||!mt(r.jsonrpc,!1))}function Py(r){return!(Yt(r)||!mt(r.name,!1))}function o0(r,e){return!(!Da(e)||!cy(r).includes(e))}function Cy(r,e,t){return mt(t,!1)?hy(r,e).includes(t):!1}function Ty(r,e,t){return mt(t,!1)?uy(r,e).includes(t):!1}function f0(r,e,t){let i=null;const n=Fy(r),s=By(e),o=Object.keys(n),f=Object.keys(s),u=c0(Object.keys(r)),h=c0(Object.keys(e)),g=u.filter(y=>!h.includes(y));return g.length&&(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
25
25
|
Required: ${g.toString()}
|
26
26
|
Received: ${Object.keys(e).toString()}`)),Qi(o,f)||(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
|
27
27
|
Required: ${o.toString()}
|
28
28
|
Approved: ${f.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;const I=Tn(e[y].accounts);I.includes(y)||(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y}
|
29
29
|
Required: ${y}
|
30
|
-
Approved: ${I.toString()}`))}),o.forEach(y=>{i||(Qi(n[y].methods,s[y].methods)?Qi(n[y].events,s[y].events)||(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function Fy(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function c0(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function By(r){const e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Tn(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Ly(r,e){return sf(r,!1)&&r<=e.max&&r>=e.min}function h0(){const r=
|
30
|
+
Approved: ${I.toString()}`))}),o.forEach(y=>{i||(Qi(n[y].methods,s[y].methods)?Qi(n[y].events,s[y].events)||(i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=se("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function Fy(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function c0(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function By(r){const e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Tn(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Ly(r,e){return sf(r,!1)&&r<=e.max&&r>=e.min}function h0(){const r=Pr();return new Promise(e=>{switch(r){case Kt.browser:e(qy());break;case Kt.reactNative:e(Uy());break;case Kt.node:e($y());break;default:e(!0)}})}function qy(){return ns()&&navigator?.onLine}async function Uy(){return Ni()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function $y(){return!0}function zy(r){switch(Pr()){case Kt.browser:ky(r);break;case Kt.reactNative:Ky(r);break}}function ky(r){!Ni()&&ns()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function Ky(r){Ni()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}const of={};class ds{static get(e){return of[e]}static set(e,t){of[e]=t}static delete(e){delete of[e]}}const jy="PARSE_ERROR",Hy="INVALID_REQUEST",Vy="METHOD_NOT_FOUND",Gy="INVALID_PARAMS",u0="INTERNAL_ERROR",ff="SERVER_ERROR",Wy=[-32700,-32600,-32601,-32602,-32603],ls={[jy]:{code:-32700,message:"Parse error"},[Hy]:{code:-32600,message:"Invalid Request"},[Vy]:{code:-32601,message:"Method not found"},[Gy]:{code:-32602,message:"Invalid params"},[u0]:{code:-32603,message:"Internal error"},[ff]:{code:-32e3,message:"Server error"}},d0=ff;function Jy(r){return Wy.includes(r)}function l0(r){return Object.keys(ls).includes(r)?ls[r]:ls[d0]}function Yy(r){const e=Object.values(ls).find(t=>t.code===r);return e||ls[d0]}function Qy(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var p0={};/*! *****************************************************************************
|
31
31
|
Copyright (c) Microsoft Corporation.
|
32
32
|
|
33
33
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -40,5 +40,5 @@
|
|
40
40
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
41
41
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
42
42
|
PERFORMANCE OF THIS SOFTWARE.
|
43
|
-
***************************************************************************** */var cf=function(r,e){return cf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},cf(r,e)};function Xy(r,e){cf(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var hf=function(){return hf=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},hf.apply(this,arguments)};function Zy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function e6(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function t6(r,e){return function(t,i){e(t,i,r)}}function r6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function i6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(y){o(y)}}function u(g){try{h(i.throw(g))}catch(y){o(y)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function n6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function s6(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function a6(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function uf(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g0(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function o6(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(g0(arguments[e]));return r}function f6(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function ps(r){return this instanceof ps?(this.v=r,this):new ps(r)}function c6(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,P){s.push([I,M,D,P])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){y(s[0][3],D)}}function u(I){I.value instanceof ps?Promise.resolve(I.value.v).then(h,g):y(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function y(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function h6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:ps(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function u6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof uf=="function"?uf(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function d6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function l6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function p6(r){return r&&r.__esModule?r:{default:r}}function g6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function b6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var v6=Object.freeze({__proto__:null,__extends:Xy,get __assign(){return hf},__rest:Zy,__decorate:e6,__param:t6,__metadata:r6,__awaiter:i6,__generator:n6,__createBinding:s6,__exportStar:a6,__values:uf,__read:g0,__spread:o6,__spreadArrays:f6,__await:ps,__asyncGenerator:c6,__asyncDelegator:h6,__asyncValues:u6,__makeTemplateObject:d6,__importStar:l6,__importDefault:p6,__classPrivateFieldGet:g6,__classPrivateFieldSet:b6}),m6=Ua(v6),oi={},b0;function y6(){if(b0)return oi;b0=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowserCryptoAvailable=oi.getSubtleCrypto=oi.getBrowerCrypto=void 0;function r(){return Pt?.crypto||Pt?.msCrypto||{}}oi.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}oi.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return oi.isBrowserCryptoAvailable=t,oi}var fi={},v0;function w6(){if(v0)return fi;v0=1,Object.defineProperty(fi,"__esModule",{value:!0}),fi.isBrowser=fi.isNode=fi.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}fi.isReactNative=r;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}fi.isNode=e;function t(){return!r()&&!e()}return fi.isBrowser=t,fi}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=m6;e.__exportStar(y6(),r),e.__exportStar(w6(),r)})(p0);function ci(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function tn(r=6){return BigInt(ci(r))}function rn(r,e,t){return{id:t||ci(),jsonrpc:"2.0",method:r,params:e}}function df(r,e){return{id:r,jsonrpc:"2.0",result:e}}function lf(r,e,t){return{id:r,jsonrpc:"2.0",error:_6(e,t)}}function _6(r,e){return typeof r>"u"?l0(u0):(typeof r=="string"&&(r=Object.assign(Object.assign({},l0(ff)),{message:r})),typeof e<"u"&&(r.data=e),Jy(r.code)&&(r=Yy(r.code)),r)}class x6{}class A6 extends x6{constructor(){super()}}class E6 extends A6{constructor(e){super()}}const S6="^wss?:";function M6(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function I6(r,e){const t=M6(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function m0(r){return I6(r,S6)}function D6(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function y0(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function pf(r){return y0(r)&&"method"in r}function Oa(r){return y0(r)&&(Jr(r)||_r(r))}function Jr(r){return"result"in r}function _r(r){return"error"in r}class O6 extends E6{constructor(e){super(e),this.events=new Ut.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(rn(e.method,e.params||[],e.id||tn().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{_r(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Oa(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const R6=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),N6=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",w0=r=>r.split("?")[0],_0=10,P6=R6();class C6{constructor(e){if(this.url=e,this.events=new Ut.exports.EventEmitter,this.registering=!1,!m0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(ki(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!m0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=p0.isReactNative()?void 0:{rejectUnauthorized:!D6(e)},s=new P6(e,[],n);N6()?s.onerror=o=>{const f=o;i(this.emitError(f.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),t(s)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ln(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=lf(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Qy(e,w0(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>_0&&this.events.setMaxListeners(_0)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${w0(this.url)}`));return this.events.emit("register_error",t),t}}var gf={exports:{}};(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,f="[object Arguments]",u="[object Array]",h="[object AsyncFunction]",g="[object Boolean]",y="[object Date]",I="[object Error]",M="[object Function]",D="[object GeneratorFunction]",P="[object Map]",k="[object Number]",K="[object Null]",C="[object Object]",j="[object Promise]",F="[object Proxy]",U="[object RegExp]",z="[object Set]",_="[object String]",R="[object Symbol]",J="[object Undefined]",Q="[object WeakMap]",N="[object ArrayBuffer]",p="[object DataView]",l="[object Float32Array]",a="[object Float64Array]",c="[object Int8Array]",b="[object Int16Array]",A="[object Int32Array]",E="[object Uint8Array]",x="[object Uint8ClampedArray]",d="[object Uint16Array]",w="[object Uint32Array]",v=/[\\^$.*+?()[\]{}|]/g,O=/^\[object .+?Constructor\]$/,W=/^(?:0|[1-9]\d*)$/,S={};S[l]=S[a]=S[c]=S[b]=S[A]=S[E]=S[x]=S[d]=S[w]=!0,S[f]=S[u]=S[N]=S[g]=S[p]=S[y]=S[I]=S[M]=S[P]=S[k]=S[C]=S[U]=S[z]=S[_]=S[Q]=!1;var H=typeof Pt=="object"&&Pt&&Pt.Object===Object&&Pt,T=typeof self=="object"&&self&&self.Object===Object&&self,q=H||T||Function("return this")(),B=e&&!e.nodeType&&e,m=B&&!0&&r&&!r.nodeType&&r,L=m&&m.exports===B,G=L&&H.process,Y=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),X=Y&&Y.isTypedArray;function ee($,V){for(var Z=-1,be=$==null?0:$.length,ut=0,Ge=[];++Z<be;){var bt=$[Z];V(bt,Z,$)&&(Ge[ut++]=bt)}return Ge}function we($,V){for(var Z=-1,be=V.length,ut=$.length;++Z<be;)$[ut+Z]=V[Z];return $}function Se($,V){for(var Z=-1,be=$==null?0:$.length;++Z<be;)if(V($[Z],Z,$))return!0;return!1}function he($,V){for(var Z=-1,be=Array($);++Z<$;)be[Z]=V(Z);return be}function Ne($){return function(V){return $(V)}}function xe($,V){return $.has(V)}function ae($,V){return $?.[V]}function ve($){var V=-1,Z=Array($.size);return $.forEach(function(be,ut){Z[++V]=[ut,be]}),Z}function le($,V){return function(Z){return $(V(Z))}}function ne($){var V=-1,Z=Array($.size);return $.forEach(function(be){Z[++V]=be}),Z}var ue=Array.prototype,fe=Function.prototype,te=Object.prototype,pe=q["__core-js_shared__"],_e=fe.toString,re=te.hasOwnProperty,Ae=function(){var $=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),Ee=te.toString,oe=RegExp("^"+_e.call(re).replace(v,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=L?q.Buffer:void 0,Me=q.Symbol,Oe=q.Uint8Array,We=te.propertyIsEnumerable,Qe=ue.splice,Ie=Me?Me.toStringTag:void 0,et=Object.getOwnPropertySymbols,tt=De?De.isBuffer:void 0,Pe=le(Object.keys,Object),Te=Bn(q,"DataView"),Ce=Bn(q,"Map"),de=Bn(q,"Promise"),Fe=Bn(q,"Set"),Be=Bn(q,"WeakMap"),ce=Bn(Object,"create"),Ue=fn(Te),$e=fn(Ce),me=fn(de),ze=fn(Fe),ke=fn(Be),ge=Me?Me.prototype:void 0,Le=ge?ge.valueOf:void 0;function Re($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function ye(){this.__data__=ce?ce(null):{},this.size=0}function Ke($){var V=this.has($)&&delete this.__data__[$];return this.size-=V?1:0,V}function it($){var V=this.__data__;if(ce){var Z=V[$];return Z===i?void 0:Z}return re.call(V,$)?V[$]:void 0}function qe($){var V=this.__data__;return ce?V[$]!==void 0:re.call(V,$)}function nt($,V){var Z=this.__data__;return this.size+=this.has($)?0:1,Z[$]=ce&&V===void 0?i:V,this}Re.prototype.clear=ye,Re.prototype.delete=Ke,Re.prototype.get=it,Re.prototype.has=qe,Re.prototype.set=nt;function Je($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function rt(){this.__data__=[],this.size=0}function ir($){var V=this.__data__,Z=Ta(V,$);if(Z<0)return!1;var be=V.length-1;return Z==be?V.pop():Qe.call(V,Z,1),--this.size,!0}function nr($){var V=this.__data__,Z=Ta(V,$);return Z<0?void 0:V[Z][1]}function sr($){return Ta(this.__data__,$)>-1}function ar($,V){var Z=this.__data__,be=Ta(Z,$);return be<0?(++this.size,Z.push([$,V])):Z[be][1]=V,this}Je.prototype.clear=rt,Je.prototype.delete=ir,Je.prototype.get=nr,Je.prototype.has=sr,Je.prototype.set=ar;function yt($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function ui(){this.size=0,this.__data__={hash:new Re,map:new(Ce||Je),string:new Re}}function di($){var V=Fa(this,$).delete($);return this.size-=V?1:0,V}function li($){return Fa(this,$).get($)}function pi($){return Fa(this,$).has($)}function gi($,V){var Z=Fa(this,$),be=Z.size;return Z.set($,V),this.size+=Z.size==be?0:1,this}yt.prototype.clear=ui,yt.prototype.delete=di,yt.prototype.get=li,yt.prototype.has=pi,yt.prototype.set=gi;function Er($){var V=-1,Z=$==null?0:$.length;for(this.__data__=new yt;++V<Z;)this.add($[V])}function bi($){return this.__data__.set($,i),this}function vi($){return this.__data__.has($)}Er.prototype.add=Er.prototype.push=bi,Er.prototype.has=vi;function jt($){var V=this.__data__=new Je($);this.size=V.size}function mi(){this.__data__=new Je,this.size=0}function yi($){var V=this.__data__,Z=V.delete($);return this.size=V.size,Z}function wi($){return this.__data__.get($)}function _s($){return this.__data__.has($)}function xs($,V){var Z=this.__data__;if(Z instanceof Je){var be=Z.__data__;if(!Ce||be.length<t-1)return be.push([$,V]),this.size=++Z.size,this;Z=this.__data__=new yt(be)}return Z.set($,V),this.size=Z.size,this}jt.prototype.clear=mi,jt.prototype.delete=yi,jt.prototype.get=wi,jt.prototype.has=_s,jt.prototype.set=xs;function t4($,V){var Z=Ba($),be=!Z&&b4($),ut=!Z&&!be&&Df($),Ge=!Z&&!be&&!ut&&Rd($),bt=Z||be||ut||Ge,Nt=bt?he($.length,String):[],qt=Nt.length;for(var dt in $)(V||re.call($,dt))&&!(bt&&(dt=="length"||ut&&(dt=="offset"||dt=="parent")||Ge&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||u4(dt,qt)))&&Nt.push(dt);return Nt}function Ta($,V){for(var Z=$.length;Z--;)if(Md($[Z][0],V))return Z;return-1}function r4($,V,Z){var be=V($);return Ba($)?be:we(be,Z($))}function As($){return $==null?$===void 0?J:K:Ie&&Ie in Object($)?c4($):g4($)}function xd($){return Es($)&&As($)==f}function Ad($,V,Z,be,ut){return $===V?!0:$==null||V==null||!Es($)&&!Es(V)?$!==$&&V!==V:i4($,V,Z,be,Ad,ut)}function i4($,V,Z,be,ut,Ge){var bt=Ba($),Nt=Ba(V),qt=bt?u:Fi($),dt=Nt?u:Fi(V);qt=qt==f?C:qt,dt=dt==f?C:dt;var lr=qt==C,Fr=dt==C,Ht=qt==dt;if(Ht&&Df($)){if(!Df(V))return!1;bt=!0,lr=!1}if(Ht&&!lr)return Ge||(Ge=new jt),bt||Rd($)?Ed($,V,Z,be,ut,Ge):o4($,V,qt,Z,be,ut,Ge);if(!(Z&n)){var Sr=lr&&re.call($,"__wrapped__"),Mr=Fr&&re.call(V,"__wrapped__");if(Sr||Mr){var Bi=Sr?$.value():$,_i=Mr?V.value():V;return Ge||(Ge=new jt),ut(Bi,_i,Z,be,Ge)}}return Ht?(Ge||(Ge=new jt),f4($,V,Z,be,ut,Ge)):!1}function n4($){if(!Od($)||l4($))return!1;var V=Id($)?oe:O;return V.test(fn($))}function s4($){return Es($)&&Dd($.length)&&!!S[As($)]}function a4($){if(!p4($))return Pe($);var V=[];for(var Z in Object($))re.call($,Z)&&Z!="constructor"&&V.push(Z);return V}function Ed($,V,Z,be,ut,Ge){var bt=Z&n,Nt=$.length,qt=V.length;if(Nt!=qt&&!(bt&&qt>Nt))return!1;var dt=Ge.get($);if(dt&&Ge.get(V))return dt==V;var lr=-1,Fr=!0,Ht=Z&s?new Er:void 0;for(Ge.set($,V),Ge.set(V,$);++lr<Nt;){var Sr=$[lr],Mr=V[lr];if(be)var Bi=bt?be(Mr,Sr,lr,V,$,Ge):be(Sr,Mr,lr,$,V,Ge);if(Bi!==void 0){if(Bi)continue;Fr=!1;break}if(Ht){if(!Se(V,function(_i,cn){if(!xe(Ht,cn)&&(Sr===_i||ut(Sr,_i,Z,be,Ge)))return Ht.push(cn)})){Fr=!1;break}}else if(!(Sr===Mr||ut(Sr,Mr,Z,be,Ge))){Fr=!1;break}}return Ge.delete($),Ge.delete(V),Fr}function o4($,V,Z,be,ut,Ge,bt){switch(Z){case p:if($.byteLength!=V.byteLength||$.byteOffset!=V.byteOffset)return!1;$=$.buffer,V=V.buffer;case N:return!($.byteLength!=V.byteLength||!Ge(new Oe($),new Oe(V)));case g:case y:case k:return Md(+$,+V);case I:return $.name==V.name&&$.message==V.message;case U:case _:return $==V+"";case P:var Nt=ve;case z:var qt=be&n;if(Nt||(Nt=ne),$.size!=V.size&&!qt)return!1;var dt=bt.get($);if(dt)return dt==V;be|=s,bt.set($,V);var lr=Ed(Nt($),Nt(V),be,ut,Ge,bt);return bt.delete($),lr;case R:if(Le)return Le.call($)==Le.call(V)}return!1}function f4($,V,Z,be,ut,Ge){var bt=Z&n,Nt=Sd($),qt=Nt.length,dt=Sd(V),lr=dt.length;if(qt!=lr&&!bt)return!1;for(var Fr=qt;Fr--;){var Ht=Nt[Fr];if(!(bt?Ht in V:re.call(V,Ht)))return!1}var Sr=Ge.get($);if(Sr&&Ge.get(V))return Sr==V;var Mr=!0;Ge.set($,V),Ge.set(V,$);for(var Bi=bt;++Fr<qt;){Ht=Nt[Fr];var _i=$[Ht],cn=V[Ht];if(be)var Nd=bt?be(cn,_i,Ht,V,$,Ge):be(_i,cn,Ht,$,V,Ge);if(!(Nd===void 0?_i===cn||ut(_i,cn,Z,be,Ge):Nd)){Mr=!1;break}Bi||(Bi=Ht=="constructor")}if(Mr&&!Bi){var La=$.constructor,qa=V.constructor;La!=qa&&"constructor"in $&&"constructor"in V&&!(typeof La=="function"&&La instanceof La&&typeof qa=="function"&&qa instanceof qa)&&(Mr=!1)}return Ge.delete($),Ge.delete(V),Mr}function Sd($){return r4($,y4,h4)}function Fa($,V){var Z=$.__data__;return d4(V)?Z[typeof V=="string"?"string":"hash"]:Z.map}function Bn($,V){var Z=ae($,V);return n4(Z)?Z:void 0}function c4($){var V=re.call($,Ie),Z=$[Ie];try{$[Ie]=void 0;var be=!0}catch{}var ut=Ee.call($);return be&&(V?$[Ie]=Z:delete $[Ie]),ut}var h4=et?function($){return $==null?[]:($=Object($),ee(et($),function(V){return We.call($,V)}))}:w4,Fi=As;(Te&&Fi(new Te(new ArrayBuffer(1)))!=p||Ce&&Fi(new Ce)!=P||de&&Fi(de.resolve())!=j||Fe&&Fi(new Fe)!=z||Be&&Fi(new Be)!=Q)&&(Fi=function($){var V=As($),Z=V==C?$.constructor:void 0,be=Z?fn(Z):"";if(be)switch(be){case Ue:return p;case $e:return P;case me:return j;case ze:return z;case ke:return Q}return V});function u4($,V){return V=V??o,!!V&&(typeof $=="number"||W.test($))&&$>-1&&$%1==0&&$<V}function d4($){var V=typeof $;return V=="string"||V=="number"||V=="symbol"||V=="boolean"?$!=="__proto__":$===null}function l4($){return!!Ae&&Ae in $}function p4($){var V=$&&$.constructor,Z=typeof V=="function"&&V.prototype||te;return $===Z}function g4($){return Ee.call($)}function fn($){if($!=null){try{return _e.call($)}catch{}try{return $+""}catch{}}return""}function Md($,V){return $===V||$!==$&&V!==V}var b4=xd(function(){return arguments}())?xd:function($){return Es($)&&re.call($,"callee")&&!We.call($,"callee")},Ba=Array.isArray;function v4($){return $!=null&&Dd($.length)&&!Id($)}var Df=tt||_4;function m4($,V){return Ad($,V)}function Id($){if(!Od($))return!1;var V=As($);return V==M||V==D||V==h||V==F}function Dd($){return typeof $=="number"&&$>-1&&$%1==0&&$<=o}function Od($){var V=typeof $;return $!=null&&(V=="object"||V=="function")}function Es($){return $!=null&&typeof $=="object"}var Rd=X?Ne(X):s4;function y4($){return v4($)?t4($):a4($)}function w4(){return[]}function _4(){return!1}r.exports=m4})(gf,gf.exports);var T6=gf.exports;const x0="wc",A0=2,Ra="core",Yr=`${x0}@2:${Ra}:`,F6={name:Ra,logger:"error"},B6={database:":memory:"},L6="crypto",E0="client_ed25519_seed",q6=ie.ONE_DAY,U6="keychain",$6="0.3",z6="messages",k6="0.3",S0=ie.SIX_HOURS,K6="publisher",M0="irn",j6="error",I0="wss://relay.walletconnect.org",H6="relayer",Ot={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},V6="_subscription",xr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},G6=.1,bf="2.17.3",ht={link_mode:"link_mode",relay:"relay"},W6="0.3",J6="WALLETCONNECT_CLIENT_ID",D0="WALLETCONNECT_LINK_MODE_APPS",dr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Y6="subscription",Q6="0.3",X6=ie.FIVE_SECONDS*1e3,Z6="pairing",ew="0.3",gs={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},nn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Pr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},tw="history",rw="0.3",iw="expirer",Ar={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},nw="0.3",sw="verify-api",aw="https://verify.walletconnect.com",O0="https://verify.walletconnect.org",bs=O0,ow=`${bs}/v3`,fw=[aw,O0],cw="echo",hw="https://echo.walletconnect.com",Qr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},hi={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Cr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},sn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},an={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},vs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},uw=.1,dw="event-client",lw=86400,pw="https://pulse.walletconnect.org/batch";function gw(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function y(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var P=0,k=0,K=0,C=D.length;K!==C&&D[K]===0;)K++,P++;for(var j=(C-K)*g+1>>>0,F=new Uint8Array(j);K!==C;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var R=j-k;R!==j&&F[R]===0;)R++;for(var J=u.repeat(P);R<j;++R)J+=r.charAt(F[R]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var P=0;if(D[P]!==" "){for(var k=0,K=0;D[P]===u;)k++,P++;for(var C=(D.length-P)*h+1>>>0,j=new Uint8Array(C);D[P];){var F=t[D.charCodeAt(P)];if(F===255)return;for(var U=0,z=C-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,P++}if(D[P]!==" "){for(var _=C-K;_!==C&&j[_]===0;)_++;for(var R=new Uint8Array(k+(C-_)),J=k;_!==C;)R[J++]=j[_++];return R}}}function M(D){var P=I(D);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:I,decode:M}}var bw=gw,vw=bw;const R0=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},mw=r=>new TextEncoder().encode(r),yw=r=>new TextDecoder().decode(r);class ww{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class _w{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return N0(this,e)}}class xw{constructor(e){this.decoders=e}or(e){return N0(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const N0=(r,e)=>new xw({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class Aw{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ww(e,t,i),this.decoder=new _w(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Na=({name:r,prefix:e,encode:t,decode:i})=>new Aw(r,e,t,i),ms=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=vw(t,e);return Na({prefix:r,name:e,encode:i,decode:s=>R0(n(s))})},Ew=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const y=n[r[g]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|y,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},Sw=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Lt=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Na({prefix:e,name:r,encode(n){return Sw(n,i,t)},decode(n){return Ew(n,i,t,r)}}),Mw=Na({prefix:"\0",name:"identity",encode:r=>yw(r),decode:r=>mw(r)});var Iw=Object.freeze({__proto__:null,identity:Mw});const Dw=Lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ow=Object.freeze({__proto__:null,base2:Dw});const Rw=Lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nw=Object.freeze({__proto__:null,base8:Rw});const Pw=ms({prefix:"9",name:"base10",alphabet:"0123456789"});var Cw=Object.freeze({__proto__:null,base10:Pw});const Tw=Lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fw=Lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bw=Object.freeze({__proto__:null,base16:Tw,base16upper:Fw});const Lw=Lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qw=Lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Uw=Lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$w=Lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zw=Lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kw=Lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kw=Lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jw=Lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hw=Lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vw=Object.freeze({__proto__:null,base32:Lw,base32upper:qw,base32pad:Uw,base32padupper:$w,base32hex:zw,base32hexupper:kw,base32hexpad:Kw,base32hexpadupper:jw,base32z:Hw});const Gw=ms({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ww=ms({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Jw=Object.freeze({__proto__:null,base36:Gw,base36upper:Ww});const Yw=ms({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qw=ms({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xw=Object.freeze({__proto__:null,base58btc:Yw,base58flickr:Qw});const Zw=Lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),e5=Lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),t5=Lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),r5=Lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var i5=Object.freeze({__proto__:null,base64:Zw,base64pad:e5,base64url:t5,base64urlpad:r5});const P0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),n5=P0.reduce((r,e,t)=>(r[t]=e,r),[]),s5=P0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function a5(r){return r.reduce((e,t)=>(e+=n5[t],e),"")}function o5(r){const e=[];for(const t of r){const i=s5[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const f5=Na({prefix:"\u{1F680}",name:"base256emoji",encode:a5,decode:o5});var c5=Object.freeze({__proto__:null,base256emoji:f5}),h5=T0,C0=128,u5=127,d5=~u5,l5=Math.pow(2,31);function T0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=l5;)e[t++]=r&255|C0,r/=128;for(;r&d5;)e[t++]=r&255|C0,r>>>=7;return e[t]=r|0,T0.bytes=t-i+1,e}var p5=vf,g5=128,F0=127;function vf(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vf.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&F0)<<n:(o&F0)*Math.pow(2,n),n+=7}while(o>=g5);return vf.bytes=s-i,t}var b5=Math.pow(2,7),v5=Math.pow(2,14),m5=Math.pow(2,21),y5=Math.pow(2,28),w5=Math.pow(2,35),_5=Math.pow(2,42),x5=Math.pow(2,49),A5=Math.pow(2,56),E5=Math.pow(2,63),S5=function(r){return r<b5?1:r<v5?2:r<m5?3:r<y5?4:r<w5?5:r<_5?6:r<x5?7:r<A5?8:r<E5?9:10},M5={encode:h5,decode:p5,encodingLength:S5},B0=M5;const L0=(r,e,t=0)=>(B0.encode(r,e,t),e),q0=r=>B0.encodingLength(r),mf=(r,e)=>{const t=e.byteLength,i=q0(r),n=i+q0(t),s=new Uint8Array(n+t);return L0(r,s,0),L0(t,s,i),s.set(e,n),new I5(r,t,e,s)};class I5{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const U0=({name:r,code:e,encode:t})=>new D5(r,e,t);class D5{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?mf(this.code,t):t.then(i=>mf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const $0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),O5=U0({name:"sha2-256",code:18,encode:$0("SHA-256")}),R5=U0({name:"sha2-512",code:19,encode:$0("SHA-512")});var N5=Object.freeze({__proto__:null,sha256:O5,sha512:R5});const z0=0,P5="identity",k0=R0;var C5=Object.freeze({__proto__:null,identity:{code:z0,name:P5,encode:k0,digest:r=>mf(z0,k0(r))}});new TextEncoder,new TextDecoder;const K0={...Iw,...Ow,...Nw,...Cw,...Bw,...Vw,...Jw,...Xw,...i5,...c5};({...N5,...C5});function T5(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function j0(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const H0=j0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),yf=j0("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=T5(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),F5={utf8:H0,"utf-8":H0,hex:K0.base16,latin1:yf,ascii:yf,binary:yf,...K0};function B5(r,e="utf8"){const t=F5[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class L5{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=U6,this.version=$6,this.initialized=!1,this.storagePrefix=Yr,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=se("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Ru(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class q5{constructor(e,t,i){this.core=e,this.logger=t,this.name=L6,this.randomSessionIdentifier=nf(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Kc(n);return kc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=km();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Kc(s),f=this.randomSessionIdentifier;return await Kg(f,n,q6,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const f=this.getPrivateKey(n),u=Km(f,s);return this.setSymKey(u,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Aa(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const f=Ju(o),u=ki(s);if(Qu(f))return Hm(u,o?.encoding);if(Yu(f)){const I=f.senderPublicKey,M=f.receiverPublicKey;n=await this.generateSharedKey(I,M)}const h=this.getSymKey(n),{type:g,senderPublicKey:y}=f;return jm({type:g,symKey:h,message:u,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const f=Wm(s,o);if(Qu(f)){const u=Gm(s,o?.encoding);return ln(u)}if(Yu(f)){const u=f.receiverPublicKey,h=f.senderPublicKey;n=await this.generateSharedKey(u,h)}try{const u=this.getSymKey(n),h=Vm({symKey:u,encoded:s,encoding:o?.encoding});return ln(h)}catch(u){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(n,s=Ti)=>{const o=hs({encoded:n,encoding:s});return en(o.type)},this.getPayloadSenderPublicKey=(n,s=Ti)=>{const o=hs({encoded:n,encoding:s});return o.senderPublicKey?At(o.senderPublicKey,Jt):void 0},this.core=e,this.logger=Vt(t,this.name),this.keychain=i||new L5(this.core,this.logger)}get context(){return Xt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(E0)}catch{e=nf(),await this.keychain.set(E0,e)}return B5(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class U5 extends Sp{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=z6,this.version=k6,this.initialized=!1,this.storagePrefix=Yr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=ai(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=ai(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Vt(e,this.name),this.core=t}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Ru(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}var $5=Object.defineProperty,z5=Object.defineProperties,k5=Object.getOwnPropertyDescriptors,V0=Object.getOwnPropertySymbols,K5=Object.prototype.hasOwnProperty,j5=Object.prototype.propertyIsEnumerable,G0=(r,e,t)=>e in r?$5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,W0=(r,e)=>{for(var t in e||(e={}))K5.call(e,t)&&G0(r,t,e[t]);if(V0)for(var t of V0(e))j5.call(e,t)&&G0(r,t,e[t]);return r},J0=(r,e)=>z5(r,k5(e));class H5 extends Mp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ut.exports.EventEmitter,this.name=K6,this.queue=new Map,this.publishTimeout=ie.toMiliseconds(ie.ONE_MINUTE),this.initialPublishTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const f=s?.ttl||S0,u=Ea(s),h=s?.prompt||!1,g=s?.tag||0,y=s?.id||tn().toString(),I={topic:i,message:n,opts:{ttl:f,relay:u,prompt:h,tag:g,id:y,attestation:s?.attestation}},M=`Failed to publish payload, please try again. id:${y} tag:${g}`;try{const D=new Promise(async P=>{const k=({id:C})=>{I.opts.id===C&&(this.removeRequestFromQueue(C),this.relayer.events.removeListener(Ot.publish,k),P(I))};this.relayer.events.on(Ot.publish,k);const K=Pi(new Promise((C,j)=>{this.rpcPublish({topic:i,message:n,ttl:f,prompt:h,tag:g,id:y,attestation:s?.attestation}).then(C).catch(F=>{this.logger.warn(F,F?.message),j(F)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${y} tag:${g}`);try{await K,this.events.removeListener(Ot.publish,k)}catch(C){this.queue.set(y,J0(W0({},I),{attempt:1})),this.logger.warn(C,C?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}}),await Pi(D,this.publishTimeout,M)}catch(D){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(D),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw D}finally{this.queue.delete(y)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Vt(t,this.name),this.registerEventListeners()}get context(){return Xt(this.logger)}async rpcPublish(e){var t,i,n,s;const{topic:o,message:f,ttl:u=S0,prompt:h,tag:g,id:y,attestation:I}=e,M={method:us(Ea().protocol).publish,params:{topic:o,message:f,ttl:u,prompt:h,tag:g,attestation:I},id:y};Yt((t=M.params)==null?void 0:t.prompt)&&((i=M.params)==null||delete i.prompt),Yt((n=M.params)==null?void 0:n.tag)&&((s=M.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:M});const D=await this.relayer.request(M);return this.relayer.events.emit(Ot.publish,e),this.logger.debug("Successfully Published Payload"),D}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,J0(W0({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:f}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:f}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ot.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ot.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class V5{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var G5=Object.defineProperty,W5=Object.defineProperties,J5=Object.getOwnPropertyDescriptors,Y0=Object.getOwnPropertySymbols,Y5=Object.prototype.hasOwnProperty,Q5=Object.prototype.propertyIsEnumerable,Q0=(r,e,t)=>e in r?G5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ys=(r,e)=>{for(var t in e||(e={}))Y5.call(e,t)&&Q0(r,t,e[t]);if(Y0)for(var t of Y0(e))Q5.call(e,t)&&Q0(r,t,e[t]);return r},wf=(r,e)=>W5(r,J5(e));class X5 extends Op{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new V5,this.events=new Ut.exports.EventEmitter,this.name=Y6,this.version=Q6,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Yr,this.subscribeTimeout=ie.toMiliseconds(ie.ONE_MINUTE),this.initialSubscribeTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=Ea(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const f=new ie.Watch;f.start(n);const u=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(h=>h.topic===i))&&(clearInterval(u),f.stop(n),s(!0)),f.elapsed(n)>=X6&&(clearInterval(u),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(dn.pulse,async()=>{await this.checkPending()}),this.events.on(dr.created,async i=>{const n=dr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(dr.deleted,async i=>{const n=dr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=Vt(t,this.name),this.clientId=""}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=Ea(i);await this.rpcUnsubscribe(e,t,n);const s=ct("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===ht.relay&&await this.restartToComplete();const s={method:us(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const f=this.getSubscriptionId(e);if(i?.transportType===ht.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(g=>this.logger.warn(g))},ie.toMiliseconds(ie.ONE_SECOND)),f;const u=new Promise(async g=>{const y=I=>{I.topic===e&&(this.events.removeListener(dr.created,y),g(I.id))};this.events.on(dr.created,y);try{const I=await Pi(new Promise((M,D)=>{this.relayer.request(s).catch(P=>{this.logger.warn(P,P?.message),D(P)}).then(M)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(dr.created,y),g(I)}catch{}}),h=await Pi(u,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ot.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:us(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Pi(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ot.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:us(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Pi(new Promise((s,o)=>{this.relayer.request(i).catch(f=>{this.logger.warn(f),o(f)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ot.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:us(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,wf(ys({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ys({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ys({},t)),this.topicMap.set(t.topic,e),this.events.emit(dr.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(dr.deleted,wf(ys({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(dr.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(dr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(e.map(t=>wf(ys({},t),{id:this.getSubscriptionId(t.topic)}))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await vm(ie.toMiliseconds(ie.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return ai(e+this.clientId)}}var Z5=Object.defineProperty,X0=Object.getOwnPropertySymbols,e8=Object.prototype.hasOwnProperty,t8=Object.prototype.propertyIsEnumerable,Z0=(r,e,t)=>e in r?Z5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ed=(r,e)=>{for(var t in e||(e={}))e8.call(e,t)&&Z0(r,t,e[t]);if(X0)for(var t of X0(e))t8.call(e,t)&&Z0(r,t,e[t]);return r};class r8 extends Ip{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ut.exports.EventEmitter,this.name=H6,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=ie.toMiliseconds(ie.THIRTY_SECONDS+ie.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||tn().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=t.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const f=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(u=>u!==o),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}},this.resetPingTimeout=()=>{if(wa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t?.message)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Ot.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.fatal(t,`Fatal socket error: ${t?.message}`),this.events.emit(Ot.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xr.payload,this.onPayloadHandler),this.provider.on(xr.connect,this.onConnectHandler),this.provider.on(xr.disconnect,this.onDisconnectHandler),this.provider.on(xr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Vt(e.logger,this.name):Zr(to({level:e.logger||j6})),this.messages=new U5(this.logger,e.core),this.subscriber=new X5(this,this.logger),this.publisher=new H5(this,this.logger),this.relayUrl=e?.relayUrl||I0,this.projectId=e.projectId,im()?this.packageName=Iu():nm()&&(this.bundleId=Iu()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return Xt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ht.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),(!(t!=null&&t.transportType)||t?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish;let f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u;const h=g=>{g.topic===e&&(this.subscriber.off(dr.created,h),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(dr.created,h)}),new Promise(async(g,y)=>{f=await this.subscriber.subscribe(e,ed({internal:{throwOnFailedPublish:o}},t)).catch(I=>{o&&y(I)})||f,g()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Pi(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await h0())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=_t(ie.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ot.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(xr.disconnect,s),await Pi(new Promise((o,f)=>{this.provider.connect().then(o).catch(f)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(xr.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,f)=>{const u=()=>{f(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(xr.disconnect,u),await this.subscriber.start().then(o).catch(f).finally(()=>{this.provider.off(xr.disconnect,u)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,ie.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,n,s;if(wa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new O6(new C6(fm({sdkVersion:bf,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),pf(e)){if(!e.method.endsWith(V6))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:ht.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(ed({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Oa(e)&&this.events.emit(Ot.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ot.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=df(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(xr.payload,this.onPayloadHandler),this.provider.off(xr.connect,this.onConnectHandler),this.provider.off(xr.disconnect,this.onDisconnectHandler),this.provider.off(xr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await h0();zy(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(Ot.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e?.message))},ie.toMiliseconds(G6))))}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var i8=Object.defineProperty,td=Object.getOwnPropertySymbols,n8=Object.prototype.hasOwnProperty,s8=Object.prototype.propertyIsEnumerable,rd=(r,e,t)=>e in r?i8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,id=(r,e)=>{for(var t in e||(e={}))n8.call(e,t)&&rd(r,t,e[t]);if(td)for(var t of td(e))s8.call(e,t)&&rd(r,t,e[t]);return r};class on extends Dp{constructor(e,t,i,n=Yr,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=W6,this.cached=[],this.initialized=!1,this.storagePrefix=Yr,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Yt(o)?this.map.set(this.getKey(o),o):my(o)?this.map.set(o.id,o):yy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(u=>T6(f[u],o[u]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});const u=id(id({},this.getData(o)),f);this.map.set(o,u),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Vt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=se("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class a8{constructor(e,t){this.core=e,this.logger=t,this.name=Z6,this.version=ew,this.events=new Ut.exports,this.initialized=!1,this.storagePrefix=Yr,this.ignoredPayloadTypes=[si],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=nf(),s=await this.core.crypto.setSymKey(n),o=_t(ie.FIVE_MINUTES),f={protocol:M0},u={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},h=r0({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(nn.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Qr.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:f,expiryTimestamp:u,methods:h}=t0(i.uri);n.props.properties.topic=s,n.addTrace(Qr.pairing_uri_validation_success),n.addTrace(Qr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Qr.existing_pairing),g.active)throw n.setError(hi.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Qr.pairing_not_expired)}const y=u||_t(ie.FIVE_MINUTES),I={topic:s,relay:f,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,I),n.addTrace(Qr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(nn.create,I),n.addTrace(Qr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Qr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(hi.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(M){throw n.setError(hi.subscribe_pairing_topic_failure),M}return n.addTrace(Qr.subscribe_pairing_topic_success),I},this.activate=async({topic:i})=>{this.isInitialized();const n=_t(ie.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:u}=Xi();this.events.once(Ye("pairing_ping",s),({error:h})=>{h?u(h):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ct("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:f}=i,u=this.core.crypto.keychain.get(n);return r0({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:u,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{const o=rn(n,s),f=await this.core.crypto.encode(i,o),u=gs[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,u),o.id},this.sendResult=async(i,n,s)=>{const o=df(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=gs[u.request.method].res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=lf(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=gs[u.request.method]?gs[u.request.method].res:gs.unregistered_method.res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ct("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Ci(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(nn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Jr(n)?this.events.emit(Ye("pairing_ping",s),{}):_r(n)&&this.events.emit(Ye("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(nn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const f=ct("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ct("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!rr(i)){const{message:f}=se("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(hi.malformed_pairing_uri),new Error(f)}if(!vy(i.uri)){const{message:f}=se("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(hi.malformed_pairing_uri),new Error(f)}const o=t0(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:f}=se("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(hi.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){const{message:f}=se("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(hi.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&ie.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(hi.pairing_expired);const{message:f}=se("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(f)}},this.isValidPing=async i=>{if(!rr(i)){const{message:s}=se("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!rr(i)){const{message:s}=se("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!mt(i,!1)){const{message:n}=se("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=se("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Ci(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=se("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Vt(t,this.name),this.pairings=new on(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Xt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ot.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===ht.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{pf(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Oa(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ar.expired,async e=>{const{topic:t}=Cu(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(nn.expire,{topic:t}))})}}class o8 extends Ep{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ut.exports.EventEmitter,this.name=tw,this.version=rw,this.cached=[],this.initialized=!1,this.storagePrefix=Yr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:_t(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Pr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=_r(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Pr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Pr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:rn(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Pr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Pr.created,e=>{const t=Pr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Pr.updated,e=>{const t=Pr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Pr.deleted,e=>{const t=Pr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(dn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{ie.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Pr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class f8 extends Rp{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ut.exports.EventEmitter,this.name=iw,this.version=nw,this.cached=[],this.initialized=!1,this.storagePrefix=Yr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ar.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ar.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return cm(e);if(typeof e=="number")return hm(e);const{message:t}=se("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ar.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;ie.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ar.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(dn.pulse,()=>this.checkExpirations()),this.events.on(Ar.created,e=>{const t=Ar.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ar.expired,e=>{const t=Ar.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ar.deleted,e=>{const t=Ar.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class c8 extends Np{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=sw,this.verifyUrlV3=ow,this.storagePrefix=Yr,this.version=A0,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&ie.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!ns()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:f}=n,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{const h=Hn(),g=this.startAbortTimer(ie.ONE_SECOND*5),y=await new Promise((I,M)=>{const D=()=>{window.removeEventListener("message",k),h.body.removeChild(P),M("attestation aborted")};this.abortController.signal.addEventListener("abort",D);const P=h.createElement("iframe");P.src=u,P.style.display="none",P.addEventListener("error",D,{signal:this.abortController.signal});const k=K=>{if(K.data&&typeof K.data=="string")try{const C=JSON.parse(K.data);if(C.type==="verify_attestation"){if(ho(C.attestation).payload.id!==o)return;clearInterval(g),h.body.removeChild(P),this.abortController.signal.removeEventListener("abort",D),window.removeEventListener("message",k),I(C.attestation===null?"":C.attestation)}}catch(C){this.logger.warn(C)}};h.body.appendChild(P),window.addEventListener("message",k,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ho(s).payload.id!==f)return;const h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const u=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(ie.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||bs;return fw.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${bs}`),s=bs),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(ie.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{const o=Xm(n,s.publicKey),f={hasExpired:ie.toMiliseconds(o.exp)<Date.now(),payload:o};if(f.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:f.payload.origin,isScam:f.payload.isScam,isVerified:f.payload.isVerified}},this.logger=Vt(t,this.name),this.abortController=new AbortController,this.isDevEnv=Zo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Xt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),ie.toMiliseconds(e))}}class h8 extends Pp{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=cw,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,u=`${hw}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=Vt(t,this.context)}}var u8=Object.defineProperty,nd=Object.getOwnPropertySymbols,d8=Object.prototype.hasOwnProperty,l8=Object.prototype.propertyIsEnumerable,sd=(r,e,t)=>e in r?u8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ws=(r,e)=>{for(var t in e||(e={}))d8.call(e,t)&&sd(r,t,e[t]);if(nd)for(var t of nd(e))l8.call(e,t)&&sd(r,t,e[t]);return r};class p8 extends Cp{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=dw,this.storagePrefix=Yr,this.storageVersion=uw,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Zo())try{const n={eventId:Fu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Ou(this.core.relayer.protocol,this.core.relayer.version,bf)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:f,trace:u}}=n,h=Fu(),g=this.core.projectId||"",y=Date.now(),I=ws({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:u}},bundleId:g,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,I),this.shouldPersist=!0),I},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const f=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(f)return ws(ws({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(dn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{ie.fromMiliseconds(Date.now())-ie.fromMiliseconds(n.timestamp)>lw&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,ws(ws({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${pw}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${bf}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Du().url,this.logger=Vt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var g8=Object.defineProperty,ad=Object.getOwnPropertySymbols,b8=Object.prototype.hasOwnProperty,v8=Object.prototype.propertyIsEnumerable,od=(r,e,t)=>e in r?g8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fd=(r,e)=>{for(var t in e||(e={}))b8.call(e,t)&&od(r,t,e[t]);if(ad)for(var t of ad(e))v8.call(e,t)&&od(r,t,e[t]);return r};class _f extends Ap{constructor(e){var t;super(e),this.protocol=x0,this.version=A0,this.name=Ra,this.events=new Ut.exports.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:u})=>{if(!o||!f)return;const h={topic:o,message:f,publishedAt:Date.now(),transportType:ht.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:u})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||I0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=to({level:typeof e?.logger=="string"&&e.logger?e.logger:F6.logger,name:Ra}),{logger:n,chunkLoggerController:s}=xp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Vt(n,this.name),this.heartbeat=new Wa,this.crypto=new q5(this,this.logger,e?.keychain),this.history=new o8(this,this.logger),this.expirer=new f8(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Wl(fd(fd({},B6),e?.storageOptions)),this.relayer=new r8({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new a8(this,this.logger),this.verify=new c8(this,this.logger,this.storage),this.echoClient=new h8(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new p8(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new _f(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(J6,i),t}get context(){return Xt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D0,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(D0)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const xf=_f,cd="wc",hd=2,ud="client",Af=`${cd}@${hd}:${ud}:`,Ef={name:ud,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},dd="WALLETCONNECT_DEEPLINK_CHOICE",m8="proposal",y8="Proposal expired",w8="session",Fn=ie.SEVEN_DAYS,_8="engine",Rt={wc_sessionPropose:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1114},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:ie.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:ie.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1119}}},Sf={min:ie.FIVE_MINUTES,max:ie.SEVEN_DAYS},Xr={idle:"IDLE",active:"ACTIVE"},x8="request",A8=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],E8="wc",S8="auth",M8="authKeys",I8="pairingTopics",D8="requests",Pa=`${E8}@${1.5}:${S8}:`,Ca=`${Pa}:PUB_KEY`;var O8=Object.defineProperty,R8=Object.defineProperties,N8=Object.getOwnPropertyDescriptors,ld=Object.getOwnPropertySymbols,P8=Object.prototype.hasOwnProperty,C8=Object.prototype.propertyIsEnumerable,pd=(r,e,t)=>e in r?O8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gt=(r,e)=>{for(var t in e||(e={}))P8.call(e,t)&&pd(r,t,e[t]);if(ld)for(var t of ld(e))C8.call(e,t)&&pd(r,t,e[t]);return r},Tr=(r,e)=>R8(r,N8(e));class T8 extends Fp{constructor(e){super(e),this.name=_8,this.events=new Ut.exports,this.initialized=!1,this.requestQueue={state:Xr.idle,queue:[]},this.sessionRequestQueue={state:Xr.idle,queue:[]},this.requestQueueDelay=ie.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Rt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},ie.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Tr(gt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:u}=i;let h=n,g,y=!1;try{h&&(y=this.client.core.pairing.pairings.get(h).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),F}if(!h||!y){const{topic:F,uri:U}=await this.client.core.pairing.create();h=F,g=U}if(!h){const{message:F}=se("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(F)}const I=await this.client.core.crypto.generateKeyPair(),M=Rt.wc_sessionPropose.req.ttl||ie.FIVE_MINUTES,D=_t(M),P=gt({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:M0}],proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:D,pairingTopic:h},f&&{sessionProperties:f}),{reject:k,resolve:K,done:C}=Xi(M,y8);this.events.once(Ye("session_connect"),async({error:F,session:U})=>{if(F)k(F);else if(U){U.self.publicKey=I;const z=Tr(gt({},U),{pairingTopic:P.pairingTopic,requiredNamespaces:P.requiredNamespaces,optionalNamespaces:P.optionalNamespaces,transportType:ht.relay});await this.client.session.set(U.topic,z),await this.setExpiry(U.topic,U.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:U.peer.metadata}),this.cleanupDuplicatePairings(z),K(z)}});const j=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:P,throwOnFailedPublish:!0});return await this.setProposal(j,gt({id:j},P)),{uri:g,approval:C}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[Cr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(R){throw o.setError(sn.no_internet_connection),R}try{await this.isValidProposalId(t?.id)}catch(R){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(sn.proposal_not_found),R}try{await this.isValidApprove(t)}catch(R){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(sn.session_approve_namespace_validation_failure),R}const{id:f,relayProtocol:u,namespaces:h,sessionProperties:g,sessionConfig:y}=t,I=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:M,proposer:D,requiredNamespaces:P,optionalNamespaces:k}=I;let K=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:M});K||(K=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Cr.session_approve_started,properties:{topic:M,trace:[Cr.session_approve_started,Cr.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),j=D.publicKey,F=await this.client.core.crypto.generateSharedKey(C,j),U=gt(gt({relay:{protocol:u??"irn"},namespaces:h,controller:{publicKey:C,metadata:this.client.metadata},expiry:_t(Fn)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),z=ht.relay;K.addTrace(Cr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:z})}catch(R){throw K.setError(sn.subscribe_session_topic_failure),R}K.addTrace(Cr.subscribe_session_topic_success);const _=Tr(gt({},U),{topic:F,requiredNamespaces:P,optionalNamespaces:k,pairingTopic:M,acknowledged:!1,self:U.controller,peer:{publicKey:D.publicKey,metadata:D.metadata},controller:C,transportType:ht.relay});await this.client.session.set(F,_),K.addTrace(Cr.store_session);try{K.addTrace(Cr.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:U,throwOnFailedPublish:!0}).catch(R=>{throw K?.setError(sn.session_settle_publish_failure),R}),K.addTrace(Cr.session_settle_publish_success),K.addTrace(Cr.publishing_session_approve),await this.sendResult({id:f,topic:M,result:{relay:{protocol:u??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(R=>{throw K?.setError(sn.session_approve_publish_failure),R}),K.addTrace(Cr.session_approve_publish_success)}catch(R){throw this.client.logger.error(R),this.client.session.delete(F,ct("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),R}return this.client.core.eventClient.deleteEvent({eventId:K.eventId}),await this.client.core.pairing.updateMetadata({topic:M,metadata:D.metadata}),await this.client.proposal.delete(f,ct("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:M}),await this.setExpiry(F,_t(Fn)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=t;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:Rt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}const{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=Xi(),u=ci(),h=tn().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Ye("session_update",u),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:i}=t,n=ci(),{done:s,resolve:o,reject:f}=Xi();return this.events.once(Ye("session_extend",n),({error:u})=>{u?f(u):o()}),await this.setExpiry(i,_t(Fn)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(u=>{f(u)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(D){throw this.client.logger.error("request() -> isValidRequest() failed"),D}const{chainId:i,request:n,topic:s,expiry:o=Rt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const u=ci(),h=tn().toString(),{done:g,resolve:y,reject:I}=Xi(o,"Request expired. Please try again.");this.events.once(Ye("session_request",u),({error:D,result:P})=>{D?I(D):y(P)});const M=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return M?(await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Tr(gt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:M}).catch(D=>I(D)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),await g()):await Promise.all([new Promise(async D=>{await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Tr(gt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(P=>I(P)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),D()}),new Promise(async D=>{var P;if(!((P=f.sessionConfig)!=null&&P.disableDeepLink)){const k=await pm(this.client.core.storage,dd);await dm({id:u,topic:s,wcDeepLink:k})}D()}),g()]).then(D=>D[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Jr(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):_r(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=ci(),s=tn().toString(),{done:o,resolve:f,reject:u}=Xi();this.events.once(Ye("session_ping",n),({error:h})=>{h?u(h):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:s}=t,o=tn().toString(),f=ci();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:f})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ct("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=se("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?ht.link_mode:ht.relay;o===ht.relay&&await this.confirmOnlineStateOrThrow();const{chains:f,statement:u="",uri:h,domain:g,nonce:y,type:I,exp:M,nbf:D,methods:P=[],expiry:k}=t,K=[...t.resources||[]],{topic:C,uri:j}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:C,uri:j}});const F=await this.client.core.crypto.generateKeyPair(),U=Aa(F);if(await Promise.all([this.client.auth.authKeys.set(Ca,{responseTopic:U,publicKey:F}),this.client.auth.pairingTopics.set(U,{topic:U,pairingTopic:C})]),await this.client.core.relayer.subscribe(U,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${C}`),P.length>0){const{namespace:E}=ya(f[0]);let x=Bm(E,"request",P);xa(K)&&(x=qm(x,K.pop())),K.push(x)}const z=k&&k>Rt.wc_sessionAuthenticate.req.ttl?k:Rt.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:I??"caip122",chains:f,statement:u,aud:h,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:M,nbf:D,resources:K},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:_t(z)},R={eip155:{chains:f,methods:[...new Set(["personal_sign",...P])],events:["chainChanged","accountsChanged"]}},J={requiredNamespaces:{},optionalNamespaces:R,relays:[{protocol:"irn"}],pairingTopic:C,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:_t(Rt.wc_sessionPropose.req.ttl)},{done:Q,resolve:N,reject:p}=Xi(z,"Request expired"),l=async({error:E,session:x})=>{if(this.events.off(Ye("session_request",c),a),E)p(E);else if(x){x.self.publicKey=F,await this.client.session.set(x.topic,x),await this.setExpiry(x.topic,x.expiry),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:x.peer.metadata});const d=this.client.session.get(x.topic);await this.deleteProposal(b),N({session:d})}},a=async E=>{var x,d,w;if(await this.deletePendingAuthRequest(c,{message:"fulfilled",code:0}),E.error){const q=ct("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===q.code?void 0:(this.events.off(Ye("session_connect"),l),p(E.error.message))}await this.deleteProposal(b),this.events.off(Ye("session_connect"),l);const{cacaos:v,responder:O}=E.result,W=[],S=[];for(const q of v){await Uu({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),p(ct("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:B}=q,m=xa(B.resources),L=[tf(B.iss)],G=_a(B.iss);if(m){const Y=ku(m),X=Ku(m);W.push(...Y),L.push(...X)}for(const Y of L)S.push(`${Y}:${G}`)}const H=await this.client.core.crypto.generateSharedKey(F,O.publicKey);let T;W.length>0&&(T={topic:H,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:O,controller:O.publicKey,expiry:_t(Fn),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:C,namespaces:i0([...new Set(W)],[...new Set(S)]),transportType:o},await this.client.core.relayer.subscribe(H,{transportType:o}),await this.client.session.set(H,T),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:O.metadata}),T=this.client.session.get(H)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(d=O.metadata.redirect)!=null&&d.linkMode&&(w=O.metadata.redirect)!=null&&w.universal&&i&&(this.client.core.addLinkModeSupportedApp(O.metadata.redirect.universal),this.client.session.update(H,{transportType:ht.link_mode})),N({auths:v,session:T})},c=ci(),b=ci();this.events.once(Ye("session_connect"),l),this.events.once(Ye("session_request",c),a);let A;try{if(s){const E=rn("wc_sessionAuthenticate",_,c);this.client.core.history.set(C,E);const x=await this.client.core.crypto.encode("",E,{type:fs,encoding:as});A=Sa(i,C,x)}else await Promise.all([this.sendRequest({topic:C,method:"wc_sessionAuthenticate",params:_,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:c}),this.sendRequest({topic:C,method:"wc_sessionPropose",params:J,expiry:Rt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Ye("session_connect"),l),this.events.off(Ye("session_request",c),a),E}return await this.setProposal(b,gt({id:b},J)),await this.setAuthRequest(c,{request:Tr(gt({},_),{verifyContext:{}}),pairingTopic:C,transportType:o}),{uri:A??j,response:Q}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[an.authenticated_session_approve_started]}});try{this.isInitialized()}catch(k){throw s.setError(vs.no_internet_connection),k}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(vs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const f=o.transportType||ht.relay;f===ht.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),g=Aa(u),y={type:si,receiverPublicKey:u,senderPublicKey:h},I=[],M=[];for(const k of n){if(!await Uu({cacao:k,projectId:this.client.core.projectId})){s.setError(vs.invalid_cacao);const U=ct("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:U,encodeOpts:y}),new Error(U.message)}s.addTrace(an.cacaos_verified);const{p:K}=k,C=xa(K.resources),j=[tf(K.iss)],F=_a(K.iss);if(C){const U=ku(C),z=Ku(C);I.push(...U),j.push(...z)}for(const U of j)M.push(`${U}:${F}`)}const D=await this.client.core.crypto.generateSharedKey(h,u);s.addTrace(an.create_authenticated_session_topic);let P;if(I?.length>0){P={topic:D,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:_t(Fn),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:i0([...new Set(I)],[...new Set(M)]),transportType:f},s.addTrace(an.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(D,{transportType:f})}catch(k){throw s.setError(vs.subscribe_authenticated_session_topic_failure),k}s.addTrace(an.subscribe_authenticated_session_topic_success),await this.client.session.set(D,P),s.addTrace(an.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(an.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(k){throw s.setError(vs.authenticated_session_approve_publish_failure),k}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:P}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=Aa(o),h={type:si,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:u,error:n,encodeOpts:h,rpcOpts:Rt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return $u(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:u}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ct("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(dd).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,ct("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Xr.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(sn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ct("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=Xr.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,_t(Rt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=ht.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||_t(Rt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:u,throwOnFailedPublish:h,appLink:g}=t,y=rn(n,s,u);let I;const M=!!g;try{const k=M?as:Ti;I=await this.client.core.crypto.encode(i,y,{encoding:k})}catch(k){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),k}let D;if(A8.includes(n)){const k=ai(JSON.stringify(y)),K=ai(I);D=await this.client.core.verify.register({id:K,decryptedId:k})}const P=Rt[n].req;if(P.attestation=D,o&&(P.ttl=o),f&&(P.id=f),this.client.core.history.set(i,y),M){const k=Sa(g,i,I);await global.Linking.openURL(k,this.client.name)}else{const k=Rt[n].req;o&&(k.ttl=o),f&&(k.id=f),h?(k.internal=Tr(gt({},k.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,I,k)):this.client.core.relayer.publish(i,I,k).catch(K=>this.client.logger.error(K))}return y.id},this.sendResult=async t=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:u}=t,h=df(i,s);let g;const y=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=y?as:Ti;g=await this.client.core.crypto.encode(n,h,Tr(gt({},f||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),M}if(y){const M=Sa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=Rt[I.request.method].res;o?(M.internal=Tr(gt({},M.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,M)):this.client.core.relayer.publish(n,g,M).catch(D=>this.client.logger.error(D))}await this.client.core.history.resolve(h)},this.sendError=async t=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:u}=t,h=lf(i,s);let g;const y=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=y?as:Ti;g=await this.client.core.crypto.encode(n,h,Tr(gt({},o||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),M}if(y){const M=Sa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=f||Rt[I.request.method].res;this.client.core.relayer.publish(n,g,M)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Ci(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Ci(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Xr.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Xr.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Xr.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,u=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=se("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:u}=n;try{const h=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(hi.proposal_listener_not_found)),this.isValidConnect(gt({},n.params));const g=f.expiryTimestamp||_t(Rt.wc_sessionPropose.req.ttl),y=gt({id:u,pairingTopic:i,expiryTimestamp:g},f);await this.setProposal(u,y);const I=await this.getVerifyContext({attestationId:s,hash:ai(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});h?.addTrace(Qr.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:y,verifyContext:I})}catch(h){await this.sendError({id:u,topic:i,error:h,rpcOpts:Rt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(Jr(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});const u=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const g=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});const y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(_r(i)){await this.client.proposal.delete(s,ct("USER_DISCONNECTED"));const o=Ye("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Ye("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:f,expiry:u,namespaces:h,sessionProperties:g,sessionConfig:y}=i.params,I=Tr(gt(gt({topic:t,relay:o,expiry:u,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:ht.relay}),M=Ye("session_connect");if(this.events.listenerCount(M)===0)throw new Error(`emitting ${M} without any listeners 997`);this.events.emit(Ye("session_connect"),{session:I}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Jr(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Ye("session_approve",n),{})):_r(i)&&(await this.client.session.delete(t,ct("USER_DISCONNECTED")),this.events.emit(Ye("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,f=ds.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ct("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(gt({topic:t},n));try{ds.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(u){throw ds.delete(o),u}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,s=Ye("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Jr(i)?this.events.emit(Ye("session_update",n),{}):_r(i)&&this.events.emit(Ye("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,_t(Fn)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,s=Ye("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Jr(i)?this.events.emit(Ye("session_extend",n),{}):_r(i)&&this.events.emit(Ye("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,s=Ye("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Jr(i)?this.events.emit(Ye("session_ping",n),{}):_r(i)&&this.events.emit(Ye("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ot.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ct("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;const{topic:o,payload:f,attestation:u,encryptedId:h,transportType:g}=t,{id:y,params:I}=f;try{await this.isValidRequest(gt({topic:o},I));const M=this.client.session.get(o),D=await this.getVerifyContext({attestationId:u,hash:ai(JSON.stringify(rn("wc_sessionRequest",I,y))),encryptedId:h,metadata:M.peer.metadata,transportType:g}),P={id:y,topic:o,params:I,verifyContext:D};await this.setPendingSessionRequest(P),g===ht.link_mode&&(i=M.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=M.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(P):(this.addSessionRequestToSessionRequestQueue(P),this.processSessionRequestQueue())}catch(M){await this.sendError({id:y,topic:o,error:M}),this.client.logger.error(M)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,s=Ye("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Jr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):_r(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:s}=i;try{const o=`${t}_session_event_${s.event.name}`,f=ds.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(gt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),ds.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Jr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):_r(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:f,transportType:u}=t;try{const{requester:h,authPayload:g,expiryTimestamp:y}=s.params,I=await this.getVerifyContext({attestationId:o,hash:ai(JSON.stringify(s)),encryptedId:f,metadata:h.metadata,transportType:u}),M={requester:h,pairingTopic:n,id:s.id,authPayload:g,verifyContext:I,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:M,pairingTopic:n,transportType:u}),u===ht.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:I})}catch(h){this.client.logger.error(h);const g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),I=this.getAppLinkIfEnabled(s.params.requester.metadata,u),M={type:si,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:M,rpcOpts:Rt.wc_sessionAuthenticate.autoReject,appLink:I})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Xr.idle,this.processSessionRequestQueue()},ie.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,f=Ye("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Ye("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Xr.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Xr.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:rn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(Yt(i)||await this.isValidPairingTopic(i),!Iy(f,!0)){const{message:u}=se("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(u)}!Yt(n)&&Ia(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Yt(s)&&Ia(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=My(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!rr(t))throw new Error(se("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const f=this.client.proposal.get(i),u=af(n,"approve()");if(u)throw new Error(u.message);const h=f0(f.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!mt(s,!0)){const{message:g}=se("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!rr(t)){const{message:s}=se("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Oy(n)){const{message:s}=se("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!rr(t)){const{message:h}=se("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!a0(i)){const{message:h}=se("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const f=wy(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);const u=af(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Ci(o)){const{message:h}=se("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(u)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=af(n,"update()");if(o)throw new Error(o.message);const f=f0(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(u)}const{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!o0(f,s)){const{message:u}=se("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!Ry(n)){const{message:u}=se("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!Cy(f,s,n.method)){const{message:u}=se("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}if(o&&!Ly(o,Sf)){const{message:u}=se("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Sf.min} and ${Sf.max}`);throw new Error(u)}},this.isValidRespond=async t=>{var i;if(!rr(t)){const{message:o}=se("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Ny(s)){const{message:o}=se("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!rr(t)){const{message:f}=se("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}const{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!o0(o,s)){const{message:f}=se("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!Py(n)){const{message:f}=se("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(o,s,n.name)){const{message:f}=se("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!mt(n,!1))throw new Error("uri is required parameter");if(!mt(s,!1))throw new Error("domain is required parameter");if(!mt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>ya(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:f}=ya(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,u={verified:{verifyUrl:o.verifyUrl||bs,validation:"UNKNOWN",origin:o.url||""}};try{if(f===ht.link_mode){const g=this.getAppLinkIfEnabled(o,f);return u.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",u}const h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(u.verified.origin=h.origin,u.verified.isScam=h.isScam,u.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!mt(n,!1)){const{message:s}=se("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=se("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,u,h,g,y,I;return!t||i!==ht.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((h=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:h.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((I=t?.redirect)==null?void 0:I.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=Tu(t,"topic")||"",n=decodeURIComponent(Tu(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ht.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Zo()||Ri()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ot.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Ca)?this.client.auth.authKeys.get(Ca):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===ht.link_mode?as:Ti});try{pf(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:ai(i)})):Oa(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Ar.expired,async e=>{const{topic:t,id:i}=Cu(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,se("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,se("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(nn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(nn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:t}=se("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=se("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:t}=se("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=se("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=se("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(mt(e,!1)){const{message:t}=se("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=se("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Dy(e)){const{message:t}=se("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=se("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class F8 extends on{constructor(e,t){super(e,t,m8,Af),this.core=e,this.logger=t}}class gd extends on{constructor(e,t){super(e,t,w8,Af),this.core=e,this.logger=t}}class B8 extends on{constructor(e,t){super(e,t,x8,Af,i=>i.id),this.core=e,this.logger=t}}class L8 extends on{constructor(e,t){super(e,t,M8,Pa,()=>Ca),this.core=e,this.logger=t}}class q8 extends on{constructor(e,t){super(e,t,I8,Pa),this.core=e,this.logger=t}}class U8 extends on{constructor(e,t){super(e,t,D8,Pa,i=>i.id),this.core=e,this.logger=t}}class $8{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new L8(this.core,this.logger),this.pairingTopics=new q8(this.core,this.logger),this.requests=new U8(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Mf extends Tp{constructor(e){super(e),this.protocol=cd,this.version=hd,this.name=Ef.name,this.events=new Ut.exports.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||Ef.name,this.metadata=e?.metadata||Du(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Zr(to({level:e?.logger||Ef.logger}));this.core=e?.core||new xf(e),this.logger=Vt(t,this.name),this.session=new gd(this.core,this.logger),this.proposal=new F8(this.core,this.logger),this.pendingRequest=new B8(this.core,this.logger),this.engine=new T8(this),this.auth=new $8(this.core,this.logger)}static async init(e){const t=new Mf(e);return await t.initialize(),t}get context(){return Xt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},ie.toMiliseconds(ie.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const z8=gd,k8=Mf;class K8 extends Ut.exports{constructor(){super()}}class bd{constructor(e){this.opts=e}}class vd{constructor(e){this.client=e}}class md{constructor(e){this.engine=e}}class j8 extends md{constructor(e){super(e),this.engine=e,this.canFulfil=async t=>{if(console.log("canFulfil",t),!this.canFulfilHandler)throw new Error(`canFulfilHandler not found for environment: '${Ni()}'`);const{transaction:i}=t,n=await this.canFulfilHandler({transaction:i,projectId:this.projectId});switch(console.log("canFulfil processing result..",n),n.status){case Li.error:return{status:Li.error,reason:n.reason};case Li.not_required:return{status:Li.not_required};case Li.available:return{status:Li.available,data:n.data};default:throw new Error(`Invalid canFulfil status: ${JSON.stringify(n)}`)}},this.fulfilmentStatus=async t=>{if(!this.fulfilmentStatusHandler)throw new Error(`fulfilmentStatusHandler not found for environment: '${Ni()}'`);const{fulfilmentId:i}=t;console.log("fulfilmentStatus",t);const n=await this.fulfilmentStatusHandler({orchestrationId:i,projectId:this.projectId});if(n.status===$f.error)throw new Error(n.reason);return console.log("fulfilmentStatus result",n),n},this.loadHandlers=()=>{switch(Ni()){case Kt.reactNative:return this.ReactNative();case Kt.browser:return this.Browser();case Kt.node:return this.Node()}},this.ReactNative=()=>{const t=global==null?void 0:global.yttrium;if(!t){console.warn("React Native Yttrium not found in global scope");return}this.canFulfilHandler=t.checkRoute,this.fulfilmentStatusHandler=t.checkStatus},this.Browser=()=>{console.warn("Yttrium not available in browser environment")},this.Node=()=>{const t=global==null?void 0:global.yttrium;t||console.warn("Yttrium not available in node environment"),this.canFulfilHandler=t.checkRoute,this.fulfilmentStatusHandler=t.checkStatus},this.loadHandlers(),this.projectId=this.engine.client.core.projectId||""}}var H8=Object.defineProperty,V8=Object.defineProperties,G8=Object.getOwnPropertyDescriptors,yd=Object.getOwnPropertySymbols,W8=Object.prototype.hasOwnProperty,J8=Object.prototype.propertyIsEnumerable,wd=(r,e,t)=>e in r?H8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Y8=(r,e)=>{for(var t in e||(e={}))W8.call(e,t)&&wd(r,t,e[t]);if(yd)for(var t of yd(e))J8.call(e,t)&&wd(r,t,e[t]);return r},Q8=(r,e)=>V8(r,G8(e));class X8 extends vd{constructor(e){super(e),this.init=async()=>{this.signClient=await k8.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async t=>{await this.client.core.pairing.pair(t)},this.approveSession=async t=>{const{topic:i,acknowledged:n}=await this.signClient.approve(Q8(Y8({},t),{id:t.id,namespaces:t.namespaces,sessionProperties:t.sessionProperties,sessionConfig:t.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async t=>await this.signClient.reject(t),this.updateSession=async t=>await this.signClient.update(t),this.extendSession=async t=>await this.signClient.extend(t),this.respondSessionRequest=async t=>await this.signClient.respond(t),this.disconnectSession=async t=>await this.signClient.disconnect(t),this.emitSessionEvent=async t=>await this.signClient.emit(t),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((t,i)=>(t[i.topic]=i,t),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async t=>await this.signClient.approveSessionAuthenticate(t),this.rejectSessionAuthenticate=async t=>await this.signClient.rejectSessionAuthenticate(t),this.formatAuthMessage=t=>this.signClient.formatAuthMessage(t),this.registerDeviceToken=t=>this.client.core.echoClient.registerDeviceToken(t),this.on=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"on"),this.client.events.on(t,i)),this.once=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"once"),this.client.events.once(t,i)),this.off=(t,i)=>(this.setEvent(t,"off"),this.client.events.off(t,i)),this.removeListener=(t,i)=>(this.setEvent(t,"removeListener"),this.client.events.removeListener(t,i)),this.canFulfil=async t=>await this.chainAbstraction.canFulfil(t),this.fulfilmentStatus=async t=>await this.chainAbstraction.fulfilmentStatus(t),this.onSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onSessionProposal=t=>{this.client.events.emit("session_proposal",t)},this.onSessionDelete=t=>{this.client.events.emit("session_delete",t)},this.onProposalExpire=t=>{this.client.events.emit("proposal_expire",t)},this.onSessionRequestExpire=t=>{this.client.events.emit("session_request_expire",t)},this.onSessionRequestAuthenticate=t=>{this.client.events.emit("session_authenticate",t)},this.setEvent=(t,i)=>{switch(t){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={},this.chainAbstraction=new j8(this)}}const Z8={decryptMessage:async r=>{const e={core:new xf({storageOptions:r.storageOptions,storage:r.storage})};await e.core.crypto.init();const t=e.core.crypto.decode(r.topic,r.encryptedMessage);return e.core=null,t},getMetadata:async r=>{const e={core:new xf({storageOptions:r.storageOptions,storage:r.storage}),sessionStore:null};e.sessionStore=new z8(e.core,e.core.logger),await e.sessionStore.init();const t=e.sessionStore.get(r.topic),i=t?.peer.metadata;return e.core=null,e.sessionStore=null,i}},_d=class extends bd{constructor(r){super(r),this.events=new Ut.exports,this.on=(e,t)=>this.engine.on(e,t),this.once=(e,t)=>this.engine.once(e,t),this.off=(e,t)=>this.engine.off(e,t),this.removeListener=(e,t)=>this.engine.removeListener(e,t),this.pair=async e=>{try{return await this.engine.pair(e)}catch(t){throw this.logger.error(t.message),t}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(t){throw this.logger.error(t.message),t}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(t){throw this.logger.error(t.message),t}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(t){throw this.logger.error(t.message),t}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(t){throw this.logger.error(t.message),t}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(t){throw this.logger.error(t.message),t}},this.canFulfil=async e=>{try{return await this.engine.canFulfil(e)}catch(t){throw this.logger.error(t.message),t}},this.fulfilmentStatus=async e=>{try{return await this.engine.fulfilmentStatus(e)}catch(t){throw this.logger.error(t.message),t}},this.metadata=r.metadata,this.name=r.name||$a,this.signConfig=r.signConfig,this.core=r.core,this.logger=this.core.logger,this.engine=new X8(this)}static async init(r){const e=new _d(r);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(r){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(r.message),r}}};let If=_d;If.notifications=Z8;const e4=If;wt.CAN_FULFIL_STATUS=Li,wt.CLIENT_CONTEXT=$a,wt.CLIENT_STORAGE_OPTIONS=$d,wt.CLIENT_STORAGE_PREFIX=Ud,wt.FULFILMENT_STATUS=$f,wt.IChainAbstraction=md,wt.IWalletKit=bd,wt.IWalletKitEngine=vd,wt.IWalletKitEvents=K8,wt.PROTOCOL=Uf,wt.PROTOCOL_VERSION=qd,wt.REQUEST_CONTEXT=zd,wt.WalletKit=e4,wt.default=If,Object.defineProperty(wt,"__esModule",{value:!0})});
|
43
|
+
***************************************************************************** */var cf=function(r,e){return cf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},cf(r,e)};function Xy(r,e){cf(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var hf=function(){return hf=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},hf.apply(this,arguments)};function Zy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function e6(r,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function t6(r,e){return function(t,i){e(t,i,r)}}function r6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function i6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(g){try{h(i.next(g))}catch(y){o(y)}}function u(g){try{h(i.throw(g))}catch(y){o(y)}}function h(g){g.done?s(g.value):n(g.value).then(f,u)}h((i=i.apply(r,e||[])).next())})}function n6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(g){return u([h,g])}}function u(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(g){h=[6,g],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function s6(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function a6(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function uf(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g0(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function o6(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(g0(arguments[e]));return r}function f6(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,f=s.length;o<f;o++,n++)i[n]=s[o];return i}function ps(r){return this instanceof ps?(this.v=r,this):new ps(r)}function c6(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(I){i[I]&&(n[I]=function(M){return new Promise(function(D,P){s.push([I,M,D,P])>1||f(I,M)})})}function f(I,M){try{u(i[I](M))}catch(D){y(s[0][3],D)}}function u(I){I.value instanceof ps?Promise.resolve(I.value.v).then(h,g):y(s[0][2],I)}function h(I){f("next",I)}function g(I){f("throw",I)}function y(I,M){I(M),s.shift(),s.length&&f(s[0][0],s[0][1])}}function h6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:ps(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function u6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof uf=="function"?uf(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(h){s({value:h,done:f})},o)}}function d6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function l6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function p6(r){return r&&r.__esModule?r:{default:r}}function g6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function b6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var v6=Object.freeze({__proto__:null,__extends:Xy,get __assign(){return hf},__rest:Zy,__decorate:e6,__param:t6,__metadata:r6,__awaiter:i6,__generator:n6,__createBinding:s6,__exportStar:a6,__values:uf,__read:g0,__spread:o6,__spreadArrays:f6,__await:ps,__asyncGenerator:c6,__asyncDelegator:h6,__asyncValues:u6,__makeTemplateObject:d6,__importStar:l6,__importDefault:p6,__classPrivateFieldGet:g6,__classPrivateFieldSet:b6}),m6=Ua(v6),fi={},b0;function y6(){if(b0)return fi;b0=1,Object.defineProperty(fi,"__esModule",{value:!0}),fi.isBrowserCryptoAvailable=fi.getSubtleCrypto=fi.getBrowerCrypto=void 0;function r(){return Pt?.crypto||Pt?.msCrypto||{}}fi.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}fi.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return fi.isBrowserCryptoAvailable=t,fi}var ci={},v0;function w6(){if(v0)return ci;v0=1,Object.defineProperty(ci,"__esModule",{value:!0}),ci.isBrowser=ci.isNode=ci.isReactNative=void 0;function r(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}ci.isReactNative=r;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}ci.isNode=e;function t(){return!r()&&!e()}return ci.isBrowser=t,ci}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=m6;e.__exportStar(y6(),r),e.__exportStar(w6(),r)})(p0);function hi(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function tn(r=6){return BigInt(hi(r))}function rn(r,e,t){return{id:t||hi(),jsonrpc:"2.0",method:r,params:e}}function df(r,e){return{id:r,jsonrpc:"2.0",result:e}}function lf(r,e,t){return{id:r,jsonrpc:"2.0",error:_6(e,t)}}function _6(r,e){return typeof r>"u"?l0(u0):(typeof r=="string"&&(r=Object.assign(Object.assign({},l0(ff)),{message:r})),typeof e<"u"&&(r.data=e),Jy(r.code)&&(r=Yy(r.code)),r)}class x6{}class A6 extends x6{constructor(){super()}}class E6 extends A6{constructor(e){super()}}const S6="^wss?:";function M6(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function I6(r,e){const t=M6(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function m0(r){return I6(r,S6)}function D6(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function y0(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function pf(r){return y0(r)&&"method"in r}function Oa(r){return y0(r)&&(Yr(r)||_r(r))}function Yr(r){return"result"in r}function _r(r){return"error"in r}class O6 extends E6{constructor(e){super(e),this.events=new Ut.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(rn(e.method,e.params||[],e.id||tn().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{_r(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Oa(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const R6=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),N6=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",w0=r=>r.split("?")[0],_0=10,P6=R6();class C6{constructor(e){if(this.url=e,this.events=new Ut.exports.EventEmitter,this.registering=!1,!m0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(ki(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!m0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=p0.isReactNative()?void 0:{rejectUnauthorized:!D6(e)},s=new P6(e,[],n);N6()?s.onerror=o=>{const f=o;i(this.emitError(f.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),t(s)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ln(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=lf(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Qy(e,w0(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>_0&&this.events.setMaxListeners(_0)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${w0(this.url)}`));return this.events.emit("register_error",t),t}}var gf={exports:{}};(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,f="[object Arguments]",u="[object Array]",h="[object AsyncFunction]",g="[object Boolean]",y="[object Date]",I="[object Error]",M="[object Function]",D="[object GeneratorFunction]",P="[object Map]",k="[object Number]",K="[object Null]",C="[object Object]",j="[object Promise]",F="[object Proxy]",U="[object RegExp]",z="[object Set]",_="[object String]",R="[object Symbol]",J="[object Undefined]",Q="[object WeakMap]",N="[object ArrayBuffer]",p="[object DataView]",l="[object Float32Array]",a="[object Float64Array]",c="[object Int8Array]",b="[object Int16Array]",A="[object Int32Array]",E="[object Uint8Array]",x="[object Uint8ClampedArray]",d="[object Uint16Array]",w="[object Uint32Array]",v=/[\\^$.*+?()[\]{}|]/g,O=/^\[object .+?Constructor\]$/,W=/^(?:0|[1-9]\d*)$/,S={};S[l]=S[a]=S[c]=S[b]=S[A]=S[E]=S[x]=S[d]=S[w]=!0,S[f]=S[u]=S[N]=S[g]=S[p]=S[y]=S[I]=S[M]=S[P]=S[k]=S[C]=S[U]=S[z]=S[_]=S[Q]=!1;var H=typeof Pt=="object"&&Pt&&Pt.Object===Object&&Pt,T=typeof self=="object"&&self&&self.Object===Object&&self,q=H||T||Function("return this")(),B=e&&!e.nodeType&&e,m=B&&!0&&r&&!r.nodeType&&r,L=m&&m.exports===B,G=L&&H.process,Y=function(){try{return G&&G.binding&&G.binding("util")}catch{}}(),X=Y&&Y.isTypedArray;function ee($,V){for(var Z=-1,be=$==null?0:$.length,ut=0,Ge=[];++Z<be;){var bt=$[Z];V(bt,Z,$)&&(Ge[ut++]=bt)}return Ge}function we($,V){for(var Z=-1,be=V.length,ut=$.length;++Z<be;)$[ut+Z]=V[Z];return $}function Se($,V){for(var Z=-1,be=$==null?0:$.length;++Z<be;)if(V($[Z],Z,$))return!0;return!1}function he($,V){for(var Z=-1,be=Array($);++Z<$;)be[Z]=V(Z);return be}function Ne($){return function(V){return $(V)}}function xe($,V){return $.has(V)}function ae($,V){return $?.[V]}function ve($){var V=-1,Z=Array($.size);return $.forEach(function(be,ut){Z[++V]=[ut,be]}),Z}function le($,V){return function(Z){return $(V(Z))}}function ne($){var V=-1,Z=Array($.size);return $.forEach(function(be){Z[++V]=be}),Z}var ue=Array.prototype,fe=Function.prototype,te=Object.prototype,pe=q["__core-js_shared__"],_e=fe.toString,re=te.hasOwnProperty,Ae=function(){var $=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),Ee=te.toString,oe=RegExp("^"+_e.call(re).replace(v,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=L?q.Buffer:void 0,Me=q.Symbol,Oe=q.Uint8Array,We=te.propertyIsEnumerable,Qe=ue.splice,Ie=Me?Me.toStringTag:void 0,et=Object.getOwnPropertySymbols,tt=De?De.isBuffer:void 0,Pe=le(Object.keys,Object),Te=Bn(q,"DataView"),Ce=Bn(q,"Map"),de=Bn(q,"Promise"),Fe=Bn(q,"Set"),Be=Bn(q,"WeakMap"),ce=Bn(Object,"create"),Ue=fn(Te),$e=fn(Ce),me=fn(de),ze=fn(Fe),ke=fn(Be),ge=Me?Me.prototype:void 0,Le=ge?ge.valueOf:void 0;function Re($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function ye(){this.__data__=ce?ce(null):{},this.size=0}function Ke($){var V=this.has($)&&delete this.__data__[$];return this.size-=V?1:0,V}function it($){var V=this.__data__;if(ce){var Z=V[$];return Z===i?void 0:Z}return re.call(V,$)?V[$]:void 0}function qe($){var V=this.__data__;return ce?V[$]!==void 0:re.call(V,$)}function nt($,V){var Z=this.__data__;return this.size+=this.has($)?0:1,Z[$]=ce&&V===void 0?i:V,this}Re.prototype.clear=ye,Re.prototype.delete=Ke,Re.prototype.get=it,Re.prototype.has=qe,Re.prototype.set=nt;function Je($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function rt(){this.__data__=[],this.size=0}function ir($){var V=this.__data__,Z=Ta(V,$);if(Z<0)return!1;var be=V.length-1;return Z==be?V.pop():Qe.call(V,Z,1),--this.size,!0}function nr($){var V=this.__data__,Z=Ta(V,$);return Z<0?void 0:V[Z][1]}function sr($){return Ta(this.__data__,$)>-1}function ar($,V){var Z=this.__data__,be=Ta(Z,$);return be<0?(++this.size,Z.push([$,V])):Z[be][1]=V,this}Je.prototype.clear=rt,Je.prototype.delete=ir,Je.prototype.get=nr,Je.prototype.has=sr,Je.prototype.set=ar;function yt($){var V=-1,Z=$==null?0:$.length;for(this.clear();++V<Z;){var be=$[V];this.set(be[0],be[1])}}function di(){this.size=0,this.__data__={hash:new Re,map:new(Ce||Je),string:new Re}}function li($){var V=Fa(this,$).delete($);return this.size-=V?1:0,V}function pi($){return Fa(this,$).get($)}function gi($){return Fa(this,$).has($)}function bi($,V){var Z=Fa(this,$),be=Z.size;return Z.set($,V),this.size+=Z.size==be?0:1,this}yt.prototype.clear=di,yt.prototype.delete=li,yt.prototype.get=pi,yt.prototype.has=gi,yt.prototype.set=bi;function Er($){var V=-1,Z=$==null?0:$.length;for(this.__data__=new yt;++V<Z;)this.add($[V])}function vi($){return this.__data__.set($,i),this}function mi($){return this.__data__.has($)}Er.prototype.add=Er.prototype.push=vi,Er.prototype.has=mi;function jt($){var V=this.__data__=new Je($);this.size=V.size}function yi(){this.__data__=new Je,this.size=0}function wi($){var V=this.__data__,Z=V.delete($);return this.size=V.size,Z}function _i($){return this.__data__.get($)}function _s($){return this.__data__.has($)}function xs($,V){var Z=this.__data__;if(Z instanceof Je){var be=Z.__data__;if(!Ce||be.length<t-1)return be.push([$,V]),this.size=++Z.size,this;Z=this.__data__=new yt(be)}return Z.set($,V),this.size=Z.size,this}jt.prototype.clear=yi,jt.prototype.delete=wi,jt.prototype.get=_i,jt.prototype.has=_s,jt.prototype.set=xs;function t4($,V){var Z=Ba($),be=!Z&&b4($),ut=!Z&&!be&&Df($),Ge=!Z&&!be&&!ut&&Rd($),bt=Z||be||ut||Ge,Nt=bt?he($.length,String):[],qt=Nt.length;for(var dt in $)(V||re.call($,dt))&&!(bt&&(dt=="length"||ut&&(dt=="offset"||dt=="parent")||Ge&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||u4(dt,qt)))&&Nt.push(dt);return Nt}function Ta($,V){for(var Z=$.length;Z--;)if(Md($[Z][0],V))return Z;return-1}function r4($,V,Z){var be=V($);return Ba($)?be:we(be,Z($))}function As($){return $==null?$===void 0?J:K:Ie&&Ie in Object($)?c4($):g4($)}function xd($){return Es($)&&As($)==f}function Ad($,V,Z,be,ut){return $===V?!0:$==null||V==null||!Es($)&&!Es(V)?$!==$&&V!==V:i4($,V,Z,be,Ad,ut)}function i4($,V,Z,be,ut,Ge){var bt=Ba($),Nt=Ba(V),qt=bt?u:Fi($),dt=Nt?u:Fi(V);qt=qt==f?C:qt,dt=dt==f?C:dt;var lr=qt==C,Br=dt==C,Ht=qt==dt;if(Ht&&Df($)){if(!Df(V))return!1;bt=!0,lr=!1}if(Ht&&!lr)return Ge||(Ge=new jt),bt||Rd($)?Ed($,V,Z,be,ut,Ge):o4($,V,qt,Z,be,ut,Ge);if(!(Z&n)){var Sr=lr&&re.call($,"__wrapped__"),Mr=Br&&re.call(V,"__wrapped__");if(Sr||Mr){var Bi=Sr?$.value():$,xi=Mr?V.value():V;return Ge||(Ge=new jt),ut(Bi,xi,Z,be,Ge)}}return Ht?(Ge||(Ge=new jt),f4($,V,Z,be,ut,Ge)):!1}function n4($){if(!Od($)||l4($))return!1;var V=Id($)?oe:O;return V.test(fn($))}function s4($){return Es($)&&Dd($.length)&&!!S[As($)]}function a4($){if(!p4($))return Pe($);var V=[];for(var Z in Object($))re.call($,Z)&&Z!="constructor"&&V.push(Z);return V}function Ed($,V,Z,be,ut,Ge){var bt=Z&n,Nt=$.length,qt=V.length;if(Nt!=qt&&!(bt&&qt>Nt))return!1;var dt=Ge.get($);if(dt&&Ge.get(V))return dt==V;var lr=-1,Br=!0,Ht=Z&s?new Er:void 0;for(Ge.set($,V),Ge.set(V,$);++lr<Nt;){var Sr=$[lr],Mr=V[lr];if(be)var Bi=bt?be(Mr,Sr,lr,V,$,Ge):be(Sr,Mr,lr,$,V,Ge);if(Bi!==void 0){if(Bi)continue;Br=!1;break}if(Ht){if(!Se(V,function(xi,cn){if(!xe(Ht,cn)&&(Sr===xi||ut(Sr,xi,Z,be,Ge)))return Ht.push(cn)})){Br=!1;break}}else if(!(Sr===Mr||ut(Sr,Mr,Z,be,Ge))){Br=!1;break}}return Ge.delete($),Ge.delete(V),Br}function o4($,V,Z,be,ut,Ge,bt){switch(Z){case p:if($.byteLength!=V.byteLength||$.byteOffset!=V.byteOffset)return!1;$=$.buffer,V=V.buffer;case N:return!($.byteLength!=V.byteLength||!Ge(new Oe($),new Oe(V)));case g:case y:case k:return Md(+$,+V);case I:return $.name==V.name&&$.message==V.message;case U:case _:return $==V+"";case P:var Nt=ve;case z:var qt=be&n;if(Nt||(Nt=ne),$.size!=V.size&&!qt)return!1;var dt=bt.get($);if(dt)return dt==V;be|=s,bt.set($,V);var lr=Ed(Nt($),Nt(V),be,ut,Ge,bt);return bt.delete($),lr;case R:if(Le)return Le.call($)==Le.call(V)}return!1}function f4($,V,Z,be,ut,Ge){var bt=Z&n,Nt=Sd($),qt=Nt.length,dt=Sd(V),lr=dt.length;if(qt!=lr&&!bt)return!1;for(var Br=qt;Br--;){var Ht=Nt[Br];if(!(bt?Ht in V:re.call(V,Ht)))return!1}var Sr=Ge.get($);if(Sr&&Ge.get(V))return Sr==V;var Mr=!0;Ge.set($,V),Ge.set(V,$);for(var Bi=bt;++Br<qt;){Ht=Nt[Br];var xi=$[Ht],cn=V[Ht];if(be)var Nd=bt?be(cn,xi,Ht,V,$,Ge):be(xi,cn,Ht,$,V,Ge);if(!(Nd===void 0?xi===cn||ut(xi,cn,Z,be,Ge):Nd)){Mr=!1;break}Bi||(Bi=Ht=="constructor")}if(Mr&&!Bi){var La=$.constructor,qa=V.constructor;La!=qa&&"constructor"in $&&"constructor"in V&&!(typeof La=="function"&&La instanceof La&&typeof qa=="function"&&qa instanceof qa)&&(Mr=!1)}return Ge.delete($),Ge.delete(V),Mr}function Sd($){return r4($,y4,h4)}function Fa($,V){var Z=$.__data__;return d4(V)?Z[typeof V=="string"?"string":"hash"]:Z.map}function Bn($,V){var Z=ae($,V);return n4(Z)?Z:void 0}function c4($){var V=re.call($,Ie),Z=$[Ie];try{$[Ie]=void 0;var be=!0}catch{}var ut=Ee.call($);return be&&(V?$[Ie]=Z:delete $[Ie]),ut}var h4=et?function($){return $==null?[]:($=Object($),ee(et($),function(V){return We.call($,V)}))}:w4,Fi=As;(Te&&Fi(new Te(new ArrayBuffer(1)))!=p||Ce&&Fi(new Ce)!=P||de&&Fi(de.resolve())!=j||Fe&&Fi(new Fe)!=z||Be&&Fi(new Be)!=Q)&&(Fi=function($){var V=As($),Z=V==C?$.constructor:void 0,be=Z?fn(Z):"";if(be)switch(be){case Ue:return p;case $e:return P;case me:return j;case ze:return z;case ke:return Q}return V});function u4($,V){return V=V??o,!!V&&(typeof $=="number"||W.test($))&&$>-1&&$%1==0&&$<V}function d4($){var V=typeof $;return V=="string"||V=="number"||V=="symbol"||V=="boolean"?$!=="__proto__":$===null}function l4($){return!!Ae&&Ae in $}function p4($){var V=$&&$.constructor,Z=typeof V=="function"&&V.prototype||te;return $===Z}function g4($){return Ee.call($)}function fn($){if($!=null){try{return _e.call($)}catch{}try{return $+""}catch{}}return""}function Md($,V){return $===V||$!==$&&V!==V}var b4=xd(function(){return arguments}())?xd:function($){return Es($)&&re.call($,"callee")&&!We.call($,"callee")},Ba=Array.isArray;function v4($){return $!=null&&Dd($.length)&&!Id($)}var Df=tt||_4;function m4($,V){return Ad($,V)}function Id($){if(!Od($))return!1;var V=As($);return V==M||V==D||V==h||V==F}function Dd($){return typeof $=="number"&&$>-1&&$%1==0&&$<=o}function Od($){var V=typeof $;return $!=null&&(V=="object"||V=="function")}function Es($){return $!=null&&typeof $=="object"}var Rd=X?Ne(X):s4;function y4($){return v4($)?t4($):a4($)}function w4(){return[]}function _4(){return!1}r.exports=m4})(gf,gf.exports);var T6=gf.exports;const x0="wc",A0=2,Ra="core",Qr=`${x0}@2:${Ra}:`,F6={name:Ra,logger:"error"},B6={database:":memory:"},L6="crypto",E0="client_ed25519_seed",q6=ie.ONE_DAY,U6="keychain",$6="0.3",z6="messages",k6="0.3",S0=ie.SIX_HOURS,K6="publisher",M0="irn",j6="error",I0="wss://relay.walletconnect.org",H6="relayer",Ot={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},V6="_subscription",xr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},G6=.1,bf="2.17.3",ht={link_mode:"link_mode",relay:"relay"},W6="0.3",J6="WALLETCONNECT_CLIENT_ID",D0="WALLETCONNECT_LINK_MODE_APPS",dr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Y6="subscription",Q6="0.3",X6=ie.FIVE_SECONDS*1e3,Z6="pairing",ew="0.3",gs={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},nn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Cr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},tw="history",rw="0.3",iw="expirer",Ar={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},nw="0.3",sw="verify-api",aw="https://verify.walletconnect.com",O0="https://verify.walletconnect.org",bs=O0,ow=`${bs}/v3`,fw=[aw,O0],cw="echo",hw="https://echo.walletconnect.com",Xr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ui={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Tr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},sn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},an={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},vs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},uw=.1,dw="event-client",lw=86400,pw="https://pulse.walletconnect.org/batch";function gw(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var f=r.length,u=r.charAt(0),h=Math.log(f)/Math.log(256),g=Math.log(256)/Math.log(f);function y(D){if(D instanceof Uint8Array||(ArrayBuffer.isView(D)?D=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Array.isArray(D)&&(D=Uint8Array.from(D))),!(D instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(D.length===0)return"";for(var P=0,k=0,K=0,C=D.length;K!==C&&D[K]===0;)K++,P++;for(var j=(C-K)*g+1>>>0,F=new Uint8Array(j);K!==C;){for(var U=D[K],z=0,_=j-1;(U!==0||z<k)&&_!==-1;_--,z++)U+=256*F[_]>>>0,F[_]=U%f>>>0,U=U/f>>>0;if(U!==0)throw new Error("Non-zero carry");k=z,K++}for(var R=j-k;R!==j&&F[R]===0;)R++;for(var J=u.repeat(P);R<j;++R)J+=r.charAt(F[R]);return J}function I(D){if(typeof D!="string")throw new TypeError("Expected String");if(D.length===0)return new Uint8Array;var P=0;if(D[P]!==" "){for(var k=0,K=0;D[P]===u;)k++,P++;for(var C=(D.length-P)*h+1>>>0,j=new Uint8Array(C);D[P];){var F=t[D.charCodeAt(P)];if(F===255)return;for(var U=0,z=C-1;(F!==0||U<K)&&z!==-1;z--,U++)F+=f*j[z]>>>0,j[z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");K=U,P++}if(D[P]!==" "){for(var _=C-K;_!==C&&j[_]===0;)_++;for(var R=new Uint8Array(k+(C-_)),J=k;_!==C;)R[J++]=j[_++];return R}}}function M(D){var P=I(D);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:I,decode:M}}var bw=gw,vw=bw;const R0=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},mw=r=>new TextEncoder().encode(r),yw=r=>new TextDecoder().decode(r);class ww{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class _w{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return N0(this,e)}}class xw{constructor(e){this.decoders=e}or(e){return N0(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const N0=(r,e)=>new xw({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class Aw{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ww(e,t,i),this.decoder=new _w(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Na=({name:r,prefix:e,encode:t,decode:i})=>new Aw(r,e,t,i),ms=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=vw(t,e);return Na({prefix:r,name:e,encode:i,decode:s=>R0(n(s))})},Ew=(r,e,t,i)=>{const n={};for(let g=0;g<e.length;++g)n[e[g]]=g;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let f=0,u=0,h=0;for(let g=0;g<s;++g){const y=n[r[g]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);u=u<<t|y,f+=t,f>=8&&(f-=8,o[h++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},Sw=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,f=0;for(let u=0;u<r.length;++u)for(f=f<<8|r[u],o+=8;o>t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<<t-o]),i)for(;s.length*t&7;)s+="=";return s},Lt=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Na({prefix:e,name:r,encode(n){return Sw(n,i,t)},decode(n){return Ew(n,i,t,r)}}),Mw=Na({prefix:"\0",name:"identity",encode:r=>yw(r),decode:r=>mw(r)});var Iw=Object.freeze({__proto__:null,identity:Mw});const Dw=Lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ow=Object.freeze({__proto__:null,base2:Dw});const Rw=Lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nw=Object.freeze({__proto__:null,base8:Rw});const Pw=ms({prefix:"9",name:"base10",alphabet:"0123456789"});var Cw=Object.freeze({__proto__:null,base10:Pw});const Tw=Lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fw=Lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bw=Object.freeze({__proto__:null,base16:Tw,base16upper:Fw});const Lw=Lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qw=Lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Uw=Lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$w=Lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zw=Lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kw=Lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kw=Lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jw=Lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hw=Lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vw=Object.freeze({__proto__:null,base32:Lw,base32upper:qw,base32pad:Uw,base32padupper:$w,base32hex:zw,base32hexupper:kw,base32hexpad:Kw,base32hexpadupper:jw,base32z:Hw});const Gw=ms({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ww=ms({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Jw=Object.freeze({__proto__:null,base36:Gw,base36upper:Ww});const Yw=ms({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qw=ms({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xw=Object.freeze({__proto__:null,base58btc:Yw,base58flickr:Qw});const Zw=Lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),e5=Lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),t5=Lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),r5=Lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var i5=Object.freeze({__proto__:null,base64:Zw,base64pad:e5,base64url:t5,base64urlpad:r5});const P0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),n5=P0.reduce((r,e,t)=>(r[t]=e,r),[]),s5=P0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function a5(r){return r.reduce((e,t)=>(e+=n5[t],e),"")}function o5(r){const e=[];for(const t of r){const i=s5[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const f5=Na({prefix:"\u{1F680}",name:"base256emoji",encode:a5,decode:o5});var c5=Object.freeze({__proto__:null,base256emoji:f5}),h5=T0,C0=128,u5=127,d5=~u5,l5=Math.pow(2,31);function T0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=l5;)e[t++]=r&255|C0,r/=128;for(;r&d5;)e[t++]=r&255|C0,r>>>=7;return e[t]=r|0,T0.bytes=t-i+1,e}var p5=vf,g5=128,F0=127;function vf(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vf.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&F0)<<n:(o&F0)*Math.pow(2,n),n+=7}while(o>=g5);return vf.bytes=s-i,t}var b5=Math.pow(2,7),v5=Math.pow(2,14),m5=Math.pow(2,21),y5=Math.pow(2,28),w5=Math.pow(2,35),_5=Math.pow(2,42),x5=Math.pow(2,49),A5=Math.pow(2,56),E5=Math.pow(2,63),S5=function(r){return r<b5?1:r<v5?2:r<m5?3:r<y5?4:r<w5?5:r<_5?6:r<x5?7:r<A5?8:r<E5?9:10},M5={encode:h5,decode:p5,encodingLength:S5},B0=M5;const L0=(r,e,t=0)=>(B0.encode(r,e,t),e),q0=r=>B0.encodingLength(r),mf=(r,e)=>{const t=e.byteLength,i=q0(r),n=i+q0(t),s=new Uint8Array(n+t);return L0(r,s,0),L0(t,s,i),s.set(e,n),new I5(r,t,e,s)};class I5{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const U0=({name:r,code:e,encode:t})=>new D5(r,e,t);class D5{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?mf(this.code,t):t.then(i=>mf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const $0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),O5=U0({name:"sha2-256",code:18,encode:$0("SHA-256")}),R5=U0({name:"sha2-512",code:19,encode:$0("SHA-512")});var N5=Object.freeze({__proto__:null,sha256:O5,sha512:R5});const z0=0,P5="identity",k0=R0;var C5=Object.freeze({__proto__:null,identity:{code:z0,name:P5,encode:k0,digest:r=>mf(z0,k0(r))}});new TextEncoder,new TextDecoder;const K0={...Iw,...Ow,...Nw,...Cw,...Bw,...Vw,...Jw,...Xw,...i5,...c5};({...N5,...C5});function T5(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function j0(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const H0=j0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),yf=j0("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=T5(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),F5={utf8:H0,"utf-8":H0,hex:K0.base16,latin1:yf,ascii:yf,binary:yf,...K0};function B5(r,e="utf8"){const t=F5[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class L5{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=U6,this.version=$6,this.initialized=!1,this.storagePrefix=Qr,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=se("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Ru(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class q5{constructor(e,t,i){this.core=e,this.logger=t,this.name=L6,this.randomSessionIdentifier=nf(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Kc(n);return kc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=km();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Kc(s),f=this.randomSessionIdentifier;return await Kg(f,n,q6,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const f=this.getPrivateKey(n),u=Km(f,s);return this.setSymKey(u,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Aa(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const f=Ju(o),u=ki(s);if(Qu(f))return Hm(u,o?.encoding);if(Yu(f)){const I=f.senderPublicKey,M=f.receiverPublicKey;n=await this.generateSharedKey(I,M)}const h=this.getSymKey(n),{type:g,senderPublicKey:y}=f;return jm({type:g,symKey:h,message:u,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const f=Wm(s,o);if(Qu(f)){const u=Gm(s,o?.encoding);return ln(u)}if(Yu(f)){const u=f.receiverPublicKey,h=f.senderPublicKey;n=await this.generateSharedKey(u,h)}try{const u=this.getSymKey(n),h=Vm({symKey:u,encoded:s,encoding:o?.encoding});return ln(h)}catch(u){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(n,s=Ti)=>{const o=hs({encoded:n,encoding:s});return en(o.type)},this.getPayloadSenderPublicKey=(n,s=Ti)=>{const o=hs({encoded:n,encoding:s});return o.senderPublicKey?At(o.senderPublicKey,Jt):void 0},this.core=e,this.logger=Vt(t,this.name),this.keychain=i||new L5(this.core,this.logger)}get context(){return Xt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(E0)}catch{e=nf(),await this.keychain.set(E0,e)}return B5(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class U5 extends Sp{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=z6,this.version=k6,this.initialized=!1,this.storagePrefix=Qr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=oi(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=oi(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Vt(e,this.name),this.core=t}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Ru(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}var $5=Object.defineProperty,z5=Object.defineProperties,k5=Object.getOwnPropertyDescriptors,V0=Object.getOwnPropertySymbols,K5=Object.prototype.hasOwnProperty,j5=Object.prototype.propertyIsEnumerable,G0=(r,e,t)=>e in r?$5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,W0=(r,e)=>{for(var t in e||(e={}))K5.call(e,t)&&G0(r,t,e[t]);if(V0)for(var t of V0(e))j5.call(e,t)&&G0(r,t,e[t]);return r},J0=(r,e)=>z5(r,k5(e));class H5 extends Mp{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ut.exports.EventEmitter,this.name=K6,this.queue=new Map,this.publishTimeout=ie.toMiliseconds(ie.ONE_MINUTE),this.initialPublishTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const f=s?.ttl||S0,u=Ea(s),h=s?.prompt||!1,g=s?.tag||0,y=s?.id||tn().toString(),I={topic:i,message:n,opts:{ttl:f,relay:u,prompt:h,tag:g,id:y,attestation:s?.attestation}},M=`Failed to publish payload, please try again. id:${y} tag:${g}`;try{const D=new Promise(async P=>{const k=({id:C})=>{I.opts.id===C&&(this.removeRequestFromQueue(C),this.relayer.events.removeListener(Ot.publish,k),P(I))};this.relayer.events.on(Ot.publish,k);const K=Pi(new Promise((C,j)=>{this.rpcPublish({topic:i,message:n,ttl:f,prompt:h,tag:g,id:y,attestation:s?.attestation}).then(C).catch(F=>{this.logger.warn(F,F?.message),j(F)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${y} tag:${g}`);try{await K,this.events.removeListener(Ot.publish,k)}catch(C){this.queue.set(y,J0(W0({},I),{attempt:1})),this.logger.warn(C,C?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}}),await Pi(D,this.publishTimeout,M)}catch(D){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(D),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw D}finally{this.queue.delete(y)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Vt(t,this.name),this.registerEventListeners()}get context(){return Xt(this.logger)}async rpcPublish(e){var t,i,n,s;const{topic:o,message:f,ttl:u=S0,prompt:h,tag:g,id:y,attestation:I}=e,M={method:us(Ea().protocol).publish,params:{topic:o,message:f,ttl:u,prompt:h,tag:g,attestation:I},id:y};Yt((t=M.params)==null?void 0:t.prompt)&&((i=M.params)==null||delete i.prompt),Yt((n=M.params)==null?void 0:n.tag)&&((s=M.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:M});const D=await this.relayer.request(M);return this.relayer.events.emit(Ot.publish,e),this.logger.debug("Successfully Published Payload"),D}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,J0(W0({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:f}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:f}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ot.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ot.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class V5{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var G5=Object.defineProperty,W5=Object.defineProperties,J5=Object.getOwnPropertyDescriptors,Y0=Object.getOwnPropertySymbols,Y5=Object.prototype.hasOwnProperty,Q5=Object.prototype.propertyIsEnumerable,Q0=(r,e,t)=>e in r?G5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ys=(r,e)=>{for(var t in e||(e={}))Y5.call(e,t)&&Q0(r,t,e[t]);if(Y0)for(var t of Y0(e))Q5.call(e,t)&&Q0(r,t,e[t]);return r},wf=(r,e)=>W5(r,J5(e));class X5 extends Op{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new V5,this.events=new Ut.exports.EventEmitter,this.name=Y6,this.version=Q6,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Qr,this.subscribeTimeout=ie.toMiliseconds(ie.ONE_MINUTE),this.initialSubscribeTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=Ea(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const f=new ie.Watch;f.start(n);const u=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(h=>h.topic===i))&&(clearInterval(u),f.stop(n),s(!0)),f.elapsed(n)>=X6&&(clearInterval(u),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(dn.pulse,async()=>{await this.checkPending()}),this.events.on(dr.created,async i=>{const n=dr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(dr.deleted,async i=>{const n=dr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=Vt(t,this.name),this.clientId=""}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=Ea(i);await this.rpcUnsubscribe(e,t,n);const s=ct("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===ht.relay&&await this.restartToComplete();const s={method:us(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const f=this.getSubscriptionId(e);if(i?.transportType===ht.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(g=>this.logger.warn(g))},ie.toMiliseconds(ie.ONE_SECOND)),f;const u=new Promise(async g=>{const y=I=>{I.topic===e&&(this.events.removeListener(dr.created,y),g(I.id))};this.events.on(dr.created,y);try{const I=await Pi(new Promise((M,D)=>{this.relayer.request(s).catch(P=>{this.logger.warn(P,P?.message),D(P)}).then(M)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(dr.created,y),g(I)}catch{}}),h=await Pi(u,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ot.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:us(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Pi(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ot.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:us(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Pi(new Promise((s,o)=>{this.relayer.request(i).catch(f=>{this.logger.warn(f),o(f)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ot.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:us(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,wf(ys({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ys({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ys({},t)),this.topicMap.set(t.topic,e),this.events.emit(dr.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(dr.deleted,wf(ys({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(dr.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(dr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(e.map(t=>wf(ys({},t),{id:this.getSubscriptionId(t.topic)}))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await vm(ie.toMiliseconds(ie.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return oi(e+this.clientId)}}var Z5=Object.defineProperty,X0=Object.getOwnPropertySymbols,e8=Object.prototype.hasOwnProperty,t8=Object.prototype.propertyIsEnumerable,Z0=(r,e,t)=>e in r?Z5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ed=(r,e)=>{for(var t in e||(e={}))e8.call(e,t)&&Z0(r,t,e[t]);if(X0)for(var t of X0(e))t8.call(e,t)&&Z0(r,t,e[t]);return r};class r8 extends Ip{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ut.exports.EventEmitter,this.name=H6,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=ie.toMiliseconds(ie.THIRTY_SECONDS+ie.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=ie.toMiliseconds(ie.ONE_SECOND*15),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||tn().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=t.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const f=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(u=>u!==o),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}},this.resetPingTimeout=()=>{if(wa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t?.message)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Ot.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.fatal(t,`Fatal socket error: ${t?.message}`),this.events.emit(Ot.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xr.payload,this.onPayloadHandler),this.provider.on(xr.connect,this.onConnectHandler),this.provider.on(xr.disconnect,this.onDisconnectHandler),this.provider.on(xr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Vt(e.logger,this.name):ei(to({level:e.logger||j6})),this.messages=new U5(this.logger,e.core),this.subscriber=new X5(this,this.logger),this.publisher=new H5(this,this.logger),this.relayUrl=e?.relayUrl||I0,this.projectId=e.projectId,im()?this.packageName=Iu():nm()&&(this.bundleId=Iu()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return Xt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ht.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),(!(t!=null&&t.transportType)||t?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish;let f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u;const h=g=>{g.topic===e&&(this.subscriber.off(dr.created,h),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(dr.created,h)}),new Promise(async(g,y)=>{f=await this.subscriber.subscribe(e,ed({internal:{throwOnFailedPublish:o}},t)).catch(I=>{o&&y(I)})||f,g()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Pi(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await h0())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=_t(ie.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ot.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(xr.disconnect,s),await Pi(new Promise((o,f)=>{this.provider.connect().then(o).catch(f)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(xr.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,f)=>{const u=()=>{f(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(xr.disconnect,u),await this.subscriber.start().then(o).catch(f).finally(()=>{this.provider.off(xr.disconnect,u)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,ie.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,n,s;if(wa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new O6(new C6(fm({sdkVersion:bf,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),pf(e)){if(!e.method.endsWith(V6))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:ht.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(ed({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Oa(e)&&this.events.emit(Ot.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ot.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=df(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(xr.payload,this.onPayloadHandler),this.provider.off(xr.connect,this.onConnectHandler),this.provider.off(xr.disconnect,this.onDisconnectHandler),this.provider.off(xr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await h0();zy(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(Ot.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e?.message))},ie.toMiliseconds(G6))))}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var i8=Object.defineProperty,td=Object.getOwnPropertySymbols,n8=Object.prototype.hasOwnProperty,s8=Object.prototype.propertyIsEnumerable,rd=(r,e,t)=>e in r?i8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,id=(r,e)=>{for(var t in e||(e={}))n8.call(e,t)&&rd(r,t,e[t]);if(td)for(var t of td(e))s8.call(e,t)&&rd(r,t,e[t]);return r};class on extends Dp{constructor(e,t,i,n=Qr,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=W6,this.cached=[],this.initialized=!1,this.storagePrefix=Qr,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Yt(o)?this.map.set(this.getKey(o),o):my(o)?this.map.set(o.id,o):yy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(u=>T6(f[u],o[u]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});const u=id(id({},this.getData(o)),f);this.map.set(o,u),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Vt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=se("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class a8{constructor(e,t){this.core=e,this.logger=t,this.name=Z6,this.version=ew,this.events=new Ut.exports,this.initialized=!1,this.storagePrefix=Qr,this.ignoredPayloadTypes=[ai],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=nf(),s=await this.core.crypto.setSymKey(n),o=_t(ie.FIVE_MINUTES),f={protocol:M0},u={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},h=r0({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(nn.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Xr.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:f,expiryTimestamp:u,methods:h}=t0(i.uri);n.props.properties.topic=s,n.addTrace(Xr.pairing_uri_validation_success),n.addTrace(Xr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Xr.existing_pairing),g.active)throw n.setError(ui.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Xr.pairing_not_expired)}const y=u||_t(ie.FIVE_MINUTES),I={topic:s,relay:f,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,I),n.addTrace(Xr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(nn.create,I),n.addTrace(Xr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Xr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ui.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(M){throw n.setError(ui.subscribe_pairing_topic_failure),M}return n.addTrace(Xr.subscribe_pairing_topic_success),I},this.activate=async({topic:i})=>{this.isInitialized();const n=_t(ie.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:u}=Xi();this.events.once(Ye("pairing_ping",s),({error:h})=>{h?u(h):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ct("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:f}=i,u=this.core.crypto.keychain.get(n);return r0({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:u,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{const o=rn(n,s),f=await this.core.crypto.encode(i,o),u=gs[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,u),o.id},this.sendResult=async(i,n,s)=>{const o=df(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=gs[u.request.method].res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=lf(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),h=gs[u.request.method]?gs[u.request.method].res:gs.unregistered_method.res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ct("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Ci(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(nn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Yr(n)?this.events.emit(Ye("pairing_ping",s),{}):_r(n)&&this.events.emit(Ye("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(nn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const f=ct("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ct("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!rr(i)){const{message:f}=se("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ui.malformed_pairing_uri),new Error(f)}if(!vy(i.uri)){const{message:f}=se("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ui.malformed_pairing_uri),new Error(f)}const o=t0(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:f}=se("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ui.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){const{message:f}=se("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ui.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&ie.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(ui.pairing_expired);const{message:f}=se("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(f)}},this.isValidPing=async i=>{if(!rr(i)){const{message:s}=se("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!rr(i)){const{message:s}=se("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!mt(i,!1)){const{message:n}=se("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=se("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Ci(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=se("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Vt(t,this.name),this.pairings=new on(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Xt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ot.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===ht.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{pf(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Oa(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ar.expired,async e=>{const{topic:t}=Cu(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(nn.expire,{topic:t}))})}}class o8 extends Ep{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ut.exports.EventEmitter,this.name=tw,this.version=rw,this.cached=[],this.initialized=!1,this.storagePrefix=Qr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:_t(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Cr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=_r(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Cr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Cr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:rn(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Cr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Cr.created,e=>{const t=Cr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Cr.updated,e=>{const t=Cr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Cr.deleted,e=>{const t=Cr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(dn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{ie.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Cr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class f8 extends Rp{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ut.exports.EventEmitter,this.name=iw,this.version=nw,this.cached=[],this.initialized=!1,this.storagePrefix=Qr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ar.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ar.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Vt(t,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return cm(e);if(typeof e=="number")return hm(e);const{message:t}=se("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ar.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=se("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=se("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;ie.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ar.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(dn.pulse,()=>this.checkExpirations()),this.events.on(Ar.created,e=>{const t=Ar.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ar.expired,e=>{const t=Ar.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ar.deleted,e=>{const t=Ar.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}}class c8 extends Np{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=sw,this.verifyUrlV3=ow,this.storagePrefix=Qr,this.version=A0,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&ie.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!ns()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:f}=n,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{const h=Hn(),g=this.startAbortTimer(ie.ONE_SECOND*5),y=await new Promise((I,M)=>{const D=()=>{window.removeEventListener("message",k),h.body.removeChild(P),M("attestation aborted")};this.abortController.signal.addEventListener("abort",D);const P=h.createElement("iframe");P.src=u,P.style.display="none",P.addEventListener("error",D,{signal:this.abortController.signal});const k=K=>{if(K.data&&typeof K.data=="string")try{const C=JSON.parse(K.data);if(C.type==="verify_attestation"){if(ho(C.attestation).payload.id!==o)return;clearInterval(g),h.body.removeChild(P),this.abortController.signal.removeEventListener("abort",D),window.removeEventListener("message",k),I(C.attestation===null?"":C.attestation)}}catch(C){this.logger.warn(C)}};h.body.appendChild(P),window.addEventListener("message",k,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ho(s).payload.id!==f)return;const h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const u=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(ie.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||bs;return fw.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${bs}`),s=bs),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(ie.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{const o=Xm(n,s.publicKey),f={hasExpired:ie.toMiliseconds(o.exp)<Date.now(),payload:o};if(f.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:f.payload.origin,isScam:f.payload.isScam,isVerified:f.payload.isVerified}},this.logger=Vt(t,this.name),this.abortController=new AbortController,this.isDevEnv=Zo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Xt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),ie.toMiliseconds(e))}}class h8 extends Pp{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=cw,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,u=`${hw}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=Vt(t,this.context)}}var u8=Object.defineProperty,nd=Object.getOwnPropertySymbols,d8=Object.prototype.hasOwnProperty,l8=Object.prototype.propertyIsEnumerable,sd=(r,e,t)=>e in r?u8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ws=(r,e)=>{for(var t in e||(e={}))d8.call(e,t)&&sd(r,t,e[t]);if(nd)for(var t of nd(e))l8.call(e,t)&&sd(r,t,e[t]);return r};class p8 extends Cp{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=dw,this.storagePrefix=Qr,this.storageVersion=uw,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Zo())try{const n={eventId:Fu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Ou(this.core.relayer.protocol,this.core.relayer.version,bf)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:f,trace:u}}=n,h=Fu(),g=this.core.projectId||"",y=Date.now(),I=ws({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:u}},bundleId:g,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,I),this.shouldPersist=!0),I},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const f=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(f)return ws(ws({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(dn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{ie.fromMiliseconds(Date.now())-ie.fromMiliseconds(n.timestamp)>lw&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,ws(ws({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${pw}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${bf}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Du().url,this.logger=Vt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var g8=Object.defineProperty,ad=Object.getOwnPropertySymbols,b8=Object.prototype.hasOwnProperty,v8=Object.prototype.propertyIsEnumerable,od=(r,e,t)=>e in r?g8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fd=(r,e)=>{for(var t in e||(e={}))b8.call(e,t)&&od(r,t,e[t]);if(ad)for(var t of ad(e))v8.call(e,t)&&od(r,t,e[t]);return r};class _f extends Ap{constructor(e){var t;super(e),this.protocol=x0,this.version=A0,this.name=Ra,this.events=new Ut.exports.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:u})=>{if(!o||!f)return;const h={topic:o,message:f,publishedAt:Date.now(),transportType:ht.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:u})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||I0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=to({level:typeof e?.logger=="string"&&e.logger?e.logger:F6.logger,name:Ra}),{logger:n,chunkLoggerController:s}=xp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Vt(n,this.name),this.heartbeat=new Wa,this.crypto=new q5(this,this.logger,e?.keychain),this.history=new o8(this,this.logger),this.expirer=new f8(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Wl(fd(fd({},B6),e?.storageOptions)),this.relayer=new r8({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new a8(this,this.logger),this.verify=new c8(this,this.logger,this.storage),this.echoClient=new h8(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new p8(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new _f(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(J6,i),t}get context(){return Xt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D0,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(D0)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const xf=_f,cd="wc",hd=2,ud="client",Af=`${cd}@${hd}:${ud}:`,Ef={name:ud,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},dd="WALLETCONNECT_DEEPLINK_CHOICE",m8="proposal",y8="Proposal expired",w8="session",Fn=ie.SEVEN_DAYS,_8="engine",Rt={wc_sessionPropose:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ie.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1114},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:ie.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:ie.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:ie.FIVE_MINUTES,prompt:!1,tag:1119}}},Sf={min:ie.FIVE_MINUTES,max:ie.SEVEN_DAYS},Zr={idle:"IDLE",active:"ACTIVE"},x8="request",A8=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],E8="wc",S8="auth",M8="authKeys",I8="pairingTopics",D8="requests",Pa=`${E8}@${1.5}:${S8}:`,Ca=`${Pa}:PUB_KEY`;var O8=Object.defineProperty,R8=Object.defineProperties,N8=Object.getOwnPropertyDescriptors,ld=Object.getOwnPropertySymbols,P8=Object.prototype.hasOwnProperty,C8=Object.prototype.propertyIsEnumerable,pd=(r,e,t)=>e in r?O8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gt=(r,e)=>{for(var t in e||(e={}))P8.call(e,t)&&pd(r,t,e[t]);if(ld)for(var t of ld(e))C8.call(e,t)&&pd(r,t,e[t]);return r},Fr=(r,e)=>R8(r,N8(e));class T8 extends Fp{constructor(e){super(e),this.name=_8,this.events=new Ut.exports,this.initialized=!1,this.requestQueue={state:Zr.idle,queue:[]},this.sessionRequestQueue={state:Zr.idle,queue:[]},this.requestQueueDelay=ie.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Rt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},ie.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Fr(gt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:u}=i;let h=n,g,y=!1;try{h&&(y=this.client.core.pairing.pairings.get(h).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),F}if(!h||!y){const{topic:F,uri:U}=await this.client.core.pairing.create();h=F,g=U}if(!h){const{message:F}=se("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(F)}const I=await this.client.core.crypto.generateKeyPair(),M=Rt.wc_sessionPropose.req.ttl||ie.FIVE_MINUTES,D=_t(M),P=gt({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:M0}],proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:D,pairingTopic:h},f&&{sessionProperties:f}),{reject:k,resolve:K,done:C}=Xi(M,y8);this.events.once(Ye("session_connect"),async({error:F,session:U})=>{if(F)k(F);else if(U){U.self.publicKey=I;const z=Fr(gt({},U),{pairingTopic:P.pairingTopic,requiredNamespaces:P.requiredNamespaces,optionalNamespaces:P.optionalNamespaces,transportType:ht.relay});await this.client.session.set(U.topic,z),await this.setExpiry(U.topic,U.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:U.peer.metadata}),this.cleanupDuplicatePairings(z),K(z)}});const j=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:P,throwOnFailedPublish:!0});return await this.setProposal(j,gt({id:j},P)),{uri:g,approval:C}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[Tr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(R){throw o.setError(sn.no_internet_connection),R}try{await this.isValidProposalId(t?.id)}catch(R){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(sn.proposal_not_found),R}try{await this.isValidApprove(t)}catch(R){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(sn.session_approve_namespace_validation_failure),R}const{id:f,relayProtocol:u,namespaces:h,sessionProperties:g,sessionConfig:y}=t,I=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:M,proposer:D,requiredNamespaces:P,optionalNamespaces:k}=I;let K=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:M});K||(K=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Tr.session_approve_started,properties:{topic:M,trace:[Tr.session_approve_started,Tr.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),j=D.publicKey,F=await this.client.core.crypto.generateSharedKey(C,j),U=gt(gt({relay:{protocol:u??"irn"},namespaces:h,controller:{publicKey:C,metadata:this.client.metadata},expiry:_t(Fn)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),z=ht.relay;K.addTrace(Tr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:z})}catch(R){throw K.setError(sn.subscribe_session_topic_failure),R}K.addTrace(Tr.subscribe_session_topic_success);const _=Fr(gt({},U),{topic:F,requiredNamespaces:P,optionalNamespaces:k,pairingTopic:M,acknowledged:!1,self:U.controller,peer:{publicKey:D.publicKey,metadata:D.metadata},controller:C,transportType:ht.relay});await this.client.session.set(F,_),K.addTrace(Tr.store_session);try{K.addTrace(Tr.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:U,throwOnFailedPublish:!0}).catch(R=>{throw K?.setError(sn.session_settle_publish_failure),R}),K.addTrace(Tr.session_settle_publish_success),K.addTrace(Tr.publishing_session_approve),await this.sendResult({id:f,topic:M,result:{relay:{protocol:u??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(R=>{throw K?.setError(sn.session_approve_publish_failure),R}),K.addTrace(Tr.session_approve_publish_success)}catch(R){throw this.client.logger.error(R),this.client.session.delete(F,ct("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),R}return this.client.core.eventClient.deleteEvent({eventId:K.eventId}),await this.client.core.pairing.updateMetadata({topic:M,metadata:D.metadata}),await this.client.proposal.delete(f,ct("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:M}),await this.setExpiry(F,_t(Fn)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=t;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:Rt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}const{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=Xi(),u=hi(),h=tn().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Ye("session_update",u),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:i}=t,n=hi(),{done:s,resolve:o,reject:f}=Xi();return this.events.once(Ye("session_extend",n),({error:u})=>{u?f(u):o()}),await this.setExpiry(i,_t(Fn)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(u=>{f(u)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(D){throw this.client.logger.error("request() -> isValidRequest() failed"),D}const{chainId:i,request:n,topic:s,expiry:o=Rt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const u=hi(),h=tn().toString(),{done:g,resolve:y,reject:I}=Xi(o,"Request expired. Please try again.");this.events.once(Ye("session_request",u),({error:D,result:P})=>{D?I(D):y(P)});const M=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return M?(await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Fr(gt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:M}).catch(D=>I(D)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),await g()):await Promise.all([new Promise(async D=>{await this.sendRequest({clientRpcId:u,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:Fr(gt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(P=>I(P)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),D()}),new Promise(async D=>{var P;if(!((P=f.sessionConfig)!=null&&P.disableDeepLink)){const k=await pm(this.client.core.storage,dd);await dm({id:u,topic:s,wcDeepLink:k})}D()}),g()]).then(D=>D[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Yr(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):_r(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=hi(),s=tn().toString(),{done:o,resolve:f,reject:u}=Xi();this.events.once(Ye("session_ping",n),({error:h})=>{h?u(h):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:s}=t,o=tn().toString(),f=hi();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:f})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ct("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=se("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?ht.link_mode:ht.relay;o===ht.relay&&await this.confirmOnlineStateOrThrow();const{chains:f,statement:u="",uri:h,domain:g,nonce:y,type:I,exp:M,nbf:D,methods:P=[],expiry:k}=t,K=[...t.resources||[]],{topic:C,uri:j}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:C,uri:j}});const F=await this.client.core.crypto.generateKeyPair(),U=Aa(F);if(await Promise.all([this.client.auth.authKeys.set(Ca,{responseTopic:U,publicKey:F}),this.client.auth.pairingTopics.set(U,{topic:U,pairingTopic:C})]),await this.client.core.relayer.subscribe(U,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${C}`),P.length>0){const{namespace:E}=ya(f[0]);let x=Bm(E,"request",P);xa(K)&&(x=qm(x,K.pop())),K.push(x)}const z=k&&k>Rt.wc_sessionAuthenticate.req.ttl?k:Rt.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:I??"caip122",chains:f,statement:u,aud:h,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:M,nbf:D,resources:K},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:_t(z)},R={eip155:{chains:f,methods:[...new Set(["personal_sign",...P])],events:["chainChanged","accountsChanged"]}},J={requiredNamespaces:{},optionalNamespaces:R,relays:[{protocol:"irn"}],pairingTopic:C,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:_t(Rt.wc_sessionPropose.req.ttl)},{done:Q,resolve:N,reject:p}=Xi(z,"Request expired"),l=async({error:E,session:x})=>{if(this.events.off(Ye("session_request",c),a),E)p(E);else if(x){x.self.publicKey=F,await this.client.session.set(x.topic,x),await this.setExpiry(x.topic,x.expiry),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:x.peer.metadata});const d=this.client.session.get(x.topic);await this.deleteProposal(b),N({session:d})}},a=async E=>{var x,d,w;if(await this.deletePendingAuthRequest(c,{message:"fulfilled",code:0}),E.error){const q=ct("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===q.code?void 0:(this.events.off(Ye("session_connect"),l),p(E.error.message))}await this.deleteProposal(b),this.events.off(Ye("session_connect"),l);const{cacaos:v,responder:O}=E.result,W=[],S=[];for(const q of v){await Uu({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),p(ct("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:B}=q,m=xa(B.resources),L=[tf(B.iss)],G=_a(B.iss);if(m){const Y=ku(m),X=Ku(m);W.push(...Y),L.push(...X)}for(const Y of L)S.push(`${Y}:${G}`)}const H=await this.client.core.crypto.generateSharedKey(F,O.publicKey);let T;W.length>0&&(T={topic:H,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:O,controller:O.publicKey,expiry:_t(Fn),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:C,namespaces:i0([...new Set(W)],[...new Set(S)]),transportType:o},await this.client.core.relayer.subscribe(H,{transportType:o}),await this.client.session.set(H,T),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:O.metadata}),T=this.client.session.get(H)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(d=O.metadata.redirect)!=null&&d.linkMode&&(w=O.metadata.redirect)!=null&&w.universal&&i&&(this.client.core.addLinkModeSupportedApp(O.metadata.redirect.universal),this.client.session.update(H,{transportType:ht.link_mode})),N({auths:v,session:T})},c=hi(),b=hi();this.events.once(Ye("session_connect"),l),this.events.once(Ye("session_request",c),a);let A;try{if(s){const E=rn("wc_sessionAuthenticate",_,c);this.client.core.history.set(C,E);const x=await this.client.core.crypto.encode("",E,{type:fs,encoding:as});A=Sa(i,C,x)}else await Promise.all([this.sendRequest({topic:C,method:"wc_sessionAuthenticate",params:_,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:c}),this.sendRequest({topic:C,method:"wc_sessionPropose",params:J,expiry:Rt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Ye("session_connect"),l),this.events.off(Ye("session_request",c),a),E}return await this.setProposal(b,gt({id:b},J)),await this.setAuthRequest(c,{request:Fr(gt({},_),{verifyContext:{}}),pairingTopic:C,transportType:o}),{uri:A??j,response:Q}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[an.authenticated_session_approve_started]}});try{this.isInitialized()}catch(k){throw s.setError(vs.no_internet_connection),k}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(vs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const f=o.transportType||ht.relay;f===ht.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),g=Aa(u),y={type:ai,receiverPublicKey:u,senderPublicKey:h},I=[],M=[];for(const k of n){if(!await Uu({cacao:k,projectId:this.client.core.projectId})){s.setError(vs.invalid_cacao);const U=ct("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:U,encodeOpts:y}),new Error(U.message)}s.addTrace(an.cacaos_verified);const{p:K}=k,C=xa(K.resources),j=[tf(K.iss)],F=_a(K.iss);if(C){const U=ku(C),z=Ku(C);I.push(...U),j.push(...z)}for(const U of j)M.push(`${U}:${F}`)}const D=await this.client.core.crypto.generateSharedKey(h,u);s.addTrace(an.create_authenticated_session_topic);let P;if(I?.length>0){P={topic:D,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:_t(Fn),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:i0([...new Set(I)],[...new Set(M)]),transportType:f},s.addTrace(an.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(D,{transportType:f})}catch(k){throw s.setError(vs.subscribe_authenticated_session_topic_failure),k}s.addTrace(an.subscribe_authenticated_session_topic_success),await this.client.session.set(D,P),s.addTrace(an.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(an.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(k){throw s.setError(vs.authenticated_session_approve_publish_failure),k}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:P}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=Aa(o),h={type:ai,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:u,error:n,encodeOpts:h,rpcOpts:Rt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return $u(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:u}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ct("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(dd).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,ct("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Zr.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(sn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ct("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=Zr.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,_t(Rt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=ht.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||_t(Rt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:u,throwOnFailedPublish:h,appLink:g}=t,y=rn(n,s,u);let I;const M=!!g;try{const k=M?as:Ti;I=await this.client.core.crypto.encode(i,y,{encoding:k})}catch(k){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),k}let D;if(A8.includes(n)){const k=oi(JSON.stringify(y)),K=oi(I);D=await this.client.core.verify.register({id:K,decryptedId:k})}const P=Rt[n].req;if(P.attestation=D,o&&(P.ttl=o),f&&(P.id=f),this.client.core.history.set(i,y),M){const k=Sa(g,i,I);await global.Linking.openURL(k,this.client.name)}else{const k=Rt[n].req;o&&(k.ttl=o),f&&(k.id=f),h?(k.internal=Fr(gt({},k.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,I,k)):this.client.core.relayer.publish(i,I,k).catch(K=>this.client.logger.error(K))}return y.id},this.sendResult=async t=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:u}=t,h=df(i,s);let g;const y=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=y?as:Ti;g=await this.client.core.crypto.encode(n,h,Fr(gt({},f||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),M}if(y){const M=Sa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=Rt[I.request.method].res;o?(M.internal=Fr(gt({},M.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,M)):this.client.core.relayer.publish(n,g,M).catch(D=>this.client.logger.error(D))}await this.client.core.history.resolve(h)},this.sendError=async t=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:u}=t,h=lf(i,s);let g;const y=u&&typeof(global==null?void 0:global.Linking)<"u";try{const M=y?as:Ti;g=await this.client.core.crypto.encode(n,h,Fr(gt({},o||{}),{encoding:M}))}catch(M){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),M}let I;try{I=await this.client.core.history.get(n,i)}catch(M){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),M}if(y){const M=Sa(u,n,g);await global.Linking.openURL(M,this.client.name)}else{const M=f||Rt[I.request.method].res;this.client.core.relayer.publish(n,g,M)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Ci(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Ci(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Zr.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Zr.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Zr.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,u=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=se("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:u}=n;try{const h=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(ui.proposal_listener_not_found)),this.isValidConnect(gt({},n.params));const g=f.expiryTimestamp||_t(Rt.wc_sessionPropose.req.ttl),y=gt({id:u,pairingTopic:i,expiryTimestamp:g},f);await this.setProposal(u,y);const I=await this.getVerifyContext({attestationId:s,hash:oi(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});h?.addTrace(Xr.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:y,verifyContext:I})}catch(h){await this.sendError({id:u,topic:i,error:h,rpcOpts:Rt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(Yr(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});const u=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const g=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});const y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(_r(i)){await this.client.proposal.delete(s,ct("USER_DISCONNECTED"));const o=Ye("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Ye("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:f,expiry:u,namespaces:h,sessionProperties:g,sessionConfig:y}=i.params,I=Fr(gt(gt({topic:t,relay:o,expiry:u,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:ht.relay}),M=Ye("session_connect");if(this.events.listenerCount(M)===0)throw new Error(`emitting ${M} without any listeners 997`);this.events.emit(Ye("session_connect"),{session:I}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Yr(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Ye("session_approve",n),{})):_r(i)&&(await this.client.session.delete(t,ct("USER_DISCONNECTED")),this.events.emit(Ye("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,f=ds.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ct("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(gt({topic:t},n));try{ds.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(u){throw ds.delete(o),u}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,s=Ye("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Yr(i)?this.events.emit(Ye("session_update",n),{}):_r(i)&&this.events.emit(Ye("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,_t(Fn)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,s=Ye("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Yr(i)?this.events.emit(Ye("session_extend",n),{}):_r(i)&&this.events.emit(Ye("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,s=Ye("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Yr(i)?this.events.emit(Ye("session_ping",n),{}):_r(i)&&this.events.emit(Ye("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ot.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ct("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;const{topic:o,payload:f,attestation:u,encryptedId:h,transportType:g}=t,{id:y,params:I}=f;try{await this.isValidRequest(gt({topic:o},I));const M=this.client.session.get(o),D=await this.getVerifyContext({attestationId:u,hash:oi(JSON.stringify(rn("wc_sessionRequest",I,y))),encryptedId:h,metadata:M.peer.metadata,transportType:g}),P={id:y,topic:o,params:I,verifyContext:D};await this.setPendingSessionRequest(P),g===ht.link_mode&&(i=M.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=M.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(P):(this.addSessionRequestToSessionRequestQueue(P),this.processSessionRequestQueue())}catch(M){await this.sendError({id:y,topic:o,error:M}),this.client.logger.error(M)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,s=Ye("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Yr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):_r(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:s}=i;try{const o=`${t}_session_event_${s.event.name}`,f=ds.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(gt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),ds.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Yr(i)?this.events.emit(Ye("session_request",n),{result:i.result}):_r(i)&&this.events.emit(Ye("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:f,transportType:u}=t;try{const{requester:h,authPayload:g,expiryTimestamp:y}=s.params,I=await this.getVerifyContext({attestationId:o,hash:oi(JSON.stringify(s)),encryptedId:f,metadata:h.metadata,transportType:u}),M={requester:h,pairingTopic:n,id:s.id,authPayload:g,verifyContext:I,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:M,pairingTopic:n,transportType:u}),u===ht.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:I})}catch(h){this.client.logger.error(h);const g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),I=this.getAppLinkIfEnabled(s.params.requester.metadata,u),M={type:ai,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:M,rpcOpts:Rt.wc_sessionAuthenticate.autoReject,appLink:I})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Zr.idle,this.processSessionRequestQueue()},ie.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,f=Ye("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Ye("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Zr.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Zr.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:rn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(u)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(Yt(i)||await this.isValidPairingTopic(i),!Iy(f,!0)){const{message:u}=se("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(u)}!Yt(n)&&Ia(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Yt(s)&&Ia(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=My(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!rr(t))throw new Error(se("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const f=this.client.proposal.get(i),u=af(n,"approve()");if(u)throw new Error(u.message);const h=f0(f.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!mt(s,!0)){const{message:g}=se("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!rr(t)){const{message:s}=se("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Oy(n)){const{message:s}=se("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!rr(t)){const{message:h}=se("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!a0(i)){const{message:h}=se("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const f=wy(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);const u=af(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Ci(o)){const{message:h}=se("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(u)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=af(n,"update()");if(o)throw new Error(o.message);const f=f0(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!rr(t)){const{message:u}=se("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(u)}const{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!o0(f,s)){const{message:u}=se("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!Ry(n)){const{message:u}=se("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!Cy(f,s,n.method)){const{message:u}=se("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}if(o&&!Ly(o,Sf)){const{message:u}=se("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Sf.min} and ${Sf.max}`);throw new Error(u)}},this.isValidRespond=async t=>{var i;if(!rr(t)){const{message:o}=se("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Ny(s)){const{message:o}=se("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!rr(t)){const{message:f}=se("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}const{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!o0(o,s)){const{message:f}=se("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!Py(n)){const{message:f}=se("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(o,s,n.name)){const{message:f}=se("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!rr(t)){const{message:n}=se("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!mt(n,!1))throw new Error("uri is required parameter");if(!mt(s,!1))throw new Error("domain is required parameter");if(!mt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>ya(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:f}=ya(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,u={verified:{verifyUrl:o.verifyUrl||bs,validation:"UNKNOWN",origin:o.url||""}};try{if(f===ht.link_mode){const g=this.getAppLinkIfEnabled(o,f);return u.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",u}const h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(u.verified.origin=h.origin,u.verified.isScam=h.isScam,u.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!mt(n,!1)){const{message:s}=se("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=se("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,u,h,g,y,I;return!t||i!==ht.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((h=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:h.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((I=t?.redirect)==null?void 0:I.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=Tu(t,"topic")||"",n=decodeURIComponent(Tu(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ht.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Zo()||Ni()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=se("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ot.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Ca)?this.client.auth.authKeys.get(Ca):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===ht.link_mode?as:Ti});try{pf(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:oi(i)})):Oa(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Ar.expired,async e=>{const{topic:t,id:i}=Cu(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,se("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,se("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(nn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(nn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:t}=se("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=se("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:t}=se("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=se("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=se("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(mt(e,!1)){const{message:t}=se("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=se("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Dy(e)){const{message:t}=se("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=se("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Ci(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=se("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class F8 extends on{constructor(e,t){super(e,t,m8,Af),this.core=e,this.logger=t}}class gd extends on{constructor(e,t){super(e,t,w8,Af),this.core=e,this.logger=t}}class B8 extends on{constructor(e,t){super(e,t,x8,Af,i=>i.id),this.core=e,this.logger=t}}class L8 extends on{constructor(e,t){super(e,t,M8,Pa,()=>Ca),this.core=e,this.logger=t}}class q8 extends on{constructor(e,t){super(e,t,I8,Pa),this.core=e,this.logger=t}}class U8 extends on{constructor(e,t){super(e,t,D8,Pa,i=>i.id),this.core=e,this.logger=t}}class $8{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new L8(this.core,this.logger),this.pairingTopics=new q8(this.core,this.logger),this.requests=new U8(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Mf extends Tp{constructor(e){super(e),this.protocol=cd,this.version=hd,this.name=Ef.name,this.events=new Ut.exports.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||Ef.name,this.metadata=e?.metadata||Du(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ei(to({level:e?.logger||Ef.logger}));this.core=e?.core||new xf(e),this.logger=Vt(t,this.name),this.session=new gd(this.core,this.logger),this.proposal=new F8(this.core,this.logger),this.pendingRequest=new B8(this.core,this.logger),this.engine=new T8(this),this.auth=new $8(this.core,this.logger)}static async init(e){const t=new Mf(e);return await t.initialize(),t}get context(){return Xt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},ie.toMiliseconds(ie.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const z8=gd,k8=Mf;class K8 extends Ut.exports{constructor(){super()}}class bd{constructor(e){this.opts=e}}class vd{constructor(e){this.client=e}}class md{constructor(e){this.engine=e}}class j8 extends md{constructor(e){super(e),this.engine=e,this.prepareFulfilment=async t=>{if(console.log("prepareFulfilment",t),!this.prepareFulfilmentHandler)throw new Error(`prepareFulfilmentHandler not found for environment: '${Pr()}'`);const{transaction:i}=t,n=await this.prepareFulfilmentHandler({transaction:i,projectId:this.projectId});switch(console.log("prepareFulfilment processing result..",n),n.status){case Li.error:return{status:Li.error,reason:n.reason};case Li.not_required:return{status:Li.not_required};case Li.available:const s=n.data;return{status:Li.available,data:{fulfilmentId:s.orchestrationId,checkIn:s.checkIn,transactions:s.transactions,funding:s.metadata.fundingFrom,initialTransaction:s.initialTransaction,initialTransactionMetadata:s.metadata.initialTransaction}};default:throw new Error(`Invalid prepareFulfilment status: ${JSON.stringify(n)}`)}},this.fulfilmentStatus=async t=>{if(!this.fulfilmentStatusHandler)throw new Error(`fulfilmentStatusHandler not found for environment: '${Pr()}'`);const{fulfilmentId:i}=t;console.log("fulfilmentStatus",t);const n=await this.fulfilmentStatusHandler({orchestrationId:i,projectId:this.projectId});if(n.status===$f.error)throw new Error(n.reason);return console.log("fulfilmentStatus result",n),n},this.estimateFees=async t=>{if(!this.estimateFeesHandler)throw new Error(`estimateFeesHandler not found for environment: '${Pr()}'`);const i=await this.estimateFeesHandler(t);return console.log("estimateFees result",i),i},this.getERC20Balance=async t=>{if(!this.getERC20BalanceHandler)throw new Error(`getERC20BalanceHandler not found for environment: '${Pr()}'`);const i=await this.getERC20BalanceHandler(t);return console.log("getERC20Balance result",i),i},this.getFulfilmentDetails=async t=>{if(!this.getFulfilmentDetailsHandler)throw new Error(`getFulfilmentDetailsHandler not found for environment: '${Pr()}'`);const i=await this.getFulfilmentDetailsHandler(t);console.log("getFulfilmentDetails handler result",i);const n=[];for(const u of i.bridge)n.push({fee:u.fee,localFee:u.localFee});const s=[];for(const u of i.route)s.push({transaction:u.transaction,eip1559:u.estimate,transactionFee:u.fee});const o={transaction:i.initial.transaction,eip1559:i.initial.estimate,transactionFee:i.initial.fee},f=i.localTotal;return console.log("getFulfilmentDetails parsed result",{routeDetails:s,initialTransactionDetails:o,bridgeDetails:n,totalFee:f}),{routeDetails:s,initialTransactionDetails:o,bridgeDetails:n,totalFee:f}},this.loadHandlers=()=>{switch(Pr()){case Kt.reactNative:return this.ReactNative();case Kt.browser:return this.Browser();case Kt.node:return this.Node()}},this.ReactNative=()=>{const t=global==null?void 0:global.yttrium;if(!t){console.warn("React Native Yttrium not found in global scope");return}this.prepareFulfilmentHandler=t.checkRoute,this.fulfilmentStatusHandler=t.checkStatus,this.estimateFeesHandler=t.estimateFees,this.getERC20BalanceHandler=t.getERC20Balance,this.getFulfilmentDetailsHandler=t.getFulfilmentDetails},this.Browser=()=>{console.warn("Yttrium not available in browser environment")},this.Node=()=>{const t=global==null?void 0:global.yttrium;t||console.warn("Yttrium not available in node environment"),this.prepareFulfilmentHandler=t.checkRoute,this.fulfilmentStatusHandler=t.checkStatus,this.estimateFeesHandler=t.estimateFees,this.getERC20BalanceHandler=t.getERC20Balance,this.getFulfilmentDetailsHandler=t.getFulfilmentDetails},this.loadHandlers(),this.projectId=this.engine.client.core.projectId||""}}var H8=Object.defineProperty,V8=Object.defineProperties,G8=Object.getOwnPropertyDescriptors,yd=Object.getOwnPropertySymbols,W8=Object.prototype.hasOwnProperty,J8=Object.prototype.propertyIsEnumerable,wd=(r,e,t)=>e in r?H8(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Y8=(r,e)=>{for(var t in e||(e={}))W8.call(e,t)&&wd(r,t,e[t]);if(yd)for(var t of yd(e))J8.call(e,t)&&wd(r,t,e[t]);return r},Q8=(r,e)=>V8(r,G8(e));class X8 extends vd{constructor(e){super(e),this.init=async()=>{this.signClient=await k8.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async t=>{await this.client.core.pairing.pair(t)},this.approveSession=async t=>{const{topic:i,acknowledged:n}=await this.signClient.approve(Q8(Y8({},t),{id:t.id,namespaces:t.namespaces,sessionProperties:t.sessionProperties,sessionConfig:t.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async t=>await this.signClient.reject(t),this.updateSession=async t=>await this.signClient.update(t),this.extendSession=async t=>await this.signClient.extend(t),this.respondSessionRequest=async t=>await this.signClient.respond(t),this.disconnectSession=async t=>await this.signClient.disconnect(t),this.emitSessionEvent=async t=>await this.signClient.emit(t),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((t,i)=>(t[i.topic]=i,t),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async t=>await this.signClient.approveSessionAuthenticate(t),this.rejectSessionAuthenticate=async t=>await this.signClient.rejectSessionAuthenticate(t),this.formatAuthMessage=t=>this.signClient.formatAuthMessage(t),this.registerDeviceToken=t=>this.client.core.echoClient.registerDeviceToken(t),this.on=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"on"),this.client.events.on(t,i)),this.once=(t,i)=>(this.setEvent(t,"off"),this.setEvent(t,"once"),this.client.events.once(t,i)),this.off=(t,i)=>(this.setEvent(t,"off"),this.client.events.off(t,i)),this.removeListener=(t,i)=>(this.setEvent(t,"removeListener"),this.client.events.removeListener(t,i)),this.prepareFulfilment=async t=>await this.chainAbstraction.prepareFulfilment(t),this.fulfilmentStatus=async t=>await this.chainAbstraction.fulfilmentStatus(t),this.estimateFees=async t=>await this.chainAbstraction.estimateFees(t),this.getERC20Balance=async t=>await this.chainAbstraction.getERC20Balance(t),this.getFulfilmentDetails=async t=>await this.chainAbstraction.getFulfilmentDetails(t),this.onSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onSessionProposal=t=>{this.client.events.emit("session_proposal",t)},this.onSessionDelete=t=>{this.client.events.emit("session_delete",t)},this.onProposalExpire=t=>{this.client.events.emit("proposal_expire",t)},this.onSessionRequestExpire=t=>{this.client.events.emit("session_request_expire",t)},this.onSessionRequestAuthenticate=t=>{this.client.events.emit("session_authenticate",t)},this.setEvent=(t,i)=>{switch(t){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={},this.chainAbstraction=new j8(this)}}const Z8={decryptMessage:async r=>{const e={core:new xf({storageOptions:r.storageOptions,storage:r.storage})};await e.core.crypto.init();const t=e.core.crypto.decode(r.topic,r.encryptedMessage);return e.core=null,t},getMetadata:async r=>{const e={core:new xf({storageOptions:r.storageOptions,storage:r.storage}),sessionStore:null};e.sessionStore=new z8(e.core,e.core.logger),await e.sessionStore.init();const t=e.sessionStore.get(r.topic),i=t?.peer.metadata;return e.core=null,e.sessionStore=null,i}},_d=class extends bd{constructor(r){super(r),this.events=new Ut.exports,this.on=(e,t)=>this.engine.on(e,t),this.once=(e,t)=>this.engine.once(e,t),this.off=(e,t)=>this.engine.off(e,t),this.removeListener=(e,t)=>this.engine.removeListener(e,t),this.pair=async e=>{try{return await this.engine.pair(e)}catch(t){throw this.logger.error(t.message),t}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(t){throw this.logger.error(t.message),t}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(t){throw this.logger.error(t.message),t}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(t){throw this.logger.error(t.message),t}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(t){throw this.logger.error(t.message),t}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(t){throw this.logger.error(t.message),t}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(t){throw this.logger.error(t.message),t}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(t){throw this.logger.error(t.message),t}},this.prepareFulfilment=async e=>{try{return await this.engine.prepareFulfilment(e)}catch(t){throw this.logger.error(t.message),t}},this.fulfilmentStatus=async e=>{try{return await this.engine.fulfilmentStatus(e)}catch(t){throw this.logger.error(t.message),t}},this.estimateFees=async e=>{try{return await this.engine.estimateFees(e)}catch(t){throw this.logger.error(t.message),t}},this.getERC20Balance=async e=>{try{return await this.engine.getERC20Balance(e)}catch(t){throw this.logger.error(t.message),t}},this.getFulfilmentDetails=async e=>{try{return await this.engine.getFulfilmentDetails(e)}catch(t){throw this.logger.error(t.message),t}},this.metadata=r.metadata,this.name=r.name||$a,this.signConfig=r.signConfig,this.core=r.core,this.logger=this.core.logger,this.engine=new X8(this)}static async init(r){const e=new _d(r);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(r){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(r.message),r}}};let If=_d;If.notifications=Z8;const e4=If;wt.CAN_FULFIL_STATUS=Li,wt.CLIENT_CONTEXT=$a,wt.CLIENT_STORAGE_OPTIONS=$d,wt.CLIENT_STORAGE_PREFIX=Ud,wt.FULFILMENT_STATUS=$f,wt.IChainAbstraction=md,wt.IWalletKit=bd,wt.IWalletKitEngine=vd,wt.IWalletKitEvents=K8,wt.PROTOCOL=Uf,wt.PROTOCOL_VERSION=qd,wt.REQUEST_CONTEXT=zd,wt.WalletKit=e4,wt.default=If,Object.defineProperty(wt,"__esModule",{value:!0})});
|
44
44
|
//# sourceMappingURL=index.umd.js.map
|