@permaweb/libs 0.0.34 → 0.0.36

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/dist/index.esm.js CHANGED
@@ -1,15 +1,15 @@
1
- var Vt=Object.create;var je=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var rr=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);var nr=(n,i,a,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let y of Xt(i))!tr.call(n,y)&&y!==a&&je(n,y,{get:()=>i[y],enumerable:!(u=Kt(i,y))||u.enumerable});return n};var A=(n,i,a)=>(a=n!=null?Vt(er(n)):{},nr(i||!n||!n.__esModule?je(a,"default",{value:n,enumerable:!0}):a,n));var T=rr((Sr,Xe)=>{var U=Xe.exports={},j,H;function Ue(){throw new Error("setTimeout has not been defined")}function Re(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?j=setTimeout:j=Ue}catch{j=Ue}try{typeof clearTimeout=="function"?H=clearTimeout:H=Re}catch{H=Re}})();function He(n){if(j===setTimeout)return setTimeout(n,0);if((j===Ue||!j)&&setTimeout)return j=setTimeout,setTimeout(n,0);try{return j(n,0)}catch{try{return j.call(null,n,0)}catch{return j.call(this,n,0)}}}function ir(n){if(H===clearTimeout)return clearTimeout(n);if((H===Re||!H)&&clearTimeout)return H=clearTimeout,clearTimeout(n);try{return H(n)}catch{try{return H.call(null,n)}catch{return H.call(this,n)}}}var V=[],ue=!1,ne,Te=-1;function or(){!ue||!ne||(ue=!1,ne.length?V=ne.concat(V):Te=-1,V.length&&Ve())}function Ve(){if(!ue){var n=He(or);ue=!0;for(var i=V.length;i;){for(ne=V,V=[];++Te<i;)ne&&ne[Te].run();Te=-1,i=V.length}ne=null,ue=!1,ir(n)}}U.nextTick=function(n){var i=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)i[a-1]=arguments[a];V.push(new Ke(n,i)),V.length===1&&!ue&&He(Ve)};function Ke(n,i){this.fun=n,this.array=i}Ke.prototype.run=function(){this.fun.apply(null,this.array)};U.title="browser";U.browser=!0;U.env={};U.argv=[];U.version="";U.versions={};function K(){}U.on=K;U.addListener=K;U.once=K;U.off=K;U.removeListener=K;U.removeAllListeners=K;U.emit=K;U.prependListener=K;U.prependOnceListener=K;U.listeners=function(n){return[]};U.binding=function(n){throw new Error("process.binding is not supported")};U.cwd=function(){return"/"};U.chdir=function(n){throw new Error("process.chdir is not supported")};U.umask=function(){return 0}});var ro=A(T(),1);var Gr=A(T());var br=A(T(),1);var he={},et=!1;function ar(){if(et)return he;et=!0,he.byteLength=h,he.toByteArray=B,he.fromByteArray=G;for(var n=[],i=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,d=u.length;y<d;++y)n[y]=u[y],i[u.charCodeAt(y)]=y;i[45]=62,i[95]=63;function s(f){var m=f.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var x=f.indexOf("=");x===-1&&(x=m);var L=x===m?0:4-x%4;return[x,L]}function h(f){var m=s(f),x=m[0],L=m[1];return(x+L)*3/4-L}function g(f,m,x){return(m+x)*3/4-x}function B(f){var m,x=s(f),L=x[0],_=x[1],R=new a(g(f,L,_)),F=0,Z=_>0?L-4:L,W;for(W=0;W<Z;W+=4)m=i[f.charCodeAt(W)]<<18|i[f.charCodeAt(W+1)]<<12|i[f.charCodeAt(W+2)]<<6|i[f.charCodeAt(W+3)],R[F++]=m>>16&255,R[F++]=m>>8&255,R[F++]=m&255;return _===2&&(m=i[f.charCodeAt(W)]<<2|i[f.charCodeAt(W+1)]>>4,R[F++]=m&255),_===1&&(m=i[f.charCodeAt(W)]<<10|i[f.charCodeAt(W+1)]<<4|i[f.charCodeAt(W+2)]>>2,R[F++]=m>>8&255,R[F++]=m&255),R}function I(f){return n[f>>18&63]+n[f>>12&63]+n[f>>6&63]+n[f&63]}function D(f,m,x){for(var L,_=[],R=m;R<x;R+=3)L=(f[R]<<16&16711680)+(f[R+1]<<8&65280)+(f[R+2]&255),_.push(I(L));return _.join("")}function G(f){for(var m,x=f.length,L=x%3,_=[],R=16383,F=0,Z=x-L;F<Z;F+=R)_.push(D(f,F,F+R>Z?Z:F+R));return L===1?(m=f[x-1],_.push(n[m>>2]+n[m<<4&63]+"==")):L===2&&(m=(f[x-2]<<8)+f[x-1],_.push(n[m>>10]+n[m>>4&63]+n[m<<2&63]+"=")),_.join("")}return he}var Ae={},tt=!1;function sr(){if(tt)return Ae;tt=!0;return Ae.read=function(n,i,a,u,y){var d,s,h=y*8-u-1,g=(1<<h)-1,B=g>>1,I=-7,D=a?y-1:0,G=a?-1:1,f=n[i+D];for(D+=G,d=f&(1<<-I)-1,f>>=-I,I+=h;I>0;d=d*256+n[i+D],D+=G,I-=8);for(s=d&(1<<-I)-1,d>>=-I,I+=u;I>0;s=s*256+n[i+D],D+=G,I-=8);if(d===0)d=1-B;else{if(d===g)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,u),d=d-B}return(f?-1:1)*s*Math.pow(2,d-u)},Ae.write=function(n,i,a,u,y,d){var s,h,g,B=d*8-y-1,I=(1<<B)-1,D=I>>1,G=y===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=u?0:d-1,m=u?1:-1,x=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(h=isNaN(i)?1:0,s=I):(s=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-s))<1&&(s--,g*=2),s+D>=1?i+=G/g:i+=G*Math.pow(2,1-D),i*g>=2&&(s++,g/=2),s+D>=I?(h=0,s=I):s+D>=1?(h=(i*g-1)*Math.pow(2,y),s=s+D):(h=i*Math.pow(2,D-1)*Math.pow(2,y),s=0));y>=8;n[a+f]=h&255,f+=m,h/=256,y-=8);for(s=s<<y|h,B+=y;B>0;n[a+f]=s&255,f+=m,s/=256,B-=8);n[a+f-m]|=x*128},Ae}var ie={},rt=!1;function nt(){if(rt)return ie;rt=!0;let n=ar(),i=sr(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ie.Buffer=s,ie.SlowBuffer=_,ie.INSPECT_MAX_BYTES=50;let u=2147483647;ie.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=y(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function y(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function d(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return I(r)}return h(r,e,t)}s.poolSize=8192;function h(r,e,t){if(typeof r=="string")return D(r,e);if(ArrayBuffer.isView(r))return f(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(J(r,ArrayBuffer)||r&&J(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(J(r,SharedArrayBuffer)||r&&J(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=r.valueOf&&r.valueOf();if(o!=null&&o!==r)return s.from(o,e,t);let c=x(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return h(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function B(r,e,t){return g(r),r<=0?d(r):e!==void 0?typeof t=="string"?d(r).fill(e,t):d(r).fill(e):d(r)}s.alloc=function(r,e,t){return B(r,e,t)};function I(r){return g(r),d(r<0?0:L(r)|0)}s.allocUnsafe=function(r){return I(r)},s.allocUnsafeSlow=function(r){return I(r)};function D(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=R(r,e)|0,o=d(t),c=o.write(r,e);return c!==t&&(o=o.slice(0,c)),o}function G(r){let e=r.length<0?0:L(r.length)|0,t=d(e);for(let o=0;o<e;o+=1)t[o]=r[o]&255;return t}function f(r){if(J(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return G(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let o;return e===void 0&&t===void 0?o=new Uint8Array(r):t===void 0?o=new Uint8Array(r,e):o=new Uint8Array(r,e,t),Object.setPrototypeOf(o,s.prototype),o}function x(r){if(s.isBuffer(r)){let e=L(r.length)|0,t=d(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||ve(r.length)?d(0):G(r);if(r.type==="Buffer"&&Array.isArray(r.data))return G(r.data)}function L(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function _(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(J(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),J(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let o=e.length,c=t.length;for(let l=0,p=Math.min(o,c);l<p;++l)if(e[l]!==t[l]){o=e[l],c=t[l];break}return o<c?-1:c<o?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let o;if(t===void 0)for(t=0,o=0;o<e.length;++o)t+=e[o].length;let c=s.allocUnsafe(t),l=0;for(o=0;o<e.length;++o){let p=e[o];if(J(p,Uint8Array))l+p.length>c.length?(s.isBuffer(p)||(p=s.from(p)),p.copy(c,l)):Uint8Array.prototype.set.call(c,p,l);else if(s.isBuffer(p))p.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=p.length}return c};function R(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||J(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return be(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Je(r).length;default:if(c)return o?-1:be(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=R;function F(r,e,t){let o=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ft(this,e,t);case"utf8":case"utf-8":return We(this,e,t);case"ascii":return Ot(this,e,t);case"latin1":case"binary":return _t(this,e,t);case"base64":return kt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qt(this,e,t);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),o=!0}}s.prototype._isBuffer=!0;function Z(r,e,t){let o=r[e];r[e]=r[t],r[t]=o}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Z(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Z(this,t,t+3),Z(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Z(this,t,t+7),Z(this,t+1,t+6),Z(this,t+2,t+5),Z(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?We(this,0,e):F.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=ie.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,o,c,l){if(J(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),o===void 0&&(o=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||o>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=o)return 0;if(c>=l)return-1;if(t>=o)return 1;if(t>>>=0,o>>>=0,c>>>=0,l>>>=0,this===e)return 0;let p=l-c,w=o-t,P=Math.min(p,w),S=this.slice(c,l),b=e.slice(t,o);for(let C=0;C<P;++C)if(S[C]!==b[C]){p=S[C],w=b[C];break}return p<w?-1:w<p?1:0};function W(r,e,t,o,c){if(r.length===0)return-1;if(typeof t=="string"?(o=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,ve(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,o)),s.isBuffer(e))return e.length===0?-1:ke(r,e,t,o,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ke(r,[e],t,o,c);throw new TypeError("val must be string, number or Buffer")}function ke(r,e,t,o,c){let l=1,p=r.length,w=e.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,p/=2,w/=2,t/=2}function P(b,C){return l===1?b[C]:b.readUInt16BE(C*l)}let S;if(c){let b=-1;for(S=t;S<p;S++)if(P(r,S)===P(e,b===-1?0:S-b)){if(b===-1&&(b=S),S-b+1===w)return b*l}else b!==-1&&(S-=S-b),b=-1}else for(t+w>p&&(t=p-w),S=t;S>=0;S--){let b=!0;for(let C=0;C<w;C++)if(P(r,S+C)!==P(e,C)){b=!1;break}if(b)return S}return-1}s.prototype.includes=function(e,t,o){return this.indexOf(e,t,o)!==-1},s.prototype.indexOf=function(e,t,o){return W(this,e,t,o,!0)},s.prototype.lastIndexOf=function(e,t,o){return W(this,e,t,o,!1)};function Lt(r,e,t,o){t=Number(t)||0;let c=r.length-t;o?(o=Number(o),o>c&&(o=c)):o=c;let l=e.length;o>l/2&&(o=l/2);let p;for(p=0;p<o;++p){let w=parseInt(e.substr(p*2,2),16);if(ve(w))return p;r[t+p]=w}return p}function Nt(r,e,t,o){return we(be(e,r.length-t),r,t,o)}function $t(r,e,t,o){return we(Yt(e),r,t,o)}function Mt(r,e,t,o){return we(Je(e),r,t,o)}function Gt(r,e,t,o){return we(Jt(e,r.length-t),r,t,o)}s.prototype.write=function(e,t,o,c){if(t===void 0)c="utf8",o=this.length,t=0;else if(o===void 0&&typeof t=="string")c=t,o=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((o===void 0||o>l)&&(o=l),e.length>0&&(o<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let p=!1;for(;;)switch(c){case"hex":return Lt(this,e,t,o);case"utf8":case"utf-8":return Nt(this,e,t,o);case"ascii":case"latin1":case"binary":return $t(this,e,t,o);case"base64":return Mt(this,e,t,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,t,o);default:if(p)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),p=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function kt(r,e,t){return e===0&&t===r.length?n.fromByteArray(r):n.fromByteArray(r.slice(e,t))}function We(r,e,t){t=Math.min(r.length,t);let o=[],c=e;for(;c<t;){let l=r[c],p=null,w=l>239?4:l>223?3:l>191?2:1;if(c+w<=t){let P,S,b,C;switch(w){case 1:l<128&&(p=l);break;case 2:P=r[c+1],(P&192)===128&&(C=(l&31)<<6|P&63,C>127&&(p=C));break;case 3:P=r[c+1],S=r[c+2],(P&192)===128&&(S&192)===128&&(C=(l&15)<<12|(P&63)<<6|S&63,C>2047&&(C<55296||C>57343)&&(p=C));break;case 4:P=r[c+1],S=r[c+2],b=r[c+3],(P&192)===128&&(S&192)===128&&(b&192)===128&&(C=(l&15)<<18|(P&63)<<12|(S&63)<<6|b&63,C>65535&&C<1114112&&(p=C))}}p===null?(p=65533,w=1):p>65535&&(p-=65536,o.push(p>>>10&1023|55296),p=56320|p&1023),o.push(p),c+=w}return Wt(o)}let Oe=4096;function Wt(r){let e=r.length;if(e<=Oe)return String.fromCharCode.apply(String,r);let t="",o=0;for(;o<e;)t+=String.fromCharCode.apply(String,r.slice(o,o+=Oe));return t}function Ot(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]&127);return o}function _t(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]);return o}function Ft(r,e,t){let o=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>o)&&(t=o);let c="";for(let l=e;l<t;++l)c+=jt[r[l]];return c}function Qt(r,e,t){let o=r.slice(e,t),c="";for(let l=0;l<o.length-1;l+=2)c+=String.fromCharCode(o[l]+o[l+1]*256);return c}s.prototype.slice=function(e,t){let o=this.length;e=~~e,t=t===void 0?o:~~t,e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function N(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=ee(function(e){e=e>>>0,ce(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&fe(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+o*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=ee(function(e){e=e>>>0,ce(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&fe(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=t,l=1,p=this[e+--c];for(;c>0&&(l*=256);)p+=this[e+--c]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*t)),p},s.prototype.readInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=ee(function(e){e=e>>>0,ce(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&fe(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(o<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=ee(function(e){e=e>>>0,ce(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&fe(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!1,52,8)};function Q(r,e,t,o,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+o>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;Q(this,e,t,o,w,0)}let l=1,p=0;for(this[t]=e&255;++p<o&&(l*=256);)this[t+p]=e/l&255;return t+o},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;Q(this,e,t,o,w,0)}let l=o-1,p=1;for(this[t+l]=e&255;--l>=0&&(p*=256);)this[t+l]=e/p&255;return t+o},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function _e(r,e,t,o,c){Ye(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,t}function Fe(r,e,t,o,c){Ye(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=p,p=p>>8,r[t+2]=p,p=p>>8,r[t+1]=p,p=p>>8,r[t]=p,t+8}s.prototype.writeBigUInt64LE=ee(function(e,t=0){return _e(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=ee(function(e,t=0){return Fe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let P=Math.pow(2,8*o-1);Q(this,e,t,o,P-1,-P)}let l=0,p=1,w=0;for(this[t]=e&255;++l<o&&(p*=256);)e<0&&w===0&&this[t+l-1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let P=Math.pow(2,8*o-1);Q(this,e,t,o,P-1,-P)}let l=o-1,p=1,w=0;for(this[t+l]=e&255;--l>=0&&(p*=256);)e<0&&w===0&&this[t+l+1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeInt8=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||Q(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=ee(function(e,t=0){return _e(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=ee(function(e,t=0){return Fe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Qe(r,e,t,o,c,l){if(t+o>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Qe(r,e,t,4),i.write(r,e,t,o,23,4),t+4}s.prototype.writeFloatLE=function(e,t,o){return ze(this,e,t,!0,o)},s.prototype.writeFloatBE=function(e,t,o){return ze(this,e,t,!1,o)};function Ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Qe(r,e,t,8),i.write(r,e,t,o,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,o){return Ze(this,e,t,!0,o)},s.prototype.writeDoubleBE=function(e,t,o){return Ze(this,e,t,!1,o)},s.prototype.copy=function(e,t,o,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<o&&(c=o),c===o||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-o&&(c=e.length-t+o);let l=c-o;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,o,c):Uint8Array.prototype.set.call(e,this.subarray(o,c),t),l},s.prototype.fill=function(e,t,o,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let p=e.charCodeAt(0);(c==="utf8"&&p<128||c==="latin1")&&(e=p)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<o)throw new RangeError("Out of range index");if(o<=t)return this;t=t>>>0,o=o===void 0?this.length:o>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<o;++l)this[l]=e;else{let p=s.isBuffer(e)?e:s.from(e,c),w=p.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<o-t;++l)this[l+t]=p[l%w]}return this};let se={};function Pe(r,e,t){se[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Pe("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Pe("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),Pe("ERR_OUT_OF_RANGE",function(r,e,t){let o=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=qe(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=qe(c)),c+="n"),o+=` It must be ${e}. Received ${c}`,o},RangeError);function qe(r){let e="",t=r.length,o=r[0]==="-"?1:0;for(;t>=o+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function zt(r,e,t){ce(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&fe(e,r.length-(t+1))}function Ye(r,e,t,o,c,l){if(r>t||r<e){let p=typeof e=="bigint"?"n":"",w;throw e===0||e===BigInt(0)?w=`>= 0${p} and < 2${p} ** ${(l+1)*8}${p}`:w=`>= -(2${p} ** ${(l+1)*8-1}${p}) and < 2 ** ${(l+1)*8-1}${p}`,new se.ERR_OUT_OF_RANGE("value",w,r)}zt(o,c,l)}function ce(r,e){if(typeof r!="number")throw new se.ERR_INVALID_ARG_TYPE(e,"number",r)}function fe(r,e,t){throw Math.floor(r)!==r?(ce(r,t),new se.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new se.ERR_BUFFER_OUT_OF_BOUNDS:new se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}let Zt=/[^+/0-9A-Za-z-_]/g;function qt(r){if(r=r.split("=")[0],r=r.trim().replace(Zt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function be(r,e){e=e||1/0;let t,o=r.length,c=null,l=[];for(let p=0;p<o;++p){if(t=r.charCodeAt(p),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(p+1===o){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function Yt(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Jt(r,e){let t,o,c,l=[];for(let p=0;p<r.length&&!((e-=2)<0);++p)t=r.charCodeAt(p),o=t>>8,c=t%256,l.push(c),l.push(o);return l}function Je(r){return n.toByteArray(qt(r))}function we(r,e,t,o){let c;for(c=0;c<o&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function J(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function ve(r){return r!==r}let jt=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let o=t*16;for(let c=0;c<16;++c)e[o+c]=r[t]+r[c]}return e}();function ee(r){return typeof BigInt>"u"?Ht:r}function Ht(){throw new Error("BigInt not supported")}return ie}var oe=nt();oe.Buffer;oe.SlowBuffer;oe.INSPECT_MAX_BYTES;oe.kMaxLength;var v=oe.Buffer,Nr=oe.INSPECT_MAX_BYTES,$r=oe.kMaxLength;var vn=A(T(),1);var wn=A(T(),1);var zr=A(T(),1);var k={module:"URgYpPQzvxxfYQtjrIQ116bl3YBfcImo3JEnNo8Hlrk",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"kJo3YG9tKpMhBJhB8GlvmsghmpbY1o7q2VRAh1LsgpI",collection:"aHN0YxA7Th1OQdtgv0slWv9LMrvYukvNgWdkotJsML0",collectionActivity:"k8K8WIJb5kXOVvZRFXF5GIZW-7b2NtaTOd6G-E5MF0k",profile:"WBhJpPafkykqZZgTr7TAsz48RKG4vbOEAH4rZ3JxIQ8",zone:"f-Xac27OGcSSQuw8__BSwAauc4vANST92fZX2j0UJn0"},collectionRegistry:"zwKi27GuKS3GOlwL3EhNGH02SJDDAO5Uy43ZJwomhZ4",profileRegistry:"SNy4m-DrqxWl01YqGM4sxI8qCni-58re8uuJLvZPypY"},it={node:"https://router-1.forward.computer"},ot={"application/json":{type:"application/json",serialize:n=>JSON.stringify(n)}},z={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"};var E={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",bootloaderInit:"On-Boot",collectionId:"Collection-Id",collectionName:"Collection-Name",commericalUse:"Commercial-Use",contentType:"Content-Type",creator:"Creator",currency:"Currency",dataModelTraining:"Data-Model-Training",dataProtocol:"Data-Protocol",dateCreated:"Date-Created",derivations:"Derivations",description:"Description",displayName:"Display-Name",handle:"Handle",implements:"Implements",initialOwner:"Initial-Owner",license:"License",name:"Name",paymentAddress:"Payment-Address",paymentMode:"Payment-Mode",profileCreator:"Profile-Creator",profileIndex:"Profile-Index",protocolName:"Protocol-Name",renderWith:"Render-With",thumbnail:"Thumbnail",title:"Title",topic:"Topic",type:"Type",zoneType:"Zone-Type"},values:{document:"Document",user:"User",zone:"Permaweb-Zone"}},at={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var rn=A(T(),1);var Hr=A(T(),1);function pe(n){return n?/^[a-z0-9_-]{43}$/i.test(n):!1}function Ee(n,i){for(let a=0;a<n.length;a++)if(n[a]&&n[a].name===i)return n[a].value;return null}function st(n){let i=n.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return i?i[1]:null}function ct(n){return n.split(",")[1]}function ut(n){let i;if(v.isBuffer(n))i=n.length;else if(typeof n=="string")i=v.byteLength(n,"utf-8");else throw new Error("Input must be a string or a Buffer");return i}function Le(n){let i;return i=n.replace(/\[|\]/g,""),`[[${i}]]`}function ge(n){let i;return i=n.replace(/\[|\]/g,""),i}var Y=(...n)=>{console.log("[@permaweb/libs]",...n)};function cr(n){return n.replace(/^[a-z]/,i=>i.toUpperCase())}function le(n){return Array.isArray(n)?n.map(le):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=cr(a);return i[y]=pe(u)?u:le(u),i},{}):n}function ur(n){return n.charAt(0).toLowerCase()+n.slice(1)}function X(n){return Array.isArray(n)?n.map(X):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=ur(a);return i[y]=pe(u)?u:X(u),i},{}):n}function O(n,i){let a=n.charAt(0).toUpperCase()+n.slice(1);return{name:`${E.keys.bootloader}-${a}`,value:i}}var lr="https://arweave.net";function ye(n){return`${lr}/${n}`}var un=A(T(),1);var Ne={p1:"P1",end:"END"},$e={default:100};async function q(n){let i=n.paginator?n.paginator:$e.default,a=[],u=0,y=null;if(n.ids&&!n.ids.length)return{data:a,count:u,nextCursor:y,previousCursor:null};try{let d=yr(n),s=await dr({gateway:n.gateway??z.goldsky,query:pr(d)});return s?.data?.transactions?.edges?.length?(a=[...s.data.transactions.edges],u=s.data.transactions.count??0,a.length<i||!s.data.transactions.pageInfo.hasNextPage?y=Ne.end:y=a[a.length-1].cursor,{data:a,count:u,nextCursor:y,previousCursor:null}):{data:a,count:u,nextCursor:y,previousCursor:null}}catch(d){return console.error(d),{data:a,count:u,nextCursor:y,previousCursor:null}}}async function lt(n,i){let a=1,u=await q(n);if(u&&u.data.length){let y=u.data;for(i&&i(`Count: ${u.count}`),i&&i(`Pages to fetch: ${Math.ceil(u.count/(n.paginator??$e.default))}`),i&&i(`Page ${a} fetched`);u.nextCursor&&u.nextCursor!==Ne.end;)a+=1,i&&i(`Fetching page ${a}...`),u=await q({...n,cursor:u.nextCursor}),u&&u.data.length&&(y=y.concat(u.data));return i&&i("All pages fetched!"),y}else i&&i("No data found");return null}function pr(n){let i={query:`query { ${n} }`};return JSON.stringify(i)}function yr(n){let i=n.paginator?n.paginator:$e.default,a=n.ids?JSON.stringify(n.ids):null,u=null;n.minBlock!==void 0&&n.minBlock!==null&&(u={},u.min=n.minBlock);let y=u?JSON.stringify(u).replace(/"([^"]+)":/g,"$1:"):null,d=n.tags?JSON.stringify(n.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"match"/g,"match").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,s=n.owners?JSON.stringify(n.owners):null,h=n.recipients?JSON.stringify(n.recipients):null,g=n.cursor&&n.cursor!==Ne.end?`"${n.cursor}"`:null,B=`first: ${i}`,I="",D="data { size type } owner { address } block { height timestamp }",G="",f="";switch(n.gateway??z.goldsky){case z.arweave:break;case z.goldsky:g||(I="count"),h&&(f=`recipients: ${h}`),D+=" recipient";break}let x=`
1
+ var Kt=Object.create;var Ye=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var nr=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports);var ir=(n,i,a,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let y of er(i))!rr.call(n,y)&&y!==a&&Ye(n,y,{get:()=>i[y],enumerable:!(u=Xt(i,y))||u.enumerable});return n};var A=(n,i,a)=>(a=n!=null?Kt(tr(n)):{},ir(i||!n||!n.__esModule?Ye(a,"default",{value:n,enumerable:!0}):a,n));var T=nr((vr,Xe)=>{var P=Xe.exports={},Y,H;function Re(){throw new Error("setTimeout has not been defined")}function Ue(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Y=setTimeout:Y=Re}catch{Y=Re}try{typeof clearTimeout=="function"?H=clearTimeout:H=Ue}catch{H=Ue}})();function He(n){if(Y===setTimeout)return setTimeout(n,0);if((Y===Re||!Y)&&setTimeout)return Y=setTimeout,setTimeout(n,0);try{return Y(n,0)}catch{try{return Y.call(null,n,0)}catch{return Y.call(this,n,0)}}}function or(n){if(H===clearTimeout)return clearTimeout(n);if((H===Ue||!H)&&clearTimeout)return H=clearTimeout,clearTimeout(n);try{return H(n)}catch{try{return H.call(null,n)}catch{return H.call(this,n)}}}var K=[],le=!1,ne,Te=-1;function ar(){!le||!ne||(le=!1,ne.length?K=ne.concat(K):Te=-1,K.length&&je())}function je(){if(!le){var n=He(ar);le=!0;for(var i=K.length;i;){for(ne=K,K=[];++Te<i;)ne&&ne[Te].run();Te=-1,i=K.length}ne=null,le=!1,or(n)}}P.nextTick=function(n){var i=new Array(arguments.length-1);if(arguments.length>1)for(var a=1;a<arguments.length;a++)i[a-1]=arguments[a];K.push(new Ke(n,i)),K.length===1&&!le&&He(je)};function Ke(n,i){this.fun=n,this.array=i}Ke.prototype.run=function(){this.fun.apply(null,this.array)};P.title="browser";P.browser=!0;P.env={};P.argv=[];P.version="";P.versions={};function X(){}P.on=X;P.addListener=X;P.once=X;P.off=X;P.removeListener=X;P.removeAllListeners=X;P.emit=X;P.prependListener=X;P.prependOnceListener=X;P.listeners=function(n){return[]};P.binding=function(n){throw new Error("process.binding is not supported")};P.cwd=function(){return"/"};P.chdir=function(n){throw new Error("process.chdir is not supported")};P.umask=function(){return 0}});var no=A(T(),1);var Wr=A(T());var Rr=A(T(),1);var he={},et=!1;function sr(){if(et)return he;et=!0,he.byteLength=f,he.toByteArray=E,he.fromByteArray=$;for(var n=[],i=[],a=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,d=u.length;y<d;++y)n[y]=u[y],i[u.charCodeAt(y)]=y;i[45]=62,i[95]=63;function s(h){var m=h.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var x=h.indexOf("=");x===-1&&(x=m);var L=x===m?0:4-x%4;return[x,L]}function f(h){var m=s(h),x=m[0],L=m[1];return(x+L)*3/4-L}function g(h,m,x){return(m+x)*3/4-x}function E(h){var m,x=s(h),L=x[0],_=x[1],U=new a(g(h,L,_)),Q=0,Z=_>0?L-4:L,G;for(G=0;G<Z;G+=4)m=i[h.charCodeAt(G)]<<18|i[h.charCodeAt(G+1)]<<12|i[h.charCodeAt(G+2)]<<6|i[h.charCodeAt(G+3)],U[Q++]=m>>16&255,U[Q++]=m>>8&255,U[Q++]=m&255;return _===2&&(m=i[h.charCodeAt(G)]<<2|i[h.charCodeAt(G+1)]>>4,U[Q++]=m&255),_===1&&(m=i[h.charCodeAt(G)]<<10|i[h.charCodeAt(G+1)]<<4|i[h.charCodeAt(G+2)]>>2,U[Q++]=m>>8&255,U[Q++]=m&255),U}function B(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function D(h,m,x){for(var L,_=[],U=m;U<x;U+=3)L=(h[U]<<16&16711680)+(h[U+1]<<8&65280)+(h[U+2]&255),_.push(B(L));return _.join("")}function $(h){for(var m,x=h.length,L=x%3,_=[],U=16383,Q=0,Z=x-L;Q<Z;Q+=U)_.push(D(h,Q,Q+U>Z?Z:Q+U));return L===1?(m=h[x-1],_.push(n[m>>2]+n[m<<4&63]+"==")):L===2&&(m=(h[x-2]<<8)+h[x-1],_.push(n[m>>10]+n[m>>4&63]+n[m<<2&63]+"=")),_.join("")}return he}var Ae={},tt=!1;function cr(){if(tt)return Ae;tt=!0;return Ae.read=function(n,i,a,u,y){var d,s,f=y*8-u-1,g=(1<<f)-1,E=g>>1,B=-7,D=a?y-1:0,$=a?-1:1,h=n[i+D];for(D+=$,d=h&(1<<-B)-1,h>>=-B,B+=f;B>0;d=d*256+n[i+D],D+=$,B-=8);for(s=d&(1<<-B)-1,d>>=-B,B+=u;B>0;s=s*256+n[i+D],D+=$,B-=8);if(d===0)d=1-E;else{if(d===g)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,u),d=d-E}return(h?-1:1)*s*Math.pow(2,d-u)},Ae.write=function(n,i,a,u,y,d){var s,f,g,E=d*8-y-1,B=(1<<E)-1,D=B>>1,$=y===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=u?0:d-1,m=u?1:-1,x=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(f=isNaN(i)?1:0,s=B):(s=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-s))<1&&(s--,g*=2),s+D>=1?i+=$/g:i+=$*Math.pow(2,1-D),i*g>=2&&(s++,g/=2),s+D>=B?(f=0,s=B):s+D>=1?(f=(i*g-1)*Math.pow(2,y),s=s+D):(f=i*Math.pow(2,D-1)*Math.pow(2,y),s=0));y>=8;n[a+h]=f&255,h+=m,f/=256,y-=8);for(s=s<<y|f,E+=y;E>0;n[a+h]=s&255,h+=m,s/=256,E-=8);n[a+h-m]|=x*128},Ae}var ie={},rt=!1;function nt(){if(rt)return ie;rt=!0;let n=sr(),i=cr(),a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ie.Buffer=s,ie.SlowBuffer=_,ie.INSPECT_MAX_BYTES=50;let u=2147483647;ie.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=y(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function y(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function d(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,s.prototype),e}function s(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return f(r,e,t)}s.poolSize=8192;function f(r,e,t){if(typeof r=="string")return D(r,e);if(ArrayBuffer.isView(r))return h(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(V(r,ArrayBuffer)||r&&V(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(V(r,SharedArrayBuffer)||r&&V(r.buffer,SharedArrayBuffer)))return m(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=r.valueOf&&r.valueOf();if(o!=null&&o!==r)return s.from(o,e,t);let c=x(r);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return s.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}s.from=function(r,e,t){return f(r,e,t)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function E(r,e,t){return g(r),r<=0?d(r):e!==void 0?typeof t=="string"?d(r).fill(e,t):d(r).fill(e):d(r)}s.alloc=function(r,e,t){return E(r,e,t)};function B(r){return g(r),d(r<0?0:L(r)|0)}s.allocUnsafe=function(r){return B(r)},s.allocUnsafeSlow=function(r){return B(r)};function D(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=U(r,e)|0,o=d(t),c=o.write(r,e);return c!==t&&(o=o.slice(0,c)),o}function $(r){let e=r.length<0?0:L(r.length)|0,t=d(e);for(let o=0;o<e;o+=1)t[o]=r[o]&255;return t}function h(r){if(V(r,Uint8Array)){let e=new Uint8Array(r);return m(e.buffer,e.byteOffset,e.byteLength)}return $(r)}function m(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let o;return e===void 0&&t===void 0?o=new Uint8Array(r):t===void 0?o=new Uint8Array(r,e):o=new Uint8Array(r,e,t),Object.setPrototypeOf(o,s.prototype),o}function x(r){if(s.isBuffer(r)){let e=L(r.length)|0,t=d(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Pe(r.length)?d(0):$(r);if(r.type==="Buffer"&&Array.isArray(r.data))return $(r.data)}function L(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function _(r){return+r!=r&&(r=0),s.alloc(+r)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),V(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let o=e.length,c=t.length;for(let l=0,p=Math.min(o,c);l<p;++l)if(e[l]!==t[l]){o=e[l],c=t[l];break}return o<c?-1:c<o?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return s.alloc(0);let o;if(t===void 0)for(t=0,o=0;o<e.length;++o)t+=e[o].length;let c=s.allocUnsafe(t),l=0;for(o=0;o<e.length;++o){let p=e[o];if(V(p,Uint8Array))l+p.length>c.length?(s.isBuffer(p)||(p=s.from(p)),p.copy(c,l)):Uint8Array.prototype.set.call(c,p,l);else if(s.isBuffer(p))p.copy(c,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=p.length}return c};function U(r,e){if(s.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||V(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&t===0)return 0;let c=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return be(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ve(r).length;default:if(c)return o?-1:be(r).length;e=(""+e).toLowerCase(),c=!0}}s.byteLength=U;function Q(r,e,t){let o=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ft(this,e,t);case"utf8":case"utf-8":return We(this,e,t);case"ascii":return _t(this,e,t);case"latin1":case"binary":return Qt(this,e,t);case"base64":return Wt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zt(this,e,t);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),o=!0}}s.prototype._isBuffer=!0;function Z(r,e,t){let o=r[e];r[e]=r[t],r[t]=o}s.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)Z(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)Z(this,t,t+3),Z(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)Z(this,t,t+7),Z(this,t+1,t+6),Z(this,t+2,t+5),Z(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?We(this,0,e):Q.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let e="",t=ie.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a&&(s.prototype[a]=s.prototype.inspect),s.prototype.compare=function(e,t,o,c,l){if(V(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),o===void 0&&(o=e?e.length:0),c===void 0&&(c=0),l===void 0&&(l=this.length),t<0||o>e.length||c<0||l>this.length)throw new RangeError("out of range index");if(c>=l&&t>=o)return 0;if(c>=l)return-1;if(t>=o)return 1;if(t>>>=0,o>>>=0,c>>>=0,l>>>=0,this===e)return 0;let p=l-c,w=o-t,v=Math.min(p,w),S=this.slice(c,l),b=e.slice(t,o);for(let C=0;C<v;++C)if(S[C]!==b[C]){p=S[C],w=b[C];break}return p<w?-1:w<p?1:0};function G(r,e,t,o,c){if(r.length===0)return-1;if(typeof t=="string"?(o=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Pe(t)&&(t=c?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(c)return-1;t=r.length-1}else if(t<0)if(c)t=0;else return-1;if(typeof e=="string"&&(e=s.from(e,o)),s.isBuffer(e))return e.length===0?-1:Ge(r,e,t,o,c);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ge(r,[e],t,o,c);throw new TypeError("val must be string, number or Buffer")}function Ge(r,e,t,o,c){let l=1,p=r.length,w=e.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,p/=2,w/=2,t/=2}function v(b,C){return l===1?b[C]:b.readUInt16BE(C*l)}let S;if(c){let b=-1;for(S=t;S<p;S++)if(v(r,S)===v(e,b===-1?0:S-b)){if(b===-1&&(b=S),S-b+1===w)return b*l}else b!==-1&&(S-=S-b),b=-1}else for(t+w>p&&(t=p-w),S=t;S>=0;S--){let b=!0;for(let C=0;C<w;C++)if(v(r,S+C)!==v(e,C)){b=!1;break}if(b)return S}return-1}s.prototype.includes=function(e,t,o){return this.indexOf(e,t,o)!==-1},s.prototype.indexOf=function(e,t,o){return G(this,e,t,o,!0)},s.prototype.lastIndexOf=function(e,t,o){return G(this,e,t,o,!1)};function Nt(r,e,t,o){t=Number(t)||0;let c=r.length-t;o?(o=Number(o),o>c&&(o=c)):o=c;let l=e.length;o>l/2&&(o=l/2);let p;for(p=0;p<o;++p){let w=parseInt(e.substr(p*2,2),16);if(Pe(w))return p;r[t+p]=w}return p}function $t(r,e,t,o){return we(be(e,r.length-t),r,t,o)}function Mt(r,e,t,o){return we(Vt(e),r,t,o)}function kt(r,e,t,o){return we(Ve(e),r,t,o)}function Gt(r,e,t,o){return we(Yt(e,r.length-t),r,t,o)}s.prototype.write=function(e,t,o,c){if(t===void 0)c="utf8",o=this.length,t=0;else if(o===void 0&&typeof t=="string")c=t,o=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-t;if((o===void 0||o>l)&&(o=l),e.length>0&&(o<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");let p=!1;for(;;)switch(c){case"hex":return Nt(this,e,t,o);case"utf8":case"utf-8":return $t(this,e,t,o);case"ascii":case"latin1":case"binary":return Mt(this,e,t,o);case"base64":return kt(this,e,t,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gt(this,e,t,o);default:if(p)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),p=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Wt(r,e,t){return e===0&&t===r.length?n.fromByteArray(r):n.fromByteArray(r.slice(e,t))}function We(r,e,t){t=Math.min(r.length,t);let o=[],c=e;for(;c<t;){let l=r[c],p=null,w=l>239?4:l>223?3:l>191?2:1;if(c+w<=t){let v,S,b,C;switch(w){case 1:l<128&&(p=l);break;case 2:v=r[c+1],(v&192)===128&&(C=(l&31)<<6|v&63,C>127&&(p=C));break;case 3:v=r[c+1],S=r[c+2],(v&192)===128&&(S&192)===128&&(C=(l&15)<<12|(v&63)<<6|S&63,C>2047&&(C<55296||C>57343)&&(p=C));break;case 4:v=r[c+1],S=r[c+2],b=r[c+3],(v&192)===128&&(S&192)===128&&(b&192)===128&&(C=(l&15)<<18|(v&63)<<12|(S&63)<<6|b&63,C>65535&&C<1114112&&(p=C))}}p===null?(p=65533,w=1):p>65535&&(p-=65536,o.push(p>>>10&1023|55296),p=56320|p&1023),o.push(p),c+=w}return Ot(o)}let Oe=4096;function Ot(r){let e=r.length;if(e<=Oe)return String.fromCharCode.apply(String,r);let t="",o=0;for(;o<e;)t+=String.fromCharCode.apply(String,r.slice(o,o+=Oe));return t}function _t(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]&127);return o}function Qt(r,e,t){let o="";t=Math.min(r.length,t);for(let c=e;c<t;++c)o+=String.fromCharCode(r[c]);return o}function Ft(r,e,t){let o=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>o)&&(t=o);let c="";for(let l=e;l<t;++l)c+=Ht[r[l]];return c}function zt(r,e,t){let o=r.slice(e,t),c="";for(let l=0;l<o.length-1;l+=2)c+=String.fromCharCode(o[l]+o[l+1]*256);return c}s.prototype.slice=function(e,t){let o=this.length;e=~~e,t=t===void 0?o:~~t,e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),t<e&&(t=e);let c=this.subarray(e,t);return Object.setPrototypeOf(c,s.prototype),c};function N(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return c},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e+--t],l=1;for(;t>0&&(l*=256);)c+=this[e+--t]*l;return c},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+o*2**24;return BigInt(c)+(BigInt(l)<<BigInt(32))}),s.prototype.readBigUInt64BE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o;return(BigInt(c)<<BigInt(32))+BigInt(l)}),s.prototype.readIntLE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=this[e],l=1,p=0;for(;++p<t&&(l*=256);)c+=this[e+p]*l;return l*=128,c>=l&&(c-=Math.pow(2,8*t)),c},s.prototype.readIntBE=function(e,t,o){e=e>>>0,t=t>>>0,o||N(e,t,this.length);let c=t,l=1,p=this[e+--c];for(;c>0&&(l*=256);)p+=this[e+--c]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*t)),p},s.prototype.readInt8=function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o},s.prototype.readInt16BE=function(e,t){e=e>>>0,t||N(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o},s.prototype.readInt32LE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(o<<24);return(BigInt(c)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=te(function(e){e=e>>>0,ue(e,"offset");let t=this[e],o=this[e+7];(t===void 0||o===void 0)&&de(e,this.length-8);let c=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(c)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+o)}),s.prototype.readFloatLE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e=e>>>0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||N(e,8,this.length),i.read(this,e,!1,52,8)};function F(r,e,t,o,c,l){if(!s.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>c||e<l)throw new RangeError('"value" argument is out of bounds');if(t+o>r.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;F(this,e,t,o,w,0)}let l=1,p=0;for(this[t]=e&255;++p<o&&(l*=256);)this[t+p]=e/l&255;return t+o},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,o=o>>>0,!c){let w=Math.pow(2,8*o)-1;F(this,e,t,o,w,0)}let l=o-1,p=1;for(this[t+l]=e&255;--l>=0&&(p*=256);)this[t+l]=e/p&255;return t+o},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function _e(r,e,t,o,c){Je(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,p=p>>8,r[t++]=p,t}function Qe(r,e,t,o,c){Je(e,o,c,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let p=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=p,p=p>>8,r[t+2]=p,p=p>>8,r[t+1]=p,p=p>>8,r[t]=p,t+8}s.prototype.writeBigUInt64LE=te(function(e,t=0){return _e(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeBigUInt64BE=te(function(e,t=0){return Qe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),s.prototype.writeIntLE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let v=Math.pow(2,8*o-1);F(this,e,t,o,v-1,-v)}let l=0,p=1,w=0;for(this[t]=e&255;++l<o&&(p*=256);)e<0&&w===0&&this[t+l-1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeIntBE=function(e,t,o,c){if(e=+e,t=t>>>0,!c){let v=Math.pow(2,8*o-1);F(this,e,t,o,v-1,-v)}let l=o-1,p=1,w=0;for(this[t+l]=e&255;--l>=0&&(p*=256);)e<0&&w===0&&this[t+l+1]!==0&&(w=1),this[t+l]=(e/p>>0)-w&255;return t+o},s.prototype.writeInt8=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,o){return e=+e,t=t>>>0,o||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=te(function(e,t=0){return _e(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),s.prototype.writeBigInt64BE=te(function(e,t=0){return Qe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Fe(r,e,t,o,c,l){if(t+o>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Fe(r,e,t,4),i.write(r,e,t,o,23,4),t+4}s.prototype.writeFloatLE=function(e,t,o){return ze(this,e,t,!0,o)},s.prototype.writeFloatBE=function(e,t,o){return ze(this,e,t,!1,o)};function Ze(r,e,t,o,c){return e=+e,t=t>>>0,c||Fe(r,e,t,8),i.write(r,e,t,o,52,8),t+8}s.prototype.writeDoubleLE=function(e,t,o){return Ze(this,e,t,!0,o)},s.prototype.writeDoubleBE=function(e,t,o){return Ze(this,e,t,!1,o)},s.prototype.copy=function(e,t,o,c){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),t>=e.length&&(t=e.length),t||(t=0),c>0&&c<o&&(c=o),c===o||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),e.length-t<c-o&&(c=e.length-t+o);let l=c-o;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,o,c):Uint8Array.prototype.set.call(e,this.subarray(o,c),t),l},s.prototype.fill=function(e,t,o,c){if(typeof e=="string"){if(typeof t=="string"?(c=t,t=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!s.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(e.length===1){let p=e.charCodeAt(0);(c==="utf8"&&p<128||c==="latin1")&&(e=p)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<o)throw new RangeError("Out of range index");if(o<=t)return this;t=t>>>0,o=o===void 0?this.length:o>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l<o;++l)this[l]=e;else{let p=s.isBuffer(e)?e:s.from(e,c),w=p.length;if(w===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(l=0;l<o-t;++l)this[l+t]=p[l%w]}return this};let ce={};function ve(r,e,t){ce[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(c){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:c,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}ve("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ve("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),ve("ERR_OUT_OF_RANGE",function(r,e,t){let o=`The value of "${r}" is out of range.`,c=t;return Number.isInteger(t)&&Math.abs(t)>2**32?c=qe(String(t)):typeof t=="bigint"&&(c=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(c=qe(c)),c+="n"),o+=` It must be ${e}. Received ${c}`,o},RangeError);function qe(r){let e="",t=r.length,o=r[0]==="-"?1:0;for(;t>=o+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Zt(r,e,t){ue(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&de(e,r.length-(t+1))}function Je(r,e,t,o,c,l){if(r>t||r<e){let p=typeof e=="bigint"?"n":"",w;throw e===0||e===BigInt(0)?w=`>= 0${p} and < 2${p} ** ${(l+1)*8}${p}`:w=`>= -(2${p} ** ${(l+1)*8-1}${p}) and < 2 ** ${(l+1)*8-1}${p}`,new ce.ERR_OUT_OF_RANGE("value",w,r)}Zt(o,c,l)}function ue(r,e){if(typeof r!="number")throw new ce.ERR_INVALID_ARG_TYPE(e,"number",r)}function de(r,e,t){throw Math.floor(r)!==r?(ue(r,t),new ce.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}let qt=/[^+/0-9A-Za-z-_]/g;function Jt(r){if(r=r.split("=")[0],r=r.trim().replace(qt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function be(r,e){e=e||1/0;let t,o=r.length,c=null,l=[];for(let p=0;p<o;++p){if(t=r.charCodeAt(p),t>55295&&t<57344){if(!c){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(p+1===o){(e-=3)>-1&&l.push(239,191,189);continue}c=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),c=t;continue}t=(c-55296<<10|t-56320)+65536}else c&&(e-=3)>-1&&l.push(239,191,189);if(c=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function Vt(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Yt(r,e){let t,o,c,l=[];for(let p=0;p<r.length&&!((e-=2)<0);++p)t=r.charCodeAt(p),o=t>>8,c=t%256,l.push(c),l.push(o);return l}function Ve(r){return n.toByteArray(Jt(r))}function we(r,e,t,o){let c;for(c=0;c<o&&!(c+t>=e.length||c>=r.length);++c)e[c+t]=r[c];return c}function V(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Pe(r){return r!==r}let Ht=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let o=t*16;for(let c=0;c<16;++c)e[o+c]=r[t]+r[c]}return e}();function te(r){return typeof BigInt>"u"?jt:r}function jt(){throw new Error("BigInt not supported")}return ie}var oe=nt();oe.Buffer;oe.SlowBuffer;oe.INSPECT_MAX_BYTES;oe.kMaxLength;var R=oe.Buffer,Mr=oe.INSPECT_MAX_BYTES,kr=oe.kMaxLength;var Ln=A(T(),1);var En=A(T(),1);var qr=A(T(),1);var W={module:"URgYpPQzvxxfYQtjrIQ116bl3YBfcImo3JEnNo8Hlrk",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"jm8OfYb4PL8-AHvx3k0csQUWDpR24bh6l8uNCoWueHA",collection:"flkCYx4lJtOtsVFyUZLN-AKpkObNoTMYu4GfUTzNoGE",collectionActivity:"k8K8WIJb5kXOVvZRFXF5GIZW-7b2NtaTOd6G-E5MF0k",profile:"WBhJpPafkykqZZgTr7TAsz48RKG4vbOEAH4rZ3JxIQ8",zone:"EQxcaL4yo_tLz7emxBPewWs98tmxJ3z8G56CfcpH3aA"},collectionRegistry:"zwKi27GuKS3GOlwL3EhNGH02SJDDAO5Uy43ZJwomhZ4",profileRegistry:"SNy4m-DrqxWl01YqGM4sxI8qCni-58re8uuJLvZPypY"};var it={"application/json":{type:"application/json",serialize:n=>JSON.stringify(n)}},z={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"};var I={keys:{access:"Access-Fee",ans110:{title:"Title",description:"Description",topic:"Topic:*",type:"Type",implements:"Implements",license:"License"},assetType:"Asset-Type",banner:"Banner",bootloader:"Bootloader",collectionId:"Collection-Id",collectionName:"Collection-Name",commericalUse:"Commercial-Use",contentType:"Content-Type",creator:"Creator",currency:"Currency",dataModelTraining:"Data-Model-Training",dataProtocol:"Data-Protocol",dateCreated:"Date-Created",derivations:"Derivations",description:"Description",displayName:"Display-Name",handle:"Handle",implements:"Implements",initialOwner:"Initial-Owner",license:"License",name:"Name",onBoot:"On-Boot",paymentAddress:"Payment-Address",paymentMode:"Payment-Mode",profileCreator:"Profile-Creator",profileIndex:"Profile-Index",protocolName:"Protocol-Name",renderWith:"Render-With",thumbnail:"Thumbnail",title:"Title",topic:"Topic",type:"Type",zoneType:"Zone-Type"},values:{document:"Document",user:"User",zone:"Permaweb-Zone"}},ot={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:100*1024};var on=A(T(),1);var Kr=A(T(),1);function J(n){return n?/^[a-z0-9_-]{43}$/i.test(n):!1}function Ee(n,i){for(let a=0;a<n.length;a++)if(n[a]&&n[a].name===i)return n[a].value;return null}function at(n){let i=n.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return i?i[1]:null}function st(n){return n.split(",")[1]}function ct(n){let i;if(R.isBuffer(n))i=n.length;else if(typeof n=="string")i=R.byteLength(n,"utf-8");else throw new Error("Input must be a string or a Buffer");return i}function Le(n){let i;return i=n.replace(/\[|\]/g,""),`[[${i}]]`}function fe(n){let i;return i=n.replace(/\[|\]/g,""),i}var j=(...n)=>{console.log("[@permaweb/libs]",...n)};function ur(n){return n.replace(/^[a-z]/,i=>i.toUpperCase())}function pe(n){return Array.isArray(n)?n.map(pe):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=ur(a);return i[y]=J(u)?u:pe(u),i},{}):n}function lr(n){return n.charAt(0).toLowerCase()+n.slice(1)}function re(n){return Array.isArray(n)?n.map(re):n&&typeof n=="object"?Object.entries(n).reduce((i,[a,u])=>{let y=J(a)||a.includes("-")?a:lr(a);return i[y]=J(u)?u:re(u),i},{}):n}function O(n,i){let a=n.charAt(0).toUpperCase()+n.slice(1);return{name:`${I.keys.bootloader}-${a}`,value:i}}var pr="https://arweave.net";function ye(n){return`${pr}/${n}`}var pn=A(T(),1);var Ne={p1:"P1",end:"END"},$e={default:100};async function q(n){let i=n.paginator?n.paginator:$e.default,a=[],u=0,y=null;if(n.ids&&!n.ids.length)return{data:a,count:u,nextCursor:y,previousCursor:null};try{let d=dr(n),s=await hr({gateway:n.gateway??z.goldsky,query:yr(d)});return s?.data?.transactions?.edges?.length?(a=[...s.data.transactions.edges],u=s.data.transactions.count??0,a.length<i||!s.data.transactions.pageInfo.hasNextPage?y=Ne.end:y=a[a.length-1].cursor,{data:a,count:u,nextCursor:y,previousCursor:null}):{data:a,count:u,nextCursor:y,previousCursor:null}}catch(d){return console.error(d),{data:a,count:u,nextCursor:y,previousCursor:null}}}async function ut(n,i){let a=1,u=await q(n);if(u&&u.data.length){let y=u.data;for(i&&i(`Count: ${u.count}`),i&&i(`Pages to fetch: ${Math.ceil(u.count/(n.paginator??$e.default))}`),i&&i(`Page ${a} fetched`);u.nextCursor&&u.nextCursor!==Ne.end;)a+=1,i&&i(`Fetching page ${a}...`),u=await q({...n,cursor:u.nextCursor}),u&&u.data.length&&(y=y.concat(u.data));return i&&i("All pages fetched!"),y}else i&&i("No data found");return null}function yr(n){let i={query:`query { ${n} }`};return JSON.stringify(i)}function dr(n){let i=n.paginator?n.paginator:$e.default,a=n.ids?JSON.stringify(n.ids):null,u=null;n.minBlock!==void 0&&n.minBlock!==null&&(u={},u.min=n.minBlock);let y=u?JSON.stringify(u).replace(/"([^"]+)":/g,"$1:"):null,d=n.tags?JSON.stringify(n.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"match"/g,"match").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,s=n.owners?JSON.stringify(n.owners):null,f=n.recipients?JSON.stringify(n.recipients):null,g=n.cursor&&n.cursor!==Ne.end?`"${n.cursor}"`:null,E="";if(n.sort)switch(E+="sort: ",n.sort){case"ascending":E+="HEIGHT_ASC";break;case"descending":E+="HEIGHT_DESC";break}let B=`first: ${i}`,D="",$="data { size type } owner { address } block { height timestamp }",h="";switch(n.gateway??z.goldsky){case z.arweave:break;case z.goldsky:g||(D="count"),f&&(h=`recipients: ${f}`),$+=" recipient";break}let x=`
2
2
  transactions(
3
3
  ids: ${a},
4
4
  tags: ${d},
5
5
  ${B}
6
6
  owners: ${s},
7
- ${f},
7
+ ${h},
8
8
  block: ${y},
9
9
  after: ${g},
10
- ${G}
10
+ ${E}
11
11
  ){
12
- ${I}
12
+ ${D}
13
13
  pageInfo {
14
14
  hasNextPage
15
15
  }
@@ -21,10 +21,10 @@ var Vt=Object.create;var je=Object.defineProperty;var Kt=Object.getOwnPropertyDe
21
21
  name
22
22
  value
23
23
  }
24
- ${D}
24
+ ${$}
25
25
  }
26
26
  }
27
- }`;return n.queryKey&&(x=`${n.queryKey}: ${x}`),x}async function dr(n){try{return await(await fetch(`https://${n.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:n.query})).json()}catch(i){throw i}}var fr=z.goldsky,hr=100;async function pt(n,i){let a=[{name:"Authority",value:k.mu}];i.tags&&i.tags.length>0&&i.tags.forEach(u=>a.push(u));try{let u=await n.ao.spawn({module:i.module,scheduler:i.scheduler,signer:n.signer,tags:a,data:i.data});return Y(`Process ID: ${u}`),u}catch(u){throw console.log(u),new Error(u.message??"Error spawning process")}}function yt(n){return async i=>await te(n,i)}async function te(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u=i.useRawData?i.data:JSON.stringify(i.data);return await n.ao.message({process:i.processId,signer:n.signer,tags:a,data:u})}catch(a){throw new Error(a)}}async function Ie(n,i){let a=i.node??it.node,u="now";try{return console.log("Getting state from HyperBEAM..."),await(await fetch(`${a}/${i.processId}~process@1.0/${u}/${i.path}`)).json()}catch(y){if(i.fallbackAction)return console.error(y.message??"Error reading process from HyperBEAM"),console.log("State not found, dryrunning..."),await de(n,{processId:i.processId,action:i.fallbackAction});throw new Error(y.message??"Error reading process from HyperBEAM")}}function dt(n){return async i=>await de(n,i)}async function de(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u;if(typeof i.data=="object")u=JSON.stringify(i.data||{});else if(typeof i.data=="string"){try{JSON.parse(i.data)}catch(d){throw console.error(d),new Error("Invalid JSON data")}u=i.data}let y=await n.ao.dryrun({process:i.processId,tags:a,data:u});if(y.Messages&&y.Messages.length){if(y.Messages[0].Data)return JSON.parse(y.Messages[0].Data);if(y.Messages[0].Tags)return y.Messages[0].Tags.reduce((d,s)=>(d[s.name]=s.value,d),{})}}catch(a){throw new Error(a.message??"Error dryrunning process")}}async function gr(n,i){try{let{Messages:a}=await n.ao.result({message:i.messageId,process:i.processId});if(a&&a.length){let u={};return a.forEach(y=>{let d=Ee(y.Tags,"Action")||i.action,s=null,h=y.Data;if(h)try{s=JSON.parse(h)}catch{s=h}let g=Ee(y.Tags,"Status"),B=Ee(y.Tags,"Message");u[d]={id:i.messageId,status:g,message:B,data:s}}),u}else return null}catch(a){console.error(a)}}async function ft(n,i){let a=null;if(i.evalSrc?a=i.evalSrc:i.evalTxId&&(a=await mr(i.evalTxId)),a)try{let u=await te(n,{processId:i.processId,action:"Eval",data:a,tags:i.evalTags||null,useRawData:!0});return Y(`Eval: ${u}`),await gr(n,{processId:i.processId,messageId:u,action:"Eval"})}catch(u){throw new Error(u.message??"Error sending process eval")}return null}function ht(n){return async(i,a)=>{try{let u={module:i.module||k.module,scheduler:i.scheduler||k.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await pt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await ft(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}}async function re(n,i,a){try{let u={module:i.module||k.module,scheduler:i.scheduler||k.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await pt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await ft(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}async function mr(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i)}}async function gt(n){let i=0,a=n.noRetryLimit?1/0:hr;for(;i<a;){await new Promise(y=>setTimeout(y,2e3));let u=await q({gateway:fr,ids:[n.processId]});if(u?.data?.length){let y=u.data[0].node.id;return Y(`Process found: ${y} (Try ${i+1})`),y}else Y(`Process not found: ${n.processId} (Try ${i+1})`),i++}if(a!==1/0)throw new Error("Process not found, please try again")}var Sn=A(T(),1);function mt(n){return async i=>{if(pe(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await wt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}}async function ae(n,i){if(pe(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await wt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}async function wt(n,i){let a=null,u=null,y=null;if(typeof i.data=="string"&&(a=v.from(ct(i.data),"base64"),u=st(i.data),y=ut(a)),i.data instanceof File&&(a=new Uint8Array(await i.data.arrayBuffer()),u=i.data.type,y=i.data.size),a&&u&&y)if(y<Number(at.dispatchUploadSize))try{let d=await n.arweave.createTransaction({data:a},"use_wallet");return d.addTag(E.keys.contentType,u),i.tags&&i.tags.length>0&&i.tags.forEach(h=>d.addTag(h.name,h.value)),(await global.window.arweaveWallet.dispatch(d)).id}catch(d){throw new Error(d.message??"Error dispatching transaction")}else throw new Error("Paid uploads are not yet supported");else throw new Error("Error preparing transaction data")}var _n=A(T(),1);var Gn=A(T(),1);var zi=A(T(),1);var ti=A(T(),1);function Be(n){return async(i,a)=>{let u=Er(i);if(u)throw new Error(u);let y=ot[i.contentType]?.serialize(i.data)??i.data,d=Ar(i);try{return await re(n,{tags:d,data:y},a?h=>a(h):void 0)}catch(s){throw new Error(s.message??"Error creating asset")}}}async function Me(n,i,a){try{let u=X(await Ie(n,{processId:i,path:"asset",fallbackAction:"Info"}));if(a?.useGateway){let y=await q({gateway:z.goldsky,ids:[i],tags:null,owners:null,cursor:null});return{...y?.data?.[0]?xe(y.data[0]):{},...u}}return{id:i,...u}}catch(u){throw new Error(u.message||"Error fetching atomic asset")}}function Tt(n){return async(i,a)=>await Me(n,i,a)}async function At(n){try{let i=await q({gateway:z.arweave,ids:n??null,tags:null,owners:null,cursor:null});return i&&i.data.length?i.data.map(a=>xe(a)):null}catch(i){throw new Error(i)}}function xe(n){let i={id:n.node.id,owner:n.node.owner.address};for(let a of n.node.tags){let u=a.name,d=(u.startsWith(`${E.keys.bootloader}-`)?u.slice(`${E.keys.bootloader}-`.length):u).split("-").map((h,g)=>g===0?h.toLowerCase():h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()).join(""),s;try{s=JSON.parse(a.value)}catch{s=a.value.toString()}i[d]=s}return i}function Ar(n){let i=[{name:E.keys.bootloaderInit,value:n.src??k.src.asset},{name:E.keys.creator,value:n.creator},{name:E.keys.assetType,value:n.assetType},{name:E.keys.contentType,value:n.contentType},{name:E.keys.implements,value:"ANS-110"},{name:E.keys.dateCreated,value:new Date().getTime().toString()},O("Name",n.name),O("Description",n.description),O("Topics",JSON.stringify(n.topics)),O("Ticker","ATOMIC"),O("Denomination",n.denomination?.toString()??"1"),O("TotalSupply",n.supply?.toString()??"1"),O("Transferable",n.transferable?.toString()??"true"),O("Creator",n.creator)];if(n.metadata)for(let a in n.metadata)i.push(O(le(a),n.metadata[a].toString()));return n.tags&&n.tags.forEach(a=>i.push(a)),i}function Er(n){if(typeof n!="object"||n===null)return"The provided arguments are invalid or empty.";let i=["name","description","topics","creator","data","contentType","assetType"];for(let a of i)if(!(a in n))return`Missing field '${a}'`;return typeof n.name!="string"||n.name.trim()===""?"Name is required":typeof n.description!="string"?"The description must be a valid string":!Array.isArray(n.topics)||n.topics.length===0?"Topics are required":typeof n.creator!="string"||n.creator.trim()===""?"Creator is required":n.data===void 0||n.data===null?"Data field is required":typeof n.contentType!="string"||n.contentType.trim()===""?"Content type must be a non-empty string":typeof n.assetType!="string"||n.assetType.trim()===""?"Type must be a non-empty string":"supply"in n&&(typeof n.supply!="number"||n.supply<=0)?"Supply must be a positive number":"denomination"in n&&(typeof n.denomination!="number"||n.denomination<=0)?"Denomination must be a positive number":"transferable"in n&&typeof n.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in n&&typeof n.metadata!="object"?"Metadata must be an object":"tags"in n&&(!Array.isArray(n.tags)||n.tags.some(a=>typeof a!="object"))?"Tags must be an array of objects":"src"in n&&typeof n.src!="string"?"Source must be a valid string":null}var pi=A(T(),1);var Ir="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",me="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function Et(n){return async(i,a)=>{if(!n.signer)throw new Error("No signer provided");let u=new Date().getTime().toString(),y=[{name:E.keys.contentType,value:"application/json"},{name:E.keys.creator,value:i.creator},{name:E.keys.ans110.title,value:ge(i.title)},{name:E.keys.ans110.description,value:ge(i.description)},{name:E.keys.dateCreated,value:u},{name:E.keys.name,value:ge(i.title)},{name:"Action",value:"Add-Collection"}],d=null,s=null;try{d=i.banner?await ae(n,i.thumbnail):me,s=i.banner?await ae(n,i.banner):Ir,i.thumbnail&&y.push({name:E.keys.thumbnail,value:d}),i.banner&&y.push({name:E.keys.banner,value:s})}catch(B){console.error(B)}let h=await fetch(ye(k.src.collection));if(!h.ok)throw new Error("Unable to fetch process src");let g=await h.text();g=g.replace(/'<NAME>'/g,Le(i.title)),g=g.replace(/'<DESCRIPTION>'/g,Le(i.description)),g=g.replace(/<CREATOR>/g,i.creator),g=g.replace(/<THUMBNAIL>/g,d||me),g=g.replace(/<BANNER>/g,s||me),g=g.replace(/<DATECREATED>/g,u),g=g.replace(/<LASTUPDATE>/g,u);try{let B=await re(n,{tags:y},a?I=>a(I):void 0);if(Y("Sending eval message to collection..."),a&&a("Sending eval message to collection..."),await n.ao.message({process:B,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:g}),!i.skipRegistry){Y("Sending collection to registry..."),a&&a("Sending collection to registry...");let I=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:B},{name:"Name",value:ge(i.title)},{name:"Creator",value:i.creator},{name:"DateCreated",value:u}];s&&I.push({name:"Banner",value:s}),d&&I.push({name:"Thumbnail",value:d}),await n.ao.message({process:k.collectionRegistry,signer:n.signer,tags:I})}if(!i.skipActivity){Y("Creating collection activity process..."),a&&a("Creating collection activity process...");let I=[{name:"CollectionId",value:B},{name:"DateCreated",value:u},{name:"On-Boot",value:k.src.collectionActivity}],D=await re(n,{tags:I},a?G=>a(G):void 0);Y("Adding activity to collection process..."),a&&a("Adding activity to collection process..."),await n.ao.message({process:B,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${D}'`})}return B}catch(B){throw new Error(B.message??"Error creating collection")}}}function It(n){return async i=>await te(n,{processId:i.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:i.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:i.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:i.assetIds,UpdateType:i.updateType})}})}function Bt(n){return async i=>{let a=await de(n,{processId:i,action:"Info"});return{...{id:i,title:a.Name,description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,thumbnail:a.Thumbnail??me,banner:a.Banner??me},assetIds:a.Assets}}}function xt(n){return async i=>{let a=i.creator?"Get-Collections-By-User":"Get-Collections",u=await de(n,{processId:k.collectionRegistry,action:a,tags:i.creator?[{name:"Creator",value:i.creator}]:null});return u&&u.Collections&&u.Collections.length?u.Collections.map(d=>({id:d.Id,title:d.Name.replace(/\[|\]/g,""),description:d.Description,creator:d.Creator,dateCreated:d.DateCreated,banner:d.Banner,thumbnail:d.Thumbnail})):null}}var Ai=A(T(),1);function Ct(n){let i=Be(n);return async(a,u)=>{let y=a.tags?a.tags:[];y.push({name:"Data-Source",value:a.parentId}),y.push({name:"Root-Source",value:a.rootId??a.parentId});let d={name:`Comment on ${a.parentId}`,description:`Comment on ${a.parentId}`,topics:["comment"],creator:a.creator,data:a.content,contentType:"text/plain",assetType:"comment",tags:y};return i(d,u)}}function St(n){return async i=>{try{let a=await Me(n,i,{useGateway:!0}),u=a?.dataSource,y=a?.rootSource;if(!u||!y)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Pt(i),parentId:u,rootId:y}}catch(a){throw new Error(a.message??"Error getting comment")}}}function Dt(n){return async i=>{if(!i.parentId&&!i.rootId)throw new Error("Must provide either parentId or rootId");let a=[];i.parentId&&a.push({name:"Data-Source",values:[i.parentId??""]}),i.rootId&&a.push({name:"Root-Source",values:[i.rootId??""]});let u=await q({gateway:z.goldsky,ids:null,tags:a,owners:null,cursor:null}),y=[];u&&u.data.length&&(y=u.data.map(s=>xe(s)));let d=[];for(let s of y){let h=s?.dataSource,g=s?.rootSource;if(!h||!g)throw new Error("dataSource and rootSource must be present on a comment");d.push({id:s.id,content:await Pt(s.id),parentId:h,rootId:g})}return d}}async function Pt(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i.message??"Error getting comment data")}}var Oi=A(T(),1);var bi=A(T(),1);function Ce(n){return async(i,a)=>{try{let u=[{name:E.keys.bootloaderInit,value:k.src.zone}];return i.tags&&i.tags.length&&i.tags.forEach(d=>u.push(d)),await re(n,{data:i.data,tags:u},a?d=>a(d):void 0)}catch(u){throw new Error(u.message??"Error creating zone")}}}function Se(n){return async(i,a)=>{try{let u=Object.entries(i).map(([d,s])=>({key:d,value:s}));return await te(n,{processId:a,action:"Zone-Update",data:u})}catch(u){throw new Error(u)}}}function bt(n){return async(i,a)=>{try{return await te(n,{processId:a,action:"Zone-Append",tags:[{name:"Path",value:i.path}],data:i.data})}catch(u){throw new Error(u)}}}function De(n){return async i=>{try{let a=await Ie(n,{processId:i,path:"zone",fallbackAction:"Info"});return X(a)}catch(a){throw new Error(a.message??"Error getting zone")}}}function vt(n){let i=Ce(n);return async(a,u)=>{let y=null,d=[{name:E.keys.dataProtocol,value:E.values.zone},{name:E.keys.zoneType,value:E.values.user}],s=async h=>{let g=h.toLowerCase();if(a[g])try{let B=await ae(n,a[g]);d.push(O(h,B))}catch(B){u?u(`Failed to resolve ${h}: ${B.message}`):console.error(B)}};a.username&&d.push(O("Username",a.username)),a.displayName&&d.push(O("DisplayName",a.displayName)),a.description&&d.push(O("Description",a.description)),await Promise.all([s("Thumbnail"),s("Banner")]);try{y=await i({tags:d},u)}catch(h){throw new Error(h.message??"Error creating profile")}return y}}function Ut(n){let i=Se(n);return async(a,u,y)=>{if(u){let d={Username:a.username,DisplayName:a.displayName,Description:a.description};if(a.thumbnail)try{d.Thumbnail=await ae(n,a.thumbnail)}catch(s){y&&y(`Failed to resolve thumbnail: ${s.message}`)}if(a.banner)try{d.Banner=await ae(n,a.banner)}catch(s){y&&y(`Failed to resolve banner: ${s.message}`)}try{return await i(d,u)}catch(s){throw new Error(s.message??"Error creating profile")}}else throw new Error("No profile provided")}}function Ge(n){let i=De(n);return async a=>{try{let u=await i(a);return{id:a,...u.store,assets:u.assets}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function Rt(n){let i=Ge(n);return async a=>{try{let u=await q({gateway:z.goldsky,tags:[{name:E.keys.dataProtocol,values:[E.values.zone]},{name:E.keys.zoneType,values:[E.values.user]}],owners:[a]});return u?.data?.length>0?(u.data.sort((y,d)=>{let s=y.node.block?.timestamp??0;return(d.node.block?.timestamp??0)-s}),await i(u.data[0].node.id)):{id:null}}catch(u){throw new Error(u.message??"Error fetching profile")}}}globalThis.Buffer||(globalThis.Buffer=v);function xr(n){return{createZone:Ce(n),updateZone:Se(n),addToZone:bt(n),getZone:De(n),createProfile:vt(n),updateProfile:Ut(n),getProfileById:Ge(n),getProfileByWalletAddress:Rt(n),createAtomicAsset:Be(n),getAtomicAsset:Tt(n),getAtomicAssets:At,createComment:Ct(n),getComment:St(n),getComments:Dt(n),createCollection:Et(n),updateCollectionAssets:It(n),getCollection:Bt(n),getCollections:xt(n),resolveTransaction:mt(n),getGQLData:q,getAggregatedGQLData:lt,createProcess:ht(n),readProcess:dt(n),sendMessage:yt(n),waitForProcess:gt,mapFromProcessCase:X,mapToProcessCase:le}}var eo={init:xr};export{eo as default};
27
+ }`;return n.queryKey&&(x=`${n.queryKey}: ${x}`),x}async function hr(n){try{return await(await fetch(`https://${n.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:n.query})).json()}catch(i){throw i}}var fr=z.goldsky,gr=100;async function lt(n,i){let a=[{name:"Authority",value:W.mu}];i.tags&&i.tags.length>0&&i.tags.forEach(u=>a.push(u));try{let u=await n.ao.spawn({module:i.module,scheduler:i.scheduler,signer:n.signer,tags:a,data:i.data});return j(`Process ID: ${u}`),u}catch(u){throw console.log(u),new Error(u.message??"Error spawning process")}}function pt(n){return async i=>await ee(n,i)}async function ee(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u=i.useRawData?i.data:JSON.stringify(i.data);return await n.ao.message({process:i.processId,signer:n.signer,tags:a,data:u})}catch(a){throw new Error(a)}}async function Ie(n,i){try{return console.log("State not found, dryrunning..."),await ge(n,{processId:i.processId,action:i.fallbackAction})}catch(a){throw new Error(a.message??"Error reading process from HyperBEAM")}}function yt(n){return async i=>await ge(n,i)}async function ge(n,i){try{let a=[{name:"Action",value:i.action}];i.tags&&a.push(...i.tags);let u;if(typeof i.data=="object")u=JSON.stringify(i.data||{});else if(typeof i.data=="string"){try{JSON.parse(i.data)}catch(d){throw console.error(d),new Error("Invalid JSON data")}u=i.data}let y=await n.ao.dryrun({process:i.processId,tags:a,data:u});if(y.Messages&&y.Messages.length){if(y.Messages[0].Data)return JSON.parse(y.Messages[0].Data);if(y.Messages[0].Tags)return y.Messages[0].Tags.reduce((d,s)=>(d[s.name]=s.value,d),{})}}catch(a){throw new Error(a.message??"Error dryrunning process")}}async function mr(n,i){try{let{Messages:a}=await n.ao.result({message:i.messageId,process:i.processId});if(a&&a.length){let u={};return a.forEach(y=>{let d=Ee(y.Tags,"Action")||i.action,s=null,f=y.Data;if(f)try{s=JSON.parse(f)}catch{s=f}let g=Ee(y.Tags,"Status"),E=Ee(y.Tags,"Message");u[d]={id:i.messageId,status:g,message:E,data:s}}),u}else return null}catch(a){console.error(a)}}async function dt(n,i){let a=null;if(i.evalSrc?a=i.evalSrc:i.evalTxId&&(a=await wr(i.evalTxId)),a)try{let u=await ee(n,{processId:i.processId,action:"Eval",data:a,tags:i.evalTags||null,useRawData:!0});return j(`Eval: ${u}`),await mr(n,{processId:i.processId,messageId:u,action:"Eval"})}catch(u){throw new Error(u.message??"Error sending process eval")}return null}function ht(n){return async(i,a)=>{try{let u={module:i.module||W.module,scheduler:i.scheduler||W.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await lt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await dt(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}}async function ae(n,i,a){try{let u={module:i.module||W.module,scheduler:i.scheduler||W.scheduler};i.data&&(u.data=i.data),i.tags&&(u.tags=i.tags),a&&a("Spawning process...");let y=await lt(n,u);if(i.evalTxId||i.evalSrc){a&&a("Process retrieved!"),a&&a("Sending eval...");try{await dt(n,{processId:y,evalTxId:i.evalTxId||null,evalSrc:i.evalSrc||null,evalTags:i.evalTags})&&a&&a("Eval complete")}catch(d){throw new Error(d.message??"Error creating process")}}return y}catch(u){throw new Error(u.message??"Error creating process")}}async function wr(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i)}}async function ft(n){let i=0,a=n.noRetryLimit?1/0:gr;for(;i<a;){await new Promise(y=>setTimeout(y,2e3));let u=await q({gateway:fr,ids:[n.processId]});if(u?.data?.length){let y=u.data[0].node.id;return j(`Process found: ${y} (Try ${i+1})`),y}else j(`Process not found: ${n.processId} (Try ${i+1})`),i++}if(a!==1/0)throw new Error("Process not found, please try again")}var bn=A(T(),1);function gt(n){return async i=>{if(J(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await mt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}}async function se(n,i){if(J(i))return i;if(!n.arweave)throw new Error("Must initialize with Arweave in order to create transactions");try{return await mt(n,{data:i})}catch(a){throw new Error(a.message??"Error resolving transaction")}}async function mt(n,i){let a=null,u=null,y=null;if(typeof i.data=="string"&&(a=R.from(st(i.data),"base64"),u=at(i.data),y=ct(a)),i.data instanceof File&&(a=new Uint8Array(await i.data.arrayBuffer()),u=i.data.type,y=i.data.size),a&&u&&y)if(y<Number(ot.dispatchUploadSize))try{let d=await n.arweave.createTransaction({data:a},"use_wallet");return d.addTag(I.keys.contentType,u),i.tags&&i.tags.length>0&&i.tags.forEach(f=>d.addTag(f.name,f.value)),(await global.window.arweaveWallet.dispatch(d)).id}catch(d){throw new Error(d.message??"Error dispatching transaction")}else throw new Error("Paid uploads are not yet supported");else throw new Error("Error preparing transaction data")}var zn=A(T(),1);var Ar={},On=A(T(),1);var qi=A(T(),1);var ii=A(T(),1);function Be(n){return async(i,a)=>{let u=Br(i);if(u)throw new Error(u);let y=it[i.contentType]?.serialize(i.data)??i.data,d=Ir(i);try{return await ae(n,{tags:d,data:y},a?f=>a(f):void 0)}catch(s){throw new Error(s.message??"Error creating asset")}}}async function Me(n,i,a){try{let u=re(await Ie(n,{processId:i,path:"asset",fallbackAction:"Info"}));if(a?.useGateway){let y=await q({gateway:z.goldsky,ids:[i],tags:null,owners:null,cursor:null});return{...y?.data?.[0]?xe(y.data[0]):{},...u}}return{id:i,...u}}catch(u){throw new Error(u.message||"Error fetching atomic asset")}}function wt(n){return async(i,a)=>await Me(n,i,a)}async function Tt(n){try{let i=await q({gateway:z.arweave,ids:n??null,tags:null,owners:null,cursor:null});return i&&i.data.length?i.data.map(a=>xe(a)):null}catch(i){throw new Error(i)}}function xe(n){let i={id:n.node.id,owner:n.node.owner.address};for(let a of n.node.tags){let u=a.name,d=(u.startsWith(`${I.keys.bootloader}-`)?u.slice(`${I.keys.bootloader}-`.length):u).split("-").map((f,g)=>g===0?f.toLowerCase():f.charAt(0).toUpperCase()+f.slice(1).toLowerCase()).join(""),s;try{s=JSON.parse(a.value)}catch{s=a.value.toString()}i[d]=s}return i}function Ir(n){let i=[{name:I.keys.onBoot,value:n.src??W.src.asset},{name:I.keys.creator,value:n.creator},{name:I.keys.assetType,value:n.assetType},{name:I.keys.contentType,value:n.contentType},{name:I.keys.implements,value:"ANS-110"},{name:I.keys.dateCreated,value:new Date().getTime().toString()},O("Name",n.name),O("Description",n.description),O("Topics",JSON.stringify(n.topics)),O("Ticker","ATOMIC"),O("Denomination",n.denomination?.toString()??"1"),O("TotalSupply",n.supply?.toString()??"1"),O("Transferable",n.transferable?.toString()??"true"),O("Creator",n.creator)];if(n.metadata)for(let a in n.metadata)i.push(O(pe(a),n.metadata[a].toString()));if(n.users)for(let a of n.users)i.push({name:"Auth-User",value:a});return n.tags&&n.tags.forEach(a=>i.push(a)),i}function Br(n){if(typeof n!="object"||n===null)return"The provided arguments are invalid or empty.";let i=["name","description","topics","creator","data","contentType","assetType"];for(let a of i)if(!(a in n))return`Missing field '${a}'`;return typeof n.name!="string"||n.name.trim()===""?"Name is required":typeof n.description!="string"?"The description must be a valid string":!Array.isArray(n.topics)||n.topics.length===0?"Topics are required":typeof n.creator!="string"||n.creator.trim()===""?"Creator is required":n.data===void 0||n.data===null?"Data field is required":typeof n.contentType!="string"||n.contentType.trim()===""?"Content type must be a non-empty string":typeof n.assetType!="string"||n.assetType.trim()===""?"Type must be a non-empty string":"supply"in n&&(typeof n.supply!="number"||n.supply<=0)?"Supply must be a positive number":"denomination"in n&&(typeof n.denomination!="number"||n.denomination<=0)?"Denomination must be a positive number":"transferable"in n&&typeof n.transferable!="boolean"?"Transferable must be a boolean value":"metadata"in n&&typeof n.metadata!="object"?"Metadata must be an object":"tags"in n&&(!Array.isArray(n.tags)||n.tags.some(a=>typeof a!="object"))?"Tags must be an array of objects":"src"in n&&typeof n.src!="string"?"Source must be a valid string":null}var hi=A(T(),1);var xr="eXCtpVbcd_jZ0dmU2PZ8focaKxBGECBQ8wMib7sIVPo",me="lJovHqM9hwNjHV5JoY9NGWtt0WD-5D4gOqNL2VWW5jk";function At(n){return async(i,a)=>{if(!n.signer)throw new Error("No signer provided");let u=new Date().getTime().toString(),y=[{name:I.keys.contentType,value:"application/json"},{name:I.keys.creator,value:i.creator},{name:I.keys.ans110.title,value:fe(i.title)},{name:I.keys.ans110.description,value:fe(i.description)},{name:I.keys.dateCreated,value:u},{name:I.keys.name,value:fe(i.title)},{name:"Action",value:"Add-Collection"}],d=null,s=null;try{d=i.banner?await se(n,i.thumbnail):me,s=i.banner?await se(n,i.banner):xr,i.thumbnail&&y.push({name:I.keys.thumbnail,value:d}),i.banner&&y.push({name:I.keys.banner,value:s})}catch(E){console.error(E)}let f=await fetch(ye(W.src.collection));if(!f.ok)throw new Error("Unable to fetch process src");let g=await f.text();g=g.replace(/'<NAME>'/g,Le(i.title)),g=g.replace(/'<DESCRIPTION>'/g,Le(i.description)),g=g.replace(/<CREATOR>/g,i.creator),g=g.replace(/<THUMBNAIL>/g,d||me),g=g.replace(/<BANNER>/g,s||me),g=g.replace(/<DATECREATED>/g,u),g=g.replace(/<LASTUPDATE>/g,u);try{let E=await ae(n,{tags:y},a?B=>a(B):void 0);if(j("Sending eval message to collection..."),a&&a("Sending eval message to collection..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:g}),!i.skipRegistry){j("Sending collection to registry..."),a&&a("Sending collection to registry...");let B=[{name:"Action",value:"Add-Collection"},{name:"CollectionId",value:E},{name:"Name",value:fe(i.title)},{name:"Creator",value:i.creator},{name:"DateCreated",value:u}];s&&B.push({name:"Banner",value:s}),d&&B.push({name:"Thumbnail",value:d}),await n.ao.message({process:W.collectionRegistry,signer:n.signer,tags:B})}if(!i.skipActivity){j("Creating collection activity process..."),a&&a("Creating collection activity process...");let B=[{name:"CollectionId",value:E},{name:"DateCreated",value:u},{name:"UCM-Process",value:"Collection-Activity"},{name:"On-Boot",value:W.src.collectionActivity}],D=await ae(n,{tags:B},a?$=>a($):void 0);j("Adding activity to collection process..."),a&&a("Adding activity to collection process..."),await n.ao.message({process:E,signer:n.signer,tags:[{name:"Action",value:"Eval"}],data:`ActivityProcess = '${D}'`})}return E}catch(E){throw new Error(E.message??"Error creating collection")}}}function Et(n){return async i=>await ee(n,{processId:i.creator,action:"Run-Action",tags:[{name:"ForwardTo",value:i.collectionId},{name:"ForwardAction",value:"Update-Assets"}],data:{Target:i.collectionId,Action:"Update-Assets",Input:JSON.stringify({AssetIds:i.assetIds,UpdateType:i.updateType})}})}function It(n){return async i=>{let a=await ge(n,{processId:i,action:"Info"});return{...{id:i,title:a.Name,description:a.Description,creator:a.Creator,dateCreated:a.DateCreated,thumbnail:a.Thumbnail??me,banner:a.Banner??me},assetIds:a.Assets}}}function Bt(n){return async i=>{let a=i.creator?"Get-Collections-By-User":"Get-Collections",u=await ge(n,{processId:W.collectionRegistry,action:a,tags:i.creator?[{name:"Creator",value:i.creator}]:null});return u&&u.Collections&&u.Collections.length?u.Collections.map(d=>({id:d.Id,title:d.Name.replace(/\[|\]/g,""),description:d.Description,creator:d.Creator,dateCreated:d.DateCreated,banner:d.Banner,thumbnail:d.Thumbnail})):null}}var Bi=A(T(),1);function xt(n){let i=Be(n);return async(a,u)=>{let y=a.tags?a.tags:[];y.push({name:"Data-Source",value:a.parentId}),y.push({name:"Root-Source",value:a.rootId??a.parentId});let d={name:`Comment on ${a.parentId}`,description:`Comment on ${a.parentId}`,topics:["comment"],creator:a.creator,data:a.content,contentType:"text/plain",assetType:"comment",tags:y};return i(d,u)}}function Ct(n){return async i=>{try{let a=await Me(n,i,{useGateway:!0}),u=a?.dataSource,y=a?.rootSource;if(!u||!y)throw new Error("dataSource and rootSource must be present on a comment");return{content:await Dt(i),parentId:u,rootId:y}}catch(a){throw new Error(a.message??"Error getting comment")}}}function St(n){return async i=>{if(!i.parentId&&!i.rootId)throw new Error("Must provide either parentId or rootId");let a=[];i.parentId&&a.push({name:"Data-Source",values:[i.parentId??""]}),i.rootId&&a.push({name:"Root-Source",values:[i.rootId??""]});let u=await q({gateway:z.goldsky,ids:null,tags:a,owners:null,cursor:null}),y=[];u&&u.data.length&&(y=u.data.map(s=>xe(s)));let d=[];for(let s of y){let f=s?.dataSource,g=s?.rootSource;if(!f||!g)throw new Error("dataSource and rootSource must be present on a comment");d.push({id:s.id,content:await Dt(s.id),parentId:f,rootId:g})}return d}}async function Dt(n){try{return await(await fetch(ye(n))).text()}catch(i){throw new Error(i.message??"Error getting comment data")}}var Qi=A(T(),1);var Ui=A(T(),1);function Ce(n){return async(i,a)=>{try{let u=[{name:I.keys.onBoot,value:W.src.zone}];return i.tags&&i.tags.length&&i.tags.forEach(d=>u.push(d)),await ae(n,{data:i.data,tags:u},a?d=>a(d):void 0)}catch(u){throw new Error(u.message??"Error creating zone")}}}function Se(n){return async(i,a)=>{try{let u=Object.entries(i).map(([d,s])=>({key:d,value:s}));return await ee(n,{processId:a,action:"Zone-Update",data:u})}catch(u){throw new Error(u)}}}function vt(n){return async(i,a)=>{try{return await ee(n,{processId:a,action:"Zone-Append",tags:[{name:"Path",value:i.path}],data:i.data})}catch(u){throw new Error(u)}}}function De(n){return async i=>{try{let a=await Ie(n,{processId:i,path:"zone",fallbackAction:"Info"});return re(a)}catch(a){throw new Error(a.message??"Error getting zone")}}}function bt(n){return async(i,a)=>{if(!J(a))throw new Error("Invalid zone address");let y=[];for(let d of i){if(!J(d.granteeId))throw new Error("Invalid granteeId address");if(d.type!=="wallet"&&d.type!=="process")throw new Error("Invalid role type");y.push({Id:d.granteeId,Roles:d.roles,Type:d.type,SendInvite:d.sendInvite})}try{return await ee(n,{processId:a,action:"Role-Set",tags:[],data:y})}catch(d){throw new Error(d)}}}function Pt(n){return async(i,a)=>{if(!(J(a)&&J(i.zoneToJoinId)))throw new Error("Invalid zone address");let y=[{name:"ZoneId",value:i.zoneToJoinId}];i.path&&y.push({name:"Path",value:i.path});try{return await ee(n,{processId:a,action:"Zone-Join",tags:y})}catch(d){throw new Error(d)}}}function Rt(n){let i=Ce(n);return async(a,u)=>{let y=null,d=[{name:I.keys.dataProtocol,value:I.values.zone},{name:I.keys.zoneType,value:I.values.user}],s=async f=>{let g=f.toLowerCase();if(a[g])try{let E=await se(n,a[g]);d.push(O(f,E))}catch(E){u?u(`Failed to resolve ${f}: ${E.message}`):console.error(E)}};a.username&&d.push(O("Username",a.username)),a.displayName&&d.push(O("DisplayName",a.displayName)),a.description&&d.push(O("Description",a.description)),await Promise.all([s("Thumbnail"),s("Banner")]);try{y=await i({tags:d},u)}catch(f){throw new Error(f.message??"Error creating profile")}return y}}function Ut(n){let i=Se(n);return async(a,u,y)=>{if(u){let d={Username:a.username,DisplayName:a.displayName,Description:a.description};if(a.thumbnail)try{d.Thumbnail=await se(n,a.thumbnail)}catch(s){y&&y(`Failed to resolve thumbnail: ${s.message}`)}if(a.banner)try{d.Banner=await se(n,a.banner)}catch(s){y&&y(`Failed to resolve banner: ${s.message}`)}try{return await i(d,u)}catch(s){throw new Error(s.message??"Error creating profile")}}else throw new Error("No profile provided")}}function ke(n){let i=De(n);return async a=>{try{let u=await i(a);if(!u)throw new Error("Error fetching profile - Not found");return{id:a,owner:u.owner,assets:u.assets,roles:u.roles,invites:u.invites,version:u.version,...u.store}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function Lt(n){let i=ke(n);return async a=>{try{let u=await q({gateway:z.goldsky,tags:[{name:I.keys.dataProtocol,values:[I.values.zone]},{name:I.keys.zoneType,values:[I.values.user]}],owners:[a]});return u?.data?.length>0?(u.data.sort((y,d)=>{let s=y.node.block?.timestamp??0;return(d.node.block?.timestamp??0)-s}),await i(u.data[0].node.id)):{id:null}}catch(u){throw new Error(u.message??"Error fetching profile")}}}function Sr(n){return{createZone:Ce(n),updateZone:Se(n),addToZone:vt(n),getZone:De(n),setZoneRoles:bt(n),joinZone:Pt(n),createProfile:Rt(n),updateProfile:Ut(n),getProfileById:ke(n),getProfileByWalletAddress:Lt(n),createAtomicAsset:Be(n),getAtomicAsset:wt(n),getAtomicAssets:Tt,createComment:xt(n),getComment:Ct(n),getComments:St(n),createCollection:At(n),updateCollectionAssets:Et(n),getCollection:It(n),getCollections:Bt(n),resolveTransaction:gt(n),getGQLData:q,getAggregatedGQLData:ut,createProcess:ht(n),readProcess:yt(n),sendMessage:pt(n),waitForProcess:ft,mapFromProcessCase:re,mapToProcessCase:pe}}var to={init:Sr};export{Ar as Types,to as default};
28
28
  /*! Bundled license information:
29
29
 
30
30
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: