@magic-ext/flow 26.3.0-canary.970.20051874417.0 → 27.0.0-canary.979.20831511014.0
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/extension.js +1 -284
- package/package.json +3 -3
package/dist/extension.js
CHANGED
|
@@ -1,285 +1,2 @@
|
|
|
1
|
-
"use strict";var MagicFlowExtension=(()=>{var dc=Object.create;var Qt=Object.defineProperty;var fc=Object.getOwnPropertyDescriptor;var pc=Object.getOwnPropertyNames;var gc=Object.getPrototypeOf,mc=Object.prototype.hasOwnProperty;var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),No=(e,t)=>{for(var n in t)Qt(e,n,{get:t[n],enumerable:!0})},Fo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pc(t))!mc.call(e,o)&&o!==n&&Qt(e,o,{get:()=>t[o],enumerable:!(r=fc(t,o))||r.enumerable});return e};var _e=(e,t,n)=>(n=e!=null?dc(gc(e)):{},Fo(t||!e||!e.__esModule?Qt(n,"default",{value:e,enumerable:!0}):n,e)),hc=e=>Fo(Qt({},"__esModule",{value:!0}),e);var Bo=K((Bh,_o)=>{"use strict";_o.exports=Magic});var Uo=K((Oh,Do)=>{"use strict";var Oo;Do.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:global):e=>(Oo||(Oo=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0))});var Ta=K(an=>{"use strict";an.byteLength=Wc;an.toByteArray=Jc;an.fromByteArray=Qc;var Re=[],ce=[],Yc=typeof Uint8Array<"u"?Uint8Array:Array,rr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ze=0,Ra=rr.length;ze<Ra;++ze)Re[ze]=rr[ze],ce[rr.charCodeAt(ze)]=ze;var ze,Ra;ce[45]=62;ce[95]=63;function ka(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Wc(e){var t=ka(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Vc(e,t,n){return(t+n)*3/4-n}function Jc(e){var t,n=ka(e),r=n[0],o=n[1],a=new Yc(Vc(e,r,o)),s=0,i=o>0?r-4:r,c;for(c=0;c<i;c+=4)t=ce[e.charCodeAt(c)]<<18|ce[e.charCodeAt(c+1)]<<12|ce[e.charCodeAt(c+2)]<<6|ce[e.charCodeAt(c+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=t&255;return o===2&&(t=ce[e.charCodeAt(c)]<<2|ce[e.charCodeAt(c+1)]>>4,a[s++]=t&255),o===1&&(t=ce[e.charCodeAt(c)]<<10|ce[e.charCodeAt(c+1)]<<4|ce[e.charCodeAt(c+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function Xc(e){return Re[e>>18&63]+Re[e>>12&63]+Re[e>>6&63]+Re[e&63]}function Zc(e,t,n){for(var r,o=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),o.push(Xc(r));return o.join("")}function Qc(e){for(var t,n=e.length,r=n%3,o=[],a=16383,s=0,i=n-r;s<i;s+=a)o.push(Zc(e,s,s+a>i?i:s+a));return r===1?(t=e[n-1],o.push(Re[t>>2]+Re[t<<4&63]+"==")):r===2&&(t=(e[n-2]<<8)+e[n-1],o.push(Re[t>>10]+Re[t>>4&63]+Re[t<<2&63]+"=")),o.join("")}});var Ca=K(or=>{"use strict";or.read=function(e,t,n,r,o){var a,s,i=o*8-r-1,c=(1<<i)-1,u=c>>1,l=-7,d=n?o-1:0,p=n?-1:1,m=e[t+d];for(d+=p,a=m&(1<<-l)-1,m>>=-l,l+=i;l>0;a=a*256+e[t+d],d+=p,l-=8);for(s=a&(1<<-l)-1,a>>=-l,l+=r;l>0;s=s*256+e[t+d],d+=p,l-=8);if(a===0)a=1-u;else{if(a===c)return s?NaN:(m?-1:1)*(1/0);s=s+Math.pow(2,r),a=a-u}return(m?-1:1)*s*Math.pow(2,a-r)};or.write=function(e,t,n,r,o,a){var s,i,c,u=a*8-o-1,l=(1<<u)-1,d=l>>1,p=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=r?0:a-1,E=r?1:-1,I=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?t+=p/c:t+=p*Math.pow(2,1-d),t*c>=2&&(s++,c/=2),s+d>=l?(i=0,s=l):s+d>=1?(i=(t*c-1)*Math.pow(2,o),s=s+d):(i=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+m]=i&255,m+=E,i/=256,o-=8);for(s=s<<o|i,u+=o;u>0;e[n+m]=s&255,m+=E,s/=256,u-=8);e[n+m-E]|=I*128}});var Ke=K(ct=>{"use strict";var ar=Ta(),it=Ca(),Pa=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ct.Buffer=g;ct.SlowBuffer=al;ct.INSPECT_MAX_BYTES=50;var sn=2147483647;ct.kMaxLength=sn;g.TYPED_ARRAY_SUPPORT=el();!g.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 el(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Be(e){if(e>sn)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,g.prototype),t}function g(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return cr(e)}return Ba(e,t,n)}g.poolSize=8192;function Ba(e,t,n){if(typeof e=="string")return nl(e,t);if(ArrayBuffer.isView(e))return rl(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(ke(e,ArrayBuffer)||e&&ke(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ke(e,SharedArrayBuffer)||e&&ke(e.buffer,SharedArrayBuffer)))return ir(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return g.from(r,t,n);let o=ol(e);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return g.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}g.from=function(e,t,n){return Ba(e,t,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function Oa(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function tl(e,t,n){return Oa(e),e<=0?Be(e):t!==void 0?typeof n=="string"?Be(e).fill(t,n):Be(e).fill(t):Be(e)}g.alloc=function(e,t,n){return tl(e,t,n)};function cr(e){return Oa(e),Be(e<0?0:lr(e)|0)}g.allocUnsafe=function(e){return cr(e)};g.allocUnsafeSlow=function(e){return cr(e)};function nl(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!g.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=Da(e,t)|0,r=Be(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function sr(e){let t=e.length<0?0:lr(e.length)|0,n=Be(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function rl(e){if(ke(e,Uint8Array)){let t=new Uint8Array(e);return ir(t.buffer,t.byteOffset,t.byteLength)}return sr(e)}function ir(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return t===void 0&&n===void 0?r=new Uint8Array(e):n===void 0?r=new Uint8Array(e,t):r=new Uint8Array(e,t,n),Object.setPrototypeOf(r,g.prototype),r}function ol(e){if(g.isBuffer(e)){let t=lr(e.length)|0,n=Be(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||fr(e.length)?Be(0):sr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return sr(e.data)}function lr(e){if(e>=sn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+sn.toString(16)+" bytes");return e|0}function al(e){return+e!=e&&(e=0),g.alloc(+e)}g.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==g.prototype};g.compare=function(t,n){if(ke(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),ke(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(t)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;let r=t.length,o=n.length;for(let a=0,s=Math.min(r,o);a<s;++a)if(t[a]!==n[a]){r=t[a],o=n[a];break}return r<o?-1:o<r?1:0};g.isEncoding=function(t){switch(String(t).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}};g.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return g.alloc(0);let r;if(n===void 0)for(n=0,r=0;r<t.length;++r)n+=t[r].length;let o=g.allocUnsafe(n),a=0;for(r=0;r<t.length;++r){let s=t[r];if(ke(s,Uint8Array))a+s.length>o.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(o,a)):Uint8Array.prototype.set.call(o,s,a);else if(g.isBuffer(s))s.copy(o,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return o};function Da(e,t){if(g.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||ke(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ur(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return za(e).length;default:if(o)return r?-1:ur(e).length;t=(""+t).toLowerCase(),o=!0}}g.byteLength=Da;function sl(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return hl(this,t,n);case"utf8":case"utf-8":return La(this,t,n);case"ascii":return gl(this,t,n);case"latin1":case"binary":return ml(this,t,n);case"base64":return fl(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yl(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}g.prototype._isBuffer=!0;function xe(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}g.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<t;n+=2)xe(this,n,n+1);return this};g.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<t;n+=4)xe(this,n,n+3),xe(this,n+1,n+2);return this};g.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<t;n+=8)xe(this,n,n+7),xe(this,n+1,n+6),xe(this,n+2,n+5),xe(this,n+3,n+4);return this};g.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?La(this,0,t):sl.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(t){if(!g.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:g.compare(this,t)===0};g.prototype.inspect=function(){let t="",n=ct.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"};Pa&&(g.prototype[Pa]=g.prototype.inspect);g.prototype.compare=function(t,n,r,o,a){if(ke(t,Uint8Array)&&(t=g.from(t,t.offset,t.byteLength)),!g.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),r===void 0&&(r=t?t.length:0),o===void 0&&(o=0),a===void 0&&(a=this.length),n<0||r>t.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&n>=r)return 0;if(o>=a)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,a>>>=0,this===t)return 0;let s=a-o,i=r-n,c=Math.min(s,i),u=this.slice(o,a),l=t.slice(n,r);for(let d=0;d<c;++d)if(u[d]!==l[d]){s=u[d],i=l[d];break}return s<i?-1:i<s?1:0};function Ua(e,t,n,r,o){if(e.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,fr(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof t=="string"&&(t=g.from(t,r)),g.isBuffer(t))return t.length===0?-1:Na(e,t,n,r,o);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Na(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Na(e,t,n,r,o){let a=1,s=e.length,i=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,s/=2,i/=2,n/=2}function c(l,d){return a===1?l[d]:l.readUInt16BE(d*a)}let u;if(o){let l=-1;for(u=n;u<s;u++)if(c(e,u)===c(t,l===-1?0:u-l)){if(l===-1&&(l=u),u-l+1===i)return l*a}else l!==-1&&(u-=u-l),l=-1}else for(n+i>s&&(n=s-i),u=n;u>=0;u--){let l=!0;for(let d=0;d<i;d++)if(c(e,u+d)!==c(t,d)){l=!1;break}if(l)return u}return-1}g.prototype.includes=function(t,n,r){return this.indexOf(t,n,r)!==-1};g.prototype.indexOf=function(t,n,r){return Ua(this,t,n,r,!0)};g.prototype.lastIndexOf=function(t,n,r){return Ua(this,t,n,r,!1)};function il(e,t,n,r){n=Number(n)||0;let o=e.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;let a=t.length;r>a/2&&(r=a/2);let s;for(s=0;s<r;++s){let i=parseInt(t.substr(s*2,2),16);if(fr(i))return s;e[n+s]=i}return s}function ul(e,t,n,r){return un(ur(t,e.length-n),e,n,r)}function cl(e,t,n,r){return un(Sl(t),e,n,r)}function ll(e,t,n,r){return un(za(t),e,n,r)}function dl(e,t,n,r){return un(vl(t,e.length-n),e,n,r)}g.prototype.write=function(t,n,r,o){if(n===void 0)o="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")o=n,r=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(r)?(r=r>>>0,o===void 0&&(o="utf8")):(o=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-n;if((r===void 0||r>a)&&(r=a),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return il(this,t,n,r);case"utf8":case"utf-8":return ul(this,t,n,r);case"ascii":case"latin1":case"binary":return cl(this,t,n,r);case"base64":return ll(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dl(this,t,n,r);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fl(e,t,n){return t===0&&n===e.length?ar.fromByteArray(e):ar.fromByteArray(e.slice(t,n))}function La(e,t,n){n=Math.min(e.length,n);let r=[],o=t;for(;o<n;){let a=e[o],s=null,i=a>239?4:a>223?3:a>191?2:1;if(o+i<=n){let c,u,l,d;switch(i){case 1:a<128&&(s=a);break;case 2:c=e[o+1],(c&192)===128&&(d=(a&31)<<6|c&63,d>127&&(s=d));break;case 3:c=e[o+1],u=e[o+2],(c&192)===128&&(u&192)===128&&(d=(a&15)<<12|(c&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=e[o+1],u=e[o+2],l=e[o+3],(c&192)===128&&(u&192)===128&&(l&192)===128&&(d=(a&15)<<18|(c&63)<<12|(u&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),o+=i}return pl(r)}var Fa=4096;function pl(e){let t=e.length;if(t<=Fa)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Fa));return n}function gl(e,t,n){let r="";n=Math.min(e.length,n);for(let o=t;o<n;++o)r+=String.fromCharCode(e[o]&127);return r}function ml(e,t,n){let r="";n=Math.min(e.length,n);for(let o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function hl(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let o="";for(let a=t;a<n;++a)o+=Al[e[a]];return o}function yl(e,t,n){let r=e.slice(t,n),o="";for(let a=0;a<r.length-1;a+=2)o+=String.fromCharCode(r[a]+r[a+1]*256);return o}g.prototype.slice=function(t,n){let r=this.length;t=~~t,n=n===void 0?r:~~n,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<t&&(n=t);let o=this.subarray(t,n);return Object.setPrototypeOf(o,g.prototype),o};function W(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(t,n,r){t=t>>>0,n=n>>>0,r||W(t,n,this.length);let o=this[t],a=1,s=0;for(;++s<n&&(a*=256);)o+=this[t+s]*a;return o};g.prototype.readUintBE=g.prototype.readUIntBE=function(t,n,r){t=t>>>0,n=n>>>0,r||W(t,n,this.length);let o=this[t+--n],a=1;for(;n>0&&(a*=256);)o+=this[t+--n]*a;return o};g.prototype.readUint8=g.prototype.readUInt8=function(t,n){return t=t>>>0,n||W(t,1,this.length),this[t]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||W(t,2,this.length),this[t]|this[t+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||W(t,2,this.length),this[t]<<8|this[t+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||W(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||W(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};g.prototype.readBigUInt64LE=$e(function(t){t=t>>>0,ut(t,"offset");let n=this[t],r=this[t+7];(n===void 0||r===void 0)&&Dt(t,this.length-8);let o=n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,a=this[++t]+this[++t]*2**8+this[++t]*2**16+r*2**24;return BigInt(o)+(BigInt(a)<<BigInt(32))});g.prototype.readBigUInt64BE=$e(function(t){t=t>>>0,ut(t,"offset");let n=this[t],r=this[t+7];(n===void 0||r===void 0)&&Dt(t,this.length-8);let o=n*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],a=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r;return(BigInt(o)<<BigInt(32))+BigInt(a)});g.prototype.readIntLE=function(t,n,r){t=t>>>0,n=n>>>0,r||W(t,n,this.length);let o=this[t],a=1,s=0;for(;++s<n&&(a*=256);)o+=this[t+s]*a;return a*=128,o>=a&&(o-=Math.pow(2,8*n)),o};g.prototype.readIntBE=function(t,n,r){t=t>>>0,n=n>>>0,r||W(t,n,this.length);let o=n,a=1,s=this[t+--o];for(;o>0&&(a*=256);)s+=this[t+--o]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(t,n){return t=t>>>0,n||W(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};g.prototype.readInt16LE=function(t,n){t=t>>>0,n||W(t,2,this.length);let r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};g.prototype.readInt16BE=function(t,n){t=t>>>0,n||W(t,2,this.length);let r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};g.prototype.readInt32LE=function(t,n){return t=t>>>0,n||W(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};g.prototype.readInt32BE=function(t,n){return t=t>>>0,n||W(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};g.prototype.readBigInt64LE=$e(function(t){t=t>>>0,ut(t,"offset");let n=this[t],r=this[t+7];(n===void 0||r===void 0)&&Dt(t,this.length-8);let o=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});g.prototype.readBigInt64BE=$e(function(t){t=t>>>0,ut(t,"offset");let n=this[t],r=this[t+7];(n===void 0||r===void 0)&&Dt(t,this.length-8);let o=(n<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(o)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r)});g.prototype.readFloatLE=function(t,n){return t=t>>>0,n||W(t,4,this.length),it.read(this,t,!0,23,4)};g.prototype.readFloatBE=function(t,n){return t=t>>>0,n||W(t,4,this.length),it.read(this,t,!1,23,4)};g.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||W(t,8,this.length),it.read(this,t,!0,52,8)};g.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||W(t,8,this.length),it.read(this,t,!1,52,8)};function oe(e,t,n,r,o,a){if(!g.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<a)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(t,n,r,o){if(t=+t,n=n>>>0,r=r>>>0,!o){let i=Math.pow(2,8*r)-1;oe(this,t,n,r,i,0)}let a=1,s=0;for(this[n]=t&255;++s<r&&(a*=256);)this[n+s]=t/a&255;return n+r};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(t,n,r,o){if(t=+t,n=n>>>0,r=r>>>0,!o){let i=Math.pow(2,8*r)-1;oe(this,t,n,r,i,0)}let a=r-1,s=1;for(this[n+a]=t&255;--a>=0&&(s*=256);)this[n+a]=t/s&255;return n+r};g.prototype.writeUint8=g.prototype.writeUInt8=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,1,255,0),this[n]=t&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function $a(e,t,n,r,o){qa(t,r,o,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a=a>>8,e[n++]=a,a=a>>8,e[n++]=a,a=a>>8,e[n++]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=s,s=s>>8,e[n++]=s,s=s>>8,e[n++]=s,s=s>>8,e[n++]=s,n}function Ga(e,t,n,r,o){qa(t,r,o,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a=a>>8,e[n+6]=a,a=a>>8,e[n+5]=a,a=a>>8,e[n+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=s,s=s>>8,e[n+2]=s,s=s>>8,e[n+1]=s,s=s>>8,e[n]=s,n+8}g.prototype.writeBigUInt64LE=$e(function(t,n=0){return $a(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=$e(function(t,n=0){return Ga(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(t,n,r,o){if(t=+t,n=n>>>0,!o){let c=Math.pow(2,8*r-1);oe(this,t,n,r,c-1,-c)}let a=0,s=1,i=0;for(this[n]=t&255;++a<r&&(s*=256);)t<0&&i===0&&this[n+a-1]!==0&&(i=1),this[n+a]=(t/s>>0)-i&255;return n+r};g.prototype.writeIntBE=function(t,n,r,o){if(t=+t,n=n>>>0,!o){let c=Math.pow(2,8*r-1);oe(this,t,n,r,c-1,-c)}let a=r-1,s=1,i=0;for(this[n+a]=t&255;--a>=0&&(s*=256);)t<0&&i===0&&this[n+a+1]!==0&&(i=1),this[n+a]=(t/s>>0)-i&255;return n+r};g.prototype.writeInt8=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1};g.prototype.writeInt16LE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2};g.prototype.writeInt16BE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2};g.prototype.writeInt32LE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4};g.prototype.writeInt32BE=function(t,n,r){return t=+t,n=n>>>0,r||oe(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};g.prototype.writeBigInt64LE=$e(function(t,n=0){return $a(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=$e(function(t,n=0){return Ga(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ma(e,t,n,r,o,a){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ja(e,t,n,r,o){return t=+t,n=n>>>0,o||Ma(e,t,n,4,34028234663852886e22,-34028234663852886e22),it.write(e,t,n,r,23,4),n+4}g.prototype.writeFloatLE=function(t,n,r){return ja(this,t,n,!0,r)};g.prototype.writeFloatBE=function(t,n,r){return ja(this,t,n,!1,r)};function Ha(e,t,n,r,o){return t=+t,n=n>>>0,o||Ma(e,t,n,8,17976931348623157e292,-17976931348623157e292),it.write(e,t,n,r,52,8),n+8}g.prototype.writeDoubleLE=function(t,n,r){return Ha(this,t,n,!0,r)};g.prototype.writeDoubleBE=function(t,n,r){return Ha(this,t,n,!1,r)};g.prototype.copy=function(t,n,r,o){if(!g.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!o&&o!==0&&(o=this.length),n>=t.length&&(n=t.length),n||(n=0),o>0&&o<r&&(o=r),o===r||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-n<o-r&&(o=t.length-n+r);let a=o-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,r,o):Uint8Array.prototype.set.call(t,this.subarray(r,o),n),a};g.prototype.fill=function(t,n,r,o){if(typeof t=="string"){if(typeof n=="string"?(o=n,n=0,r=this.length):typeof r=="string"&&(o=r,r=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!g.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(t.length===1){let s=t.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);let a;if(typeof t=="number")for(a=n;a<r;++a)this[a]=t;else{let s=g.isBuffer(t)?t:g.from(t,o),i=s.length;if(i===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(a=0;a<r-n;++a)this[a+n]=s[a%i]}return this};var st={};function dr(e,t,n){st[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}dr("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);dr("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);dr("ERR_OUT_OF_RANGE",function(e,t,n){let r=`The value of "${e}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=_a(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=_a(o)),o+="n"),r+=` It must be ${t}. Received ${o}`,r},RangeError);function _a(e){let t="",n=e.length,r=e[0]==="-"?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function wl(e,t,n){ut(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&Dt(t,e.length-(n+1))}function qa(e,t,n,r,o,a){if(e>n||e<t){let s=typeof t=="bigint"?"n":"",i;throw a>3?t===0||t===BigInt(0)?i=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:i=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:i=`>= ${t}${s} and <= ${n}${s}`,new st.ERR_OUT_OF_RANGE("value",i,e)}wl(r,o,a)}function ut(e,t){if(typeof e!="number")throw new st.ERR_INVALID_ARG_TYPE(t,"number",e)}function Dt(e,t,n){throw Math.floor(e)!==e?(ut(e,n),new st.ERR_OUT_OF_RANGE(n||"offset","an integer",e)):t<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,e)}var El=/[^+/0-9A-Za-z-_]/g;function bl(e){if(e=e.split("=")[0],e=e.trim().replace(El,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ur(e,t){t=t||1/0;let n,r=e.length,o=null,a=[];for(let s=0;s<r;++s){if(n=e.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&a.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(t-=3)>-1&&a.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return a}function Sl(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function vl(e,t){let n,r,o,a=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,o=n%256,a.push(o),a.push(r);return a}function za(e){return ar.toByteArray(bl(e))}function un(e,t,n,r){let o;for(o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ke(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function fr(e){return e!==e}var Al=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let r=n*16;for(let o=0;o<16;++o)t[r+o]=e[n]+e[o]}return t}();function $e(e){return typeof BigInt>"u"?Il:e}function Il(){throw new Error("BigInt not supported")}});var gr=K((Ge,Ya)=>{"use strict";var cn=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global,ln=function(){function e(){this.fetch=!1,this.DOMException=cn.DOMException}return e.prototype=cn,new e}();(function(e){var t=function(n){var r=typeof e<"u"&&e||typeof self<"u"&&self||typeof global<"u"&&global||{},o={searchParams:"URLSearchParams"in r,iterable:"Symbol"in r&&"iterator"in Symbol,blob:"FileReader"in r&&"Blob"in r&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in r,arrayBuffer:"ArrayBuffer"in r};function a(f){return f&&DataView.prototype.isPrototypeOf(f)}if(o.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(f){return f&&s.indexOf(Object.prototype.toString.call(f))>-1};function c(f){if(typeof f!="string"&&(f=String(f)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(f)||f==="")throw new TypeError('Invalid character in header field name: "'+f+'"');return f.toLowerCase()}function u(f){return typeof f!="string"&&(f=String(f)),f}function l(f){var y={next:function(){var S=f.shift();return{done:S===void 0,value:S}}};return o.iterable&&(y[Symbol.iterator]=function(){return y}),y}function d(f){this.map={},f instanceof d?f.forEach(function(y,S){this.append(S,y)},this):Array.isArray(f)?f.forEach(function(y){if(y.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+y.length);this.append(y[0],y[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(y){this.append(y,f[y])},this)}d.prototype.append=function(f,y){f=c(f),y=u(y);var S=this.map[f];this.map[f]=S?S+", "+y:y},d.prototype.delete=function(f){delete this.map[c(f)]},d.prototype.get=function(f){return f=c(f),this.has(f)?this.map[f]:null},d.prototype.has=function(f){return this.map.hasOwnProperty(c(f))},d.prototype.set=function(f,y){this.map[c(f)]=u(y)},d.prototype.forEach=function(f,y){for(var S in this.map)this.map.hasOwnProperty(S)&&f.call(y,this.map[S],S,this)},d.prototype.keys=function(){var f=[];return this.forEach(function(y,S){f.push(S)}),l(f)},d.prototype.values=function(){var f=[];return this.forEach(function(y){f.push(y)}),l(f)},d.prototype.entries=function(){var f=[];return this.forEach(function(y,S){f.push([S,y])}),l(f)},o.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function p(f){if(!f._noBody){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}}function m(f){return new Promise(function(y,S){f.onload=function(){y(f.result)},f.onerror=function(){S(f.error)}})}function E(f){var y=new FileReader,S=m(y);return y.readAsArrayBuffer(f),S}function I(f){var y=new FileReader,S=m(y),F=/charset=([A-Za-z0-9_-]+)/.exec(f.type),U=F?F[1]:"utf-8";return y.readAsText(f,U),S}function D(f){for(var y=new Uint8Array(f),S=new Array(y.length),F=0;F<y.length;F++)S[F]=String.fromCharCode(y[F]);return S.join("")}function G(f){if(f.slice)return f.slice(0);var y=new Uint8Array(f.byteLength);return y.set(new Uint8Array(f)),y.buffer}function L(){return this.bodyUsed=!1,this._initBody=function(f){this.bodyUsed=this.bodyUsed,this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:o.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:o.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():o.arrayBuffer&&o.blob&&a(f)?(this._bodyArrayBuffer=G(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||i(f))?this._bodyArrayBuffer=G(f):this._bodyText=f=Object.prototype.toString.call(f):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof f=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.blob&&(this.blob=function(){var f=p(this);if(f)return f;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var f=p(this);return f||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(o.blob)return this.blob().then(E);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var f=p(this);if(f)return f;if(this._bodyBlob)return I(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(tt)}),this.json=function(){return this.text().then(JSON.parse)},this}var P=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function M(f){var y=f.toUpperCase();return P.indexOf(y)>-1?y:f}function R(f,y){if(!(this instanceof R))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');y=y||{};var S=y.body;if(f instanceof R){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,y.headers||(this.headers=new d(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!S&&f._bodyInit!=null&&(S=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=y.credentials||this.credentials||"same-origin",(y.headers||!this.headers)&&(this.headers=new d(y.headers)),this.method=M(y.method||this.method||"GET"),this.mode=y.mode||this.mode||null,this.signal=y.signal||this.signal||function(){if("AbortController"in r){var A=new AbortController;return A.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&S)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(S),(this.method==="GET"||this.method==="HEAD")&&(y.cache==="no-store"||y.cache==="no-cache")){var F=/([?&])_=[^&]*/;if(F.test(this.url))this.url=this.url.replace(F,"$1_="+new Date().getTime());else{var U=/\?/;this.url+=(U.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}R.prototype.clone=function(){return new R(this,{body:this._bodyInit})};function tt(f){var y=new FormData;return f.trim().split("&").forEach(function(S){if(S){var F=S.split("="),U=F.shift().replace(/\+/g," "),A=F.join("=").replace(/\+/g," ");y.append(decodeURIComponent(U),decodeURIComponent(A))}}),y}function nt(f){var y=new d,S=f.replace(/\r?\n[\t ]+/g," ");return S.split("\r").map(function(F){return F.indexOf(`
|
|
2
|
-
`)===0?F.substr(1,F.length):F}).forEach(function(F){var U=F.split(":"),A=U.shift().trim();if(A){var Zt=U.join(":").trim();try{y.append(A,Zt)}catch(Xn){console.warn("Response "+Xn.message)}}}),y}L.call(R.prototype);function ye(f,y){if(!(this instanceof ye))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(y||(y={}),this.type="default",this.status=y.status===void 0?200:y.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=y.statusText===void 0?"":""+y.statusText,this.headers=new d(y.headers),this.url=y.url||"",this._initBody(f)}L.call(ye.prototype),ye.prototype.clone=function(){return new ye(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},ye.error=function(){var f=new ye(null,{status:200,statusText:""});return f.ok=!1,f.status=0,f.type="error",f};var lc=[301,302,303,307,308];ye.redirect=function(f,y){if(lc.indexOf(y)===-1)throw new RangeError("Invalid status code");return new ye(null,{status:y,headers:{location:f}})},n.DOMException=r.DOMException;try{new n.DOMException}catch{n.DOMException=function(y,S){this.message=y,this.name=S;var F=Error(y);this.stack=F.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function Jn(f,y){return new Promise(function(S,F){var U=new R(f,y);if(U.signal&&U.signal.aborted)return F(new n.DOMException("Aborted","AbortError"));var A=new XMLHttpRequest;function Zt(){A.abort()}A.onload=function(){var X={statusText:A.statusText,headers:nt(A.getAllResponseHeaders()||"")};U.url.indexOf("file://")===0&&(A.status<200||A.status>599)?X.status=200:X.status=A.status,X.url="responseURL"in A?A.responseURL:X.headers.get("X-Request-URL");var qe="response"in A?A.response:A.responseText;setTimeout(function(){S(new ye(qe,X))},0)},A.onerror=function(){setTimeout(function(){F(new TypeError("Network request failed"))},0)},A.ontimeout=function(){setTimeout(function(){F(new TypeError("Network request timed out"))},0)},A.onabort=function(){setTimeout(function(){F(new n.DOMException("Aborted","AbortError"))},0)};function Xn(X){try{return X===""&&r.location.href?r.location.href:X}catch{return X}}if(A.open(U.method,Xn(U.url),!0),U.credentials==="include"?A.withCredentials=!0:U.credentials==="omit"&&(A.withCredentials=!1),"responseType"in A&&(o.blob?A.responseType="blob":o.arrayBuffer&&(A.responseType="arraybuffer")),y&&typeof y.headers=="object"&&!(y.headers instanceof d||r.Headers&&y.headers instanceof r.Headers)){var Po=[];Object.getOwnPropertyNames(y.headers).forEach(function(X){Po.push(c(X)),A.setRequestHeader(X,u(y.headers[X]))}),U.headers.forEach(function(X,qe){Po.indexOf(qe)===-1&&A.setRequestHeader(qe,X)})}else U.headers.forEach(function(X,qe){A.setRequestHeader(qe,X)});U.signal&&(U.signal.addEventListener("abort",Zt),A.onreadystatechange=function(){A.readyState===4&&U.signal.removeEventListener("abort",Zt)}),A.send(typeof U._bodyInit>"u"?null:U._bodyInit)})}return Jn.polyfill=!0,r.fetch||(r.fetch=Jn,r.Headers=d,r.Request=R,r.Response=ye),n.Headers=d,n.Request=R,n.Response=ye,n.fetch=Jn,Object.defineProperty(n,"__esModule",{value:!0}),n}({})})(ln);ln.fetch.ponyfill=!0;delete ln.fetch.polyfill;var dt=cn.fetch?cn:ln;Ge=dt.fetch;Ge.default=dt.fetch;Ge.fetch=dt.fetch;Ge.Headers=dt.Headers;Ge.Request=dt.Request;Ge.Response=dt.Response;Ya.exports=Ge});var Va=K((xh,dn)=>{"use strict";var{AbortController:Wa,AbortSignal:Nl}=typeof self<"u"?self:typeof window<"u"?window:void 0;dn.exports=Wa;dn.exports.AbortSignal=Nl;dn.exports.default=Wa});var pn=K((Jh,Qa)=>{"use strict";var id=function(t,n){return function(r,o){var a=o*2,s=n*2;r[a]=t[s],r[a+1]=t[s+1]}};Qa.exports=id});var es=K(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.default=void 0;var ud=cd(pn());function cd(e){return e&&e.__esModule?e:{default:e}}var ld=function(t){for(var n=t.A,r=t.C,o=0;o<25;o+=5){for(var a=0;a<5;a++)(0,ud.default)(n,o+a)(r,a);for(var s=0;s<5;s++){var i=(o+s)*2,c=(s+1)%5*2,u=(s+2)%5*2;n[i]^=~r[c]&r[u],n[i+1]^=~r[c+1]&r[u+1]}}},dd=ld;gn.default=dd});var ts=K(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.default=void 0;var fd=new Uint32Array([0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424]),pd=fd;mn.default=pd});var rs=K(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.default=void 0;var ns=gd(ts());function gd(e){return e&&e.__esModule?e:{default:e}}var md=function(t){var n=t.A,r=t.roundIndex,o=r*2;n[0]^=ns.default[o],n[1]^=ns.default[o+1]},hd=md;hn.default=hd});var os=K(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.default=void 0;var yd=[10,7,11,17,18,3,5,16,8,21,24,4,15,23,19,13,12,2,20,14,22,9,6,1],wd=yd;yn.default=wd});var as=K(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.default=void 0;var Ed=[1,3,6,10,15,21,28,36,45,55,2,14,27,41,56,8,25,43,62,18,39,61,20,44],bd=Ed;wn.default=bd});var ss=K(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.default=void 0;var Sd=wr(os()),vd=wr(as()),En=wr(pn());function wr(e){return e&&e.__esModule?e:{default:e}}var Ad=function(t){var n=t.A,r=t.C,o=t.W;(0,En.default)(n,1)(o,0);for(var a=0,s=0,i=0,c=32,u=0;u<24;u++){var l=Sd.default[u],d=vd.default[u];(0,En.default)(n,l)(r,0),a=o[0],s=o[1],c=32-d,i=d<32?0:1,o[i]=a<<d|s>>>c,o[(i+1)%2]=s<<d|a>>>c,(0,En.default)(o,0)(n,l),(0,En.default)(r,0)(o,0)}},Id=Ad;bn.default=Id});var is=K(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.default=void 0;var Rd=kd(pn());function kd(e){return e&&e.__esModule?e:{default:e}}var Td=function(t){for(var n=t.A,r=t.C,o=t.D,a=t.W,s=0,i=0,c=0;c<5;c++){var u=c*2,l=(c+5)*2,d=(c+10)*2,p=(c+15)*2,m=(c+20)*2;r[u]=n[u]^n[l]^n[d]^n[p]^n[m],r[u+1]=n[u+1]^n[l+1]^n[d+1]^n[p+1]^n[m+1]}for(var E=0;E<5;E++){(0,Rd.default)(r,(E+1)%5)(a,0),s=a[0],i=a[1],a[0]=s<<1|i>>>31,a[1]=i<<1|s>>>31,o[E*2]=r[(E+4)%5*2]^a[0],o[E*2+1]=r[(E+4)%5*2+1]^a[1];for(var I=0;I<25;I+=5)n[(I+E)*2]^=o[E*2],n[(I+E)*2+1]^=o[E*2+1]}},Cd=Td;Sn.default=Cd});var us=K(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.default=void 0;var Pd=vn(es()),Nd=vn(rs()),Fd=vn(ss()),_d=vn(is());function vn(e){return e&&e.__esModule?e:{default:e}}var Bd=function(){var t=new Uint32Array(10),n=new Uint32Array(10),r=new Uint32Array(2);return function(o){for(var a=0;a<24;a++)(0,_d.default)({A:o,C:t,D:n,W:r}),(0,Fd.default)({A:o,C:t,W:r}),(0,Pd.default)({A:o,C:t}),(0,Nd.default)({A:o,roundIndex:a});t.fill(0),n.fill(0),r.fill(0)}},Od=Bd;An.default=Od});var ls=K(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.default=void 0;var Er=Ke(),Dd=Ud(us());function Ud(e){return e&&e.__esModule?e:{default:e}}var cs=function(t,n){for(var r=0;r<t.length;r+=8){var o=r/4;n[o]^=t[r+7]<<24|t[r+6]<<16|t[r+5]<<8|t[r+4],n[o+1]^=t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r]}return n},Ld=function(t,n){for(var r=0;r<n.length;r+=8){var o=r/4;n[r]=t[o+1],n[r+1]=t[o+1]>>>8,n[r+2]=t[o+1]>>>16,n[r+3]=t[o+1]>>>24,n[r+4]=t[o],n[r+5]=t[o]>>>8,n[r+6]=t[o]>>>16,n[r+7]=t[o]>>>24}return n},$d=function(t){var n=this,r=t.capacity,o=t.padding,a=(0,Dd.default)(),s=200,i=r/8,c=s-r/4,u=0,l=new Uint32Array(s/4),d=Er.Buffer.allocUnsafe(c);return this.absorb=function(p){for(var m=0;m<p.length;m++)d[u]=p[m],u+=1,u>=c&&(cs(d,l),a(l),u=0);return n},this.squeeze=function(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},m={buffer:p.buffer||Er.Buffer.allocUnsafe(i),padding:p.padding||o,queue:Er.Buffer.allocUnsafe(d.length),state:new Uint32Array(l.length)};d.copy(m.queue);for(var E=0;E<l.length;E++)m.state[E]=l[E];m.queue.fill(0,u),m.queue[u]|=m.padding,m.queue[c-1]|=128,cs(m.queue,m.state);for(var I=0;I<m.buffer.length;I+=c)a(m.state),Ld(m.state,m.buffer.slice(I,I+c));return m.buffer},this.reset=function(){return d.fill(0),l.fill(0),u=0,n},this},Gd=$d;In.default=Gd});var gs=K(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.default=de.SHAKE=de.SHA3Hash=de.SHA3=de.Keccak=void 0;var ds=Ke(),Md=jd(ls());function jd(e){return e&&e.__esModule?e:{default:e}}var br=function(t){var n=t.allowedSizes,r=t.defaultSize,o=t.padding;return function a(){var s=this,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:r;if(!this||this.constructor!==a)return new a(i);if(n&&!n.includes(i))throw new Error("Unsupported hash length");var c=new Md.default({capacity:i});return this.update=function(u){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"utf8";if(ds.Buffer.isBuffer(u))return c.absorb(u),s;if(typeof u=="string")return s.update(ds.Buffer.from(u,l));throw new TypeError("Not a string or buffer")},this.digest=function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"binary",l=typeof u=="string"?{format:u}:u,d=c.squeeze({buffer:l.buffer,padding:l.padding||o});return l.format&&l.format!=="binary"?d.toString(l.format):d},this.reset=function(){return c.reset(),s},this}},fs=br({allowedSizes:[224,256,384,512],defaultSize:512,padding:1});de.Keccak=fs;var Sr=br({allowedSizes:[224,256,384,512],defaultSize:512,padding:6});de.SHA3=Sr;var Hd=br({allowedSizes:[128,256],defaultSize:256,padding:31});de.SHAKE=Hd;var ps=fs;de.SHA3Hash=ps;Sr.SHA3Hash=ps;var qd=Sr;de.default=qd});var Fh={};No(Fh,{default:()=>Nh});var cc=_e(Bo());var $o=_e(Uo()),yc=()=>{let e=[];var t;return{async deliver(n){e.push(n),t&&(t(e.shift()),t=void 0)},receive(){return new Promise(function(r){let o=e.shift();if(o)return r(o);t=r})}}},rt="INIT",Se="SUBSCRIBE",we="UNSUBSCRIBE",en="UPDATED",Zn="SNAPSHOT",wc="EXIT",Lo="TERMINATE",k=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||typeof window=="object"&&window.window===window&&window;k.FCL_REGISTRY=k.FCL_REGISTRY==null?{}:k.FCL_REGISTRY;var Ec=0,bc=5e3,N=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return new Promise((o,a)=>{let s=r.expectReply||!1,i=r.timeout!=null?r.timeout:bc;s&&i&&setTimeout(()=>a(new Error(`Timeout: ${i}ms passed without a response.`)),i);let c={to:e,from:r.from,tag:t,data:n,timeout:i,reply:o,reject:a};try{k.FCL_REGISTRY[e]&&k.FCL_REGISTRY[e].mailbox.deliver(c),s||o(!0)}catch(u){console.error("FCL.Actor -- Could Not Deliver Message",c,k.FCL_REGISTRY[e],u)}})},Sc=e=>{delete k.FCL_REGISTRY[e]},vc=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return async t=>{typeof e[rt]=="function"&&await e[rt](t);e:for(;;){let n=await t.receive();try{if(n.tag===wc){typeof e[Lo]=="function"&&await e[Lo](t,n,n.data||{});break e}await e[n.tag](t,n,n.data||{})}catch(r){console.error(`${t.self()} Error`,n,r)}finally{continue e}}}},ve=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(t==null&&(t=++Ec),k.FCL_REGISTRY[t]!=null)return t;k.FCL_REGISTRY[t]={addr:t,mailbox:yc(),subs:new Set,kvs:{},error:null};let n={self:()=>t,receive:()=>k.FCL_REGISTRY[t].mailbox.receive(),send:function(r,o,a){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return s.from=t,N(r,o,a,s)},sendSelf:(r,o,a)=>{k.FCL_REGISTRY[t]&&N(t,r,o,a)},broadcast:function(r,o){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};a.from=t;for(let s of k.FCL_REGISTRY[t].subs)N(s,r,o,a)},subscribe:r=>r!=null&&k.FCL_REGISTRY[t].subs.add(r),unsubscribe:r=>r!=null&&k.FCL_REGISTRY[t].subs.delete(r),subscriberCount:()=>k.FCL_REGISTRY[t].subs.size,hasSubs:()=>!!k.FCL_REGISTRY[t].subs.size,put:(r,o)=>{r!=null&&(k.FCL_REGISTRY[t].kvs[r]=o)},get:(r,o)=>{let a=k.FCL_REGISTRY[t].kvs[r];return a??o},delete:r=>{delete k.FCL_REGISTRY[t].kvs[r]},update:(r,o)=>{r!=null&&(k.FCL_REGISTRY[t].kvs[r]=o(k.FCL_REGISTRY[t].kvs[r]))},keys:()=>Object.keys(k.FCL_REGISTRY[t].kvs),all:()=>k.FCL_REGISTRY[t].kvs,where:r=>Object.keys(k.FCL_REGISTRY[t].kvs).reduce((o,a)=>r.test(a)?{...o,[a]:k.FCL_REGISTRY[t].kvs[a]}:o,{}),merge:function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.keys(r).forEach(o=>k.FCL_REGISTRY[t].kvs[o]=r[o])},fatalError:r=>{k.FCL_REGISTRY[t].error=r;for(let o of k.FCL_REGISTRY[t].subs)N(o,en)}};return typeof e=="object"&&(e=vc(e)),(0,$o.default)(async()=>{await e(n),Sc(t)}),t};function Nt(e,t,n){t(e);let r="@EXIT",o=ve(async a=>{for(a.send(e,Se);;){let s=await a.receive(),i=k.FCL_REGISTRY[e].error;if(s.tag===r){a.send(e,we);return}if(i){n(null,i),a.send(e,we);return}n(s.data,null)}});return()=>N(o,r)}function Go(e,t){return t(e),N(e,Zn,null,{expectReply:!0,timeout:0})}function Mo(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
3
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
4
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
`,a,`
|
|
9
|
-
|
|
10
|
-
`,...r,`
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
`),a}}var jo=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>a(o),r)},Ac=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>({...o,...a(r)}),{})},tn=e=>e&&typeof e=="object"&&!Array.isArray(e),Qn=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!n.length)return e;let o=n.shift();if(tn(e)&&tn(o))for(let a in o)tn(o[a])?(e[a]||Object.assign(e,{[a]:{}}),Qn(e[a],o[a])):Object.assign(e,{[a]:o[a]});return Qn(e,...n)},Ic=e=>Array.isArray(e)?Qn({},...e):e,Rc=e=>e.contracts?e.contracts:{},kc=e=>t=>Object.entries(t).reduce((n,r)=>{let[o,a]=r,s=a?.aliases?.[e];return s&&(n[o]=s),n},{}),Tc=e=>t=>{let{deployments:n={},accounts:r={}}=t,o=n?.[e];return o?Object.entries(o).reduce((a,s)=>{let[i,c]=s,u=r[i]?.address;return u?c.reduce((l,d)=>({...l,[d]:u}),{}):a},{}):{}},Cc=(e,t)=>jo(Ic,Ac(Tc(t),jo(Rc,kc(t))))(e),Pc=e=>typeof e!="string"?!1:/^[0-9A-Fa-f]+$/.test(e),Ho=e=>Object.entries(e?.accounts).reduce((t,n)=>{let[r,o]=n;return t?!0:o?.hasOwnProperty("key")&&Pc(o?.key)},!1),Nc=e=>tn(e)?Ho(e):e.some(Ho),Fc=e=>e?.toLowerCase()==="local"?"emulator":e?.toLowerCase(),Ae="config",Wo="PUT_CONFIG",Vo="GET_CONFIG",Jo="GET_ALL_CONFIG",Xo="UPDATE_CONFIG",Zo="DELETE_CONFIG",Qo="CLEAR_CONFIG",ea="WHERE_CONFIG",Ft="CONFIG/UPDATED",ta=e=>e,na={[Wo]:(e,t,n)=>{let{key:r,value:o}=n;if(r==null)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast(Ft,{...e.all()})},[Vo]:(e,t,n)=>{let{key:r,fallback:o}=n;if(r==null)throw new Error("Missing 'key' for config/get");t.reply(e.get(r,o))},[Jo]:(e,t)=>{t.reply({...e.all()})},[Xo]:(e,t,n)=>{let{key:r,fn:o}=n;if(r==null)throw new Error("Missing 'key' for config/update");e.update(r,o||ta),e.broadcast(Ft,{...e.all()})},[Zo]:(e,t,n)=>{let{key:r}=n;if(r==null)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(Ft,{...e.all()})},[Qo]:(e,t)=>{let n=Object.keys(e.all());for(let r of n)e.delete(r);e.broadcast(Ft,{...e.all()})},[ea]:(e,t,n)=>{let{pattern:r}=n;if(r==null)throw new Error("Missing 'pattern' for config/where");t.reply(e.where(r))},[Se]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Ft,{...e.all()})},[we]:(e,t)=>{e.unsubscribe(t.from)}};ve(na,Ae);function Bt(e,t){return N(Ae,Wo,{key:e,value:t}),Q()}function ot(e,t){return N(Ae,Vo,{key:e,fallback:t},{expectReply:!0,timeout:10})}async function tr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!e.length)return t;let[n,...r]=e,o=await ot(n);return o??tr(r,t)}function rn(){return N(Ae,Jo,null,{expectReply:!0,timeout:10})}function ra(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ta;return N(Ae,Xo,{key:e,fn:t}),Q()}function oa(e){return N(Ae,Zo,{key:e}),Q()}function aa(e){return N(Ae,ea,{pattern:e},{expectReply:!0,timeout:10})}function sa(e){return Nt(Ae,()=>ve(na,Ae),e)}function _c(){return N(Ae,Qo)}function qo(e){return _c().then(Q(e))}async function ia(e){let t=await ot("flow.network"),n=Fc(t),{flowJSON:r}=e;if(Mo(!!r,"config.load -- 'flowJSON' must be defined"),Mo(n,'Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl'),Nc(r)){let o=n==="emulator";if(Le({title:"Private Keys Detected",message:"Private keys should be stored in a separate flow.json file for security. See more here: https://developers.flow.com/tools/flow-cli/security",level:o?re.warn:re.error}),!o)return}for(let[o,a]of Object.entries(Cc(r,n))){let s=`0x${o}`,i=await ot(s);i&&i!==a?Le({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:re.warn}):Bt(s,a);let c=`system.contracts.${o}`,u=await ot(c);u&&u!==a?Le({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:re.warn}):Bt(c,a)}}function Q(e){return e!=null&&typeof e=="object"&&Object.keys(e).map(t=>Bt(t,e[t])),{put:Bt,get:ot,all:rn,first:tr,update:ra,delete:oa,where:aa,subscribe:sa,overload:ua,load:ia}}Q.put=Bt;Q.get=ot;Q.all=rn;Q.first=tr;Q.update=ra;Q.delete=oa;Q.where=aa;Q.subscribe=sa;Q.overload=ua;Q.load=ia;var Bc=e=>e;function ua(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bc;return new Promise(async(n,r)=>{let o=await rn();try{Q(e);var a=await t(await rn());await qo(o),n(a)}catch(s){await qo(o),r(s)}})}var re=Object.freeze({debug:5,info:4,log:3,warn:2,error:1}),Oc=e=>{let{title:t,message:n}=e;return[`
|
|
15
|
-
%c${t}
|
|
16
|
-
============================
|
|
17
|
-
|
|
18
|
-
${n}
|
|
19
|
-
|
|
20
|
-
============================
|
|
21
|
-
`.replace(/\n[^\S\r\n]+/g,`
|
|
22
|
-
`).trim(),,"font-weight:bold;font-family:monospace;"]},Le=async e=>{let{title:t,message:n,level:r,always:o=!1}=e,a=await Q.get("logger.level",re.warn);if(!o&&a<r)return;let s=Oc({title:t,message:n});switch(r){case re.debug:console.debug(...s);break;case re.info:console.info(...s);break;case re.warn:console.warn(...s);break;case re.error:console.error(...s);break;default:console.log(...s)}};Le.deprecate=e=>{let{pkg:t,subject:n,transition:r,level:o=re.warn,message:a="",callback:s=null}=e,i=u=>u.charAt(0).toUpperCase()+u.slice(1),c=()=>Le({title:`${t?t+" ":""}Deprecation Notice`,message:`
|
|
23
|
-
${n?`${i(n)} is deprecated and will cease to work in future releases${t?" of "+t:""}.`:""}${a?`
|
|
24
|
-
`+a:""}${r?`
|
|
25
|
-
You can learn more (including a guide on common transition paths) here: ${r}`:""}
|
|
26
|
-
`.trim(),level:o});return typeof s=="function"?async function(){return await c(),await s(...arguments)}:c()};function zo(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
27
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
28
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
`,a,`
|
|
33
|
-
|
|
34
|
-
`,...r,`
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
`),a}}var xo=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>a(o),r)},Dc=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>({...o,...a(r)}),{})},nn=e=>e&&typeof e=="object"&&!Array.isArray(e),er=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!n.length)return e;let o=n.shift();if(nn(e)&&nn(o))for(let a in o)nn(o[a])?(e[a]||Object.assign(e,{[a]:{}}),er(e[a],o[a])):Object.assign(e,{[a]:o[a]});return er(e,...n)},Uc=e=>Array.isArray(e)?er({},...e):e,Lc=e=>e.contracts?e.contracts:{},$c=e=>t=>Object.entries(t).reduce((n,r)=>{let[o,a]=r,s=a?.aliases?.[e];return s&&(n[o]=s),n},{}),Gc=e=>t=>{let{deployments:n={},accounts:r={}}=t,o=n?.[e];return o?Object.entries(o).reduce((a,s)=>{let[i,c]=s,u=r[i]?.address;return u?c.reduce((l,d)=>({...l,[d]:u}),{}):a},{}):{}},Mc=(e,t)=>xo(Uc,Dc(Gc(t),xo(Lc,$c(t))))(e),jc=e=>typeof e!="string"?!1:/^[0-9A-Fa-f]+$/.test(e),Ko=e=>Object.entries(e?.accounts).reduce((t,n)=>{let[r,o]=n;return t?!0:o?.hasOwnProperty("key")&&jc(o?.key)},!1),Hc=e=>nn(e)?Ko(e):e.some(Ko),qc=e=>e?.toLowerCase()==="local"?"emulator":e?.toLowerCase(),Ie="config",ca="PUT_CONFIG",la="GET_CONFIG",da="GET_ALL_CONFIG",fa="UPDATE_CONFIG",pa="DELETE_CONFIG",ga="CLEAR_CONFIG",ma="WHERE_CONFIG",_t="CONFIG/UPDATED",ha=e=>e,ya={[ca]:(e,t,n)=>{let{key:r,value:o}=n;if(r==null)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast(_t,{...e.all()})},[la]:(e,t,n)=>{let{key:r,fallback:o}=n;if(r==null)throw new Error("Missing 'key' for config/get");t.reply(e.get(r,o))},[da]:(e,t)=>{t.reply({...e.all()})},[fa]:(e,t,n)=>{let{key:r,fn:o}=n;if(r==null)throw new Error("Missing 'key' for config/update");e.update(r,o||ha),e.broadcast(_t,{...e.all()})},[pa]:(e,t,n)=>{let{key:r}=n;if(r==null)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(_t,{...e.all()})},[ga]:(e,t)=>{let n=Object.keys(e.all());for(let r of n)e.delete(r);e.broadcast(_t,{...e.all()})},[ma]:(e,t,n)=>{let{pattern:r}=n;if(r==null)throw new Error("Missing 'pattern' for config/where");t.reply(e.where(r))},[Se]:(e,t)=>{e.subscribe(t.from),e.send(t.from,_t,{...e.all()})},[we]:(e,t)=>{e.unsubscribe(t.from)}};ve(ya,Ie);function Ot(e,t){return N(Ie,ca,{key:e,value:t}),w()}function at(e,t){return N(Ie,la,{key:e,fallback:t},{expectReply:!0,timeout:10})}async function nr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!e.length)return t;let[n,...r]=e,o=await at(n);return o??nr(r,t)}function on(){return N(Ie,da,null,{expectReply:!0,timeout:10})}function wa(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ha;return N(Ie,fa,{key:e,fn:t}),w()}function Ea(e){return N(Ie,pa,{key:e}),w()}function ba(e){return N(Ie,ma,{pattern:e},{expectReply:!0,timeout:10})}function Sa(e){return Nt(Ie,()=>ve(ya,Ie),e)}function zc(){return N(Ie,ga)}function Yo(e){return zc().then(w(e))}async function va(e){let t=await at("flow.network"),n=qc(t),{flowJSON:r}=e;if(zo(!!r,"config.load -- 'flowJSON' must be defined"),zo(n,'Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl'),Hc(r)){let o=n==="emulator";if(Le({title:"Private Keys Detected",message:"Private keys should be stored in a separate flow.json file for security. See more here: https://developers.flow.com/tools/flow-cli/security",level:o?re.warn:re.error}),!o)return}for(let[o,a]of Object.entries(Mc(r,n))){let s=`0x${o}`,i=await at(s);i&&i!==a?Le({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:re.warn}):Ot(s,a);let c=`system.contracts.${o}`,u=await at(c);u&&u!==a?Le({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:re.warn}):Ot(c,a)}}function w(e){return e!=null&&typeof e=="object"&&Object.keys(e).map(t=>Ot(t,e[t])),{put:Ot,get:at,all:on,first:nr,update:wa,delete:Ea,where:ba,subscribe:Sa,overload:Aa,load:va}}w.put=Ot;w.get=at;w.all=on;w.first=nr;w.update=wa;w.delete=Ea;w.where=ba;w.subscribe=Sa;w.overload=Aa;w.load=va;var xc=e=>e;function Aa(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xc;return new Promise(async(n,r)=>{let o=await on();try{w(e);var a=await t(await on());await Yo(o),n(a)}catch(s){await Yo(o),r(s)}})}var Y=Object.freeze({debug:5,info:4,log:3,warn:2,error:1}),Kc=e=>{let{title:t,message:n}=e;return[`
|
|
39
|
-
%c${t}
|
|
40
|
-
============================
|
|
41
|
-
|
|
42
|
-
${n}
|
|
43
|
-
|
|
44
|
-
============================
|
|
45
|
-
`.replace(/\n[^\S\r\n]+/g,`
|
|
46
|
-
`).trim(),,"font-weight:bold;font-family:monospace;"]},$=async e=>{let{title:t,message:n,level:r,always:o=!1}=e,a=await w.get("logger.level",Y.warn);if(!o&&a<r)return;let s=Kc({title:t,message:n});switch(r){case Y.debug:console.debug(...s);break;case Y.info:console.info(...s);break;case Y.warn:console.warn(...s);break;case Y.error:console.error(...s);break;default:console.log(...s)}};$.deprecate=e=>{let{pkg:t,subject:n,transition:r,level:o=Y.warn,message:a="",callback:s=null}=e,i=u=>u.charAt(0).toUpperCase()+u.slice(1),c=()=>$({title:`${t?t+" ":""}Deprecation Notice`,message:`
|
|
47
|
-
${n?`${i(n)} is deprecated and will cease to work in future releases${t?" of "+t:""}.`:""}${a?`
|
|
48
|
-
`+a:""}${r?`
|
|
49
|
-
You can learn more (including a guide on common transition paths) here: ${r}`:""}
|
|
50
|
-
`.trim(),level:o});return typeof s=="function"?async function(){return await c(),await s(...arguments)}:c()};function h(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
51
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
52
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
`,a,`
|
|
57
|
-
|
|
58
|
-
`,...r,`
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
`),a}}var ie=_e(Ke()),le=_e(Ke());function lt(e){if(Array.isArray(e)){for(var t=[],n=0;n<e.length;n++)t.push(lt(e[n]));var r=ie.Buffer.concat(t);return ie.Buffer.concat([xa(r.length,192),r])}else{var o=Cl(e);return o.length===1&&o[0]<128?o:ie.Buffer.concat([xa(o.length,128),o])}}function xa(e,t){if(e<56)return ie.Buffer.from([e+t]);var n=pr(e),r=n.length/2,o=pr(t+55+r);return ie.Buffer.from(o+n,"hex")}function Ka(e){return e.slice(0,2)==="0x"}function Rl(e){return typeof e!="string"?e:Ka(e)?e.slice(2):e}function pr(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");var t=e.toString(16);return t.length%2?"0"+t:t}function kl(e){return e.length%2?"0"+e:e}function Tl(e){var t=pr(e);return ie.Buffer.from(t,"hex")}function Cl(e){if(!ie.Buffer.isBuffer(e)){if(typeof e=="string")return Ka(e)?ie.Buffer.from(kl(Rl(e)),"hex"):ie.Buffer.from(e);if(typeof e=="number")return e?Tl(e):ie.Buffer.from([]);if(e==null)return ie.Buffer.from([]);if(e instanceof Uint8Array)return ie.Buffer.from(e);throw new Error("invalid type")}return e}var Yh=_e(Ke());var Ja=_e(gr());function B(e){return e==null?null:e.replace(/^0x/,"").replace(/^Fx/,"")}function q(e){return e==null?null:"0x"+B(e)}var Fl=globalThis.AbortController||Va(),Ut=class extends Error{constructor(t){let{error:n,hostname:r,path:o,method:a,requestBody:s,responseBody:i,responseStatusText:c,statusCode:u}=t,l=`
|
|
63
|
-
HTTP Request Error: An error occurred when interacting with the Access API.
|
|
64
|
-
${n?`error=${n}`:""}
|
|
65
|
-
${r?`hostname=${r}`:""}
|
|
66
|
-
${o?`path=${o}`:""}
|
|
67
|
-
${a?`method=${a}`:""}
|
|
68
|
-
${s?`requestBody=${s}`:""}
|
|
69
|
-
${i?`responseBody=${i}`:""}
|
|
70
|
-
${c?`responseStatusText=${c}`:""}
|
|
71
|
-
${u?`statusCode=${u}`:""}
|
|
72
|
-
`;super(l),this.name="HTTP Request Error",this.statusCode=u,this.errorMessage=n}};async function z(e){let{hostname:t,path:n,method:r,body:o,headers:a,retryLimit:s=5,retryIntervalMs:i=1e3,timeoutLimit:c=3e4}=e,u=o?JSON.stringify(o):null;function l(){let p=new Fl,m=setTimeout(()=>{p.abort()},c);return(0,Ja.default)(`${t}${n}`,{method:r,body:u,headers:a,signal:p.signal}).then(async E=>{if(E.ok)return E.json();let I=E.body?await E.text():null,D=_l(I);throw new Ut({error:D?.message,hostname:t,path:n,method:r,requestBody:u,responseBody:I,responseStatusText:E.statusText,statusCode:E.status})}).catch(async E=>{throw E instanceof Ut||E.name==="AbortError"?E:(await $({title:"Access Node Error",message:`The provided access node ${t} does not appear to be a valid REST/HTTP access node.
|
|
73
|
-
Please verify that you are not unintentionally using a GRPC access node.
|
|
74
|
-
See more here: https://docs.onflow.org/fcl/reference/sdk-guidelines/#connect`,level:Y.error}),new Ut({error:E?.message,hostname:t,path:n,method:r,requestBody:u}))}).finally(()=>{clearTimeout(m)})}async function d(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;try{return await l()}catch(m){let E=[408,429,500,502,503,504];if(m.name==="AbortError"||E.includes(m.statusCode))return await new Promise((I,D)=>{p<s?(console.warn(`Access node unavailable, retrying in ${i} ms...`),setTimeout(()=>{I(d(p+1))},i)):D(m)});throw m}}return await d()}function _l(e){try{return JSON.parse(e)}catch{return null}}async function Bl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/scripts?block_id=${e.block.id}`,method:"POST",body:{script:t.Buffer.from(e.message.cadence).toString("base64"),arguments:e.message.arguments.map(a=>t.Buffer.from(JSON.stringify(e.arguments[a].asArgument)).toString("base64"))}});return mr(e,t,o)}async function Ol(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/scripts?block_height=${e.block.height}`,method:"POST",body:{script:t.Buffer.from(e.message.cadence).toString("base64"),arguments:e.message.arguments.map(a=>t.Buffer.from(JSON.stringify(e.arguments[a].asArgument)).toString("base64"))}});return mr(e,t,o)}async function Dl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:"/v1/scripts?block_height=sealed",method:"POST",body:{script:t.Buffer.from(e.message.cadence).toString("base64"),arguments:e.message.arguments.map(a=>t.Buffer.from(JSON.stringify(e.arguments[a].asArgument)).toString("base64"))}});return mr(e,t,o)}function mr(e,t,n){let r=t.response();return r.tag=e.tag,r.encodedData=JSON.parse(t.Buffer.from(n,"base64").toString()),r}async function Ul(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return h(n.node,"SDK Send Execute Script Error: opts.node must be defined."),h(t.response,"SDK Send Execute Script Error: context.response must be defined."),h(t.Buffer,"SDK Send Execute Script Error: context.Buffer must be defined."),e=await e,e.block.id?await Bl(e,t,n):e.block.height?await Ol(e,t,n):await Dl(e,t,n)}var Ll={SHA2_256:1,SHA2_384:2,SHA3_256:3,SHA3_384:4,KMAC128_BLS_BLS12_381:5},$l={ECDSA_P256:1,ECDSA_secp256k1:2,BLS_BLS12_381:3};async function Gl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/accounts/${e.account.addr}?block_height=${e.block.height}&expand=contracts,keys`,method:"GET",body:null});return Xa(e,t,o)}async function Ml(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/accounts/${e.account.addr}?block_height=sealed&expand=contracts,keys`,method:"GET",body:null});return Xa(e,t,o)}function Xa(e,t,n){let r=t.response();r.tag=e.tag;let o=a=>{let s={};if(!a)return s;for(let i of Object.keys(a))s[i]=t.Buffer.from(a[i],"base64").toString();return s};return r.account={address:n.address,balance:Number(n.balance),code:"",contracts:o(n.contracts),keys:n.keys?.map(a=>({index:Number(a.index),publicKey:a.public_key.replace(/^0x/,""),signAlgo:$l[a.signing_algorithm],signAlgoString:a.signing_algorithm,hashAlgo:Ll[a.hashing_algorithm],hashAlgoString:a.hashing_algorithm,sequenceNumber:Number(a.sequence_number),weight:Number(a.weight),revoked:a.revoked}))??[]},r}async function jl(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return h(n.node,"SDK Send Get Account Error: opts.node must be defined."),h(t.response,"SDK Send Get Account Error: context.response must be defined."),h(t.Buffer,"SDK Send Get Account Error: context.Buffer must be defined."),e=await e,e.block.height!==null?await Gl(e,t,n):await Ml(e,t,n)}async function Hl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/blocks/${e.block.id}`,method:"GET",body:null});return hr(e,t,o)}async function ql(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/blocks?height=${e.block.height}`,method:"GET",body:null});return hr(e,t,o)}async function zl(e,t,n){let r=n.httpRequest||z,o=e.block?.isSealed?"sealed":"final",a=await r({hostname:n.node,path:`/v1/blocks?height=${o}`,method:"GET",body:null});return hr(e,t,a)}function hr(e,t,n){let r=n.length?n[0]:null,o=t.response();return o.tag=e.tag,o.blockHeader={id:r.header.id,parentId:r.header.parent_id,height:Number(r.header.height),timestamp:r.header.timestamp},o}async function xl(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Block Header Error: opts.node must be defined."),h(t.response,"SDK Send Get Block Header Error: context.response must be defined."),e=await e;let r=e.block.id!==null,o=e.block.height!==null;return r?await Hl(e,t,n):o?await ql(e,t,n):await zl(e,t,n)}async function Kl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/blocks/${e.block.id}?expand=payload`,method:"GET",body:null});return yr(e,t,o)}async function Yl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/blocks?height=${e.block.height}&expand=payload`,method:"GET",body:null});return yr(e,t,o)}async function Wl(e,t,n){let r=n.httpRequest||z,o=e.block?.isSealed?"sealed":"final",a=await r({hostname:n.node,path:`/v1/blocks?height=${o}&expand=payload`,method:"GET",body:null});return yr(e,t,a)}function yr(e,t,n){let r=n.length?n[0]:null,o=t.response();return o.tag=e.tag,o.block={id:r.header.id,parentId:r.header.parent_id,height:Number(r.header.height),timestamp:r.header.timestamp,collectionGuarantees:r.payload.collection_guarantees.map(a=>({collectionId:a.collection_id,signerIds:a.signer_ids})),blockSeals:r.payload.block_seals.map(a=>({blockId:a.block_id,executionReceiptId:a.result_id}))},o}async function Vl(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Block Error: opts.node must be defined."),h(t.response,"SDK Send Get Block Error: context.response must be defined."),e=await e;let r=e.block.id!==null,o=e.block.height!==null;return r?await Kl(e,t,n):o?await Yl(e,t,n):await Wl(e,t,n)}async function Jl(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Collection Error: opts.node must be defined."),h(t.response,"SDK Send Get Collection Error: context.response must be defined.");let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/collections/${e.collection.id}?expand=transactions`,method:"GET",body:null}),a=t.response();return a.tag=e.tag,a.collection={id:o.id,transactionIds:o.transactions.map(s=>s.id)},a}async function Xl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/events?type=${e.events.eventType}&start_height=${e.events.start}&end_height=${e.events.end}`,method:"GET",body:null});return Za(e,t,o)}async function Zl(e,t,n){let o=await(n.httpRequest||z)({hostname:n.node,path:`/v1/events?type=${e.events.eventType}&block_ids=${e.events.blockIds.join(",")}`,method:"GET",body:null});return Za(e,t,o)}function Za(e,t,n){let r=t.response();return r.tag=e.tag,r.events=[],n.forEach(o=>o.events?o.events.forEach(a=>r.events.push({blockId:o.block_id,blockHeight:Number(o.block_height),blockTimestamp:o.block_timestamp,type:a.type,transactionId:a.transaction_id,transactionIndex:Number(a.transaction_index),eventIndex:Number(a.event_index),payload:JSON.parse(t.Buffer.from(a.payload,"base64").toString())})):null),r}async function Ql(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Events Error: opts.node must be defined."),h(t.response,"SDK Send Get Events Error: context.response must be defined."),h(t.Buffer,"SDK Send Get Events Error: context.Buffer must be defined."),e=await e;let r=e.events.start!==null,o=Array.isArray(e.events.blockIds)&&e.events.blockIds.length>0;return h(r||o,"SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified."),r?await Xl(e,t,n):await Zl(e,t,n)}async function ed(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Transaction Error: opts.node must be defined."),h(t.response,"SDK Send Get Transaction Error: context.response must be defined."),h(t.Buffer,"SDK Send Get Transaction Error: context.Buffer must be defined.");let r=n.httpRequest||z;e=await e;let o=await r({hostname:n.node,path:`/v1/transactions/${e.transaction.id}`,method:"GET",body:null}),a=u=>({address:u.address,keyId:Number(u.key_id),sequenceNumber:Number(u.sequence_number)}),s=u=>({address:u.address,keyId:Number(u.key_index),signature:u.signature}),i=u=>JSON.parse(t.Buffer.from(u,"base64").toString()),c=t.response();return c.tag=e.tag,c.transaction={script:t.Buffer.from(o.script,"base64").toString(),args:[...o.arguments.map(i)],referenceBlockId:o.reference_block_id,gasLimit:Number(o.gas_limit),payer:o.payer,proposalKey:o.proposal_key?a(o.proposal_key):o.proposal_key,authorizers:o.authorizers,payloadSignatures:[...o.payload_signatures.map(s)],envelopeSignatures:[...o.envelope_signatures.map(s)]},c}var td={UNKNOWN:0,PENDING:1,FINALIZED:2,EXECUTED:3,SEALED:4,EXPIRED:5};async function nd(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Transaction Status Error: opts.node must be defined."),h(t.response,"SDK Send Get Transaction Status Error: context.response must be defined."),h(t.Buffer,"SDK Send Get Transaction Status Error: context.Buffer must be defined.");let r=n.httpRequest||z;e=await e;let o=await r({hostname:n.node,path:`/v1/transaction_results/${e.transaction.id}`,method:"GET",body:null}),a=t.response();return a.tag=e.tag,a.transactionStatus={blockId:o.block_id,status:td[o.status.toUpperCase()]||"",statusString:o.status.toUpperCase(),statusCode:o.status_code,errorMessage:o.error_message,events:o.events.map(s=>({type:s.type,transactionId:s.transaction_id,transactionIndex:Number(s.transaction_index),eventIndex:Number(s.event_index),payload:JSON.parse(t.Buffer.from(s.payload,"base64").toString())}))},a}async function rd(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Ping Error: opts.node must be defined."),h(t.response,"SDK Send Ping Error: context.response must be defined."),await(n.httpRequest||z)({hostname:n.node,path:"/v1/blocks?height=sealed",method:"GET",body:null});let o=t.response();return o.tag=e.tag,o}var od=e=>`${withPrefix(e.addr)}-${e.keyId}`;async function ad(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Transaction Error: opts.node must be defined."),h(t.response,"SDK Send Transaction Error: context.response must be defined."),h(t.Buffer,"SDK Send Transaction Error: context.Buffer must be defined.");let r=n.httpRequest||z;e=await e;let o=[];for(let l of Object.values(e.accounts))try{!l.role.payer&&l.signature!=null&&o.push({address:B(l.addr),key_index:String(l.keyId),signature:t.Buffer.from(l.signature,"hex").toString("base64")})}catch(d){throw console.error("SDK HTTP Send Error: Trouble applying payload signature",{acct:l,ix:e}),d}let a={};for(let l of Object.values(e.accounts))try{if(l.role.payer&&l.signature!=null){let d=l.tempId||od(l);a[d]=a[d]||{address:B(l.addr),key_index:String(l.keyId),signature:t.Buffer.from(l.signature,"hex").toString("base64")}}}catch(d){throw console.error("SDK HTTP Send Error: Trouble applying envelope signature",{acct:l,ix:e}),d}a=Object.values(a);var s=Date.now();let i=await r({hostname:n.node,path:"/v1/transactions",method:"POST",body:{script:t.Buffer.from(e.message.cadence).toString("base64"),arguments:[...e.message.arguments.map(l=>t.Buffer.from(JSON.stringify(e.arguments[l].asArgument)).toString("base64"))],reference_block_id:e.message.refBlock?e.message.refBlock:null,gas_limit:String(e.message.computeLimit),payer:B(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),proposal_key:{address:B(e.accounts[e.proposer].addr),key_index:String(e.accounts[e.proposer].keyId),sequence_number:String(e.accounts[e.proposer].sequenceNum)},authorizers:e.authorizations.map(l=>e.accounts[l].addr).reduce((l,d)=>l.find(p=>p===d)?l:[...l,d],[]).map(B),payload_signatures:o,envelope_signatures:a}});var c=Date.now();let u=t.response();return u.tag=e.tag,u.transactionId=i.id,typeof window<"u"&&typeof CustomEvent<"u"&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:u.transactionId,delta:c-s}})),u}async function sd(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(n.node,"SDK Send Get Network Parameters Error: opts.node must be defined."),h(t.response,"SDK Send Get Network Parameters Error: context.response must be defined.");let r=n.httpRequest||z;e=await e;let o=await r({hostname:n.node,path:"/v1/network/parameters",method:"GET",body:null}),a=t.response();return a.tag=e.tag,a.networkParameters={chainId:o.chain_id},a}var fn=async function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};switch(h(n.node,'SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.'),h(t.ix,"SDK Send Error: context.ix must be defined."),e=await e,!0){case t.ix.isTransaction(e):return n.sendTransaction?n.sendTransaction(e,t,n):ad(e,t,n);case t.ix.isGetTransactionStatus(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,t,n):nd(e,t,n);case t.ix.isGetTransaction(e):return n.sendGetTransaction?n.sendGetTransaction(e,t,n):ed(e,t,n);case t.ix.isScript(e):return n.sendExecuteScript?n.sendExecuteScript(e,t,n):Ul(e,t,n);case t.ix.isGetAccount(e):return n.sendGetAccount?n.sendGetAccount(e,t,n):jl(e,t,n);case t.ix.isGetEvents(e):return n.sendGetEvents?n.sendGetEvents(e,t,n):Ql(e,t,n);case t.ix.isGetBlock(e):return n.sendGetBlock?n.sendGetBlock(e,t,n):Vl(e,t,n);case t.ix.isGetBlockHeader(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,t,n):xl(e,t,n);case t.ix.isGetCollection(e):return n.sendGetCollection?n.sendGetCollection(e,t,n):Jl(e,t,n);case t.ix.isPing(e):return n.sendPing?n.sendPing(e,t,n):rd(e,t,n);case t.ix.isGetNetworkParameters(e):return n.sendGetNetworkParameters?n.sendGetNetworkParameters(e,t,n):sd(e,t,n);default:return e}};var If=_e(gs());var zd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var ms,xd=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:zd):e=>(ms||(ms=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),Kd=()=>{let e=[];var t;return{async deliver(n){e.push(n),t&&(t(e.shift()),t=void 0)},receive(){return new Promise(function(r){let o=e.shift();if(o)return r(o);t=r})}}},hs="INIT",Rr="SUBSCRIBE",Tn="UNSUBSCRIBE",Yd="UPDATED",Wd="EXIT",ys="TERMINATE",T=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||typeof window=="object"&&window.window===window&&window;T.FCL_REGISTRY=T.FCL_REGISTRY==null?{}:T.FCL_REGISTRY;var Vd=0,Jd=5e3,x=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return new Promise((o,a)=>{let s=r.expectReply||!1,i=r.timeout!=null?r.timeout:Jd;s&&i&&setTimeout(()=>a(new Error(`Timeout: ${i}ms passed without a response.`)),i);let c={to:e,from:r.from,tag:t,data:n,timeout:i,reply:o,reject:a};try{T.FCL_REGISTRY[e]&&T.FCL_REGISTRY[e].mailbox.deliver(c),s||o(!0)}catch(u){console.error("FCL.Actor -- Could Not Deliver Message",c,T.FCL_REGISTRY[e],u)}})},Xd=e=>{delete T.FCL_REGISTRY[e]},Zd=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return async t=>{typeof e[hs]=="function"&&await e[hs](t);e:for(;;){let n=await t.receive();try{if(n.tag===Wd){typeof e[ys]=="function"&&await e[ys](t,n,n.data||{});break e}await e[n.tag](t,n,n.data||{})}catch(r){console.error(`${t.self()} Error`,n,r)}finally{continue e}}}},jt=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(t==null&&(t=++Vd),T.FCL_REGISTRY[t]!=null)return t;T.FCL_REGISTRY[t]={addr:t,mailbox:Kd(),subs:new Set,kvs:{},error:null};let n={self:()=>t,receive:()=>T.FCL_REGISTRY[t].mailbox.receive(),send:function(r,o,a){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return s.from=t,x(r,o,a,s)},sendSelf:(r,o,a)=>{T.FCL_REGISTRY[t]&&x(t,r,o,a)},broadcast:function(r,o){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};a.from=t;for(let s of T.FCL_REGISTRY[t].subs)x(s,r,o,a)},subscribe:r=>r!=null&&T.FCL_REGISTRY[t].subs.add(r),unsubscribe:r=>r!=null&&T.FCL_REGISTRY[t].subs.delete(r),subscriberCount:()=>T.FCL_REGISTRY[t].subs.size,hasSubs:()=>!!T.FCL_REGISTRY[t].subs.size,put:(r,o)=>{r!=null&&(T.FCL_REGISTRY[t].kvs[r]=o)},get:(r,o)=>{let a=T.FCL_REGISTRY[t].kvs[r];return a??o},delete:r=>{delete T.FCL_REGISTRY[t].kvs[r]},update:(r,o)=>{r!=null&&(T.FCL_REGISTRY[t].kvs[r]=o(T.FCL_REGISTRY[t].kvs[r]))},keys:()=>Object.keys(T.FCL_REGISTRY[t].kvs),all:()=>T.FCL_REGISTRY[t].kvs,where:r=>Object.keys(T.FCL_REGISTRY[t].kvs).reduce((o,a)=>r.test(a)?{...o,[a]:T.FCL_REGISTRY[t].kvs[a]}:o,{}),merge:function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.keys(r).forEach(o=>T.FCL_REGISTRY[t].kvs[o]=r[o])},fatalError:r=>{T.FCL_REGISTRY[t].error=r;for(let o of T.FCL_REGISTRY[t].subs)x(o,Yd)}};return typeof e=="object"&&(e=Zd(e)),xd(async()=>{await e(n),Xd(t)}),t};function ks(e,t,n){t(e);let r="@EXIT",o=jt(async a=>{for(a.send(e,Rr);;){let s=await a.receive(),i=T.FCL_REGISTRY[e].error;if(s.tag===r){a.send(e,Tn);return}if(i){n(null,i),a.send(e,Tn);return}n(s.data,null)}});return()=>x(o,r)}function ws(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
75
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
76
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
`,a,`
|
|
81
|
-
|
|
82
|
-
`,...r,`
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
`),a}}var Es=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>a(o),r)},Qd=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>({...o,...a(r)}),{})},Rn=e=>e&&typeof e=="object"&&!Array.isArray(e),vr=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!n.length)return e;let o=n.shift();if(Rn(e)&&Rn(o))for(let a in o)Rn(o[a])?(e[a]||Object.assign(e,{[a]:{}}),vr(e[a],o[a])):Object.assign(e,{[a]:o[a]});return vr(e,...n)},ef=e=>Array.isArray(e)?vr({},...e):e,tf=e=>e.contracts?e.contracts:{},nf=e=>t=>Object.entries(t).reduce((n,r)=>{let[o,a]=r,s=a?.aliases?.[e];return s&&(n[o]=s),n},{}),rf=e=>t=>{let{deployments:n={},accounts:r={}}=t,o=n?.[e];return o?Object.entries(o).reduce((a,s)=>{let[i,c]=s,u=r[i]?.address;return u?c.reduce((l,d)=>({...l,[d]:u}),{}):a},{}):{}},of=(e,t)=>Es(ef,Qd(rf(t),Es(tf,nf(t))))(e),af=e=>typeof e!="string"?!1:/^[0-9A-Fa-f]+$/.test(e),bs=e=>Object.entries(e?.accounts).reduce((t,n)=>{let[r,o]=n;return t?!0:o?.hasOwnProperty("key")&&af(o?.key)},!1),sf=e=>Rn(e)?bs(e):e.some(bs),uf=e=>e?.toLowerCase()==="local"?"emulator":e?.toLowerCase(),Te="config",Ts="PUT_CONFIG",Cs="GET_CONFIG",Ps="GET_ALL_CONFIG",Ns="UPDATE_CONFIG",Fs="DELETE_CONFIG",_s="CLEAR_CONFIG",Bs="WHERE_CONFIG",Lt="CONFIG/UPDATED",Os=e=>e,Ds={[Ts]:(e,t,n)=>{let{key:r,value:o}=n;if(r==null)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast(Lt,{...e.all()})},[Cs]:(e,t,n)=>{let{key:r,fallback:o}=n;if(r==null)throw new Error("Missing 'key' for config/get");t.reply(e.get(r,o))},[Ps]:(e,t)=>{t.reply({...e.all()})},[Ns]:(e,t,n)=>{let{key:r,fn:o}=n;if(r==null)throw new Error("Missing 'key' for config/update");e.update(r,o||Os),e.broadcast(Lt,{...e.all()})},[Fs]:(e,t,n)=>{let{key:r}=n;if(r==null)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(Lt,{...e.all()})},[_s]:(e,t)=>{let n=Object.keys(e.all());for(let r of n)e.delete(r);e.broadcast(Lt,{...e.all()})},[Bs]:(e,t,n)=>{let{pattern:r}=n;if(r==null)throw new Error("Missing 'pattern' for config/where");t.reply(e.where(r))},[Rr]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Lt,{...e.all()})},[Tn]:(e,t)=>{e.unsubscribe(t.from)}};jt(Ds,Te);function Gt(e,t){return x(Te,Ts,{key:e,value:t}),ee()}function pt(e,t){return x(Te,Cs,{key:e,fallback:t},{expectReply:!0,timeout:10})}async function kr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!e.length)return t;let[n,...r]=e,o=await pt(n);return o??kr(r,t)}function Cn(){return x(Te,Ps,null,{expectReply:!0,timeout:10})}function Us(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Os;return x(Te,Ns,{key:e,fn:t}),ee()}function Ls(e){return x(Te,Fs,{key:e}),ee()}function $s(e){return x(Te,Bs,{pattern:e},{expectReply:!0,timeout:10})}function Gs(e){return ks(Te,()=>jt(Ds,Te),e)}function cf(){return x(Te,_s)}function Ss(e){return cf().then(ee(e))}async function Ms(e){let t=await pt("flow.network"),n=uf(t),{flowJSON:r}=e;if(ws(!!r,"config.load -- 'flowJSON' must be defined"),ws(n,'Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl'),sf(r)){let o=n==="emulator";if(Me({title:"Private Keys Detected",message:"Private keys should be stored in a separate flow.json file for security. See more here: https://developers.flow.com/tools/flow-cli/security",level:o?ae.warn:ae.error}),!o)return}for(let[o,a]of Object.entries(of(r,n))){let s=`0x${o}`,i=await pt(s);i&&i!==a?Me({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:ae.warn}):Gt(s,a);let c=`system.contracts.${o}`,u=await pt(c);u&&u!==a?Me({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:ae.warn}):Gt(c,a)}}function ee(e){return e!=null&&typeof e=="object"&&Object.keys(e).map(t=>Gt(t,e[t])),{put:Gt,get:pt,all:Cn,first:kr,update:Us,delete:Ls,where:$s,subscribe:Gs,overload:js,load:Ms}}ee.put=Gt;ee.get=pt;ee.all=Cn;ee.first=kr;ee.update=Us;ee.delete=Ls;ee.where=$s;ee.subscribe=Gs;ee.overload=js;ee.load=Ms;var lf=e=>e;function js(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:lf;return new Promise(async(n,r)=>{let o=await Cn();try{ee(e);var a=await t(await Cn());await Ss(o),n(a)}catch(s){await Ss(o),r(s)}})}var ae=Object.freeze({debug:5,info:4,log:3,warn:2,error:1}),df=e=>{let{title:t,message:n}=e;return[`
|
|
87
|
-
%c${t}
|
|
88
|
-
============================
|
|
89
|
-
|
|
90
|
-
${n}
|
|
91
|
-
|
|
92
|
-
============================
|
|
93
|
-
`.replace(/\n[^\S\r\n]+/g,`
|
|
94
|
-
`).trim(),,"font-weight:bold;font-family:monospace;"]},Me=async e=>{let{title:t,message:n,level:r,always:o=!1}=e,a=await ee.get("logger.level",ae.warn);if(!o&&a<r)return;let s=df({title:t,message:n});switch(r){case ae.debug:console.debug(...s);break;case ae.info:console.info(...s);break;case ae.warn:console.warn(...s);break;case ae.error:console.error(...s);break;default:console.log(...s)}};Me.deprecate=e=>{let{pkg:t,subject:n,transition:r,level:o=ae.warn,message:a="",callback:s=null}=e,i=u=>u.charAt(0).toUpperCase()+u.slice(1),c=()=>Me({title:`${t?t+" ":""}Deprecation Notice`,message:`
|
|
95
|
-
${n?`${i(n)} is deprecated and will cease to work in future releases${t?" of "+t:""}.`:""}${a?`
|
|
96
|
-
`+a:""}${r?`
|
|
97
|
-
You can learn more (including a guide on common transition paths) here: ${r}`:""}
|
|
98
|
-
`.trim(),level:o});return typeof s=="function"?async function(){return await c(),await s(...arguments)}:c()};function vs(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
99
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
100
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
`,a,`
|
|
105
|
-
|
|
106
|
-
`,...r,`
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
`),a}}var As=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>a(o),r)},ff=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>({...o,...a(r)}),{})},kn=e=>e&&typeof e=="object"&&!Array.isArray(e),Ar=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!n.length)return e;let o=n.shift();if(kn(e)&&kn(o))for(let a in o)kn(o[a])?(e[a]||Object.assign(e,{[a]:{}}),Ar(e[a],o[a])):Object.assign(e,{[a]:o[a]});return Ar(e,...n)},pf=e=>Array.isArray(e)?Ar({},...e):e,gf=e=>e.contracts?e.contracts:{},mf=e=>t=>Object.entries(t).reduce((n,r)=>{let[o,a]=r,s=a?.aliases?.[e];return s&&(n[o]=s),n},{}),hf=e=>t=>{let{deployments:n={},accounts:r={}}=t,o=n?.[e];return o?Object.entries(o).reduce((a,s)=>{let[i,c]=s,u=r[i]?.address;return u?c.reduce((l,d)=>({...l,[d]:u}),{}):a},{}):{}},yf=(e,t)=>As(pf,ff(hf(t),As(gf,mf(t))))(e),wf=e=>typeof e!="string"?!1:/^[0-9A-Fa-f]+$/.test(e),Is=e=>Object.entries(e?.accounts).reduce((t,n)=>{let[r,o]=n;return t?!0:o?.hasOwnProperty("key")&&wf(o?.key)},!1),Ef=e=>kn(e)?Is(e):e.some(Is),bf=e=>e?.toLowerCase()==="local"?"emulator":e?.toLowerCase(),Ce="config",Hs="PUT_CONFIG",qs="GET_CONFIG",zs="GET_ALL_CONFIG",xs="UPDATE_CONFIG",Ks="DELETE_CONFIG",Ys="CLEAR_CONFIG",Ws="WHERE_CONFIG",$t="CONFIG/UPDATED",Vs=e=>e,Js={[Hs]:(e,t,n)=>{let{key:r,value:o}=n;if(r==null)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast($t,{...e.all()})},[qs]:(e,t,n)=>{let{key:r,fallback:o}=n;if(r==null)throw new Error("Missing 'key' for config/get");t.reply(e.get(r,o))},[zs]:(e,t)=>{t.reply({...e.all()})},[xs]:(e,t,n)=>{let{key:r,fn:o}=n;if(r==null)throw new Error("Missing 'key' for config/update");e.update(r,o||Vs),e.broadcast($t,{...e.all()})},[Ks]:(e,t,n)=>{let{key:r}=n;if(r==null)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast($t,{...e.all()})},[Ys]:(e,t)=>{let n=Object.keys(e.all());for(let r of n)e.delete(r);e.broadcast($t,{...e.all()})},[Ws]:(e,t,n)=>{let{pattern:r}=n;if(r==null)throw new Error("Missing 'pattern' for config/where");t.reply(e.where(r))},[Rr]:(e,t)=>{e.subscribe(t.from),e.send(t.from,$t,{...e.all()})},[Tn]:(e,t)=>{e.unsubscribe(t.from)}};jt(Js,Ce);function Mt(e,t){return x(Ce,Hs,{key:e,value:t}),te()}function gt(e,t){return x(Ce,qs,{key:e,fallback:t},{expectReply:!0,timeout:10})}async function Tr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!e.length)return t;let[n,...r]=e,o=await gt(n);return o??Tr(r,t)}function Pn(){return x(Ce,zs,null,{expectReply:!0,timeout:10})}function Xs(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Vs;return x(Ce,xs,{key:e,fn:t}),te()}function Zs(e){return x(Ce,Ks,{key:e}),te()}function Qs(e){return x(Ce,Ws,{pattern:e},{expectReply:!0,timeout:10})}function ei(e){return ks(Ce,()=>jt(Js,Ce),e)}function Sf(){return x(Ce,Ys)}function Rs(e){return Sf().then(te(e))}async function ti(e){let t=await gt("flow.network"),n=bf(t),{flowJSON:r}=e;if(vs(!!r,"config.load -- 'flowJSON' must be defined"),vs(n,'Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl'),Ef(r)){let o=n==="emulator";if(Me({title:"Private Keys Detected",message:"Private keys should be stored in a separate flow.json file for security. See more here: https://developers.flow.com/tools/flow-cli/security",level:o?ae.warn:ae.error}),!o)return}for(let[o,a]of Object.entries(yf(r,n))){let s=`0x${o}`,i=await gt(s);i&&i!==a?Me({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:ae.warn}):Mt(s,a);let c=`system.contracts.${o}`,u=await gt(c);u&&u!==a?Me({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:ae.warn}):Mt(c,a)}}function te(e){return e!=null&&typeof e=="object"&&Object.keys(e).map(t=>Mt(t,e[t])),{put:Mt,get:gt,all:Pn,first:Tr,update:Xs,delete:Zs,where:Qs,subscribe:ei,overload:ni,load:ti}}te.put=Mt;te.get=gt;te.all=Pn;te.first=Tr;te.update=Xs;te.delete=Zs;te.where=Qs;te.subscribe=ei;te.overload=ni;te.load=ti;var vf=e=>e;function ni(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vf;return new Promise(async(n,r)=>{let o=await Pn();try{te(e);var a=await t(await Pn());await Rs(o),n(a)}catch(s){await Rs(o),r(s)}})}var ft=Object.freeze({debug:5,info:4,log:3,warn:2,error:1}),Af=e=>{let{title:t,message:n}=e;return[`
|
|
111
|
-
%c${t}
|
|
112
|
-
============================
|
|
113
|
-
|
|
114
|
-
${n}
|
|
115
|
-
|
|
116
|
-
============================
|
|
117
|
-
`.replace(/\n[^\S\r\n]+/g,`
|
|
118
|
-
`).trim(),,"font-weight:bold;font-family:monospace;"]},Ir=async e=>{let{title:t,message:n,level:r,always:o=!1}=e,a=await te.get("logger.level",ft.warn);if(!o&&a<r)return;let s=Af({title:t,message:n});switch(r){case ft.debug:console.debug(...s);break;case ft.info:console.info(...s);break;case ft.warn:console.warn(...s);break;case ft.error:console.error(...s);break;default:console.log(...s)}};Ir.deprecate=e=>{let{pkg:t,subject:n,transition:r,level:o=ft.warn,message:a="",callback:s=null}=e,i=u=>u.charAt(0).toUpperCase()+u.slice(1),c=()=>Ir({title:`${t?t+" ":""}Deprecation Notice`,message:`
|
|
119
|
-
${n?`${i(n)} is deprecated and will cease to work in future releases${t?" of "+t:""}.`:""}${a?`
|
|
120
|
-
`+a:""}${r?`
|
|
121
|
-
You can learn more (including a guide on common transition paths) here: ${r}`:""}
|
|
122
|
-
`.trim(),level:o});return typeof s=="function"?async function(){return await c(),await s(...arguments)}:c()};function ri(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(!e.length&&!t.length||!e.length)return n;if(!t.length)return[...n,e[0]];let[r,...o]=e,[a,...s]=t;return r!==void 0&&n.push(r),a!==void 0&&n.push(a),ri(o,s,n)}function oi(e){return function(t){return typeof t=="function"?(Ir.deprecate({pkg:"FCL/SDK",subject:"Interopolation of functions into template literals",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"}),oi(e)(t(e))):String(t)}}function mt(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return typeof e=="string"?()=>e:Array.isArray(e)?o=>ri(e,n.map(oi(o))).join("").trim():e}var On="UNKNOWN",Br="SCRIPT",Or="TRANSACTION",Dr="GET_TRANSACTION_STATUS",Ur="GET_ACCOUNT",Lr="GET_EVENTS",$r="PING",Gr="GET_TRANSACTION",Mr="GET_BLOCK",jr="GET_BLOCK_HEADER",Hr="GET_COLLECTION",qr="GET_NETWORK_PARAMETERS",zr="BAD",Dn="OK",xr="ACCOUNT",mi="PARAM",Kr="ARGUMENT",hi="authorizer",yi="payer",Rf="proposer",kf=`{
|
|
123
|
-
"kind":"${xr}",
|
|
124
|
-
"tempId":null,
|
|
125
|
-
"addr":null,
|
|
126
|
-
"keyId":null,
|
|
127
|
-
"sequenceNum":null,
|
|
128
|
-
"signature":null,
|
|
129
|
-
"signingFunction":null,
|
|
130
|
-
"resolve":null,
|
|
131
|
-
"role": {
|
|
132
|
-
"proposer":false,
|
|
133
|
-
"authorizer":false,
|
|
134
|
-
"payer":false,
|
|
135
|
-
"param":false
|
|
136
|
-
}
|
|
137
|
-
}`,Tf=`{
|
|
138
|
-
"kind":"${Kr}",
|
|
139
|
-
"tempId":null,
|
|
140
|
-
"value":null,
|
|
141
|
-
"asArgument":null,
|
|
142
|
-
"xform":null,
|
|
143
|
-
"resolve": null,
|
|
144
|
-
"resolveArgument": null
|
|
145
|
-
}`,wi=`{
|
|
146
|
-
"tag":"${On}",
|
|
147
|
-
"assigns":{},
|
|
148
|
-
"status":"${Dn}",
|
|
149
|
-
"reason":null,
|
|
150
|
-
"accounts":{},
|
|
151
|
-
"params":{},
|
|
152
|
-
"arguments":{},
|
|
153
|
-
"message": {
|
|
154
|
-
"cadence":null,
|
|
155
|
-
"refBlock":null,
|
|
156
|
-
"computeLimit":null,
|
|
157
|
-
"proposer":null,
|
|
158
|
-
"payer":null,
|
|
159
|
-
"authorizations":[],
|
|
160
|
-
"params":[],
|
|
161
|
-
"arguments":[]
|
|
162
|
-
},
|
|
163
|
-
"proposer":null,
|
|
164
|
-
"authorizations":[],
|
|
165
|
-
"payer":[],
|
|
166
|
-
"events": {
|
|
167
|
-
"eventType":null,
|
|
168
|
-
"start":null,
|
|
169
|
-
"end":null,
|
|
170
|
-
"blockIds":[]
|
|
171
|
-
},
|
|
172
|
-
"transaction": {
|
|
173
|
-
"id":null
|
|
174
|
-
},
|
|
175
|
-
"block": {
|
|
176
|
-
"id":null,
|
|
177
|
-
"height":null,
|
|
178
|
-
"isSealed":null
|
|
179
|
-
},
|
|
180
|
-
"account": {
|
|
181
|
-
"addr":null
|
|
182
|
-
},
|
|
183
|
-
"collection": {
|
|
184
|
-
"id":null
|
|
185
|
-
}
|
|
186
|
-
}`,Ei=new Set(Object.keys(JSON.parse(wi))),Un=()=>JSON.parse(wi),ai="abcdefghijklmnopqrstuvwxyz0123456789".split(""),Cf=()=>ai[~~(Math.random()*ai.length)],Yr=()=>Array.from({length:10},Cf).join(""),bi=e=>typeof e=="number",Si=e=>Array.isArray(e),vi=e=>e!==null&&typeof e=="object",Wr=e=>e==null,Et=e=>typeof e=="function",Ai=e=>{if(!vi(e)||Wr(e)||bi(e))return!1;for(let t of Ei)if(!e.hasOwnProperty(t))return!1;return!0},se=e=>(e.status=Dn,e),Vr=(e,t)=>(e.status=zr,e.reason=t,e),fe=e=>t=>(t.tag=e,se(t)),si=e=>e.keyId==null?e:(h(!isNaN(parseInt(e.keyId)),"account.keyId must be an integer"),{...e,keyId:parseInt(e.keyId)}),Pf=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n=>{h(typeof e=="function"||typeof e=="object","prepAccount must be passed an authorization function or an account object"),h(t.role!=null,"Account must have a role");let r=JSON.parse(kf),o=t.role,a=Yr();e.authorization&&Et(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&Et(e)&&(e={resolve:e});let s=e.resolve;return s&&(e.resolve=function(i){for(var c=arguments.length,u=new Array(c>1?c-1:0),l=1;l<c;l++)u[l-1]=arguments[l];return[s,si].reduce(async(d,p)=>p(await d,...u),i)}),e=si(e),n.accounts[a]={...r,tempId:a,...e,role:{...r.role,...typeof e.role=="object"?e.role:{},[o]:!0}},o===hi?n.authorizations.push(a):o===yi?n.payer.push(a):n[o]=a,n}},Ii=e=>t=>{let n=Yr();return t.message.arguments.push(n),t.arguments[n]=JSON.parse(Tf),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,t.arguments[n].resolveArgument=Et(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,se(t)},Nf=fe(On),Ri=fe(Br),Ff=fe(Or),ki=fe(Dr),_f=fe(Gr),Ti=fe(Ur),Ci=fe(Lr),Bf=fe($r),Pi=fe(Mr),Of=fe(jr),Df=fe(Hr),Ni=fe(qr),pe=e=>t=>t.tag===e,Uf=pe(On),Jr=pe(Br),je=pe(Or),Lf=pe(Dr),$f=pe(Gr),Fi=pe(Ur),Gf=pe(Lr),Mf=pe($r),jf=pe(Mr),Hf=pe(jr),qf=pe(Hr),zf=pe(qr),_i=e=>e.status===Dn,Xr=e=>e.status===zr,Bi=e=>e.reason,xf=e=>e.kind===xr,Kf=e=>e.kind===mi,Yf=e=>e.kind===Kr,Wf=e=>{for(let t of Object.keys(e))if(!Ei.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e},Fn=async function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{if(e=Wf(await e),Xr(e))throw new Error(`Interaction Error: ${e.reason}`);if(!t.length)return e;let[n,...r]=t,o=await n;if(Et(o))return Fn(o(e),r);if(Wr(o)||!o)return Fn(e,r);if(Ai(o))return Fn(o,r);throw new Error("Invalid Interaction Composition")}catch(n){throw n}},Z=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];let[r,o]=t;return Si(r)&&o==null?a=>Z(a,r):Fn(r,o)},Vf=e=>e,Ln=(e,t,n)=>e.assigns[t]==null?n:e.assigns[t],Oi=(e,t)=>n=>(n.assigns[e]=t,se(n)),Di=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Vf;return n=>(n.assigns[e]=t(n.assigns[e],n),se(n))},Jf=e=>t=>(delete t.assigns[e],se(t)),Zr=Object.freeze({__proto__:null,UNKNOWN:On,SCRIPT:Br,TRANSACTION:Or,GET_TRANSACTION_STATUS:Dr,GET_ACCOUNT:Ur,GET_EVENTS:Lr,PING:$r,GET_TRANSACTION:Gr,GET_BLOCK:Mr,GET_BLOCK_HEADER:jr,GET_COLLECTION:Hr,GET_NETWORK_PARAMETERS:qr,BAD:zr,OK:Dn,ACCOUNT:xr,PARAM:mi,ARGUMENT:Kr,AUTHORIZER:hi,PAYER:yi,PROPOSER:Rf,interaction:Un,uuid:Yr,isNumber:bi,isArray:Si,isObj:vi,isNull:Wr,isFn:Et,isInteraction:Ai,Ok:se,Bad:Vr,prepAccount:Pf,makeArgument:Ii,makeUnknown:Nf,makeScript:Ri,makeTransaction:Ff,makeGetTransactionStatus:ki,makeGetTransaction:_f,makeGetAccount:Ti,makeGetEvents:Ci,makePing:Bf,makeGetBlock:Pi,makeGetBlockHeader:Of,makeGetCollection:Df,makeGetNetworkParameters:Ni,isUnknown:Uf,isScript:Jr,isTransaction:je,isGetTransactionStatus:Lf,isGetTransaction:$f,isGetAccount:Fi,isGetEvents:Gf,isPing:Mf,isGetBlock:jf,isGetBlockHeader:Hf,isGetCollection:qf,isGetNetworkParameters:zf,isOk:_i,isBad:Xr,why:Bi,isAccount:xf,isParam:Kf,isArgument:Yf,pipe:Z,get:Ln,put:Oi,update:Di,destroy:Jf});function Qr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return Z(Un(),e)}var Xf=`{
|
|
187
|
-
"tag":null,
|
|
188
|
-
"transaction":null,
|
|
189
|
-
"transactionStatus":null,
|
|
190
|
-
"transactionId":null,
|
|
191
|
-
"encodedData":null,
|
|
192
|
-
"events":null,
|
|
193
|
-
"account":null,
|
|
194
|
-
"block":null,
|
|
195
|
-
"blockHeader":null,
|
|
196
|
-
"latestBlock":null,
|
|
197
|
-
"collection":null,
|
|
198
|
-
"networkParameters":null
|
|
199
|
-
}`,eo=()=>JSON.parse(Xf);function Ht(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return Z([Pi,t=>(t.block.isSealed=e,se(t))])}function yt(e){return Z([Ti,t=>(t.account.addr=B(e),se(t))])}var Zf=()=>{$.deprecate({pkg:"@onflow/decode",subject:"Operating upon data of the latestBlock field of the response object",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field"})},O=async e=>e,Qf=async()=>null,ep=async e=>e.staticType,tp=async e=>({domain:e.domain,identifier:e.identifier}),np=async e=>({path:e.path,address:e.address,borrowType:e.borrowType}),rp=async(e,t,n)=>e?await bt(e,t,n):null,op=async e=>({address:e.address,type:e.type}),ap=async(e,t,n)=>await Promise.all(e.map(r=>new Promise(async o=>o(await bt(r,t,[...n,r.type]))))),sp=async(e,t,n)=>await e.reduce(async(r,o)=>(r=await r,r[await bt(o.key,t,[...n,o.key])]=await bt(o.value,t,[...n,o.key]),r),Promise.resolve({})),Nn=async(e,t,n)=>{let r=await e.fields.reduce(async(a,s)=>(a=await a,a[s.name]=await bt(s.value,t,[...n,s.name]),a),Promise.resolve({})),o=e.id&&Ui(t,e.id);return o?await o(r):r},ii={UInt:O,Int:O,UInt8:O,Int8:O,UInt16:O,Int16:O,UInt32:O,Int32:O,UInt64:O,Int64:O,UInt128:O,Int128:O,UInt256:O,Int256:O,Word8:O,Word16:O,Word32:O,Word64:O,UFix64:O,Fix64:O,String:O,Character:O,Bool:O,Address:O,Void:Qf,Optional:rp,Reference:op,Array:ap,Dictionary:sp,Event:Nn,Resource:Nn,Struct:Nn,Enum:Nn,Type:ep,Path:tp,Capability:np},Ui=(e,t)=>{let n=Object.keys(e).find(r=>/^\/.*\/$/.test(r)?new RegExp(r.substring(1,r.length-1)).test(t):r===t);return t&&n&&e[n]},bt=async(e,t,n)=>{let r=Ui(t,e.type);if(!r)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await r(e.value,t,n)},Cr=async function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],o={...Object.keys(ii).filter(a=>!Object.keys(t).find(s=>new RegExp(s).test(a))).reduce((a,s)=>(a[s]=ii[s],a),t),...t};return bt(e,o,n)},Oe=async function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.encodedData?Cr(e.encodedData,t):e.transactionStatus?{...e.transactionStatus,events:await Promise.all(e.transactionStatus.events.map(async function(r){return{type:r.type,transactionId:r.transactionId,transactionIndex:r.transactionIndex,eventIndex:r.eventIndex,data:await Cr(r.payload,t)}}))}:e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(r){return{blockId:r.blockId,blockHeight:r.blockHeight,blockTimestamp:r.blockTimestamp,type:r.type,transactionId:r.transactionId,transactionIndex:r.transactionIndex,eventIndex:r.eventIndex,data:await Cr(r.payload,t)}})):e.account?e.account:e.block?e.block:e.blockHeader?e.blockHeader:e.latestBlock?(Zf(),e.latestBlock):e.transactionId?e.transactionId:e.collection?e.collection:e.networkParameters?{chainId:{"flow-testnet":"testnet","flow-mainnet":"mainnet","flow-emulator":"local"}[e.networkParameters.chainId]}:null},ui=e=>typeof e=="function",ci=e=>typeof e=="string",ip=()=>/\b(0x\w+)\b/g;function li(e){return ip().test(e)}var Li=()=>/import\s+"(\w+)"/g;function di(e){return Li().test(e)}function up(e){return e.matchAll(Li())}async function cp(e){if(!je(e)&&!Jr(e))return e;var t=Ln(e,"ix.cadence");if(h(ui(t)||ci(t),"Cadence needs to be a function or a string."),ui(t)&&(t=await t({})),h(ci(t),"Cadence needs to be a string at this point."),h(!li(t)||!di(t),"Both account identifier and contract identifier syntax not simultaneously supported."),li(t)&&(t=await w().where(/^0x/).then(n=>Object.entries(n).reduce((r,o)=>{let[a,s]=o,i=new RegExp("(\\b"+a+"\\b)","g");return r.replace(i,s)},t))),di(t))for(let[n,r]of up(t)){let o=await w().get(`system.contracts.${r}`);o?t=t.replace(n,`import ${r} from ${q(o)}`):$({title:"Contract Placeholder not found",message:`Cannot find a value for contract placeholder ${r}. Please add to your flow.json or explicitly add it to the config 'contracts.*' namespace.`,level:Y.warn})}return e.message.cadence=t,e}var Nr=e=>typeof e=="function";function lp(e){if(h(typeof e.xform!=null,`No type specified for argument: ${e.value}`),Nr(e.xform))return e.xform(e.value);if(Nr(e.xform.asArgument))return e.xform.asArgument(e.value);h(!1,"Invalid Argument",e)}async function $i(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3;if(h(t>0,`Argument Resolve Recursion Limit Exceeded for Arg: ${e.tempId}`),Nr(e.resolveArgument)){let n=await e.resolveArgument();return $i(n,t-1)}else return e}async function dp(e){if(je(e)||Jr(e))for(let[t,n]of Object.entries(e.arguments)){let r=await $i(n);e.arguments[t].asArgument=lp(r)}return e}var fp=e=>Mi(ji(Hi(e))),pp=e=>Mi(ji(bp(e)));var gp=(e,t)=>le.Buffer.from(e.padEnd(t*2,0),"hex"),Gi=(e,t)=>le.Buffer.from(e.padStart(t*2,0),"hex"),mp=gp(le.Buffer.from("FLOW-V0.0-transaction").toString("hex"),32).toString("hex"),Mi=e=>mp+e,Pr=e=>Gi(e,8),hp=e=>Gi(e,32),yp=e=>le.Buffer.from(JSON.stringify(e),"utf8"),wp=e=>le.Buffer.from(e,"utf8"),Ep=e=>le.Buffer.from(e,"hex"),ji=e=>lt(e).toString("hex");var Hi=e=>(Ap(e),[wp(e.cadence),e.arguments.map(yp),hp(e.refBlock),e.computeLimit,Pr(B(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Pr(B(e.payer)),e.authorizers.map(t=>Pr(B(t)))]),bp=e=>(Ip(e),[Hi(e),Sp(e)]),Sp=e=>{let t=vp(e);return e.payloadSigs.map(n=>({signerIndex:t.get(n.address),keyId:n.keyId,sig:n.sig})).sort((n,r)=>{if(n.signerIndex>r.signerIndex)return 1;if(n.signerIndex<r.signerIndex)return-1;if(n.keyId>r.keyId)return 1;if(n.keyId<r.keyId)return-1}).map(n=>[n.signerIndex,n.keyId,Ep(n.sig)])},vp=e=>{let t=new Map,n=0,r=o=>{t.has(o)||(t.set(o,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t};var Ap=e=>{Rp.forEach(t=>Bn(e,t)),kp.forEach(t=>Bn(e.proposalKey,t,"proposalKey"))},Ip=e=>{Tp.forEach(t=>Bn(e,t)),e.payloadSigs.forEach((t,n)=>{Cp.forEach(r=>Bn(t,r,"payloadSigs",n))})};var _n=e=>typeof e=="number",wt=e=>typeof e=="string",qi=e=>e!==null&&typeof e=="object",Fr=e=>qi(e)&&e instanceof Array,Rp=[{name:"cadence",check:wt},{name:"arguments",check:Fr},{name:"refBlock",check:wt,defaultVal:"0"},{name:"computeLimit",check:_n},{name:"proposalKey",check:qi},{name:"payer",check:wt},{name:"authorizers",check:Fr}],kp=[{name:"address",check:wt},{name:"keyId",check:_n},{name:"sequenceNum",check:_n}],Tp=[{name:"payloadSigs",check:Fr}],Cp=[{name:"address",check:wt},{name:"keyId",check:_n},{name:"sig",check:wt}];var Bn=(e,t,n,r)=>{let{name:o,check:a,defaultVal:s}=t;if(e[o]==null&&s!=null&&(e[o]=s),e[o]==null)throw Pp(o,n,r);if(!a(e[o]))throw Np(o,n,r)},zi=(e,t,n)=>t?n==null?`${t}.${e}`:`${t}.${n}.${e}`:e,Pp=(e,t,n)=>new Error(`Missing field ${zi(e,t,n)}`),Np=(e,t,n)=>new Error(`Invalid field ${zi(e,t,n)}`);function xi(e){let t=new Set(e.authorizations);return t.add(e.proposer),Array.isArray(e.payer)?e.payer.forEach(n=>t.delete(n)):t.delete(e.payer),Array.from(t)}function Ki(e){let t=new Set(Array.isArray(e.payer)?e.payer:[e.payer]);return Array.from(t)}var qt=e=>{let t=()=>{let o=e.authorizations.map(a=>q(e.accounts[a].addr)).reduce((a,s)=>a.find(i=>i===s)?a:[...a,s],[]);return o[0]?o:[]},n=()=>xi(e).map(o=>({address:q(e.accounts[o].addr),keyId:e.accounts[o].keyId,sig:e.accounts[o].signature})),r=()=>Ki(e).map(o=>({address:q(e.accounts[o].addr),keyId:e.accounts[o].keyId,sig:e.accounts[o].signature}));return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(o=>e.arguments[o].asArgument),proposalKey:{address:q(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:q(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),authorizers:t(),payloadSigs:n(),envelopeSigs:r()}};var fi=e=>`${q(e.addr)}-${e.keyId}`,Fp=e=>typeof e=="function";function _p(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(n=>t.arguments[n].asArgument),data:{},interaction:t,voucher:qt(t)}}catch(n){throw console.error("buildPreSignable",n),n}}async function _r(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:3;h(r,"Account Resolve Recursion Limit Exceeded",{ix:e,accounts:t});let o=[];for(let s of t){let i=s.resolve;s.resolve=null;var a=n||s;if(Fp(i)&&(s=await i(s,_p(s,e))),Array.isArray(s))await _r(e,s,a,r-1);else{if(s.addr&&(s.addr=B(s.addr)),s.addr!=null&&s.keyId!=null&&(s.tempId=fi(s)),e.accounts[s.tempId]=e.accounts[s.tempId]||s,e.accounts[s.tempId].role.proposer=e.accounts[s.tempId].role.proposer||s.role.proposer,e.accounts[s.tempId].role.payer=e.accounts[s.tempId].role.payer||s.role.payer,e.accounts[s.tempId].role.authorizer=e.accounts[s.tempId].role.authorizer||s.role.authorizer,e.accounts[s.tempId].role.proposer&&e.proposer===a.tempId&&(e.proposer=s.tempId),e.accounts[s.tempId].role.payer&&(Array.isArray(e.payer)?e.payer=Array.from(new Set([...e.payer,s.tempId].map(c=>c===a.tempId?s.tempId:c))):e.payer=Array.from(new Set([e.payer,s.tempId].map(c=>c===a.tempId?s.tempId:c))),e.payer.length>1)){let c=[],u=[];if(e.payer=e.payer.reduce((d,p)=>{let{addr:m}=e.accounts[p],E=fi(e.accounts[p]);return u.push(m),c.includes(E)?d:(c.push(E),[...d,p])},[]),Array.from(new Set(u)).length>1)throw new Error("Payer can not be different accounts")}e.accounts[s.tempId].role.authorizer&&(n?o=Array.from(new Set([...o,s.tempId])):e.authorizations=e.authorizations.map(c=>c===a.tempId?s.tempId:c))}a.tempId!=s.tempId&&delete e.accounts[a.tempId]}n&&(e.authorizations=e.authorizations.map(s=>s===n.tempId?o:s).reduce((s,i)=>Array.isArray(i)?[...s,...i]:[...s,i],[]))}async function Bp(e){if(je(e)){Array.isArray(e.payer)||$.deprecate({pkg:"FCL",subject:'"ix.payer" must be an array. Support for ix.payer as a singular',message:"See changelog for more info."});try{await _r(e,Object.values(e.accounts)),await _r(e,Object.values(e.accounts))}catch(t){throw console.error(`=== SAD PANDA ===
|
|
200
|
-
|
|
201
|
-
`,t,`
|
|
202
|
-
|
|
203
|
-
=== SAD PANDA ===`),t}}return e}async function Op(e){if(je(e))try{let t=xi(e),n=fp(gi(e));await Promise.all(t.map(pi(e,n)));let r=Ki(e),o=pp({...gi(e),payloadSigs:t.map(a=>({address:e.accounts[a].addr,keyId:e.accounts[a].keyId,sig:e.accounts[a].signature}))});await Promise.all(r.map(pi(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}return e}function pi(e,t){return async function(r){let o=e.accounts[r];if(o.signature!=null)return;let{signature:a}=await o.signingFunction(Dp(o,t,e));e.accounts[r].signature=a}}function Dp(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:B(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(r=>n.arguments[r].asArgument),data:{},interaction:n,voucher:qt(n)}}catch(r){throw console.error("buildSignable",r),r}}function gi(e){let t=B((Array.isArray(e.payer)?e.accounts[e.payer[0]]:e.accounts[e.payer]).addr);return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>e.arguments[n].asArgument),proposalKey:{address:B(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t,authorizers:e.authorizations.map(n=>B(e.accounts[n].addr)).reduce((n,r)=>n.find(o=>o===r)?n:[...n,r],[])}}async function Up(e){let t=Ln(e,"ix.validators",[]);return Z(e,t.map(n=>r=>n(r,{Ok:se,Bad:Vr})))}async function Lp(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=B(e.accounts[t].addr);return e}async function $p(e){let t=Ln(e,"ix.voucher-intercept");return Et(t)&&await t(qt(e)),e}var Gp=100;async function Mp(e){return je(e)&&(e.message.computeLimit=e.message.computeLimit||await w.get("fcl.limit"),e.message.computeLimit||($.deprecate({pkg:"FCL/SDK",subject:"The built-in default compute limit (DEFAULT_COMPUTE_LIMIT=10)",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0009-deprecate-default-compute-limit"}),e.message.computeLimit=Gp)),e}var jp=e=>e,ht=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jp;return async n=>{let r=a=>[`
|
|
204
|
-
Accounts:`,{proposer:a.proposer,authorizations:a.authorizations,payer:a.payer},`
|
|
205
|
-
|
|
206
|
-
Details:`,a.accounts].filter(Boolean),o=function(){for(var a=arguments.length,s=new Array(a),i=0;i<a;i++)s[i]=arguments[i];console.log(`debug[${e}] ---
|
|
207
|
-
`,...s,`
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
---`)};return await w.get(`debug.${e}`)&&await t(n,o,r),n}},Yi=Z([cp,ht("cadence",(e,t)=>t(e.message.cadence)),Mp,ht("compute limit",(e,t)=>t(e.message.computeLimit)),dp,ht("arguments",(e,t)=>t(e.message.arguments,e.message)),Bp,ht("accounts",(e,t,n)=>t(...n(e))),Hp,qp,Op,ht("signatures",(e,t,n)=>t(...n(e))),Lp,Up,$p,ht("resolved",(e,t)=>t(e))]);async function Hp(e){if(je(e)&&e.message.refBlock==null){let t=await w().get("accessNode.api"),n=await w.first(["sdk.transport","sdk.send"],fn);h(n,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),e.message.refBlock=(await n(Qr([Ht()]),{config:w,response:eo,Buffer:le.Buffer,ix:Zr},{node:t}).then(Oe)).id}return e}async function qp(e){if(je(e)){var t=Object.values(e.accounts).find(n=>n.role.proposer);if(h(t,"Transactions require a proposer"),t.sequenceNum==null){let n=await w().get("accessNode.api"),r=await w.first(["sdk.transport","sdk.send"],fn);h(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),e.accounts[t.tempId].sequenceNum=await r(await Qr([yt(t.addr)]),{config:w,response:eo,Buffer:le.Buffer,ix:Zr},{node:n}).then(Oe).then(o=>o.keys).then(o=>o.find(a=>a.index===t.keyId)).then(o=>o.sequenceNumber)}}return e}function ge(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(t.length>1){let[o,a]=t;return ge((s,i)=>{let{Ok:c,Bad:u}=i;return o?c(s):u(s,a)})}let[r]=t;return o=>r(o,{Ok:se,Bad:Vr})}var ue=async function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=await w.first(["sdk.transport","sdk.send"],t.send||fn);ge(n,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21");let r=await w.first(["sdk.resolve"],t.resolve||Yi);return t.node=t.node||await w().get("accessNode.api"),Array.isArray(e)&&(e=Z(Un(),e)),n(await r(e),{config:w,response:eo,ix:Zr,Buffer:le.Buffer},t)};async function Ye(e){let t=await w().where(/^decoder\./),n=Object.entries(t).map(r=>{let[o,a]=r;return o=`/${o.replace(/^decoder\./,"")}$/`,[o,a]});return Oe(e,Object.fromEntries(n))}function to(e){return Di("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function $n(e){return Z([t=>(t.block.height=e,t),to(t=>{if(typeof t.block.isSealed=="boolean")throw new Error("Unable to specify both block height and isSealed.");if(t.block.id)throw new Error("Unable to specify both block height and block id.");return t})])}function no(e){return Z([t=>(t.block.id=e,se(t)),to((t,n)=>{let{Ok:r,Bad:o}=n;return Fi(t)?o(t,"Unable to specify a block id with a Get Account interaction."):typeof t.block.isSealed=="boolean"?o(t,"Unable to specify both block id and isSealed."):t.block.height?o(t,"Unable to specify both block id and block height."):r(t)})])}function ro(e){let{height:t,id:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return h(!(n&&t),'Method: account -- Cannot pass "id" and "height" simultaneously'),n?ue([yt(e),no(n)],r).then(Oe):t?ue([yt(e),$n(t)],r).then(Oe):ue([yt(e)],r).then(Oe)}function Gn(){let{sealed:e=!1,id:t,height:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return h(!(e&&t||e&&n),'Method: block -- Cannot pass "sealed" with "id" or "height"'),h(!(t&&n),'Method: block -- Cannot pass "id" and "height" simultaneously'),t?ue([Ht(),no(t)],r).then(Oe):n?ue([Ht(),$n(n)],r).then(Oe):ue([Ht(e)],r).then(Oe)}function oo(e,t,n){return Z([Ci,r=>(r.events.eventType=e,r.events.start=t,r.events.end=n,se(r))])}function ao(e){return Z([ki,t=>(t.transaction.id=e,se(t))])}function so(){return Z([Ni,e=>se(e)])}function io(e){return t=>(t.message.computeLimit=e,t)}function uo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return Z(e.map(Ii))}function zt(e,t){return{value:e,xform:t}}function co(){return Z([Ri,Oi("ix.cadence",mt(...arguments))])}var ho={};No(ho,{Address:()=>mo,Array:()=>jg,Bool:()=>Lg,Character:()=>Ug,Dictionary:()=>Hg,Enum:()=>Kg,Event:()=>qg,Fix64:()=>Og,Identity:()=>gg,Int:()=>hg,Int128:()=>kg,Int16:()=>bg,Int256:()=>Cg,Int32:()=>vg,Int64:()=>Ig,Int8:()=>wg,Optional:()=>Gg,Path:()=>Yg,Reference:()=>Mg,Resource:()=>zg,String:()=>Dg,Struct:()=>xg,UFix64:()=>Bg,UInt:()=>mg,UInt128:()=>Rg,UInt16:()=>Eg,UInt256:()=>Tg,UInt32:()=>Sg,UInt64:()=>Ag,UInt8:()=>yg,Void:()=>$g,Word16:()=>Ng,Word32:()=>Fg,Word64:()=>_g,Word8:()=>Pg,_Array:()=>jg});var xp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Wi,Kp=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:xp):e=>(Wi||(Wi=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),Yp=()=>{let e=[];var t;return{async deliver(n){e.push(n),t&&(t(e.shift()),t=void 0)},receive(){return new Promise(function(r){let o=e.shift();if(o)return r(o);t=r})}}},Vi="INIT",tu="SUBSCRIBE",lo="UNSUBSCRIBE",Wp="UPDATED",Vp="EXIT",Ji="TERMINATE",C=typeof self=="object"&&self.self===self&&self||typeof global=="object"&&global.global===global&&global||typeof window=="object"&&window.window===window&&window;C.FCL_REGISTRY=C.FCL_REGISTRY==null?{}:C.FCL_REGISTRY;var Jp=0,Xp=5e3,me=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return new Promise((o,a)=>{let s=r.expectReply||!1,i=r.timeout!=null?r.timeout:Xp;s&&i&&setTimeout(()=>a(new Error(`Timeout: ${i}ms passed without a response.`)),i);let c={to:e,from:r.from,tag:t,data:n,timeout:i,reply:o,reject:a};try{C.FCL_REGISTRY[e]&&C.FCL_REGISTRY[e].mailbox.deliver(c),s||o(!0)}catch(u){console.error("FCL.Actor -- Could Not Deliver Message",c,C.FCL_REGISTRY[e],u)}})},Zp=e=>{delete C.FCL_REGISTRY[e]},Qp=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return async t=>{typeof e[Vi]=="function"&&await e[Vi](t);e:for(;;){let n=await t.receive();try{if(n.tag===Vp){typeof e[Ji]=="function"&&await e[Ji](t,n,n.data||{});break e}await e[n.tag](t,n,n.data||{})}catch(r){console.error(`${t.self()} Error`,n,r)}finally{continue e}}}},po=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(t==null&&(t=++Jp),C.FCL_REGISTRY[t]!=null)return t;C.FCL_REGISTRY[t]={addr:t,mailbox:Yp(),subs:new Set,kvs:{},error:null};let n={self:()=>t,receive:()=>C.FCL_REGISTRY[t].mailbox.receive(),send:function(r,o,a){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return s.from=t,me(r,o,a,s)},sendSelf:(r,o,a)=>{C.FCL_REGISTRY[t]&&me(t,r,o,a)},broadcast:function(r,o){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};a.from=t;for(let s of C.FCL_REGISTRY[t].subs)me(s,r,o,a)},subscribe:r=>r!=null&&C.FCL_REGISTRY[t].subs.add(r),unsubscribe:r=>r!=null&&C.FCL_REGISTRY[t].subs.delete(r),subscriberCount:()=>C.FCL_REGISTRY[t].subs.size,hasSubs:()=>!!C.FCL_REGISTRY[t].subs.size,put:(r,o)=>{r!=null&&(C.FCL_REGISTRY[t].kvs[r]=o)},get:(r,o)=>{let a=C.FCL_REGISTRY[t].kvs[r];return a??o},delete:r=>{delete C.FCL_REGISTRY[t].kvs[r]},update:(r,o)=>{r!=null&&(C.FCL_REGISTRY[t].kvs[r]=o(C.FCL_REGISTRY[t].kvs[r]))},keys:()=>Object.keys(C.FCL_REGISTRY[t].kvs),all:()=>C.FCL_REGISTRY[t].kvs,where:r=>Object.keys(C.FCL_REGISTRY[t].kvs).reduce((o,a)=>r.test(a)?{...o,[a]:C.FCL_REGISTRY[t].kvs[a]}:o,{}),merge:function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.keys(r).forEach(o=>C.FCL_REGISTRY[t].kvs[o]=r[o])},fatalError:r=>{C.FCL_REGISTRY[t].error=r;for(let o of C.FCL_REGISTRY[t].subs)me(o,Wp)}};return typeof e=="object"&&(e=Qp(e)),Kp(async()=>{await e(n),Zp(t)}),t};function eg(e,t,n){t(e);let r="@EXIT",o=po(async a=>{for(a.send(e,tu);;){let s=await a.receive(),i=C.FCL_REGISTRY[e].error;if(s.tag===r){a.send(e,lo);return}if(i){n(null,i),a.send(e,lo);return}n(s.data,null)}});return()=>me(o,r)}function Xi(e,t){if(!e){let a=new Error(`INVARIANT ${t}`);a.stack=a.stack.split(`
|
|
211
|
-
`).filter(s=>!/at invariant/.test(s)).join(`
|
|
212
|
-
`);for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];throw console.error(`
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
`,a,`
|
|
217
|
-
|
|
218
|
-
`,...r,`
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
`),a}}var Zi=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>a(o),r)},tg=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r=>t.reduce((o,a)=>({...o,...a(r)}),{})},Mn=e=>e&&typeof e=="object"&&!Array.isArray(e),fo=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(!n.length)return e;let o=n.shift();if(Mn(e)&&Mn(o))for(let a in o)Mn(o[a])?(e[a]||Object.assign(e,{[a]:{}}),fo(e[a],o[a])):Object.assign(e,{[a]:o[a]});return fo(e,...n)},ng=e=>Array.isArray(e)?fo({},...e):e,rg=e=>e.contracts?e.contracts:{},og=e=>t=>Object.entries(t).reduce((n,r)=>{let[o,a]=r,s=a?.aliases?.[e];return s&&(n[o]=s),n},{}),ag=e=>t=>{let{deployments:n={},accounts:r={}}=t,o=n?.[e];return o?Object.entries(o).reduce((a,s)=>{let[i,c]=s,u=r[i]?.address;return u?c.reduce((l,d)=>({...l,[d]:u}),{}):a},{}):{}},sg=(e,t)=>Zi(ng,tg(ag(t),Zi(rg,og(t))))(e),ig=e=>typeof e!="string"?!1:/^[0-9A-Fa-f]+$/.test(e),Qi=e=>Object.entries(e?.accounts).reduce((t,n)=>{let[r,o]=n;return t?!0:o?.hasOwnProperty("key")&&ig(o?.key)},!1),ug=e=>Mn(e)?Qi(e):e.some(Qi),cg=e=>e?.toLowerCase()==="local"?"emulator":e?.toLowerCase(),Ne="config",nu="PUT_CONFIG",ru="GET_CONFIG",ou="GET_ALL_CONFIG",au="UPDATE_CONFIG",su="DELETE_CONFIG",iu="CLEAR_CONFIG",uu="WHERE_CONFIG",xt="CONFIG/UPDATED",cu=e=>e,lu={[nu]:(e,t,n)=>{let{key:r,value:o}=n;if(r==null)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast(xt,{...e.all()})},[ru]:(e,t,n)=>{let{key:r,fallback:o}=n;if(r==null)throw new Error("Missing 'key' for config/get");t.reply(e.get(r,o))},[ou]:(e,t)=>{t.reply({...e.all()})},[au]:(e,t,n)=>{let{key:r,fn:o}=n;if(r==null)throw new Error("Missing 'key' for config/update");e.update(r,o||cu),e.broadcast(xt,{...e.all()})},[su]:(e,t,n)=>{let{key:r}=n;if(r==null)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(xt,{...e.all()})},[iu]:(e,t)=>{let n=Object.keys(e.all());for(let r of n)e.delete(r);e.broadcast(xt,{...e.all()})},[uu]:(e,t,n)=>{let{pattern:r}=n;if(r==null)throw new Error("Missing 'pattern' for config/where");t.reply(e.where(r))},[tu]:(e,t)=>{e.subscribe(t.from),e.send(t.from,xt,{...e.all()})},[lo]:(e,t)=>{e.unsubscribe(t.from)}};po(lu,Ne);function Kt(e,t){return me(Ne,nu,{key:e,value:t}),ne()}function St(e,t){return me(Ne,ru,{key:e,fallback:t},{expectReply:!0,timeout:10})}async function go(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(!e.length)return t;let[n,...r]=e,o=await St(n);return o??go(r,t)}function jn(){return me(Ne,ou,null,{expectReply:!0,timeout:10})}function du(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:cu;return me(Ne,au,{key:e,fn:t}),ne()}function fu(e){return me(Ne,su,{key:e}),ne()}function pu(e){return me(Ne,uu,{pattern:e},{expectReply:!0,timeout:10})}function gu(e){return eg(Ne,()=>po(lu,Ne),e)}function lg(){return me(Ne,iu)}function eu(e){return lg().then(ne(e))}async function mu(e){let t=await St("flow.network"),n=cg(t),{flowJSON:r}=e;if(Xi(!!r,"config.load -- 'flowJSON' must be defined"),Xi(n,'Flow Network Required -- In order for FCL to load your contracts please define "flow.network" to "emulator", "local", "testnet", or "mainnet" in your config. See more here: https://developers.flow.com/tools/fcl-js/reference/configure-fcl'),ug(r)){let o=n==="emulator";if(We({title:"Private Keys Detected",message:"Private keys should be stored in a separate flow.json file for security. See more here: https://developers.flow.com/tools/flow-cli/security",level:o?Pe.warn:Pe.error}),!o)return}for(let[o,a]of Object.entries(sg(r,n))){let s=`0x${o}`,i=await St(s);i&&i!==a?We({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:Pe.warn}):Kt(s,a);let c=`system.contracts.${o}`,u=await St(c);u&&u!==a?We({title:"Contract Placeholder Conflict Detected",message:"A generated contract placeholder from config.load conflicts with a placeholder you've set manually in config have the same name.",level:Pe.warn}):Kt(c,a)}}function ne(e){return e!=null&&typeof e=="object"&&Object.keys(e).map(t=>Kt(t,e[t])),{put:Kt,get:St,all:jn,first:go,update:du,delete:fu,where:pu,subscribe:gu,overload:hu,load:mu}}ne.put=Kt;ne.get=St;ne.all=jn;ne.first=go;ne.update=du;ne.delete=fu;ne.where=pu;ne.subscribe=gu;ne.overload=hu;ne.load=mu;var dg=e=>e;function hu(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:dg;return new Promise(async(n,r)=>{let o=await jn();try{ne(e);var a=await t(await jn());await eu(o),n(a)}catch(s){await eu(o),r(s)}})}var Pe=Object.freeze({debug:5,info:4,log:3,warn:2,error:1}),fg=e=>{let{title:t,message:n}=e;return[`
|
|
223
|
-
%c${t}
|
|
224
|
-
============================
|
|
225
|
-
|
|
226
|
-
${n}
|
|
227
|
-
|
|
228
|
-
============================
|
|
229
|
-
`.replace(/\n[^\S\r\n]+/g,`
|
|
230
|
-
`).trim(),,"font-weight:bold;font-family:monospace;"]},We=async e=>{let{title:t,message:n,level:r,always:o=!1}=e,a=await ne.get("logger.level",Pe.warn);if(!o&&a<r)return;let s=fg({title:t,message:n});switch(r){case Pe.debug:console.debug(...s);break;case Pe.info:console.info(...s);break;case Pe.warn:console.warn(...s);break;case Pe.error:console.error(...s);break;default:console.log(...s)}};We.deprecate=e=>{let{pkg:t,subject:n,transition:r,level:o=Pe.warn,message:a="",callback:s=null}=e,i=u=>u.charAt(0).toUpperCase()+u.slice(1),c=()=>We({title:`${t?t+" ":""}Deprecation Notice`,message:`
|
|
231
|
-
${n?`${i(n)} is deprecated and will cease to work in future releases${t?" of "+t:""}.`:""}${a?`
|
|
232
|
-
`+a:""}${r?`
|
|
233
|
-
You can learn more (including a guide on common transition paths) here: ${r}`:""}
|
|
234
|
-
`.trim(),level:o});return typeof s=="function"?async function(){return await c(),await s(...arguments)}:c()};var v=(e,t,n)=>({label:e,asArgument:t,asInjection:n}),Ve=e=>Array.isArray(e),Je=e=>typeof e=="object",yu=e=>e==null,pg=e=>typeof e=="boolean",j=e=>typeof e=="number",V=e=>Number.isInteger(e),_=e=>typeof e=="string",b=e=>{throw new Error("Type Error: "+e)},J=e=>{We.deprecate({pkg:"@onflow/types",subject:`Passing in Number as value for ${e}`,message:`Going forward, use String as value for ${e}.`,transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/types/WARNINGS.md#0002-[U]Int*-and-Word*-as-Number"})},gg=v("Identity",e=>e,e=>e),mg=v("UInt",e=>{if(j(e)&&V(e))return J("UInt"),{type:"UInt",value:e.toString()};if(_(e))return{type:"UInt",value:e};b("Expected Positive Integer for type Unsigned Int")},e=>e),hg=v("Int",e=>{if(j(e)&&V(e))return J("Int"),{type:"Int",value:e.toString()};if(_(e))return{type:"Int",value:e};b("Expected Integer for type Int")},e=>e),yg=v("UInt8",e=>{if(j(e)&&V(e))return J("UInt8"),{type:"UInt8",value:e.toString()};if(_(e))return{type:"UInt8",value:e};b("Expected integer for UInt8")},e=>e),wg=v("Int8",e=>{if(j(e)&&V(e))return J("Int8"),{type:"Int8",value:e.toString()};if(_(e))return{type:"Int8",value:e};b("Expected positive integer for Int8")},e=>e),Eg=v("UInt16",e=>{if(j(e)&&V(e))return J("UInt16"),{type:"UInt16",value:e.toString()};if(_(e))return{type:"UInt16",value:e};b("Expected integer for UInt16")},e=>e),bg=v("Int16",e=>{if(j(e)&&V(e))return J("Int16"),{type:"Int16",value:e.toString()};if(_(e))return{type:"Int16",value:e};b("Expected positive integer for Int16")},e=>e),Sg=v("UInt32",e=>{if(j(e)&&V(e))return J("UInt32"),{type:"UInt32",value:e.toString()};if(_(e))return{type:"UInt32",value:e};b("Expected integer for UInt32")},e=>e),vg=v("Int32",e=>{if(j(e)&&V(e))return J("Int32"),{type:"Int32",value:e.toString()};if(_(e))return{type:"Int32",value:e};b("Expected positive integer for Int32")},e=>e),Ag=v("UInt64",e=>{if(j(e)&&V(e))return J("UInt64"),{type:"UInt64",value:e.toString()};if(_(e))return{type:"UInt64",value:e};b("Expected integer for UInt64")},e=>e),Ig=v("Int64",e=>{if(j(e)&&V(e))return J("Int64"),{type:"Int64",value:e.toString()};if(_(e))return{type:"Int64",value:e};b("Expected positive integer for Int64")},e=>e),Rg=v("UInt128",e=>{if(j(e)&&V(e))return J("UInt128"),{type:"UInt128",value:e.toString()};if(_(e))return{type:"UInt128",value:e};b("Expected integer for UInt128")},e=>e),kg=v("Int128",e=>{if(j(e)&&V(e))return J("Int128"),{type:"Int128",value:e.toString()};if(_(e))return{type:"Int128",value:e};b("Expected positive integer for Int128")},e=>e),Tg=v("UInt256",e=>{if(j(e)&&V(e))return J("UInt256"),{type:"UInt256",value:e.toString()};if(_(e))return{type:"UInt256",value:e};b("Expected integer for UInt256")},e=>e),Cg=v("Int256",e=>{if(j(e)&&V(e))return J("Int256"),{type:"Int256",value:e.toString()};if(_(e))return{type:"Int256",value:e};b("Expected integer for Int256")},e=>e),Pg=v("Word8",e=>{if(j(e)&&V(e))return J("Word8"),{type:"Word8",value:e.toString()};if(_(e))return{type:"Word8",value:e};b("Expected positive number for Word8")},e=>e),Ng=v("Word16",e=>{if(j(e)&&V(e))return J("Word16"),{type:"Word16",value:e.toString()};if(_(e))return{type:"Word16",value:e};b("Expected positive number for Word16")},e=>e),Fg=v("Word32",e=>{if(j(e)&&V(e))return J("Word32"),{type:"Word32",value:e.toString()};if(_(e))return{type:"Word32",value:e};b("Expected positive number for Word32")},e=>e),_g=v("Word64",e=>{if(j(e)&&V(e))return J("Word64"),{type:"Word64",value:e.toString()};if(_(e))return{type:"Word64",value:e};b("Expected positive number for Word64")},e=>e),wu=()=>{We.deprecate({subject:"Passing in Numbers as values for Fix64 and UFix64 types",pkg:"@onflow/types",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/types/WARNINGS.md#0001-[U]Fix64-as-Number"})},Bg=v("UFix64",e=>{if(_(e)){let t=e.split(".");return t.length!==2&&b(`Expected one decimal but found ${t.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers`),(t[1].length==0||t[1].length>8)&&b(`Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${t[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers`),t[1]=t[1].padEnd(8,"0"),e=t.join("."),{type:"UFix64",value:e}}else if(j(e))return wu(),{type:"UFix64",value:e.toString()};b("Expected String for UFix64")},e=>e),Og=v("Fix64",e=>{if(_(e)){let t=e.split(".");return t.length!==2&&b(`Expected one decimal but found ${t.length} in the [U]Fix64 value. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers`),(t[1].length==0||t[1].length>8)&&b(`Expected at least one digit, and at most 8 digits following the decimal of the [U]Fix64 value but found ${t[1].length} digits. Find out more about [U]Fix64 types here: https://docs.onflow.org/cadence/json-cadence-spec/#fixed-point-numbers`),t[1]=t[1].padEnd(8,"0"),e=t.join("."),{type:"Fix64",value:e}}else if(j(e))return wu(),{type:"Fix64",value:e.toString()};b("Expected String for Fix64")},e=>e),Dg=v("String",e=>{if(_(e))return{type:"String",value:e};b("Expected String for type String")},e=>e),Ug=v("Character",e=>{if(_(e))return{type:"Character",value:e};b("Expected Character for type Character")},e=>e),Lg=v("Bool",e=>{if(pg(e))return{type:"Bool",value:e};b("Expected Boolean for type Bool")},e=>e),mo=v("Address",e=>{if(_(e))return{type:"Address",value:e};b("Expected Address for type Address")},e=>e),$g=v("Void",e=>{if(!e||yu(e))return{type:"Void"};b("Expected Void for type Void")},e=>e),Gg=e=>v("Optional",t=>({type:"Optional",value:yu(t)?null:e.asArgument(t)}),t=>t),Mg=v("Reference",e=>{if(Je(e))return{type:"Reference",value:e};b("Expected Object for type Reference")},e=>e),jg=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v("Array",t=>({type:"Array",value:Ve(e)?e.map((n,r)=>n.asArgument(t[r])):t.map(n=>e.asArgument(n))}),t=>t)},Hg=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return v("Dictionary",t=>{if(Je(t))return{type:"Dictionary",value:Ve(e)?e.map((n,r)=>({key:n.key.asArgument(t[r].key),value:n.value.asArgument(t[r].value)})):Ve(t)?t.map(n=>({key:e.key.asArgument(n.key),value:e.value.asArgument(n.value)})):[{key:e.key.asArgument(t.key),value:e.value.asArgument(t.value)}]};b("Expected Object for type Dictionary")},t=>t)},qg=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return v("Event",n=>{if(Je(n))return{type:"Event",value:{id:e,fields:Ve(t)?t.map((r,o)=>({name:n.fields[o].name,value:r.value.asArgument(n.fields[o].value)})):n.fields.map(r=>({name:r.name,value:t.value.asArgument(r.value)}))}};b("Expected Object for type Event")},n=>n)},zg=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return v("Resource",n=>{if(Je(n))return{type:"Resource",value:{id:e,fields:Ve(t)?t.map((r,o)=>({name:n.fields[o].name,value:r.value.asArgument(n.fields[o].value)})):n.fields.map(r=>({name:r.name,value:t.value.asArgument(r.value)}))}};b("Expected Object for type Resource")},n=>n)},xg=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return v("Struct",n=>{if(Je(n))return{type:"Struct",value:{id:e,fields:Ve(t)?t.map((r,o)=>({name:n.fields[o].name,value:r.value.asArgument(n.fields[o].value)})):n.fields.map(r=>({name:r.name,value:t.value.asArgument(r.value)}))}};b("Expected Object for type Struct")},n=>n)},Kg=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return v("Enum",n=>{if(Je(n))return{type:"Enum",value:{id:e,fields:Ve(t)?t.map((r,o)=>({name:n.fields[o].name,value:r.value.asArgument(n.fields[o].value)})):n.fields.map(r=>({name:r.name,value:t.value.asArgument(r.value)}))}};b("Expected Object for type Enum")},n=>n)},Yg=v("Path",e=>{if(Je(e))return _(e.domain)||b(`Expected a string for the Path domain but found ${e.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path`),e.domain==="storage"||e.domain==="private"||e.domain==="public"||b(`Expected either "storage", "private" or "public" as the Path domain but found ${e.domain}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path`),_(e.identifier)||b(`Expected a string for the Path identifier but found ${e.identifier}. Find out more about the Path type here: https://docs.onflow.org/cadence/json-cadence-spec/#path`),{type:"Path",value:{domain:e.domain,identifier:e.identifier}};b("Expected Object for type Path")},e=>e);var Nu=_e(gr());var Eu="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",Wg=Eu.length;function Hn(){for(var e="",t=32;t--;)e+=Eu[Math.random()*Wg|0];return e}var ko=_e(Ke());async function Qg(){return(await ue([so()]).then(Ye)).chainId}async function Fu(){let e=await Qg();return w.put("flow.network.default",e),e}async function Wt(){let e=await w.get("flow.network.default");return e||(e=await Fu(),e||(e=await w.get("flow.network"),e?$.deprecate({pkg:"FCL",subject:'Using the "flow.network" configuration key for specifying the flow network',message:"Configuring flow.network is no longer required",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/TRANSITIONS.md#0002-deprecate-flow.network-config-key"}):(e=await w.get("env"),e&&$.deprecate({pkg:"FCL",subject:'Using the "env" configuration key for specifying the flow network',message:"Configuring to specify flow network is no longer required",transition:"https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/TRANSITIONS.md#0001-deprecate-env-config-key"})))),h(e,"Error getting chainId from access node. Please configure flow.network instead"),e}function em(){return w.subscribe(function(t){let n=t?.["accessNode.api"];this.prevAccessNode!==n&&Fu(),this.prevAccessNode=n}.bind({}))}function tm(){return typeof navigator<"u"&&/android/i.test(navigator.userAgent)}function nm(){return typeof navigator<"u"&&/iPhone|iPod/.test(navigator.userAgent)}function rm(){return typeof navigator<"u"&&/iPad/.test(navigator.userAgent)}function om(){return nm()||rm()}function am(){return tm()||om()}var sm=()=>typeof window>"u",im={can:!sm(),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,t)=>sessionStorage.setItem(e,JSON.stringify(t))};w({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":im});em();async function bu(e){return Object.fromEntries(Object.entries(await w().where(e)).map(t=>{let[n,r]=t;return[n.replace(e,""),r]}))}var Fe="1.4.1",Yn=e=>t=>typeof t===e,De=e=>e!=null,um=Yn("object"),kt=Yn("string"),_u=Yn("function"),jy=Yn("number");function cm(e){return _u(e)?e(zt,ho):[]}async function Su(e){let{url:t}=e;h(typeof t<"u","retrieve({ url }) -- url must be defined");let n;try{n=await(0,Nu.default)(t)}catch{throw new Error("httpDocumentResolver Error: Failed to retrieve document.")}return n.ok?await n.json():null}var vu=new Map([["http",Su],["https",Su]]);async function lm(e){let{url:t}=e;h(typeof t<"u","retrieve({ url }) -- url must be defined"),h(typeof t=="string","retrieve({ url }) -- url must be a string");let n=await w().where(/^document\.resolver\./);Object.keys(n).map(i=>{let c=n[i],u=i.replace(/^document\.resolver\./,"");vu.set(u,c)});let r=/^(.*):\/\/([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$/.exec(t);h(r,"Failed to parse URL");let o=r[1];h(r,"Failed to parse URL protocol");let a=vu.get(o);return h(a,`No resolver found for protcol=${o}`),await a({url:t})}function Bu(e){if(e==null)return null;switch(e.f_version){case"1.0.0":return e;default:throw new Error("normalizeInteractionTemplate Error: Invalid InteractionTemplate")}}function dm(e){let{network:t,template:n}=e;switch(ge(t!=null,"deriveCadenceByNetwork({ network }) -- network must be defined"),ge(typeof t=="string","deriveCadenceByNetwork({ network }) -- network must be a string"),ge(n!=null,"generateDependencyPin({ template }) -- template must be defined"),ge(typeof n=="object","generateDependencyPin({ template }) -- template must be an object"),ge(n.f_type==="InteractionTemplate","generateDependencyPin({ template }) -- template must be an InteractionTemplate"),n=Bu(n),n.f_version){case"1.0.0":return Object.keys(n?.data?.dependencies).map(o=>{let a=Object.values(n?.data?.dependencies?.[o]);ge(a,`deriveCadenceByNetwork -- Could not find contracts for dependency placeholder: ${o}`),ge(a.length===0,`deriveCadenceByNetwork -- Could not find contracts for dependency placeholder: ${o}`);let i=a[0]?.[t];return ge(i,`deriveCadenceByNetwork -- Could not find ${t} network information for dependency: ${o}`),[o,i.address]}).reduce((o,a)=>{let[s,i]=a,c=new RegExp("(\\b"+s+"\\b)","g");return o.replace(c,i)},n.data.cadence);default:throw new Error("deriveCadenceByNetwork Error: Unsupported template version")}}async function fm(e){let{template:t}=e,n=await Wt();h(n,"FCL configureDependencies Error: Missing configuration value for 'flow.network'");let r={};switch(t.f_version){case"1.0.0":let o=Object.keys(t?.data?.dependencies);for(let a of o){let s=t?.data?.dependencies[a],i=Object.keys(s);h(i.length>0,`FCL configureDependencies Error: No contracts found in template for placeholder=${a}`);let u=s[i[0]][n];h(u,`FCL configureDependencies Error: No dependency information for placeholder=${a} contract=${i[0]} network=${n}`),h(u?.address,`FCL configureDependencies Error: No address information for placeholder=${a} contract=${i[0]} network=${n}`),r[a]=q(u?.address)}return r;default:throw new Error("FCL configureDependencies Error: Unsupported template version")}}async function pm(e){kt(e?.template)&&(e.template=await lm({url:e?.template}));let t={};e?.template&&(e.template=Bu(e?.template),t=await fm({template:e.template}));let n=e.cadence||dm({template:e.template,network:await Wt()});return e.cadence=n,e.dependencies=t,e}async function gm(e,t){h(De(t),`${e}(opts) -- opts is required`),h(um(t),`${e}(opts) -- opts must be an object`),h(!(t.cadence&&t.template),`${e}({ template, cadence }) -- cannot pass both cadence and template`),h(De(t.cadence||t?.template),`${e}({ cadence }) -- cadence is required`),h(kt(t.cadence)||t?.template,`${e}({ cadence }) -- cadence must be a string`),h(t.cadence||await w().get("flow.network"),`${e}(opts) -- Required value for "flow.network" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration`),h(await w().get("accessNode.api"),`${e}(opts) -- Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration`)}async function mm(e){return gm("query",e)}async function hm(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return await mm(e),e=await pm(e),w().overload(e.dependencies||{},async()=>ue([co(e.cadence),uo(cm(e.args||[])),e.limit&&typeof e.limit=="number"&&io(e.limit)]).then(Ye))}async function ym(e,t){if(e==null||t==null)return[];let n=new URL(e);n.searchParams.append("code",t);let r=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(a=>a.json());if(Array.isArray(r))return r;let o=[];if(Array.isArray(r.authorizations))for(let a of r.authorizations)o.push({type:"authz",keyId:r.keyId,...a});return r.provider!=null&&o.push({type:"authn",id:"wallet-provider#authn",...r.provider}),o}function wm(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return[...e,...t]}var Tt={f_type:"Service",f_vsn:"1.0.0"},Ou={f_type:"Identity",f_vsn:"1.0.0"},Em={f_type:"USER",f_vsn:"1.0.0"},bm={f_type:"PollingResponse",f_vsn:"1.0.0"},Sm={f_type:"CompositeSignature",f_vsn:"1.0.0"};function vm(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...Tt,type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:q(e.addr),name:e.name,icon:e.icon}}}}function Am(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...Tt,type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:{...Ou,address:q(e.addr),keyId:e.keyId},params:e.params,data:e.data}}}function Im(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...Tt,type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:{...Ou,address:q(e.addr),keyId:e.keyId},params:e.params,data:e.data}}}function Du(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{old:e,...Tt,type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}}}}function Uu(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...Tt,type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}}}}function Rm(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return null}}function km(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:throw new Error("Invalid user-signature service")}}function Lu(e){if(e==null)return null;switch(e.method==null&&(e={...e,type:"local-view",method:"VIEW/IFRAME"}),e.f_vsn){case"1.0.0":return e;default:return{...Tt,type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}}}function Tm(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:throw new Error("FCL Normalizer Error: Invalid account-proof service")}}function Cm(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:throw new Error("Invalid authn-refresh service")}}var Pm={"back-channel-rpc":Uu,"pre-authz":Im,authz:Am,authn:vm,frame:Du,"open-id":Rm,"user-signature":km,"local-view":Lu,"account-proof":Tm,"authn-refresh":Cm};function Nm(e,t){try{var n=Pm[e.type](e,t);return n}catch(r){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,r),e}}function Fm(e){return lt([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function _m(e){return e.addr=e.addr?q(e.addr):null,e.paddr=e.paddr?q(e.paddr):null,e}function Bm(e,t){return t.find(n=>n.type===e)}async function Au(e){e=_m(e);var t=wm(e.services||[],await ym(e.hks,e.code)).map(r=>Nm(r,e));let n=Bm("authn",t);return{...Em,addr:q(e.addr),cid:Fm(n),loggedIn:!0,services:t,expiresAt:e.expires}}function Kn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;return e.find(n=>n.type===t)}function Vt(e){let t=new URL(e.endpoint);if(window?.location?.origin&&t.searchParams.append("l6n",window.location.origin),e.params!=null)for(let[n,r]of Object.entries(e.params||{}))t.searchParams.append(n,r);return t}function $u(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.method||"POST",r=n==="GET"?void 0:JSON.stringify(t.data||e.data||{});return fetch(Vt(e),{method:n,headers:{...e.headers||{},...t.headers||{},"Content-Type":"application/json"},body:r}).then(o=>o.json())}function Ue(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...bm,status:e.status??"APPROVED",reason:e.reason??null,data:e.compositeSignature||e.data||{...e},updates:Uu(e.authorizationUpdates),local:Du((e.local||[])[0])}}}var Iu={"HTTP/GET":"GET","HTTP/POST":"POST"},Om=e=>(h(Iu[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),Iu[e.method]);async function vo(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:()=>!0;if(h(e,"Missing Polling Service",{service:e}),!t())throw new Error("Externally Halted");let n;try{if(typeof document<"u"&&document.visibilityState==="hidden")return await new Promise(r=>setTimeout(r,500)),vo(e,t);n=await $u(e,{method:Om(e)}).then(Ue)}catch(r){throw r}switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error(`Declined: ${n.reason||"No reason supplied."}`);default:return await new Promise(r=>setTimeout(r,500)),vo(n.updates,t)}}var qn="FCL_IFRAME",Dm=`
|
|
235
|
-
position:fixed;
|
|
236
|
-
top: 0px;
|
|
237
|
-
right: 0px;
|
|
238
|
-
bottom: 0px;
|
|
239
|
-
left: 0px;
|
|
240
|
-
height: 100%;
|
|
241
|
-
width: 100vw;
|
|
242
|
-
display:block;
|
|
243
|
-
background:rgba(0,0,0,0.25);
|
|
244
|
-
z-index: 2147483647;
|
|
245
|
-
box-sizing: border-box;
|
|
246
|
-
color-scheme: light;
|
|
247
|
-
`;function Gu(e){h(!document.getElementById(qn),"Attempt at triggering multiple Frames",{src:e});let t=document.createElement("iframe");t.src=e,t.id=qn,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText=Dm,document.body.append(t);let n=()=>{document.getElementById(qn)&&document.getElementById(qn).remove()};return[t.contentWindow,n]}var Um="FCL_POP",Ee=null,Ru=null;function Lm(e,t,n,r,o){let a=n.top.outerHeight/2+n.top.screenY-o/2,s=n.top.outerWidth/2+n.top.screenX-r/2,i=n.open(e,t,`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${r}, height=${o}, top=${a}, left=${s}`);if(!i)throw new Error("Popup failed to open (was it blocked by a popup blocker?)");return i}function Mu(e){return Ee==null||Ee?.closed?Ee=Lm(e,Um,window,640,770):(Ru!==e&&Ee.location.replace(e),Ee.focus()),Ru=e,[Ee,()=>{Ee&&!Ee.closed&&Ee.close(),Ee=null}]}var he=null,ku=null;function ju(e){if(he==null||he?.closed){if(he=window.open(e,"_blank"),!he)throw new Error("Tab failed to open (was it blocked by the browser?)")}else ku!==e&&he.location.replace(e),he.focus();return ku=e,[he,()=>{he&&!he.closed&&he.close(),he=null}]}var $m={"VIEW/IFRAME":Gu,"VIEW/POP":Mu,"VIEW/TAB":ju};async function Gm(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};try{return $m[e.method](Vt(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}async function Tu(e){let{service:t,body:n,config:r,opts:o}=e,a=await $u(t,{data:{fclVersion:Fe,service:{params:t.params,data:t.data,type:t.type},config:r,...n}}).then(Ue);if(a.status==="APPROVED")return a.data;if(a.status==="DECLINED")throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if(a.status==="REDIRECT")return a;if(a.status==="PENDING"){var s=!0;let[i,c]=await Gm(Lu(a.local)),u=()=>{try{c(),s=!1}catch(l){console.error("Frame Close Error",l)}};return vo(a.updates,()=>s).then(l=>(u(),l)).catch(l=>{throw console.error(l),u(),l})}else throw console.error("Auto Decline: Invalid Response",{service:t,resp:a}),new Error("Auto Decline: Invalid Response")}var zn="FCL:VIEW:CLOSE",yo="FCL:VIEW:READY",wo="FCL:VIEW:RESPONSE",H=e=>typeof e=="string"&&e.toLowerCase(),Mm=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Xe=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),Wn=e=>{let{close:t,send:n,onReady:r,onResponse:o,onMessage:a}=e;return s=>{try{if(typeof s.data!="object"||Mm.has(s.data.type))return;H(s.data.type)===H(zn)&&t(),H(s.data.type)===H(yo)&&r(s,{send:n,close:t}),H(s.data.type)===H(wo)&&o(s,{send:n,close:t}),a(s,{send:n,close:t}),H(s.data.type)===H("FCL:FRAME:READY")&&(Xe(s.data.type,yo),r(s,{send:n,close:t})),H(s.data.type)===H("FCL:FRAME:RESPONSE")&&(Xe(s.data.type,wo),o(s,{send:n,close:t})),H(s.data.type)===H("FCL:FRAME:CLOSE")&&(Xe(s.data.type,zn),t()),H(s.data.type)===H("FCL::CHALLENGE::RESPONSE")&&(Xe(s.data.type,wo),o(s,{send:n,close:t})),H(s.data.type)===H("FCL::AUTHZ_READY")&&(Xe(s.data.type,yo),r(s,{send:n,close:t})),H(s.data.type)===H("FCL::CHALLENGE::CANCEL")&&(Xe(s.data.type,zn),t()),H(s.data.type)===H("FCL::CANCEL")&&(Xe(s.data.type,zn),t())}catch(i){console.error("Frame Callback Error",i),t()}}},vt=()=>{};function jm(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null)return{send:vt,close:vt};let n=t.onClose||vt,r=t.onMessage||vt,o=t.onReady||vt,a=t.onResponse||vt,s=Wn({close:u,send:l,onReady:o,onResponse:a,onMessage:r});window.addEventListener("message",s);let[i,c]=Gu(Vt(e));return{send:l,close:u};function u(){try{window.removeEventListener("message",s),c(),n()}catch(d){console.error("Frame Close Error",d)}}function l(d){try{i.postMessage(JSON.parse(JSON.stringify(d||{})),"*")}catch(p){console.error("Frame Send Error",d,p)}}}function Hm(e){let{service:t,body:n,config:r,opts:o}=e;return new Promise((a,s)=>{let i=Hn(),c=o.includeOlderJsonRpcCall;jm(t,{async onReady(u,l){let{send:d}=l;try{d({type:"FCL:VIEW:READY:RESPONSE",fclVersion:Fe,body:n,service:{params:t.params,data:t.data,type:t.type},config:r}),d({fclVersion:Fe,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&d({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,t.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(p){throw p}},onResponse(u,l){let{close:d}=l;try{if(typeof u.data!="object")return;let p=Ue(u.data);switch(p.status){case"APPROVED":a(p.data),d();break;case"DECLINED":s(`Declined: ${p.reason||"No reason supplied"}`),d();break;case"REDIRECT":a(p),d();break;default:s("Declined: No reason supplied"),d();break}}catch(p){throw console.error("execIframeRPC onResponse error",p),p}},onMessage(u,l){let{close:d}=l;try{if(typeof u.data!="object"||u.data.jsonrpc!=="2.0"||u.data.id!==i)return;let p=Ue(u.data.result);switch(p.status){case"APPROVED":a(p.data),d();break;case"DECLINED":s(`Declined: ${p.reason||"No reason supplied"}`),d();break;case"REDIRECT":a(p),d();break;default:s("Declined: No reason supplied"),d();break}}catch(p){throw console.error("execIframeRPC onMessage error",p),p}},onClose(){s("Declined: Externally Halted")}})})}var At=()=>{};function qm(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null)return{send:At,close:At};let n=t.onClose||At,r=t.onMessage||At,o=t.onReady||At,a=t.onResponse||At,s=Wn({close:l,send:d,onReady:o,onResponse:a,onMessage:r});window.addEventListener("message",s);let[i,c]=Mu(Vt(e)),u=setInterval(function(){i&&i.closed&&l()},500);return{send:d,close:l};function l(){try{window.removeEventListener("message",s),clearInterval(u),c(),n()}catch(p){console.error("Popup Close Error",p)}}function d(p){try{i.postMessage(JSON.parse(JSON.stringify(p||{})),"*")}catch(m){console.error("Popup Send Error",p,m)}}}function zm(e){let{service:t,body:n,config:r,opts:o}=e;return new Promise((a,s)=>{let i=Hn(),{redir:c,includeOlderJsonRpcCall:u}=o;qm(t,{async onReady(l,d){let{send:p}=d;try{p({fclVersion:Fe,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r}),p({fclVersion:Fe,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&p({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,t.params]})}catch(m){throw m}},onResponse(l,d){let{close:p}=d;try{if(typeof l.data!="object")return;let m=Ue(l.data);switch(m.status){case"APPROVED":a(m.data),!c&&p();break;case"DECLINED":s(`Declined: ${m.reason||"No reason supplied"}`),p();break;case"REDIRECT":a(m),p();break;default:s("Declined: No reason supplied"),p();break}}catch(m){throw console.error("execPopRPC onResponse error",m),m}},onMessage(l,d){let{close:p}=d;try{if(typeof l.data!="object"||l.data.jsonrpc!=="2.0"||l.data.id!==i)return;let m=Ue(l.data.result);switch(m.status){case"APPROVED":a(m.data),!c&&p();break;case"DECLINED":s(`Declined: ${m.reason||"No reason supplied"}`),p();break;case"REDIRECT":a(m),p();break;default:s("Declined: No reason supplied"),p();break}}catch(m){throw console.error("execPopRPC onMessage error",m),m}},onClose(){s("Declined: Externally Halted")}})})}var It=()=>{};function xm(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null)return{send:It,close:It};let n=t.onClose||It,r=t.onMessage||It,o=t.onReady||It,a=t.onResponse||It,s=Wn({close:l,send:d,onReady:o,onResponse:a,onMessage:r});window.addEventListener("message",s);let[i,c]=ju(Vt(e)),u=setInterval(function(){i&&i.closed&&l()},500);return{send:d,close:l};function l(){try{window.removeEventListener("message",s),clearInterval(u),c(),n()}catch(p){console.error("Tab Close Error",p)}}function d(p){try{i.postMessage(JSON.parse(JSON.stringify(p||{})),"*")}catch(m){console.error("Tab Send Error",p,m)}}}function Km(e){let{service:t,body:n,config:r,opts:o}=e;return new Promise((a,s)=>{let i=Hn(),{redir:c,includeOlderJsonRpcCall:u}=o;xm(t,{async onReady(l,d){let{send:p}=d;try{p({fclVersion:Fe,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r}),p({fclVersion:Fe,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&p({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,t.params]})}catch(m){throw m}},onResponse(l,d){let{close:p}=d;try{if(typeof l.data!="object")return;let m=Ue(l.data);switch(m.status){case"APPROVED":a(m.data),!c&&p();break;case"DECLINED":s(`Declined: ${m.reason||"No reason supplied"}`),p();break;case"REDIRECT":a(m),p();break;default:s("Declined: No reason supplied"),p();break}}catch(m){throw console.error("execPopRPC onResponse error",m),m}},onMessage(l,d){let{close:p}=d;try{if(typeof l.data!="object"||l.data.jsonrpc!=="2.0"||l.data.id!==i)return;let m=Ue(l.data.result);switch(m.status){case"APPROVED":a(m.data),!c&&p();break;case"DECLINED":s(`Declined: ${m.reason||"No reason supplied"}`),p();break;case"REDIRECT":a(m),p();break;default:s("Declined: No reason supplied"),p();break}}catch(m){throw console.error("execPopRPC onMessage error",m),m}},onClose(){s("Declined: Externally Halted")}})})}var Rt=()=>{};function Ym(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null)return{send:Rt,close:Rt};let n=t.onClose||Rt,r=t.onMessage||Rt,o=t.onReady||Rt,a=t.onResponse||Rt,s=Wn({close:i,send:c,onReady:o,onResponse:a,onMessage:r});return window.addEventListener("message",s),c({service:e}),{send:c,close:i};function i(){try{window.removeEventListener("message",s),n()}catch(u){console.error("Ext Close Error",u)}}function c(u){try{window&&window.postMessage(JSON.parse(JSON.stringify(u||{})),"*")}catch(l){console.error("Ext Send Error",u,l)}}}function Wm(e){let{service:t,body:n,config:r,opts:o}=e;return new Promise((a,s)=>{Ym(t,{async onReady(i,c){let{send:u}=c;try{u({fclVersion:Fe,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:t.params,data:t.data,type:t.type},config:r})}catch(l){throw l}},onResponse(i,c){let{close:u}=c;try{if(typeof i.data!="object")return;let l=Ue(i.data);switch(l.status){case"APPROVED":a(l.data),u();break;case"DECLINED":s(`Declined: ${l.reason||"No reason supplied"}`),u();break;case"REDIRECT":a(l),u();break;default:s("Declined: No reason supplied"),u();break}}catch(l){throw console.error("execExtRPC onResponse error",l),l}},onClose(){s("Declined: Externally Halted")}})})}var Hu={"HTTP/RPC":Tu,"HTTP/POST":Tu,"IFRAME/RPC":Hm,"POP/RPC":zm,"TAB/RPC":Km,"EXT/RPC":Wm},Vm=["ServicePlugin"],Jm=["discovery-service"],Xm=e=>{let{services:t,serviceStrategy:n}=e;h(Array.isArray(t)&&t.length,"Array of Discovery Services is required");for(let r of t)h(De(r.f_type)&&r.f_type==="Service","Service is required"),h(De(r.type)&&r.type==="authn",`Service must be type authn. Received ${r.type}`),h(r.method in Hu||n.method===r.method,`Service method ${r.method} is not supported`);return h(De(n),"Service strategy is required"),h(De(n.method)&&kt(n.method),"Service strategy method is required"),h(De(n.exec)&&_u(n.exec),"Service strategy exec function is required"),{discoveryServices:t,serviceStrategy:n}},Zm=()=>{let e=new Set,t=new Map(Object.entries(Hu)),n=i=>{if(h(Jm.includes(i.type),`Service Plugin type ${i.type} is not supported`),i.type==="discovery-service"){let{discoveryServices:c,serviceStrategy:u}=Xm(i);r(c),t.has(u.method)?$({title:"Add Service Plugin",message:`Service strategy for ${u.method} already exists`,level:Y.warn}):t.set(u.method,u.exec)}},r=i=>e=new Set([...i]);return Object.freeze({add:n,getServices:()=>[...e],getStrategy:i=>t.get(i),getStrategies:()=>[...t.keys()]})},Qm=e=>{let t;h(e,"No plugins supplied"),Array.isArray(e)?t=[...e]:t=[e];for(let n of t)h(De(n.name),"Plugin name is required"),h(De(n.f_type),"Plugin f_type is required"),h(Vm.includes(n.f_type),`Plugin type ${n.f_type} is not supported`);return t},eh=()=>{let e=new Map;return Object.freeze({add:r=>{let o=Qm(r);for(let a of o)e.set(a.name,a),a.f_type==="ServicePlugin"&&Jt.add(a)},getPlugins:()=>e})},Jt=Zm(),Hy=eh(),th=async e=>{let{service:t,body:n,config:r,opts:o}=e;return Jt.getStrategy(t.method)({service:t,body:n,config:r,opts:o})};async function et(e){let{service:t,msg:n={},config:r={},opts:o={}}=e;n.data=t.data;let a={services:await bu(/^service\./),app:await bu(/^app\.detail\./),client:{...r.client,fclVersion:Fe,fclLibrary:"https://github.com/onflow/fcl-js",hostname:window?.location?.hostname??null,network:await Wt()}};try{let s=await th({service:t,body:n,config:a,opts:o});return s.status==="REDIRECT"?(h(t.type===s.data.type,"Cannot shift recursive service type in execService"),await et({service:s.data,msg:n,config:a,opts:o})):s}catch(s){throw $({title:`Error on execService ${t?.type}`,message:s,level:Y.error}),s}}function Ao(e){if(e==null)return null;switch(e.f_vsn){case"1.0.0":return e;default:return{...Sm,addr:B(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId}}}var qu=async()=>[...window?.fcl_extensions||[],...Jt.getServices()];async function nh(e){let t=await w.get("discovery.authn.include",[]),n=await w.first(["discovery.wallet.method","discovery.wallet.method.default"]),r=e?.method?e.method:n,o=e?.endpoint??await w.first(["discovery.wallet","challenge.handshake"]);return h(o,`
|
|
248
|
-
If no service is passed to "authenticate," then "discovery.wallet" must be defined in fcl config.
|
|
249
|
-
See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"
|
|
250
|
-
`),{...e,type:"authn",endpoint:o,method:r,discoveryAuthnInclude:t}}async function rh(e){let{types:t}=e,n=await w.get("discovery.authn.endpoint");h(!!n,'"discovery.authn.endpoint" in config must be defined.');let r=await w.get("discovery.authn.include",[]),o=new URL(n);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,fclVersion:Fe,include:r,clientServices:await qu(),supportedStrategies:Jt.getStrategies(),userAgent:window?.navigator?.userAgent,network:await Wt()})}).then(a=>a.json())}var Qe={AUTHN:"authn",RESULTS:"results",SNAPSHOT:"SNAPSHOT",UPDATED:"UPDATED",UPDATE_RESULTS:"UPDATE_RESULTS"},oh=(e,t)=>{e&&console.warn(`
|
|
251
|
-
%cFCL Warning
|
|
252
|
-
============================
|
|
253
|
-
${t}
|
|
254
|
-
For more info, please see the docs: https://docs.onflow.org/fcl/
|
|
255
|
-
============================
|
|
256
|
-
`,"font-weight:bold;font-family:monospace;")},Cu=async()=>{try{let e=await rh({types:[Qe.AUTHN]});N(Qe.AUTHN,Qe.UPDATE_RESULTS,{results:e})}catch(e){$({title:`${e.name} Error fetching Discovery API services.`,message:e.message,level:Y.error})}},qy={[rt]:async e=>{oh(typeof window>"u",'"fcl.discovery" is only available in the browser.'),document.readyState==="complete"?Cu():window.onload=async()=>{Cu()}},[Qe.UPDATE_RESULTS]:(e,t,n)=>{e.merge(n),e.broadcast(Qe.UPDATED,{...e.all()})},[Se]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Qe.UPDATED,{...e.all()})},[we]:(e,t)=>e.unsubscribe(t.from),[Qe.SNAPSHOT]:async(e,t)=>t.reply({...e.all()})};var ah=e=>typeof e=="function",be="CURRENT_USER",Eo="CURRENT_USER/UPDATED",zu="SNAPSHOT",Io="SET_CURRENT_USER",xu="DEL_CURRENT_USER",Ro=`{
|
|
257
|
-
"f_type": "User",
|
|
258
|
-
"f_vsn": "1.0.0",
|
|
259
|
-
"addr":null,
|
|
260
|
-
"cid":null,
|
|
261
|
-
"loggedIn":null,
|
|
262
|
-
"expiresAt":null,
|
|
263
|
-
"services":[]
|
|
264
|
-
}`,sh=async e=>{let t=JSON.parse(Ro),n=await e.get(be);return n!=null&&t.f_vsn!==n.f_vsn?(e.removeItem(be),t):n||t},ih={[rt]:async e=>{typeof window>"u"&&console.warn(`
|
|
265
|
-
%cFCL Warning
|
|
266
|
-
============================
|
|
267
|
-
"currentUser" is only available in the browser.
|
|
268
|
-
For more info, please see the docs: https://docs.onflow.org/fcl/
|
|
269
|
-
============================
|
|
270
|
-
`,"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ro));let t=await w.first(["fcl.storage","fcl.storage.default"]);if(t.can){let n=await sh(t);uh(n)&&e.merge(n)}},[Se]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Eo,{...e.all()})},[we]:(e,t)=>{e.unsubscribe(t.from)},[zu]:async(e,t)=>{t.reply({...e.all()})},[Io]:async(e,t,n)=>{e.merge(n);let r=await w.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(be,e.all()),e.broadcast(Eo,{...e.all()})},[xu]:async(e,t)=>{e.merge(JSON.parse(Ro));let n=await w.first(["fcl.storage","fcl.storage.default"]);n.can&&n.put(be,e.all()),e.broadcast(Eo,{...e.all()})}},Ct=()=>ve(ih,be);function uh(e){return e.expiresAt==null||e.expiresAt===0||e.expiresAt>Date.now()}async function ch(){let e=await w.get("fcl.accountProof.resolver");if(e==null)return;if(!ah(e)){$({title:"Account Proof Data Resolver must be a function",message:`Check fcl.accountProof.resolver configuration.
|
|
271
|
-
Expected: fcl.accountProof.resolver: async () => { ... }
|
|
272
|
-
Received: fcl.accountProof.resolver: ${typeof e}
|
|
273
|
-
`,level:Y.warn});return}let t=await e();if(t!=null)return h(typeof t.appIdentifier=="string","appIdentifier must be a string"),h(/^[0-9a-f]+$/i.test(t.nonce),"Nonce must be a hex string"),t}var lh=async e=>{let{discoveryAuthnInclude:t}=e;return{client:{discoveryAuthnInclude:t,clientServices:await qu(),supportedStrategies:Jt.getStrategies()}}};async function Xt(){let{service:e,redir:t=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(e&&!e?.provider?.is_installed&&e?.provider?.requires_install){window.location.href=e?.provider?.install_link;return}return new Promise(async(n,r)=>{Ct();let o={redir:t},a=await Yt(),s=await nh(e),i=Kn(a.services,"authn-refresh"),c;if(a.loggedIn)if(i)try{let u=await et({service:i,msg:c,opts:o});N(be,Io,await Au(u))}catch(u){$({title:`${u.name} Could not refresh wallet authentication.`,message:u.message,level:Y.error})}finally{return n(await Yt())}else return n(a);try{c=await ch()}catch(u){return $({title:`${u.name} On Authentication: Could not resolve account proof data.`,message:u.message,level:Y.error}),r(u)}try{let u=await et({service:s,msg:c,config:await lh(s),opts:o});N(be,Io,await Au(u))}catch(u){$({title:`${u} On Authentication`,message:u,level:Y.error})}finally{n(await Yt())}})}function Ku(){Ct(),N(be,xu)}var dh=e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]});function fh(e){let t=dh(e),n=[];t.proposer!=null&&n.push(["PROPOSER",t.proposer]);for(let o of t.payer||[])n.push(["PAYER",o]);for(let o of t.authorization||[])n.push(["AUTHORIZER",o]);var r=n.map(o=>{let[a,s]=o;return{tempId:[s.identity.address,s.identity.keyId].join("|"),addr:s.identity.address,keyId:s.identity.keyId,signingFunction(i){return et({service:s,msg:i})},role:{proposer:a==="PROPOSER",payer:a==="PAYER",authorizer:a==="AUTHORIZER"}}});return r}async function Yu(e){return Ct(),{...e,tempId:"CURRENT_USER",async resolve(t,n){let r=await Xt({redir:!0}),o=Kn(r.services,"authz"),a=Kn(r.services,"pre-authz");if(a)return fh(await et({service:a,msg:n}));if(o){let s;return am()&&o.method==="WC/RPC"&&(s=window.open("","_blank")),{...t,tempId:"CURRENT_USER",resolve:null,addr:B(o.identity.address),keyId:o.identity.keyId,sequenceNum:null,signature:null,async signingFunction(i){return Ao(await et({service:o,msg:i,opts:{includeOlderJsonRpcCall:!0,windowRef:s}}))}}}throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}}}function Wu(e){Ct();let t="@EXIT",n=ve(async r=>{for(r.send(be,Se);;){let o=await r.receive();if(o.tag===t){r.send(be,we);return}e(o.data)}});return()=>N(n,t)}function Yt(){return Ct(),N(be,zu,null,{expectReply:!0,timeout:0})}async function Vu(){let{addr:e}=await Xt();return zt(q(e),mo)}var ph=e=>(h(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function Ju(e){Ct();let t=await Xt({redir:!0}),n=Kn(t.services,"user-signature");h(n,"Current user must have authorized a signing service.");try{let r=await et({service:n,msg:ph(e)});return Array.isArray(r)?r.map(o=>Ao(o)):[Ao(r)]}catch(r){return r}}var He=()=>({authenticate:Xt,unauthenticate:Ku,authorization:Yu,signUserMessage:Ju,subscribe:Wu,snapshot:Yt,resolveArgument:Vu});He.authenticate=Xt;He.unauthenticate=Ku;He.authorization=Yu;He.signUserMessage=Ju;He.subscribe=Wu;He.snapshot=Yt;He.resolveArgument=Vu;var gh="USER_SIGNATURE",mh=e=>{if(e.appIdentifier){let{appIdentifier:t,address:n,nonce:r,signatures:o}=e;return h(kt(t),"verifyAccountProof({ appIdentifier }) -- appIdentifier must be a string"),h(kt(n)&&B(n).length===16,"verifyAccountProof({ address }) -- address must be a valid address"),h(/^[0-9a-f]+$/i.test(r),"nonce must be a hex string"),h(Array.isArray(o)&&o.every((a,s,i)=>a.f_type==="CompositeSignature"),"Must include an Array of CompositeSignatures to verify"),h(o.map(a=>a.addr).every((a,s,i)=>a===i[0]),"User signatures to be verified must be from a single account address"),!0}else{let{message:t,address:n,compSigs:r}=e;return h(/^[0-9a-f]+$/i.test(t),"Signed message must be a hex string"),h(kt(n)&&B(n).length===16,"verifyUserSignatures({ address }) -- address must be a valid address"),h(Array.isArray(r)&&r.every((o,a,s)=>o.f_type==="CompositeSignature"),"Must include an Array of CompositeSignatures to verify"),h(r.map(o=>o.addr).every((o,a,s)=>o===s[0]),"User signatures to be verified must be from a single account address"),!0}},hh=async(e,t)=>{let n=e==="ACCOUNT_PROOF"?"verifyAccountProofSignatures":"verifyUserSignatures",r=await Wt(),o;return h(t.fclCryptoContract||r==="testnet"||r==="mainnet","${verifyFunction}({ fclCryptoContract }) -- config.flow.network must be specified (testnet || mainnet) or contract address provided via opts.fclCryptoContract"),t.fclCryptoContract?o=t.fclCryptoContract:o=r==="testnet"?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284",`
|
|
274
|
-
import FCLCrypto from ${o}
|
|
275
|
-
|
|
276
|
-
pub fun main(
|
|
277
|
-
address: Address,
|
|
278
|
-
message: String,
|
|
279
|
-
keyIndices: [Int],
|
|
280
|
-
signatures: [String]
|
|
281
|
-
): Bool {
|
|
282
|
-
return FCLCrypto.${n}(address: address, message: message, keyIndices: keyIndices, signatures: signatures)
|
|
283
|
-
}
|
|
284
|
-
`};async function yh(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=q(t[0].addr);mh({message:e,address:r,compSigs:t});let o=[],a=[];for(let s of t)o.push(s.signature),a.push(s.keyId.toString());return hm({cadence:await hh(gh,n),args:(s,i)=>[s(r,i.Address),s(e,i.String),s(a,i.Array(i.Int)),s(o,i.Array(i.String))]})}var zy=$.deprecate({pkg:"FCL",subject:"fcl.verifyUserSignatures()",message:"Please use fcl.AppUtils.verifyUserSignatures()",callback:function(t,n){return yh(t,n)}});var wh=2500,bo="POLL",Eh=async e=>ue([ao(e)]).then(Ye),bh=e=>e.status===5,To=e=>e.status>=4,Xu=e=>e.status>=3,Zu=e=>e.status>=2,Sh=e=>e.status>=1,vh=e=>e.status>=0,Ah=(e,t)=>JSON.stringify(e)!==JSON.stringify(t),Ih={[rt]:async e=>{e.sendSelf(bo)},[Se]:(e,t)=>{e.subscribe(t.from),e.send(t.from,en,e.all())},[we]:(e,t)=>{e.unsubscribe(t.from)},[Zn]:async(e,t)=>{t.reply(e.all())},[bo]:async e=>{let t;try{t=await Eh(e.self())}catch(n){return e.fatalError(n)}To(t)||setTimeout(()=>e.sendSelf(bo),wh),Ah(e.all(),t)&&e.broadcast(en,t),e.merge(t)}},Qu=e=>{if(typeof e=="object"&&(e=e.transactionId),e==null)throw new Error("transactionId required");return e},Pu=e=>ve(Ih,Qu(e));function Pt(e){function t(){return Go(e,Pu)}function n(o){return Nt(Qu(e),Pu,o)}function r(o){return function(){let i=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).suppress||!1;return new Promise((c,u)=>{let l=n((d,p)=>{(p||d.statusCode)&&!i?(u(p||d.errorMessage),l()):o(d)&&(c(d),l())})})}}return{snapshot:t,subscribe:n,onceFinalized:r(Zu),onceExecuted:r(Xu),onceSealed:r(To)}}Pt.isUnknown=vh;Pt.isPending=Sh;Pt.isFinalized=Zu;Pt.isExecuted=Xu;Pt.isSealed=To;Pt.isExpired=bh;var Rh=1e4,kh="UPDATED",Ze="TICK",xn="hwm",So=async e=>setTimeout(()=>e.sendSelf(Ze),await w().get("fcl.eventPollRate",Rh)),xy={[Ze]:async e=>{if(!e.hasSubs())return;let t=e.get(xn);if(t==null)e.put(xn,await Gn()),e.put(Ze,await So(e));else{let n=await Gn();if(e.put(xn,n),t.height<n.height){let r=await ue([oo(e.self(),t.height+1,n.height)]).then(Ye);for(let o of r)e.broadcast(kh,o.data)}e.put(Ze,await So(e))}},[Se]:async(e,t)=>{e.hasSubs()||e.put(Ze,await So(e)),e.subscribe(t.from)},[we]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get(Ze)),e.delete(Ze),e.delete(xn))}};var Th={},ec={},tc={},nc={},Ch=function(t,n){return function(r,o){var a=o*2,s=n*2;r[a]=t[s],r[a+1]=t[s+1]}},Co=Ch;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(Co);function n(a){return a&&a.__esModule?a:{default:a}}var r=function(s){for(var i=s.A,c=s.C,u=0;u<25;u+=5){for(var l=0;l<5;l++)(0,t.default)(i,u+l)(c,l);for(var d=0;d<5;d++){var p=(u+d)*2,m=(d+1)%5*2,E=(d+2)%5*2;i[p]^=~c[m]&c[E],i[p+1]^=~c[m+1]&c[E+1]}}},o=r;e.default=o})(nc);var rc={},oc={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=new Uint32Array([0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424]),n=t;e.default=n})(oc);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(oc);function n(a){return a&&a.__esModule?a:{default:a}}var r=function(s){var i=s.A,c=s.roundIndex,u=c*2;i[0]^=t.default[u],i[1]^=t.default[u+1]},o=r;e.default=o})(rc);var ac={},sc={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=[10,7,11,17,18,3,5,16,8,21,24,4,15,23,19,13,12,2,20,14,22,9,6,1],n=t;e.default=n})(sc);var ic={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=[1,3,6,10,15,21,28,36,45,55,2,14,27,41,56,8,25,43,62,18,39,61,20,44],n=t;e.default=n})(ic);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=o(sc),n=o(ic),r=o(Co);function o(i){return i&&i.__esModule?i:{default:i}}var a=function(c){var u=c.A,l=c.C,d=c.W;(0,r.default)(u,1)(d,0);for(var p=0,m=0,E=0,I=32,D=0;D<24;D++){var G=t.default[D],L=n.default[D];(0,r.default)(u,G)(l,0),p=d[0],m=d[1],I=32-L,E=L<32?0:1,d[E]=p<<L|m>>>I,d[(E+1)%2]=m<<L|p>>>I,(0,r.default)(d,0)(u,G),(0,r.default)(l,0)(d,0)}},s=a;e.default=s})(ac);var uc={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(Co);function n(a){return a&&a.__esModule?a:{default:a}}var r=function(s){for(var i=s.A,c=s.C,u=s.D,l=s.W,d=0,p=0,m=0;m<5;m++){var E=m*2,I=(m+5)*2,D=(m+10)*2,G=(m+15)*2,L=(m+20)*2;c[E]=i[E]^i[I]^i[D]^i[G]^i[L],c[E+1]=i[E+1]^i[I+1]^i[D+1]^i[G+1]^i[L+1]}for(var P=0;P<5;P++){(0,t.default)(c,(P+1)%5)(l,0),d=l[0],p=l[1],l[0]=d<<1|p>>>31,l[1]=p<<1|d>>>31,u[P*2]=c[(P+4)%5*2]^l[0],u[P*2+1]=c[(P+4)%5*2+1]^l[1];for(var M=0;M<25;M+=5)i[(M+P)*2]^=u[P*2],i[(M+P)*2+1]^=u[P*2+1]}},o=r;e.default=o})(uc);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=a(nc),n=a(rc),r=a(ac),o=a(uc);function a(c){return c&&c.__esModule?c:{default:c}}var s=function(){var u=new Uint32Array(10),l=new Uint32Array(10),d=new Uint32Array(2);return function(p){for(var m=0;m<24;m++)(0,o.default)({A:p,C:u,D:l,W:d}),(0,r.default)({A:p,C:u,W:d}),(0,t.default)({A:p,C:u}),(0,n.default)({A:p,roundIndex:m});u.fill(0),l.fill(0),d.fill(0)}},i=s;e.default=i})(tc);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=ko.default,n=r(tc);function r(c){return c&&c.__esModule?c:{default:c}}var o=function(u,l){for(var d=0;d<u.length;d+=8){var p=d/4;l[p]^=u[d+7]<<24|u[d+6]<<16|u[d+5]<<8|u[d+4],l[p+1]^=u[d+3]<<24|u[d+2]<<16|u[d+1]<<8|u[d]}return l},a=function(u,l){for(var d=0;d<l.length;d+=8){var p=d/4;l[d]=u[p+1],l[d+1]=u[p+1]>>>8,l[d+2]=u[p+1]>>>16,l[d+3]=u[p+1]>>>24,l[d+4]=u[p],l[d+5]=u[p]>>>8,l[d+6]=u[p]>>>16,l[d+7]=u[p]>>>24}return l},s=function(u){var l=this,d=u.capacity,p=u.padding,m=(0,n.default)(),E=200,I=d/8,D=E-d/4,G=0,L=new Uint32Array(E/4),P=t.Buffer.allocUnsafe(D);return this.absorb=function(M){for(var R=0;R<M.length;R++)P[G]=M[R],G+=1,G>=D&&(o(P,L),m(L),G=0);return l},this.squeeze=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},R={buffer:M.buffer||t.Buffer.allocUnsafe(I),padding:M.padding||p,queue:t.Buffer.allocUnsafe(P.length),state:new Uint32Array(L.length)};P.copy(R.queue);for(var tt=0;tt<L.length;tt++)R.state[tt]=L[tt];R.queue.fill(0,G),R.queue[G]|=R.padding,R.queue[D-1]|=128,o(R.queue,R.state);for(var nt=0;nt<R.buffer.length;nt+=D)m(R.state),a(R.state,R.buffer.slice(nt,nt+D));return R.buffer},this.reset=function(){return P.fill(0),L.fill(0),G=0,l},this},i=s;e.default=i})(ec);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.SHAKE=e.SHA3Hash=e.SHA3=e.Keccak=void 0;var t=ko.default,n=r(ec);function r(l){return l&&l.__esModule?l:{default:l}}var o=function(d){var p=d.allowedSizes,m=d.defaultSize,E=d.padding;return function I(){var D=this,G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:m;if(!this||this.constructor!==I)return new I(G);if(p&&!p.includes(G))throw new Error("Unsupported hash length");var L=new n.default({capacity:G});return this.update=function(P){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"utf8";if(t.Buffer.isBuffer(P))return L.absorb(P),D;if(typeof P=="string")return D.update(t.Buffer.from(P,M));throw new TypeError("Not a string or buffer")},this.digest=function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"binary",M=typeof P=="string"?{format:P}:P,R=L.squeeze({buffer:M.buffer,padding:M.padding||E});return M.format&&M.format!=="binary"?R.toString(M.format):R},this.reset=function(){return L.reset(),D},this}},a=o({allowedSizes:[224,256,384,512],defaultSize:512,padding:1});e.Keccak=a;var s=o({allowedSizes:[224,256,384,512],defaultSize:512,padding:6});e.SHA3=s;var i=o({allowedSizes:[128,256],defaultSize:256,padding:31});e.SHAKE=i;var c=a;e.SHA3Hash=c,s.SHA3Hash=c;var u=s;e.default=u})(Th);var Ky=He().authorization;var Vn=class extends cc.MultichainExtension{constructor(n){super({rpcUrl:n.rpcUrl,chainType:"FLOW",network:n.network});this.flowConfig=n}name="flow";getAccount=()=>this.request(this.utils.createJsonRpcRequestPayload("flow_getAccount",[]));authorization=async(n={})=>{w().put("accessNode.api",this.config.rpcUrl);let r=await this.request(this.utils.createJsonRpcRequestPayload("flow_getAccount",[])),o=0,a;return n?.role?.proposer&&(a=(await ro(r)).keys[o].sequenceNumber),{...n,addr:r,keyId:o,signingFunction:async i=>{let c=await this.request({id:42,jsonrpc:"2.0",method:"flow_signTransaction",params:{message:i.message,cadence:i.cadence}});return{addr:r,keyId:o,signature:c}},sequenceNum:a}}};var Nh=Vn;return hc(Fh);})();
|
|
1
|
+
"use strict";var MagicFlowExtension=(()=>{var d=Object.create;var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),A=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!x.call(e,o)&&o!==n&&s(e,o,{get:()=>t[o],enumerable:!(r=h(t,o))||r.enumerable});return e};var l=(e,t,n)=>(n=e!=null?d(F(e)):{},u(t||!e||!e.__esModule?s(n,"default",{value:e,enumerable:!0}):n,e)),U=e=>u(s({},"__esModule",{value:!0}),e);var f=k((N,g)=>{"use strict";g.exports=Magic});var T={};A(T,{default:()=>R});var m=l(f()),i=l(q("@onflow/fcl"));var c=class extends m.MultichainExtension{constructor(n){super({rpcUrl:n.rpcUrl,chainType:"FLOW",network:n.network});this.flowConfig=n}name="flow";getAccount=()=>this.request(this.utils.createJsonRpcRequestPayload("flow_getAccount",[]));authorization=async(n={})=>{i.config().put("accessNode.api",this.config.rpcUrl);let r=await this.request(this.utils.createJsonRpcRequestPayload("flow_getAccount",[])),o=0,p;return n?.role?.proposer&&(p=(await i.account(r)).keys[o].sequenceNumber),{...n,addr:r,keyId:o,signingFunction:async a=>{let w=await this.request({id:42,jsonrpc:"2.0",method:"flow_signTransaction",params:{message:a.message,cadence:a.cadence}});return{addr:r,keyId:o,signature:w}},sequenceNum:p}}};var R=c;return U(T);})();
|
|
285
2
|
if (MagicFlowExtension && MagicFlowExtension.default != null) { MagicFlowExtension = Object.assign(MagicFlowExtension.default, MagicFlowExtension); delete MagicFlowExtension.default; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic-ext/flow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0-canary.979.20831511014.0",
|
|
4
4
|
"description": "magic flow extension",
|
|
5
5
|
"author": "Magic <team@magic.link> (https://magic.link/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
]
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@magic-sdk/provider": "
|
|
31
|
+
"@magic-sdk/provider": "32.0.0-canary.979.20831511014.0",
|
|
32
32
|
"@onflow/fcl": "^1.4.1",
|
|
33
33
|
"@onflow/types": "^1.1.0"
|
|
34
34
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@onflow/fcl": "^1.4.1",
|
|
37
37
|
"@onflow/types": "^1.1.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ae4e5792908dd3fcc78e25ef87f2ffdfc321a924"
|
|
40
40
|
}
|