You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
89 KiB
14 lines
89 KiB
var app=function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function r(t){t.forEach(e)}function s(t){return"function"==typeof t}function o(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function i(e,n,r){e.$$.on_destroy.push(function(e,...n){if(null==e){for(const t of n)t(void 0);return t}const r=e.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}(n,r))}function a(t,e,n){return t.set(n),e}const l="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function c(t,e){t.appendChild(e)}function u(t,e,n){t.insertBefore(e,n||null)}function d(t){t.parentNode&&t.parentNode.removeChild(t)}function f(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function h(t){return document.createElement(t)}function g(t){return document.createTextNode(t)}function p(){return g(" ")}function y(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function w(t){return function(e){return e.stopPropagation(),t.call(this,e)}}function b(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function m(t,e){e=""+e,t.data!==e&&(t.data=e)}function v(t,e){t.value=null==e?"":e}function E(t,e,n,r){null==n?t.style.removeProperty(e):t.style.setProperty(e,n,"")}function x(t,e,n){t.classList.toggle(e,!!n)}let k;function $(t){k=t}function A(){if(!k)throw new Error("Function called outside component initialization");return k}function B(t){A().$$.on_mount.push(t)}function I(){const t=A();return(e,n,{cancelable:r=!1}={})=>{const s=t.$$.callbacks[e];if(s){const o=function(t,e,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:r})}(e,n,{cancelable:r});return s.slice().forEach(e=>{e.call(t,o)}),!o.defaultPrevented}return!0}}function _(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t.call(this,e))}const L=[],S=[];let C=[];const U=[],T=Promise.resolve();let N=!1;function O(t){C.push(t)}const R=new Set;let P=0;function D(){if(0!==P)return;const t=k;do{try{for(;P<L.length;){const t=L[P];P++,$(t),q(t.$$)}}catch(t){throw L.length=0,P=0,t}for($(null),L.length=0,P=0;S.length;)S.pop()();for(let t=0;t<C.length;t+=1){const e=C[t];R.has(e)||(R.add(e),e())}C.length=0}while(L.length);for(;U.length;)U.pop()();N=!1,R.clear(),$(t)}function q(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(O)}}const H=new Set;let F;function V(){F={r:0,c:[],p:F}}function j(){F.r||r(F.c),F=F.p}function z(t,e){t&&t.i&&(H.delete(t),t.i(e))}function K(t,e,n,r){if(t&&t.o){if(H.has(t))return;H.add(t),F.c.push(()=>{H.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function M(t){return void 0!==t?.length?t:Array.from(t)}function Z(t){t&&t.c()}function G(t,n,o){const{fragment:i,after_update:a}=t.$$;i&&i.m(n,o),O(()=>{const n=t.$$.on_mount.map(e).filter(s);t.$$.on_destroy?t.$$.on_destroy.push(...n):r(n),t.$$.on_mount=[]}),a.forEach(O)}function W(t,e){const n=t.$$;null!==n.fragment&&(!function(t){const e=[],n=[];C.forEach(r=>-1===t.indexOf(r)?e.push(r):n.push(r)),n.forEach(t=>t()),C=e}(n.after_update),r(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Y(t,e){-1===t.$$.dirty[0]&&(L.push(t),N||(N=!0,T.then(D)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function J(e,s,o,i,a,l,c=null,u=[-1]){const f=k;$(e);const h=e.$$={fragment:null,ctx:[],props:l,update:t,not_equal:a,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(s.context||(f?f.$$.context:[])),callbacks:n(),dirty:u,skip_bound:!1,root:s.target||f.$$.root};c&&c(h.root);let g=!1;if(h.ctx=o?o(e,s.props||{},(t,n,...r)=>{const s=r.length?r[0]:n;return h.ctx&&a(h.ctx[t],h.ctx[t]=s)&&(!h.skip_bound&&h.bound[t]&&h.bound[t](s),g&&Y(e,t)),n}):[],h.update(),g=!0,r(h.before_update),h.fragment=!!i&&i(h.ctx),s.target){if(s.hydrate){const t=function(t){return Array.from(t.childNodes)}(s.target);h.fragment&&h.fragment.l(t),t.forEach(d)}else h.fragment&&h.fragment.c();s.intro&&z(e.$$.fragment),G(e,s.target,s.anchor),D()}$(f)}class Q{$$=void 0;$$set=void 0;$destroy(){W(this,1),this.$destroy=t}$on(e,n){if(!s(n))return t;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const t=r.indexOf(n);-1!==t&&r.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function X(e){let n,r,s;return{c(){n=h("button"),n.textContent="Login",b(n,"class","login-header-btn svelte-1bc06ax")},m(t,o){u(t,n,o),r||(s=y(n,"click",e[9]),r=!0)},p:t,d(t){t&&d(n),r=!1,s()}}}function tt(t){let e,n,s,o,i,a,l,f,w,v,E,k,$,A,B=nt(t[2])+"";return{c(){e=h("nav"),n=h("button"),n.textContent="Dashboard",s=p(),o=h("button"),o.textContent="Config",i=p(),a=h("button"),a.textContent="Update",l=p(),f=h("div"),w=h("span"),v=g(B),E=p(),k=h("button"),k.textContent="Logout",b(n,"class","nav-btn svelte-1bc06ax"),x(n,"active","dashboard"===t[0]),b(o,"class","nav-btn svelte-1bc06ax"),x(o,"active","config"===t[0]),b(a,"class","nav-btn svelte-1bc06ax"),x(a,"active","update"===t[0]),b(e,"class","svelte-1bc06ax"),b(w,"class","pubkey svelte-1bc06ax"),b(k,"class","logout-btn svelte-1bc06ax"),b(f,"class","user-section svelte-1bc06ax")},m(r,d){u(r,e,d),c(e,n),c(e,s),c(e,o),c(e,i),c(e,a),u(r,l,d),u(r,f,d),c(f,w),c(w,v),c(f,E),c(f,k),$||(A=[y(n,"click",t[5]),y(o,"click",t[6]),y(a,"click",t[7]),y(k,"click",t[8])],$=!0)},p(t,e){1&e&&x(n,"active","dashboard"===t[0]),1&e&&x(o,"active","config"===t[0]),1&e&&x(a,"active","update"===t[0]),4&e&&B!==(B=nt(t[2])+"")&&m(v,B)},d(t){t&&(d(e),d(l),d(f)),$=!1,r(A)}}}function et(e){let n,r,s,o;function i(t,e){return t[1]?tt:X}let a=i(e),l=a(e);return{c(){n=h("header"),r=h("div"),s=h("h1"),s.textContent="ORLY Launcher",o=p(),l.c(),b(s,"class","svelte-1bc06ax"),b(r,"class","header-content svelte-1bc06ax"),b(n,"class","svelte-1bc06ax")},m(t,e){u(t,n,e),c(n,r),c(r,s),c(r,o),l.m(r,null)},p(t,[e]){a===(a=i(t))&&l?l.p(t,e):(l.d(1),l=a(t),l&&(l.c(),l.m(r,null)))},i:t,o:t,d(t){t&&d(n),l.d()}}}function nt(t){return t?t.slice(0,8)+"..."+t.slice(-4):""}function rt(t,e,n){const r=I();let{currentPage:s="dashboard"}=e,{isLoggedIn:o=!1}=e,{userPubkey:i=""}=e;function a(t){r("navigate",t)}return t.$$set=t=>{"currentPage"in t&&n(0,s=t.currentPage),"isLoggedIn"in t&&n(1,o=t.isLoggedIn),"userPubkey"in t&&n(2,i=t.userPubkey)},[s,o,i,r,a,()=>a("dashboard"),()=>a("config"),()=>a("update"),()=>r("logout"),()=>r("login")]}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class st extends Q{constructor(t){super(),J(this,t,rt,et,o,{currentPage:0,isLoggedIn:1,userPubkey:2})}}function ot(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function it(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function at(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}const lt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ct=t=>t instanceof Uint8Array,ut=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),dt=(t,e)=>t<<32-e|t>>>e; |
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function ft(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ct(t))throw new Error("expected Uint8Array, got "+typeof t);return t}let ht=class{clone(){return this._cloneInto()}};function gt(t){const e=e=>t().update(ft(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function pt(t=32){if(lt&&"function"==typeof lt.getRandomValues)return lt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}let yt=class extends ht{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ut(this.buffer)}update(t){at(this);const{view:e,buffer:n,blockLen:r}=this,s=(t=ft(t)).length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);if(i===r){const e=ut(t);for(;r<=s-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){at(this),function(t,e){it(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),l=r?4:0,c=r?0:4;t.setUint32(e+l,i,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const i=ut(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)i.setUint32(4*t,c[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:s,destroyed:o,pos:i}=this;return t.length=r,t.pos=i,t.finished=s,t.destroyed=o,r%e&&t.buffer.set(n),t}};const wt=(t,e,n)=>t&e^~t&n,bt=(t,e,n)=>t&e^t&n^e&n,mt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Et=new Uint32Array(64);let xt=class extends yt{constructor(){super(64,32,8,!1),this.A=0|vt[0],this.B=0|vt[1],this.C=0|vt[2],this.D=0|vt[3],this.E=0|vt[4],this.F=0|vt[5],this.G=0|vt[6],this.H=0|vt[7]}get(){const{A:t,B:e,C:n,D:r,E:s,F:o,G:i,H:a}=this;return[t,e,n,r,s,o,i,a]}set(t,e,n,r,s,o,i,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)Et[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Et[t-15],n=Et[t-2],r=dt(e,7)^dt(e,18)^e>>>3,s=dt(n,17)^dt(n,19)^n>>>10;Et[t]=s+Et[t-7]+r+Et[t-16]|0}let{A:n,B:r,C:s,D:o,E:i,F:a,G:l,H:c}=this;for(let t=0;t<64;t++){const e=c+(dt(i,6)^dt(i,11)^dt(i,25))+wt(i,a,l)+mt[t]+Et[t]|0,u=(dt(n,2)^dt(n,13)^dt(n,22))+bt(n,r,s)|0;c=l,l=a,a=i,i=o+e|0,o=s,s=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,s,o,i,a,l,c)}roundClean(){Et.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const kt=gt(()=>new xt); |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const $t=BigInt(1),At=BigInt(2),Bt=t=>t instanceof Uint8Array,It=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _t(t){if(!Bt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=It[t[n]];return e}function Lt(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function St(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let e=0;e<n.length;e++){const r=2*e,s=t.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[e]=o}return n}function Ct(t){return Lt(_t(t))}function Ut(t){if(!Bt(t))throw new Error("Uint8Array expected");return Lt(_t(Uint8Array.from(t).reverse()))}function Tt(t,e){return St(t.toString(16).padStart(2*e,"0"))}function Nt(t,e){return Tt(t,e).reverse()}function Ot(t,e,n){let r;if("string"==typeof e)try{r=St(e)}catch(n){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${n}`)}else{if(!Bt(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(`${t} expected ${n} bytes, got ${s}`);return r}function Rt(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!Bt(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}const Pt=t=>(At<<BigInt(t-1))-$t,Dt=t=>new Uint8Array(t),qt=t=>Uint8Array.from(t);function Ht(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Dt(t),s=Dt(t),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},a=(...t)=>n(s,r,...t),l=(t=Dt())=>{s=a(qt([0]),t),r=a(),0!==t.length&&(s=a(qt([1]),t),r=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return Rt(...n)};return(t,e)=>{let n;for(i(),l(t);!(n=e(c()));)l();return i(),n}}const Ft={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function Vt(t,e,n={}){const r=(e,n,r)=>{const s=Ft[n];if("function"!=typeof s)throw new Error(`Invalid validator "${n}", expected function`);const o=t[e];if(!(r&&void 0===o||s(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${n}`)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}var jt=Object.freeze({__proto__:null,bitMask:Pt,bytesToHex:_t,bytesToNumberBE:Ct,bytesToNumberLE:Ut,concatBytes:Rt,createHmacDrbg:Ht,ensureBytes:Ot,hexToBytes:St,hexToNumber:Lt,numberToBytesBE:Tt,numberToBytesLE:Nt,validateObject:Vt}); |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zt=BigInt(0),Kt=BigInt(1),Mt=BigInt(2),Zt=BigInt(3),Gt=BigInt(4),Wt=BigInt(5),Yt=BigInt(8);function Jt(t,e){const n=t%e;return n>=zt?n:e+n}function Qt(t,e,n){if(n<=zt||e<zt)throw new Error("Expected power/modulo > 0");if(n===Kt)return zt;let r=Kt;for(;e>zt;)e&Kt&&(r=r*t%n),t=t*t%n,e>>=Kt;return r}function Xt(t,e,n){let r=t;for(;e-- >zt;)r*=r,r%=n;return r}function te(t,e){if(t===zt||e<=zt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Jt(t,e),r=e,s=zt,o=Kt;for(;n!==zt;){const t=r%n,e=s-o*(r/n);r=n,n=t,s=o,o=e}if(r!==Kt)throw new Error("invert: does not exist");return Jt(s,e)}function ee(t){if(t%Gt===Zt){const e=(t+Kt)/Gt;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%Yt===Wt){const e=(t-Wt)/Yt;return function(t,n){const r=t.mul(n,Mt),s=t.pow(r,e),o=t.mul(n,s),i=t.mul(t.mul(o,Mt),s),a=t.mul(o,t.sub(i,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-Kt)/Mt;let n,r,s;for(n=t-Kt,r=0;n%Mt===zt;n/=Mt,r++);for(s=Mt;s<t&&Qt(s,e,t)!==t-Kt;s++);if(1===r){const e=(t+Kt)/Gt;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}const o=(n+Kt)/Mt;return function(t,i){if(t.pow(i,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=r,l=t.pow(t.mul(t.ONE,s),n),c=t.pow(i,o),u=t.pow(i,n);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<a&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const n=t.pow(l,Kt<<BigInt(a-e-1));l=t.sqr(n),c=t.mul(c,n),u=t.mul(u,l),a=e}return c}}(t)}BigInt(9),BigInt(16);const ne=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function re(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function se(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function oe(t){const e=se(t);return e+Math.ceil(e/2)} |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ |
|
const ie=BigInt(0),ae=BigInt(1);function le(t){return Vt(t.Fp,ne.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Vt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...re(t.n,t.nBitLength),...t,p:t.Fp.ORDER})} |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:ce,hexToBytes:ue}=jt,de={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=de;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ce(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=de,n="string"==typeof t?ue(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:o}=de._parseInt(n.subarray(2)),{d:i,l:a}=de._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),s=e(n(t.r)),o=r.length/2,i=s.length/2,a=n(o),l=n(i);return`30${n(i+o+4)}02${l}${s}02${a}${r}`}},fe=BigInt(0),he=BigInt(1);BigInt(2);const ge=BigInt(3);function pe(t){const e=function(t){const e=le(t);Vt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const s=e.toAffine();return Rt(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),s=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function o(t){const{a:r,b:s}=e,o=n.sqr(t),i=n.mul(o,t);return n.add(n.add(i,n.mul(t,r)),s)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(t){return"bigint"==typeof t&&fe<t&&t<e.n}function a(t){if(!i(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:o}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=_t(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*r,"0")}let i;try{i="bigint"==typeof t?t:Ct(Ot("private key",t,r))}catch(e){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return s&&(i=Jt(i,o)),a(i),i}const c=new Map;function u(t){if(!(t instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof d)throw new Error("projective point not allowed");const s=t=>n.eql(t,n.ZERO);return s(e)&&s(r)?d.ZERO:new d(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(d.fromAffine)}static fromHex(t){const e=d.fromAffine(s(Ot("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return d.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const s=n.sqr(r),i=o(t);if(!n.eql(s,i))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:s}=this,{px:o,py:i,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(o,s)),c=n.eql(n.mul(r,a),n.mul(i,s));return l&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,s=n.mul(r,ge),{px:o,py:i,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(o,o),h=n.mul(i,i),g=n.mul(a,a),p=n.mul(o,i);return p=n.add(p,p),u=n.mul(o,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(s,g),c=n.add(l,c),l=n.sub(h,c),c=n.add(h,c),c=n.mul(l,c),l=n.mul(p,l),u=n.mul(s,u),g=n.mul(t,g),p=n.sub(f,g),p=n.mul(t,p),p=n.add(p,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,g),f=n.mul(f,p),c=n.add(c,f),g=n.mul(i,a),g=n.add(g,g),f=n.mul(g,p),l=n.sub(l,f),u=n.mul(g,h),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(t){u(t);const{px:r,py:s,pz:o}=this,{px:i,py:a,pz:l}=t;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const g=e.a,p=n.mul(e.b,ge);let y=n.mul(r,i),w=n.mul(s,a),b=n.mul(o,l),m=n.add(r,s),v=n.add(i,a);m=n.mul(m,v),v=n.add(y,w),m=n.sub(m,v),v=n.add(r,o);let E=n.add(i,l);return v=n.mul(v,E),E=n.add(y,b),v=n.sub(v,E),E=n.add(s,o),c=n.add(a,l),E=n.mul(E,c),c=n.add(w,b),E=n.sub(E,c),h=n.mul(g,v),c=n.mul(p,b),h=n.add(c,h),c=n.sub(w,h),h=n.add(w,h),f=n.mul(c,h),w=n.add(y,y),w=n.add(w,y),b=n.mul(g,b),v=n.mul(p,v),w=n.add(w,b),b=n.sub(y,b),b=n.mul(g,b),v=n.add(v,b),y=n.mul(w,v),f=n.add(f,y),y=n.mul(E,v),c=n.mul(m,c),c=n.sub(c,y),y=n.mul(m,w),h=n.mul(E,h),h=n.add(h,y),new d(c,f,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(d.ZERO)}wNAF(t){return h.wNAFCached(this,c,t,t=>{const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(d.fromAffine)})}multiplyUnsafe(t){const r=d.ZERO;if(t===fe)return r;if(a(t),t===he)return this;const{endo:s}=e;if(!s)return h.unsafeLadder(this,t);let{k1neg:o,k1:i,k2neg:l,k2:c}=s.splitScalar(t),u=r,f=r,g=this;for(;i>fe||c>fe;)i&he&&(u=u.add(g)),c&he&&(f=f.add(g)),g=g.double(),i>>=he,c>>=he;return o&&(u=u.negate()),l&&(f=f.negate()),f=new d(n.mul(f.px,s.beta),f.py,f.pz),u.add(f)}multiply(t){a(t);let r,s,o=t;const{endo:i}=e;if(i){const{k1neg:t,k1:e,k2neg:a,k2:l}=i.splitScalar(o);let{p:c,f:u}=this.wNAF(e),{p:f,f:g}=this.wNAF(l);c=h.constTimeNegate(t,c),f=h.constTimeNegate(a,f),f=new d(n.mul(f.px,i.beta),f.py,f.pz),r=c.add(f),s=u.add(g)}else{const{p:t,f:e}=this.wNAF(o);r=t,s=e}return d.normalizeZ([r,s])[0]}multiplyAndAddUnsafe(t,e,n){const r=d.BASE,s=(t,e)=>e!==fe&&e!==he&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),o=s(this,e).add(s(t,n));return o.is0()?void 0:o}toAffine(t){const{px:e,py:r,pz:s}=this,o=this.is0();null==t&&(t=o?n.ONE:n.inv(s));const i=n.mul(e,t),a=n.mul(r,t),l=n.mul(s,t);if(o)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:i,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===he)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===he?this:n?n(d,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(d,this,t)}toHex(t=!0){return _t(this.toRawBytes(t))}}d.BASE=new d(e.Gx,e.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=e.nBitLength,h=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,s=e;for(;n>ie;)n&ae&&(r=r.add(s)),s=s.double(),n>>=ae;return r},precomputeWindow(t,e){const{windows:n,windowSize:s}=r(e),o=[];let i=t,a=i;for(let t=0;t<n;t++){a=i,o.push(a);for(let t=1;t<s;t++)a=a.add(i),o.push(a);i=a.double()}return o},wNAF(e,s,o){const{windows:i,windowSize:a}=r(e);let l=t.ZERO,c=t.BASE;const u=BigInt(2**e-1),d=2**e,f=BigInt(e);for(let t=0;t<i;t++){const e=t*a;let r=Number(o&u);o>>=f,r>a&&(r-=d,o+=ae);const i=e,h=e+Math.abs(r)-1,g=t%2!=0,p=r<0;0===r?c=c.add(n(g,s[i])):l=l.add(n(p,s[h]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const s=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,s),1!==s&&e.set(t,r(o))),this.wNAF(s,o,n)}}}(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:i}}function ye(t){const e=function(t){const e=le(t);return Vt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,s=n.BYTES+1,o=2*n.BYTES+1;function i(t){return Jt(t,r)}function a(t){return te(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=pe({...e,toBytes(t,e,r){const s=e.toAffine(),o=n.toBytes(s.x),i=Rt;return r?i(Uint8Array.from([e.hasEvenY()?2:3]),o):i(Uint8Array.from([4]),o,n.toBytes(s.y))},fromBytes(t){const e=t.length,r=t[0],i=t.subarray(1);if(e!==s||2!==r&&3!==r){if(e===o&&4===r){return{x:n.fromBytes(i.subarray(0,n.BYTES)),y:n.fromBytes(i.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}{const t=Ct(i);if(!(fe<(a=t)&&a<n.ORDER))throw new Error("Point is not on curve");const e=u(t);let s=n.sqrt(e);return!(1&~r)!==((s&he)===he)&&(s=n.neg(s)),{x:t,y:s}}var a}}),f=t=>_t(Tt(t,e.nByteLength));function h(t){return t>r>>he}const g=(t,e,n)=>Ct(t.slice(e,n));class p{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=Ot("compactSignature",t,2*n),new p(g(t,0,n),g(t,n,2*n))}static fromDER(t){const{r:e,s:n}=de.toSig(Ot("DER",t));return new p(e,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new p(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:s,recovery:o}=this,c=m(Ot("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&o?"03":"02",h=l.fromHex(d+f(u)),g=a(u),p=i(-c*g),y=i(s*g),w=l.BASE.multiplyAndAddUnsafe(h,p,y);if(!w)throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return St(this.toDERHex())}toDERHex(){return de.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return St(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=oe(e.n);return function(t,e,n=!1){const r=t.length,s=se(e),o=oe(e);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const i=Jt(n?Ct(t):Ut(t),e-Kt)+Kt;return n?Nt(i,s):Tt(i,s)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function w(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===s||r===o:n?r===2*s||r===2*o:t instanceof l}const b=e.bits2int||function(t){const n=Ct(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},m=e.bits2int_modN||function(t){return i(b(t))},v=Pt(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(fe<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Tt(t,e.nByteLength)}function x(t,r,s=k){if(["recovered","canonical"].some(t=>t in s))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:u}=e;let{lowS:f,prehash:g,extraEntropy:y}=s;null==f&&(f=!0),t=Ot("msgHash",t),g&&(t=Ot("prehashed msgHash",o(t)));const w=m(t),v=c(r),x=[E(v),E(w)];if(null!=y){const t=!0===y?u(n.BYTES):y;x.push(Ot("extraEntropy",t))}const $=Rt(...x),A=w;return{seed:$,k2sig:function(t){const e=b(t);if(!d(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),s=i(r.x);if(s===fe)return;const o=i(n*i(A+s*v));if(o===fe)return;let c=(r.x===s?0:2)|Number(r.y&he),u=o;return f&&h(o)&&(u=function(t){return h(t)?i(-t):t}(o),c^=1),new p(s,u,c)}}}const k={lowS:e.lowS,prehash:!1},$={lowS:e.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return l.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(w(t))throw new Error("first arg must be private key");if(!w(e))throw new Error("second arg must be public key");return l.fromHex(e).multiply(c(t)).toRawBytes(n)},sign:function(t,n,r=k){const{seed:s,k2sig:o}=x(t,n,r),i=e;return Ht(i.hash.outputLen,i.nByteLength,i.hmac)(s,o)},verify:function(t,n,r,s=$){const o=t;if(n=Ot("msgHash",n),r=Ot("publicKey",r),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=s;let d,f;try{if("string"==typeof o||o instanceof Uint8Array)try{d=p.fromDER(o)}catch(t){if(!(t instanceof de.Err))throw t;d=p.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;d=new p(t,e)}}f=l.fromHex(r)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=e.hash(n));const{r:h,s:g}=d,y=m(n),w=a(g),b=i(y*w),v=i(h*w),E=l.BASE.multiplyAndAddUnsafe(f,b,v)?.toAffine();return!!E&&i(E.x)===h},ProjectivePoint:l,Signature:p,utils:y}}BigInt(4);class we extends ht{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ot(t.outputLen),ot(t.blockLen)}(t);const n=ft(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){return at(this),this.iHash.update(t),this}digestInto(t){at(this),it(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:s,blockLen:o,outputLen:i}=this;return t.finished=r,t.destroyed=s,t.blockLen=o,t.outputLen=i,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const be=(t,e,n)=>new we(t,e).update(n).digest(); |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ |
|
function me(t){return{hash:t,hmac:(e,...n)=>be(t,e,function(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!ct(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}(...n)),randomBytes:pt}}be.create=(t,e)=>new we(t,e); |
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ |
|
const ve=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ee=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xe=BigInt(1),ke=BigInt(2),$e=(t,e)=>(t+e/ke)/e;function Ae(t){const e=ve,n=BigInt(3),r=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,d=Xt(u,n,e)*u%e,f=Xt(d,n,e)*u%e,h=Xt(f,ke,e)*c%e,g=Xt(h,s,e)*h%e,p=Xt(g,o,e)*g%e,y=Xt(p,a,e)*p%e,w=Xt(y,l,e)*y%e,b=Xt(w,a,e)*p%e,m=Xt(b,n,e)*u%e,v=Xt(m,i,e)*g%e,E=Xt(v,r,e)*c%e,x=Xt(E,ke,e);if(!Be.eql(Be.sqr(x),t))throw new Error("Cannot find square root");return x}const Be=function(t,e,n=!1,r={}){if(t<=zt)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:s,nByteLength:o}=re(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=ee(t),a=Object.freeze({ORDER:t,BITS:s,BYTES:o,MASK:Pt(s),ZERO:zt,ONE:Kt,create:e=>Jt(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return zt<=e&&e<t},is0:t=>t===zt,isOdd:t=>(t&Kt)===Kt,neg:e=>Jt(-e,t),eql:(t,e)=>t===e,sqr:e=>Jt(e*e,t),add:(e,n)=>Jt(e+n,t),sub:(e,n)=>Jt(e-n,t),mul:(e,n)=>Jt(e*n,t),pow:(t,e)=>function(t,e,n){if(n<zt)throw new Error("Expected power > 0");if(n===zt)return t.ONE;if(n===Kt)return e;let r=t.ONE,s=e;for(;n>zt;)n&Kt&&(r=t.mul(r,s)),s=t.sqr(s),n>>=Kt;return r}(a,t,e),div:(e,n)=>Jt(e*te(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>te(e,t),sqrt:r.sqrt||(t=>i(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce((e,r,s)=>t.is0(r)?e:(n[s]=e,t.mul(e,r)),t.ONE),s=t.inv(r);return e.reduceRight((e,r,s)=>t.is0(r)?e:(n[s]=t.mul(e,n[s]),t.mul(e,r)),s),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?Nt(t,o):Tt(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return n?Ut(t):Ct(t)}});return Object.freeze(a)}(ve,void 0,void 0,{sqrt:Ae}),Ie=function(t,e){const n=e=>ye({...t,...me(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Be,n:Ee,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ee,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-xe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,i=BigInt("0x100000000000000000000000000000000"),a=$e(o*t,e),l=$e(-r*t,e);let c=Jt(t-a*n-l*s,e),u=Jt(-a*r-l*o,e);const d=c>i,f=u>i;if(d&&(c=e-c),f&&(u=e-u),c>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},kt),_e=BigInt(0),Le=t=>"bigint"==typeof t&&_e<t&&t<ve,Se={};function Ce(t,...e){let n=Se[t];if(void 0===n){const e=kt(Uint8Array.from(t,t=>t.charCodeAt(0)));n=Rt(e,e),Se[t]=n}return kt(Rt(n,...e))}const Ue=t=>t.toRawBytes(!0).slice(1),Te=t=>Tt(t,32),Ne=t=>Jt(t,ve),Oe=t=>Jt(t,Ee),Re=Ie.ProjectivePoint;function Pe(t){let e=Ie.utils.normPrivateKeyToScalar(t),n=Re.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Oe(-e),bytes:Ue(n)}}function De(t){if(!Le(t))throw new Error("bad x: need 0 < x < p");const e=Ne(t*t);let n=Ae(Ne(e*t+BigInt(7)));n%ke!==_e&&(n=Ne(-n));const r=new Re(t,n,xe);return r.assertValidity(),r}function qe(...t){return Oe(Ct(Ce("BIP0340/challenge",...t)))}function He(t){return Pe(t).bytes}function Fe(t,e,n=pt(32)){const r=Ot("message",t),{bytes:s,scalar:o}=Pe(e),i=Ot("auxRand",n,32),a=Te(o^Ct(Ce("BIP0340/aux",i))),l=Ce("BIP0340/nonce",a,s,r),c=Oe(Ct(l));if(c===_e)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Pe(c),f=qe(u,s,r),h=new Uint8Array(64);if(h.set(u,0),h.set(Te(Oe(d+f*o)),32),!Ve(h,r,s))throw new Error("sign: Invalid signature produced");return h}function Ve(t,e,n){const r=Ot("signature",t,64),s=Ot("message",e),o=Ot("publicKey",n,32);try{const t=De(Ct(o)),e=Ct(r.subarray(0,32));if(!Le(e))return!1;const n=Ct(r.subarray(32,64));if(!("bigint"==typeof(c=n)&&_e<c&&c<Ee))return!1;const u=qe(Te(e),Ue(t),s),d=(i=t,a=n,l=Oe(-u),Re.BASE.multiplyAndAddUnsafe(i,a,l));return!(!d||!d.hasEvenY()||d.toAffine().x!==e)}catch(t){return!1}var i,a,l,c}const je=(()=>({getPublicKey:He,sign:Fe,verify:Ve,utils:{randomPrivateKey:Ie.utils.randomPrivateKey,lift_x:De,pointToBytes:Ue,numberToBytesBE:Tt,bytesToNumberBE:Ct,taggedHash:Ce,mod:Jt}}))(),ze=t=>t instanceof Uint8Array,Ke=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Me=(t,e)=>t<<32-e|t>>>e; |
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const Ze=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ge(t){if(!ze(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Ze[t[n]];return e}function We(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ze(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ye{clone(){return this._cloneInto()}}function Je(t){const e=e=>t().update(We(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Qe(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Xe(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}const tn={number:Qe,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:Xe,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Qe(t.outputLen),Qe(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){Xe(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}};class en extends Ye{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ke(this.buffer)}update(t){tn.exists(this);const{view:e,buffer:n,blockLen:r}=this,s=(t=We(t)).length;for(let o=0;o<s;){const i=Math.min(r-this.pos,s-o);if(i===r){const e=Ke(t);for(;r<=s-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){tn.exists(this),tn.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:s}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),l=r?4:0,c=r?0:4;t.setUint32(e+l,i,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const i=Ke(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)i.setUint32(4*t,c[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:s,destroyed:o,pos:i}=this;return t.length=r,t.pos=i,t.finished=s,t.destroyed=o,r%e&&t.buffer.set(n),t}}const nn=(t,e,n)=>t&e^~t&n,rn=(t,e,n)=>t&e^t&n^e&n,sn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),on=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64);class ln extends en{constructor(){super(64,32,8,!1),this.A=0|on[0],this.B=0|on[1],this.C=0|on[2],this.D=0|on[3],this.E=0|on[4],this.F=0|on[5],this.G=0|on[6],this.H=0|on[7]}get(){const{A:t,B:e,C:n,D:r,E:s,F:o,G:i,H:a}=this;return[t,e,n,r,s,o,i,a]}set(t,e,n,r,s,o,i,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|o,this.G=0|i,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)an[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=an[t-15],n=an[t-2],r=Me(e,7)^Me(e,18)^e>>>3,s=Me(n,17)^Me(n,19)^n>>>10;an[t]=s+an[t-7]+r+an[t-16]|0}let{A:n,B:r,C:s,D:o,E:i,F:a,G:l,H:c}=this;for(let t=0;t<64;t++){const e=c+(Me(i,6)^Me(i,11)^Me(i,25))+nn(i,a,l)+sn[t]+an[t]|0,u=(Me(n,2)^Me(n,13)^Me(n,22))+rn(n,r,s)|0;c=l,l=a,a=i,i=o+e|0,o=s,s=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,o=o+this.D|0,i=i+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,s,o,i,a,l,c)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class cn extends ln{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const un=Je(()=>new ln);Je(()=>new cn);var dn=Symbol("verified");function fn(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let t=0;t<n.length;t++)if("string"!=typeof n[t])return!1}return!0}new TextDecoder("utf-8");var hn=new TextEncoder;function gn(t){return Ge(un(hn.encode(function(t){if(!fn(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t))))}var pn=new class{generateSecretKey(){return je.utils.randomPrivateKey()}getPublicKey(t){return Ge(je.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=Ge(je.getPublicKey(e)),n.id=gn(n),n.sig=Ge(je.sign(gn(n),e)),n[dn]=!0,n}verifyEvent(t){if("boolean"==typeof t[dn])return t[dn];const e=gn(t);if(e!==t.id)return t[dn]=!1,!1;try{const n=je.verify(t.sig,e,t.pubkey);return t[dn]=n,n}catch(e){return t[dn]=!1,!1}}},yn=pn.generateSecretKey,wn=pn.getPublicKey,bn=pn.finalizeEvent; |
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ |
|
function mn(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function vn(...t){const e=(t,e)=>n=>t(e(n)),n=Array.from(t).reverse().reduce((t,n)=>t?e(t,n.encode):n.encode,void 0),r=t.reduce((t,n)=>t?e(t,n.decode):n.decode,void 0);return{encode:n,decode:r}}function En(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map(e=>{if(mn(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]})},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map(e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n})}}}function xn(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function kn(t,e="="){if(mn(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function $n(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function An(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const s=[],o=Array.from(t);for(o.forEach(t=>{if(mn(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)});;){let t=0,i=!0;for(let s=r;s<o.length;s++){const a=o[s],l=e*t+a;if(!Number.isSafeInteger(l)||e*t/e!==t||l-a!==e*t)throw new Error("convertRadix: carry overflow");if(t=l%n,o[s]=Math.floor(l/n),!Number.isSafeInteger(o[s])||o[s]*n+t!==l)throw new Error("convertRadix: carry overflow");i&&(o[s]?i=!1:r=s)}if(s.push(t),i)break}for(let e=0;e<t.length-1&&0===t[e];e++)s.push(0);return s.reverse()}pn.verifyEvent;const Bn=(t,e)=>e?Bn(e,t%e):t,In=(t,e)=>t+(e-Bn(t,e));function _n(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(In(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${In(e,n)}`);let s=0,o=0;const i=2**n-1,a=[];for(const r of t){if(mn(r),r>=2**e)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(s=s<<e|r,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)a.push((s>>o-n&i)>>>0);s&=2**o-1}if(s=s<<n-o&i,!r&&o>=e)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&a.push(s>>>0),a}function Ln(t,e=!1){if(mn(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(In(8,t)>32||In(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return _n(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(_n(n,t,8,e))}}}function Sn(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}const Cn=vn(Ln(4),En("0123456789ABCDEF"),xn("")),Un=vn(Ln(5),En("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),kn(5),xn(""));vn(Ln(5),En("0123456789ABCDEFGHIJKLMNOPQRSTUV"),kn(5),xn("")),vn(Ln(5),En("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),xn(""),$n(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Tn=vn(Ln(6),En("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),kn(6),xn("")),Nn=vn(Ln(6),En("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),kn(6),xn("")),On=t=>{return vn((mn(e=58),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return An(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(An(t,e,256))}}),En(t),xn(""));var e},Rn=On("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");On("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),On("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Pn=[0,2,3,5,6,7,9,10,11],Dn={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Rn.encode(r).padStart(Pn[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),s=Pn.indexOf(r.length),o=Rn.decode(r);for(let t=0;t<o.length-s;t++)if(0!==o[t])throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(o.slice(o.length-s)))}return Uint8Array.from(e)}},qn=vn(En("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),xn("")),Hn=[996825010,642813549,513874426,1027748829,705979059];function Fn(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<Hn.length;t++)1==(e>>t&1)&&(n^=Hn[t]);return n}function Vn(t,e,n=1){const r=t.length;let s=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);s=Fn(s)^n>>5}s=Fn(s);for(let e=0;e<r;e++)s=Fn(s)^31&t.charCodeAt(e);for(let t of e)s=Fn(s)^t;for(let t=0;t<6;t++)s=Fn(s);return s^=n,qn.encode(_n([s%2**30],30,5,!1))}function jn(t){const e="bech32"===t?1:734539939,n=Ln(5),r=n.decode,s=n.encode,o=Sn(r);function i(t,n=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==n&&t.length>n)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(t=r).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const o=t.slice(0,s),i=t.slice(s+1);if(i.length<6)throw new Error("Data must be at least 6 characters long");const a=qn.decode(i).slice(0,-6),l=Vn(o,a,e);if(!i.endsWith(l))throw new Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:o,words:a}}return{encode:function(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=t.length+7+n.length;if(!1!==r&&s>r)throw new TypeError(`Length ${s} exceeds limit ${r}`);return`${t=t.toLowerCase()}1${qn.encode(n)}${Vn(t,n,e)}`},decode:i,decodeToBytes:function(t){const{prefix:e,words:n}=i(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:Sn(i),fromWords:r,fromWordsUnsafe:o,toWords:s}}const zn=jn("bech32");jn("bech32m");const Kn={utf8:{encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},hex:vn(Ln(4),En("0123456789abcdef"),xn(""),$n(t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),base16:Cn,base32:Un,base64:Tn,base64url:Nn,base58:Rn,base58xmr:Dn};Object.keys(Kn).join(", ");var Mn=new TextDecoder("utf-8");new TextEncoder;function Zn(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],s=n.slice(2,2+r);if(n=n.slice(2+r),s.length<r)throw new Error(`not enough data to read on TLV ${t}`);e[t]=e[t]||[],e[t].push(s)}return e}function Gn(t){return Wn("npub",function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let e=0;e<n.length;e++){const r=2*e,s=t.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[e]=o}return n}(t))}function Wn(t,e){return function(t,e){let n=zn.toWords(e);return zn.encode(t,n,5e3)}(t,e)}const{window:Yn}=l;function Jn(t){let e,n,s,o,i,a,l,f,g,m,v,E,k,$,A,B,I,_;function L(t,e){return"extension"===t[2]?Xn:Qn}let S=L(t),C=S(t),U=t[5]&&er(t),T=t[6]&&nr(t);return{c(){e=h("div"),n=h("div"),s=h("div"),o=h("h2"),o.textContent="Login to Launcher Admin",i=p(),a=h("button"),a.textContent="×",l=p(),f=h("div"),g=h("div"),m=h("button"),m.textContent="Extension",v=p(),E=h("button"),E.textContent="Nsec",k=p(),$=h("div"),C.c(),A=p(),U&&U.c(),B=p(),T&&T.c(),b(o,"class","svelte-rhbu32"),b(a,"class","close-btn svelte-rhbu32"),b(s,"class","modal-header svelte-rhbu32"),b(m,"class","tab-btn svelte-rhbu32"),x(m,"active","extension"===t[2]),b(E,"class","tab-btn svelte-rhbu32"),x(E,"active","nsec"===t[2]),b(g,"class","tabs svelte-rhbu32"),b($,"class","tab-content svelte-rhbu32"),b(f,"class","tab-container svelte-rhbu32"),b(n,"class","modal svelte-rhbu32"),x(n,"dark-theme",t[1]),b(e,"class","modal-overlay svelte-rhbu32"),b(e,"role","button"),b(e,"tabindex","0")},m(r,d){u(r,e,d),c(e,n),c(n,s),c(s,o),c(s,i),c(s,a),c(n,l),c(n,f),c(f,g),c(g,m),c(g,v),c(g,E),c(f,k),c(f,$),C.m($,null),c($,A),U&&U.m($,null),c($,B),T&&T.m($,null),I||(_=[y(a,"click",t[8]),y(m,"click",t[16]),y(E,"click",t[17]),y(n,"click",w(t[14])),y(n,"keydown",w(t[15])),y(e,"click",t[8]),y(e,"keydown",t[19])],I=!0)},p(t,e){4&e&&x(m,"active","extension"===t[2]),4&e&&x(E,"active","nsec"===t[2]),S===(S=L(t))&&C?C.p(t,e):(C.d(1),C=S(t),C&&(C.c(),C.m($,A))),t[5]?U?U.p(t,e):(U=er(t),U.c(),U.m($,B)):U&&(U.d(1),U=null),t[6]?T?T.p(t,e):(T=nr(t),T.c(),T.m($,null)):T&&(T.d(1),T=null),2&e&&x(n,"dark-theme",t[1])},d(t){t&&d(e),C.d(),U&&U.d(),T&&T.d(),I=!1,r(_)}}}function Qn(t){let e,n,s,o,i,a,l,f,w,E,x,k,$,A,B=t[4]?"Logging in...":"Login with Nsec",I=t[7]&&tr(t);return{c(){e=h("div"),n=h("p"),n.textContent="Enter your nsec or generate a new key pair.",s=p(),o=h("button"),i=g("Generate New Key"),a=p(),I&&I.c(),l=p(),f=h("input"),w=p(),E=h("button"),x=g(B),b(n,"class","svelte-rhbu32"),b(o,"class","generate-btn svelte-rhbu32"),o.disabled=t[4],b(f,"type","password"),b(f,"placeholder","nsec1..."),f.disabled=t[4],b(f,"class","nsec-input svelte-rhbu32"),b(E,"class","login-btn svelte-rhbu32"),E.disabled=k=t[4]||!t[3].trim(),b(e,"class","nsec-login svelte-rhbu32")},m(r,d){u(r,e,d),c(e,n),c(e,s),c(e,o),c(o,i),c(e,a),I&&I.m(e,null),c(e,l),c(e,f),v(f,t[3]),c(e,w),c(e,E),c(E,x),$||(A=[y(o,"click",t[10]),y(f,"input",t[18]),y(E,"click",t[12])],$=!0)},p(t,n){16&n&&(o.disabled=t[4]),t[7]?I?I.p(t,n):(I=tr(t),I.c(),I.m(e,l)):I&&(I.d(1),I=null),16&n&&(f.disabled=t[4]),8&n&&f.value!==t[3]&&v(f,t[3]),16&n&&B!==(B=t[4]?"Logging in...":"Login with Nsec")&&m(x,B),24&n&&k!==(k=t[4]||!t[3].trim())&&(E.disabled=k)},d(t){t&&d(e),I&&I.d(),$=!1,r(A)}}}function Xn(t){let e,n,r,s,o,i,a,l=t[4]?"Connecting...":"Login with Extension";return{c(){e=h("div"),n=h("p"),n.textContent="Login using a NIP-07 browser extension like nos2x or Alby.",r=p(),s=h("button"),o=g(l),b(n,"class","svelte-rhbu32"),b(s,"class","login-btn svelte-rhbu32"),s.disabled=t[4],b(e,"class","extension-login svelte-rhbu32")},m(l,d){u(l,e,d),c(e,n),c(e,r),c(e,s),c(s,o),i||(a=y(s,"click",t[11]),i=!0)},p(t,e){16&e&&l!==(l=t[4]?"Connecting...":"Login with Extension")&&m(o,l),16&e&&(s.disabled=t[4])},d(t){t&&d(e),i=!1,a()}}}function tr(t){let e,n,r,s,o;return{c(){e=h("div"),n=h("label"),n.textContent="Your new public key (npub):",r=p(),s=h("code"),o=g(t[7]),b(n,"class","svelte-rhbu32"),b(s,"class","svelte-rhbu32"),b(e,"class","generated-info svelte-rhbu32")},m(t,i){u(t,e,i),c(e,n),c(e,r),c(e,s),c(s,o)},p(t,e){128&e&&m(o,t[7])},d(t){t&&d(e)}}}function er(t){let e,n;return{c(){e=h("div"),n=g(t[5]),b(e,"class","message error-message svelte-rhbu32")},m(t,r){u(t,e,r),c(e,n)},p(t,e){32&e&&m(n,t[5])},d(t){t&&d(e)}}}function nr(t){let e,n;return{c(){e=h("div"),n=g(t[6]),b(e,"class","message success-message svelte-rhbu32")},m(t,r){u(t,e,r),c(e,n)},p(t,e){64&e&&m(n,t[6])},d(t){t&&d(e)}}}function rr(e){let n,r,s,o=e[0]&&Jn(e);return{c(){o&&o.c(),n=g("")},m(t,i){o&&o.m(t,i),u(t,n,i),r||(s=y(Yn,"keydown",e[13]),r=!0)},p(t,[e]){t[0]?o?o.p(t,e):(o=Jn(t),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:t,o:t,d(t){t&&d(n),o&&o.d(t),r=!1,s()}}}function sr(t,e,n){const r=I();let{showModal:s=!1}=e,{isDarkTheme:o=!1}=e,i="extension",a="",l=!1,c="",u="",d="",f="";function h(){n(0,s=!1),n(3,a=""),n(5,c=""),n(6,u=""),d="",n(7,f=""),r("close")}function g(t){n(2,i=t),n(5,c=""),n(6,u=""),d="",n(7,f="")}async function p(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");const t=a.trim();let e;try{e=function(t){let{prefix:e,words:n}=zn.decode(t,5e3),r=new Uint8Array(zn.fromWords(n));switch(e){case"nprofile":{let t=Zn(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Ge(t[0][0]),relays:t[1]?t[1].map(t=>Mn.decode(t)):[]}}}case"nevent":{let t=Zn(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Ge(t[0][0]),relays:t[1]?t[1].map(t=>Mn.decode(t)):[],author:t[2]?.[0]?Ge(t[2][0]):void 0,kind:t[3]?.[0]?parseInt(Ge(t[3][0]),16):void 0}}}case"naddr":{let t=Zn(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Mn.decode(t[0][0]),pubkey:Ge(t[2][0]),kind:parseInt(Ge(t[3][0]),16),relays:t[1]?t[1].map(t=>Mn.decode(t)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:Ge(r)};default:throw new Error(`unknown prefix ${e}`)}}(t)}catch{throw new Error("Invalid nsec format")}if("nsec"!==e.type)throw new Error("Please enter an nsec (private key)");const s=e.data,o=wn(s),i={getPublicKey:async()=>o,signEvent:async t=>bn(t,s)};n(6,u="Successfully logged in!"),r("login",{method:"nsec",pubkey:o,privateKey:t,signer:i}),setTimeout(h,500)}catch(t){n(5,c=t.message)}finally{n(4,l=!1)}}return t.$$set=t=>{"showModal"in t&&n(0,s=t.showModal),"isDarkTheme"in t&&n(1,o=t.isDarkTheme)},[s,o,i,a,l,c,u,f,h,g,async function(){n(5,c=""),n(6,u="");try{const t=yn(),e=Wn("nsec",t),r=Gn(wn(t));d=e,n(7,f=r),n(3,a=e),n(6,u="New key generated!")}catch(t){n(5,c="Failed to generate key: "+t.message)}},async function(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install nos2x or Alby.");const t=await window.nostr.getPublicKey();t&&(n(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:t,signer:window.nostr}),setTimeout(h,500))}catch(t){n(5,c=t.message)}finally{n(4,l=!1)}},p,function(t){"Escape"===t.key&&h(),"Enter"===t.key&&"nsec"===i&&p()},function(e){_.call(this,t,e)},function(e){_.call(this,t,e)},()=>g("extension"),()=>g("nsec"),function(){a=this.value,n(3,a)},t=>"Escape"===t.key&&h()]}class or extends Q{constructor(t){super(),J(this,t,sr,rr,o,{showModal:0,isDarkTheme:1})}}const ir=[];function ar(e,n=t){let r;const s=new Set;function i(t){if(o(e,t)&&(e=t,r)){const t=!ir.length;for(const t of s)t[1](),ir.push(t,e);if(t){for(let t=0;t<ir.length;t+=2)ir[t][0](ir[t+1]);ir.length=0}}}function a(t){i(t(e))}return{set:i,update:a,subscribe:function(o,l=t){const c=[o,l];return s.add(c),1===s.size&&(r=n(i,a)||t),o(e),()=>{s.delete(c),0===s.size&&r&&(r(),r=null)}}}}const lr=ar(!1),cr=ar(""),ur=ar(null),dr=ar(""),fr=ar(null),hr=ar(null),gr=ar(null),pr=ar(!1),yr=ar("");async function wr(t,e={},n,r){const s=`${window.location.origin}${t}`,o=e.method||"GET",i=await async function(t,e,n,r){if(!t||!e)return null;try{const e={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",r],["method",n.toUpperCase()]],content:""},s=await t.signEvent(e),o=JSON.stringify(s);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_")}catch(t){return console.error("createNIP98Auth error:",t),null}}(n,r,o,s),a={...e.headers};return i&&(a.Authorization=`Nostr ${i}`),fetch(s,{...e,headers:a})}function br(t){let e,n,r,s,o,i=t[0].pid+"";return{c(){e=h("div"),n=h("span"),n.textContent="PID:",r=p(),s=h("span"),o=g(i),b(n,"class","label svelte-xh5u5u"),b(s,"class","value svelte-xh5u5u"),b(e,"class","detail-row svelte-xh5u5u")},m(t,i){u(t,e,i),c(e,n),c(e,r),c(e,s),c(s,o)},p(t,e){1&e&&i!==(i=t[0].pid+"")&&m(o,i)},d(t){t&&d(e)}}}function mr(t){let e,n,r,s,o,i=t[0].restarts+"";return{c(){e=h("div"),n=h("span"),n.textContent="Restarts:",r=p(),s=h("span"),o=g(i),b(n,"class","label svelte-xh5u5u"),b(s,"class","value warning svelte-xh5u5u"),b(e,"class","detail-row svelte-xh5u5u")},m(t,i){u(t,e,i),c(e,n),c(e,r),c(e,s),c(s,o)},p(t,e){1&e&&i!==(i=t[0].restarts+"")&&m(o,i)},d(t){t&&d(e)}}}function vr(e){let n,r,s,o,i,a,l,f,y,w,v,x,k,$,A,B,I,_,L,S,C,U,T=xr(e[0].status)+"",N=e[0].name+"",O=e[0].status+"",R=e[0].binary+"",P=e[0].pid>0&&br(e),D=e[0].restarts>0&&mr(e);return{c(){n=h("div"),r=h("div"),s=h("span"),o=g(T),i=p(),a=h("span"),l=g(N),f=p(),y=h("div"),w=h("div"),v=h("span"),v.textContent="Status:",x=p(),k=h("span"),$=g(O),A=p(),P&&P.c(),B=p(),I=h("div"),_=h("span"),_.textContent="Binary:",L=p(),S=h("span"),C=g(R),U=p(),D&&D.c(),b(s,"class","status-indicator svelte-xh5u5u"),E(s,"color",Er(e[0].status)),b(a,"class","process-name svelte-xh5u5u"),b(r,"class","process-header svelte-xh5u5u"),b(v,"class","label svelte-xh5u5u"),b(k,"class","value svelte-xh5u5u"),E(k,"color",Er(e[0].status)),b(w,"class","detail-row svelte-xh5u5u"),b(_,"class","label svelte-xh5u5u"),b(S,"class","value binary svelte-xh5u5u"),b(I,"class","detail-row svelte-xh5u5u"),b(y,"class","process-details svelte-xh5u5u"),b(n,"class","process-card svelte-xh5u5u")},m(t,e){u(t,n,e),c(n,r),c(r,s),c(s,o),c(r,i),c(r,a),c(a,l),c(n,f),c(n,y),c(y,w),c(w,v),c(w,x),c(w,k),c(k,$),c(y,A),P&&P.m(y,null),c(y,B),c(y,I),c(I,_),c(I,L),c(I,S),c(S,C),c(y,U),D&&D.m(y,null)},p(t,[e]){1&e&&T!==(T=xr(t[0].status)+"")&&m(o,T),1&e&&E(s,"color",Er(t[0].status)),1&e&&N!==(N=t[0].name+"")&&m(l,N),1&e&&O!==(O=t[0].status+"")&&m($,O),1&e&&E(k,"color",Er(t[0].status)),t[0].pid>0?P?P.p(t,e):(P=br(t),P.c(),P.m(y,B)):P&&(P.d(1),P=null),1&e&&R!==(R=t[0].binary+"")&&m(C,R),t[0].restarts>0?D?D.p(t,e):(D=mr(t),D.c(),D.m(y,null)):D&&(D.d(1),D=null)},i:t,o:t,d(t){t&&d(n),P&&P.d(),D&&D.d()}}}function Er(t){switch(t){case"running":return"var(--success)";case"stopped":default:return"var(--muted-color)";case"crashed":return"var(--error)"}}function xr(t){switch(t){case"running":return"●";case"stopped":return"○";case"crashed":return"✗";default:return"?"}}function kr(t,e,n){let{process:r}=e;return t.$$set=t=>{"process"in t&&n(0,r=t.process)},[r]}class $r extends Q{constructor(t){super(),J(this,t,kr,vr,o,{process:0})}}function Ar(t,e,n){const r=t.slice();return r[8]=e[n],r}function Br(t){let e,n;return{c(){e=h("div"),n=g(t[1]),b(e,"class","error-banner svelte-17dya06")},m(t,r){u(t,e,r),c(e,n)},p(t,e){2&e&&m(n,t[1])},d(t){t&&d(e)}}}function Ir(e){let n;return{c(){n=h("div"),n.textContent="Loading status...",b(n,"class","loading svelte-17dya06")},m(t,e){u(t,n,e)},p:t,i:t,o:t,d(t){t&&d(n)}}}function _r(t){let e,n,r,s,o,i,a,l,y,w,v,E,x,k,$,A,B,I,_,L,S,C,U,T=t[2].version+"",N=t[2].uptime+"",O=(t[2].processes?.length||0)+"",R=M(t[2].processes||[]),P=[];for(let e=0;e<R.length;e+=1)P[e]=Lr(Ar(t,R,e));const D=t=>K(P[t],1,1,()=>{P[t]=null});return{c(){e=h("div"),n=h("div"),r=h("span"),r.textContent="Version",s=p(),o=h("span"),i=g(T),a=p(),l=h("div"),y=h("span"),y.textContent="Uptime",w=p(),v=h("span"),E=g(N),x=p(),k=h("div"),$=h("span"),$.textContent="Processes",A=p(),B=h("span"),I=g(O),_=p(),L=h("h3"),L.textContent="Managed Processes",S=p(),C=h("div");for(let t=0;t<P.length;t+=1)P[t].c();b(r,"class","label svelte-17dya06"),b(o,"class","value svelte-17dya06"),b(n,"class","summary-card svelte-17dya06"),b(y,"class","label svelte-17dya06"),b(v,"class","value svelte-17dya06"),b(l,"class","summary-card svelte-17dya06"),b($,"class","label svelte-17dya06"),b(B,"class","value svelte-17dya06"),b(k,"class","summary-card svelte-17dya06"),b(e,"class","status-summary svelte-17dya06"),b(L,"class","svelte-17dya06"),b(C,"class","processes-grid svelte-17dya06")},m(t,d){u(t,e,d),c(e,n),c(n,r),c(n,s),c(n,o),c(o,i),c(e,a),c(e,l),c(l,y),c(l,w),c(l,v),c(v,E),c(e,x),c(e,k),c(k,$),c(k,A),c(k,B),c(B,I),u(t,_,d),u(t,L,d),u(t,S,d),u(t,C,d);for(let t=0;t<P.length;t+=1)P[t]&&P[t].m(C,null);U=!0},p(t,e){if((!U||4&e)&&T!==(T=t[2].version+"")&&m(i,T),(!U||4&e)&&N!==(N=t[2].uptime+"")&&m(E,N),(!U||4&e)&&O!==(O=(t[2].processes?.length||0)+"")&&m(I,O),4&e){let n;for(R=M(t[2].processes||[]),n=0;n<R.length;n+=1){const r=Ar(t,R,n);P[n]?(P[n].p(r,e),z(P[n],1)):(P[n]=Lr(r),P[n].c(),z(P[n],1),P[n].m(C,null))}for(V(),n=R.length;n<P.length;n+=1)D(n);j()}},i(t){if(!U){for(let t=0;t<R.length;t+=1)z(P[t]);U=!0}},o(t){P=P.filter(Boolean);for(let t=0;t<P.length;t+=1)K(P[t]);U=!1},d(t){t&&(d(e),d(_),d(L),d(S),d(C)),f(P,t)}}}function Lr(t){let e,n;return e=new $r({props:{process:t[8]}}),{c(){Z(e.$$.fragment)},m(t,r){G(e,t,r),n=!0},p(t,n){const r={};4&n&&(r.process=t[8]),e.$set(r)},i(t){n||(z(e.$$.fragment,t),n=!0)},o(t){K(e.$$.fragment,t),n=!1},d(t){W(e,t)}}}function Sr(t){let e,n,s,o,i,a,l,f,w,m,v,E,x,k,$,A,B,I=t[1]&&Br(t);const _=[_r,Ir],L=[];function S(t,e){return t[2]?0:t[1]?-1:1}return~(x=S(t))&&(k=L[x]=_[x](t)),{c(){e=h("div"),n=h("div"),s=h("h2"),s.textContent="Dashboard",o=p(),i=h("div"),a=h("button"),l=g("Refresh"),f=p(),w=h("button"),m=g("Restart All"),v=p(),I&&I.c(),E=p(),k&&k.c(),b(s,"class","svelte-17dya06"),b(a,"class","refresh-btn svelte-17dya06"),a.disabled=t[0],b(w,"class","restart-btn svelte-17dya06"),w.disabled=t[0],b(i,"class","actions svelte-17dya06"),b(n,"class","page-header svelte-17dya06"),b(e,"class","dashboard svelte-17dya06")},m(r,d){u(r,e,d),c(e,n),c(n,s),c(n,o),c(n,i),c(i,a),c(a,l),c(i,f),c(i,w),c(w,m),c(e,v),I&&I.m(e,null),c(e,E),~x&&L[x].m(e,null),$=!0,A||(B=[y(a,"click",t[3]),y(w,"click",t[4])],A=!0)},p(t,[n]){(!$||1&n)&&(a.disabled=t[0]),(!$||1&n)&&(w.disabled=t[0]),t[1]?I?I.p(t,n):(I=Br(t),I.c(),I.m(e,E)):I&&(I.d(1),I=null);let r=x;x=S(t),x===r?~x&&L[x].p(t,n):(k&&(V(),K(L[r],1,1,()=>{L[r]=null}),j()),~x?(k=L[x],k?k.p(t,n):(k=L[x]=_[x](t),k.c()),z(k,1),k.m(e,null)):k=null)},i(t){$||(z(k),$=!0)},o(t){K(k),$=!1},d(t){t&&d(e),I&&I.d(),~x&&L[x].d(),A=!1,r(B)}}}function Cr(t,e,n){let r,s,o,l,c,u;var d;async function f(){try{a(fr,c=await async function(t,e){const n=await wr("/api/status",{},t,e);if(!n.ok)throw new Error(`Failed to fetch status: ${n.statusText}`);return n.json()}(l,o),c),a(yr,s="",s)}catch(t){a(yr,s=t.message,s)}}return i(t,pr,t=>n(0,r=t)),i(t,yr,t=>n(1,s=t)),i(t,cr,t=>n(6,o=t)),i(t,ur,t=>n(7,l=t)),i(t,fr,t=>n(2,c=t)),B(async()=>{await f(),u=setInterval(f,5e3)}),d=()=>{u&&clearInterval(u)},A().$$.on_destroy.push(d),[r,s,c,f,async function(){if(confirm("Are you sure you want to restart all services?")){a(pr,r=!0,r);try{await async function(t,e){const n=await wr("/api/restart",{method:"POST"},t,e);if(!n.ok)throw new Error(`Restart failed: ${n.statusText}`);return n.json()}(l,o),setTimeout(f,2e3)}catch(t){a(yr,s=t.message,s)}finally{a(pr,r=!1,r)}}}]}class Ur extends Q{constructor(t){super(),J(this,t,Cr,Sr,o,{})}}function Tr(t,e,n){const r=t.slice();return r[6]=e[n],r}function Nr(t){let e,n;return{c(){e=h("div"),n=g(t[1]),b(e,"class","error-banner svelte-1kruta9")},m(t,r){u(t,e,r),c(e,n)},p(t,e){2&e&&m(n,t[1])},d(t){t&&d(e)}}}function Or(e){let n;return{c(){n=h("div"),n.textContent="Loading configuration...",b(n,"class","loading svelte-1kruta9")},m(t,e){u(t,n,e)},p:t,d(t){t&&d(n)}}}function Rr(t){let e,n,r,s,o,i,a,l,y,w,v,E,k,$,A,B,I,_,L,S,C,U,T,N,O,R,P,D,q,H,F,V,j,z,K,Z,G,W,Y,J,Q,X,tt,et,nt,rt,st,ot,it,at,lt,ct,ut,dt,ft,ht,gt,pt,yt,wt,bt,mt,vt,Et,xt,kt,$t,At,Bt,It,_t,Lt,St,Ct,Ut,Tt,Nt,Ot,Rt,Pt,Dt,qt,Ht,Ft,Vt,jt,zt,Kt,Mt,Zt,Gt,Wt,Yt,Jt,Qt,Xt,te,ee,ne,re,se,oe,ie,ae,le,ce,ue,de,fe,he,ge,pe,ye,we,be,me,ve,Ee=t[2].db_backend+"",xe=t[2].db_binary+"",ke=t[2].db_listen+"",$e=t[2].data_dir+"",Ae=t[2].acl_enabled?"Yes":"No",Be=t[2].acl_mode+"",Ie=t[2].acl_binary+"",_e=t[2].acl_listen+"",Le=t[2].relay_binary+"",Se=t[2].log_level+"",Ce=t[2].distributed_sync_enabled?"Enabled":"Disabled",Ue=t[2].cluster_sync_enabled?"Enabled":"Disabled",Te=t[2].relay_group_enabled?"Enabled":"Disabled",Ne=t[2].negentropy_enabled?"Enabled":"Disabled",Oe=t[2].bin_dir+"",Re=M(t[2].admin_owners||[]),Pe=[];for(let e=0;e<Re.length;e+=1)Pe[e]=Dr(Tr(t,Re,e));let De=null;return Re.length||(De=Pr()),{c(){e=h("div"),n=h("section"),r=h("h3"),r.textContent="Database",s=p(),o=h("div"),i=h("div"),a=h("span"),a.textContent="Backend",l=p(),y=h("span"),w=g(Ee),v=p(),E=h("div"),k=h("span"),k.textContent="Binary",$=p(),A=h("span"),B=g(xe),I=p(),_=h("div"),L=h("span"),L.textContent="Listen Address",S=p(),C=h("span"),U=g(ke),T=p(),N=h("div"),O=h("span"),O.textContent="Data Directory",R=p(),P=h("span"),D=g($e),q=p(),H=h("section"),F=h("h3"),F.textContent="ACL",V=p(),j=h("div"),z=h("div"),K=h("span"),K.textContent="Enabled",Z=p(),G=h("span"),W=g(Ae),Y=p(),J=h("div"),Q=h("span"),Q.textContent="Mode",X=p(),tt=h("span"),et=g(Be),nt=p(),rt=h("div"),st=h("span"),st.textContent="Binary",ot=p(),it=h("span"),at=g(Ie),lt=p(),ct=h("div"),ut=h("span"),ut.textContent="Listen Address",dt=p(),ft=h("span"),ht=g(_e),gt=p(),pt=h("section"),yt=h("h3"),yt.textContent="Relay",wt=p(),bt=h("div"),mt=h("div"),vt=h("span"),vt.textContent="Binary",Et=p(),xt=h("span"),kt=g(Le),$t=p(),At=h("div"),Bt=h("span"),Bt.textContent="Log Level",It=p(),_t=h("span"),Lt=g(Se),St=p(),Ct=h("section"),Ut=h("h3"),Ut.textContent="Sync Services",Tt=p(),Nt=h("div"),Ot=h("div"),Rt=h("span"),Rt.textContent="Distributed Sync",Pt=p(),Dt=h("span"),qt=g(Ce),Ht=p(),Ft=h("div"),Vt=h("span"),Vt.textContent="Cluster Sync",jt=p(),zt=h("span"),Kt=g(Ue),Mt=p(),Zt=h("div"),Gt=h("span"),Gt.textContent="Relay Group",Wt=p(),Yt=h("span"),Jt=g(Te),Qt=p(),Xt=h("div"),te=h("span"),te.textContent="Negentropy",ee=p(),ne=h("span"),re=g(Ne),se=p(),oe=h("section"),ie=h("h3"),ie.textContent="Admin",ae=p(),le=h("div"),ce=h("div"),ue=h("span"),ue.textContent="Binary Directory",de=p(),fe=h("span"),he=g(Oe),ge=p(),pe=h("div"),ye=h("span"),ye.textContent="Admin Owners",we=p(),be=h("div");for(let t=0;t<Pe.length;t+=1)Pe[t].c();De&&De.c(),me=p(),ve=h("div"),ve.innerHTML='<p class="svelte-1kruta9">Configuration is loaded from environment variables. To change settings, update the environment and restart the launcher.</p>',b(r,"class","svelte-1kruta9"),b(a,"class","label svelte-1kruta9"),b(y,"class","value svelte-1kruta9"),b(i,"class","config-item svelte-1kruta9"),b(k,"class","label svelte-1kruta9"),b(A,"class","value mono svelte-1kruta9"),b(E,"class","config-item svelte-1kruta9"),b(L,"class","label svelte-1kruta9"),b(C,"class","value mono svelte-1kruta9"),b(_,"class","config-item svelte-1kruta9"),b(O,"class","label svelte-1kruta9"),b(P,"class","value mono svelte-1kruta9"),b(N,"class","config-item svelte-1kruta9"),b(o,"class","config-grid svelte-1kruta9"),b(n,"class","config-section svelte-1kruta9"),b(F,"class","svelte-1kruta9"),b(K,"class","label svelte-1kruta9"),b(G,"class","value bool svelte-1kruta9"),x(G,"enabled",t[2].acl_enabled),b(z,"class","config-item svelte-1kruta9"),b(Q,"class","label svelte-1kruta9"),b(tt,"class","value svelte-1kruta9"),b(J,"class","config-item svelte-1kruta9"),b(st,"class","label svelte-1kruta9"),b(it,"class","value mono svelte-1kruta9"),b(rt,"class","config-item svelte-1kruta9"),b(ut,"class","label svelte-1kruta9"),b(ft,"class","value mono svelte-1kruta9"),b(ct,"class","config-item svelte-1kruta9"),b(j,"class","config-grid svelte-1kruta9"),b(H,"class","config-section svelte-1kruta9"),b(yt,"class","svelte-1kruta9"),b(vt,"class","label svelte-1kruta9"),b(xt,"class","value mono svelte-1kruta9"),b(mt,"class","config-item svelte-1kruta9"),b(Bt,"class","label svelte-1kruta9"),b(_t,"class","value svelte-1kruta9"),b(At,"class","config-item svelte-1kruta9"),b(bt,"class","config-grid svelte-1kruta9"),b(pt,"class","config-section svelte-1kruta9"),b(Ut,"class","svelte-1kruta9"),b(Rt,"class","label svelte-1kruta9"),b(Dt,"class","value bool svelte-1kruta9"),x(Dt,"enabled",t[2].distributed_sync_enabled),b(Ot,"class","config-item svelte-1kruta9"),b(Vt,"class","label svelte-1kruta9"),b(zt,"class","value bool svelte-1kruta9"),x(zt,"enabled",t[2].cluster_sync_enabled),b(Ft,"class","config-item svelte-1kruta9"),b(Gt,"class","label svelte-1kruta9"),b(Yt,"class","value bool svelte-1kruta9"),x(Yt,"enabled",t[2].relay_group_enabled),b(Zt,"class","config-item svelte-1kruta9"),b(te,"class","label svelte-1kruta9"),b(ne,"class","value bool svelte-1kruta9"),x(ne,"enabled",t[2].negentropy_enabled),b(Xt,"class","config-item svelte-1kruta9"),b(Nt,"class","config-grid svelte-1kruta9"),b(Ct,"class","config-section svelte-1kruta9"),b(ie,"class","svelte-1kruta9"),b(ue,"class","label svelte-1kruta9"),b(fe,"class","value mono svelte-1kruta9"),b(ce,"class","config-item svelte-1kruta9"),b(ye,"class","label svelte-1kruta9"),b(be,"class","owners-list svelte-1kruta9"),b(pe,"class","config-item full-width svelte-1kruta9"),b(le,"class","config-grid svelte-1kruta9"),b(oe,"class","config-section svelte-1kruta9"),b(e,"class","config-sections svelte-1kruta9"),b(ve,"class","config-note svelte-1kruta9")},m(t,d){u(t,e,d),c(e,n),c(n,r),c(n,s),c(n,o),c(o,i),c(i,a),c(i,l),c(i,y),c(y,w),c(o,v),c(o,E),c(E,k),c(E,$),c(E,A),c(A,B),c(o,I),c(o,_),c(_,L),c(_,S),c(_,C),c(C,U),c(o,T),c(o,N),c(N,O),c(N,R),c(N,P),c(P,D),c(e,q),c(e,H),c(H,F),c(H,V),c(H,j),c(j,z),c(z,K),c(z,Z),c(z,G),c(G,W),c(j,Y),c(j,J),c(J,Q),c(J,X),c(J,tt),c(tt,et),c(j,nt),c(j,rt),c(rt,st),c(rt,ot),c(rt,it),c(it,at),c(j,lt),c(j,ct),c(ct,ut),c(ct,dt),c(ct,ft),c(ft,ht),c(e,gt),c(e,pt),c(pt,yt),c(pt,wt),c(pt,bt),c(bt,mt),c(mt,vt),c(mt,Et),c(mt,xt),c(xt,kt),c(bt,$t),c(bt,At),c(At,Bt),c(At,It),c(At,_t),c(_t,Lt),c(e,St),c(e,Ct),c(Ct,Ut),c(Ct,Tt),c(Ct,Nt),c(Nt,Ot),c(Ot,Rt),c(Ot,Pt),c(Ot,Dt),c(Dt,qt),c(Nt,Ht),c(Nt,Ft),c(Ft,Vt),c(Ft,jt),c(Ft,zt),c(zt,Kt),c(Nt,Mt),c(Nt,Zt),c(Zt,Gt),c(Zt,Wt),c(Zt,Yt),c(Yt,Jt),c(Nt,Qt),c(Nt,Xt),c(Xt,te),c(Xt,ee),c(Xt,ne),c(ne,re),c(e,se),c(e,oe),c(oe,ie),c(oe,ae),c(oe,le),c(le,ce),c(ce,ue),c(ce,de),c(ce,fe),c(fe,he),c(le,ge),c(le,pe),c(pe,ye),c(pe,we),c(pe,be);for(let t=0;t<Pe.length;t+=1)Pe[t]&&Pe[t].m(be,null);De&&De.m(be,null),u(t,me,d),u(t,ve,d)},p(t,e){if(4&e&&Ee!==(Ee=t[2].db_backend+"")&&m(w,Ee),4&e&&xe!==(xe=t[2].db_binary+"")&&m(B,xe),4&e&&ke!==(ke=t[2].db_listen+"")&&m(U,ke),4&e&&$e!==($e=t[2].data_dir+"")&&m(D,$e),4&e&&Ae!==(Ae=t[2].acl_enabled?"Yes":"No")&&m(W,Ae),4&e&&x(G,"enabled",t[2].acl_enabled),4&e&&Be!==(Be=t[2].acl_mode+"")&&m(et,Be),4&e&&Ie!==(Ie=t[2].acl_binary+"")&&m(at,Ie),4&e&&_e!==(_e=t[2].acl_listen+"")&&m(ht,_e),4&e&&Le!==(Le=t[2].relay_binary+"")&&m(kt,Le),4&e&&Se!==(Se=t[2].log_level+"")&&m(Lt,Se),4&e&&Ce!==(Ce=t[2].distributed_sync_enabled?"Enabled":"Disabled")&&m(qt,Ce),4&e&&x(Dt,"enabled",t[2].distributed_sync_enabled),4&e&&Ue!==(Ue=t[2].cluster_sync_enabled?"Enabled":"Disabled")&&m(Kt,Ue),4&e&&x(zt,"enabled",t[2].cluster_sync_enabled),4&e&&Te!==(Te=t[2].relay_group_enabled?"Enabled":"Disabled")&&m(Jt,Te),4&e&&x(Yt,"enabled",t[2].relay_group_enabled),4&e&&Ne!==(Ne=t[2].negentropy_enabled?"Enabled":"Disabled")&&m(re,Ne),4&e&&x(ne,"enabled",t[2].negentropy_enabled),4&e&&Oe!==(Oe=t[2].bin_dir+"")&&m(he,Oe),4&e){let n;for(Re=M(t[2].admin_owners||[]),n=0;n<Re.length;n+=1){const r=Tr(t,Re,n);Pe[n]?Pe[n].p(r,e):(Pe[n]=Dr(r),Pe[n].c(),Pe[n].m(be,null))}for(;n<Pe.length;n+=1)Pe[n].d(1);Pe.length=Re.length,!Re.length&&De?De.p(t,e):Re.length?De&&(De.d(1),De=null):(De=Pr(),De.c(),De.m(be,null))}},d(t){t&&(d(e),d(me),d(ve)),f(Pe,t),De&&De.d()}}}function Pr(e){let n;return{c(){n=h("span"),n.textContent="No owners configured",b(n,"class","no-owners svelte-1kruta9")},m(t,e){u(t,n,e)},p:t,d(t){t&&d(n)}}}function Dr(t){let e,n,r=t[6]+"";return{c(){e=h("code"),n=g(r),b(e,"class","owner svelte-1kruta9")},m(t,r){u(t,e,r),c(e,n)},p(t,e){4&e&&r!==(r=t[6]+"")&&m(n,r)},d(t){t&&d(e)}}}function qr(e){let n,r,s,o,i,a,l,f,w,m,v=e[1]&&Nr(e);function E(t,e){return t[2]?Rr:t[1]?void 0:Or}let x=E(e),k=x&&x(e);return{c(){n=h("div"),r=h("div"),s=h("h2"),s.textContent="Configuration",o=p(),i=h("button"),a=g("Refresh"),l=p(),v&&v.c(),f=p(),k&&k.c(),b(s,"class","svelte-1kruta9"),b(i,"class","refresh-btn svelte-1kruta9"),i.disabled=e[0],b(r,"class","page-header svelte-1kruta9"),b(n,"class","config-page svelte-1kruta9")},m(t,d){u(t,n,d),c(n,r),c(r,s),c(r,o),c(r,i),c(i,a),c(n,l),v&&v.m(n,null),c(n,f),k&&k.m(n,null),w||(m=y(i,"click",e[3]),w=!0)},p(t,[e]){1&e&&(i.disabled=t[0]),t[1]?v?v.p(t,e):(v=Nr(t),v.c(),v.m(n,f)):v&&(v.d(1),v=null),x===(x=E(t))&&k?k.p(t,e):(k&&k.d(1),k=x&&x(t),k&&(k.c(),k.m(n,null)))},i:t,o:t,d(t){t&&d(n),v&&v.d(),k&&k.d(),w=!1,m()}}}function Hr(t,e,n){let r,s,o,l,c;async function u(){a(pr,r=!0,r);try{a(hr,c=await async function(t,e){const n=await wr("/api/config",{},t,e);if(!n.ok)throw new Error(`Failed to fetch config: ${n.statusText}`);return n.json()}(l,o),c),a(yr,s="",s)}catch(t){a(yr,s=t.message,s)}finally{a(pr,r=!1,r)}}return i(t,pr,t=>n(0,r=t)),i(t,yr,t=>n(1,s=t)),i(t,cr,t=>n(4,o=t)),i(t,ur,t=>n(5,l=t)),i(t,hr,t=>n(2,c=t)),B(async()=>{await u()}),[r,s,c,u]}class Fr extends Q{constructor(t){super(),J(this,t,Hr,qr,o,{})}}function Vr(t,e,n){const r=t.slice();return r[15]=e[n],r}function jr(t,e,n){const r=t.slice();return r[18]=e[n],r[19]=e,r[20]=n,r}function zr(t){let e,n;return{c(){e=h("div"),n=g(t[4]),b(e,"class","error-banner svelte-1ig49gt")},m(t,r){u(t,e,r),c(e,n)},p(t,e){16&e&&m(n,t[4])},d(t){t&&d(e)}}}function Kr(t){let e,n,r,s=t[2].message+"",o=t[2].downloaded_files?.length&&Mr(t);return{c(){e=h("div"),n=g(s),r=p(),o&&o.c(),b(e,"class","success-banner svelte-1ig49gt")},m(t,s){u(t,e,s),c(e,n),c(e,r),o&&o.m(e,null)},p(t,r){4&r&&s!==(s=t[2].message+"")&&m(n,s),t[2].downloaded_files?.length?o?o.p(t,r):(o=Mr(t),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(t){t&&d(e),o&&o.d()}}}function Mr(t){let e,n,r,s=t[2].downloaded_files.join(", ")+"";return{c(){e=h("br"),n=g("Downloaded: "),r=g(s)},m(t,s){u(t,e,s),u(t,n,s),u(t,r,s)},p(t,e){4&e&&s!==(s=t[2].downloaded_files.join(", ")+"")&&m(r,s)},d(t){t&&(d(e),d(n),d(r))}}}function Zr(t){let e,n,r,s,o,i,a,l,f=t[18]+"";function w(){t[10].call(o,t[18])}return{c(){e=h("div"),n=h("span"),r=g(f),s=p(),o=h("input"),i=p(),b(n,"class","binary-name svelte-1ig49gt"),b(o,"type","text"),b(o,"placeholder","https://..."),o.disabled=t[3],b(o,"class","svelte-1ig49gt"),b(e,"class","url-input svelte-1ig49gt")},m(d,f){u(d,e,f),c(e,n),c(n,r),c(e,s),c(e,o),v(o,t[1][t[18]]),c(e,i),a||(l=y(o,"input",w),a=!0)},p(e,n){t=e,2&n&&f!==(f=t[18]+"")&&m(r,f),8&n&&(o.disabled=t[3]),2&n&&o.value!==t[1][t[18]]&&v(o,t[1][t[18]])},d(t){t&&d(e),a=!1,l()}}}function Gr(t){let e,n,r,s,o,i,a,l=M(t[5].available_versions),g=[];for(let e=0;e<l.length;e+=1)g[e]=Yr(Vr(t,l,e));return{c(){e=h("div"),n=h("h3"),n.textContent="Installed Versions",r=p(),s=h("table"),o=h("thead"),o.innerHTML='<tr><th class="svelte-1ig49gt">Version</th> <th class="svelte-1ig49gt">Installed</th> <th class="svelte-1ig49gt">Binaries</th> <th class="svelte-1ig49gt">Status</th></tr>',i=p(),a=h("tbody");for(let t=0;t<g.length;t+=1)g[t].c();b(n,"class","svelte-1ig49gt"),b(s,"class","svelte-1ig49gt"),b(e,"class","versions-list svelte-1ig49gt")},m(t,l){u(t,e,l),c(e,n),c(e,r),c(e,s),c(s,o),c(s,i),c(s,a);for(let t=0;t<g.length;t+=1)g[t]&&g[t].m(a,null)},p(t,e){if(32&e){let n;for(l=M(t[5].available_versions),n=0;n<l.length;n+=1){const r=Vr(t,l,n);g[n]?g[n].p(r,e):(g[n]=Yr(r),g[n].c(),g[n].m(a,null))}for(;n<g.length;n+=1)g[n].d(1);g.length=l.length}},d(t){t&&d(e),f(g,t)}}}function Wr(t){let e;return{c(){e=h("span"),e.textContent="Current",b(e,"class","current-badge svelte-1ig49gt")},m(t,n){u(t,e,n)},d(t){t&&d(e)}}}function Yr(t){let e,n,r,s,o,i,a,l,f,y,w,v,E,k=t[15].version+"",$=new Date(t[15].installed_at).toLocaleString()+"",A=(t[15].binaries?.length||0)+"",B=t[15].is_current&&Wr();return{c(){e=h("tr"),n=h("td"),r=g(k),s=p(),o=h("td"),i=g($),a=p(),l=h("td"),f=g(A),y=g(" files"),w=p(),v=h("td"),B&&B.c(),E=p(),b(n,"class","version-cell svelte-1ig49gt"),b(o,"class","svelte-1ig49gt"),b(l,"class","svelte-1ig49gt"),b(v,"class","svelte-1ig49gt"),b(e,"class","svelte-1ig49gt"),x(e,"current",t[15].is_current)},m(t,d){u(t,e,d),c(e,n),c(n,r),c(e,s),c(e,o),c(o,i),c(e,a),c(e,l),c(l,f),c(l,y),c(e,w),c(e,v),B&&B.m(v,null),c(e,E)},p(t,n){32&n&&k!==(k=t[15].version+"")&&m(r,k),32&n&&$!==($=new Date(t[15].installed_at).toLocaleString()+"")&&m(i,$),32&n&&A!==(A=(t[15].binaries?.length||0)+"")&&m(f,A),t[15].is_current?B||(B=Wr(),B.c(),B.m(v,null)):B&&(B.d(1),B=null),32&n&&x(e,"current",t[15].is_current)},d(t){t&&d(e),B&&B.d()}}}function Jr(e){let n,s,o,i,a,l,w,E,x,k,$,A,B,I,_,L,S,C,U,T,N,O,R,P,D,q,H,F,V,j,z,K,Z,G,W,Y,J,Q=(e[5]?.current_version||"unknown")+"",X=e[3]?"Updating...":"Download & Install",tt=e[4]&&zr(e),et=e[2]?.success&&Kr(e),nt=M(Object.keys(e[1])),rt=[];for(let t=0;t<nt.length;t+=1)rt[t]=Zr(jr(e,nt,t));let st=e[5]?.available_versions?.length&&Gr(e);return{c(){n=h("div"),s=h("div"),s.innerHTML='<h2 class="svelte-1ig49gt">Update Binaries</h2>',o=p(),tt&&tt.c(),i=p(),et&&et.c(),a=p(),l=h("div"),w=h("h3"),w.textContent="Current Version",E=p(),x=h("div"),k=h("span"),$=g(Q),A=p(),B=h("button"),I=g("Rollback"),L=p(),S=h("div"),C=h("h3"),C.textContent="Install New Version",U=p(),T=h("div"),N=h("label"),N.textContent="Version",O=p(),R=h("input"),P=p(),D=h("div"),q=h("div"),H=h("label"),H.textContent="Binary URLs",F=p(),V=h("button"),j=g("Fill from Release"),z=p();for(let t=0;t<rt.length;t+=1)rt[t].c();K=p(),Z=h("button"),G=g(X),W=p(),st&&st.c(),b(s,"class","page-header svelte-1ig49gt"),b(w,"class","svelte-1ig49gt"),b(k,"class","version svelte-1ig49gt"),b(B,"class","rollback-btn svelte-1ig49gt"),B.disabled=_=e[3]||(e[5]?.available_versions?.length||0)<2,b(x,"class","version-info svelte-1ig49gt"),b(l,"class","current-version svelte-1ig49gt"),b(C,"class","svelte-1ig49gt"),b(N,"for","version"),b(N,"class","svelte-1ig49gt"),b(R,"type","text"),b(R,"id","version"),b(R,"placeholder","v0.55.11"),R.disabled=e[3],b(R,"class","svelte-1ig49gt"),b(T,"class","form-group svelte-1ig49gt"),b(H,"class","svelte-1ig49gt"),b(V,"class","helper-btn svelte-1ig49gt"),V.disabled=e[3],b(q,"class","url-header svelte-1ig49gt"),b(D,"class","form-group svelte-1ig49gt"),b(Z,"class","update-btn svelte-1ig49gt"),Z.disabled=e[3],b(S,"class","update-form svelte-1ig49gt"),b(n,"class","update-page svelte-1ig49gt")},m(t,r){u(t,n,r),c(n,s),c(n,o),tt&&tt.m(n,null),c(n,i),et&&et.m(n,null),c(n,a),c(n,l),c(l,w),c(l,E),c(l,x),c(x,k),c(k,$),c(x,A),c(x,B),c(B,I),c(n,L),c(n,S),c(S,C),c(S,U),c(S,T),c(T,N),c(T,O),c(T,R),v(R,e[0]),c(S,P),c(S,D),c(D,q),c(q,H),c(q,F),c(q,V),c(V,j),c(D,z);for(let t=0;t<rt.length;t+=1)rt[t]&&rt[t].m(D,null);c(S,K),c(S,Z),c(Z,G),c(n,W),st&&st.m(n,null),Y||(J=[y(B,"click",e[7]),y(R,"input",e[9]),y(V,"click",e[8]),y(Z,"click",e[6])],Y=!0)},p(t,[e]){if(t[4]?tt?tt.p(t,e):(tt=zr(t),tt.c(),tt.m(n,i)):tt&&(tt.d(1),tt=null),t[2]?.success?et?et.p(t,e):(et=Kr(t),et.c(),et.m(n,a)):et&&(et.d(1),et=null),32&e&&Q!==(Q=(t[5]?.current_version||"unknown")+"")&&m($,Q),40&e&&_!==(_=t[3]||(t[5]?.available_versions?.length||0)<2)&&(B.disabled=_),8&e&&(R.disabled=t[3]),1&e&&R.value!==t[0]&&v(R,t[0]),8&e&&(V.disabled=t[3]),10&e){let n;for(nt=M(Object.keys(t[1])),n=0;n<nt.length;n+=1){const r=jr(t,nt,n);rt[n]?rt[n].p(r,e):(rt[n]=Zr(r),rt[n].c(),rt[n].m(D,null))}for(;n<rt.length;n+=1)rt[n].d(1);rt.length=nt.length}8&e&&X!==(X=t[3]?"Updating...":"Download & Install")&&m(G,X),8&e&&(Z.disabled=t[3]),t[5]?.available_versions?.length?st?st.p(t,e):(st=Gr(t),st.c(),st.m(n,null)):st&&(st.d(1),st=null)},i:t,o:t,d(t){t&&d(n),tt&&tt.d(),et&&et.d(),f(rt,t),st&&st.d(),Y=!1,r(J)}}}function Qr(t,e,n){let r,s,o,l,c;i(t,yr,t=>n(4,r=t)),i(t,cr,t=>n(11,s=t)),i(t,ur,t=>n(12,o=t)),i(t,pr,t=>n(13,l=t)),i(t,gr,t=>n(5,c=t));let u="",d={orly:"","orly-db-badger":"","orly-acl-follows":"","orly-launcher":""},f=null,h=!1;async function g(){a(pr,l=!0,l);try{a(gr,c=await async function(t,e){const n=await wr("/api/binaries",{},t,e);if(!n.ok)throw new Error(`Failed to fetch binaries: ${n.statusText}`);return n.json()}(o,s),c),a(yr,r="",r)}catch(t){a(yr,r=t.message,r)}finally{a(pr,l=!1,l)}}return B(async()=>{await g()}),[u,d,f,h,r,c,async function(){const t={};for(const[e,n]of Object.entries(d))n.trim()&&(t[e]=n.trim());if(u.trim())if(0!==Object.keys(t).length){n(3,h=!0),n(2,f=null),a(yr,r="",r);try{n(2,f=await async function(t,e,n,r){const s=await wr("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:n,urls:r})},t,e);if(!s.ok){const t=await s.json();throw new Error(t.message||`Update failed: ${s.statusText}`)}return s.json()}(o,s,u.trim(),t)),await g()}catch(t){a(yr,r=t.message,r)}finally{n(3,h=!1)}}else a(yr,r="At least one binary URL is required",r);else a(yr,r="Version is required",r)},async function(){if(confirm("Are you sure you want to rollback to the previous version?")){n(3,h=!0),a(yr,r="",r);try{const t=await async function(t,e){const n=await wr("/api/rollback",{method:"POST"},t,e);if(!n.ok){const t=await n.json();throw new Error(t.message||`Rollback failed: ${n.statusText}`)}return n.json()}(o,s);n(2,f={success:!0,message:`Rolled back from ${t.previous_version} to ${t.current_version}. Restart services to apply.`}),await g()}catch(t){a(yr,r=t.message,r)}finally{n(3,h=!1)}}},function(){const t=prompt("Enter release base URL (e.g., https://git.mleku.dev/mleku/next.orly.dev/releases/download/v0.55.11):");if(!t)return;const e=t.replace(/\/$/,""),r=prompt("Enter architecture (amd64 or arm64):","amd64");if(!r)return;const s=u.trim()||t.split("/").pop();n(1,d.orly=`${e}/orly-${s.replace("v","")}-linux-${r}`,d),n(1,d["orly-db-badger"]=`${e}/orly-db-badger-${s.replace("v","")}-linux-${r}`,d),n(1,d["orly-acl-follows"]=`${e}/orly-acl-follows-${s.replace("v","")}-linux-${r}`,d),n(1,d["orly-launcher"]=`${e}/orly-launcher-${s.replace("v","")}-linux-${r}`,d),u.trim()||n(0,u=s)},function(){u=this.value,n(0,u)},function(t){d[t]=this.value,n(1,d)}]}class Xr extends Q{constructor(t){super(),J(this,t,Qr,Jr,o,{})}}function ts(e){let n,r;return n=new Xr({}),{c(){Z(n.$$.fragment)},m(t,e){G(n,t,e),r=!0},p:t,i(t){r||(z(n.$$.fragment,t),r=!0)},o(t){K(n.$$.fragment,t),r=!1},d(t){W(n,t)}}}function es(e){let n,r;return n=new Fr({}),{c(){Z(n.$$.fragment)},m(t,e){G(n,t,e),r=!0},p:t,i(t){r||(z(n.$$.fragment,t),r=!0)},o(t){K(n.$$.fragment,t),r=!1},d(t){W(n,t)}}}function ns(e){let n,r;return n=new Ur({}),{c(){Z(n.$$.fragment)},m(t,e){G(n,t,e),r=!0},p:t,i(t){r||(z(n.$$.fragment,t),r=!0)},o(t){K(n.$$.fragment,t),r=!1},d(t){W(n,t)}}}function rs(e){let n,r,s,o,i,a,l,f;return{c(){n=h("div"),r=h("h2"),r.textContent="ORLY Launcher Admin",s=p(),o=h("p"),o.textContent="Please login to manage the relay services.",i=p(),a=h("button"),a.textContent="Login with Nostr",b(r,"class","svelte-4k9oqz"),b(o,"class","svelte-4k9oqz"),b(a,"class","login-btn svelte-4k9oqz"),b(n,"class","login-prompt svelte-4k9oqz")},m(t,d){u(t,n,d),c(n,r),c(n,s),c(n,o),c(n,i),c(n,a),l||(f=y(a,"click",e[10]),l=!0)},p:t,i:t,o:t,d(t){t&&d(n),l=!1,f()}}}function ss(t){let e,n,r,s,o,i,a,l,f,g;n=new st({props:{currentPage:t[0],isLoggedIn:t[4],userPubkey:t[3]}}),n.$on("navigate",t[8]),n.$on("login",t[9]),n.$on("logout",t[6]);const y=[rs,ns,es,ts],w=[];function m(t,e){return t[4]?"dashboard"===t[0]?1:"config"===t[0]?2:"update"===t[0]?3:-1:0}function v(e){t[11](e)}~(o=m(t))&&(i=w[o]=y[o](t));let E={isDarkTheme:t[2]};return void 0!==t[1]&&(E.showModal=t[1]),l=new or({props:E}),S.push(()=>function(t,e,n){const r=t.$$.props[e];void 0!==r&&(t.$$.bound[r]=n,n(t.$$.ctx[r]))}(l,"showModal",v)),l.$on("login",t[5]),l.$on("close",t[12]),{c(){e=h("main"),Z(n.$$.fragment),r=p(),s=h("div"),i&&i.c(),a=p(),Z(l.$$.fragment),b(s,"class","content svelte-4k9oqz"),b(e,"class","svelte-4k9oqz"),x(e,"dark-theme",t[2])},m(t,i){u(t,e,i),G(n,e,null),c(e,r),c(e,s),~o&&w[o].m(s,null),c(e,a),G(l,e,null),g=!0},p(t,[r]){const a={};1&r&&(a.currentPage=t[0]),16&r&&(a.isLoggedIn=t[4]),8&r&&(a.userPubkey=t[3]),n.$set(a);let c=o;o=m(t),o===c?~o&&w[o].p(t,r):(i&&(V(),K(w[c],1,1,()=>{w[c]=null}),j()),~o?(i=w[o],i?i.p(t,r):(i=w[o]=y[o](t),i.c()),z(i,1),i.m(s,null)):i=null);const u={};var d;4&r&&(u.isDarkTheme=t[2]),!f&&2&r&&(f=!0,u.showModal=t[1],d=()=>f=!1,U.push(d)),l.$set(u),(!g||4&r)&&x(e,"dark-theme",t[2])},i(t){g||(z(n.$$.fragment,t),z(i),z(l.$$.fragment,t),g=!0)},o(t){K(n.$$.fragment,t),K(i),K(l.$$.fragment,t),g=!1},d(t){t&&d(e),W(n),~o&&w[o].d(),W(l)}}}function os(t,e,n){let r,s,o,l;i(t,dr,t=>n(13,r=t)),i(t,ur,t=>n(14,s=t)),i(t,cr,t=>n(3,o=t)),i(t,lr,t=>n(4,l=t));let c="dashboard",u=!1,d=!1;function f(t){n(0,c=t)}B(()=>{const t=localStorage.getItem("launcher_auth_method"),e=localStorage.getItem("launcher_pubkey");"extension"===t&&e&&window.nostr&&window.nostr.getPublicKey().then(t=>{t===e&&(a(lr,l=!0,l),a(cr,o=t,o),a(ur,s=window.nostr,s),a(dr,r="extension",r))}).catch(()=>{localStorage.removeItem("launcher_auth_method"),localStorage.removeItem("launcher_pubkey")}),n(2,d=window.matchMedia("(prefers-color-scheme: dark)").matches)});return[c,u,d,o,l,function(t){const{method:e,pubkey:i,signer:c,privateKey:d}=t.detail;a(lr,l=!0,l),a(cr,o=i,o),a(ur,s=c,s),a(dr,r=e,r),localStorage.setItem("launcher_auth_method",e),localStorage.setItem("launcher_pubkey",i),n(1,u=!1)},function(){a(lr,l=!1,l),a(cr,o="",o),a(ur,s=null,s),a(dr,r="",r),localStorage.removeItem("launcher_auth_method"),localStorage.removeItem("launcher_pubkey"),localStorage.removeItem("launcher_privkey_encrypted")},f,t=>f(t.detail),()=>n(1,u=!0),()=>n(1,u=!0),function(t){u=t,n(1,u)},()=>n(1,u=!1)]}return new class extends Q{constructor(t){super(),J(this,t,os,ss,o,{})}}({target:document.body})}();
|
|
|