Paywell / website / app / wallet.js
| 1 | var PWW=(()=>{var kc=Object.create;var qr=Object.defineProperty;var Tc=Object.getOwnPropertyDescriptor;var Ic=Object.getOwnPropertyNames;var Uc=Object.getPrototypeOf,Lc=Object.prototype.hasOwnProperty;var Nc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Vi=(t,e)=>{for(var r in e)qr(t,r,{get:e[r],enumerable:!0})},zi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ic(e))!Lc.call(t,o)&&o!==r&&qr(t,o,{get:()=>e[o],enumerable:!(n=Tc(e,o))||n.enumerable});return t};var Cc=(t,e,r)=>(r=t!=null?kc(Uc(t)):{},zi(e||!t||!t.__esModule?qr(r,"default",{value:t,enumerable:!0}):r,t)),_c=t=>zi(qr({},"__esModule",{value:!0}),t);var vc=Nc((xc,Ec)=>{var mc=function(){var t=function(m,b){var v=236,x=17,w=m,B=r[b],g=null,d=0,C=null,k=[],T={},D=function(P,_){d=w*4+17,g=function(U){for(var R=new Array(U),H=0;H<U;H+=1){R[H]=new Array(U);for(var O=0;O<U;O+=1)R[H][O]=null}return R}(d),S(0,0),S(d-7,0),S(0,d-7),$(),L(),W(P,_),w>=7&&M(P),C==null&&(C=it(w,B,k)),j(C,_)},S=function(P,_){for(var U=-1;U<=7;U+=1)if(!(P+U<=-1||d<=P+U))for(var R=-1;R<=7;R+=1)_+R<=-1||d<=_+R||(0<=U&&U<=6&&(R==0||R==6)||0<=R&&R<=6&&(U==0||U==6)||2<=U&&U<=4&&2<=R&&R<=4?g[P+U][_+R]=!0:g[P+U][_+R]=!1)},I=function(){for(var P=0,_=0,U=0;U<8;U+=1){D(!0,U);var R=o.getLostPoint(T);(U==0||P>R)&&(P=R,_=U)}return _},L=function(){for(var P=8;P<d-8;P+=1)g[P][6]==null&&(g[P][6]=P%2==0);for(var _=8;_<d-8;_+=1)g[6][_]==null&&(g[6][_]=_%2==0)},$=function(){for(var P=o.getPatternPosition(w),_=0;_<P.length;_+=1)for(var U=0;U<P.length;U+=1){var R=P[_],H=P[U];if(g[R][H]==null)for(var O=-2;O<=2;O+=1)for(var q=-2;q<=2;q+=1)O==-2||O==2||q==-2||q==2||O==0&&q==0?g[R+O][H+q]=!0:g[R+O][H+q]=!1}},M=function(P){for(var _=o.getBCHTypeNumber(w),U=0;U<18;U+=1){var R=!P&&(_>>U&1)==1;g[Math.floor(U/3)][U%3+d-8-3]=R}for(var U=0;U<18;U+=1){var R=!P&&(_>>U&1)==1;g[U%3+d-8-3][Math.floor(U/3)]=R}},W=function(P,_){for(var U=B<<3|_,R=o.getBCHTypeInfo(U),H=0;H<15;H+=1){var O=!P&&(R>>H&1)==1;H<6?g[H][8]=O:H<8?g[H+1][8]=O:g[d-15+H][8]=O}for(var H=0;H<15;H+=1){var O=!P&&(R>>H&1)==1;H<8?g[8][d-H-1]=O:H<9?g[8][15-H-1+1]=O:g[8][15-H-1]=O}g[d-8][8]=!P},j=function(P,_){for(var U=-1,R=d-1,H=7,O=0,q=o.getMaskFunction(_),K=d-1;K>0;K-=2)for(K==6&&(K-=1);;){for(var G=0;G<2;G+=1)if(g[R][K-G]==null){var Z=!1;O<P.length&&(Z=(P[O]>>>H&1)==1);var V=q(R,K-G);V&&(Z=!Z),g[R][K-G]=Z,H-=1,H==-1&&(O+=1,H=7)}if(R+=U,R<0||d<=R){R-=U,U=-U;break}}},Y=function(P,_){for(var U=0,R=0,H=0,O=new Array(_.length),q=new Array(_.length),K=0;K<_.length;K+=1){var G=_[K].dataCount,Z=_[K].totalCount-G;R=Math.max(R,G),H=Math.max(H,Z),O[K]=new Array(G);for(var V=0;V<O[K].length;V+=1)O[K][V]=255&P.getBuffer()[V+U];U+=G;var _t=o.getErrorCorrectPolynomial(Z),Pt=s(O[K],_t.getLength()-1),Ki=Pt.mod(_t);q[K]=new Array(_t.getLength()-1);for(var V=0;V<q[K].length;V+=1){var qi=V+Ki.getLength()-q[K].length;q[K][V]=qi>=0?Ki.getAt(qi):0}}for(var Wi=0,V=0;V<_.length;V+=1)Wi+=_[V].totalCount;for(var Fn=new Array(Wi),Kr=0,V=0;V<R;V+=1)for(var K=0;K<_.length;K+=1)V<O[K].length&&(Fn[Kr]=O[K][V],Kr+=1);for(var V=0;V<H;V+=1)for(var K=0;K<_.length;K+=1)V<q[K].length&&(Fn[Kr]=q[K][V],Kr+=1);return Fn},it=function(P,_,U){for(var R=a.getRSBlocks(P,_),H=c(),O=0;O<U.length;O+=1){var q=U[O];H.put(q.getMode(),4),H.put(q.getLength(),o.getLengthInBits(q.getMode(),P)),q.write(H)}for(var K=0,O=0;O<R.length;O+=1)K+=R[O].dataCount;if(H.getLengthInBits()>K*8)throw"code length overflow. ("+H.getLengthInBits()+">"+K*8+")";for(H.getLengthInBits()+4<=K*8&&H.put(0,4);H.getLengthInBits()%8!=0;)H.putBit(!1);for(;!(H.getLengthInBits()>=K*8||(H.put(v,8),H.getLengthInBits()>=K*8));)H.put(x,8);return Y(H,R)};T.addData=function(P,_){_=_||"Byte";var U=null;switch(_){case"Numeric":U=f(P);break;case"Alphanumeric":U=h(P);break;case"Byte":U=u(P);break;case"Kanji":U=l(P);break;default:throw"mode:"+_}k.push(U),C=null},T.isDark=function(P,_){if(P<0||d<=P||_<0||d<=_)throw P+","+_;return g[P][_]},T.getModuleCount=function(){return d},T.make=function(){if(w<1){for(var P=1;P<40;P++){for(var _=a.getRSBlocks(P,B),U=c(),R=0;R<k.length;R++){var H=k[R];U.put(H.getMode(),4),U.put(H.getLength(),o.getLengthInBits(H.getMode(),P)),H.write(U)}for(var O=0,R=0;R<_.length;R++)O+=_[R].dataCount;if(U.getLengthInBits()<=O*8)break}w=P}D(!1,I())},T.createTableTag=function(P,_){P=P||2,_=typeof _>"u"?P*4:_;var U="";U+='<table style="',U+=" border-width: 0px; border-style: none;",U+=" border-collapse: collapse;",U+=" padding: 0px; margin: "+_+"px;",U+='">',U+="<tbody>";for(var R=0;R<T.getModuleCount();R+=1){U+="<tr>";for(var H=0;H<T.getModuleCount();H+=1)U+='<td style="',U+=" border-width: 0px; border-style: none;",U+=" border-collapse: collapse;",U+=" padding: 0px; margin: 0px;",U+=" width: "+P+"px;",U+=" height: "+P+"px;",U+=" background-color: ",U+=T.isDark(R,H)?"#000000":"#ffffff",U+=";",U+='"/>';U+="</tr>"}return U+="</tbody>",U+="</table>",U},T.createSvgTag=function(P,_,U,R){var H={};typeof arguments[0]=="object"&&(H=arguments[0],P=H.cellSize,_=H.margin,U=H.alt,R=H.title),P=P||2,_=typeof _>"u"?P*4:_,U=typeof U=="string"?{text:U}:U||{},U.text=U.text||null,U.id=U.text?U.id||"qrcode-description":null,R=typeof R=="string"?{text:R}:R||{},R.text=R.text||null,R.id=R.text?R.id||"qrcode-title":null;var O=T.getModuleCount()*P+_*2,q,K,G,Z,V="",_t;for(_t="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",V+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',V+=H.scalable?"":' width="'+O+'px" height="'+O+'px"',V+=' viewBox="0 0 '+O+" "+O+'" ',V+=' preserveAspectRatio="xMinYMin meet"',V+=R.text||U.text?' role="img" aria-labelledby="'+X([R.id,U.id].join(" ").trim())+'"':"",V+=">",V+=R.text?'<title id="'+X(R.id)+'">'+X(R.text)+"</title>":"",V+=U.text?'<description id="'+X(U.id)+'">'+X(U.text)+"</description>":"",V+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',V+='<path d="',G=0;G<T.getModuleCount();G+=1)for(Z=G*P+_,q=0;q<T.getModuleCount();q+=1)T.isDark(G,q)&&(K=q*P+_,V+="M"+K+","+Z+_t);return V+='" stroke="transparent" fill="black"/>',V+="</svg>",V},T.createDataURL=function(P,_){P=P||2,_=typeof _>"u"?P*4:_;var U=T.getModuleCount()*P+_*2,R=_,H=U-_;return A(U,U,function(O,q){if(R<=O&&O<H&&R<=q&&q<H){var K=Math.floor((O-R)/P),G=Math.floor((q-R)/P);return T.isDark(G,K)?0:1}else return 1})},T.createImgTag=function(P,_,U){P=P||2,_=typeof _>"u"?P*4:_;var R=T.getModuleCount()*P+_*2,H="";return H+="<img",H+=' src="',H+=T.createDataURL(P,_),H+='"',H+=' width="',H+=R,H+='"',H+=' height="',H+=R,H+='"',U&&(H+=' alt="',H+=X(U),H+='"'),H+="/>",H};var X=function(P){for(var _="",U=0;U<P.length;U+=1){var R=P.charAt(U);switch(R){case"<":_+="<";break;case">":_+=">";break;case"&":_+="&";break;case'"':_+=""";break;default:_+=R;break}}return _},F=function(P){var _=1;P=typeof P>"u"?_*2:P;var U=T.getModuleCount()*_+P*2,R=P,H=U-P,O,q,K,G,Z,V={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},_t={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},Pt="";for(O=0;O<U;O+=2){for(K=Math.floor((O-R)/_),G=Math.floor((O+1-R)/_),q=0;q<U;q+=1)Z="\u2588",R<=q&&q<H&&R<=O&&O<H&&T.isDark(K,Math.floor((q-R)/_))&&(Z=" "),R<=q&&q<H&&R<=O+1&&O+1<H&&T.isDark(G,Math.floor((q-R)/_))?Z+=" ":Z+="\u2588",Pt+=P<1&&O+1>=H?_t[Z]:V[Z];Pt+=` |
| 2 | `}return U%2&&P>0?Pt.substring(0,Pt.length-U-1)+Array(U+1).join("\u2580"):Pt.substring(0,Pt.length-1)};return T.createASCII=function(P,_){if(P=P||1,P<2)return F(_);P-=1,_=typeof _>"u"?P*2:_;var U=T.getModuleCount()*P+_*2,R=_,H=U-_,O,q,K,G,Z=Array(P+1).join("\u2588\u2588"),V=Array(P+1).join(" "),_t="",Pt="";for(O=0;O<U;O+=1){for(K=Math.floor((O-R)/P),Pt="",q=0;q<U;q+=1)G=1,R<=q&&q<H&&R<=O&&O<H&&T.isDark(K,Math.floor((q-R)/P))&&(G=0),Pt+=G?Z:V;for(K=0;K<P;K+=1)_t+=Pt+` |
| 3 | `}return _t.substring(0,_t.length-1)},T.renderTo2dContext=function(P,_){_=_||2;for(var U=T.getModuleCount(),R=0;R<U;R++)for(var H=0;H<U;H++)P.fillStyle=T.isDark(R,H)?"black":"white",P.fillRect(R*_,H*_,_,_)},T};t.stringToBytesFuncs={default:function(m){for(var b=[],v=0;v<m.length;v+=1){var x=m.charCodeAt(v);b.push(x&255)}return b}},t.stringToBytes=t.stringToBytesFuncs.default,t.createStringToBytes=function(m,b){var v=function(){for(var w=E(m),B=function(){var L=w.read();if(L==-1)throw"eof";return L},g=0,d={};;){var C=w.read();if(C==-1)break;var k=B(),T=B(),D=B(),S=String.fromCharCode(C<<8|k),I=T<<8|D;d[S]=I,g+=1}if(g!=b)throw g+" != "+b;return d}(),x=63;return function(w){for(var B=[],g=0;g<w.length;g+=1){var d=w.charCodeAt(g);if(d<128)B.push(d);else{var C=v[w.charAt(g)];typeof C=="number"?(C&255)==C?B.push(C):(B.push(C>>>8),B.push(C&255)):B.push(x)}}return B}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},n={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},o=function(){var m=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],b=1335,v=7973,x=21522,w={},B=function(g){for(var d=0;g!=0;)d+=1,g>>>=1;return d};return w.getBCHTypeInfo=function(g){for(var d=g<<10;B(d)-B(b)>=0;)d^=b<<B(d)-B(b);return(g<<10|d)^x},w.getBCHTypeNumber=function(g){for(var d=g<<12;B(d)-B(v)>=0;)d^=v<<B(d)-B(v);return g<<12|d},w.getPatternPosition=function(g){return m[g-1]},w.getMaskFunction=function(g){switch(g){case n.PATTERN000:return function(d,C){return(d+C)%2==0};case n.PATTERN001:return function(d,C){return d%2==0};case n.PATTERN010:return function(d,C){return C%3==0};case n.PATTERN011:return function(d,C){return(d+C)%3==0};case n.PATTERN100:return function(d,C){return(Math.floor(d/2)+Math.floor(C/3))%2==0};case n.PATTERN101:return function(d,C){return d*C%2+d*C%3==0};case n.PATTERN110:return function(d,C){return(d*C%2+d*C%3)%2==0};case n.PATTERN111:return function(d,C){return(d*C%3+(d+C)%2)%2==0};default:throw"bad maskPattern:"+g}},w.getErrorCorrectPolynomial=function(g){for(var d=s([1],0),C=0;C<g;C+=1)d=d.multiply(s([1,i.gexp(C)],0));return d},w.getLengthInBits=function(g,d){if(1<=d&&d<10)switch(g){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw"mode:"+g}else if(d<27)switch(g){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw"mode:"+g}else if(d<41)switch(g){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw"mode:"+g}else throw"type:"+d},w.getLostPoint=function(g){for(var d=g.getModuleCount(),C=0,k=0;k<d;k+=1)for(var T=0;T<d;T+=1){for(var D=0,S=g.isDark(k,T),I=-1;I<=1;I+=1)if(!(k+I<0||d<=k+I))for(var L=-1;L<=1;L+=1)T+L<0||d<=T+L||I==0&&L==0||S==g.isDark(k+I,T+L)&&(D+=1);D>5&&(C+=3+D-5)}for(var k=0;k<d-1;k+=1)for(var T=0;T<d-1;T+=1){var $=0;g.isDark(k,T)&&($+=1),g.isDark(k+1,T)&&($+=1),g.isDark(k,T+1)&&($+=1),g.isDark(k+1,T+1)&&($+=1),($==0||$==4)&&(C+=3)}for(var k=0;k<d;k+=1)for(var T=0;T<d-6;T+=1)g.isDark(k,T)&&!g.isDark(k,T+1)&&g.isDark(k,T+2)&&g.isDark(k,T+3)&&g.isDark(k,T+4)&&!g.isDark(k,T+5)&&g.isDark(k,T+6)&&(C+=40);for(var T=0;T<d;T+=1)for(var k=0;k<d-6;k+=1)g.isDark(k,T)&&!g.isDark(k+1,T)&&g.isDark(k+2,T)&&g.isDark(k+3,T)&&g.isDark(k+4,T)&&!g.isDark(k+5,T)&&g.isDark(k+6,T)&&(C+=40);for(var M=0,T=0;T<d;T+=1)for(var k=0;k<d;k+=1)g.isDark(k,T)&&(M+=1);var W=Math.abs(100*M/d/d-50)/5;return C+=W*10,C},w}(),i=function(){for(var m=new Array(256),b=new Array(256),v=0;v<8;v+=1)m[v]=1<<v;for(var v=8;v<256;v+=1)m[v]=m[v-4]^m[v-5]^m[v-6]^m[v-8];for(var v=0;v<255;v+=1)b[m[v]]=v;var x={};return x.glog=function(w){if(w<1)throw"glog("+w+")";return b[w]},x.gexp=function(w){for(;w<0;)w+=255;for(;w>=256;)w-=255;return m[w]},x}();function s(m,b){if(typeof m.length>"u")throw m.length+"/"+b;var v=function(){for(var w=0;w<m.length&&m[w]==0;)w+=1;for(var B=new Array(m.length-w+b),g=0;g<m.length-w;g+=1)B[g]=m[g+w];return B}(),x={};return x.getAt=function(w){return v[w]},x.getLength=function(){return v.length},x.multiply=function(w){for(var B=new Array(x.getLength()+w.getLength()-1),g=0;g<x.getLength();g+=1)for(var d=0;d<w.getLength();d+=1)B[g+d]^=i.gexp(i.glog(x.getAt(g))+i.glog(w.getAt(d)));return s(B,0)},x.mod=function(w){if(x.getLength()-w.getLength()<0)return x;for(var B=i.glog(x.getAt(0))-i.glog(w.getAt(0)),g=new Array(x.getLength()),d=0;d<x.getLength();d+=1)g[d]=x.getAt(d);for(var d=0;d<w.getLength();d+=1)g[d]^=i.gexp(i.glog(w.getAt(d))+B);return s(g,0).mod(w)},x}var a=function(){var m=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],b=function(w,B){var g={};return g.totalCount=w,g.dataCount=B,g},v={},x=function(w,B){switch(B){case r.L:return m[(w-1)*4+0];case r.M:return m[(w-1)*4+1];case r.Q:return m[(w-1)*4+2];case r.H:return m[(w-1)*4+3];default:return}};return v.getRSBlocks=function(w,B){var g=x(w,B);if(typeof g>"u")throw"bad rs block @ typeNumber:"+w+"/errorCorrectionLevel:"+B;for(var d=g.length/3,C=[],k=0;k<d;k+=1)for(var T=g[k*3+0],D=g[k*3+1],S=g[k*3+2],I=0;I<T;I+=1)C.push(b(D,S));return C},v}(),c=function(){var m=[],b=0,v={};return v.getBuffer=function(){return m},v.getAt=function(x){var w=Math.floor(x/8);return(m[w]>>>7-x%8&1)==1},v.put=function(x,w){for(var B=0;B<w;B+=1)v.putBit((x>>>w-B-1&1)==1)},v.getLengthInBits=function(){return b},v.putBit=function(x){var w=Math.floor(b/8);m.length<=w&&m.push(0),x&&(m[w]|=128>>>b%8),b+=1},v},f=function(m){var b=e.MODE_NUMBER,v=m,x={};x.getMode=function(){return b},x.getLength=function(g){return v.length},x.write=function(g){for(var d=v,C=0;C+2<d.length;)g.put(w(d.substring(C,C+3)),10),C+=3;C<d.length&&(d.length-C==1?g.put(w(d.substring(C,C+1)),4):d.length-C==2&&g.put(w(d.substring(C,C+2)),7))};var w=function(g){for(var d=0,C=0;C<g.length;C+=1)d=d*10+B(g.charAt(C));return d},B=function(g){if("0"<=g&&g<="9")return g.charCodeAt(0)-48;throw"illegal char :"+g};return x},h=function(m){var b=e.MODE_ALPHA_NUM,v=m,x={};x.getMode=function(){return b},x.getLength=function(B){return v.length},x.write=function(B){for(var g=v,d=0;d+1<g.length;)B.put(w(g.charAt(d))*45+w(g.charAt(d+1)),11),d+=2;d<g.length&&B.put(w(g.charAt(d)),6)};var w=function(B){if("0"<=B&&B<="9")return B.charCodeAt(0)-48;if("A"<=B&&B<="Z")return B.charCodeAt(0)-65+10;switch(B){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+B}};return x},u=function(m){var b=e.MODE_8BIT_BYTE,v=m,x=t.stringToBytes(m),w={};return w.getMode=function(){return b},w.getLength=function(B){return x.length},w.write=function(B){for(var g=0;g<x.length;g+=1)B.put(x[g],8)},w},l=function(m){var b=e.MODE_KANJI,v=m,x=t.stringToBytesFuncs.SJIS;if(!x)throw"sjis not supported.";(function(g,d){var C=x(g);if(C.length!=2||(C[0]<<8|C[1])!=d)throw"sjis not supported."})("\u53CB",38726);var w=x(m),B={};return B.getMode=function(){return b},B.getLength=function(g){return~~(w.length/2)},B.write=function(g){for(var d=w,C=0;C+1<d.length;){var k=(255&d[C])<<8|255&d[C+1];if(33088<=k&&k<=40956)k-=33088;else if(57408<=k&&k<=60351)k-=49472;else throw"illegal char at "+(C+1)+"/"+k;k=(k>>>8&255)*192+(k&255),g.put(k,13),C+=2}if(C<d.length)throw"illegal char at "+(C+1)},B},y=function(){var m=[],b={};return b.writeByte=function(v){m.push(v&255)},b.writeShort=function(v){b.writeByte(v),b.writeByte(v>>>8)},b.writeBytes=function(v,x,w){x=x||0,w=w||v.length;for(var B=0;B<w;B+=1)b.writeByte(v[B+x])},b.writeString=function(v){for(var x=0;x<v.length;x+=1)b.writeByte(v.charCodeAt(x))},b.toByteArray=function(){return m},b.toString=function(){var v="";v+="[";for(var x=0;x<m.length;x+=1)x>0&&(v+=","),v+=m[x];return v+="]",v},b},N=function(){var m=0,b=0,v=0,x="",w={},B=function(d){x+=String.fromCharCode(g(d&63))},g=function(d){if(!(d<0)){if(d<26)return 65+d;if(d<52)return 97+(d-26);if(d<62)return 48+(d-52);if(d==62)return 43;if(d==63)return 47}throw"n:"+d};return w.writeByte=function(d){for(m=m<<8|d&255,b+=8,v+=1;b>=6;)B(m>>>b-6),b-=6},w.flush=function(){if(b>0&&(B(m<<6-b),m=0,b=0),v%3!=0)for(var d=3-v%3,C=0;C<d;C+=1)x+="="},w.toString=function(){return x},w},E=function(m){var b=m,v=0,x=0,w=0,B={};B.read=function(){for(;w<8;){if(v>=b.length){if(w==0)return-1;throw"unexpected end of file./"+w}var d=b.charAt(v);if(v+=1,d=="=")return w=0,-1;if(d.match(/^\s$/))continue;x=x<<6|g(d.charCodeAt(0)),w+=6}var C=x>>>w-8&255;return w-=8,C};var g=function(d){if(65<=d&&d<=90)return d-65;if(97<=d&&d<=122)return d-97+26;if(48<=d&&d<=57)return d-48+52;if(d==43)return 62;if(d==47)return 63;throw"c:"+d};return B},p=function(m,b){var v=m,x=b,w=new Array(m*b),B={};B.setPixel=function(k,T,D){w[T*v+k]=D},B.write=function(k){k.writeString("GIF87a"),k.writeShort(v),k.writeShort(x),k.writeByte(128),k.writeByte(0),k.writeByte(0),k.writeByte(0),k.writeByte(0),k.writeByte(0),k.writeByte(255),k.writeByte(255),k.writeByte(255),k.writeString(","),k.writeShort(0),k.writeShort(0),k.writeShort(v),k.writeShort(x),k.writeByte(0);var T=2,D=d(T);k.writeByte(T);for(var S=0;D.length-S>255;)k.writeByte(255),k.writeBytes(D,S,255),S+=255;k.writeByte(D.length-S),k.writeBytes(D,S,D.length-S),k.writeByte(0),k.writeString(";")};var g=function(k){var T=k,D=0,S=0,I={};return I.write=function(L,$){if(L>>>$)throw"length over";for(;D+$>=8;)T.writeByte(255&(L<<D|S)),$-=8-D,L>>>=8-D,S=0,D=0;S=L<<D|S,D=D+$},I.flush=function(){D>0&&T.writeByte(S)},I},d=function(k){for(var T=1<<k,D=(1<<k)+1,S=k+1,I=C(),L=0;L<T;L+=1)I.add(String.fromCharCode(L));I.add(String.fromCharCode(T)),I.add(String.fromCharCode(D));var $=y(),M=g($);M.write(T,S);var W=0,j=String.fromCharCode(w[W]);for(W+=1;W<w.length;){var Y=String.fromCharCode(w[W]);W+=1,I.contains(j+Y)?j=j+Y:(M.write(I.indexOf(j),S),I.size()<4095&&(I.size()==1<<S&&(S+=1),I.add(j+Y)),j=Y)}return M.write(I.indexOf(j),S),M.write(D,S),M.flush(),$.toByteArray()},C=function(){var k={},T=0,D={};return D.add=function(S){if(D.contains(S))throw"dup key:"+S;k[S]=T,T+=1},D.size=function(){return T},D.indexOf=function(S){return k[S]},D.contains=function(S){return typeof k[S]<"u"},D};return B},A=function(m,b,v){for(var x=p(m,b),w=0;w<b;w+=1)for(var B=0;B<m;B+=1)x.setPixel(B,w,v(B,w));var g=y();x.write(g);for(var d=N(),C=g.toByteArray(),k=0;k<C.length;k+=1)d.writeByte(C[k]);return d.flush(),"data:image/gif;base64,"+d};return t}();(function(){mc.stringToBytesFuncs["UTF-8"]=function(t){function e(r){for(var n=[],o=0;o<r.length;o++){var i=r.charCodeAt(o);i<128?n.push(i):i<2048?n.push(192|i>>6,128|i&63):i<55296||i>=57344?n.push(224|i>>12,128|i>>6&63,128|i&63):(o++,i=65536+((i&1023)<<10|r.charCodeAt(o)&1023),n.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return n}return e(t)}})();(function(t){typeof define=="function"&&define.amd?define([],t):typeof xc=="object"&&(Ec.exports=t())})(function(){return mc})});var Ol={};Vi(Ol,{buildPayment:()=>Hl,newWords:()=>Cl,open:()=>Pl,qrSvg:()=>$l,sync:()=>Rl,validAddress:()=>Ac,validWords:()=>_l});function Yi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pc(t,...e){if(!Yi(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Gi(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(r=>typeof r=="string"):e.every(r=>Number.isSafeInteger(r)):!1}function Rc(t){if(typeof t!="function")throw new Error("function expected");return!0}function Wr(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function Zi(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Xn(t){if(!Array.isArray(t))throw new Error("array expected")}function Fi(t,e){if(!Gi(!0,e))throw new Error(`${t}: array of strings expected`)}function Hc(t,e){if(!Gi(!1,e))throw new Error(`${t}: array of numbers expected`)}function $c(...t){let e=i=>i,r=(i,s)=>a=>i(s(a)),n=t.map(i=>i.encode).reduceRight(r,e),o=t.map(i=>i.decode).reduce(r,e);return{encode:n,decode:o}}function Oc(t){let e=typeof t=="string"?t.split(""):t,r=e.length;Fi("alphabet",e);let n=new Map(e.map((o,i)=>[o,i]));return{encode:o=>(Xn(o),o.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:o=>(Xn(o),o.map(i=>{Wr("alphabet.decode",i);let s=n.get(i);if(s===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return s}))}}function Mc(t=""){return Wr("join",t),{encode:e=>(Fi("join.decode",e),e.join(t)),decode:e=>(Wr("join.decode",e),e.split(t))}}function Dc(t){return Rc(t),{encode:e=>e,decode:e=>t(e)}}var Qi=(t,e)=>e===0?t:Qi(e,t%e),Vr=(t,e)=>t+(e-Qi(t,e)),Qn=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function ji(t,e,r,n){if(Xn(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Vr(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Vr(e,r)}`);let o=0,i=0,s=Qn[e],a=Qn[r]-1,c=[];for(let f of t){if(Zi(f),f>=s)throw new Error(`convertRadix2: invalid data word=${f} from=${e}`);if(o=o<<e|f,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=r;i-=r)c.push((o>>i-r&a)>>>0);let h=Qn[i];if(h===void 0)throw new Error("invalid carry");o&=h-1}if(o=o<<r-i&a,!n&&i>=e)throw new Error("Excess padding");if(!n&&o>0)throw new Error(`Non-zero padding: ${o}`);return n&&i>0&&c.push(o>>>0),c}function Kc(t,e=!1){if(Zi(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Vr(8,t)>32||Vr(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Yi(r))throw new Error("radix2.encode input should be Uint8Array");return ji(Array.from(r),8,t,!e)},decode:r=>(Hc("radix2.decode",r),Uint8Array.from(ji(r,t,8,e)))}}var Xi={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},qc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wc={encode(t){return Pc(t),t.toHex()},decode(t){return Wr("hex",t),Uint8Array.fromHex(t)}},gr=qc?Wc:$c(Kc(4),Oc("0123456789abcdef"),Mc(""),Dc(t=>{if(typeof t!="string"||t.length%2!==0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));var rt=new Uint8Array,ro=new Uint8Array([0]);function Ze(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function Rt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Vc(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];if(!Rt(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var no=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Fe(t){return Object.prototype.toString.call(t)==="[object Object]"}function Wt(t){return Number.isSafeInteger(t)}var Ji={equalBytes:Ze,isBytes:Rt,isCoder:Ut,checkBounds:es,concatBytes:Vc,createView:no,isPlainObject:Fe},ts=t=>{if(t!==null&&typeof t!="string"&&!Ut(t)&&!Rt(t)&&!Wt(t))throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);return{encodeStream(e,r){if(t===null)return;if(Ut(t))return t.encodeStream(e,r);let n;if(typeof t=="number"?n=t:typeof t=="string"&&(n=Gt.resolve(e.stack,t)),typeof n=="bigint"&&(n=Number(n)),n===void 0||n!==r)throw e.err(`Wrong length: ${n} len=${t} exp=${r} (${typeof r})`)},decodeStream(e){let r;if(Ut(t)?r=Number(t.decodeStream(e)):typeof t=="number"?r=t:typeof t=="string"&&(r=Gt.resolve(e.stack,t)),typeof r=="bigint"&&(r=Number(r)),typeof r!="number")throw e.err(`Wrong length: ${r}`);return r}}},wt={BITS:32,FULL_MASK:-1>>>0,len:t=>Math.ceil(t/32),create:t=>new Uint32Array(wt.len(t)),clean:t=>t.fill(0),debug:t=>Array.from(t).map(e=>(e>>>0).toString(2).padStart(32,"0")),checkLen:(t,e)=>{if(wt.len(e)!==t.length)throw new Error(`wrong length=${t.length}. Expected: ${wt.len(e)}`)},chunkLen:(t,e,r)=>{if(e<0)throw new Error(`wrong pos=${e}`);if(e+r>t)throw new Error(`wrong range=${e}/${r} of ${t}`)},set:(t,e,r,n=!0)=>!n&&t[e]&r?!1:(t[e]|=r,!0),pos:(t,e)=>({chunk:Math.floor((t+e)/32),mask:1<<32-(t+e)%32-1}),indices:(t,e,r=!1)=>{wt.checkLen(t,e);let{FULL_MASK:n,BITS:o}=wt,i=o-e%o,s=i?n>>>i<<i:n,a=[];for(let c=0;c<t.length;c++){let f=t[c];if(r&&(f=~f),c===t.length-1&&(f&=s),f!==0)for(let h=0;h<o;h++){let u=1<<o-h-1;f&u&&a.push(c*o+h)}}return a},range:t=>{let e=[],r;for(let n of t)r===void 0||n!==r.pos+r.length?e.push(r={pos:n,length:1}):r.length+=1;return e},rangeDebug:(t,e,r=!1)=>`[${wt.range(wt.indices(t,e,r)).map(n=>`(${n.pos}/${n.length})`).join(", ")}]`,setRange:(t,e,r,n,o=!0)=>{wt.chunkLen(e,r,n);let{FULL_MASK:i,BITS:s}=wt,a=r%s?Math.floor(r/s):void 0,c=r+n,f=c%s?Math.floor(c/s):void 0;if(a!==void 0&&a===f)return wt.set(t,a,i>>>s-n<<s-n-r,o);if(a!==void 0&&!wt.set(t,a,i>>>r%s,o))return!1;let h=a!==void 0?a+1:r/s,u=f!==void 0?f:c/s;for(let l=h;l<u;l++)if(!wt.set(t,l,i,o))return!1;return!(f!==void 0&&a!==f&&!wt.set(t,f,i<<s-c%s,o))}},Gt={pushObj:(t,e,r)=>{let n={obj:e};t.push(n),r((o,i)=>{n.field=o,i(),n.field=void 0}),t.pop()},path:t=>{let e=[];for(let r of t)r.field!==void 0&&e.push(r.field);return e.join("/")},err:(t,e,r)=>{let n=new Error(`${t}(${Gt.path(e)}): ${typeof r=="string"?r:r.message}`);return r instanceof Error&&r.stack&&(n.stack=r.stack),n},resolve:(t,e)=>{let r=e.split("/"),n=t.map(s=>s.obj),o=0;for(;o<r.length&&r[o]==="..";o++)n.pop();let i=n.pop();for(;o<r.length;o++){if(!i||i[r[o]]===void 0)return;i=i[r[o]]}return i}},Jn=class t{constructor(e,r={},n=[],o=void 0,i=0){this.pos=0,this.bitBuf=0,this.bitPos=0,this.data=e,this.opts=r,this.stack=n,this.parent=o,this.parentOffset=i,this.view=no(e)}_enablePointers(){if(this.parent)return this.parent._enablePointers();this.bs||(this.bs=wt.create(this.data.length),wt.setRange(this.bs,this.data.length,0,this.pos,this.opts.allowMultipleReads))}markBytesBS(e,r){return this.parent?this.parent.markBytesBS(this.parentOffset+e,r):!r||!this.bs?!0:wt.setRange(this.bs,this.data.length,e,r,!1)}markBytes(e){let r=this.pos;this.pos+=e;let n=this.markBytesBS(r,e);if(!this.opts.allowMultipleReads&&!n)throw this.err(`multiple read pos=${this.pos} len=${e}`);return n}pushObj(e,r){return Gt.pushObj(this.stack,e,r)}readView(e,r){if(!Number.isFinite(e))throw this.err(`readView: wrong length=${e}`);if(this.pos+e>this.data.length)throw this.err("readView: Unexpected end of buffer");let n=r(this.view,this.pos);return this.markBytes(e),n}absBytes(e){if(e>this.data.length)throw new Error("Unexpected end of buffer");return this.data.subarray(e)}finish(){if(!this.opts.allowUnreadBytes){if(this.bitPos)throw this.err(`${this.bitPos} bits left after unpack: ${gr.encode(this.data.slice(this.pos))}`);if(this.bs&&!this.parent){let e=wt.indices(this.bs,this.data.length,!0);if(e.length){let r=wt.range(e).map(({pos:n,length:o})=>`(${n}/${o})[${gr.encode(this.data.subarray(n,n+o))}]`).join(", ");throw this.err(`unread byte ranges: ${r} (total=${this.data.length})`)}else return}if(!this.isEnd())throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${gr.encode(this.data.slice(this.pos))}`)}}err(e){return Gt.err("Reader",this.stack,e)}offsetReader(e){if(e>this.data.length)throw this.err("offsetReader: Unexpected end of buffer");return new t(this.absBytes(e),this.opts,this.stack,this,e)}bytes(e,r=!1){if(this.bitPos)throw this.err("readBytes: bitPos not empty");if(!Number.isFinite(e))throw this.err(`readBytes: wrong length=${e}`);if(this.pos+e>this.data.length)throw this.err("readBytes: Unexpected end of buffer");let n=this.data.subarray(this.pos,this.pos+e);return r||this.markBytes(e),n}byte(e=!1){if(this.bitPos)throw this.err("readByte: bitPos not empty");if(this.pos+1>this.data.length)throw this.err("readBytes: Unexpected end of buffer");let r=this.data[this.pos];return e||this.markBytes(1),r}get leftBytes(){return this.data.length-this.pos}get totalBytes(){return this.data.length}isEnd(){return this.pos>=this.data.length&&!this.bitPos}bits(e){if(e>32)throw this.err("BitReader: cannot read more than 32 bits in single call");let r=0;for(;e;){this.bitPos||(this.bitBuf=this.byte(),this.bitPos=8);let n=Math.min(e,this.bitPos);this.bitPos-=n,r=r<<n|this.bitBuf>>this.bitPos&2**n-1,this.bitBuf&=2**this.bitPos-1,e-=n}return r>>>0}find(e,r=this.pos){if(!Rt(e))throw this.err(`find: needle is not bytes! ${e}`);if(this.bitPos)throw this.err("findByte: bitPos not empty");if(!e.length)throw this.err("find: needle is empty");for(let n=r;(n=this.data.indexOf(e[0],n))!==-1;n++){if(n===-1||this.data.length-n<e.length)return;if(Ze(e,this.data.subarray(n,n+e.length)))return n}}},to=class{constructor(e=[]){this.pos=0,this.buffers=[],this.ptrs=[],this.bitBuf=0,this.bitPos=0,this.viewBuf=new Uint8Array(8),this.finished=!1,this.stack=e,this.view=no(this.viewBuf)}pushObj(e,r){return Gt.pushObj(this.stack,e,r)}writeView(e,r){if(this.finished)throw this.err("buffer: finished");if(!Wt(e)||e>8)throw new Error(`wrong writeView length=${e}`);r(this.view),this.bytes(this.viewBuf.slice(0,e)),this.viewBuf.fill(0)}err(e){if(this.finished)throw this.err("buffer: finished");return Gt.err("Reader",this.stack,e)}bytes(e){if(this.finished)throw this.err("buffer: finished");if(this.bitPos)throw this.err("writeBytes: ends with non-empty bit buffer");this.buffers.push(e),this.pos+=e.length}byte(e){if(this.finished)throw this.err("buffer: finished");if(this.bitPos)throw this.err("writeByte: ends with non-empty bit buffer");this.buffers.push(new Uint8Array([e])),this.pos++}finish(e=!0){if(this.finished)throw this.err("buffer: finished");if(this.bitPos)throw this.err("buffer: ends with non-empty bit buffer");let r=this.buffers.concat(this.ptrs.map(i=>i.buffer)),n=r.map(i=>i.length).reduce((i,s)=>i+s,0),o=new Uint8Array(n);for(let i=0,s=0;i<r.length;i++){let a=r[i];o.set(a,s),s+=a.length}for(let i=this.pos,s=0;s<this.ptrs.length;s++){let a=this.ptrs[s];o.set(a.ptr.encode(i),a.pos),i+=a.buffer.length}if(e){this.buffers=[];for(let i of this.ptrs)i.buffer.fill(0);this.ptrs=[],this.finished=!0,this.bitBuf=0}return o}bits(e,r){if(r>32)throw this.err("writeBits: cannot write more than 32 bits in single call");if(e>=2**r)throw this.err(`writeBits: value (${e}) >= 2**bits (${r})`);for(;r;){let n=Math.min(r,8-this.bitPos);this.bitBuf=this.bitBuf<<n|e>>r-n,this.bitPos+=n,r-=n,e&=2**r-1,this.bitPos===8&&(this.bitPos=0,this.buffers.push(new Uint8Array([this.bitBuf])),this.pos++)}}},eo=t=>Uint8Array.from(t).reverse();function es(t,e,r){if(r){let n=2n**(e-1n);if(t<-n||t>=n)throw new Error(`value out of signed bounds. Expected ${-n} <= ${t} < ${n}`)}else if(0n>t||t>=2n**e)throw new Error(`value out of unsigned bounds. Expected 0 <= ${t} < ${2n**e}`)}function rs(t){return{encodeStream:t.encodeStream,decodeStream:t.decodeStream,size:t.size,encode:e=>{let r=new to;return t.encodeStream(r,e),r.finish()},decode:(e,r={})=>{let n=new Jn(e,r),o=t.decodeStream(n);return n.finish(),o}}}function vt(t,e){if(!Ut(t))throw new Error(`validate: invalid inner value ${t}`);if(typeof e!="function")throw new Error("validate: fn should be function");return rs({size:t.size,encodeStream:(r,n)=>{let o;try{o=e(n)}catch(i){throw r.err(i)}t.encodeStream(r,o)},decodeStream:r=>{let n=t.decodeStream(r);try{return e(n)}catch(o){throw r.err(o)}}})}var Bt=t=>{let e=rs(t);return t.validate?vt(e,t.validate):e},zr=t=>Fe(t)&&typeof t.decode=="function"&&typeof t.encode=="function";function Ut(t){return Fe(t)&&zr(t)&&typeof t.encodeStream=="function"&&typeof t.decodeStream=="function"&&(t.size===void 0||Wt(t.size))}function zc(){return{encode:t=>{if(!Array.isArray(t))throw new Error("array expected");let e={};for(let r of t){if(!Array.isArray(r)||r.length!==2)throw new Error("array of two elements expected");let n=r[0],o=r[1];if(e[n]!==void 0)throw new Error(`key(${n}) appears twice in struct`);e[n]=o}return e},decode:t=>{if(!Fe(t))throw new Error(`expected plain object, got ${t}`);return Object.entries(t)}}}var jc={encode:t=>{if(typeof t!="bigint")throw new Error(`expected bigint, got ${typeof t}`);if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`element bigger than MAX_SAFE_INTEGER=${t}`);return Number(t)},decode:t=>{if(!Wt(t))throw new Error("element is not a safe integer");return BigInt(t)}};function Yc(t){if(!Fe(t))throw new Error("plain object expected");return{encode:e=>{if(!Wt(e)||!(e in t))throw new Error(`wrong value ${e}`);return t[e]},decode:e=>{if(typeof e!="string")throw new Error(`wrong value ${typeof e}`);return t[e]}}}function Gc(t,e=!1){if(!Wt(t))throw new Error(`decimal/precision: wrong value ${t}`);if(typeof e!="boolean")throw new Error(`decimal/round: expected boolean, got ${typeof e}`);let r=10n**BigInt(t);return{encode:n=>{if(typeof n!="bigint")throw new Error(`expected bigint, got ${typeof n}`);let o=(n<0n?-n:n).toString(10),i=o.length-t;i<0&&(o=o.padStart(o.length-i,"0"),i=0);let s=o.length-1;for(;s>=i&&o[s]==="0";s--);let a=o.slice(0,i),c=o.slice(i,s+1);return a||(a="0"),n<0n&&(a="-"+a),c?`${a}.${c}`:a},decode:n=>{if(typeof n!="string")throw new Error(`expected string, got ${typeof n}`);if(n==="-0")throw new Error("negative zero is not allowed");let o=!1;if(n.startsWith("-")&&(o=!0,n=n.slice(1)),!/^(0|[1-9]\d*)(\.\d+)?$/.test(n))throw new Error(`wrong string value=${n}`);let i=n.indexOf(".");i=i===-1?n.length:i;let s=n.slice(0,i),a=n.slice(i+1).replace(/0+$/,""),c=BigInt(s)*r;if(!e&&a.length>t)throw new Error(`fractional part cannot be represented with this precision (num=${n}, prec=${t})`);let f=Math.min(a.length,t),h=BigInt(a.slice(0,f))*10n**BigInt(t-f),u=c+h;return o?-u:u}}}function Zc(t){if(!Array.isArray(t))throw new Error(`expected array, got ${typeof t}`);for(let e of t)if(!zr(e))throw new Error(`wrong base coder ${e}`);return{encode:e=>{for(let r of t){let n=r.encode(e);if(n!==void 0)return n}throw new Error(`match/encode: cannot find match in ${e}`)},decode:e=>{for(let r of t){let n=r.decode(e);if(n!==void 0)return n}throw new Error(`match/decode: cannot find match in ${e}`)}}}var ns=t=>{if(!zr(t))throw new Error("BaseCoder expected");return{encode:t.decode,decode:t.encode}},ue={dict:zc,numberBigint:jc,tsEnum:Yc,decimal:Gc,match:Zc,reverse:ns};var oo=(t,e=!1,r=!1,n=!0)=>{if(!Wt(t))throw new Error(`bigint/size: wrong value ${t}`);if(typeof e!="boolean")throw new Error(`bigint/le: expected boolean, got ${typeof e}`);if(typeof r!="boolean")throw new Error(`bigint/signed: expected boolean, got ${typeof r}`);if(typeof n!="boolean")throw new Error(`bigint/sized: expected boolean, got ${typeof n}`);let o=BigInt(t),i=2n**(8n*o-1n);return Bt({size:n?t:void 0,encodeStream:(s,a)=>{r&&a<0&&(a=a|i);let c=[];for(let h=0;h<t;h++)c.push(Number(a&255n)),a>>=8n;let f=new Uint8Array(c).reverse();if(!n){let h=0;for(h=0;h<f.length&&f[h]===0;h++);f=f.subarray(h)}s.bytes(e?f.reverse():f)},decodeStream:s=>{let a=s.bytes(n?t:Math.min(t,s.leftBytes)),c=e?a:eo(a),f=0n;for(let h=0;h<c.length;h++)f|=BigInt(c[h])<<8n*BigInt(h);return r&&f&i&&(f=(f^i)-i),f},validate:s=>{if(typeof s!="bigint")throw new Error(`bigint: invalid value: ${s}`);return es(s,8n*o,!!r),s}})};var os=oo(32,!1);var Qe=oo(8,!0);var is=oo(8,!0,!0);var Fc=(t,e)=>Bt({size:t,encodeStream:(r,n)=>r.writeView(t,o=>e.write(o,n)),decodeStream:r=>r.readView(t,e.read),validate:r=>{if(typeof r!="number")throw new Error(`viewCoder: expected number, got ${typeof r}`);return e.validate&&e.validate(r),r}}),wr=(t,e,r)=>{let n=t*8,o=2**(n-1),i=c=>{if(!Wt(c))throw new Error(`sintView: value is not safe integer: ${c}`);if(c<-o||c>=o)throw new Error(`sintView: value out of bounds. Expected ${-o} <= ${c} < ${o}`)},s=2**n,a=c=>{if(!Wt(c))throw new Error(`uintView: value is not safe integer: ${c}`);if(0>c||c>=s)throw new Error(`uintView: value out of bounds. Expected 0 <= ${c} < ${s}`)};return Fc(t,{write:r.write,read:r.read,validate:e?i:a})},Q=wr(4,!1,{read:(t,e)=>t.getUint32(e,!0),write:(t,e)=>t.setUint32(0,e,!0)}),ss=wr(4,!1,{read:(t,e)=>t.getUint32(e,!1),write:(t,e)=>t.setUint32(0,e,!1)}),le=wr(4,!0,{read:(t,e)=>t.getInt32(e,!0),write:(t,e)=>t.setInt32(0,e,!0)});var io=wr(2,!1,{read:(t,e)=>t.getUint16(e,!0),write:(t,e)=>t.setUint16(0,e,!0)});var $t=wr(1,!1,{read:(t,e)=>t.getUint8(e),write:(t,e)=>t.setUint8(0,e)});var et=(t,e=!1)=>{if(typeof e!="boolean")throw new Error(`bytes/le: expected boolean, got ${typeof e}`);let r=ts(t),n=Rt(t);return Bt({size:typeof t=="number"?t:void 0,encodeStream:(o,i)=>{n||r.encodeStream(o,i.length),o.bytes(e?eo(i):i),n&&o.bytes(t)},decodeStream:o=>{let i;if(n){let s=o.find(t);if(!s)throw o.err("bytes: cannot find terminator");i=o.bytes(s-o.pos),o.bytes(t.length)}else i=o.bytes(t===null?o.leftBytes:r.decodeStream(o));return e?eo(i):i},validate:o=>{if(!Rt(o))throw new Error(`bytes: invalid value ${o}`);return o}})};function as(t,e){if(!Ut(e))throw new Error(`prefix: invalid inner value ${e}`);return Vt(et(t),ns(e))}var jr=(t,e=!1)=>vt(Vt(et(t,e),Xi),r=>{if(typeof r!="string")throw new Error(`expected string, got ${typeof r}`);return r});var cs=(t,e={isLE:!1,with0x:!1})=>{let r=Vt(et(t,e.isLE),gr),n=e.with0x;if(typeof n!="boolean")throw new Error(`hex/with0x: expected boolean, got ${typeof n}`);return n&&(r=Vt(r,{encode:o=>`0x${o}`,decode:o=>{if(!o.startsWith("0x"))throw new Error("hex(with0x=true).encode input should start with 0x");return o.slice(2)}})),r};function Vt(t,e){if(!Ut(t))throw new Error(`apply: invalid inner value ${t}`);if(!zr(e))throw new Error(`apply: invalid base value ${t}`);return Bt({size:t.size,encodeStream:(r,n)=>{let o;try{o=e.decode(n)}catch(i){throw r.err(""+i)}return t.encodeStream(r,o)},decodeStream:r=>{let n=t.decodeStream(r);try{return e.encode(n)}catch(o){throw r.err(""+o)}}})}var fs=(t,e=!1)=>{if(!Rt(t))throw new Error(`flag/flagValue: expected Uint8Array, got ${typeof t}`);if(typeof e!="boolean")throw new Error(`flag/xor: expected boolean, got ${typeof e}`);return Bt({size:t.length,encodeStream:(r,n)=>{!!n!==e&&r.bytes(t)},decodeStream:r=>{let n=r.leftBytes>=t.length;return n&&(n=Ze(r.bytes(t.length,!0),t),n&&r.bytes(t.length)),n!==e},validate:r=>{if(r!==void 0&&typeof r!="boolean")throw new Error(`flag: expected boolean value or undefined, got ${typeof r}`);return r}})};function us(t,e,r){if(!Ut(e))throw new Error(`flagged: invalid inner value ${e}`);if(typeof t!="string"&&!Ut(e))throw new Error(`flagged: wrong path=${t}`);return Bt({encodeStream:(n,o)=>{typeof t=="string"?Gt.resolve(n.stack,t)?e.encodeStream(n,o):r&&e.encodeStream(n,r):(t.encodeStream(n,!!o),o?e.encodeStream(n,o):r&&e.encodeStream(n,r))},decodeStream:n=>{let o=!1;if(typeof t=="string"?o=!!Gt.resolve(n.stack,t):o=t.decodeStream(n),o)return e.decodeStream(n);r&&e.decodeStream(n)}})}function Yr(t,e,r=!0){if(!Ut(t))throw new Error(`magic: invalid inner value ${t}`);if(typeof r!="boolean")throw new Error(`magic: expected boolean, got ${typeof r}`);return Bt({size:t.size,encodeStream:(n,o)=>t.encodeStream(n,e),decodeStream:n=>{let o=t.decodeStream(n);if(r&&typeof o!="object"&&o!==e||Rt(e)&&!Ze(e,o))throw n.err(`magic: invalid value: ${o} !== ${e}`)},validate:n=>{if(n!==void 0)throw new Error(`magic: wrong value=${typeof n}`);return n}})}function ls(t){let e=0;for(let r of t){if(r.size===void 0)return;if(!Wt(r.size))throw new Error(`sizeof: wrong element size=${e}`);e+=r.size}return e}function ft(t){if(!Fe(t))throw new Error(`struct: expected plain object, got ${t}`);for(let e in t)if(!Ut(t[e]))throw new Error(`struct: field ${e} is not CoderType`);return Bt({size:ls(Object.values(t)),encodeStream:(e,r)=>{e.pushObj(r,n=>{for(let o in t)n(o,()=>t[o].encodeStream(e,r[o]))})},decodeStream:e=>{let r={};return e.pushObj(r,n=>{for(let o in t)n(o,()=>r[o]=t[o].decodeStream(e))}),r},validate:e=>{if(typeof e!="object"||e===null)throw new Error(`struct: invalid value ${e}`);return e}})}function ds(t){if(!Array.isArray(t))throw new Error(`Packed.Tuple: got ${typeof t} instead of array`);for(let e=0;e<t.length;e++)if(!Ut(t[e]))throw new Error(`tuple: field ${e} is not CoderType`);return Bt({size:ls(t),encodeStream:(e,r)=>{if(!Array.isArray(r))throw e.err(`tuple: invalid value ${r}`);e.pushObj(r,n=>{for(let o=0;o<t.length;o++)n(`${o}`,()=>t[o].encodeStream(e,r[o]))})},decodeStream:e=>{let r=[];return e.pushObj(r,n=>{for(let o=0;o<t.length;o++)n(`${o}`,()=>r.push(t[o].decodeStream(e)))}),r},validate:e=>{if(!Array.isArray(e))throw new Error(`tuple: invalid value ${e}`);if(e.length!==t.length)throw new Error(`tuple: wrong length=${e.length}, expected ${t.length}`);return e}})}function St(t,e){if(!Ut(e))throw new Error(`array: invalid inner value ${e}`);let r=ts(typeof t=="string"?`../${t}`:t);return Bt({size:typeof t=="number"&&e.size?t*e.size:void 0,encodeStream:(n,o)=>{let i=n;i.pushObj(o,s=>{Rt(t)||r.encodeStream(n,o.length);for(let a=0;a<o.length;a++)s(`${a}`,()=>{let c=o[a],f=n.pos;if(e.encodeStream(n,c),Rt(t)){if(t.length>i.pos-f)return;let h=i.finish(!1).subarray(f,i.pos);if(Ze(h.subarray(0,t.length),t))throw i.err(`array: inner element encoding same as separator. elm=${c} data=${h}`)}})}),Rt(t)&&n.bytes(t)},decodeStream:n=>{let o=[];return n.pushObj(o,i=>{if(t===null)for(let s=0;!n.isEnd()&&(i(`${s}`,()=>o.push(e.decodeStream(n))),!(e.size&&n.leftBytes<e.size));s++);else if(Rt(t))for(let s=0;;s++){if(Ze(n.bytes(t.length,!0),t)){n.bytes(t.length);break}i(`${s}`,()=>o.push(e.decodeStream(n)))}else{let s;i("arrayLen",()=>s=r.decodeStream(n));for(let a=0;a<s;a++)i(`${a}`,()=>o.push(e.decodeStream(n)))}}),o},validate:n=>{if(!Array.isArray(n))throw new Error(`array: invalid value ${n}`);return n}})}function Qc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function so(t,...e){if(!Qc(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ao(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function hs(t,e){so(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Fr=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ot=(t,e)=>t<<32-e|t>>>e,yr=(t,e)=>t<<e|t>>>32-e>>>0;function Xc(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function co(t){return typeof t=="string"&&(t=Xc(t)),so(t),t}var Zr=class{clone(){return this._cloneInto()}};function Qr(t){let e=n=>t().update(co(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Jc(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var ps=(t,e,r)=>t&e^~t&r,gs=(t,e,r)=>t&e^t&r^e&r,Xe=class extends Zr{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Fr(this.buffer)}update(e){ao(this);let{view:r,buffer:n,blockLen:o}=this;e=co(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Fr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ao(this),hs(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)r[u]=0;Jc(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Fr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,h[u],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var tf=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),ys=new Uint8Array(new Array(16).fill(0).map((t,e)=>e)),ef=ys.map(t=>(9*t+5)%16),uo=[ys],lo=[ef];for(let t=0;t<4;t++)for(let e of[uo,lo])e.push(e[t].map(r=>tf[r]));var bs=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),rf=uo.map((t,e)=>t.map(r=>bs[e][r])),nf=lo.map((t,e)=>t.map(r=>bs[e][r])),of=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),sf=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function ws(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var Xr=new Uint32Array(16),fo=class extends Xe{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:r,h2:n,h3:o,h4:i}=this;return[e,r,n,o,i]}set(e,r,n,o,i){this.h0=e|0,this.h1=r|0,this.h2=n|0,this.h3=o|0,this.h4=i|0}process(e,r){for(let y=0;y<16;y++,r+=4)Xr[y]=e.getUint32(r,!0);let n=this.h0|0,o=n,i=this.h1|0,s=i,a=this.h2|0,c=a,f=this.h3|0,h=f,u=this.h4|0,l=u;for(let y=0;y<5;y++){let N=4-y,E=of[y],p=sf[y],A=uo[y],m=lo[y],b=rf[y],v=nf[y];for(let x=0;x<16;x++){let w=yr(n+ws(y,i,a,f)+Xr[A[x]]+E,b[x])+u|0;n=u,u=f,f=yr(a,10)|0,a=i,i=w}for(let x=0;x<16;x++){let w=yr(o+ws(N,s,c,h)+Xr[m[x]]+p,v[x])+l|0;o=l,l=h,h=yr(c,10)|0,c=s,s=w}}this.set(this.h1+a+h|0,this.h2+f+l|0,this.h3+u+o|0,this.h4+n+s|0,this.h0+i+c|0)}roundClean(){Xr.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},ms=Qr(()=>new fo);var af=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]),de=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),he=new Uint32Array(64),ho=class extends Xe{constructor(){super(64,32,8,!1),this.A=de[0]|0,this.B=de[1]|0,this.C=de[2]|0,this.D=de[3]|0,this.E=de[4]|0,this.F=de[5]|0,this.G=de[6]|0,this.H=de[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let u=0;u<16;u++,r+=4)he[u]=e.getUint32(r,!1);for(let u=16;u<64;u++){let l=he[u-15],y=he[u-2],N=Ot(l,7)^Ot(l,18)^l>>>3,E=Ot(y,17)^Ot(y,19)^y>>>10;he[u]=E+he[u-7]+N+he[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:h}=this;for(let u=0;u<64;u++){let l=Ot(a,6)^Ot(a,11)^Ot(a,25),y=h+l+ps(a,c,f)+af[u]+he[u]|0,E=(Ot(n,2)^Ot(n,13)^Ot(n,22))+gs(n,o,i)|0;h=f,f=c,c=a,a=s+y|0,s=i,i=o,o=n,n=y+E|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,o,i,s,a,c,f,h)}roundClean(){he.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var kt=Qr(()=>new ho);function xs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function cf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Je(t,...e){if(!cf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Es(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xs(t.outputLen),xs(t.blockLen)}function tr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vs(t,e){Je(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Jr=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Mt=(t,e)=>t<<32-e|t>>>e;function ff(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function br(t){return typeof t=="string"&&(t=ff(t)),Je(t),t}function Bs(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Je(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var er=class{clone(){return this._cloneInto()}};function Ss(t){let e=n=>t().update(br(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function tn(t=32){if(Ne&&typeof Ne.getRandomValues=="function")return Ne.getRandomValues(new Uint8Array(t));if(Ne&&typeof Ne.randomBytes=="function")return Ne.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function uf(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var As=(t,e,r)=>t&e^~t&r,ks=(t,e,r)=>t&e^t&r^e&r,en=class extends er{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Jr(this.buffer)}update(e){tr(this);let{view:r,buffer:n,blockLen:o}=this;e=br(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Jr(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){tr(this),vs(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)r[u]=0;uf(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Jr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,h[u],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var lf=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]),pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ge=new Uint32Array(64),po=class extends en{constructor(){super(64,32,8,!1),this.A=pe[0]|0,this.B=pe[1]|0,this.C=pe[2]|0,this.D=pe[3]|0,this.E=pe[4]|0,this.F=pe[5]|0,this.G=pe[6]|0,this.H=pe[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let u=0;u<16;u++,r+=4)ge[u]=e.getUint32(r,!1);for(let u=16;u<64;u++){let l=ge[u-15],y=ge[u-2],N=Mt(l,7)^Mt(l,18)^l>>>3,E=Mt(y,17)^Mt(y,19)^y>>>10;ge[u]=E+ge[u-7]+N+ge[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:h}=this;for(let u=0;u<64;u++){let l=Mt(a,6)^Mt(a,11)^Mt(a,25),y=h+l+As(a,c,f)+lf[u]+ge[u]|0,E=(Mt(n,2)^Mt(n,13)^Mt(n,22))+ks(n,o,i)|0;h=f,f=c,c=a,a=s+y|0,s=i,i=o,o=n,n=y+E|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,o,i,s,a,c,f,h)}roundClean(){ge.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var rn=Ss(()=>new po);var nn=class extends er{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Es(e);let n=br(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return tr(this),this.iHash.update(e),this}digestInto(e){tr(this),Je(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},go=(t,e,r)=>new nn(t,e).update(r).digest();go.create=(t,e)=>new nn(t,e);var Eo={};Vi(Eo,{aInRange:()=>zt,abool:()=>Ce,abytes:()=>rr,bitGet:()=>yf,bitLen:()=>mo,bitMask:()=>mr,bitSet:()=>bf,bytesToHex:()=>_e,bytesToNumberBE:()=>Ht,bytesToNumberLE:()=>an,concatBytes:()=>Ft,createHmacDrbg:()=>xo,ensureBytes:()=>ut,equalBytes:()=>gf,hexToBytes:()=>Re,hexToNumber:()=>bo,inRange:()=>ye,isBytes:()=>we,memoized:()=>fn,notImplemented:()=>xf,numberToBytesBE:()=>Dt,numberToBytesLE:()=>cn,numberToHexUnpadded:()=>Pe,numberToVarBytesBE:()=>pf,utf8ToBytes:()=>wf,validateObject:()=>be});var on=BigInt(0),sn=BigInt(1),df=BigInt(2);function we(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rr(t){if(!we(t))throw new Error("Uint8Array expected")}function Ce(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}var hf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _e(t){rr(t);let e="";for(let r=0;r<t.length;r++)e+=hf[t[r]];return e}function Pe(t){let e=t.toString(16);return e.length&1?"0"+e:e}function bo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?on:BigInt("0x"+t)}var Zt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ts(t){if(t>=Zt._0&&t<=Zt._9)return t-Zt._0;if(t>=Zt.A&&t<=Zt.F)return t-(Zt.A-10);if(t>=Zt.a&&t<=Zt.f)return t-(Zt.a-10)}function Re(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ts(t.charCodeAt(i)),a=Ts(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ht(t){return bo(_e(t))}function an(t){return rr(t),bo(_e(Uint8Array.from(t).reverse()))}function Dt(t,e){return Re(t.toString(16).padStart(e*2,"0"))}function cn(t,e){return Dt(t,e).reverse()}function pf(t){return Re(Pe(t))}function ut(t,e,r){let n;if(typeof e=="string")try{n=Re(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(we(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function Ft(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];rr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function gf(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function wf(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}var wo=t=>typeof t=="bigint"&&on<=t;function ye(t,e,r){return wo(t)&&wo(e)&&wo(r)&&e<=t&&t<r}function zt(t,e,r,n){if(!ye(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function mo(t){let e;for(e=0;t>on;t>>=sn,e+=1);return e}function yf(t,e){return t>>BigInt(e)&sn}function bf(t,e,r){return t|(r?sn:on)<<BigInt(e)}var mr=t=>(df<<BigInt(t-1))-sn,yo=t=>new Uint8Array(t),Is=t=>Uint8Array.from(t);function xo(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=yo(t),o=yo(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...u)=>r(o,n,...u),c=(u=yo())=>{o=a(Is([0]),u),n=a(),u.length!==0&&(o=a(Is([1]),u),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,l=[];for(;u<e;){n=a();let y=n.slice();l.push(y),u+=n.length}return Ft(...l)};return(u,l)=>{s(),c(u);let y;for(;!(y=l(f()));)c();return s(),y}}var mf={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||we(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function be(t,e,r={}){let n=(o,i,s)=>{let a=mf[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var xf=()=>{throw new Error("not implemented")};function fn(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var dt=BigInt(0),nt=BigInt(1),He=BigInt(2),Ef=BigInt(3),vo=BigInt(4),Us=BigInt(5),Ls=BigInt(8),vf=BigInt(9),Bf=BigInt(16);function lt(t,e){let r=t%e;return r>=dt?r:e+r}function Sf(t,e,r){if(e<dt)throw new Error("invalid exponent, negatives unsupported");if(r<=dt)throw new Error("invalid modulus");if(r===nt)return dt;let n=nt;for(;e>dt;)e&nt&&(n=n*t%r),t=t*t%r,e>>=nt;return n}function Lt(t,e,r){let n=t;for(;e-- >dt;)n*=n,n%=r;return n}function un(t,e){if(t===dt)throw new Error("invert: expected non-zero number");if(e<=dt)throw new Error("invert: expected positive modulus, got "+e);let r=lt(t,e),n=e,o=dt,i=nt,s=nt,a=dt;for(;r!==dt;){let f=n/r,h=n%r,u=o-s*f,l=i-a*f;n=r,r=h,o=s,i=a,s=u,a=l}if(n!==nt)throw new Error("invert: does not exist");return lt(o,e)}function Af(t){let e=(t-nt)/He,r,n,o;for(r=t-nt,n=0;r%He===dt;r/=He,n++);for(o=He;o<t&&Sf(o,e,t)!==t-nt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+nt)/vo;return function(c,f){let h=c.pow(f,s);if(!c.eql(c.sqr(h),f))throw new Error("Cannot find square root");return h}}let i=(r+nt)/He;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,h=a.pow(a.mul(a.ONE,o),r),u=a.pow(c,i),l=a.pow(c,r);for(;!a.eql(l,a.ONE);){if(a.eql(l,a.ZERO))return a.ZERO;let y=1;for(let E=a.sqr(l);y<f&&!a.eql(E,a.ONE);y++)E=a.sqr(E);let N=a.pow(h,nt<<BigInt(f-y-1));h=a.sqr(N),u=a.mul(u,N),l=a.mul(l,h),f=y}return u}}function kf(t){if(t%vo===Ef){let e=(t+nt)/vo;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Ls===Us){let e=(t-Us)/Ls;return function(n,o){let i=n.mul(o,He),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,He),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return t%Bf,Af(t)}var Tf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bo(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Tf.reduce((n,o)=>(n[o]="function",n),e);return be(t,r)}function If(t,e,r){if(r<dt)throw new Error("invalid exponent, negatives unsupported");if(r===dt)return t.ONE;if(r===nt)return e;let n=t.ONE,o=e;for(;r>dt;)r&nt&&(n=t.mul(n,o)),o=t.sqr(o),r>>=nt;return n}function Uf(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function So(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ln(t,e,r=!1,n={}){if(t<=dt)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=So(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:mr(o),ZERO:dt,ONE:nt,create:c=>lt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return dt<=c&&c<t},is0:c=>c===dt,isOdd:c=>(c&nt)===nt,neg:c=>lt(-c,t),eql:(c,f)=>c===f,sqr:c=>lt(c*c,t),add:(c,f)=>lt(c+f,t),sub:(c,f)=>lt(c-f,t),mul:(c,f)=>lt(c*f,t),pow:(c,f)=>If(a,c,f),div:(c,f)=>lt(c*un(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>un(c,t),sqrt:n.sqrt||(c=>(s||(s=kf(t)),s(a,c))),invertBatch:c=>Uf(a,c),cmov:(c,f,h)=>h?f:c,toBytes:c=>r?cn(c,i):Dt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?an(c):Ht(c)}});return Object.freeze(a)}function Ns(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Ao(t){let e=Ns(t);return e+Math.ceil(e/2)}function Cs(t,e,r=!1){let n=t.length,o=Ns(e),i=Ao(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ht(t):an(t),a=lt(s,e-nt)+nt;return r?cn(a,o):Dt(a,o)}var _s=BigInt(0),dn=BigInt(1);function ko(t,e){let r=e.negate();return t?r:e}function Ps(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function To(t,e){Ps(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function Nf(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function Cf(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Io=new WeakMap,Rs=new WeakMap;function Uo(t){return Rs.get(t)||1}function Hs(t,e){return{constTimeNegate:ko,hasPrecomputes(r){return Uo(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>_s;)n&dn&&(o=o.add(i)),i=i.double(),n>>=dn;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=To(n,e),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let h=1;h<i;h++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=To(r,e),a=t.ZERO,c=t.BASE,f=BigInt(2**r-1),h=2**r,u=BigInt(r);for(let l=0;l<i;l++){let y=l*s,N=Number(o&f);o>>=u,N>s&&(N-=h,o+=dn);let E=y,p=y+Math.abs(N)-1,A=l%2!==0,m=N<0;N===0?c=c.add(ko(A,n[E])):a=a.add(ko(m,n[p]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=t.ZERO){let{windows:s,windowSize:a}=To(r,e),c=BigInt(2**r-1),f=2**r,h=BigInt(r);for(let u=0;u<s;u++){let l=u*a;if(o===_s)break;let y=Number(o&c);if(o>>=h,y>a&&(y-=f,o+=dn),y===0)continue;let N=n[l+Math.abs(y)-1];y<0&&(N=N.negate()),i=i.add(N)}return i},getPrecomputes(r,n,o){let i=Io.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Io.set(n,o(i))),i},wNAFCached(r,n,o){let i=Uo(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Uo(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ps(n,e),Rs.set(r,n),Io.delete(r)}}}function $s(t,e,r,n){if(Nf(r,t),Cf(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=mo(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),f=Math.floor((e.BITS-1)/s)*s,h=o;for(let u=f;u>=0;u-=s){c.fill(o);for(let y=0;y<n.length;y++){let N=n[y],E=Number(N>>BigInt(u)&BigInt(a));c[E]=c[E].add(r[y])}let l=o;for(let y=c.length-1,N=o;y>0;y--)N=N.add(c[y]),l=l.add(N);if(h=h.add(l),u!==0)for(let y=0;y<s;y++)h=h.double()}return h}function Lo(t){return Bo(t.Fp),be(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...So(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function Os(t){t.lowS!==void 0&&Ce("lowS",t.lowS),t.prehash!==void 0&&Ce("prehash",t.prehash)}function _f(t){let e=Lo(t);be(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Pf,hexToBytes:Rf}=Eo,Qt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=Qt;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Pe(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Pe(o.length/2|128):"";return Pe(t)+i+o+e},decode(t,e){let{Err:r}=Qt,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let h of f)s=s<<8|h;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Qt;if(t<Xt)throw new e("integer: negative integers are not allowed");let r=Pe(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=Qt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Pf(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Qt,o=typeof t=="string"?Rf(t):t;rr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:h}=n.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=Qt,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},Xt=BigInt(0),yt=BigInt(1),Ed=BigInt(2),Ms=BigInt(3),vd=BigInt(4);function Hf(t){let e=_f(t),{Fp:r}=e,n=ln(e.n,e.nBitLength),o=e.toBytes||((E,p,A)=>{let m=p.toAffine();return Ft(Uint8Array.from([4]),r.toBytes(m.x),r.toBytes(m.y))}),i=e.fromBytes||(E=>{let p=E.subarray(1),A=r.fromBytes(p.subarray(0,r.BYTES)),m=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:A,y:m}});function s(E){let{a:p,b:A}=e,m=r.sqr(E),b=r.mul(m,E);return r.add(r.add(b,r.mul(E,p)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(E){return ye(E,yt,e.n)}function c(E){let{allowedPrivateKeyLengths:p,nByteLength:A,wrapPrivateKey:m,n:b}=e;if(p&&typeof E!="bigint"){if(we(E)&&(E=_e(E)),typeof E!="string"||!p.includes(E.length))throw new Error("invalid private key");E=E.padStart(A*2,"0")}let v;try{v=typeof E=="bigint"?E:Ht(ut("private key",E,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof E)}return m&&(v=lt(v,b)),zt("private key",v,yt,b),v}function f(E){if(!(E instanceof l))throw new Error("ProjectivePoint expected")}let h=fn((E,p)=>{let{px:A,py:m,pz:b}=E;if(r.eql(b,r.ONE))return{x:A,y:m};let v=E.is0();p==null&&(p=v?r.ONE:r.inv(b));let x=r.mul(A,p),w=r.mul(m,p),B=r.mul(b,p);if(v)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x,y:w}}),u=fn(E=>{if(E.is0()){if(e.allowInfinityPoint&&!r.is0(E.py))return;throw new Error("bad point: ZERO")}let{x:p,y:A}=E.toAffine();if(!r.isValid(p)||!r.isValid(A))throw new Error("bad point: x or y not FE");let m=r.sqr(A),b=s(p);if(!r.eql(m,b))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(p,A,m){if(this.px=p,this.py=A,this.pz=m,p==null||!r.isValid(p))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(m==null||!r.isValid(m))throw new Error("z required");Object.freeze(this)}static fromAffine(p){let{x:A,y:m}=p||{};if(!p||!r.isValid(A)||!r.isValid(m))throw new Error("invalid affine point");if(p instanceof l)throw new Error("projective point not allowed");let b=v=>r.eql(v,r.ZERO);return b(A)&&b(m)?l.ZERO:new l(A,m,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){let A=r.invertBatch(p.map(m=>m.pz));return p.map((m,b)=>m.toAffine(A[b])).map(l.fromAffine)}static fromHex(p){let A=l.fromAffine(i(ut("pointHex",p)));return A.assertValidity(),A}static fromPrivateKey(p){return l.BASE.multiply(c(p))}static msm(p,A){return $s(l,n,p,A)}_setWindowSize(p){N.setWindowSize(this,p)}assertValidity(){u(this)}hasEvenY(){let{y:p}=this.toAffine();if(r.isOdd)return!r.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){f(p);let{px:A,py:m,pz:b}=this,{px:v,py:x,pz:w}=p,B=r.eql(r.mul(A,w),r.mul(v,b)),g=r.eql(r.mul(m,w),r.mul(x,b));return B&&g}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:p,b:A}=e,m=r.mul(A,Ms),{px:b,py:v,pz:x}=this,w=r.ZERO,B=r.ZERO,g=r.ZERO,d=r.mul(b,b),C=r.mul(v,v),k=r.mul(x,x),T=r.mul(b,v);return T=r.add(T,T),g=r.mul(b,x),g=r.add(g,g),w=r.mul(p,g),B=r.mul(m,k),B=r.add(w,B),w=r.sub(C,B),B=r.add(C,B),B=r.mul(w,B),w=r.mul(T,w),g=r.mul(m,g),k=r.mul(p,k),T=r.sub(d,k),T=r.mul(p,T),T=r.add(T,g),g=r.add(d,d),d=r.add(g,d),d=r.add(d,k),d=r.mul(d,T),B=r.add(B,d),k=r.mul(v,x),k=r.add(k,k),d=r.mul(k,T),w=r.sub(w,d),g=r.mul(k,C),g=r.add(g,g),g=r.add(g,g),new l(w,B,g)}add(p){f(p);let{px:A,py:m,pz:b}=this,{px:v,py:x,pz:w}=p,B=r.ZERO,g=r.ZERO,d=r.ZERO,C=e.a,k=r.mul(e.b,Ms),T=r.mul(A,v),D=r.mul(m,x),S=r.mul(b,w),I=r.add(A,m),L=r.add(v,x);I=r.mul(I,L),L=r.add(T,D),I=r.sub(I,L),L=r.add(A,b);let $=r.add(v,w);return L=r.mul(L,$),$=r.add(T,S),L=r.sub(L,$),$=r.add(m,b),B=r.add(x,w),$=r.mul($,B),B=r.add(D,S),$=r.sub($,B),d=r.mul(C,L),B=r.mul(k,S),d=r.add(B,d),B=r.sub(D,d),d=r.add(D,d),g=r.mul(B,d),D=r.add(T,T),D=r.add(D,T),S=r.mul(C,S),L=r.mul(k,L),D=r.add(D,S),S=r.sub(T,S),S=r.mul(C,S),L=r.add(L,S),T=r.mul(D,L),g=r.add(g,T),T=r.mul($,L),B=r.mul(I,B),B=r.sub(B,T),T=r.mul(I,D),d=r.mul($,d),d=r.add(d,T),new l(B,g,d)}subtract(p){return this.add(p.negate())}is0(){return this.equals(l.ZERO)}wNAF(p){return N.wNAFCached(this,p,l.normalizeZ)}multiplyUnsafe(p){let{endo:A,n:m}=e;zt("scalar",p,Xt,m);let b=l.ZERO;if(p===Xt)return b;if(this.is0()||p===yt)return this;if(!A||N.hasPrecomputes(this))return N.wNAFCachedUnsafe(this,p,l.normalizeZ);let{k1neg:v,k1:x,k2neg:w,k2:B}=A.splitScalar(p),g=b,d=b,C=this;for(;x>Xt||B>Xt;)x&yt&&(g=g.add(C)),B&yt&&(d=d.add(C)),C=C.double(),x>>=yt,B>>=yt;return v&&(g=g.negate()),w&&(d=d.negate()),d=new l(r.mul(d.px,A.beta),d.py,d.pz),g.add(d)}multiply(p){let{endo:A,n:m}=e;zt("scalar",p,yt,m);let b,v;if(A){let{k1neg:x,k1:w,k2neg:B,k2:g}=A.splitScalar(p),{p:d,f:C}=this.wNAF(w),{p:k,f:T}=this.wNAF(g);d=N.constTimeNegate(x,d),k=N.constTimeNegate(B,k),k=new l(r.mul(k.px,A.beta),k.py,k.pz),b=d.add(k),v=C.add(T)}else{let{p:x,f:w}=this.wNAF(p);b=x,v=w}return l.normalizeZ([b,v])[0]}multiplyAndAddUnsafe(p,A,m){let b=l.BASE,v=(w,B)=>B===Xt||B===yt||!w.equals(b)?w.multiplyUnsafe(B):w.multiply(B),x=v(this,A).add(v(p,m));return x.is0()?void 0:x}toAffine(p){return h(this,p)}isTorsionFree(){let{h:p,isTorsionFree:A}=e;if(p===yt)return!0;if(A)return A(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:p,clearCofactor:A}=e;return p===yt?this:A?A(l,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return Ce("isCompressed",p),this.assertValidity(),o(l,this,p)}toHex(p=!0){return Ce("isCompressed",p),_e(this.toRawBytes(p))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let y=e.nBitLength,N=Hs(l,e.endo?Math.ceil(y/2):y);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function $f(t){let e=Lo(t);return be(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ds(t){let e=$f(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return lt(S,n)}function a(S){return un(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:u}=Hf({...e,toBytes(S,I,L){let $=I.toAffine(),M=r.toBytes($.x),W=Ft;return Ce("isCompressed",L),L?W(Uint8Array.from([I.hasEvenY()?2:3]),M):W(Uint8Array.from([4]),M,r.toBytes($.y))},fromBytes(S){let I=S.length,L=S[0],$=S.subarray(1);if(I===o&&(L===2||L===3)){let M=Ht($);if(!ye(M,yt,r.ORDER))throw new Error("Point is not on curve");let W=h(M),j;try{j=r.sqrt(W)}catch(X){let F=X instanceof Error?": "+X.message:"";throw new Error("Point is not on curve"+F)}let Y=(j&yt)===yt;return(L&1)===1!==Y&&(j=r.neg(j)),{x:M,y:j}}else if(I===i&&L===4){let M=r.fromBytes($.subarray(0,r.BYTES)),W=r.fromBytes($.subarray(r.BYTES,2*r.BYTES));return{x:M,y:W}}else{let M=o,W=i;throw new Error("invalid Point, expected length of "+M+", or uncompressed "+W+", got "+I)}}}),l=S=>_e(Dt(S,e.nByteLength));function y(S){let I=n>>yt;return S>I}function N(S){return y(S)?s(-S):S}let E=(S,I,L)=>Ht(S.slice(I,L));class p{constructor(I,L,$){this.r=I,this.s=L,this.recovery=$,this.assertValidity()}static fromCompact(I){let L=e.nByteLength;return I=ut("compactSignature",I,L*2),new p(E(I,0,L),E(I,L,2*L))}static fromDER(I){let{r:L,s:$}=Qt.toSig(ut("DER",I));return new p(L,$)}assertValidity(){zt("r",this.r,yt,n),zt("s",this.s,yt,n)}addRecoveryBit(I){return new p(this.r,this.s,I)}recoverPublicKey(I){let{r:L,s:$,recovery:M}=this,W=w(ut("msgHash",I));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");let j=M===2||M===3?L+e.n:L;if(j>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let Y=M&1?"03":"02",it=c.fromHex(Y+l(j)),X=a(j),F=s(-W*X),P=s($*X),_=c.BASE.multiplyAndAddUnsafe(it,F,P);if(!_)throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Re(this.toDERHex())}toDERHex(){return Qt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Re(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}let A={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Ao(e.n);return Cs(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function m(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function b(S){let I=we(S),L=typeof S=="string",$=(I||L)&&S.length;return I?$===o||$===i:L?$===2*o||$===2*i:S instanceof c}function v(S,I,L=!0){if(b(S))throw new Error("first arg must be private key");if(!b(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(L)}let x=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let I=Ht(S),L=S.length*8-e.nBitLength;return L>0?I>>BigInt(L):I},w=e.bits2int_modN||function(S){return s(x(S))},B=mr(e.nBitLength);function g(S){return zt("num < 2^"+e.nBitLength,S,Xt,B),Dt(S,e.nByteLength)}function d(S,I,L=C){if(["recovered","canonical"].some(R=>R in L))throw new Error("sign() legacy options not supported");let{hash:$,randomBytes:M}=e,{lowS:W,prehash:j,extraEntropy:Y}=L;W==null&&(W=!0),S=ut("msgHash",S),Os(L),j&&(S=ut("prehashed msgHash",$(S)));let it=w(S),X=f(I),F=[g(X),g(it)];if(Y!=null&&Y!==!1){let R=Y===!0?M(r.BYTES):Y;F.push(ut("extraEntropy",R))}let P=Ft(...F),_=it;function U(R){let H=x(R);if(!u(H))return;let O=a(H),q=c.BASE.multiply(H).toAffine(),K=s(q.x);if(K===Xt)return;let G=s(O*s(_+K*X));if(G===Xt)return;let Z=(q.x===K?0:2)|Number(q.y&yt),V=G;return W&&y(G)&&(V=N(G),Z^=1),new p(K,V,Z)}return{seed:P,k2sig:U}}let C={lowS:e.lowS,prehash:!1},k={lowS:e.lowS,prehash:!1};function T(S,I,L=C){let{seed:$,k2sig:M}=d(S,I,L),W=e;return xo(W.hash.outputLen,W.nByteLength,W.hmac)($,M)}c.BASE._setWindowSize(8);function D(S,I,L,$=k){let M=S;I=ut("msgHash",I),L=ut("publicKey",L);let{lowS:W,prehash:j,format:Y}=$;if(Os($),"strict"in $)throw new Error("options.strict was renamed to lowS");if(Y!==void 0&&Y!=="compact"&&Y!=="der")throw new Error("format must be compact or der");let it=typeof M=="string"||we(M),X=!it&&!Y&&typeof M=="object"&&M!==null&&typeof M.r=="bigint"&&typeof M.s=="bigint";if(!it&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,P;try{if(X&&(F=new p(M.r,M.s)),it){try{Y!=="compact"&&(F=p.fromDER(M))}catch(Z){if(!(Z instanceof Qt.Err))throw Z}!F&&Y!=="der"&&(F=p.fromCompact(M))}P=c.fromHex(L)}catch{return!1}if(!F||W&&F.hasHighS())return!1;j&&(I=e.hash(I));let{r:_,s:U}=F,R=w(I),H=a(U),O=s(R*H),q=s(_*H),K=c.BASE.multiplyAndAddUnsafe(P,O,q)?.toAffine();return K?s(K.x)===_:!1}return{CURVE:e,getPublicKey:m,getSharedSecret:v,sign:T,verify:D,ProjectivePoint:c,Signature:p,utils:A}}function Of(t){return{hash:t,hmac:(e,...r)=>go(t,e,Bs(...r)),randomBytes:tn}}function Ks(t,e){let r=n=>Ds({...t,...Of(n)});return Object.freeze({...r(e),create:r})}var vr=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),hn=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xr=BigInt(1),pn=BigInt(2),qs=(t,e)=>(t+e/pn)/e;function Vs(t){let e=vr,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,h=f*f*t%e,u=Lt(h,r,e)*h%e,l=Lt(u,r,e)*h%e,y=Lt(l,pn,e)*f%e,N=Lt(y,o,e)*y%e,E=Lt(N,i,e)*N%e,p=Lt(E,a,e)*E%e,A=Lt(p,c,e)*p%e,m=Lt(A,a,e)*E%e,b=Lt(m,r,e)*h%e,v=Lt(b,s,e)*N%e,x=Lt(v,n,e)*f%e,w=Lt(x,pn,e);if(!Co.eql(Co.sqr(w),t))throw new Error("Cannot find square root");return w}var Co=ln(vr,void 0,void 0,{sqrt:Vs}),Jt=Ks({a:BigInt(0),b:BigInt(7),Fp:Co,n:hn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=hn,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=qs(i*t,e),c=qs(-n*t,e),f=lt(t-a*r-c*o,e),h=lt(-a*n-c*i,e),u=f>s,l=h>s;if(u&&(f=e-f),l&&(h=e-h),f>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:f,k2neg:l,k2:h}}}},rn),zs=BigInt(0),Ws={};function gn(t,...e){let r=Ws[t];if(r===void 0){let n=rn(Uint8Array.from(t,o=>o.charCodeAt(0)));r=Ft(n,n),Ws[t]=r}return rn(Ft(r,...e))}var Ro=t=>t.toRawBytes(!0).slice(1),_o=t=>Dt(t,32),No=t=>lt(t,vr),Er=t=>lt(t,hn),Ho=Jt.ProjectivePoint,Mf=(t,e,r)=>Ho.BASE.multiplyAndAddUnsafe(t,e,r);function Po(t){let e=Jt.utils.normPrivateKeyToScalar(t),r=Ho.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:Er(-e),bytes:Ro(r)}}function js(t){zt("x",t,xr,vr);let e=No(t*t),r=No(e*t+BigInt(7)),n=Vs(r);n%pn!==zs&&(n=No(-n));let o=new Ho(t,n,xr);return o.assertValidity(),o}var nr=Ht;function Ys(...t){return Er(nr(gn("BIP0340/challenge",...t)))}function Df(t){return Po(t).bytes}function Kf(t,e,r=tn(32)){let n=ut("message",t),{bytes:o,scalar:i}=Po(e),s=ut("auxRand",r,32),a=_o(i^nr(gn("BIP0340/aux",s))),c=gn("BIP0340/nonce",a,o,n),f=Er(nr(c));if(f===zs)throw new Error("sign failed: k is zero");let{bytes:h,scalar:u}=Po(f),l=Ys(h,o,n),y=new Uint8Array(64);if(y.set(h,0),y.set(_o(Er(u+l*i)),32),!Gs(y,n,o))throw new Error("sign: Invalid signature produced");return y}function Gs(t,e,r){let n=ut("signature",t,64),o=ut("message",e),i=ut("publicKey",r,32);try{let s=js(nr(i)),a=nr(n.subarray(0,32));if(!ye(a,xr,vr))return!1;let c=nr(n.subarray(32,64));if(!ye(c,xr,hn))return!1;let f=Ys(_o(a),Ro(s),o),h=Mf(s,c,Er(-f));return!(!h||!h.hasEvenY()||h.toAffine().x!==a)}catch{return!1}}var jt={getPublicKey:Df,sign:Kf,verify:Gs,utils:{randomPrivateKey:Jt.utils.randomPrivateKey,lift_x:js,pointToBytes:Ro,numberToBytesBE:Dt,bytesToNumberBE:Ht,taggedHash:gn,mod:lt}};var yn=Jt.ProjectivePoint,wn=Jt.CURVE.n,{isBytes:J,concatBytes:te,equalBytes:st}=Ji;var Br=t=>ms(kt(t)),ee=(...t)=>kt(kt(te(...t))),Od=jt.utils.randomPrivateKey,bn=jt.getPublicKey,$o=Jt.getPublicKey,Zs=t=>t.r<wn/2n;function Fs(t,e,r=!1){let n=Jt.sign(t,e);if(r&&!Zs(n)){let o=new Uint8Array(32),i=0;for(;!Zs(n);)if(o.set(Q.encode(i++)),n=Jt.sign(t,e,{extraEntropy:o}),i>4294967295)throw new Error("lowR counter overflow: report the error")}return n.toDERRawBytes()}var Oo=jt.sign,mn=jt.utils.taggedHash,xt;(function(t){t[t.ecdsa=0]="ecdsa",t[t.schnorr=1]="schnorr"})(xt||(xt={}));function me(t,e){let r=t.length;if(e===xt.ecdsa){if(r===32)throw new Error("Expected non-Schnorr key");return yn.fromHex(t),t}else if(e===xt.schnorr){if(r!==32)throw new Error("Expected 32-byte Schnorr key");return jt.utils.lift_x(jt.utils.bytesToNumberBE(t)),t}else throw new Error("Unknown key type")}function Qs(t,e){let r=jt.utils,n=r.taggedHash("TapTweak",t,e),o=r.bytesToNumberBE(n);if(o>=wn)throw new Error("tweak higher than curve order");return o}function Xs(t,e=new Uint8Array){let r=jt.utils,n=r.bytesToNumberBE(t),o=yn.fromPrivateKey(n),i=o.hasEvenY()?n:r.mod(-n,wn),s=r.pointToBytes(o),a=Qs(s,e);return r.numberToBytesBE(r.mod(i+a,wn),32)}function Mo(t,e){let r=jt.utils,n=Qs(t,e),i=r.lift_x(r.bytesToNumberBE(t)).add(yn.fromPrivateKey(n)),s=i.hasEvenY()?0:1;return[r.pointToBytes(i),s]}var Do=kt(yn.BASE.toRawBytes(!1)),re={bech32:"bc",pubKeyHash:0,scriptHash:5,wif:128},Ko={bech32:"tb",pubKeyHash:111,scriptHash:196,wif:239};function Sr(t,e){if(!J(t)||!J(e))throw new Error(`cmp: wrong type a=${typeof t} b=${typeof e}`);let r=Math.min(t.length,e.length);for(let n=0;n<r;n++)if(t[n]!=e[n])return Math.sign(t[n]-e[n]);return Math.sign(t.length-e.length)}function kr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function na(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(r=>typeof r=="string"):e.every(r=>Number.isSafeInteger(r)):!1}function Vo(t){if(typeof t!="function")throw new Error("function expected");return!0}function or(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function ir(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function En(t){if(!Array.isArray(t))throw new Error("array expected")}function vn(t,e){if(!na(!0,e))throw new Error(`${t}: array of strings expected`)}function zo(t,e){if(!na(!1,e))throw new Error(`${t}: array of numbers expected`)}function Tr(...t){let e=i=>i,r=(i,s)=>a=>i(s(a)),n=t.map(i=>i.encode).reduceRight(r,e),o=t.map(i=>i.decode).reduce(r,e);return{encode:n,decode:o}}function An(t){let e=typeof t=="string"?t.split(""):t,r=e.length;vn("alphabet",e);let n=new Map(e.map((o,i)=>[o,i]));return{encode:o=>(En(o),o.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${t}`);return e[i]})),decode:o=>(En(o),o.map(i=>{or("alphabet.decode",i);let s=n.get(i);if(s===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${t}`);return s}))}}function kn(t=""){return or("join",t),{encode:e=>(vn("join.decode",e),e.join(t)),decode:e=>(or("join.decode",e),e.split(t))}}function qf(t,e="="){return ir(t),or("padding",e),{encode(r){for(vn("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){vn("padding.decode",r);let n=r.length;if(n*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if((n-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,n)}}}function Wf(t){return Vo(t),{encode:e=>e,decode:e=>t(e)}}function qo(t,e,r){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(En(t),!t.length)return[];let n=0,o=[],i=Array.from(t,a=>{if(ir(a),a<0||a>=e)throw new Error(`invalid integer: ${a}`);return a}),s=i.length;for(;;){let a=0,c=!0;for(let f=n;f<s;f++){let h=i[f],u=e*a,l=u+h;if(!Number.isSafeInteger(l)||u/e!==a||l-h!==u)throw new Error("convertRadix: carry overflow");let y=l/r;a=l%r;let N=Math.floor(y);if(i[f]=N,!Number.isSafeInteger(N)||N*r+a!==l)throw new Error("convertRadix: carry overflow");if(c)N?c=!1:n=f;else continue}if(o.push(a),c)break}for(let a=0;a<t.length-1&&t[a]===0;a++)o.push(0);return o.reverse()}var oa=(t,e)=>e===0?t:oa(e,t%e),Bn=(t,e)=>t+(e-oa(t,e)),xn=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Sn(t,e,r,n){if(En(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Bn(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${Bn(e,r)}`);let o=0,i=0,s=xn[e],a=xn[r]-1,c=[];for(let f of t){if(ir(f),f>=s)throw new Error(`convertRadix2: invalid data word=${f} from=${e}`);if(o=o<<e|f,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=r;i-=r)c.push((o>>i-r&a)>>>0);let h=xn[i];if(h===void 0)throw new Error("invalid carry");o&=h-1}if(o=o<<r-i&a,!n&&i>=e)throw new Error("Excess padding");if(!n&&o>0)throw new Error(`Non-zero padding: ${o}`);return n&&i>0&&c.push(o>>>0),c}function ia(t){ir(t);let e=2**8;return{encode:r=>{if(!kr(r))throw new Error("radix.encode input should be Uint8Array");return qo(Array.from(r),e,t)},decode:r=>(zo("radix.decode",r),Uint8Array.from(qo(r,t,e)))}}function jo(t,e=!1){if(ir(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Bn(8,t)>32||Bn(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!kr(r))throw new Error("radix2.encode input should be Uint8Array");return Sn(Array.from(r),8,t,!e)},decode:r=>(zo("radix2.decode",r),Uint8Array.from(Sn(r,t,8,e)))}}function ta(t){return Vo(t),function(...e){try{return t.apply(null,e)}catch{}}}function sa(t,e){return ir(t),Vo(e),{encode(r){if(!kr(r))throw new Error("checksum.encode: input should be Uint8Array");let n=e(r).slice(0,t),o=new Uint8Array(r.length+t);return o.set(r),o.set(n,r.length),o},decode(r){if(!kr(r))throw new Error("checksum.decode: input should be Uint8Array");let n=r.slice(0,-t),o=r.slice(-t),i=e(n).slice(0,t);for(let s=0;s<t;s++)if(i[s]!==o[s])throw new Error("Invalid checksum");return n}}}var Ir={alphabet:An,chain:Tr,checksum:sa,convertRadix:qo,convertRadix2:Sn,radix:ia,radix2:jo,join:kn,padding:qf};var Vf=t=>Tr(ia(58),An(t),kn("")),zf=Vf("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var Tn=t=>Tr(sa(4,e=>t(t(e))),zf);var Wo=Tr(An("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),kn("")),ea=[996825010,642813549,513874426,1027748829,705979059];function Ar(t){let e=t>>25,r=(t&33554431)<<5;for(let n=0;n<ea.length;n++)(e>>n&1)===1&&(r^=ea[n]);return r}function ra(t,e,r=1){let n=t.length,o=1;for(let i=0;i<n;i++){let s=t.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);o=Ar(o)^s>>5}o=Ar(o);for(let i=0;i<n;i++)o=Ar(o)^t.charCodeAt(i)&31;for(let i of e)o=Ar(o)^i;for(let i=0;i<6;i++)o=Ar(o);return o^=r,Wo.encode(Sn([o%xn[30]],30,5,!1))}function aa(t){let e=t==="bech32"?1:734539939,r=jo(5),n=r.decode,o=r.encode,i=ta(n);function s(u,l,y=90){or("bech32.encode prefix",u),kr(l)&&(l=Array.from(l)),zo("bech32.encode",l);let N=u.length;if(N===0)throw new TypeError(`Invalid prefix length ${N}`);let E=N+7+l.length;if(y!==!1&&E>y)throw new TypeError(`Length ${E} exceeds limit ${y}`);let p=u.toLowerCase(),A=ra(p,l,e);return`${p}1${Wo.encode(l)}${A}`}function a(u,l=90){or("bech32.decode input",u);let y=u.length;if(y<8||l!==!1&&y>l)throw new TypeError(`invalid string length: ${y} (${u}). Expected (8..${l})`);let N=u.toLowerCase();if(u!==N&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");let E=N.lastIndexOf("1");if(E===0||E===-1)throw new Error('Letter "1" must be present between prefix and data only');let p=N.slice(0,E),A=N.slice(E+1);if(A.length<6)throw new Error("Data must be at least 6 characters long");let m=Wo.decode(A).slice(0,-6),b=ra(p,m,e);if(!A.endsWith(b))throw new Error(`Invalid checksum in ${u}: expected "${b}"`);return{prefix:p,words:m}}let c=ta(a);function f(u){let{prefix:l,words:y}=a(u,!1);return{prefix:l,words:y,bytes:n(y)}}function h(u,l){return s(u,o(l))}return{encode:s,decode:a,encodeFromBytes:h,decodeToBytes:f,decodeUnsafe:c,fromWords:n,fromWordsUnsafe:i,toWords:o}}var In=aa("bech32"),Yo=aa("bech32m");var at=Tr(jo(4),An("0123456789abcdef"),kn(""),Wf(t=>{if(typeof t!="string"||t.length%2!==0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));var ht;(function(t){t[t.OP_0=0]="OP_0",t[t.PUSHDATA1=76]="PUSHDATA1",t[t.PUSHDATA2=77]="PUSHDATA2",t[t.PUSHDATA4=78]="PUSHDATA4",t[t["1NEGATE"]=79]="1NEGATE",t[t.RESERVED=80]="RESERVED",t[t.OP_1=81]="OP_1",t[t.OP_2=82]="OP_2",t[t.OP_3=83]="OP_3",t[t.OP_4=84]="OP_4",t[t.OP_5=85]="OP_5",t[t.OP_6=86]="OP_6",t[t.OP_7=87]="OP_7",t[t.OP_8=88]="OP_8",t[t.OP_9=89]="OP_9",t[t.OP_10=90]="OP_10",t[t.OP_11=91]="OP_11",t[t.OP_12=92]="OP_12",t[t.OP_13=93]="OP_13",t[t.OP_14=94]="OP_14",t[t.OP_15=95]="OP_15",t[t.OP_16=96]="OP_16",t[t.NOP=97]="NOP",t[t.VER=98]="VER",t[t.IF=99]="IF",t[t.NOTIF=100]="NOTIF",t[t.VERIF=101]="VERIF",t[t.VERNOTIF=102]="VERNOTIF",t[t.ELSE=103]="ELSE",t[t.ENDIF=104]="ENDIF",t[t.VERIFY=105]="VERIFY",t[t.RETURN=106]="RETURN",t[t.TOALTSTACK=107]="TOALTSTACK",t[t.FROMALTSTACK=108]="FROMALTSTACK",t[t["2DROP"]=109]="2DROP",t[t["2DUP"]=110]="2DUP",t[t["3DUP"]=111]="3DUP",t[t["2OVER"]=112]="2OVER",t[t["2ROT"]=113]="2ROT",t[t["2SWAP"]=114]="2SWAP",t[t.IFDUP=115]="IFDUP",t[t.DEPTH=116]="DEPTH",t[t.DROP=117]="DROP",t[t.DUP=118]="DUP",t[t.NIP=119]="NIP",t[t.OVER=120]="OVER",t[t.PICK=121]="PICK",t[t.ROLL=122]="ROLL",t[t.ROT=123]="ROT",t[t.SWAP=124]="SWAP",t[t.TUCK=125]="TUCK",t[t.CAT=126]="CAT",t[t.SUBSTR=127]="SUBSTR",t[t.LEFT=128]="LEFT",t[t.RIGHT=129]="RIGHT",t[t.SIZE=130]="SIZE",t[t.INVERT=131]="INVERT",t[t.AND=132]="AND",t[t.OR=133]="OR",t[t.XOR=134]="XOR",t[t.EQUAL=135]="EQUAL",t[t.EQUALVERIFY=136]="EQUALVERIFY",t[t.RESERVED1=137]="RESERVED1",t[t.RESERVED2=138]="RESERVED2",t[t["1ADD"]=139]="1ADD",t[t["1SUB"]=140]="1SUB",t[t["2MUL"]=141]="2MUL",t[t["2DIV"]=142]="2DIV",t[t.NEGATE=143]="NEGATE",t[t.ABS=144]="ABS",t[t.NOT=145]="NOT",t[t["0NOTEQUAL"]=146]="0NOTEQUAL",t[t.ADD=147]="ADD",t[t.SUB=148]="SUB",t[t.MUL=149]="MUL",t[t.DIV=150]="DIV",t[t.MOD=151]="MOD",t[t.LSHIFT=152]="LSHIFT",t[t.RSHIFT=153]="RSHIFT",t[t.BOOLAND=154]="BOOLAND",t[t.BOOLOR=155]="BOOLOR",t[t.NUMEQUAL=156]="NUMEQUAL",t[t.NUMEQUALVERIFY=157]="NUMEQUALVERIFY",t[t.NUMNOTEQUAL=158]="NUMNOTEQUAL",t[t.LESSTHAN=159]="LESSTHAN",t[t.GREATERTHAN=160]="GREATERTHAN",t[t.LESSTHANOREQUAL=161]="LESSTHANOREQUAL",t[t.GREATERTHANOREQUAL=162]="GREATERTHANOREQUAL",t[t.MIN=163]="MIN",t[t.MAX=164]="MAX",t[t.WITHIN=165]="WITHIN",t[t.RIPEMD160=166]="RIPEMD160",t[t.SHA1=167]="SHA1",t[t.SHA256=168]="SHA256",t[t.HASH160=169]="HASH160",t[t.HASH256=170]="HASH256",t[t.CODESEPARATOR=171]="CODESEPARATOR",t[t.CHECKSIG=172]="CHECKSIG",t[t.CHECKSIGVERIFY=173]="CHECKSIGVERIFY",t[t.CHECKMULTISIG=174]="CHECKMULTISIG",t[t.CHECKMULTISIGVERIFY=175]="CHECKMULTISIGVERIFY",t[t.NOP1=176]="NOP1",t[t.CHECKLOCKTIMEVERIFY=177]="CHECKLOCKTIMEVERIFY",t[t.CHECKSEQUENCEVERIFY=178]="CHECKSEQUENCEVERIFY",t[t.NOP4=179]="NOP4",t[t.NOP5=180]="NOP5",t[t.NOP6=181]="NOP6",t[t.NOP7=182]="NOP7",t[t.NOP8=183]="NOP8",t[t.NOP9=184]="NOP9",t[t.NOP10=185]="NOP10",t[t.CHECKSIGADD=186]="CHECKSIGADD",t[t.INVALID=255]="INVALID"})(ht||(ht={}));function fa(t=6,e=!1){return Bt({encodeStream:(r,n)=>{if(n===0n)return;let o=n<0,i=BigInt(n),s=[];for(let a=o?-i:i;a;a>>=8n)s.push(Number(a&0xffn));s[s.length-1]>=128?s.push(o?128:0):o&&(s[s.length-1]|=128),r.bytes(new Uint8Array(s))},decodeStream:r=>{let n=r.leftBytes;if(n>t)throw new Error(`ScriptNum: number (${n}) bigger than limit=${t}`);if(n===0)return 0n;if(e){let s=r.bytes(n,!0);if(!(s[s.length-1]&127)&&(n<=1||!(s[s.length-2]&128)))throw new Error("Non-minimally encoded ScriptNum")}let o=0,i=0n;for(let s=0;s<n;++s)o=r.byte(),i|=BigInt(o)<<8n*BigInt(s);return o>=128&&(i&=2n**BigInt(n*8)-1n>>1n,i=-i),i}})}function ua(t,e=4,r=!0){if(typeof t=="number")return t;if(J(t))try{let n=fa(e,r).decode(t);return n>Number.MAX_SAFE_INTEGER?void 0:Number(n)}catch{return}}var ct=Bt({encodeStream:(t,e)=>{for(let r of e){if(typeof r=="string"){if(ht[r]===void 0)throw new Error(`Unknown opcode=${r}`);t.byte(ht[r]);continue}else if(typeof r=="number"){if(r===0){t.byte(0);continue}else if(1<=r&&r<=16){t.byte(ht.OP_1-1+r);continue}}if(typeof r=="number"&&(r=fa().encode(BigInt(r))),!J(r))throw new Error(`Wrong Script OP=${r} (${typeof r})`);let n=r.length;n<ht.PUSHDATA1?t.byte(n):n<=255?(t.byte(ht.PUSHDATA1),t.byte(n)):n<=65535?(t.byte(ht.PUSHDATA2),t.bytes(io.encode(n))):(t.byte(ht.PUSHDATA4),t.bytes(Q.encode(n))),t.bytes(r)}},decodeStream:t=>{let e=[];for(;!t.isEnd();){let r=t.byte();if(ht.OP_0<r&&r<=ht.PUSHDATA4){let n;if(r<ht.PUSHDATA1)n=r;else if(r===ht.PUSHDATA1)n=$t.decodeStream(t);else if(r===ht.PUSHDATA2)n=io.decodeStream(t);else if(r===ht.PUSHDATA4)n=Q.decodeStream(t);else throw new Error("Should be not possible");e.push(t.bytes(n))}else if(r===0)e.push(0);else if(ht.OP_1<=r&&r<=ht.OP_16)e.push(r-(ht.OP_1-1));else{let n=ht[r];if(n===void 0)throw new Error(`Unknown opcode=${r.toString(16)}`);e.push(n)}}return e}}),ca={253:[253,2,253n,65535n],254:[254,4,65536n,4294967295n],255:[255,8,4294967296n,18446744073709551615n]},Ur=Bt({encodeStream:(t,e)=>{if(typeof e=="number"&&(e=BigInt(e)),0n<=e&&e<=252n)return t.byte(Number(e));for(let[r,n,o,i]of Object.values(ca))if(!(o>e||e>i)){t.byte(r);for(let s=0;s<n;s++)t.byte(Number(e>>8n*BigInt(s)&0xffn));return}throw t.err(`VarInt too big: ${e}`)},decodeStream:t=>{let e=t.byte();if(e<=252)return BigInt(e);let[r,n,o]=ca[e],i=0n;for(let s=0;s<n;s++)i|=BigInt(t.byte())<<8n*BigInt(s);if(i<o)throw t.err(`Wrong CompactSize(${8*n})`);return i}}),It=Vt(Ur,ue.numberBigint),Tt=et(Ur),sr=St(It,Tt),Un=t=>St(Ur,t),la=ft({txid:et(32,!0),index:Q,finalScriptSig:Tt,sequence:Q}),ne=ft({amount:Qe,script:Tt}),jf=ft({version:le,segwitFlag:fs(new Uint8Array([0,1])),inputs:Un(la),outputs:Un(ne),witnesses:us("segwitFlag",St("inputs/length",sr)),lockTime:Q});function Yf(t){if(t.segwitFlag&&t.witnesses&&!t.witnesses.length)throw new Error("Segwit flag with empty witnesses array");return t}var oe=vt(jf,Yf),$e=ft({version:le,inputs:Un(la),outputs:Un(ne),lockTime:Q});function Lr(t){if(t.nonWitnessUtxo){if(t.index===void 0)throw new Error("Unknown input index");return t.nonWitnessUtxo.outputs[t.index]}else{if(t.witnessUtxo)return t.witnessUtxo;throw new Error("Cannot find previous output info")}}function Go(t,e,r,n=!1){let{nonWitnessUtxo:o,txid:i}=t;typeof o=="string"&&(o=at.decode(o)),J(o)&&(o=oe.decode(o)),!("nonWitnessUtxo"in t)&&o===void 0&&(o=e?.nonWitnessUtxo),typeof i=="string"&&(i=at.decode(i)),i===void 0&&(i=e?.txid);let s={...e,...t,nonWitnessUtxo:o,txid:i};!("nonWitnessUtxo"in t)&&s.nonWitnessUtxo===void 0&&delete s.nonWitnessUtxo,s.sequence===void 0&&(s.sequence=Fo),s.tapMerkleRoot===null&&delete s.tapMerkleRoot,s=Nr(cr,s,e,r),Ln.encode(s);let a;return s.nonWitnessUtxo&&s.index!==void 0?a=s.nonWitnessUtxo.outputs[s.index]:s.witnessUtxo&&(a=s.witnessUtxo),a&&!n&&Nn(a&&a.script,s.redeemScript,s.witnessScript),s}function Zo(t,e=!1){let r="legacy",n=tt.ALL,o=Lr(t),i=Et.decode(o.script),s=i.type,a=i,c=[i];if(i.type==="tr")return n=tt.DEFAULT,{txType:"taproot",type:"tr",last:i,lastScript:o.script,defaultSighash:n,sighash:t.sighashType||n};{if((i.type==="wpkh"||i.type==="wsh")&&(r="segwit"),i.type==="sh"){if(!t.redeemScript)throw new Error("inputType: sh without redeemScript");let l=Et.decode(t.redeemScript);(l.type==="wpkh"||l.type==="wsh")&&(r="segwit"),c.push(l),a=l,s+=`-${l.type}`}if(a.type==="wsh"){if(!t.witnessScript)throw new Error("inputType: wsh without witnessScript");let l=Et.decode(t.witnessScript);l.type==="wsh"&&(r="segwit"),c.push(l),a=l,s+=`-${l.type}`}let f=c[c.length-1];if(f.type==="sh"||f.type==="wsh")throw new Error("inputType: sh/wsh cannot be terminal type");let h=Et.encode(f),u={type:s,txType:r,last:f,lastScript:h,defaultSighash:n,sighash:t.sighashType||n};if(r==="legacy"&&!e&&!t.nonWitnessUtxo)throw new Error("Transaction/sign: legacy input without nonWitnessUtxo, can result in attack that forces paying higher fees. Pass allowLegacyWitnessUtxo=true, if you sure");return u}}var da=t=>Math.ceil(t/4);var Cn=new Uint8Array(32),Gf={amount:0xffffffffffffffffn,script:rt},Zf=8,Ff=2,Me=0,Fo=4294967295,th=ue.decimal(Zf),_r=(t,e)=>t===void 0?e:t;function _n(t){if(Array.isArray(t))return t.map(e=>_n(e));if(J(t))return Uint8Array.from(t);if(["number","bigint","boolean","string","undefined"].includes(typeof t))return t;if(t===null)return t;if(typeof t=="object")return Object.fromEntries(Object.entries(t).map(([e,r])=>[e,_n(r)]));throw new Error(`cloneDeep: unknown type=${t} (${typeof t})`)}var tt;(function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ALL=1]="ALL",t[t.NONE=2]="NONE",t[t.SINGLE=3]="SINGLE",t[t.ANYONECANPAY=128]="ANYONECANPAY"})(tt||(tt={}));var Jo;(function(t){t[t.DEFAULT=0]="DEFAULT",t[t.ALL=1]="ALL",t[t.NONE=2]="NONE",t[t.SINGLE=3]="SINGLE",t[t.DEFAULT_ANYONECANPAY=128]="DEFAULT_ANYONECANPAY",t[t.ALL_ANYONECANPAY=129]="ALL_ANYONECANPAY",t[t.NONE_ANYONECANPAY=130]="NONE_ANYONECANPAY",t[t.SINGLE_ANYONECANPAY=131]="SINGLE_ANYONECANPAY"})(Jo||(Jo={}));function Qf(t,e,r,n=rt){return st(r,e)&&(t=Xs(t,n),e=bn(t)),{privKey:t,pubKey:e}}function De(t){if(t.script===void 0||t.amount===void 0)throw new Error("Transaction/output: script and amount required");return{script:t.script,amount:t.amount}}function ar(t){if(t.txid===void 0||t.index===void 0)throw new Error("Transaction/input: txid and index required");return{txid:t.txid,index:t.index,sequence:_r(t.sequence,Fo),finalScriptSig:_r(t.finalScriptSig,rt)}}function Qo(t){for(let e in t){let r=e;ga.includes(r)||delete t[r]}}var Xo=ft({txid:et(32,!0),index:Q});function Xf(t){if(typeof t!="number"||typeof Jo[t]!="string")throw new Error(`Invalid SigHash=${t}`);return t}function pa(t){let e=t&31;return{isAny:!!(t&tt.ANYONECANPAY),isNone:e===tt.NONE,isSingle:e===tt.SINGLE}}function Jf(t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error(`Wrong object type for transaction options: ${t}`);let e={...t,version:_r(t.version,Ff),lockTime:_r(t.lockTime,0),PSBTVersion:_r(t.PSBTVersion,0)};if(typeof e.allowUnknowInput<"u"&&(t.allowUnknownInputs=e.allowUnknowInput),typeof e.allowUnknowOutput<"u"&&(t.allowUnknownOutputs=e.allowUnknowOutput),![-1,0,1,2].includes(e.version))throw new Error(`Unknown version: ${e.version}`);if(typeof e.lockTime!="number")throw new Error("Transaction lock time should be number");if(Q.encode(e.lockTime),e.PSBTVersion!==0&&e.PSBTVersion!==2)throw new Error(`Unknown PSBT version ${e.PSBTVersion}`);for(let r of["allowUnknownOutputs","allowUnknownInputs","disableScriptCheck","bip174jsCompat","allowLegacyWitnessUtxo","lowR"]){let n=e[r];if(n!==void 0&&typeof n!="boolean")throw new Error(`Transation options wrong type: ${r}=${n} (${typeof n})`)}if(e.customScripts!==void 0){let r=e.customScripts;if(!Array.isArray(r))throw new Error(`wrong custom scripts type (expected array): customScripts=${r} (${typeof r})`);for(let n of r){if(typeof n.encode!="function"||typeof n.decode!="function")throw new Error(`wrong script=${n} (${typeof n})`);if(n.finalizeTaproot!==void 0&&typeof n.finalizeTaproot!="function")throw new Error(`wrong script=${n} (${typeof n})`)}}return Object.freeze(e)}var xe=class t{constructor(e={}){this.global={},this.inputs=[],this.outputs=[];let r=this.opts=Jf(e);r.lockTime!==Me&&(this.global.fallbackLocktime=r.lockTime),this.global.txVersion=r.version}static fromRaw(e,r={}){let n=oe.decode(e),o=new t({...r,version:n.version,lockTime:n.lockTime});for(let i of n.outputs)o.addOutput(i);if(o.outputs=n.outputs,o.inputs=n.inputs,n.witnesses)for(let i=0;i<n.witnesses.length;i++)o.inputs[i].finalScriptWitness=n.witnesses[i];return o}static fromPSBT(e,r={}){let n;try{n=ei.decode(e)}catch(u){try{n=ri.decode(e)}catch{throw u}}let o=n.global.version||0;if(o!==0&&o!==2)throw new Error(`Wrong PSBT version=${o}`);let i=n.global.unsignedTx,s=o===0?i?.version:n.global.txVersion,a=o===0?i?.lockTime:n.global.fallbackLocktime,c=new t({...r,version:s,lockTime:a,PSBTVersion:o}),f=o===0?i?.inputs.length:n.global.inputCount;c.inputs=n.inputs.slice(0,f).map((u,l)=>({finalScriptSig:rt,...n.global.unsignedTx?.inputs[l],...u}));let h=o===0?i?.outputs.length:n.global.outputCount;return c.outputs=n.outputs.slice(0,h).map((u,l)=>({...u,...n.global.unsignedTx?.outputs[l]})),c.global={...n.global,txVersion:s},a!==Me&&(c.global.fallbackLocktime=a),c}toPSBT(e=this.opts.PSBTVersion){if(e!==0&&e!==2)throw new Error(`Wrong PSBT version=${e}`);let r=this.inputs.map(i=>ti(e,cr,i));for(let i of r)i.partialSig&&!i.partialSig.length&&delete i.partialSig,i.finalScriptSig&&!i.finalScriptSig.length&&delete i.finalScriptSig,i.finalScriptWitness&&!i.finalScriptWitness.length&&delete i.finalScriptWitness;let n=this.outputs.map(i=>ti(e,Pr,i)),o={...this.global};return e===0?(o.unsignedTx=$e.decode($e.encode({version:this.version,lockTime:this.lockTime,inputs:this.inputs.map(ar).map(i=>({...i,finalScriptSig:rt})),outputs:this.outputs.map(De)})),delete o.fallbackLocktime,delete o.txVersion):(o.version=e,o.txVersion=this.version,o.inputCount=this.inputs.length,o.outputCount=this.outputs.length,o.fallbackLocktime&&o.fallbackLocktime===Me&&delete o.fallbackLocktime),this.opts.bip174jsCompat&&(r.length||r.push({}),n.length||n.push({})),(e===0?ei:ri).encode({global:o,inputs:r,outputs:n})}get lockTime(){let e=Me,r=0,n=Me,o=0;for(let i of this.inputs)i.requiredHeightLocktime&&(e=Math.max(e,i.requiredHeightLocktime),r++),i.requiredTimeLocktime&&(n=Math.max(n,i.requiredTimeLocktime),o++);return r&&r>=o?e:n!==Me?n:this.global.fallbackLocktime||Me}get version(){if(this.global.txVersion===void 0)throw new Error("No global.txVersion");return this.global.txVersion}inputStatus(e){this.checkInputIdx(e);let r=this.inputs[e];return r.finalScriptSig&&r.finalScriptSig.length||r.finalScriptWitness&&r.finalScriptWitness.length?"finalized":r.tapKeySig||r.tapScriptSig&&r.tapScriptSig.length||r.partialSig&&r.partialSig.length?"signed":"unsigned"}inputSighash(e){this.checkInputIdx(e);let r=this.inputs[e].sighashType,n=r===void 0?tt.DEFAULT:r,o=n===tt.DEFAULT?tt.ALL:n&3;return{sigInputs:n&tt.ANYONECANPAY,sigOutputs:o}}signStatus(){let e=!0,r=!0,n=[],o=[];for(let i=0;i<this.inputs.length;i++){if(this.inputStatus(i)==="unsigned")continue;let{sigInputs:a,sigOutputs:c}=this.inputSighash(i);if(a===tt.ANYONECANPAY?n.push(i):e=!1,c===tt.ALL)r=!1;else if(c===tt.SINGLE)o.push(i);else if(c!==tt.NONE)throw new Error(`Wrong signature hash output type: ${c}`)}return{addInput:e,addOutput:r,inputs:n,outputs:o}}get isFinal(){for(let e=0;e<this.inputs.length;e++)if(this.inputStatus(e)!=="finalized")return!1;return!0}get hasWitnesses(){let e=!1;for(let r of this.inputs)r.finalScriptWitness&&r.finalScriptWitness.length&&(e=!0);return e}get weight(){if(!this.isFinal)throw new Error("Transaction is not finalized");let e=32,r=this.outputs.map(De);e+=4*It.encode(this.outputs.length).length;for(let n of r)e+=32+4*Tt.encode(n.script).length;this.hasWitnesses&&(e+=2),e+=4*It.encode(this.inputs.length).length;for(let n of this.inputs)e+=160+4*Tt.encode(n.finalScriptSig||rt).length,this.hasWitnesses&&n.finalScriptWitness&&(e+=sr.encode(n.finalScriptWitness).length);return e}get vsize(){return da(this.weight)}toBytes(e=!1,r=!1){return oe.encode({version:this.version,lockTime:this.lockTime,inputs:this.inputs.map(ar).map(n=>({...n,finalScriptSig:e&&n.finalScriptSig||rt})),outputs:this.outputs.map(De),witnesses:this.inputs.map(n=>n.finalScriptWitness||[]),segwitFlag:r&&this.hasWitnesses})}get unsignedTx(){return this.toBytes(!1,!1)}get hex(){return at.encode(this.toBytes(!0,this.hasWitnesses))}get hash(){if(!this.isFinal)throw new Error("Transaction is not finalized");return at.encode(ee(this.toBytes(!0)))}get id(){if(!this.isFinal)throw new Error("Transaction is not finalized");return at.encode(ee(this.toBytes(!0)).reverse())}checkInputIdx(e){if(!Number.isSafeInteger(e)||0>e||e>=this.inputs.length)throw new Error(`Wrong input index=${e}`)}getInput(e){return this.checkInputIdx(e),_n(this.inputs[e])}get inputsLength(){return this.inputs.length}addInput(e,r=!1){if(!r&&!this.signStatus().addInput)throw new Error("Tx has signed inputs, cannot add new one");return this.inputs.push(Go(e,void 0,void 0,this.opts.disableScriptCheck)),this.inputs.length-1}updateInput(e,r,n=!1){this.checkInputIdx(e);let o;if(!n){let i=this.signStatus();(!i.addInput||i.inputs.includes(e))&&(o=wa)}this.inputs[e]=Go(r,this.inputs[e],o,this.opts.disableScriptCheck)}checkOutputIdx(e){if(!Number.isSafeInteger(e)||0>e||e>=this.outputs.length)throw new Error(`Wrong output index=${e}`)}getOutput(e){return this.checkOutputIdx(e),_n(this.outputs[e])}getOutputAddress(e,r=re){let n=this.getOutput(e);if(n.script)return Ee(r).encode(Et.decode(n.script))}get outputsLength(){return this.outputs.length}normalizeOutput(e,r,n){let{amount:o,script:i}=e;if(o===void 0&&(o=r?.amount),typeof o!="bigint")throw new Error(`Wrong amount type, should be of type bigint in sats, but got ${o} of type ${typeof o}`);typeof i=="string"&&(i=at.decode(i)),i===void 0&&(i=r?.script);let s={...r,...e,amount:o,script:i};if(s.amount===void 0&&delete s.amount,s=Nr(Pr,s,r,n),Rn.encode(s),s.script&&!this.opts.allowUnknownOutputs&&Et.decode(s.script).type==="unknown")throw new Error("Transaction/output: unknown output script type, there is a chance that input is unspendable. Pass allowUnknownOutputs=true, if you sure");return this.opts.disableScriptCheck||Nn(s.script,s.redeemScript,s.witnessScript),s}addOutput(e,r=!1){if(!r&&!this.signStatus().addOutput)throw new Error("Tx has signed outputs, cannot add new one");return this.outputs.push(this.normalizeOutput(e)),this.outputs.length-1}updateOutput(e,r,n=!1){this.checkOutputIdx(e);let o;if(!n){let i=this.signStatus();(!i.addOutput||i.outputs.includes(e))&&(o=ya)}this.outputs[e]=this.normalizeOutput(r,this.outputs[e],o)}addOutputAddress(e,r,n=re){return this.addOutput({script:Et.encode(Ee(n).decode(e)),amount:r})}get fee(){let e=0n;for(let n of this.inputs){let o=Lr(n);if(!o)throw new Error("Empty input amount");e+=o.amount}let r=this.outputs.map(De);for(let n of r)e-=n.amount;return e}preimageLegacy(e,r,n){let{isAny:o,isNone:i,isSingle:s}=pa(n);if(e<0||!Number.isSafeInteger(e))throw new Error(`Invalid input idx=${e}`);if(s&&e>=this.outputs.length||e>=this.inputs.length)return os.encode(1n);r=ct.encode(ct.decode(r).filter(h=>h!=="CODESEPARATOR"));let a=this.inputs.map(ar).map((h,u)=>({...h,finalScriptSig:u===e?r:rt}));o?a=[a[e]]:(i||s)&&(a=a.map((h,u)=>({...h,sequence:u===e?h.sequence:0})));let c=this.outputs.map(De);i?c=[]:s&&(c=c.slice(0,e).fill(Gf).concat([c[e]]));let f=oe.encode({lockTime:this.lockTime,version:this.version,segwitFlag:!1,inputs:a,outputs:c});return ee(f,le.encode(n))}preimageWitnessV0(e,r,n,o){let{isAny:i,isNone:s,isSingle:a}=pa(n),c=Cn,f=Cn,h=Cn,u=this.inputs.map(ar),l=this.outputs.map(De);i||(c=ee(...u.map(Xo.encode))),!i&&!a&&!s&&(f=ee(...u.map(N=>Q.encode(N.sequence)))),!a&&!s?h=ee(...l.map(ne.encode)):a&&e<l.length&&(h=ee(ne.encode(l[e])));let y=u[e];return ee(le.encode(this.version),c,f,et(32,!0).encode(y.txid),Q.encode(y.index),Tt.encode(r),Qe.encode(o),Q.encode(y.sequence),h,Q.encode(this.lockTime),Q.encode(n))}preimageWitnessV1(e,r,n,o,i=-1,s,a=192,c){if(!Array.isArray(o)||this.inputs.length!==o.length)throw new Error(`Invalid amounts array=${o}`);if(!Array.isArray(r)||this.inputs.length!==r.length)throw new Error(`Invalid prevOutScript array=${r}`);let f=[$t.encode(0),$t.encode(n),le.encode(this.version),Q.encode(this.lockTime)],h=n===tt.DEFAULT?tt.ALL:n&3,u=n&tt.ANYONECANPAY,l=this.inputs.map(ar),y=this.outputs.map(De);u!==tt.ANYONECANPAY&&f.push(...[l.map(Xo.encode),o.map(Qe.encode),r.map(Tt.encode),l.map(E=>Q.encode(E.sequence))].map(E=>kt(te(...E)))),h===tt.ALL&&f.push(kt(te(...y.map(ne.encode))));let N=(c?1:0)|(s?2:0);if(f.push(new Uint8Array([N])),u===tt.ANYONECANPAY){let E=l[e];f.push(Xo.encode(E),Qe.encode(o[e]),Tt.encode(r[e]),Q.encode(E.sequence))}else f.push(Q.encode(e));return N&1&&f.push(kt(Tt.encode(c||rt))),h===tt.SINGLE&&f.push(e<y.length?kt(ne.encode(y[e])):Cn),s&&f.push(Cr(s,a),$t.encode(0),le.encode(i)),mn("TapSighash",...f)}signIdx(e,r,n,o){this.checkInputIdx(r);let i=this.inputs[r],s=Zo(i,this.opts.allowLegacyWitnessUtxo);if(!J(e)){if(!i.bip32Derivation||!i.bip32Derivation.length)throw new Error("bip32Derivation: empty");let h=i.bip32Derivation.filter(l=>l[1].fingerprint==e.fingerprint).map(([l,{path:y}])=>{let N=e;for(let E of y)N=N.deriveChild(E);if(!st(N.publicKey,l))throw new Error("bip32Derivation: wrong pubKey");if(!N.privateKey)throw new Error("bip32Derivation: no privateKey");return N});if(!h.length)throw new Error(`bip32Derivation: no items with fingerprint=${e.fingerprint}`);let u=!1;for(let l of h)this.signIdx(l.privateKey,r)&&(u=!0);return u}n?n.forEach(Xf):n=[s.defaultSighash];let a=s.sighash;if(!n.includes(a))throw new Error(`Input with not allowed sigHash=${a}. Allowed: ${n.join(", ")}`);let{sigOutputs:c}=this.inputSighash(r);if(c===tt.SINGLE&&r>=this.outputs.length)throw new Error(`Input with sighash SINGLE, but there is no output with corresponding index=${r}`);let f=Lr(i);if(s.txType==="taproot"){let h=this.inputs.map(Lr),u=h.map(p=>p.script),l=h.map(p=>p.amount),y=!1,N=bn(e),E=i.tapMerkleRoot||rt;if(i.tapInternalKey){let{pubKey:p,privKey:A}=Qf(e,N,i.tapInternalKey,E),[m,b]=Mo(i.tapInternalKey,E);if(st(m,p)){let v=this.preimageWitnessV1(r,u,a,l),x=te(Oo(v,A,o),a!==tt.DEFAULT?new Uint8Array([a]):rt);this.updateInput(r,{tapKeySig:x},!0),y=!0}}if(i.tapLeafScript){i.tapScriptSig=i.tapScriptSig||[];for(let[p,A]of i.tapLeafScript){let m=A.subarray(0,-1),b=ct.decode(m),v=A[A.length-1],x=Cr(m,v);if(b.findIndex(d=>J(d)&&st(d,N))===-1)continue;let B=this.preimageWitnessV1(r,u,a,l,void 0,m,v),g=te(Oo(B,e,o),a!==tt.DEFAULT?new Uint8Array([a]):rt);this.updateInput(r,{tapScriptSig:[[{pubKey:N,leafHash:x},g]]},!0),y=!0}}if(!y)throw new Error("No taproot scripts signed");return!0}else{let h=$o(e),u=!1,l=Br(h);for(let E of ct.decode(s.lastScript))J(E)&&(st(E,h)||st(E,l))&&(u=!0);if(!u)throw new Error(`Input script doesn't have pubKey: ${s.lastScript}`);let y;if(s.txType==="legacy")y=this.preimageLegacy(r,s.lastScript,a);else if(s.txType==="segwit"){let E=s.lastScript;s.last.type==="wpkh"&&(E=Et.encode({type:"pkh",hash:s.last.hash})),y=this.preimageWitnessV0(r,E,a,f.amount)}else throw new Error(`Transaction/sign: unknown tx type: ${s.txType}`);let N=Fs(y,e,this.opts.lowR);this.updateInput(r,{partialSig:[[h,te(N,new Uint8Array([a]))]]},!0)}return!0}sign(e,r,n){let o=0;for(let i=0;i<this.inputs.length;i++)try{this.signIdx(e,i,r,n)&&o++}catch{}if(!o)throw new Error("No inputs signed");return o}finalizeIdx(e){if(this.checkInputIdx(e),this.fee<0n)throw new Error("Outputs spends more than inputs amount");let r=this.inputs[e],n=Zo(r,this.opts.allowLegacyWitnessUtxo);if(n.txType==="taproot"){if(r.tapKeySig)r.finalScriptWitness=[r.tapKeySig];else if(r.tapLeafScript&&r.tapScriptSig){let c=r.tapLeafScript.sort((f,h)=>Oe.encode(f[0]).length-Oe.encode(h[0]).length);for(let[f,h]of c){let u=h.slice(0,-1),l=h[h.length-1],y=Et.decode(u),N=Cr(u,l),E=r.tapScriptSig.filter(A=>st(A[0].leafHash,N)),p=[];if(y.type==="tr_ms"){let A=y.m,m=y.pubkeys,b=0;for(let v of m){let x=E.findIndex(w=>st(w[0].pubKey,v));if(b===A||x===-1){p.push(rt);continue}p.push(E[x][1]),b++}if(b!==A)continue}else if(y.type==="tr_ns"){for(let A of y.pubkeys){let m=E.findIndex(b=>st(b[0].pubKey,A));m!==-1&&p.push(E[m][1])}if(p.length!==y.pubkeys.length)continue}else if(y.type==="unknown"&&this.opts.allowUnknownInputs){let A=ct.decode(u);if(p=E.map(([{pubKey:m},b])=>{let v=A.findIndex(x=>J(x)&&st(x,m));if(v===-1)throw new Error("finalize/taproot: cannot find position of pubkey in script");return{signature:b,pos:v}}).sort((m,b)=>m.pos-b.pos).map(m=>m.signature),!p.length)continue}else{let A=this.opts.customScripts;if(A)for(let m of A){if(!m.finalizeTaproot)continue;let b=ct.decode(u),v=m.encode(b);if(v===void 0)continue;let x=m.finalizeTaproot(u,v,E);if(x){r.finalScriptWitness=x.concat(Oe.encode(f)),r.finalScriptSig=rt,Qo(r);return}}throw new Error("Finalize: Unknown tapLeafScript")}r.finalScriptWitness=p.reverse().concat([u,Oe.encode(f)]);break}if(!r.finalScriptWitness)throw new Error("finalize/taproot: empty witness")}else throw new Error("finalize/taproot: unknown input");r.finalScriptSig=rt,Qo(r);return}if(!r.partialSig||!r.partialSig.length)throw new Error("Not enough partial sign");let o=rt,i=[];if(n.last.type==="ms"){let c=n.last.m,f=n.last.pubkeys,h=[];for(let u of f){let l=r.partialSig.find(y=>st(u,y[0]));l&&h.push(l[1])}if(h=h.slice(0,c),h.length!==c)throw new Error(`Multisig: wrong signatures count, m=${c} n=${f.length} signatures=${h.length}`);o=ct.encode([0,...h])}else if(n.last.type==="pk")o=ct.encode([r.partialSig[0][1]]);else if(n.last.type==="pkh")o=ct.encode([r.partialSig[0][1],r.partialSig[0][0]]);else if(n.last.type==="wpkh")o=rt,i=[r.partialSig[0][1],r.partialSig[0][0]];else if(n.last.type==="unknown"&&!this.opts.allowUnknownInputs)throw new Error("Unknown inputs not allowed");let s,a;if(n.type.includes("wsh-")&&(o.length&&n.lastScript.length&&(i=ct.decode(o).map(c=>{if(c===0)return rt;if(J(c))return c;throw new Error(`Wrong witness op=${c}`)})),i=i.concat(n.lastScript)),n.txType==="segwit"&&(a=i),n.type.startsWith("sh-wsh-")?s=ct.encode([ct.encode([0,kt(n.lastScript)])]):n.type.startsWith("sh-")?s=ct.encode([...ct.decode(o),n.lastScript]):n.type.startsWith("wsh-")||n.txType!=="segwit"&&(s=o),!s&&!a)throw new Error("Unknown error finalizing input");s&&(r.finalScriptSig=s),a&&(r.finalScriptWitness=a),Qo(r)}finalize(){for(let e=0;e<this.inputs.length;e++)this.finalizeIdx(e)}extract(){if(!this.isFinal)throw new Error("Transaction has unfinalized inputs");if(!this.outputs.length)throw new Error("Transaction has no outputs");if(this.fee<0n)throw new Error("Outputs spends more than inputs amount");return this.toBytes(!0,!0)}combine(e){for(let o of["PSBTVersion","version","lockTime"])if(this.opts[o]!==e.opts[o])throw new Error(`Transaction/combine: different ${o} this=${this.opts[o]} other=${e.opts[o]}`);for(let o of["inputs","outputs"])if(this[o].length!==e[o].length)throw new Error(`Transaction/combine: different ${o} length this=${this[o].length} other=${e[o].length}`);let r=this.global.unsignedTx?$e.encode(this.global.unsignedTx):rt,n=e.global.unsignedTx?$e.encode(e.global.unsignedTx):rt;if(!st(r,n))throw new Error("Transaction/combine: different unsigned tx");this.global=Nr(Pn,this.global,e.global);for(let o=0;o<this.inputs.length;o++)this.updateInput(o,e.inputs[o],!0);for(let o=0;o<this.outputs.length;o++)this.updateOutput(o,e.outputs[o],!0);return this}clone(){return t.fromPSBT(this.toPSBT(this.opts.PSBTVersion),this.opts)}};var oi=vt(et(null),t=>me(t,xt.ecdsa)),Hn=vt(et(32),t=>me(t,xt.schnorr)),ba=vt(et(null),t=>{if(t.length!==64&&t.length!==65)throw new Error("Schnorr signature should be 64 or 65 bytes long");return t}),$n=ft({fingerprint:ss,path:St(null,Q)}),Ea=ft({hashes:St(It,et(32)),der:$n}),tu=et(78),eu=ft({pubKey:Hn,leafHash:et(32)}),ru=ft({version:$t,internalKey:et(32),merklePath:St(null,et(32))}),Oe=vt(ru,t=>{if(t.merklePath.length>128)throw new Error("TaprootControlBlock: merklePath should be of length 0..128 (inclusive)");return t}),nu=St(null,ft({depth:$t,version:$t,script:Tt})),pt=et(null),ma=et(20),Rr=et(32),Pn={unsignedTx:[0,!1,$e,[0],[0],!1],xpub:[1,tu,$n,[],[0,2],!1],txVersion:[2,!1,Q,[2],[2],!1],fallbackLocktime:[3,!1,Q,[],[2],!1],inputCount:[4,!1,It,[2],[2],!1],outputCount:[5,!1,It,[2],[2],!1],txModifiable:[6,!1,$t,[],[2],!1],version:[251,!1,Q,[],[0,2],!1],proprietary:[252,pt,pt,[],[0,2],!1]},cr={nonWitnessUtxo:[0,!1,oe,[],[0,2],!1],witnessUtxo:[1,!1,ne,[],[0,2],!1],partialSig:[2,oi,pt,[],[0,2],!1],sighashType:[3,!1,Q,[],[0,2],!1],redeemScript:[4,!1,pt,[],[0,2],!1],witnessScript:[5,!1,pt,[],[0,2],!1],bip32Derivation:[6,oi,$n,[],[0,2],!1],finalScriptSig:[7,!1,pt,[],[0,2],!1],finalScriptWitness:[8,!1,sr,[],[0,2],!1],porCommitment:[9,!1,pt,[],[0,2],!1],ripemd160:[10,ma,pt,[],[0,2],!1],sha256:[11,Rr,pt,[],[0,2],!1],hash160:[12,ma,pt,[],[0,2],!1],hash256:[13,Rr,pt,[],[0,2],!1],txid:[14,!1,Rr,[2],[2],!0],index:[15,!1,Q,[2],[2],!0],sequence:[16,!1,Q,[],[2],!0],requiredTimeLocktime:[17,!1,Q,[],[2],!1],requiredHeightLocktime:[18,!1,Q,[],[2],!1],tapKeySig:[19,!1,ba,[],[0,2],!1],tapScriptSig:[20,eu,ba,[],[0,2],!1],tapLeafScript:[21,Oe,pt,[],[0,2],!1],tapBip32Derivation:[22,Rr,Ea,[],[0,2],!1],tapInternalKey:[23,!1,Hn,[],[0,2],!1],tapMerkleRoot:[24,!1,Rr,[],[0,2],!1],proprietary:[252,pt,pt,[],[0,2],!1]},ga=["txid","sequence","index","witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknown"],wa=["partialSig","finalScriptSig","finalScriptWitness","tapKeySig","tapScriptSig"],Pr={redeemScript:[0,!1,pt,[],[0,2],!1],witnessScript:[1,!1,pt,[],[0,2],!1],bip32Derivation:[2,oi,$n,[],[0,2],!1],amount:[3,!1,is,[2],[2],!0],script:[4,!1,pt,[2],[2],!0],tapInternalKey:[5,!1,Hn,[],[0,2],!1],tapTree:[6,!1,nu,[],[0,2],!1],tapBip32Derivation:[7,Hn,Ea,[],[0,2],!1],proprietary:[252,pt,pt,[],[0,2],!1]},ya=[],xa=St(ro,ft({key:as(It,ft({type:It,key:et(null)})),value:et(It)}));function ii(t){let[e,r,n,o,i,s]=t;return{type:e,kc:r,vc:n,reqInc:o,allowInc:i,silentIgnore:s}}var ah=ft({type:It,key:et(null)});function si(t){let e={};for(let r in t){let[n,o,i]=t[r];e[n]=[r,o,i]}return Bt({encodeStream:(r,n)=>{let o=[];for(let i in t){let s=n[i];if(s===void 0)continue;let[a,c,f]=t[i];if(!c)o.push({key:{type:a,key:rt},value:f.encode(s)});else{let h=s.map(([u,l])=>[c.encode(u),f.encode(l)]);h.sort((u,l)=>Sr(u[0],l[0]));for(let[u,l]of h)o.push({key:{key:u,type:a},value:l})}}if(n.unknown){n.unknown.sort((i,s)=>Sr(i[0].key,s[0].key));for(let[i,s]of n.unknown)o.push({key:i,value:s})}xa.encodeStream(r,o)},decodeStream:r=>{let n=xa.decodeStream(r),o={},i={};for(let s of n){let a="unknown",c=s.key.key,f=s.value;if(e[s.key.type]){let[h,u,l]=e[s.key.type];if(a=h,!u&&c.length)throw new Error(`PSBT: Non-empty key for ${a} (key=${at.encode(c)} value=${at.encode(f)}`);if(c=u?u.decode(c):void 0,f=l.decode(f),!u){if(o[a])throw new Error(`PSBT: Same keys: ${a} (key=${c} value=${f})`);o[a]=f,i[a]=!0;continue}}else c={type:s.key.type,key:s.key.key};if(i[a])throw new Error(`PSBT: Key type with empty key and no key=${a} val=${f}`);o[a]||(o[a]=[]),o[a].push([c,f])}return o}})}var Ln=vt(si(cr),t=>{if(t.finalScriptWitness&&!t.finalScriptWitness.length)throw new Error("validateInput: empty finalScriptWitness");if(t.partialSig&&!t.partialSig.length)throw new Error("Empty partialSig");if(t.partialSig)for(let[e]of t.partialSig)me(e,xt.ecdsa);if(t.bip32Derivation)for(let[e]of t.bip32Derivation)me(e,xt.ecdsa);if(t.requiredTimeLocktime!==void 0&&t.requiredTimeLocktime<5e8)throw new Error(`validateInput: wrong timeLocktime=${t.requiredTimeLocktime}`);if(t.requiredHeightLocktime!==void 0&&(t.requiredHeightLocktime<=0||t.requiredHeightLocktime>=5e8))throw new Error(`validateInput: wrong heighLocktime=${t.requiredHeightLocktime}`);if(t.nonWitnessUtxo&&t.index!==void 0){let e=t.nonWitnessUtxo.outputs.length-1;if(t.index>e)throw new Error(`validateInput: index(${t.index}) not in nonWitnessUtxo`);let r=t.nonWitnessUtxo.outputs[t.index];if(t.witnessUtxo&&(!st(t.witnessUtxo.script,r.script)||t.witnessUtxo.amount!==r.amount))throw new Error("validateInput: witnessUtxo different from nonWitnessUtxo")}if(t.tapLeafScript)for(let[e,r]of t.tapLeafScript){if((e.version&254)!==r[r.length-1])throw new Error("validateInput: tapLeafScript version mimatch");if(r[r.length-1]&1)throw new Error("validateInput: tapLeafScript version has parity bit!")}if(t.nonWitnessUtxo&&t.index!==void 0&&t.txid){if(t.nonWitnessUtxo.outputs.length-1<t.index)throw new Error("nonWitnessUtxo: incorect output index");let r=xe.fromRaw(oe.encode(t.nonWitnessUtxo),{allowUnknownOutputs:!0,disableScriptCheck:!0,allowUnknownInputs:!0}),n=at.encode(t.txid);if(r.isFinal&&r.id!==n)throw new Error(`nonWitnessUtxo: wrong txid, exp=${n} got=${r.id}`)}return t}),Rn=vt(si(Pr),t=>{if(t.bip32Derivation)for(let[e]of t.bip32Derivation)me(e,xt.ecdsa);return t}),va=vt(si(Pn),t=>{if((t.version||0)===0){if(!t.unsignedTx)throw new Error("PSBTv0: missing unsignedTx");for(let r of t.unsignedTx.inputs)if(r.finalScriptSig&&r.finalScriptSig.length)throw new Error("PSBTv0: input scriptSig found in unsignedTx")}return t}),ou=ft({magic:Yr(jr(new Uint8Array([255])),"psbt"),global:va,inputs:St("global/unsignedTx/inputs/length",Ln),outputs:St(null,Rn)}),iu=ft({magic:Yr(jr(new Uint8Array([255])),"psbt"),global:va,inputs:St("global/inputCount",Ln),outputs:St("global/outputCount",Rn)}),ch=ft({magic:Yr(jr(new Uint8Array([255])),"psbt"),items:St(null,Vt(St(ro,ds([cs(It),et(Ur)])),ue.dict()))});function ni(t,e,r){for(let n in r){if(n==="unknown"||!e[n])continue;let{allowInc:o}=ii(e[n]);if(!o.includes(t))throw new Error(`PSBTv${t}: field ${n} is not allowed`)}for(let n in e){let{reqInc:o}=ii(e[n]);if(o.includes(t)&&r[n]===void 0)throw new Error(`PSBTv${t}: missing required field ${n}`)}}function ti(t,e,r){let n={};for(let o in r){let i=o;if(i!=="unknown"){if(!e[i])continue;let{allowInc:s,silentIgnore:a}=ii(e[i]);if(!s.includes(t)){if(a)continue;throw new Error(`Failed to serialize in PSBTv${t}: ${i} but versions allows inclusion=${s}`)}}n[i]=r[i]}return n}function Ba(t){let e=t&&t.global&&t.global.version||0;ni(e,Pn,t.global);for(let s of t.inputs)ni(e,cr,s);for(let s of t.outputs)ni(e,Pr,s);let r=e?t.global.inputCount:t.global.unsignedTx.inputs.length;if(t.inputs.length<r)throw new Error("Not enough inputs");let n=t.inputs.slice(r);if(n.length>1||n.length&&Object.keys(n[0]).length)throw new Error(`Unexpected inputs left in tx=${n}`);let o=e?t.global.outputCount:t.global.unsignedTx.outputs.length;if(t.outputs.length<o)throw new Error("Not outputs inputs");let i=t.outputs.slice(o);if(i.length>1||i.length&&Object.keys(i[0]).length)throw new Error(`Unexpected outputs left in tx=${i}`);return t}function Nr(t,e,r,n){let o={...r,...e};for(let i in t){let s=i,[a,c,f]=t[s],h=n&&!n.includes(i);if(e[i]===void 0&&i in e){if(h)throw new Error(`Cannot remove signed field=${i}`);delete o[i]}else if(c){let u=r&&r[i]?r[i]:[],l=e[s];if(l){if(!Array.isArray(l))throw new Error(`keyMap(${i}): KV pairs should be [k, v][]`);l=l.map(E=>{if(E.length!==2)throw new Error(`keyMap(${i}): KV pairs should be [k, v][]`);return[typeof E[0]=="string"?c.decode(at.decode(E[0])):E[0],typeof E[1]=="string"?f.decode(at.decode(E[1])):E[1]]});let y={},N=(E,p,A)=>{if(y[E]===void 0){y[E]=[p,A];return}let m=at.encode(f.encode(y[E][1])),b=at.encode(f.encode(A));if(m!==b)throw new Error(`keyMap(${s}): same key=${E} oldVal=${m} newVal=${b}`)};for(let[E,p]of u){let A=at.encode(c.encode(E));N(A,E,p)}for(let[E,p]of l){let A=at.encode(c.encode(E));if(p===void 0){if(h)throw new Error(`Cannot remove signed field=${s}/${E}`);delete y[A]}else N(A,E,p)}o[s]=Object.values(y)}}else if(typeof o[i]=="string")o[i]=f.decode(at.decode(o[i]));else if(h&&i in e&&r&&r[i]!==void 0&&!st(f.encode(e[i]),f.encode(r[i])))throw new Error(`Cannot change signed field=${i}`)}for(let i in o)t[i]||delete o[i];return o}var ei=vt(ou,Ba),ri=vt(iu,Ba);function fr(t,e){try{return me(t,e),!0}catch{return!1}}var su={encode(t){if(!(t.length!==2||!J(t[0])||!fr(t[0],xt.ecdsa)||t[1]!=="CHECKSIG"))return{type:"pk",pubkey:t[0]}},decode:t=>t.type==="pk"?[t.pubkey,"CHECKSIG"]:void 0},au={encode(t){if(!(t.length!==5||t[0]!=="DUP"||t[1]!=="HASH160"||!J(t[2]))&&!(t[3]!=="EQUALVERIFY"||t[4]!=="CHECKSIG"))return{type:"pkh",hash:t[2]}},decode:t=>t.type==="pkh"?["DUP","HASH160",t.hash,"EQUALVERIFY","CHECKSIG"]:void 0},cu={encode(t){if(!(t.length!==3||t[0]!=="HASH160"||!J(t[1])||t[2]!=="EQUAL"))return{type:"sh",hash:t[1]}},decode:t=>t.type==="sh"?["HASH160",t.hash,"EQUAL"]:void 0},fu={encode(t){if(!(t.length!==2||t[0]!==0||!J(t[1]))&&t[1].length===32)return{type:"wsh",hash:t[1]}},decode:t=>t.type==="wsh"?[0,t.hash]:void 0},uu={encode(t){if(!(t.length!==2||t[0]!==0||!J(t[1]))&&t[1].length===20)return{type:"wpkh",hash:t[1]}},decode:t=>t.type==="wpkh"?[0,t.hash]:void 0},lu={encode(t){let e=t.length-1;if(t[e]!=="CHECKMULTISIG")return;let r=t[0],n=t[e-1];if(typeof r!="number"||typeof n!="number")return;let o=t.slice(1,-2);if(n===o.length){for(let i of o)if(!J(i))return;return{type:"ms",m:r,pubkeys:o}}},decode:t=>t.type==="ms"?[t.m,...t.pubkeys,t.pubkeys.length,"CHECKMULTISIG"]:void 0},du={encode(t){if(!(t.length!==2||t[0]!==1||!J(t[1])))return{type:"tr",pubkey:t[1]}},decode:t=>t.type==="tr"?[1,t.pubkey]:void 0},hu={encode(t){let e=t.length-1;if(t[e]!=="CHECKSIG")return;let r=[];for(let n=0;n<e;n++){let o=t[n];if(n&1){if(o!=="CHECKSIGVERIFY"||n===e-1)return;continue}if(!J(o))return;r.push(o)}return{type:"tr_ns",pubkeys:r}},decode:t=>{if(t.type!=="tr_ns")return;let e=[];for(let r=0;r<t.pubkeys.length-1;r++)e.push(t.pubkeys[r],"CHECKSIGVERIFY");return e.push(t.pubkeys[t.pubkeys.length-1],"CHECKSIG"),e}},pu={encode(t){let e=t.length-1;if(t[e]!=="NUMEQUAL"||t[1]!=="CHECKSIG")return;let r=[],n=ua(t[e-1]);if(typeof n=="number"){for(let o=0;o<e-1;o++){let i=t[o];if(o&1){if(i!==(o===1?"CHECKSIG":"CHECKSIGADD"))throw new Error("OutScript.encode/tr_ms: wrong element");continue}if(!J(i))throw new Error("OutScript.encode/tr_ms: wrong key element");r.push(i)}return{type:"tr_ms",pubkeys:r,m:n}}},decode:t=>{if(t.type!=="tr_ms")return;let e=[t.pubkeys[0],"CHECKSIG"];for(let r=1;r<t.pubkeys.length;r++)e.push(t.pubkeys[r],"CHECKSIGADD");return e.push(t.m,"NUMEQUAL"),e}},gu={encode(t){return{type:"unknown",script:ct.encode(t)}},decode:t=>t.type==="unknown"?ct.decode(t.script):void 0},wu=[su,au,cu,fu,uu,lu,du,hu,pu,gu],yu=Vt(ct,ue.match(wu)),Et=vt(yu,t=>{if(t.type==="pk"&&!fr(t.pubkey,xt.ecdsa))throw new Error("OutScript/pk: wrong key");if((t.type==="pkh"||t.type==="sh"||t.type==="wpkh")&&(!J(t.hash)||t.hash.length!==20))throw new Error(`OutScript/${t.type}: wrong hash`);if(t.type==="wsh"&&(!J(t.hash)||t.hash.length!==32))throw new Error("OutScript/wsh: wrong hash");if(t.type==="tr"&&(!J(t.pubkey)||!fr(t.pubkey,xt.schnorr)))throw new Error("OutScript/tr: wrong taproot public key");if((t.type==="ms"||t.type==="tr_ns"||t.type==="tr_ms")&&!Array.isArray(t.pubkeys))throw new Error("OutScript/multisig: wrong pubkeys array");if(t.type==="ms"){let e=t.pubkeys.length;for(let r of t.pubkeys)if(!fr(r,xt.ecdsa))throw new Error("OutScript/multisig: wrong pubkey");if(t.m<=0||e>16||t.m>e)throw new Error("OutScript/multisig: invalid params")}if(t.type==="tr_ns"||t.type==="tr_ms"){for(let e of t.pubkeys)if(!fr(e,xt.schnorr))throw new Error(`OutScript/${t.type}: wrong pubkey`)}if(t.type==="tr_ms"){let e=t.pubkeys.length;if(t.m<=0||e>999||t.m>e)throw new Error("OutScript/tr_ms: invalid params")}return t});function Sa(t,e){if(!st(t.hash,kt(e)))throw new Error("checkScript: wsh wrong witnessScript hash");let r=Et.decode(e);if(r.type==="tr"||r.type==="tr_ns"||r.type==="tr_ms")throw new Error(`checkScript: P2${r.type} cannot be wrapped in P2SH`);if(r.type==="wpkh"||r.type==="sh")throw new Error(`checkScript: P2${r.type} cannot be wrapped in P2WSH`)}function Nn(t,e,r){if(t){let n=Et.decode(t);if(n.type==="tr_ns"||n.type==="tr_ms"||n.type==="ms"||n.type=="pk")throw new Error(`checkScript: non-wrapped ${n.type}`);if(n.type==="sh"&&e){if(!st(n.hash,Br(e)))throw new Error("checkScript: sh wrong redeemScript hash");let o=Et.decode(e);if(o.type==="tr"||o.type==="tr_ns"||o.type==="tr_ms")throw new Error(`checkScript: P2${o.type} cannot be wrapped in P2SH`);if(o.type==="sh")throw new Error("checkScript: P2SH cannot be wrapped in P2SH")}n.type==="wsh"&&r&&Sa(n,r)}if(e){let n=Et.decode(e);n.type==="wsh"&&r&&Sa(n,r)}}var ci=(t,e=re)=>{if(!fr(t,xt.ecdsa))throw new Error("P2WPKH: invalid publicKey");if(t.length===65)throw new Error("P2WPKH: uncompressed public key");let r=Br(t);return{type:"wpkh",script:Et.encode({type:"wpkh",hash:r}),address:Ee(e).encode({type:"wpkh",hash:r})}};var bu=192,Cr=(t,e=bu)=>mn("TapLeaf",new Uint8Array([e]),Tt.encode(t));var ka=Tn(kt);function Ta(t,e){if(e.length<2||e.length>40)throw new Error("Witness: invalid length");if(t>16)throw new Error("Witness: invalid version");if(t===0&&!(e.length===20||e.length===32))throw new Error("Witness: invalid length for version")}function ai(t,e,r=re){Ta(t,e);let n=t===0?In:Yo;return n.encode(r.bech32,[t].concat(n.toWords(e)))}function Aa(t,e){return ka.encode(te(Uint8Array.from(e),t))}function Ee(t=re){return{encode(e){let{type:r}=e;if(r==="wpkh")return ai(0,e.hash,t);if(r==="wsh")return ai(0,e.hash,t);if(r==="tr")return ai(1,e.pubkey,t);if(r==="pkh")return Aa(e.hash,[t.pubKeyHash]);if(r==="sh")return Aa(e.hash,[t.scriptHash]);throw new Error(`Unknown address type=${r}`)},decode(e){if(e.length<14||e.length>74)throw new Error("Invalid address length");if(t.bech32&&e.toLowerCase().startsWith(`${t.bech32}1`)){let n;try{if(n=In.decode(e),n.words[0]!==0)throw new Error(`bech32: wrong version=${n.words[0]}`)}catch{if(n=Yo.decode(e),n.words[0]===0)throw new Error(`bech32m: wrong version=${n.words[0]}`)}if(n.prefix!==t.bech32)throw new Error(`wrong bech32 prefix=${n.prefix}`);let[o,...i]=n.words,s=In.fromWords(i);if(Ta(o,s),o===0&&s.length===32)return{type:"wsh",hash:s};if(o===0&&s.length===20)return{type:"wpkh",hash:s};if(o===1&&s.length===32)return{type:"tr",pubkey:s};throw new Error("Unknown witness program")}let r=ka.decode(e);if(r.length!==21)throw new Error("Invalid base58 address");if(r[0]===t.pubKeyHash)return{type:"pkh",hash:r.slice(1)};if(r[0]===t.scriptHash)return{type:"sh",hash:r.slice(1)};throw new Error(`Invalid address prefix=${r[0]}`)}}}function ve(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function xu(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function At(t,...e){if(!xu(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function On(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ve(t.outputLen),ve(t.blockLen)}function ur(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ia(t,e){At(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Kt(t,e){return t<<32-e|t>>>e}function Hr(t,e){return t<<e|t>>>32-e>>>0}var La=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Eu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Na(t){if(At(t),La)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Eu[t[r]];return e}var ie={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ua(t){if(t>=ie._0&&t<=ie._9)return t-ie._0;if(t>=ie.A&&t<=ie.F)return t-(ie.A-10);if(t>=ie.a&&t<=ie.f)return t-(ie.a-10)}function Ca(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(La)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ua(t.charCodeAt(i)),a=Ua(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function fi(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Be(t){return typeof t=="string"&&(t=fi(t)),At(t),t}function qe(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];At(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var lr=class{clone(){return this._cloneInto()}};function _a(t,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function dr(t){let e=n=>t().update(Be(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Mn(t=32){if(Ke&&typeof Ke.getRandomValues=="function")return Ke.getRandomValues(new Uint8Array(t));if(Ke&&typeof Ke.randomBytes=="function")return Uint8Array.from(Ke.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}var Dn=class extends lr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,On(e);let n=Be(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return ur(this),this.iHash.update(e),this}digestInto(e){ur(this),At(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Se=(t,e,r)=>new Dn(t,e).update(r).digest();Se.create=(t,e)=>new Dn(t,e);function vu(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}function Pa(t,e,r){return t&e^~t&r}function Ra(t,e,r){return t&e^t&r^e&r}var Ae=class extends lr{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Yt(this.buffer)}update(e){ur(this);let{view:r,buffer:n,blockLen:o}=this;e=Be(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Yt(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ur(this),Ia(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)r[u]=0;vu(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Yt(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,h[u],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var Bu=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),$a=new Uint8Array(new Array(16).fill(0).map((t,e)=>e)),Su=$a.map(t=>(9*t+5)%16),li=[$a],di=[Su];for(let t=0;t<4;t++)for(let e of[li,di])e.push(e[t].map(r=>Bu[r]));var Oa=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),Au=li.map((t,e)=>t.map(r=>Oa[e][r])),ku=di.map((t,e)=>t.map(r=>Oa[e][r])),Tu=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Iu=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function Ha(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}var Kn=new Uint32Array(16),ui=class extends Ae{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:r,h2:n,h3:o,h4:i}=this;return[e,r,n,o,i]}set(e,r,n,o,i){this.h0=e|0,this.h1=r|0,this.h2=n|0,this.h3=o|0,this.h4=i|0}process(e,r){for(let y=0;y<16;y++,r+=4)Kn[y]=e.getUint32(r,!0);let n=this.h0|0,o=n,i=this.h1|0,s=i,a=this.h2|0,c=a,f=this.h3|0,h=f,u=this.h4|0,l=u;for(let y=0;y<5;y++){let N=4-y,E=Tu[y],p=Iu[y],A=li[y],m=di[y],b=Au[y],v=ku[y];for(let x=0;x<16;x++){let w=Hr(n+Ha(y,i,a,f)+Kn[A[x]]+E,b[x])+u|0;n=u,u=f,f=Hr(a,10)|0,a=i,i=w}for(let x=0;x<16;x++){let w=Hr(o+Ha(N,s,c,h)+Kn[m[x]]+p,v[x])+l|0;o=l,l=h,h=Hr(c,10)|0,c=s,s=w}}this.set(this.h1+a+h|0,this.h2+f+l|0,this.h3+u+o|0,this.h4+n+s|0,this.h0+i+c|0)}roundClean(){Kn.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},Ma=dr(()=>new ui);var Uu=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]),ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Te=new Uint32Array(64),hi=class extends Ae{constructor(e=32){super(64,e,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let u=0;u<16;u++,r+=4)Te[u]=e.getUint32(r,!1);for(let u=16;u<64;u++){let l=Te[u-15],y=Te[u-2],N=Kt(l,7)^Kt(l,18)^l>>>3,E=Kt(y,17)^Kt(y,19)^y>>>10;Te[u]=E+Te[u-7]+N+Te[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:h}=this;for(let u=0;u<64;u++){let l=Kt(a,6)^Kt(a,11)^Kt(a,25),y=h+l+Pa(a,c,f)+Uu[u]+Te[u]|0,E=(Kt(n,2)^Kt(n,13)^Kt(n,22))+Ra(n,o,i)|0;h=f,f=c,c=a,a=s+y|0,s=i,i=o,o=n,n=y+E|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,h=h+this.H|0,this.set(n,o,i,s,a,c,f,h)}roundClean(){Te.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ie=dr(()=>new hi);var qn=BigInt(4294967295),pi=BigInt(32);function Da(t,e=!1){return e?{h:Number(t&qn),l:Number(t>>pi&qn)}:{h:Number(t>>pi&qn)|0,l:Number(t&qn)|0}}function Lu(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:s}=Da(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]}var Nu=(t,e)=>BigInt(t>>>0)<<pi|BigInt(e>>>0),Cu=(t,e,r)=>t>>>r,_u=(t,e,r)=>t<<32-r|e>>>r,Pu=(t,e,r)=>t>>>r|e<<32-r,Ru=(t,e,r)=>t<<32-r|e>>>r,Hu=(t,e,r)=>t<<64-r|e>>>r-32,$u=(t,e,r)=>t>>>r-32|e<<64-r,Ou=(t,e)=>e,Mu=(t,e)=>t,Du=(t,e,r)=>t<<r|e>>>32-r,Ku=(t,e,r)=>e<<r|t>>>32-r,qu=(t,e,r)=>e<<r-32|t>>>64-r,Wu=(t,e,r)=>t<<r-32|e>>>64-r;function Vu(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var zu=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ju=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Yu=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Gu=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Zu=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Fu=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var Qu={fromBig:Da,split:Lu,toBig:Nu,shrSH:Cu,shrSL:_u,rotrSH:Pu,rotrSL:Ru,rotrBH:Hu,rotrBL:$u,rotr32H:Ou,rotr32L:Mu,rotlSH:Du,rotlSL:Ku,rotlBH:qu,rotlBL:Wu,add:Vu,add3L:zu,add3H:ju,add4L:Yu,add4H:Gu,add5H:Fu,add5L:Zu},z=Qu;var[Xu,Ju]=z.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ue=new Uint32Array(80),Le=new Uint32Array(80),gi=class extends Ae{constructor(e=64){super(128,e,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:h,Fh:u,Fl:l,Gh:y,Gl:N,Hh:E,Hl:p}=this;return[e,r,n,o,i,s,a,c,f,h,u,l,y,N,E,p]}set(e,r,n,o,i,s,a,c,f,h,u,l,y,N,E,p){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=h|0,this.Fh=u|0,this.Fl=l|0,this.Gh=y|0,this.Gl=N|0,this.Hh=E|0,this.Hl=p|0}process(e,r){for(let b=0;b<16;b++,r+=4)Ue[b]=e.getUint32(r),Le[b]=e.getUint32(r+=4);for(let b=16;b<80;b++){let v=Ue[b-15]|0,x=Le[b-15]|0,w=z.rotrSH(v,x,1)^z.rotrSH(v,x,8)^z.shrSH(v,x,7),B=z.rotrSL(v,x,1)^z.rotrSL(v,x,8)^z.shrSL(v,x,7),g=Ue[b-2]|0,d=Le[b-2]|0,C=z.rotrSH(g,d,19)^z.rotrBH(g,d,61)^z.shrSH(g,d,6),k=z.rotrSL(g,d,19)^z.rotrBL(g,d,61)^z.shrSL(g,d,6),T=z.add4L(B,k,Le[b-7],Le[b-16]),D=z.add4H(T,w,C,Ue[b-7],Ue[b-16]);Ue[b]=D|0,Le[b]=T|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:h,Eh:u,El:l,Fh:y,Fl:N,Gh:E,Gl:p,Hh:A,Hl:m}=this;for(let b=0;b<80;b++){let v=z.rotrSH(u,l,14)^z.rotrSH(u,l,18)^z.rotrBH(u,l,41),x=z.rotrSL(u,l,14)^z.rotrSL(u,l,18)^z.rotrBL(u,l,41),w=u&y^~u&E,B=l&N^~l&p,g=z.add5L(m,x,B,Ju[b],Le[b]),d=z.add5H(g,A,v,w,Xu[b],Ue[b]),C=g|0,k=z.rotrSH(n,o,28)^z.rotrBH(n,o,34)^z.rotrBH(n,o,39),T=z.rotrSL(n,o,28)^z.rotrBL(n,o,34)^z.rotrBL(n,o,39),D=n&i^n&a^i&a,S=o&s^o&c^s&c;A=E|0,m=p|0,E=y|0,p=N|0,y=u|0,N=l|0,{h:u,l}=z.add(f|0,h|0,d|0,C|0),f=a|0,h=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=z.add3L(C,T,S);n=z.add3H(I,d,k,D),o=I|0}({h:n,l:o}=z.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=z.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=z.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:h}=z.add(this.Dh|0,this.Dl|0,f|0,h|0),{h:u,l}=z.add(this.Eh|0,this.El|0,u|0,l|0),{h:y,l:N}=z.add(this.Fh|0,this.Fl|0,y|0,N|0),{h:E,l:p}=z.add(this.Gh|0,this.Gl|0,E|0,p|0),{h:A,l:m}=z.add(this.Hh|0,this.Hl|0,A|0,m|0),this.set(n,o,i,s,a,c,f,h,u,l,y,N,E,p,A,m)}roundClean(){Ue.fill(0),Le.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var $r=dr(()=>new gi);var mi=BigInt(0),bi=BigInt(1);function We(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function xi(t){if(!We(t))throw new Error("Uint8Array expected")}function hr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Or(t){let e=t.toString(16);return e.length&1?"0"+e:e}function Wa(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?mi:BigInt("0x"+t)}var Va=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",tl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pr(t){if(xi(t),Va)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=tl[t[r]];return e}var se={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ka(t){if(t>=se._0&&t<=se._9)return t-se._0;if(t>=se.A&&t<=se.F)return t-(se.A-10);if(t>=se.a&&t<=se.f)return t-(se.a-10)}function Mr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Va)return Uint8Array.fromHex(t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ka(t.charCodeAt(i)),a=Ka(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function ae(t){return Wa(pr(t))}function Ei(t){return xi(t),Wa(pr(Uint8Array.from(t).reverse()))}function Ve(t,e){return Mr(t.toString(16).padStart(e*2,"0"))}function vi(t,e){return Ve(t,e).reverse()}function Nt(t,e,r){let n;if(typeof e=="string")try{n=Mr(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(We(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function Dr(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];xi(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var wi=t=>typeof t=="bigint"&&mi<=t;function Wn(t,e,r){return wi(t)&&wi(e)&&wi(r)&&e<=t&&t<r}function ze(t,e,r,n){if(!Wn(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function za(t){let e;for(e=0;t>mi;t>>=bi,e+=1);return e}var je=t=>(bi<<BigInt(t))-bi,yi=t=>new Uint8Array(t),qa=t=>Uint8Array.from(t);function ja(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=yi(t),o=yi(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...u)=>r(o,n,...u),c=(u=yi(0))=>{o=a(qa([0]),u),n=a(),u.length!==0&&(o=a(qa([1]),u),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,l=[];for(;u<e;){n=a();let y=n.slice();l.push(y),u+=n.length}return Dr(...l)};return(u,l)=>{s(),c(u);let y;for(;!(y=l(f()));)c();return s(),y}}var el={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||We(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ye(t,e,r={}){let n=(o,i,s)=>{let a=el[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}function Bi(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var gt=BigInt(0),ot=BigInt(1),Ge=BigInt(2),rl=BigInt(3),Si=BigInt(4),Ya=BigInt(5),Ga=BigInt(8),nl=BigInt(9),ol=BigInt(16);function bt(t,e){let r=t%e;return r>=gt?r:e+r}function il(t,e,r){if(e<gt)throw new Error("invalid exponent, negatives unsupported");if(r<=gt)throw new Error("invalid modulus");if(r===ot)return gt;let n=ot;for(;e>gt;)e&ot&&(n=n*t%r),t=t*t%r,e>>=ot;return n}function Ct(t,e,r){let n=t;for(;e-- >gt;)n*=n,n%=r;return n}function Vn(t,e){if(t===gt)throw new Error("invert: expected non-zero number");if(e<=gt)throw new Error("invert: expected positive modulus, got "+e);let r=bt(t,e),n=e,o=gt,i=ot,s=ot,a=gt;for(;r!==gt;){let f=n/r,h=n%r,u=o-s*f,l=i-a*f;n=r,r=h,o=s,i=a,s=u,a=l}if(n!==ot)throw new Error("invert: does not exist");return bt(o,e)}function sl(t){let e=(t-ot)/Ge,r,n,o;for(r=t-ot,n=0;r%Ge===gt;r/=Ge,n++);for(o=Ge;o<t&&il(o,e,t)!==t-ot;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+ot)/Si;return function(c,f){let h=c.pow(f,s);if(!c.eql(c.sqr(h),f))throw new Error("Cannot find square root");return h}}let i=(r+ot)/Ge;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,h=a.pow(a.mul(a.ONE,o),r),u=a.pow(c,i),l=a.pow(c,r);for(;!a.eql(l,a.ONE);){if(a.eql(l,a.ZERO))return a.ZERO;let y=1;for(let E=a.sqr(l);y<f&&!a.eql(E,a.ONE);y++)E=a.sqr(E);let N=a.pow(h,ot<<BigInt(f-y-1));h=a.sqr(N),u=a.mul(u,N),l=a.mul(l,h),f=y}return u}}function al(t){if(t%Si===rl){let e=(t+ot)/Si;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Ga===Ya){let e=(t-Ya)/Ga;return function(n,o){let i=n.mul(o,Ge),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,Ge),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return t%ol,sl(t)}var cl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ai(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=cl.reduce((n,o)=>(n[o]="function",n),e);return Ye(t,r)}function fl(t,e,r){if(r<gt)throw new Error("invalid exponent, negatives unsupported");if(r===gt)return t.ONE;if(r===ot)return e;let n=t.ONE,o=e;for(;r>gt;)r&ot&&(n=t.mul(n,o)),o=t.sqr(o),r>>=ot;return n}function ul(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function ki(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function zn(t,e,r=!1,n={}){if(t<=gt)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=ki(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,isLE:r,BITS:o,BYTES:i,MASK:je(o),ZERO:gt,ONE:ot,create:c=>bt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return gt<=c&&c<t},is0:c=>c===gt,isOdd:c=>(c&ot)===ot,neg:c=>bt(-c,t),eql:(c,f)=>c===f,sqr:c=>bt(c*c,t),add:(c,f)=>bt(c+f,t),sub:(c,f)=>bt(c-f,t),mul:(c,f)=>bt(c*f,t),pow:(c,f)=>fl(a,c,f),div:(c,f)=>bt(c*Vn(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Vn(c,t),sqrt:n.sqrt||(c=>(s||(s=al(t)),s(a,c))),invertBatch:c=>ul(a,c),cmov:(c,f,h)=>h?f:c,toBytes:c=>r?vi(c,i):Ve(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Ei(c):ae(c)}});return Object.freeze(a)}function Za(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Ti(t){let e=Za(t);return e+Math.ceil(e/2)}function Fa(t,e,r=!1){let n=t.length,o=Za(e),i=Ti(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ei(t):ae(t),a=bt(s,e-ot)+ot;return r?vi(a,o):Ve(a,o)}var Qa=BigInt(0),Ci=BigInt(1);function Ii(t,e){let r=e.negate();return t?r:e}function Ja(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ui(t,e){Ja(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=je(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Xa(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(t&o),c=t>>s;a>n&&(a-=i,c+=Ci);let f=e*n,h=f+Math.abs(a)-1,u=a===0,l=a<0,y=e%2!==0;return{nextN:c,offset:h,isZero:u,isNeg:l,isNegF:y,offsetF:f}}function ll(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function dl(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var Li=new WeakMap,tc=new WeakMap;function Ni(t){return tc.get(t)||1}function ec(t,e){return{constTimeNegate:Ii,hasPrecomputes(r){return Ni(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>Qa;)n&Ci&&(o=o.add(i)),i=i.double(),n>>=Ci;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Ui(n,e),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let h=1;h<i;h++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=t.ZERO,s=t.BASE,a=Ui(r,e);for(let c=0;c<a.windows;c++){let{nextN:f,offset:h,isZero:u,isNeg:l,isNegF:y,offsetF:N}=Xa(o,c,a);o=f,u?s=s.add(Ii(y,n[N])):i=i.add(Ii(l,n[h]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=t.ZERO){let s=Ui(r,e);for(let a=0;a<s.windows&&o!==Qa;a++){let{nextN:c,offset:f,isZero:h,isNeg:u}=Xa(o,a,s);if(o=c,!h){let l=n[f];i=i.add(u?l.negate():l)}}return i},getPrecomputes(r,n,o){let i=Li.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&Li.set(n,o(i))),i},wNAFCached(r,n,o){let i=Ni(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Ni(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ja(n,e),tc.set(r,n),Li.delete(r)}}}function rc(t,e,r,n){if(ll(r,t),dl(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=za(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=je(s),c=new Array(Number(a)+1).fill(o),f=Math.floor((e.BITS-1)/s)*s,h=o;for(let u=f;u>=0;u-=s){c.fill(o);for(let y=0;y<n.length;y++){let N=n[y],E=Number(N>>BigInt(u)&a);c[E]=c[E].add(r[y])}let l=o;for(let y=c.length-1,N=o;y>0;y--)N=N.add(c[y]),l=l.add(N);if(h=h.add(l),u!==0)for(let y=0;y<s;y++)h=h.double()}return h}function _i(t){return Ai(t.Fp),Ye(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ki(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function nc(t){t.lowS!==void 0&&hr("lowS",t.lowS),t.prehash!==void 0&&hr("prehash",t.prehash)}function hl(t){let e=_i(t);Ye(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var Pi=class extends Error{constructor(e=""){super(e)}},ce={Err:Pi,_tlv:{encode:(t,e)=>{let{Err:r}=ce;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Or(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Or(o.length/2|128):"";return Or(t)+i+o+e},decode(t,e){let{Err:r}=ce,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let h of f)s=s<<8|h;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=ce;if(t<fe)throw new e("integer: negative integers are not allowed");let r=Or(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=ce;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ae(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ce,o=Nt("signature",t),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:h}=n.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=ce,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},fe=BigInt(0),mt=BigInt(1),hp=BigInt(2),oc=BigInt(3),pp=BigInt(4);function pl(t){let e=hl(t),{Fp:r}=e,n=zn(e.n,e.nBitLength),o=e.toBytes||((E,p,A)=>{let m=p.toAffine();return Dr(Uint8Array.from([4]),r.toBytes(m.x),r.toBytes(m.y))}),i=e.fromBytes||(E=>{let p=E.subarray(1),A=r.fromBytes(p.subarray(0,r.BYTES)),m=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:A,y:m}});function s(E){let{a:p,b:A}=e,m=r.sqr(E),b=r.mul(m,E);return r.add(r.add(b,r.mul(E,p)),A)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(E){return Wn(E,mt,e.n)}function c(E){let{allowedPrivateKeyLengths:p,nByteLength:A,wrapPrivateKey:m,n:b}=e;if(p&&typeof E!="bigint"){if(We(E)&&(E=pr(E)),typeof E!="string"||!p.includes(E.length))throw new Error("invalid private key");E=E.padStart(A*2,"0")}let v;try{v=typeof E=="bigint"?E:ae(Nt("private key",E,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof E)}return m&&(v=bt(v,b)),ze("private key",v,mt,b),v}function f(E){if(!(E instanceof l))throw new Error("ProjectivePoint expected")}let h=Bi((E,p)=>{let{px:A,py:m,pz:b}=E;if(r.eql(b,r.ONE))return{x:A,y:m};let v=E.is0();p==null&&(p=v?r.ONE:r.inv(b));let x=r.mul(A,p),w=r.mul(m,p),B=r.mul(b,p);if(v)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x,y:w}}),u=Bi(E=>{if(E.is0()){if(e.allowInfinityPoint&&!r.is0(E.py))return;throw new Error("bad point: ZERO")}let{x:p,y:A}=E.toAffine();if(!r.isValid(p)||!r.isValid(A))throw new Error("bad point: x or y not FE");let m=r.sqr(A),b=s(p);if(!r.eql(m,b))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(p,A,m){if(p==null||!r.isValid(p))throw new Error("x required");if(A==null||!r.isValid(A))throw new Error("y required");if(m==null||!r.isValid(m))throw new Error("z required");this.px=p,this.py=A,this.pz=m,Object.freeze(this)}static fromAffine(p){let{x:A,y:m}=p||{};if(!p||!r.isValid(A)||!r.isValid(m))throw new Error("invalid affine point");if(p instanceof l)throw new Error("projective point not allowed");let b=v=>r.eql(v,r.ZERO);return b(A)&&b(m)?l.ZERO:new l(A,m,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(p){let A=r.invertBatch(p.map(m=>m.pz));return p.map((m,b)=>m.toAffine(A[b])).map(l.fromAffine)}static fromHex(p){let A=l.fromAffine(i(Nt("pointHex",p)));return A.assertValidity(),A}static fromPrivateKey(p){return l.BASE.multiply(c(p))}static msm(p,A){return rc(l,n,p,A)}_setWindowSize(p){N.setWindowSize(this,p)}assertValidity(){u(this)}hasEvenY(){let{y:p}=this.toAffine();if(r.isOdd)return!r.isOdd(p);throw new Error("Field doesn't support isOdd")}equals(p){f(p);let{px:A,py:m,pz:b}=this,{px:v,py:x,pz:w}=p,B=r.eql(r.mul(A,w),r.mul(v,b)),g=r.eql(r.mul(m,w),r.mul(x,b));return B&&g}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:p,b:A}=e,m=r.mul(A,oc),{px:b,py:v,pz:x}=this,w=r.ZERO,B=r.ZERO,g=r.ZERO,d=r.mul(b,b),C=r.mul(v,v),k=r.mul(x,x),T=r.mul(b,v);return T=r.add(T,T),g=r.mul(b,x),g=r.add(g,g),w=r.mul(p,g),B=r.mul(m,k),B=r.add(w,B),w=r.sub(C,B),B=r.add(C,B),B=r.mul(w,B),w=r.mul(T,w),g=r.mul(m,g),k=r.mul(p,k),T=r.sub(d,k),T=r.mul(p,T),T=r.add(T,g),g=r.add(d,d),d=r.add(g,d),d=r.add(d,k),d=r.mul(d,T),B=r.add(B,d),k=r.mul(v,x),k=r.add(k,k),d=r.mul(k,T),w=r.sub(w,d),g=r.mul(k,C),g=r.add(g,g),g=r.add(g,g),new l(w,B,g)}add(p){f(p);let{px:A,py:m,pz:b}=this,{px:v,py:x,pz:w}=p,B=r.ZERO,g=r.ZERO,d=r.ZERO,C=e.a,k=r.mul(e.b,oc),T=r.mul(A,v),D=r.mul(m,x),S=r.mul(b,w),I=r.add(A,m),L=r.add(v,x);I=r.mul(I,L),L=r.add(T,D),I=r.sub(I,L),L=r.add(A,b);let $=r.add(v,w);return L=r.mul(L,$),$=r.add(T,S),L=r.sub(L,$),$=r.add(m,b),B=r.add(x,w),$=r.mul($,B),B=r.add(D,S),$=r.sub($,B),d=r.mul(C,L),B=r.mul(k,S),d=r.add(B,d),B=r.sub(D,d),d=r.add(D,d),g=r.mul(B,d),D=r.add(T,T),D=r.add(D,T),S=r.mul(C,S),L=r.mul(k,L),D=r.add(D,S),S=r.sub(T,S),S=r.mul(C,S),L=r.add(L,S),T=r.mul(D,L),g=r.add(g,T),T=r.mul($,L),B=r.mul(I,B),B=r.sub(B,T),T=r.mul(I,D),d=r.mul($,d),d=r.add(d,T),new l(B,g,d)}subtract(p){return this.add(p.negate())}is0(){return this.equals(l.ZERO)}wNAF(p){return N.wNAFCached(this,p,l.normalizeZ)}multiplyUnsafe(p){let{endo:A,n:m}=e;ze("scalar",p,fe,m);let b=l.ZERO;if(p===fe)return b;if(this.is0()||p===mt)return this;if(!A||N.hasPrecomputes(this))return N.wNAFCachedUnsafe(this,p,l.normalizeZ);let{k1neg:v,k1:x,k2neg:w,k2:B}=A.splitScalar(p),g=b,d=b,C=this;for(;x>fe||B>fe;)x&mt&&(g=g.add(C)),B&mt&&(d=d.add(C)),C=C.double(),x>>=mt,B>>=mt;return v&&(g=g.negate()),w&&(d=d.negate()),d=new l(r.mul(d.px,A.beta),d.py,d.pz),g.add(d)}multiply(p){let{endo:A,n:m}=e;ze("scalar",p,mt,m);let b,v;if(A){let{k1neg:x,k1:w,k2neg:B,k2:g}=A.splitScalar(p),{p:d,f:C}=this.wNAF(w),{p:k,f:T}=this.wNAF(g);d=N.constTimeNegate(x,d),k=N.constTimeNegate(B,k),k=new l(r.mul(k.px,A.beta),k.py,k.pz),b=d.add(k),v=C.add(T)}else{let{p:x,f:w}=this.wNAF(p);b=x,v=w}return l.normalizeZ([b,v])[0]}multiplyAndAddUnsafe(p,A,m){let b=l.BASE,v=(w,B)=>B===fe||B===mt||!w.equals(b)?w.multiplyUnsafe(B):w.multiply(B),x=v(this,A).add(v(p,m));return x.is0()?void 0:x}toAffine(p){return h(this,p)}isTorsionFree(){let{h:p,isTorsionFree:A}=e;if(p===mt)return!0;if(A)return A(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:p,clearCofactor:A}=e;return p===mt?this:A?A(l,this):this.multiplyUnsafe(e.h)}toRawBytes(p=!0){return hr("isCompressed",p),this.assertValidity(),o(l,this,p)}toHex(p=!0){return hr("isCompressed",p),pr(this.toRawBytes(p))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let y=e.nBitLength,N=ec(l,e.endo?Math.ceil(y/2):y);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function gl(t){let e=_i(t);return Ye(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ic(t){let e=gl(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return bt(S,n)}function a(S){return Vn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:u}=pl({...e,toBytes(S,I,L){let $=I.toAffine(),M=r.toBytes($.x),W=Dr;return hr("isCompressed",L),L?W(Uint8Array.from([I.hasEvenY()?2:3]),M):W(Uint8Array.from([4]),M,r.toBytes($.y))},fromBytes(S){let I=S.length,L=S[0],$=S.subarray(1);if(I===o&&(L===2||L===3)){let M=ae($);if(!Wn(M,mt,r.ORDER))throw new Error("Point is not on curve");let W=h(M),j;try{j=r.sqrt(W)}catch(X){let F=X instanceof Error?": "+X.message:"";throw new Error("Point is not on curve"+F)}let Y=(j&mt)===mt;return(L&1)===1!==Y&&(j=r.neg(j)),{x:M,y:j}}else if(I===i&&L===4){let M=r.fromBytes($.subarray(0,r.BYTES)),W=r.fromBytes($.subarray(r.BYTES,2*r.BYTES));return{x:M,y:W}}else{let M=o,W=i;throw new Error("invalid Point, expected length of "+M+", or uncompressed "+W+", got "+I)}}}),l=S=>pr(Ve(S,e.nByteLength));function y(S){let I=n>>mt;return S>I}function N(S){return y(S)?s(-S):S}let E=(S,I,L)=>ae(S.slice(I,L));class p{constructor(I,L,$){ze("r",I,mt,n),ze("s",L,mt,n),this.r=I,this.s=L,$!=null&&(this.recovery=$),Object.freeze(this)}static fromCompact(I){let L=e.nByteLength;return I=Nt("compactSignature",I,L*2),new p(E(I,0,L),E(I,L,2*L))}static fromDER(I){let{r:L,s:$}=ce.toSig(Nt("DER",I));return new p(L,$)}assertValidity(){}addRecoveryBit(I){return new p(this.r,this.s,I)}recoverPublicKey(I){let{r:L,s:$,recovery:M}=this,W=w(Nt("msgHash",I));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");let j=M===2||M===3?L+e.n:L;if(j>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let Y=M&1?"03":"02",it=c.fromHex(Y+l(j)),X=a(j),F=s(-W*X),P=s($*X),_=c.BASE.multiplyAndAddUnsafe(it,F,P);if(!_)throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Mr(this.toDERHex())}toDERHex(){return ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Mr(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}let A={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Ti(e.n);return Fa(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function m(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function b(S){let I=We(S),L=typeof S=="string",$=(I||L)&&S.length;return I?$===o||$===i:L?$===2*o||$===2*i:S instanceof c}function v(S,I,L=!0){if(b(S))throw new Error("first arg must be private key");if(!b(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(L)}let x=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let I=ae(S),L=S.length*8-e.nBitLength;return L>0?I>>BigInt(L):I},w=e.bits2int_modN||function(S){return s(x(S))},B=je(e.nBitLength);function g(S){return ze("num < 2^"+e.nBitLength,S,fe,B),Ve(S,e.nByteLength)}function d(S,I,L=C){if(["recovered","canonical"].some(R=>R in L))throw new Error("sign() legacy options not supported");let{hash:$,randomBytes:M}=e,{lowS:W,prehash:j,extraEntropy:Y}=L;W==null&&(W=!0),S=Nt("msgHash",S),nc(L),j&&(S=Nt("prehashed msgHash",$(S)));let it=w(S),X=f(I),F=[g(X),g(it)];if(Y!=null&&Y!==!1){let R=Y===!0?M(r.BYTES):Y;F.push(Nt("extraEntropy",R))}let P=Dr(...F),_=it;function U(R){let H=x(R);if(!u(H))return;let O=a(H),q=c.BASE.multiply(H).toAffine(),K=s(q.x);if(K===fe)return;let G=s(O*s(_+K*X));if(G===fe)return;let Z=(q.x===K?0:2)|Number(q.y&mt),V=G;return W&&y(G)&&(V=N(G),Z^=1),new p(K,V,Z)}return{seed:P,k2sig:U}}let C={lowS:e.lowS,prehash:!1},k={lowS:e.lowS,prehash:!1};function T(S,I,L=C){let{seed:$,k2sig:M}=d(S,I,L),W=e;return ja(W.hash.outputLen,W.nByteLength,W.hmac)($,M)}c.BASE._setWindowSize(8);function D(S,I,L,$=k){let M=S;I=Nt("msgHash",I),L=Nt("publicKey",L);let{lowS:W,prehash:j,format:Y}=$;if(nc($),"strict"in $)throw new Error("options.strict was renamed to lowS");if(Y!==void 0&&Y!=="compact"&&Y!=="der")throw new Error("format must be compact or der");let it=typeof M=="string"||We(M),X=!it&&!Y&&typeof M=="object"&&M!==null&&typeof M.r=="bigint"&&typeof M.s=="bigint";if(!it&&!X)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,P;try{if(X&&(F=new p(M.r,M.s)),it){try{Y!=="compact"&&(F=p.fromDER(M))}catch(Z){if(!(Z instanceof ce.Err))throw Z}!F&&Y!=="der"&&(F=p.fromCompact(M))}P=c.fromHex(L)}catch{return!1}if(!F||W&&F.hasHighS())return!1;j&&(I=e.hash(I));let{r:_,s:U}=F,R=w(I),H=a(U),O=s(R*H),q=s(_*H),K=c.BASE.multiplyAndAddUnsafe(P,O,q)?.toAffine();return K?s(K.x)===_:!1}return{CURVE:e,getPublicKey:m,getSharedSecret:v,sign:T,verify:D,ProjectivePoint:c,Signature:p,utils:A}}function wl(t){return{hash:t,hmac:(e,...r)=>Se(t,e,qe(...r)),randomBytes:Mn}}function sc(t,e){let r=n=>ic({...t,...wl(n)});return{...r(e),create:r}}var fc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ac=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),yl=BigInt(1),Ri=BigInt(2),cc=(t,e)=>(t+e/Ri)/e;function bl(t){let e=fc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,h=f*f*t%e,u=Ct(h,r,e)*h%e,l=Ct(u,r,e)*h%e,y=Ct(l,Ri,e)*f%e,N=Ct(y,o,e)*y%e,E=Ct(N,i,e)*N%e,p=Ct(E,a,e)*E%e,A=Ct(p,c,e)*p%e,m=Ct(A,a,e)*E%e,b=Ct(m,r,e)*h%e,v=Ct(b,s,e)*N%e,x=Ct(v,n,e)*f%e,w=Ct(x,Ri,e);if(!Hi.eql(Hi.sqr(w),t))throw new Error("Cannot find square root");return w}var Hi=zn(fc,void 0,void 0,{sqrt:bl}),qt=sc({a:BigInt(0),b:BigInt(7),Fp:Hi,n:ac,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=ac,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-yl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=cc(i*t,e),c=cc(-n*t,e),f=bt(t-a*r-c*o,e),h=bt(-a*n-c*i,e),u=f>s,l=h>s;if(u&&(f=e-f),l&&(h=e-h),f>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:f,k2neg:l,k2:h}}}},Ie),Bp=BigInt(0);var Sp=qt.ProjectivePoint;var jn=qt.ProjectivePoint,$i=Tn(Ie);function uc(t){At(t);let e=t.length===0?"0":Na(t);return BigInt("0x"+e)}function ml(t){if(typeof t!="bigint")throw new Error("bigint expected");return Ca(t.toString(16).padStart(64,"0"))}var xl=fi("Bitcoin seed"),Oi={private:76066276,public:76067358},Mi=2147483648,El=t=>Ma(Ie(t)),vl=t=>Yt(t).getUint32(0,!1),Yn=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error("invalid number, should be from 0 to 2**32-1, got "+t);let e=new Uint8Array(4);return Yt(e).setUint32(0,t,!1),e},Gn=class t{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return vl(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){let e=this.privateKey;if(!e)throw new Error("No private key");return $i.encode(this.serialize(this.versions.private,qe(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return $i.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,r=Oi){if(At(e),8*e.length<128||8*e.length>512)throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got "+e.length);let n=Se($r,xl,e);return new t({versions:r,chainCode:n.slice(32),privateKey:n.slice(0,32)})}static fromExtendedKey(e,r=Oi){let n=$i.decode(e),o=Yt(n),i=o.getUint32(0,!1),s={versions:r,depth:n[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:n.slice(13,45)},a=n.slice(45),c=a[0]===0;if(i!==r[c?"private":"public"])throw new Error("Version mismatch");return c?new t({...s,privateKey:a.slice(1)}):new t({...s,publicKey:a})}static fromJSON(e){return t.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||Oi,this.depth=e.depth||0,this.chainCode=e.chainCode||null,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!qt.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey=typeof e.privateKey=="bigint"?e.privateKey:uc(e.privateKey),this.privKeyBytes=ml(this.privKey),this.pubKey=qt.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this.pubKey=jn.fromHex(e.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=El(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;let r=e.replace(/^[mM]'?\//,"").split("/"),n=this;for(let o of r){let i=/^(\d+)('?)$/.exec(o),s=i&&i[1];if(!i||i.length!==3||typeof s!="string")throw new Error("invalid child index: "+o);let a=+s;if(!Number.isSafeInteger(a)||a>=Mi)throw new Error("Invalid index");i[2]==="'"&&(a+=Mi),n=n.deriveChild(a)}return n}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let r=Yn(e);if(e>=Mi){let a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");r=qe(new Uint8Array([0]),a,r)}else r=qe(this.pubKey,r);let n=Se($r,this.chainCode,r),o=uc(n.slice(0,32)),i=n.slice(32);if(!qt.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");let s={versions:this.versions,chainCode:i,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){let a=bt(this.privKey+o,qt.CURVE.n);if(!qt.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");s.privateKey=a}else{let a=jn.fromHex(this.pubKey).add(jn.fromPrivateKey(o));if(a.equals(jn.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=a.toRawBytes(!0)}return new t(s)}catch{return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return At(e,32),qt.sign(e,this.privKey).toCompactRawBytes()}verify(e,r){if(At(e,32),At(r,64),!this.publicKey)throw new Error("No publicKey set!");let n;try{n=qt.Signature.fromCompact(r)}catch{return!1}return qt.verify(n,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,r){if(!this.chainCode)throw new Error("No chainCode set");return At(r,33),qe(Yn(e),new Uint8Array([this.depth]),Yn(this.parentFingerprint),Yn(this.index),this.chainCode,r)}};function Bl(t,e,r,n){On(t);let o=_a({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(ve(i),ve(s),ve(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Be(e),f=Be(r),h=new Uint8Array(s),u=Se.create(t,c),l=u._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:h,PRF:u,PRFSalt:l}}function Sl(t,e,r,n,o){return t.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),r}function lc(t,e,r,n){let{c:o,dkLen:i,DK:s,PRF:a,PRFSalt:c}=Bl(t,e,r,n),f,h=new Uint8Array(4),u=Yt(h),l=new Uint8Array(a.outputLen);for(let y=1,N=0;N<i;y++,N+=a.outputLen){let E=s.subarray(N,N+a.outputLen);u.setInt32(0,y,!1),(f=c._cloneInto(f)).update(h).digestInto(l),E.set(l.subarray(0,E.length));for(let p=1;p<o;p++){a._cloneInto(f).update(l).digestInto(l);for(let A=0;A<E.length;A++)E[A]^=l[A]}}return Sl(a,c,s,f,l)}var Al=t=>t[0]==="\u3042\u3044\u3053\u304F\u3057\u3093";function dc(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function hc(t){let e=dc(t),r=e.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:r}}function pc(t){At(t,16,20,24,28,32)}function gc(t,e=128){if(ve(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Il(Mn(e/8),t)}var kl=t=>{let e=8-t.length/4;return new Uint8Array([Ie(t)[0]>>e<<e])};function wc(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(e=>{if(typeof e!="string")throw new Error("wordlist: non-string element: "+e)}),Ir.chain(Ir.checksum(1,kl),Ir.radix2(11,!0),Ir.alphabet(t))}function Tl(t,e){let{words:r}=hc(t),n=wc(e).decode(r);return pc(n),n}function Il(t,e){return pc(t),wc(e).encode(t).join(Al(e)?"\u3000":" ")}function yc(t,e){try{Tl(t,e)}catch{return!1}return!0}var Ul=t=>dc("mnemonic"+t);function bc(t,e=""){return lc($r,hc(t).nfkd,Ul(e),{c:2048,dkLen:64})}var Di=`abandon |
| 4 | ability |
| 5 | able |
| 6 | about |
| 7 | above |
| 8 | absent |
| 9 | absorb |
| 10 | abstract |
| 11 | absurd |
| 12 | abuse |
| 13 | access |
| 14 | accident |
| 15 | account |
| 16 | accuse |
| 17 | achieve |
| 18 | acid |
| 19 | acoustic |
| 20 | acquire |
| 21 | across |
| 22 | act |
| 23 | action |
| 24 | actor |
| 25 | actress |
| 26 | actual |
| 27 | adapt |
| 28 | add |
| 29 | addict |
| 30 | address |
| 31 | adjust |
| 32 | admit |
| 33 | adult |
| 34 | advance |
| 35 | advice |
| 36 | aerobic |
| 37 | affair |
| 38 | afford |
| 39 | afraid |
| 40 | again |
| 41 | age |
| 42 | agent |
| 43 | agree |
| 44 | ahead |
| 45 | aim |
| 46 | air |
| 47 | airport |
| 48 | aisle |
| 49 | alarm |
| 50 | album |
| 51 | alcohol |
| 52 | alert |
| 53 | alien |
| 54 | all |
| 55 | alley |
| 56 | allow |
| 57 | almost |
| 58 | alone |
| 59 | alpha |
| 60 | already |
| 61 | also |
| 62 | alter |
| 63 | always |
| 64 | amateur |
| 65 | amazing |
| 66 | among |
| 67 | amount |
| 68 | amused |
| 69 | analyst |
| 70 | anchor |
| 71 | ancient |
| 72 | anger |
| 73 | angle |
| 74 | angry |
| 75 | animal |
| 76 | ankle |
| 77 | announce |
| 78 | annual |
| 79 | another |
| 80 | answer |
| 81 | antenna |
| 82 | antique |
| 83 | anxiety |
| 84 | any |
| 85 | apart |
| 86 | apology |
| 87 | appear |
| 88 | apple |
| 89 | approve |
| 90 | april |
| 91 | arch |
| 92 | arctic |
| 93 | area |
| 94 | arena |
| 95 | argue |
| 96 | arm |
| 97 | armed |
| 98 | armor |
| 99 | army |
| 100 | around |
| 101 | arrange |
| 102 | arrest |
| 103 | arrive |
| 104 | arrow |
| 105 | art |
| 106 | artefact |
| 107 | artist |
| 108 | artwork |
| 109 | ask |
| 110 | aspect |
| 111 | assault |
| 112 | asset |
| 113 | assist |
| 114 | assume |
| 115 | asthma |
| 116 | athlete |
| 117 | atom |
| 118 | attack |
| 119 | attend |
| 120 | attitude |
| 121 | attract |
| 122 | auction |
| 123 | audit |
| 124 | august |
| 125 | aunt |
| 126 | author |
| 127 | auto |
| 128 | autumn |
| 129 | average |
| 130 | avocado |
| 131 | avoid |
| 132 | awake |
| 133 | aware |
| 134 | away |
| 135 | awesome |
| 136 | awful |
| 137 | awkward |
| 138 | axis |
| 139 | baby |
| 140 | bachelor |
| 141 | bacon |
| 142 | badge |
| 143 | bag |
| 144 | balance |
| 145 | balcony |
| 146 | ball |
| 147 | bamboo |
| 148 | banana |
| 149 | banner |
| 150 | bar |
| 151 | barely |
| 152 | bargain |
| 153 | barrel |
| 154 | base |
| 155 | basic |
| 156 | basket |
| 157 | battle |
| 158 | beach |
| 159 | bean |
| 160 | beauty |
| 161 | because |
| 162 | become |
| 163 | beef |
| 164 | before |
| 165 | begin |
| 166 | behave |
| 167 | behind |
| 168 | believe |
| 169 | below |
| 170 | belt |
| 171 | bench |
| 172 | benefit |
| 173 | best |
| 174 | betray |
| 175 | better |
| 176 | between |
| 177 | beyond |
| 178 | bicycle |
| 179 | bid |
| 180 | bike |
| 181 | bind |
| 182 | biology |
| 183 | bird |
| 184 | birth |
| 185 | bitter |
| 186 | black |
| 187 | blade |
| 188 | blame |
| 189 | blanket |
| 190 | blast |
| 191 | bleak |
| 192 | bless |
| 193 | blind |
| 194 | blood |
| 195 | blossom |
| 196 | blouse |
| 197 | blue |
| 198 | blur |
| 199 | blush |
| 200 | board |
| 201 | boat |
| 202 | body |
| 203 | boil |
| 204 | bomb |
| 205 | bone |
| 206 | bonus |
| 207 | book |
| 208 | boost |
| 209 | border |
| 210 | boring |
| 211 | borrow |
| 212 | boss |
| 213 | bottom |
| 214 | bounce |
| 215 | box |
| 216 | boy |
| 217 | bracket |
| 218 | brain |
| 219 | brand |
| 220 | brass |
| 221 | brave |
| 222 | bread |
| 223 | breeze |
| 224 | brick |
| 225 | bridge |
| 226 | brief |
| 227 | bright |
| 228 | bring |
| 229 | brisk |
| 230 | broccoli |
| 231 | broken |
| 232 | bronze |
| 233 | broom |
| 234 | brother |
| 235 | brown |
| 236 | brush |
| 237 | bubble |
| 238 | buddy |
| 239 | budget |
| 240 | buffalo |
| 241 | build |
| 242 | bulb |
| 243 | bulk |
| 244 | bullet |
| 245 | bundle |
| 246 | bunker |
| 247 | burden |
| 248 | burger |
| 249 | burst |
| 250 | bus |
| 251 | business |
| 252 | busy |
| 253 | butter |
| 254 | buyer |
| 255 | buzz |
| 256 | cabbage |
| 257 | cabin |
| 258 | cable |
| 259 | cactus |
| 260 | cage |
| 261 | cake |
| 262 | call |
| 263 | calm |
| 264 | camera |
| 265 | camp |
| 266 | can |
| 267 | canal |
| 268 | cancel |
| 269 | candy |
| 270 | cannon |
| 271 | canoe |
| 272 | canvas |
| 273 | canyon |
| 274 | capable |
| 275 | capital |
| 276 | captain |
| 277 | car |
| 278 | carbon |
| 279 | card |
| 280 | cargo |
| 281 | carpet |
| 282 | carry |
| 283 | cart |
| 284 | case |
| 285 | cash |
| 286 | casino |
| 287 | castle |
| 288 | casual |
| 289 | cat |
| 290 | catalog |
| 291 | catch |
| 292 | category |
| 293 | cattle |
| 294 | caught |
| 295 | cause |
| 296 | caution |
| 297 | cave |
| 298 | ceiling |
| 299 | celery |
| 300 | cement |
| 301 | census |
| 302 | century |
| 303 | cereal |
| 304 | certain |
| 305 | chair |
| 306 | chalk |
| 307 | champion |
| 308 | change |
| 309 | chaos |
| 310 | chapter |
| 311 | charge |
| 312 | chase |
| 313 | chat |
| 314 | cheap |
| 315 | check |
| 316 | cheese |
| 317 | chef |
| 318 | cherry |
| 319 | chest |
| 320 | chicken |
| 321 | chief |
| 322 | child |
| 323 | chimney |
| 324 | choice |
| 325 | choose |
| 326 | chronic |
| 327 | chuckle |
| 328 | chunk |
| 329 | churn |
| 330 | cigar |
| 331 | cinnamon |
| 332 | circle |
| 333 | citizen |
| 334 | city |
| 335 | civil |
| 336 | claim |
| 337 | clap |
| 338 | clarify |
| 339 | claw |
| 340 | clay |
| 341 | clean |
| 342 | clerk |
| 343 | clever |
| 344 | click |
| 345 | client |
| 346 | cliff |
| 347 | climb |
| 348 | clinic |
| 349 | clip |
| 350 | clock |
| 351 | clog |
| 352 | close |
| 353 | cloth |
| 354 | cloud |
| 355 | clown |
| 356 | club |
| 357 | clump |
| 358 | cluster |
| 359 | clutch |
| 360 | coach |
| 361 | coast |
| 362 | coconut |
| 363 | code |
| 364 | coffee |
| 365 | coil |
| 366 | coin |
| 367 | collect |
| 368 | color |
| 369 | column |
| 370 | combine |
| 371 | come |
| 372 | comfort |
| 373 | comic |
| 374 | common |
| 375 | company |
| 376 | concert |
| 377 | conduct |
| 378 | confirm |
| 379 | congress |
| 380 | connect |
| 381 | consider |
| 382 | control |
| 383 | convince |
| 384 | cook |
| 385 | cool |
| 386 | copper |
| 387 | copy |
| 388 | coral |
| 389 | core |
| 390 | corn |
| 391 | correct |
| 392 | cost |
| 393 | cotton |
| 394 | couch |
| 395 | country |
| 396 | couple |
| 397 | course |
| 398 | cousin |
| 399 | cover |
| 400 | coyote |
| 401 | crack |
| 402 | cradle |
| 403 | craft |
| 404 | cram |
| 405 | crane |
| 406 | crash |
| 407 | crater |
| 408 | crawl |
| 409 | crazy |
| 410 | cream |
| 411 | credit |
| 412 | creek |
| 413 | crew |
| 414 | cricket |
| 415 | crime |
| 416 | crisp |
| 417 | critic |
| 418 | crop |
| 419 | cross |
| 420 | crouch |
| 421 | crowd |
| 422 | crucial |
| 423 | cruel |
| 424 | cruise |
| 425 | crumble |
| 426 | crunch |
| 427 | crush |
| 428 | cry |
| 429 | crystal |
| 430 | cube |
| 431 | culture |
| 432 | cup |
| 433 | cupboard |
| 434 | curious |
| 435 | current |
| 436 | curtain |
| 437 | curve |
| 438 | cushion |
| 439 | custom |
| 440 | cute |
| 441 | cycle |
| 442 | dad |
| 443 | damage |
| 444 | damp |
| 445 | dance |
| 446 | danger |
| 447 | daring |
| 448 | dash |
| 449 | daughter |
| 450 | dawn |
| 451 | day |
| 452 | deal |
| 453 | debate |
| 454 | debris |
| 455 | decade |
| 456 | december |
| 457 | decide |
| 458 | decline |
| 459 | decorate |
| 460 | decrease |
| 461 | deer |
| 462 | defense |
| 463 | define |
| 464 | defy |
| 465 | degree |
| 466 | delay |
| 467 | deliver |
| 468 | demand |
| 469 | demise |
| 470 | denial |
| 471 | dentist |
| 472 | deny |
| 473 | depart |
| 474 | depend |
| 475 | deposit |
| 476 | depth |
| 477 | deputy |
| 478 | derive |
| 479 | describe |
| 480 | desert |
| 481 | design |
| 482 | desk |
| 483 | despair |
| 484 | destroy |
| 485 | detail |
| 486 | detect |
| 487 | develop |
| 488 | device |
| 489 | devote |
| 490 | diagram |
| 491 | dial |
| 492 | diamond |
| 493 | diary |
| 494 | dice |
| 495 | diesel |
| 496 | diet |
| 497 | differ |
| 498 | digital |
| 499 | dignity |
| 500 | dilemma |
| 501 | dinner |
| 502 | dinosaur |
| 503 | direct |
| 504 | dirt |
| 505 | disagree |
| 506 | discover |
| 507 | disease |
| 508 | dish |
| 509 | dismiss |
| 510 | disorder |
| 511 | display |
| 512 | distance |
| 513 | divert |
| 514 | divide |
| 515 | divorce |
| 516 | dizzy |
| 517 | doctor |
| 518 | document |
| 519 | dog |
| 520 | doll |
| 521 | dolphin |
| 522 | domain |
| 523 | donate |
| 524 | donkey |
| 525 | donor |
| 526 | door |
| 527 | dose |
| 528 | double |
| 529 | dove |
| 530 | draft |
| 531 | dragon |
| 532 | drama |
| 533 | drastic |
| 534 | draw |
| 535 | dream |
| 536 | dress |
| 537 | drift |
| 538 | drill |
| 539 | drink |
| 540 | drip |
| 541 | drive |
| 542 | drop |
| 543 | drum |
| 544 | dry |
| 545 | duck |
| 546 | dumb |
| 547 | dune |
| 548 | during |
| 549 | dust |
| 550 | dutch |
| 551 | duty |
| 552 | dwarf |
| 553 | dynamic |
| 554 | eager |
| 555 | eagle |
| 556 | early |
| 557 | earn |
| 558 | earth |
| 559 | easily |
| 560 | east |
| 561 | easy |
| 562 | echo |
| 563 | ecology |
| 564 | economy |
| 565 | edge |
| 566 | edit |
| 567 | educate |
| 568 | effort |
| 569 | egg |
| 570 | eight |
| 571 | either |
| 572 | elbow |
| 573 | elder |
| 574 | electric |
| 575 | elegant |
| 576 | element |
| 577 | elephant |
| 578 | elevator |
| 579 | elite |
| 580 | else |
| 581 | embark |
| 582 | embody |
| 583 | embrace |
| 584 | emerge |
| 585 | emotion |
| 586 | employ |
| 587 | empower |
| 588 | empty |
| 589 | enable |
| 590 | enact |
| 591 | end |
| 592 | endless |
| 593 | endorse |
| 594 | enemy |
| 595 | energy |
| 596 | enforce |
| 597 | engage |
| 598 | engine |
| 599 | enhance |
| 600 | enjoy |
| 601 | enlist |
| 602 | enough |
| 603 | enrich |
| 604 | enroll |
| 605 | ensure |
| 606 | enter |
| 607 | entire |
| 608 | entry |
| 609 | envelope |
| 610 | episode |
| 611 | equal |
| 612 | equip |
| 613 | era |
| 614 | erase |
| 615 | erode |
| 616 | erosion |
| 617 | error |
| 618 | erupt |
| 619 | escape |
| 620 | essay |
| 621 | essence |
| 622 | estate |
| 623 | eternal |
| 624 | ethics |
| 625 | evidence |
| 626 | evil |
| 627 | evoke |
| 628 | evolve |
| 629 | exact |
| 630 | example |
| 631 | excess |
| 632 | exchange |
| 633 | excite |
| 634 | exclude |
| 635 | excuse |
| 636 | execute |
| 637 | exercise |
| 638 | exhaust |
| 639 | exhibit |
| 640 | exile |
| 641 | exist |
| 642 | exit |
| 643 | exotic |
| 644 | expand |
| 645 | expect |
| 646 | expire |
| 647 | explain |
| 648 | expose |
| 649 | express |
| 650 | extend |
| 651 | extra |
| 652 | eye |
| 653 | eyebrow |
| 654 | fabric |
| 655 | face |
| 656 | faculty |
| 657 | fade |
| 658 | faint |
| 659 | faith |
| 660 | fall |
| 661 | false |
| 662 | fame |
| 663 | family |
| 664 | famous |
| 665 | fan |
| 666 | fancy |
| 667 | fantasy |
| 668 | farm |
| 669 | fashion |
| 670 | fat |
| 671 | fatal |
| 672 | father |
| 673 | fatigue |
| 674 | fault |
| 675 | favorite |
| 676 | feature |
| 677 | february |
| 678 | federal |
| 679 | fee |
| 680 | feed |
| 681 | feel |
| 682 | female |
| 683 | fence |
| 684 | festival |
| 685 | fetch |
| 686 | fever |
| 687 | few |
| 688 | fiber |
| 689 | fiction |
| 690 | field |
| 691 | figure |
| 692 | file |
| 693 | film |
| 694 | filter |
| 695 | final |
| 696 | find |
| 697 | fine |
| 698 | finger |
| 699 | finish |
| 700 | fire |
| 701 | firm |
| 702 | first |
| 703 | fiscal |
| 704 | fish |
| 705 | fit |
| 706 | fitness |
| 707 | fix |
| 708 | flag |
| 709 | flame |
| 710 | flash |
| 711 | flat |
| 712 | flavor |
| 713 | flee |
| 714 | flight |
| 715 | flip |
| 716 | float |
| 717 | flock |
| 718 | floor |
| 719 | flower |
| 720 | fluid |
| 721 | flush |
| 722 | fly |
| 723 | foam |
| 724 | focus |
| 725 | fog |
| 726 | foil |
| 727 | fold |
| 728 | follow |
| 729 | food |
| 730 | foot |
| 731 | force |
| 732 | forest |
| 733 | forget |
| 734 | fork |
| 735 | fortune |
| 736 | forum |
| 737 | forward |
| 738 | fossil |
| 739 | foster |
| 740 | found |
| 741 | fox |
| 742 | fragile |
| 743 | frame |
| 744 | frequent |
| 745 | fresh |
| 746 | friend |
| 747 | fringe |
| 748 | frog |
| 749 | front |
| 750 | frost |
| 751 | frown |
| 752 | frozen |
| 753 | fruit |
| 754 | fuel |
| 755 | fun |
| 756 | funny |
| 757 | furnace |
| 758 | fury |
| 759 | future |
| 760 | gadget |
| 761 | gain |
| 762 | galaxy |
| 763 | gallery |
| 764 | game |
| 765 | gap |
| 766 | garage |
| 767 | garbage |
| 768 | garden |
| 769 | garlic |
| 770 | garment |
| 771 | gas |
| 772 | gasp |
| 773 | gate |
| 774 | gather |
| 775 | gauge |
| 776 | gaze |
| 777 | general |
| 778 | genius |
| 779 | genre |
| 780 | gentle |
| 781 | genuine |
| 782 | gesture |
| 783 | ghost |
| 784 | giant |
| 785 | gift |
| 786 | giggle |
| 787 | ginger |
| 788 | giraffe |
| 789 | girl |
| 790 | give |
| 791 | glad |
| 792 | glance |
| 793 | glare |
| 794 | glass |
| 795 | glide |
| 796 | glimpse |
| 797 | globe |
| 798 | gloom |
| 799 | glory |
| 800 | glove |
| 801 | glow |
| 802 | glue |
| 803 | goat |
| 804 | goddess |
| 805 | gold |
| 806 | good |
| 807 | goose |
| 808 | gorilla |
| 809 | gospel |
| 810 | gossip |
| 811 | govern |
| 812 | gown |
| 813 | grab |
| 814 | grace |
| 815 | grain |
| 816 | grant |
| 817 | grape |
| 818 | grass |
| 819 | gravity |
| 820 | great |
| 821 | green |
| 822 | grid |
| 823 | grief |
| 824 | grit |
| 825 | grocery |
| 826 | group |
| 827 | grow |
| 828 | grunt |
| 829 | guard |
| 830 | guess |
| 831 | guide |
| 832 | guilt |
| 833 | guitar |
| 834 | gun |
| 835 | gym |
| 836 | habit |
| 837 | hair |
| 838 | half |
| 839 | hammer |
| 840 | hamster |
| 841 | hand |
| 842 | happy |
| 843 | harbor |
| 844 | hard |
| 845 | harsh |
| 846 | harvest |
| 847 | hat |
| 848 | have |
| 849 | hawk |
| 850 | hazard |
| 851 | head |
| 852 | health |
| 853 | heart |
| 854 | heavy |
| 855 | hedgehog |
| 856 | height |
| 857 | hello |
| 858 | helmet |
| 859 | help |
| 860 | hen |
| 861 | hero |
| 862 | hidden |
| 863 | high |
| 864 | hill |
| 865 | hint |
| 866 | hip |
| 867 | hire |
| 868 | history |
| 869 | hobby |
| 870 | hockey |
| 871 | hold |
| 872 | hole |
| 873 | holiday |
| 874 | hollow |
| 875 | home |
| 876 | honey |
| 877 | hood |
| 878 | hope |
| 879 | horn |
| 880 | horror |
| 881 | horse |
| 882 | hospital |
| 883 | host |
| 884 | hotel |
| 885 | hour |
| 886 | hover |
| 887 | hub |
| 888 | huge |
| 889 | human |
| 890 | humble |
| 891 | humor |
| 892 | hundred |
| 893 | hungry |
| 894 | hunt |
| 895 | hurdle |
| 896 | hurry |
| 897 | hurt |
| 898 | husband |
| 899 | hybrid |
| 900 | ice |
| 901 | icon |
| 902 | idea |
| 903 | identify |
| 904 | idle |
| 905 | ignore |
| 906 | ill |
| 907 | illegal |
| 908 | illness |
| 909 | image |
| 910 | imitate |
| 911 | immense |
| 912 | immune |
| 913 | impact |
| 914 | impose |
| 915 | improve |
| 916 | impulse |
| 917 | inch |
| 918 | include |
| 919 | income |
| 920 | increase |
| 921 | index |
| 922 | indicate |
| 923 | indoor |
| 924 | industry |
| 925 | infant |
| 926 | inflict |
| 927 | inform |
| 928 | inhale |
| 929 | inherit |
| 930 | initial |
| 931 | inject |
| 932 | injury |
| 933 | inmate |
| 934 | inner |
| 935 | innocent |
| 936 | input |
| 937 | inquiry |
| 938 | insane |
| 939 | insect |
| 940 | inside |
| 941 | inspire |
| 942 | install |
| 943 | intact |
| 944 | interest |
| 945 | into |
| 946 | invest |
| 947 | invite |
| 948 | involve |
| 949 | iron |
| 950 | island |
| 951 | isolate |
| 952 | issue |
| 953 | item |
| 954 | ivory |
| 955 | jacket |
| 956 | jaguar |
| 957 | jar |
| 958 | jazz |
| 959 | jealous |
| 960 | jeans |
| 961 | jelly |
| 962 | jewel |
| 963 | job |
| 964 | join |
| 965 | joke |
| 966 | journey |
| 967 | joy |
| 968 | judge |
| 969 | juice |
| 970 | jump |
| 971 | jungle |
| 972 | junior |
| 973 | junk |
| 974 | just |
| 975 | kangaroo |
| 976 | keen |
| 977 | keep |
| 978 | ketchup |
| 979 | key |
| 980 | kick |
| 981 | kid |
| 982 | kidney |
| 983 | kind |
| 984 | kingdom |
| 985 | kiss |
| 986 | kit |
| 987 | kitchen |
| 988 | kite |
| 989 | kitten |
| 990 | kiwi |
| 991 | knee |
| 992 | knife |
| 993 | knock |
| 994 | know |
| 995 | lab |
| 996 | label |
| 997 | labor |
| 998 | ladder |
| 999 | lady |
| 1000 | lake |
| 1001 | lamp |
| 1002 | language |
| 1003 | laptop |
| 1004 | large |
| 1005 | later |
| 1006 | latin |
| 1007 | laugh |
| 1008 | laundry |
| 1009 | lava |
| 1010 | law |
| 1011 | lawn |
| 1012 | lawsuit |
| 1013 | layer |
| 1014 | lazy |
| 1015 | leader |
| 1016 | leaf |
| 1017 | learn |
| 1018 | leave |
| 1019 | lecture |
| 1020 | left |
| 1021 | leg |
| 1022 | legal |
| 1023 | legend |
| 1024 | leisure |
| 1025 | lemon |
| 1026 | lend |
| 1027 | length |
| 1028 | lens |
| 1029 | leopard |
| 1030 | lesson |
| 1031 | letter |
| 1032 | level |
| 1033 | liar |
| 1034 | liberty |
| 1035 | library |
| 1036 | license |
| 1037 | life |
| 1038 | lift |
| 1039 | light |
| 1040 | like |
| 1041 | limb |
| 1042 | limit |
| 1043 | link |
| 1044 | lion |
| 1045 | liquid |
| 1046 | list |
| 1047 | little |
| 1048 | live |
| 1049 | lizard |
| 1050 | load |
| 1051 | loan |
| 1052 | lobster |
| 1053 | local |
| 1054 | lock |
| 1055 | logic |
| 1056 | lonely |
| 1057 | long |
| 1058 | loop |
| 1059 | lottery |
| 1060 | loud |
| 1061 | lounge |
| 1062 | love |
| 1063 | loyal |
| 1064 | lucky |
| 1065 | luggage |
| 1066 | lumber |
| 1067 | lunar |
| 1068 | lunch |
| 1069 | luxury |
| 1070 | lyrics |
| 1071 | machine |
| 1072 | mad |
| 1073 | magic |
| 1074 | magnet |
| 1075 | maid |
| 1076 | |
| 1077 | main |
| 1078 | major |
| 1079 | make |
| 1080 | mammal |
| 1081 | man |
| 1082 | manage |
| 1083 | mandate |
| 1084 | mango |
| 1085 | mansion |
| 1086 | manual |
| 1087 | maple |
| 1088 | marble |
| 1089 | march |
| 1090 | margin |
| 1091 | marine |
| 1092 | market |
| 1093 | marriage |
| 1094 | mask |
| 1095 | mass |
| 1096 | master |
| 1097 | match |
| 1098 | material |
| 1099 | math |
| 1100 | matrix |
| 1101 | matter |
| 1102 | maximum |
| 1103 | maze |
| 1104 | meadow |
| 1105 | mean |
| 1106 | measure |
| 1107 | meat |
| 1108 | mechanic |
| 1109 | medal |
| 1110 | media |
| 1111 | melody |
| 1112 | melt |
| 1113 | member |
| 1114 | memory |
| 1115 | mention |
| 1116 | menu |
| 1117 | mercy |
| 1118 | merge |
| 1119 | merit |
| 1120 | merry |
| 1121 | mesh |
| 1122 | message |
| 1123 | metal |
| 1124 | method |
| 1125 | middle |
| 1126 | midnight |
| 1127 | milk |
| 1128 | million |
| 1129 | mimic |
| 1130 | mind |
| 1131 | minimum |
| 1132 | minor |
| 1133 | minute |
| 1134 | miracle |
| 1135 | mirror |
| 1136 | misery |
| 1137 | miss |
| 1138 | mistake |
| 1139 | mix |
| 1140 | mixed |
| 1141 | mixture |
| 1142 | mobile |
| 1143 | model |
| 1144 | modify |
| 1145 | mom |
| 1146 | moment |
| 1147 | monitor |
| 1148 | monkey |
| 1149 | monster |
| 1150 | month |
| 1151 | moon |
| 1152 | moral |
| 1153 | more |
| 1154 | morning |
| 1155 | mosquito |
| 1156 | mother |
| 1157 | motion |
| 1158 | motor |
| 1159 | mountain |
| 1160 | mouse |
| 1161 | move |
| 1162 | movie |
| 1163 | much |
| 1164 | muffin |
| 1165 | mule |
| 1166 | multiply |
| 1167 | muscle |
| 1168 | museum |
| 1169 | mushroom |
| 1170 | music |
| 1171 | must |
| 1172 | mutual |
| 1173 | myself |
| 1174 | mystery |
| 1175 | myth |
| 1176 | naive |
| 1177 | name |
| 1178 | napkin |
| 1179 | narrow |
| 1180 | nasty |
| 1181 | nation |
| 1182 | nature |
| 1183 | near |
| 1184 | neck |
| 1185 | need |
| 1186 | negative |
| 1187 | neglect |
| 1188 | neither |
| 1189 | nephew |
| 1190 | nerve |
| 1191 | nest |
| 1192 | net |
| 1193 | network |
| 1194 | neutral |
| 1195 | never |
| 1196 | news |
| 1197 | next |
| 1198 | nice |
| 1199 | night |
| 1200 | noble |
| 1201 | noise |
| 1202 | nominee |
| 1203 | noodle |
| 1204 | normal |
| 1205 | north |
| 1206 | nose |
| 1207 | notable |
| 1208 | note |
| 1209 | nothing |
| 1210 | notice |
| 1211 | novel |
| 1212 | now |
| 1213 | nuclear |
| 1214 | number |
| 1215 | nurse |
| 1216 | nut |
| 1217 | oak |
| 1218 | obey |
| 1219 | object |
| 1220 | oblige |
| 1221 | obscure |
| 1222 | observe |
| 1223 | obtain |
| 1224 | obvious |
| 1225 | occur |
| 1226 | ocean |
| 1227 | october |
| 1228 | odor |
| 1229 | off |
| 1230 | offer |
| 1231 | office |
| 1232 | often |
| 1233 | oil |
| 1234 | okay |
| 1235 | old |
| 1236 | olive |
| 1237 | olympic |
| 1238 | omit |
| 1239 | once |
| 1240 | one |
| 1241 | onion |
| 1242 | online |
| 1243 | only |
| 1244 | open |
| 1245 | opera |
| 1246 | opinion |
| 1247 | oppose |
| 1248 | option |
| 1249 | orange |
| 1250 | orbit |
| 1251 | orchard |
| 1252 | order |
| 1253 | ordinary |
| 1254 | organ |
| 1255 | orient |
| 1256 | original |
| 1257 | orphan |
| 1258 | ostrich |
| 1259 | other |
| 1260 | outdoor |
| 1261 | outer |
| 1262 | output |
| 1263 | outside |
| 1264 | oval |
| 1265 | oven |
| 1266 | over |
| 1267 | own |
| 1268 | owner |
| 1269 | oxygen |
| 1270 | oyster |
| 1271 | ozone |
| 1272 | pact |
| 1273 | paddle |
| 1274 | page |
| 1275 | pair |
| 1276 | palace |
| 1277 | palm |
| 1278 | panda |
| 1279 | panel |
| 1280 | panic |
| 1281 | panther |
| 1282 | paper |
| 1283 | parade |
| 1284 | parent |
| 1285 | park |
| 1286 | parrot |
| 1287 | party |
| 1288 | pass |
| 1289 | patch |
| 1290 | path |
| 1291 | patient |
| 1292 | patrol |
| 1293 | pattern |
| 1294 | pause |
| 1295 | pave |
| 1296 | payment |
| 1297 | peace |
| 1298 | peanut |
| 1299 | pear |
| 1300 | peasant |
| 1301 | pelican |
| 1302 | pen |
| 1303 | penalty |
| 1304 | pencil |
| 1305 | people |
| 1306 | pepper |
| 1307 | perfect |
| 1308 | permit |
| 1309 | person |
| 1310 | pet |
| 1311 | phone |
| 1312 | photo |
| 1313 | phrase |
| 1314 | physical |
| 1315 | piano |
| 1316 | picnic |
| 1317 | picture |
| 1318 | piece |
| 1319 | pig |
| 1320 | pigeon |
| 1321 | pill |
| 1322 | pilot |
| 1323 | pink |
| 1324 | pioneer |
| 1325 | pipe |
| 1326 | pistol |
| 1327 | pitch |
| 1328 | pizza |
| 1329 | place |
| 1330 | planet |
| 1331 | plastic |
| 1332 | plate |
| 1333 | play |
| 1334 | please |
| 1335 | pledge |
| 1336 | pluck |
| 1337 | plug |
| 1338 | plunge |
| 1339 | poem |
| 1340 | poet |
| 1341 | point |
| 1342 | polar |
| 1343 | pole |
| 1344 | police |
| 1345 | pond |
| 1346 | pony |
| 1347 | pool |
| 1348 | popular |
| 1349 | portion |
| 1350 | position |
| 1351 | possible |
| 1352 | post |
| 1353 | potato |
| 1354 | pottery |
| 1355 | poverty |
| 1356 | powder |
| 1357 | power |
| 1358 | practice |
| 1359 | praise |
| 1360 | predict |
| 1361 | prefer |
| 1362 | prepare |
| 1363 | present |
| 1364 | pretty |
| 1365 | prevent |
| 1366 | price |
| 1367 | pride |
| 1368 | primary |
| 1369 | |
| 1370 | priority |
| 1371 | prison |
| 1372 | private |
| 1373 | prize |
| 1374 | problem |
| 1375 | process |
| 1376 | produce |
| 1377 | profit |
| 1378 | program |
| 1379 | project |
| 1380 | promote |
| 1381 | proof |
| 1382 | property |
| 1383 | prosper |
| 1384 | protect |
| 1385 | proud |
| 1386 | provide |
| 1387 | public |
| 1388 | pudding |
| 1389 | pull |
| 1390 | pulp |
| 1391 | pulse |
| 1392 | pumpkin |
| 1393 | punch |
| 1394 | pupil |
| 1395 | puppy |
| 1396 | purchase |
| 1397 | purity |
| 1398 | purpose |
| 1399 | purse |
| 1400 | push |
| 1401 | put |
| 1402 | puzzle |
| 1403 | pyramid |
| 1404 | quality |
| 1405 | quantum |
| 1406 | quarter |
| 1407 | question |
| 1408 | quick |
| 1409 | quit |
| 1410 | quiz |
| 1411 | quote |
| 1412 | rabbit |
| 1413 | raccoon |
| 1414 | race |
| 1415 | rack |
| 1416 | radar |
| 1417 | radio |
| 1418 | rail |
| 1419 | rain |
| 1420 | raise |
| 1421 | rally |
| 1422 | ramp |
| 1423 | ranch |
| 1424 | random |
| 1425 | range |
| 1426 | rapid |
| 1427 | rare |
| 1428 | rate |
| 1429 | rather |
| 1430 | raven |
| 1431 | raw |
| 1432 | razor |
| 1433 | ready |
| 1434 | real |
| 1435 | reason |
| 1436 | rebel |
| 1437 | rebuild |
| 1438 | recall |
| 1439 | receive |
| 1440 | recipe |
| 1441 | record |
| 1442 | recycle |
| 1443 | reduce |
| 1444 | reflect |
| 1445 | reform |
| 1446 | refuse |
| 1447 | region |
| 1448 | regret |
| 1449 | regular |
| 1450 | reject |
| 1451 | relax |
| 1452 | release |
| 1453 | relief |
| 1454 | rely |
| 1455 | remain |
| 1456 | remember |
| 1457 | remind |
| 1458 | remove |
| 1459 | render |
| 1460 | renew |
| 1461 | rent |
| 1462 | reopen |
| 1463 | repair |
| 1464 | repeat |
| 1465 | replace |
| 1466 | report |
| 1467 | require |
| 1468 | rescue |
| 1469 | resemble |
| 1470 | resist |
| 1471 | resource |
| 1472 | response |
| 1473 | result |
| 1474 | retire |
| 1475 | retreat |
| 1476 | return |
| 1477 | reunion |
| 1478 | reveal |
| 1479 | review |
| 1480 | reward |
| 1481 | rhythm |
| 1482 | rib |
| 1483 | ribbon |
| 1484 | rice |
| 1485 | rich |
| 1486 | ride |
| 1487 | ridge |
| 1488 | rifle |
| 1489 | right |
| 1490 | rigid |
| 1491 | ring |
| 1492 | riot |
| 1493 | ripple |
| 1494 | risk |
| 1495 | ritual |
| 1496 | rival |
| 1497 | river |
| 1498 | road |
| 1499 | roast |
| 1500 | robot |
| 1501 | robust |
| 1502 | rocket |
| 1503 | romance |
| 1504 | roof |
| 1505 | rookie |
| 1506 | room |
| 1507 | rose |
| 1508 | rotate |
| 1509 | rough |
| 1510 | round |
| 1511 | route |
| 1512 | royal |
| 1513 | rubber |
| 1514 | rude |
| 1515 | rug |
| 1516 | rule |
| 1517 | run |
| 1518 | runway |
| 1519 | rural |
| 1520 | sad |
| 1521 | saddle |
| 1522 | sadness |
| 1523 | safe |
| 1524 | sail |
| 1525 | salad |
| 1526 | salmon |
| 1527 | salon |
| 1528 | salt |
| 1529 | salute |
| 1530 | same |
| 1531 | sample |
| 1532 | sand |
| 1533 | satisfy |
| 1534 | satoshi |
| 1535 | sauce |
| 1536 | sausage |
| 1537 | save |
| 1538 | say |
| 1539 | scale |
| 1540 | scan |
| 1541 | scare |
| 1542 | scatter |
| 1543 | scene |
| 1544 | scheme |
| 1545 | school |
| 1546 | science |
| 1547 | scissors |
| 1548 | scorpion |
| 1549 | scout |
| 1550 | scrap |
| 1551 | screen |
| 1552 | script |
| 1553 | scrub |
| 1554 | sea |
| 1555 | search |
| 1556 | season |
| 1557 | seat |
| 1558 | second |
| 1559 | secret |
| 1560 | section |
| 1561 | security |
| 1562 | seed |
| 1563 | seek |
| 1564 | segment |
| 1565 | select |
| 1566 | sell |
| 1567 | seminar |
| 1568 | senior |
| 1569 | sense |
| 1570 | sentence |
| 1571 | series |
| 1572 | service |
| 1573 | session |
| 1574 | settle |
| 1575 | setup |
| 1576 | seven |
| 1577 | shadow |
| 1578 | shaft |
| 1579 | shallow |
| 1580 | share |
| 1581 | shed |
| 1582 | shell |
| 1583 | sheriff |
| 1584 | shield |
| 1585 | shift |
| 1586 | shine |
| 1587 | ship |
| 1588 | shiver |
| 1589 | shock |
| 1590 | shoe |
| 1591 | shoot |
| 1592 | shop |
| 1593 | short |
| 1594 | shoulder |
| 1595 | shove |
| 1596 | shrimp |
| 1597 | shrug |
| 1598 | shuffle |
| 1599 | shy |
| 1600 | sibling |
| 1601 | sick |
| 1602 | side |
| 1603 | siege |
| 1604 | sight |
| 1605 | sign |
| 1606 | silent |
| 1607 | silk |
| 1608 | silly |
| 1609 | silver |
| 1610 | similar |
| 1611 | simple |
| 1612 | since |
| 1613 | sing |
| 1614 | siren |
| 1615 | sister |
| 1616 | situate |
| 1617 | six |
| 1618 | size |
| 1619 | skate |
| 1620 | sketch |
| 1621 | ski |
| 1622 | skill |
| 1623 | skin |
| 1624 | skirt |
| 1625 | skull |
| 1626 | slab |
| 1627 | slam |
| 1628 | sleep |
| 1629 | slender |
| 1630 | slice |
| 1631 | slide |
| 1632 | slight |
| 1633 | slim |
| 1634 | slogan |
| 1635 | slot |
| 1636 | slow |
| 1637 | slush |
| 1638 | small |
| 1639 | smart |
| 1640 | smile |
| 1641 | smoke |
| 1642 | smooth |
| 1643 | snack |
| 1644 | snake |
| 1645 | snap |
| 1646 | sniff |
| 1647 | snow |
| 1648 | soap |
| 1649 | soccer |
| 1650 | social |
| 1651 | sock |
| 1652 | soda |
| 1653 | soft |
| 1654 | solar |
| 1655 | soldier |
| 1656 | solid |
| 1657 | solution |
| 1658 | solve |
| 1659 | someone |
| 1660 | song |
| 1661 | soon |
| 1662 | sorry |
| 1663 | sort |
| 1664 | soul |
| 1665 | sound |
| 1666 | soup |
| 1667 | source |
| 1668 | south |
| 1669 | space |
| 1670 | spare |
| 1671 | spatial |
| 1672 | spawn |
| 1673 | speak |
| 1674 | special |
| 1675 | speed |
| 1676 | spell |
| 1677 | spend |
| 1678 | sphere |
| 1679 | spice |
| 1680 | spider |
| 1681 | spike |
| 1682 | spin |
| 1683 | spirit |
| 1684 | split |
| 1685 | spoil |
| 1686 | sponsor |
| 1687 | spoon |
| 1688 | sport |
| 1689 | spot |
| 1690 | spray |
| 1691 | spread |
| 1692 | spring |
| 1693 | spy |
| 1694 | square |
| 1695 | squeeze |
| 1696 | squirrel |
| 1697 | stable |
| 1698 | stadium |
| 1699 | staff |
| 1700 | stage |
| 1701 | stairs |
| 1702 | stamp |
| 1703 | stand |
| 1704 | start |
| 1705 | state |
| 1706 | stay |
| 1707 | steak |
| 1708 | steel |
| 1709 | stem |
| 1710 | step |
| 1711 | stereo |
| 1712 | stick |
| 1713 | still |
| 1714 | sting |
| 1715 | stock |
| 1716 | stomach |
| 1717 | stone |
| 1718 | stool |
| 1719 | story |
| 1720 | stove |
| 1721 | strategy |
| 1722 | street |
| 1723 | strike |
| 1724 | strong |
| 1725 | struggle |
| 1726 | student |
| 1727 | stuff |
| 1728 | stumble |
| 1729 | style |
| 1730 | subject |
| 1731 | submit |
| 1732 | subway |
| 1733 | success |
| 1734 | such |
| 1735 | sudden |
| 1736 | suffer |
| 1737 | sugar |
| 1738 | suggest |
| 1739 | suit |
| 1740 | summer |
| 1741 | sun |
| 1742 | sunny |
| 1743 | sunset |
| 1744 | super |
| 1745 | supply |
| 1746 | supreme |
| 1747 | sure |
| 1748 | surface |
| 1749 | surge |
| 1750 | surprise |
| 1751 | surround |
| 1752 | survey |
| 1753 | suspect |
| 1754 | sustain |
| 1755 | swallow |
| 1756 | swamp |
| 1757 | swap |
| 1758 | swarm |
| 1759 | swear |
| 1760 | sweet |
| 1761 | swift |
| 1762 | swim |
| 1763 | swing |
| 1764 | switch |
| 1765 | sword |
| 1766 | symbol |
| 1767 | symptom |
| 1768 | syrup |
| 1769 | system |
| 1770 | table |
| 1771 | tackle |
| 1772 | tag |
| 1773 | tail |
| 1774 | talent |
| 1775 | talk |
| 1776 | tank |
| 1777 | tape |
| 1778 | target |
| 1779 | task |
| 1780 | taste |
| 1781 | tattoo |
| 1782 | taxi |
| 1783 | teach |
| 1784 | team |
| 1785 | tell |
| 1786 | ten |
| 1787 | tenant |
| 1788 | tennis |
| 1789 | tent |
| 1790 | term |
| 1791 | test |
| 1792 | text |
| 1793 | thank |
| 1794 | that |
| 1795 | theme |
| 1796 | then |
| 1797 | theory |
| 1798 | there |
| 1799 | they |
| 1800 | thing |
| 1801 | this |
| 1802 | thought |
| 1803 | three |
| 1804 | thrive |
| 1805 | throw |
| 1806 | thumb |
| 1807 | thunder |
| 1808 | ticket |
| 1809 | tide |
| 1810 | tiger |
| 1811 | tilt |
| 1812 | timber |
| 1813 | time |
| 1814 | tiny |
| 1815 | tip |
| 1816 | tired |
| 1817 | tissue |
| 1818 | title |
| 1819 | toast |
| 1820 | tobacco |
| 1821 | today |
| 1822 | toddler |
| 1823 | toe |
| 1824 | together |
| 1825 | toilet |
| 1826 | token |
| 1827 | tomato |
| 1828 | tomorrow |
| 1829 | tone |
| 1830 | tongue |
| 1831 | tonight |
| 1832 | tool |
| 1833 | tooth |
| 1834 | top |
| 1835 | topic |
| 1836 | topple |
| 1837 | torch |
| 1838 | tornado |
| 1839 | tortoise |
| 1840 | toss |
| 1841 | total |
| 1842 | tourist |
| 1843 | toward |
| 1844 | tower |
| 1845 | town |
| 1846 | toy |
| 1847 | track |
| 1848 | trade |
| 1849 | traffic |
| 1850 | tragic |
| 1851 | train |
| 1852 | transfer |
| 1853 | trap |
| 1854 | trash |
| 1855 | travel |
| 1856 | tray |
| 1857 | treat |
| 1858 | tree |
| 1859 | trend |
| 1860 | trial |
| 1861 | tribe |
| 1862 | trick |
| 1863 | trigger |
| 1864 | trim |
| 1865 | trip |
| 1866 | trophy |
| 1867 | trouble |
| 1868 | truck |
| 1869 | true |
| 1870 | truly |
| 1871 | trumpet |
| 1872 | trust |
| 1873 | truth |
| 1874 | try |
| 1875 | tube |
| 1876 | tuition |
| 1877 | tumble |
| 1878 | tuna |
| 1879 | tunnel |
| 1880 | turkey |
| 1881 | turn |
| 1882 | turtle |
| 1883 | twelve |
| 1884 | twenty |
| 1885 | twice |
| 1886 | twin |
| 1887 | twist |
| 1888 | two |
| 1889 | type |
| 1890 | typical |
| 1891 | ugly |
| 1892 | umbrella |
| 1893 | unable |
| 1894 | unaware |
| 1895 | uncle |
| 1896 | uncover |
| 1897 | under |
| 1898 | undo |
| 1899 | unfair |
| 1900 | unfold |
| 1901 | unhappy |
| 1902 | uniform |
| 1903 | unique |
| 1904 | unit |
| 1905 | universe |
| 1906 | unknown |
| 1907 | unlock |
| 1908 | until |
| 1909 | unusual |
| 1910 | unveil |
| 1911 | update |
| 1912 | upgrade |
| 1913 | uphold |
| 1914 | upon |
| 1915 | upper |
| 1916 | upset |
| 1917 | urban |
| 1918 | urge |
| 1919 | usage |
| 1920 | use |
| 1921 | used |
| 1922 | useful |
| 1923 | useless |
| 1924 | usual |
| 1925 | utility |
| 1926 | vacant |
| 1927 | vacuum |
| 1928 | vague |
| 1929 | valid |
| 1930 | valley |
| 1931 | valve |
| 1932 | van |
| 1933 | vanish |
| 1934 | vapor |
| 1935 | various |
| 1936 | vast |
| 1937 | vault |
| 1938 | vehicle |
| 1939 | velvet |
| 1940 | vendor |
| 1941 | venture |
| 1942 | venue |
| 1943 | verb |
| 1944 | verify |
| 1945 | version |
| 1946 | very |
| 1947 | vessel |
| 1948 | veteran |
| 1949 | viable |
| 1950 | vibrant |
| 1951 | vicious |
| 1952 | victory |
| 1953 | video |
| 1954 | view |
| 1955 | village |
| 1956 | vintage |
| 1957 | violin |
| 1958 | virtual |
| 1959 | virus |
| 1960 | visa |
| 1961 | visit |
| 1962 | visual |
| 1963 | vital |
| 1964 | vivid |
| 1965 | vocal |
| 1966 | voice |
| 1967 | void |
| 1968 | volcano |
| 1969 | volume |
| 1970 | vote |
| 1971 | voyage |
| 1972 | wage |
| 1973 | wagon |
| 1974 | wait |
| 1975 | walk |
| 1976 | wall |
| 1977 | walnut |
| 1978 | want |
| 1979 | warfare |
| 1980 | warm |
| 1981 | warrior |
| 1982 | wash |
| 1983 | wasp |
| 1984 | waste |
| 1985 | water |
| 1986 | wave |
| 1987 | way |
| 1988 | wealth |
| 1989 | weapon |
| 1990 | wear |
| 1991 | weasel |
| 1992 | weather |
| 1993 | web |
| 1994 | wedding |
| 1995 | weekend |
| 1996 | weird |
| 1997 | welcome |
| 1998 | west |
| 1999 | wet |
| 2000 | whale |
| 2001 | what |
| 2002 | wheat |
| 2003 | wheel |
| 2004 | when |
| 2005 | where |
| 2006 | whip |
| 2007 | whisper |
| 2008 | wide |
| 2009 | width |
| 2010 | wife |
| 2011 | wild |
| 2012 | will |
| 2013 | win |
| 2014 | window |
| 2015 | wine |
| 2016 | wing |
| 2017 | wink |
| 2018 | winner |
| 2019 | winter |
| 2020 | wire |
| 2021 | wisdom |
| 2022 | wise |
| 2023 | wish |
| 2024 | witness |
| 2025 | wolf |
| 2026 | woman |
| 2027 | wonder |
| 2028 | wood |
| 2029 | wool |
| 2030 | word |
| 2031 | work |
| 2032 | world |
| 2033 | worry |
| 2034 | worth |
| 2035 | wrap |
| 2036 | wreck |
| 2037 | wrestle |
| 2038 | wrist |
| 2039 | write |
| 2040 | wrong |
| 2041 | yard |
| 2042 | year |
| 2043 | yellow |
| 2044 | you |
| 2045 | young |
| 2046 | youth |
| 2047 | zebra |
| 2048 | zero |
| 2049 | zone |
| 2050 | zoo`.split(` |
| 2051 | `);var Sc=Cc(vc()),Zn=Ko,Ll="m/84'/1'/0'",Nl=10;function Cl(){return gc(Di,128)}function _l(t){return yc(String(t||"").trim().toLowerCase().replace(/\s+/g," "),Di)}function Pl(t){let e=bc(String(t).trim().toLowerCase().replace(/\s+/g," ")),r=Gn.fromMasterSeed(e).derive(Ll),n=(i,s)=>r.deriveChild(i).deriveChild(s),o=(i,s)=>ci(n(i,s).publicKey,Zn);return{address:(i=0,s=0)=>o(s,i).address,key:n,addr:o}}async function Bc(t){let e=await fetch(t);if(!e.ok)throw new Error("Network busy, try again.");return e.json()}async function Rl(t){let e=[],r=new Map,n=0,o=0;for(let c of[0,1]){let f=0;for(let h=0;h<40&&f<(c?4:Nl);h++){let u=t.addr(c,h),[l,y]=await Promise.all([Bc(`/api/chain/address/${u.address}/utxo`),Bc(`/api/chain/address/${u.address}/txs`)]);if(!y.length){f++;continue}f=0,c?o=h+1:n=h+1;for(let N of l)e.push({txid:N.txid,vout:N.vout,value:N.value,confirmed:N.status&&N.status.confirmed,change:c,i:h,script:u.script});for(let N of y)r.set(N.txid,N)}}let i=new Set;for(let c of[0,1])for(let f=0;f<(c?o:n)+1;f++)i.add(t.address(f,c));let s=[...r.values()].map(c=>{let f=0;for(let h of c.vout)i.has(h.scriptpubkey_address)&&(f+=h.value);for(let h of c.vin)h.prevout&&i.has(h.prevout.scriptpubkey_address)&&(f-=h.prevout.value);return{txid:c.txid,delta:f,time:c.status&&c.status.block_time?c.status.block_time*1e3:null,confirmed:!!(c.status&&c.status.confirmed)}}).sort((c,f)=>(f.time||9e15)-(c.time||9e15)),a=e.reduce((c,f)=>c+f.value,0);return{utxos:e,balance:a,history:s,nextReceive:n,nextChange:o}}function Ac(t){try{return Ee(Zn).decode(String(t).trim()),!0}catch{return!1}}function Hl(t,e,r,n,o){if(r=String(r).trim(),!Ac(r))throw new Error("That isn\u2019t a test-network Bitcoin address (they start with tb1).");if(n=Math.floor(n),!(n>=330))throw new Error("That amount is too small to send.");let i=[...e.utxos].sort((u,l)=>l.value-u.value),s=[],a=0,c=0;for(let u of i)if(s.push(u),a+=u.value,c=Math.ceil((11+68*s.length+31*2)*o),a>=n+c)break;if(a<n+c)throw new Error("Not enough in your wallet for this payment and the network fee.");let f=new xe;for(let u of s)f.addInput({txid:u.txid,index:u.vout,witnessUtxo:{script:u.script,amount:BigInt(u.value)}});f.addOutputAddress(r,BigInt(n),Zn);let h=a-n-c;return h>=546?f.addOutputAddress(t.address(e.nextChange,1),BigInt(h),Zn):c+=h,s.forEach((u,l)=>f.signIdx(t.key(u.change,u.i).privateKey,l)),f.finalize(),{hex:f.hex,fee:c,txid:f.id}}function $l(t){let e=(0,Sc.default)(0,"M");return e.addData(t),e.make(),e.createSvgTag({cellSize:6,margin:2,scalable:!0})}return _c(Ol);})(); |
| 2052 | /*! Bundled license information: |
| 2053 | |
| 2054 | @scure/base/lib/esm/index.js: |
| 2055 | (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2056 | |
| 2057 | @noble/hashes/esm/utils.js: |
| 2058 | (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2059 | |
| 2060 | @noble/hashes/esm/utils.js: |
| 2061 | (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2062 | |
| 2063 | @noble/curves/esm/abstract/utils.js: |
| 2064 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2065 | |
| 2066 | @noble/curves/esm/abstract/modular.js: |
| 2067 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2068 | |
| 2069 | @noble/curves/esm/abstract/curve.js: |
| 2070 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2071 | |
| 2072 | @noble/curves/esm/abstract/weierstrass.js: |
| 2073 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2074 | |
| 2075 | @noble/curves/esm/_shortw_utils.js: |
| 2076 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2077 | |
| 2078 | @noble/curves/esm/secp256k1.js: |
| 2079 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2080 | |
| 2081 | @scure/base/lib/esm/index.js: |
| 2082 | (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2083 | |
| 2084 | @scure/btc-signer/esm/index.js: |
| 2085 | (*! scure-btc-signer - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2086 | |
| 2087 | @noble/hashes/esm/utils.js: |
| 2088 | (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2089 | |
| 2090 | @noble/curves/esm/abstract/utils.js: |
| 2091 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2092 | |
| 2093 | @noble/curves/esm/abstract/modular.js: |
| 2094 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2095 | |
| 2096 | @noble/curves/esm/abstract/curve.js: |
| 2097 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2098 | |
| 2099 | @noble/curves/esm/abstract/weierstrass.js: |
| 2100 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2101 | |
| 2102 | @noble/curves/esm/_shortw_utils.js: |
| 2103 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2104 | |
| 2105 | @noble/curves/esm/secp256k1.js: |
| 2106 | (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) |
| 2107 | |
| 2108 | @scure/bip32/lib/esm/index.js: |
| 2109 | (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *) |
| 2110 | |
| 2111 | @scure/bip39/esm/index.js: |
| 2112 | (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *) |
| 2113 | */ |