@smartledger/bsv 8.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +2 -2
- package/bsv-ltp.min.js +7 -7
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +2 -2
- package/bsv.min.js +2 -2
- package/docs/AUDIT_SCOPE.md +9 -9
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/script/interpreter.js +20 -25
- package/package.json +1 -1
- package/test/script/defaults.js +67 -0
- package/version.js +1 -1
package/bsv-ltp.min.js
CHANGED
|
@@ -10,13 +10,13 @@ var bsvLTP=(()=>{var Dx=Object.create;var gs=Object.defineProperty;var Ux=Object
|
|
|
10
10
|
`)+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}xe.types=um();function dm(e){return Array.isArray(e)}xe.isArray=dm;function th(e){return typeof e=="boolean"}xe.isBoolean=th;function Mu(e){return e===null}xe.isNull=Mu;function tR(e){return e==null}xe.isNullOrUndefined=tR;function pm(e){return typeof e=="number"}xe.isNumber=pm;function ku(e){return typeof e=="string"}xe.isString=ku;function rR(e){return typeof e=="symbol"}xe.isSymbol=rR;function Ai(e){return e===void 0}xe.isUndefined=Ai;function Is(e){return Io(e)&&rh(e)==="[object RegExp]"}xe.isRegExp=Is;xe.types.isRegExp=Is;function Io(e){return typeof e=="object"&&e!==null}xe.isObject=Io;function Nu(e){return Io(e)&&rh(e)==="[object Date]"}xe.isDate=Nu;xe.types.isDate=Nu;function As(e){return Io(e)&&(rh(e)==="[object Error]"||e instanceof Error)}xe.isError=As;xe.types.isNativeError=As;function Pu(e){return typeof e=="function"}xe.isFunction=Pu;function nR(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}xe.isPrimitive=nR;xe.isBuffer=cm();function rh(e){return Object.prototype.toString.call(e)}function Ql(e){return e<10?"0"+e.toString(10):e.toString(10)}var iR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oR(){var e=new Date,t=[Ql(e.getHours()),Ql(e.getMinutes()),Ql(e.getSeconds())].join(":");return[e.getDate(),iR[e.getMonth()],t].join(" ")}xe.log=function(){console.log("%s - %s",oR(),xe.format.apply(xe,arguments))};xe.inherits=De();xe._extend=function(e,t){if(!t||!Io(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};function gm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ii=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;xe.promisify=function(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(Ii&&t[Ii]){var r=t[Ii];if(typeof r!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(r,Ii,{value:r,enumerable:!1,writable:!1,configurable:!0}),r}function r(){for(var n,i,o=new Promise(function(c,h){n=c,i=h}),s=[],a=0;a<arguments.length;a++)s.push(arguments[a]);s.push(function(c,h){c?i(c):n(h)});try{t.apply(this,s)}catch(c){i(c)}return o}return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Ii&&Object.defineProperty(r,Ii,{value:r,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(r,lm(t))};xe.promisify.custom=Ii;function sR(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}function aR(e){if(typeof e!="function")throw new TypeError('The "original" argument must be of type Function');function t(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then(function(a){x.default.nextTick(s.bind(null,null,a))},function(a){x.default.nextTick(sR.bind(null,a,s))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,lm(e)),t}xe.callbackify=aR});var Sm=P((fL,_m)=>{"use strict";m();function ym(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function mm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ym(Object(r),!0).forEach(function(n){uR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ym(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function uR(e,t,r){return t=bm(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vm(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,bm(n.key),n)}}function cR(e,t,r){return t&&vm(e.prototype,t),r&&vm(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function bm(e){var t=lR(e,"string");return typeof t=="symbol"?t:String(t)}function lR(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var hR=Tt(),Cu=hR.Buffer,dR=en(),nh=dR.inspect,pR=nh&&nh.custom||"inspect";function gR(e,t,r){Cu.prototype.copy.call(e,t,r)}_m.exports=(function(){function e(){fR(this,e),this.head=null,this.tail=null,this.length=0}return cR(e,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return Cu.alloc(0);for(var n=Cu.allocUnsafe(r>>>0),i=this.head,o=0;i;)gR(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=Cu.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:pR,value:function(r,n){return nh(this,mm(mm({},n),{},{depth:0,customInspect:!1}))}}]),e})()});var oh=P((lL,Em)=>{"use strict";m();function yR(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,x.default.nextTick(ih,this,e)):x.default.nextTick(ih,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted?x.default.nextTick(Lu,r):(r._writableState.errorEmitted=!0,x.default.nextTick(wm,r,o)):x.default.nextTick(wm,r,o):t?(x.default.nextTick(Lu,r),t(o)):x.default.nextTick(Lu,r)}),this)}function wm(e,t){ih(e,t),Lu(e)}function Lu(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function mR(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function ih(e,t){e.emit("error",t)}function vR(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}Em.exports={destroy:yR,undestroy:mR,errorOrDestroy:vR}});var Oi=P((dL,Am)=>{"use strict";m();function bR(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Im={};function Sr(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){bR(s,o);function s(a,c,h){return o.call(this,n(a,c,h))||this}return s})(r);i.prototype.name=r.name,i.prototype.code=e,Im[e]=i}function xm(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function _R(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function SR(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function wR(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Sr("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Sr("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&_R(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(SR(e," argument"))i="The ".concat(e," ").concat(n," ").concat(xm(t,"type"));else{var o=wR(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(xm(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Sr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Sr("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Sr("ERR_STREAM_PREMATURE_CLOSE","Premature close");Sr("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Sr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Sr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Sr("ERR_STREAM_WRITE_AFTER_END","write after end");Sr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Sr("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Sr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Am.exports.codes=Im});var sh=P((gL,Om)=>{"use strict";m();var ER=Oi().codes.ERR_INVALID_OPT_VALUE;function xR(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function IR(e,t,r,n){var i=xR(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new ER(o,i)}return Math.floor(i)}return e.objectMode?16:16*1024}Om.exports={getHighWaterMark:IR}});var uh=P((mL,Rm)=>{m();Rm.exports=AR;function AR(e,t){if(ah("noDeprecation"))return e;var r=!1;function n(){if(!r){if(ah("throwDeprecation"))throw new Error(t);ah("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function ah(e){try{if(!globalThis.localStorage)return!1}catch{return!1}var t=globalThis.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}});var lh=P((bL,km)=>{"use strict";m();km.exports=Xe;function Pm(e){var t=this;this.next=null,this.entry=null,this.finish=function(){QR(t,e)}}var Ao;Xe.WritableState=Rs;var OR={deprecate:uh()},Bm=xl(),Uu=Tt().Buffer,RR=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function TR(e){return Uu.from(e)}function PR(e){return Uu.isBuffer(e)||e instanceof RR}var ch=oh(),BR=sh(),NR=BR.getHighWaterMark,zn=Oi().codes,MR=zn.ERR_INVALID_ARG_TYPE,kR=zn.ERR_METHOD_NOT_IMPLEMENTED,CR=zn.ERR_MULTIPLE_CALLBACK,LR=zn.ERR_STREAM_CANNOT_PIPE,DR=zn.ERR_STREAM_DESTROYED,UR=zn.ERR_STREAM_NULL_VALUES,FR=zn.ERR_STREAM_WRITE_AFTER_END,qR=zn.ERR_UNKNOWN_ENCODING,Oo=ch.errorOrDestroy;De()(Xe,Bm);function HR(){}function Rs(e,t,r){Ao=Ao||Ri(),e=e||{},typeof r!="boolean"&&(r=t instanceof Ao),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=NR(this,e,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=e.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){YR(t,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Pm(this)}Rs.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Rs.prototype,"buffer",{get:OR.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Du;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Du=Function.prototype[Symbol.hasInstance],Object.defineProperty(Xe,Symbol.hasInstance,{value:function(t){return Du.call(this,t)?!0:this!==Xe?!1:t&&t._writableState instanceof Rs}})):Du=function(t){return t instanceof this};function Xe(e){Ao=Ao||Ri();var t=this instanceof Ao;if(!t&&!Du.call(Xe,this))return new Xe(e);this._writableState=new Rs(e,this,t),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),Bm.call(this)}Xe.prototype.pipe=function(){Oo(this,new LR)};function jR(e,t){var r=new FR;Oo(e,r),x.default.nextTick(t,r)}function KR(e,t,r,n){var i;return r===null?i=new UR:typeof r!="string"&&!t.objectMode&&(i=new MR("chunk",["string","Buffer"],r)),i?(Oo(e,i),x.default.nextTick(n,i),!1):!0}Xe.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&PR(e);return o&&!Uu.isBuffer(e)&&(e=TR(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=HR),n.ending?jR(this,r):(o||KR(this,n,e,r))&&(n.pendingcb++,i=GR(this,n,o,e,t,r)),i};Xe.prototype.cork=function(){this._writableState.corked++};Xe.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Nm(this,e))};Xe.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new qR(t);return this._writableState.defaultEncoding=t,this};Object.defineProperty(Xe.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function VR(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=Uu.from(t,r)),t}Object.defineProperty(Xe.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function GR(e,t,r,n,i,o){if(!r){var s=VR(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else fh(e,t,!1,a,n,i,o);return c}function fh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new DR("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function zR(e,t,r,n,i){--t.pendingcb,r?(x.default.nextTick(i,n),x.default.nextTick(Os,e,t),e._writableState.errorEmitted=!0,Oo(e,n)):(i(n),e._writableState.errorEmitted=!0,Oo(e,n),Os(e,t))}function WR(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function YR(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new CR;if(WR(r),t)zR(e,r,n,t,i);else{var o=Mm(r)||e.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Nm(e,r),n?x.default.nextTick(Tm,e,r,o,i):Tm(e,r,o,i)}}function Tm(e,t,r,n){r||$R(e,t),t.pendingcb--,n(),Os(e,t)}function $R(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Nm(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,fh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Pm(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,h=r.encoding,g=r.callback,y=t.objectMode?1:c.length;if(fh(e,t,!1,y,c,h,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Xe.prototype._write=function(e,t,r){r(new kR("_write()"))};Xe.prototype._writev=null;Xe.prototype.end=function(e,t,r){var n=this._writableState;return typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||JR(this,n,r),this};Object.defineProperty(Xe.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Mm(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function ZR(e,t){e._final(function(r){t.pendingcb--,r&&Oo(e,r),t.prefinished=!0,e.emit("prefinish"),Os(e,t)})}function XR(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,x.default.nextTick(ZR,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Os(e,t){var r=Mm(t);if(r&&(XR(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function JR(e,t,r){t.ending=!0,Os(e,t),r&&(t.finished?x.default.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function QR(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Xe.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}});Xe.prototype.destroy=ch.destroy;Xe.prototype._undestroy=ch.undestroy;Xe.prototype._destroy=function(e,t){t(e)}});var Ri=P((SL,Lm)=>{"use strict";m();var eT=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Lm.exports=tn;var Cm=ph(),dh=lh();De()(tn,Cm);for(hh=eT(dh.prototype),Fu=0;Fu<hh.length;Fu++)qu=hh[Fu],tn.prototype[qu]||(tn.prototype[qu]=dh.prototype[qu]);var hh,qu,Fu;function tn(e){if(!(this instanceof tn))return new tn(e);Cm.call(this,e),dh.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",tT)))}Object.defineProperty(tn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(tn.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(tn.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function tT(){this._writableState.ended||x.default.nextTick(rT,this)}function rT(e){e.end()}Object.defineProperty(tn.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(t){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=t,this._writableState.destroyed=t)}})});var Fm=P((gh,Um)=>{m();var Hu=Tt(),vn=Hu.Buffer;function Dm(e,t){for(var r in e)t[r]=e[r]}vn.from&&vn.alloc&&vn.allocUnsafe&&vn.allocUnsafeSlow?Um.exports=Hu:(Dm(Hu,gh),gh.Buffer=Ro);function Ro(e,t,r){return vn(e,t,r)}Dm(vn,Ro);Ro.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return vn(e,t,r)};Ro.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=vn(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};Ro.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return vn(e)};Ro.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Hu.SlowBuffer(e)}});var To=P(Hm=>{"use strict";m();var mh=Fm().Buffer,qm=mh.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function nT(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function iT(e){var t=nT(e);if(typeof t!="string"&&(mh.isEncoding===qm||!qm(e)))throw new Error("Unknown encoding: "+e);return t||e}Hm.StringDecoder=Ts;function Ts(e){this.encoding=iT(e);var t;switch(this.encoding){case"utf16le":this.text=cT,this.end=lT,t=4;break;case"utf8":this.fillLast=aT,t=4;break;case"base64":this.text=hT,this.end=dT,t=3;break;default:this.write=pT,this.end=gT;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=mh.allocUnsafe(t)}Ts.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Ts.prototype.end=fT;Ts.prototype.text=uT;Ts.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function yh(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function oT(e,t,r){var n=t.length-1;if(n<r)return 0;var i=yh(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=yh(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=yh(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function sT(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function aT(e){var t=this.lastTotal-this.lastNeed,r=sT(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function uT(e,t){var r=oT(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function fT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function cT(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function lT(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function hT(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function dT(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function pT(e){return e.toString(this.encoding)}function gT(e){return e&&e.length?this.write(e):""}});var ju=P((AL,Vm)=>{"use strict";m();var jm=Oi().codes.ERR_STREAM_PREMATURE_CLOSE;function yT(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function mT(){}function vT(e){return e.setHeader&&typeof e.abort=="function"}function Km(e,t,r){if(typeof t=="function")return Km(e,null,t);t||(t={}),r=yT(r||mT);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,o=function(){e.writable||a()},s=e._writableState&&e._writableState.finished,a=function(){i=!1,s=!0,n||r.call(e)},c=e._readableState&&e._readableState.endEmitted,h=function(){n=!1,c=!0,i||r.call(e)},g=function(T){r.call(e,T)},y=function(){var T;if(n&&!c)return(!e._readableState||!e._readableState.ended)&&(T=new jm),r.call(e,T);if(i&&!s)return(!e._writableState||!e._writableState.ended)&&(T=new jm),r.call(e,T)},w=function(){e.req.on("finish",a)};return vT(e)?(e.on("complete",a),e.on("abort",y),e.req?w():e.on("request",w)):i&&!e._writableState&&(e.on("end",o),e.on("close",o)),e.on("end",h),e.on("finish",a),t.error!==!1&&e.on("error",g),e.on("close",y),function(){e.removeListener("complete",a),e.removeListener("abort",y),e.removeListener("request",w),e.req&&e.req.removeListener("finish",a),e.removeListener("end",o),e.removeListener("close",o),e.removeListener("finish",a),e.removeListener("end",h),e.removeListener("error",g),e.removeListener("close",y)}}Vm.exports=Km});var zm=P((RL,Gm)=>{"use strict";m();var Ku;function Wn(e,t,r){return t=bT(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bT(e){var t=_T(e,"string");return typeof t=="symbol"?t:String(t)}function _T(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ST=ju(),Yn=Symbol("lastResolve"),Ti=Symbol("lastReject"),Ps=Symbol("error"),Vu=Symbol("ended"),Pi=Symbol("lastPromise"),vh=Symbol("handlePromise"),Bi=Symbol("stream");function $n(e,t){return{value:e,done:t}}function wT(e){var t=e[Yn];if(t!==null){var r=e[Bi].read();r!==null&&(e[Pi]=null,e[Yn]=null,e[Ti]=null,t($n(r,!1)))}}function ET(e){x.default.nextTick(wT,e)}function xT(e,t){return function(r,n){e.then(function(){if(t[Vu]){r($n(void 0,!0));return}t[vh](r,n)},n)}}var IT=Object.getPrototypeOf(function(){}),AT=Object.setPrototypeOf((Ku={get stream(){return this[Bi]},next:function(){var t=this,r=this[Ps];if(r!==null)return Promise.reject(r);if(this[Vu])return Promise.resolve($n(void 0,!0));if(this[Bi].destroyed)return new Promise(function(s,a){x.default.nextTick(function(){t[Ps]?a(t[Ps]):s($n(void 0,!0))})});var n=this[Pi],i;if(n)i=new Promise(xT(n,this));else{var o=this[Bi].read();if(o!==null)return Promise.resolve($n(o,!1));i=new Promise(this[vh])}return this[Pi]=i,i}},Wn(Ku,Symbol.asyncIterator,function(){return this}),Wn(Ku,"return",function(){var t=this;return new Promise(function(r,n){t[Bi].destroy(null,function(i){if(i){n(i);return}r($n(void 0,!0))})})}),Ku),IT),OT=function(t){var r,n=Object.create(AT,(r={},Wn(r,Bi,{value:t,writable:!0}),Wn(r,Yn,{value:null,writable:!0}),Wn(r,Ti,{value:null,writable:!0}),Wn(r,Ps,{value:null,writable:!0}),Wn(r,Vu,{value:t._readableState.endEmitted,writable:!0}),Wn(r,vh,{value:function(o,s){var a=n[Bi].read();a?(n[Pi]=null,n[Yn]=null,n[Ti]=null,o($n(a,!1))):(n[Yn]=o,n[Ti]=s)},writable:!0}),r));return n[Pi]=null,ST(t,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Ti];o!==null&&(n[Pi]=null,n[Yn]=null,n[Ti]=null,o(i)),n[Ps]=i;return}var s=n[Yn];s!==null&&(n[Pi]=null,n[Yn]=null,n[Ti]=null,s($n(void 0,!0))),n[Vu]=!0}),t.on("readable",ET.bind(null,n)),n};Gm.exports=OT});var Ym=P((PL,Wm)=>{m();Wm.exports=function(){throw new Error("Readable.from is not available in the browser")}});var ph=P((ML,iv)=>{"use strict";m();iv.exports=Te;var Po;Te.ReadableState=Jm;var NL=yo().EventEmitter,Xm=function(t,r){return t.listeners(r).length},Ns=xl(),Gu=Tt().Buffer,RT=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function TT(e){return Gu.from(e)}function PT(e){return Gu.isBuffer(e)||e instanceof RT}var bh=en(),_e;bh&&bh.debuglog?_e=bh.debuglog("stream"):_e=function(){};var BT=Sm(),Ah=oh(),NT=sh(),MT=NT.getHighWaterMark,zu=Oi().codes,kT=zu.ERR_INVALID_ARG_TYPE,CT=zu.ERR_STREAM_PUSH_AFTER_EOF,LT=zu.ERR_METHOD_NOT_IMPLEMENTED,DT=zu.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,Bo,_h,Sh;De()(Te,Ns);var Bs=Ah.errorOrDestroy,wh=["error","close","destroy","pause","resume"];function UT(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function Jm(e,t,r){Po=Po||Ri(),e=e||{},typeof r!="boolean"&&(r=t instanceof Po),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=MT(this,e,"readableHighWaterMark",r),this.buffer=new BT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Bo||(Bo=To().StringDecoder),this.decoder=new Bo(e.encoding),this.encoding=e.encoding)}function Te(e){if(Po=Po||Ri(),!(this instanceof Te))return new Te(e);var t=this instanceof Po;this._readableState=new Jm(e,this,t),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Ns.call(this)}Object.defineProperty(Te.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}});Te.prototype.destroy=Ah.destroy;Te.prototype._undestroy=Ah.undestroy;Te.prototype._destroy=function(e,t){t(e)};Te.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Gu.from(e,t),t=""),n=!0),Qm(this,e,t,!1,n)};Te.prototype.unshift=function(e){return Qm(this,e,null,!0,!1)};function Qm(e,t,r,n,i){_e("readableAddChunk",t);var o=e._readableState;if(t===null)o.reading=!1,HT(e,o);else{var s;if(i||(s=FT(o,t)),s)Bs(e,s);else if(o.objectMode||t&&t.length>0)if(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Gu.prototype&&(t=TT(t)),n)o.endEmitted?Bs(e,new DT):Eh(e,o,t,!0);else if(o.ended)Bs(e,new CT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Eh(e,o,t,!1):Ih(e,o)):Eh(e,o,t,!1)}else n||(o.reading=!1,Ih(e,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Eh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Wu(e)),Ih(e,t)}function FT(e,t){var r;return!PT(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new kT("chunk",["string","Buffer","Uint8Array"],t)),r}Te.prototype.isPaused=function(){return this._readableState.flowing===!1};Te.prototype.setEncoding=function(e){Bo||(Bo=To().StringDecoder);var t=new Bo(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var $m=1073741824;function qT(e){return e>=$m?e=$m:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Zm(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=qT(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}Te.prototype.read=function(e){_e("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return _e("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?xh(this):Wu(this),null;if(e=Zm(e,t),e===0&&t.ended)return t.length===0&&xh(this),null;var n=t.needReadable;_e("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,_e("length less than watermark",n)),t.ended||t.reading?(n=!1,_e("reading or ended",n)):n&&(_e("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Zm(r,t)));var i;return e>0?i=rv(e,t):i=null,i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&xh(this)),i!==null&&this.emit("data",i),i};function HT(e,t){if(_e("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?Wu(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,ev(e)))}}function Wu(e){var t=e._readableState;_e("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(_e("emitReadable",t.flowing),t.emittedReadable=!0,x.default.nextTick(ev,e))}function ev(e){var t=e._readableState;_e("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Oh(e)}function Ih(e,t){t.readingMore||(t.readingMore=!0,x.default.nextTick(jT,e,t))}function jT(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var r=t.length;if(_e("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}Te.prototype._read=function(e){Bs(this,new LT("_read()"))};Te.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,_e("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:M;n.endEmitted?x.default.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(L,j){_e("onunpipe"),L===r&&j&&j.hasUnpiped===!1&&(j.hasUnpiped=!0,g())}function a(){_e("onend"),e.end()}var c=KT(r);e.on("drain",c);var h=!1;function g(){_e("cleanup"),e.removeListener("close",I),e.removeListener("finish",T),e.removeListener("drain",c),e.removeListener("error",w),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",M),r.removeListener("data",y),h=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}r.on("data",y);function y(L){_e("ondata");var j=e.write(L);_e("dest.write",j),j===!1&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&nv(n.pipes,e)!==-1)&&!h&&(_e("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function w(L){_e("onerror",L),M(),e.removeListener("error",w),Xm(e,"error")===0&&Bs(e,L)}UT(e,"error",w);function I(){e.removeListener("finish",T),M()}e.once("close",I);function T(){_e("onfinish"),e.removeListener("close",I),M()}e.once("finish",T);function M(){_e("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(_e("pipe resume"),r.resume()),e};function KT(e){return function(){var r=e._readableState;_e("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Xm(e,"data")&&(r.flowing=!0,Oh(e))}}Te.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=nv(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};Te.prototype.on=function(e,t){var r=Ns.prototype.on.call(this,e,t),n=this._readableState;return e==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):e==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,_e("on readable",n.length,n.reading),n.length?Wu(this):n.reading||x.default.nextTick(VT,this)),r};Te.prototype.addListener=Te.prototype.on;Te.prototype.removeListener=function(e,t){var r=Ns.prototype.removeListener.call(this,e,t);return e==="readable"&&x.default.nextTick(tv,this),r};Te.prototype.removeAllListeners=function(e){var t=Ns.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&x.default.nextTick(tv,this),t};function tv(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function VT(e){_e("readable nexttick read 0"),e.read(0)}Te.prototype.resume=function(){var e=this._readableState;return e.flowing||(_e("resume"),e.flowing=!e.readableListening,GT(this,e)),e.paused=!1,this};function GT(e,t){t.resumeScheduled||(t.resumeScheduled=!0,x.default.nextTick(zT,e,t))}function zT(e,t){_e("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Oh(e),t.flowing&&!t.reading&&e.read(0)}Te.prototype.pause=function(){return _e("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(_e("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Oh(e){var t=e._readableState;for(_e("flow",t.flowing);t.flowing&&e.read()!==null;);}Te.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(_e("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(_e("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(a){return function(){return e[a].apply(e,arguments)}})(i));for(var o=0;o<wh.length;o++)e.on(wh[o],this.emit.bind(this,wh[o]));return this._read=function(s){_e("wrapped _read",s),n&&(n=!1,e.resume())},this};typeof Symbol=="function"&&(Te.prototype[Symbol.asyncIterator]=function(){return _h===void 0&&(_h=zm()),_h(this)});Object.defineProperty(Te.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(Te.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(Te.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}});Te._fromList=rv;Object.defineProperty(Te.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function rv(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function xh(e){var t=e._readableState;_e("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,x.default.nextTick(WT,t,e))}function WT(e,t){if(_e("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}typeof Symbol=="function"&&(Te.from=function(e,t){return Sh===void 0&&(Sh=Ym()),Sh(Te,e,t)});function nv(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var Rh=P((CL,sv)=>{"use strict";m();sv.exports=bn;var Yu=Oi().codes,YT=Yu.ERR_METHOD_NOT_IMPLEMENTED,$T=Yu.ERR_MULTIPLE_CALLBACK,ZT=Yu.ERR_TRANSFORM_ALREADY_TRANSFORMING,XT=Yu.ERR_TRANSFORM_WITH_LENGTH_0,$u=Ri();De()(bn,$u);function JT(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new $T);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function bn(e){if(!(this instanceof bn))return new bn(e);$u.call(this,e),this._transformState={afterTransform:JT.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",QT)}function QT(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){ov(e,t,r)}):ov(this,null,null)}bn.prototype.push=function(e,t){return this._transformState.needTransform=!1,$u.prototype.push.call(this,e,t)};bn.prototype._transform=function(e,t,r){r(new YT("_transform()"))};bn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};bn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};bn.prototype._destroy=function(e,t){$u.prototype._destroy.call(this,e,function(r){t(r)})};function ov(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new XT;if(e._transformState.transforming)throw new ZT;return e.push(null)}});var fv=P((DL,uv)=>{"use strict";m();uv.exports=Ms;var av=Rh();De()(Ms,av);function Ms(e){if(!(this instanceof Ms))return new Ms(e);av.call(this,e)}Ms.prototype._transform=function(e,t,r){r(null,e)}});var pv=P((FL,dv)=>{"use strict";m();var Th;function e2(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var hv=Oi().codes,t2=hv.ERR_MISSING_ARGS,r2=hv.ERR_STREAM_DESTROYED;function cv(e){if(e)throw e}function n2(e){return e.setHeader&&typeof e.abort=="function"}function i2(e,t,r,n){n=e2(n);var i=!1;e.on("close",function(){i=!0}),Th===void 0&&(Th=ju()),Th(e,{readable:t,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,n2(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(s||new r2("pipe"))}}}function lv(e){e()}function o2(e,t){return e.pipe(t)}function s2(e){return!e.length||typeof e[e.length-1]!="function"?cv:e.pop()}function a2(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=s2(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new t2("streams");var i,o=t.map(function(s,a){var c=a<t.length-1,h=a>0;return i2(s,c,h,function(g){i||(i=g),g&&o.forEach(lv),!c&&(o.forEach(lv),n(i))})});return t.reduce(o2)}dv.exports=a2});var Bh=P((HL,gv)=>{m();gv.exports=wr;var Ph=yo().EventEmitter,u2=De();u2(wr,Ph);wr.Readable=ph();wr.Writable=lh();wr.Duplex=Ri();wr.Transform=Rh();wr.PassThrough=fv();wr.finished=ju();wr.pipeline=pv();wr.Stream=wr;function wr(){Ph.call(this)}wr.prototype.pipe=function(e,t){var r=this;function n(g){e.writable&&e.write(g)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}e.on("drain",i),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",a));var o=!1;function s(){o||(o=!0,e.end())}function a(){o||(o=!0,typeof e.destroy=="function"&&e.destroy())}function c(g){if(h(),Ph.listenerCount(this,"error")===0)throw g}r.on("error",c),e.on("error",c);function h(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",h),r.removeListener("close",h),e.removeListener("close",h)}return r.on("end",h),r.on("close",h),e.on("close",h),e.emit("pipe",r),e}});var vv=P((KL,mv)=>{"use strict";m();var rn=qt().Buffer,yv=Bh().Transform,f2=De();function Zn(e){yv.call(this),this._block=rn.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}f2(Zn,yv);Zn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Zn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};var c2=typeof Uint8Array<"u",l2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(rn.prototype instanceof Uint8Array||rn.TYPED_ARRAY_SUPPORT);function h2(e,t){if(e instanceof rn)return e;if(typeof e=="string")return rn.from(e,t);if(l2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return rn.alloc(0);var r=rn.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(c2&&e instanceof Uint8Array||rn.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return rn.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Zn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=h2(e,t);for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var o=0,s=e.length*8;s>0;++o)this._length[o]+=s,s=this._length[o]/4294967296|0,s>0&&(this._length[o]-=4294967296*s);return this};Zn.prototype._update=function(){throw new Error("_update is not implemented")};Zn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Zn.prototype._digest=function(){throw new Error("_digest is not implemented")};mv.exports=Zn});var Nh=P((GL,_v)=>{"use strict";m();var d2=De(),bv=vv(),p2=qt().Buffer,g2=new Array(16);function Zu(){bv.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}d2(Zu,bv);Zu.prototype._update=function(){for(var e=g2,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,o=this._d;r=Gt(r,n,i,o,e[0],3614090360,7),o=Gt(o,r,n,i,e[1],3905402710,12),i=Gt(i,o,r,n,e[2],606105819,17),n=Gt(n,i,o,r,e[3],3250441966,22),r=Gt(r,n,i,o,e[4],4118548399,7),o=Gt(o,r,n,i,e[5],1200080426,12),i=Gt(i,o,r,n,e[6],2821735955,17),n=Gt(n,i,o,r,e[7],4249261313,22),r=Gt(r,n,i,o,e[8],1770035416,7),o=Gt(o,r,n,i,e[9],2336552879,12),i=Gt(i,o,r,n,e[10],4294925233,17),n=Gt(n,i,o,r,e[11],2304563134,22),r=Gt(r,n,i,o,e[12],1804603682,7),o=Gt(o,r,n,i,e[13],4254626195,12),i=Gt(i,o,r,n,e[14],2792965006,17),n=Gt(n,i,o,r,e[15],1236535329,22),r=zt(r,n,i,o,e[1],4129170786,5),o=zt(o,r,n,i,e[6],3225465664,9),i=zt(i,o,r,n,e[11],643717713,14),n=zt(n,i,o,r,e[0],3921069994,20),r=zt(r,n,i,o,e[5],3593408605,5),o=zt(o,r,n,i,e[10],38016083,9),i=zt(i,o,r,n,e[15],3634488961,14),n=zt(n,i,o,r,e[4],3889429448,20),r=zt(r,n,i,o,e[9],568446438,5),o=zt(o,r,n,i,e[14],3275163606,9),i=zt(i,o,r,n,e[3],4107603335,14),n=zt(n,i,o,r,e[8],1163531501,20),r=zt(r,n,i,o,e[13],2850285829,5),o=zt(o,r,n,i,e[2],4243563512,9),i=zt(i,o,r,n,e[7],1735328473,14),n=zt(n,i,o,r,e[12],2368359562,20),r=Wt(r,n,i,o,e[5],4294588738,4),o=Wt(o,r,n,i,e[8],2272392833,11),i=Wt(i,o,r,n,e[11],1839030562,16),n=Wt(n,i,o,r,e[14],4259657740,23),r=Wt(r,n,i,o,e[1],2763975236,4),o=Wt(o,r,n,i,e[4],1272893353,11),i=Wt(i,o,r,n,e[7],4139469664,16),n=Wt(n,i,o,r,e[10],3200236656,23),r=Wt(r,n,i,o,e[13],681279174,4),o=Wt(o,r,n,i,e[0],3936430074,11),i=Wt(i,o,r,n,e[3],3572445317,16),n=Wt(n,i,o,r,e[6],76029189,23),r=Wt(r,n,i,o,e[9],3654602809,4),o=Wt(o,r,n,i,e[12],3873151461,11),i=Wt(i,o,r,n,e[15],530742520,16),n=Wt(n,i,o,r,e[2],3299628645,23),r=Yt(r,n,i,o,e[0],4096336452,6),o=Yt(o,r,n,i,e[7],1126891415,10),i=Yt(i,o,r,n,e[14],2878612391,15),n=Yt(n,i,o,r,e[5],4237533241,21),r=Yt(r,n,i,o,e[12],1700485571,6),o=Yt(o,r,n,i,e[3],2399980690,10),i=Yt(i,o,r,n,e[10],4293915773,15),n=Yt(n,i,o,r,e[1],2240044497,21),r=Yt(r,n,i,o,e[8],1873313359,6),o=Yt(o,r,n,i,e[15],4264355552,10),i=Yt(i,o,r,n,e[6],2734768916,15),n=Yt(n,i,o,r,e[13],1309151649,21),r=Yt(r,n,i,o,e[4],4149444226,6),o=Yt(o,r,n,i,e[11],3174756917,10),i=Yt(i,o,r,n,e[2],718787259,15),n=Yt(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0};Zu.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=p2.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Xu(e,t){return e<<t|e>>>32-t}function Gt(e,t,r,n,i,o,s){return Xu(e+(t&r|~t&n)+i+o|0,s)+t|0}function zt(e,t,r,n,i,o,s){return Xu(e+(t&n|r&~n)+i+o|0,s)+t|0}function Wt(e,t,r,n,i,o,s){return Xu(e+(t^r^n)+i+o|0,s)+t|0}function Yt(e,t,r,n,i,o,s){return Xu(e+(r^(t|~n))+i+o|0,s)+t|0}_v.exports=Zu});var wv=P((WL,Sv)=>{m();var y2={}.toString;Sv.exports=Array.isArray||function(e){return y2.call(e)=="[object Array]"}});var xv=P(($L,Ev)=>{"use strict";m();var m2=wi(),v2=Vn(),b2=v2("TypedArray.prototype.buffer",!0),_2=$l();Ev.exports=b2||function(t){if(!_2(t))throw new m2("Not a Typed Array");return t.buffer}});var Ju=P((XL,Av)=>{"use strict";m();var Mr=qt().Buffer,S2=wv(),w2=xv(),E2=ArrayBuffer.isView||function(t){try{return w2(t),!0}catch{return!1}},x2=typeof Uint8Array<"u",Iv=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",I2=Iv&&(Mr.prototype instanceof Uint8Array||Mr.TYPED_ARRAY_SUPPORT);Av.exports=function(t,r){if(Mr.isBuffer(t))return t.constructor&&!("isBuffer"in t)?Mr.from(t):t;if(typeof t=="string")return Mr.from(t,r);if(Iv&&E2(t)){if(t.byteLength===0)return Mr.alloc(0);if(I2){var n=Mr.from(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength===t.byteLength)return n}var i=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=Mr.from(i);if(o.length===t.byteLength)return o}if(x2&&t instanceof Uint8Array)return Mr.from(t);var s=S2(t);if(s)for(var a=0;a<t.length;a+=1){var c=t[a];if(typeof c!="number"||c<0||c>255||~~c!==c)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||Mr.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return Mr.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}});var Pv=P((QL,Tv)=>{"use strict";m();var A2=qt().Buffer,O2=Ju(),Rv=typeof Uint8Array<"u",R2=Rv&&typeof ArrayBuffer<"u",Ov=R2&&ArrayBuffer.isView;Tv.exports=function(e,t){if(typeof e=="string"||A2.isBuffer(e)||Rv&&e instanceof Uint8Array||Ov&&Ov(e))return O2(e,t);throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView')}});var ks=P((t4,Mh)=>{"use strict";m();typeof x.default>"u"||!x.default.version||x.default.version.indexOf("v0.")===0||x.default.version.indexOf("v1.")===0&&x.default.version.indexOf("v1.8.")!==0?Mh.exports={nextTick:T2}:Mh.exports=x.default;function T2(e,t,r,n){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var i=arguments.length,o,s;switch(i){case 0:case 1:return x.default.nextTick(e);case 2:return x.default.nextTick(function(){e.call(null,t)});case 3:return x.default.nextTick(function(){e.call(null,t,r)});case 4:return x.default.nextTick(function(){e.call(null,t,r,n)});default:for(o=new Array(i-1),s=0;s<o.length;)o[s++]=arguments[s];return x.default.nextTick(function(){e.apply(null,o)})}}});var Nv=P((n4,Bv)=>{m();var P2={}.toString;Bv.exports=Array.isArray||function(e){return P2.call(e)=="[object Array]"}});var kh=P((o4,Mv)=>{m();Mv.exports=yo().EventEmitter});var ef=P((Ch,Cv)=>{m();var Qu=Tt(),_n=Qu.Buffer;function kv(e,t){for(var r in e)t[r]=e[r]}_n.from&&_n.alloc&&_n.allocUnsafe&&_n.allocUnsafeSlow?Cv.exports=Qu:(kv(Qu,Ch),Ch.Buffer=No);function No(e,t,r){return _n(e,t,r)}kv(_n,No);No.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return _n(e,t,r)};No.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var n=_n(e);return t!==void 0?typeof r=="string"?n.fill(t,r):n.fill(t):n.fill(0),n};No.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return _n(e)};No.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Qu.SlowBuffer(e)}});var Mo=P($t=>{m();function B2(e){return Array.isArray?Array.isArray(e):tf(e)==="[object Array]"}$t.isArray=B2;function N2(e){return typeof e=="boolean"}$t.isBoolean=N2;function M2(e){return e===null}$t.isNull=M2;function k2(e){return e==null}$t.isNullOrUndefined=k2;function C2(e){return typeof e=="number"}$t.isNumber=C2;function L2(e){return typeof e=="string"}$t.isString=L2;function D2(e){return typeof e=="symbol"}$t.isSymbol=D2;function U2(e){return e===void 0}$t.isUndefined=U2;function F2(e){return tf(e)==="[object RegExp]"}$t.isRegExp=F2;function q2(e){return typeof e=="object"&&e!==null}$t.isObject=q2;function H2(e){return tf(e)==="[object Date]"}$t.isDate=H2;function j2(e){return tf(e)==="[object Error]"||e instanceof Error}$t.isError=j2;function K2(e){return typeof e=="function"}$t.isFunction=K2;function V2(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}$t.isPrimitive=V2;$t.isBuffer=Tt().Buffer.isBuffer;function tf(e){return Object.prototype.toString.call(e)}});var Dv=P((c4,Lh)=>{"use strict";m();function G2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Lv=ef().Buffer,Cs=en();function z2(e,t,r){e.copy(t,r)}Lh.exports=(function(){function e(){G2(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},e.prototype.unshift=function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},e.prototype.shift=function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},e.prototype.concat=function(r){if(this.length===0)return Lv.alloc(0);for(var n=Lv.allocUnsafe(r>>>0),i=this.head,o=0;i;)z2(i.data,n,o),o+=i.data.length,i=i.next;return n},e})();Cs&&Cs.inspect&&Cs.inspect.custom&&(Lh.exports.prototype[Cs.inspect.custom]=function(){var e=Cs.inspect({length:this.length});return this.constructor.name+" "+e})});var Dh=P((h4,Uv)=>{"use strict";m();var rf=ks();function W2(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,rf.nextTick(nf,this,e)):rf.nextTick(nf,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?r._writableState?r._writableState.errorEmitted||(r._writableState.errorEmitted=!0,rf.nextTick(nf,r,o)):rf.nextTick(nf,r,o):t&&t(o)}),this)}function Y2(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function nf(e,t){e.emit("error",t)}Uv.exports={destroy:W2,undestroy:Y2}});var Fh=P((p4,zv)=>{"use strict";m();var Ni=ks();zv.exports=Et;function qv(e){var t=this;this.next=null,this.entry=null,this.finish=function(){hP(t,e)}}var $2=!x.default.browser&&["v0.10","v0.9."].indexOf(x.default.version.slice(0,5))>-1?setImmediate:Ni.nextTick,ko;Et.WritableState=Ds;var Hv=Object.create(Mo());Hv.inherits=De();var Z2={deprecate:uh()},jv=kh(),sf=ef().Buffer,X2=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function J2(e){return sf.from(e)}function Q2(e){return sf.isBuffer(e)||e instanceof X2}var Kv=Dh();Hv.inherits(Et,jv);function eP(){}function Ds(e,t){ko=ko||Mi(),e=e||{};var r=t instanceof ko;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var n=e.highWaterMark,i=e.writableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=e.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){aP(t,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new qv(this)}Ds.prototype.getBuffer=function(){for(var t=this.bufferedRequest,r=[];t;)r.push(t),t=t.next;return r};(function(){try{Object.defineProperty(Ds.prototype,"buffer",{get:Z2.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var of;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(of=Function.prototype[Symbol.hasInstance],Object.defineProperty(Et,Symbol.hasInstance,{value:function(e){return of.call(this,e)?!0:this!==Et?!1:e&&e._writableState instanceof Ds}})):of=function(e){return e instanceof this};function Et(e){if(ko=ko||Mi(),!of.call(Et,this)&&!(this instanceof ko))return new Et(e);this._writableState=new Ds(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),jv.call(this)}Et.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function tP(e,t){var r=new Error("write after end");e.emit("error",r),Ni.nextTick(t,r)}function rP(e,t,r,n){var i=!0,o=!1;return r===null?o=new TypeError("May not write null values to stream"):typeof r!="string"&&r!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),Ni.nextTick(n,o),i=!1),i}Et.prototype.write=function(e,t,r){var n=this._writableState,i=!1,o=!n.objectMode&&Q2(e);return o&&!sf.isBuffer(e)&&(e=J2(e)),typeof t=="function"&&(r=t,t=null),o?t="buffer":t||(t=n.defaultEncoding),typeof r!="function"&&(r=eP),n.ended?tP(this,r):(o||rP(this,n,e,r))&&(n.pendingcb++,i=iP(this,n,o,e,t,r)),i};Et.prototype.cork=function(){var e=this._writableState;e.corked++};Et.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&Vv(this,e))};Et.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function nP(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=sf.from(t,r)),t}Object.defineProperty(Et.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function iP(e,t,r,n,i,o){if(!r){var s=nP(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var h=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},h?h.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Uh(e,t,!1,a,n,i,o);return c}function Uh(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function oP(e,t,r,n,i){--t.pendingcb,r?(Ni.nextTick(i,n),Ni.nextTick(Ls,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),Ls(e,t))}function sP(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function aP(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(sP(r),t)oP(e,r,n,t,i);else{var o=Gv(r);!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Vv(e,r),n?$2(Fv,e,r,o,i):Fv(e,r,o,i)}}function Fv(e,t,r,n){r||uP(e,t),t.pendingcb--,n(),Ls(e,t)}function uP(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function Vv(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Uh(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new qv(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,h=r.encoding,g=r.callback,y=t.objectMode?1:c.length;if(Uh(e,t,!1,y,c,h,g),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}Et.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))};Et.prototype._writev=null;Et.prototype.end=function(e,t,r){var n=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null),e!=null&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||lP(this,n,r)};function Gv(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function fP(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),Ls(e,t)})}function cP(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,Ni.nextTick(fP,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Ls(e,t){var r=Gv(t);return r&&(cP(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),r}function lP(e,t,r){t.ending=!0,Ls(e,t),r&&(t.finished?Ni.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function hP(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}Object.defineProperty(Et.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Et.prototype.destroy=Kv.destroy;Et.prototype._undestroy=Kv.undestroy;Et.prototype._destroy=function(e,t){this.end(),t(e)}});var Mi=P((y4,Zv)=>{"use strict";m();var Wv=ks(),dP=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};Zv.exports=Sn;var Yv=Object.create(Mo());Yv.inherits=De();var $v=jh(),Hh=Fh();Yv.inherits(Sn,$v);for(qh=dP(Hh.prototype),af=0;af<qh.length;af++)uf=qh[af],Sn.prototype[uf]||(Sn.prototype[uf]=Hh.prototype[uf]);var qh,uf,af;function Sn(e){if(!(this instanceof Sn))return new Sn(e);$v.call(this,e),Hh.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",pP)}Object.defineProperty(Sn.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function pP(){this.allowHalfOpen||this._writableState.ended||Wv.nextTick(gP,this)}function gP(e){e.end()}Object.defineProperty(Sn.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});Sn.prototype._destroy=function(e,t){this.push(null),this.end(),Wv.nextTick(t,e)}});var jh=P((b4,ub)=>{"use strict";m();var Lo=ks();ub.exports=ze;var yP=Nv(),Us;ze.ReadableState=nb;var v4=yo().EventEmitter,eb=function(e,t){return e.listeners(t).length},Wh=kh(),Fs=ef().Buffer,mP=(typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function vP(e){return Fs.from(e)}function bP(e){return Fs.isBuffer(e)||e instanceof mP}var tb=Object.create(Mo());tb.inherits=De();var Kh=en(),Ne=void 0;Kh&&Kh.debuglog?Ne=Kh.debuglog("stream"):Ne=function(){};var _P=Dv(),rb=Dh(),Co;tb.inherits(ze,Wh);var Vh=["error","close","destroy","pause","resume"];function SP(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):yP(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}function nb(e,t){Us=Us||Mi(),e=e||{};var r=t instanceof Us;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,i=e.readableHighWaterMark,o=this.objectMode?16:16*1024;n||n===0?this.highWaterMark=n:r&&(i||i===0)?this.highWaterMark=i:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new _P,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Co||(Co=To().StringDecoder),this.decoder=new Co(e.encoding),this.encoding=e.encoding)}function ze(e){if(Us=Us||Mi(),!(this instanceof ze))return new ze(e);this._readableState=new nb(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),Wh.call(this)}Object.defineProperty(ze.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});ze.prototype.destroy=rb.destroy;ze.prototype._undestroy=rb.undestroy;ze.prototype._destroy=function(e,t){this.push(null),t(e)};ze.prototype.push=function(e,t){var r=this._readableState,n;return r.objectMode?n=!0:typeof e=="string"&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=Fs.from(e,t),t=""),n=!0),ib(this,e,t,!1,n)};ze.prototype.unshift=function(e){return ib(this,e,null,!0,!1)};function ib(e,t,r,n,i){var o=e._readableState;if(t===null)o.reading=!1,IP(e,o);else{var s;i||(s=wP(o,t)),s?e.emit("error",s):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Fs.prototype&&(t=vP(t)),n?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):Gh(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||t.length!==0?Gh(e,o,t,!1):ob(e,o)):Gh(e,o,t,!1))):n||(o.reading=!1)}return EP(o)}function Gh(e,t,r,n){t.flowing&&t.length===0&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&ff(e)),ob(e,t)}function wP(e,t){var r;return!bP(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(r=new TypeError("Invalid non-string/buffer chunk")),r}function EP(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}ze.prototype.isPaused=function(){return this._readableState.flowing===!1};ze.prototype.setEncoding=function(e){return Co||(Co=To().StringDecoder),this._readableState.decoder=new Co(e),this._readableState.encoding=e,this};var Xv=8388608;function xP(e){return e>=Xv?e=Xv:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function Jv(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=xP(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}ze.prototype.read=function(e){Ne("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Ne("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?zh(this):ff(this),null;if(e=Jv(e,t),e===0&&t.ended)return t.length===0&&zh(this),null;var n=t.needReadable;Ne("need readable",n),(t.length===0||t.length-e<t.highWaterMark)&&(n=!0,Ne("length less than watermark",n)),t.ended||t.reading?(n=!1,Ne("reading or ended",n)):n&&(Ne("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Jv(r,t)));var i;return e>0?i=sb(e,t):i=null,i===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&zh(this)),i!==null&&this.emit("data",i),i};function IP(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,ff(e)}}function ff(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Ne("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Lo.nextTick(Qv,e):Qv(e))}function Qv(e){Ne("emit readable"),e.emit("readable"),Yh(e)}function ob(e,t){t.readingMore||(t.readingMore=!0,Lo.nextTick(AP,e,t))}function AP(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Ne("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}ze.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};ze.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e);break}n.pipesCount+=1,Ne("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||t.end!==!1)&&e!==x.default.stdout&&e!==x.default.stderr,o=i?a:L;n.endEmitted?Lo.nextTick(o):r.once("end",o),e.on("unpipe",s);function s(j,G){Ne("onunpipe"),j===r&&G&&G.hasUnpiped===!1&&(G.hasUnpiped=!0,g())}function a(){Ne("onend"),e.end()}var c=OP(r);e.on("drain",c);var h=!1;function g(){Ne("cleanup"),e.removeListener("close",T),e.removeListener("finish",M),e.removeListener("drain",c),e.removeListener("error",I),e.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",L),r.removeListener("data",w),h=!0,n.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var y=!1;r.on("data",w);function w(j){Ne("ondata"),y=!1;var G=e.write(j);G===!1&&!y&&((n.pipesCount===1&&n.pipes===e||n.pipesCount>1&&ab(n.pipes,e)!==-1)&&!h&&(Ne("false write response, pause",n.awaitDrain),n.awaitDrain++,y=!0),r.pause())}function I(j){Ne("onerror",j),L(),e.removeListener("error",I),eb(e,"error")===0&&e.emit("error",j)}SP(e,"error",I);function T(){e.removeListener("finish",M),L()}e.once("close",T);function M(){Ne("onfinish"),e.removeListener("close",T),L()}e.once("finish",M);function L(){Ne("unpipe"),r.unpipe(e)}return e.emit("pipe",r),n.flowing||(Ne("pipe resume"),r.resume()),e};function OP(e){return function(){var t=e._readableState;Ne("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&eb(e,"data")&&(t.flowing=!0,Yh(e))}}ze.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=ab(t.pipes,e);return s===-1?this:(t.pipes.splice(s,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)};ze.prototype.on=function(e,t){var r=Wh.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var n=this._readableState;!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&ff(this):Lo.nextTick(RP,this))}return r};ze.prototype.addListener=ze.prototype.on;function RP(e){Ne("readable nexttick read 0"),e.read(0)}ze.prototype.resume=function(){var e=this._readableState;return e.flowing||(Ne("resume"),e.flowing=!0,TP(this,e)),this};function TP(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Lo.nextTick(PP,e,t))}function PP(e,t){t.reading||(Ne("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),Yh(e),t.flowing&&!t.reading&&e.read(0)}ze.prototype.pause=function(){return Ne("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Ne("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function Yh(e){var t=e._readableState;for(Ne("flow",t.flowing);t.flowing&&e.read()!==null;);}ze.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;e.on("end",function(){if(Ne("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&t.push(s)}t.push(null)}),e.on("data",function(s){if(Ne("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=t.push(s);a||(n=!0,e.pause())}});for(var i in e)this[i]===void 0&&typeof e[i]=="function"&&(this[i]=(function(s){return function(){return e[s].apply(e,arguments)}})(i));for(var o=0;o<Vh.length;o++)e.on(Vh[o],this.emit.bind(this,Vh[o]));return this._read=function(s){Ne("wrapped _read",s),n&&(n=!1,e.resume())},this};Object.defineProperty(ze.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});ze._fromList=sb;function sb(e,t){if(t.length===0)return null;var r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.head.data:r=t.buffer.concat(t.length),t.buffer.clear()):r=BP(e,t.buffer,t.decoder),r}function BP(e,t,r){var n;return e<t.head.data.length?(n=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?n=t.shift():n=r?NP(e,t):MP(e,t),n}function NP(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),e-=s,e===0){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}function MP(e,t){var r=Fs.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),e-=s,e===0){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}function zh(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Lo.nextTick(kP,t,e))}function kP(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ab(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}});var $h=P((S4,lb)=>{"use strict";m();lb.exports=wn;var cf=Mi(),cb=Object.create(Mo());cb.inherits=De();cb.inherits(wn,cf);function CP(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function wn(e){if(!(this instanceof wn))return new wn(e);cf.call(this,e),this._transformState={afterTransform:CP.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",LP)}function LP(){var e=this;typeof this._flush=="function"?this._flush(function(t,r){fb(e,t,r)}):fb(this,null,null)}wn.prototype.push=function(e,t){return this._transformState.needTransform=!1,cf.prototype.push.call(this,e,t)};wn.prototype._transform=function(e,t,r){throw new Error("_transform() is not implemented")};wn.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};wn.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};wn.prototype._destroy=function(e,t){var r=this;cf.prototype._destroy.call(this,e,function(n){t(n),r.emit("close")})};function fb(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var gb=P((E4,pb)=>{"use strict";m();pb.exports=qs;var hb=$h(),db=Object.create(Mo());db.inherits=De();db.inherits(qs,hb);function qs(e){if(!(this instanceof qs))return new qs(e);hb.call(this,e)}qs.prototype._transform=function(e,t,r){r(null,e)}});var mb=P((nn,yb)=>{m();nn=yb.exports=jh();nn.Stream=nn;nn.Readable=nn;nn.Writable=Fh();nn.Duplex=Mi();nn.Transform=$h();nn.PassThrough=gb()});var _b=P((A4,bb)=>{"use strict";m();var DP=qt().Buffer,UP=Pv(),vb=mb().Transform,FP=De();function Xn(e){vb.call(this),this._block=DP.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}FP(Xn,vb);Xn.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Xn.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Xn.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");for(var r=UP(e,t),n=this._block,i=0;this._blockOffset+r.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o]=r[i],o+=1,i+=1;this._update(),this._blockOffset=0}for(;i<r.length;)n[this._blockOffset]=r[i],this._blockOffset+=1,i+=1;for(var s=0,a=r.length*8;a>0;++s)this._length[s]+=a,a=this._length[s]/4294967296|0,a>0&&(this._length[s]-=4294967296*a);return this};Xn.prototype._update=function(){throw new Error("_update is not implemented")};Xn.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Xn.prototype._digest=function(){throw new Error("_digest is not implemented")};bb.exports=Xn});var Xh=P((R4,Ob)=>{"use strict";m();var Zh=Tt().Buffer,qP=De(),Ab=_b(),HP=new Array(16),Hs=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],js=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ks=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Vs=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Gs=[0,1518500249,1859775393,2400959708,2840853838],zs=[1352829926,1548603684,1836072691,2053994217,0];function ki(e,t){return e<<t|e>>>32-t}function Sb(e,t,r,n,i,o,s,a){return ki(e+(t^r^n)+o+s|0,a)+i|0}function wb(e,t,r,n,i,o,s,a){return ki(e+(t&r|~t&n)+o+s|0,a)+i|0}function Eb(e,t,r,n,i,o,s,a){return ki(e+((t|~r)^n)+o+s|0,a)+i|0}function xb(e,t,r,n,i,o,s,a){return ki(e+(t&n|r&~n)+o+s|0,a)+i|0}function Ib(e,t,r,n,i,o,s,a){return ki(e+(t^(r|~n))+o+s|0,a)+i|0}function lf(){Ab.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}qP(lf,Ab);lf.prototype._update=function(){for(var e=HP,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._a|0,c=this._b|0,h=this._c|0,g=this._d|0,y=this._e|0,w=0;w<80;w+=1){var I,T;w<16?(I=Sb(r,n,i,o,s,e[Hs[w]],Gs[0],Ks[w]),T=Ib(a,c,h,g,y,e[js[w]],zs[0],Vs[w])):w<32?(I=wb(r,n,i,o,s,e[Hs[w]],Gs[1],Ks[w]),T=xb(a,c,h,g,y,e[js[w]],zs[1],Vs[w])):w<48?(I=Eb(r,n,i,o,s,e[Hs[w]],Gs[2],Ks[w]),T=Eb(a,c,h,g,y,e[js[w]],zs[2],Vs[w])):w<64?(I=xb(r,n,i,o,s,e[Hs[w]],Gs[3],Ks[w]),T=wb(a,c,h,g,y,e[js[w]],zs[3],Vs[w])):(I=Ib(r,n,i,o,s,e[Hs[w]],Gs[4],Ks[w]),T=Sb(a,c,h,g,y,e[js[w]],zs[4],Vs[w])),r=s,s=o,o=ki(i,10),i=n,n=I,a=y,y=g,g=ki(h,10),h=c,c=T}var M=this._b+i+g|0;this._b=this._c+o+y|0,this._c=this._d+s+a|0,this._d=this._e+r+c|0,this._e=this._a+n+h|0,this._a=M};lf.prototype._digest=function(){this._block[this._blockOffset]=128,this._blockOffset+=1,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Zh.alloc?Zh.alloc(20):new Zh(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};Ob.exports=lf});var Ci=P((P4,Rb)=>{"use strict";m();var jP=qt().Buffer,KP=Ju();function hf(e,t){this._block=jP.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}hf.prototype.update=function(e,t){e=KP(e,t||"utf8");for(var r=this._block,n=this._blockSize,i=e.length,o=this._len,s=0;s<i;){for(var a=o%n,c=Math.min(i-s,n-a),h=0;h<c;h++)r[a+h]=e[s+h];o+=c,s+=c,o%n===0&&this._update(r)}return this._len+=i,this};hf.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o};hf.prototype._update=function(){throw new Error("_update must be implemented by subclass")};Rb.exports=hf});var Bb=P((N4,Pb)=>{"use strict";m();var VP=De(),Tb=Ci(),GP=qt().Buffer,zP=[1518500249,1859775393,-1894007588,-899497514],WP=new Array(80);function Ws(){this.init(),this._w=WP,Tb.call(this,64,56)}VP(Ws,Tb);Ws.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function YP(e){return e<<5|e>>>27}function $P(e){return e<<30|e>>>2}function ZP(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ws.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var c=0;c<80;++c){var h=~~(c/20),g=YP(r)+ZP(h,n,i,o)+s+t[c]+zP[h]|0;s=o,o=i,i=$P(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Ws.prototype._hash=function(){var e=GP.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Pb.exports=Ws});var kb=P((k4,Mb)=>{"use strict";m();var XP=De(),Nb=Ci(),JP=qt().Buffer,QP=[1518500249,1859775393,-1894007588,-899497514],eB=new Array(80);function Ys(){this.init(),this._w=eB,Nb.call(this,64,56)}XP(Ys,Nb);Ys.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function tB(e){return e<<1|e>>>31}function rB(e){return e<<5|e>>>27}function nB(e){return e<<30|e>>>2}function iB(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Ys.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=tB(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var c=0;c<80;++c){var h=~~(c/20),g=rB(r)+iB(h,n,i,o)+s+t[c]+QP[h]|0;s=o,o=i,i=nB(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0};Ys.prototype._hash=function(){var e=JP.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};Mb.exports=Ys});var Jh=P((L4,Lb)=>{"use strict";m();var oB=De(),Cb=Ci(),sB=qt().Buffer,aB=[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],uB=new Array(64);function $s(){this.init(),this._w=uB,Cb.call(this,64,56)}oB($s,Cb);$s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function fB(e,t,r){return r^e&(t^r)}function cB(e,t,r){return e&t|r&(e|t)}function lB(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function hB(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function dB(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function pB(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}$s.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,a=this._f|0,c=this._g|0,h=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=pB(t[g-2])+t[g-7]+dB(t[g-15])+t[g-16]|0;for(var y=0;y<64;++y){var w=h+hB(s)+fB(s,a,c)+aB[y]+t[y]|0,I=lB(r)+cB(r,n,i)|0;h=c,c=a,a=s,s=o+w|0,o=i,i=n,n=r,r=w+I|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=h+this._h|0};$s.prototype._hash=function(){var e=sB.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};Lb.exports=$s});var Ub=P((U4,Db)=>{"use strict";m();var gB=De(),yB=Jh(),mB=Ci(),vB=qt().Buffer,bB=new Array(64);function df(){this.init(),this._w=bB,mB.call(this,64,56)}gB(df,yB);df.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};df.prototype._hash=function(){var e=vB.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};Db.exports=df});var Qh=P((q4,Gb)=>{"use strict";m();var _B=De(),Vb=Ci(),SB=qt().Buffer,Fb=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],wB=new Array(160);function Zs(){this.init(),this._w=wB,Vb.call(this,128,112)}_B(Zs,Vb);Zs.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function qb(e,t,r){return r^e&(t^r)}function Hb(e,t,r){return e&t|r&(e|t)}function jb(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function Kb(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function EB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function xB(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function IB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function AB(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Ct(e,t){return e>>>0<t>>>0?1:0}Zs.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,o=this._dh|0,s=this._eh|0,a=this._fh|0,c=this._gh|0,h=this._hh|0,g=this._al|0,y=this._bl|0,w=this._cl|0,I=this._dl|0,T=this._el|0,M=this._fl|0,L=this._gl|0,j=this._hl|0,G=0;G<32;G+=2)t[G]=e.readInt32BE(G*4),t[G+1]=e.readInt32BE(G*4+4);for(;G<160;G+=2){var q=t[G-30],W=t[G-30+1],J=EB(q,W),Y=xB(W,q);q=t[G-4],W=t[G-4+1];var be=IB(q,W),se=AB(W,q),de=t[G-14],A=t[G-14+1],u=t[G-32],l=t[G-32+1],p=Y+A|0,v=J+de+Ct(p,Y)|0;p=p+se|0,v=v+be+Ct(p,se)|0,p=p+l|0,v=v+u+Ct(p,l)|0,t[G]=v,t[G+1]=p}for(var b=0;b<160;b+=2){v=t[b],p=t[b+1];var E=Hb(r,n,i),O=Hb(g,y,w),_=jb(r,g),f=jb(g,r),S=Kb(s,T),K=Kb(T,s),F=Fb[b],$=Fb[b+1],Z=qb(s,a,c),Q=qb(T,M,L),ae=j+K|0,ge=h+S+Ct(ae,j)|0;ae=ae+Q|0,ge=ge+Z+Ct(ae,Q)|0,ae=ae+$|0,ge=ge+F+Ct(ae,$)|0,ae=ae+p|0,ge=ge+v+Ct(ae,p)|0;var le=f+O|0,R=_+E+Ct(le,f)|0;h=c,j=L,c=a,L=M,a=s,M=T,T=I+ae|0,s=o+ge+Ct(T,I)|0,o=i,I=w,i=n,w=y,n=r,y=g,g=ae+le|0,r=ge+R+Ct(g,ae)|0}this._al=this._al+g|0,this._bl=this._bl+y|0,this._cl=this._cl+w|0,this._dl=this._dl+I|0,this._el=this._el+T|0,this._fl=this._fl+M|0,this._gl=this._gl+L|0,this._hl=this._hl+j|0,this._ah=this._ah+r+Ct(this._al,g)|0,this._bh=this._bh+n+Ct(this._bl,y)|0,this._ch=this._ch+i+Ct(this._cl,w)|0,this._dh=this._dh+o+Ct(this._dl,I)|0,this._eh=this._eh+s+Ct(this._el,T)|0,this._fh=this._fh+a+Ct(this._fl,M)|0,this._gh=this._gh+c+Ct(this._gl,L)|0,this._hh=this._hh+h+Ct(this._hl,j)|0};Zs.prototype._hash=function(){var e=SB.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};Gb.exports=Zs});var Wb=P((j4,zb)=>{"use strict";m();var OB=De(),RB=Qh(),TB=Ci(),PB=qt().Buffer,BB=new Array(160);function pf(){this.init(),this._w=BB,TB.call(this,128,112)}OB(pf,RB);pf.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};pf.prototype._hash=function(){var e=PB.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};zb.exports=pf});var ed=P((V4,En)=>{"use strict";m();En.exports=function(t){var r=t.toLowerCase(),n=En.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n};En.exports.sha=Bb();En.exports.sha1=kb();En.exports.sha224=Ub();En.exports.sha256=Jh();En.exports.sha384=Wb();En.exports.sha512=Qh()});var gf=P((z4,$b)=>{"use strict";m();var NB=qt().Buffer,Yb=Bh().Transform,MB=To().StringDecoder,kB=De(),CB=Ju();function kr(e){Yb.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}kB(kr,Yb);kr.prototype.update=function(e,t,r){var n=CB(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};kr.prototype.setAutoPadding=function(){};kr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};kr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};kr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};kr.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};kr.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};kr.prototype._finalOrDigest=function(e){var t=this.__final()||NB.alloc(0);return e&&(t=this._toString(t,e,!0)),t};kr.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new MB(t),this._encoding=t),this._encoding!==t)throw new Error("can\u2019t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};$b.exports=kr});var Jb=P((Y4,Xb)=>{"use strict";m();var LB=De(),DB=Nh(),UB=Xh(),FB=ed(),Zb=gf();function yf(e){Zb.call(this,"digest"),this._hash=e}LB(yf,Zb);yf.prototype._update=function(e){this._hash.update(e)};yf.prototype._final=function(){return this._hash.digest()};Xb.exports=function(t){return t=t.toLowerCase(),t==="md5"?new DB:t==="rmd160"||t==="ripemd160"?new UB:new yf(FB(t))}});var t_=P((Z4,e_)=>{"use strict";m();var qB=De(),Li=qt().Buffer,Qb=gf(),HB=Li.alloc(128),Do=64;function mf(e,t){Qb.call(this,"digest"),typeof t=="string"&&(t=Li.from(t)),this._alg=e,this._key=t,t.length>Do?t=e(t):t.length<Do&&(t=Li.concat([t,HB],Do));for(var r=this._ipad=Li.allocUnsafe(Do),n=this._opad=Li.allocUnsafe(Do),i=0;i<Do;i++)r[i]=t[i]^54,n[i]=t[i]^92;this._hash=[r]}qB(mf,Qb);mf.prototype._update=function(e){this._hash.push(e)};mf.prototype._final=function(){var e=this._alg(Li.concat(this._hash));return this._alg(Li.concat([this._opad,e]))};e_.exports=mf});var n_=P((J4,r_)=>{m();var jB=Nh();r_.exports=function(e){return new jB().update(e).digest()}});var s_=P((eD,o_)=>{"use strict";m();var KB=De(),VB=t_(),i_=gf(),Xs=qt().Buffer,GB=n_(),td=Xh(),rd=ed(),zB=Xs.alloc(128);function Js(e,t){i_.call(this,"digest"),typeof t=="string"&&(t=Xs.from(t));var r=e==="sha512"||e==="sha384"?128:64;if(this._alg=e,this._key=t,t.length>r){var n=e==="rmd160"?new td:rd(e);t=n.update(t).digest()}else t.length<r&&(t=Xs.concat([t,zB],r));for(var i=this._ipad=Xs.allocUnsafe(r),o=this._opad=Xs.allocUnsafe(r),s=0;s<r;s++)i[s]=t[s]^54,o[s]=t[s]^92;this._hash=e==="rmd160"?new td:rd(e),this._hash.update(i)}KB(Js,i_);Js.prototype._update=function(e){this._hash.update(e)};Js.prototype._final=function(){var e=this._hash.digest(),t=this._alg==="rmd160"?new td:rd(this._alg);return t.update(this._opad).update(e).digest()};o_.exports=function(t,r){return t=t.toLowerCase(),t==="rmd160"||t==="ripemd160"?new Js("rmd160",r):t==="md5"?new VB(GB,r):new Js(t,r)}});var a_=P((rD,id)=>{"use strict";m();var nd=65536,WB=4294967295;function YB(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
11
11
|
Use Chrome, Firefox or Internet Explorer 11`)}var $B=qt().Buffer,vf=globalThis.crypto||globalThis.msCrypto;vf&&vf.getRandomValues?id.exports=ZB:id.exports=YB;function ZB(e,t){if(e>WB)throw new RangeError("requested too many random bytes");var r=$B.allocUnsafe(e);if(e>0)if(e>nd)for(var n=0;n<e;n+=nd)vf.getRandomValues(r.slice(n,n+nd));else vf.getRandomValues(r);return typeof t=="function"?x.default.nextTick(function(){t(null,r)}):r}});var Qs=P(bf=>{"use strict";m();bf.createHash=Jb();bf.createHmac=s_();bf.randomBytes=a_()});var ea=P((sD,f_)=>{"use strict";m();var u_=65536;function Di(){}Di.getRandomBuffer=function(e){var t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t&&typeof t.getRandomValues=="function")return Di._fromGetRandomValues(t,e);try{var r=Qs();if(r&&typeof r.randomBytes=="function")return r.randomBytes(e)}catch{}throw new Error("bsv: no CSPRNG available in this environment (needs globalThis.crypto.getRandomValues or node crypto)")};Di._fromGetRandomValues=function(e,t){for(var r=d.Buffer.alloc(t),n=0;n<t;n+=u_){var i=new Uint8Array(Math.min(u_,t-n));e.getRandomValues(i),d.Buffer.from(i).copy(r,n)}return r};Di.getRandomBufferNode=function(e){var t=Qs();return t.randomBytes(e)};Di.getRandomBufferBrowser=function(e){var t=typeof globalThis<"u"?globalThis:{},r=null;if(t.crypto&&typeof t.crypto.getRandomValues=="function"?r=t.crypto:t.msCrypto&&typeof t.msCrypto.getRandomValues=="function"&&(r=t.msCrypto),!r)throw new Error("window.crypto.getRandomValues not available");return Di._fromGetRandomValues(r,e)};f_.exports=Di});var Ve=P((uD,c_)=>{"use strict";m();var XB=ea(),Ke={};Ke.isArray=e=>Array.isArray(e);Ke.isNumber=e=>typeof e=="number";Ke.isObject=e=>e&&typeof e=="object";Ke.isString=e=>typeof e=="string";Ke.isUndefined=e=>typeof e>"u";Ke.isFunction=e=>typeof e=="function";Ke.isNull=e=>e===null;Ke.isDate=e=>e instanceof Date;Ke.extend=(e,t)=>Object.assign(e,t);Ke.noop=()=>{};Ke.every=(e,t)=>e.every(t||(r=>r));Ke.map=(e,t)=>Array.from(e).map(t||(r=>r));Ke.includes=(e,t)=>e.includes(t);Ke.each=(e,t)=>e.forEach(t);Ke.clone=e=>Object.assign({},e);Ke.pick=(e,t)=>{let r={};return t.forEach(n=>{typeof e[n]<"u"&&(r[n]=e[n])}),r};Ke.values=e=>Object.values(e);Ke.filter=(e,t)=>e.filter(t);Ke.reduce=(e,t,r)=>e.reduce(t,r);Ke.without=(e,t)=>e.filter(r=>r!==t);Ke.shuffle=e=>{let t=e.slice(0);for(let r=t.length-1;r>0;r--){let i=XB.getRandomBuffer(4).readUInt32BE(0)/4294967296,o=Math.floor(i*(r+1));[t[r],t[o]]=[t[o],t[r]]}return t};Ke.difference=(e,t)=>e.filter(r=>!t.includes(r));Ke.findIndex=(e,t)=>e.findIndex(t);Ke.some=(e,t)=>e.some(t);Ke.range=e=>[...Array(e).keys()];c_.exports=Ke});var h_=P((cD,l_)=>{"use strict";m();var JB="https://docs.moneybutton.com/";l_.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+JB+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]});var Jn=P((hD,sd)=>{"use strict";m();var od=Ve();function QB(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var d_=function(e,t){var r=function(){if(od.isString(t.message))this.message=QB(t.message,arguments);else if(od.isFunction(t.message))this.message=t.message.apply(null,arguments);else throw new Error("Invalid error definition for "+t.name);this.stack=this.message+`
|
|
12
12
|
`+new Error().stack};return r.prototype=Object.create(e.prototype),r.prototype.name=e.prototype.name+t.name,e[t.name]=r,t.errors&&p_(r,t.errors),r},p_=function(e,t){od.each(t,function(r){d_(e,r)})},eN=function(e,t){return p_(e,t),e},Uo={};Uo.Error=function(){this.message="Internal error",this.stack=this.message+`
|
|
13
|
-
`+new Error().stack};Uo.Error.prototype=Object.create(Error.prototype);Uo.Error.prototype.name="bsv.Error";var tN=h_();eN(Uo.Error,tN);sd.exports=Uo.Error;sd.exports.extend=function(e){return d_(Uo.Error,e)}});var ke=P((pD,g_)=>{"use strict";m();var ta=Jn(),rN=Ve();g_.exports={checkState:function(e,t){if(!e)throw new ta.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ta.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",rN.isString(t)){if(t==="Buffer"){var n=Tt();if(!n.Buffer.isBuffer(e))throw new ta.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ta.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ta.InvalidArgumentType(e,t.name,r)}}});var Er=P((yD,b_)=>{"use strict";m();var Be=A0(),m_=ke(),v_=Ve(),_f=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Be.Zero=new Be(0);Be.One=new Be(1);Be.Minus1=new Be(-1);Be.fromNumber=function(e){return m_.checkArgument(v_.isNumber(e)),new Be(e)};Be.fromString=function(e,t){return m_.checkArgument(v_.isString(e)),new Be(e,t)};Be.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=_f(e));var r=e.toString("hex"),n=new Be(r,16);return n};Be.fromSM=function(e,t){var r;if(e.length===0)return Be.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=_f(e)),e[0]&128?(e[0]=e[0]&127,r=Be.fromBuffer(e),r.neg().copy(r)):r=Be.fromBuffer(e),r};Be.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Be.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Be.trim(t,n):n<e.size&&(t=Be.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=_f(t)),t};Be.prototype.toSMBigEndian=function(){var e;return this.cmp(Be.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Be.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=_f(r)),r};function y_(e,t){var r=new Error(e);return r.scriptErr=t,r}Be.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw y_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw y_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return Be.fromSM(e,{endian:"little"})};Be.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Be.trim=function(e,t){return e.slice(t-e.length,e.length)};Be.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Be.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Be.fromHex=function(e,...t){return Be.fromBuffer(d.Buffer.from(e,"hex"),...t)};b_.exports=Be});function ad(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Qn(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function on(e,t,r=""){let n=ad(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=n?`length=${i}`:`type=${typeof e}`,h=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(h):new TypeError(h)}return e}function Sf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Qn(e.outputLen),Qn(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Fo(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wf(e,t){on(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Zt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ef(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Cr(e,t){return e<<32-t|e>>>t}function In(e,t){return e<<t|e>>>32-t>>>0}function xf(e){if(on(e),S_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=nN[e[r]];return t}function __(e){if(e>=xn._0&&e<=xn._9)return e-xn._0;if(e>=xn.A&&e<=xn.F)return e-(xn.A-10);if(e>=xn.a&&e<=xn.f)return e-(xn.a-10)}function ud(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(S_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=__(e.charCodeAt(o)),a=__(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function An(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function w_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];on(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function Lr(e,t={}){let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ra(e=32){Qn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var S_,nN,xn,Ui,On=er(()=>{m();S_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",nN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));xn={_0:48,_9:57,A:65,F:70,a:97,f:102};Ui=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function qo(e,t,r){return e&t^~e&r}function If(e,t,r){return e&t^e&r^t&r}var Rn,Tn,Pn,Ht,jt,fd=er(()=>{m();On();Rn=class{constructor(t,r,n,i){C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"padOffset");C(this,"isLE");C(this,"buffer");C(this,"view");C(this,"finished",!1);C(this,"length",0);C(this,"pos",0);C(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ef(this.buffer)}update(t){Fo(this),on(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Ef(t);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fo(this),wf(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,Zt(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let y=s;y<i;y++)r[y]=0;n.setBigUint64(i-8,BigInt(this.length*8),o),this.process(n,0);let a=Ef(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let h=c/4,g=this.get();if(h>g.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,g[y],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=i,t.pos=a,i%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pn=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Ht=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),jt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function iN(e,t=!1){return t?{h:Number(e&Af),l:Number(e>>E_&Af)}:{h:Number(e>>E_&Af)|0,l:Number(e&Af)|0}}function x_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=iN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function sn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Af,E_,cd,ld,Fi,qi,na,ia,I_,A_,O_,R_,T_,P_,B_=er(()=>{m();Af=BigInt(4294967295),E_=BigInt(32);cd=(e,t,r)=>e>>>r,ld=(e,t,r)=>e<<32-r|t>>>r,Fi=(e,t,r)=>e>>>r|t<<32-r,qi=(e,t,r)=>e<<32-r|t>>>r,na=(e,t,r)=>e<<64-r|t>>>r-32,ia=(e,t,r)=>e>>>r-32|t<<64-r;I_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),A_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,O_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),R_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,T_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),P_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});var M_={};sl(M_,{_SHA224:()=>Tf,_SHA256:()=>Rf,_SHA384:()=>Bf,_SHA512:()=>Pf,_SHA512_224:()=>Nf,_SHA512_256:()=>Mf,sha224:()=>fN,sha256:()=>ni,sha384:()=>lN,sha512:()=>cN,sha512_224:()=>dN,sha512_256:()=>hN});var sN,ei,Of,Rf,Tf,N_,aN,uN,ti,ri,Ho,Pf,Bf,Xt,Jt,Nf,Mf,ni,fN,cN,lN,hN,dN,hd=er(()=>{m();fd();B_();On();sN=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array(64),Of=class extends Rn{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[t,r,n,i,o,s,a,c]}set(t,r,n,i,o,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let y=0;y<16;y++,r+=4)ei[y]=t.getUint32(r,!1);for(let y=16;y<64;y++){let w=ei[y-15],I=ei[y-2],T=Cr(w,7)^Cr(w,18)^w>>>3,M=Cr(I,17)^Cr(I,19)^I>>>10;ei[y]=M+ei[y-7]+T+ei[y-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:h,H:g}=this;for(let y=0;y<64;y++){let w=Cr(a,6)^Cr(a,11)^Cr(a,25),I=g+w+qo(a,c,h)+sN[y]+ei[y]|0,M=(Cr(n,2)^Cr(n,13)^Cr(n,22))+If(n,i,o)|0;g=h,h=c,c=a,a=s+I|0,s=o,o=i,i=n,n=I+M|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,g=g+this.H|0,this.set(n,i,o,s,a,c,h,g)}roundClean(){Zt(ei)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Zt(this.buffer)}},Rf=class extends Of{constructor(){super(32);C(this,"A",Tn[0]|0);C(this,"B",Tn[1]|0);C(this,"C",Tn[2]|0);C(this,"D",Tn[3]|0);C(this,"E",Tn[4]|0);C(this,"F",Tn[5]|0);C(this,"G",Tn[6]|0);C(this,"H",Tn[7]|0)}},Tf=class extends Of{constructor(){super(28);C(this,"A",Pn[0]|0);C(this,"B",Pn[1]|0);C(this,"C",Pn[2]|0);C(this,"D",Pn[3]|0);C(this,"E",Pn[4]|0);C(this,"F",Pn[5]|0);C(this,"G",Pn[6]|0);C(this,"H",Pn[7]|0)}},N_=x_(["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(e=>BigInt(e))),aN=N_[0],uN=N_[1],ti=new Uint32Array(80),ri=new Uint32Array(80),Ho=class extends Rn{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:h,El:g,Fh:y,Fl:w,Gh:I,Gl:T,Hh:M,Hl:L}=this;return[t,r,n,i,o,s,a,c,h,g,y,w,I,T,M,L]}set(t,r,n,i,o,s,a,c,h,g,y,w,I,T,M,L){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=g|0,this.Fh=y|0,this.Fl=w|0,this.Gh=I|0,this.Gl=T|0,this.Hh=M|0,this.Hl=L|0}process(t,r){for(let q=0;q<16;q++,r+=4)ti[q]=t.getUint32(r),ri[q]=t.getUint32(r+=4);for(let q=16;q<80;q++){let W=ti[q-15]|0,J=ri[q-15]|0,Y=Fi(W,J,1)^Fi(W,J,8)^cd(W,J,7),be=qi(W,J,1)^qi(W,J,8)^ld(W,J,7),se=ti[q-2]|0,de=ri[q-2]|0,A=Fi(se,de,19)^na(se,de,61)^cd(se,de,6),u=qi(se,de,19)^ia(se,de,61)^ld(se,de,6),l=O_(be,u,ri[q-7],ri[q-16]),p=R_(l,Y,A,ti[q-7],ti[q-16]);ti[q]=p|0,ri[q]=l|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:h,Dl:g,Eh:y,El:w,Fh:I,Fl:T,Gh:M,Gl:L,Hh:j,Hl:G}=this;for(let q=0;q<80;q++){let W=Fi(y,w,14)^Fi(y,w,18)^na(y,w,41),J=qi(y,w,14)^qi(y,w,18)^ia(y,w,41),Y=y&I^~y&M,be=w&T^~w&L,se=T_(G,J,be,uN[q],ri[q]),de=P_(se,j,W,Y,aN[q],ti[q]),A=se|0,u=Fi(n,i,28)^na(n,i,34)^na(n,i,39),l=qi(n,i,28)^ia(n,i,34)^ia(n,i,39),p=n&o^n&a^o&a,v=i&s^i&c^s&c;j=M|0,G=L|0,M=I|0,L=T|0,I=y|0,T=w|0,{h:y,l:w}=sn(h|0,g|0,de|0,A|0),h=a|0,g=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let b=I_(A,l,v);n=A_(b,de,u,p),i=b|0}({h:n,l:i}=sn(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=sn(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=sn(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:g}=sn(this.Dh|0,this.Dl|0,h|0,g|0),{h:y,l:w}=sn(this.Eh|0,this.El|0,y|0,w|0),{h:I,l:T}=sn(this.Fh|0,this.Fl|0,I|0,T|0),{h:M,l:L}=sn(this.Gh|0,this.Gl|0,M|0,L|0),{h:j,l:G}=sn(this.Hh|0,this.Hl|0,j|0,G|0),this.set(n,i,o,s,a,c,h,g,y,w,I,T,M,L,j,G)}roundClean(){Zt(ti,ri)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pf=class extends Ho{constructor(){super(64);C(this,"Ah",jt[0]|0);C(this,"Al",jt[1]|0);C(this,"Bh",jt[2]|0);C(this,"Bl",jt[3]|0);C(this,"Ch",jt[4]|0);C(this,"Cl",jt[5]|0);C(this,"Dh",jt[6]|0);C(this,"Dl",jt[7]|0);C(this,"Eh",jt[8]|0);C(this,"El",jt[9]|0);C(this,"Fh",jt[10]|0);C(this,"Fl",jt[11]|0);C(this,"Gh",jt[12]|0);C(this,"Gl",jt[13]|0);C(this,"Hh",jt[14]|0);C(this,"Hl",jt[15]|0)}},Bf=class extends Ho{constructor(){super(48);C(this,"Ah",Ht[0]|0);C(this,"Al",Ht[1]|0);C(this,"Bh",Ht[2]|0);C(this,"Bl",Ht[3]|0);C(this,"Ch",Ht[4]|0);C(this,"Cl",Ht[5]|0);C(this,"Dh",Ht[6]|0);C(this,"Dl",Ht[7]|0);C(this,"Eh",Ht[8]|0);C(this,"El",Ht[9]|0);C(this,"Fh",Ht[10]|0);C(this,"Fl",Ht[11]|0);C(this,"Gh",Ht[12]|0);C(this,"Gl",Ht[13]|0);C(this,"Hh",Ht[14]|0);C(this,"Hl",Ht[15]|0)}},Xt=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Jt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Nf=class extends Ho{constructor(){super(28);C(this,"Ah",Xt[0]|0);C(this,"Al",Xt[1]|0);C(this,"Bh",Xt[2]|0);C(this,"Bl",Xt[3]|0);C(this,"Ch",Xt[4]|0);C(this,"Cl",Xt[5]|0);C(this,"Dh",Xt[6]|0);C(this,"Dl",Xt[7]|0);C(this,"Eh",Xt[8]|0);C(this,"El",Xt[9]|0);C(this,"Fh",Xt[10]|0);C(this,"Fl",Xt[11]|0);C(this,"Gh",Xt[12]|0);C(this,"Gl",Xt[13]|0);C(this,"Hh",Xt[14]|0);C(this,"Hl",Xt[15]|0)}},Mf=class extends Ho{constructor(){super(32);C(this,"Ah",Jt[0]|0);C(this,"Al",Jt[1]|0);C(this,"Bh",Jt[2]|0);C(this,"Bl",Jt[3]|0);C(this,"Ch",Jt[4]|0);C(this,"Cl",Jt[5]|0);C(this,"Dh",Jt[6]|0);C(this,"Dl",Jt[7]|0);C(this,"Eh",Jt[8]|0);C(this,"El",Jt[9]|0);C(this,"Fh",Jt[10]|0);C(this,"Fl",Jt[11]|0);C(this,"Gh",Jt[12]|0);C(this,"Gl",Jt[13]|0);C(this,"Hh",Jt[14]|0);C(this,"Hl",Jt[15]|0)}},ni=Lr(()=>new Rf,Ui(1)),fN=Lr(()=>new Tf,Ui(4)),cN=Lr(()=>new Pf,Ui(3)),lN=Lr(()=>new Bf,Ui(2)),hN=Lr(()=>new Mf,Ui(6)),dN=Lr(()=>new Nf,Ui(5))});function ji(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Lf(e){if(typeof e=="bigint"){if(!kf(e))throw new RangeError("positive bigint expected, got "+e)}else pd(e);return e}function xr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function oa(e){let t=Lf(e).toString(16);return t.length&1?"0"+t:t}function k_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Cf:BigInt("0x"+e)}function tr(e){return k_(xf(e))}function Ko(e){return k_(xf(Uf(on(e)).reverse()))}function Df(e,t){if(Qn(t),t===0)throw new RangeError("zero length");e=Lf(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return ud(r.padStart(t*2,"0"))}function gd(e,t){return Df(e,t).reverse()}function Uf(e){return Uint8Array.from(Le(e))}function Vo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function pN(e,t,r){return kf(e)&&kf(t)&&kf(r)&&t<=e&&e<r}function yd(e,t,r,n){if(!pN(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ki(e){if(e<Cf)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Cf;e>>=dd,t+=1);return t}function C_(e,t,r){if(Qn(e,"hashLen"),Qn(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),h=n(e),g=0,y=()=>{c.fill(1),h.fill(0),g=0},w=(...L)=>r(h,Me(c,...L)),I=(L=i)=>{h=w(o,L),c=w(),L.length!==0&&(h=w(s,L),c=w())},T=()=>{if(g++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,j=[];for(;L<t;){c=w();let G=c.slice();j.push(G),L+=c.length}return Me(...j)};return(L,j)=>{y(),I(L);let G;for(;(G=j(T()))===void 0;)I();return y(),G}}function Ir(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let h=typeof c;if(h!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${h}`)}let i=(o,s)=>Object.entries(o).forEach(([a,c])=>n(a,c,s));i(t,!1),i(r,!0)}var Le,pd,Bn,Me,jo,Hi,ar,Cf,dd,kf,Go,Vi=er(()=>{m();On();Le=(e,t,r)=>on(e,t,r),pd=Qn,Bn=xf,Me=(...e)=>w_(...e),jo=e=>ud(e),Hi=ad,ar=e=>ra(e),Cf=BigInt(0),dd=BigInt(1);kf=e=>typeof e=="bigint"&&Cf<=e;Go=e=>(dd<<BigInt(e))-dd});function hr(e,t){if(t<=Kt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function dr(e,t,r){if(t<Kt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >Kt;)n*=n,n%=r;return n}function L_(e,t){if(e===Kt)throw new Error("invert: expected non-zero number");if(t<=Kt)throw new Error("invert: expected positive modulus, got "+t);let r=hr(e,t),n=t,i=Kt,o=xt,s=xt,a=Kt;for(;r!==Kt;){let h=n/r,g=n-r*h,y=i-s*h,w=o-a*h;n=r,r=g,i=s,o=a,s=y,a=w}if(n!==xt)throw new Error("invert: does not exist");return hr(i,t)}function vd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function K_(e,t){let r=e,n=(r.ORDER+xt)/F_,i=r.pow(t,n);return vd(r,i,t),i}function mN(e,t){let r=e,n=(r.ORDER-q_)/H_,i=r.mul(t,Gi),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,Gi),o),c=r.mul(s,r.sub(a,r.ONE));return vd(r,c,t),c}function vN(e){let t=zo(e),r=V_(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+gN)/j_;return((a,c)=>{let h=a,g=h.pow(c,s),y=h.mul(g,n),w=h.mul(g,i),I=h.mul(g,o),T=h.eql(h.sqr(y),c),M=h.eql(h.sqr(w),c);g=h.cmov(g,y,T),y=h.cmov(I,w,M);let L=h.eql(h.sqr(y),c),j=h.cmov(g,y,L);return vd(h,j,c),j})}function V_(e){if(e<U_)throw new Error("sqrt is not defined for small field");let t=e-xt,r=0;for(;t%Gi===Kt;)t/=Gi,r++;let n=Gi,i=zo(e);for(;md(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return K_;let o=i.pow(n,t),s=(t+xt)/Gi;return function(c,h){let g=c;if(g.is0(h))return h;if(md(g,h)!==1)throw new Error("Cannot find square root");let y=r,w=g.mul(g.ONE,o),I=g.pow(h,t),T=g.pow(h,s);for(;!g.eql(I,g.ONE);){if(g.is0(I))return g.ZERO;let M=1,L=g.sqr(I);for(;!g.eql(L,g.ONE);)if(M++,L=g.sqr(L),M===y)throw new Error("Cannot find square root");let j=xt<<BigInt(y-M-1),G=g.pow(w,j);y=M,w=g.sqr(G),I=g.mul(I,w),T=g.mul(T,G)}return T}}function bN(e){return e%F_===U_?K_:e%H_===q_?mN:e%j_===yN?vN(e):V_(e)}function zi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=_N.reduce((n,i)=>(n[i]="function",n),t);if(Ir(e,r),xr(e.BYTES,"BYTES"),xr(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=xt)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function SN(e,t,r){let n=e;if(r<Kt)throw new Error("invalid exponent, negatives unsupported");if(r===Kt)return n.ONE;if(r===xt)return t;let i=n.ONE,o=t;for(;r>Kt;)r&xt&&(i=n.mul(i,o)),o=n.sqr(o),r>>=xt;return i}function Wi(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,c,h)=>n.is0(c)?a:(i[h]=a,n.mul(a,c)),n.ONE),s=n.inv(o);return t.reduceRight((a,c,h)=>n.is0(c)?a:(i[h]=n.mul(a,i[h]),n.mul(a,c)),s),i}function md(e,t){let r=e,n=(r.ORDER-xt)/Gi,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function bd(e,t){return md(e,t)!==-1}function wN(e,t){if(t!==void 0&&pd(t),e<=Kt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Ki(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function zo(e,t={}){return new Ff(e,t)}function G_(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=xt)throw new Error("field order must be greater than 1");let t=Ki(e-xt);return Math.ceil(t/8)}function sa(e){let t=G_(e);return t+Math.ceil(t/2)}function Wo(e,t,r=!1){Le(e);let n=e.length,i=G_(t),o=Math.max(sa(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ko(e):tr(e),a=hr(s,t-xt)+xt;return r?gd(a,i):Df(a,i)}var Kt,xt,Gi,U_,F_,q_,gN,H_,yN,j_,_N,D_,Ff,Yo=er(()=>{m();Vi();Kt=BigInt(0),xt=BigInt(1),Gi=BigInt(2),U_=BigInt(3),F_=BigInt(4),q_=BigInt(5),gN=BigInt(7),H_=BigInt(8),yN=BigInt(9),j_=BigInt(16);_N=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];D_=new WeakMap,Ff=class{constructor(t,r={}){C(this,"ORDER");C(this,"BITS");C(this,"BYTES");C(this,"isLE");C(this,"ZERO",Kt);C(this,"ONE",xt);C(this,"_lengths");C(this,"_mod");if(t<=xt)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=wN(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return hr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Kt<=t&&t<this.ORDER}is0(t){return t===Kt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&xt)===xt}neg(t){return hr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return hr(t*t,this.ORDER)}add(t,r){return hr(t+r,this.ORDER)}sub(t,r){return hr(t-r,this.ORDER)}mul(t,r){return hr(t*r,this.ORDER)}pow(t,r){return SN(this,t,r)}div(t,r){return hr(t*L_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return L_(t,this.ORDER)}sqrt(t){let r=D_.get(this);return r||D_.set(this,r=bN(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?gd(t,this.BYTES):Df(t,this.BYTES)}fromBytes(t,r=!1){Le(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let h=new Uint8Array(i);h.set(t,o?0:h.length-t.length),t=h}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=o?Ko(t):tr(t);if(a&&(c=hr(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Wi(this,t)}cmov(t,r,n){return ji(n,"condition"),n?r:t}};Object.freeze(Ff.prototype)});function $_(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");Ir({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),zi(t.Fp),zi(t.Fn)}function aa(e,t){let r=t.negate();return e?r:t}function Ed(e,t){let r=Wi(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function Z_(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function _d(e,t){Z_(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Go(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function z_(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),c=e>>s;a>n&&(a-=o,c+=Yi);let h=t*n,g=h+Math.abs(a)-1,y=a===0,w=a<0,I=t%2!==0;return{nextN:c,offset:g,isZero:y,isNeg:w,isNegF:I,offsetF:h}}function EN(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function xN(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}function wd(e){return X_.get(e)||1}function W_(e){if(e!==$o)throw new Error("invalid wNAF")}function J_(e,t,r,n){let i=t,o=e.ZERO,s=e.ZERO;for(;r>$o||n>$o;)r&Yi&&(o=o.add(i)),n&Yi&&(s=s.add(i)),i=i.double(),r>>=Yi,n>>=Yi;return{p1:o,p2:s}}function Q_(e,t,r){let n=e.Fn;EN(t,e),xN(r,n);let i=t.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=Ki(BigInt(i)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let h=Go(c),g=new Array(Number(h)+1).fill(s),y=Math.floor((n.BITS-1)/c)*c,w=s;for(let I=y;I>=0;I-=c){g.fill(s);for(let M=0;M<o;M++){let L=r[M],j=Number(L>>BigInt(I)&h);g[j]=g[j].add(t[M])}let T=s;for(let M=g.length-1,L=s;M>0;M--)L=L.add(g[M]),T=T.add(L);if(w=w.add(T),I!==0)for(let M=0;M<c;M++)w=w.double()}return w}function Y_(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return zi(t),t}else return zo(e,{isLE:r})}function eS(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let h=t[c];if(!(typeof h=="bigint"&&h>$o))throw new Error(`CURVE.${c} must be positive bigint`)}let i=Y_(t.p,r.Fp,n),o=Y_(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!i.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Hf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var $o,Yi,Sd,X_,qf,jf=er(()=>{m();Vi();Yo();$o=BigInt(0),Yi=BigInt(1);Sd=new WeakMap,X_=new WeakMap;qf=class{constructor(t,r){C(this,"BASE");C(this,"ZERO");C(this,"Fn");C(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>$o;)r&Yi&&(n=n.add(i)),i=i.double(),r>>=Yi;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=_d(r,this.bits),o=[],s=t,a=s;for(let c=0;c<n;c++){a=s,o.push(a);for(let h=1;h<i;h++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE,s=_d(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:h,isZero:g,isNeg:y,isNegF:w,offsetF:I}=z_(n,a,s);n=c,g?o=o.add(aa(w,r[I])):i=i.add(aa(y,r[h]))}return W_(n),{p:i,f:o}}wNAFUnsafe(t,r,n,i=this.ZERO){let o=_d(t,this.bits);for(let s=0;s<o.windows&&n!==$o;s++){let{nextN:a,offset:c,isZero:h,isNeg:g}=z_(n,s,o);if(n=a,!h){let y=r[c];i=i.add(g?y.negate():y)}}return W_(n),i}getPrecomputes(t,r,n){let i=Sd.get(r);return i||(i=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(i=n(i)),Sd.set(r,i))),i}cached(t,r,n){let i=wd(t);return this.wNAF(i,this.getPrecomputes(i,t,n),r)}unsafe(t,r,n,i){let o=wd(t);return o===1?this._unsafeLadder(t,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,n),r,i)}createCache(t,r){Z_(r,this.bits),X_.set(t,r),Sd.delete(t)}hasCache(t){return wd(t)!==1}}});function tS(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function IN(e){if(tS(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<xd(e-1)+1>>>0}function xd(e){return tS(e),31-Math.clz32(e)}function rS(e,t,r,n,i){let o=e,s=r||((g,y)=>new Array(g).fill(y??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let y=g;return typeof y.length=="number"&&typeof y.slice=="function"&&typeof y[Symbol.iterator]=="function"},c=(...g)=>{if(!g.length)return 0;for(let w of g)if(!a(w))throw new Error("poly: not polynomial: "+w);let y=g[0].length;for(let w=1;w<g.length;w++)if(g[w].length!==y)throw new Error(`poly: mismatched lengths ${y} vs ${g[w].length}`);if(i!==void 0&&y!==i)throw new Error(`poly: expected fixed length ${i}, got ${y}`);return y};function h(g,y,w=!1){let I=xd(y),T=w?t.brp(I):t.roots(I);for(let M=0;M<y;M++)if(o.eql(g,T[M]))return M;return-1}return{roots:t,create:s,length:i,extend:(g,y)=>{c(g);let w=s(y,o.ZERO);for(let I=0;I<Math.min(g.length,y);I++)w[I]=g[I];return w},degree:g=>{c(g);for(let y=g.length-1;y>=0;y--)if(!o.is0(g[y]))return y;return-1},add:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.add(g[T],y[T]);return I},sub:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.sub(g[T],y[T]);return I},dot:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.mul(g[T],y[T]);return I},mul:(g,y)=>{if(a(y)){let w=c(g,y);if(n){let I=n.direct(g,!1,!0),T=n.direct(y,!1,!0);for(let M=0;M<I.length;M++)I[M]=o.mul(I[M],T[M]);return n.inverse(I,!0,!1)}else{let I=s(w);for(let T=0;T<w;T++)for(let M=0;M<w;M++){let L=(T+M)%w;I[L]=o.add(I[L],o.mul(g[T],y[M]))}return I}}else{let w=s(c(g));for(let I=0;I<w.length;I++)w[I]=o.mul(g[I],y);return w}},convolve(g,y){let w=IN(g.length+y.length-1);return this.mul(this.extend(g,w),this.extend(y,w))},shift(g,y){let w=s(c(g));w[0]=g[0];for(let I=1,T=o.ONE;I<g.length;I++)T=o.mul(T,y),w[I]=o.mul(g[I],T);return w},clone:g=>{c(g);let y=s(g.length);for(let w=0;w<g.length;w++)y[w]=g[w];return y},eval:(g,y)=>{c(g,y);let w=o.ZERO;for(let I=0;I<g.length;I++)w=o.add(w,o.mul(g[I],y[I]));return w},monomial:{basis:(g,y)=>{let w=s(y),I=o.ONE;for(let T=0;T<y;T++)w[T]=I,I=o.mul(I,g);return w},eval:(g,y)=>{c(g);let w=o.ZERO;for(let I=g.length-1;I>=0;I--)w=o.add(o.mul(w,y),g[I]);return w}},lagrange:{basis:(g,y,w=!1,I)=>{let T=xd(y),M=I||(w?t.brp(T):t.roots(T)),L=s(y),j=h(g,y,w);if(j!==-1)return L[j]=o.ONE,L;let G=o.pow(g,BigInt(y)),q=o.mul(o.sub(G,o.ONE),o.inv(BigInt(y))),W=s(y);for(let Y=0;Y<y;Y++)W[Y]=o.sub(g,M[Y]);let J=o.invertBatch(W);for(let Y=0;Y<y;Y++)L[Y]=o.mul(q,o.mul(M[Y],J[Y]));return L},eval(g,y,w=!1){c(g);let I=h(y,g.length,w);if(I!==-1)return g[I];let T=this.basis(y,g.length,w),M=o.ZERO;for(let L=0;L<g.length;L++)o.is0(g[L])||(M=o.add(M,o.mul(g[L],T[L])));return M}},vanishing(g){c(g);let y=s(g.length+1,o.ZERO);y[0]=o.ONE;for(let w of g){let I=o.neg(w);for(let T=y.length-1;T>0;T--)y[T]=o.add(o.mul(y[T],I),y[T-1]);y[0]=o.mul(y[0],I)}return y}}}var nS=er(()=>{m()});function $i(e,t){if(xr(e),xr(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function ON(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function iS(e){if(!Hi(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Vo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function RN(e,t,r,n){Le(e),xr(r),t=iS(t),t.length>255&&(t=n(Me(Vo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Me(t,$i(t.length,1)),c=new Uint8Array(o),h=$i(r,2),g=new Array(s),y=n(Me(c,e,h,$i(0,1),a));g[0]=n(Me(y,$i(1,1),a));for(let I=1;I<s;I++){let T=[ON(y,g[I-1]),$i(I+1,1),a];g[I]=n(Me(...T))}return Me(...g).slice(0,r)}function TN(e,t,r,n,i){if(Le(e),xr(r),t=iS(t),t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update($i(r,2)).update(t).update($i(t.length,1)).digest()}function Id(e,t,r){Ir(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;if(xr(s.outputLen,"valid hash"),Le(e),xr(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let h=n.toString(2).length,g=Math.ceil((h+i)/8),y=t*o*g,w;if(a==="xmd")w=RN(e,c,y,s);else if(a==="xof")w=TN(e,c,y,i,s);else if(a==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let I=new Array(t);for(let T=0;T<t;T++){let M=new Array(o);for(let L=0;L<o;L++){let j=g*(L+T*o),G=w.subarray(j,j+g);M[L]=hr(AN(G),n)}I[T]=M}return I}function oS(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[o,s,a,c]=r.map(y=>y.reduce((w,I)=>e.add(e.mul(w,n),I))),[h,g]=Wi(e,[s,c],!0);return n=e.mul(o,h),i=e.mul(i,e.mul(a,g)),{x:n,y:i}}}function sS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let n=a=>Object.freeze({...a,DST:Hi(a.DST)?Uf(a.DST):a.DST,...a.encodeDST===void 0?{}:{encodeDST:Hi(a.encodeDST)?Uf(a.encodeDST):a.encodeDST}}),i=n(r);function o(a){return e.fromAffine(t(a))}function s(a){let c=a.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(a,c){let h=Object.assign({},i,c),g=Id(a,2,h),y=o(g[0]),w=o(g[1]);return s(y.add(w))},encodeToCurve(a,c){let h=i.encodeDST?{DST:i.encodeDST}:{},g=Object.assign({},i,h,c),y=Id(a,1,g),w=o(y[0]);return s(w)},mapToCurve(a){if(i.m===1){if(typeof a!="bigint")throw new Error("expected bigint (m=1)");return s(o([a]))}if(!Array.isArray(a))throw new Error("expected array of bigints");for(let c of a)if(typeof c!="bigint")throw new Error("expected array of bigints");return s(o(a))},hashToScalar(a,c){let h=e.Fn.ORDER,g=Object.assign({},i,{p:h,m:1,DST:PN},c);return Id(a,1,g)[0][0]}})}var AN,PN,aS=er(()=>{m();Vi();Yo();AN=tr;PN="HashToScalar-"});function Ad(e){Ir(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),$_(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(R,k={DST:new Uint8Array})=>{let H=n(Me(k.DST,R));return r.create(r.isLE?Ko(H):tr(H))}:e.hashToScalar,o=An(e.H1!==void 0?e.H1:e.name+"rho"),s=An(e.H2!==void 0?e.H2:e.name+"chal"),a=An(e.H3!==void 0?e.H3:e.name+"nonce"),c=An(e.H4!==void 0?e.H4:e.name+"msg"),h=An(e.H5!==void 0?e.H5:e.name+"com"),g=An(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),y=An(e.HID!==void 0?e.HID:e.name+"id"),w=R=>i(R,{DST:o}),I=R=>i(R,{DST:s}),T=R=>i(R,{DST:a}),M=R=>n(Me(c,R)),L=R=>n(Me(h,R)),j=R=>i(R,{DST:g}),G=R=>i(R,{DST:y}),q=(R=ar)=>{let k=Wo(R(sa(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ko(k):tr(k)},W=R=>R.toBytes(),J=R=>{let k=t.fromBytes(R);return e.validatePoint&&e.validatePoint(k),k},Y=(R,k)=>({identifier:R,hiding:W(t.BASE.multiply(r.fromBytes(k.hiding))),binding:W(t.BASE.multiply(r.fromBytes(k.binding)))}),be=e.adjustPoint===void 0?R=>R:e.adjustPoint,se=R=>{if(!r.isValid(R)||r.is0(R))throw new Error("Invalid identifier "+R);return R},de=R=>Bn(r.toBytes(se(R))),A=R=>{let k=se(r.fromBytes(jo(R)));if(de(k)!==R)throw new Error("expected canonical identifier hex");return k},u={encode:(R,k)=>{let H=Me(W(R),r.toBytes(k));return e.adjustTx&&(H=e.adjustTx.encode(H)),H},decode:R=>{e.adjustTx&&(R=e.adjustTx.decode(R));let k=J(R.subarray(0,-r.BYTES)),H=r.fromBytes(R.subarray(-r.BYTES));return{R:k,z:H}}},l=(R=ar)=>{let k=q(R);e.adjustScalar&&(k=e.adjustScalar(k));let H=t.BASE.multiply(k);return{scalar:k,point:H}},p="roots are unavailable in FROST polynomial mode",v={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(p)},brp(){throw new Error(p)},inverse(){throw new Error(p)},omega(){throw new Error(p)},clear(){}},b=rS(r,v),E=(R,k)=>Q_(t,R,k),O=(R,k)=>{if(!k.length)throw new Error("empty coefficients");return b.monomial.eval(k,R)},_=(R,k)=>{let H="invalid parameters";if(!R.some(te=>r.eql(te,k)))throw new Error(H);let V=new Set(R);if(V.size!==R.length)throw new Error(H);if(!V.has(k))throw new Error(H);let ie=r.ONE,ee=r.ONE;for(let te of R)r.eql(te,k)||(ie=r.mul(ie,te),ee=r.mul(ee,r.sub(te,k)));return r.div(ie,ee)},f=(R,k)=>{let H=b.monomial.basis(R,k.length);return E(k,H)},S=(R,k,H,V=ar)=>{Kf(R);let ie=k===void 0?q(V):r.fromBytes(k);if(!H){H=[];for(let he=0;he<R.min-1;he++)H.push(q(V))}if(H.length!==R.min-1)throw new Error("wrong coefficients length");let ee=[ie,...H],te=ee.map(he=>t.BASE.multiply(he));return{coefficients:ee,commitment:te,secret:ie}},K={challenge:(R,k,H)=>j(Me(r.toBytes(R),W(k),W(H))),compute(R,k,H,V=ar){if(k.length<1)throw new Error("coefficients should have at least one element");let{point:ie,scalar:ee}=l(V),te=H[0],he=this.challenge(R,te,ie),oe=r.add(ee,r.mul(k[0],he));return u.encode(ie,oe)},validate(R,k,H){if(k.length<1)throw new Error("commitment should have at least one element");let{R:V,z:ie}=u.decode(H),ee=J(k[0]),te=this.challenge(R,ee,V);if(!V.equals(t.BASE.multiply(ie).subtract(ee.multiply(te))))throw new Error("invalid proof of knowledge")}},F={challenge:(R,k,H)=>e.challenge?e.challenge(R,k,H):I(Me(W(R),W(k),H)),sign(R,k,H=ar){let{point:V,scalar:ie}=l(H),ee=t.BASE.multiply(k),te=this.challenge(V,ee,R),he=r.add(ie,r.mul(te,k));return[V,he]},verify(R,k,H,V){e.adjustPoint&&(V=e.adjustPoint(V)),e.adjustPoint&&(k=e.adjustPoint(k));let ie=this.challenge(k,V,R),ee=t.BASE.multiply(H),te=V.multiply(ie),he=ee.subtract(te).subtract(k);return he.clearCofactor&&(he=he.clearCofactor()),t.ZERO.equals(he)}},$=(R,k,H)=>{if(!t.BASE.multiply(H).equals(f(R,k)))throw new Error("invalid secret share")},Z={fromNumber(R){if(!Number.isSafeInteger(R))throw new Error("expected safe interger");return de(BigInt(R))},derive(R){if(typeof R!="string")throw new Error("wrong identifier string: "+R);return de(G(An(R)))}},Q=(R,k=ar)=>T(Me(k(32),r.toBytes(R))),ae=(R,k,H)=>{let V=k.map(re=>[re.identifier,A(re.identifier),J(re.hiding),J(re.binding)]);V.sort((re,me)=>re[1]<me[1]?-1:re[1]>me[1]?1:0);let ie=[];for(let[re,me,ve,Se]of V)ie.push(r.toBytes(me),W(ve),W(Se));let ee=L(Me(...ie)),te=Me(W(R),M(H),ee),he={};for(let[re,me]of V)he[re]=w(Me(te,r.toBytes(me)));let oe=[],ue=[];for(let[re,me,ve,Se]of V){if(t.ZERO.equals(ve)||t.ZERO.equals(Se))throw new Error("infinity commitment");oe.push(ve,Se),ue.push(r.ONE,he[re])}let We=E(oe,ue);return{identifiers:V.map(re=>re[1]),groupCommitment:We,bindingFactors:he}},ge=(R,k,H,V)=>{let ie=be(J(R)),ee=A(V),{identifiers:te,groupCommitment:he,bindingFactors:oe}=ae(ie,k,H),ue=oe[V],We=_(te,ee),Oe=F.challenge(he,ie,H);return{lambda:We,challenge:Oe,bindingFactor:ue,groupCommitment:he}};Object.freeze(Z);let le={Identifier:Z,DKG:Object.freeze({round1:(R,k,H,V=ar)=>{Kf(k);let ie=A(R),{coefficients:ee,commitment:te}=S(k,H,void 0,V),he=K.compute(ie,ee,te,V),oe=te.map(W),ue={identifier:de(ie),commitment:oe,proofOfKnowledge:he},We={identifier:ie,coefficients:ee,commitment:te.map(W),signers:{min:k.min,max:k.max},step:1};return{public:ue,secret:We}},round2:(R,k)=>{if(k.length!==R.signers.max-1)throw new Error("wrong number of round1 packages");if(!R.coefficients||R.step===3)throw new Error("round3 package used in round2");let H={};for(let V of k){if(V.commitment.length!==R.signers.min)throw new Error("wrong number of commitments");let ie=A(V.identifier);if(ie===R.identifier)throw new Error("duplicate id="+de(ie));K.validate(ie,V.commitment,V.proofOfKnowledge);for(let te of V.commitment)J(te);if(H[V.identifier])throw new Error("Duplicate id="+ie);let ee=r.toBytes(O(ie,R.coefficients));H[V.identifier]={identifier:de(R.identifier),signingShare:ee}}return R.step=2,H},round3:(R,k,H)=>{if(k.length!==R.signers.max-1)throw new Error("wrong length of round1 packages");if(!R.coefficients||R.step!==2)throw new Error("round2 package used in round3");if(H.length!==k.length)throw new Error("wrong length of round2 packages");let V={};for(let me of k){if(!me.identifier||!me.commitment)throw new Error("wrong round1 share");V[me.identifier]={...me}}for(let me of H){if(!me.identifier||!me.signingShare)throw new Error("wrong round2 share");if(!V[me.identifier])throw new Error("round1 share for "+me.identifier+" is missing");V[me.identifier].signingShare=me.signingShare}if(Object.keys(V).length!==k.length)throw new Error("mismatch identifiers between rounds");let ie=r.ZERO;if(R.commitment.length!==R.signers.min)throw new Error("wrong commitments length");let ee=R.commitment.map(J),te=O(R.identifier,R.coefficients);$(R.identifier,ee,te);let he=ee.map(W),oe={[de(R.identifier)]:he};for(let me in V){let ve=V[me];if(!ve.signingShare||!ve.commitment)throw new Error("mismatch identifiers");let Se=A(me),pn=r.fromBytes(ve.signingShare),Ye=ve.commitment.map(J);$(R.identifier,Ye,pn),ie=r.add(ie,pn);let je=de(Se);if(oe[je])throw new Error("duplicated id="+je);oe[je]=ve.commitment}ie=r.add(ie,te);let ue=new Array(R.signers.min).fill(t.ZERO);for(let me in oe){let ve=oe[me];if(ve.length!==R.signers.min)throw new Error("wrong commitments length");for(let Se=0;Se<ve.length;Se++)ue[Se]=ue[Se].add(J(ve[Se]))}let We=ue.map(W),Oe={};for(let me in oe)Oe[me]=W(f(A(me),ue));let re={public:{signers:{min:R.signers.min,max:R.signers.max},commitments:We,verifyingShares:Object.fromEntries(Object.entries(Oe).map(([me,ve])=>[me,ve.slice()]))},secret:{identifier:de(R.identifier),signingShare:r.toBytes(ie)}};e.adjustDKG&&(re=e.adjustDKG(re));for(let me=0;me<R.coefficients.length;me++)R.coefficients[me]-=R.coefficients[me];return delete R.coefficients,R.step=3,re},clean(R){if(R.identifier-=R.identifier,R.coefficients)for(let k=0;k<R.coefficients.length;k++)R.coefficients[k]-=R.coefficients[k];R.step=3}}),trustedDealer(R,k,H,V=ar){if(Kf(R),k===void 0){k=[];for(let ue=1;ue<=R.max;ue++)k.push(Z.fromNumber(ue))}else if(!Array.isArray(k)||k.length!==R.max)throw new Error("identifiers should be array of "+R.max);let ie={};for(let ue of k){let We=A(ue);if(ue in ie)throw new Error("duplicated id="+ue);ie[ue]=We}let ee=S(R,H,void 0,V),te=ee.commitment.map(W),he={},oe={};for(let ue of k){let We=O(ie[ue],ee.coefficients);oe[ue]=W(t.BASE.multiply(We)),he[ue]={identifier:ue,signingShare:r.toBytes(We)}}return{public:{signers:{min:R.min,max:R.max},commitments:te,verifyingShares:oe},secretShares:he}},validateSecret(R,k){let H=A(R.identifier),V=k.commitments.map(J),ie=r.fromBytes(R.signingShare);$(H,V,ie)},commit(R,k=ar){let H=r.fromBytes(R.signingShare),V=Q(H,k),ie=Q(H,k),ee={hiding:r.toBytes(V),binding:r.toBytes(ie)};return{nonces:ee,commitments:Y(R.identifier,ee)}},signShare(R,k,H,V,ie){uS(k.signers,V.length);let ee=r.fromBytes(H.hiding),te=r.fromBytes(H.binding);if(r.is0(ee)||r.is0(te))throw new Error("signing nonces already used");let he={identifier:R.identifier,hiding:W(t.BASE.multiply(ee)),binding:W(t.BASE.multiply(te))},oe=V.find(Ze=>Ze.identifier===R.identifier);if(!oe)throw new Error("missing signer commitment");if(Bn(oe.hiding)!==Bn(he.hiding)||Bn(oe.binding)!==Bn(he.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(R=e.adjustSecret(R,k)),e.adjustPublic&&(k=e.adjustPublic(k));let ue=r.fromBytes(R.signingShare),{lambda:We,challenge:Oe,bindingFactor:re,groupCommitment:me}=ge(k.commitments[0],V,ie,R.identifier),ve=e.adjustNonces?e.adjustNonces(me,H):H,Se=e.adjustNonces?r.fromBytes(ve.hiding):ee,pn=e.adjustNonces?r.fromBytes(ve.binding):te,Ye=r.mul(r.mul(We,ue),Oe),je=r.mul(pn,re),$a=r.toBytes(r.add(r.add(Se,je),Ye));return H.hiding.fill(0),H.binding.fill(0),$a},verifyShare(R,k,H,V,ie){e.adjustPublic&&(R=e.adjustPublic(R));let ee=k.find(pn=>pn.identifier===V);if(!ee)throw new Error("cannot find identifier commitment");let te=J(R.verifyingShares[V]),he=J(ee.hiding),oe=J(ee.binding),{lambda:ue,challenge:We,bindingFactor:Oe,groupCommitment:re}=ge(R.commitments[0],k,H,V),me=he.add(oe.multiply(Oe));e.adjustGroupCommitmentShare&&(me=e.adjustGroupCommitmentShare(re,me));let ve=t.BASE.multiply(r.fromBytes(ie)),Se=me.add(te.multiply(r.mul(We,ue)));return ve.equals(Se)},aggregate(R,k,H,V){e.adjustPublic&&(R=e.adjustPublic(R));try{uS(R.signers,k.length)}catch{throw new Zo("aggregation failed",[])}let ie=k.map(oe=>oe.identifier);if(ie.length!==Object.keys(V).length)throw new Zo("aggregation failed",[]);for(let oe of ie)if(!(oe in V)||!(oe in R.verifyingShares))throw new Zo("aggregation failed",[]);let ee=J(R.commitments[0]),{groupCommitment:te}=ae(ee,k,H),he=r.ZERO;for(let oe of ie)he=r.add(he,r.fromBytes(V[oe]));if(!F.verify(H,te,he,ee)){let oe=[];for(let ue of ie)this.verifyShare(R,k,H,ue,V[ue])||oe.push(ue);throw new Zo("aggregation failed",oe)}return u.encode(te,he)},sign(R,k){let H=r.fromBytes(k);e.adjustScalar&&(H=e.adjustScalar(H));let[V,ie]=F.sign(R,H);return u.encode(V,ie)},verify(R,k,H){let V=e.parsePublicKey?e.parsePublicKey(H):J(H),{R:ie,z:ee}=u.decode(R);return F.verify(k,ie,ee,V)},combineSecret(R,k){if(Kf(k),!Array.isArray(R)||R.length<k.min)throw new Error("wrong secret shares array");let H=[],V={};for(let te of R){let he=A(te.identifier),oe=de(he);if(V[oe])throw new Error("duplicated id="+oe);V[oe]=!0,H.push([he,r.fromBytes(te.signingShare)])}let ie=H.map(([te])=>te),ee=r.ZERO;for(let[te,he]of H)ee=r.add(ee,r.mul(he,_(ie,te)));return r.toBytes(ee)},utils:Object.freeze({Fn:r,randomScalar:(R=ar)=>r.toBytes(l(R).scalar),generateSecretPolynomial:(R,k,H,V)=>{let ie=S(R,k,H,V);return{...ie,commitment:ie.commitment.map(W)}}})};return Object.freeze(le)}var Kf,uS,Zo,fS=er(()=>{m();On();Vi();jf();nS();Yo();Kf=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},uS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Zo=class extends Error{constructor(r,n){super(r);C(this,"cheaters");this.cheaters=n}}});var Vf,cS,lS=er(()=>{m();On();Vf=class{constructor(t,r){C(this,"oHash");C(this,"iHash");C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"finished",!1);C(this,"destroyed",!1);if(Sf(t),on(r,void 0,"key"),this.iHash=t.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 n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Zt(i)}update(t){return Fo(this),this.iHash.update(t),this}digestInto(t){Fo(this),wf(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},cS=(()=>{let e=((t,r,n)=>new Vf(t,r).update(n).digest());return e.create=(t,r)=>new Vf(t,r),e})()});function BN(e,t,r){yd("scalar",e,Ar,r);let[[n,i],[o,s]]=t,a=hS(s*e,r),c=hS(-i*e,r),h=e-a*n-c*o,g=-a*i-c*s,y=h<Ar,w=g<Ar;y&&(h=-h),w&&(g=-g);let I=Go(Math.ceil(Ki(r)/2))+Lt;if(h<Ar||h>=I||g<Ar||g>=I)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:y,k1:h,k2neg:w,k2:g}}function Rd(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Od(e,t){Ir(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ji(r.lowS,"lowS"),ji(r.prehash,"prehash"),r.format!==void 0&&Rd(r.format),r}function dS(e,t={}){let r=eS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Ir(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:h}=t;if(c&&(!n.is0(o.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=yS(n,i);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function w(l,p,v){if(h&&p.is0())return Uint8Array.of(0);let{x:b,y:E}=p.toAffine(),O=n.toBytes(b);if(ji(v,"isCompressed"),v){y();let _=!n.isOdd(E);return Me(pS(_),O)}else return Me(Uint8Array.of(4),O,n.toBytes(E))}function I(l){Le(l,void 0,"Point");let{publicKey:p,publicKeyUncompressed:v}=g,b=l.length,E=l[0],O=l.subarray(1);if(h&&b===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(b===p&&(E===2||E===3)){let _=n.fromBytes(O);if(!n.isValid(_))throw new Error("bad point: is not on curve, wrong x");let f=L(_),S;try{S=n.sqrt(f)}catch($){let Z=$ instanceof Error?": "+$.message:"";throw new Error("bad point: is not on curve, sqrt error"+Z)}y();let K=n.isOdd(S);return(E&1)===1!==K&&(S=n.neg(S)),{x:_,y:S}}else if(b===v&&E===4){let _=n.BYTES,f=n.fromBytes(O.subarray(0,_)),S=n.fromBytes(O.subarray(_,_*2));if(!j(f,S))throw new Error("bad point: is not on curve");return{x:f,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${p} or uncompressed=${v}`)}let T=t.toBytes===void 0?w:t.toBytes,M=t.fromBytes===void 0?I:t.fromBytes;function L(l){let p=n.sqr(l),v=n.mul(p,l);return n.add(n.add(v,n.mul(l,o.a)),o.b)}function j(l,p){let v=n.sqr(p),b=L(l);return n.eql(v,b)}if(!j(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let G=n.mul(n.pow(o.a,Xo),Pd),q=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(G,q)))throw new Error("bad curve params: a or b");function W(l,p,v=!1){if(!n.isValid(p)||v&&n.is0(p))throw new Error(`bad point coordinate ${l}`);return p}function J(l){if(!(l instanceof se))throw new Error("Weierstrass Point expected")}function Y(l){if(!c||!c.basises)throw new Error("no endo");return BN(l,c.basises,i.ORDER)}function be(l,p,v,b,E){return v=new se(n.mul(v.X,l),v.Y,v.Z),p=aa(b,p),v=aa(E,v),p.add(v)}let u=class u{constructor(p,v,b){C(this,"X");C(this,"Y");C(this,"Z");this.X=W("x",p),this.Y=W("y",v,!0),this.Z=W("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(p){let{x:v,y:b}=p||{};if(!p||!n.isValid(v)||!n.isValid(b))throw new Error("invalid affine point");if(p instanceof u)throw new Error("projective point not allowed");return n.is0(v)&&n.is0(b)?u.ZERO:new u(v,b,n.ONE)}static fromBytes(p){let v=u.fromAffine(M(Le(p,void 0,"point")));return v.assertValidity(),v}static fromHex(p){return u.fromBytes(jo(p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,v=!0){return A.createCache(this,p),v||this.multiply(Xo),this}assertValidity(){let p=this;if(p.is0()){if(t.allowInfinityPoint&&n.is0(p.X)&&n.eql(p.Y,n.ONE)&&n.is0(p.Z))return;throw new Error("bad point: ZERO")}let{x:v,y:b}=p.toAffine();if(!n.isValid(v)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!j(v,b))throw new Error("bad point: equation left != right");if(!p.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:p}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(p)}equals(p){J(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:_,Z:f}=p,S=n.eql(n.mul(v,f),n.mul(O,E)),K=n.eql(n.mul(b,f),n.mul(_,E));return S&&K}negate(){return new u(this.X,n.neg(this.Y),this.Z)}double(){let{a:p,b:v}=o,b=n.mul(v,Xo),{X:E,Y:O,Z:_}=this,f=n.ZERO,S=n.ZERO,K=n.ZERO,F=n.mul(E,E),$=n.mul(O,O),Z=n.mul(_,_),Q=n.mul(E,O);return Q=n.add(Q,Q),K=n.mul(E,_),K=n.add(K,K),f=n.mul(p,K),S=n.mul(b,Z),S=n.add(f,S),f=n.sub($,S),S=n.add($,S),S=n.mul(f,S),f=n.mul(Q,f),K=n.mul(b,K),Z=n.mul(p,Z),Q=n.sub(F,Z),Q=n.mul(p,Q),Q=n.add(Q,K),K=n.add(F,F),F=n.add(K,F),F=n.add(F,Z),F=n.mul(F,Q),S=n.add(S,F),Z=n.mul(O,_),Z=n.add(Z,Z),F=n.mul(Z,Q),f=n.sub(f,F),K=n.mul(Z,$),K=n.add(K,K),K=n.add(K,K),new u(f,S,K)}add(p){J(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:_,Z:f}=p,S=n.ZERO,K=n.ZERO,F=n.ZERO,$=o.a,Z=n.mul(o.b,Xo),Q=n.mul(v,O),ae=n.mul(b,_),ge=n.mul(E,f),le=n.add(v,b),R=n.add(O,_);le=n.mul(le,R),R=n.add(Q,ae),le=n.sub(le,R),R=n.add(v,E);let k=n.add(O,f);return R=n.mul(R,k),k=n.add(Q,ge),R=n.sub(R,k),k=n.add(b,E),S=n.add(_,f),k=n.mul(k,S),S=n.add(ae,ge),k=n.sub(k,S),F=n.mul($,R),S=n.mul(Z,ge),F=n.add(S,F),S=n.sub(ae,F),F=n.add(ae,F),K=n.mul(S,F),ae=n.add(Q,Q),ae=n.add(ae,Q),ge=n.mul($,ge),R=n.mul(Z,R),ae=n.add(ae,ge),ge=n.sub(Q,ge),ge=n.mul($,ge),R=n.add(R,ge),Q=n.mul(ae,R),K=n.add(K,Q),Q=n.mul(k,R),S=n.mul(le,S),S=n.sub(S,Q),Q=n.mul(le,ae),F=n.mul(k,F),F=n.add(F,Q),new u(S,K,F)}subtract(p){return J(p),this.add(p.negate())}is0(){return this.equals(u.ZERO)}multiply(p){let{endo:v}=t;if(!i.isValidNot0(p))throw new RangeError("invalid scalar: out of range");let b,E,O=_=>A.cached(this,_,f=>Ed(u,f));if(v){let{k1neg:_,k1:f,k2neg:S,k2:K}=Y(p),{p:F,f:$}=O(f),{p:Z,f:Q}=O(K);E=$.add(Q),b=be(v.beta,F,Z,_,S)}else{let{p:_,f}=O(p);b=_,E=f}return Ed(u,[b,E])[0]}multiplyUnsafe(p){let{endo:v}=t,b=this,E=p;if(!i.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Ar||b.is0())return u.ZERO;if(E===Lt)return b;if(A.hasCache(this))return this.multiply(E);if(v){let{k1neg:O,k1:_,k2neg:f,k2:S}=Y(E),{p1:K,p2:F}=J_(u,b,_,S);return be(v.beta,K,F,O,f)}else return A.unsafe(b,E)}toAffine(p){let v=this,b=p,{X:E,Y:O,Z:_}=v;if(n.eql(_,n.ONE))return{x:E,y:O};let f=v.is0();b==null&&(b=f?n.ONE:n.inv(_));let S=n.mul(E,b),K=n.mul(O,b),F=n.mul(_,b);if(f)return{x:n.ZERO,y:n.ZERO};if(!n.eql(F,n.ONE))throw new Error("invZ was invalid");return{x:S,y:K}}isTorsionFree(){let{isTorsionFree:p}=t;return s===Lt?!0:p?p(u,this):A.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:p}=t;return s===Lt?this:p?p(u,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Lt?this.is0():this.clearCofactor().is0()}toBytes(p=!0){return ji(p,"isCompressed"),this.assertValidity(),T(u,this,p)}toHex(p=!0){return Bn(this.toBytes(p))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};C(u,"BASE",new u(o.Gx,o.Gy,n.ONE)),C(u,"ZERO",new u(n.ZERO,n.ONE,n.ZERO)),C(u,"Fp",n),C(u,"Fn",i);let se=u,de=i.BITS,A=new qf(se,t.endo?Math.ceil(de/2):de);return de>=8&&se.BASE.precompute(8),Object.freeze(se.prototype),Object.freeze(se),se}function pS(e){return Uint8Array.of(e?2:3)}function NN(e,t){let r=zi(e),n=r.ORDER,i=Ar;for(let M=n-Lt;M%an===Ar;M/=an)i+=Lt;let o=i,s=an<<o-Lt-Lt,a=s*an,c=(n-Lt)/a,h=(c-Lt)/an,g=a-Lt,y=s,w=r.pow(t,c),I=r.pow(t,(c+Lt)/an),T=(M,L)=>{let j=w,G=r.pow(L,g),q=r.sqr(G);q=r.mul(q,L);let W=r.mul(M,q);W=r.pow(W,h),W=r.mul(W,G),G=r.mul(W,L),q=r.mul(W,M);let J=r.mul(q,G);W=r.pow(J,y);let Y=r.eql(W,r.ONE);G=r.mul(q,I),W=r.mul(J,j),q=r.cmov(G,q,Y),J=r.cmov(W,J,Y);for(let be=o;be>Lt;be--){let se=be-an;se=an<<se-Lt;let de=r.pow(J,se),A=r.eql(de,r.ONE);G=r.mul(q,j),j=r.mul(j,j),de=r.mul(J,j),q=r.cmov(G,q,A),J=r.cmov(de,J,A)}return{isValid:!r.is0(L)&&(Y||r.is0(M)),value:q}};if(r.ORDER%Pd===Xo){let M=(r.ORDER-Xo)/Pd,L=r.sqrt(r.neg(t));T=(j,G)=>{let q=r.sqr(G),W=r.mul(j,G);q=r.mul(q,W);let J=r.pow(q,M);J=r.mul(J,W);let Y=r.mul(J,L),be=r.mul(r.sqr(J),G),se=r.eql(be,j),de=r.cmov(Y,J,se);return{isValid:!r.is0(G)&&se,value:de}}}return T}function gS(e,t){let r=zi(e),{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||bd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!bd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let c=NN(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return h=>{let g,y,w,I,T,M,L,j;g=r.sqr(h),g=r.mul(g,o),y=r.sqr(g),y=r.add(y,g),w=r.add(y,r.ONE),w=r.mul(w,i),I=r.cmov(o,r.neg(y),!r.eql(y,r.ZERO)),I=r.mul(I,n),y=r.sqr(w),M=r.sqr(I),T=r.mul(M,n),y=r.add(y,T),y=r.mul(y,w),M=r.mul(M,I),T=r.mul(M,i),y=r.add(y,T),L=r.mul(g,w);let{isValid:G,value:q}=c(y,M);j=r.mul(g,h),j=r.mul(j,q),L=r.cmov(L,w,G),j=r.cmov(j,q,G);let W=r.isOdd(h)===r.isOdd(j);j=r.cmov(r.neg(j),j,W);let J=Wi(r,[I],!0)[0];return L=r.mul(L,J),{x:L,y:j}}}function yS(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function MN(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?ar:t.randomBytes,i=Object.assign(yS(e.Fp,r),{seed:Math.max(sa(r.ORDER),16)});function o(I){try{let T=r.fromBytes(I);return r.isValidNot0(T)}catch{return!1}}function s(I,T){let{publicKey:M,publicKeyUncompressed:L}=i;try{let j=I.length;return T===!0&&j!==M||T===!1&&j!==L?!1:!!e.fromBytes(I)}catch{return!1}}function a(I){return I=I===void 0?n(i.seed):I,Wo(Le(I,i.seed,"seed"),r.ORDER)}function c(I,T=!0){return e.BASE.multiply(r.fromBytes(I)).toBytes(T)}function h(I){let{secretKey:T,publicKey:M,publicKeyUncompressed:L}=i,j=r._lengths;if(!Hi(I))return;let G=Le(I,void 0,"key").length,q=G===M||G===L,W=G===T||!!j?.includes(G);if(!(q&&W))return q}function g(I,T,M=!0){if(h(I)===!0)throw new Error("first arg must be private key");if(h(T)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(I);return e.fromBytes(T).multiply(L).toBytes(M)}let y={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},w=Hf(a,c);return Object.freeze(y),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:g,keygen:w,Point:e,utils:y,lengths:i})}function mS(e,t,r={}){let n=t;Sf(n),Ir(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?ar:r.randomBytes,o=r.hmac===void 0?(b,E)=>cS(n,b,E):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:h}=a,{keygen:g,getPublicKey:y,getSharedSecret:w,utils:I,lengths:T}=MN(e,r),M={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},L=c*an+Lt<s.ORDER;function j(b){let E=c>>Lt;return b>E}function G(b,E){if(!a.isValidNot0(E))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return E}function q(){if(L)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function W(b,E){Rd(E);let O=T.signature,_=E==="compact"?O:E==="recovered"?O+1:void 0;return Le(b,_)}class J{constructor(E,O,_){C(this,"r");C(this,"s");C(this,"recovery");if(this.r=G("r",E),this.s=G("s",O),_!=null){if(q(),![0,1,2,3].includes(_))throw new Error("invalid recovery id");this.recovery=_}Object.freeze(this)}static fromBytes(E,O=M.format){W(E,O);let _;if(O==="der"){let{r:F,s:$}=Dr.toSig(Le(E));return new J(F,$)}O==="recovered"&&(_=E[0],O="compact",E=E.subarray(1));let f=T.signature/2,S=E.subarray(0,f),K=E.subarray(f,f*2);return new J(a.fromBytes(S),a.fromBytes(K),_)}static fromHex(E,O){return this.fromBytes(jo(E),O)}assertRecovery(){let{recovery:E}=this;if(E==null)throw new Error("invalid recovery id: must be present");return E}addRecoveryBit(E){return new J(this.r,this.s,E)}recoverPublicKey(E){let{r:O,s:_}=this,f=this.assertRecovery(),S=f===2||f===3?O+c:O;if(!s.isValid(S))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=s.toBytes(S),F=e.fromBytes(Me(pS((f&1)===0),K)),$=a.inv(S),Z=be(Le(E,void 0,"msgHash")),Q=a.create(-Z*$),ae=a.create(_*$),ge=e.BASE.multiplyUnsafe(Q).add(F.multiplyUnsafe(ae));if(ge.is0())throw new Error("invalid recovery: point at infinify");return ge.assertValidity(),ge}hasHighS(){return j(this.s)}toBytes(E=M.format){if(Rd(E),E==="der")return jo(Dr.hexFromSig(this));let{r:O,s:_}=this,f=a.toBytes(O),S=a.toBytes(_);return E==="recovered"?(q(),Me(Uint8Array.of(this.assertRecovery()),f,S)):Me(f,S)}toHex(E){return Bn(this.toBytes(E))}}Object.freeze(J.prototype),Object.freeze(J);let Y=r.bits2int===void 0?function(E){if(E.length>8192)throw new Error("input is too large");let O=tr(E),_=E.length*8-h;return _>0?O>>BigInt(_):O}:r.bits2int,be=r.bits2int_modN===void 0?function(E){return a.create(Y(E))}:r.bits2int_modN,se=Go(h);function de(b){return yd("num < 2^"+h,b,Ar,se),a.toBytes(b)}function A(b,E){return Le(b,void 0,"message"),E?Le(n(b),void 0,"prehashed message"):b}function u(b,E,O){let{lowS:_,prehash:f,extraEntropy:S}=Od(O,M);b=A(b,f);let K=be(b),F=a.fromBytes(E);if(!a.isValidNot0(F))throw new Error("invalid private key");let $=[de(F),de(K)];if(S!=null&&S!==!1){let ge=S===!0?i(T.secretKey):S;$.push(Le(ge,void 0,"extraEntropy"))}let Z=Me(...$),Q=K;function ae(ge){let le=Y(ge);if(!a.isValidNot0(le))return;let R=a.inv(le),k=e.BASE.multiply(le).toAffine(),H=a.create(k.x);if(H===Ar)return;let V=a.create(R*a.create(Q+H*F));if(V===Ar)return;let ie=(k.x===H?0:2)|Number(k.y&Lt),ee=V;return _&&j(V)&&(ee=a.neg(V),ie^=1),new J(H,ee,L?void 0:ie)}return{seed:Z,k2sig:ae}}function l(b,E,O={}){let{seed:_,k2sig:f}=u(b,E,O);return C_(n.outputLen,a.BYTES,o)(_,f).toBytes(O.format)}function p(b,E,O,_={}){let{lowS:f,prehash:S,format:K}=Od(_,M);if(O=Le(O,void 0,"publicKey"),E=A(E,S),!Hi(b)){let F=b instanceof J?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+F)}W(b,K);try{let F=J.fromBytes(b,K),$=e.fromBytes(O);if(f&&F.hasHighS())return!1;let{r:Z,s:Q}=F,ae=be(E),ge=a.inv(Q),le=a.create(ae*ge),R=a.create(Z*ge),k=e.BASE.multiplyUnsafe(le).add($.multiplyUnsafe(R));return k.is0()?!1:a.create(k.x)===Z}catch{return!1}}function v(b,E,O={}){let{prehash:_}=Od(O,M);return E=A(E,_),J.fromBytes(b,"recovered").recoverPublicKey(E).toBytes()}return Object.freeze({keygen:g,getPublicKey:y,getSharedSecret:w,utils:I,lengths:T,Point:e,sign:l,verify:p,recoverPublicKey:v,Signature:J,hash:n})}var hS,Td,Dr,Ar,Lt,an,Xo,Pd,vS=er(()=>{m();lS();On();Vi();jf();Yo();hS=(e,t)=>(e+(e>=0?t:-t)/an)/t;Td=class extends Error{constructor(t=""){super(t)}},Dr={Err:Td,_tlv:{encode:(e,t)=>{let{Err:r}=Dr;if(xr(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=oa(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?oa(i.length/2|128):"";return oa(e)+o+i+t},decode(e,t){let{Err:r}=Dr;t=Le(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&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 h=t.subarray(n,n+c);if(h.length!==c)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let g of h)s=s<<8|g;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Dr;if(Lf(e),e<Ar)throw new t("integer: negative integers are not allowed");let r=oa(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Dr;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return tr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Dr,i=Le(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:h,l:g}=n.decode(2,c);if(g.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(h)}},hexFromSig(e){let{_tlv:t,_int:r}=Dr,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(Dr._tlv);Object.freeze(Dr._int);Object.freeze(Dr);Ar=BigInt(0),Lt=BigInt(1),an=BigInt(2),Xo=BigInt(3),Pd=BigInt(4)});var OS={};sl(OS,{__TEST:()=>UN,schnorr:()=>FN,schnorr_FROST:()=>zN,secp256k1:()=>LN,secp256k1_FROST:()=>jN,secp256k1_hasher:()=>Md});function CN(e){let t=Gf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),h=e*e*e%t,g=h*h*e%t,y=dr(g,r,t)*g%t,w=dr(y,r,t)*g%t,I=dr(w,Bd,t)*h%t,T=dr(I,i,t)*I%t,M=dr(T,o,t)*T%t,L=dr(M,a,t)*M%t,j=dr(L,c,t)*L%t,G=dr(j,a,t)*M%t,q=dr(G,r,t)*g%t,W=dr(q,s,t)*T%t,J=dr(W,n,t)*h%t,Y=dr(J,Bd,t);if(!Nn.eql(Nn.sqr(Y),e))throw new Error("Cannot find square root");return Y}function ua(e,...t){let r=bS[e];if(r===void 0){let n=ni(Vo(e));r=Me(n,n),bS[e]=r}return ni(Me(r,...t))}function ES(e){let{Fn:t,BASE:r}=Ue,n=t.fromBytes(e),i=r.multiply(n);return{scalar:un(i.y)?n:t.neg(n),bytes:Zi(i)}}function zf(e){let t=Nn;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),n=t.create(r*e+BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=Ue.fromAffine({x:e,y:i});return o.assertValidity(),o}function Nd(...e){return Ue.Fn.create(Jo(ua("BIP0340/challenge",...e)))}function _S(e){return ES(e).bytes}function DN(e,t,r=ra(32)){let{Fn:n,BASE:i}=Ue,o=Le(e,void 0,"message"),{bytes:s,scalar:a}=ES(t),c=Le(r,32,"auxRand"),h=n.toBytes(a^Jo(ua("BIP0340/aux",c))),g=ua("BIP0340/nonce",h,s,o),y=n.create(Jo(g));if(y===0n)throw new Error("sign failed: k is zero");let w=i.multiply(y),I=un(w.y)?y:n.neg(y),T=Zi(w),M=Nd(T,s,o),L=new Uint8Array(64);if(L.set(T,0),L.set(n.toBytes(n.create(I+M*a)),32),!xS(L,o,s))throw new Error("sign: Invalid signature produced");return L}function xS(e,t,r){let{Fp:n,Fn:i,BASE:o}=Ue,s=Le(e,64,"signature"),a=Le(t,void 0,"message"),c=Le(r,32,"publicKey");try{let h=zf(Jo(c)),g=Jo(s.subarray(0,32));if(!n.isValidNot0(g))return!1;let y=Jo(s.subarray(32,64));if(!i.isValidNot0(y))return!1;let w=Nd(i.toBytes(g),Zi(h),a),I=o.multiplyUnsafe(y).add(h.multiplyUnsafe(i.neg(w))),{x:T,y:M}=I.toAffine();return!(I.is0()||!un(M)||T!==g)}catch{return!1}}function IS(e,t){if(t===void 0)return wS;let r=Zi(e),n=tr(ua("TapTweak",r,t));if(!Ue.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function kd(e){let t=Ue.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ue.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Ue.fromBytes(n).negate().toBytes()]))}}function AS(e,t){let r=Ue.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=Ue.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function KN(e,t){if(un(e.y))return t;let r=Ue.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function VN(e,t,r){let n=Ue.Fn,i=AS(e,t),o=kd(t),s=IS(Ue.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function GN(e,t){let r=kd(e),n=IS(Ue.fromBytes(r.commitments[0]),t),i=Ue.BASE.multiply(n),o=r.commitments.map((a,c)=>(c===0?Ue.fromBytes(a).add(i):Ue.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Ue.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Gf,kN,wS,Bd,Nn,Ue,LN,bS,Zi,un,Jo,UN,FN,qN,SS,HN,Md,jN,zN,RS=er(()=>{m();hd();On();jf();fS();aS();Yo();vS();Vi();Gf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kN={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},wS=BigInt(0),Bd=BigInt(2);Nn=zo(Gf.p,{sqrt:CN}),Ue=dS(Gf,{Fp:Nn,endo:kN}),LN=mS(Ue,ni),bS={};Zi=e=>e.toBytes(!0).slice(1),un=e=>e%Bd===wS;Jo=tr;UN=Object.freeze({lift_x:zf}),FN=(()=>{let r=n=>(n=n===void 0?ra(48):n,Wo(n,Gf.n));return Object.freeze({keygen:Hf(r,_S),getPublicKey:_S,sign:DN,verify:xS,Point:Ue,utils:Object.freeze({randomSecretKey:r,taggedHash:ua,lift_x:zf,pointToBytes:Zi}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),qN=oS(Nn,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),HN=()=>SS||(SS=gS(Nn,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Nn.create(BigInt("-11"))})),Md=sS(Ue,e=>{let{x:t,y:r}=HN()(Nn.create(e[0]));return qN(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Nn.ORDER,m:1,k:128,expand:"xmd",hash:ni}),jN=Ad({name:"FROST-secp256k1-SHA256-v1",Point:Ue,hashToScalar:Md.hashToScalar,hash:ni});zN=Ad({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ue,hashToScalar:Md.hashToScalar,hash:ni,parsePublicKey(e){if(e.length===32)return zf(tr(e));if(e.length===33)return Ue.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ue.BASE.multiply(e);return un(t.y)?e:Ue.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return Nd(Zi(e),Zi(t),r)},adjustNonces:KN,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:kd,adjustSecret:AS,adjustTx:{encode:e=>e.subarray(1),decode:e=>Me(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:GN(e.public,t),secret:VN(e.secret,e.public,t)}}})});var ii=P((wU,NS)=>{"use strict";m();var TS=Er(),{secp256k1:WN}=(RS(),al(OS)),ca=WN.Point,Wf=ca.Fn.ORDER;function YN(e){return BigInt("0x"+(e.toString(16)||"0"))}function Cd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new TS(t,16)}function Yf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return YN(e);throw new Error("Invalid Point")}function fa(e){var t=Object.create(Fe.prototype);return t._p=e,t}function PS(e,t){var r=Yf(t).toString(16).padStart(64,"0");return ca.fromHex((e?"03":"02")+r)}function BS(e,t){var r;try{r=PS((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function Fe(e,t,r){if(!(this instanceof Fe))return new Fe(e,t,r);var n,i;try{n=Yf(e),i=Yf(t)}catch{throw new Error("Invalid Point")}BS(n,i);try{this._p=ca.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}Fe.fromX=function(t,r){try{var n=fa(PS(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};Fe.getG=function(){return fa(ca.BASE)};Fe.getN=function(){return Cd(Wf)};Fe.prototype.getX=function(){return Cd(this._p.toAffine().x)};Fe.prototype.getY=function(){return Cd(this._p.toAffine().y)};Object.defineProperty(Fe.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(Fe.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});Fe.prototype.mul=function(t){var r=(Yf(t)%Wf+Wf)%Wf;return r===0n||this._p.is0()?fa(ca.ZERO):fa(this._p.multiply(r))};Fe.prototype.add=function(t){return fa(this._p.add(t._p))};Fe.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};Fe.prototype.eq=function(t){return this._p.equals(t._p)};Fe.prototype.isInfinity=function(){return this._p.is0()};Fe.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return BS(t.x,t.y),this};Fe.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};Fe.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=TS.fromBuffer(e.slice(1,33));return Fe.fromX(r,n)};Fe.prototype.toBuffer=function(){return Fe.pointToCompressed(this)};Fe.prototype.toHex=function(){return this.toBuffer().toString("hex")};Fe.fromBuffer=function(e){return Fe.pointFromCompressed(e)};Fe.fromHex=function(e){return Fe.fromBuffer(d.Buffer.from(e,"hex"))};NS.exports=Fe});var kS=P((xU,MS)=>{"use strict";m();var $f=Qs(),Mn=ke(),It=MS.exports;It.sha1=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha1").update(e).digest()};It.sha1.blocksize=512;It.sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha256").update(e).digest()};It.sha256.blocksize=512;It.sha256sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.sha256(It.sha256(e))};It.ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("ripemd160").update(e).digest()};It.sha256ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.ripemd160(It.sha256(e))};It.sha512=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha512").update(e).digest()};It.sha512.blocksize=1024;It.hmac=function(e,t,r){Mn.checkArgument(d.Buffer.isBuffer(t)),Mn.checkArgument(d.Buffer.isBuffer(r)),Mn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};It.sha256hmac=function(e,t){return It.hmac(It.sha256,e,t)};It.sha512hmac=function(e,t){return It.hmac(It.sha512,e,t)}});var HS={};sl(HS,{_MD5:()=>Qf,_RIPEMD160:()=>ec,_SHA1:()=>Jf,md5:()=>JN,ripemd160:()=>oM,sha1:()=>$N});function CS(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Qo,oi,Jf,$N,ZN,XN,Zf,Ld,Qf,JN,QN,LS,eM,DS,US,FS,qS,tM,rM,nM,iM,Xf,ec,oM,jS=er(()=>{m();fd();On();Qo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),oi=new Uint32Array(80),Jf=class extends Rn{constructor(){super(64,20,8,!1);C(this,"A",Qo[0]|0);C(this,"B",Qo[1]|0);C(this,"C",Qo[2]|0);C(this,"D",Qo[3]|0);C(this,"E",Qo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}process(r,n){for(let h=0;h<16;h++,n+=4)oi[h]=r.getUint32(n,!1);for(let h=16;h<80;h++)oi[h]=In(oi[h-3]^oi[h-8]^oi[h-14]^oi[h-16],1);let{A:i,B:o,C:s,D:a,E:c}=this;for(let h=0;h<80;h++){let g,y;h<20?(g=qo(o,s,a),y=1518500249):h<40?(g=o^s^a,y=1859775393):h<60?(g=If(o,s,a),y=2400959708):(g=o^s^a,y=3395469782);let w=In(i,5)+g+c+y+oi[h]|0;c=a,a=s,s=In(o,30),o=i,i=w}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,this.set(i,o,s,a,c)}roundClean(){Zt(oi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),Zt(this.buffer)}},$N=Lr(()=>new Jf),ZN=Math.pow(2,32),XN=Array.from({length:64},(e,t)=>Math.floor(ZN*Math.abs(Math.sin(t+1)))),Zf=Qo.slice(0,4),Ld=new Uint32Array(16),Qf=class extends Rn{constructor(){super(64,16,8,!0);C(this,"A",Zf[0]|0);C(this,"B",Zf[1]|0);C(this,"C",Zf[2]|0);C(this,"D",Zf[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}process(r,n){for(let c=0;c<16;c++,n+=4)Ld[c]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let c=0;c<64;c++){let h,g,y;c<16?(h=qo(o,s,a),g=c,y=[7,12,17,22]):c<32?(h=qo(a,o,s),g=(5*c+1)%16,y=[5,9,14,20]):c<48?(h=o^s^a,g=(3*c+5)%16,y=[4,11,16,23]):(h=s^(o|~a),g=7*c%16,y=[6,10,15,21]),h=h+i+XN[c]+Ld[g],i=a,a=s,s=o,o=o+In(h,y[c%4])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){Zt(Ld)}destroy(){this.destroyed=!0,this.set(0,0,0,0),Zt(this.buffer)}},JN=Lr(()=>new Qf),QN=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),LS=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),eM=LS.map(e=>(9*e+5)%16),DS=(()=>{let r=[[LS],[eM]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>QN[o]));return r})(),US=DS[0],FS=DS[1],qS=[[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(e=>Uint8Array.from(e)),tM=US.map((e,t)=>e.map(r=>qS[t][r])),rM=FS.map((e,t)=>e.map(r=>qS[t][r])),nM=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),iM=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Xf=new Uint32Array(16),ec=class extends Rn{constructor(){super(64,20,8,!0);C(this,"h0",1732584193);C(this,"h1",-271733879);C(this,"h2",-1732584194);C(this,"h3",271733878);C(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}process(r,n){for(let T=0;T<16;T++,n+=4)Xf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,c=this.h2|0,h=c,g=this.h3|0,y=g,w=this.h4|0,I=w;for(let T=0;T<5;T++){let M=4-T,L=nM[T],j=iM[T],G=US[T],q=FS[T],W=tM[T],J=rM[T];for(let Y=0;Y<16;Y++){let be=In(i+CS(T,s,c,g)+Xf[G[Y]]+L,W[Y])+w|0;i=w,w=g,g=In(c,10)|0,c=s,s=be}for(let Y=0;Y<16;Y++){let be=In(o+CS(M,a,h,y)+Xf[q[Y]]+j,J[Y])+I|0;o=I,I=y,y=In(h,10)|0,h=a,a=be}}this.set(this.h1+c+y|0,this.h2+g+I|0,this.h3+w+o|0,this.h4+i+a|0,this.h0+s+h|0)}roundClean(){Zt(Xf)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0)}},oM=Lr(()=>new ec)});var VS=P((PU,KS)=>{"use strict";m();var{sha256:sM,sha512:aM}=(hd(),al(M_)),{sha1:uM,ripemd160:fM}=(jS(),al(HS)),kn=ke(),At=KS.exports;At.sha1=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(uM(e))};At.sha1.blocksize=512;At.sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(sM(e))};At.sha256.blocksize=512;At.sha256sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.sha256(At.sha256(e))};At.ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(fM(e))};At.sha256ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.ripemd160(At.sha256(e))};At.sha512=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(aM(e))};At.sha512.blocksize=1024;At.hmac=function(e,t,r){kn.checkArgument(d.Buffer.isBuffer(t)),kn.checkArgument(d.Buffer.isBuffer(r)),kn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};At.sha256hmac=function(e,t){return At.hmac(At.sha256,e,t)};At.sha512hmac=function(e,t){return At.hmac(At.sha512,e,t)}});var Qt=P((NU,zS)=>{"use strict";m();var GS={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function cM(){var e;try{e=Qs()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(GS),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==GS[n])return!1}catch{return!1}}return!0}zS.exports=cM()?kS():VS()});var pr=P((kU,$S)=>{"use strict";m();var YS=Ve(),lM=ke(),WS=function(t){return YS.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};$S.exports={isValidJSON:function(t){var r;if(!YS.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:WS,isHexaString:WS,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){lM.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var ga=P((LU,JS)=>{"use strict";m();var Cn=Ve(),la=pr(),Xi=[],ha={};function ZS(){}ZS.prototype.toString=function(){return this.name};function da(e,t){if(~Xi.indexOf(e))return e;if(t){Cn.isArray(t)||(t=[t]);for(var r=0;r<Xi.length;r++){var n=Xi[r],i=Cn.pick(n,t),o=Cn.values(i);if(~o.indexOf(e))return n}return}return ha[e]}function tc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function pa(e){var t=new ZS;la.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Cn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:tc(e.cashAddrPrefix)}),e.networkMagic&&Cn.extend(t,{networkMagic:la.integerAsBuffer(e.networkMagic)}),e.port&&Cn.extend(t,{port:e.port}),e.dnsSeeds&&Cn.extend(t,{dnsSeeds:e.dnsSeeds}),Xi.push(t),hM(t,r),t}function hM(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Cn.isUndefined(i)&&!Cn.isObject(i)&&(ha[i]=e)}}function dM(e,t){for(var r=0;r<t.length;r++){var n=t[r];ha[n]===e&&delete ha[n]}}function pM(e){for(var t=0;t<Xi.length;t++)Xi[t]===e&&Xi.splice(t,1);dM(e,Object.keys(ha))}var rc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},XS=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],si={PORT:18333,NETWORK_MAGIC:rc.testnet,DNS_SEEDS:XS,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Ln={PORT:18444,NETWORK_MAGIC:rc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ai={PORT:9333,NETWORK_MAGIC:rc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},gM={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:rc.livenet,port:8333,dnsSeeds:XS},yM={name:"testnet",prefix:si.PREFIX,cashAddrPrefix:si.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:si.NETWORK_MAGIC},mM={name:"regtest",prefix:Ln.PREFIX,cashAddrPrefix:Ln.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ln.NETWORK_MAGIC,port:Ln.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},vM={name:"stn",prefix:ai.PREFIX,cashAddrPrefix:ai.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ai.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};pa(yM);pa(vM);pa(mM);pa(gM);var Dd=da("livenet"),bM=da("regtest"),fn=da("testnet"),_M=da("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.PORT:this.stnEnabled?ai.PORT:si.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?la.integerAsBuffer(Ln.NETWORK_MAGIC):this.stnEnabled?la.integerAsBuffer(ai.NETWORK_MAGIC):la.integerAsBuffer(si.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.DNS_SEEDS:this.stnEnabled?ai.DNS_SEEDS:si.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.CASHADDRPREFIX:this.stnEnabled?ai.CASHADDRPREFIX:si.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?tc(Ln.CASHADDRPREFIX):this.stnEnabled?tc(ai.CASHADDRPREFIX):tc(si.CASHADDRPREFIX)}});function SM(){fn.regtestEnabled=!0}function wM(){fn.regtestEnabled=!1}function EM(){fn.stnEnabled=!0}function xM(){fn.stnEnabled=!1}JS.exports={add:pa,remove:pM,defaultNetwork:Dd,livenet:Dd,mainnet:Dd,testnet:fn,regtest:bM,stn:_M,get:da,enableRegtest:SM,disableRegtest:wM,enableStn:EM,disableStn:xM}});var rw=P((UU,tw)=>{"use strict";m();var Ud=Ve(),QS=Tt(),es="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),ew={};for(ya=0;ya<es.length;ya++)ew[es[ya]]=ya;var ya;function IM(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=es[0];for(r=t.length-1;r>=0;r--)o+=es[t[r]];return o}function AM(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=ew[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===es[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Dt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Dt.validCharacters=function(t){return QS.Buffer.isBuffer(t)&&(t=t.toString()),Ud.every(Ud.map(t,function(r){return Ud.includes(es,r)}))};Dt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Dt.encode=function(e){if(!QS.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return IM(e)};Dt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return AM(e)};Dt.prototype.fromBuffer=function(e){return this.buf=e,this};Dt.fromBuffer=function(e){return new Dt().fromBuffer(e)};Dt.fromHex=function(e){return Dt.fromBuffer(d.Buffer.from(e,"hex"))};Dt.prototype.fromString=function(e){var t=Dt.decode(e);return this.buf=t,this};Dt.fromString=function(e){return new Dt().fromString(e)};Dt.prototype.toBuffer=function(){return this.buf};Dt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Dt.prototype.toString=function(){return Dt.encode(this.buf)};tw.exports=Dt});var Fd=P((qU,sw)=>{"use strict";m();var nw=Ve(),nc=rw(),iw=Tt(),ow=Qt().sha256sha256,Je=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Je.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Je.validChecksum=function(t,r){return nw.isString(t)&&(t=iw.Buffer.from(nc.decode(t))),nw.isString(r)&&(r=iw.Buffer.from(nc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),Je.checksum(t).toString("hex")===r.toString("hex")};Je.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(nc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=ow(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};Je.checksum=function(e){return ow(e).slice(0,4)};Je.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=Je.checksum(e);return e.copy(t),r.copy(t,e.length),nc.encode(t)};Je.prototype.fromBuffer=function(e){return this.buf=e,this};Je.fromBuffer=function(e){return new Je().fromBuffer(e)};Je.fromHex=function(e){return Je.fromBuffer(d.Buffer.from(e,"hex"))};Je.prototype.fromString=function(e){var t=Je.decode(e);return this.buf=t,this};Je.fromString=function(e){var t=Je.decode(e);return new Je(t)};Je.prototype.toBuffer=function(){return this.buf};Je.prototype.toHex=function(){return this.toBuffer().toString("hex")};Je.prototype.toString=function(){return Je.encode(this.buf)};sw.exports=Je});var va=P((jU,uw)=>{"use strict";m();var ma=Ve(),aw=ke(),ts=Er(),et=function e(t){if(!(this instanceof e))return new e(t);if(!ma.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ma.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ma.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};et.prototype.eof=function(){return this.pos>=this.buf.length};et.prototype.finished=et.prototype.eof;et.prototype.read=function(e){aw.checkArgument(!ma.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};et.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};et.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};et.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=ts.fromBuffer(e);return this.pos=this.pos+8,t};et.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new ts(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new ts(i,10,"le")}return this.pos=this.pos+8,n};et.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};et.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return aw.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};et.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};et.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new ts(this.readUInt16LE());case 254:return new ts(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new ts(e)}};et.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};et.prototype.readReverse=function(e){ma.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};uw.exports=et});var jd=P((VU,hw)=>{"use strict";m();function ui(e){"@babel/helpers - typeof";return ui=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ui(e)}function fw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,RM(n.key),n)}}function OM(e,t,r){return t&&fw(e.prototype,t),r&&fw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function RM(e){var t=TM(e,"string");return ui(t)==="symbol"?t:String(t)}function TM(e,t){if(ui(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ui(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function PM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function BM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Hd(e,t)}function Hd(e,t){return Hd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Hd(e,t)}function NM(e){var t=CM();return function(){var n=ic(e),i;if(t){var o=ic(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return MM(this,i)}}function MM(e,t){if(t&&(ui(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kM(e)}function kM(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function CM(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ic(e){return ic=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ic(e)}var lw={},rs,qd;function ba(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){BM(a,o);var s=NM(a);function a(c,h,g){var y;return PM(this,a),y=s.call(this,n(c,h,g)),y.code=e,y}return OM(a)})(r);lw[e]=i}function cw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function LM(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function DM(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function UM(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}ba("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);ba("ERR_INVALID_ARG_TYPE",function(e,t,r){rs===void 0&&(rs=oc()),rs(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&LM(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(DM(e," argument"))i="The ".concat(e," ").concat(n," ").concat(cw(t,"type"));else{var o=UM(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(cw(t,"type"))}return i+=". Received type ".concat(ui(r)),i},TypeError);ba("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";qd===void 0&&(qd=en());var n=qd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);ba("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(ui(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);ba("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];rs===void 0&&(rs=oc()),rs(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);hw.exports.codes=lw});var ww=P((zU,Sw)=>{"use strict";m();function dw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function pw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dw(Object(r),!0).forEach(function(n){FM(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function FM(e,t,r){return t=vw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qM(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,vw(n.key),n)}}function HM(e,t,r){return t&&gw(e.prototype,t),r&&gw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function vw(e){var t=jM(e,"string");return ur(t)==="symbol"?t:String(t)}function jM(e,t){if(ur(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ur(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function KM(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ea(e,t)}function VM(e){var t=_w();return function(){var n=xa(e),i;if(t){var o=xa(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return bw(this,i)}}function bw(e,t){if(t&&(ur(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kd(e)}function Kd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vd(e){var t=typeof Map=="function"?new Map:void 0;return Vd=function(n){if(n===null||!GM(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return sc(n,arguments,xa(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ea(i,n)},Vd(e)}function sc(e,t,r){return _w()?sc=Reflect.construct.bind():sc=function(i,o,s){var a=[null];a.push.apply(a,o);var c=Function.bind.apply(i,a),h=new c;return s&&Ea(h,s.prototype),h},sc.apply(null,arguments)}function _w(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function GM(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ea(e,t){return Ea=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ea(e,t)}function xa(e){return xa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},xa(e)}function ur(e){"@babel/helpers - typeof";return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(e)}var zM=en(),Gd=zM.inspect,WM=jd(),YM=WM.codes.ERR_INVALID_ARG_TYPE;function yw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function $M(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Ur="",_a="",Sa="",Vt="",Ji={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},ZM=10;function mw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function wa(e){return Gd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function XM(e,t,r){var n="",i="",o=0,s="",a=!1,c=wa(e),h=c.split(`
|
|
13
|
+
`+new Error().stack};Uo.Error.prototype=Object.create(Error.prototype);Uo.Error.prototype.name="bsv.Error";var tN=h_();eN(Uo.Error,tN);sd.exports=Uo.Error;sd.exports.extend=function(e){return d_(Uo.Error,e)}});var ke=P((pD,g_)=>{"use strict";m();var ta=Jn(),rN=Ve();g_.exports={checkState:function(e,t){if(!e)throw new ta.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new ta.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,r){if(r=r||"(unknown name)",rN.isString(t)){if(t==="Buffer"){var n=Tt();if(!n.Buffer.isBuffer(e))throw new ta.InvalidArgumentType(e,t,r)}else if(typeof e!==t)throw new ta.InvalidArgumentType(e,t,r)}else if(!(e instanceof t))throw new ta.InvalidArgumentType(e,t.name,r)}}});var Er=P((yD,b_)=>{"use strict";m();var Be=A0(),m_=ke(),v_=Ve(),_f=function(e){for(var t=d.Buffer.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};Be.Zero=new Be(0);Be.One=new Be(1);Be.Minus1=new Be(-1);Be.fromNumber=function(e){return m_.checkArgument(v_.isNumber(e)),new Be(e)};Be.fromString=function(e,t){return m_.checkArgument(v_.isString(e)),new Be(e,t)};Be.fromBuffer=function(e,t){typeof t<"u"&&t.endian==="little"&&(e=_f(e));var r=e.toString("hex"),n=new Be(r,16);return n};Be.fromSM=function(e,t){var r;if(e.length===0)return Be.fromBuffer(d.Buffer.from([0]));var n="big";return t&&(n=t.endian),n==="little"&&(e=_f(e)),e[0]&128?(e[0]=e[0]&127,r=Be.fromBuffer(e),r.neg().copy(r)):r=Be.fromBuffer(e),r};Be.prototype.toNumber=function(){return parseInt(this.toString(10),10)};Be.prototype.toBuffer=function(e){var t,r;if(e&&e.size){r=this.toString(16,2);var n=r.length/2;t=d.Buffer.from(r,"hex"),n===e.size||(n>e.size?t=Be.trim(t,n):n<e.size&&(t=Be.pad(t,n,e.size)))}else r=this.toString(16,2),t=d.Buffer.from(r,"hex");return typeof e<"u"&&e.endian==="little"&&(t=_f(t)),t};Be.prototype.toSMBigEndian=function(){var e;return this.cmp(Be.Zero)===-1?(e=this.neg().toBuffer(),e[0]&128?e=d.Buffer.concat([d.Buffer.from([128]),e]):e[0]=e[0]|128):(e=this.toBuffer(),e[0]&128&&(e=d.Buffer.concat([d.Buffer.from([0]),e]))),e.length===1&&e[0]===0&&(e=d.Buffer.from([])),e};Be.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return t==="little"&&(r=_f(r)),r};function y_(e,t){var r=new Error(e);return r.scriptErr=t,r}Be.fromScriptNumBuffer=function(e,t,r){var n=r||4;if(e.length>n)throw y_("script number overflow","SCRIPT_ERR_SCRIPTNUM_OVERFLOW");if(t&&e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))throw y_("non-minimally encoded script number","SCRIPT_ERR_SCRIPTNUM_MINENCODE");return Be.fromSM(e,{endian:"little"})};Be.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})};Be.trim=function(e,t){return e.slice(t-e.length,e.length)};Be.pad=function(e,t,r){for(var n=d.Buffer.alloc(r),i=0;i<e.length;i++)n[n.length-1-i]=e[e.length-1-i];for(i=0;i<r-t;i++)n[i]=0;return n};Be.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")};Be.fromHex=function(e,...t){return Be.fromBuffer(d.Buffer.from(e,"hex"),...t)};b_.exports=Be});function ad(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Qn(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function on(e,t,r=""){let n=ad(e),i=e?.length,o=t!==void 0;if(!n||o&&i!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=n?`length=${i}`:`type=${typeof e}`,h=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(h):new TypeError(h)}return e}function Sf(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Qn(e.outputLen),Qn(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Fo(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function wf(e,t){on(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Zt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ef(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Cr(e,t){return e<<32-t|e>>>t}function In(e,t){return e<<t|e>>>32-t>>>0}function xf(e){if(on(e),S_)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=nN[e[r]];return t}function __(e){if(e>=xn._0&&e<=xn._9)return e-xn._0;if(e>=xn.A&&e<=xn.F)return e-(xn.A-10);if(e>=xn.a&&e<=xn.f)return e-(xn.a-10)}function ud(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(S_)try{return Uint8Array.fromHex(e)}catch(i){throw i instanceof SyntaxError?new RangeError(i.message):i}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=__(e.charCodeAt(o)),a=__(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function An(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function w_(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];on(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}function Lr(e,t={}){let r=(i,o)=>e(o).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}function ra(e=32){Qn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var S_,nN,xn,Ui,On=er(()=>{m();S_=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",nN=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));xn={_0:48,_9:57,A:65,F:70,a:97,f:102};Ui=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})});function qo(e,t,r){return e&t^~e&r}function If(e,t,r){return e&t^e&r^t&r}var Rn,Tn,Pn,Ht,jt,fd=er(()=>{m();On();Rn=class{constructor(t,r,n,i){C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"padOffset");C(this,"isLE");C(this,"buffer");C(this,"view");C(this,"finished",!1);C(this,"length",0);C(this,"pos",0);C(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ef(this.buffer)}update(t){Fo(this),on(t);let{view:r,buffer:n,blockLen:i}=this,o=t.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Ef(t);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fo(this),wf(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,Zt(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let y=s;y<i;y++)r[y]=0;n.setBigUint64(i-8,BigInt(this.length*8),o),this.process(n,0);let a=Ef(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let h=c/4,g=this.get();if(h>g.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,g[y],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=i,t.pos=a,i%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pn=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Ht=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),jt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function iN(e,t=!1){return t?{h:Number(e&Af),l:Number(e>>E_&Af)}:{h:Number(e>>E_&Af)|0,l:Number(e&Af)|0}}function x_(e,t=!1){let r=e.length,n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=iN(e[o],t);[n[o],i[o]]=[s,a]}return[n,i]}function sn(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Af,E_,cd,ld,Fi,qi,na,ia,I_,A_,O_,R_,T_,P_,B_=er(()=>{m();Af=BigInt(4294967295),E_=BigInt(32);cd=(e,t,r)=>e>>>r,ld=(e,t,r)=>e<<32-r|t>>>r,Fi=(e,t,r)=>e>>>r|t<<32-r,qi=(e,t,r)=>e<<32-r|t>>>r,na=(e,t,r)=>e<<64-r|t>>>r-32,ia=(e,t,r)=>e>>>r-32|t<<64-r;I_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),A_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,O_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),R_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,T_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),P_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0});var M_={};sl(M_,{_SHA224:()=>Tf,_SHA256:()=>Rf,_SHA384:()=>Bf,_SHA512:()=>Pf,_SHA512_224:()=>Nf,_SHA512_256:()=>Mf,sha224:()=>fN,sha256:()=>ni,sha384:()=>lN,sha512:()=>cN,sha512_224:()=>dN,sha512_256:()=>hN});var sN,ei,Of,Rf,Tf,N_,aN,uN,ti,ri,Ho,Pf,Bf,Xt,Jt,Nf,Mf,ni,fN,cN,lN,hN,dN,hd=er(()=>{m();fd();B_();On();sN=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ei=new Uint32Array(64),Of=class extends Rn{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[t,r,n,i,o,s,a,c]}set(t,r,n,i,o,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let y=0;y<16;y++,r+=4)ei[y]=t.getUint32(r,!1);for(let y=16;y<64;y++){let w=ei[y-15],I=ei[y-2],T=Cr(w,7)^Cr(w,18)^w>>>3,M=Cr(I,17)^Cr(I,19)^I>>>10;ei[y]=M+ei[y-7]+T+ei[y-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:h,H:g}=this;for(let y=0;y<64;y++){let w=Cr(a,6)^Cr(a,11)^Cr(a,25),I=g+w+qo(a,c,h)+sN[y]+ei[y]|0,M=(Cr(n,2)^Cr(n,13)^Cr(n,22))+If(n,i,o)|0;g=h,h=c,c=a,a=s+I|0,s=o,o=i,i=n,n=I+M|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,g=g+this.H|0,this.set(n,i,o,s,a,c,h,g)}roundClean(){Zt(ei)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Zt(this.buffer)}},Rf=class extends Of{constructor(){super(32);C(this,"A",Tn[0]|0);C(this,"B",Tn[1]|0);C(this,"C",Tn[2]|0);C(this,"D",Tn[3]|0);C(this,"E",Tn[4]|0);C(this,"F",Tn[5]|0);C(this,"G",Tn[6]|0);C(this,"H",Tn[7]|0)}},Tf=class extends Of{constructor(){super(28);C(this,"A",Pn[0]|0);C(this,"B",Pn[1]|0);C(this,"C",Pn[2]|0);C(this,"D",Pn[3]|0);C(this,"E",Pn[4]|0);C(this,"F",Pn[5]|0);C(this,"G",Pn[6]|0);C(this,"H",Pn[7]|0)}},N_=x_(["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(e=>BigInt(e))),aN=N_[0],uN=N_[1],ti=new Uint32Array(80),ri=new Uint32Array(80),Ho=class extends Rn{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:h,El:g,Fh:y,Fl:w,Gh:I,Gl:T,Hh:M,Hl:L}=this;return[t,r,n,i,o,s,a,c,h,g,y,w,I,T,M,L]}set(t,r,n,i,o,s,a,c,h,g,y,w,I,T,M,L){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=g|0,this.Fh=y|0,this.Fl=w|0,this.Gh=I|0,this.Gl=T|0,this.Hh=M|0,this.Hl=L|0}process(t,r){for(let q=0;q<16;q++,r+=4)ti[q]=t.getUint32(r),ri[q]=t.getUint32(r+=4);for(let q=16;q<80;q++){let W=ti[q-15]|0,J=ri[q-15]|0,Y=Fi(W,J,1)^Fi(W,J,8)^cd(W,J,7),be=qi(W,J,1)^qi(W,J,8)^ld(W,J,7),se=ti[q-2]|0,de=ri[q-2]|0,A=Fi(se,de,19)^na(se,de,61)^cd(se,de,6),u=qi(se,de,19)^ia(se,de,61)^ld(se,de,6),l=O_(be,u,ri[q-7],ri[q-16]),p=R_(l,Y,A,ti[q-7],ti[q-16]);ti[q]=p|0,ri[q]=l|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:h,Dl:g,Eh:y,El:w,Fh:I,Fl:T,Gh:M,Gl:L,Hh:j,Hl:G}=this;for(let q=0;q<80;q++){let W=Fi(y,w,14)^Fi(y,w,18)^na(y,w,41),J=qi(y,w,14)^qi(y,w,18)^ia(y,w,41),Y=y&I^~y&M,be=w&T^~w&L,se=T_(G,J,be,uN[q],ri[q]),de=P_(se,j,W,Y,aN[q],ti[q]),A=se|0,u=Fi(n,i,28)^na(n,i,34)^na(n,i,39),l=qi(n,i,28)^ia(n,i,34)^ia(n,i,39),p=n&o^n&a^o&a,v=i&s^i&c^s&c;j=M|0,G=L|0,M=I|0,L=T|0,I=y|0,T=w|0,{h:y,l:w}=sn(h|0,g|0,de|0,A|0),h=a|0,g=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let b=I_(A,l,v);n=A_(b,de,u,p),i=b|0}({h:n,l:i}=sn(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=sn(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=sn(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:g}=sn(this.Dh|0,this.Dl|0,h|0,g|0),{h:y,l:w}=sn(this.Eh|0,this.El|0,y|0,w|0),{h:I,l:T}=sn(this.Fh|0,this.Fl|0,I|0,T|0),{h:M,l:L}=sn(this.Gh|0,this.Gl|0,M|0,L|0),{h:j,l:G}=sn(this.Hh|0,this.Hl|0,j|0,G|0),this.set(n,i,o,s,a,c,h,g,y,w,I,T,M,L,j,G)}roundClean(){Zt(ti,ri)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pf=class extends Ho{constructor(){super(64);C(this,"Ah",jt[0]|0);C(this,"Al",jt[1]|0);C(this,"Bh",jt[2]|0);C(this,"Bl",jt[3]|0);C(this,"Ch",jt[4]|0);C(this,"Cl",jt[5]|0);C(this,"Dh",jt[6]|0);C(this,"Dl",jt[7]|0);C(this,"Eh",jt[8]|0);C(this,"El",jt[9]|0);C(this,"Fh",jt[10]|0);C(this,"Fl",jt[11]|0);C(this,"Gh",jt[12]|0);C(this,"Gl",jt[13]|0);C(this,"Hh",jt[14]|0);C(this,"Hl",jt[15]|0)}},Bf=class extends Ho{constructor(){super(48);C(this,"Ah",Ht[0]|0);C(this,"Al",Ht[1]|0);C(this,"Bh",Ht[2]|0);C(this,"Bl",Ht[3]|0);C(this,"Ch",Ht[4]|0);C(this,"Cl",Ht[5]|0);C(this,"Dh",Ht[6]|0);C(this,"Dl",Ht[7]|0);C(this,"Eh",Ht[8]|0);C(this,"El",Ht[9]|0);C(this,"Fh",Ht[10]|0);C(this,"Fl",Ht[11]|0);C(this,"Gh",Ht[12]|0);C(this,"Gl",Ht[13]|0);C(this,"Hh",Ht[14]|0);C(this,"Hl",Ht[15]|0)}},Xt=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Jt=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Nf=class extends Ho{constructor(){super(28);C(this,"Ah",Xt[0]|0);C(this,"Al",Xt[1]|0);C(this,"Bh",Xt[2]|0);C(this,"Bl",Xt[3]|0);C(this,"Ch",Xt[4]|0);C(this,"Cl",Xt[5]|0);C(this,"Dh",Xt[6]|0);C(this,"Dl",Xt[7]|0);C(this,"Eh",Xt[8]|0);C(this,"El",Xt[9]|0);C(this,"Fh",Xt[10]|0);C(this,"Fl",Xt[11]|0);C(this,"Gh",Xt[12]|0);C(this,"Gl",Xt[13]|0);C(this,"Hh",Xt[14]|0);C(this,"Hl",Xt[15]|0)}},Mf=class extends Ho{constructor(){super(32);C(this,"Ah",Jt[0]|0);C(this,"Al",Jt[1]|0);C(this,"Bh",Jt[2]|0);C(this,"Bl",Jt[3]|0);C(this,"Ch",Jt[4]|0);C(this,"Cl",Jt[5]|0);C(this,"Dh",Jt[6]|0);C(this,"Dl",Jt[7]|0);C(this,"Eh",Jt[8]|0);C(this,"El",Jt[9]|0);C(this,"Fh",Jt[10]|0);C(this,"Fl",Jt[11]|0);C(this,"Gh",Jt[12]|0);C(this,"Gl",Jt[13]|0);C(this,"Hh",Jt[14]|0);C(this,"Hl",Jt[15]|0)}},ni=Lr(()=>new Rf,Ui(1)),fN=Lr(()=>new Tf,Ui(4)),cN=Lr(()=>new Pf,Ui(3)),lN=Lr(()=>new Bf,Ui(2)),hN=Lr(()=>new Mf,Ui(6)),dN=Lr(()=>new Nf,Ui(5))});function ji(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Lf(e){if(typeof e=="bigint"){if(!kf(e))throw new RangeError("positive bigint expected, got "+e)}else pd(e);return e}function xr(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function oa(e){let t=Lf(e).toString(16);return t.length&1?"0"+t:t}function k_(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Cf:BigInt("0x"+e)}function tr(e){return k_(xf(e))}function Ko(e){return k_(xf(Uf(on(e)).reverse()))}function Df(e,t){if(Qn(t),t===0)throw new RangeError("zero length");e=Lf(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return ud(r.padStart(t*2,"0"))}function gd(e,t){return Df(e,t).reverse()}function Uf(e){return Uint8Array.from(Le(e))}function Vo(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}function pN(e,t,r){return kf(e)&&kf(t)&&kf(r)&&t<=e&&e<r}function yd(e,t,r,n){if(!pN(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ki(e){if(e<Cf)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Cf;e>>=dd,t+=1);return t}function C_(e,t,r){if(Qn(e,"hashLen"),Qn(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),h=n(e),g=0,y=()=>{c.fill(1),h.fill(0),g=0},w=(...L)=>r(h,Me(c,...L)),I=(L=i)=>{h=w(o,L),c=w(),L.length!==0&&(h=w(s,L),c=w())},T=()=>{if(g++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,j=[];for(;L<t;){c=w();let G=c.slice();j.push(G),L+=c.length}return Me(...j)};return(L,j)=>{y(),I(L);let G;for(;(G=j(T()))===void 0;)I();return y(),G}}function Ir(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw new TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let h=typeof c;if(h!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${h}`)}let i=(o,s)=>Object.entries(o).forEach(([a,c])=>n(a,c,s));i(t,!1),i(r,!0)}var Le,pd,Bn,Me,jo,Hi,ar,Cf,dd,kf,Go,Vi=er(()=>{m();On();Le=(e,t,r)=>on(e,t,r),pd=Qn,Bn=xf,Me=(...e)=>w_(...e),jo=e=>ud(e),Hi=ad,ar=e=>ra(e),Cf=BigInt(0),dd=BigInt(1);kf=e=>typeof e=="bigint"&&Cf<=e;Go=e=>(dd<<BigInt(e))-dd});function hr(e,t){if(t<=Kt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function dr(e,t,r){if(t<Kt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >Kt;)n*=n,n%=r;return n}function L_(e,t){if(e===Kt)throw new Error("invert: expected non-zero number");if(t<=Kt)throw new Error("invert: expected positive modulus, got "+t);let r=hr(e,t),n=t,i=Kt,o=xt,s=xt,a=Kt;for(;r!==Kt;){let h=n/r,g=n-r*h,y=i-s*h,w=o-a*h;n=r,r=g,i=s,o=a,s=y,a=w}if(n!==xt)throw new Error("invert: does not exist");return hr(i,t)}function vd(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function K_(e,t){let r=e,n=(r.ORDER+xt)/F_,i=r.pow(t,n);return vd(r,i,t),i}function mN(e,t){let r=e,n=(r.ORDER-q_)/H_,i=r.mul(t,Gi),o=r.pow(i,n),s=r.mul(t,o),a=r.mul(r.mul(s,Gi),o),c=r.mul(s,r.sub(a,r.ONE));return vd(r,c,t),c}function vN(e){let t=zo(e),r=V_(e),n=r(t,t.neg(t.ONE)),i=r(t,n),o=r(t,t.neg(n)),s=(e+gN)/j_;return((a,c)=>{let h=a,g=h.pow(c,s),y=h.mul(g,n),w=h.mul(g,i),I=h.mul(g,o),T=h.eql(h.sqr(y),c),M=h.eql(h.sqr(w),c);g=h.cmov(g,y,T),y=h.cmov(I,w,M);let L=h.eql(h.sqr(y),c),j=h.cmov(g,y,L);return vd(h,j,c),j})}function V_(e){if(e<U_)throw new Error("sqrt is not defined for small field");let t=e-xt,r=0;for(;t%Gi===Kt;)t/=Gi,r++;let n=Gi,i=zo(e);for(;md(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return K_;let o=i.pow(n,t),s=(t+xt)/Gi;return function(c,h){let g=c;if(g.is0(h))return h;if(md(g,h)!==1)throw new Error("Cannot find square root");let y=r,w=g.mul(g.ONE,o),I=g.pow(h,t),T=g.pow(h,s);for(;!g.eql(I,g.ONE);){if(g.is0(I))return g.ZERO;let M=1,L=g.sqr(I);for(;!g.eql(L,g.ONE);)if(M++,L=g.sqr(L),M===y)throw new Error("Cannot find square root");let j=xt<<BigInt(y-M-1),G=g.pow(w,j);y=M,w=g.sqr(G),I=g.mul(I,w),T=g.mul(T,G)}return T}}function bN(e){return e%F_===U_?K_:e%H_===q_?mN:e%j_===yN?vN(e):V_(e)}function zi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=_N.reduce((n,i)=>(n[i]="function",n),t);if(Ir(e,r),xr(e.BYTES,"BYTES"),xr(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=xt)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function SN(e,t,r){let n=e;if(r<Kt)throw new Error("invalid exponent, negatives unsupported");if(r===Kt)return n.ONE;if(r===xt)return t;let i=n.ONE,o=t;for(;r>Kt;)r&xt&&(i=n.mul(i,o)),o=n.sqr(o),r>>=xt;return i}function Wi(e,t,r=!1){let n=e,i=new Array(t.length).fill(r?n.ZERO:void 0),o=t.reduce((a,c,h)=>n.is0(c)?a:(i[h]=a,n.mul(a,c)),n.ONE),s=n.inv(o);return t.reduceRight((a,c,h)=>n.is0(c)?a:(i[h]=n.mul(a,i[h]),n.mul(a,c)),s),i}function md(e,t){let r=e,n=(r.ORDER-xt)/Gi,i=r.pow(t,n),o=r.eql(i,r.ONE),s=r.eql(i,r.ZERO),a=r.eql(i,r.neg(r.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function bd(e,t){return md(e,t)!==-1}function wN(e,t){if(t!==void 0&&pd(t),e<=Kt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Ki(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,i=Math.ceil(n/8);return{nBitLength:n,nByteLength:i}}function zo(e,t={}){return new Ff(e,t)}function G_(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=xt)throw new Error("field order must be greater than 1");let t=Ki(e-xt);return Math.ceil(t/8)}function sa(e){let t=G_(e);return t+Math.ceil(t/2)}function Wo(e,t,r=!1){Le(e);let n=e.length,i=G_(t),o=Math.max(sa(t),16);if(n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=r?Ko(e):tr(e),a=hr(s,t-xt)+xt;return r?gd(a,i):Df(a,i)}var Kt,xt,Gi,U_,F_,q_,gN,H_,yN,j_,_N,D_,Ff,Yo=er(()=>{m();Vi();Kt=BigInt(0),xt=BigInt(1),Gi=BigInt(2),U_=BigInt(3),F_=BigInt(4),q_=BigInt(5),gN=BigInt(7),H_=BigInt(8),yN=BigInt(9),j_=BigInt(16);_N=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];D_=new WeakMap,Ff=class{constructor(t,r={}){C(this,"ORDER");C(this,"BITS");C(this,"BYTES");C(this,"isLE");C(this,"ZERO",Kt);C(this,"ONE",xt);C(this,"_lengths");C(this,"_mod");if(t<=xt)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:i,nByteLength:o}=wN(t,n);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=i,this.BYTES=o,Object.freeze(this)}create(t){return hr(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return Kt<=t&&t<this.ORDER}is0(t){return t===Kt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&xt)===xt}neg(t){return hr(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return hr(t*t,this.ORDER)}add(t,r){return hr(t+r,this.ORDER)}sub(t,r){return hr(t-r,this.ORDER)}mul(t,r){return hr(t*r,this.ORDER)}pow(t,r){return SN(this,t,r)}div(t,r){return hr(t*L_(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return L_(t,this.ORDER)}sqrt(t){let r=D_.get(this);return r||D_.set(this,r=bN(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?gd(t,this.BYTES):Df(t,this.BYTES)}fromBytes(t,r=!1){Le(t);let{_lengths:n,BYTES:i,isLE:o,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>i)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let h=new Uint8Array(i);h.set(t,o?0:h.length-t.length),t=h}if(t.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);let c=o?Ko(t):tr(t);if(a&&(c=hr(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return Wi(this,t)}cmov(t,r,n){return ji(n,"condition"),n?r:t}};Object.freeze(Ff.prototype)});function $_(e){let t=e;if(typeof t!="function")throw new TypeError("Point must be a constructor");Ir({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),zi(t.Fp),zi(t.Fn)}function aa(e,t){let r=t.negate();return e?r:t}function Ed(e,t){let r=Wi(e.Fp,t.map(n=>n.Z));return t.map((n,i)=>e.fromAffine(n.toAffine(r[i])))}function Z_(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function _d(e,t){Z_(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),i=2**e,o=Go(e),s=BigInt(e);return{windows:r,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function z_(e,t,r){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=r,a=Number(e&i),c=e>>s;a>n&&(a-=o,c+=Yi);let h=t*n,g=h+Math.abs(a)-1,y=a===0,w=a<0,I=t%2!==0;return{nextN:c,offset:g,isZero:y,isNeg:w,isNegF:I,offsetF:h}}function EN(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function xN(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}function wd(e){return X_.get(e)||1}function W_(e){if(e!==$o)throw new Error("invalid wNAF")}function J_(e,t,r,n){let i=t,o=e.ZERO,s=e.ZERO;for(;r>$o||n>$o;)r&Yi&&(o=o.add(i)),n&Yi&&(s=s.add(i)),i=i.double(),r>>=Yi,n>>=Yi;return{p1:o,p2:s}}function Q_(e,t,r){let n=e.Fn;EN(t,e),xN(r,n);let i=t.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=Ki(BigInt(i)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let h=Go(c),g=new Array(Number(h)+1).fill(s),y=Math.floor((n.BITS-1)/c)*c,w=s;for(let I=y;I>=0;I-=c){g.fill(s);for(let M=0;M<o;M++){let L=r[M],j=Number(L>>BigInt(I)&h);g[j]=g[j].add(t[M])}let T=s;for(let M=g.length-1,L=s;M>0;M--)L=L.add(g[M]),T=T.add(L);if(w=w.add(T),I!==0)for(let M=0;M<c;M++)w=w.double()}return w}function Y_(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return zi(t),t}else return zo(e,{isLE:r})}function eS(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let h=t[c];if(!(typeof h=="bigint"&&h>$o))throw new Error(`CURVE.${c} must be positive bigint`)}let i=Y_(t.p,r.Fp,n),o=Y_(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!i.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:o}}function Hf(e,t){return function(n){let i=e(n);return{secretKey:i,publicKey:t(i)}}}var $o,Yi,Sd,X_,qf,jf=er(()=>{m();Vi();Yo();$o=BigInt(0),Yi=BigInt(1);Sd=new WeakMap,X_=new WeakMap;qf=class{constructor(t,r){C(this,"BASE");C(this,"ZERO");C(this,"Fn");C(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let i=t;for(;r>$o;)r&Yi&&(n=n.add(i)),i=i.double(),r>>=Yi;return n}precomputeWindow(t,r){let{windows:n,windowSize:i}=_d(r,this.bits),o=[],s=t,a=s;for(let c=0;c<n;c++){a=s,o.push(a);for(let h=1;h<i;h++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE,s=_d(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:h,isZero:g,isNeg:y,isNegF:w,offsetF:I}=z_(n,a,s);n=c,g?o=o.add(aa(w,r[I])):i=i.add(aa(y,r[h]))}return W_(n),{p:i,f:o}}wNAFUnsafe(t,r,n,i=this.ZERO){let o=_d(t,this.bits);for(let s=0;s<o.windows&&n!==$o;s++){let{nextN:a,offset:c,isZero:h,isNeg:g}=z_(n,s,o);if(n=a,!h){let y=r[c];i=i.add(g?y.negate():y)}}return W_(n),i}getPrecomputes(t,r,n){let i=Sd.get(r);return i||(i=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(i=n(i)),Sd.set(r,i))),i}cached(t,r,n){let i=wd(t);return this.wNAF(i,this.getPrecomputes(i,t,n),r)}unsafe(t,r,n,i){let o=wd(t);return o===1?this._unsafeLadder(t,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,t,n),r,i)}createCache(t,r){Z_(r,this.bits),X_.set(t,r),Sd.delete(t)}hasCache(t){return wd(t)!==1}}});function tS(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new Error("wrong u32 integer:"+e);return e}function IN(e){if(tS(e),e<=1)return 1;if(e>2147483648)throw new Error("nextPowerOfTwo overflow: result does not fit u32");return 1<<xd(e-1)+1>>>0}function xd(e){return tS(e),31-Math.clz32(e)}function rS(e,t,r,n,i){let o=e,s=r||((g,y)=>new Array(g).fill(y??o.ZERO)),a=g=>{if(Array.isArray(g))return!0;if(!ArrayBuffer.isView(g))return!1;let y=g;return typeof y.length=="number"&&typeof y.slice=="function"&&typeof y[Symbol.iterator]=="function"},c=(...g)=>{if(!g.length)return 0;for(let w of g)if(!a(w))throw new Error("poly: not polynomial: "+w);let y=g[0].length;for(let w=1;w<g.length;w++)if(g[w].length!==y)throw new Error(`poly: mismatched lengths ${y} vs ${g[w].length}`);if(i!==void 0&&y!==i)throw new Error(`poly: expected fixed length ${i}, got ${y}`);return y};function h(g,y,w=!1){let I=xd(y),T=w?t.brp(I):t.roots(I);for(let M=0;M<y;M++)if(o.eql(g,T[M]))return M;return-1}return{roots:t,create:s,length:i,extend:(g,y)=>{c(g);let w=s(y,o.ZERO);for(let I=0;I<Math.min(g.length,y);I++)w[I]=g[I];return w},degree:g=>{c(g);for(let y=g.length-1;y>=0;y--)if(!o.is0(g[y]))return y;return-1},add:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.add(g[T],y[T]);return I},sub:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.sub(g[T],y[T]);return I},dot:(g,y)=>{let w=c(g,y),I=s(w);for(let T=0;T<w;T++)I[T]=o.mul(g[T],y[T]);return I},mul:(g,y)=>{if(a(y)){let w=c(g,y);if(n){let I=n.direct(g,!1,!0),T=n.direct(y,!1,!0);for(let M=0;M<I.length;M++)I[M]=o.mul(I[M],T[M]);return n.inverse(I,!0,!1)}else{let I=s(w);for(let T=0;T<w;T++)for(let M=0;M<w;M++){let L=(T+M)%w;I[L]=o.add(I[L],o.mul(g[T],y[M]))}return I}}else{let w=s(c(g));for(let I=0;I<w.length;I++)w[I]=o.mul(g[I],y);return w}},convolve(g,y){let w=IN(g.length+y.length-1);return this.mul(this.extend(g,w),this.extend(y,w))},shift(g,y){let w=s(c(g));w[0]=g[0];for(let I=1,T=o.ONE;I<g.length;I++)T=o.mul(T,y),w[I]=o.mul(g[I],T);return w},clone:g=>{c(g);let y=s(g.length);for(let w=0;w<g.length;w++)y[w]=g[w];return y},eval:(g,y)=>{c(g,y);let w=o.ZERO;for(let I=0;I<g.length;I++)w=o.add(w,o.mul(g[I],y[I]));return w},monomial:{basis:(g,y)=>{let w=s(y),I=o.ONE;for(let T=0;T<y;T++)w[T]=I,I=o.mul(I,g);return w},eval:(g,y)=>{c(g);let w=o.ZERO;for(let I=g.length-1;I>=0;I--)w=o.add(o.mul(w,y),g[I]);return w}},lagrange:{basis:(g,y,w=!1,I)=>{let T=xd(y),M=I||(w?t.brp(T):t.roots(T)),L=s(y),j=h(g,y,w);if(j!==-1)return L[j]=o.ONE,L;let G=o.pow(g,BigInt(y)),q=o.mul(o.sub(G,o.ONE),o.inv(BigInt(y))),W=s(y);for(let Y=0;Y<y;Y++)W[Y]=o.sub(g,M[Y]);let J=o.invertBatch(W);for(let Y=0;Y<y;Y++)L[Y]=o.mul(q,o.mul(M[Y],J[Y]));return L},eval(g,y,w=!1){c(g);let I=h(y,g.length,w);if(I!==-1)return g[I];let T=this.basis(y,g.length,w),M=o.ZERO;for(let L=0;L<g.length;L++)o.is0(g[L])||(M=o.add(M,o.mul(g[L],T[L])));return M}},vanishing(g){c(g);let y=s(g.length+1,o.ZERO);y[0]=o.ONE;for(let w of g){let I=o.neg(w);for(let T=y.length-1;T>0;T--)y[T]=o.add(o.mul(y[T],I),y[T-1]);y[0]=o.mul(y[0],I)}return y}}}var nS=er(()=>{m()});function $i(e,t){if(xr(e),xr(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function ON(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function iS(e){if(!Hi(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Vo(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function RN(e,t,r,n){Le(e),xr(r),t=iS(t),t.length>255&&(t=n(Me(Vo("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=Me(t,$i(t.length,1)),c=new Uint8Array(o),h=$i(r,2),g=new Array(s),y=n(Me(c,e,h,$i(0,1),a));g[0]=n(Me(y,$i(1,1),a));for(let I=1;I<s;I++){let T=[ON(y,g[I-1]),$i(I+1,1),a];g[I]=n(Me(...T))}return Me(...g).slice(0,r)}function TN(e,t,r,n,i){if(Le(e),xr(r),t=iS(t),t.length>255){let o=Math.ceil(2*n/8);t=i.create({dkLen:o}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update($i(r,2)).update(t).update($i(t.length,1)).digest()}function Id(e,t,r){Ir(r,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;if(xr(s.outputLen,"valid hash"),Le(e),xr(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(o<1)throw new Error("hash_to_field: expected m >= 1");let h=n.toString(2).length,g=Math.ceil((h+i)/8),y=t*o*g,w;if(a==="xmd")w=RN(e,c,y,s);else if(a==="xof")w=TN(e,c,y,i,s);else if(a==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let I=new Array(t);for(let T=0;T<t;T++){let M=new Array(o);for(let L=0;L<o;L++){let j=g*(L+T*o),G=w.subarray(j,j+g);M[L]=hr(AN(G),n)}I[T]=M}return I}function oS(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[o,s,a,c]=r.map(y=>y.reduce((w,I)=>e.add(e.mul(w,n),I))),[h,g]=Wi(e,[s,c],!0);return n=e.mul(o,h),i=e.mul(i,e.mul(a,g)),{x:n,y:i}}}function sS(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let n=a=>Object.freeze({...a,DST:Hi(a.DST)?Uf(a.DST):a.DST,...a.encodeDST===void 0?{}:{encodeDST:Hi(a.encodeDST)?Uf(a.encodeDST):a.encodeDST}}),i=n(r);function o(a){return e.fromAffine(t(a))}function s(a){let c=a.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return Object.freeze({get defaults(){return n(i)},Point:e,hashToCurve(a,c){let h=Object.assign({},i,c),g=Id(a,2,h),y=o(g[0]),w=o(g[1]);return s(y.add(w))},encodeToCurve(a,c){let h=i.encodeDST?{DST:i.encodeDST}:{},g=Object.assign({},i,h,c),y=Id(a,1,g),w=o(y[0]);return s(w)},mapToCurve(a){if(i.m===1){if(typeof a!="bigint")throw new Error("expected bigint (m=1)");return s(o([a]))}if(!Array.isArray(a))throw new Error("expected array of bigints");for(let c of a)if(typeof c!="bigint")throw new Error("expected array of bigints");return s(o(a))},hashToScalar(a,c){let h=e.Fn.ORDER,g=Object.assign({},i,{p:h,m:1,DST:PN},c);return Id(a,1,g)[0][0]}})}var AN,PN,aS=er(()=>{m();Vi();Yo();AN=tr;PN="HashToScalar-"});function Ad(e){Ir(e,{name:"string",hash:"function"},{hashToScalar:"function",validatePoint:"function",parsePublicKey:"function",adjustScalar:"function",adjustPoint:"function",challenge:"function",adjustNonces:"function",adjustSecret:"function",adjustPublic:"function",adjustGroupCommitmentShare:"function",adjustDKG:"function"}),$_(e.Point);let{Point:t}=e,r=e.Fn===void 0?t.Fn:e.Fn,n=e.hash,i=e.hashToScalar===void 0?(R,k={DST:new Uint8Array})=>{let H=n(Me(k.DST,R));return r.create(r.isLE?Ko(H):tr(H))}:e.hashToScalar,o=An(e.H1!==void 0?e.H1:e.name+"rho"),s=An(e.H2!==void 0?e.H2:e.name+"chal"),a=An(e.H3!==void 0?e.H3:e.name+"nonce"),c=An(e.H4!==void 0?e.H4:e.name+"msg"),h=An(e.H5!==void 0?e.H5:e.name+"com"),g=An(e.HDKG!==void 0?e.HDKG:e.name+"dkg"),y=An(e.HID!==void 0?e.HID:e.name+"id"),w=R=>i(R,{DST:o}),I=R=>i(R,{DST:s}),T=R=>i(R,{DST:a}),M=R=>n(Me(c,R)),L=R=>n(Me(h,R)),j=R=>i(R,{DST:g}),G=R=>i(R,{DST:y}),q=(R=ar)=>{let k=Wo(R(sa(r.ORDER)),r.ORDER,r.isLE);return r.isLE?Ko(k):tr(k)},W=R=>R.toBytes(),J=R=>{let k=t.fromBytes(R);return e.validatePoint&&e.validatePoint(k),k},Y=(R,k)=>({identifier:R,hiding:W(t.BASE.multiply(r.fromBytes(k.hiding))),binding:W(t.BASE.multiply(r.fromBytes(k.binding)))}),be=e.adjustPoint===void 0?R=>R:e.adjustPoint,se=R=>{if(!r.isValid(R)||r.is0(R))throw new Error("Invalid identifier "+R);return R},de=R=>Bn(r.toBytes(se(R))),A=R=>{let k=se(r.fromBytes(jo(R)));if(de(k)!==R)throw new Error("expected canonical identifier hex");return k},u={encode:(R,k)=>{let H=Me(W(R),r.toBytes(k));return e.adjustTx&&(H=e.adjustTx.encode(H)),H},decode:R=>{e.adjustTx&&(R=e.adjustTx.decode(R));let k=J(R.subarray(0,-r.BYTES)),H=r.fromBytes(R.subarray(-r.BYTES));return{R:k,z:H}}},l=(R=ar)=>{let k=q(R);e.adjustScalar&&(k=e.adjustScalar(k));let H=t.BASE.multiply(k);return{scalar:k,point:H}},p="roots are unavailable in FROST polynomial mode",v={info:{G:r.ZERO,oddFactor:r.ZERO,powerOfTwo:0},roots(){throw new Error(p)},brp(){throw new Error(p)},inverse(){throw new Error(p)},omega(){throw new Error(p)},clear(){}},b=rS(r,v),E=(R,k)=>Q_(t,R,k),O=(R,k)=>{if(!k.length)throw new Error("empty coefficients");return b.monomial.eval(k,R)},_=(R,k)=>{let H="invalid parameters";if(!R.some(te=>r.eql(te,k)))throw new Error(H);let V=new Set(R);if(V.size!==R.length)throw new Error(H);if(!V.has(k))throw new Error(H);let ie=r.ONE,ee=r.ONE;for(let te of R)r.eql(te,k)||(ie=r.mul(ie,te),ee=r.mul(ee,r.sub(te,k)));return r.div(ie,ee)},f=(R,k)=>{let H=b.monomial.basis(R,k.length);return E(k,H)},S=(R,k,H,V=ar)=>{Kf(R);let ie=k===void 0?q(V):r.fromBytes(k);if(!H){H=[];for(let he=0;he<R.min-1;he++)H.push(q(V))}if(H.length!==R.min-1)throw new Error("wrong coefficients length");let ee=[ie,...H],te=ee.map(he=>t.BASE.multiply(he));return{coefficients:ee,commitment:te,secret:ie}},K={challenge:(R,k,H)=>j(Me(r.toBytes(R),W(k),W(H))),compute(R,k,H,V=ar){if(k.length<1)throw new Error("coefficients should have at least one element");let{point:ie,scalar:ee}=l(V),te=H[0],he=this.challenge(R,te,ie),oe=r.add(ee,r.mul(k[0],he));return u.encode(ie,oe)},validate(R,k,H){if(k.length<1)throw new Error("commitment should have at least one element");let{R:V,z:ie}=u.decode(H),ee=J(k[0]),te=this.challenge(R,ee,V);if(!V.equals(t.BASE.multiply(ie).subtract(ee.multiply(te))))throw new Error("invalid proof of knowledge")}},F={challenge:(R,k,H)=>e.challenge?e.challenge(R,k,H):I(Me(W(R),W(k),H)),sign(R,k,H=ar){let{point:V,scalar:ie}=l(H),ee=t.BASE.multiply(k),te=this.challenge(V,ee,R),he=r.add(ie,r.mul(te,k));return[V,he]},verify(R,k,H,V){e.adjustPoint&&(V=e.adjustPoint(V)),e.adjustPoint&&(k=e.adjustPoint(k));let ie=this.challenge(k,V,R),ee=t.BASE.multiply(H),te=V.multiply(ie),he=ee.subtract(te).subtract(k);return he.clearCofactor&&(he=he.clearCofactor()),t.ZERO.equals(he)}},$=(R,k,H)=>{if(!t.BASE.multiply(H).equals(f(R,k)))throw new Error("invalid secret share")},Z={fromNumber(R){if(!Number.isSafeInteger(R))throw new Error("expected safe interger");return de(BigInt(R))},derive(R){if(typeof R!="string")throw new Error("wrong identifier string: "+R);return de(G(An(R)))}},Q=(R,k=ar)=>T(Me(k(32),r.toBytes(R))),ae=(R,k,H)=>{let V=k.map(re=>[re.identifier,A(re.identifier),J(re.hiding),J(re.binding)]);V.sort((re,me)=>re[1]<me[1]?-1:re[1]>me[1]?1:0);let ie=[];for(let[re,me,ve,Se]of V)ie.push(r.toBytes(me),W(ve),W(Se));let ee=L(Me(...ie)),te=Me(W(R),M(H),ee),he={};for(let[re,me]of V)he[re]=w(Me(te,r.toBytes(me)));let oe=[],ue=[];for(let[re,me,ve,Se]of V){if(t.ZERO.equals(ve)||t.ZERO.equals(Se))throw new Error("infinity commitment");oe.push(ve,Se),ue.push(r.ONE,he[re])}let We=E(oe,ue);return{identifiers:V.map(re=>re[1]),groupCommitment:We,bindingFactors:he}},ge=(R,k,H,V)=>{let ie=be(J(R)),ee=A(V),{identifiers:te,groupCommitment:he,bindingFactors:oe}=ae(ie,k,H),ue=oe[V],We=_(te,ee),Oe=F.challenge(he,ie,H);return{lambda:We,challenge:Oe,bindingFactor:ue,groupCommitment:he}};Object.freeze(Z);let le={Identifier:Z,DKG:Object.freeze({round1:(R,k,H,V=ar)=>{Kf(k);let ie=A(R),{coefficients:ee,commitment:te}=S(k,H,void 0,V),he=K.compute(ie,ee,te,V),oe=te.map(W),ue={identifier:de(ie),commitment:oe,proofOfKnowledge:he},We={identifier:ie,coefficients:ee,commitment:te.map(W),signers:{min:k.min,max:k.max},step:1};return{public:ue,secret:We}},round2:(R,k)=>{if(k.length!==R.signers.max-1)throw new Error("wrong number of round1 packages");if(!R.coefficients||R.step===3)throw new Error("round3 package used in round2");let H={};for(let V of k){if(V.commitment.length!==R.signers.min)throw new Error("wrong number of commitments");let ie=A(V.identifier);if(ie===R.identifier)throw new Error("duplicate id="+de(ie));K.validate(ie,V.commitment,V.proofOfKnowledge);for(let te of V.commitment)J(te);if(H[V.identifier])throw new Error("Duplicate id="+ie);let ee=r.toBytes(O(ie,R.coefficients));H[V.identifier]={identifier:de(R.identifier),signingShare:ee}}return R.step=2,H},round3:(R,k,H)=>{if(k.length!==R.signers.max-1)throw new Error("wrong length of round1 packages");if(!R.coefficients||R.step!==2)throw new Error("round2 package used in round3");if(H.length!==k.length)throw new Error("wrong length of round2 packages");let V={};for(let me of k){if(!me.identifier||!me.commitment)throw new Error("wrong round1 share");V[me.identifier]={...me}}for(let me of H){if(!me.identifier||!me.signingShare)throw new Error("wrong round2 share");if(!V[me.identifier])throw new Error("round1 share for "+me.identifier+" is missing");V[me.identifier].signingShare=me.signingShare}if(Object.keys(V).length!==k.length)throw new Error("mismatch identifiers between rounds");let ie=r.ZERO;if(R.commitment.length!==R.signers.min)throw new Error("wrong commitments length");let ee=R.commitment.map(J),te=O(R.identifier,R.coefficients);$(R.identifier,ee,te);let he=ee.map(W),oe={[de(R.identifier)]:he};for(let me in V){let ve=V[me];if(!ve.signingShare||!ve.commitment)throw new Error("mismatch identifiers");let Se=A(me),pn=r.fromBytes(ve.signingShare),Ye=ve.commitment.map(J);$(R.identifier,Ye,pn),ie=r.add(ie,pn);let je=de(Se);if(oe[je])throw new Error("duplicated id="+je);oe[je]=ve.commitment}ie=r.add(ie,te);let ue=new Array(R.signers.min).fill(t.ZERO);for(let me in oe){let ve=oe[me];if(ve.length!==R.signers.min)throw new Error("wrong commitments length");for(let Se=0;Se<ve.length;Se++)ue[Se]=ue[Se].add(J(ve[Se]))}let We=ue.map(W),Oe={};for(let me in oe)Oe[me]=W(f(A(me),ue));let re={public:{signers:{min:R.signers.min,max:R.signers.max},commitments:We,verifyingShares:Object.fromEntries(Object.entries(Oe).map(([me,ve])=>[me,ve.slice()]))},secret:{identifier:de(R.identifier),signingShare:r.toBytes(ie)}};e.adjustDKG&&(re=e.adjustDKG(re));for(let me=0;me<R.coefficients.length;me++)R.coefficients[me]-=R.coefficients[me];return delete R.coefficients,R.step=3,re},clean(R){if(R.identifier-=R.identifier,R.coefficients)for(let k=0;k<R.coefficients.length;k++)R.coefficients[k]-=R.coefficients[k];R.step=3}}),trustedDealer(R,k,H,V=ar){if(Kf(R),k===void 0){k=[];for(let ue=1;ue<=R.max;ue++)k.push(Z.fromNumber(ue))}else if(!Array.isArray(k)||k.length!==R.max)throw new Error("identifiers should be array of "+R.max);let ie={};for(let ue of k){let We=A(ue);if(ue in ie)throw new Error("duplicated id="+ue);ie[ue]=We}let ee=S(R,H,void 0,V),te=ee.commitment.map(W),he={},oe={};for(let ue of k){let We=O(ie[ue],ee.coefficients);oe[ue]=W(t.BASE.multiply(We)),he[ue]={identifier:ue,signingShare:r.toBytes(We)}}return{public:{signers:{min:R.min,max:R.max},commitments:te,verifyingShares:oe},secretShares:he}},validateSecret(R,k){let H=A(R.identifier),V=k.commitments.map(J),ie=r.fromBytes(R.signingShare);$(H,V,ie)},commit(R,k=ar){let H=r.fromBytes(R.signingShare),V=Q(H,k),ie=Q(H,k),ee={hiding:r.toBytes(V),binding:r.toBytes(ie)};return{nonces:ee,commitments:Y(R.identifier,ee)}},signShare(R,k,H,V,ie){uS(k.signers,V.length);let ee=r.fromBytes(H.hiding),te=r.fromBytes(H.binding);if(r.is0(ee)||r.is0(te))throw new Error("signing nonces already used");let he={identifier:R.identifier,hiding:W(t.BASE.multiply(ee)),binding:W(t.BASE.multiply(te))},oe=V.find(Ze=>Ze.identifier===R.identifier);if(!oe)throw new Error("missing signer commitment");if(Bn(oe.hiding)!==Bn(he.hiding)||Bn(oe.binding)!==Bn(he.binding))throw new Error("incorrect signer commitment");e.adjustSecret&&(R=e.adjustSecret(R,k)),e.adjustPublic&&(k=e.adjustPublic(k));let ue=r.fromBytes(R.signingShare),{lambda:We,challenge:Oe,bindingFactor:re,groupCommitment:me}=ge(k.commitments[0],V,ie,R.identifier),ve=e.adjustNonces?e.adjustNonces(me,H):H,Se=e.adjustNonces?r.fromBytes(ve.hiding):ee,pn=e.adjustNonces?r.fromBytes(ve.binding):te,Ye=r.mul(r.mul(We,ue),Oe),je=r.mul(pn,re),$a=r.toBytes(r.add(r.add(Se,je),Ye));return H.hiding.fill(0),H.binding.fill(0),$a},verifyShare(R,k,H,V,ie){e.adjustPublic&&(R=e.adjustPublic(R));let ee=k.find(pn=>pn.identifier===V);if(!ee)throw new Error("cannot find identifier commitment");let te=J(R.verifyingShares[V]),he=J(ee.hiding),oe=J(ee.binding),{lambda:ue,challenge:We,bindingFactor:Oe,groupCommitment:re}=ge(R.commitments[0],k,H,V),me=he.add(oe.multiply(Oe));e.adjustGroupCommitmentShare&&(me=e.adjustGroupCommitmentShare(re,me));let ve=t.BASE.multiply(r.fromBytes(ie)),Se=me.add(te.multiply(r.mul(We,ue)));return ve.equals(Se)},aggregate(R,k,H,V){e.adjustPublic&&(R=e.adjustPublic(R));try{uS(R.signers,k.length)}catch{throw new Zo("aggregation failed",[])}let ie=k.map(oe=>oe.identifier);if(ie.length!==Object.keys(V).length)throw new Zo("aggregation failed",[]);for(let oe of ie)if(!(oe in V)||!(oe in R.verifyingShares))throw new Zo("aggregation failed",[]);let ee=J(R.commitments[0]),{groupCommitment:te}=ae(ee,k,H),he=r.ZERO;for(let oe of ie)he=r.add(he,r.fromBytes(V[oe]));if(!F.verify(H,te,he,ee)){let oe=[];for(let ue of ie)this.verifyShare(R,k,H,ue,V[ue])||oe.push(ue);throw new Zo("aggregation failed",oe)}return u.encode(te,he)},sign(R,k){let H=r.fromBytes(k);e.adjustScalar&&(H=e.adjustScalar(H));let[V,ie]=F.sign(R,H);return u.encode(V,ie)},verify(R,k,H){let V=e.parsePublicKey?e.parsePublicKey(H):J(H),{R:ie,z:ee}=u.decode(R);return F.verify(k,ie,ee,V)},combineSecret(R,k){if(Kf(k),!Array.isArray(R)||R.length<k.min)throw new Error("wrong secret shares array");let H=[],V={};for(let te of R){let he=A(te.identifier),oe=de(he);if(V[oe])throw new Error("duplicated id="+oe);V[oe]=!0,H.push([he,r.fromBytes(te.signingShare)])}let ie=H.map(([te])=>te),ee=r.ZERO;for(let[te,he]of H)ee=r.add(ee,r.mul(he,_(ie,te)));return r.toBytes(ee)},utils:Object.freeze({Fn:r,randomScalar:(R=ar)=>r.toBytes(l(R).scalar),generateSecretPolynomial:(R,k,H,V)=>{let ie=S(R,k,H,V);return{...ie,commitment:ie.commitment.map(W)}}})};return Object.freeze(le)}var Kf,uS,Zo,fS=er(()=>{m();On();Vi();jf();nS();Yo();Kf=e=>{if(!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))throw new Error("Wrong signers info: min="+e.min+" max="+e.max);if(e.min<2||e.max<2||e.min>e.max)throw new Error("Wrong signers info: min="+e.min+" max="+e.max)},uS=(e,t)=>{if(t<e.min||t>e.max)throw new Error("Wrong number of commitments="+t)},Zo=class extends Error{constructor(r,n){super(r);C(this,"cheaters");this.cheaters=n}}});var Vf,cS,lS=er(()=>{m();On();Vf=class{constructor(t,r){C(this,"oHash");C(this,"iHash");C(this,"blockLen");C(this,"outputLen");C(this,"canXOF",!1);C(this,"finished",!1);C(this,"destroyed",!1);if(Sf(t),on(r,void 0,"key"),this.iHash=t.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 n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Zt(i)}update(t){return Fo(this),this.iHash.update(t),this}digestInto(t){Fo(this),wf(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=o,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},cS=(()=>{let e=((t,r,n)=>new Vf(t,r).update(n).digest());return e.create=(t,r)=>new Vf(t,r),e})()});function BN(e,t,r){yd("scalar",e,Ar,r);let[[n,i],[o,s]]=t,a=hS(s*e,r),c=hS(-i*e,r),h=e-a*n-c*o,g=-a*i-c*s,y=h<Ar,w=g<Ar;y&&(h=-h),w&&(g=-g);let I=Go(Math.ceil(Ki(r)/2))+Lt;if(h<Ar||h>=I||g<Ar||g>=I)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:y,k1:h,k2neg:w,k2:g}}function Rd(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Od(e,t){Ir(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ji(r.lowS,"lowS"),ji(r.prehash,"prehash"),r.format!==void 0&&Rd(r.format),r}function dS(e,t={}){let r=eS("weierstrass",e,t),n=r.Fp,i=r.Fn,o=r.CURVE,{h:s,n:a}=o;Ir(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:h}=t;if(c&&(!n.is0(o.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=yS(n,i);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function w(l,p,v){if(h&&p.is0())return Uint8Array.of(0);let{x:b,y:E}=p.toAffine(),O=n.toBytes(b);if(ji(v,"isCompressed"),v){y();let _=!n.isOdd(E);return Me(pS(_),O)}else return Me(Uint8Array.of(4),O,n.toBytes(E))}function I(l){Le(l,void 0,"Point");let{publicKey:p,publicKeyUncompressed:v}=g,b=l.length,E=l[0],O=l.subarray(1);if(h&&b===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(b===p&&(E===2||E===3)){let _=n.fromBytes(O);if(!n.isValid(_))throw new Error("bad point: is not on curve, wrong x");let f=L(_),S;try{S=n.sqrt(f)}catch($){let Z=$ instanceof Error?": "+$.message:"";throw new Error("bad point: is not on curve, sqrt error"+Z)}y();let K=n.isOdd(S);return(E&1)===1!==K&&(S=n.neg(S)),{x:_,y:S}}else if(b===v&&E===4){let _=n.BYTES,f=n.fromBytes(O.subarray(0,_)),S=n.fromBytes(O.subarray(_,_*2));if(!j(f,S))throw new Error("bad point: is not on curve");return{x:f,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${p} or uncompressed=${v}`)}let T=t.toBytes===void 0?w:t.toBytes,M=t.fromBytes===void 0?I:t.fromBytes;function L(l){let p=n.sqr(l),v=n.mul(p,l);return n.add(n.add(v,n.mul(l,o.a)),o.b)}function j(l,p){let v=n.sqr(p),b=L(l);return n.eql(v,b)}if(!j(o.Gx,o.Gy))throw new Error("bad curve params: generator point");let G=n.mul(n.pow(o.a,Xo),Pd),q=n.mul(n.sqr(o.b),BigInt(27));if(n.is0(n.add(G,q)))throw new Error("bad curve params: a or b");function W(l,p,v=!1){if(!n.isValid(p)||v&&n.is0(p))throw new Error(`bad point coordinate ${l}`);return p}function J(l){if(!(l instanceof se))throw new Error("Weierstrass Point expected")}function Y(l){if(!c||!c.basises)throw new Error("no endo");return BN(l,c.basises,i.ORDER)}function be(l,p,v,b,E){return v=new se(n.mul(v.X,l),v.Y,v.Z),p=aa(b,p),v=aa(E,v),p.add(v)}let u=class u{constructor(p,v,b){C(this,"X");C(this,"Y");C(this,"Z");this.X=W("x",p),this.Y=W("y",v,!0),this.Z=W("z",b),Object.freeze(this)}static CURVE(){return o}static fromAffine(p){let{x:v,y:b}=p||{};if(!p||!n.isValid(v)||!n.isValid(b))throw new Error("invalid affine point");if(p instanceof u)throw new Error("projective point not allowed");return n.is0(v)&&n.is0(b)?u.ZERO:new u(v,b,n.ONE)}static fromBytes(p){let v=u.fromAffine(M(Le(p,void 0,"point")));return v.assertValidity(),v}static fromHex(p){return u.fromBytes(jo(p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,v=!0){return A.createCache(this,p),v||this.multiply(Xo),this}assertValidity(){let p=this;if(p.is0()){if(t.allowInfinityPoint&&n.is0(p.X)&&n.eql(p.Y,n.ONE)&&n.is0(p.Z))return;throw new Error("bad point: ZERO")}let{x:v,y:b}=p.toAffine();if(!n.isValid(v)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!j(v,b))throw new Error("bad point: equation left != right");if(!p.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:p}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(p)}equals(p){J(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:_,Z:f}=p,S=n.eql(n.mul(v,f),n.mul(O,E)),K=n.eql(n.mul(b,f),n.mul(_,E));return S&&K}negate(){return new u(this.X,n.neg(this.Y),this.Z)}double(){let{a:p,b:v}=o,b=n.mul(v,Xo),{X:E,Y:O,Z:_}=this,f=n.ZERO,S=n.ZERO,K=n.ZERO,F=n.mul(E,E),$=n.mul(O,O),Z=n.mul(_,_),Q=n.mul(E,O);return Q=n.add(Q,Q),K=n.mul(E,_),K=n.add(K,K),f=n.mul(p,K),S=n.mul(b,Z),S=n.add(f,S),f=n.sub($,S),S=n.add($,S),S=n.mul(f,S),f=n.mul(Q,f),K=n.mul(b,K),Z=n.mul(p,Z),Q=n.sub(F,Z),Q=n.mul(p,Q),Q=n.add(Q,K),K=n.add(F,F),F=n.add(K,F),F=n.add(F,Z),F=n.mul(F,Q),S=n.add(S,F),Z=n.mul(O,_),Z=n.add(Z,Z),F=n.mul(Z,Q),f=n.sub(f,F),K=n.mul(Z,$),K=n.add(K,K),K=n.add(K,K),new u(f,S,K)}add(p){J(p);let{X:v,Y:b,Z:E}=this,{X:O,Y:_,Z:f}=p,S=n.ZERO,K=n.ZERO,F=n.ZERO,$=o.a,Z=n.mul(o.b,Xo),Q=n.mul(v,O),ae=n.mul(b,_),ge=n.mul(E,f),le=n.add(v,b),R=n.add(O,_);le=n.mul(le,R),R=n.add(Q,ae),le=n.sub(le,R),R=n.add(v,E);let k=n.add(O,f);return R=n.mul(R,k),k=n.add(Q,ge),R=n.sub(R,k),k=n.add(b,E),S=n.add(_,f),k=n.mul(k,S),S=n.add(ae,ge),k=n.sub(k,S),F=n.mul($,R),S=n.mul(Z,ge),F=n.add(S,F),S=n.sub(ae,F),F=n.add(ae,F),K=n.mul(S,F),ae=n.add(Q,Q),ae=n.add(ae,Q),ge=n.mul($,ge),R=n.mul(Z,R),ae=n.add(ae,ge),ge=n.sub(Q,ge),ge=n.mul($,ge),R=n.add(R,ge),Q=n.mul(ae,R),K=n.add(K,Q),Q=n.mul(k,R),S=n.mul(le,S),S=n.sub(S,Q),Q=n.mul(le,ae),F=n.mul(k,F),F=n.add(F,Q),new u(S,K,F)}subtract(p){return J(p),this.add(p.negate())}is0(){return this.equals(u.ZERO)}multiply(p){let{endo:v}=t;if(!i.isValidNot0(p))throw new RangeError("invalid scalar: out of range");let b,E,O=_=>A.cached(this,_,f=>Ed(u,f));if(v){let{k1neg:_,k1:f,k2neg:S,k2:K}=Y(p),{p:F,f:$}=O(f),{p:Z,f:Q}=O(K);E=$.add(Q),b=be(v.beta,F,Z,_,S)}else{let{p:_,f}=O(p);b=_,E=f}return Ed(u,[b,E])[0]}multiplyUnsafe(p){let{endo:v}=t,b=this,E=p;if(!i.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Ar||b.is0())return u.ZERO;if(E===Lt)return b;if(A.hasCache(this))return this.multiply(E);if(v){let{k1neg:O,k1:_,k2neg:f,k2:S}=Y(E),{p1:K,p2:F}=J_(u,b,_,S);return be(v.beta,K,F,O,f)}else return A.unsafe(b,E)}toAffine(p){let v=this,b=p,{X:E,Y:O,Z:_}=v;if(n.eql(_,n.ONE))return{x:E,y:O};let f=v.is0();b==null&&(b=f?n.ONE:n.inv(_));let S=n.mul(E,b),K=n.mul(O,b),F=n.mul(_,b);if(f)return{x:n.ZERO,y:n.ZERO};if(!n.eql(F,n.ONE))throw new Error("invZ was invalid");return{x:S,y:K}}isTorsionFree(){let{isTorsionFree:p}=t;return s===Lt?!0:p?p(u,this):A.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:p}=t;return s===Lt?this:p?p(u,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Lt?this.is0():this.clearCofactor().is0()}toBytes(p=!0){return ji(p,"isCompressed"),this.assertValidity(),T(u,this,p)}toHex(p=!0){return Bn(this.toBytes(p))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};C(u,"BASE",new u(o.Gx,o.Gy,n.ONE)),C(u,"ZERO",new u(n.ZERO,n.ONE,n.ZERO)),C(u,"Fp",n),C(u,"Fn",i);let se=u,de=i.BITS,A=new qf(se,t.endo?Math.ceil(de/2):de);return de>=8&&se.BASE.precompute(8),Object.freeze(se.prototype),Object.freeze(se),se}function pS(e){return Uint8Array.of(e?2:3)}function NN(e,t){let r=zi(e),n=r.ORDER,i=Ar;for(let M=n-Lt;M%an===Ar;M/=an)i+=Lt;let o=i,s=an<<o-Lt-Lt,a=s*an,c=(n-Lt)/a,h=(c-Lt)/an,g=a-Lt,y=s,w=r.pow(t,c),I=r.pow(t,(c+Lt)/an),T=(M,L)=>{let j=w,G=r.pow(L,g),q=r.sqr(G);q=r.mul(q,L);let W=r.mul(M,q);W=r.pow(W,h),W=r.mul(W,G),G=r.mul(W,L),q=r.mul(W,M);let J=r.mul(q,G);W=r.pow(J,y);let Y=r.eql(W,r.ONE);G=r.mul(q,I),W=r.mul(J,j),q=r.cmov(G,q,Y),J=r.cmov(W,J,Y);for(let be=o;be>Lt;be--){let se=be-an;se=an<<se-Lt;let de=r.pow(J,se),A=r.eql(de,r.ONE);G=r.mul(q,j),j=r.mul(j,j),de=r.mul(J,j),q=r.cmov(G,q,A),J=r.cmov(de,J,A)}return{isValid:!r.is0(L)&&(Y||r.is0(M)),value:q}};if(r.ORDER%Pd===Xo){let M=(r.ORDER-Xo)/Pd,L=r.sqrt(r.neg(t));T=(j,G)=>{let q=r.sqr(G),W=r.mul(j,G);q=r.mul(q,W);let J=r.pow(q,M);J=r.mul(J,W);let Y=r.mul(J,L),be=r.mul(r.sqr(J),G),se=r.eql(be,j),de=r.cmov(Y,J,se);return{isValid:!r.is0(G)&&se,value:de}}}return T}function gS(e,t){let r=zi(e),{A:n,B:i,Z:o}=t;if(!r.isValidNot0(n)||!r.isValidNot0(i)||!r.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");if(r.eql(o,r.neg(r.ONE))||bd(r,o))throw new Error("mapToCurveSimpleSWU: invalid opts");let s=r.mul(i,r.inv(r.mul(o,n))),a=r.add(r.add(r.mul(r.sqr(s),s),r.mul(n,s)),i);if(!bd(r,a))throw new Error("mapToCurveSimpleSWU: invalid opts");let c=NN(r,o);if(!r.isOdd)throw new Error("Field does not have .isOdd()");return h=>{let g,y,w,I,T,M,L,j;g=r.sqr(h),g=r.mul(g,o),y=r.sqr(g),y=r.add(y,g),w=r.add(y,r.ONE),w=r.mul(w,i),I=r.cmov(o,r.neg(y),!r.eql(y,r.ZERO)),I=r.mul(I,n),y=r.sqr(w),M=r.sqr(I),T=r.mul(M,n),y=r.add(y,T),y=r.mul(y,w),M=r.mul(M,I),T=r.mul(M,i),y=r.add(y,T),L=r.mul(g,w);let{isValid:G,value:q}=c(y,M);j=r.mul(g,h),j=r.mul(j,q),L=r.cmov(L,w,G),j=r.cmov(j,q,G);let W=r.isOdd(h)===r.isOdd(j);j=r.cmov(r.neg(j),j,W);let J=Wi(r,[I],!0)[0];return L=r.mul(L,J),{x:L,y:j}}}function yS(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function MN(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?ar:t.randomBytes,i=Object.assign(yS(e.Fp,r),{seed:Math.max(sa(r.ORDER),16)});function o(I){try{let T=r.fromBytes(I);return r.isValidNot0(T)}catch{return!1}}function s(I,T){let{publicKey:M,publicKeyUncompressed:L}=i;try{let j=I.length;return T===!0&&j!==M||T===!1&&j!==L?!1:!!e.fromBytes(I)}catch{return!1}}function a(I){return I=I===void 0?n(i.seed):I,Wo(Le(I,i.seed,"seed"),r.ORDER)}function c(I,T=!0){return e.BASE.multiply(r.fromBytes(I)).toBytes(T)}function h(I){let{secretKey:T,publicKey:M,publicKeyUncompressed:L}=i,j=r._lengths;if(!Hi(I))return;let G=Le(I,void 0,"key").length,q=G===M||G===L,W=G===T||!!j?.includes(G);if(!(q&&W))return q}function g(I,T,M=!0){if(h(I)===!0)throw new Error("first arg must be private key");if(h(T)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(I);return e.fromBytes(T).multiply(L).toBytes(M)}let y={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},w=Hf(a,c);return Object.freeze(y),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:g,keygen:w,Point:e,utils:y,lengths:i})}function mS(e,t,r={}){let n=t;Sf(n),Ir(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes===void 0?ar:r.randomBytes,o=r.hmac===void 0?(b,E)=>cS(n,b,E):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:h}=a,{keygen:g,getPublicKey:y,getSharedSecret:w,utils:I,lengths:T}=MN(e,r),M={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},L=c*an+Lt<s.ORDER;function j(b){let E=c>>Lt;return b>E}function G(b,E){if(!a.isValidNot0(E))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return E}function q(){if(L)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function W(b,E){Rd(E);let O=T.signature,_=E==="compact"?O:E==="recovered"?O+1:void 0;return Le(b,_)}class J{constructor(E,O,_){C(this,"r");C(this,"s");C(this,"recovery");if(this.r=G("r",E),this.s=G("s",O),_!=null){if(q(),![0,1,2,3].includes(_))throw new Error("invalid recovery id");this.recovery=_}Object.freeze(this)}static fromBytes(E,O=M.format){W(E,O);let _;if(O==="der"){let{r:F,s:$}=Dr.toSig(Le(E));return new J(F,$)}O==="recovered"&&(_=E[0],O="compact",E=E.subarray(1));let f=T.signature/2,S=E.subarray(0,f),K=E.subarray(f,f*2);return new J(a.fromBytes(S),a.fromBytes(K),_)}static fromHex(E,O){return this.fromBytes(jo(E),O)}assertRecovery(){let{recovery:E}=this;if(E==null)throw new Error("invalid recovery id: must be present");return E}addRecoveryBit(E){return new J(this.r,this.s,E)}recoverPublicKey(E){let{r:O,s:_}=this,f=this.assertRecovery(),S=f===2||f===3?O+c:O;if(!s.isValid(S))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=s.toBytes(S),F=e.fromBytes(Me(pS((f&1)===0),K)),$=a.inv(S),Z=be(Le(E,void 0,"msgHash")),Q=a.create(-Z*$),ae=a.create(_*$),ge=e.BASE.multiplyUnsafe(Q).add(F.multiplyUnsafe(ae));if(ge.is0())throw new Error("invalid recovery: point at infinify");return ge.assertValidity(),ge}hasHighS(){return j(this.s)}toBytes(E=M.format){if(Rd(E),E==="der")return jo(Dr.hexFromSig(this));let{r:O,s:_}=this,f=a.toBytes(O),S=a.toBytes(_);return E==="recovered"?(q(),Me(Uint8Array.of(this.assertRecovery()),f,S)):Me(f,S)}toHex(E){return Bn(this.toBytes(E))}}Object.freeze(J.prototype),Object.freeze(J);let Y=r.bits2int===void 0?function(E){if(E.length>8192)throw new Error("input is too large");let O=tr(E),_=E.length*8-h;return _>0?O>>BigInt(_):O}:r.bits2int,be=r.bits2int_modN===void 0?function(E){return a.create(Y(E))}:r.bits2int_modN,se=Go(h);function de(b){return yd("num < 2^"+h,b,Ar,se),a.toBytes(b)}function A(b,E){return Le(b,void 0,"message"),E?Le(n(b),void 0,"prehashed message"):b}function u(b,E,O){let{lowS:_,prehash:f,extraEntropy:S}=Od(O,M);b=A(b,f);let K=be(b),F=a.fromBytes(E);if(!a.isValidNot0(F))throw new Error("invalid private key");let $=[de(F),de(K)];if(S!=null&&S!==!1){let ge=S===!0?i(T.secretKey):S;$.push(Le(ge,void 0,"extraEntropy"))}let Z=Me(...$),Q=K;function ae(ge){let le=Y(ge);if(!a.isValidNot0(le))return;let R=a.inv(le),k=e.BASE.multiply(le).toAffine(),H=a.create(k.x);if(H===Ar)return;let V=a.create(R*a.create(Q+H*F));if(V===Ar)return;let ie=(k.x===H?0:2)|Number(k.y&Lt),ee=V;return _&&j(V)&&(ee=a.neg(V),ie^=1),new J(H,ee,L?void 0:ie)}return{seed:Z,k2sig:ae}}function l(b,E,O={}){let{seed:_,k2sig:f}=u(b,E,O);return C_(n.outputLen,a.BYTES,o)(_,f).toBytes(O.format)}function p(b,E,O,_={}){let{lowS:f,prehash:S,format:K}=Od(_,M);if(O=Le(O,void 0,"publicKey"),E=A(E,S),!Hi(b)){let F=b instanceof J?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+F)}W(b,K);try{let F=J.fromBytes(b,K),$=e.fromBytes(O);if(f&&F.hasHighS())return!1;let{r:Z,s:Q}=F,ae=be(E),ge=a.inv(Q),le=a.create(ae*ge),R=a.create(Z*ge),k=e.BASE.multiplyUnsafe(le).add($.multiplyUnsafe(R));return k.is0()?!1:a.create(k.x)===Z}catch{return!1}}function v(b,E,O={}){let{prehash:_}=Od(O,M);return E=A(E,_),J.fromBytes(b,"recovered").recoverPublicKey(E).toBytes()}return Object.freeze({keygen:g,getPublicKey:y,getSharedSecret:w,utils:I,lengths:T,Point:e,sign:l,verify:p,recoverPublicKey:v,Signature:J,hash:n})}var hS,Td,Dr,Ar,Lt,an,Xo,Pd,vS=er(()=>{m();lS();On();Vi();jf();Yo();hS=(e,t)=>(e+(e>=0?t:-t)/an)/t;Td=class extends Error{constructor(t=""){super(t)}},Dr={Err:Td,_tlv:{encode:(e,t)=>{let{Err:r}=Dr;if(xr(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,i=oa(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let o=n>127?oa(i.length/2|128):"";return oa(e)+o+i+t},decode(e,t){let{Err:r}=Dr;t=Le(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let i=t[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&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 h=t.subarray(n,n+c);if(h.length!==c)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let g of h)s=s<<8|g;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Dr;if(Lf(e),e<Ar)throw new t("integer: negative integers are not allowed");let r=oa(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Dr;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return tr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Dr,i=Le(e,void 0,"signature"),{v:o,l:s}=n.decode(48,i);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:h,l:g}=n.decode(2,c);if(g.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(h)}},hexFromSig(e){let{_tlv:t,_int:r}=Dr,n=t.encode(2,r.encode(e.r)),i=t.encode(2,r.encode(e.s)),o=n+i;return t.encode(48,o)}};Object.freeze(Dr._tlv);Object.freeze(Dr._int);Object.freeze(Dr);Ar=BigInt(0),Lt=BigInt(1),an=BigInt(2),Xo=BigInt(3),Pd=BigInt(4)});var OS={};sl(OS,{__TEST:()=>UN,schnorr:()=>FN,schnorr_FROST:()=>zN,secp256k1:()=>LN,secp256k1_FROST:()=>jN,secp256k1_hasher:()=>Md});function CN(e){let t=Gf.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),h=e*e*e%t,g=h*h*e%t,y=dr(g,r,t)*g%t,w=dr(y,r,t)*g%t,I=dr(w,Bd,t)*h%t,T=dr(I,i,t)*I%t,M=dr(T,o,t)*T%t,L=dr(M,a,t)*M%t,j=dr(L,c,t)*L%t,G=dr(j,a,t)*M%t,q=dr(G,r,t)*g%t,W=dr(q,s,t)*T%t,J=dr(W,n,t)*h%t,Y=dr(J,Bd,t);if(!Nn.eql(Nn.sqr(Y),e))throw new Error("Cannot find square root");return Y}function ua(e,...t){let r=bS[e];if(r===void 0){let n=ni(Vo(e));r=Me(n,n),bS[e]=r}return ni(Me(r,...t))}function ES(e){let{Fn:t,BASE:r}=Ue,n=t.fromBytes(e),i=r.multiply(n);return{scalar:un(i.y)?n:t.neg(n),bytes:Zi(i)}}function zf(e){let t=Nn;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x \u2265 p");let r=t.create(e*e),n=t.create(r*e+BigInt(7)),i=t.sqrt(n);un(i)||(i=t.neg(i));let o=Ue.fromAffine({x:e,y:i});return o.assertValidity(),o}function Nd(...e){return Ue.Fn.create(Jo(ua("BIP0340/challenge",...e)))}function _S(e){return ES(e).bytes}function DN(e,t,r=ra(32)){let{Fn:n,BASE:i}=Ue,o=Le(e,void 0,"message"),{bytes:s,scalar:a}=ES(t),c=Le(r,32,"auxRand"),h=n.toBytes(a^Jo(ua("BIP0340/aux",c))),g=ua("BIP0340/nonce",h,s,o),y=n.create(Jo(g));if(y===0n)throw new Error("sign failed: k is zero");let w=i.multiply(y),I=un(w.y)?y:n.neg(y),T=Zi(w),M=Nd(T,s,o),L=new Uint8Array(64);if(L.set(T,0),L.set(n.toBytes(n.create(I+M*a)),32),!xS(L,o,s))throw new Error("sign: Invalid signature produced");return L}function xS(e,t,r){let{Fp:n,Fn:i,BASE:o}=Ue,s=Le(e,64,"signature"),a=Le(t,void 0,"message"),c=Le(r,32,"publicKey");try{let h=zf(Jo(c)),g=Jo(s.subarray(0,32));if(!n.isValidNot0(g))return!1;let y=Jo(s.subarray(32,64));if(!i.isValidNot0(y))return!1;let w=Nd(i.toBytes(g),Zi(h),a),I=o.multiplyUnsafe(y).add(h.multiplyUnsafe(i.neg(w))),{x:T,y:M}=I.toAffine();return!(I.is0()||!un(M)||T!==g)}catch{return!1}}function IS(e,t){if(t===void 0)return wS;let r=Zi(e),n=tr(ua("TapTweak",r,t));if(!Ue.Fn.isValid(n))throw new Error("invalid TapTweak hash");return n}function kd(e){let t=Ue.fromBytes(e.commitments[0]);return un(t.y)?e:{signers:{min:e.signers.min,max:e.signers.max},commitments:e.commitments.map(r=>Ue.fromBytes(r).negate().toBytes()),verifyingShares:Object.fromEntries(Object.entries(e.verifyingShares).map(([r,n])=>[r,Ue.fromBytes(n).negate().toBytes()]))}}function AS(e,t){let r=Ue.fromBytes(t.commitments[0]);if(un(r.y))return e;let n=Ue.Fn;return{...e,signingShare:n.toBytes(n.neg(n.fromBytes(e.signingShare)))}}function KN(e,t){if(un(e.y))return t;let r=Ue.Fn;return{binding:r.toBytes(r.neg(r.fromBytes(t.binding))),hiding:r.toBytes(r.neg(r.fromBytes(t.hiding)))}}function VN(e,t,r){let n=Ue.Fn,i=AS(e,t),o=kd(t),s=IS(Ue.fromBytes(o.commitments[0]),r),a=n.toBytes(n.add(n.fromBytes(i.signingShare),s));return{identifier:i.identifier,signingShare:a}}function GN(e,t){let r=kd(e),n=IS(Ue.fromBytes(r.commitments[0]),t),i=Ue.BASE.multiply(n),o=r.commitments.map((a,c)=>(c===0?Ue.fromBytes(a).add(i):Ue.fromBytes(a)).toBytes()),s={};for(let a in r.verifyingShares)s[a]=Ue.fromBytes(r.verifyingShares[a]).add(i).toBytes();return{signers:{min:r.signers.min,max:r.signers.max},commitments:o,verifyingShares:s}}var Gf,kN,wS,Bd,Nn,Ue,LN,bS,Zi,un,Jo,UN,FN,qN,SS,HN,Md,jN,zN,RS=er(()=>{m();hd();On();jf();fS();aS();Yo();vS();Vi();Gf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},kN={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},wS=BigInt(0),Bd=BigInt(2);Nn=zo(Gf.p,{sqrt:CN}),Ue=dS(Gf,{Fp:Nn,endo:kN}),LN=mS(Ue,ni),bS={};Zi=e=>e.toBytes(!0).slice(1),un=e=>e%Bd===wS;Jo=tr;UN=Object.freeze({lift_x:zf}),FN=(()=>{let r=n=>(n=n===void 0?ra(48):n,Wo(n,Gf.n));return Object.freeze({keygen:Hf(r,_S),getPublicKey:_S,sign:DN,verify:xS,Point:Ue,utils:Object.freeze({randomSecretKey:r,taggedHash:ua,lift_x:zf,pointToBytes:Zi}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),qN=oS(Nn,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),HN=()=>SS||(SS=gS(Nn,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:Nn.create(BigInt("-11"))})),Md=sS(Ue,e=>{let{x:t,y:r}=HN()(Nn.create(e[0]));return qN(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:Nn.ORDER,m:1,k:128,expand:"xmd",hash:ni}),jN=Ad({name:"FROST-secp256k1-SHA256-v1",Point:Ue,hashToScalar:Md.hashToScalar,hash:ni});zN=Ad({name:"FROST-secp256k1-SHA256-TR-v1",Point:Ue,hashToScalar:Md.hashToScalar,hash:ni,parsePublicKey(e){if(e.length===32)return zf(tr(e));if(e.length===33)return Ue.fromBytes(e);throw new Error(`expected x-only or compressed public key, got length=${e.length}`)},adjustScalar(e){let t=Ue.BASE.multiply(e);return un(t.y)?e:Ue.Fn.neg(e)},adjustPoint:e=>un(e.y)?e:e.negate(),challenge(e,t,r){return Nd(Zi(e),Zi(t),r)},adjustNonces:KN,adjustGroupCommitmentShare:(e,t)=>un(e.y)?t:t.negate(),adjustPublic:kd,adjustSecret:AS,adjustTx:{encode:e=>e.subarray(1),decode:e=>Me(Uint8Array.of(2),e)},adjustDKG:e=>{let t=new Uint8Array(0);return{public:GN(e.public,t),secret:VN(e.secret,e.public,t)}}})});var ii=P((wU,NS)=>{"use strict";m();var TS=Er(),{secp256k1:WN}=(RS(),al(OS)),ca=WN.Point,Wf=ca.Fn.ORDER;function YN(e){return BigInt("0x"+(e.toString(16)||"0"))}function Cd(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new TS(t,16)}function Yf(e){if(e==null)throw new Error("Invalid Point");if(typeof e=="bigint")return e;if(typeof e=="number")return BigInt(e);if(typeof e=="string")return BigInt(e.indexOf("0x")===0?e:"0x"+e);if(typeof e.toString=="function")return YN(e);throw new Error("Invalid Point")}function fa(e){var t=Object.create(Fe.prototype);return t._p=e,t}function PS(e,t){var r=Yf(t).toString(16).padStart(64,"0");return ca.fromHex((e?"03":"02")+r)}function BS(e,t){var r;try{r=PS((t&1n)===1n,e)}catch{throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function Fe(e,t,r){if(!(this instanceof Fe))return new Fe(e,t,r);var n,i;try{n=Yf(e),i=Yf(t)}catch{throw new Error("Invalid Point")}BS(n,i);try{this._p=ca.fromAffine({x:n,y:i})}catch{throw new Error("Invalid Point")}return this}Fe.fromX=function(t,r){try{var n=fa(PS(t,r))}catch{throw new Error("Invalid X")}return n.validate(),n};Fe.getG=function(){return fa(ca.BASE)};Fe.getN=function(){return Cd(Wf)};Fe.prototype.getX=function(){return Cd(this._p.toAffine().x)};Fe.prototype.getY=function(){return Cd(this._p.toAffine().y)};Object.defineProperty(Fe.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}});Object.defineProperty(Fe.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}});Fe.prototype.mul=function(t){var r=(Yf(t)%Wf+Wf)%Wf;return r===0n||this._p.is0()?fa(ca.ZERO):fa(this._p.multiply(r))};Fe.prototype.add=function(t){return fa(this._p.add(t._p))};Fe.prototype.mulAdd=function(t,r,n){return this.mul(t).add(r.mul(n))};Fe.prototype.eq=function(t){return this._p.equals(t._p)};Fe.prototype.isInfinity=function(){return this._p.is0()};Fe.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t=this._p.toAffine();return BS(t.x,t.y),this};Fe.pointToCompressed=function(t){var r=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32}),i,o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])};Fe.pointFromCompressed=function(e){if(e.length!==33)throw new Error("invalid buffer length");var t=e[0],r;if(t===3)r=!0;else if(t===2)r=!1;else throw new Error("invalid value of compressed prefix");var n=TS.fromBuffer(e.slice(1,33));return Fe.fromX(r,n)};Fe.prototype.toBuffer=function(){return Fe.pointToCompressed(this)};Fe.prototype.toHex=function(){return this.toBuffer().toString("hex")};Fe.fromBuffer=function(e){return Fe.pointFromCompressed(e)};Fe.fromHex=function(e){return Fe.fromBuffer(d.Buffer.from(e,"hex"))};NS.exports=Fe});var kS=P((xU,MS)=>{"use strict";m();var $f=Qs(),Mn=ke(),It=MS.exports;It.sha1=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha1").update(e).digest()};It.sha1.blocksize=512;It.sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha256").update(e).digest()};It.sha256.blocksize=512;It.sha256sha256=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.sha256(It.sha256(e))};It.ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("ripemd160").update(e).digest()};It.sha256ripemd160=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),It.ripemd160(It.sha256(e))};It.sha512=function(e){return Mn.checkArgument(d.Buffer.isBuffer(e)),$f.createHash("sha512").update(e).digest()};It.sha512.blocksize=1024;It.hmac=function(e,t,r){Mn.checkArgument(d.Buffer.isBuffer(t)),Mn.checkArgument(d.Buffer.isBuffer(r)),Mn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};It.sha256hmac=function(e,t){return It.hmac(It.sha256,e,t)};It.sha512hmac=function(e,t){return It.hmac(It.sha512,e,t)}});var HS={};sl(HS,{_MD5:()=>Qf,_RIPEMD160:()=>ec,_SHA1:()=>Jf,md5:()=>JN,ripemd160:()=>o3,sha1:()=>$N});function CS(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Qo,oi,Jf,$N,ZN,XN,Zf,Ld,Qf,JN,QN,LS,e3,DS,US,FS,qS,t3,r3,n3,i3,Xf,ec,o3,jS=er(()=>{m();fd();On();Qo=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),oi=new Uint32Array(80),Jf=class extends Rn{constructor(){super(64,20,8,!1);C(this,"A",Qo[0]|0);C(this,"B",Qo[1]|0);C(this,"C",Qo[2]|0);C(this,"D",Qo[3]|0);C(this,"E",Qo[4]|0)}get(){let{A:r,B:n,C:i,D:o,E:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0,this.E=s|0}process(r,n){for(let h=0;h<16;h++,n+=4)oi[h]=r.getUint32(n,!1);for(let h=16;h<80;h++)oi[h]=In(oi[h-3]^oi[h-8]^oi[h-14]^oi[h-16],1);let{A:i,B:o,C:s,D:a,E:c}=this;for(let h=0;h<80;h++){let g,y;h<20?(g=qo(o,s,a),y=1518500249):h<40?(g=o^s^a,y=1859775393):h<60?(g=If(o,s,a),y=2400959708):(g=o^s^a,y=3395469782);let w=In(i,5)+g+c+y+oi[h]|0;c=a,a=s,s=In(o,30),o=i,i=w}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,c=c+this.E|0,this.set(i,o,s,a,c)}roundClean(){Zt(oi)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),Zt(this.buffer)}},$N=Lr(()=>new Jf),ZN=Math.pow(2,32),XN=Array.from({length:64},(e,t)=>Math.floor(ZN*Math.abs(Math.sin(t+1)))),Zf=Qo.slice(0,4),Ld=new Uint32Array(16),Qf=class extends Rn{constructor(){super(64,16,8,!0);C(this,"A",Zf[0]|0);C(this,"B",Zf[1]|0);C(this,"C",Zf[2]|0);C(this,"D",Zf[3]|0)}get(){let{A:r,B:n,C:i,D:o}=this;return[r,n,i,o]}set(r,n,i,o){this.A=r|0,this.B=n|0,this.C=i|0,this.D=o|0}process(r,n){for(let c=0;c<16;c++,n+=4)Ld[c]=r.getUint32(n,!0);let{A:i,B:o,C:s,D:a}=this;for(let c=0;c<64;c++){let h,g,y;c<16?(h=qo(o,s,a),g=c,y=[7,12,17,22]):c<32?(h=qo(a,o,s),g=(5*c+1)%16,y=[5,9,14,20]):c<48?(h=o^s^a,g=(3*c+5)%16,y=[4,11,16,23]):(h=s^(o|~a),g=7*c%16,y=[6,10,15,21]),h=h+i+XN[c]+Ld[g],i=a,a=s,s=o,o=o+In(h,y[c%4])}i=i+this.A|0,o=o+this.B|0,s=s+this.C|0,a=a+this.D|0,this.set(i,o,s,a)}roundClean(){Zt(Ld)}destroy(){this.destroyed=!0,this.set(0,0,0,0),Zt(this.buffer)}},JN=Lr(()=>new Qf),QN=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),LS=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),e3=LS.map(e=>(9*e+5)%16),DS=(()=>{let r=[[LS],[e3]];for(let n=0;n<4;n++)for(let i of r)i.push(i[n].map(o=>QN[o]));return r})(),US=DS[0],FS=DS[1],qS=[[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(e=>Uint8Array.from(e)),t3=US.map((e,t)=>e.map(r=>qS[t][r])),r3=FS.map((e,t)=>e.map(r=>qS[t][r])),n3=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),i3=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);Xf=new Uint32Array(16),ec=class extends Rn{constructor(){super(64,20,8,!0);C(this,"h0",1732584193);C(this,"h1",-271733879);C(this,"h2",-1732584194);C(this,"h3",271733878);C(this,"h4",-1009589776)}get(){let{h0:r,h1:n,h2:i,h3:o,h4:s}=this;return[r,n,i,o,s]}set(r,n,i,o,s){this.h0=r|0,this.h1=n|0,this.h2=i|0,this.h3=o|0,this.h4=s|0}process(r,n){for(let T=0;T<16;T++,n+=4)Xf[T]=r.getUint32(n,!0);let i=this.h0|0,o=i,s=this.h1|0,a=s,c=this.h2|0,h=c,g=this.h3|0,y=g,w=this.h4|0,I=w;for(let T=0;T<5;T++){let M=4-T,L=n3[T],j=i3[T],G=US[T],q=FS[T],W=t3[T],J=r3[T];for(let Y=0;Y<16;Y++){let be=In(i+CS(T,s,c,g)+Xf[G[Y]]+L,W[Y])+w|0;i=w,w=g,g=In(c,10)|0,c=s,s=be}for(let Y=0;Y<16;Y++){let be=In(o+CS(M,a,h,y)+Xf[q[Y]]+j,J[Y])+I|0;o=I,I=y,y=In(h,10)|0,h=a,a=be}}this.set(this.h1+c+y|0,this.h2+g+I|0,this.h3+w+o|0,this.h4+i+a|0,this.h0+s+h|0)}roundClean(){Zt(Xf)}destroy(){this.destroyed=!0,Zt(this.buffer),this.set(0,0,0,0,0)}},o3=Lr(()=>new ec)});var VS=P((PU,KS)=>{"use strict";m();var{sha256:s3,sha512:a3}=(hd(),al(M_)),{sha1:u3,ripemd160:f3}=(jS(),al(HS)),kn=ke(),At=KS.exports;At.sha1=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(u3(e))};At.sha1.blocksize=512;At.sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(s3(e))};At.sha256.blocksize=512;At.sha256sha256=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.sha256(At.sha256(e))};At.ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(f3(e))};At.sha256ripemd160=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),At.ripemd160(At.sha256(e))};At.sha512=function(e){return kn.checkArgument(d.Buffer.isBuffer(e)),d.Buffer.from(a3(e))};At.sha512.blocksize=1024;At.hmac=function(e,t,r){kn.checkArgument(d.Buffer.isBuffer(t)),kn.checkArgument(d.Buffer.isBuffer(r)),kn.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r.length<n){var i=d.Buffer.alloc(n);i.fill(0),r.copy(i),r=i}var o=d.Buffer.alloc(n);o.fill(92);var s=d.Buffer.alloc(n);s.fill(54);for(var a=d.Buffer.alloc(n),c=d.Buffer.alloc(n),h=0;h<n;h++)a[h]=o[h]^r[h],c[h]=s[h]^r[h];return e(d.Buffer.concat([a,e(d.Buffer.concat([c,t]))]))};At.sha256hmac=function(e,t){return At.hmac(At.sha256,e,t)};At.sha512hmac=function(e,t){return At.hmac(At.sha512,e,t)}});var Qt=P((NU,zS)=>{"use strict";m();var GS={sha1:"a9993e364706816aba3e25717850c26c9cd0d89d",sha256:"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",sha512:"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",ripemd160:"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"};function c3(){var e;try{e=Qs()}catch{return!1}if(!e||typeof e.createHash!="function")return!1;for(var t=Object.keys(GS),r=0;r<t.length;r++){var n=t[r];try{if(e.createHash(n).update("abc").digest("hex")!==GS[n])return!1}catch{return!1}}return!0}zS.exports=c3()?kS():VS()});var pr=P((kU,$S)=>{"use strict";m();var YS=Ve(),l3=ke(),WS=function(t){return YS.isString(t)?/^[0-9a-fA-F]+$/.test(t):!1};$S.exports={isValidJSON:function(t){var r;if(!YS.isString(t))return!1;try{r=JSON.parse(t)}catch{return!1}return typeof r=="object"},isHexa:WS,isHexaString:WS,defineImmutable:function(t,r){return Object.keys(r).forEach(function(n){Object.defineProperty(t,n,{configurable:!1,enumerable:!0,value:r[n]})}),t},isNaturalNumber:function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){l3.checkArgumentType(t,"number","integer");let r=d.Buffer.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}});var ga=P((LU,JS)=>{"use strict";m();var Cn=Ve(),la=pr(),Xi=[],ha={};function ZS(){}ZS.prototype.toString=function(){return this.name};function da(e,t){if(~Xi.indexOf(e))return e;if(t){Cn.isArray(t)||(t=[t]);for(var r=0;r<Xi.length;r++){var n=Xi[r],i=Cn.pick(n,t),o=Cn.values(i);if(~o.indexOf(e))return n}return}return ha[e]}function tc(e){for(var t=[],r=0;r<e.length;r++)t.push(e.charCodeAt(r)&31);return t}function pa(e){var t=new ZS;la.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&Cn.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:tc(e.cashAddrPrefix)}),e.networkMagic&&Cn.extend(t,{networkMagic:la.integerAsBuffer(e.networkMagic)}),e.port&&Cn.extend(t,{port:e.port}),e.dnsSeeds&&Cn.extend(t,{dnsSeeds:e.dnsSeeds}),Xi.push(t),h3(t,r),t}function h3(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=e[n];!Cn.isUndefined(i)&&!Cn.isObject(i)&&(ha[i]=e)}}function d3(e,t){for(var r=0;r<t.length;r++){var n=t[r];ha[n]===e&&delete ha[n]}}function p3(e){for(var t=0;t<Xi.length;t++)Xi[t]===e&&Xi.splice(t,1);d3(e,Object.keys(ha))}var rc={livenet:3823236072,testnet:4108710900,regtest:3669344250,stn:4224632057},XS=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],si={PORT:18333,NETWORK_MAGIC:rc.testnet,DNS_SEEDS:XS,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},Ln={PORT:18444,NETWORK_MAGIC:rc.regtest,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},ai={PORT:9333,NETWORK_MAGIC:rc.stn,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g3={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:rc.livenet,port:8333,dnsSeeds:XS},y3={name:"testnet",prefix:si.PREFIX,cashAddrPrefix:si.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:si.NETWORK_MAGIC},m3={name:"regtest",prefix:Ln.PREFIX,cashAddrPrefix:Ln.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:Ln.NETWORK_MAGIC,port:Ln.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},v3={name:"stn",prefix:ai.PREFIX,cashAddrPrefix:ai.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:ai.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};pa(y3);pa(v3);pa(m3);pa(g3);var Dd=da("livenet"),b3=da("regtest"),fn=da("testnet"),_3=da("stn");Object.defineProperty(fn,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.PORT:this.stnEnabled?ai.PORT:si.PORT}});Object.defineProperty(fn,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?la.integerAsBuffer(Ln.NETWORK_MAGIC):this.stnEnabled?la.integerAsBuffer(ai.NETWORK_MAGIC):la.integerAsBuffer(si.NETWORK_MAGIC)}});Object.defineProperty(fn,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.DNS_SEEDS:this.stnEnabled?ai.DNS_SEEDS:si.DNS_SEEDS}});Object.defineProperty(fn,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?Ln.CASHADDRPREFIX:this.stnEnabled?ai.CASHADDRPREFIX:si.CASHADDRPREFIX}});Object.defineProperty(fn,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?tc(Ln.CASHADDRPREFIX):this.stnEnabled?tc(ai.CASHADDRPREFIX):tc(si.CASHADDRPREFIX)}});function S3(){fn.regtestEnabled=!0}function w3(){fn.regtestEnabled=!1}function E3(){fn.stnEnabled=!0}function x3(){fn.stnEnabled=!1}JS.exports={add:pa,remove:p3,defaultNetwork:Dd,livenet:Dd,mainnet:Dd,testnet:fn,regtest:b3,stn:_3,get:da,enableRegtest:S3,disableRegtest:w3,enableStn:E3,disableStn:x3}});var rw=P((UU,tw)=>{"use strict";m();var Ud=Ve(),QS=Tt(),es="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),ew={};for(ya=0;ya<es.length;ya++)ew[es[ya]]=ya;var ya;function I3(e){if(e.length===0)return"";var t=[0],r,n,i;for(r=0;r<e.length;r++){for(n=0,i=e[r];n<t.length;n++)i+=t[n]<<8,t[n]=i%58,i=i/58|0;for(;i>0;)t.push(i%58),i=i/58|0}var o="";for(r=0;e[r]===0&&r<e.length-1;r++)o+=es[0];for(r=t.length-1;r>=0;r--)o+=es[t[r]];return o}function A3(e){if(e.length===0)return d.Buffer.alloc(0);var t=[0],r,n,i;for(r=0;r<e.length;r++){var o=ew[e[r]];if(o===void 0)throw new Error("Non-base58 character");for(n=0,i=o;n<t.length;n++)i+=t[n]*58,t[n]=i&255,i>>=8;for(;i>0;)t.push(i&255),i>>=8}for(r=0;e[r]===es[0]&&r<e.length-1;r++)t.push(0);return d.Buffer.from(t.reverse())}var Dt=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Dt.validCharacters=function(t){return QS.Buffer.isBuffer(t)&&(t=t.toString()),Ud.every(Ud.map(t,function(r){return Ud.includes(es,r)}))};Dt.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Dt.encode=function(e){if(!QS.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return I3(e)};Dt.decode=function(e){if(typeof e!="string")throw new Error("Input should be a string");return A3(e)};Dt.prototype.fromBuffer=function(e){return this.buf=e,this};Dt.fromBuffer=function(e){return new Dt().fromBuffer(e)};Dt.fromHex=function(e){return Dt.fromBuffer(d.Buffer.from(e,"hex"))};Dt.prototype.fromString=function(e){var t=Dt.decode(e);return this.buf=t,this};Dt.fromString=function(e){return new Dt().fromString(e)};Dt.prototype.toBuffer=function(){return this.buf};Dt.prototype.toHex=function(){return this.toBuffer().toString("hex")};Dt.prototype.toString=function(){return Dt.encode(this.buf)};tw.exports=Dt});var Fd=P((qU,sw)=>{"use strict";m();var nw=Ve(),nc=rw(),iw=Tt(),ow=Qt().sha256sha256,Je=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t)){var r=t;this.fromBuffer(r)}else if(typeof t=="string"){var n=t;this.fromString(n)}};Je.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this};Je.validChecksum=function(t,r){return nw.isString(t)&&(t=iw.Buffer.from(nc.decode(t))),nw.isString(r)&&(r=iw.Buffer.from(nc.decode(r))),r||(r=t.slice(-4),t=t.slice(0,-4)),Je.checksum(t).toString("hex")===r.toString("hex")};Je.decode=function(e){if(typeof e!="string")throw new Error("Input must be a string");var t=d.Buffer.from(nc.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),i=ow(r),o=i.slice(0,4);if(n.toString("hex")!==o.toString("hex"))throw new Error("Checksum mismatch");return r};Je.checksum=function(e){return ow(e).slice(0,4)};Je.encode=function(e){if(!d.Buffer.isBuffer(e))throw new Error("Input must be a buffer");var t=d.Buffer.alloc(e.length+4),r=Je.checksum(e);return e.copy(t),r.copy(t,e.length),nc.encode(t)};Je.prototype.fromBuffer=function(e){return this.buf=e,this};Je.fromBuffer=function(e){return new Je().fromBuffer(e)};Je.fromHex=function(e){return Je.fromBuffer(d.Buffer.from(e,"hex"))};Je.prototype.fromString=function(e){var t=Je.decode(e);return this.buf=t,this};Je.fromString=function(e){var t=Je.decode(e);return new Je(t)};Je.prototype.toBuffer=function(){return this.buf};Je.prototype.toHex=function(){return this.toBuffer().toString("hex")};Je.prototype.toString=function(){return Je.encode(this.buf)};sw.exports=Je});var va=P((jU,uw)=>{"use strict";m();var ma=Ve(),aw=ke(),ts=Er(),et=function e(t){if(!(this instanceof e))return new e(t);if(!ma.isUndefined(t))if(d.Buffer.isBuffer(t))this.set({buf:t});else if(ma.isString(t)){var r=d.Buffer.from(t,"hex");if(r.length*2!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else if(ma.isObject(t)){var n=t;this.set(n)}else throw new TypeError("Unrecognized argument for BufferReader")};et.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this};et.prototype.eof=function(){return this.pos>=this.buf.length};et.prototype.finished=et.prototype.eof;et.prototype.read=function(e){aw.checkArgument(!ma.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t};et.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e};et.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e};et.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e};et.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e};et.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=ts.fromBuffer(e);return this.pos=this.pos+8,t};et.prototype.readUInt64LEBN=function(){var e=this.buf.readUInt32LE(this.pos),t=this.buf.readUInt32LE(this.pos+4),r=t*4294967296+e,n;if(r<=9007199254740991)n=new ts(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);n=new ts(i,10,"le")}return this.pos=this.pos+8,n};et.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN(),r=t.toNumber();if(r<=Math.pow(2,53))return r;throw new Error("number too large to retain precision - use readVarintBN");default:return e}};et.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return aw.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t};et.prototype.readVarintBuf=function(){var e=this.buf.readUInt8(this.pos);switch(e){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}};et.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new ts(this.readUInt16LE());case 254:return new ts(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new ts(e)}};et.prototype.reverse=function(){for(var e=d.Buffer.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this};et.prototype.readReverse=function(e){ma.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,d.Buffer.from(t).reverse()};uw.exports=et});var jd=P((VU,hw)=>{"use strict";m();function ui(e){"@babel/helpers - typeof";return ui=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ui(e)}function fw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,R3(n.key),n)}}function O3(e,t,r){return t&&fw(e.prototype,t),r&&fw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function R3(e){var t=T3(e,"string");return ui(t)==="symbol"?t:String(t)}function T3(e,t){if(ui(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ui(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function P3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function B3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Hd(e,t)}function Hd(e,t){return Hd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Hd(e,t)}function N3(e){var t=C3();return function(){var n=ic(e),i;if(t){var o=ic(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return M3(this,i)}}function M3(e,t){if(t&&(ui(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return k3(e)}function k3(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function C3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ic(e){return ic=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ic(e)}var lw={},rs,qd;function ba(e,t,r){r||(r=Error);function n(o,s,a){return typeof t=="string"?t:t(o,s,a)}var i=(function(o){B3(a,o);var s=N3(a);function a(c,h,g){var y;return P3(this,a),y=s.call(this,n(c,h,g)),y.code=e,y}return O3(a)})(r);lw[e]=i}function cw(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function L3(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function D3(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function U3(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}ba("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);ba("ERR_INVALID_ARG_TYPE",function(e,t,r){rs===void 0&&(rs=oc()),rs(typeof e=="string","'name' must be a string");var n;typeof t=="string"&&L3(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(D3(e," argument"))i="The ".concat(e," ").concat(n," ").concat(cw(t,"type"));else{var o=U3(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(o," ").concat(n," ").concat(cw(t,"type"))}return i+=". Received type ".concat(ui(r)),i},TypeError);ba("ERR_INVALID_ARG_VALUE",function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"is invalid";qd===void 0&&(qd=en());var n=qd.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(r,". Received ").concat(n)},TypeError,RangeError);ba("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return r&&r.constructor&&r.constructor.name?n="instance of ".concat(r.constructor.name):n="type ".concat(ui(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError);ba("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];rs===void 0&&(rs=oc()),rs(t.length>0,"At least one arg needs to be specified");var n="The ",i=t.length;switch(t=t.map(function(o){return'"'.concat(o,'"')}),i){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,i-1).join(", "),n+=", and ".concat(t[i-1]," arguments");break}return"".concat(n," must be specified")},TypeError);hw.exports.codes=lw});var ww=P((zU,Sw)=>{"use strict";m();function dw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function pw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dw(Object(r),!0).forEach(function(n){F3(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dw(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function F3(e,t,r){return t=vw(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gw(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,vw(n.key),n)}}function H3(e,t,r){return t&&gw(e.prototype,t),r&&gw(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function vw(e){var t=j3(e,"string");return ur(t)==="symbol"?t:String(t)}function j3(e,t){if(ur(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(ur(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function K3(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ea(e,t)}function V3(e){var t=_w();return function(){var n=xa(e),i;if(t){var o=xa(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return bw(this,i)}}function bw(e,t){if(t&&(ur(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kd(e)}function Kd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vd(e){var t=typeof Map=="function"?new Map:void 0;return Vd=function(n){if(n===null||!G3(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return sc(n,arguments,xa(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ea(i,n)},Vd(e)}function sc(e,t,r){return _w()?sc=Reflect.construct.bind():sc=function(i,o,s){var a=[null];a.push.apply(a,o);var c=Function.bind.apply(i,a),h=new c;return s&&Ea(h,s.prototype),h},sc.apply(null,arguments)}function _w(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function G3(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function Ea(e,t){return Ea=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ea(e,t)}function xa(e){return xa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},xa(e)}function ur(e){"@babel/helpers - typeof";return ur=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(e)}var z3=en(),Gd=z3.inspect,W3=jd(),Y3=W3.codes.ERR_INVALID_ARG_TYPE;function yw(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function $3(e,t){if(t=Math.floor(t),e.length==0||t==0)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+=e.substring(0,r-e.length),e}var Ur="",_a="",Sa="",Vt="",Ji={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"},Z3=10;function mw(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(n){r[n]=e[n]}),Object.defineProperty(r,"message",{value:e.message}),r}function wa(e){return Gd(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function X3(e,t,r){var n="",i="",o=0,s="",a=!1,c=wa(e),h=c.split(`
|
|
14
14
|
`),g=wa(t).split(`
|
|
15
|
-
`),y=0,w="";if(r==="strictEqual"&&ur(e)==="object"&&ur(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),h.length===1&&g.length===1&&h[0]!==g[0]){var I=h[0].length+g[0].length;if(I<=
|
|
15
|
+
`),y=0,w="";if(r==="strictEqual"&&ur(e)==="object"&&ur(t)==="object"&&e!==null&&t!==null&&(r="strictEqualObject"),h.length===1&&g.length===1&&h[0]!==g[0]){var I=h[0].length+g[0].length;if(I<=Z3){if((ur(e)!=="object"||e===null)&&(ur(t)!=="object"||t===null)&&(e!==0||t!==0))return"".concat(Ji[r],`
|
|
16
16
|
|
|
17
17
|
`)+"".concat(h[0]," !== ").concat(g[0],`
|
|
18
18
|
`)}else if(r!=="strictEqualObject"){var T=x.default.stderr&&x.default.stderr.isTTY?x.default.stderr.columns:80;if(I<T){for(;h[0][y]===g[0][y];)y++;y>2&&(w=`
|
|
19
|
-
`.concat($
|
|
19
|
+
`.concat($3(" ",y),"^"),y=0)}}}for(var M=h[h.length-1],L=g[g.length-1];M===L&&(y++<2?s=`
|
|
20
20
|
`.concat(M).concat(s):n=M,h.pop(),g.pop(),!(h.length===0||g.length===0));)M=h[h.length-1],L=g[g.length-1];var j=Math.max(h.length,g.length);if(j===0){var G=c.split(`
|
|
21
21
|
`);if(G.length>30)for(G[26]="".concat(Ur,"...").concat(Vt);G.length>27;)G.pop();return"".concat(Ji.notIdentical,`
|
|
22
22
|
|
|
@@ -43,7 +43,7 @@ Use Chrome, Firefox or Internet Explorer 11`)}var $B=qt().Buffer,vf=globalThis.c
|
|
|
43
43
|
`).concat(i,`
|
|
44
44
|
`).concat(Ur,"...").concat(Vt).concat(n,`
|
|
45
45
|
`)+"".concat(Ur,"...").concat(Vt)}return"".concat(W).concat(a?J:"",`
|
|
46
|
-
`).concat(i).concat(n).concat(s).concat(w)}var
|
|
46
|
+
`).concat(i).concat(n).concat(s).concat(w)}var J3=(function(e,t){K3(n,e);var r=V3(n);function n(i){var o;if(q3(this,n),ur(i)!=="object"||i===null)throw new Y3("options","Object",i);var s=i.message,a=i.operator,c=i.stackStartFn,h=i.actual,g=i.expected,y=Error.stackTraceLimit;if(Error.stackTraceLimit=0,s!=null)o=r.call(this,String(s));else if(x.default.stderr&&x.default.stderr.isTTY&&(x.default.stderr&&x.default.stderr.getColorDepth&&x.default.stderr.getColorDepth()!==1?(Ur="\x1B[34m",_a="\x1B[32m",Vt="\x1B[39m",Sa="\x1B[31m"):(Ur="",_a="",Vt="",Sa="")),ur(h)==="object"&&h!==null&&ur(g)==="object"&&g!==null&&"stack"in h&&h instanceof Error&&"stack"in g&&g instanceof Error&&(h=mw(h),g=mw(g)),a==="deepStrictEqual"||a==="strictEqual")o=r.call(this,X3(h,g,a));else if(a==="notDeepStrictEqual"||a==="notStrictEqual"){var w=Ji[a],I=wa(h).split(`
|
|
47
47
|
`);if(a==="notStrictEqual"&&ur(h)==="object"&&h!==null&&(w=Ji.notStrictEqualObject),I.length>30)for(I[26]="".concat(Ur,"...").concat(Vt);I.length>27;)I.pop();I.length===1?o=r.call(this,"".concat(w," ").concat(I[0])):o=r.call(this,"".concat(w,`
|
|
48
48
|
|
|
49
49
|
`).concat(I.join(`
|
|
@@ -56,8 +56,8 @@ Use Chrome, Firefox or Internet Explorer 11`)}var $B=qt().Buffer,vf=globalThis.c
|
|
|
56
56
|
|
|
57
57
|
should equal
|
|
58
58
|
|
|
59
|
-
`):M=" ".concat(a," ").concat(M)),o=r.call(this,"".concat(T).concat(M))}return Error.stackTraceLimit=y,o.generatedMessage=!s,Object.defineProperty(Kd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=h,o.expected=g,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Kd(o),c),o.stack,o.name="AssertionError",bw(o)}return
|
|
60
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R3(e,t){if(e){if(typeof e=="string")return yE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return yE(e,t)}}function yE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T3(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],c=!0,h=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(g){h=!0,i=g}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(h)throw i}}return a}}function P3(e){if(Array.isArray(e))return e}function Or(e){"@babel/helpers - typeof";return Or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Or(e)}var B3=/a/g.flags!==void 0,mc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},mE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},RE=Object.is?Object.is:sE(),gc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},ep=Number.isNaN?Number.isNaN:pE();function rp(e){return e.call.bind(e)}var Ta=rp(Object.prototype.hasOwnProperty),yc=rp(Object.prototype.propertyIsEnumerable),vE=rp(Object.prototype.toString),rr=en().types,N3=rr.isAnyArrayBuffer,M3=rr.isArrayBufferView,bE=rr.isDate,lc=rr.isMap,_E=rr.isRegExp,hc=rr.isSet,k3=rr.isNativeError,C3=rr.isBoxedPrimitive,SE=rr.isNumberObject,wE=rr.isStringObject,EE=rr.isBooleanObject,xE=rr.isBigIntObject,L3=rr.isSymbolObject,D3=rr.isFloat32Array,U3=rr.isFloat64Array;function F3(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function dc(e){return Object.keys(e).filter(F3).concat(gc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function TE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var pc=void 0,q3=!0,H3=!1,tp=0,np=1,PE=2,BE=3;function j3(e,t){return B3?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function K3(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function V3(e,t){return e.byteLength!==t.byteLength?!1:TE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function G3(e,t){return e.byteLength===t.byteLength&&TE(new Uint8Array(e),new Uint8Array(t))===0}function z3(e,t){return SE(e)?SE(t)&&RE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):wE(e)?wE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):EE(e)?EE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):xE(e)?xE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):L3(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Rr(e,t,r,n){if(e===t)return e!==0?!0:r?RE(e,t):!0;if(r){if(Or(e)!=="object")return typeof e=="number"&&ep(e)&&ep(t);if(Or(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Or(e)!=="object")return t===null||Or(t)!=="object"?e==t:!1;if(t===null||Or(t)!=="object")return!1}var i=vE(e),o=vE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=dc(e,pc),a=dc(t,pc);return s.length!==a.length?!1:Ra(e,t,r,n,np,s)}if(i==="[object Object]"&&(!lc(e)&&lc(t)||!hc(e)&&hc(t)))return!1;if(bE(e)){if(!bE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(_E(e)){if(!_E(t)||!j3(e,t))return!1}else if(k3(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(M3(e)){if(!r&&(D3(e)||U3(e))){if(!K3(e,t))return!1}else if(!V3(e,t))return!1;var c=dc(e,pc),h=dc(t,pc);return c.length!==h.length?!1:Ra(e,t,r,n,tp,c)}else{if(hc(e))return!hc(t)||e.size!==t.size?!1:Ra(e,t,r,n,PE);if(lc(e))return!lc(t)||e.size!==t.size?!1:Ra(e,t,r,n,BE);if(N3(e)){if(!G3(e,t))return!1}else if(C3(e)&&!z3(e,t))return!1}return Ra(e,t,r,n,tp)}function IE(e,t){return t.filter(function(r){return yc(e,r)})}function Ra(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ta(t,o[a]))return!1;if(r&&arguments.length===5){var c=gc(e);if(c.length!==0){var h=0;for(a=0;a<c.length;a++){var g=c[a];if(yc(e,g)){if(!yc(t,g))return!1;o.push(g),h++}else if(yc(t,g))return!1}var y=gc(t);if(c.length!==y.length&&IE(t,y).length!==h)return!1}else{var w=gc(t);if(w.length!==0&&IE(t,w).length!==0)return!1}}if(o.length===0&&(i===tp||i===np&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var I=n.val1.get(e);if(I!==void 0){var T=n.val2.get(t);if(T!==void 0)return I===T}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var M=X3(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),M}function AE(e,t,r,n){for(var i=mc(e),o=0;o<i.length;o++){var s=i[o];if(Rr(t,s,r,n))return e.delete(s),!0}return!1}function NE(e){switch(Or(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(ep(e))return!1}return!0}function W3(e,t,r){var n=NE(r);return n??(t.has(n)&&!e.has(n))}function Y3(e,t,r,n,i){var o=NE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Rr(n,s,!1,i)?!1:!e.has(o)&&Rr(n,s,!1,i)}function $3(e,t,r,n){for(var i=null,o=mc(e),s=0;s<o.length;s++){var a=o[s];if(Or(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!W3(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var c=mc(t),h=0;h<c.length;h++){var g=c[h];if(Or(g)==="object"&&g!==null){if(!AE(i,g,r,n))return!1}else if(!r&&!e.has(g)&&!AE(i,g,r,n))return!1}return i.size===0}return!0}function OE(e,t,r,n,i,o){for(var s=mc(e),a=0;a<s.length;a++){var c=s[a];if(Rr(r,c,i,o)&&Rr(n,t.get(c),i,o))return e.delete(c),!0}return!1}function Z3(e,t,r,n){for(var i=null,o=mE(e),s=0;s<o.length;s++){var a=gE(o[s],2),c=a[0],h=a[1];if(Or(c)==="object"&&c!==null)i===null&&(i=new Set),i.add(c);else{var g=t.get(c);if(g===void 0&&!t.has(c)||!Rr(h,g,r,n)){if(r||!Y3(e,t,c,h,n))return!1;i===null&&(i=new Set),i.add(c)}}}if(i!==null){for(var y=mE(t),w=0;w<y.length;w++){var I=gE(y[w],2),T=I[0],M=I[1];if(Or(T)==="object"&&T!==null){if(!OE(i,e,T,M,r,n))return!1}else if(!r&&(!e.has(T)||!Rr(e.get(T),M,!1,n))&&!OE(i,e,T,M,!1,n))return!1}return i.size===0}return!0}function X3(e,t,r,n,i,o){var s=0;if(o===PE){if(!$3(e,t,r,i))return!1}else if(o===BE){if(!Z3(e,t,r,i))return!1}else if(o===np)for(;s<e.length;s++)if(Ta(e,s)){if(!Ta(t,s)||!Rr(e[s],t[s],r,i))return!1}else{if(Ta(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var c=a[s];if(!Ta(t,c)||!Rr(e[c],t[c],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var h=n[s];if(!Rr(e[h],t[h],r,i))return!1}return!0}function J3(e,t){return Rr(e,t,H3)}function Q3(e,t){return Rr(e,t,q3)}ME.exports={isDeepEqual:J3,isDeepStrictEqual:Q3}});var oc=P((AF,JE)=>{"use strict";m();function Fr(e){"@babel/helpers - typeof";return Fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fr(e)}function CE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,t6(n.key),n)}}function e6(e,t,r){return t&&CE(e.prototype,t),r&&CE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function t6(e){var t=r6(e,"string");return Fr(t)==="symbol"?t:String(t)}function r6(e,t){if(Fr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Fr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function n6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i6=jd(),Pa=i6.codes,LE=Pa.ERR_AMBIGUOUS_ARGUMENT,ns=Pa.ERR_INVALID_ARG_TYPE,o6=Pa.ERR_INVALID_ARG_VALUE,s6=Pa.ERR_INVALID_RETURN_VALUE,ci=Pa.ERR_MISSING_ARGS,li=ww(),a6=en(),vc=a6.inspect,qE=en().types,u6=qE.isPromise,bc=qE.isRegExp,f6=Kw()(),HE=cc()(),_c=Zw()("RegExp.prototype.test"),fi,Sc;function Ba(){var e=kE();fi=e.isDeepEqual,Sc=e.isDeepStrictEqual}var DE=!1,Ge=JE.exports=ip,wc={};function qr(e){throw e.message instanceof Error?e.message:new li(e)}function jE(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(DE===!1){DE=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var c={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||jE};r!==void 0&&(c.message=r);var h=new li(c);throw s&&(h.message=s,h.generatedMessage=!0),h}Ge.fail=jE;Ge.AssertionError=li;function KE(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new li({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function ip(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];KE.apply(void 0,[ip,t.length].concat(t))}Ge.ok=ip;Ge.equal=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t!=r&&qr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Ge.notEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t==r&&qr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Ge.deepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)||qr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Ge.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)&&qr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Ge.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),Sc(t,r)||qr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Ge.notDeepStrictEqual=VE;function VE(e,t,r){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),Sc(e,t)&&qr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:VE})}Ge.strictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");HE(t,r)||qr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Ge.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");HE(t,r)&&qr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var UE=e6(function e(t,r,n){var i=this;n6(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&bc(t[o])&&_c(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function c6(e,t,r,n,i,o){if(!(r in e)||!Sc(e[r],t[r])){if(!n){var s=new UE(e,i),a=new UE(t,i,e),c=new li({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=e,c.expected=t,c.operator=o.name,c}qr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function GE(e,t,r,n){if(typeof t!="function"){if(bc(t))return _c(t,e);if(arguments.length===2)throw new ns("expected",["Function","RegExp"],t);if(Fr(e)!=="object"||e===null){var i=new li({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new o6("error",t,"may not be an empty object");return fi===void 0&&Ba(),o.forEach(function(s){typeof e[s]=="string"&&bc(t[s])&&_c(t[s],e[s])||c6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function zE(e){if(typeof e!="function")throw new ns("fn","Function",e);try{e()}catch(t){return t}return wc}function FE(e){return u6(e)||e!==null&&Fr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function WE(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!FE(t))throw new s6("instance of Promise","promiseFn",t)}else if(FE(e))t=e;else throw new ns("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return wc}).catch(function(r){return r})})}function YE(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new ns("error",["Object","Error","Function","RegExp"],r);if(Fr(t)==="object"&&t!==null){if(t.message===r)throw new LE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new LE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Fr(r)!=="object"&&typeof r!="function")throw new ns("error",["Object","Error","Function","RegExp"],r);if(t===wc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";qr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!GE(t,r,n,e))throw t}function $E(e,t,r,n){if(t!==wc){if(typeof r=="string"&&(n=r,r=void 0),!r||GE(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";qr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
|
|
59
|
+
`):M=" ".concat(a," ").concat(M)),o=r.call(this,"".concat(T).concat(M))}return Error.stackTraceLimit=y,o.generatedMessage=!s,Object.defineProperty(Kd(o),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),o.code="ERR_ASSERTION",o.actual=h,o.expected=g,o.operator=a,Error.captureStackTrace&&Error.captureStackTrace(Kd(o),c),o.stack,o.name="AssertionError",bw(o)}return H3(n,[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(o,s){return Gd(this,pw(pw({},s),{},{customInspect:!1,depth:0}))}}]),n})(Vd(Error),Gd.custom);Sw.exports=J3});var zd=P((YU,xw)=>{"use strict";m();var Ew=Object.prototype.toString;xw.exports=function(t){var r=Ew.call(t),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&Ew.call(t.callee)==="[object Function]"),n}});var Mw=P((ZU,Nw)=>{"use strict";m();var Bw;Object.keys||(Ia=Object.prototype.hasOwnProperty,Wd=Object.prototype.toString,Iw=zd(),Yd=Object.prototype.propertyIsEnumerable,Aw=!Yd.call({toString:null},"toString"),Ow=Yd.call(function(){},"prototype"),Aa=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ac=function(e){var t=e.constructor;return t&&t.prototype===e},Rw={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},Tw=(function(){if(typeof window>"u")return!1;for(var e in window)try{if(!Rw["$"+e]&&Ia.call(window,e)&&window[e]!==null&&typeof window[e]=="object")try{ac(window[e])}catch{return!0}}catch{return!0}return!1})(),Pw=function(e){if(typeof window>"u"||!Tw)return ac(e);try{return ac(e)}catch{return!1}},Bw=function(t){var r=t!==null&&typeof t=="object",n=Wd.call(t)==="[object Function]",i=Iw(t),o=r&&Wd.call(t)==="[object String]",s=[];if(!r&&!n&&!i)throw new TypeError("Object.keys called on a non-object");var a=Ow&&n;if(o&&t.length>0&&!Ia.call(t,0))for(var c=0;c<t.length;++c)s.push(String(c));if(i&&t.length>0)for(var h=0;h<t.length;++h)s.push(String(h));else for(var g in t)!(a&&g==="prototype")&&Ia.call(t,g)&&s.push(String(g));if(Aw)for(var y=Pw(t),w=0;w<Aa.length;++w)!(y&&Aa[w]==="constructor")&&Ia.call(t,Aa[w])&&s.push(Aa[w]);return s});var Ia,Wd,Iw,Yd,Aw,Ow,Aa,ac,Rw,Tw,Pw;Nw.exports=Bw});var $d=P((JU,Lw)=>{"use strict";m();var Q3=Array.prototype.slice,eM=zd(),kw=Object.keys,uc=kw?function(t){return kw(t)}:Mw(),Cw=Object.keys;uc.shim=function(){if(Object.keys){var t=(function(){var r=Object.keys(arguments);return r&&r.length===arguments.length})(1,2);t||(Object.keys=function(n){return eM(n)?Cw(Q3.call(n)):Cw(n)})}else Object.keys=uc;return Object.keys||uc};Lw.exports=uc});var Hw=P((eF,qw)=>{"use strict";m();var tM=$d(),Uw=nu()(),Fw=Vn(),fc=iu(),rM=Fw("Array.prototype.push"),Dw=Fw("Object.prototype.propertyIsEnumerable"),nM=Uw?fc.getOwnPropertySymbols:null;qw.exports=function(t,r){if(t==null)throw new TypeError("target must be an object");var n=fc(t);if(arguments.length===1)return n;for(var i=1;i<arguments.length;++i){var o=fc(arguments[i]),s=tM(o),a=Uw&&(fc.getOwnPropertySymbols||nM);if(a)for(var c=a(o),h=0;h<c.length;++h){var g=c[h];Dw(o,g)&&rM(s,g)}for(var y=0;y<s.length;++y){var w=s[y];if(Dw(o,w)){var I=o[w];n[w]=I}}}return n}});var Kw=P((rF,jw)=>{"use strict";m();var Zd=Hw(),iM=function(){if(!Object.assign)return!1;for(var e="abcdefghijklmnopqrst",t=e.split(""),r={},n=0;n<t.length;++n)r[t[n]]=t[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return e!==o},oM=function(){if(!Object.assign||!Object.preventExtensions)return!1;var e=Object.preventExtensions({1:2});try{Object.assign(e,"xy")}catch{return e[1]==="y"}return!1};jw.exports=function(){return!Object.assign||iM()||oM()?Zd:Object.assign}});var Xd=P((iF,Gw)=>{"use strict";m();var Vw=function(e){return e!==e};Gw.exports=function(t,r){return t===0&&r===0?1/t===1/r:!!(t===r||Vw(t)&&Vw(r))}});var cc=P((sF,zw)=>{"use strict";m();var sM=Xd();zw.exports=function(){return typeof Object.is=="function"?Object.is:sM}});var Zw=P((uF,$w)=>{"use strict";m();var Ww=du(),Yw=ws(),aM=Yw(Ww("String.prototype.indexOf"));$w.exports=function(t,r){var n=Ww(t,!!r);return typeof n=="function"&&aM(t,".prototype.")>-1?Yw(n):n}});var Oa=P((cF,eE)=>{"use strict";m();var uM=$d(),fM=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",cM=Object.prototype.toString,lM=Array.prototype.concat,Xw=jl(),hM=function(e){return typeof e=="function"&&cM.call(e)==="[object Function]"},Jw=Vl()(),dM=function(e,t,r,n){if(t in e){if(n===!0){if(e[t]===r)return}else if(!hM(n)||!n())return}Jw?Xw(e,t,r,!0):Xw(e,t,r)},Qw=function(e,t){var r=arguments.length>2?arguments[2]:{},n=uM(t);fM&&(n=lM.call(n,Object.getOwnPropertySymbols(t)));for(var i=0;i<n.length;i+=1)dM(e,n[i],t[n[i]],r[n[i]])};Qw.supportsDescriptors=!!Jw;eE.exports=Qw});var rE=P((hF,tE)=>{"use strict";m();var pM=cc(),gM=Oa();tE.exports=function(){var t=pM();return gM(Object,{is:t},{is:function(){return Object.is!==t}}),t}});var sE=P((pF,oE)=>{"use strict";m();var yM=Oa(),mM=ws(),vM=Xd(),nE=cc(),bM=rE(),iE=mM(nE(),Object);yM(iE,{getPolyfill:nE,implementation:vM,shim:bM});oE.exports=iE});var Jd=P((yF,aE)=>{"use strict";m();aE.exports=function(t){return t!==t}});var Qd=P((vF,uE)=>{"use strict";m();var _M=Jd();uE.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:_M}});var cE=P((_F,fE)=>{"use strict";m();var SM=Oa(),wM=Qd();fE.exports=function(){var t=wM();return SM(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}});var pE=P((wF,dE)=>{"use strict";m();var EM=ws(),xM=Oa(),IM=Jd(),lE=Qd(),AM=cE(),hE=EM(lE(),Number);xM(hE,{getPolyfill:lE,implementation:IM,shim:AM});dE.exports=hE});var kE=P((xF,ME)=>{"use strict";m();function gE(e,t){return PM(e)||TM(e,t)||RM(e,t)||OM()}function OM(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
60
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RM(e,t){if(e){if(typeof e=="string")return yE(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return yE(e,t)}}function yE(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function TM(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,i,o,s,a=[],c=!0,h=!1;try{if(o=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(g){h=!0,i=g}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(h)throw i}}return a}}function PM(e){if(Array.isArray(e))return e}function Or(e){"@babel/helpers - typeof";return Or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Or(e)}var BM=/a/g.flags!==void 0,mc=function(t){var r=[];return t.forEach(function(n){return r.push(n)}),r},mE=function(t){var r=[];return t.forEach(function(n,i){return r.push([i,n])}),r},RE=Object.is?Object.is:sE(),gc=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},ep=Number.isNaN?Number.isNaN:pE();function rp(e){return e.call.bind(e)}var Ta=rp(Object.prototype.hasOwnProperty),yc=rp(Object.prototype.propertyIsEnumerable),vE=rp(Object.prototype.toString),rr=en().types,NM=rr.isAnyArrayBuffer,MM=rr.isArrayBufferView,bE=rr.isDate,lc=rr.isMap,_E=rr.isRegExp,hc=rr.isSet,kM=rr.isNativeError,CM=rr.isBoxedPrimitive,SE=rr.isNumberObject,wE=rr.isStringObject,EE=rr.isBooleanObject,xE=rr.isBigIntObject,LM=rr.isSymbolObject,DM=rr.isFloat32Array,UM=rr.isFloat64Array;function FM(e){if(e.length===0||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return e.length===10&&e>=Math.pow(2,32)}function dc(e){return Object.keys(e).filter(FM).concat(gc(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}function TE(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0}var pc=void 0,qM=!0,HM=!1,tp=0,np=1,PE=2,BE=3;function jM(e,t){return BM?e.source===t.source&&e.flags===t.flags:RegExp.prototype.toString.call(e)===RegExp.prototype.toString.call(t)}function KM(e,t){if(e.byteLength!==t.byteLength)return!1;for(var r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function VM(e,t){return e.byteLength!==t.byteLength?!1:TE(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))===0}function GM(e,t){return e.byteLength===t.byteLength&&TE(new Uint8Array(e),new Uint8Array(t))===0}function zM(e,t){return SE(e)?SE(t)&&RE(Number.prototype.valueOf.call(e),Number.prototype.valueOf.call(t)):wE(e)?wE(t)&&String.prototype.valueOf.call(e)===String.prototype.valueOf.call(t):EE(e)?EE(t)&&Boolean.prototype.valueOf.call(e)===Boolean.prototype.valueOf.call(t):xE(e)?xE(t)&&BigInt.prototype.valueOf.call(e)===BigInt.prototype.valueOf.call(t):LM(t)&&Symbol.prototype.valueOf.call(e)===Symbol.prototype.valueOf.call(t)}function Rr(e,t,r,n){if(e===t)return e!==0?!0:r?RE(e,t):!0;if(r){if(Or(e)!=="object")return typeof e=="number"&&ep(e)&&ep(t);if(Or(t)!=="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1}else{if(e===null||Or(e)!=="object")return t===null||Or(t)!=="object"?e==t:!1;if(t===null||Or(t)!=="object")return!1}var i=vE(e),o=vE(t);if(i!==o)return!1;if(Array.isArray(e)){if(e.length!==t.length)return!1;var s=dc(e,pc),a=dc(t,pc);return s.length!==a.length?!1:Ra(e,t,r,n,np,s)}if(i==="[object Object]"&&(!lc(e)&&lc(t)||!hc(e)&&hc(t)))return!1;if(bE(e)){if(!bE(t)||Date.prototype.getTime.call(e)!==Date.prototype.getTime.call(t))return!1}else if(_E(e)){if(!_E(t)||!jM(e,t))return!1}else if(kM(e)||e instanceof Error){if(e.message!==t.message||e.name!==t.name)return!1}else if(MM(e)){if(!r&&(DM(e)||UM(e))){if(!KM(e,t))return!1}else if(!VM(e,t))return!1;var c=dc(e,pc),h=dc(t,pc);return c.length!==h.length?!1:Ra(e,t,r,n,tp,c)}else{if(hc(e))return!hc(t)||e.size!==t.size?!1:Ra(e,t,r,n,PE);if(lc(e))return!lc(t)||e.size!==t.size?!1:Ra(e,t,r,n,BE);if(NM(e)){if(!GM(e,t))return!1}else if(CM(e)&&!zM(e,t))return!1}return Ra(e,t,r,n,tp)}function IE(e,t){return t.filter(function(r){return yc(e,r)})}function Ra(e,t,r,n,i,o){if(arguments.length===5){o=Object.keys(e);var s=Object.keys(t);if(o.length!==s.length)return!1}for(var a=0;a<o.length;a++)if(!Ta(t,o[a]))return!1;if(r&&arguments.length===5){var c=gc(e);if(c.length!==0){var h=0;for(a=0;a<c.length;a++){var g=c[a];if(yc(e,g)){if(!yc(t,g))return!1;o.push(g),h++}else if(yc(t,g))return!1}var y=gc(t);if(c.length!==y.length&&IE(t,y).length!==h)return!1}else{var w=gc(t);if(w.length!==0&&IE(t,w).length!==0)return!1}}if(o.length===0&&(i===tp||i===np&&e.length===0||e.size===0))return!0;if(n===void 0)n={val1:new Map,val2:new Map,position:0};else{var I=n.val1.get(e);if(I!==void 0){var T=n.val2.get(t);if(T!==void 0)return I===T}n.position++}n.val1.set(e,n.position),n.val2.set(t,n.position);var M=XM(e,t,r,o,n,i);return n.val1.delete(e),n.val2.delete(t),M}function AE(e,t,r,n){for(var i=mc(e),o=0;o<i.length;o++){var s=i[o];if(Rr(t,s,r,n))return e.delete(s),!0}return!1}function NE(e){switch(Or(e)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":e=+e;case"number":if(ep(e))return!1}return!0}function WM(e,t,r){var n=NE(r);return n??(t.has(n)&&!e.has(n))}function YM(e,t,r,n,i){var o=NE(r);if(o!=null)return o;var s=t.get(o);return s===void 0&&!t.has(o)||!Rr(n,s,!1,i)?!1:!e.has(o)&&Rr(n,s,!1,i)}function $M(e,t,r,n){for(var i=null,o=mc(e),s=0;s<o.length;s++){var a=o[s];if(Or(a)==="object"&&a!==null)i===null&&(i=new Set),i.add(a);else if(!t.has(a)){if(r||!WM(e,t,a))return!1;i===null&&(i=new Set),i.add(a)}}if(i!==null){for(var c=mc(t),h=0;h<c.length;h++){var g=c[h];if(Or(g)==="object"&&g!==null){if(!AE(i,g,r,n))return!1}else if(!r&&!e.has(g)&&!AE(i,g,r,n))return!1}return i.size===0}return!0}function OE(e,t,r,n,i,o){for(var s=mc(e),a=0;a<s.length;a++){var c=s[a];if(Rr(r,c,i,o)&&Rr(n,t.get(c),i,o))return e.delete(c),!0}return!1}function ZM(e,t,r,n){for(var i=null,o=mE(e),s=0;s<o.length;s++){var a=gE(o[s],2),c=a[0],h=a[1];if(Or(c)==="object"&&c!==null)i===null&&(i=new Set),i.add(c);else{var g=t.get(c);if(g===void 0&&!t.has(c)||!Rr(h,g,r,n)){if(r||!YM(e,t,c,h,n))return!1;i===null&&(i=new Set),i.add(c)}}}if(i!==null){for(var y=mE(t),w=0;w<y.length;w++){var I=gE(y[w],2),T=I[0],M=I[1];if(Or(T)==="object"&&T!==null){if(!OE(i,e,T,M,r,n))return!1}else if(!r&&(!e.has(T)||!Rr(e.get(T),M,!1,n))&&!OE(i,e,T,M,!1,n))return!1}return i.size===0}return!0}function XM(e,t,r,n,i,o){var s=0;if(o===PE){if(!$M(e,t,r,i))return!1}else if(o===BE){if(!ZM(e,t,r,i))return!1}else if(o===np)for(;s<e.length;s++)if(Ta(e,s)){if(!Ta(t,s)||!Rr(e[s],t[s],r,i))return!1}else{if(Ta(t,s))return!1;for(var a=Object.keys(e);s<a.length;s++){var c=a[s];if(!Ta(t,c)||!Rr(e[c],t[c],r,i))return!1}return a.length===Object.keys(t).length}for(s=0;s<n.length;s++){var h=n[s];if(!Rr(e[h],t[h],r,i))return!1}return!0}function JM(e,t){return Rr(e,t,HM)}function QM(e,t){return Rr(e,t,qM)}ME.exports={isDeepEqual:JM,isDeepStrictEqual:QM}});var oc=P((AF,JE)=>{"use strict";m();function Fr(e){"@babel/helpers - typeof";return Fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fr(e)}function CE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,t6(n.key),n)}}function e6(e,t,r){return t&&CE(e.prototype,t),r&&CE(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function t6(e){var t=r6(e,"string");return Fr(t)==="symbol"?t:String(t)}function r6(e,t){if(Fr(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(Fr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function n6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i6=jd(),Pa=i6.codes,LE=Pa.ERR_AMBIGUOUS_ARGUMENT,ns=Pa.ERR_INVALID_ARG_TYPE,o6=Pa.ERR_INVALID_ARG_VALUE,s6=Pa.ERR_INVALID_RETURN_VALUE,ci=Pa.ERR_MISSING_ARGS,li=ww(),a6=en(),vc=a6.inspect,qE=en().types,u6=qE.isPromise,bc=qE.isRegExp,f6=Kw()(),HE=cc()(),_c=Zw()("RegExp.prototype.test"),fi,Sc;function Ba(){var e=kE();fi=e.isDeepEqual,Sc=e.isDeepStrictEqual}var DE=!1,Ge=JE.exports=ip,wc={};function qr(e){throw e.message instanceof Error?e.message:new li(e)}function jE(e,t,r,n,i){var o=arguments.length,s;if(o===0)s="Failed";else if(o===1)r=e,e=void 0;else{if(DE===!1){DE=!0;var a=x.default.emitWarning?x.default.emitWarning:console.warn.bind(console);a("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")}o===2&&(n="!=")}if(r instanceof Error)throw r;var c={actual:e,expected:t,operator:n===void 0?"fail":n,stackStartFn:i||jE};r!==void 0&&(c.message=r);var h=new li(c);throw s&&(h.message=s,h.generatedMessage=!0),h}Ge.fail=jE;Ge.AssertionError=li;function KE(e,t,r,n){if(!r){var i=!1;if(t===0)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new li({actual:r,expected:!0,message:n,operator:"==",stackStartFn:e});throw o.generatedMessage=i,o}}function ip(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];KE.apply(void 0,[ip,t.length].concat(t))}Ge.ok=ip;Ge.equal=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t!=r&&qr({actual:t,expected:r,message:n,operator:"==",stackStartFn:e})};Ge.notEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");t==r&&qr({actual:t,expected:r,message:n,operator:"!=",stackStartFn:e})};Ge.deepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)||qr({actual:t,expected:r,message:n,operator:"deepEqual",stackStartFn:e})};Ge.notDeepEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),fi(t,r)&&qr({actual:t,expected:r,message:n,operator:"notDeepEqual",stackStartFn:e})};Ge.deepStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),Sc(t,r)||qr({actual:t,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:e})};Ge.notDeepStrictEqual=VE;function VE(e,t,r){if(arguments.length<2)throw new ci("actual","expected");fi===void 0&&Ba(),Sc(e,t)&&qr({actual:e,expected:t,message:r,operator:"notDeepStrictEqual",stackStartFn:VE})}Ge.strictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");HE(t,r)||qr({actual:t,expected:r,message:n,operator:"strictEqual",stackStartFn:e})};Ge.notStrictEqual=function e(t,r,n){if(arguments.length<2)throw new ci("actual","expected");HE(t,r)&&qr({actual:t,expected:r,message:n,operator:"notStrictEqual",stackStartFn:e})};var UE=e6(function e(t,r,n){var i=this;n6(this,e),r.forEach(function(o){o in t&&(n!==void 0&&typeof n[o]=="string"&&bc(t[o])&&_c(t[o],n[o])?i[o]=n[o]:i[o]=t[o])})});function c6(e,t,r,n,i,o){if(!(r in e)||!Sc(e[r],t[r])){if(!n){var s=new UE(e,i),a=new UE(t,i,e),c=new li({actual:s,expected:a,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=e,c.expected=t,c.operator=o.name,c}qr({actual:e,expected:t,message:n,operator:o.name,stackStartFn:o})}}function GE(e,t,r,n){if(typeof t!="function"){if(bc(t))return _c(t,e);if(arguments.length===2)throw new ns("expected",["Function","RegExp"],t);if(Fr(e)!=="object"||e===null){var i=new li({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:n});throw i.operator=n.name,i}var o=Object.keys(t);if(t instanceof Error)o.push("name","message");else if(o.length===0)throw new o6("error",t,"may not be an empty object");return fi===void 0&&Ba(),o.forEach(function(s){typeof e[s]=="string"&&bc(t[s])&&_c(t[s],e[s])||c6(e,t,s,r,o,n)}),!0}return t.prototype!==void 0&&e instanceof t?!0:Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function zE(e){if(typeof e!="function")throw new ns("fn","Function",e);try{e()}catch(t){return t}return wc}function FE(e){return u6(e)||e!==null&&Fr(e)==="object"&&typeof e.then=="function"&&typeof e.catch=="function"}function WE(e){return Promise.resolve().then(function(){var t;if(typeof e=="function"){if(t=e(),!FE(t))throw new s6("instance of Promise","promiseFn",t)}else if(FE(e))t=e;else throw new ns("promiseFn",["Function","Promise"],e);return Promise.resolve().then(function(){return t}).then(function(){return wc}).catch(function(r){return r})})}function YE(e,t,r,n){if(typeof r=="string"){if(arguments.length===4)throw new ns("error",["Object","Error","Function","RegExp"],r);if(Fr(t)==="object"&&t!==null){if(t.message===r)throw new LE("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new LE("error/message",'The error "'.concat(t,'" is identical to the message.'));n=r,r=void 0}else if(r!=null&&Fr(r)!=="object"&&typeof r!="function")throw new ns("error",["Object","Error","Function","RegExp"],r);if(t===wc){var i="";r&&r.name&&(i+=" (".concat(r.name,")")),i+=n?": ".concat(n):".";var o=e.name==="rejects"?"rejection":"exception";qr({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(o).concat(i),stackStartFn:e})}if(r&&!GE(t,r,n,e))throw t}function $E(e,t,r,n){if(t!==wc){if(typeof r=="string"&&(n=r,r=void 0),!r||GE(t,r)){var i=n?": ".concat(n):".",o=e.name==="doesNotReject"?"rejection":"exception";qr({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(i,`
|
|
61
61
|
`)+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}Ge.throws=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];YE.apply(void 0,[e,zE(t)].concat(n))};Ge.rejects=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return WE(t).then(function(o){return YE.apply(void 0,[e,o].concat(n))})};Ge.doesNotThrow=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];$E.apply(void 0,[e,zE(t)].concat(n))};Ge.doesNotReject=function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return WE(t).then(function(o){return $E.apply(void 0,[e,o].concat(n))})};Ge.ifError=function e(t){if(t!=null){var r="ifError got unwanted exception: ";Fr(t)==="object"&&typeof t.message=="string"?t.message.length===0&&t.constructor?r+=t.constructor.name:r+=t.message:r+=vc(t);var n=new li({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),i=t.stack;if(typeof i=="string"){var o=i.split(`
|
|
62
62
|
`);o.shift();for(var s=n.stack.split(`
|
|
63
63
|
`),a=0;a<o.length;a++){var c=s.indexOf(o[a]);if(c!==-1){s=s.slice(0,c);break}}n.stack="".concat(s.join(`
|
|
@@ -66,5 +66,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
66
66
|
`))}throw n}};function ZE(e,t,r,n,i){if(!bc(t))throw new ns("regexp","RegExp",t);var o=i==="match";if(typeof e!="string"||_c(t,e)!==o){if(r instanceof Error)throw r;var s=!r;r=r||(typeof e!="string"?'The "string" argument must be of type string. Received type '+"".concat(Fr(e)," (").concat(vc(e),")"):(o?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(vc(t),`. Input:
|
|
67
67
|
|
|
68
68
|
`).concat(vc(e),`
|
|
69
|
-
`));var a=new li({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Ge.match=function e(t,r,n){ZE(t,r,n,e,"match")};Ge.doesNotMatch=function e(t,r,n){ZE(t,r,n,e,"doesNotMatch")};function XE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];KE.apply(void 0,[XE,t.length].concat(t))}Ge.strict=f6(XE,Ge,{equal:Ge.strictEqual,deepEqual:Ge.deepStrictEqual,notEqual:Ge.notStrictEqual,notDeepEqual:Ge.notDeepStrictEqual});Ge.strict.strict=Ge.strict});var Qi=P((RF,e1)=>{"use strict";m();var QE=oc(),tt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};tt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};tt.prototype.toBuffer=function(){return this.concat()};tt.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};tt.prototype.write=function(e){return QE(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};tt.prototype.writeReverse=function(e){return QE(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};tt.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};tt.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};tt.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};tt.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};tt.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};tt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};tt.prototype.writeVarintNum=function(e){var t=tt.varintBufNum(e);return this.write(t),this};tt.prototype.writeVarintBN=function(e){var t=tt.varintBufBN(e);return this.write(t),this};tt.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};tt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new tt;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};e1.exports=tt});var sp=P((PF,t1)=>{"use strict";m();var is=Ve(),Na=ke(),l6=pr();function Pe(e){if(!(this instanceof Pe))return new Pe(e);var t;if(is.isNumber(e))t=e;else if(is.isString(e))t=Pe.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return l6.defineImmutable(this,{num:t}),this}Pe.fromBuffer=function(e){return Na.checkArgument(d.Buffer.isBuffer(e)),new Pe(+("0x"+e.toString("hex")))};Pe.fromNumber=function(e){return Na.checkArgument(is.isNumber(e)),new Pe(e)};Pe.fromString=function(e){Na.checkArgument(is.isString(e));var t=Pe.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Pe(t)};Pe.prototype.toHex=function(){return this.num.toString(16)};Pe.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Pe.prototype.toNumber=function(){return this.num};Pe.prototype.toString=function(){var e=Pe.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Pe.smallInt=function(e){return Na.checkArgument(is.isNumber(e),"Invalid Argument: n should be number"),Na.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Pe("OP_0"):new Pe(Pe.map.OP_1+e-1)};Pe.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Pe.reverseMap=[];for(op in Pe.map)Pe.reverseMap[Pe.map[op]]=op;var op;is.extend(Pe,Pe.map);Pe.isSmallIntOp=function(e){return e instanceof Pe&&(e=e.toNumber()),e===Pe.map.OP_0||e>=Pe.map.OP_1&&e<=Pe.map.OP_16};Pe.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};t1.exports=Pe});var ir=P((NF,n1)=>{"use strict";m();var eo=Er(),h6=Ve(),nr=ke(),d6=pr(),Ie=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof eo)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Ie.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ie.fromCompact=function(e){nr.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ie,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return nr.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),nr.checkArgument(i.length===32,new Error("r must be 32 bytes")),nr.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=eo.fromBuffer(i),t.s=eo.fromBuffer(o),t};Ie.fromDER=Ie.fromBuffer=function(e,t){var r=Ie.parseDER(e,t),n=new Ie;return n.r=r.r,n.s=r.s,n};Ie.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Ie.fromDER(r,!1);return n.nhashtype=t,n};Ie.fromString=function(e){var t=d.Buffer.from(e,"hex");return Ie.fromDER(t)};function r1(e,t){nr.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),nr.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),nr.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ie.parseDER=function(e,t){nr.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),h6.isUndefined(t)&&(t=!0);var r=e[0];nr.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;nr.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];nr.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),c=eo.fromBuffer(a),h=e[4]===0;nr.checkArgument(s===a.length,new Error("Length of r incorrect"));var g=e[4+s+0];nr.checkArgument(g===2,new Error("Integer byte for s should be 0x02"));var y=e[4+s+1],w=e.slice(4+s+2,4+s+2+y),I=eo.fromBuffer(w),T=e[4+s+2]===0;nr.checkArgument(y===w.length,new Error("Length of s incorrect"));var M=4+s+2+y;nr.checkArgument(n===M-2,new Error("Length of signature incorrect")),t&&(r1("r",a),r1("s",w));var L={header:r,length:n,rheader:o,rlength:s,rneg:h,rbuf:a,r:c,sheader:g,slength:y,sneg:T,sbuf:w,s:I};return L};Ie.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Ie.prototype.toBuffer=Ie.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,c=2+s+2+a,h=2,g=2,y=48,w=d.Buffer.concat([d.Buffer.from([y,c,h,s]),i,d.Buffer.from([g,a]),o]);return w};Ie.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ie.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Ie.prototype.hasLowS=function(){return!(this.s.lt(new eo(1))||this.s.gt(new eo("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ie.prototype.hasDefinedHashtype=function(){if(!d6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ie.SIGHASH_ALL||e>Ie.SIGHASH_SINGLE)};Ie.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Ie.SIGHASH_ALL=1;Ie.SIGHASH_NONE=2;Ie.SIGHASH_SINGLE=3;Ie.SIGHASH_CHRONICLE=32;Ie.SIGHASH_FORKID=64;Ie.SIGHASH_ANYONECANPAY=128;Ie.prototype.isCanonical=function(){var e=ii(),t=e.getN().shrn(1);return this.s.lte(t)};Ie.prototype.toCanonical=function(){if(this.isCanonical())return new Ie({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ii(),t=e.getN(),r=t.sub(this.s);return new Ie({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ie.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ii(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ie.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ie.prototype.applySecurityPatches=function(){var e=ii(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};n1.exports=Ie});var fp=P((kF,s1)=>{"use strict";m();var Hr=no(),p6=va(),g6=Qi(),ap=Qt(),X=sp(),ro=Tr(),to=ir(),i1=ga(),$e=ke(),Ae=Ve(),up=Jn(),o1=Tt(),y6=pr(),D=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Hr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Ae.isString(t))return e.fromString(t);Ae.isObject(t)&&Ae.isArray(t.chunks)&&this.set(t)};D.prototype.set=function(e){return $e.checkArgument(Ae.isObject(e)),$e.checkArgument(Ae.isArray(e.chunks)),this.chunks=e.chunks,this};D.fromBuffer=function(e){var t=new D;t.chunks=[];for(var r=new p6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<X.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===X.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new up.Script.InvalidBuffer(e.toString("hex")):s}return t};D.prototype.toBuffer=function(){for(var e=new g6,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<X.OP_PUSHDATA1?e.write(r.buf):n===X.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===X.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===X.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};D.fromASM=function(e){var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=X.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Ae.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=a.length;c>=0&&c<X.OP_PUSHDATA1?s=c:c<Math.pow(2,8)?s=X.OP_PUSHDATA1:c<Math.pow(2,16)?s=X.OP_PUSHDATA2:c<Math.pow(2,32)&&(s=X.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.fromHex=function(e){return new D(o1.Buffer.from(e,"hex"))};D.fromString=function(e){if(y6.isHexa(e)||e.length===0)return new D(o1.Buffer.from(e,"hex"));var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber();if(Ae.isUndefined(s))if(s=parseInt(i),s>0&&s<X.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===X.OP_PUSHDATA1||s===X.OP_PUSHDATA2||s===X.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===X.OP_PUSHDATA1||r===X.OP_PUSHDATA2||r===X.OP_PUSHDATA4)&&(i=i+" "+X(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof X.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+X(r).toString():i=i+" "+X(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};D.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};D.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};D.prototype.toHex=function(){return this.toBuffer().toString("hex")};D.prototype.inspect=function(){return"<Script: "+this.toString()+">"};D.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};D.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};D.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};D.prototype.getPublicKey=function(){return $e.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};D.prototype.getPublicKeyHash=function(){return $e.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};D.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===X.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return ro.isValid(e)}return!1};D.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};D.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===X.OP_HASH160&&e[1]===20&&e[e.length-1]===X.OP_EQUAL};D.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=D.fromBuffer(t)}catch(i){if(i instanceof up.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==D.types.UNKNOWN};D.prototype.isMultisigOut=function(){return this.chunks.length>3&&X.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&X.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===X.OP_CHECKMULTISIG};D.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&to.isTxDER(e.buf)})};D.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===X.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new D({chunks:t});return r.isPushOnly()};D.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==X.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new D({chunks:e});return t.isDataOut()};D.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Ae.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};D.prototype.isPushOnly=function(){return Ae.every(this.chunks,function(e){return e.opcodenum<=X.OP_16||e.opcodenum===X.OP_PUSHDATA1||e.opcodenum===X.OP_PUSHDATA2||e.opcodenum===X.OP_PUSHDATA4})};D.types={};D.types.UNKNOWN="Unknown";D.types.PUBKEY_OUT="Pay to public key";D.types.PUBKEY_IN="Spend from public key";D.types.PUBKEYHASH_OUT="Pay to public key hash";D.types.PUBKEYHASH_IN="Spend from public key hash";D.types.SCRIPTHASH_OUT="Pay to script hash";D.types.SCRIPTHASH_IN="Spend from script hash";D.types.MULTISIG_OUT="Pay to multisig";D.types.MULTISIG_IN="Spend from multisig";D.types.DATA_OUT="Data push";D.types.SAFE_DATA_OUT="Safe data push";D.OP_RETURN_STANDARD_SIZE=220;D.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==D.types.UNKNOWN?e:this.classifyInput()};D.outputIdentifiers={};D.outputIdentifiers.PUBKEY_OUT=D.prototype.isPublicKeyOut;D.outputIdentifiers.PUBKEYHASH_OUT=D.prototype.isPublicKeyHashOut;D.outputIdentifiers.MULTISIG_OUT=D.prototype.isMultisigOut;D.outputIdentifiers.SCRIPTHASH_OUT=D.prototype.isScriptHashOut;D.outputIdentifiers.DATA_OUT=D.prototype.isDataOut;D.outputIdentifiers.SAFE_DATA_OUT=D.prototype.isSafeDataOut;D.prototype.classifyOutput=function(){for(var e in D.outputIdentifiers)if(D.outputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.inputIdentifiers={};D.inputIdentifiers.PUBKEY_IN=D.prototype.isPublicKeyIn;D.inputIdentifiers.PUBKEYHASH_IN=D.prototype.isPublicKeyHashIn;D.inputIdentifiers.MULTISIG_IN=D.prototype.isMultisigIn;D.inputIdentifiers.SCRIPTHASH_IN=D.prototype.isScriptHashIn;D.prototype.classifyInput=function(){for(var e in D.inputIdentifiers)if(D.inputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.prototype.isStandard=function(){return this.classify()!==D.types.UNKNOWN};D.prototype.prepend=function(e){return this._addByType(e,!0),this};D.prototype.equals=function(e){if($e.checkState(e instanceof D,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};D.prototype.add=function(e){return this._addByType(e,!1),this};D.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof X)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof D)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};D.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};D.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof X?r=e.toNumber():r=X(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};D.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<X.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=X.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=X.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=X.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};D.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==X.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};D.buildMultisigOut=function(e,t,r){$e.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new D;n.add(X.smallInt(t)),e=Ae.map(e,ro);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new ro(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(X.smallInt(e.length)),n.add(X.OP_CHECKMULTISIG),n};D.buildMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(X.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};D.buildP2SHMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(X.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||D.buildMultisigOut(e,t,n)).toBuffer()),i};D.buildPublicKeyHashOut=function(e){$e.checkArgument(!Ae.isUndefined(e)),$e.checkArgument(e instanceof ro||e instanceof Hr||Ae.isString(e)),e instanceof ro?e=e.toAddress():Ae.isString(e)&&(e=new Hr(e));var t=new D;return t.add(X.OP_DUP).add(X.OP_HASH160).add(e.hashBuffer).add(X.OP_EQUALVERIFY).add(X.OP_CHECKSIG),t._network=e.network,t};D.buildPublicKeyOut=function(e){$e.checkArgument(e instanceof ro);var t=new D;return t.add(e.toBuffer()).add(X.OP_CHECKSIG),t};D.buildDataOut=function(e,t){$e.checkArgument(Ae.isUndefined(e)||Ae.isString(e)||Ae.isArray(e)||d.Buffer.isBuffer(e));var r=e;Ae.isArray(r)||(r=[e]);var n=new D;n.add(X.OP_RETURN);for(let i of r)$e.checkArgument(Ae.isUndefined(i)||Ae.isString(i)||d.Buffer.isBuffer(i)),Ae.isString(i)&&(i=d.Buffer.from(i,t)),Ae.isUndefined(i)||n.add(i);return n};D.buildSafeDataOut=function(e,t){var r=D.buildDataOut(e,t),n=new D;return n.add(X.OP_FALSE),n.add(r),n};D.buildScriptHashOut=function(e){$e.checkArgument(e instanceof D||e instanceof Hr&&e.isPayToScriptHash());var t=new D;return t.add(X.OP_HASH160).add(e instanceof Hr?e.hashBuffer:ap.sha256ripemd160(e.toBuffer())).add(X.OP_EQUAL),t._network=e._network||e.network,t};D.buildPublicKeyIn=function(e,t){$e.checkArgument(e instanceof to||d.Buffer.isBuffer(e)),$e.checkArgument(Ae.isUndefined(t)||Ae.isNumber(t)),e instanceof to&&(e=e.toBuffer());var r=new D;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||to.SIGHASH_ALL)&255])])),r};D.buildPublicKeyHashIn=function(e,t,r){$e.checkArgument(t instanceof to||d.Buffer.isBuffer(t)),$e.checkArgument(Ae.isUndefined(r)||Ae.isNumber(r)),t instanceof to&&(t=t.toBuffer());var n=new D().add(d.Buffer.concat([t,d.Buffer.from([(r||to.SIGHASH_ALL)&255])])).add(new ro(e).toBuffer());return n};D.empty=function(){return new D};D.prototype.toScriptHashOut=function(){return D.buildScriptHashOut(this)};D.fromAddress=function(e){if(e=Hr(e),e.isPayToScriptHash())return D.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return D.buildPublicKeyHashOut(e);throw new up.Script.UnrecognizedAddress(e)};D.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};D.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToPublicKeyHash;else return!1;return e};D.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[1].buf),e.type=Hr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Hr.PayToScriptHash;else return!1;return e};D.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=i1.get(e)||this._network||i1.defaultNetwork,new Hr(t)):!1};D.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=D({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};D.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===X.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===X.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===X.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===X.OP_PUSHDATA1:r.length<=65535?n===X.OP_PUSHDATA2:!0:!0};D.prototype._decodeOP_N=function(e){if(e===X.OP_0)return 0;if(e>=X.OP_1&&e<=X.OP_16)return e-(X.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};D.prototype.getSignatureOperationsCount=function(e){e=Ae.isUndefined(e)?!0:e;var t=this,r=0,n=X.OP_INVALIDOPCODE;return Ae.each(t.chunks,function(o){var s=o.opcodenum;s===X.OP_CHECKSIG||s===X.OP_CHECKSIGVERIFY?r++:(s===X.OP_CHECKMULTISIG||s===X.OP_CHECKMULTISIGVERIFY)&&(e&&n>=X.OP_1&&n<=X.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};s1.exports=D});var Ma=P((LF,f1)=>{"use strict";m();var a1=Qi(),u1=va(),m6=Er(),jr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof m6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};jr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};jr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};jr.prototype.toString=function(){return this.buf.toString("hex")};jr.prototype.fromBuffer=function(e){return this.buf=e,this};jr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};jr.prototype.fromBN=function(e){return this.buf=a1().writeVarintBN(e).concat(),this};jr.prototype.fromNumber=function(e){return this.buf=a1().writeVarintNum(e).concat(),this};jr.prototype.toBuffer=function(){return this.buf};jr.prototype.toBN=function(){return u1(this.buf).readVarintBN()};jr.prototype.toNumber=function(){return u1(this.buf).readVarintNum()};f1.exports=jr});var Dn=P((UF,l1)=>{"use strict";m();var Ec=Ve(),cp=Er(),c1=Tt(),xc=pr(),v6=Qi(),b6=Ma(),lp=Kr(),hp=ke(),_6=Jn(),S6=9007199254740991;function Ut(e){if(!(this instanceof Ut))return new Ut(e);if(Ec.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Ec.isString(e.script)&&xc.isHexa(e.script)?t=c1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ut.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ut.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof cp?(this._satoshisBN=e,this._satoshis=e.toNumber()):Ec.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=cp.fromNumber(this._satoshis)):(hp.checkArgument(xc.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=cp.fromNumber(e),this._satoshis=e),hp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.invalidSatoshis=function(){return this._satoshis>S6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ut.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),hp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.toObject=Ut.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ut.fromObject=function(e){return new Ut(e)};Ut.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=lp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof _6.Script.InvalidBuffer)this._script=null;else throw t}};Ut.prototype.setScript=function(e){if(e instanceof lp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Ec.isString(e))this._script=lp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ut.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ut.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=c1.Buffer.from([]),new Ut(t)};Ut.prototype.toBufferWriter=function(e){e||(e=new v6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ut.prototype.getSize=function(){var e=this.script.toBuffer().length,t=b6(e).toBuffer().length;return 8+t+e};l1.exports=Ut});var ka=P((qF,h1)=>{"use strict";m();var gr=Er(),cn=ii(),w6=ir(),E6=Tr(),x6=ea(),hi=Qt(),I6=Ve(),dp=ke(),qe=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(qe.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});qe.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=ir();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};qe.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};qe.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};qe.fromString=function(e){var t=JSON.parse(e);return new qe(t)};qe.prototype.randomK=function(){var e=cn.getN(),t;do t=gr.fromBuffer(x6.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(gr.Zero)));return this.k=t,this};qe.prototype.deterministicK=function(e){I6.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=hi.sha256hmac(t,r),r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r);for(var o=gr.fromBuffer(t),s=cn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(gr.Zero));a++)r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r),o=gr.fromBuffer(t);return this.k=o,this};qe.prototype.toPublicKey=function(){var e=this.sig.i;dp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=gr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=cn.getN(),a=cn.getG(),c=o?r.add(s):r,h=cn.fromX(i,c),g=h.mul(s);if(!g.isInfinity())throw new Error("nR is not a valid curve point");var y=t.neg().umod(s),w=r.invm(s),I=h.mul(n).add(a.mul(y)).mul(w),T=E6.fromPoint(I,this.sig.compressed);return T};qe.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=cn.getN();try{if(e.lte(gr.Zero)||t.lte(gr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=gr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=cn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(c){return"Signature security validation failed: "+c.message}};qe.toLowS=function(e){return e.gt(gr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=cn.getN().sub(e)),e};qe.prototype._findSignature=function(e,t){var r=cn.getN(),n=cn.getG(),i=0,o,s,a,c;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),c=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(gr.Zero)<=0||c.cmp(gr.Zero)<=0);return this._kFresh=!1,c=qe.toLowS(c),{s:c,r:a}};qe.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;dp.checkState(e&&t&&r,new Error("invalid parameters")),dp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=gr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new w6(i),this};qe.prototype.signRandomK=function(){return this.randomK(),this.sign()};qe.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};qe.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};qe.prototype.verifyBool=function(){return this.verify()===!0};qe.sign=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().sig};qe.signWithCalcI=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};qe.signRandomK=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};qe.verify=function(e,t,r,n){return qe().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};h1.exports=qe});var os=P((jF,y1)=>{"use strict";m();var di=Ve(),A6=ke(),Ca=Jn(),O6=Qi(),pp=Tt(),p1=pr(),Ic=Kr(),R6=pi(),d1=Dn(),Ac=4294967295,T6=Ac-2,g1=Ac,P6=Ac-1;function He(e){if(!(this instanceof He))return new He(e);if(e)return this._fromObject(e)}He.MAXINT=Ac;He.DEFAULT_SEQNUMBER=g1;He.DEFAULT_LOCKTIME_SEQNUMBER=P6;He.DEFAULT_RBF_SEQNUMBER=T6;He.BASE_SIZE=40;Object.defineProperty(He.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Ic(this._scriptBuffer),this._script._isInput=!0),this._script)}});He.fromObject=function(e){A6.checkArgument(di.isObject(e));var t=new He;return t._fromObject(e)};He.prototype._fromObject=function(e){var t;if(di.isString(e.prevTxId)&&p1.isHexa(e.prevTxId)?t=pp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof d1?e.output:new d1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=di.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=di.isUndefined(e.sequenceNumber)?di.isUndefined(e.seqnum)?g1:e.seqnum:e.sequenceNumber,di.isUndefined(e.script)&&di.isUndefined(e.scriptBuffer))throw new Ca.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};He.prototype.toObject=He.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};He.fromBufferReader=function(e){var t=new He;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};He.prototype.toBufferWriter=function(e){e||(e=new O6),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};He.prototype.setScript=function(e){if(this._script=null,e instanceof Ic)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Ic.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(p1.isHexa(e))this._scriptBuffer=pp.Buffer.from(e,"hex");else if(di.isString(e))this._script=new Ic(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=pp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};He.prototype.getSignatures=function(){throw new Ca.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};He.prototype.isFullySigned=function(){throw new Ca.AbstractMethodInvoked("Input#isFullySigned")};He.prototype.isFinal=function(){return this.sequenceNumber===He.MAXINT};He.prototype.addSignature=function(){throw new Ca.AbstractMethodInvoked("Input#addSignature")};He.prototype.clearSignatures=function(){throw new Ca.AbstractMethodInvoked("Input#clearSignatures")};He.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,R6.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};He.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};He.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};y1.exports=He});var ss=P((VF,m1)=>{"use strict";m();m1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var us=P((zF,_1)=>{"use strict";m();var as=Ve(),Pr=ke(),B6=ss(),v1=pr(),b1=Tr(),N6=Jn(),La=ir();function Vr(e){if(!(this instanceof Vr))return new Vr(e);if(e instanceof Vr)return e;if(as.isObject(e))return this._fromObject(e);throw new N6.InvalidArgument("TransactionSignatures must be instantiated from an object")}B6(Vr,La);Vr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new b1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof La?e.signature:d.Buffer.isBuffer(e.signature)?La.fromBuffer(e.signature):La.fromString(e.signature),this.sigtype=e.sigtype,this};Vr.prototype._checkObjectArgs=function(e){Pr.checkArgument(b1(e.publicKey),"publicKey"),Pr.checkArgument(!as.isUndefined(e.inputIndex),"inputIndex"),Pr.checkArgument(!as.isUndefined(e.outputIndex),"outputIndex"),Pr.checkState(as.isNumber(e.inputIndex),"inputIndex must be a number"),Pr.checkState(as.isNumber(e.outputIndex),"outputIndex must be a number"),Pr.checkArgument(e.signature,"signature"),Pr.checkArgument(e.prevTxId,"prevTxId"),Pr.checkState(e.signature instanceof La||d.Buffer.isBuffer(e.signature)||v1.isHexa(e.signature),"signature must be a buffer or hexa value"),Pr.checkState(d.Buffer.isBuffer(e.prevTxId)||v1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Pr.checkArgument(e.sigtype,"sigtype"),Pr.checkState(as.isNumber(e.sigtype),"sigtype must be a number")};Vr.prototype.toObject=Vr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Vr.fromObject=function(e){return Pr.checkArgument(e),new Vr(e)};_1.exports=Vr});var I1=P((YF,x1)=>{"use strict";m();var M6=ss(),w1=ke(),gp=os(),k6=Dn(),C6=pi(),E1=Kr(),S1=ir(),L6=us();function Un(){gp.apply(this,arguments)}M6(Un,gp);Un.prototype.getSignatures=function(e,t,r,n){w1.checkState(this.output instanceof k6),n=n||S1.SIGHASH_ALL|S1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new L6({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:C6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Un.prototype.addSignature=function(e,t){return w1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(E1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Un.prototype.clearSignatures=function(){return this.setScript(E1.empty()),this};Un.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Un.SCRIPT_MAX_SIZE=74;Un.prototype._estimateSize=function(){return gp.BASE_SIZE+Un.SCRIPT_MAX_SIZE};x1.exports=Un});var P1=P((ZF,T1)=>{"use strict";m();var D6=ss(),O1=ke(),U6=Qt(),yp=os(),F6=Dn(),q6=pi(),R1=Kr(),A1=ir(),H6=us();function Fn(){yp.apply(this,arguments)}D6(Fn,yp);Fn.prototype.getSignatures=function(e,t,r,n,i){O1.checkState(this.output instanceof F6),i=i||U6.sha256ripemd160(t.publicKey.toBuffer()),n=n||A1.SIGHASH_ALL|A1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new H6({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:q6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Fn.prototype.addSignature=function(e,t){return O1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(R1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Fn.prototype.clearSignatures=function(){return this.setScript(R1.empty()),this};Fn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Fn.SCRIPT_MAX_SIZE=108;Fn.prototype._estimateSize=function(){return yp.BASE_SIZE+Fn.SCRIPT_MAX_SIZE};T1.exports=Fn});var M1=P((JF,N1)=>{"use strict";m();var Gr=Ve(),j6=ss(),Rc=os(),K6=Dn(),Da=ke(),B1=Kr(),Oc=ir(),mp=pi(),vp=us(),V6=Tr(),G6=Ma();function Pt(e,t,r,n){Rc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new V6(o)),Da.checkState(B1.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Gr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}j6(Pt,Rc);Pt.prototype.toObject=function(){var e=Rc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Gr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Pt.prototype._deserializeSignatures=function(e){return Gr.map(e,function(t){if(t)return new vp(t)})};Pt.prototype._serializeSignatures=function(){return Gr.map(this.signatures,function(e){if(e)return e.toObject()})};Pt.prototype.getSignatures=function(e,t,r,n){Da.checkState(this.output instanceof K6),n=n||Oc.SIGHASH_ALL|Oc.SIGHASH_FORKID;var i=this,o=[];return Gr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new vp({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:mp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Pt.prototype.addSignature=function(e,t){return Da.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Da.checkArgument(!Gr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Da.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Pt.prototype._updateScript=function(){return this.setScript(B1.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Pt.prototype._createSignatures=function(){return Gr.map(Gr.filter(this.signatures,function(e){return!Gr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Pt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Pt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Pt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Pt.prototype.countSignatures=function(){return Gr.reduce(this.signatures,function(e,t){return e+!!t},0)};Pt.prototype.publicKeysWithoutSignature=function(){var e=this;return Gr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Pt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,mp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Pt.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var c=new vp({signature:Oc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Oc.SIGHASH_ALL});c.signature.nhashtype=c.sigtype;var h=mp.verify(e,c.signature,c.publicKey,c.inputIndex,t.output.script);return h?(s=c,!1):!0}),s||null})};Pt.SIGNATURE_SIZE=73;Pt.prototype._estimateSize=function(){var e=1+this.threshold*Pt.SIGNATURE_SIZE;return Rc.BASE_SIZE+G6(e).toBuffer().length+e};N1.exports=Pt});var U1=P((e5,D1)=>{"use strict";m();var zr=Ve(),z6=ss(),Tc=os(),W6=Dn(),Ua=ke(),bp=Kr(),k1=ir(),C1=pi(),L1=us(),Y6=Tr(),$6=Ma();function Ot(e,t,r,n){Tc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Y6(o)),this.redeemScript=bp.buildMultisigOut(this.publicKeys,r),Ua.checkState(bp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},zr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}z6(Ot,Tc);Ot.prototype.toObject=function(){var e=Tc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=zr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ot.prototype._deserializeSignatures=function(e){return zr.map(e,function(t){if(t)return new L1(t)})};Ot.prototype._serializeSignatures=function(){return zr.map(this.signatures,function(e){if(e)return e.toObject()})};Ot.prototype.getSignatures=function(e,t,r,n){Ua.checkState(this.output instanceof W6),n=n||k1.SIGHASH_ALL|k1.SIGHASH_FORKID;var i=this,o=[];return zr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new L1({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:C1.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Ot.prototype.addSignature=function(e,t){return Ua.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Ua.checkArgument(!zr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Ua.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ot.prototype._updateScript=function(){return this.setScript(bp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Ot.prototype._createSignatures=function(){return zr.map(zr.filter(this.signatures,function(e){return!zr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ot.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ot.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ot.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ot.prototype.countSignatures=function(){return zr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ot.prototype.publicKeysWithoutSignature=function(){var e=this;return zr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ot.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,C1.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Ot.SIGNATURE_SIZE=73;Ot.PUBKEY_SIZE=34;Ot.prototype._estimateSize=function(){var e=this.publicKeys.length*Ot.PUBKEY_SIZE,t=this.threshold*Ot.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Tc.BASE_SIZE+$6(i).toBuffer().length+i};D1.exports=Ot});var Pc=P((r5,fs)=>{m();fs.exports=os();fs.exports.PublicKey=I1();fs.exports.PublicKeyHash=P1();fs.exports.MultiSig=M1();fs.exports.MultiSigScriptHash=U1()});var pi=P((i5,K1)=>{"use strict";m();var Z6=Tt(),fr=ir(),_p=Kr(),X6=Dn(),J6=va(),Fa=Qi(),F1=Er(),Bc=Qt(),q1=ka(),Sp=ke(),wp=Nc(),gi=Ve(),H1=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Q6="ffffffffffffffff",ek=wp.SCRIPT_ENABLE_SIGHASH_FORKID,tk=function(e,t,r,n,i){var o=e.inputs[r];Sp.checkArgument(i instanceof F1,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(M){var L=new Fa;gi.each(M.inputs,function(q){L.writeReverse(q.prevTxId),L.writeUInt32LE(q.outputIndex)});var j=L.toBuffer(),G=Bc.sha256sha256(j);return G}function a(M){var L=new Fa;gi.each(M.inputs,function(q){L.writeUInt32LE(q.sequenceNumber)});var j=L.toBuffer(),G=Bc.sha256sha256(j);return G}function c(M,L){var j=new Fa;gi.isUndefined(L)?gi.each(M.outputs,function(W){W.toBufferWriter(j)}):M.outputs[L].toBufferWriter(j);var G=j.toBuffer(),q=Bc.sha256sha256(G);return q}var h=d.Buffer.alloc(32),g=d.Buffer.alloc(32),y=d.Buffer.alloc(32);t&fr.SIGHASH_ANYONECANPAY||(h=s(e)),!(t&fr.SIGHASH_ANYONECANPAY)&&(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE&&(g=a(e)),(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE?y=c(e):(t&31)===fr.SIGHASH_SINGLE&&r<e.outputs.length&&(y=c(e,r));var w=new Fa;w.writeInt32LE(e.version),w.write(h),w.write(g),w.writeReverse(o.prevTxId),w.writeUInt32LE(o.outputIndex),w.writeVarintNum(n.toBuffer().length),w.write(n.toBuffer()),w.writeUInt64LEBN(i);var I=o.sequenceNumber;w.writeUInt32LE(I),w.write(y),w.writeUInt32LE(e.nLockTime),w.writeUInt32LE(t>>>0);var T=w.toBuffer();return T},j1=function(t,r,n,i,o,s){var a=xp(),c=Pc();gi.isUndefined(s)&&(s=ek);var h=a.shallowCopy(t);if(i=new _p(i),s&wp.SCRIPT_ENABLE_REPLAY_PROTECTION){var g=r>>8,y=16711680|g^57005;r=y<<8|r&255}if(r&fr.SIGHASH_FORKID&&!(r&fr.SIGHASH_CHRONICLE)&&s&wp.SCRIPT_ENABLE_SIGHASH_FORKID)return tk(h,r,n,i,o);i.removeCodeseparators();var w;for(w=0;w<h.inputs.length;w++)h.inputs[w]=new c(h.inputs[w]).setScript(_p.empty());if(h.inputs[n]=new c(h.inputs[n]).setScript(i),(r&31)===fr.SIGHASH_NONE||(r&31)===fr.SIGHASH_SINGLE)for(w=0;w<h.inputs.length;w++)w!==n&&(h.inputs[w].sequenceNumber=0);if((r&31)===fr.SIGHASH_NONE)h.outputs=[];else if((r&31)===fr.SIGHASH_SINGLE){if(n>=h.outputs.length)return H1;for(h.outputs.length=n+1,w=0;w<n;w++)h.outputs[w]=new X6({satoshis:F1.fromBuffer(Z6.Buffer.from(Q6,"hex")),script:_p.empty()})}r&fr.SIGHASH_ANYONECANPAY&&(h.inputs=[h.inputs[n]]);var I=new Fa().write(h.toBuffer()).writeInt32LE(r).toBuffer();return I},Ep=function(t,r,n,i,o,s){var a=j1(t,r,n,i,o,s);if(a.compare(H1)===0)return a;var c=Bc.sha256sha256(a);return c=new J6(c).readReverse(),c};function rk(e,t,r,n,i,o,s){var a=Ep(e,r,n,i,o,s),c=q1.sign(a,t,"little").set({nhashtype:r});return c}function nk(e,t,r,n,i,o,s){Sp.checkArgument(!gi.isUndefined(e)),Sp.checkArgument(!gi.isUndefined(t)&&!gi.isUndefined(t.nhashtype));var a=Ep(e,t.nhashtype,n,i,o,s);return q1.verify(a,t,r,"little")}K1.exports={sighashPreimage:j1,sighash:Ep,sign:rk,verify:nk}});var Ip=P((s5,G1)=>{"use strict";m();var qn=Ve(),Mc=ke(),V1=pr(),ik=Kr(),ok=no();function Hn(e){if(!(this instanceof Hn))return new Hn(e);Mc.checkArgument(qn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new ok(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!V1.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=qn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!qn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Mc.checkArgument(!qn.isUndefined(e.scriptPubKey)||!qn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new ik(e.scriptPubKey||e.script);Mc.checkArgument(!qn.isUndefined(e.amount)||!qn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=qn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Mc.checkArgument(qn.isNumber(o),"Amount must be a number"),V1.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Hn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Hn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Hn.fromObject=function(e){return new Hn(e)};Hn.prototype.toObject=Hn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};G1.exports=Hn});var xp=P((u5,Q1)=>{"use strict";m();var pe=Ve(),Ft=ke(),sk=Tt(),Nt=Jn(),W1=pr(),Y1=va(),ak=Qi(),z1=Ma(),$1=Qt(),Cc=ir(),Z1=pi(),uk=no(),X1=Ip(),Bt=Pc(),fk=Bt.PublicKeyHash,ck=Bt.PublicKey,lk=Bt.MultiSigScriptHash,hk=Bt.MultiSig,Wr=Dn(),ln=Kr(),dk=io(),kc=Er(),pk=Nc(),gk=pk.SCRIPT_ENABLE_SIGHASH_FORKID;function z(e){if(!(this instanceof z))return new z(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof z)return z.shallowCopy(e);if(W1.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(pe.isObject(e))this.fromObject(e);else throw new Nt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var yk=1,mk=0,vk=1e6;z.DUST_AMOUNT=546;z.FEE_SECURITY_MARGIN=150;z.MAX_MONEY=21e6*1e8;z.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;z.NLOCKTIME_MAX_VALUE=4294967295;z.FEE_PER_KB=500;z.CHANGE_OUTPUT_MAX_SIZE=62;z.shallowCopy=function(e){var t=new z(e.toBuffer());return t};var J1={configurable:!1,enumerable:!0,get:function(){return this._hash=new Y1(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(z.prototype,"hash",J1);Object.defineProperty(z.prototype,"id",J1);var Ap={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(z.prototype,"inputAmount",Ap);Ap.get=function(){return this._getOutputAmount()};Object.defineProperty(z.prototype,"outputAmount",Ap);z.prototype._getHash=function(){return $1.sha256sha256(this.toBuffer())};z.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};z.prototype.uncheckedSerialize=z.prototype.toString=function(){return this.toBuffer().toString("hex")};z.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};z.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};z.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Nt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Nt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};z.prototype._hasFeeError=function(e,t){if(!pe.isUndefined(this._fee)&&this._fee!==t)return new Nt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(z.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Nt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Nt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};z.prototype._missingChange=function(){return!this._changeScript};z.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<z.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Nt.Transaction.DustOutputs}};z.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Nt.Transaction.MissingSignatures};z.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};z.prototype.toBuffer=function(){var e=new ak;return this.toBufferWriter(e).toBuffer()};z.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),pe.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),pe.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};z.prototype.fromBuffer=function(e){var t=new Y1(e);return this.fromBufferReader(t)};z.prototype.fromBufferReader=function(e){Ft.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Bt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Wr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};z.prototype.toObject=z.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),pe.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),pe.isUndefined(this._fee)||(n.fee=this._fee),n};z.prototype.fromObject=function(t){Ft.checkArgument(pe.isObject(t)||t instanceof z);var r=this,n;return t instanceof z?n=t.toObject():n=t,pe.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Bt(i));return}var o=new ln(i.output.script),s;if(o.isPublicKeyHashOut())s=new Bt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Bt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Bt.PublicKey(i);else throw new Nt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),pe.each(n.outputs,function(i){r.addOutput(new Wr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new ln(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};z.prototype._checkConsistency=function(e){pe.isUndefined(this._changeIndex)||(Ft.checkState(this._changeScript,"Change script is expected."),Ft.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Ft.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Ft.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};z.prototype.lockUntilDate=function(e){if(Ft.checkArgument(e),pe.isNumber(e)&&e<z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.LockTimeTooEarly;pe.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};z.prototype.lockUntilBlockHeight=function(e){if(Ft.checkArgument(pe.isNumber(e)),e>=z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.BlockHeightTooHigh;if(e<0)throw new Nt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};z.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<z.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};z.prototype.fromString=function(e){this.fromBuffer(sk.Buffer.from(e,"hex"))};z.prototype._newTransaction=function(){this.version=yk,this.nLockTime=mk};z.prototype.from=function(e,t,r){if(pe.isArray(e)){var n=this;return pe.each(e,function(o){n.from(o,t,r)}),this}var i=pe.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};z.prototype._fromNonP2SH=function(e){var t;e=new X1(e),e.script.isPublicKeyHashOutPrefix()?t=fk:e.script.isPublicKeyOut()?t=ck:t=Bt,this.addInput(new t({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()}))};z.prototype._fromMultisigUtxo=function(e,t,r){Ft.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new X1(e),e.script.isMultisigOut())n=hk;else if(e.script.isScriptHashOut())n=lk;else throw new Nt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()},t,r))};z.prototype.addInput=function(e,t,r){if(Ft.checkArgumentType(e,Bt,"input"),!e.output&&(pe.isUndefined(t)||pe.isUndefined(r)))throw new Nt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!pe.isUndefined(r)&&(t=t instanceof ln?t:new ln(t),Ft.checkArgumentType(r,"number","satoshis"),e.output=new Wr({script:t,satoshis:r})),this.uncheckedAddInput(e)};z.prototype.uncheckedAddInput=function(e){return Ft.checkArgumentType(e,Bt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};z.prototype.hasAllUtxoInfo=function(){return pe.every(this.inputs.map(function(e){return!!e.output}))};z.prototype.fee=function(e){return Ft.checkArgument(pe.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};z.prototype.feePerKb=function(e){return Ft.checkArgument(pe.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};z.prototype.change=function(e){return Ft.checkArgument(e,"address is required"),this._changeScript=ln.fromAddress(e),this._updateChangeOutput(),this};z.prototype.getChangeOutput=function(){return pe.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};z.prototype.to=function(e,t){if(pe.isArray(e)){var r=this;return pe.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Ft.checkArgument(W1.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Wr({script:ln(new uk(e)),satoshis:t})),this};z.prototype.addData=function(e){return this.addOutput(new Wr({script:ln.buildDataOut(e),satoshis:0})),this};z.prototype.addSafeData=function(e){return this.addOutput(new Wr({script:ln.buildSafeDataOut(e),satoshis:0})),this};z.prototype.addOutput=function(e){return Ft.checkArgumentType(e,Wr,"output"),this._addOutput(e),this._updateChangeOutput(),this};z.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};z.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};z.prototype._getOutputAmount=function(){if(pe.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,pe.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};z.prototype._getInputAmount=function(){if(pe.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,pe.each(this.inputs,function(t){if(pe.isUndefined(t.output))throw new Nt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};z.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),pe.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=z.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:r})))}};z.prototype.getFee=function(){return this.isCoinbase()?0:pe.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};z.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||z.FEE_PER_KB))};z.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};z.prototype._clearSignatures=function(){pe.each(this.inputs,function(e){e.clearSignatures!==Bt.prototype.clearSignatures&&e.clearSignatures()})};z.prototype._estimateSize=function(){var e=8;return e+=z1(this.inputs.length).toBuffer().length,e+=z1(this.outputs.length).toBuffer().length,pe.each(this.inputs,function(t){e+=t._estimateSize()}),pe.each(this.outputs,function(t){e+=t.getSize()}),e};z.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=pe.without(this.outputs,t),this._outputAmount=void 0};z.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};z.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};z.prototype.shuffleOutputs=function(){return this.sortOutputs(pe.shuffle)};z.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};z.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};z.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||pe.difference(this.outputs,e).length!==0;if(t)throw new Nt.Transaction.InvalidSorting;if(!pe.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};z.prototype.removeInput=function(e,t){var r;if(!t&&pe.isNumber(e)?r=e:r=pe.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Nt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=pe.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};z.prototype.sign=function(e,t){Ft.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return pe.isArray(e)?(pe.each(e,function(n){r.sign(n,t)}),this):(pe.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};z.prototype.getSignatures=function(e,t){e=new dk(e),t=t||Cc.SIGHASH_ALL|Cc.SIGHASH_FORKID;var r=this,n=[],i=$1.sha256ripemd160(e.publicKey.toBuffer());return pe.each(this.inputs,function(s,a){pe.each(s.getSignatures(r,e,a,t,i),function(c){n.push(c)})}),n};z.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};z.prototype.isFullySigned=function(){return pe.each(this.inputs,function(e){if(e.isFullySigned===Bt.prototype.isFullySigned)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),pe.every(pe.map(this.inputs,function(e){return e.isFullySigned()}))};z.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Bt.prototype.isValidSignature)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};z.prototype.verifySignature=function(e,t,r,n,i,o){return Z1.verify(this,e,t,r,n,i,o)};z.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new kc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new kc(z.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new kc(z.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>vk)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!pe.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};z.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};z.prototype.sighash=function(e,t,r,n,i){t=t||Cc.SIGHASH_ALL|Cc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new kc(o.output.satoshis)),i=i||gk,Z1.sighash(this,t,e,r,n,i)};Q1.exports=z});var Op=P((c5,oo)=>{m();oo.exports=xp();oo.exports.Input=Pc();oo.exports.Output=Dn();oo.exports.UnspentOutput=Ip();oo.exports.Signature=us();oo.exports.Sighash=pi()});var Nc=P((h5,rx)=>{"use strict";m();var Lc=Ve(),Ha=fp(),N=sp(),fe=Er(),qa=Qt(),yi=ir(),Rp=Tr();function ex(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var B=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};B.prototype.verify=function(e,t,r,n,i,o){var s=Op();if(Lc.isUndefined(r)&&(r=new s),Lc.isUndefined(n)&&(n=0),Lc.isUndefined(i)&&(i=B.currentConsensusFlags(),o||(i&=~B.SCRIPT_ENABLE_SIGHASH_FORKID)),i&B.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=B.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&B.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var c=(i&B.SCRIPT_VERIFY_P2SH)!==0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0;c&&(a=this.stack.slice());var h=this.stack;if(this.initialize(),this.set({script:t,stack:h,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var g=this.stack[this.stack.length-1];if(!B.castToBool(g))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(c&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var y=a[a.length-1],w=Ha.fromBuffer(y);if(a.pop(),this.initialize(),this.set({script:w,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!B.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&B.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&B.SCRIPT_VERIFY_P2SH)===0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};rx.exports=B;B.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};B.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};B.true=d.Buffer.from([1]);B.false=d.Buffer.from([]);B.MAX_SCRIPT_ELEMENT_SIZE=520;B.MAXIMUM_ELEMENT_SIZE=4;B.DEFAULT_SCRIPT_NUM_LENGTH=4;B.MAX_OPS_PER_SCRIPT=500;B.MAX_SCRIPT_SIZE=1e4;B.UNLIMITED=Number.MAX_SAFE_INTEGER;B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;B.LOCKTIME_THRESHOLD=5e8;B.LOCKTIME_THRESHOLD_BN=new fe(B.LOCKTIME_THRESHOLD);B.useGenesisLimits=function(e){return e=e||2147483647,B.MAX_SCRIPT_ELEMENT_SIZE=e,B.MAXIMUM_ELEMENT_SIZE=e,B.MAX_OPS_PER_SCRIPT=e,B.MAX_SCRIPT_SIZE=e,B};B.getLimits=function(){return{maxScriptElementSize:B.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:B.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:B.MAX_OPS_PER_SCRIPT,maxScriptSize:B.MAX_SCRIPT_SIZE}};B.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(B.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(B.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(B.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(B.MAX_SCRIPT_SIZE=e.maxScriptSize),B};B.SCRIPT_VERIFY_NONE=0;B.SCRIPT_VERIFY_P2SH=1;B.SCRIPT_VERIFY_STRICTENC=2;B.SCRIPT_VERIFY_DERSIG=4;B.SCRIPT_VERIFY_LOW_S=8;B.SCRIPT_VERIFY_NULLDUMMY=16;B.SCRIPT_VERIFY_SIGPUSHONLY=32;B.SCRIPT_VERIFY_MINIMALDATA=64;B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;B.SCRIPT_VERIFY_CLEANSTACK=256;B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;B.SCRIPT_VERIFY_MINIMALIF=8192;B.SCRIPT_VERIFY_NULLFAIL=16384;B.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;B.SCRIPT_ENABLE_SIGHASH_FORKID=65536;B.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;B.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;B.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;B.SCRIPT_GENESIS=1<<18;B.SCRIPT_UTXO_AFTER_GENESIS=1<<19;B.SCRIPT_ENABLE_CHRONICLE=1<<20;B.SCRIPT_CHRONICLE=B.SCRIPT_ENABLE_CHRONICLE;B.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;B.CHRONICLE_ACTIVATION_HEIGHT=943816;B.mainnetFlags=function(e){e=e||{};var t=B.SCRIPT_VERIFY_P2SH|B.SCRIPT_VERIFY_STRICTENC|B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_NULLFAIL|B.SCRIPT_VERIFY_MINIMALDATA|B.SCRIPT_ENABLE_SIGHASH_FORKID|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_ENABLE_MONOLITH_OPCODES;return e.afterChronicle!==!1&&(t|=B.SCRIPT_ENABLE_CHRONICLE),t};B.currentConsensusFlags=function(){return B.SCRIPT_ENABLE_MONOLITH_OPCODES|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_GENESIS|B.SCRIPT_UTXO_AFTER_GENESIS|B.SCRIPT_ENABLE_CHRONICLE|B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_SIGHASH_FORKID};B.useMainnetConsensus=function(e){return e=e||{},B.useGenesisLimits(e.max),B.MAXIMUM_ELEMENT_SIZE=e.maxScriptNumLength||B.DEFAULT_SCRIPT_NUM_LENGTH,B.mainnetFlags(e)};B.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;B.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;B.SEQUENCE_LOCKTIME_MASK=65535;B.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};B.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_STRICTENC))!==0&&!yi.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&B.SCRIPT_VERIFY_LOW_S)!==0){if(t=yi.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0){if(t=yi.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&yi.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&B.SCRIPT_CHRONICLE)&&t.nhashtype&yi.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&yi.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};B.prototype.checkPubkeyEncoding=function(e){return(this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0&&!Rp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};B.prototype.isAfterGenesis=function(){return(this.flags&B.SCRIPT_UTXO_AFTER_GENESIS)!==0};B.prototype.isAfterChronicle=function(){return(this.flags&(B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_CHRONICLE))!==0};B.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_ELEMENT_SIZE};B.prototype.maxScriptSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_SIZE};B.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_OPS_PER_SCRIPT};B.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:B.MAXIMUM_ELEMENT_SIZE};B.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};B._isMinimallyEncoded=function(e,t){return t=t||B.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};B._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};B.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(t),this.returned)return!0}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};B.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,ex(this.stack),ex(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};B.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<B.LOCKTIME_THRESHOLD&&e.lt(B.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=B.LOCKTIME_THRESHOLD&&e.gte(B.LOCKTIME_THRESHOLD_BN))||e.gt(new fe(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};B.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=B.SEQUENCE_LOCKTIME_TYPE_FLAG|B.SEQUENCE_LOCKTIME_MASK,i=new fe(r&n),o=e.and(new fe(n)),s=new fe(B.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function bk(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function tx(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}B.prototype.step=function(){var e=this;function t(re){return e.stack[e.stack.length+re]}function r(re){switch(re){case N.OP_2MUL:case N.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT:if((e.flags&B.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case N.OP_DIV:case N.OP_MOD:case N.OP_SPLIT:case N.OP_CAT:case N.OP_AND:case N.OP_OR:case N.OP_XOR:case N.OP_BIN2NUM:case N.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&B.SCRIPT_VERIFY_MINIMALDATA)!==0,i,o,s,a,c,h,g,y,w,I,T,M,L,j,G,q,W,J=this.script.chunks[this.pc];this.pc++;var Y=J.opcodenum,be=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||Y===N.OP_RETURN);if(Lc.isUndefined(Y))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(J.buf&&J.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(Y>N.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(Y)&&(!this.isAfterGenesis()||be))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(be&&Y>=0&&Y<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!J.buf)this.stack.push(B.false);else{if(J.len!==J.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(J.buf)}}else if(be||N.OP_IF<=Y&&Y<=N.OP_ENDIF)switch(Y){case N.OP_1NEGATE:case N.OP_1:case N.OP_2:case N.OP_3:case N.OP_4:case N.OP_5:case N.OP_6:case N.OP_7:case N.OP_8:case N.OP_9:case N.OP_10:case N.OP_11:case N.OP_12:case N.OP_13:case N.OP_14:case N.OP_15:case N.OP_16:c=Y-(N.OP_1-1),i=new fe(c).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=fe.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(se.lt(new fe(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(se))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var de=fe.fromScriptNumBuffer(t(-1),n,5);if(de.lt(new fe(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((de&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(de))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case N.OP_LSHIFTNUM:case N.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var A=this.maxScriptNumLength(),u=fe.fromScriptNumBuffer(t(-1),n,A);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var l=fe.fromScriptNumBuffer(t(-1),n,A);this.stack.pop();var p=u.toNumber(),v=l.isNeg(),b=l.abs(),E;if(Y===N.OP_LSHIFTNUM){var O=l.toScriptNumBuffer().length;if(O+Math.floor(p/8)>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;E=b.shln(p)}else E=p>=b.bitLength()?new fe(0):b.shrn(p);if(v&&!E.isZero()&&(E=E.neg()),E.toScriptNumBuffer().length>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(E.toScriptNumBuffer());break;case N.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(tx(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!be)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(q=!1,be){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),q=i.length===4&&i.equals(tx(this.tx.version)),Y===N.OP_VERNOTIF&&(q=!q),this.stack.pop()}this.vfExec.push(q),this.vfElse.push(!1);break;case N.OP_IF:case N.OP_NOTIF:if(q=!1,be){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&B.SCRIPT_VERIFY_MINIMALIF){if(i.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(i.length===1&&i[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}q=B.castToBool(i),Y===N.OP_NOTIF&&(q=!q),this.stack.pop()}this.vfExec.push(q),this.vfElse.push(!1);break;case N.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),q=B.castToBool(i),q)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case N.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case N.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case N.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case N.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),q=B.castToBool(i),q&&this.stack.push(d.Buffer.from(i));break;case N.OP_DEPTH:i=new fe(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case N.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case N.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case N.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case N.OP_PICK:case N.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),y=fe.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),c=y.toNumber(),this.stack.pop(),c<0||c>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-c-1),Y===N.OP_ROLL&&this.stack.splice(this.stack.length-c-1,1),this.stack.push(d.Buffer.from(i));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=t(-3),g=t(-2);var f=t(-1);this.stack[this.stack.length-3]=g,this.stack[this.stack.length-2]=f,this.stack[this.stack.length-1]=h;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=t(-2),g=t(-1),this.stack[this.stack.length-2]=g,this.stack[this.stack.length-1]=h;break;case N.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case N.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new fe(t(-1).length),this.stack.push(y.toScriptNumBuffer());break;case N.OP_AND:case N.OP_OR:case N.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(Y){case N.OP_AND:for(let re=0;re<o.length;re++)o[re]&=s[re];break;case N.OP_OR:for(let re=0;re<o.length;re++)o[re]|=s[re];break;case N.OP_XOR:for(let re=0;re<o.length;re++)o[re]^=s[re];break;default:break}this.stack.pop();break;case N.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);for(let re=0;re<i.length;re++)i[re]=~i[re];break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(w=new fe(o),I=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),c=I.toNumber(),c<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let re;Y===N.OP_LSHIFT&&(re=w.ushln(c)),Y===N.OP_RSHIFT&&(re=w.ushrn(c));let me=bk(d.Buffer.from(re.toArray().slice(o.length*-1)),o.length);this.stack.push(me)}break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var S=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(S?B.true:B.false),Y===N.OP_EQUALVERIFY)if(S)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case N.OP_2MUL:case N.OP_2DIV:case N.OP_1ADD:case N.OP_1SUB:case N.OP_NEGATE:case N.OP_ABS:case N.OP_NOT:case N.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),y=fe.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),Y){case N.OP_2MUL:y=y.mul(new fe(2));break;case N.OP_2DIV:y=y.div(new fe(2));break;case N.OP_1ADD:y=y.add(fe.One);break;case N.OP_1SUB:y=y.sub(fe.One);break;case N.OP_NEGATE:y=y.neg();break;case N.OP_ABS:y.cmp(fe.Zero)<0&&(y=y.neg());break;case N.OP_NOT:y=new fe((y.cmp(fe.Zero)===0)+0);break;case N.OP_0NOTEQUAL:y=new fe((y.cmp(fe.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case N.OP_ADD:case N.OP_SUB:case N.OP_MUL:case N.OP_MOD:case N.OP_DIV:case N.OP_BOOLAND:case N.OP_BOOLOR:case N.OP_NUMEQUAL:case N.OP_NUMEQUALVERIFY:case N.OP_NUMNOTEQUAL:case N.OP_LESSTHAN:case N.OP_GREATERTHAN:case N.OP_LESSTHANOREQUAL:case N.OP_GREATERTHANOREQUAL:case N.OP_MIN:case N.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(w=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),I=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),y=new fe(0),Y){case N.OP_ADD:y=w.add(I);break;case N.OP_SUB:y=w.sub(I);break;case N.OP_MUL:y=w.mul(I);break;case N.OP_DIV:if(I.cmp(fe.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=w.div(I);break;case N.OP_MOD:if(I.cmp(fe.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;y=w.mod(I);break;case N.OP_BOOLAND:y=new fe((w.cmp(fe.Zero)!==0&&I.cmp(fe.Zero)!==0)+0);break;case N.OP_BOOLOR:y=new fe((w.cmp(fe.Zero)!==0||I.cmp(fe.Zero)!==0)+0);break;case N.OP_NUMEQUAL:y=new fe((w.cmp(I)===0)+0);break;case N.OP_NUMEQUALVERIFY:y=new fe((w.cmp(I)===0)+0);break;case N.OP_NUMNOTEQUAL:y=new fe((w.cmp(I)!==0)+0);break;case N.OP_LESSTHAN:y=new fe((w.cmp(I)<0)+0);break;case N.OP_GREATERTHAN:y=new fe((w.cmp(I)>0)+0);break;case N.OP_LESSTHANOREQUAL:y=new fe((w.cmp(I)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:y=new fe((w.cmp(I)>=0)+0);break;case N.OP_MIN:y=w.cmp(I)<0?w:I;break;case N.OP_MAX:y=w.cmp(I)>0?w:I;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),Y===N.OP_NUMEQUALVERIFY)if(B.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case N.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;w=fe.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),I=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var K=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());q=I.cmp(w)<=0&&w.cmp(K)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(q?B.true:B.false);break;case N.OP_RIPEMD160:case N.OP_SHA1:case N.OP_SHA256:case N.OP_HASH160:case N.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var F;Y===N.OP_RIPEMD160?F=qa.ripemd160(i):Y===N.OP_SHA1?F=qa.sha1(i):Y===N.OP_SHA256?F=qa.sha256(i):Y===N.OP_HASH160?F=qa.sha256ripemd160(i):Y===N.OP_HASH256&&(F=qa.sha256sha256(i)),this.stack.pop(),this.stack.push(F);break;case N.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case N.OP_CHECKSIG:case N.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(T=t(-2),M=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;L=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var $=new Ha().add(T);L.findAndDelete($);try{j=yi.fromTxFormat(T),G=Rp.fromBuffer(M,!1),W=this.tx.verifySignature(j,G,this.nin,L,this.satoshisBN,this.flags)}catch{W=!1}if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&T.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(W?B.true:B.false),Y===N.OP_CHECKSIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var Z=1;if(this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Q=fe.fromScriptNumBuffer(t(-Z),n,this.maxScriptNumLength()).toNumber();if(Q<0||Q>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=Q,this.nOpCount>B.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var ae=++Z;Z+=Q;var ge=Q+2;if(this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var le=fe.fromScriptNumBuffer(t(-Z),n,this.maxScriptNumLength()).toNumber();if(le<0||le>Q)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var R=++Z;if(Z+=le,this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;L=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var k=0;k<le;k++)T=t(-R-k),L.findAndDelete(new Ha().add(T));for(W=!0;W&&le>0;){if(T=t(-R),M=t(-ae),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;var H;try{j=yi.fromTxFormat(T),G=Rp.fromBuffer(M,!1),H=this.tx.verifySignature(j,G,this.nin,L,this.satoshisBN,this.flags)}catch{H=!1}H&&(R++,le--),ae++,Q--,le>Q&&(W=!1)}for(;Z-- >1;){if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&!ge&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ge>0&&ge--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&B.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(W?B.true:B.false),Y===N.OP_CHECKMULTISIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case N.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var V=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(V<0||V>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var ie=d.Buffer.from(o);this.stack[this.stack.length-2]=ie.slice(0,V),this.stack[this.stack.length-1]=ie.slice(V);break;case N.OP_LEFT:case N.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),c=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),c<0||c>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),Y===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,c):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-c);break;case N.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var ee=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),te=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(te<0||te>=o.length||ee<0||ee>o.length-te)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(te,te+ee);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var he=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(he<0||he>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var oe=t(-1);if(oe=B._minimallyEncode(oe),oe.length>he)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(oe.length===he){this.stack[this.stack.length-1]=oe;break}var ue=0;oe.length>0&&(ue=oe[oe.length-1]&128,oe[oe.length-1]&=127);var We=d.Buffer.alloc(he);oe.copy(We,0);for(var Oe=oe.length-1;Oe++<he-2;)We[Oe]=0;We[Oe]=ue,this.stack[this.stack.length-1]=We;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=B._minimallyEncode(o),this.stack[this.stack.length-1]=s,!B._isMinimallyEncoded(s))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Kr=P((p5,Tp)=>{m();Tp.exports=fp();Tp.exports.Interpreter=Nc()});var no=P((y5,sx)=>{"use strict";m();var Pp=Ve(),jn=ke(),_k=Jn(),nx=Fd(),Br=ga(),ix=Qt(),ox=pr(),Bp=Tr();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Pp.isArray(e)&&Pp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(jn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Br.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Br.get(t)||Br.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,ox.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Bp)return ne._transformPublicKey(e);if(e instanceof ja())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Pp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ne._transformObject=function(e){return jn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),jn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Br.get(e.network)||Br.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Br.get(e[0],"pubkeyhash"),n=Br.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Br.get(t),o=ne._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Bp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=ix.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new _k.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Br.defaultNetwork,ne.payingTo(ja().buildMultisigOut(e,t),r)};ne._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Br.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=nx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Br.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Bp.fromPrivateKey(e);return t=t||e.network||Br.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){jn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return jn.checkArgument(e,"script is required"),jn.checkArgument(e instanceof ja(),"script must be instance of Script"),ne.fromScriptHash(ix.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){jn.checkState(ox.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return nx.encode(this.toBuffer())};sx.exports=ne;function ja(){return Kr()}});var io=P((v5,cx)=>{"use strict";m();var Dc=Ve(),Sk=no(),ax=Fd(),mi=Er(),ux=pr(),hn=ga(),Mp=ii(),wk=Tr(),Ek=ea(),fx=ke(),Np="[REDACTED]";function ye(e,t){if(!(this instanceof ye))return new ye(e,t);if(e instanceof ye)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new mi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Mp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return ux.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}ye.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Dc.isUndefined(e)||Dc.isNull(e))r.bn=ye._getRandomBN();else if(e instanceof mi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ye._transformBuffer(e,t);else if(e.bn&&e.network)r=ye._transformObject(e);else if(!t&&hn.get(e))r.bn=ye._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")ux.isHexa(e)?r.bn=new mi(d.Buffer.from(e,"hex")):r=ye._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ye._getRandomBN=function(){var e,t;do{var r=Ek.getRandomBuffer(32);t=mi.fromBuffer(r),e=t.lt(Mp.getN())}while(!e);return t};ye._transformBuffer=function(e,t){var r={};if(e.length===32)return ye._transformBNBuffer(e,t);if(r.network=hn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==hn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=mi.fromBuffer(e.slice(1,33)),r};ye._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=mi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ye._transformWIF=function(e,t){return ye._transformBuffer(ax.decode(e),t)};ye.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ye(ye._transformBNBuffer(e,t,r)):new ye(e,t)};ye.fromHex=function(e,t,r){return ye.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ye._transformObject=function(e){if(e.bn instanceof mi)return{bn:e.bn,network:hn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Np)throw new TypeError('Invalid private key: `bn` is "'+Np+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new mi(e.bn,"hex");if(t.isZero()||t.gte(Mp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=hn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};ye.fromString=ye.fromWIF=function(e,t){return fx.checkArgument(Dc.isString(e),"First argument is expected to be a string."),new ye(e,t)};ye.fromObject=ye.fromJSON=function(e){return fx.checkArgument(Dc.isObject(e),"First argument is expected to be an object."),new ye(e)};ye.fromRandom=function(e){var t=ye._getRandomBN();return new ye(t,e)};ye.getValidationError=function(e,t){var r;try{new ye(e,t)}catch(n){r=n}return r};ye.isValid=function(e,t){return e?!ye.getValidationError(e,t):!1};ye.prototype.toString=function(){return this.toWIF()};ye.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),ax.encode(r)};ye.prototype.toBigNumber=function(){return this.bn};ye.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ye.prototype.toHex=function(){return this.toBuffer().toString("hex")};ye.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=wk.fromPrivateKey(this)),this._pubkey};ye.prototype.toAddress=function(e){var t=this.toPublicKey();return Sk.fromPublicKey(t,e||this.network)};ye.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ye.prototype.toJSON=function(){return{bn:Np,compressed:this.compressed,network:this.network.toString()}};ye.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};cx.exports=ye});var Tr=P((_5,hx)=>{"use strict";m();var cs=Er(),ls=ii(),xk=Qt(),Ik=pr(),lx=ga(),kp=Ve(),so=ke();function ce(e,t){if(!(this instanceof ce))return new ce(e,t);if(so.checkArgument(e,"First argument is required, please include public key data."),e instanceof ce)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),Ik.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||lx.defaultNetwork}),this}ce.prototype._classifyArgs=function(e,t){var r={compressed:kp.isUndefined(t.compressed)||t.compressed};if(e instanceof ls)r.point=e;else if(e.x&&e.y)r=ce._transformObject(e);else if(typeof e=="string")r=ce._transformDER(d.Buffer.from(e,"hex"));else if(ce._isBuffer(e))r=ce._transformDER(e);else if(ce._isPrivateKey(e))r=ce._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=kp.isUndefined(t.network)?void 0:lx.get(t.network)),r};ce._isPrivateKey=function(e){var t=io();return e instanceof t};ce._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};ce._transformPrivateKey=function(e){so.checkArgument(ce._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=ls.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};ce._transformDER=function(e,t){so.checkArgument(ce._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=kp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new cs(o),i=new cs(s),r.point=new ls(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new cs(o),r=ce._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new cs(o),r=ce._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};ce._transformX=function(e,t){so.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=ls.fromX(e,t),r};ce._transformObject=function(e){var t=new cs(e.x,"hex"),r=new cs(e.y,"hex"),n=new ls(t,r);return new ce(n,{compressed:e.compressed})};ce.fromPrivateKey=function(e){so.checkArgument(ce._isPrivateKey(e),"Must be an instance of PrivateKey");var t=ce._transformPrivateKey(e);return new ce(t.point,{compressed:t.compressed,network:t.network})};ce.fromDER=ce.fromBuffer=function(e,t){so.checkArgument(ce._isBuffer(e),"Must be a buffer of DER encoded public key");var r=ce._transformDER(e,t);return new ce(r.point,{compressed:r.compressed})};ce.fromPoint=function(e,t){return so.checkArgument(e instanceof ls,"First argument must be an instance of Point."),new ce(e,{compressed:t})};ce.fromHex=ce.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=ce._transformDER(r);return new ce(n.point,{compressed:n.compressed})};ce.fromX=function(e,t){var r=ce._transformX(e,t);return new ce(r.point,{compressed:r.compressed})};ce.getValidationError=function(e){var t;try{new ce(e)}catch(r){t=r}return t};ce.isValid=function(e){return!ce.getValidationError(e)};ce.prototype.toObject=ce.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};ce.prototype.toBuffer=ce.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};ce.prototype._getID=function(){return xk.sha256ripemd160(this.toBuffer())};ce.prototype.toAddress=function(e){var t=no();return t.fromPublicKey(this,e||this.network)};ce.prototype.toString=ce.prototype.toHex=function(){return this.toDER().toString("hex")};ce.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};hx.exports=ce});var Ka=P((w5,px)=>{"use strict";m();var dx=ea();function Ak(){var e=dx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function Ok(e){return dx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}px.exports={uuid4:Ak,randomHex:Ok}});var bx=P((I5,vx)=>{"use strict";m();var Va=Tr(),Cp=Qt(),Lp=ka(),gx=ir(),Dp=io(),Rt=ke(),x5=Ve(),Rk=Ka();function yx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Va?t.issuerPublicKey:Va.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Va.fromString(n):null}catch{return null}}var hs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},mx={create:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object"),Rt.checkArgument(i instanceof Dp,"Invalid issuer private key");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),c=this._signToken(a,i);return{success:!0,rightToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:c,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,subject:r,issuedAt:c.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:c.id,issuer:t,subject:r,rightType:e}}}}}catch(h){return{success:!1,error:h.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Rt.checkArgument(e&&typeof e=="object","Invalid token"),Rt.checkArgument(typeof t=="string","New owner DID must be string"),Rt.checkArgument(r instanceof Dp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=yx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},c=this._signToken(a,r),h=JSON.parse(JSON.stringify(e));h.id="urn:uuid:"+this._generateUUID(),h.issuanceDate=new Date().toISOString(),h.credentialSubject.id=t,h.credentialSubject.transferHistory=h.credentialSubject.transferHistory||[],h.credentialSubject.transferHistory.push({transferId:c.id,transferDate:c.issuanceDate,from:e.credentialSubject.id,to:t}),delete h.proof;var g=this._signToken(h,r);return{success:!0,newToken:g,transferProof:c,transferId:c.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:g.id,transferProof:c,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:c.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:c.id,transferDate:c.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:g.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:g.id,transferId:c.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:c.issuanceDate}}}}}catch(y){return{success:!1,error:y.message}}},prepareObligationToken:function(e,t,r,n){Rt.checkArgument(e&&typeof e=="object","Invalid right token"),Rt.checkArgument(typeof t=="string","Obligor DID must be string"),Rt.checkArgument(r&&typeof r=="object","Obligation must be object"),Rt.checkArgument(n instanceof Dp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Rt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(hs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return hs},verifyToken:function(e,t){var r=[];try{if(Rt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Va?t:Va.fromString(t),i=this._canonicalizeToken(e),o=Cp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=gx.fromDER(d.Buffer.from(s[2],"base64url")),c=new Lp;return c.hashbuf=o,c.sig=a,c.pubkey=n,c.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(h){return r.push(h.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Cp.sha256(d.Buffer.from(r)),i=new Lp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Cp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=yx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=gx.fromDER(d.Buffer.from(s[2],"base64url")),c=new Lp;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(hs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return Rk.uuid4()}};mx.RightTypes=hs;vx.exports=mx});var Sx=P((O5,_x)=>{"use strict";m();var Ga=Qt(),yr=ke(),Tk=Ka(),ao={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},Pk={prepareClaimValidation:function(e,t){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=ao[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string"),yr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Ga.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{yr.checkArgument(typeof e=="string","Claim hash must be string"),yr.checkArgument(t&&typeof t=="object","Invalid disputant"),yr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Ga.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{yr.checkArgument(Array.isArray(e),"Claims must be array"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,c){try{var h=this.prepareClaimValidation(a,t);h.success&&h.validation.valid&&i++,r.push({index:c,result:h})}catch(g){n.push({index:c,error:g.message})}}.bind(this));var o=this._generateBatchId(),s=Ga.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){yr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Ga.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=ao[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return ao},getSchemaNames:function(){return Object.keys(ao)},getSchema:function(e){return ao[e]||null},addSchema:function(e,t){yr.checkArgument(typeof e=="string","Schema name must be string"),yr.checkArgument(t&&typeof t=="object","Invalid schema"),ao[e]=t},createTemplate:function(e){var t=ao[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Ga.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return Tk.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};_x.exports=Pk});var Ex=P((T5,wx)=>{"use strict";m();var za=Qt(),ds=ke(),Bk={prepareTokenCommitment:function(e,t){t=t||{},ds.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},ds.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){ds.checkArgument(e&&typeof e=="object","Invalid token"),ds.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){ds.checkArgument(typeof e=="string","Token ID must be string"),ds.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=za.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:za.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=za.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var c=this._createCommitment(a,t);r.push(c.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=za.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=za.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};wx.exports=Bk});var Ax=P((B5,Ix)=>{"use strict";m();var Nk=Tr(),Yr=Qt(),xx=ka(),Mk=ir(),kk=io(),or=ke(),Ck={prepareSignatureProof:function(e,t,r){r=r||{},or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t instanceof kk,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Yr.sha256(d.Buffer.from(n)),o=new xx;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSignatureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Yr.sha256(d.Buffer.from(r)),i=Mk.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new xx;s.hashbuf=n,s.sig=i,s.pubkey=Nk.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosure:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(Array.isArray(t),"Revealed fields must be array"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(c){var h=this._getNestedValue(e,c),g=this._findFieldCommitment(n,c);if(g){o.push({path:c,value:h,commitment:g.hash,salt:g.salt});var y=this._generateMerkleProof(i,g.index);s.push({path:c,leafIndex:g.index,proof:y})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid proof"),or.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],c=this._hashField(o.path,o.value,o.salt);if(c!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var h=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);h?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var c=this._checkLegalRequirement(e,a);i.push(c),c.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid statement"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Yr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Yr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Yr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Yr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(g){return g.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,c=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),h=Yr.sha256(c).toString("hex");i.push(h)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],c=o%2===0,h;a.isLeft?h=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):h=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Yr.sha256(h).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Yr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};Ix.exports=Ck});var Tx=P((C5,Rx)=>{"use strict";m();var Wa=Qt(),M5=no(),k5=Op(),cr=ke(),Ox=Ka(),Lk={prepareRegistry:function(e){e=e||{},cr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(typeof t=="string","Approver must be string"),cr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid revocation"),cr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{cr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return cr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},cr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+Ox.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,Wa.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Wa.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+Ox.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};Rx.exports=Lk});var Mx=P((D5,Nx)=>{"use strict";m();var Up=Tr(),Fp=Qt(),Px=ka(),Dk=ir(),Bx=io(),mr=ke(),Uk=Ka();function Fk(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Up?t.issuerPublicKey:Up.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Up.fromString(n):null}catch{return null}}var Uc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},ps={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},lr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Fc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},mr.checkArgument(typeof e=="string","Obligation type must be string"),mr.checkArgument(typeof t=="string","Issuer DID must be string"),mr.checkArgument(typeof r=="string","Obligor DID must be string"),mr.checkArgument(n&&typeof n=="object","Obligation must be object"),mr.checkArgument(i instanceof Bx,"Invalid issuer private key");var s=Object.values(Uc);mr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||ps.MEDIUM,status:lr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var c=this._signToken(a,i);return{success:!0,obligationToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:c,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,obligor:r,issuedAt:c.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:c.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:c.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(h){return{success:!1,error:h.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===lr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),mr.checkArgument(r instanceof Bx,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===lr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===lr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?lr.COMPLETED:lr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(c){return{success:!1,error:c.message}}},prepareObligationBreachAssessment:function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid breach details"),mr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Fp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},mr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===lr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ps.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ps.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Uc},getObligationPriority:function(){return ps},getObligationStatus:function(){return lr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Fp.sha256(d.Buffer.from(r)),i=new Px;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Fp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Fk(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Dk.fromDER(d.Buffer.from(s[2],"base64url")),c=new Px;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Uc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(lr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===lr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ps);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==lr.COMPLETED},_generateUUID:function(){return Uk.uuid4()}};Fc.ObligationTypes=Uc;Fc.ObligationPriority=ps;Fc.ObligationStatus=lr;Nx.exports=Fc});var Cx=P((F5,kx)=>{"use strict";m();var uo=bx(),qc=Sx(),Ya=Ex(),qp=Ax(),dn=Tx(),qk=Mx(),Hp=io(),vr=ke(),Re=function(e){return this instanceof Re?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Re(e)};Re.prototype.createRightToken=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right data"),vr.checkArgument(t instanceof Hp,"Invalid private key"),r=r||{};try{var n=uo.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=uo._signToken(n,t)),r.anchor){var i=Ya.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=dn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Re.prototype.validateClaim=function(e,t){return qc.validate(e,t)};Re.prototype.createSelectiveDisclosure=function(e,t,r){return qp.prepareSelectiveDisclosure(e,t,r)};Re.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:uo.verifyToken(e,t)};Re.prototype.transferRight=function(e,t,r,n){vr.checkArgument(e&&typeof e=="object","Invalid token"),vr.checkArgument(typeof t=="string","New owner must be string"),vr.checkArgument(r instanceof Hp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=uo.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var c=Ya.anchorToken(s,n.anchor);c.success&&(s.transferAnchorTx=c.txid)}if(this.registry){var h=dn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});h.success&&(s.registrationId=h.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(g){return{success:!1,error:g.message}}};Re.prototype.createObligation=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right token"),vr.checkArgument(t&&typeof t=="object","Invalid obligation data"),vr.checkArgument(r instanceof Hp,"Invalid private key");try{var n=uo.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Re.prototype.revokeToken=function(e,t,r){return vr.checkArgument(typeof e=="string","Token ID must be string"),vr.checkArgument(t&&typeof t=="object","Invalid revocation data"),vr.checkArgument(typeof r=="string","Authority must be string"),this.registry?dn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Re.prototype.checkTokenStatus=function(e){return vr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Re.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Re.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Re.prototype.createLegalValidityProof=function(e,t,r){return qp.prepareLegalValidityProof(e,t,r)};Re.prototype.anchorTokenBatch=function(e,t){return Ya.anchorBatch(e,t)};Re.prototype.verifyAnchor=function(e,t){return Ya.verifyAnchor(e,t)};Re.prototype.getRightTypes=function(){return uo.getRightTypes()};Re.prototype.getClaimSchemas=function(){return qc.getSchemas()};Re.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Re.prototype.setRegistry=function(e){vr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Re.create=function(e){return new Re(e)};Re.createRightToken=function(e,t,r){var n=new Re;return n.createRightToken(e,t,r)};Re.validateClaim=function(e,t){return qc.validate(e,t)};Re.verifyToken=function(e,t){var r=new Re;return r.verifyToken(e,t)};Re.createRegistry=function(e){return dn.createRegistry(e)};Re.Right=uo;Re.Claim=qc;Re.Anchor=Ya;Re.Proof=qp;Re.Registry=dn;Re.Obligation=qk;kx.exports=Re});var Hk=P((H5,Lx)=>{m();Lx.exports=Cx()});return Hk();})();
|
|
69
|
+
`));var a=new li({actual:e,expected:t,message:r,operator:i,stackStartFn:n});throw a.generatedMessage=s,a}}Ge.match=function e(t,r,n){ZE(t,r,n,e,"match")};Ge.doesNotMatch=function e(t,r,n){ZE(t,r,n,e,"doesNotMatch")};function XE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];KE.apply(void 0,[XE,t.length].concat(t))}Ge.strict=f6(XE,Ge,{equal:Ge.strictEqual,deepEqual:Ge.deepStrictEqual,notEqual:Ge.notStrictEqual,notDeepEqual:Ge.notDeepStrictEqual});Ge.strict.strict=Ge.strict});var Qi=P((RF,e1)=>{"use strict";m();var QE=oc(),tt=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};tt.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(t,r){return t+r.length},0),this};tt.prototype.toBuffer=function(){return this.concat()};tt.prototype.concat=function(){return d.Buffer.concat(this.bufs,this.bufLen)};tt.prototype.write=function(e){return QE(d.Buffer.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this};tt.prototype.writeReverse=function(e){return QE(d.Buffer.isBuffer(e)),this.bufs.push(d.Buffer.from(e).reverse()),this.bufLen+=e.length,this};tt.prototype.writeUInt8=function(e){var t=d.Buffer.alloc(1);return t.writeUInt8(e,0),this.write(t),this};tt.prototype.writeUInt16BE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this};tt.prototype.writeUInt16LE=function(e){var t=d.Buffer.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this};tt.prototype.writeUInt32BE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this};tt.prototype.writeInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt32LE=function(e){var t=d.Buffer.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this};tt.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this};tt.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this};tt.prototype.writeVarintNum=function(e){var t=tt.varintBufNum(e);return this.write(t),this};tt.prototype.writeVarintBN=function(e){var t=tt.varintBufBN(e);return this.write(t),this};tt.varintBufNum=function(e){var t;return e<253?(t=d.Buffer.alloc(1),t.writeUInt8(e,0)):e<65536?(t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?(t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=d.Buffer.alloc(9),t.writeUInt8(255,0),t.writeInt32LE(e&-1,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t};tt.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)t=d.Buffer.alloc(1),t.writeUInt8(r,0);else if(r<65536)t=d.Buffer.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)t=d.Buffer.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new tt;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t};e1.exports=tt});var sp=P((PF,t1)=>{"use strict";m();var is=Ve(),Na=ke(),l6=pr();function Pe(e){if(!(this instanceof Pe))return new Pe(e);var t;if(is.isNumber(e))t=e;else if(is.isString(e))t=Pe.map[e];else throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');return l6.defineImmutable(this,{num:t}),this}Pe.fromBuffer=function(e){return Na.checkArgument(d.Buffer.isBuffer(e)),new Pe(+("0x"+e.toString("hex")))};Pe.fromNumber=function(e){return Na.checkArgument(is.isNumber(e)),new Pe(e)};Pe.fromString=function(e){Na.checkArgument(is.isString(e));var t=Pe.map[e];if(typeof t>"u")throw new TypeError("Invalid opcodestr");return new Pe(t)};Pe.prototype.toHex=function(){return this.num.toString(16)};Pe.prototype.toBuffer=function(){return d.Buffer.from(this.toHex(),"hex")};Pe.prototype.toNumber=function(){return this.num};Pe.prototype.toString=function(){var e=Pe.reverseMap[this.num];if(typeof e>"u")throw new Error("Opcode does not have a string representation");return e};Pe.smallInt=function(e){return Na.checkArgument(is.isNumber(e),"Invalid Argument: n should be number"),Na.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),e===0?Pe("OP_0"):new Pe(Pe.map.OP_1+e-1)};Pe.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_LSHIFTNUM:182,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};Pe.reverseMap=[];for(op in Pe.map)Pe.reverseMap[Pe.map[op]]=op;var op;is.extend(Pe,Pe.map);Pe.isSmallIntOp=function(e){return e instanceof Pe&&(e=e.toNumber()),e===Pe.map.OP_0||e>=Pe.map.OP_1&&e<=Pe.map.OP_16};Pe.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"};t1.exports=Pe});var ir=P((NF,n1)=>{"use strict";m();var eo=Er(),h6=Ve(),nr=ke(),d6=pr(),Ie=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof eo)this.set({r:t,s:r});else if(t){var n=t;this.set(n)}};Ie.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=typeof e.i<"u"?e.i:this.i,this.compressed=typeof e.compressed<"u"?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this};Ie.fromCompact=function(e){nr.checkArgument(d.Buffer.isBuffer(e),"Argument is expected to be a Buffer");var t=new Ie,r=!0,n=e.slice(0,1)[0]-27-4;n<0&&(r=!1,n=n+4);var i=e.slice(1,33),o=e.slice(33,65);return nr.checkArgument(n===0||n===1||n===2||n===3,new Error("i must be 0, 1, 2, or 3")),nr.checkArgument(i.length===32,new Error("r must be 32 bytes")),nr.checkArgument(o.length===32,new Error("s must be 32 bytes")),t.compressed=r,t.i=n,t.r=eo.fromBuffer(i),t.s=eo.fromBuffer(o),t};Ie.fromDER=Ie.fromBuffer=function(e,t){var r=Ie.parseDER(e,t),n=new Ie;return n.r=r.r,n.s=r.s,n};Ie.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=Ie.fromDER(r,!1);return n.nhashtype=t,n};Ie.fromString=function(e){var t=d.Buffer.from(e,"hex");return Ie.fromDER(t)};function r1(e,t){nr.checkArgument(t.length>0,new Error("Length of "+e+" is zero")),nr.checkArgument(!(t[0]&128),new Error("Value of "+e+" is negative")),nr.checkArgument(!(t.length>1&&t[0]===0&&!(t[1]&128)),new Error("Value of "+e+" is excessively padded"))}Ie.parseDER=function(e,t){nr.checkArgument(d.Buffer.isBuffer(e),new Error("DER formatted signature should be a buffer")),h6.isUndefined(t)&&(t=!0);var r=e[0];nr.checkArgument(r===48,new Error("Header byte should be 0x30"));var n=e[1],i=e.slice(2).length;nr.checkArgument(!t||n===i,new Error("Length byte should length of what follows")),n=n<i?n:i;var o=e[2];nr.checkArgument(o===2,new Error("Integer byte for r should be 0x02"));var s=e[3],a=e.slice(4,4+s),c=eo.fromBuffer(a),h=e[4]===0;nr.checkArgument(s===a.length,new Error("Length of r incorrect"));var g=e[4+s+0];nr.checkArgument(g===2,new Error("Integer byte for s should be 0x02"));var y=e[4+s+1],w=e.slice(4+s+2,4+s+2+y),I=eo.fromBuffer(w),T=e[4+s+2]===0;nr.checkArgument(y===w.length,new Error("Length of s incorrect"));var M=4+s+2+y;nr.checkArgument(n===M-2,new Error("Length of signature incorrect")),t&&(r1("r",a),r1("s",w));var L={header:r,length:n,rheader:o,rlength:s,rneg:h,rbuf:a,r:c,sheader:g,slength:y,sneg:T,sbuf:w,s:I};return L};Ie.prototype.toCompact=function(e,t){if(e=typeof e=="number"?e:this.i,t=typeof t=="boolean"?t:this.compressed,!(e===0||e===1||e===2||e===3))throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;t===!1&&(r=r-4);var n=d.Buffer.from([r]),i=this.r.toBuffer({size:32}),o=this.s.toBuffer({size:32});return d.Buffer.concat([n,i,o])};Ie.prototype.toBuffer=Ie.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(e[0]&128),n=!!(t[0]&128),i=r?d.Buffer.concat([d.Buffer.from([0]),e]):e,o=n?d.Buffer.concat([d.Buffer.from([0]),t]):t,s=i.length,a=o.length,c=2+s+2+a,h=2,g=2,y=48,w=d.Buffer.concat([d.Buffer.from([y,c,h,s]),i,d.Buffer.from([g,a]),o]);return w};Ie.prototype.toString=function(){var e=this.toDER();return e.toString("hex")};Ie.isTxDER=function(e){if(e.length<9||e.length>73||e[0]!==48||e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(e[2]!==2||t===0||n[0]&128||t>1&&n[0]===0&&!(n[1]&128))return!1;var i=e.slice(6+t);return!(e[6+t-2]!==2||r===0||i[0]&128||r>1&&i[0]===0&&!(i[1]&128))};Ie.prototype.hasLowS=function(){return!(this.s.lt(new eo(1))||this.s.gt(new eo("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))};Ie.prototype.hasDefinedHashtype=function(){if(!d6.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&31;return!(e<Ie.SIGHASH_ALL||e>Ie.SIGHASH_SINGLE)};Ie.prototype.toTxFormat=function(){var e=this.toDER(),t=d.Buffer.alloc(1);return t.writeUInt8(this.nhashtype,0),d.Buffer.concat([e,t])};Ie.SIGHASH_ALL=1;Ie.SIGHASH_NONE=2;Ie.SIGHASH_SINGLE=3;Ie.SIGHASH_CHRONICLE=32;Ie.SIGHASH_FORKID=64;Ie.SIGHASH_ANYONECANPAY=128;Ie.prototype.isCanonical=function(){var e=ii(),t=e.getN().shrn(1);return this.s.lte(t)};Ie.prototype.toCanonical=function(){if(this.isCanonical())return new Ie({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=ii(),t=e.getN(),r=t.sub(this.s);return new Ie({r:this.r,s:r,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})};Ie.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=ii(),t=e.getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0};Ie.prototype.isValid=function(){try{return this.validate(),!0}catch{return!1}};Ie.prototype.applySecurityPatches=function(){var e=ii(),t=e.getN(),r=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");if(this.s.gt(r))throw new Error("Invalid signature: non-canonical (high) s");return this};n1.exports=Ie});var fp=P((kF,s1)=>{"use strict";m();var Hr=no(),p6=va(),g6=Qi(),ap=Qt(),X=sp(),ro=Tr(),to=ir(),i1=ga(),$e=ke(),Ae=Ve(),up=Jn(),o1=Tt(),y6=pr(),D=function e(t){if(!(this instanceof e))return new e(t);if(this.chunks=[],d.Buffer.isBuffer(t))return e.fromBuffer(t);if(t instanceof Hr)return e.fromAddress(t);if(t instanceof e)return e.fromBuffer(t.toBuffer());if(Ae.isString(t))return e.fromString(t);Ae.isObject(t)&&Ae.isArray(t.chunks)&&this.set(t)};D.prototype.set=function(e){return $e.checkArgument(Ae.isObject(e)),$e.checkArgument(Ae.isArray(e.chunks)),this.chunks=e.chunks,this};D.fromBuffer=function(e){var t=new D;t.chunks=[];for(var r=new p6(e);!r.finished();)try{var n=r.readUInt8(),i,o;n>0&&n<X.OP_PUSHDATA1?(i=n,t.chunks.push({buf:r.read(i),len:i,opcodenum:n})):n===X.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):n===X.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),t.chunks.push({buf:o,len:i,opcodenum:n})):t.chunks.push({opcodenum:n})}catch(s){throw s instanceof RangeError?new up.Script.InvalidBuffer(e.toString("hex")):s}return t};D.prototype.toBuffer=function(){for(var e=new g6,t=0;t<this.chunks.length;t++){var r=this.chunks[t],n=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(n<X.OP_PUSHDATA1?e.write(r.buf):n===X.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):n===X.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):n===X.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()};D.fromASM=function(e){var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber();if(i==="0")s=0,t.chunks.push({opcodenum:s}),n=n+1;else if(i==="-1")s=X.OP_1NEGATE,t.chunks.push({opcodenum:s}),n=n+1;else if(Ae.isUndefined(s)){var a=d.Buffer.from(r[n],"hex");if(a.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=a.length;c>=0&&c<X.OP_PUSHDATA1?s=c:c<Math.pow(2,8)?s=X.OP_PUSHDATA1:c<Math.pow(2,16)?s=X.OP_PUSHDATA2:c<Math.pow(2,32)&&(s=X.OP_PUSHDATA4),t.chunks.push({buf:a,len:a.length,opcodenum:s}),n=n+1}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.fromHex=function(e){return new D(o1.Buffer.from(e,"hex"))};D.fromString=function(e){if(y6.isHexa(e)||e.length===0)return new D(o1.Buffer.from(e,"hex"));var t=new D;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var i=r[n],o=X(i),s=o.toNumber();if(Ae.isUndefined(s))if(s=parseInt(i),s>0&&s<X.OP_PUSHDATA1)t.chunks.push({buf:d.Buffer.from(r[n+1].slice(2),"hex"),len:s,opcodenum:s}),n=n+2;else throw new Error("Invalid script: "+JSON.stringify(e));else if(s===X.OP_PUSHDATA1||s===X.OP_PUSHDATA2||s===X.OP_PUSHDATA4){if(r[n+2].slice(0,2)!=="0x")throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:d.Buffer.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:s}),n=n+3}else t.chunks.push({opcodenum:s}),n=n+1}return t};D.prototype._chunkToString=function(e,t){var r=e.opcodenum,n=t==="asm",i="";if(e.buf)!n&&(r===X.OP_PUSHDATA1||r===X.OP_PUSHDATA2||r===X.OP_PUSHDATA4)&&(i=i+" "+X(r).toString()),e.len>0&&(n?i=i+" "+e.buf.toString("hex"):i=i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(typeof X.reverseMap[r]<"u")n?r===0?i=i+" 0":r===79?i=i+" -1":i=i+" "+X(r).toString():i=i+" "+X(r).toString();else{var o=r.toString(16);o.length%2!==0&&(o="0"+o),n?i=i+" "+o:i=i+" 0x"+o}return i};D.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)};D.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)};D.prototype.toHex=function(){return this.toBuffer().toString("hex")};D.prototype.inspect=function(){return"<Script: "+this.toString()+">"};D.prototype.isPublicKeyHashOut=function(){return!!(this.chunks.length===5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};D.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===X.OP_DUP&&this.chunks[1].opcodenum===X.OP_HASH160&&this.chunks[2].buf&&this.chunks[2].buf.length===20&&this.chunks[3].opcodenum===X.OP_EQUALVERIFY&&this.chunks[4].opcodenum===X.OP_CHECKSIG)};D.prototype.isPublicKeyHashIn=function(){if(this.chunks.length===2){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&e[0]===48&&t&&t.length){var r=t[0];if((r===4||r===6||r===7)&&t.length===65)return!0;if((r===3||r===2)&&t.length===33)return!0}}return!1};D.prototype.getPublicKey=function(){return $e.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf};D.prototype.getPublicKeyHash=function(){return $e.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf};D.prototype.isPublicKeyOut=function(){if(this.chunks.length===2&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===X.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if(((t===4||t===6||t===7)&&e.length===65||(t===3||t===2)&&e.length===33)&&(r=!0),r)return ro.isValid(e)}return!1};D.prototype.isPublicKeyIn=function(){if(this.chunks.length===1){var e=this.chunks[0].buf;if(e&&e.length&&e[0]===48)return!0}return!1};D.prototype.isScriptHashOut=function(){var e=this.toBuffer();return e.length===23&&e[0]===X.OP_HASH160&&e[1]===20&&e[e.length-1]===X.OP_EQUAL};D.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e=this.chunks[this.chunks.length-1],t=e.buf;if(!t)return!1;var r;try{r=D.fromBuffer(t)}catch(i){if(i instanceof up.Script.InvalidBuffer)return!1;throw i}var n=r.classify();return n!==D.types.UNKNOWN};D.prototype.isMultisigOut=function(){return this.chunks.length>3&&X.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)})&&X.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===X.OP_CHECKMULTISIG};D.prototype.isMultisigIn=function(){return this.chunks.length>=2&&this.chunks[0].opcodenum===0&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&d.Buffer.isBuffer(e.buf)&&to.isTxDER(e.buf)})};D.prototype.isDataOut=function(){var e=this.chunks.length>=1&&this.chunks[0].opcodenum===X.OP_RETURN;if(!e)return!1;var t=this.chunks.slice(1),r=new D({chunks:t});return r.isPushOnly()};D.prototype.isSafeDataOut=function(){if(this.chunks.length<2||this.chunks[0].opcodenum!==X.OP_FALSE)return!1;var e=this.chunks.slice(1),t=new D({chunks:e});return t.isDataOut()};D.prototype.getData=function(){if(this.isSafeDataOut()){var e=this.chunks.slice(2),t=e.map(r=>r.buf);return t}if(this.isDataOut()||this.isScriptHashOut())return Ae.isUndefined(this.chunks[1])?d.Buffer.alloc(0):d.Buffer.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return d.Buffer.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")};D.prototype.isPushOnly=function(){return Ae.every(this.chunks,function(e){return e.opcodenum<=X.OP_16||e.opcodenum===X.OP_PUSHDATA1||e.opcodenum===X.OP_PUSHDATA2||e.opcodenum===X.OP_PUSHDATA4})};D.types={};D.types.UNKNOWN="Unknown";D.types.PUBKEY_OUT="Pay to public key";D.types.PUBKEY_IN="Spend from public key";D.types.PUBKEYHASH_OUT="Pay to public key hash";D.types.PUBKEYHASH_IN="Spend from public key hash";D.types.SCRIPTHASH_OUT="Pay to script hash";D.types.SCRIPTHASH_IN="Spend from script hash";D.types.MULTISIG_OUT="Pay to multisig";D.types.MULTISIG_IN="Spend from multisig";D.types.DATA_OUT="Data push";D.types.SAFE_DATA_OUT="Safe data push";D.OP_RETURN_STANDARD_SIZE=220;D.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==D.types.UNKNOWN?e:this.classifyInput()};D.outputIdentifiers={};D.outputIdentifiers.PUBKEY_OUT=D.prototype.isPublicKeyOut;D.outputIdentifiers.PUBKEYHASH_OUT=D.prototype.isPublicKeyHashOut;D.outputIdentifiers.MULTISIG_OUT=D.prototype.isMultisigOut;D.outputIdentifiers.SCRIPTHASH_OUT=D.prototype.isScriptHashOut;D.outputIdentifiers.DATA_OUT=D.prototype.isDataOut;D.outputIdentifiers.SAFE_DATA_OUT=D.prototype.isSafeDataOut;D.prototype.classifyOutput=function(){for(var e in D.outputIdentifiers)if(D.outputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.inputIdentifiers={};D.inputIdentifiers.PUBKEY_IN=D.prototype.isPublicKeyIn;D.inputIdentifiers.PUBKEYHASH_IN=D.prototype.isPublicKeyHashIn;D.inputIdentifiers.MULTISIG_IN=D.prototype.isMultisigIn;D.inputIdentifiers.SCRIPTHASH_IN=D.prototype.isScriptHashIn;D.prototype.classifyInput=function(){for(var e in D.inputIdentifiers)if(D.inputIdentifiers[e].bind(this)())return D.types[e];return D.types.UNKNOWN};D.prototype.isStandard=function(){return this.classify()!==D.types.UNKNOWN};D.prototype.prepend=function(e){return this._addByType(e,!0),this};D.prototype.equals=function(e){if($e.checkState(e instanceof D,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(d.Buffer.isBuffer(this.chunks[t].buf)&&!d.Buffer.isBuffer(e.chunks[t].buf)||d.Buffer.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0};D.prototype.add=function(e){return this._addByType(e,!1),this};D.prototype._addByType=function(e,t){if(typeof e=="string")this._addOpcode(e,t);else if(typeof e=="number")this._addOpcode(e,t);else if(e instanceof X)this._addOpcode(e,t);else if(d.Buffer.isBuffer(e))this._addBuffer(e,t);else if(e instanceof D)this.chunks=this.chunks.concat(e.chunks);else if(typeof e=="object")this._insertAtPosition(e,t);else throw new Error("Invalid script chunk")};D.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)};D.prototype._addOpcode=function(e,t){var r;return typeof e=="number"?r=e:e instanceof X?r=e.toNumber():r=X(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this};D.prototype._addBuffer=function(e,t){var r,n=e.length;if(n>=0&&n<X.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=X.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=X.OP_PUSHDATA2;else if(n<Math.pow(2,32))r=X.OP_PUSHDATA4;else throw new Error("You can't push that much data");return this._insertAtPosition({buf:e,len:n,opcodenum:r},t),this};D.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==X.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this};D.buildMultisigOut=function(e,t,r){$e.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new D;n.add(X.smallInt(t)),e=Ae.map(e,ro);var i=e;r.noSorting||(i=e.map(a=>a.toString("hex")).sort().map(a=>new ro(a)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(X.smallInt(e.length)),n.add(X.OP_CHECKMULTISIG),n};D.buildMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(X.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i};D.buildP2SHMultisigIn=function(e,t,r,n){$e.checkArgument(Ae.isArray(e)),$e.checkArgument(Ae.isNumber(t)),$e.checkArgument(Ae.isArray(r)),n=n||{};var i=new D;return i.add(X.OP_0),Ae.each(r,function(o){$e.checkArgument(d.Buffer.isBuffer(o),"Signatures must be an array of Buffers"),i.add(o)}),i.add((n.cachedMultisig||D.buildMultisigOut(e,t,n)).toBuffer()),i};D.buildPublicKeyHashOut=function(e){$e.checkArgument(!Ae.isUndefined(e)),$e.checkArgument(e instanceof ro||e instanceof Hr||Ae.isString(e)),e instanceof ro?e=e.toAddress():Ae.isString(e)&&(e=new Hr(e));var t=new D;return t.add(X.OP_DUP).add(X.OP_HASH160).add(e.hashBuffer).add(X.OP_EQUALVERIFY).add(X.OP_CHECKSIG),t._network=e.network,t};D.buildPublicKeyOut=function(e){$e.checkArgument(e instanceof ro);var t=new D;return t.add(e.toBuffer()).add(X.OP_CHECKSIG),t};D.buildDataOut=function(e,t){$e.checkArgument(Ae.isUndefined(e)||Ae.isString(e)||Ae.isArray(e)||d.Buffer.isBuffer(e));var r=e;Ae.isArray(r)||(r=[e]);var n=new D;n.add(X.OP_RETURN);for(let i of r)$e.checkArgument(Ae.isUndefined(i)||Ae.isString(i)||d.Buffer.isBuffer(i)),Ae.isString(i)&&(i=d.Buffer.from(i,t)),Ae.isUndefined(i)||n.add(i);return n};D.buildSafeDataOut=function(e,t){var r=D.buildDataOut(e,t),n=new D;return n.add(X.OP_FALSE),n.add(r),n};D.buildScriptHashOut=function(e){$e.checkArgument(e instanceof D||e instanceof Hr&&e.isPayToScriptHash());var t=new D;return t.add(X.OP_HASH160).add(e instanceof Hr?e.hashBuffer:ap.sha256ripemd160(e.toBuffer())).add(X.OP_EQUAL),t._network=e._network||e.network,t};D.buildPublicKeyIn=function(e,t){$e.checkArgument(e instanceof to||d.Buffer.isBuffer(e)),$e.checkArgument(Ae.isUndefined(t)||Ae.isNumber(t)),e instanceof to&&(e=e.toBuffer());var r=new D;return r.add(d.Buffer.concat([e,d.Buffer.from([(t||to.SIGHASH_ALL)&255])])),r};D.buildPublicKeyHashIn=function(e,t,r){$e.checkArgument(t instanceof to||d.Buffer.isBuffer(t)),$e.checkArgument(Ae.isUndefined(r)||Ae.isNumber(r)),t instanceof to&&(t=t.toBuffer());var n=new D().add(d.Buffer.concat([t,d.Buffer.from([(r||to.SIGHASH_ALL)&255])])).add(new ro(e).toBuffer());return n};D.empty=function(){return new D};D.prototype.toScriptHashOut=function(){return D.buildScriptHashOut(this)};D.fromAddress=function(e){if(e=Hr(e),e.isPayToScriptHash())return D.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return D.buildPublicKeyHashOut(e);throw new up.Script.UnrecognizedAddress(e)};D.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()};D.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToScriptHash;else if(this.isPublicKeyHashOut())e.hashBuffer=this.getData(),e.type=Hr.PayToPublicKeyHash;else return!1;return e};D.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[1].buf),e.type=Hr.PayToPublicKeyHash;else if(this.isScriptHashIn())e.hashBuffer=ap.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=Hr.PayToScriptHash;else return!1;return e};D.prototype.toAddress=function(e){var t=this.getAddressInfo();return t?(t.network=i1.get(e)||this._network||i1.defaultNetwork,new Hr(t)):!1};D.prototype.findAndDelete=function(e){for(var t=e.toBuffer(),r=t.toString("hex"),n=0;n<this.chunks.length;n++){var i=D({chunks:[this.chunks[n]]}),o=i.toBuffer(),s=o.toString("hex");r===s&&this.chunks.splice(n,1)}return this};D.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,n=t.opcodenum;return r?r.length===0?n===X.OP_0:r.length===1&&r[0]>=1&&r[0]<=16?n===X.OP_1+(r[0]-1):r.length===1&&r[0]===129?n===X.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===X.OP_PUSHDATA1:r.length<=65535?n===X.OP_PUSHDATA2:!0:!0};D.prototype._decodeOP_N=function(e){if(e===X.OP_0)return 0;if(e>=X.OP_1&&e<=X.OP_16)return e-(X.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))};D.prototype.getSignatureOperationsCount=function(e){e=Ae.isUndefined(e)?!0:e;var t=this,r=0,n=X.OP_INVALIDOPCODE;return Ae.each(t.chunks,function(o){var s=o.opcodenum;s===X.OP_CHECKSIG||s===X.OP_CHECKSIGVERIFY?r++:(s===X.OP_CHECKMULTISIG||s===X.OP_CHECKMULTISIGVERIFY)&&(e&&n>=X.OP_1&&n<=X.OP_16?r+=t._decodeOP_N(n):r+=20),n=s}),r};s1.exports=D});var Ma=P((LF,f1)=>{"use strict";m();var a1=Qi(),u1=va(),m6=Er(),jr=function e(t){if(!(this instanceof e))return new e(t);if(d.Buffer.isBuffer(t))this.buf=t;else if(typeof t=="number"){var r=t;this.fromNumber(r)}else if(t instanceof m6){var n=t;this.fromBN(n)}else if(t){var i=t;this.set(i)}};jr.prototype.set=function(e){return this.buf=e.buf||this.buf,this};jr.prototype.fromString=function(e){return this.set({buf:d.Buffer.from(e,"hex")}),this};jr.prototype.toString=function(){return this.buf.toString("hex")};jr.prototype.fromBuffer=function(e){return this.buf=e,this};jr.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this};jr.prototype.fromBN=function(e){return this.buf=a1().writeVarintBN(e).concat(),this};jr.prototype.fromNumber=function(e){return this.buf=a1().writeVarintNum(e).concat(),this};jr.prototype.toBuffer=function(){return this.buf};jr.prototype.toBN=function(){return u1(this.buf).readVarintBN()};jr.prototype.toNumber=function(){return u1(this.buf).readVarintNum()};f1.exports=jr});var Dn=P((UF,l1)=>{"use strict";m();var Ec=Ve(),cp=Er(),c1=Tt(),xc=pr(),v6=Qi(),b6=Ma(),lp=Kr(),hp=ke(),_6=Jn(),S6=9007199254740991;function Ut(e){if(!(this instanceof Ut))return new Ut(e);if(Ec.isObject(e))if(this.satoshis=e.satoshis,d.Buffer.isBuffer(e.script))this._scriptBuffer=e.script;else{var t;Ec.isString(e.script)&&xc.isHexa(e.script)?t=c1.Buffer.from(e.script,"hex"):t=e.script,this.setScript(t)}else throw new TypeError("Unrecognized argument for Output")}Object.defineProperty(Ut.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script?this._script:(this.setScriptFromBuffer(this._scriptBuffer),this._script)}});Object.defineProperty(Ut.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof cp?(this._satoshisBN=e,this._satoshis=e.toNumber()):Ec.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=cp.fromNumber(this._satoshis)):(hp.checkArgument(xc.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=cp.fromNumber(e),this._satoshis=e),hp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.invalidSatoshis=function(){return this._satoshis>S6?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0?"transaction txout negative":!1};Object.defineProperty(Ut.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),hp.checkState(xc.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}});Ut.prototype.toObject=Ut.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t};Ut.fromObject=function(e){return new Ut(e)};Ut.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=lp.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(t instanceof _6.Script.InvalidBuffer)this._script=null;else throw t}};Ut.prototype.setScript=function(e){if(e instanceof lp)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(Ec.isString(e))this._script=lp.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else if(d.Buffer.isBuffer(e))this.setScriptFromBuffer(e);else throw new TypeError("Invalid argument type: script");return this};Ut.prototype.inspect=function(){var e;return this.script?e=this.script.inspect():e=this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"};Ut.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return r!==0?t.script=e.read(r):t.script=c1.Buffer.from([]),new Ut(t)};Ut.prototype.toBufferWriter=function(e){e||(e=new v6),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e};Ut.prototype.getSize=function(){var e=this.script.toBuffer().length,t=b6(e).toBuffer().length;return 8+t+e};l1.exports=Ut});var ka=P((qF,h1)=>{"use strict";m();var gr=Er(),cn=ii(),w6=ir(),E6=Tr(),x6=ea(),hi=Qt(),I6=Ve(),dp=ke(),qe=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};Object.defineProperty(qe.prototype,"k",{get:function(){return this._k},set:function(e){this._k=e,this._kFresh=!0},enumerable:!0,configurable:!0});qe.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(d.Buffer.isBuffer(e.sig)){var t=ir();this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return e.k&&(this.k=e.k),this.verified=e.verified||this.verified,this};qe.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()};qe.prototype.calci=function(){for(var e=0;e<4;e++){this.sig.i=e;var t;try{t=this.toPublicKey()}catch(r){console.error(r);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")};qe.fromString=function(e){var t=JSON.parse(e);return new qe(t)};qe.prototype.randomK=function(){var e=cn.getN(),t;do t=gr.fromBuffer(x6.getRandomBuffer(32));while(!(t.lt(e)&&t.gt(gr.Zero)));return this.k=t,this};qe.prototype.deterministicK=function(e){I6.isUndefined(e)&&(e=0);var t=d.Buffer.alloc(32);t.fill(1);var r=d.Buffer.alloc(32);r.fill(0);var n=this.privkey.bn.toBuffer({size:32}),i=this.endian==="little"?d.Buffer.from(this.hashbuf).reverse():this.hashbuf;r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0]),n,i]),r),t=hi.sha256hmac(t,r),r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([1]),n,i]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r);for(var o=gr.fromBuffer(t),s=cn.getN(),a=0;a<e||!(o.lt(s)&&o.gt(gr.Zero));a++)r=hi.sha256hmac(d.Buffer.concat([t,d.Buffer.from([0])]),r),t=hi.sha256hmac(t,r),t=hi.sha256hmac(t,r),o=gr.fromBuffer(t);return this.k=o,this};qe.prototype.toPublicKey=function(){var e=this.sig.i;dp.checkArgument(e===0||e===1||e===2||e===3,new Error("i must be equal to 0, 1, 2, or 3"));var t=gr.fromBuffer(this.hashbuf),r=this.sig.r,n=this.sig.s,i=e&1,o=e>>1,s=cn.getN(),a=cn.getG(),c=o?r.add(s):r,h=cn.fromX(i,c),g=h.mul(s);if(!g.isInfinity())throw new Error("nR is not a valid curve point");var y=t.neg().umod(s),w=r.invm(s),I=h.mul(n).add(a.mul(y)).mul(w),T=E6.fromPoint(I,this.sig.compressed);return T};qe.prototype.sigError=function(){if(!d.Buffer.isBuffer(this.hashbuf)||this.hashbuf.length!==32)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=cn.getN();try{if(e.lte(gr.Zero)||t.lte(gr.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var n=gr.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),i=t.invm(r),o=i.mul(n).umod(r),s=i.mul(e).umod(r),a=cn.getG().mulAdd(o,this.pubkey.point,s);return a.isInfinity()?"p is infinity":a.getX().umod(r).cmp(e)!==0?"Invalid signature":!1}catch(c){return"Signature security validation failed: "+c.message}};qe.toLowS=function(e){return e.gt(gr.fromBuffer(d.Buffer.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=cn.getN().sub(e)),e};qe.prototype._findSignature=function(e,t){var r=cn.getN(),n=cn.getG(),i=0,o,s,a,c;do(!this.k||!this._kFresh||i>0)&&this.deterministicK(i),i++,o=this.k,s=n.mul(o),a=s.x.umod(r),c=o.invm(r).mul(t.add(e.mul(a))).umod(r);while(a.cmp(gr.Zero)<=0||c.cmp(gr.Zero)<=0);return this._kFresh=!1,c=qe.toLowS(c),{s:c,r:a}};qe.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;dp.checkState(e&&t&&r,new Error("invalid parameters")),dp.checkState(d.Buffer.isBuffer(e)&&e.length===32,new Error("hashbuf must be a 32 byte buffer"));var n=gr.fromBuffer(e,this.endian?{endian:this.endian}:void 0),i=this._findSignature(r,n);return i.compressed=this.pubkey.compressed,this.sig=new w6(i),this};qe.prototype.signRandomK=function(){return this.randomK(),this.sign()};qe.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)};qe.prototype.verify=function(){return this.verified=!this.sigError(),this.verified};qe.prototype.verifyBool=function(){return this.verify()===!0};qe.sign=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().sig};qe.signWithCalcI=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig};qe.signRandomK=function(e,t,r){return qe().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig};qe.verify=function(e,t,r,n){return qe().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify()};h1.exports=qe});var os=P((jF,y1)=>{"use strict";m();var di=Ve(),A6=ke(),Ca=Jn(),O6=Qi(),pp=Tt(),p1=pr(),Ic=Kr(),R6=pi(),d1=Dn(),Ac=4294967295,T6=Ac-2,g1=Ac,P6=Ac-1;function He(e){if(!(this instanceof He))return new He(e);if(e)return this._fromObject(e)}He.MAXINT=Ac;He.DEFAULT_SEQNUMBER=g1;He.DEFAULT_LOCKTIME_SEQNUMBER=P6;He.DEFAULT_RBF_SEQNUMBER=T6;He.BASE_SIZE=40;Object.defineProperty(He.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new Ic(this._scriptBuffer),this._script._isInput=!0),this._script)}});He.fromObject=function(e){A6.checkArgument(di.isObject(e));var t=new He;return t._fromObject(e)};He.prototype._fromObject=function(e){var t;if(di.isString(e.prevTxId)&&p1.isHexa(e.prevTxId)?t=pp.Buffer.from(e.prevTxId,"hex"):t=e.prevTxId,this.output=e.output?e.output instanceof d1?e.output:new d1(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=di.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=di.isUndefined(e.sequenceNumber)?di.isUndefined(e.seqnum)?g1:e.seqnum:e.sequenceNumber,di.isUndefined(e.script)&&di.isUndefined(e.scriptBuffer))throw new Ca.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this};He.prototype.toObject=He.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t};He.fromBufferReader=function(e){var t=new He;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t};He.prototype.toBufferWriter=function(e){e||(e=new O6),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e};He.prototype.setScript=function(e){if(this._script=null,e instanceof Ic)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(e===null)this._script=Ic.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(p1.isHexa(e))this._scriptBuffer=pp.Buffer.from(e,"hex");else if(di.isString(e))this._script=new Ic(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(d.Buffer.isBuffer(e))this._scriptBuffer=pp.Buffer.from(e);else throw new TypeError("Invalid argument type: script");return this};He.prototype.getSignatures=function(){throw new Ca.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))};He.prototype.isFullySigned=function(){throw new Ca.AbstractMethodInvoked("Input#isFullySigned")};He.prototype.isFinal=function(){return this.sequenceNumber===He.MAXINT};He.prototype.addSignature=function(){throw new Ca.AbstractMethodInvoked("Input#addSignature")};He.prototype.clearSignatures=function(){throw new Ca.AbstractMethodInvoked("Input#clearSignatures")};He.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,R6.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};He.prototype.isNull=function(){return this.prevTxId.toString("hex")==="0000000000000000000000000000000000000000000000000000000000000000"&&this.outputIndex===4294967295};He.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length};y1.exports=He});var ss=P((VF,m1)=>{"use strict";m();m1.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}});var us=P((zF,_1)=>{"use strict";m();var as=Ve(),Pr=ke(),B6=ss(),v1=pr(),b1=Tr(),N6=Jn(),La=ir();function Vr(e){if(!(this instanceof Vr))return new Vr(e);if(e instanceof Vr)return e;if(as.isObject(e))return this._fromObject(e);throw new N6.InvalidArgument("TransactionSignatures must be instantiated from an object")}B6(Vr,La);Vr.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new b1(e.publicKey),this.prevTxId=d.Buffer.isBuffer(e.prevTxId)?e.prevTxId:d.Buffer.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof La?e.signature:d.Buffer.isBuffer(e.signature)?La.fromBuffer(e.signature):La.fromString(e.signature),this.sigtype=e.sigtype,this};Vr.prototype._checkObjectArgs=function(e){Pr.checkArgument(b1(e.publicKey),"publicKey"),Pr.checkArgument(!as.isUndefined(e.inputIndex),"inputIndex"),Pr.checkArgument(!as.isUndefined(e.outputIndex),"outputIndex"),Pr.checkState(as.isNumber(e.inputIndex),"inputIndex must be a number"),Pr.checkState(as.isNumber(e.outputIndex),"outputIndex must be a number"),Pr.checkArgument(e.signature,"signature"),Pr.checkArgument(e.prevTxId,"prevTxId"),Pr.checkState(e.signature instanceof La||d.Buffer.isBuffer(e.signature)||v1.isHexa(e.signature),"signature must be a buffer or hexa value"),Pr.checkState(d.Buffer.isBuffer(e.prevTxId)||v1.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),Pr.checkArgument(e.sigtype,"sigtype"),Pr.checkState(as.isNumber(e.sigtype),"sigtype must be a number")};Vr.prototype.toObject=Vr.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}};Vr.fromObject=function(e){return Pr.checkArgument(e),new Vr(e)};_1.exports=Vr});var I1=P((YF,x1)=>{"use strict";m();var M6=ss(),w1=ke(),gp=os(),k6=Dn(),C6=pi(),E1=Kr(),S1=ir(),L6=us();function Un(){gp.apply(this,arguments)}M6(Un,gp);Un.prototype.getSignatures=function(e,t,r,n){w1.checkState(this.output instanceof k6),n=n||S1.SIGHASH_ALL|S1.SIGHASH_FORKID;var i=t.toPublicKey();return i.toString()===this.output.script.getPublicKey().toString("hex")?[new L6({publicKey:i,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:C6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Un.prototype.addSignature=function(e,t){return w1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(E1.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this};Un.prototype.clearSignatures=function(){return this.setScript(E1.empty()),this};Un.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()};Un.SCRIPT_MAX_SIZE=74;Un.prototype._estimateSize=function(){return gp.BASE_SIZE+Un.SCRIPT_MAX_SIZE};x1.exports=Un});var P1=P((ZF,T1)=>{"use strict";m();var D6=ss(),O1=ke(),U6=Qt(),yp=os(),F6=Dn(),q6=pi(),R1=Kr(),A1=ir(),H6=us();function Fn(){yp.apply(this,arguments)}D6(Fn,yp);Fn.prototype.getSignatures=function(e,t,r,n,i){O1.checkState(this.output instanceof F6),i=i||U6.sha256ripemd160(t.publicKey.toBuffer()),n=n||A1.SIGHASH_ALL|A1.SIGHASH_FORKID;var o=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return o&&i.equals(o)?[new H6({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:q6.sign(e,t,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]};Fn.prototype.addSignature=function(e,t){return O1.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(R1.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this};Fn.prototype.clearSignatures=function(){return this.setScript(R1.empty()),this};Fn.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()};Fn.SCRIPT_MAX_SIZE=108;Fn.prototype._estimateSize=function(){return yp.BASE_SIZE+Fn.SCRIPT_MAX_SIZE};T1.exports=Fn});var M1=P((JF,N1)=>{"use strict";m();var Gr=Ve(),j6=ss(),Rc=os(),K6=Dn(),Da=ke(),B1=Kr(),Oc=ir(),mp=pi(),vp=us(),V6=Tr(),G6=Ma();function Pt(e,t,r,n){Rc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new V6(o)),Da.checkState(B1.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},Gr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}j6(Pt,Rc);Pt.prototype.toObject=function(){var e=Rc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=Gr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Pt.prototype._deserializeSignatures=function(e){return Gr.map(e,function(t){if(t)return new vp(t)})};Pt.prototype._serializeSignatures=function(){return Gr.map(this.signatures,function(e){if(e)return e.toObject()})};Pt.prototype.getSignatures=function(e,t,r,n){Da.checkState(this.output instanceof K6),n=n||Oc.SIGHASH_ALL|Oc.SIGHASH_FORKID;var i=this,o=[];return Gr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new vp({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:mp.sign(e,t,n,r,i.output.script,i.output.satoshisBN),sigtype:n}))}),o};Pt.prototype.addSignature=function(e,t){return Da.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Da.checkArgument(!Gr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Da.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Pt.prototype._updateScript=function(){return this.setScript(B1.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this};Pt.prototype._createSignatures=function(){return Gr.map(Gr.filter(this.signatures,function(e){return!Gr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Pt.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Pt.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Pt.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Pt.prototype.countSignatures=function(){return Gr.reduce(this.signatures,function(e,t){return e+!!t},0)};Pt.prototype.publicKeysWithoutSignature=function(){var e=this;return Gr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Pt.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,mp.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)};Pt.normalizeSignatures=function(e,t,r,n,i){return i.map(function(o){var s=null;return n=n.filter(function(a){if(s)return!0;var c=new vp({signature:Oc.fromTxFormat(a),publicKey:o,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:Oc.SIGHASH_ALL});c.signature.nhashtype=c.sigtype;var h=mp.verify(e,c.signature,c.publicKey,c.inputIndex,t.output.script);return h?(s=c,!1):!0}),s||null})};Pt.SIGNATURE_SIZE=73;Pt.prototype._estimateSize=function(){var e=1+this.threshold*Pt.SIGNATURE_SIZE;return Rc.BASE_SIZE+G6(e).toBuffer().length+e};N1.exports=Pt});var U1=P((e5,D1)=>{"use strict";m();var zr=Ve(),z6=ss(),Tc=os(),W6=Dn(),Ua=ke(),bp=Kr(),k1=ir(),C1=pi(),L1=us(),Y6=Tr(),$6=Ma();function Ot(e,t,r,n){Tc.apply(this,arguments);var i=this;t=t||e.publicKeys,r=r||e.threshold,n=n||e.signatures,this.publicKeys=t.map(o=>o.toString("hex")).sort().map(o=>new Y6(o)),this.redeemScript=bp.buildMultisigOut(this.publicKeys,r),Ua.checkState(bp.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},zr.each(this.publicKeys,function(o,s){i.publicKeyIndex[o.toString()]=s}),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}z6(Ot,Tc);Ot.prototype.toObject=function(){var e=Tc.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=zr.map(this.publicKeys,function(t){return t.toString()}),e.signatures=this._serializeSignatures(),e};Ot.prototype._deserializeSignatures=function(e){return zr.map(e,function(t){if(t)return new L1(t)})};Ot.prototype._serializeSignatures=function(){return zr.map(this.signatures,function(e){if(e)return e.toObject()})};Ot.prototype.getSignatures=function(e,t,r,n){Ua.checkState(this.output instanceof W6),n=n||k1.SIGHASH_ALL|k1.SIGHASH_FORKID;var i=this,o=[];return zr.each(this.publicKeys,function(s){s.toString()===t.publicKey.toString()&&o.push(new L1({publicKey:t.publicKey,prevTxId:i.prevTxId,outputIndex:i.outputIndex,inputIndex:r,signature:C1.sign(e,t,n,r,i.redeemScript,i.output.satoshisBN),sigtype:n}))}),o};Ot.prototype.addSignature=function(e,t){return Ua.checkState(!this.isFullySigned(),"All needed signatures have already been added"),Ua.checkArgument(!zr.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),Ua.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this};Ot.prototype._updateScript=function(){return this.setScript(bp.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this};Ot.prototype._createSignatures=function(){return zr.map(zr.filter(this.signatures,function(e){return!zr.isUndefined(e)}),function(e){return d.Buffer.concat([e.signature.toDER(),d.Buffer.from([e.sigtype&255])])})};Ot.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()};Ot.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold};Ot.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()};Ot.prototype.countSignatures=function(){return zr.reduce(this.signatures,function(e,t){return e+!!t},0)};Ot.prototype.publicKeysWithoutSignature=function(){var e=this;return zr.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})};Ot.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,C1.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)};Ot.SIGNATURE_SIZE=73;Ot.PUBKEY_SIZE=34;Ot.prototype._estimateSize=function(){var e=this.publicKeys.length*Ot.PUBKEY_SIZE,t=this.threshold*Ot.SIGNATURE_SIZE,r=3+e,n=r<=75?1:r<=255?2:3,i=t+1+n+r;return Tc.BASE_SIZE+$6(i).toBuffer().length+i};D1.exports=Ot});var Pc=P((r5,fs)=>{m();fs.exports=os();fs.exports.PublicKey=I1();fs.exports.PublicKeyHash=P1();fs.exports.MultiSig=M1();fs.exports.MultiSigScriptHash=U1()});var pi=P((i5,K1)=>{"use strict";m();var Z6=Tt(),fr=ir(),_p=Kr(),X6=Dn(),J6=va(),Fa=Qi(),F1=Er(),Bc=Qt(),q1=ka(),Sp=ke(),wp=Nc(),gi=Ve(),H1=d.Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Q6="ffffffffffffffff",ek=wp.SCRIPT_ENABLE_SIGHASH_FORKID,tk=function(e,t,r,n,i){var o=e.inputs[r];Sp.checkArgument(i instanceof F1,"For ForkId=0 signatures, satoshis or complete input must be provided");function s(M){var L=new Fa;gi.each(M.inputs,function(q){L.writeReverse(q.prevTxId),L.writeUInt32LE(q.outputIndex)});var j=L.toBuffer(),G=Bc.sha256sha256(j);return G}function a(M){var L=new Fa;gi.each(M.inputs,function(q){L.writeUInt32LE(q.sequenceNumber)});var j=L.toBuffer(),G=Bc.sha256sha256(j);return G}function c(M,L){var j=new Fa;gi.isUndefined(L)?gi.each(M.outputs,function(W){W.toBufferWriter(j)}):M.outputs[L].toBufferWriter(j);var G=j.toBuffer(),q=Bc.sha256sha256(G);return q}var h=d.Buffer.alloc(32),g=d.Buffer.alloc(32),y=d.Buffer.alloc(32);t&fr.SIGHASH_ANYONECANPAY||(h=s(e)),!(t&fr.SIGHASH_ANYONECANPAY)&&(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE&&(g=a(e)),(t&31)!==fr.SIGHASH_SINGLE&&(t&31)!==fr.SIGHASH_NONE?y=c(e):(t&31)===fr.SIGHASH_SINGLE&&r<e.outputs.length&&(y=c(e,r));var w=new Fa;w.writeInt32LE(e.version),w.write(h),w.write(g),w.writeReverse(o.prevTxId),w.writeUInt32LE(o.outputIndex),w.writeVarintNum(n.toBuffer().length),w.write(n.toBuffer()),w.writeUInt64LEBN(i);var I=o.sequenceNumber;w.writeUInt32LE(I),w.write(y),w.writeUInt32LE(e.nLockTime),w.writeUInt32LE(t>>>0);var T=w.toBuffer();return T},j1=function(t,r,n,i,o,s){var a=xp(),c=Pc();gi.isUndefined(s)&&(s=ek);var h=a.shallowCopy(t);if(i=new _p(i),s&wp.SCRIPT_ENABLE_REPLAY_PROTECTION){var g=r>>8,y=16711680|g^57005;r=y<<8|r&255}if(r&fr.SIGHASH_FORKID&&!(r&fr.SIGHASH_CHRONICLE)&&s&wp.SCRIPT_ENABLE_SIGHASH_FORKID)return tk(h,r,n,i,o);i.removeCodeseparators();var w;for(w=0;w<h.inputs.length;w++)h.inputs[w]=new c(h.inputs[w]).setScript(_p.empty());if(h.inputs[n]=new c(h.inputs[n]).setScript(i),(r&31)===fr.SIGHASH_NONE||(r&31)===fr.SIGHASH_SINGLE)for(w=0;w<h.inputs.length;w++)w!==n&&(h.inputs[w].sequenceNumber=0);if((r&31)===fr.SIGHASH_NONE)h.outputs=[];else if((r&31)===fr.SIGHASH_SINGLE){if(n>=h.outputs.length)return H1;for(h.outputs.length=n+1,w=0;w<n;w++)h.outputs[w]=new X6({satoshis:F1.fromBuffer(Z6.Buffer.from(Q6,"hex")),script:_p.empty()})}r&fr.SIGHASH_ANYONECANPAY&&(h.inputs=[h.inputs[n]]);var I=new Fa().write(h.toBuffer()).writeInt32LE(r).toBuffer();return I},Ep=function(t,r,n,i,o,s){var a=j1(t,r,n,i,o,s);if(a.compare(H1)===0)return a;var c=Bc.sha256sha256(a);return c=new J6(c).readReverse(),c};function rk(e,t,r,n,i,o,s){var a=Ep(e,r,n,i,o,s),c=q1.sign(a,t,"little").set({nhashtype:r});return c}function nk(e,t,r,n,i,o,s){Sp.checkArgument(!gi.isUndefined(e)),Sp.checkArgument(!gi.isUndefined(t)&&!gi.isUndefined(t.nhashtype));var a=Ep(e,t.nhashtype,n,i,o,s);return q1.verify(a,t,r,"little")}K1.exports={sighashPreimage:j1,sighash:Ep,sign:rk,verify:nk}});var Ip=P((s5,G1)=>{"use strict";m();var qn=Ve(),Mc=ke(),V1=pr(),ik=Kr(),ok=no();function Hn(e){if(!(this instanceof Hn))return new Hn(e);Mc.checkArgument(qn.isObject(e),"Must provide an object from where to extract data");var t=e.address?new ok(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!V1.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var n=qn.isUndefined(e.vout)?e.outputIndex:e.vout;if(!qn.isNumber(n))throw new Error("Invalid outputIndex, received "+n);Mc.checkArgument(!qn.isUndefined(e.scriptPubKey)||!qn.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var i=new ik(e.scriptPubKey||e.script);Mc.checkArgument(!qn.isUndefined(e.amount)||!qn.isUndefined(e.satoshis),"Must provide an amount for the output");var o=qn.isUndefined(e.amount)?e.satoshis:Math.round(e.amount*1e8);Mc.checkArgument(qn.isNumber(o),"Amount must be a number"),V1.defineImmutable(this,{address:t,txId:r,outputIndex:n,script:i,satoshis:o})}Hn.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"};Hn.prototype.toString=function(){return this.txId+":"+this.outputIndex};Hn.fromObject=function(e){return new Hn(e)};Hn.prototype.toObject=Hn.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}};G1.exports=Hn});var xp=P((u5,Q1)=>{"use strict";m();var pe=Ve(),Ft=ke(),sk=Tt(),Nt=Jn(),W1=pr(),Y1=va(),ak=Qi(),z1=Ma(),$1=Qt(),Cc=ir(),Z1=pi(),uk=no(),X1=Ip(),Bt=Pc(),fk=Bt.PublicKeyHash,ck=Bt.PublicKey,lk=Bt.MultiSigScriptHash,hk=Bt.MultiSig,Wr=Dn(),ln=Kr(),dk=io(),kc=Er(),pk=Nc(),gk=pk.SCRIPT_ENABLE_SIGHASH_FORKID;function z(e){if(!(this instanceof z))return new z(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof z)return z.shallowCopy(e);if(W1.isHexa(e))this.fromString(e);else if(d.Buffer.isBuffer(e))this.fromBuffer(e);else if(pe.isObject(e))this.fromObject(e);else throw new Nt.InvalidArgument("Must provide an object or string to deserialize a transaction")}else this._newTransaction()}var yk=1,mk=0,vk=1e6;z.DUST_AMOUNT=546;z.FEE_SECURITY_MARGIN=150;z.MAX_MONEY=21e6*1e8;z.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8;z.NLOCKTIME_MAX_VALUE=4294967295;z.FEE_PER_KB=500;z.CHANGE_OUTPUT_MAX_SIZE=62;z.shallowCopy=function(e){var t=new z(e.toBuffer());return t};var J1={configurable:!1,enumerable:!0,get:function(){return this._hash=new Y1(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(z.prototype,"hash",J1);Object.defineProperty(z.prototype,"id",J1);var Ap={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(z.prototype,"inputAmount",Ap);Ap.get=function(){return this._getOutputAmount()};Object.defineProperty(z.prototype,"outputAmount",Ap);z.prototype._getHash=function(){return $1.sha256sha256(this.toBuffer())};z.prototype.serialize=function(e){return e===!0||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)};z.prototype.uncheckedSerialize=z.prototype.toString=function(){return this.toBuffer().toString("hex")};z.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()};z.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e};z.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new Nt.Transaction.InvalidSatoshis;var t=this._getUnspentValue(),r;return t<0?e.disableMoreOutputThanInput||(r=new Nt.Transaction.InvalidOutputAmountSum):r=this._hasFeeError(e,t),r||this._hasDustOutputs(e)||this._isMissingSignatures(e)};z.prototype._hasFeeError=function(e,t){if(!pe.isUndefined(this._fee)&&this._fee!==t)return new Nt.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(z.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new Nt.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new Nt.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}};z.prototype._missingChange=function(){return!this._changeScript};z.prototype._hasDustOutputs=function(e){if(!e.disableDustOutputs){var t,r;for(t in this.outputs)if(r=this.outputs[t],r.satoshis<z.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new Nt.Transaction.DustOutputs}};z.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned&&!this.isFullySigned())return new Nt.Transaction.MissingSignatures};z.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"};z.prototype.toBuffer=function(){var e=new ak;return this.toBufferWriter(e).toBuffer()};z.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),pe.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),pe.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e};z.prototype.fromBuffer=function(e){var t=new Y1(e);return this.fromBufferReader(t)};z.prototype.fromBufferReader=function(e){Ft.checkArgument(!e.finished(),"No transaction data received");var t,r,n;for(this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var i=Bt.fromBufferReader(e);this.inputs.push(i)}for(n=e.readVarintNum(),t=0;t<n;t++)this.outputs.push(Wr.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this};z.prototype.toObject=z.prototype.toJSON=function(){var t=[];this.inputs.forEach(function(i){t.push(i.toObject())});var r=[];this.outputs.forEach(function(i){r.push(i.toObject())});var n={hash:this.hash,version:this.version,inputs:t,outputs:r,nLockTime:this.nLockTime};return this._changeScript&&(n.changeScript=this._changeScript.toString()),pe.isUndefined(this._changeIndex)||(n.changeIndex=this._changeIndex),pe.isUndefined(this._fee)||(n.fee=this._fee),n};z.prototype.fromObject=function(t){Ft.checkArgument(pe.isObject(t)||t instanceof z);var r=this,n;return t instanceof z?n=t.toObject():n=t,pe.each(n.inputs,function(i){if(!i.output||!i.output.script){r.uncheckedAddInput(new Bt(i));return}var o=new ln(i.output.script),s;if(o.isPublicKeyHashOut())s=new Bt.PublicKeyHash(i);else if(o.isScriptHashOut()&&i.publicKeys&&i.threshold)s=new Bt.MultiSigScriptHash(i,i.publicKeys,i.threshold,i.signatures);else if(o.isPublicKeyOut())s=new Bt.PublicKey(i);else throw new Nt.Transaction.Input.UnsupportedScript(i.output.script);r.addInput(s)}),pe.each(n.outputs,function(i){r.addOutput(new Wr(i))}),n.changeIndex&&(this._changeIndex=n.changeIndex),n.changeScript&&(this._changeScript=new ln(n.changeScript)),n.fee&&(this._fee=n.fee),this.nLockTime=n.nLockTime,this.version=n.version,this._checkConsistency(t),this};z.prototype._checkConsistency=function(e){pe.isUndefined(this._changeIndex)||(Ft.checkState(this._changeScript,"Change script is expected."),Ft.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),Ft.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&Ft.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")};z.prototype.lockUntilDate=function(e){if(Ft.checkArgument(e),pe.isNumber(e)&&e<z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.LockTimeTooEarly;pe.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};z.prototype.lockUntilBlockHeight=function(e){if(Ft.checkArgument(pe.isNumber(e)),e>=z.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new Nt.Transaction.BlockHeightTooHigh;if(e<0)throw new Nt.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===Bt.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=Bt.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this};z.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<z.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null};z.prototype.fromString=function(e){this.fromBuffer(sk.Buffer.from(e,"hex"))};z.prototype._newTransaction=function(){this.version=yk,this.nLockTime=mk};z.prototype.from=function(e,t,r){if(pe.isArray(e)){var n=this;return pe.each(e,function(o){n.from(o,t,r)}),this}var i=pe.some(this.inputs,function(o){return o.prevTxId.toString("hex")===e.txId&&o.outputIndex===e.outputIndex});return i?this:(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e),this)};z.prototype._fromNonP2SH=function(e){var t;e=new X1(e),e.script.isPublicKeyHashOutPrefix()?t=fk:e.script.isPublicKeyOut()?t=ck:t=Bt,this.addInput(new t({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()}))};z.prototype._fromMultisigUtxo=function(e,t,r){Ft.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys");var n;if(e=new X1(e),e.script.isMultisigOut())n=hk;else if(e.script.isScriptHashOut())n=lk;else throw new Nt.Transaction.Input.UnsupportedScript(e.script.toString());this.addInput(new n({output:new Wr({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:ln.empty()},t,r))};z.prototype.addInput=function(e,t,r){if(Ft.checkArgumentType(e,Bt,"input"),!e.output&&(pe.isUndefined(t)||pe.isUndefined(r)))throw new Nt.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return!e.output&&t&&!pe.isUndefined(r)&&(t=t instanceof ln?t:new ln(t),Ft.checkArgumentType(r,"number","satoshis"),e.output=new Wr({script:t,satoshis:r})),this.uncheckedAddInput(e)};z.prototype.uncheckedAddInput=function(e){return Ft.checkArgumentType(e,Bt,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this};z.prototype.hasAllUtxoInfo=function(){return pe.every(this.inputs.map(function(e){return!!e.output}))};z.prototype.fee=function(e){return Ft.checkArgument(pe.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this};z.prototype.feePerKb=function(e){return Ft.checkArgument(pe.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this};z.prototype.change=function(e){return Ft.checkArgument(e,"address is required"),this._changeScript=ln.fromAddress(e),this._updateChangeOutput(),this};z.prototype.getChangeOutput=function(){return pe.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]};z.prototype.to=function(e,t){if(pe.isArray(e)){var r=this;return pe.each(e,function(n){r.to(n.address,n.satoshis)}),this}return Ft.checkArgument(W1.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new Wr({script:ln(new uk(e)),satoshis:t})),this};z.prototype.addData=function(e){return this.addOutput(new Wr({script:ln.buildDataOut(e),satoshis:0})),this};z.prototype.addSafeData=function(e){return this.addOutput(new Wr({script:ln.buildSafeDataOut(e),satoshis:0})),this};z.prototype.addOutput=function(e){return Ft.checkArgumentType(e,Wr,"output"),this._addOutput(e),this._updateChangeOutput(),this};z.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this};z.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0};z.prototype._getOutputAmount=function(){if(pe.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,pe.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount};z.prototype._getInputAmount=function(){if(pe.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,pe.each(this.inputs,function(t){if(pe.isUndefined(t.output))throw new Nt.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount};z.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),pe.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue(),t=this.getFee(),r=e-t;this._removeOutput(this._changeIndex),this._changeIndex=void 0,r>=z.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new Wr({script:this._changeScript,satoshis:r})))}};z.prototype.getFee=function(){return this.isCoinbase()?0:pe.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee};z.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||z.FEE_PER_KB))};z.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()};z.prototype._clearSignatures=function(){pe.each(this.inputs,function(e){e.clearSignatures!==Bt.prototype.clearSignatures&&e.clearSignatures()})};z.prototype._estimateSize=function(){var e=8;return e+=z1(this.inputs.length).toBuffer().length,e+=z1(this.outputs.length).toBuffer().length,pe.each(this.inputs,function(t){e+=t._estimateSize()}),pe.each(this.outputs,function(t){e+=t.getSize()}),e};z.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=pe.without(this.outputs,t),this._outputAmount=void 0};z.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()};z.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.prevTxId.compare(n.prevTxId)||r.outputIndex-n.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(r,n){return r.satoshis-n.satoshis||r.script.toBuffer().compare(n.script.toBuffer())}),t}),this};z.prototype.shuffleOutputs=function(){return this.sortOutputs(pe.shuffle)};z.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)};z.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this};z.prototype._newOutputOrder=function(e){var t=this.outputs.length!==e.length||pe.difference(this.outputs,e).length!==0;if(t)throw new Nt.Transaction.InvalidSorting;if(!pe.isUndefined(this._changeIndex)){var r=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(r)}return this.outputs=e,this};z.prototype.removeInput=function(e,t){var r;if(!t&&pe.isNumber(e)?r=e:r=pe.findIndex(this.inputs,function(i){return i.prevTxId.toString("hex")===e&&i.outputIndex===t}),r<0||r>=this.inputs.length)throw new Nt.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=pe.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()};z.prototype.sign=function(e,t){Ft.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return pe.isArray(e)?(pe.each(e,function(n){r.sign(n,t)}),this):(pe.each(this.getSignatures(e,t),function(n){r.applySignature(n)}),this)};z.prototype.getSignatures=function(e,t){e=new dk(e),t=t||Cc.SIGHASH_ALL|Cc.SIGHASH_FORKID;var r=this,n=[],i=$1.sha256ripemd160(e.publicKey.toBuffer());return pe.each(this.inputs,function(s,a){pe.each(s.getSignatures(r,e,a,t,i),function(c){n.push(c)})}),n};z.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this};z.prototype.isFullySigned=function(){return pe.each(this.inputs,function(e){if(e.isFullySigned===Bt.prototype.isFullySigned)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),pe.every(pe.map(this.inputs,function(e){return e.isFullySigned()}))};z.prototype.isValidSignature=function(e){var t=this;if(this.inputs[e.inputIndex].isValidSignature===Bt.prototype.isValidSignature)throw new Nt.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(t,e)};z.prototype.verifySignature=function(e,t,r,n,i,o){return Z1.verify(this,e,t,r,n,i,o)};z.prototype.verify=function(){if(this.inputs.length===0)return"transaction txins empty";if(this.outputs.length===0)return"transaction txouts empty";for(var e=new kc(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new kc(z.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if(e=e.add(r._satoshisBN),e.gt(new kc(z.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>vk)return"transaction over the maximum block size";var n={};for(t=0;t<this.inputs.length;t++){var i=this.inputs[t],o=i.prevTxId+":"+i.outputIndex;if(!pe.isUndefined(n[o]))return"transaction input "+t+" duplicate input";n[o]=!0}var s=this.isCoinbase();if(s){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0};z.prototype.isCoinbase=function(){return this.inputs.length===1&&this.inputs[0].isNull()};z.prototype.sighash=function(e,t,r,n,i){t=t||Cc.SIGHASH_ALL|Cc.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new kc(o.output.satoshis)),i=i||gk,Z1.sighash(this,t,e,r,n,i)};Q1.exports=z});var Op=P((c5,oo)=>{m();oo.exports=xp();oo.exports.Input=Pc();oo.exports.Output=Dn();oo.exports.UnspentOutput=Ip();oo.exports.Signature=us();oo.exports.Sighash=pi()});var Nc=P((h5,rx)=>{"use strict";m();var Lc=Ve(),Ha=fp(),N=sp(),fe=Er(),qa=Qt(),yi=ir(),Rp=Tr();function ex(e){return e.map(function(t){return d.Buffer.isBuffer(t)?d.Buffer.from(t):t})}var B=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};B.prototype.verify=function(e,t,r,n,i,o){var s=Op();if(Lc.isUndefined(r)&&(r=new s),Lc.isUndefined(n)&&(n=0),Lc.isUndefined(i)&&(i=B.currentConsensusFlags(),o||(i&=~B.SCRIPT_ENABLE_SIGHASH_FORKID)),i&B.SCRIPT_ENABLE_SIGHASH_FORKID&&(i|=B.SCRIPT_VERIFY_STRICTENC,!o))throw new Error("internal error - need satoshisBN to verify FORKID transactions");this.set({script:e,tx:r,nin:n,flags:i,satoshisBN:o});var a;if((i&B.SCRIPT_VERIFY_SIGPUSHONLY)!==0&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;var c=(i&B.SCRIPT_VERIFY_P2SH)!==0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0;c&&(a=this.stack.slice());var h=this.stack;if(this.initialize(),this.set({script:t,stack:h,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(this.stack.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var g=this.stack[this.stack.length-1];if(!B.castToBool(g))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(c&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(a.length===0)throw new Error("internal error - stack copy empty");var y=a[a.length-1],w=Ha.fromBuffer(y);if(a.pop(),this.initialize(),this.set({script:w,stack:a,tx:r,nin:n,flags:i,satoshisBN:o}),!this.evaluate())return!1;if(a.length===0)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!B.castToBool(a[a.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if((i&B.SCRIPT_VERIFY_CLEANSTACK)!==0){if((i&B.SCRIPT_VERIFY_P2SH)===0&&(i&B.SCRIPT_UTXO_AFTER_GENESIS)===0)throw new Error("internal error - CLEANSTACK without P2SH");if(this.stack.length!==1)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0};rx.exports=B;B.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.returned=!1,this.nonTopLevelReturnAfterGenesis=!1,this.vfExec=[],this.vfElse=[],this.errstr="",this.flags=0};B.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=typeof e.nin<"u"?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=typeof e.pc<"u"?e.pc:this.pc,this.pbegincodehash=typeof e.pbegincodehash<"u"?e.pbegincodehash:this.pbegincodehash,this.nOpCount=typeof e.nOpCount<"u"?e.nOpCount:this.nOpCount,this.returned=typeof e.returned<"u"?e.returned:this.returned,this.nonTopLevelReturnAfterGenesis=typeof e.nonTopLevelReturnAfterGenesis<"u"?e.nonTopLevelReturnAfterGenesis:this.nonTopLevelReturnAfterGenesis,this.vfExec=e.vfExec||this.vfExec,this.vfElse=e.vfElse||this.vfElse,this.errstr=e.errstr||this.errstr,this.flags=typeof e.flags<"u"?e.flags:this.flags};B.true=d.Buffer.from([1]);B.false=d.Buffer.from([]);B.MAX_SCRIPT_ELEMENT_SIZE=520;B.MAXIMUM_ELEMENT_SIZE=4;B.MAX_OPS_PER_SCRIPT=500;B.MAX_SCRIPT_SIZE=1e4;B.UNLIMITED=Number.MAX_SAFE_INTEGER;B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS=75e4;B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE=32e6;B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS=4294967295;B.LOCKTIME_THRESHOLD=5e8;B.LOCKTIME_THRESHOLD_BN=new fe(B.LOCKTIME_THRESHOLD);B.useGenesisLimits=function(e){return e=e||2147483647,B.MAX_SCRIPT_ELEMENT_SIZE=e,B.MAXIMUM_ELEMENT_SIZE=e,B.MAX_OPS_PER_SCRIPT=e,B.MAX_SCRIPT_SIZE=e,B};B.getLimits=function(){return{maxScriptElementSize:B.MAX_SCRIPT_ELEMENT_SIZE,maximumElementSize:B.MAXIMUM_ELEMENT_SIZE,maxOpsPerScript:B.MAX_OPS_PER_SCRIPT,maxScriptSize:B.MAX_SCRIPT_SIZE}};B.setLimits=function(e){return e=e||{},e.maxScriptElementSize!=null&&(B.MAX_SCRIPT_ELEMENT_SIZE=e.maxScriptElementSize),e.maximumElementSize!=null&&(B.MAXIMUM_ELEMENT_SIZE=e.maximumElementSize),e.maxOpsPerScript!=null&&(B.MAX_OPS_PER_SCRIPT=e.maxOpsPerScript),e.maxScriptSize!=null&&(B.MAX_SCRIPT_SIZE=e.maxScriptSize),B};B.SCRIPT_VERIFY_NONE=0;B.SCRIPT_VERIFY_P2SH=1;B.SCRIPT_VERIFY_STRICTENC=2;B.SCRIPT_VERIFY_DERSIG=4;B.SCRIPT_VERIFY_LOW_S=8;B.SCRIPT_VERIFY_NULLDUMMY=16;B.SCRIPT_VERIFY_SIGPUSHONLY=32;B.SCRIPT_VERIFY_MINIMALDATA=64;B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128;B.SCRIPT_VERIFY_CLEANSTACK=256;B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512;B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024;B.SCRIPT_VERIFY_MINIMALIF=8192;B.SCRIPT_VERIFY_NULLFAIL=16384;B.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768;B.SCRIPT_ENABLE_SIGHASH_FORKID=65536;B.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17;B.SCRIPT_ENABLE_MONOLITH_OPCODES=2048;B.SCRIPT_ENABLE_MAGNETIC_OPCODES=4096;B.SCRIPT_GENESIS=1<<18;B.SCRIPT_UTXO_AFTER_GENESIS=1<<19;B.SCRIPT_ENABLE_CHRONICLE=1<<20;B.SCRIPT_CHRONICLE=B.SCRIPT_ENABLE_CHRONICLE;B.SCRIPT_UTXO_AFTER_CHRONICLE=1<<21;B.CHRONICLE_ACTIVATION_HEIGHT=943816;B.mainnetFlags=function(e){e=e||{};var t=B.SCRIPT_VERIFY_P2SH|B.SCRIPT_VERIFY_STRICTENC|B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_NULLFAIL|B.SCRIPT_VERIFY_MINIMALDATA|B.SCRIPT_ENABLE_SIGHASH_FORKID|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_ENABLE_MONOLITH_OPCODES|B.SCRIPT_GENESIS|B.SCRIPT_UTXO_AFTER_GENESIS;return e.afterChronicle!==!1&&(t|=B.SCRIPT_ENABLE_CHRONICLE|B.SCRIPT_UTXO_AFTER_CHRONICLE),t};B.currentConsensusFlags=function(){return B.SCRIPT_ENABLE_MONOLITH_OPCODES|B.SCRIPT_ENABLE_MAGNETIC_OPCODES|B.SCRIPT_GENESIS|B.SCRIPT_UTXO_AFTER_GENESIS|B.SCRIPT_ENABLE_CHRONICLE|B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_SIGHASH_FORKID};B.useMainnetConsensus=function(e){return e=e||{},B.useGenesisLimits(e.max),B.mainnetFlags(e)};B.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31;B.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22;B.SEQUENCE_LOCKTIME_MASK=65535;B.castToBool=function(e){for(var t=0;t<e.length;t++)if(e[t]!==0)return!(t===e.length-1&&e[t]===128);return!1};B.prototype.checkSignatureEncoding=function(e){var t;if(e.length===0)return!0;if((this.flags&(B.SCRIPT_VERIFY_DERSIG|B.SCRIPT_VERIFY_LOW_S|B.SCRIPT_VERIFY_STRICTENC))!==0&&!yi.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if((this.flags&B.SCRIPT_VERIFY_LOW_S)!==0){if(t=yi.fromTxFormat(e),!t.hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if((this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0){if(t=yi.fromTxFormat(e),!t.hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&yi.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(!(this.flags&B.SCRIPT_CHRONICLE)&&t.nhashtype&yi.SIGHASH_CHRONICLE)return this.errstr="SCRIPT_ERR_ILLEGAL_CHRONICLE",!1;if(this.flags&B.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&yi.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0};B.prototype.checkPubkeyEncoding=function(e){return(this.flags&B.SCRIPT_VERIFY_STRICTENC)!==0&&!Rp.isValid(e)?(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1):!0};B.prototype.isAfterGenesis=function(){return(this.flags&B.SCRIPT_UTXO_AFTER_GENESIS)!==0};B.prototype.isAfterChronicle=function(){return(this.flags&(B.SCRIPT_UTXO_AFTER_CHRONICLE|B.SCRIPT_ENABLE_CHRONICLE))!==0};B.prototype.maxScriptElementSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_ELEMENT_SIZE};B.prototype.maxScriptSize=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_SCRIPT_SIZE};B.prototype.maxOpsPerScript=function(){return this.isAfterGenesis()?B.UNLIMITED:B.MAX_OPS_PER_SCRIPT};B.prototype.maxScriptNumLength=function(){return this.isAfterChronicle()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE:this.isAfterGenesis()?B.MAX_SCRIPT_NUM_LENGTH_AFTER_GENESIS:B.MAXIMUM_ELEMENT_SIZE};B.prototype.maxPubKeysPerMultisig=function(){return this.isAfterGenesis()?B.MAX_PUBKEYS_PER_MULTISIG_AFTER_GENESIS:20};B._isMinimallyEncoded=function(e,t){return t=t||B.MAXIMUM_ELEMENT_SIZE,!(e.length>t||e.length>0&&(e[e.length-1]&127)===0&&(e.length<=1||(e[e.length-2]&128)===0))};B._minimallyEncode=function(e){if(e.length===0)return e;var t=e[e.length-1];if(t&127)return e;if(e.length===1)return d.Buffer.from("");if(e[e.length-2]&128)return e;for(var r=e.length-1;r>0;r--)if(e[r-1]!==0)return e[r-1]&128?e[r++]=t:e[r-1]|=t,e.slice(0,r);return d.Buffer.from("")};B.prototype.evaluate=function(){if(this.script.toBuffer().length>this.maxScriptSize())return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:N.fromNumber(this.script.chunks[this.pc].opcodenum)};var e=this.step();if(!e)return!1;if(this._callbackStep(t),this.returned)return!0}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr=t.scriptErr||"SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return this.vfExec.length>0?(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1):!0};B.prototype._callbackStep=function(e){if(typeof this.stepListener=="function")try{this.stepListener(e,ex(this.stack),ex(this.altstack))}catch(t){console.log(`Error in Step callback:${t}`)}};B.prototype.checkLockTime=function(e){if(!(this.tx.nLockTime<B.LOCKTIME_THRESHOLD&&e.lt(B.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=B.LOCKTIME_THRESHOLD&&e.gte(B.LOCKTIME_THRESHOLD_BN))||e.gt(new fe(this.tx.nLockTime)))return!1;var t=this.tx.inputs[this.nin];return!(!t||t.isFinal())};B.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin];if(!t)return!1;var r=t.sequenceNumber;if(this.tx.version<2||r&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var n=B.SEQUENCE_LOCKTIME_TYPE_FLAG|B.SEQUENCE_LOCKTIME_MASK,i=new fe(r&n),o=e.and(new fe(n)),s=new fe(B.SEQUENCE_LOCKTIME_TYPE_FLAG);return!(!(i.lt(s)&&o.lt(s)||i.gte(s)&&o.gte(s))||o.gt(i))};function bk(e,t){let r=e;for(;r.length<t;)r=d.Buffer.concat([d.Buffer.from([0]),r]);return r}function tx(e){var t=d.Buffer.alloc(4);return t.writeInt32LE(e|0,0),t}B.prototype.step=function(){var e=this;function t(re){return e.stack[e.stack.length+re]}function r(re){switch(re){case N.OP_2MUL:case N.OP_2DIV:if(!e.isAfterChronicle())return!0;break;case N.OP_INVERT:case N.OP_MUL:case N.OP_LSHIFT:case N.OP_RSHIFT:if((e.flags&B.SCRIPT_ENABLE_MAGNETIC_OPCODES)===0)return!0;break;case N.OP_DIV:case N.OP_MOD:case N.OP_SPLIT:case N.OP_CAT:case N.OP_AND:case N.OP_OR:case N.OP_XOR:case N.OP_BIN2NUM:case N.OP_NUM2BIN:return!1;default:break}return!1}var n=(this.flags&B.SCRIPT_VERIFY_MINIMALDATA)!==0,i,o,s,a,c,h,g,y,w,I,T,M,L,j,G,q,W,J=this.script.chunks[this.pc];this.pc++;var Y=J.opcodenum,be=this.vfExec.indexOf(!1)===-1&&(!this.nonTopLevelReturnAfterGenesis||Y===N.OP_RETURN);if(Lc.isUndefined(Y))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(J.buf&&J.buf.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(Y>N.OP_16&&++this.nOpCount>this.maxOpsPerScript())return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(r(Y)&&(!this.isAfterGenesis()||be))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(be&&Y>=0&&Y<=N.OP_PUSHDATA4){if(n&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(!J.buf)this.stack.push(B.false);else{if(J.len!==J.buf.length)return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;this.stack.push(J.buf)}}else if(be||N.OP_IF<=Y&&Y<=N.OP_ENDIF)switch(Y){case N.OP_1NEGATE:case N.OP_1:case N.OP_2:case N.OP_3:case N.OP_4:case N.OP_5:case N.OP_6:case N.OP_7:case N.OP_8:case N.OP_9:case N.OP_10:case N.OP_11:case N.OP_12:case N.OP_13:case N.OP_14:case N.OP_15:case N.OP_16:c=Y-(N.OP_1-1),i=new fe(c).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_NOP:break;case N.OP_NOP2:case N.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var se=fe.fromScriptNumBuffer(this.stack[this.stack.length-1],n,5);if(se.lt(new fe(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(se))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP3:case N.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&B.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)||this.isAfterGenesis()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var de=fe.fromScriptNumBuffer(t(-1),n,5);if(de.lt(new fe(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if((de&B.SEQUENCE_LOCKTIME_DISABLE_FLAG)!==0)break;if(!this.checkSequence(de))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case N.OP_NOP1:case N.OP_NOP9:case N.OP_NOP10:if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case N.OP_LSHIFTNUM:case N.OP_RSHIFTNUM:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var A=this.maxScriptNumLength(),u=fe.fromScriptNumBuffer(t(-1),n,A);if(u.isNeg())return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop();var l=fe.fromScriptNumBuffer(t(-1),n,A);this.stack.pop();var p=u.toNumber(),v=l.isNeg(),b=l.abs(),E;if(Y===N.OP_LSHIFTNUM){var O=l.toScriptNumBuffer().length;if(O+Math.floor(p/8)>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;E=b.shln(p)}else E=p>=b.bitLength()?new fe(0):b.shrn(p);if(v&&!E.isZero()&&(E=E.neg()),E.toScriptNumBuffer().length>A)return this.errstr="SCRIPT_ERR_SCRIPTNUM_OVERFLOW",!1;this.stack.push(E.toScriptNumBuffer());break;case N.OP_VER:if(!this.isAfterChronicle())return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;this.stack.push(tx(this.tx.version));break;case N.OP_VERIF:case N.OP_VERNOTIF:if(!this.isAfterChronicle()){if(this.isAfterGenesis()&&!be)break;return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}if(q=!1,be){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(this.tx==null)return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR",!1;i=t(-1),q=i.length===4&&i.equals(tx(this.tx.version)),Y===N.OP_VERNOTIF&&(q=!q),this.stack.pop()}this.vfExec.push(q),this.vfElse.push(!1);break;case N.OP_IF:case N.OP_NOTIF:if(q=!1,be){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(i=t(-1),this.flags&B.SCRIPT_VERIFY_MINIMALIF){if(i.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(i.length===1&&i[0]!==1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1}q=B.castToBool(i),Y===N.OP_NOTIF&&(q=!q),this.stack.pop()}this.vfExec.push(q),this.vfElse.push(!1);break;case N.OP_ELSE:if(this.vfExec.length===0||this.vfElse[this.vfElse.length-1]&&this.isAfterGenesis())return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1],this.vfElse[this.vfElse.length-1]=!0;break;case N.OP_ENDIF:if(this.vfExec.length===0)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop(),this.vfElse.pop();break;case N.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),q=B.castToBool(i),q)this.stack.pop();else return this.errstr="SCRIPT_ERR_VERIFY",!1;break;case N.OP_RETURN:if(this.isAfterGenesis()){if(this.vfExec.length===0){this.returned=!0;break}this.nonTopLevelReturnAfterGenesis=!0;break}return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case N.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case N.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case N.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case N.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3),s=t(-2);var _=t(-1);this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s)),this.stack.push(d.Buffer.from(_));break;case N.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-4),s=t(-3),this.stack.push(d.Buffer.from(o)),this.stack.push(d.Buffer.from(s));break;case N.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-6,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;a=this.stack.splice(this.stack.length-4,2),this.stack.push(a[0]),this.stack.push(a[1]);break;case N.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1),q=B.castToBool(i),q&&this.stack.push(d.Buffer.from(i));break;case N.OP_DEPTH:i=new fe(this.stack.length).toScriptNumBuffer(),this.stack.push(i);break;case N.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case N.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-1)));break;case N.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case N.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(d.Buffer.from(t(-2)));break;case N.OP_PICK:case N.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(i=t(-1),y=fe.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),c=y.toNumber(),this.stack.pop(),c<0||c>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-c-1),Y===N.OP_ROLL&&this.stack.splice(this.stack.length-c-1,1),this.stack.push(d.Buffer.from(i));break;case N.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=t(-3),g=t(-2);var f=t(-1);this.stack[this.stack.length-3]=g,this.stack[this.stack.length-2]=f,this.stack[this.stack.length-1]=h;break;case N.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;h=t(-2),g=t(-1),this.stack[this.stack.length-2]=g,this.stack[this.stack.length-1]=h;break;case N.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,d.Buffer.from(t(-1)));break;case N.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new fe(t(-1).length),this.stack.push(y.toScriptNumBuffer());break;case N.OP_AND:case N.OP_OR:case N.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length!==s.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(Y){case N.OP_AND:for(let re=0;re<o.length;re++)o[re]&=s[re];break;case N.OP_OR:for(let re=0;re<o.length;re++)o[re]|=s[re];break;case N.OP_XOR:for(let re=0;re<o.length;re++)o[re]^=s[re];break;default:break}this.stack.pop();break;case N.OP_INVERT:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);for(let re=0;re<i.length;re++)i[re]=~i[re];break;case N.OP_LSHIFT:case N.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),o.length===0)this.stack.pop();else{if(w=new fe(o),I=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),c=I.toNumber(),c<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop();let re;Y===N.OP_LSHIFT&&(re=w.ushln(c)),Y===N.OP_RSHIFT&&(re=w.ushrn(c));let me=bk(d.Buffer.from(re.toArray().slice(o.length*-1)),o.length);this.stack.push(me)}break;case N.OP_EQUAL:case N.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2),s=t(-1);var S=o.toString("hex")===s.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(S?B.true:B.false),Y===N.OP_EQUALVERIFY)if(S)this.stack.pop();else return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;break;case N.OP_2MUL:case N.OP_2DIV:case N.OP_1ADD:case N.OP_1SUB:case N.OP_NEGATE:case N.OP_ABS:case N.OP_NOT:case N.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(i=t(-1),y=fe.fromScriptNumBuffer(i,n,this.maxScriptNumLength()),Y){case N.OP_2MUL:y=y.mul(new fe(2));break;case N.OP_2DIV:y=y.div(new fe(2));break;case N.OP_1ADD:y=y.add(fe.One);break;case N.OP_1SUB:y=y.sub(fe.One);break;case N.OP_NEGATE:y=y.neg();break;case N.OP_ABS:y.cmp(fe.Zero)<0&&(y=y.neg());break;case N.OP_NOT:y=new fe((y.cmp(fe.Zero)===0)+0);break;case N.OP_0NOTEQUAL:y=new fe((y.cmp(fe.Zero)!==0)+0);break}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case N.OP_ADD:case N.OP_SUB:case N.OP_MUL:case N.OP_MOD:case N.OP_DIV:case N.OP_BOOLAND:case N.OP_BOOLOR:case N.OP_NUMEQUAL:case N.OP_NUMEQUALVERIFY:case N.OP_NUMNOTEQUAL:case N.OP_LESSTHAN:case N.OP_GREATERTHAN:case N.OP_LESSTHANOREQUAL:case N.OP_GREATERTHANOREQUAL:case N.OP_MIN:case N.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(w=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()),I=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()),y=new fe(0),Y){case N.OP_ADD:y=w.add(I);break;case N.OP_SUB:y=w.sub(I);break;case N.OP_MUL:y=w.mul(I);break;case N.OP_DIV:if(I.cmp(fe.Zero)===0)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=w.div(I);break;case N.OP_MOD:if(I.cmp(fe.Zero)===0)return this.errstr="SCRIPT_ERR_MOD_BY_ZERO",!1;y=w.mod(I);break;case N.OP_BOOLAND:y=new fe((w.cmp(fe.Zero)!==0&&I.cmp(fe.Zero)!==0)+0);break;case N.OP_BOOLOR:y=new fe((w.cmp(fe.Zero)!==0||I.cmp(fe.Zero)!==0)+0);break;case N.OP_NUMEQUAL:y=new fe((w.cmp(I)===0)+0);break;case N.OP_NUMEQUALVERIFY:y=new fe((w.cmp(I)===0)+0);break;case N.OP_NUMNOTEQUAL:y=new fe((w.cmp(I)!==0)+0);break;case N.OP_LESSTHAN:y=new fe((w.cmp(I)<0)+0);break;case N.OP_GREATERTHAN:y=new fe((w.cmp(I)>0)+0);break;case N.OP_LESSTHANOREQUAL:y=new fe((w.cmp(I)<=0)+0);break;case N.OP_GREATERTHANOREQUAL:y=new fe((w.cmp(I)>=0)+0);break;case N.OP_MIN:y=w.cmp(I)<0?w:I;break;case N.OP_MAX:y=w.cmp(I)>0?w:I;break}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),Y===N.OP_NUMEQUALVERIFY)if(B.castToBool(t(-1)))this.stack.pop();else return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;break;case N.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;w=fe.fromScriptNumBuffer(t(-3),n,this.maxScriptNumLength()),I=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength());var K=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength());q=I.cmp(w)<=0&&w.cmp(K)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(q?B.true:B.false);break;case N.OP_RIPEMD160:case N.OP_SHA1:case N.OP_SHA256:case N.OP_HASH160:case N.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;i=t(-1);var F;Y===N.OP_RIPEMD160?F=qa.ripemd160(i):Y===N.OP_SHA1?F=qa.sha1(i):Y===N.OP_SHA256?F=qa.sha256(i):Y===N.OP_HASH160?F=qa.sha256ripemd160(i):Y===N.OP_HASH256&&(F=qa.sha256sha256(i)),this.stack.pop(),this.stack.push(F);break;case N.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case N.OP_CHECKSIG:case N.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(T=t(-2),M=t(-1),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;L=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});var $=new Ha().add(T);L.findAndDelete($);try{j=yi.fromTxFormat(T),G=Rp.fromBuffer(M,!1),W=this.tx.verifySignature(j,G,this.nin,L,this.satoshisBN,this.flags)}catch{W=!1}if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&T.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(W?B.true:B.false),Y===N.OP_CHECKSIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;break;case N.OP_CHECKMULTISIG:case N.OP_CHECKMULTISIGVERIFY:var Z=1;if(this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Q=fe.fromScriptNumBuffer(t(-Z),n,this.maxScriptNumLength()).toNumber();if(Q<0||Q>this.maxPubKeysPerMultisig())return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=Q,this.nOpCount>B.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var ae=++Z;Z+=Q;var ge=Q+2;if(this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var le=fe.fromScriptNumBuffer(t(-Z),n,this.maxScriptNumLength()).toNumber();if(le<0||le>Q)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var R=++Z;if(Z+=le,this.stack.length<Z)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;L=new Ha().set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var k=0;k<le;k++)T=t(-R-k),L.findAndDelete(new Ha().add(T));for(W=!0;W&&le>0;){if(T=t(-R),M=t(-ae),!this.checkSignatureEncoding(T)||!this.checkPubkeyEncoding(M))return!1;var H;try{j=yi.fromTxFormat(T),G=Rp.fromBuffer(M,!1),H=this.tx.verifySignature(j,G,this.nin,L,this.satoshisBN,this.flags)}catch{H=!1}H&&(R++,le--),ae++,Q--,le>Q&&(W=!1)}for(;Z-- >1;){if(!W&&this.flags&B.SCRIPT_VERIFY_NULLFAIL&&!ge&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;ge>0&&ge--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&B.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(W?B.true:B.false),Y===N.OP_CHECKMULTISIGVERIFY)if(W)this.stack.pop();else return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;break;case N.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),s=t(-1),o.length+s.length>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=d.Buffer.concat([o,s]),this.stack.pop();break;case N.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-2);var V=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(V<0||V>o.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var ie=d.Buffer.from(o);this.stack[this.stack.length-2]=ie.slice(0,V),this.stack[this.stack.length-1]=ie.slice(V);break;case N.OP_LEFT:case N.OP_RIGHT:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-2),c=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),c<0||c>o.length)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),Y===N.OP_LEFT?this.stack[this.stack.length-1]=d.Buffer.from(o).slice(0,c):this.stack[this.stack.length-1]=d.Buffer.from(o).slice(o.length-c);break;case N.OP_SUBSTR:if(!this.isAfterChronicle()){if(this.flags&B.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;o=t(-3);var ee=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber(),te=fe.fromScriptNumBuffer(t(-2),n,this.maxScriptNumLength()).toNumber();if(te<0||te>=o.length||ee<0||ee>o.length-te)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=d.Buffer.from(o).slice(te,te+ee);break;case N.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var he=fe.fromScriptNumBuffer(t(-1),n,this.maxScriptNumLength()).toNumber();if(he<0||he>this.maxScriptElementSize())return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var oe=t(-1);if(oe=B._minimallyEncode(oe),oe.length>he)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(oe.length===he){this.stack[this.stack.length-1]=oe;break}var ue=0;oe.length>0&&(ue=oe[oe.length-1]&128,oe[oe.length-1]&=127);var We=d.Buffer.alloc(he);oe.copy(We,0);for(var Oe=oe.length-1;Oe++<he-2;)We[Oe]=0;We[Oe]=ue,this.stack[this.stack.length-1]=We;break;case N.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(o=t(-1),s=B._minimallyEncode(o),this.stack[this.stack.length-1]=s,!B._isMinimallyEncoded(s))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}});var Kr=P((p5,Tp)=>{m();Tp.exports=fp();Tp.exports.Interpreter=Nc()});var no=P((y5,sx)=>{"use strict";m();var Pp=Ve(),jn=ke(),_k=Jn(),nx=Fd(),Br=ga(),ix=Qt(),ox=pr(),Bp=Tr();function ne(e,t,r){if(!(this instanceof ne))return new ne(e,t,r);if(Pp.isArray(e)&&Pp.isNumber(t))return ne.createMultisig(e,t,r);if(e instanceof ne)return e;if(jn.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!Br.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==ne.PayToPublicKeyHash&&r!==ne.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var n=this._classifyArguments(e,t,r);return n.network=n.network||Br.get(t)||Br.defaultNetwork,n.type=n.type||r||ne.PayToPublicKeyHash,ox.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}ne.prototype._classifyArguments=function(e,t,r){if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===20)return ne._transformHash(e);if((e instanceof d.Buffer||e instanceof Uint8Array)&&e.length===21)return ne._transformBuffer(e,t,r);if(e instanceof Bp)return ne._transformPublicKey(e);if(e instanceof ja())return ne._transformScript(e,t);if(typeof e=="string")return ne._transformString(e,t,r);if(Pp.isObject(e))return ne._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")};ne.PayToPublicKeyHash="pubkeyhash";ne.PayToScriptHash="scripthash";ne._transformHash=function(e){var t={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==20)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t};ne._transformObject=function(e){return jn.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),jn.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?d.Buffer.from(e.hash,"hex"):e.hashBuffer,network:Br.get(e.network)||Br.defaultNetwork,type:e.type}};ne._classifyFromVersion=function(e){var t={},r=Br.get(e[0],"pubkeyhash"),n=Br.get(e[0],"scripthash");return r?(t.network=r,t.type=ne.PayToPublicKeyHash):n&&(t.network=n,t.type=ne.PayToScriptHash),t};ne._transformBuffer=function(e,t,r){var n={};if(!(e instanceof d.Buffer)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length!==21)throw new TypeError("Address buffers must be exactly 21 bytes.");var i=Br.get(t),o=ne._classifyFromVersion(e);if(t&&!i)throw new TypeError("Unknown network");if(!o.network||i&&i!==o.network)throw new TypeError("Address has mismatched network type.");if(!o.type||r&&r!==o.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=o.network,n.type=o.type,n};ne._transformPublicKey=function(e){var t={};if(!(e instanceof Bp))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=ix.sha256ripemd160(e.toBuffer()),t.type=ne.PayToPublicKeyHash,t};ne._transformScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new _k.Script.CantDeriveAddress(e);return r};ne.createMultisig=function(e,t,r){return r=r||e[0].network||Br.defaultNetwork,ne.payingTo(ja().buildMultisigOut(e,t),r)};ne._transformString=function(e,t,r){if(typeof e!="string")throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var n=Br.get(t);if(t&&!n)throw new TypeError("Unknown network");var i=nx.decode(e);return ne._transformBuffer(i,t,r)};ne.fromPublicKey=function(e,t){var r=ne._transformPublicKey(e);return t=t||Br.defaultNetwork,new ne(r.hashBuffer,t,r.type)};ne.fromPrivateKey=function(e,t){let r=Bp.fromPrivateKey(e);return t=t||e.network||Br.defaultNetwork,ne.fromPublicKey(r,t)};ne.fromPublicKeyHash=function(e,t){var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToPublicKeyHash)};ne.fromScriptHash=function(e,t){jn.checkArgument(e,"hash parameter is required");var r=ne._transformHash(e);return new ne(r.hashBuffer,t,ne.PayToScriptHash)};ne.payingTo=function(e,t){return jn.checkArgument(e,"script is required"),jn.checkArgument(e instanceof ja(),"script must be instance of Script"),ne.fromScriptHash(ix.sha256ripemd160(e.toBuffer()),t)};ne.fromScript=function(e,t){jn.checkArgument(e instanceof ja(),"script must be a Script instance");var r=ne._transformScript(e,t);return new ne(r.hashBuffer,t,r.type)};ne.fromBuffer=function(e,t,r){var n=ne._transformBuffer(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromHex=function(e,t,r){return ne.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ne.fromString=function(e,t,r){var n=ne._transformString(e,t,r);return new ne(n.hashBuffer,n.network,n.type)};ne.fromObject=function(t){jn.checkState(ox.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.');var r=d.Buffer.from(t.hash,"hex");return new ne(r,t.network,t.type)};ne.getValidationError=function(e,t,r){var n;try{new ne(e,t,r)}catch(i){n=i}return n};ne.isValid=function(e,t,r){return!ne.getValidationError(e,t,r)};ne.prototype.isPayToPublicKeyHash=function(){return this.type===ne.PayToPublicKeyHash};ne.prototype.isPayToScriptHash=function(){return this.type===ne.PayToScriptHash};ne.prototype.toBuffer=function(){var e=d.Buffer.from([this.network[this.type]]),t=d.Buffer.concat([e,this.hashBuffer]);return t};ne.prototype.toHex=function(){return this.toBuffer().toString("hex")};ne.prototype.toObject=ne.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}};ne.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"};ne.prototype.toString=function(){return nx.encode(this.toBuffer())};sx.exports=ne;function ja(){return Kr()}});var io=P((v5,cx)=>{"use strict";m();var Dc=Ve(),Sk=no(),ax=Fd(),mi=Er(),ux=pr(),hn=ga(),Mp=ii(),wk=Tr(),Ek=ea(),fx=ke(),Np="[REDACTED]";function ye(e,t){if(!(this instanceof ye))return new ye(e,t);if(e instanceof ye)return e;var r=this._classifyArguments(e,t);if(!r.bn||r.bn.cmp(new mi(0))===0)throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(Mp.getN()))throw new TypeError("Number must be less than N");if(typeof r.network>"u")throw new TypeError('Must specify the network ("livenet" or "testnet")');return ux.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}ye.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?hn.get(t):hn.defaultNetwork};if(Dc.isUndefined(e)||Dc.isNull(e))r.bn=ye._getRandomBN();else if(e instanceof mi)r.bn=e;else if(e instanceof d.Buffer||e instanceof Uint8Array)r=ye._transformBuffer(e,t);else if(e.bn&&e.network)r=ye._transformObject(e);else if(!t&&hn.get(e))r.bn=ye._getRandomBN(),r.network=hn.get(e);else if(typeof e=="string")ux.isHexa(e)?r.bn=new mi(d.Buffer.from(e,"hex")):r=ye._transformWIF(e,t);else throw new TypeError("First argument is an unrecognized data type.");return r};ye._getRandomBN=function(){var e,t;do{var r=Ek.getRandomBuffer(32);t=mi.fromBuffer(r),e=t.lt(Mp.getN())}while(!e);return t};ye._transformBuffer=function(e,t){var r={};if(e.length===32)return ye._transformBNBuffer(e,t);if(r.network=hn.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==hn.get(t))throw new TypeError("Private key network mismatch");if(e.length===34&&e[33]===1)r.compressed=!0;else if(e.length===33)r.compressed=!1;else throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");return r.bn=mi.fromBuffer(e.slice(1,33)),r};ye._transformBNBuffer=function(e,t,r){var n={};return n.network=hn.get(t)||hn.defaultNetwork,n.bn=mi.fromBuffer(e),n.compressed=r===void 0?!0:!!r,n};ye._transformWIF=function(e,t){return ye._transformBuffer(ax.decode(e),t)};ye.fromBuffer=function(e,t,r){return r!==void 0&&e&&e.length===32?new ye(ye._transformBNBuffer(e,t,r)):new ye(e,t)};ye.fromHex=function(e,t,r){return ye.fromBuffer(d.Buffer.from(e,"hex"),t,r)};ye._transformObject=function(e){if(e.bn instanceof mi)return{bn:e.bn,network:hn.get(e.network),compressed:e.compressed};if(typeof e.bn!="string"||!e.bn.length)throw new TypeError("Invalid private key: `bn` must be a hex string");if(e.bn===Np)throw new TypeError('Invalid private key: `bn` is "'+Np+'". JSON.stringify() redacts the secret on purpose \u2014 use toObject() for a round-trippable export, or toWIF().');if(!/^[0-9a-fA-F]+$/.test(e.bn))throw new TypeError("Invalid private key: `bn` is not hexadecimal");var t=new mi(e.bn,"hex");if(t.isZero()||t.gte(Mp.getN()))throw new TypeError("Invalid private key: outside the range of valid keys");var r=hn.get(e.network);return{bn:t,network:r,compressed:e.compressed}};ye.fromString=ye.fromWIF=function(e,t){return fx.checkArgument(Dc.isString(e),"First argument is expected to be a string."),new ye(e,t)};ye.fromObject=ye.fromJSON=function(e){return fx.checkArgument(Dc.isObject(e),"First argument is expected to be an object."),new ye(e)};ye.fromRandom=function(e){var t=ye._getRandomBN();return new ye(t,e)};ye.getValidationError=function(e,t){var r;try{new ye(e,t)}catch(n){r=n}return r};ye.isValid=function(e,t){return e?!ye.getValidationError(e,t):!1};ye.prototype.toString=function(){return this.toWIF()};ye.prototype.toWIF=function(){var e=this.network,t=this.compressed,r;return t?r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32}),d.Buffer.from([1])]):r=d.Buffer.concat([d.Buffer.from([e.privatekey]),this.bn.toBuffer({size:32})]),ax.encode(r)};ye.prototype.toBigNumber=function(){return this.bn};ye.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})};ye.prototype.toHex=function(){return this.toBuffer().toString("hex")};ye.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=wk.fromPrivateKey(this)),this._pubkey};ye.prototype.toAddress=function(e){var t=this.toPublicKey();return Sk.fromPublicKey(t,e||this.network)};ye.prototype.toObject=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}};ye.prototype.toJSON=function(){return{bn:Np,compressed:this.compressed,network:this.network.toString()}};ye.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"};cx.exports=ye});var Tr=P((_5,hx)=>{"use strict";m();var cs=Er(),ls=ii(),xk=Qt(),Ik=pr(),lx=ga(),kp=Ve(),so=ke();function ce(e,t){if(!(this instanceof ce))return new ce(e,t);if(so.checkArgument(e,"First argument is required, please include public key data."),e instanceof ce)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),Ik.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||lx.defaultNetwork}),this}ce.prototype._classifyArgs=function(e,t){var r={compressed:kp.isUndefined(t.compressed)||t.compressed};if(e instanceof ls)r.point=e;else if(e.x&&e.y)r=ce._transformObject(e);else if(typeof e=="string")r=ce._transformDER(d.Buffer.from(e,"hex"));else if(ce._isBuffer(e))r=ce._transformDER(e);else if(ce._isPrivateKey(e))r=ce._transformPrivateKey(e);else throw new TypeError("First argument is an unrecognized data format.");return r.network||(r.network=kp.isUndefined(t.network)?void 0:lx.get(t.network)),r};ce._isPrivateKey=function(e){var t=io();return e instanceof t};ce._isBuffer=function(e){return e instanceof d.Buffer||e instanceof Uint8Array};ce._transformPrivateKey=function(e){so.checkArgument(ce._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=ls.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t};ce._transformDER=function(e,t){so.checkArgument(ce._isBuffer(e),"Must be a buffer of DER encoded public key");var r={};t=kp.isUndefined(t)?!0:t;var n,i,o,s;if(e[0]===4||!t&&(e[0]===6||e[0]===7)){if(o=e.slice(1,33),s=e.slice(33,65),o.length!==32||s.length!==32||e.length!==65)throw new TypeError("Length of x and y must be 32 bytes");n=new cs(o),i=new cs(s),r.point=new ls(n,i),r.compressed=!1}else if(e[0]===3)o=e.slice(1),n=new cs(o),r=ce._transformX(!0,n),r.compressed=!0;else if(e[0]===2)o=e.slice(1),n=new cs(o),r=ce._transformX(!1,n),r.compressed=!0;else throw new TypeError("Invalid DER format public key");return r};ce._transformX=function(e,t){so.checkArgument(typeof e=="boolean","Must specify whether y is odd or not (true or false)");var r={};return r.point=ls.fromX(e,t),r};ce._transformObject=function(e){var t=new cs(e.x,"hex"),r=new cs(e.y,"hex"),n=new ls(t,r);return new ce(n,{compressed:e.compressed})};ce.fromPrivateKey=function(e){so.checkArgument(ce._isPrivateKey(e),"Must be an instance of PrivateKey");var t=ce._transformPrivateKey(e);return new ce(t.point,{compressed:t.compressed,network:t.network})};ce.fromDER=ce.fromBuffer=function(e,t){so.checkArgument(ce._isBuffer(e),"Must be a buffer of DER encoded public key");var r=ce._transformDER(e,t);return new ce(r.point,{compressed:r.compressed})};ce.fromPoint=function(e,t){return so.checkArgument(e instanceof ls,"First argument must be an instance of Point."),new ce(e,{compressed:t})};ce.fromHex=ce.fromString=function(e,t){var r=d.Buffer.from(e,t||"hex"),n=ce._transformDER(r);return new ce(n.point,{compressed:n.compressed})};ce.fromX=function(e,t){var r=ce._transformX(e,t);return new ce(r.point,{compressed:r.compressed})};ce.getValidationError=function(e){var t;try{new ce(e)}catch(r){t=r}return t};ce.isValid=function(e){return!ce.getValidationError(e)};ce.prototype.toObject=ce.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}};ce.prototype.toBuffer=ce.prototype.toDER=function(){var e=this.point.getX(),t=this.point.getY(),r=e.toBuffer({size:32}),n=t.toBuffer({size:32}),i;if(this.compressed){var o=n[n.length-1]%2;return o?i=d.Buffer.from([3]):i=d.Buffer.from([2]),d.Buffer.concat([i,r])}else return i=d.Buffer.from([4]),d.Buffer.concat([i,r,n])};ce.prototype._getID=function(){return xk.sha256ripemd160(this.toBuffer())};ce.prototype.toAddress=function(e){var t=no();return t.fromPublicKey(this,e||this.network)};ce.prototype.toString=ce.prototype.toHex=function(){return this.toDER().toString("hex")};ce.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"};hx.exports=ce});var Ka=P((w5,px)=>{"use strict";m();var dx=ea();function Ak(){var e=dx.getRandomBuffer(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")}function Ok(e){return dx.getRandomBuffer(Math.ceil(e/2)).toString("hex").substring(0,e)}px.exports={uuid4:Ak,randomHex:Ok}});var bx=P((I5,vx)=>{"use strict";m();var Va=Tr(),Cp=Qt(),Lp=ka(),gx=ir(),Dp=io(),Rt=ke(),x5=Ve(),Rk=Ka();function yx(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Va?t.issuerPublicKey:Va.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Va.fromString(n):null}catch{return null}}var hs={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},mx={create:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,rightType:e,claim:n,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||new Date().toISOString(),validUntil:o.validUntil||null,transferable:o.transferable!==!1,revocable:o.revocable!==!1}};return o.metadata&&(a.credentialSubject.metadata=o.metadata),a},prepareRightToken:function(e,t,r,n,i,o){o=o||{},Rt.checkArgument(typeof e=="string","Right type must be string"),Rt.checkArgument(typeof t=="string","Issuer DID must be string"),Rt.checkArgument(typeof r=="string","Subject DID must be string"),Rt.checkArgument(n&&typeof n=="object","Claim must be object"),Rt.checkArgument(i instanceof Dp,"Invalid issuer private key");var s=Object.values(hs);Rt.checkArgument(s.includes(e),"Invalid right type: "+e);try{var a=this.create(e,t,r,n,i,o),c=this._signToken(a,i);return{success:!0,rightToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:c,metadata:{type:e,issuer:t,subject:r,transferable:a.credentialSubject.transferable,revocable:a.credentialSubject.revocable,jurisdiction:a.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,subject:r,issuedAt:c.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:c.id,issuer:t,subject:r,rightType:e}}}}}catch(h){return{success:!1,error:h.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:i.rightType,issuer:i.issuerDID,subject:i.subjectDID,result:i.valid,verifiedAt:i.verifiedAt}},updateTokenStatus:i.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:i.verifiedAt}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareRightTokenTransfer:function(e,t,r,n){n=n||{},Rt.checkArgument(e&&typeof e=="object","Invalid token"),Rt.checkArgument(typeof t=="string","New owner DID must be string"),Rt.checkArgument(r instanceof Dp,"Invalid current owner key");try{var i=this.prepareRightTokenVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+i.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=e.credentialSubject&&e.credentialSubject.id,s=yx({issuer:o},{issuerPublicKey:n.currentOwnerPublicKey});if(!s)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==s.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:new Date().toISOString(),transferReason:n.reason||"ownership_transfer",consideration:n.consideration||null}},c=this._signToken(a,r),h=JSON.parse(JSON.stringify(e));h.id="urn:uuid:"+this._generateUUID(),h.issuanceDate=new Date().toISOString(),h.credentialSubject.id=t,h.credentialSubject.transferHistory=h.credentialSubject.transferHistory||[],h.credentialSubject.transferHistory.push({transferId:c.id,transferDate:c.issuanceDate,from:e.credentialSubject.id,to:t}),delete h.proof;var g=this._signToken(h,r);return{success:!0,newToken:g,transferProof:c,transferId:c.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:g.id,transferProof:c,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:c.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:c.id,transferDate:c.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:g.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:g.id,transferId:c.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:c.issuanceDate}}}}}catch(y){return{success:!1,error:y.message}}},prepareObligationToken:function(e,t,r,n){Rt.checkArgument(e&&typeof e=="object","Invalid right token"),Rt.checkArgument(typeof t=="string","Obligor DID must be string"),Rt.checkArgument(r&&typeof r=="object","Obligation must be object"),Rt.checkArgument(n instanceof Dp,"Invalid issuer key");try{var i={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:new Date().toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(i,n);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(s){return{success:!1,error:s.message}}},prepareRightTypeValidation:function(e){Rt.checkArgument(typeof e=="string","Right type must be string");var t=Object.values(hs),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){var t={PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"};return t[e]||"UNKNOWN"},_getRightTypeDescription:function(e){var t={PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"};return t[e]||"Unknown right type"},getRightTypes:function(){return hs},verifyToken:function(e,t){var r=[];try{if(Rt.checkArgument(e&&typeof e=="object","Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var n=t instanceof Va?t:Va.fromString(t),i=this._canonicalizeToken(e),o=Cp.sha256(d.Buffer.from(i));if(e.tokenHash&&e.tokenHash!==o.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var s=e.proof.jws.split(".");if(s.length!==3||!s[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var a=gx.fromDER(d.Buffer.from(s[2],"base64url")),c=new Lp;return c.hashbuf=o,c.sig=a,c.pubkey=n,c.verify()||r.push("Signature verification failed"),{valid:r.length===0,errors:r,tokenHash:o.toString("hex"),verifiedAt:new Date().toISOString()}}catch(h){return r.push(h.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Cp.sha256(d.Buffer.from(r)),i=new Lp;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=t.toDER().toString("base64url");return n+".."+i},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Cp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=yx(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=gx.fromDER(d.Buffer.from(s[2],"base64url")),c=new Lp;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.validFrom){var o=new Date(e.credentialSubject.validFrom);n<o&&r.push("Token not yet valid")}if(e.credentialSubject.validUntil){var s=new Date(e.credentialSubject.validUntil);n>s&&t.push("Token expired")}},_validateRightType:function(e,t){if(!e.credentialSubject.rightType){t.push("Missing rightType");return}var r=Object.values(hs);r.includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType)},_validateJurisdiction:function(e,t,r){if(!e.credentialSubject.jurisdiction){r.push("Missing jurisdiction");return}t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction))},_generateUUID:function(){return Rk.uuid4()}};mx.RightTypes=hs;vx.exports=mx});var Sx=P((O5,_x)=>{"use strict";m();var Ga=Qt(),yr=ke(),Tk=Ka(),ao={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},Pk={prepareClaimValidation:function(e,t){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=ao[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var n=[],i=[];this._validateObject(e,r,"",n,i);var o={valid:n.length===0,errors:n,warnings:i,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(s){return{success:!1,error:"Validation preparation failed: "+s.message}}},prepareClaimAttestation:function(e,t,r){try{yr.checkArgument(e&&typeof e=="object","Invalid claim"),yr.checkArgument(typeof t=="string","Schema name must be string"),yr.checkArgument(r&&typeof r=="object","Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var i={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:new Date().toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},o=Ga.sha256(d.Buffer.from(this.canonicalize(i))).toString("hex");return i.attestationHash=o,{success:!0,attestation:i,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:i},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:i.attestor.did,attestationHash:o}}}}}catch(s){return{success:!1,error:"Attestation preparation failed: "+s.message}}},prepareClaimDispute:function(e,t,r){try{yr.checkArgument(typeof e=="string","Claim hash must be string"),yr.checkArgument(t&&typeof t=="object","Invalid disputant"),yr.checkArgument(r&&typeof r=="object","Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:new Date().toISOString(),status:"FILED",priority:r.priority||"NORMAL"},i=Ga.sha256(d.Buffer.from(this.canonicalize(n))).toString("hex");return n.disputeHash=i,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:i}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:i,priority:n.priority}}}}}catch(o){return{success:!1,error:"Dispute preparation failed: "+o.message}}},prepareBulkClaimValidation:function(e,t){try{yr.checkArgument(Array.isArray(e),"Claims must be array"),yr.checkArgument(typeof t=="string","Schema name must be string");var r=[],n=[],i=0;e.forEach(function(a,c){try{var h=this.prepareClaimValidation(a,t);h.success&&h.validation.valid&&i++,r.push({index:c,result:h})}catch(g){n.push({index:c,error:g.message})}}.bind(this));var o=this._generateBatchId(),s=Ga.sha256(d.Buffer.from(JSON.stringify(r.map(a=>a.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:o,batchHash:s,totalClaims:e.length,validClaims:i,invalidClaims:e.length-i,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:o,batchHash:s,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:o,summary:{total:e.length,valid:i,invalid:e.length-i}}}}}}catch(a){return{success:!1,error:"Bulk validation preparation failed: "+a.message}}},canonicalize:function(e){yr.checkArgument(e&&typeof e=="object","Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return Ga.sha256(d.Buffer.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=ao[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var n=this._createTemplateFromSchema(r),i=this._generateFormStructure(r);return{success:!0,schemaName:e,template:n,schema:r,formStructure:i,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:i,template:n}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:n,customizations:t.customizations||{}}}}}}catch(o){return{success:!1,error:"Template preparation failed: "+o.message}}},getSchemas:function(){return ao},getSchemaNames:function(){return Object.keys(ao)},getSchema:function(e){return ao[e]||null},addSchema:function(e,t){yr.checkArgument(typeof e=="string","Schema name must be string"),yr.checkArgument(t&&typeof t=="object","Invalid schema"),ao[e]=t},createTemplate:function(e){var t=ao[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return Ga.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){return Tk.randomHex(16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r],i={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(n),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(n)};n.enum&&(i.options=n.enum.map(function(o){return{value:o,label:this._humanizeValue(o)}}.bind(this))),t.fields.push(i)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.pattern&&(t[r]=n.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];n.enum&&(t[r]=n.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":e.format==="date"?"date":e.format==="date-time"?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),e.minimum!==void 0&&(t.min=e.minimum),e.maximum!==void 0&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(t){return t.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()})},_validateObject:function(e,t,r,n,i){t.type==="object"?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(o){e.hasOwnProperty(o)||n.push("Missing required field: "+this._getFieldPath(r,o))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var s=this._getFieldPath(r,o),a=t.properties[o];a?this._validateValue(e[o],a,s,n,i):i.push("Unknown field: "+s)}.bind(this))):this._validateValue(e,t,r,n,i)},_validateValue:function(e,t,r,n,i){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type){n.push("Invalid type for "+r+": expected "+t.type+", got "+o);return}}if(t.type==="string"&&(t.pattern&&!new RegExp(t.pattern).test(e)&&n.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&n.push("Invalid enum value for "+r+": "+e),t.format==="date"&&!this._isValidDate(e)&&n.push("Invalid date format for "+r),t.format==="date-time"&&!this._isValidDateTime(e)&&n.push("Invalid date-time format for "+r)),(t.type==="number"||t.type==="integer")&&(t.minimum!==void 0&&e<t.minimum&&n.push("Value below minimum for "+r+": "+e+" < "+t.minimum),t.maximum!==void 0&&e>t.maximum&&n.push("Value above maximum for "+r+": "+e+" > "+t.maximum),t.type==="integer"&&!Number.isInteger(e)&&n.push("Value must be integer for "+r)),t.type==="array"&&t.items)for(var s=0;s<e.length;s++)this._validateValue(e[s],t.items,r+"["+s+"]",n,i);t.type==="object"&&this._validateObject(e,t,r,n,i)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if(e.type==="object"){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var n=e.properties[r];t[r]=this._getDefaultValue(n)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:e.format==="date"?"2023-01-01":e.format==="date-time"?new Date().toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};_x.exports=Pk});var Ex=P((T5,wx)=>{"use strict";m();var za=Qt(),ds=ke(),Bk={prepareTokenCommitment:function(e,t){t=t||{},ds.checkArgument(e&&typeof e=="object","Invalid token");try{var r=this._createCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,commitment:r,opReturnData:n,txTemplate:i,preparedAt:new Date().toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},prepareBatchCommitment:function(e,t){t=t||{},ds.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),n=this._formatOpReturn(r,t),i=this._createTxTemplate(n,t);return{success:!0,batchCommitment:r,opReturnData:n,txTemplate:i,tokenCount:e.length,preparedAt:new Date().toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(o){return{success:!1,error:o.message}}},verifyTokenAnchor:function(e,t,r){ds.checkArgument(e&&typeof e=="object","Invalid token"),ds.checkArgument(typeof t=="string","Transaction ID must be string");try{var n=this._createCommitment(e,{}),i=this._extractOpReturn(r);if(!i)return{valid:!1,error:"No OP_RETURN data found in transaction"};var o=this._verifyCommitment(n,i);return{valid:o,chainVerified:!1,txid:t,commitment:n,anchorData:i,verifiedAt:new Date().toISOString()}}catch(s){return{valid:!1,error:s.message}}},formatRevocation:function(e,t){ds.checkArgument(typeof e=="string","Token ID must be string"),ds.checkArgument(t&&typeof t=="object","Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=za.sha256(d.Buffer.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(i){return{success:!1,error:i.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:za.sha256(d.Buffer.from(r)).toString("hex"),tokenId:e.id,timestamp:new Date().toISOString(),purpose:t.purpose||"legal_token"},i=za.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return{hash:i,data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(a){var c=this._createCommitment(a,t);r.push(c.hash),n.push(a.id)}.bind(this));var i=this._createMerkleRoot(r),o={type:"LTP_BATCH",merkleRoot:i,tokenCount:e.length,tokenIds:n,timestamp:new Date().toISOString(),purpose:t.purpose||"batch_anchor"},s=za.sha256(d.Buffer.from(JSON.stringify(o))).toString("hex");return{hash:s,data:o,merkleRoot:i,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:d.Buffer.from(r+"."+n,"utf8"),size:d.Buffer.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(n){throw new Error("Failed to create transaction template: "+n.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:d.Buffer.from(n,"hex").toString("utf8")}}}return null}catch{return null}},_verifyCommitment:function(e,t){try{return!t||!t.decoded?!1:t.decoded.includes(e.hash)}catch{return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(e.length===0)return null;if(e.length===1)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var i=t[n],o=t[n+1]||i,s=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(o,"hex")]),a=za.sha256(s).toString("hex");r.push(a)}t=r}return t[0]},_estimateSize:function(e){var t=10,r=e.outputs.length*34,n=148;return{base:t+r,withOneInput:t+r+n,bytesPerInput:n}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};wx.exports=Bk});var Ax=P((B5,Ix)=>{"use strict";m();var Nk=Tr(),Yr=Qt(),xx=ka(),Mk=ir(),kk=io(),or=ke(),Ck={prepareSignatureProof:function(e,t,r){r=r||{},or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t instanceof kk,"Invalid private key");try{var n=this._canonicalizeForSigning(e),i=Yr.sha256(d.Buffer.from(n)),o=new xx;o.hashbuf=i,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign();var s=o.sig,a={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(i,s),proofValue:s.toDER().toString("hex")};return{success:!0,proof:a,tokenHash:i.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:i.toString("hex"),proof:a,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:i.toString("hex"),signature:s.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSignatureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(typeof t=="string","Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),n=Yr.sha256(d.Buffer.from(r)),i=Mk.fromDER(d.Buffer.from(e.proof.proofValue,"hex")),o={tokenHash:n.toString("hex"),signature:i.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},s=new xx;s.hashbuf=n,s.sig=i,s.pubkey=Nk.fromString(t);var a=s.verify()===!0;return{success:!0,verification:{valid:a,tokenHash:n.toString("hex"),signatureValid:a,publicKey:t,verifiedAt:new Date().toISOString()},verificationData:o,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:n.toString("hex"),result:a,publicKey:t,verifiedAt:new Date().toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:a,verifier:t}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosure:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(Array.isArray(t),"Revealed fields must be array"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=this._createFieldCommitments(e,r),i=this._createMerkleTree(n),o=[],s=[];t.forEach(function(c){var h=this._getNestedValue(e,c),g=this._findFieldCommitment(n,c);if(g){o.push({path:c,value:h,commitment:g.hash,salt:g.salt});var y=this._generateMerkleProof(i,g.index);s.push({path:c,leafIndex:g.index,proof:y})}}.bind(this));var a={type:"LegalTokenSelectiveDisclosure",created:new Date().toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:i.root,disclosures:o,merkleProofs:s,totalFields:n.length};return{success:!0,proof:a,hiddenFieldCount:n.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:a,merkleRoot:i.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:a,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:n.length,disclosedAt:new Date().toISOString()}}}}}catch(c){return{success:!1,error:c.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(or.checkArgument(e&&typeof e=="object","Invalid proof"),or.checkArgument(typeof t=="string","Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],n=[];e.disclosures.forEach(function(o,s){var a=e.merkleProofs[s],c=this._hashField(o.path,o.value,o.salt);if(c!==o.commitment){n.push("Invalid commitment for field: "+o.path);return}var h=this._verifyMerkleProof(o.commitment,a.leafIndex,a.proof,e.merkleRoot);h?r.push({path:o.path,value:o.value,verified:!0}):n.push("Invalid Merkle proof for field: "+o.path)}.bind(this));var i={valid:n.length===0,errors:n,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:i.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:i.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:n.length,result:i.valid}}}}}catch(o){return{success:!1,error:o.message}}},prepareLegalValidityProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid jurisdiction"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=t.requirements||[],i=[],o=!0;n.forEach(function(a){var c=this._checkLegalRequirement(e,a);i.push(c),c.satisfied||(o=!1)}.bind(this));var s={type:"LegalValidityProof",created:new Date().toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:i,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:s,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:s,complianceReport:{jurisdiction:t.code,totalRequirements:n.length,satisfiedRequirements:i.filter(a=>a.satisfied).length,failedRequirements:i.filter(a=>!a.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:new Date().toISOString(),requirements:i}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:i.filter(a=>!a.satisfied)}}}}}catch(a){return{success:!1,error:a.message}}},prepareZeroKnowledgeProof:function(e,t,r){or.checkArgument(e&&typeof e=="object","Invalid token"),or.checkArgument(t&&typeof t=="object","Invalid statement"),or.checkArgument(typeof r=="string","Nonce must be string");try{var n=Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+r)).toString("hex"),i={type:"LegalTokenZKProof",created:new Date().toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:i,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:i,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:i,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:new Date().toISOString()}}}}}catch(o){return{success:!1,error:o.message}}},_generateZKProofData:function(e,t,r){var n={challenge:Yr.sha256(d.Buffer.from(t.claim+r)).toString("hex"),response:Yr.sha256(d.Buffer.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:Yr.sha256(d.Buffer.from(r+e.id+t.predicate)).toString("hex")};return n},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(i,o){if(i!=="proof"&&i!=="tokenHash"){var s=Yr.sha256(d.Buffer.from(t+i+n)).toString("hex"),a=this._hashField(i,o,s);r.push({path:i,value:o,salt:s,hash:a,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return Yr.sha256(d.Buffer.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(g){return g.hash});if(t.length===0)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var i=[],o=0;o<n.length;o+=2){var s=n[o],a=n[o+1]||s,c=d.Buffer.concat([d.Buffer.from(s,"hex"),d.Buffer.from(a,"hex")]),h=Yr.sha256(c).toString("hex");i.push(h)}r.push(i),n=i}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],n=t,i=0;i<e.levels.length-1;i++){var o=e.levels[i],s=n%2===0,a=s?n+1:n-1;a<o.length&&r.push({hash:o[a],isLeft:!s}),n=Math.floor(n/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var i=e,o=t,s=0;s<r.length;s++){var a=r[s],c=o%2===0,h;a.isLeft?h=d.Buffer.concat([d.Buffer.from(a.hash,"hex"),d.Buffer.from(i,"hex")]):h=d.Buffer.concat([d.Buffer.from(i,"hex"),d.Buffer.from(a.hash,"hex")]),i=Yr.sha256(h).toString("hex"),o=Math.floor(o/2)}return i===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(n,i){var o=t+"["+i+"]";this._traverseObject(n,o,r)}.bind(this)):e!==null&&typeof e=="object"?Object.keys(e).forEach(function(n){var i=t?t+"."+n:n;this._traverseObject(e[n],i,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(r,n){return r&&r[n]},e)},_findFieldCommitment:function(e,t){return e.find(function(r){return r.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r!=null};case"field_value":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var n=new Date,i=new Date(e.issuanceDate);return{requirement:t.type,satisfied:i<=n};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:new Date().toISOString()};return Yr.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};Ix.exports=Ck});var Tx=P((C5,Rx)=>{"use strict";m();var Wa=Qt(),M5=no(),k5=Op(),cr=ke(),Ox=Ka(),Lk={prepareRegistry:function(e){e=e||{},cr.checkArgument(typeof e=="object","Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:new Date().toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:e.enableRevocation!==!1,enableAuditTrail:e.enableAuditTrail!==!1,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}},r=this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}});return{success:!0,registry:t,initialAudit:r,instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},cr.checkArgument(e&&typeof e=="object","Invalid token"),cr.checkArgument(t&&typeof t=="object","Invalid registry config");try{var n=this._validateTokenForRegistration(e,t);if(!n.valid)return{success:!1,error:"Token validation failed: "+n.error};var i={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:new Date().toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:n.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:i.registeredAt,metadata:{status:i.status,tokenType:e.type,compliance:i.compliance}});return{success:!0,registrationRecord:i,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:n,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:i},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenApproval:function(e,t,r){try{cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(typeof t=="string","Approver must be string"),cr.checkArgument(r&&typeof r=="object","Invalid registry config");var n={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:new Date().toISOString()},i=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:n.approvedAt});return{success:!0,approvalData:n,auditEntry:i,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:i}}}}catch(o){return{success:!1,error:o.message}}},prepareTokenRevocation:function(e,t,r){try{if(cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid revocation"),cr.checkArgument(r&&typeof r=="object","Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var n={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:new Date().toISOString(),effectiveDate:t.effectiveDate||new Date().toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},i={tokenId:e,status:"REVOKED",revokedAt:n.revokedAt,revocationReason:n.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:n.revokedAt,metadata:{reason:n.reason,legalBasis:n.legalBasis}});return{success:!0,revocationRecord:n,statusUpdate:i,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:n},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(s){return{success:!1,error:s.message}}},prepareTokenStatusQuery:function(e,t){try{return cr.checkArgument(typeof e=="string","Token ID must be string"),cr.checkArgument(t&&typeof t=="object","Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(r){return{success:!1,error:r.message}}},prepareTokenSearch:function(e,t){e=e||{};try{cr.checkArgument(t&&typeof t=="object","Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var n=e.offset||0,i=e.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(s){return{success:!1,error:s.message}}},prepareStatisticsQuery:function(e){return cr.checkArgument(e&&typeof e=="object","Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},cr.checkArgument(e&&typeof e=="object","Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var n=t.offset||0,i=t.limit||100;r.push("offset="+n),r.push("limit="+i);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){return"reg_"+Ox.randomHex(16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,Wa.sha256(d.Buffer.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return Wa.sha256(d.Buffer.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],n=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),n=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),n=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),n=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),n=!1),{valid:n,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){var t={id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||new Date().toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)};return t},_generateAuditId:function(){return"audit_"+Ox.randomHex(32)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return Wa.sha256(d.Buffer.from(t)).toString("hex").substring(0,16)}};Rx.exports=Lk});var Mx=P((D5,Nx)=>{"use strict";m();var Up=Tr(),Fp=Qt(),Px=ka(),Dk=ir(),Bx=io(),mr=ke(),Uk=Ka();function Fk(e,t){if(t=t||{},t.issuerPublicKey)return t.issuerPublicKey instanceof Up?t.issuerPublicKey:Up.fromString(t.issuerPublicKey);var r=e&&e.issuer;if(typeof r!="string")return null;try{var n=r.split("#")[0].split(":")[2];return n?Up.fromString(n):null}catch{return null}}var Uc={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},ps={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},lr={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},Fc={prepareObligationToken:function(e,t,r,n,i,o){o=o||{},mr.checkArgument(typeof e=="string","Obligation type must be string"),mr.checkArgument(typeof t=="string","Issuer DID must be string"),mr.checkArgument(typeof r=="string","Obligor DID must be string"),mr.checkArgument(n&&typeof n=="object","Obligation must be object"),mr.checkArgument(i instanceof Bx,"Invalid issuer private key");var s=Object.values(Uc);mr.checkArgument(s.includes(e),"Invalid obligation type: "+e);try{var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:new Date().toISOString(),credentialSubject:{id:r,obligationType:e,obligation:n,jurisdiction:o.jurisdiction||"US",priority:o.priority||ps.MEDIUM,status:lr.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||new Date().toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:o.enforceable!==!1,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(a.credentialSubject.metadata=o.metadata);var c=this._signToken(a,i);return{success:!0,obligationToken:c,tokenHash:c.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:c,metadata:{type:e,issuer:t,obligor:r,priority:a.credentialSubject.priority,status:a.credentialSubject.status,jurisdiction:a.credentialSubject.jurisdiction,dueDate:a.credentialSubject.dueDate,correlativeRight:a.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:c.id,tokenHash:c.tokenHash,type:e,issuer:t,obligor:r,issuedAt:c.issuanceDate,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:c.id,issuer:t,obligor:r,obligationType:e,dueDate:a.credentialSubject.dueDate,priority:a.credentialSubject.priority}},scheduleReminders:a.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:c.id,obligor:r,dueDate:a.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(h){return{success:!1,error:h.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],n=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,n),this._validateObligationType(e,r),this._validateObligationStatus(e,r,n),this._validateObligationPriority(e,n);var i={valid:r.length===0,errors:r,warnings:n,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:new Date().toISOString()};return{success:!0,verification:i,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:i.valid,errors:r,warnings:n,verifiedAt:i.verifiedAt,isOverdue:i.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:i.obligationType,issuer:i.issuerDID,obligor:i.obligorDID,result:i.valid,verifiedAt:i.verifiedAt}},updateStatus:i.isOverdue&&e.credentialSubject.status===lr.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.OVERDUE,updatedAt:i.verifiedAt,reason:"Due date passed"}}:null}}}catch(o){return{success:!1,error:"Verification preparation failed: "+o.message}}},prepareObligationFulfillment:function(e,t,r,n){n=n||{},mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid fulfillment"),mr.checkArgument(r instanceof Bx,"Invalid obligor key");try{var i=this.prepareObligationVerification(e,{});if(!i.success||!i.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+i.verification.errors.join(", ")};if(e.credentialSubject.status===lr.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===lr.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:new Date().toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},s=this._signToken(o,r),a=o.credentialSubject.completionPercentage>=100?lr.COMPLETED:lr.IN_PROGRESS;return{success:!0,fulfillmentRecord:s,newStatus:a,fulfillmentId:s.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:s,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:a,fulfillmentId:s.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:a}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:s.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(c){return{success:!1,error:c.message}}},prepareObligationBreachAssessment:function(e,t,r){mr.checkArgument(e&&typeof e=="object","Invalid token"),mr.checkArgument(t&&typeof t=="object","Invalid breach details"),mr.checkArgument(r&&typeof r=="object","Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:new Date().toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||new Date().toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:new Date().toISOString()}},i=Fp.sha256(d.Buffer.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=i,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||new Date().toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:lr.BREACHED,breachId:n.id,breachDate:t.date||new Date().toISOString(),updatedAt:new Date().toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:t.severity==="CRITICAL"?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(o){return{success:!1,error:o.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},mr.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:new Date().toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},n=new Date,i=new Date(n.getTime()+10080*60*1e3);return e.forEach(function(o){var s={id:o.id,type:o.credentialSubject.obligationType,status:o.credentialSubject.status,priority:o.credentialSubject.priority,obligor:o.credentialSubject.id,dueDate:o.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(o),isDueSoon:!1};if(o.credentialSubject.dueDate){var a=new Date(o.credentialSubject.dueDate);s.isDueSoon=a<=i&&a>n}r.summary.byStatus[s.status]=(r.summary.byStatus[s.status]||0)+1,r.summary.byPriority[s.priority]=(r.summary.byPriority[s.priority]||0)+1,r.summary.byType[s.type]=(r.summary.byType[s.type]||0)+1,s.isOverdue&&r.summary.overdue++,s.isDueSoon&&r.summary.dueSoon++,s.status===lr.COMPLETED&&r.summary.completed++,s.isOverdue&&s.priority===ps.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:o.id,message:"Critical obligation is overdue",priority:"HIGH"}),s.isDueSoon&&s.priority===ps.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:o.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(s)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(o){return{success:!1,error:o.message}}},getObligationTypes:function(){return Uc},getObligationPriority:function(){return ps},getObligationStatus:function(){return lr},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=Fp.sha256(d.Buffer.from(r)),i=new Px;i.hashbuf=n,i.privkey=t,i.pubkey=t.toPublicKey(),i.sign();var o=i.sig,s={type:"EcdsaSecp256k1Signature2019",created:new Date().toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,o)},a=JSON.parse(JSON.stringify(e));return a.proof=s,a.tokenHash=n.toString("hex"),a},_createJWS:function(e,t){var r={alg:"ES256K",typ:"JWT"},n=d.Buffer.from(JSON.stringify(r)).toString("base64url"),i=e.toString("base64url"),o=t.toDER().toString("base64url");return n+".."+o},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(e!==null&&typeof e=="object"){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),(!e.type||!Array.isArray(e.type))&&t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws){t.push("Missing signature proof");return}var n=this._canonicalizeToken(e),i=Fp.sha256(d.Buffer.from(n));if(e.tokenHash&&e.tokenHash!==i.toString("hex")){t.push("Token hash mismatch");return}var o=Fk(e,r);if(!o){t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");return}var s=e.proof.jws.split(".");if(s.length!==3||!s[2]){t.push("Malformed JWS");return}var a=Dk.fromDER(d.Buffer.from(s[2],"base64url")),c=new Px;c.hashbuf=i,c.sig=a,c.pubkey=o,c.verify()!==!0&&t.push("Signature verification failed")}catch(h){t.push("Signature verification failed: "+h.message)}},_validateTokenTemporal:function(e,t,r){var n=new Date,i=new Date(e.issuanceDate);if(i>n&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate){var o=new Date(e.credentialSubject.effectiveDate);n<o&&r.push("Obligation not yet effective")}if(e.credentialSubject.expirationDate){var s=new Date(e.credentialSubject.expirationDate);n>s&&t.push("Obligation expired")}},_validateObligationType:function(e,t){if(!e.credentialSubject.obligationType){t.push("Missing obligationType");return}var r=Object.values(Uc);r.includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType)},_validateObligationStatus:function(e,t,r){if(!e.credentialSubject.status){t.push("Missing status");return}var n=Object.values(lr);n.includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===lr.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")},_validateObligationPriority:function(e,t){if(e.credentialSubject.priority){var r=Object.values(ps);r.includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority)}},_checkIfOverdue:function(e){if(!e.credentialSubject.dueDate)return!1;var t=new Date,r=new Date(e.credentialSubject.dueDate);return t>r&&e.credentialSubject.status!==lr.COMPLETED},_generateUUID:function(){return Uk.uuid4()}};Fc.ObligationTypes=Uc;Fc.ObligationPriority=ps;Fc.ObligationStatus=lr;Nx.exports=Fc});var Cx=P((F5,kx)=>{"use strict";m();var uo=bx(),qc=Sx(),Ya=Ex(),qp=Ax(),dn=Tx(),qk=Mx(),Hp=io(),vr=ke(),Re=function(e){return this instanceof Re?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=dn.createRegistry(this.config.registry)),this):new Re(e)};Re.prototype.createRightToken=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right data"),vr.checkArgument(t instanceof Hp,"Invalid private key"),r=r||{};try{var n=uo.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(r.addProof!==!1&&(n=uo._signToken(n,t)),r.anchor){var i=Ya.anchorToken(n,r.anchor);i.success&&(n.anchorTx=i.txid,n.anchorBlock=i.blockHeight)}if(this.registry&&r.register!==!1){var o=dn.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});o.success&&(n.registrationId=o.registrationId,n.registrationStatus=o.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(s){return{success:!1,error:s.message}}};Re.prototype.validateClaim=function(e,t){return qc.validate(e,t)};Re.prototype.createSelectiveDisclosure=function(e,t,r){return qp.prepareSelectiveDisclosure(e,t,r)};Re.prototype.verifyToken=function(e,t){return!e||!e.proof?{valid:!1,error:"No proof found in token"}:uo.verifyToken(e,t)};Re.prototype.transferRight=function(e,t,r,n){vr.checkArgument(e&&typeof e=="object","Invalid token"),vr.checkArgument(typeof t=="string","New owner must be string"),vr.checkArgument(r instanceof Hp,"Invalid owner key"),n=n||{};try{var i=this.verifyToken(e,r.toPublicKey().toString());if(!i.valid)return{success:!1,error:"Invalid token or ownership proof"};var o=uo.prepareRightTokenTransfer(e,t,r,n);if(!o.success)return{success:!1,error:o.error};var s=o.newToken,a=o.transferProof;if(n.anchor){var c=Ya.anchorToken(s,n.anchor);c.success&&(s.transferAnchorTx=c.txid)}if(this.registry){var h=dn.registerToken(this.registry,s,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});h.success&&(s.registrationId=h.registrationId)}return{success:!0,token:s,transferId:a.id,transferredAt:a.issuanceDate,transferProof:a}}catch(g){return{success:!1,error:g.message}}};Re.prototype.createObligation=function(e,t,r){vr.checkArgument(e&&typeof e=="object","Invalid right token"),vr.checkArgument(t&&typeof t=="object","Invalid obligation data"),vr.checkArgument(r instanceof Hp,"Invalid private key");try{var n=uo.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(i){return{success:!1,error:i.message}}};Re.prototype.revokeToken=function(e,t,r){return vr.checkArgument(typeof e=="string","Token ID must be string"),vr.checkArgument(t&&typeof t=="object","Invalid revocation data"),vr.checkArgument(typeof r=="string","Authority must be string"),this.registry?dn.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}};Re.prototype.checkTokenStatus=function(e){return vr.checkArgument(typeof e=="string","Token ID must be string"),this.registry?dn.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}};Re.prototype.searchTokens=function(e){return this.registry?dn.searchTokens(this.registry,e):{success:!1,error:"No registry available"}};Re.prototype.getRegistryStats=function(){return this.registry?dn.getStatistics(this.registry):{error:"No registry available"}};Re.prototype.createLegalValidityProof=function(e,t,r){return qp.prepareLegalValidityProof(e,t,r)};Re.prototype.anchorTokenBatch=function(e,t){return Ya.anchorBatch(e,t)};Re.prototype.verifyAnchor=function(e,t){return Ya.verifyAnchor(e,t)};Re.prototype.getRightTypes=function(){return uo.getRightTypes()};Re.prototype.getClaimSchemas=function(){return qc.getSchemas()};Re.prototype.createRegistry=function(e){return this.registry=dn.createRegistry(e),this.registry};Re.prototype.setRegistry=function(e){vr.checkArgument(e&&typeof e=="object","Invalid registry"),this.registry=e};Re.create=function(e){return new Re(e)};Re.createRightToken=function(e,t,r){var n=new Re;return n.createRightToken(e,t,r)};Re.validateClaim=function(e,t){return qc.validate(e,t)};Re.verifyToken=function(e,t){var r=new Re;return r.verifyToken(e,t)};Re.createRegistry=function(e){return dn.createRegistry(e)};Re.Right=uo;Re.Claim=qc;Re.Anchor=Ya;Re.Proof=qp;Re.Registry=dn;Re.Obligation=qk;kx.exports=Re});var Hk=P((H5,Lx)=>{m();Lx.exports=Cx()});return Hk();})();
|
|
70
70
|
if(typeof module!=="undefined"&&module.exports){module.exports=bsvLTP}else if(typeof define==="function"&&define.amd){define([],function(){return bsvLTP})}
|